Python-URL! - weekly Python news and links (Apr 21)
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=djqas_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
Ikaroo Tools CSV files
Hello Is there a way e to use joker characters in queries ? Regards Salvatore -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
irc proxy search crack
irc proxy search crack http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
crack registration codes for pogo games
crack registration codes for pogo games http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
revit 9 keygen
revit 9 keygen http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
crack for spyware doctor
crack for spyware doctor http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
Re: Prob. w/ Script Posting Last Value
En Thu, 17 Apr 2008 15:51:43 -0300, Victor Subervi [EMAIL PROTECTED] escribió: On Thu, Apr 17, 2008 at 1:07 PM, Steve Holden [EMAIL PROTECTED] 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 'img src=getpic.py?id=%dx=%dbr /br //td\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 'img src=getpic.py?id=%dx=%dbr /br //td\n' % (d, y) by for d, y in (results of some DB query to get d and y for each image): print 'img src=getpic.py?id=%dx=%dbr /br //td\n' % (d, y) Well, I just tried this: #! /usr/bin/python print Content-type: text/html !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html head title/title /head body input type='hidden' name='db' value='benobeno_bre' / y = 1 for d in 2, 12: while y 12: print 'img src=getpic.py?id=%dx=%dbr /br //td\n' % (d, y) y += 1 print /body /html 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 -- http://mail.python.org/mailman/listinfo/python-list
Is massive spam coming from me on python lists?
I've recently gotten more than too many spam messages and all say Sender: [EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Any reliable obfurscator for Python 2.5
On 4/21/08, Steve Holden [EMAIL PROTECTED] 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. -- http://mail.python.org/mailman/listinfo/python-list
firewire patch cable
firewire patch cable http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
89th mp brigade patch
89th mp brigade patch http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
antivir keygen
antivir keygen http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
cracked engine block
cracked engine block http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
wheel of fortune crack
wheel of fortune crack http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
call of duty united offensive patch
call of duty united offensive patch http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
dark crusade 1.11 patch
dark crusade 1.11 patch http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
Re: py3k concerns. An example
En Fri, 18 Apr 2008 12:58:56 -0300, Aaron Watters [EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list
cabbage patch kids messy face doll
cabbage patch kids messy face doll http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
transmac crack
transmac crack http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
crack cocaine user profile
crack cocaine user profile http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
Re: Is massive spam coming from me on python lists?
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: [EMAIL PROTECTED] 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 All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm -- http://mail.python.org/mailman/listinfo/python-list
Conditional for...in failing with utf-8, Spanish book translation
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Conditional for...in failing with utf-8, Spanish book translation
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Is massive spam coming from me on python lists?
On 2008-04-21 08:01, Brian Vanderburg II wrote: I've recently gotten more than too many spam messages and all say Sender: [EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Conditional for...in failing with utf-8, Spanish book translation
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 = uabcdefghijklmnopqrstuvwxyzóíñú acceptable = uabcdefghijklmnopqrstuvwxyzóíñúá 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#SECTION00513 Stefan -- http://mail.python.org/mailman/listinfo/python-list
Elementtree find problem
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Is massive spam coming from me on python lists?
In article [EMAIL PROTECTED], Brian Vanderburg II [EMAIL PROTECTED] wrote: I've recently gotten more than too many spam messages and all say Sender: [EMAIL PROTECTED] 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/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Is massive spam coming from me on python lists?
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: [EMAIL PROTECTED] [...] 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: [EMAIL PROTECTED] (See http://ime.webhop.org for further contact info.) -- http://mail.python.org/mailman/listinfo/python-list
lost sourcecode: decompyle?
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: [EMAIL PROTECTED] (See http://ime.webhop.org for further contact info.) -- http://mail.python.org/mailman/listinfo/python-list
Re: Elementtree find problem
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Is massive spam coming from me on python lists?
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: [EMAIL PROTECTED] [...] 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 signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list
cracked skin on fingers
cracked skin on fingers http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
ulead gif animator 5 crack
ulead gif animator 5 crack http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
pes 6 stadium patch download
pes 6 stadium patch download http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
utu conductor patch
utu conductor patch http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
mystery case files huntsville 1.6 keygen
mystery case files huntsville 1.6 keygen http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
spy sweeper 5.5 crack serial
spy sweeper 5.5 crack serial http://cracks.00bp.com F R E E C R A C K S -- http://mail.python.org/mailman/listinfo/python-list
Re: Pickle problem
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 [EMAIL PROTECTED] wrote: On Apr 18, 11:55 am, Mario Ceresa [EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: question about the mainloop
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. -- http://mail.python.org/mailman/listinfo/python-list
sys.maxint in Python 3
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: sys.maxint in Python 3
[EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Db
[EMAIL PROTECTED] 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. -- http://mail.python.org/mailman/listinfo/python-list
Re: manipulating class attributes from a decorator while the class is being defined
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: manipulating class attributes from a decorator while the class is being defined
Wilbert Berendsen [EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list
Opposite of repr() (kind of)
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 -- http://mail.python.org/mailman/listinfo/python-list
Python-URL! - weekly Python news and links (Apr 21)
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=djqas_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
Invicta 3284 Swiss Quartz Ladies Watch - Replica Watch Fake
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 [EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Help needed - I don't understand how Python manages memory
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: [EMAIL PROTECTED] (pref) | Snail: PO Box 370 [EMAIL PROTECTED] (alt) |Belconnen ACT 2616 Web:http://www.andymac.org/ |Australia -- http://mail.python.org/mailman/listinfo/python-list
Re: Alternate indent proposal for python 3000
On 21 Apr, 00:54, Dan Bishop [EMAIL PROTECTED] 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! -- http://mail.python.org/mailman/listinfo/python-list
Re: How to insert multiple rows in SQLite Dbase
On Apr 1, 12:22 am, afandi [EMAIL PROTECTED] wrote: On Mar 30, 4:46 am, Gerhard Häring [EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list
PIL font encoding
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 -- http://mail.python.org/mailman/listinfo/python-list
Required Python Consultants
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:[EMAIL PROTECTED][EMAIL PROTECTED] Land Line - +91 080 23224418 / 23224420 HYPERLINK http://www.winfoware.comwww.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 -- http://mail.python.org/mailman/listinfo/python-list
Python Consultants required - Urgent
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.comwww.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 -- http://mail.python.org/mailman/listinfo/python-list
Somebody *really* got fond of python
http://xkcd.com/413/ :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Opposite of repr() (kind of)
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 -- http://mail.python.org/mailman/listinfo/python-list
Help with Python+Bazaar+Launchpad
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:// name@bazaar.launchpad.net/~name/python/branch-name. 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! -- http://mail.python.org/mailman/listinfo/python-list
Re: Opposite of repr() (kind of)
On Apr 21, 7:05 am, Guillermo [EMAIL PROTECTED] 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 built-in function len. -- http://mail.python.org/mailman/listinfo/python-list
Re: I just killed GIL!!!
On Apr 20, 10:57 pm, [EMAIL PROTECTED] (Aahz) wrote: In article [EMAIL PROTECTED], Carl Banks [EMAIL PROTECTED] wrote: On Apr 17, 3:37 am, Jonathan Gardner [EMAIL PROTECTED] 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? Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: SWIG (Python) - no constructor defined for concrete class
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 -- http://mail.python.org/mailman/listinfo/python-list
Batteries Included...
Today's XKCD comic has a nice Python reference! http://xkcd.com/413/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Opposite of repr() (kind of)
This must be the dumbest question ever... Solved. On Apr 21, 1:05 pm, Guillermo [EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Somebody *really* got fond of python
On Apr 21, 12:23 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: http://xkcd.com/413/ :) Didn't realise you'd posted this when I posted my Batteries Included... post. Amused me as well! -- http://mail.python.org/mailman/listinfo/python-list
Re: manipulating class attributes from a decorator while the class is being defined
On Apr 19, 11:19 pm, Wilbert Berendsen [EMAIL PROTECTED] 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 --- -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL font encoding
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/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Finally had to plonk google gorups.
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. -- http://mail.python.org/mailman/listinfo/python-list
Re: Java or C++?
On Apr 15, 1:46 pm, Brian Vanderburg II [EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: I just killed GIL!!!
In article [EMAIL PROTECTED], Carl Banks [EMAIL PROTECTED] wrote: On Apr 20, 10:57 pm, [EMAIL PROTECTED] (Aahz) wrote: In article [EMAIL PROTECTED], Carl Banks [EMAIL PROTECTED] wrote: On Apr 17, 3:37 am, Jonathan Gardner [EMAIL PROTECTED] 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 ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ Why is this newsgroup different from all other newsgroups? -- http://mail.python.org/mailman/listinfo/python-list
xkcd strikes again
http://xkcd.com/413/ (As usual, make sure to read the alt text.) -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ Why is this newsgroup different from all other newsgroups? -- http://mail.python.org/mailman/listinfo/python-list
how to pass C++ object to another C++ function via Python function
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. -- http://mail.python.org/mailman/listinfo/python-list
Re: Finally had to plonk google gorups.
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: [EMAIL PROTECTED] (See http://ime.webhop.org for further contact info.) -- http://mail.python.org/mailman/listinfo/python-list
Re: how to pass C++ object to another C++ function via Python function
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Nested lists, simple though
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: py3k concerns. An example
On Apr 19, 4:42 am, Carl Banks [EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: how to pass C++ object to another C++ function via Python function
En Mon, 21 Apr 2008 10:24:15 -0300, grbgooglefan [EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: how to pass C++ object to another C++ function via Python function
Gabriel Genellina wrote: En Mon, 21 Apr 2008 10:24:15 -0300, grbgooglefan [EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: py3k concerns. An example
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.5 adoption
In article [EMAIL PROTECTED], Joseph Turian [EMAIL PROTECTED] 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 ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ Why is this newsgroup different from all other newsgroups? -- http://mail.python.org/mailman/listinfo/python-list
Finding the selected file in Windows Explorer
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Java or C++?
On Apr 14, 11:44 am, [EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list
Python make like tools (was Re: [ANN] DoIt 0.1.0 Released (build tool))
Eduardo Schettino wrote: 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. I took a look at dolt syntax, and saw this: QQQ def create_folder(path): Create folder given by path if it doesnt exist if not os.path.exists(path): os.mkdir(path) return True def task_create_build_folder(): buildFolder = jsPath + build return {'action':create_folder, 'args': (buildFolder,) } QQQ 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 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). -- http://mail.python.org/mailman/listinfo/python-list
Re: I just killed GIL!!!
On Apr 21, 9:20 am, [EMAIL PROTECTED] (Aahz) wrote: In article [EMAIL PROTECTED], Carl Banks [EMAIL PROTECTED] wrote: On Apr 20, 10:57 pm, [EMAIL PROTECTED] (Aahz) wrote: In article [EMAIL PROTECTED], Carl Banks [EMAIL PROTECTED] wrote: On Apr 17, 3:37 am, Jonathan Gardner [EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.5 adoption
On Apr 21, 9:28 am, [EMAIL PROTECTED] (Aahz) wrote: In article [EMAIL PROTECTED], Joseph Turian [EMAIL PROTECTED] 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 ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ Why is this newsgroup different from all other newsgroups? Different is a verbally atomic relation. -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding the selected file in Windows Explorer
On Apr 21, 9:44 am, [EMAIL PROTECTED] 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/[EMAIL PROTECTED]/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 -- http://mail.python.org/mailman/listinfo/python-list
Problem setting cookie in Internet Explorer
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... -- http://mail.python.org/mailman/listinfo/python-list
Re: Python make like tools (was Re: [ANN] DoIt 0.1.0 Released (build tool))
On 21 Apr, 16:51, Ville M. Vainio [EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem setting cookie in Internet Explorer
On Apr 21, 10:13 am, sophie_newbie [EMAIL PROTECTED] 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 -- http://mail.python.org/mailman/listinfo/python-list
Python Developer, DIRECT CLIENT REQUIREMENT: Please Respond
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:[EMAIL PROTECTED] Phone :603-791-4428 Fax :267-284-6042 -- http://mail.python.org/mailman/listinfo/python-list
Re: MySQL hardcoding?
[EMAIL PROTECTED] 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') 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:\\mysqlshare\\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. Well, for one thing, MySQL doesn't have a character set called Windows-1251, which is an obsolete Cyrillic variant of Windows. See the list of MySQL character sets at: http://dev.mysql.com/doc/refman/5.0/en/charset-charsets.html; MySQL does have cp1251, which is apparently the same thing. Be aware that in Python, there are really only two character sets - ASCII and Unicode. The upper code page thing is deprecated, and you can't do some string operations on characters with values 128. It's best to convert input to Unicode, run everything in Python in Unicode, send to the database in utf8, and store your data in utf8. You have use_unicode set to True. If you're going to run the MySQL connection in Unicode, you should use utf8 talking to the database, and Unicode strings in Python. Otherwise, you have to understand very clearly exactly how both Python and MySQL handle character sets, and how this changes in Python 2.4, 2.5, and 3.x. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Python make like tools (was Re: [ANN] DoIt 0.1.0 Released (build tool))
I took a look at dolt syntax, and saw this: QQQ def create_folder(path): Create folder given by path if it doesnt exist if not os.path.exists(path): os.mkdir(path) return True def task_create_build_folder(): buildFolder = jsPath + build return {'action':create_folder, 'args': (buildFolder,) } QQQ 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 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 anything. You just need to create a function that returns a dictionary with some predefined keys. 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,)} 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. 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. 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). apart from one .py file installation (easy_install is not enough?) thats what i am trying to do. thanks for the feedback. cheers, Eduardo -- http://mail.python.org/mailman/listinfo/python-list
Tweaking PEP-234 to improve Duck Typing
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=stq=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!) -- http://mail.python.org/mailman/listinfo/python-list
Does Python 2.5.2's embedded SQLite support full text searching?
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: wholesale air force one bape adidas wallet bikini tn shox air max air rift
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): [EMAIL PROTECTED] 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 DG 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 DG Bag http://www.nike1.com.cn Leather Bag http://www.nike1.com.cn AF 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 DooneyBourke 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
Financial Modeling with Python by Shayne Fletcher, Christopher Gardner
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
Re: Help needed - I don't understand how Python manages memory
On Apr 21, 4:09 am, Gabriel Genellina [EMAIL PROTECTED] 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. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem setting cookie in Internet Explorer
On Apr 21, 4:24 pm, Mike Driscoll [EMAIL PROTECTED] wrote: On Apr 21, 10:13 am, sophie_newbie [EMAIL PROTECTED] 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! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python make like tools (was Re: [ANN] DoIt 0.1.0 Released (build tool))
I guess I should post a link to the project in this thread... http://python-doit.sourceforge.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Database vs Data Structure?
On Apr 19, 10:56 pm, Dennis Lee Bieber [EMAIL PROTECTED] wrote: On Sat, 19 Apr 2008 11:27:20 -0700, Scott David Daniels [EMAIL PROTECTED] declaimed the following in comp.lang.python: Hijacking as with the gmail kill filter I had to apply... [EMAIL PROTECTED] 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 G * 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 G -- Wulfraed Dennis Lee Bieber KD6MOG [EMAIL PROTECTED] [EMAIL PROTECTED] HTTP://wlfraed.home.netcom.com/ (Bestiaria Support Staff: [EMAIL PROTECTED]) 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. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.5 adoption
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: On Apr 21, 9:28 am, [EMAIL PROTECTED] (Aahz) wrote: Why is this newsgroup different from all other newsgroups? Different is a verbally atomic relation. It's a Passover question. -- -- Lou Pecora -- http://mail.python.org/mailman/listinfo/python-list
yield expression programmized-formal interpretation. (interpretation of yield expression.)
What if I say oath= yield or other= yield ? Does yield evaluate without parenthes? (Eth.) -- http://mail.python.org/mailman/listinfo/python-list
Re: Does Python 2.5.2's embedded SQLite support full text searching?
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 -- http://mail.python.org/mailman/listinfo/python-list