Python Ireland Talks Reminder - Wed 10th October 2007
Hi All, Just a quick reminder. Give me a call, if you are lost. I'll be there early this evening. Wed 10th October 2007 Talks: 19:00 - 21:00 (+pub) Room 3074 in the Arts block ( Map : http://www.tcd.ie/Maps/arts_block.html ) See http://wiki.python.ie/moin.cgi/PythonMeetup/October2007 for more details. My mobile: 086 1502003 Cheers, /// Vicky PS: Apolagies for all the confusion, will get someone to properly proof-read my outgoing mails, or Mick will send them out next time, *hint hint. On 10/8/07, Tim Kersten [EMAIL PROTECTED] wrote: Nice one. See you there :-) On 10/8/07, Sean O'Donnell [EMAIL PROTECTED] wrote: yip, talks are definately on on Wednesday. Sean Tim Kersten wrote: Hi *, Just wanted to ask if there are talks this Wednesday as stated in the wiki: http://wiki.python.ie/moin.cgi/PythonMeetup/October2007 ? From somewhere I had the idea that the talks in Trinity were going to be in November and we were just meeting up in the Schoolhouse this month. I assume that I wrong and there will be talks in TCD this Wednesday. Please correct me if I'm wrong :-) Cheers, Tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Python Ireland group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.ie/group/pythonireland?hl=en -~--~~~~--~~--~--~--- -- ~~ ~~ http://irishbornchinese.com ~~ ~~ http://www.python.ie~~ ~~ -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
[ANN] Data Plotting Library DISLIN 9.2
Dear Python users, I am pleased to announce version 9.2 of the data plotting software DISLIN. DISLIN is a high-level and easy to use plotting library for displaying data as curves, bar graphs, pie charts, 3D-colour plots, surfaces, contours and maps. Several output formats are supported such as X11, VGA, PostScript, PDF, CGM, WMF, HPGL, TIFF, GIF, PNG, BMP and SVG. The software is available for the most C, Fortran 77 and Fortran 90/95 compilers. Plotting extensions for the interpreting languages Perl, Python and Java are also supported. DISLIN distributions and manuals in PDF, PostScript and HTML format are available from the DISLIN home page http://www.dislin.de and via FTP from the server ftp://ftp.gwdg.de/pub/grafik/dislin All DISLIN distributions are free for non-commercial use. Licenses for commercial use are available from the site http://www.dislin.de. --- Helmut Michels Max Planck Institute for Solar System Research Phone: +49 5556 979-334 Max-Planck-Str. 2 Fax : +49 5556 979-240 D-37191 Katlenburg-Lindau Mail : [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
ANNOUNCE: omniORB 4.1.1 and omniORBpy 3.1
I am pleased to announce that omniORB 4.1.1 and omniORBpy 3.1 are now available. omniORB is a robust, high performance CORBA implementation for C++; omniORBpy is a version for Python. You can download them in source and Windows binary forms from SourceForge: http://sourceforge.net/project/showfiles.php?group_id=51138package_id=44914release_id=544978 http://sourceforge.net/project/showfiles.php?group_id=51138package_id=48639release_id=544980 These are mainly bug fix releases, with a number of minor new features. See the release notes and bug lists for more details: For omniORB 4.1.1: http://sourceforge.net/project/shownotes.php?release_id=544978group_id=51138 http://omniorb.sourceforge.net/bugs/bugfixes-410.html For omniORBpy 3.1: http://sourceforge.net/project/shownotes.php?release_id=544980group_id=51138 http://omniorb.sourceforge.net/pybugs/bugfixes-30.html Duncan. -- -- Duncan Grisby -- -- [EMAIL PROTECTED] -- -- http://www.grisby.org -- -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
ANN: Pyrex 0.9.6.2
Pyrex 0.9.6.2 is now available: http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/ Another couple of minor fixes. What is Pyrex? -- Pyrex is a language for writing Python extension modules. It lets you freely mix operations on Python and C data, with all Python reference counting and error checking handled automatically. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Problem with argument parsing
On 9 Okt, 17:18, Diez B. Roggisch [EMAIL PROTECTED] wrote: lgwe wrote: I have a python-script: myscript, used to start a program on another computer and I use OptionParser in optpars. I use it like this: myscript -H host arg1 -x -y zzz I would like OptionParser to ignore all arguments after arg1, because these are options that should be used by the program started on the oter computer arg1 -x -y zzz. One solution is to write: myscript -H host arg1 -x -y zzz But is it in some way possible to instruct OptionParser to ignore -x - y zzz without the ...? Use -- to separate arguments to be parsed by OptionParser from the to-be-ignored-ones, which is documented btw. Diez Thanks! I understand that this must be documented. But I can't find if anywhere in http://docs.python.org/lib/module-optparse.html. (maybee I just cant see it, but it is there) -- http://mail.python.org/mailman/listinfo/python-list
Re: Unexpected behaviour with HTMLParser...
Just Another Victim of the Ambient Morality schrieb: Diez B. Roggisch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Just Another Victim of the Ambient Morality schrieb: HTMLParser is behaving in, what I find to be, strange ways and I would like to better understand what it is doing and why. First, it doesn't appear to translate HTML escape characters. I don't know the actual terminology but things like amp; don't get translated into as one would like. Furthermore, not only does HTMLParser not translate it properly, it seems to omit it altogether! This prevents me from even doing the translation myself, so I can't even working around the issue. Why is it doing this? Is there some mode I need to set? Can anyone else duplicate this behaviour? Is it a bug? Without code, that's hard to determine. But you are aware of e.g. handle_entityref(name) handle_charref(ref) ? Actually, I am not aware of these methods but I will certainly look into them! I was hoping that the issue would be known or simple before I commited to posting code, something that is, to my chagrin, not easily done with my news client... Secondly, HTMLParser often calls handle_data() consecutively, without any calls to handle_starttag() in between. I did not expect this. In HTML, you either have text or you have tags. Why split up my text into successive handle_data() calls? This makes no sense to me. At the very least, it does this in response to text with amp; like escape sequences (or whatever they're called), so that it may successively avoid those translations. That's the way XML/HTML is defined - there is no guarantee that you get text as whole. If you must, you can collect the snippets yourself, and on the next end-tag deliver them as whole. I think there's some miscommunication, here. You can't mean That's the way XML/HTML is defined because those format specifications say nothing about how the format must be parsed. As far as I can tell, you either meant to say that that's the way HTMLParser is specified or you're referring to how text in XML/HTML can be broken up by tags, in which case I've already addressed that in my post. I expected to see handle_starttag() calls in between calls to handle_data(). Unless I'm missing something, it simply makes no sense to break up contiguous text into multiple handle_data() calls... I meant that's the way XML/HTML-parsing is defined, yes. Again, why is it doing this? Is there some mode I need to set? Can anyone else duplicate this behaviour? Is it a bug? No. It's the way it is, because it would require buffering with unlimited capacity to ensure this property. It depends on what you mean by unlimited capacity. Is it so bad to buffer with as much memory as you have? ...or, at least, have a setting for such operation? Moreover, you know that you'll never have to buffer more than there is HTML, so you hardly need unlimited capacity... For instance, I believe Xerces does this translation for you 'cause, really, why wouldn't you want it to? I've been dealing with XML-files that are several gigbytes of size and never fit into physical memory. So buffering would severely impact the whole system if it was the default of the parser. And you are wrong - xerces (the SAX-parser, which is the equivalent to HTMLParser) explicitly does not do that. It is not guaranteed that the character-data is passed in one chunk. DOM is an etirely different subject, it _has_ to be fully parsed. But then, it's often problematic because of that. These are serious problems for me and I would greatly appreciate a deeper understanding of these issues. HTH, and read the docs. This does help, thank you. I have obviously read the docs, since I can use HTMLParser enough to find this behaviour. I don't find the docs to be very explanatory (perhaps I'm reading the wrong docs) and I think they assume you already know a lot about HTML and parsing, which may be necessary assumptions but are not necessarily true... Well, you at least overlooked the methods I mentioned. Diez -- http://mail.python.org/mailman/listinfo/python-list
button binding isn't triggering event like it's supposed to
hi. i am trying to learn event binding. i have a form with a couple of buttons for different tags, which all call the same function. the text on the buttons changes from record to record. this is the problem area: def showrecords(self): this function updates the form labels to show the current record global gmax global gctr global CurrTitle global CurrAuthor global CurrTag1 global CurrTag2 global CurrTag3 global CurrTag4 global CurrTag5 global CurrAbstract global CurrLocation global CurrID global HuntFor self.Lbn.config(text=gmax) self.Lbnof.config(text=gctr+1) self.LbTitle.config(text=CurrTitle, justify=LEFT) self.LbName.config(text=CurrAuthor) self.LbPath.config(text=CurrLocation) self.BtTag1.bind('Button-1',self.calltotags(tag=CurrTag1)) self.BtTag1.config(text=CurrTag1) self.BtTag2.bind('Button-1',self.calltotags(tag=CurrTag2)) self.BtTag2.config(text=CurrTag2) self.BtTag3.bind('Button-1',self.calltotags(tag=CurrTag3)) self.BtTag3.config(text=CurrTag3) self.BtTag4.bind('Button-1',self.calltotags(tag=CurrTag4)) self.BtTag4.config(text=CurrTag4) self.BtTag5.bind('Button-1',self.calltotags(tag=CurrTag5)) self.BtTag5.config(text=CurrTag5) self.LbAbs.config(text=CurrAbstract) def calltotags(event, tag): # This function sets the search variable HuntFor value, and calls the tagwork class. global HuntFor global toggle HuntFor=tag toggle=Tagcluster print HuntFor tagwork() when i click on the buttons, none of them call the function. i only see the huntfor value in the prompt when i load the program. can someone please enlighten me as to why this happens? (the buttons are loaded on the root window in an earlier function, and i have the same problem even if i try binding the events there) also, can someone suggest a good (and free!) code editor for python please? thanks in advance. mridula. -- http://mail.python.org/mailman/listinfo/python-list
APOLOGY (was: pytz has so many timezones!)
I apologize for being a dick. It won't happen again. I was actually thinking that the 25 standard timezones (which make a reasonable list or can be easily generated by clicking a map) could serve as a filter to make the detail list reasonably sized. Something like this: import pytz import datetime import sqlite3 import random utc = pytz.timezone('UTC') utc_dt = datetime.datetime(2007,1,1,0,0,0,tzinfo=utc) offset_zone = [] for i in pytz.all_timezones: the_zone = pytz.timezone(i) loc_dt = utc_dt.astimezone(the_zone) loc_offset = loc_dt.strftime('%z') offset_zone.append((loc_offset,the_zone.zone)) con = sqlite3.connect(:memory:) cur = con.cursor() cur.executescript( create table tz( offset, zone ); ) cur.executemany( INSERT INTO tz(offset, zone) VALUES (?,?) , offset_zone) cur.execute( SELECT DISTINCT offset FROM tz WHERE offset LIKE '+%' ORDER BY offset; ) east = cur.fetchall() cur.execute( SELECT DISTINCT offset FROM tz WHERE offset LIKE '-%' ORDER BY offset DESC; ) west = cur.fetchall() distinct_offsets = east + west print print 'Choose your GMT offset:' for i in distinct_offsets: if i[0]=='+' or i[0]=='+0600' or i[0]=='+1200' or i[0]=='-1200' or i[0]=='-0600': print print i[0], print print the_choice = random.choice(distinct_offsets) print 'Offset',the_choice[0],'chosen.' print cur.execute( SELECT offset, zone FROM tz WHERE offset=? ORDER BY offset; ,the_choice) list_o_zones = cur.fetchall() print 'Which timezone?' print for i in list_o_zones: print i[0],i[1] ## Choose your GMT offset: ## ## + +0100 +0200 +0300 +0330 +0400 +0430 +0500 +0530 +0545 ## +0600 +0630 +0700 +0800 +0900 +0930 +0945 +1000 +1030 +1100 +1130 ## +1200 +1300 +1345 +1400 ## -1200 -1100 -1000 -0930 -0900 -0800 -0700 ## -0600 -0500 -0400 -0330 -0300 -0200 -0100 ## ## Offset -0930 chosen. ## ## Which timezone? ## ## -0930 Pacific/Marquesas ## ## ## ## Choose your GMT offset: ## ## + +0100 +0200 +0300 +0330 +0400 +0430 +0500 +0530 +0545 ## +0600 +0630 +0700 +0800 +0900 +0930 +0945 +1000 +1030 +1100 +1130 ## +1200 +1300 +1345 +1400 ## -1200 -1100 -1000 -0930 -0900 -0800 -0700 ## -0600 -0500 -0400 -0330 -0300 -0200 -0100 ## ## Offset +0945 chosen. ## ## Which timezone? ## ## +0945 Australia/Eucla ## ## ## ## Choose your GMT offset: ## ## + +0100 +0200 +0300 +0330 +0400 +0430 +0500 +0530 +0545 ## +0600 +0630 +0700 +0800 +0900 +0930 +0945 +1000 +1030 +1100 +1130 ## +1200 +1300 +1345 +1400 ## -1200 -1100 -1000 -0930 -0900 -0800 -0700 ## -0600 -0500 -0400 -0330 -0300 -0200 -0100 ## ## Offset -0100 chosen. ## ## Which timezone? ## ## -0100 America/Scoresbysund ## -0100 Atlantic/Azores ## -0100 Atlantic/Cape_Verde ## -0100 Etc/GMT+1 ## ## ## ## Choose your GMT offset: ## ## + +0100 +0200 +0300 +0330 +0400 +0430 +0500 +0530 +0545 ## +0600 +0630 +0700 +0800 +0900 +0930 +0945 +1000 +1030 +1100 +1130 ## +1200 +1300 +1345 +1400 ## -1200 -1100 -1000 -0930 -0900 -0800 -0700 ## -0600 -0500 -0400 -0330 -0300 -0200 -0100 ## ## Offset +1000 chosen. ## ## Which timezone? ## ## +1000 Antarctica/DumontDUrville ## +1000 Asia/Sakhalin ## +1000 Asia/Vladivostok ## +1000 Australia/Brisbane ## +1000 Australia/Lindeman ## +1000 Australia/Queensland ## +1000 Etc/GMT-10 ## +1000 Pacific/Guam ## +1000 Pacific/Port_Moresby ## +1000 Pacific/Saipan ## +1000 Pacific/Truk ## +1000 Pacific/Yap ## ## ## ## Choose your GMT offset: ## ## + +0100 +0200 +0300 +0330 +0400 +0430 +0500 +0530 +0545 ## +0600 +0630 +0700 +0800 +0900 +0930 +0945 +1000 +1030 +1100 +1130 ## +1200 +1300 +1345 +1400 ## -1200 -1100 -1000 -0930 -0900 -0800 -0700 ## -0600 -0500 -0400 -0330 -0300 -0200 -0100 ## ## Offset +0300 chosen. ## ## Which timezone? ## ## +0300 Africa/Addis_Ababa ## +0300 Africa/Asmara ## +0300 Africa/Asmera ## +0300 Africa/Dar_es_Salaam ## +0300 Africa/Djibouti ## +0300 Africa/Kampala ## +0300 Africa/Khartoum ## +0300 Africa/Mogadishu ## +0300 Africa/Nairobi ## +0300 Antarctica/Syowa ## +0300 Asia/Aden ## +0300 Asia/Baghdad ## +0300 Asia/Bahrain ## +0300 Asia/Kuwait ## +0300 Asia/Qatar ## +0300 Asia/Riyadh ## +0300 Etc/GMT-3 ## +0300 Europe/Moscow ## +0300 Europe/Volgograd ## +0300 Indian/Antananarivo ## +0300 Indian/Comoro ## +0300 Indian/Mayotte ## +0300 W-SU ## Choose your GMT offset: ## ## + +0100 +0200 +0300 +0330 +0400 +0430 +0500 +0530 +0545 ## +0600 +0630 +0700 +0800 +0900 +0930 +0945 +1000 +1030 +1100 +1130 ## +1200 +1300 +1345 +1400 ## -1200 -1100 -1000 -0930 -0900 -0800 -0700 ## -0600 -0500 -0400 -0330 -0300 -0200 -0100 ## ## Offset -0600 chosen. ## ## Which timezone? ## ## -0600 America/Belize ## -0600 America/Cancun ## -0600 America/Chicago ## -0600 America/Costa_Rica ## -0600 America/El_Salvador ## -0600 America/Guatemala ## -0600 America/Indiana/Knox ## -0600 America/Indiana/Petersburg ## -0600 America/Indiana/Tell_City ## -0600
unpickle from URL problem
I am on a Windows box. I pickle a tuple of 2 simple objects with the pickle module. It pickles fine. It unpickles fine. I upload to a server. I try to unpickle from the URL. No luck. Try it: x1, x2 = pickle.load(urllib.urlopen('http://www.american.edu/econ/notes/hw/example1')) I change the filetype to unix. I upload again. I try to unpickle from the URL. Now it works. Try it: x1, x2 = pickle.load(urllib.urlopen('http://www.american.edu/econ/notes/hw/example2')) Why the difference? Thank you, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
Re: Static variable vs Class variable
Yes, it is. I'm afraid not. As I admitted in my reply to Marc, I overstated my case by saying that L isn't rebound at all. Of course it is rebound, but to itself. However, it is not true that += always leads to a rebinding of a to the result of the operation +. The + operator for lists creates a new list. += for lists does an in-place modification: It still is true. a += b rebinds a. Period. Which is the _essential_ thing in my post, because this rebinding semantics are what confused the OP. L = [] M = L L += [1] M [1] Compare with: L = [] M = L L = L + [1] M [] You said: I presume you got confused by the somewhat arbitrary difference between __add__ and __iadd__ that somehow suggest there is an in-place- modification going on in case of mutables but as the following snippet shows - that's not the case: ... Admittedly, I miss _one_ word here: necessarily before the an. That's an explicit denial that in-place modification takes place, and that's *way* off the mark. I was concentrating so hard on showing in- place modification that I glossed over the return self part. And I was concetrating so hard on the rebinding-part, I glossed over the in-place-modification part. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Static variable vs Class variable
Diez B. Roggisch schrieb: Yes, it is. I'm afraid not. As I admitted in my reply to Marc, I overstated my case by saying that L isn't rebound at all. Of course it is rebound, but to itself. However, it is not true that += always leads to a rebinding of a to the result of the operation +. The + operator for lists creates a new list. += for lists does an in-place modification: It still is true. a += b rebinds a. Period. Which is the _essential_ thing in my post, because this rebinding semantics are what confused the OP. Which I just came around to show in a somewhat enhanced example I could have used the first time: class Foo(object): a = [] @classmethod def increment(cls): print cls cls.a += [1] class Bar(Foo): pass Foo.increment() Bar.increment() print Foo.a print Bar.a Bar.a = [] print Foo.a print Bar.a 192:~/projects/SoundCloud/ViewAnimationTest deets$ python /tmp/test.py class '__main__.Foo' class '__main__.Bar' [1, 1] [1, 1] [1, 1] [] Which makes the rebinding-part of __iadd__ pretty much an issue, don't you think? Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: unpickle from URL problem
On Wed, 10 Oct 2007 05:58:51 +, Alan Isaac wrote: I am on a Windows box. I pickle a tuple of 2 simple objects with the pickle module. It pickles fine. It unpickles fine. I upload to a server. I try to unpickle from the URL. No luck. Try it: x1, x2 = pickle.load(urllib.urlopen('http://www.american.edu/econ/notes/hw/example1')) I change the filetype to unix. I upload again. I try to unpickle from the URL. Now it works. Try it: x1, x2 = pickle.load(urllib.urlopen('http://www.american.edu/econ/notes/hw/example2')) Why the difference? Pickles are *binary* files, not text files, so make sure you always treat them as binary, e.g. opening the files with mode 'rb' and 'wb' and don't transmit them in text mode over FTP etc. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet another comparison of Python Web Frameworks
On Oct 10, 5:57 am, [EMAIL PROTECTED] wrote: Since you are starting a new project you may want to look into something new and different http://mdp.cti.depaul.edu/examples Well, the name is certainly appealing to an old gauge field theorist like myself ;) Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Re: Unexpected behaviour with HTMLParser...
Just Another Victim of the Ambient Morality wrote: HTMLParser is behaving in, what I find to be, strange ways and I would like to better understand what it is doing and why. In case you also want an HTML library that is easy to use (and powerful and flexible and...), look at lxml.html. http://codespeak.net/lxml/dev/lxmlhtml.html It's part of lxml 2.0, which is currently in alpha status (which does not mean it's unstable or something, just not as complete as its authors want it to be). http://codespeak.net/lxml/dev/ Stefan -- http://mail.python.org/mailman/listinfo/python-list
Cantankerous trolliness ad infinitum, was: Re: The Modernization of Emacs: terminology buffer and keybinding
[EMAIL PROTECTED] wrote: ^ Is this some sport of yours to constantly create new gmail accounts and spam Usenet? So you assert, but man bears a much closer resemblance to manus than it does to mens. This is irrelevant. Consult an etymological dictionary. F'up-to: comp.lang.lisp, where I'm reading this. -- http://mail.python.org/mailman/listinfo/python-list
Re: pytz has so many timezones!
Thanks a lot, Guys. The immediate step I think to take is having two combo boxes (dividing the data by '/'). Thanks for enormous response and the valuable suggestions! Sanjay -- http://mail.python.org/mailman/listinfo/python-list
pyxml package not working? No xml.dom.ext.reader module available after install.
I've tried to install the pyxml-package, available at http://pyxml.sourceforge.net/, both from source and using some hack on the win32-binary package available for python2.4, but without luck. After install the module xml.dom.ext.reader is not available, eventhough the folder, __init__py and everything is in place. Why? And could someone please make a win32-binary package of pyxml for python2.5? Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with argument parsing
lgwe wrote: On 9 Okt, 17:18, Diez B. Roggisch [EMAIL PROTECTED] wrote: lgwe wrote: I have a python-script: myscript, used to start a program on another computer and I use OptionParser in optpars. I use it like this: myscript -H host arg1 -x -y zzz I would like OptionParser to ignore all arguments after arg1, because these are options that should be used by the program started on the oter computer arg1 -x -y zzz. One solution is to write: myscript -H host arg1 -x -y zzz But is it in some way possible to instruct OptionParser to ignore -x - y zzz without the ...? Use -- to separate arguments to be parsed by OptionParser from the to-be-ignored-ones, which is documented btw. Diez Thanks! I understand that this must be documented. But I can't find if anywhere in http://docs.python.org/lib/module-optparse.html. (maybee I just cant see it, but it is there) It's general unix-commandline-knowledge... but you are right of course. It should be documented. Maybe you can file a documentation-bug or something? Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: pyxml package not working? No xml.dom.ext.reader module available after install.
Thomas W wrote: I've tried to install the pyxml-package, available at http://pyxml.sourceforge.net/, both from source and using some hack on the win32-binary package available for python2.4, but without luck. After install the module xml.dom.ext.reader is not available, eventhough the folder, __init__py and everything is in place. Why? And could someone please make a win32-binary package of pyxml for python2.5? Thanks! PyXML has not been actively maintained for some years now. Use ElementTree or lxml instead. http://codespeak.net/lxml Stefan -- http://mail.python.org/mailman/listinfo/python-list
[ANN] Data Plotting Library DISLIN 9.2
Dear Python users, I am pleased to announce version 9.2 of the data plotting software DISLIN. DISLIN is a high-level and easy to use plotting library for displaying data as curves, bar graphs, pie charts, 3D-colour plots, surfaces, contours and maps. Several output formats are supported such as X11, VGA, PostScript, PDF, CGM, WMF, HPGL, TIFF, GIF, PNG, BMP and SVG. The software is available for the most C, Fortran 77 and Fortran 90/95 compilers. Plotting extensions for the interpreting languages Perl, Python and Java are also supported. DISLIN distributions and manuals in PDF, PostScript and HTML format are available from the DISLIN home page http://www.dislin.de and via FTP from the server ftp://ftp.gwdg.de/pub/grafik/dislin All DISLIN distributions are free for non-commercial use. Licenses for commercial use are available from the site http://www.dislin.de. --- Helmut Michels Max Planck Institute for Solar System Research Phone: +49 5556 979-334 Max-Planck-Str. 2 Fax : +49 5556 979-240 D-37191 Katlenburg-Lindau Mail : [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Static variable vs Class variable
Steven D'Aprano írta: On Tue, 09 Oct 2007 21:25:38 +0200, Laszlo Nagy wrote: a = 1 a+= 1 # The compiler will probably optimize this and the Python bytecode interpreter will not rebind 'a' here, just increment the integer in memory. No. This is Python, not C. You can't increment integers in memory. What? Please read my post. I was talking about __implementation level__, clearly. :-) -- http://mail.python.org/mailman/listinfo/python-list
Singleton
Hi, I've been trying to get some sort of singleton working in python, but I struggle a bit and I thought I'd ask for advice. The first approach was simply to use a module, and every variable in it will be seen by all who import the module. That works in some cases, but not if I have the following structure: one/ __init__.py mod1.py run.py two/ __init__.py mod2.py run.py looks like this: #!/usr/bin/env python import mod1 print mod1.number import two.mod2 print two.mod2.number mod1.py looks like this: import random number=random.randint(0,100) mod2.py looks like this import one.mod1 number = one.mod1.number PYTHONPATH is set to the directory containing the 'one' and 'two' directories. Now when I run the 'run.py', it will print two different numbers. sys.modules tells me that 'mod1' is imported as both 'one.mod1' and 'mod1', which explains the result. Looking at: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52558 I find a singleton class, but it has the same problem. If it's imported in two different ways, I have not a singleton but a ... 'doubleton' or something. It is possible to solve this by always importing with the complete path like 'one.mod1', even when inside the 'one' directory, but that's an error waiting to happen. So how do people solve this? Is there an obvious way that I missed? I'm thankful for any advice you might provide. -- http://mail.python.org/mailman/listinfo/python-list
Re: NUCULAR fielded text searchable indexing
On 9 Okt, 22:32, [EMAIL PROTECTED] wrote: Well I'd like people to use the software because they think it's good. If the name is a problem it's probably only the first of many reasons they won't want to use it or will not like it because it doesn't match their preconceptions. Please ignore the fuss about the name - I guess you didn't spend the required three months pre-hyping the project on a blog, thus not getting buy in from the impatient masses - and tell us how the software compares to stuff like Lucene or Xapian. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: pyxml package not working? No xml.dom.ext.reader module available after install.
On 10 Okt, 11:13, Stefan Behnel [EMAIL PROTECTED] wrote: Thomas W wrote: I've tried to install the pyxml-package, available athttp://pyxml.sourceforge.net/, both from source and using some hack on the win32-binary package available for python2.4, but without luck. After install the module xml.dom.ext.reader is not available, eventhough the folder, __init__py and everything is in place. Why? And could someone please make a win32-binary package of pyxml for python2.5? Thanks! PyXML has not been actively maintained for some years now. Use ElementTree or lxml instead. http://codespeak.net/lxml Stefan But the problem is that I'm using some piece of code that needs pyxml. Wouldn't be a problem if I was developing this project myself. Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: struct.unpack less than 1 byte
2007/10/10, cprogrammer [EMAIL PROTECTED]: hello all, i need to read from a file a struct like this [1byte, 12bits, 12bits] reading 1 byte or more is not a problem ... but the 12 bits values are ... thanks -- http://mail.python.org/mailman/listinfo/python-list 12bits, 12bits == 3 byes -- -- Guilherme H. Polo Goncalves -- http://mail.python.org/mailman/listinfo/python-list
Python service gets interrupted function call
Hi All, I wanted to know how to handle events like 'logoff' in the main thread so that any process which is being run by svcDoRun method of service does not get 'interrupted function call' exception. I am posting a very simple service program , and i want to know that is there a way to handle such interrupts without explicitly calling try except block over blocking calls. Here is the example which is getting interrupted exception at logoff. === import os, time, sys import win32serviceutil, win32service import pywintypes, win32con, winerror # Use import * to keep this looking as much as a normal service # as possible. Real code shouldn't do this. from win32event import * from win32file import * from win32pipe import * from win32api import * from ntsecuritycon import * import servicemanager import traceback import thread, time class TrialService(win32serviceutil.ServiceFramework): _svc_name_ = TrialService _svc_display_name_ = TrialService _svc_description_ = TrialService _exe_name_ = C:/Python24/Lib/site-packages/win32/ pythonservice.exe def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) self.hWaitStop = CreateEvent(None, 0, 0, None) self.overlapped = pywintypes.OVERLAPPED() self.overlapped.hEvent = CreateEvent(None,0,0,None) def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) SetEvent(self.hWaitStop) def SvcDoRun(self): time.sleep(1000) def ctrl_handler(ctrl_type): return True if __name__ =='__main__': SetConsoleCtrlHandler(ctrl_handler, True) win32serviceutil.HandleCommandLine(TrialService) In actual call i just want to call my app in place of time.sleep but my app will have blocking code segments. Any help will be greatly appreciated . Thanks Ashish -- http://mail.python.org/mailman/listinfo/python-list
struct.unpack less than 1 byte
hello all, i need to read from a file a struct like this [1byte, 12bits, 12bits] reading 1 byte or more is not a problem ... but the 12 bits values are ... thanks -- http://mail.python.org/mailman/listinfo/python-list
more information for making money
www.space666.com sports , poker ,etc. -- http://mail.python.org/mailman/listinfo/python-list
Last value of yield statement
Hello all, Let us say I have a function like this: def efficientFiller(file): worthless_list = [] pot_file = open(file,'r') pot_file_text = pot_file.readlines() for line in pot_file_text: if line.find(msgid) != -1: message_id = shlex.split(line)[1] if message_id in dictionary: number = pot_file_text.index(line) corresponding_crap = dictionary.get(message_id) final_string = 'msgstr' + + '' + corresponding_crap + '' + '\n' pot_file_text[number+1] = final_string yield pot_file_text efficient_filler = efficientFiller(libexo-0.3.pot) new_list = list(efficient_filler) print new_list I want to plainly get the last value the yield statement generates. How can I go about doing this please? Regards, Shriphani Palakodety -- http://mail.python.org/mailman/listinfo/python-list
Re: Last value of yield statement
On Oct 10, 5:19 am, Shriphani [EMAIL PROTECTED] wrote: Hello all, Let us say I have a function like this: def efficientFiller(file): Note that you are shadowing the built-in variable 'file' here. Better use 'filename', or something to that effect. worthless_list = [] pot_file = open(file,'r') pot_file_text = pot_file.readlines() for line in pot_file_text: if line.find(msgid) != -1: message_id = shlex.split(line)[1] if message_id in dictionary: number = pot_file_text.index(line) corresponding_crap = dictionary.get(message_id) final_string = 'msgstr' + + '' + corresponding_crap + '' + '\n' pot_file_text[number+1] = final_string yield pot_file_text efficient_filler = efficientFiller(libexo-0.3.pot) new_list = list(efficient_filler) print new_list I want to plainly get the last value the yield statement generates. How can I go about doing this please? Regards, Shriphani Palakodety efficient_filler = efficientFiller(libexo-0.3.pot) new_list = list(efficient_filler) last_value = new_list[-1] print last_value # OR efficient_filler = efficientFiller(libexo-0.3.pot) for last_value in efficient_filler: pass print last_value The latter assumes that the last value is the only value you want. -- http://mail.python.org/mailman/listinfo/python-list
ANNOUNCE: omniORB 4.1.1 and omniORBpy 3.1
I am pleased to announce that omniORB 4.1.1 and omniORBpy 3.1 are now available. omniORB is a robust, high performance CORBA implementation for C++; omniORBpy is a version for Python. You can download them in source and Windows binary forms from SourceForge: http://sourceforge.net/project/showfiles.php?group_id=51138package_id=44914release_id=544978 http://sourceforge.net/project/showfiles.php?group_id=51138package_id=48639release_id=544980 These are mainly bug fix releases, with a number of minor new features. See the release notes and bug lists for more details: For omniORB 4.1.1: http://sourceforge.net/project/shownotes.php?release_id=544978group_id=51138 http://omniorb.sourceforge.net/bugs/bugfixes-410.html For omniORBpy 3.1: http://sourceforge.net/project/shownotes.php?release_id=544980group_id=51138 http://omniorb.sourceforge.net/pybugs/bugfixes-30.html Duncan. -- -- Duncan Grisby -- -- [EMAIL PROTECTED] -- -- http://www.grisby.org -- -- http://mail.python.org/mailman/listinfo/python-list
Re: Last value of yield statement
On Oct 10, 3:34 pm, Dustan [EMAIL PROTECTED] wrote: On Oct 10, 5:19 am, Shriphani [EMAIL PROTECTED] wrote: Hello all, Let us say I have a function like this: def efficientFiller(file): Note that you are shadowing the built-in variable 'file' here. Better use 'filename', or something to that effect. worthless_list = [] pot_file = open(file,'r') pot_file_text = pot_file.readlines() for line in pot_file_text: if line.find(msgid) != -1: message_id = shlex.split(line)[1] if message_id in dictionary: number = pot_file_text.index(line) corresponding_crap = dictionary.get(message_id) final_string = 'msgstr' + + '' + corresponding_crap + '' + '\n' pot_file_text[number+1] = final_string yield pot_file_text efficient_filler = efficientFiller(libexo-0.3.pot) new_list = list(efficient_filler) print new_list I want to plainly get the last value the yield statement generates. How can I go about doing this please? Regards, Shriphani Palakodety efficient_filler = efficientFiller(libexo-0.3.pot) new_list = list(efficient_filler) last_value = new_list[-1] print last_value # OR efficient_filler = efficientFiller(libexo-0.3.pot) for last_value in efficient_filler: pass print last_value The latter assumes that the last value is the only value you want. Hello again, Well the basic trouble is that the yield statement you see there causes it to print the list over and over again when a string containing msgid is found and the subsequent conditions are satisfied. I just want the last list the yield statement generates. I don't want the last element of the list generated. just the last statement. Regards, Shriphani Palakodety -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixing Python and C classes in a module
On 10/10/2007 1:02 PM, [EMAIL PROTECTED] wrote: It is easier to do it the other way around. Create module.py and _module.so and in module.py write: from _module.so import * It is even easier to type from _module import * and somewhat more productive, too :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: struct.unpack less than 1 byte
On Oct 10, 8:15 pm, Guilherme Polo [EMAIL PROTECTED] wrote: 2007/10/10, cprogrammer [EMAIL PROTECTED]: i need to read from a file a struct like this [1byte, 12bits, 12bits] reading 1 byte or more is not a problem ... but the 12 bits values are ... 12bits, 12bits == 3 byes and 8 + 12 + 12 = 32 :-) Assuming little-endianess and that all 3 items are unsigned: import struct bytes = \x21\x43\xba\xdc i32 = struct.unpack(I, bytes)[0] hex(i32) '0xdcba4321L' fields = map(int, (i32 0xff, (i32 8) 0xfff, i32 20)) fields [33, 2627, 3531] map(hex, fields) ['0x21', '0xa43', '0xdcb'] -- http://mail.python.org/mailman/listinfo/python-list
Re: struct.unpack less than 1 byte
You are able to read single bits from file in C ? You'll have to read the bytes and than perform some bitwise operations on them to extract the bits hello all, i need to read from a file a struct like this [1byte, 12bits, 12bits] reading 1 byte or more is not a problem ... but the 12 bits values are ... thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: The fundamental concept of continuations
[EMAIL PROTECTED] writes: Again I am depressed to encounter a fundamentally new concept that I was all along unheard of. Its not even in paul graham's book where i learnt part of Lisp. Its in Marc Feeley's video. Can anyone explain: (1) its origin (2) its syntax and semantics in emacs lisp, common lisp, scheme (3) Is it present in python and java ? (4) Its implementation in assembly. for example in the manner that pointer fundamentally arises from indirect addressing and nothing new. So how do you juggle PC to do it. (5) how does it compare to and superior to a function or subroutine call. how does it differ. Basically, there is no difference to function/subroutine call. The difference is just that there is no call stack: the dynamic context for a call is created on the heap and is garbage-collected when it is no longer accessible. A continuation is just a reference to the state of the current dynamic context. As long as a continuation remains accessible, you can return to it as often as you like. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum -- http://mail.python.org/mailman/listinfo/python-list
Re: unpickle from URL problem
On Wed, 10 Oct 2007 05:58:51 GMT, Alan Isaac [EMAIL PROTECTED] wrote: I am on a Windows box. I pickle a tuple of 2 simple objects with the pickle module. It pickles fine. It unpickles fine. I upload to a server. I try to unpickle from the URL. No luck. Try it: x1, x2 = pickle.load(urllib.urlopen('http://www.american.edu/econ/notes/hw/example1')) I change the filetype to unix. I upload again. I try to unpickle from the URL. Now it works. Try it: x1, x2 = pickle.load(urllib.urlopen('http://www.american.edu/econ/notes/hw/example2')) Why the difference? You shouldn't unpickle things you get from the network, since pickle can execute arbitrary code: http://jcalderone.livejournal.com/15864.html Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: NUCULAR fielded text searchable indexing
[Paul] tell us how the software compares to stuff like Lucene or Xapian. +1 -- Richie -- http://mail.python.org/mailman/listinfo/python-list
function wrappers
Dear all, I have a Fortran programming background and I have some difficulties in understading how function wrappers work. I have delved into the subject because of the new decorators, but I understand the decorator syntax. My ignorance is more profound... Here is an example without decorators: def require_int(func): def wrapper(arg): assert isinstance(arg, int) return func(arg) return wrapper p1(a): print a p2=require_int(p1) My question is: why do p2 arguments become wrapper arguments? What is the flux of the arguments in the program when you pass functions as arguments? I have looked into some books and google but I cannot find a satisfactory explanation. Could somebody please give me a hint or point me to an appropriate source? Thanks for your time, Ramon -- http://mail.python.org/mailman/listinfo/python-list
Re: Last value of yield statement
On 10/10/07, Shriphani [EMAIL PROTECTED] wrote: On Oct 10, 3:34 pm, Dustan [EMAIL PROTECTED] wrote: On Oct 10, 5:19 am, Shriphani [EMAIL PROTECTED] wrote: Hello all, Let us say I have a function like this: def efficientFiller(file): Note that you are shadowing the built-in variable 'file' here. Better use 'filename', or something to that effect. worthless_list = [] pot_file = open(file,'r') pot_file_text = pot_file.readlines() for line in pot_file_text: if line.find(msgid) != -1: message_id = shlex.split(line)[1] if message_id in dictionary: number = pot_file_text.index(line) corresponding_crap = dictionary.get(message_id) final_string = 'msgstr' + + '' + corresponding_crap + '' + '\n' pot_file_text[number+1] = final_string yield pot_file_text efficient_filler = efficientFiller(libexo-0.3.pot) new_list = list(efficient_filler) print new_list I want to plainly get the last value the yield statement generates. How can I go about doing this please? Well the basic trouble is that the yield statement you see there causes it to print the list over and over again when a string containing msgid is found and the subsequent conditions are satisfied. I just want the last list the yield statement generates. I don't want the last element of the list generated. just the last statement. I may be being stupid but i really fail to understand that why would you want to use 'yield' in such a scenario ? Btw, the following line in your code may cause some unexpected behavior (in case of duplicates): code number = pot_file_text.index(line) /code You should rather use 'enumerate' . Cheers, -- -- Amit Khemka -- http://mail.python.org/mailman/listinfo/python-list
Re: Last value of yield statement
On 10/10/2007 8:19 PM, Shriphani wrote: Hello all, Let us say I have a function like this: def efficientFiller(file): worthless_list = [] pot_file = open(file,'r') pot_file_text = pot_file.readlines() for line in pot_file_text: if line.find(msgid) != -1: message_id = shlex.split(line)[1] if message_id in dictionary: number = pot_file_text.index(line) corresponding_crap = dictionary.get(message_id) final_string = 'msgstr' + + '' + corresponding_crap + '' + '\n' pot_file_text[number+1] = final_string yield pot_file_text efficient_filler = efficientFiller(libexo-0.3.pot) new_list = list(efficient_filler) print new_list I want to plainly get the last value the yield statement generates. How can I go about doing this please? I don't think that 'efficient' and 'plainly' mean what you think they mean. However to answer your question: new_list[-1] if new_list else None BTW I get the impression that the yield statement yields the whole pot_file_text list each time, so that new_list will be a list of lists; is that intentional? -- http://mail.python.org/mailman/listinfo/python-list
Re: pyxml package not working? No xml.dom.ext.reader module available after install.
Thomas W wrote: On 10 Okt, 11:13, Stefan Behnel [EMAIL PROTECTED] wrote: Thomas W wrote: I've tried to install the pyxml-package, available athttp://pyxml.sourceforge.net/, both from source and using some hack on the win32-binary package available for python2.4, but without luck. After install the module xml.dom.ext.reader is not available, eventhough the folder, __init__py and everything is in place. Why? And could someone please make a win32-binary package of pyxml for python2.5? Thanks! PyXML has not been actively maintained for some years now. Use ElementTree or lxml instead. http://codespeak.net/lxml Stefan But the problem is that I'm using some piece of code that needs pyxml. Wouldn't be a problem if I was developing this project myself. Ah, ok. I was just suggesting that you'd be very lucky if someone came up with a fresh build or something... Stefan -- http://mail.python.org/mailman/listinfo/python-list
setup.py build SWIG: missing py files (they are outside the build directory)
Hi all, I am trying to make a package distribution containing some extension module written in C. The problem is that when I run setup.py some files are generated in the wrong position. Suppose that this is my setup.py: from distutils.core import setup, Extension setup(name='foo', package_dir = {foo : src}, packages=['foo', 'foo.spam', ], ext_modules=[ Extension(foo.spam._spam, sources=['src/spam/spam.i', 'src/spam/spam.cc', ], ) ] ) Here is an example of what I get after running: python setup.py build -cmingw32 bdist .\ +build\ +lib.win32-2.4\ +foo\ +spam\ __init__.py _spam.pyd __init__.py foo.py +src\ +dist\ foo-0.0.win32.zip setup.py spam.py So the problem is that spam.py (generated by SWIG) is not in .\build \lib.win32-2.4\foo\spam but in the same directory as setup.py! Of course I can move it manually, but I have to update also foo-0.0.win32.zip and all this is quite annoying... Did I miss some option in the setup? Is it possible to run a system command (copy) after each extension is compiled and linked and the corresponding .py file is generated? Thanks in advance! Mauro -- http://mail.python.org/mailman/listinfo/python-list
Re: Last value of yield statement
On Oct 10, 4:05 pm, John Machin [EMAIL PROTECTED] wrote: On 10/10/2007 8:19 PM, Shriphani wrote: Hello all, Let us say I have a function like this: def efficientFiller(file): worthless_list = [] pot_file = open(file,'r') pot_file_text = pot_file.readlines() for line in pot_file_text: if line.find(msgid) != -1: message_id = shlex.split(line)[1] if message_id in dictionary: number = pot_file_text.index(line) corresponding_crap = dictionary.get(message_id) final_string = 'msgstr' + + '' + corresponding_crap + '' + '\n' pot_file_text[number+1] = final_string yield pot_file_text efficient_filler = efficientFiller(libexo-0.3.pot) new_list = list(efficient_filler) print new_list I want to plainly get the last value the yield statement generates. How can I go about doing this please? I don't think that 'efficient' and 'plainly' mean what you think they mean. However to answer your question: new_list[-1] if new_list else None BTW I get the impression that the yield statement yields the whole pot_file_text list each time, so that new_list will be a list of lists; is that intentional? Hello again, I am sorry for having made that extra post and should have seen that the solution I wanted was posted here. Anyway thanks a lot Regards, Shriphani Palakodety -- http://mail.python.org/mailman/listinfo/python-list
Re: function wrappers
On Wed, 10 Oct 2007 12:39:24 +0200, Ramon Crehuet wrote: def require_int(func): def wrapper(arg): assert isinstance(arg, int) return func(arg) return wrapper p1(a): print a p2=require_int(p1) My question is: why do p2 arguments become wrapper arguments? What is the flux of the arguments in the program when you pass functions as arguments? The function `p1` is passed into `require_int`. It is bound to the local name `func` in `require_int`. Everytime `require_int` is called a new function object is created and bound to the local name `wrapper`. The name `func` in that new function object refers to the object bound to `func` in the `require_int` namespace. Then the new function is returned still carrying a reference to the `func` object that was passed into `require_int`. Ciao, Marc 'Blackjack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: Last value of yield statement
On Oct 10, 11:19 am, Shriphani [EMAIL PROTECTED] wrote: Hello all, Let us say I have a function like this: def efficientFiller(file): worthless_list = [] pot_file = open(file,'r') pot_file_text = pot_file.readlines() for line in pot_file_text: if line.find(msgid) != -1: message_id = shlex.split(line)[1] if message_id in dictionary: number = pot_file_text.index(line) corresponding_crap = dictionary.get(message_id) final_string = 'msgstr' + + '' + corresponding_crap + '' + '\n' pot_file_text[number+1] = final_string yield pot_file_text efficient_filler = efficientFiller(libexo-0.3.pot) new_list = list(efficient_filler) print new_list I want to plainly get the last value the yield statement generates. How can I go about doing this please? If you want only one value, you should be using return rather than yield. What do you think your code does - and what is it supposed to do? If it's not doing what it's supposed to be doing, it's better to understand why not rather than try to patch up the output. I'm going to guess that you want to take the lines of a file, and after every line of the form 'msgid K' insert a line 'msgstr ...' when K is in some dictionary you've got. I'll assume you want the new lines as a generator rather than as a list. Then, something like (untested) def lookup_msgids(filename): Yield lines from the given file, with 'msgstr' lines added after 'msgid' lines when the id is in the id dictionary. for line in open(filename, 'r'): yield line if line.startswith('msgid'): msgid = shlex.split(line)[1] if msgid in dictionary: yield 'msgstr %s\n' % dictionary[msgid] libexo_pot = list(lookup_msgids('libexo-0.3.pot')) print libexo_pot -- Paul Hankin -- http://mail.python.org/mailman/listinfo/python-list
Autoglade
I've been working on a python based tool named autoglade that could be of help to simplify application development using glade as the interface designer. There is a lot of room for improvement but it's pretty usable right now. You can download autoglade from http://sourceforge.net/projects/autoglade. A basic tutorial can be found in the wiki: http://autoglade.wiki.sourceforge.net/autoglade+tutorial+-+first+steps This tutorial shows how you can create applications only from the glade definition, no programming. A great companion for tools like nautilus actions. Comments, suggestions, critics, bugs, fixes, etc are gladly welcome. -- Diego Torres Milano -- http://mail.python.org/mailman/listinfo/python-list
Re: function wrappers
On Oct 10, 11:39 am, Ramon Crehuet [EMAIL PROTECTED] wrote: Dear all, I have a Fortran programming background and I have some difficulties in understading how function wrappers work. I have delved into the subject because of the new decorators, but I understand the decorator syntax. My ignorance is more profound... Here is an example without decorators: Functions are first-class values: this means they can be passed around, used in expressions, and returned from other functions in just the same way that ints, floats and other more obvious types. All a decorator is a function that takes the function you give it, and returns a new function. In your 'require_int' example, it returns the nested function 'wrapper'. The clever bit is that 'wrapper' remembers the argument to the decorator - func - (with value p1 in your example), and can call it later. Think of the 'def' statement as constructing an object which happens to be a function. It has a dictionary which is used for variable lookup so that it can remember 'func'. The def statement also binds this function object to a name: the name of the function. You can see some of the gory details if you go: def f(): print 42 dir(f) ... list of attributes of the function object. -- Paul Hankin -- http://mail.python.org/mailman/listinfo/python-list
Re: Exceptions: Logging TB and local variables?
allen.fowler wrote: Hi, My code looks like this: for item in bigset: self.__sub1(item) self.__sub2(item) self.__sub3(item) # the subX functions, in turn, use various 3rd party modules. Now, I would like to do this: for item in bigset: try: self.__sub1(item) self.__sub2(item) self.__sub3(item) except StandardError: # Log error and continue to next item in set. log_error_to_file() In the error log, I would like to record various local variables that existed in subX at the time the Exception was thrown... (even though the actuall exception may have been thrown from deep inside some 3rd party module that subX called) How can I do this? Thank you, Allen Two possibilieies: You will need to determine ALL the exceptions that the 3rd party party modules can raise. If they are custom exceptions you will need to import them into your application from their modules. example: say that 3rd party modules raise TransientError, IOError, and ValueError exceptions. TransientError is a custom exception from module foo from foo import TransientError for item in bigset: try: self.__sub1(item) self.__sub2(item) self.__sub3(item) except (TransientError, IOError, ValueError): # Log error and continue to next item in set. log_error_to_file() 2) Hook exception traceback handler def myTraceBackHandler(type, value, tb): global variables I want to dump during traceback # # This function allows the user to redefine what happens if the program # aborts due to an uncaught exception. # This provides a way to get a partial session log if the program # abortsas well as some information about what caused the program to # abort. # import traceback # # Get traceback lines # tblines=traceback.format_exception(type, value, tb) # # Write some lines to log # log_error_to_file() # # Always write the exceptions to screen # sys.exit('\n'.join(tblines)) Hope this helps. -Larry -- http://mail.python.org/mailman/listinfo/python-list
Re: function wrappers
Ramon Crehuet wrote: def require_int(func): def wrapper(arg): assert isinstance(arg, int) return func(arg) return wrapper def p1(a): print a p2 = require_int(p1) My question is: why do p2 arguments become wrapper arguments? What is the flux of the arguments in the program when you pass functions as arguments? I suspect you don't understand that each time require_int is called a _new_ function named wrapper is created (and then returned). -Scott David Daniels Scott David [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet another comparison of Python Web Frameworks
Michele, At work we are shopping for a Web framework, so I have been looking at the available options on the current market. just because you were involved in creating an own version of Python does NOT free you from the social obligation to create your own Python web framework. So stop shopping and start announcing your own pwf like all other Python programmers do. Harald -- http://mail.python.org/mailman/listinfo/python-list
Re: Singleton
On Oct 10, 5:36 am, [EMAIL PROTECTED] wrote: Hi, I've been trying to get some sort of singleton working in python, but I struggle a bit and I thought I'd ask for advice. The first approach was simply to use a module, and every variable in it will be seen by all who import the module. That works in some cases, but not if I have the following structure: one/ __init__.py mod1.py run.py two/ __init__.py mod2.py run.py looks like this: #!/usr/bin/env python Well, here's your problem. Your main script is inside a package: that is what's causing the namespace difficulties you're seeing. I highly suggest you not do that. A better ideas is to create a small script in the project root that imports run.py, like this: #!/usr/bin/env python from one import run [continuing with run.py] import mod1 print mod1.number It's is only tangentially related to your problem, but this usage is deprecated. Importing a file in the same package using import modl instead of from one import mod1 is called an impicit relative import (well, actually in this case it isn't a relative import--more on that later-- but you seem to have intended it as a relative import). Implicit relative imports are scheduled to be removed from a future release of Python. You should use either an absolute import: from one import mod1 Or an explicit relative import in Python 2.5 or above: from . import mod1 See PEP 328. [continuing again with run.py] import two.mod2 print two.mod2.number mod1.py looks like this: import random number=random.randint(0,100) mod2.py looks like this import one.mod1 number = one.mod1.number PYTHONPATH is set to the directory containing the 'one' and 'two' directories. Now when I run the 'run.py', it will print two different numbers. sys.modules tells me that 'mod1' is imported as both 'one.mod1' and 'mod1', which explains the result. Here's the problem: the main script is NOT executed within the package one. A file's presence in a package directory is not sufficient for it to be part of the package: you actuatlly have to import the file through that package. When you ran run.py, the Python interpreter did not import the file via the one package. It loaded the file, compiled it, and ran it, but as a standalone file, not as part of a package. Then, when you imported mod1 from run.py, it only saw that mod1.py was a file in the same directory. So it imported it as a regular module, not a submodule of a package. Now, when mod2 imported mod1, it went through the package one to import it. Therefore, it considered mod1 to be part of the package one, and so imported it as a submodule of one. Looking at:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52558 I find a singleton class, but it has the same problem. If it's imported in two different ways, I have not a singleton but a ... 'doubleton' or something. It is possible to solve this by always importing with the complete path like 'one.mod1', even when inside the 'one' directory, but that's an error waiting to happen. I've been doing it for a few years; I haven't had a problem. If you're concerned, you can add from __future__ import absolute_imports to your files to catch any lapses. So how do people solve this? Is there an obvious way that I missed? I'm thankful for any advice you might provide. Just keep your main scripts out of the package directories and you'll be fine. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
cannot create python packages
Hi, i have the following files: current_dir/level1/Called.py current_dir/Caller.py Called.py: --- class Called: def exec1(self): print Hello Caller.py: -- from level1.Called import * c=Called() c.exec1() However it is impossible for Caller.py to find Called.py. I even tried to place the level1 structure inside /usr/lib/pythonX.Y/, whithout success however. Any ideas? Thnx ___ Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html -- http://mail.python.org/mailman/listinfo/python-list
Re: cannot create python packages
Try to put a empty file named __init__.py on current_dir/level1/On 10/10/07, Konstantinos Pachopoulos [EMAIL PROTECTED] wrote: Hi, i have the following files: current_dir/level1/Called.py current_dir/Caller.py Called.py: --- class Called: def exec1(self): print Hello Caller.py: -- from level1.Called import * c=Called() c.exec1() However it is impossible for Caller.py to find Called.py. I even tried to place the level1 structure inside /usr/lib/pythonX.Y/, whithout success however. Any ideas? Thnx ___ Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html -- http://mail.python.org/mailman/listinfo/python-list -- Rafael Sachetto Oliveira Sir - Simple Image Resizer http://rsachetto.googlepages.com -- http://mail.python.org/mailman/listinfo/python-list
Python on embedded system
hi, I'd like to reduce python and just compile this modules: Modulo 59 Nota Tecnica Rev.2 Data 01/03 !-- @page { size: 8.5in 11in; margin: 0.79in } P { margin-bottom: 0.08in } -- _main_ _buildin_ marshal imp sys os float md5 socket asyncore select thread threading time termios I set up the PYTHON_DISABLE_MODULES with _PYTHON_DISABLED_MODULES=readline pyexpat dbm gdbm bsddb \ _curses _curses_panel _tkinter nis zipfile _codecsmodule \ cryptmodule _randommodule grpmodule regexmodule parsermodule \ dbmodule glmodule pwdmodule gcmodule rgbimgmodule _heapqmodule \ imageop cPickle audioop multybytecodec and using the buildroot patch that disable modules. At the and I having a 12 Mb of stuff. I don't understand how to avoid the installation of a lot of not useful py file. It is possible to reduce the size of python enviroment? Regards Michael ___ L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail: http://it.docs.yahoo.com/nowyoucan.html-- http://mail.python.org/mailman/listinfo/python-list
Re: Unexpected behaviour with HTMLParser...
On 10/9/07, Just Another Victim of the Ambient Morality [EMAIL PROTECTED] wrote: Diez B. Roggisch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Without code, that's hard to determine. But you are aware of e.g. handle_entityref(name) handle_charref(ref) ? Actually, I am not aware of these methods but I will certainly look into them! I was hoping that the issue would be known or simple before I commited to posting code, something that is, to my chagrin, not easily done with my news client... For example, here's something simple/simplistic you can do to handle character and entity references: from htmlentitydefs import name2codepoint ... def handle_charref(self, ref): try: if ref.startswith('x'): char = unichr(int(ref[1:], 16)) else: char = unichr(int(ref)) except (TypeError, ValueError): char = ' ' # Do something with char def handle_entityref(self, ref): try: char = unichr(name2codepoint[ref]) except (KeyError, ValueError): char = ' ' # Do something with char A. -- http://mail.python.org/mailman/listinfo/python-list
Re: Singleton
Spring Python (http://springpython.python-hosting.com) offers a singleton solution. You can mark up function calls to only be called the first time, i.e. as singletons. The results are cached inside the Spring Python IoC container, so the next time the function is called, it returns the cached copy. Prototypes bypass the caching, and instead allow the function to be called everytime. This also support the idea of prototype functions contain references to singleton objects. from springpython.context import * class MyContainer(DecoratorBasedApplicationContext): def __init__(self): DecoratorBasedAppicationContext.__init__(self) @component(scope.SINGLETON) # You can leave off the argument, since scope.SINGLETON is the default) def singletonComponent(self): return [There can be only one!] @component(scope.PROTOTYPE): def prototypeComponent(self): return [I think I'm a clone now. There's another one of me always hangin' around!] if __name__ == __main__: appContext = MyContainer() obj1 = appContext.singletonComponent() obj2 = appContext.singletonComponent() if obj1 == obj2: print These are the same object else: print Something is wrong! obj3 = appContext.prototypeComponent() obj4 = appContext.prototypeComponent() if obj1 != obj2: print These are different instances of the function call. else: print These shouldn't be the same! See also http://springpython.python-hosting.com/wiki/InversionOfControl and http://springpython.python-hosting.com/wiki/DecoratorBasedApplicationContext. -- http://mail.python.org/mailman/listinfo/python-list
Re: Singleton
On Oct 10, 9:34 am, [EMAIL PROTECTED] wrote: Spring Python (http://springpython.python-hosting.com) offers a [snip spam] Too bad your bot can't be bothered to read the post it would have known the singleton wasn't the problem here. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Jython import coventions
On Oct 9, 10:42 pm, Benjamin [EMAIL PROTECTED] wrote: When importing Java packages in Jython, what is the convention to simplify imports? For example: import java.util as util Is this correct? Or should I use from * import *? I have preferred the style... import java import javax ...and then using complete references to java classes, in your case, java.util.whatever. It clearly shows me where I'm using Python classes vs. java classes when I read my own code. For this situation, more path structure seems less confusing to me. -- http://mail.python.org/mailman/listinfo/python-list
Re: Singleton
On Wed, 10 Oct 2007 09:36:56 +, pythoncurious wrote: So how do people solve this? Is there an obvious way that I missed? Mostly by avoiding singletons. Why do you need only one instance? Perhaps you should consider the Borg pattern instead. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531 -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: cannot create python packages
On 10 Ott, 15:01, Konstantinos Pachopoulos [EMAIL PROTECTED] wrote: Hi, i have the following files: current_dir/level1/Called.py current_dir/Caller.py Called.py: --- class Called: def exec1(self): print Hello Caller.py: -- from level1.Called import * c=Called() c.exec1() However it is impossible for Caller.py to find Called.py. I even tried to place the level1 structure inside /usr/lib/pythonX.Y/, whithout success however. Any ideas? Thnx ___ Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html I think you need a __init__.py file in level1 directory -- http://mail.python.org/mailman/listinfo/python-list
Re: NUCULAR fielded text searchable indexing
On Oct 10, 6:05 am, Paul Boddie [EMAIL PROTECTED] wrote: On 9 Okt, 22:32, [EMAIL PROTECTED] wrote: ...tell us how the [ http://nucular.sourceforge.net ] software compares to stuff like Lucene or Xapian... I wish I could, honestly. I've looked briefly into trying to put together some sort of comparisons, but I find the documentation for both the systems mentioned quite forbidding. I certainly don't want to spend as much time developing comparisons with other projects as I did developing nucular :). For the moment I will make the completely unbiased suggestion that nucular indices may be a lot easier to set up and use than either Lucene or Xapian, particularly from a Python programming perspective. It's also not immediately clear to me whether Xapian and Lucene support completely unrestricted numbers and combinations of fields, but I'm not sure. I'll see if I can come up with something better than that... As a side note, if you do benchmarks, please don't use the Lucene benchmark query taken from http://lucene.apache.org/java/docs/benchmarks.html namely, Query: +Domain:sos +(+((Name:goo*^2.0 Name:plan*^2.0) (Teaser:goo* Tea ser:plan*) (Details:goo* Details:plan*)) -Cancel:y) +DisplayStartDate: [mkwsw2jk0 -mq3dj1uq0] +EndDate:[mq3dj1uq0-ntlxuggw0] Because I expect nucular will perform very poorly on this query (since it can't even implement it). I put a set of query features that I thought was suitable for most purposes into nucular. Others may appear in later releases, but the one's that are there cover the most common needs, I think. I would prefer benchmarks that compared simple common examples, not obscure complicated ones. -- Aaron Watters === if you want a friend, get a dog. -- Truman -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet another comparison of Python Web Frameworks
On Oct 9, 11:57 pm, [EMAIL PROTECTED] wrote: Since you are starting a new project you may want to look into something new and different http://mdp.cti.depaul.edu/examples This is actually a neat framework! I'm a somewhat of fan of web- frameworks and I used most major ones and I like to poke around. Here is a mini review: Gluon seems to be modeled with the web.py mentality, everything in one package, very simple but covering all essentials templating, database, sessions and server. It reminds me of a content management system, you start with a working server, then you add your components to it. It also implements a Zope-like through-the-web interaction, everything can be modified in the administration interface, templates, databases, code, media. This sort of functionality is sometimes frowned upon but can be a very convenient way to make small changes. Honestly the framework field is a bit crowded so it is an uphill battle to get a framework accepted, but it is nice to see something different. i. ps. fix the typos in the docs and get people's names right, it makes a bad impression otherwise -- http://mail.python.org/mailman/listinfo/python-list
Re: Symbolic Link
On Sep 9, 10:05 pm, Lawrence D'Oliveiro [EMAIL PROTECTED] central.gen.new_zealand wrote: In message [EMAIL PROTECTED],samwysewrote: A hard-link, OTOH, allows direct access to the contents of a file, as long as it is on the same filesystem. No extra steps are required, so the process runs a few microseconds faster, and directory-level permissions can't get in the way. Hard links are best avoided, because of the confusion they can cause. There are reasons to use hard links, there are reasons to use symbolic links. Depending on the circumstances, either could cause confusion simply because either could do something other than what's needed. Here's a handy chart to help decide which is appropriate: http://publib.boulder.ibm.com/iseries/v5r1/ic2924/index.htm?info/ifs/rzaaxmstlinkcmp.htm -- http://mail.python.org/mailman/listinfo/python-list
Re: Singleton
On Oct 10, 9:39 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Wed, 10 Oct 2007 09:36:56 +, pythoncurious wrote: So how do people solve this? Is there an obvious way that I missed? Mostly by avoiding singletons. Why do you need only one instance? Perhaps you should consider the Borg pattern instead. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531 That wouldn't help. In the OP's case, it would create two borgs. Did anyone actually read the OP's post? Or is this just an opportunity to pimp libraries and bicker about style? Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: struct.unpack less than 1 byte
On Wed, 10 Oct 2007 03:42:15 -0700, John Machin wrote: On Oct 10, 8:15 pm, Guilherme Polo [EMAIL PROTECTED] wrote: 2007/10/10, cprogrammer [EMAIL PROTECTED]: i need to read from a file a struct like this [1byte, 12bits, 12bits] reading 1 byte or more is not a problem ... but the 12 bits values are ... 12bits, 12bits == 3 byes and 8 + 12 + 12 = 32 :-) [snipped bitfiddling] Or, if you're doing more of those parsing tasks (or just dislike bit shifting), you could have a look into `construct`_:: from construct import * foo = BitStruct(foo, ... Octet(spam), # synonym for BitField(spam, 8) ... BitField(ham, 12), ... BitField(eggs, 12) ... ) foo Buffered('foo') foo.parse(\xff\xff\xff\xff) Container(eggs = 4095, ham = 4095, spam = 255) Cheers, Stargaming .. _construct: http://construct.wikispaces.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Singleton
[EMAIL PROTECTED] writes: Now when I run the 'run.py', it will print two different numbers. sys.modules tells me that 'mod1' is imported as both 'one.mod1' and 'mod1', which explains the result. If I were you, I'd make sure that the module duplicate problem is resolved first, for example by putting run.py somewhere outside one/. Then the singleton problem disappears as well. It is possible to solve this by always importing with the complete path like 'one.mod1', even when inside the 'one' directory, but that's an error waiting to happen. Is it, really? As far as I can tell, Python handles that case rather robustly. For example: $ mkdir one $ touch one/__init__.py $ touch one/mod1.py one/mod2.py $ echo 'import mod2' one/mod1.py $ python 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. import one.mod1 import sys sorted(sys.modules) ['UserDict', '__builtin__', '__main__', '_codecs', '_sre', '_types', 'codecs', 'copy_reg', 'encodings', 'encodings.aliases', 'encodings.codecs', 'encodings.encodings', 'encodings.types', 'encodings.utf_8', 'exceptions', 'linecache', 'one', 'one.mod1', 'one.mod2', 'os', 'os.path', 'posix', 'posixpath', 're', 'readline', 'rlcompleter', 'signal', 'site', 'sre_compile', 'sre_constants', 'sre_parse', 'stat', 'sys', 'types', 'warnings', 'zipimport'] Although mod1 imports mod2 simply with import mod2, the fact that mod1 itself is imported as part of one is respected. As a result, mod2 is imported as one.mod2, exactly as if it were imported from outside the one package. run.py is an exception because it is started directly using python run.py, so it never gets the information that it's supposed to be part of a package. To fix the problem, all you need to do is make sure that executable scripts such as run.py are either placed safely outside the package, or that they take care to always use absolute imports, such as import one.mod1 instead of import mod1. Placing them outside the package is a good example of preventing an error waiting to happen, like the one you hinted at. -- http://mail.python.org/mailman/listinfo/python-list
Building Binary Packages
I am trying to figure out how to build binaries for Python packages and I've done it with MinGW. However, in my research, I've noticed that some of the programmers out there think that you should use the compiler that is used to compile the official Python distributions, which appears to be Visual Studio 2003. None of these programmers has really given their reasons for this though. Does compiling with a different compiler introduce subtle issues of some sort? If so, what are they (in general)? If you don't use VS2003, what compiler do you use? Here are the some links to what I've been reading: http://boodebr.org/main/python/build-windows-extensions http://www.z3lab.org/sections/blogs/philipp-weitershausen/2007_07_26_cheap-binary-windows http://www.gooli.org/blog/building-m2crypto-on-windows/ Thank you for your time. Mike -- http://mail.python.org/mailman/listinfo/python-list
Version specific or not?
We have an app and I'm trying to decide where the app should be installed. The question is whether it should be site-specific or not, as in /usr/lib/python2.3/site-packages or /usr/lib/site-python The latter would solve a lot of problems for me. In the case of emacs, most stuff seems to go into $EMACS/site-lisp and far less into $EMACS/$current_version/site-lisp. The python site dirs seem to be the opposite. We have lots of stuff in the 2.3/site-packages and very little in the site-python directory. If there are multiple versions of python installed on the same machine, having a shebang that just looked for /usr/bin/python would make my life a lot easier. * Since we distribute .pyo files, is there an issue if the .pyo was built with 2.3.5 and then executed by 2.4 or 2.5? * Are there any caveats? TIA -- Time flies like the wind. Fruit flies like a banana. Stranger things have .0. happened but none stranger than this. Does your driver's license say Organ ..0 Donor?Black holes are where God divided by zero. Listen to me! We are all- 000 individuals! What if this weren't a hypothetical question? steveo at syslang.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem of Readability of Python
On Oct 8, 4:24 am, [EMAIL PROTECTED] (Alex Martelli) wrote: Licheng Fang [EMAIL PROTECTED] wrote: ... Python Tutorial says an empty class can be used to do this. But if namespaces are implemented as dicts, wouldn't it incur much overhead if one defines empty classes as such for some very frequently used data structures of the program? Just measure: $ python -mtimeit -s'class A(object):pass' -s'a=A()' 'a.zop=23' 100 loops, best of 3: 0.241 usec per loop $ python -mtimeit -s'a=[None]' 'a[0]=23' 1000 loops, best of 3: 0.156 usec per loop So, the difference, on my 18-months-old laptop, is about 85 nanoseconds per write-access; if you have a million such accesses in a typical run of your program, it will slow the program down by about 85 milliseconds. Is that much overhead? If your program does nothing else except those accesses, maybe, but then why are your writing that program AT ALL?-) And yes, you CAN save about 1/3 of those 85 nanoseconds by having '__slots__=[zop]' in your class A(object)... but that's the kind of thing one normally does only to tiny parts of one's program that have been identified by profiling as dramatic bottlenecks, to shave off the last few nanoseconds in the very last stages of micro-optimization of a program that's ALMOST, but not QUITE, fast enough... knowing about such extreme last-ditch optimization tricks is of very doubtful value (and I think I'm qualified to say that, since I _do_ know many of them...:-). There ARE important performance things to know about Python, but those worth a few nanoseconds don't matter much. Alex This is enlightening. Surely I shouldn't have worried too much about performance before doing some measurement. -- http://mail.python.org/mailman/listinfo/python-list
Re: Fwd: NUCULAR fielded text searchable indexing
On 2007-10-09, Bill Hamilton [EMAIL PROTECTED] wrote: On 10/9/07, Grant Edwards [EMAIL PROTECTED] wrote: On 2007-10-09, Robin Becker [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: On Oct 9, 8:46 am, Istvan Albert [EMAIL PROTECTED] wrote: ps. there is a python project named The Devil Framework, I cringe every time I hear about it.Nucularis not as bad, but it is close. Aw shucks. I thought it was funny. Can't I make fun of politicians in my open source projects? Besides there is a great tradition of tounge-in-cheek package names, like Cold fusion, for example. ... I think it's an excellent name :) And Bush would probably pronounce it Nuke-lee-ur. I dislike Bush as much as the next guy, but could we please keep politics off the group? I say, it's a joke, son! And there's nothing political about it. The joke is predicated on the incongruity between the superficial logic of the statement and reality. The superficial part is the assumption that somebody who swaps two syllables when pronouncing a word will swap them back when the word is _spelled_ with them swapped. The reality is that's not they way language processing works the human brain. There's also some incongruity in the assumption that George Bush would be discussing an obscure Python library. OK, it wasn't _that_ funny, but there wasn't anything even remotely political about it. I just needed somebody who is widely know to mis-pronounce nuclear as nuke-you-lar. Jimmy Carter would have worked just as well -- a little better, actually, since he graduated from the Nuclear Engineering program at the US Naval Acadamy, and the mere fact that he mispronounces nuclear is sort of incongruous. But, there probably aren't that many people who remember how Jimmy Carter pronounced the work nuclear, or that he had a degree in nuclear engineering. Anyway, I apologize for my attempt at humor, since it appears to have somehow offended. -- Grant Edwards grante Yow! The Osmonds! You are at all Osmonds!! Throwing up visi.comon a freeway at dawn!!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet another comparison of Python Web Frameworks
On Oct 10, 5:57 am, [EMAIL PROTECTED] wrote: Since you are starting a new project you may want to look into something new and different http://mdp.cti.depaul.edu/examples Requiring Python 2.5 may not be a good idea for the time being. For instance, I am forced to use Python 2.4 because of some C libraries I need, so I cannot even consider a framework based on Python 2.5 for the moment :-( Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
ANN: Pyrex 0.9.6.2
Pyrex 0.9.6.2 is now available: http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/ Another couple of minor fixes. What is Pyrex? -- Pyrex is a language for writing Python extension modules. It lets you freely mix operations on Python and C data, with all Python reference counting and error checking handled automatically. -- http://mail.python.org/mailman/listinfo/python-list
RE: Fwd: NUCULAR fielded text searchable indexing
From: Grant Edwards Anyway, I apologize for my attempt at humor, since it appears to have somehow offended. Why apologize? If someone doesn't like the name given to a piece of software by its author(s), screw them. If I find the software useful, I'll use it. Even if its called 'bouncingBetty'. Actually, I might try it, just because of the name, but you get my point. The information contained in this message and any attachment may be proprietary, confidential, and privileged or subject to the work product doctrine and thus protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify me immediately by replying to this message and deleting it and all copies and backups thereof. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
multimethods decorator
Hi all. Im reading the Gido's aproach using decorators at http://www.artima.com/weblogs/viewpost.jsp?thread=101605 It looks good to me, but the examples shows the functionality using functions. Now, when i try to give this decorator into a method, if i try the class test(object): @multimethod(...) def met(self, ...): The multimethod decorator needs the types of the arguments, and, if the met method requires self as the first argument, the multimethod should look like @multimethod(self.__class__, bla, ble) or some like that... Now i know that im wrong, because i have this error @multimethod(self.__class__) NameError: name 'self' is not defined So what would be the first argument to @multimethod?? Thanks!! Gerardo -- http://mail.python.org/mailman/listinfo/python-list
a good website for softwares,movies and music etc.
www.space666.com a good website for softwares,movies and music,sex etc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Singleton
On Wed, 10 Oct 2007 06:57:15 -0700, Carl Banks wrote: On Oct 10, 9:39 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Wed, 10 Oct 2007 09:36:56 +, pythoncurious wrote: So how do people solve this? Is there an obvious way that I missed? Mostly by avoiding singletons. Why do you need only one instance? Perhaps you should consider the Borg pattern instead. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531 That wouldn't help. In the OP's case, it would create two borgs. Two borgs, or two million, the whole point of using borgs is that it doesn't matter. Did anyone actually read the OP's post? Or is this just an opportunity to pimp libraries and bicker about style? Well, let's see now... the OP says: I've been trying to get some sort of singleton working in python, but I struggle a bit and I thought I'd ask for advice. If we take each word to have it's normal English meaning, then the OP is struggling to get a singleton working correctly in Python. The way I solve that problem is to deftly side-step it by not using a singleton. (Doctor, it hurts when I do this. Then don't do it.) Of course, if there is some other meaning to the OP's post, then possibly I've completely misunderstood it. Would you mind telling me what you've seen that the rest of us haven't? -- Steven. -- http://mail.python.org/mailman/listinfo/python-list
Re: unpickle from URL problem
Marc 'BlackJack' Rintsch wrote: Pickles are *binary* files, not text files Actually not: http://docs.python.org/lib/node316.html These were created with protocol 0. But my question is about the different outcomes I observed. Thank you, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
Re: unpickle from URL problem
Jean-Paul Calderone wrote: You shouldn't unpickle things you get from the network, since pickle can execute arbitrary code: http://jcalderone.livejournal.com/15864.html Yes, but I have my reasons. (This is not library code: I just want students to all be using the same objects for an exercise, and I need not to worry about their directory structure.) Can you explain the differences I see? Thank you, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
Re: Singleton
Steven D'Aprano wrote: On Wed, 10 Oct 2007 06:57:15 -0700, Carl Banks wrote: On Oct 10, 9:39 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: On Wed, 10 Oct 2007 09:36:56 +, pythoncurious wrote: So how do people solve this? Is there an obvious way that I missed? Mostly by avoiding singletons. Why do you need only one instance? Perhaps you should consider the Borg pattern instead. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531 That wouldn't help. In the OP's case, it would create two borgs. Two borgs, or two million, the whole point of using borgs is that it doesn't matter. It does matter where the classes live (module-wise). Which is the problem the OP had, borg or not to borg. class Borg(object): __shared_state = {} def __init__(self): self.__dict__ = self.__shared_state if __name__ == __main__: import test mainBorg = Borg() mainBorg.a = 100 testBorg = test.Borg() testBorg.a = 200 print mainBorg.a print testBorg.a Run this as this: [EMAIL PROTECTED]:/tmp$ ll *py -rw-r--r-- 1 droggisch 298 2007-10-10 17:30 test.py [EMAIL PROTECTED]:/tmp$ python test.py 100 200 You will see that there are _two_ different Borg-Cubes, as the output indicates. This has hit me more than once, and Carl Banks pointed that error out to the OP. And if you'd follow your own advice of take each word to have it's normal English meaning, then the OP is not struggling to get a singleton working but struggling to get some sort of singleton working, as you cite yourself, and first tried to implement his needs using no singleton-recipe (or borg pattern) but a module: The first approach was simply to use a module, and every variable in it will be seen by all who import the module. That works in some cases, but not if I have the following structure: Which didn't work out for the same reason his singleton approach didn't work and your beloved Borg-pattern doesn't as well. Diez -- http://mail.python.org/mailman/listinfo/python-list
How do I make urllib2 preserve case in HTTP header names?
The HTTP specification, RFC 2616, states that field names in HTTP headers are case insensitive. But I'm trying to use Python 2.5.1's urllib2 to interact with a web service offered by Amazon.com, which deviates from the HTTP spec in that it requires use of case-sensitive header names ReportName, ReportID, and NumberOfReports. I try to send an HTTP header named NumberOfReports, but it comes out mangled as Numberofreports'. What is the best way to use Python 2.5.1 on Windows Server 2003 to create HTTP or HTTPS requests that do not mangle the case of header field names? Test case follows: == To see how Python breaks the CaseSensitiveName, go to command prompt and start netcat listening on the HTTP port: nc -l -p 80 localhost Then run this program on the same machine. You will see that CaseSensitiveName has become Casesensitivename. import urllib2 req = urllib2.Request(http://localhost/;, ) req.add_header('CaseSensitiveName', 'CaseSensitiveValue') infp = urllib2.urlopen(req) data = infp.read() infp.close() print data -- http://mail.python.org/mailman/listinfo/python-list
Re: unpickle from URL problem
Alan Isaac [EMAIL PROTECTED] writes: I upload to a server. I try to unpickle from the URL. No luck. Try it: x1, x2 = pickle.load(urllib.urlopen('http://www.american.edu/econ/notes/hw/example1')) I change the filetype to unix. I upload again. I try to unpickle from the URL. Now it works. Try it: x1, x2 = pickle.load(urllib.urlopen('http://www.american.edu/econ/notes/hw/example2')) Why the difference? The first upload breaks the file. You uploaded it in (presumably FTP's) text mode, which changes \n - \r\n. But you download it using http, which specifies no such conversion in the opposite direction. It is true that the lowest pickle protocol is textual in nature, but it just means that you can open a file in text mode, write the pickle into the file, and reliably read it back on the same platform. The newlines will be converted to the platform newline representation (such as \r\n on Windows or \r on Mac) upon write, and back to the original single-byte (\n) representation upon read. But if you feed the unpickler a string that already contains \r\n, there is nothing to convert it back to \n. -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] Data Plotting Library DISLIN 9.2
Thanks! I play with this library, for fun ; with success. -- http://mail.python.org/mailman/listinfo/python-list
Re: why did MIT drop scheme for python in intro to computing?
Grant Edwards [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 2007-10-09, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Does scheme have a gui library? Yes. It had a far, far better Tk binding than Python. http://kaolin.unice.fr/STk/ I've used both for real-world applications, and STk was _miles_ ahead of tkinter. It was a real, native binding to the Tk library rather than something stuck together with TCL. GUI widgets were real Scheme objects that acted the way one expected them to, rather than wrapped TCL objects. However, Tk has been largely abandoned in favor of a native GTK+ binding http://www.stklos.org/ -- Grant Edwards grante Yow! You should all JUMP at UP AND DOWN for TWO HOURS visi.comwhile I decide on a NEW CAREER!! I couldn't find any documentation on stklos (other than a few examples) regarding its gtk+ binding. Could you please point me to appropriate link? thanks in advance, Ashish K Hanwadikar http://ashish.typepad.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: unit testing
[EMAIL PROTECTED] wrote: I maintain old code... code written a long time ago, before unittest was popular. Getting unittest to work on that is difficult at best. Writing unit tests for lots of old code is not the most funny thing you can imagine... For situations like that, it might be much better to use a tool like TextTest http://texttest.carmen.se/ . -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem of Readability of Python
Am I missing something, or am I the only one who explicitly declares structs in python? For example: FileObject = { filename : None, path : None, } fobj = FileObject.copy() fobj[filename] = passwd fobj[path] = /etc/ Kevin Kelley On 10/7/07, Licheng Fang [EMAIL PROTECTED] wrote: Python is supposed to be readable, but after programming in Python for a while I find my Python programs can be more obfuscated than their C/C ++ counterparts sometimes. Part of the reason is that with heterogeneous lists/tuples at hand, I tend to stuff many things into the list and *assume* a structure of the list or tuple, instead of declaring them explicitly as one will do with C structs. So, what used to be struct nameval { char * name; int val; } a; a.name = ... a.val = ... becomes cryptic a[0] = ... a[1] = ... Python Tutorial says an empty class can be used to do this. But if namespaces are implemented as dicts, wouldn't it incur much overhead if one defines empty classes as such for some very frequently used data structures of the program? Any elegant solutions? -- http://mail.python.org/mailman/listinfo/python-list -- Kevin Kelley http://technogeek.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet another comparison of Python Web Frameworks
On Oct 10, 5:57 am, [EMAIL PROTECTED] wrote: Since you are starting a new project you may want to look into something new and different http://mdp.cti.depaul.edu/examples The delivered sourcecode is syntactically broken. Tabs and whitespaces were mixed and when I open a file like gluon/global.py I find sections like this: class Request(Storage): defines the request object and the default values of its members def __init__(self): self.env=Storage() # this line is incorrect syntax in Python self.cookies=Storage() self.get_vars=Storage() Moreover there aren't any indications that the code was tested. Kay -- http://mail.python.org/mailman/listinfo/python-list
EasyMock for python ?
Hi, Does anybody know where to find a library like EasyMock for python ? I searched quickly but could not find anything. I found python-mocks on sourceforge but form quickly reading the docs, it is not an EasyMock style mock. Actually, according to http://martinfowler.com/articles/mocksArentStubs.html I don't think it is even a mock library. More a stub. Philippe -- http://mail.python.org/mailman/listinfo/python-list
Re: Singleton
On Oct 10, 11:18 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: Of course, if there is some other meaning to the OP's post, then possibly I've completely misunderstood it. Would you mind telling me what you've seen that the rest of us haven't? I read far enough to see that OP had mischaracterized the problem and that it wasn't a problem with singletons at all; it was a problem with importing. And that it would still manifiest itself with borgs. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Building Binary Packages
On Wed, 10 Oct 2007 14:35:35 +, kyosohma wrote: I am trying to figure out how to build binaries for Python packages and I've done it with MinGW. Apparently, you still can: http://tinyurl.com/yb4bps -- http://mail.python.org/mailman/listinfo/python-list
Re: unpickle from URL problem
Hrvoje Niksic wrote: The first upload breaks the file. You uploaded it in (presumably FTP's) text mode, which changes \n - \r\n. But you download it using http, which specifies no such conversion in the opposite direction. No: I used binary upload both time. (Unless my ftp client is broken, and I think not.) The first example simply keeps the Windows eols, which are present in the pickled file on my Windows machine. This is the one created by pickle.dump. This file unpickles just fine. I altered the 2nd file before upload, changing to the Unix eol convention. This also unpickles just fine on my machine, but in addition the urllib download of this file unpickles just fine. Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
Re: [Tutor] matching a street address with regular expressions
On 10/4/07, Ricardo Aráoz [EMAIL PROTECTED] wrote: Christopher Spears wrote: One of the exercises in Core Python Programming is to create a regular expression that will match a street address. Here is one of my attempts. street = 1180 Bordeaux Drive patt = \d+ \w+ import re m = re.match(patt, street) if m is not None: m.group() ... '1180 Bordeaux' Obviously, I can just create a pattern \d+ \w+ \w+. However, the pattern would be useless if I had a street name like 3120 De la Cruz Boulevard. Any hints? Also, that pattern can be easily modified to have any number of words at the end: patt = \d+ (\w+){1,} This would take care of 3120 De la Cruz Boulevard. -- http://mail.python.org/mailman/listinfo/python-list
Re: unpickle from URL problem
On Wed, 10 Oct 2007 15:21:06 +, Alan Isaac wrote: Marc 'BlackJack' Rintsch wrote: Pickles are *binary* files, not text files Actually not: http://docs.python.org/lib/node316.html These were created with protocol 0. Actually yes, the docs are wrong. It's a binary file with bytes constraint to ASCII values. Nevertheless it breaks if you don't open the files in binary mode and try to use it on a platform that treats line endings differently. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: multimethods decorator
Gerardo Herzig a écrit : Hi all. Im reading the Gido's aproach using decorators at http://www.artima.com/weblogs/viewpost.jsp?thread=101605 It looks good to me, but the examples shows the functionality using functions. Now, when i try to give this decorator into a method, if i try the class test(object): @multimethod(...) def met(self, ...): The multimethod decorator needs the types of the arguments, and, if the met method requires self as the first argument, the multimethod should look like @multimethod(self.__class__, bla, ble) or some like that... Now i know that im wrong, because i have this error @multimethod(self.__class__) NameError: name 'self' is not defined Indeed. Neither self (which will only be known at method call time) nor even the 'test' class (which is not yet defined when the decorator is executed) are availables. So what would be the first argument to @multimethod?? A string ?-) FWIW, there's already an implementation of multiple dispacth by Mr. Eby... -- http://mail.python.org/mailman/listinfo/python-list
Re: M2Crypto possible intermittent bug
John Nagle wrote: I just upgraded from M2Crypto 0.17 to M2Crypto 0.18, and I'm running my regression tests. I'm seeing occasional cases where M2Crypto raises the exception SSL.SSLError, and the associated error is (0, 'Error'), which is the bogus error you get if you feed 0 to perror. It failed once on verisign.com's cert, then worked on the next try. This is on Windows, running Python 2.4 (which is what M2Crypto supports on Windows.) I'm trying to make this reproduceable. More later. John Nagle Still trying to reproduce this. Every time except the first, the regression test passed. More later. Might be an uninitialized variable in a DLL, or something like that. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: function wrappers
Scott David Daniels a écrit : Ramon Crehuet wrote: def require_int(func): def wrapper(arg): assert isinstance(arg, int) return func(arg) return wrapper def p1(a): print a p2 = require_int(p1) My question is: why do p2 arguments become wrapper arguments? What is the flux of the arguments in the program when you pass functions as arguments? I suspect you don't understand that each time require_int is called a _new_ function named wrapper is created which remembers the 'environnement' in which it was defined - this is known as a 'closure'. (and then returned). And when this wrapper function is called (instead of the original), it receives the arg, test it, and if approriate delegate call to the original (wrapped) function. Another way (perhaps easier to understand if you don't have any experience with higher order functions and other functional programming idioms) to get the same result would be: class require_int(object): def __init__(self, func): self._func = func def __call__(self, arg): assert isinstance(arg, int) return self._func(arg) -- http://mail.python.org/mailman/listinfo/python-list
Is hostmonster any good for hosting python?
According to hostmonster's list of features, they do support python. Does anybody have any experience with hostmonster? -- http://mail.python.org/mailman/listinfo/python-list
FastCGI on Windows: socket.fromfd() support?
Microsoft's IIS server recently added native support for FastCGI. The big roadblock to Python support seems to be that socket.fromfd() doesn't work on Windows. Are there any plans to add this or similar functionality to the Windows build? Thanks, Drew -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem of Readability of Python
Kevin wrote: Am I missing something, or am I the only one who explicitly declares structs in python? For example: FileObject = { filename : None, path : None, } fobj = FileObject.copy() fobj[filename] = passwd fobj[path] = /etc/ Yes, I think this is the only time I've ever seen that. I think the normal way of doing this in Python is: class FileObject(object): def __init__(self, filename, path): self.filename = filename self.path = path fobj = FileObject(filename='passwd', path='etc') STeVe -- http://mail.python.org/mailman/listinfo/python-list
Re: Yet another comparison of Python Web Frameworks
Kay Schluehr wrote: http://mdp.cti.depaul.edu/examples The delivered sourcecode is syntactically broken. Tabs and whitespaces were mixed and when I open a file like gluon/global.py I find sections like this: class Request(Storage): defines the request object and the default values of its members def __init__(self): self.env=Storage() # this line is incorrect syntax in Python You may have configured your editor to use a tabwidth of four spaces (Python always uses 8). Peter -- http://mail.python.org/mailman/listinfo/python-list