Pyro 4.1 released
Pyro 4.1 - I'm pleased to announce the release of Pyro 4.1! Detailed info here: http://www.razorvine.net/python/Pyro (a page about migration from Pyro 3.x is included) Download Pyro 4.1 here: http://www.xs4all.nl/~irmen/pyro4/download/ License: MIT software license. What is Pyro? - PYthon Remote Objects provides a very easy way of remote communication between python objects somewhere in a network. It enables you to do remote method calls on objects as if they were normal local objects. Objects can be located by a direct identifier or indirectly by logical, humanly-readable names that are managed in a name server. Pyro is designed to be simple (but powerful) so it's only a manner of adding a few lines of code to ignite your objects. Simple example: http://www.razorvine.net/python/Pyro/Example Changes --- The most important changes compared to Pyro 4.0 are: - socketserver now also implements handleRequests for external event loops - external event loop has been changed slightly, see the updated eventloop example for usage example - threadpool server now has a pool of worker threads that grows/shrinks as needed, between configurable limits - added @Pyro.callback decorator to be able to raise callback exceptions locally as well as on the caller side. Enjoy, Irmen de Jong -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Pydev 1.5.8 Released
Hi All, Pydev 1.5.8 has been released Details on Pydev: http://pydev.org Details on its development: http://pydev.blogspot.com Release Highlights: --- * Features only available on Aptana Studio 3 (Beta): * Theming support provided by Aptana Studio used * Find bar provided by Aptana used (instead of the default find/replace dialog) * Aptana App Explorer provides Pydev nodes * Eclipse: * Eclipse 3.6 is now supported * Pydev Jars are now signed * Django: * DoesNotExist and MultipleObjectsReturned recognized in Django * Added option to make the name of Django models,views,tests editors work as regular editors while still changing the icon * Run/Debug: * Ctrl+Shift+B properly working to toggle breakpoint * If file is not found in debugger, only warn once (and properly cache the return) * Run configuration menus: Only showing the ones that have an available interpreter configured * Outline/Pydev Package Explorer: * Fixed sorting issue in pydev package explorer when comparing elements from the python model with elements from the eclipse resource model * Fixed issue when the 'go into' was used in the pydev package explorer (refresh was not automatic) * Added decoration to class attributes * Added node identifying if __name__ == '__main__' * General: * Properly working with editor names when the path would be the same for different editors * Fixed issue where aptanavfs appeared in the title for aptana remote files * Fixed halting condition * Not always applying completion of dot in interactive console on context-insensitive completions * Home key properly handled in compare editor * Interactive console working with pickle * String substitution configuration in interpreter properly works * On import completions, full module names are not shown anymore, only the next submodule alternative What is PyDev? --- PyDev is a plugin that enables users to use Eclipse for Python, Jython and IronPython development -- making Eclipse a first class Python IDE -- It comes with many goodies such as code completion, syntax highlighting, syntax analysis, refactor, debug and many others. Cheers, -- Fabio Zadrozny -- Software Developer Aptana http://aptana.com/ Pydev - Python Development Environment for Eclipse http://pydev.org http://pydev.blogspot.com -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Python dynamic attribute creation
On 6/27/10 10:10 PM, Carl Banks wrote: On Jun 27, 3:49 am, Bruno Desthuilliers bdesth.quelquech...@free.quelquepart.fr wrote: WANG Cong a écrit : On 06/26/10 00:11, Neil Hodgsonnyamatongwe+thun...@gmail.com wrote: WANG Cong: 4) Also, this will _somewhat_ violate the OOP princples, in OOP, this is and should be implemented by inherence. Most object oriented programming languages starting with Smalltalk have allowed adding attributes (addInstVarName) to classes at runtime. Thanks, I have to admit that I know nothing about Smalltalk. Then you really don't know much about OO. I don't really know much about Smalltalk either. Same. I've been informed that I find Objective-C rather comfortable and strangely Pythonic because its object model is based in Smalltalk, and although Python's a step or two farther removed (what with not embedding smalltalkish directly into another language), is as well. I don't think one needs to know Smalltalk to know much about OO. One might need to know Smalltalk to understand the history and perhaps some rationale of OO, _maybe_, but at this point-- the pure theory of OOP is taught and discussed far and wide entirely outside of the context of Smalltalk. Smalltalk may have originated it and may be one of the purest forms of the concept, but... To say you can't really know much about OOP without knowing much about Smalltalk seems basically, well, wrong. -- ... Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -- http://mail.python.org/mailman/listinfo/python-list
Extension modules and common routines in Python/C API
Hi, folks! I'm writing wrapper for C library. This library consist of several parts. And i want split my extension package into different extension modules. I think, this is the right way ;-) But, there are some common parts that exist in extension package, get_library_version, Error, and so on. I've decided to create additional module, named core, where these routines and variables are defined. And when get_library_version, for example, is used by programmer, Error, in opposite, is used by routines in another modules. As i mentioned in ( above mail), i use create_error for adding new exception class with neccessary fields. Now i call create_error in initcore function, which initialize core module. But, if i don't import package.core, and only import package.module, when package.module.function fails, python's runtime throws error: SystemError: error return without exception set because, Error is not properly initialize in that point. And, if i add: if(!Error) create_error(); in init functions of all my modules, create_error runs several times (for each imported module). I think, i get a different Error every time. I can't check this because of above issue. So, my questions is: how can i organize this pattern? Should i add import package.core in __init__.py in package dir? Or should i create subclass exception of Error in every module? What is the right and pythonic way for doing that? :) Thanks! (crosspost from http://stackoverflow.com/questions/3119026/extension-modules-and-common-routines-in-python-c-api ) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
On Sun, Jun 27, 2010 at 6:49 AM, Bruno Desthuilliers bdesth.quelquech...@free.quelquepart.fr wrote: WANG Cong a écrit : On 06/26/10 00:11, Neil Hodgson nyamatongwe+thun...@gmail.com wrote: WANG Cong: 4) Also, this will _somewhat_ violate the OOP princples, in OOP, this is and should be implemented by inherence. Most object oriented programming languages starting with Smalltalk have allowed adding attributes (addInstVarName) to classes at runtime. Thanks, I have to admit that I know nothing about Smalltalk. Then you really don't know much about OO. Guess I don't know much about OO then, despite having written OO code for at least the last ten years... Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list
Re: 回复: I wander which is better? JSP or Pytho n? And is there a place for JSP?
-- 原始邮件 -- 发件人: Chris Rebertc...@rebertia.com; 发送时间: 2010年6月28日(星期一) 中午1:09 收件人: Rogerrogerda...@gmail.com; 主题: Re: I wander which is better? JSP or Python? And is there a place for JSP? On Sun, Jun 27, 2010 at 9:49 PM, Roger rogerda...@gmail.com wrote: As I plan to study JSP, I find it extremly complicated and a part of J2EE. I did not attend to get the whole of J2EE. I hope anybody can describe the future of JSP. Is there a place for JSP? This is python-list/comp.lang.python; we discuss the **Python** programming language and related topics here. Your question is about **Java** and has nothing to do with Python. 2010/6/27 rogerdai16 rogerda...@gmail.com Subject: I wander which is better? JSP or Python? And is there a place for JSP? Oh, sorry. I was just to make a comparison between Python and JSP.Will Python take the place of JSP? Ah, my apologies, I neglected to notice your post's Subject, which is where you establish the relation to Python. (I hate it when people put critical info in the Subject but don't explicitly mention this in the message body...) You're asking for a very apples-and-oranges comparison. Python is an entire general-purpose programming language (as is Java), whereas JSP is (approximately) a Java web templating technology, something much more specific. So, could Python /itself/ replace JSP? No, of course not; like I said, apples and oranges. Python Server Pages (http://en.wikipedia.org/wiki/Python_Server_Pages ) vs. JSP would be a more apt comparison. However, PSP per se doesn't seem to be used much. Also, drop-in replacing JSP with PSP or similar would involve extra complexity in trying to integrate the two languages together, and thus probably not be worth the trouble (although Jython might remedy this somewhat). So, zooming out further in order to move towards more sensible comparisons: Can Python replace Java in web applications? Yes, surely. Many significant, successful web applications have been written in Python using various Python web frameworks (e.g. Django), which often include their own Python-based templating system. Is it a good idea to port something from Java to Python just for the sake of using Python? Probably not; if it ain't broke, don't fix it (though that's not to say don't refactor it). Zooming out even further, hopefully to the level of question you meant to ask: Could/Will Python displace Java (and thus JSP) for web programming? Who can say? It would be something of a religious debate. In the abstract, yes, I think it could; the requisite mature, well-designed web frameworks are already extant. Over time, they might attract more newbies than Java frameworks (although I am admittedly only guessing here based on Java stereotypes). Realistically, no, it won't, except perhaps in the extreme long run (Java has too much momentum); but we Pythonistas are having enough fun doing our own web stuff in Python-land that we don't need to try and be hyper-competitive and actively usurp Java's existing niche in the web application ecosystem. Cheers, Chris -- I hope this thorough answer sufficiently compensates for my improperly bitey initial response. http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
In article 4c2747c1$0$4545$426a7...@news.free.fr, Bruno Desthuilliers bdesth.quelquech...@free.quelquepart.fr wrote: Python has no pretention at elegance. That's not true at all. More precisely, I would agree with you if the emphasis is on pretention but not if the emphasis is on elegance; I think that Python is extremely elegant, and that elegance is one of the attractions of Python for many people. In fact, PyCon 2009 had elegance begets simplicity as its t-shirt slogan. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ If you don't know what your program is supposed to do, you'd better not start writing it. --Dijkstra -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
In article viavn.238$vd2...@news-server.bigpond.net.au, Neil Hodgson nyamatongwe+thun...@gmail.com wrote: WANG Cong: 4) Also, this will _somewhat_ violate the OOP princples, in OOP, this is and should be implemented by inherence. Most object oriented programming languages starting with Smalltalk have allowed adding attributes (addInstVarName) to classes at runtime. Low level OOPLs like C++ and Delphi did not implement this for efficiency reasons. That reminds me of this quote: ...some experts might say a C++ program is not object-oriented without inheritance and virtual functions. As one of the early Smalltalk implementors myself, I can say they are full of themselves. --zconcept -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ If you don't know what your program is supposed to do, you'd better not start writing it. --Dijkstra -- http://mail.python.org/mailman/listinfo/python-list
Re: Extension modules and common routines in Python/C API
ty ty, 28.06.2010 08:16: I'm writing wrapper for C library. This library consist of several parts. And i want split my extension package into different extension modules. I think, this is the right way ;-) Depends. If it's somewhat large or deals with sufficiently distinct functionality, it might be worth doing. But, there are some common parts that exist in extension package, get_library_version, Error, and so on. I've decided to create additional module, named core, where these routines and variables are defined. Is that supposed to be used by Python code or internally by your modules? If it's the latter, I'd just write a plain C module and link it into each of the extension modules that use it. Otherwise, a common utility module might be ok, but I don't know anything about your real code that would suggest either way. You may also consider taking both approaches, i.e. write a linked-in module and a public Python wrapper around it. And when get_library_version, for example, is used by programmer, Error, in opposite, is used by routines in another modules. As i mentioned in ( above mail), i use create_error for adding new exception class with neccessary fields. Now i call create_error in initcore function, which initialize core module. But, if i don't import package.core, and only import package.module, when package.module.function fails , python's runtime throws error Obviously. Just make sure you always import your core module first. If it defines something as basic as the main error class (assuming that's what you meant with Error), I'd make that the very first thing in the init function. You might also want to take a look at Cython. It's a Python dialect that makes writing extension modules easy, so if you have a lot of C code to wrap, it'll help you get it done substantially faster than in plain C code. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Why Is Escaping Data Considered So Magical?
On 6/26/10 7:21 PM, Lawrence D'Oliveiro wrote: In messagemailman.2123.1277522976.32709.python-l...@python.org, Tim Chase wrote: On 06/25/2010 07:49 PM, Lawrence D'Oliveiro wrote: ... I see that you published my unobfuscated e-mail address on USENET for all to see. I obfuscated it for a reason, to keep the spammers away. I'm assuming this was a momentary lapse of judgement, for which I expect an apology. Otherwise, it becomes grounds for an abuse complaint to your ISP. Wow. Way to be a douchebag. I was going to say something about the realities of this forum and its dual-nature and conflicting netiquette and on. But I decided it really just had no point. So, I'm left with: wow. You kinda suck*, man. -- ... Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ P.S. *Then again, I'm fairly sure anytime someone has a form letter which contains the words, I expect an apology, there's some personal suck going on. -- http://mail.python.org/mailman/listinfo/python-list
回复: I wander which is bette r? JSP or Python? And is there a place for JSP?
Oh,sorry.I was just to make a comparison between Python and JSP.Will Python take the place of JSP? 我的QQ空间 the Past 24 Hours. 昨天下午,毛概被点 已经有所预感,没有郁闷的心情 反倒是... -- 原始邮件 -- 发件人: Chris Rebertc...@rebertia.com; 发送时间: 2010年6月28日(星期一) 中午1:09 收件人: Rogerrogerda...@gmail.com; 主题: Re: I wander which is better? JSP or Python? And is there a place for JSP? On Sun, Jun 27, 2010 at 9:49 PM, Roger rogerda...@gmail.com wrote: As I plan to study JSP, I find it extremly complicated and a part of J2EE. I did not attend to get the whole of J2EE. I hope anybody can describe the future of JSP. Is there a place for JSP? This is python-list/comp.lang.python; we discuss the **Python** programming language and related topics here. Your question is about **Java** and has nothing to do with Python. comp.lang.java.programmer is over there: http://groups.google.com/group/comp.lang.java.programmer/topics Regards, Chris -- http://blog.rebertia.com-- http://mail.python.org/mailman/listinfo/python-list
Re: Why Python3
On Sun, 27 Jun 2010 21:25:49 -0700, John Nagle wrote: Unfortunately, that's not what's happening in the development pipeline. PyPy targets Python 2.5. Unladen Swallow targets Python 2.6.1. IronPython targets Python 2.6. C module support for CPython 3.x is still very spotty. We have a long way to go before Python 3.x is ready for prime time. None of PyPy, Unladen Swallow or IronPython are dependencies for Python 3.x to be ready for prime time. Neither is C module support. Python 3.1 itself is solid, reliable release of the Python language. It and the standard library are more than ready to be put into production. Of course, if you personally require some C module ham which only supports 2.6, you'll have good reason to stick with 2.6. But then if your project absolutely depends on module spam which only supports Python 1.5, you'll be still using Python 1.5. So what? For the rest of us, you can do a lot with just Python 3.1, with or without C modules. Whether it does *enough* to be considered for deployment depends on what you're deploying it to do. I for one would not hesitate to use Python 3.1 as a scripting language, or for any application where the standard library is all you need. You can do a lot with just the standard library. For the rest, the question isn't is Python 3 ready for production?, because the answer for that is absolutely. The question is, are the libraries I need ready for Python 3?, and the answer to that is often No, but sometimes a provisional or experimental Yes. Personally, I'm getting tired of all the negative nellies who seem to think that take up of Python 3 is a race, and that if anyone is still using 2.x by next Tuesday that means Python 3 is a failure and we should all just dump it as a bad idea. Python 3 uptake is not a race. Both Python 2.7 and 3.x will be supported for many years to come. If you can't use 3 *now*, that's fine, nobody says you should -- but by the same token, try to tone down the negativity. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: I strongly dislike Python 3
Stefan Reich, 26.06.2010 17:59: This has probably been talked about on your lists, but I wasn't part of that discussion. I don't care to read up old arguments in one of the archives isn't a very convincing reason to start a discussion. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Why Is Escaping Data Considered So Magical?
On Mon, 2010-06-28, Kushal Kumaran wrote: On Mon, Jun 28, 2010 at 2:00 AM, Jorgen Grahn grahn+n...@snipabacken.se wrote: On Sun, 2010-06-27, Lawrence D'Oliveiro wrote: In message roy-854954.20435125062...@news.panix.com, Roy Smith wrote: I recently fixed a bug in some production code. The programmer was careful to use snprintf() to avoid buffer overflows. The only problem is, he wrote something along the lines of: snprintf(buf, strlen(foo), foo); A long while ago I came up with this macro: #define Descr(v) v, sizeof v making the correct version of the above become snprintf(Descr(buf), foo); This is off-topic, but I believe snprintf() in C can *never* safely be the only thing you do to the buffer: you also have to NUL-terminate it manually in some corner cases. See the documentation. snprintf goes to great lengths to be safe, in fact. You might be thinking of strncpy. Yes, it was indeed strncpy I was thinking of. Thanks. But actually, the snprintf(3) man page I have is not 100% clear on this issue, so last time I used it, I added a manual NUL-termination plus a comment saying I wasn't sure it was needed. I normally use C++ or Python, so I am a bit rusty on these things. /Jorgen -- // Jorgen Grahn grahn@ Oo o. . . \X/ snipabacken.se O o . -- http://mail.python.org/mailman/listinfo/python-list
Re: I strongly dislike Python 3
On 28/06/2010 00:03, eric_dex...@msn.com wrote: It should be easier to have a large number of python versions on one machine... I am realy fond of 2.5 so I am probily going to start compiling them or just include the python2.5 exe if I port stuff and settle it that way.. I have Python versions 2.1-2.7 and 3.0-3.2 installed on my Windows box without any problems. I don't often have to use the full range (mostly, in fact, for confirming that my unit tests still run on my few released modules). But I certainly do use several different ones each day where I have to make sure I'm running the same version as the user who's experiencing a problem. One technique I find particularly handy is to create a pythonxx.exe hardlink in my c:\tools (which is always on my path), pointing to c:\pythonxx\python.exe in turn. Then it's just a matter of: python25 my-script.py Even without that, it's only a question of c:\python25\python my-script.py if I need to. I have in the past used a crude shebang-alike Python pre-processor which hands off to the right version. It's a bit sluggish, though, and that outweighed for me the slight convenience. YMMV TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: I strongly dislike Python 3
geremy condra debat...@gmail.com writes: On Sun, Jun 27, 2010 at 10:35 PM, John Bokma j...@castleamber.com wrote: [..] I've used several operating systems over many years and each OS has its own issues. I am currently using mostly Linux and it's far from the flawless OS some people seem to think it is. While it's true that some things are easier on OS A than on OS B changing your operating system because one (minor) thing doesn't work is often not an option. Sure, linux has its flaws- but it does include a working shell OOTB, which is what raised this question in the first place. As mentioned already by someone else, install bash on Windows and problem solved (it can be installed without Cygwin). On top of that, I don't think it's that hard to make a small program that one associates with .py files which checks the first line and feeds the .py to the correct version of Python based on the information in the aformentioned first line. I could spend my time reinventing all kinds of wheels. I'm just not sure why I'd want to. It's clear that you are not interested in running Windows. But the world is not limited to what you want. There are people out there who are /not/ interested to switch to a different OS just because it's the easiest option to /you/. Another option (instead of installing a better shell) might be to make several VMs, each with their own Python version. Run subversion (or any other version control system) on your host, and you can test whatever you want. Is this seriously your solution? Sure it is. Maybe not for you, but there are people who prefer an isolated VM to test stuff in some cases. I am one of them. Can you see why I would rather have a working shell than have to automate test suites across a half dozen VMs? Install bash in that case, problem solved. Yet another solution is to have your test suite change the file association for the .py (and related) extensions to the correct version of Python. I know it's not for you, you're happy on Linux, but for others this might work perfectly. There are plenty of people who are very happy with coding under an MS OS. I now and then miss those days :-). Ok, and for those people things like cygwin exist. My point is just that it is frequently easier to do an actual linux install. Maybe in your specific case, sure. But /again/ there are plenty of people who use Windows /for a reason/. Why would one change an entire operation system just to have bash? It's not needed. On top of that, I have installed Cygwin and used it for a while, and don't see why installing Linux is easier. Especially if a majority of the other programs I want to use don't run under Wine / don't have alternatives on Linux (alternative as in a suitable alternative for /my/ needs). -- John Bokma j3b Hacking Hiking in Mexico - http://johnbokma.com/ http://castleamber.com/ - Perl Python Development -- http://mail.python.org/mailman/listinfo/python-list
[python-openid] 2.2.3 python package missing
Hi, I write to you, to inform I can't install python-openid 2.2.3 version. I've writed to the author : I've work on a project, I use AuthKit and this tool have a dependency with python-openid-2.2.3 http://openidenabled.com/files/python-openid/packages/python-openid-2.2.3.tar.gz this file is missing on your server. To fix deployment issue, can you keep older library version ? Regards, Stephane -- http://mail.python.org/mailman/listinfo/python-list
Re: I strongly dislike Python 3
Stephen Hansen me+list/pyt...@ixokai.io writes: On 6/27/10 7:35 PM, John Bokma wrote: On top of that, I don't think it's that hard to make a small program that one associates with .py files which checks the first line and feeds the .py to the correct version of Python based on the information in the aformentioned first line. http://effbot.org/zone/exemaker.htm does approximately that and has been very useful for me. Thanks for the link. -- John Bokma j3b Hacking Hiking in Mexico - http://johnbokma.com/ http://castleamber.com/ - Perl Python Development -- http://mail.python.org/mailman/listinfo/python-list
Re: I strongly dislike Python 3
Tim Golden m...@timgolden.me.uk writes: On 28/06/2010 00:03, eric_dex...@msn.com wrote: It should be easier to have a large number of python versions on one machine... I am realy fond of 2.5 so I am probily going to start compiling them or just include the python2.5 exe if I port stuff and settle it that way.. I have Python versions 2.1-2.7 and 3.0-3.2 installed on my Windows box without any problems. I don't often have to use the full range (mostly, in fact, for confirming that my unit tests still run on my few released modules). But I certainly do use several different ones each day where I have to make sure I'm running the same version as the user who's experiencing a problem. One technique I find particularly handy is to create a pythonxx.exe hardlink in my c:\tools (which is always on my path), pointing to c:\pythonxx\python.exe in turn. Then it's just a matter of: python25 my-script.py Even without that, it's only a question of c:\python25\python my-script.py if I need to. I have in the past used a crude shebang-alike Python pre-processor which hands off to the right version. It's a bit sluggish, though, and that outweighed for me the slight convenience. YMMV You might want to look into the assoc command to (temporarily) associate .py co with a different version of Python. -- John Bokma j3b Hacking Hiking in Mexico - http://johnbokma.com/ http://castleamber.com/ - Perl Python Development -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
Aahz a écrit : In article 4c2747c1$0$4545$426a7...@news.free.fr, Bruno Desthuilliers bdesth.quelquech...@free.quelquepart.fr wrote: Python has no pretention at elegance. That's not true at all. More precisely, I would agree with you if the emphasis is on pretention but not if the emphasis is on elegance; Python Zen, #9 (or #8 if you're a TrueHacker !-)) -- http://mail.python.org/mailman/listinfo/python-list
Re: I strongly dislike Python 3
On 28/06/2010 09:29, John Bokma wrote: Tim Goldenm...@timgolden.me.uk writes: On 28/06/2010 00:03, eric_dex...@msn.com wrote: It should be easier to have a large number of python versions on one machine... I am realy fond of 2.5 so I am probily going to start compiling them or just include the python2.5 exe if I port stuff and settle it that way.. I have Python versions 2.1-2.7 and 3.0-3.2 installed on my Windows box without any problems. I don't often have to use the full range (mostly, in fact, for confirming that my unit tests still run on my few released modules). But I certainly do use several different ones each day where I have to make sure I'm running the same version as the user who's experiencing a problem. One technique I find particularly handy is to create a pythonxx.exe hardlink in my c:\tools (which is always on my path), pointing to c:\pythonxx\python.exe in turn. Then it's just a matter of: python25 my-script.py Even without that, it's only a question of c:\python25\python my-script.py if I need to. I have in the past used a crude shebang-alike Python pre-processor which hands off to the right version. It's a bit sluggish, though, and that outweighed for me the slight convenience. YMMV You might want to look into the assoc command to (temporarily) associate .py co with a different version of Python. Thanks for the idea. ISTR playing around with this in the past. Ultimately, though, it's typically a one-off run I'm doing (possibly repeated several times while I fix the problem!) and the assoc will affect all open sessions even if I revert it later, so I haven't gone down that route. I do have a version-switcher script which makes whichever Python exe runs it the default / on the path / etc. which is a sort of poor man's virtualenv. (And predates virtualenv, in my defence). But even that I use rarely. TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: I strongly dislike Python 3
On Mon, Jun 28, 2010 at 4:23 AM, John Bokma j...@castleamber.com wrote: geremy condra debat...@gmail.com writes: On Sun, Jun 27, 2010 at 10:35 PM, John Bokma j...@castleamber.com wrote: [..] I've used several operating systems over many years and each OS has its own issues. I am currently using mostly Linux and it's far from the flawless OS some people seem to think it is. While it's true that some things are easier on OS A than on OS B changing your operating system because one (minor) thing doesn't work is often not an option. Sure, linux has its flaws- but it does include a working shell OOTB, which is what raised this question in the first place. As mentioned already by someone else, install bash on Windows and problem solved (it can be installed without Cygwin). On top of that, I don't think it's that hard to make a small program that one associates with .py files which checks the first line and feeds the .py to the correct version of Python based on the information in the aformentioned first line. I could spend my time reinventing all kinds of wheels. I'm just not sure why I'd want to. It's clear that you are not interested in running Windows. But the world is not limited to what you want. There are people out there who are /not/ interested to switch to a different OS just because it's the easiest option to /you/. I'm starting to think that you aren't actually reading what I'm writing and are instead in the fantasyland where I've advocated something other than doing what seems easiest and most convenient at the time. In fact, you seem to be laboring under the false belief that I have advocated the utter ruination of microsoft, its products, and your way of life. Since I don't make a habit of that, and in any event certainly haven't done so in this thread, I have to assume that any further protestation on my part will only be met with a correspondingly greater failure to comprehend on yours. As a result, I'm bowing out. Thanks for the lively discussion. Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list
Re: I strongly dislike Python 3
geremy condra debat...@gmail.com writes: I'm starting to think Great, about time. Based on your previous reply I had the feeling you're a condescending prick, but now I am conviced, so *ploink*! -- John Bokma j3b Hacking Hiking in Mexico - http://johnbokma.com/ http://castleamber.com/ - Perl Python Development -- http://mail.python.org/mailman/listinfo/python-list
Re: I strongly dislike Python 3
On 06/28/2010 03:21 AM, Stephen Hansen wrote: On 6/27/10 6:11 PM, geremy condra wrote: On Sun, Jun 27, 2010 at 8:50 PM, Grant Edwardsinva...@invalid.invalid wrote: If you install a real shell on Windows, then the hash-bang line works fine. :) Might as well spare yourself the trouble and install linux or *bsd. It's probably easier. Not at all, bash via msys is trivial to install and use. Installing Linux is still a LOT easier than installing a working MSYS since you get proper package management with proper dependency resolution, while with MSYS, you end up downloading dozens of different inter-dependent GNU packages one-by-one until anything works. At least that's what it looked like a couple of months ago. Granted, cygwin has a nice installer. -- http://mail.python.org/mailman/listinfo/python-list
Re: [python-openid] 2.2.3 python package missing
On 06/28/2010 10:26 AM, Stéphane Klein wrote: Hi, I write to you, to inform I can't install python-openid 2.2.3 version. I've writed to the author : I've work on a project, I use AuthKit and this tool have a dependency with python-openid-2.2.3 http://openidenabled.com/files/python-openid/packages/python-openid-2.2.3.tar.gz this file is missing on your server. To fix deployment issue, can you keep older library version ? Use the link *you* posted. It will redirect you to an index page. Click Python -- downloads. http://github.com/openid/python-openid/downloads Now was that really that difficult? - Thomas PS: okay, that doesn't include version 2.2.3. However, I expect that 2.2.5 will work just as well for you, and I am *certain* that 2.2.4 will work: I checked the github commit logs and discovered that URL:http://github.com/openid/python-openid/commit/80ba35b21777f637040cf8cd6b0bc6a3a7c9ef2d is the only change between the two versions -- it looks like version 2.2.3 never worked in the first place. -- http://mail.python.org/mailman/listinfo/python-list
Creating exception class with custom fields in Python/C API
Hello, list! I'm writing a wrapper for C-library. When something goes wrong in that library, i can get error details. And i want to assign them to fields of my own exception class. For this purpose, i looked throught Modules/_ctypes/_ctypes.c (in python source tree) and implemented same things. Briefly: define PyObject * Error in header file, write init and other necessary functions assign them to PyMethodDef array initialize class's dict with methods above (in function create_error) create new exception with no base class and with dict (in function create_error) call to create_error and assign Error class to module (PyModule_AddObject) throw error with PyErr_SetObject(Error, tpl);, where tpl is tuple with error details, which are assigned to Error's fields in init function All of this is consistent with what i saw in Modules/_ctypes/_ctypes.c, i think. But it doesn't work: when i call PyErr_SetObject(Error, tpl);, Python's runtime raises error: TypeError: unbound method __init__() must be called with Error instance as first argument (got str instance instead) And PyObject_Print(Error, stdout, 0); returns: {'__init__': unbound method Error.__init__ ...} It's item for init function in PyMethodDef array: {__init__, myerror_init, METH_VARARGS, initialize error} and it's function's signature: static PyObject * myerror_init(PyObject * self, PyObject *args) (python version -- 2.6.4) Why methods are unbound? And what i've missed? Or what is the right and pythonic way to define exception with custom class attributes? Thanks. (crosspost from stackoverflow: http://stackoverflow.com/questions/3118617/creating-exception-class-with-custom-fields-in-python-c-api ) -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] Benchmarker 1.1.0 released - a samll benchmark utility
Makoto Kuwata, 26.06.2010 19:09: I released Benchmarker 1.1.0. http://pypi.python.org/pypi/Benchmarker/ Benchmarker is a small utility to benchmark your code. Does it use any statistically sound way to run the benchmarks? It seems to produce just one number on output, which can be misleading depending on the way it measures. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Why Is Escaping Data Considered So Magical?
Carl Banks wrote: Indeed, strncpy does not copy that final NUL if it's at or beyond the nth element. Probably the most mind-bogglingly stupid thing about the standard C library, which has lots of mind-boggling stupidity. I don't think it was as stupid as that back when C was designed. Every byte of memory was precious in those days, and if you had, say, 10 bytes allocated for a string, you wanted to be able to use all 10 of them for useful data. So the convention was that a NUL byte was used to mark the end of the string *if it didn't fill all the available space*. Functions such as strncpy and snprintf are designed for use with strings that follow this convention. Proper usage requires being cognizant of the maximum length and using appropriate length-limited functions for all operations on such strings. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: python source code - win/dos executable (on linux)
Lawrence D'Oliveiro ha scritto: In message 4c24c152$0$31381$4fafb...@reader1.news.tin.it, superpollo wrote: suppose i work in a linux environment, but i would like to ship a win/dos executable file from time to time, just for test purposes (my testers are windows users and don't want to go through the hassle of installing python on their win boxes). Is it really such a hassle to install things on Windows? no, but it *IS* to explain it to dumb users... :-( bye -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
Carl Banks a écrit : On Jun 27, 3:49 am, Bruno Desthuilliers bdesth.quelquech...@free.quelquepart.fr wrote: WANG Cong a écrit : On 06/26/10 00:11, Neil Hodgson nyamatongwe+thun...@gmail.com wrote: WANG Cong: 4) Also, this will _somewhat_ violate the OOP princples, in OOP, this is and should be implemented by inherence. Most object oriented programming languages starting with Smalltalk have allowed adding attributes (addInstVarName) to classes at runtime. Thanks, I have to admit that I know nothing about Smalltalk. Then you really don't know much about OO. I don't really know much about Smalltalk either. Duh. I cancelled this totally stupid and useless post a couple seconds after hitting the send button, but still too late :( So first let me present my apologies to WANG Cong and everyone else, this was a crude, arrogant and totally stupid thing to say, and I should know better. Sorry. Now on why I first wrote this (warning : personal opinions ahead): object started with Simula, but objects in Simula are mostly glorified ADTs with type-based polymorphic dispatch. Smalltalk (and all it's environment) got _way_ further by turning this into a coherent whole by introducing messages (which are more than just type-based polymorphic dispatch - Smalltalk's messages are objects themselves) and code blocks - as the only mean to control flow. I believe that Smalltalk is (so far) the only OO language that was innovative enough to really escape from good old procedural programming, and as such possibly the only True OOPL. Now for various reasons (including implementation issues and conservatism), it happened that the Simula approach to OO became the mainstream with languages like C++ then Java, and that most of OO litterature - OOP principles, golden rules etc - is about this somehow very restricted approach, so people being taught OO that way have a very restricted - and incomplete - vision of what OO is really about. That was how I was taught OO, and I always felt that there was something wrong, inconsistant or missing. Studying Smalltalk (however briefly) was for me a real AHA, mind-opening moment - suddenly OO made sense as this coherent, comprehensive and innovative approach to programming I so far failed to find in Java or C++. Now I don't mean one has to master Smalltalk to be allowed to talk about OO, nor that OO can't exist outside Smalltak (Python being IMHO another exemple of an interesting and mostly coherent object system, even if doesn't go as far as Smalltalk do), but - pardon me if this seems arrogant (and please correct me if it really is) - I can't help thinking that one cannot really understand OO whithout at least a brief study of Smalltalk (and - once again - a full Smalltalk environment, as Smalltalk the language is only one part of the 'full' object system). Hope this will at least help those I may have offended understand my point, however stupidly I expressed it :( B. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why Is Escaping Data Considered So Magical?
Gregory Ewing greg.ew...@canterbury.ac.nz writes: I don't think it was as stupid as that back when C was designed. Every byte of memory was precious in those days, and if you had, say, 10 bytes allocated for a string, you wanted to be able to use all 10 of them for useful data. No I don't think so. Traditional C strings simply didn't carry length info except for the nul byte at the end. Most string functions expected the nul to be there. The nul byte convention (instead of having a header word with a length) arguably saved some space both by eliminating a multi-byte header and by allowing trailing substrings to be represented as pointers into a larger string. In retrospect it seems like a big error. -- http://mail.python.org/mailman/listinfo/python-list
Re: [python-openid] 2.2.3 python package missing
Le 28/06/2010 11:34, Thomas Jollans a écrit : On 06/28/2010 10:26 AM, Stéphane Klein wrote: Hi, I write to you, to inform I can't install python-openid 2.2.3 version. I've writed to the author : I've work on a project, I use AuthKit and this tool have a dependency with python-openid-2.2.3 http://openidenabled.com/files/python-openid/packages/python-openid-2.2.3.tar.gz this file is missing on your server. To fix deployment issue, can you keep older library version ? Use the link *you* posted. It will redirect you to an index page. Click Python -- downloads. http://github.com/openid/python-openid/downloads Now was that really that difficult? This is my difficulty : steph...@stephane-desktop:$ cd /tmp steph...@stephane-desktop:$ virtualenv env1 New python executable in env1/bin/python Installing setuptoolsdone. steph...@stephane-desktop:$ source env1/bin/activate (env1)steph...@stephane-desktop:$ pip install python-openid Downloading/unpacking python-openid Downloading python-openid-2.2.3.tar.gz (unknown size): 12Kb downloaded Exception: Traceback (most recent call last): File /tmp/env1/lib/python2.6/site-packages/pip-0.7.2-py2.6.egg/pip/basecommand.py, line 120, in main self.run(options, args) File /tmp/env1/lib/python2.6/site-packages/pip-0.7.2-py2.6.egg/pip/commands/install.py, line 161, in run requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle) File /tmp/env1/lib/python2.6/site-packages/pip-0.7.2-py2.6.egg/pip/req.py, line 879, in prepare_files self.unpack_url(url, location, self.is_download) File /tmp/env1/lib/python2.6/site-packages/pip-0.7.2-py2.6.egg/pip/req.py, line 1093, in unpack_url self.unpack_file(temp_location, location, content_type, link) File /tmp/env1/lib/python2.6/site-packages/pip-0.7.2-py2.6.egg/pip/req.py, line 1135, in unpack_file self.untar_file(filename, location) File /tmp/env1/lib/python2.6/site-packages/pip-0.7.2-py2.6.egg/pip/req.py, line 1192, in untar_file tar = tarfile.open(filename, mode) File /usr/lib/python2.6/tarfile.py, line 1665, in open return func(name, filemode, fileobj, **kwargs) File /usr/lib/python2.6/tarfile.py, line 1716, in gzopen raise ReadError(not a gzip file) ReadError: not a gzip file Storing complete log in /home/stephane/.pip/pip.log Thanks for your help, Stephane -- http://mail.python.org/mailman/listinfo/python-list
compile as exe with arguments
I want to compile as an exe using py2exe but the function should take arguments. How would I do this? Currently my exe runs (no errors) but nothing happens. -- http://mail.python.org/mailman/listinfo/python-list
Re: compile as exe with arguments
On 06/28/10 11:18, dirknbr wrote: I want to compile as an exe using py2exe but the function should take arguments. How would I do this? Currently my exe runs (no errors) but nothing happens. I am not sure if I understand your question correctly, have you used a module like optparse and it doesn't do anything? It works for me the last time I used it. -- mph -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
Alexander Kapps a écrit : (snip) While I personally don't agree with this proposal (but I understand why some people might want it), I can see a reason. When disallowing direct attribute creation, those typos that seem to catch newcommers won't happen anymore. What I mean is this: class Foo(object): def __init__(self): self.somearg = 0 f = Foo() f.soemarg = 42 ---^ There, typo, but still working It's something like a custom __setattr__ that errors out when trying to assign to an attribute that doesn't exists, Chicken and egg problem, really : f.__dict__['somearg'] doesn't exists until self.somearg = 0 is executed. The problem is that Python's methods are only thin wrapper around functions (cf http://wiki.python.org/moin/FromFunctionToMethod) so there's no difference between self.somearg = 0 in Foo.__init__ and f.somearg = 42. IOW, there's no way to implement this proposal without completely changing Python's object model. -- http://mail.python.org/mailman/listinfo/python-list
Re: [python-openid] 2.2.3 python package missing
On 06/28/2010 11:51 AM, Stéphane Klein wrote: Le 28/06/2010 11:34, Thomas Jollans a écrit : On 06/28/2010 10:26 AM, Stéphane Klein wrote: Hi, I write to you, to inform I can't install python-openid 2.2.3 version. I've writed to the author : I've work on a project, I use AuthKit and this tool have a dependency with python-openid-2.2.3 http://openidenabled.com/files/python-openid/packages/python-openid-2.2.3.tar.gz this file is missing on your server. To fix deployment issue, can you keep older library version ? Use the link *you* posted. It will redirect you to an index page. Click Python -- downloads. http://github.com/openid/python-openid/downloads Now was that really that difficult? This is my difficulty : steph...@stephane-desktop:$ cd /tmp steph...@stephane-desktop:$ virtualenv env1 New python executable in env1/bin/python Installing setuptoolsdone. steph...@stephane-desktop:$ source env1/bin/activate (env1)steph...@stephane-desktop:$ pip install python-openid Okay. Judging by URL:http://pypi.python.org/pypi/python-openid and URL:http://github.com/openid/python-openid/issues, installing the package via PyPI is known to currently be broken. In the mean time, you'd be advised to install it manually, that means: 1. download it from http://github.com/openid/python-openid/downloads 2. extract the tarball 3. python setup.py install -- Thomas Downloading/unpacking python-openid Downloading python-openid-2.2.3.tar.gz (unknown size): 12Kb downloaded I don't have the faintest idea why this would try to download an old version. Ah well. Exception: Traceback (most recent call last): File /tmp/env1/lib/python2.6/site-packages/pip-0.7.2-py2.6.egg/pip/basecommand.py, line 120, in main self.run(options, args) File /tmp/env1/lib/python2.6/site-packages/pip-0.7.2-py2.6.egg/pip/commands/install.py, line 161, in run requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle) File /tmp/env1/lib/python2.6/site-packages/pip-0.7.2-py2.6.egg/pip/req.py, line 879, in prepare_files self.unpack_url(url, location, self.is_download) File /tmp/env1/lib/python2.6/site-packages/pip-0.7.2-py2.6.egg/pip/req.py, line 1093, in unpack_url self.unpack_file(temp_location, location, content_type, link) File /tmp/env1/lib/python2.6/site-packages/pip-0.7.2-py2.6.egg/pip/req.py, line 1135, in unpack_file self.untar_file(filename, location) File /tmp/env1/lib/python2.6/site-packages/pip-0.7.2-py2.6.egg/pip/req.py, line 1192, in untar_file tar = tarfile.open(filename, mode) File /usr/lib/python2.6/tarfile.py, line 1665, in open return func(name, filemode, fileobj, **kwargs) File /usr/lib/python2.6/tarfile.py, line 1716, in gzopen raise ReadError(not a gzip file) ReadError: not a gzip file Storing complete log in /home/stephane/.pip/pip.log -- http://mail.python.org/mailman/listinfo/python-list
Re: compile as exe with arguments
On Jun 28, 11:26 am, Martin P. Hellwig martin.hell...@dcuktec.org wrote: On 06/28/10 11:18, dirknbr wrote: I want to compile as an exe using py2exe but the function should take arguments. How would I do this? Currently my exe runs (no errors) but nothing happens. I am not sure if I understand your question correctly, have you used a module like optparse and it doesn't do anything? It works for me the last time I used it. -- mph Aha that might be it, I had a look at http://docs.python.org/library/optparse.html How do you integrate (options, args) = parser.parse_args() with our function? -- http://mail.python.org/mailman/listinfo/python-list
Famous Emacs People With Hand Injuries
• Famous Emacs People With Hand Injuries http://xahlee.org/emacs/emacs_hand_pain_celebrity.html plain text version follows. - Famous Emacs People With Hand Injuries Xah Lee, 2010-06-28 This page collect tales of computer programer celebrities who have injured their hand seriously by Repeatitive Strain Injury (RSI), in particular, due to use emacs. -- Richard Stallman, FSF/GNU Founder Richard Stallman's RSI is well known during the 1990s. I remember reading about it somewhere on his website in the 1990s, perhaps on gnu.org, but i couldn't find it now. At one point, i remember that he is trying to switch to voice systems. Here's a second hand tale. Which Keyboard? (2007-06-21), by Michael Tiemann, at cnet.com Fast forward twenty years and I was working 12-16 hours a day hacking on the GNU C++ compiler with more than 100,000 lines of code to my name, and loving every minute of it. One weekend I visited Richard Stallman at MIT and I was shocked to learn that he could no longer type. He was given strict instructions by his doctor to not touch a computer keyboard for 6-12 months, and that if he did, he may lose forever his ability to type. He was a programming pioneer, and at the time, his symptoms were not well known or understood. We all came to understand that it was RSI--repetitive stress injury, exacerbated by the very keystroke combinations that made the Emacs editor such a powerful programming environment. But the root cause was not Emacs--it was the punative design of the QWERTY keyboard, a legacy of the industrial era when complex keyboard mechanisms were not able to keep up with the speed of human fingers. ... Note: Michael Tiemann was a founder of Cygnus (Cygwin), then later was CEO of Redhat when Redhat bought it. -- Jamie W Zawinski Jamie Zawinski is the main developer of Xemacs, when it was called Lucid Emacs around 1989, and he is often the one blamed for the emacs/ xemacs schisim. Jamie is also well known for being the main developer of Netscape browser when the web started in mid 1990s. Jamie keeps a diary on computer, before there's a word “blog”, and in his writings scattered around his diaries he has talked about his hand injury situation, in his dot com work-to-death years. Here are some quotes from his writings online: my wrists and welcome to them (1999), by Jamie Zawinski. At jwz.org. For several years I had pretty severe wrist pain, and it terrified me. I had these visions of me with withered stumps at the ends of my arms, trying to limp along using speech-recognition software, and my career being over. The folllowing is from: the netscape dorm (1994), by Jamie Zawinski, at jwz.org. My hands have been really been hurting lately; I hope all this typing hasn't finally blown out my wrists. If I can't type, my life is over. My right hand especially is flaking out -- the last knuckle of the middle two fingers ache, as if they're badly bruised. I guess it's time to figure out how to use our medical program. As if a doctor is going to tell me something other than ``stop typing so much.'' Ha ha ha, that's a good one. -- Ben Wing, Xemacs Main Developer Ben Wing, is the main developer of Xemacs in the 1990s, following Jamie W Zawinski. Following is a quote from his xemacs home page at http://xemacs.org/People/ben.wing/ Since September 1992, I've worked on XEmacs as a contractor for various companies and more recently as an unpaid volunteer. Alas, life has not been good to me recently. This former San Francisco Mission Critter developed insidious hand and neck problems after a brief stint working on a Java-based VRML toolkit for the now defunct Dimension X, and I was forced to quit working. I was exiled first to Stroller Valley and later all the way to Tucson, Arizona, and for two years was almost completely disabled due to pain. More recently I have fought my way back with loads and loads of narcotic painkillers, and after a stint as an art student at the University of Arizona I'm currently a Ph.D. student in linguistics at the University of Texas, Austin. It's hard to find much info about Ben Wing online. His pages haven't been updated for something like 15 years, and his domain name 666.com has been squatted. I gather he's no longer in the programing industry since late 1990s. -- John Ousterhout John Ousterhout, most well known as the inventor of the tcl language, developed RSI. He switched to using a voice system for almost everything. Here's his article on RSI. Dealing With RSI (1995-2007), by John Ousterhout. At Source. I started having pain in my left wrist in 1995, and the problems got progressively worse in spite of (and partly because of) various attempts at treatment. In 1996 I started
Python as a scripting language. Alternative to bash script?
I've a fairly long bash script and I'm wondering how easy it would be to port to Python. Main queries are: Ease of calling out to bash to use something like imageMagick or Java? Ease of grabbing return parameters? E.g. convert can return both height and width of an image. Can this be returned to the Python program? Can Python access the exit status of a program? I'd prefer the advantages of using Python, just wondering if I got so far with the port then found it wouldn't do something? Has anyone made this comparison please? TIA -- Dave Pawson XSLT XSL-FO FAQ. Docbook FAQ. http://www.dpawson.co.uk -- http://mail.python.org/mailman/listinfo/python-list
disputing the history of lisp machines
just discovered a blog written by a old lisper Dan Weinreb, refuting on a story on Lisp Machine companies as told by Richard Stallman. “Rebuttal to Stallman’s Story About The Formation of Symbolics and LMI” (2007-11), by Dan Weinreb. At http://danweinreb.org/blog/rebuttal-to-stallmans-story-about-the-formation-of-symbolics-and-lmi From my experience, and extensive reading about Richard Stallman since late 1990s, that i would believe Dan Weinreb on this more than Richard Stallman. I find Richard Stallman's writings, are often biased, and in many of his writings and lectures i've seen, he's even intentionally mis-infom people for his point of view on the philosophy of software licensing. (see http://xahlee.org/UnixResource_dir/writ2/FSF_philosophy.html ) Dan Weinreb's blog article probably has been mentioned here before, but i felt it be announced again. Xah ∑ http://xahlee.org/ ☄ -- http://mail.python.org/mailman/listinfo/python-list
Re: compile as exe with arguments
On Jun 28, 11:40 am, dirknbr dirk...@gmail.com wrote: On Jun 28, 11:26 am, Martin P. Hellwig martin.hell...@dcuktec.org wrote: On 06/28/10 11:18, dirknbr wrote: I want to compile as an exe using py2exe but the function should take arguments. How would I do this? Currently my exe runs (no errors) but nothing happens. I am not sure if I understand your question correctly, have you used a module like optparse and it doesn't do anything? It works for me the last time I used it. -- mph Aha that might be it, I had a look athttp://docs.python.org/library/optparse.html How do you integrate (options, args) = parser.parse_args() with our function? Ok I had a look at this now http://wiki.python.org/moin/OptParse and got it. -- http://mail.python.org/mailman/listinfo/python-list
An invalid expression as parameter
When write i for i in range(16) I get SyntaxError: invalid syntax but When I use it like this: def f(x):\ ... pass f(i for i in range(16)) all is right I think it maybe f((i for i in range(16))) -- Li Hui http://www.lihui.org -- http://mail.python.org/mailman/listinfo/python-list
Re: I wander which is better? JSP or Python? And is there a place for JSP?
On Jun 28, 12:49 am, Roger rogerda...@gmail.com wrote: As I plan to study JSP, I find it extremly complicated and a part of J2EE. I did not attend to get the whole of J2EE. I hope anybody can describe the future of JSP. Is there a place for JSP? I work on a big java project to make money and I like JSP's -- in fact I prefer working with JSPs over working with complicated web infrastructures such as java based RSF/Spring or Python based Zope and Django. You drop a file into a JSP directory and a page that looks similar appears on your web server -- no messing with config files and regular expressions and such. It's very easy to understand, develop, debug. This is why I wrote WHIFF to use a similar but generalized drop in paradigm. http://whiffdoc.appspot.com -- Aaron Watters === % man less less is more. -- http://mail.python.org/mailman/listinfo/python-list
RE: Continuously running scripts question
Thank you all very much for your replies. Appreciate your thoughts. I'll check this out. Thanks. Jay -- On 2010-06-25, Tim Harig usernet at ilthio.net wrote: It sounds to me, since your script is acting on an event, that it would benefit from using something like inotify, or whatever your system equivilant would be (FSEvents for Mac? FAM framework for general POSIX. There are python modules available.), so that your script can react when (and only when) it notices changes to the folder in question. pynotify (Linux inotify): http://trac.dbzteam.org/pyinotify FSEvents wrapper: http://pypi.python.org/pypi/pyobjc-framework-FSEvents/2.2b2 FAM: C libraries and daemon: http://savannah.nongnu.org/projects/fam/ Python wrapper: http://sourceforge.net/projects/python-fam/ Similar functionality is available for other platforms; but, you will need to look at the documentation for those platforms for information on how to access it. -- http://mail.python.org/mailman/listinfo/python-list
Is safe to use the shelve module with eventlet?
Hi all. I'm using eventlet http://eventlet.net/ to build a simple web crawler. Can I use the shelve module for data persistence? Will I run into problems due to the non-blocking nature of eventlet? Thanks in advanced. Alex -- http://mail.python.org/mailman/listinfo/python-list
Copy / Update - Paste a directory.
Hello everybody ! wow my first time on this mailing list :) Well, here the deal. Im doing a script that basically copy and past into the local drive a specified directory with all this files. Im doing the copy with a copytree which is working well. But, (and I know it will not work as copytree dont update directory) Im, like, stuck when I have to update the directory. For a better understanding here what the tree look like: G:/prod/actual/project/xxx/shot/shot_EN_006/render/v001 and sometime as we have to rerender, we update the render folder with a v002: G:/prod/actual/project/xxx/shot/shot_EN_006/render/v002 So, actually my script can copy my *G:/*prod/actual/project/xxx/shot/shot_EN_006/render/v001 directory to *C:/*prod/actual/project/xxx/shot/shot_EN_006/render/v001 but I dont know how to proceed to update this folder when asked. Here the actual script, as you can see the update part will not work. Anyone can help me to figure out a solution please ?. Thank you and have a good day ! copy.py Description: Binary data -- http://mail.python.org/mailman/listinfo/python-list
Re: I strongly dislike Python 3
On Jun 26, 9:06 pm, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: I didn't notice this level of angst when Python made equally significant changes going from 1.5 to 2.0... admittedly Python 1.5 code would work unchanged in 2.0, but the 2.x series introduced MUCH bigger additions to Python than anything 3.0 and 3.1 have added, and anyone taking advantage of those changes is implicitly writing code which is not backwards As a historical note, Python was a lot less pervasive then. Nevertheless there were some subtle but significant breakages in 1--2 which caused a lot of people to throw up their hands and give up. The abandonment of regex comes to mind, and there were others. I personally earned income a couple years ago as a contractor supporting Python 1.x applications which were put into cryogenic preservation when the developers decided to abandon Python in favor of a less chaotic platform, like Java or C# or even (got help us) Perl. I apologize if I pontificate. -- Aaron Watters -- http://mail.python.org/mailman/listinfo/python-list
Re: I strongly dislike Python 3
On 2010-06-28, Thomas Jollans tho...@jollans.com wrote: On 06/28/2010 03:21 AM, Stephen Hansen wrote: On 6/27/10 6:11 PM, geremy condra wrote: On Sun, Jun 27, 2010 at 8:50 PM, Grant Edwardsinva...@invalid.invalid wrote: If you install a real shell on Windows, then the hash-bang line works fine. :) Might as well spare yourself the trouble and install linux or *bsd. It's probably easier. Not at all, bash via msys is trivial to install and use. Installing Linux is still a LOT easier than installing a working MSYS since you get proper package management with proper dependency resolution, while with MSYS, you end up downloading dozens of different inter-dependent GNU packages one-by-one until anything works. At least that's what it looked like a couple of months ago. Granted, cygwin has a nice installer. Cygwin's installer is OK if you're installing while online. Otherwise, it's difficult unless you download absolutely everything. -- Grant Edwards grant.b.edwardsYow! Let me do my TRIBUTE at to FISHNET STOCKINGS ... gmail.com -- http://mail.python.org/mailman/listinfo/python-list
optparse TypeError
I get an int object is not callable TypeError when I execute this. But I don't understand why. parser = optparse.OptionParser(usage: %lines [options] arg1) parser.add_option(-l, --lines, dest=lines, default=10, type=int, help=number of lines) parser.add_option(-t, --topbottom, dest=topbottom, default=T, type=str, help=T(op) or B(ottom)) (options, args) = parser.parse_args() if len(args) != 1: parser.error(incorrect number of arguments) lines=options.lines tb=options.topbottom Dirk lines(args[0],topbottom=tb,maxi=lines) -- http://mail.python.org/mailman/listinfo/python-list
Copy / Update - Paste a directory.
Hello everybody ! wow my first time on this mailing list :) Well, here the deal. Im doing a script that basically copy and past into the local drive a specified directory with all this files. Im doing the copy with a copytree which is working well. But, (and I know it will not work as copytree dont update directory) Im, like, stuck when I have to update the directory. For a better understanding here what the tree look like: G:/prod/actual/project/xxx/shot/shot_EN_006/render/v001 and sometime as we have to rerender, we update the render folder with a v002: G:/prod/actual/project/xxx/shot/shot_EN_006/render/v002 So, actually my script can copy my *G:/*prod/actual/project/xxx/shot/shot_EN_006/render/v001 directory to *C:/*prod/actual/project/xxx/shot/shot_EN_006/render/v001 but I dont know how to proceed to update this folder when asked. Here the actual script, as you can see the update part will not work. -- -- # -*- coding: utf-8 -*- import os import sys import threading import shutil def checkRead(): networkMount = 'D:/' localMount = 'C:/' for item in sys.argv: project = (sys.argv[2]) path = (sys.argv[3]) workPath = '/Prod//Projects/' + '/' + project + '/' + '/shots/' + '/' + path + '/' + '/render/' + '/REN/' localPath = localMount + workPath networkPath = networkMount + workPath if sys.argv[1] == 'update': if os.listdir(networkPath) != os.listdir(localPath): copyfile = shutil.copyfile(networkPath, localPath) elif sys.argv[1] == 'copy': if os.path.exists(localPath) == 0: copytree = shutil.copytree(networkPath, localPath, symlinks=True, ignore=None) if sys.argv[1] not in ('update', 'copy'): print 'Error, please enter the command: update or copy' if __name__ == __main__: checkRead() -- -- Anyone can help me to figure out a solution please ?. Thank you and have a good day ! PS: Im not sure that the first mail worked so I resend it, sorry for the flood. -- http://mail.python.org/mailman/listinfo/python-list
Re: optparse TypeError
On 28 June 2010 14:30, dirknbr dirk...@gmail.com wrote: I get an int object is not callable TypeError when I execute this. But I don't understand why. (snip) lines=options.lines Here you are assigning the -l option to the name 'lines'. lines(args[0],topbottom=tb,maxi=lines) Here you are attempting to call a function with the name 'lines'. But 'lines' has been assigned an integer above. I'm assuming that elsewhere you've defined a function called 'lines'. You'll need to call either the function or the option by another name. -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list
Re: I strongly dislike Python 3
In article mailman.2146.1277570052.32709.python-l...@python.org, Thomas Jollans tho...@jollans.com wrote: There is no reason for print not being a function. Also, do you use print *that* much? Really? I use it all the time. Who doesn't? What do you use instead? -- -Ed Falk, f...@despams.r.us.com http://thespamdiaries.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: I strongly dislike Python 3
Edward A. Falk, 28.06.2010 16:15: In articlemailman.2146.1277570052.32709.python-l...@python.org, Thomas Jollans wrote: There is no reason for print not being a function. Also, do you use print *that* much? Really? I use it all the time. Who doesn't? What do you use instead? Usually file.write() or log.info() and friends. Since you can't really control the encoding used by print(), nor redirect it locally, it's mostly useless for anything but debugging and small scripts. Stefan -- http://mail.python.org/mailman/listinfo/python-list
video
http://www.islamhouse.com/tp/236845 -- http://mail.python.org/mailman/listinfo/python-list
Re: I strongly dislike Python 3
On 6/28/10 2:20 AM, Thomas Jollans wrote: On 06/28/2010 03:21 AM, Stephen Hansen wrote: On 6/27/10 6:11 PM, geremy condra wrote: On Sun, Jun 27, 2010 at 8:50 PM, Grant Edwardsinva...@invalid.invalid wrote: If you install a real shell on Windows, then the hash-bang line works fine. :) Might as well spare yourself the trouble and install linux or *bsd. It's probably easier. Not at all, bash via msys is trivial to install and use. Installing Linux is still a LOT easier than installing a working MSYS since you get proper package management with proper dependency resolution, while with MSYS, you end up downloading dozens of different inter-dependent GNU packages one-by-one until anything works. At least that's what it looked like a couple of months ago. Granted, cygwin has a nice installer. Huh? The hardest part about installing msys is adding mingw-get to the PATH. Then you just mingw-get install mingwrt w32api binutils gcc and you have your basic environment done. If there's something you want in addition, say gdb, you just mingw-get install gdb. You don't have to pick and choose various interdependent packages. It does allt he dependency stuff for the packages it can handle. Now, mingw-get is a bit newish (though I don't know when they came out with it), but before that you only had to pick and choose packages IIRC if you decided you wanted a really minimal msys. You could get a basic 'meh, basically everything normal' and just run with it and have nearly everything you'd expect in a bash-command-line sort of environment. -- ... Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -- http://mail.python.org/mailman/listinfo/python-list
Re: I strongly dislike Python 3
On 2010-06-28, Stefan Behnel stefan...@behnel.de wrote: Edward A. Falk, 28.06.2010 16:15: In articlemailman.2146.1277570052.32709.python-l...@python.org, Thomas Jollans wrote: There is no reason for print not being a function. Also, do you use print *that* much? Really? I use it all the time. Who doesn't? What do you use instead? Usually file.write() or log.info() and friends. Since you can't really control the encoding used by print(), nor redirect it locally, it's mostly useless for anything but debugging and small scripts. Maybe it's just me, but I find both debugging and small scripts to be very useful. -- Grant Edwards grant.b.edwardsYow! I need to discuss at BUY-BACK PROVISIONS gmail.comwith at least six studio SLEAZEBALLS!! -- http://mail.python.org/mailman/listinfo/python-list
Re: I strongly dislike Python 3
On 6/28/10 7:15 AM, Edward A. Falk wrote: In articlemailman.2146.1277570052.32709.python-l...@python.org, Thomas Jollanstho...@jollans.com wrote: There is no reason for print not being a function. Also, do you use print *that* much? Really? I use it all the time. Who doesn't? What do you use instead? It depends on what my purpose is. If its debugging output or something similar, I use the logging module exclusively (the fine grained control it gives me on just how much information, categorized as such, with which modules, is invaluable to prevent brain hemorrhage from TMI or confusion from TLI). Any other use, I basically operate on a file object. I never write to stdout directly, but instead to some file object passed into some function-- it may very well be stdout, but the code doesn't know that, because I half the time I don't have a stdout (or stderr) and half the time I do. I *could* use, say, print file_object, ... in those cases, but I sort of hate that construct kind of a lot. So don't. :) -- ... Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -- http://mail.python.org/mailman/listinfo/python-list
Re: An invalid expression as parameter
On 6/28/10 5:47 AM, Li Hui wrote: When write i for i in range(16) I get SyntaxError: invalid syntax but When I use it like this: def f(x):\ ... pass f(i for i in range(16)) all is right I think it maybe f((i for i in range(16))) The expression for name in iterator syntax is actually two very different things. One is a list comprehension, one is a generator comprehension. (Then there's dictionary stuff later, but I shant complicate matters!) One creates a list, the other creates a generator which is a kind of iterator, which (eventually) something else can scan over to get and operate on a sequence. A list comprehension must be within brackets, as so: [i for i in range(4)] [0, 1, 2, 3] If you want to enter a generator expression on its own, you must surround it in parens, as: (i for i in range(4)) generator object at 0x6a2d8 Note though, that you get a generator object and not a list or anything. You can see what that generator would do by: gen = (i for i in range(4)) for x in gen: ... print x ... 0 1 2 3 Now, if you are entering a generator where its not 'on its own' and its not ambiguous-- such as inside a function call-- you don't have to surround it by its own parens. So you don't have to do f((i for i in range(4)). You only have to group it when its own its own. I mean you *can* wrap parens around it all the time: but just as parens don't create tuples, the parens don't -create- the generator so much as set it apart from possibly confusing surrounding elements when needed. -- ... Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -- http://mail.python.org/mailman/listinfo/python-list
Re: I strongly dislike Python 3
On 6/28/10 7:35 AM, Grant Edwards wrote: On 2010-06-28, Stefan Behnelstefan...@behnel.de wrote: Edward A. Falk, 28.06.2010 16:15: In articlemailman.2146.1277570052.32709.python-l...@python.org, Thomas Jollans wrote: There is no reason for print not being a function. Also, do you use print *that* much? Really? I use it all the time. Who doesn't? What do you use instead? Usually file.write() or log.info() and friends. Since you can't really control the encoding used by print(), nor redirect it locally, it's mostly useless for anything but debugging and small scripts. Maybe it's just me, but I find both debugging and small scripts to be very useful. No one said otherwise, or that print was useless and never used in such contexts. -- ... Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -- http://mail.python.org/mailman/listinfo/python-list
Re: GDAL-1.7.1 : vcvarsall.bat missing
On Jun 25, 9:51 am, Max Erickson maxerick...@gmail.com wrote: kBob krd...@gmail.com wrote: On Jun 25, 1:26 am, Mark Lawrence breamore...@yahoo.co.uk wrote: On 24/06/2010 21:48, Christian Heimes wrote: I am attempting to install the GDAL bindings (GDAL-1.7.1) on a Windows XP Desktop with Python 2.6 and GDAL. During install, the If it suits your needs, you can wire the OSGEO installation of GDAL to a python.org python installation (rather than a bundled OSGEO python interpreter, which is another option): http://trac.osgeo.org/osgeo4w/ Setting the correct paths was enough to get the basic things I used to work (but I haven't used it extensively). Thanks for the tips, gentlemen. I'll try my luck with Cygwin's ggc before I look into another C/C++ compiler. Kelly Dean Fort Collins, CO Giovanni Bajo packages a version of MinGW GCC for use with Python: http://www.develer.com/oss/GccWinBinaries He does note on the page that the MinGW project isn't quite so sure that GCC 4.x is ready for release. Max Thanks again for the tips. Your suggestions are very helpful. I was able to get the FWTools installed on the Windows Desktop. It worked out very well. No issues with the GDAL included in this set of binaries. However, I am intrigued with the OSGeo Project, especially with the Qt binaries included. After understanding GDAL, I'll have to build some GUI applications to display the GeoTIFF, MrSID, and JPG2000. I was planning to use Tkinter, but with Qt available from OSgeo4W, it will give me an opportunity to explorer the GUI development offer by this package. Kelly Dean Fort Collins, CO -- http://mail.python.org/mailman/listinfo/python-list
Re: Python as a scripting language. Alternative to bash script?
On Mon, Jun 28, 2010 at 4:48 AM, Dave Pawson dave.paw...@gmail.com wrote: I've a fairly long bash script and I'm wondering how easy it would be to port to Python. Main queries are: Ease of calling out to bash to use something like imageMagick or Java? Easiest way is os.system, most flexible way is subprocess.Popen. Ease of grabbing return parameters? E.g. convert can return both height and width of an image. Can this be returned to the Python program? How does a program return anything other than an exit code? Subprocess allows you to read the program's stdout if that's what you're looking for. In the case of ImageMagick, you can use a Python wrapper to the library instead of calling the program from the command line, and then you can get all the return values you want. Can Python access the exit status of a program? proc = subprocess.Popen(args) retcode = proc.wait() There's a shortcut of retcode = subprocess.call(args), but that doesn't give you access to stdout, just the return code. I'd prefer the advantages of using Python, just wondering if I got so far with the port then found it wouldn't do something? If there's anything it can't do that bash can, you can always just call the shell command. Has anyone made this comparison please? If you already have a working shell script, it's probably not worth your time. But if you've having trouble getting bash to cooperate, it's not that difficult to rewrite a shell script in Python. TIA -- Dave Pawson XSLT XSL-FO FAQ. Docbook FAQ. http://www.dpawson.co.uk -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Python as a scripting language. Alternative to bash script?
On Mon, 28 Jun 2010 12:48:51 +0100 Dave Pawson dave.paw...@gmail.com wrote: I've a fairly long bash script and I'm wondering how easy it would be to port to Python. That's too big a question without seeing more of what your script does. I will try to suggest some direction though. First, if you have a complicated bash script that works, the best choice may be to just leave it alone. Think about Python for your next project instead. Main queries are: Ease of calling out to bash to use something like imageMagick or Java? You don't need to call bash to call an external program. Check out the subprocess module. If you do need a shell to simplify calling a program (environment and wild card expansione.g.) don't call bash. Just use a basic sh. You won't be using the bash control structures so keep to whatever is supplied by your OS. If that turns out to be bash anyway then no harm. Another option is to write small Python scripts that you can call from your bash script. You can even create them in your bash script. Here is a silly example. uc=import sys s = sys.argv[1] print s.upper() ... echo -n Upper case of $SOMESTRING is ; python -c $uc $SOMESTRING Ease of grabbing return parameters? E.g. convert can return both height and width of an image. Can this be returned to the Python program? Just to set the terminology straight, a parameter is what you call the function with. The return value is what it returns. The program output is what it emits (prints.) Programs return an integer value. This is also called the exxit status. On success this is 0 but can be otherwise on failure. You can use this, for example, with diff to determine if two files differ when you don't care how they differ. What you want is the output of the program. For this you need to capture the output and parse it. Look at the subprocess module. -- D'Arcy J.M. Cain da...@druid.net | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
In article 4c285e7c$0$17371$426a7...@news.free.fr, Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid wrote: Aahz a écrit : In article 4c2747c1$0$4545$426a7...@news.free.fr, Bruno Desthuilliers bdesth.quelquech...@free.quelquepart.fr wrote: Python has no pretention at elegance. That's not true at all. More precisely, I would agree with you if the emphasis is on pretention but not if the emphasis is on elegance; Python Zen, #9 (or #8 if you're a TrueHacker !-)) ...and this implies that Python has no focus on elegance because...? -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ If you don't know what your program is supposed to do, you'd better not start writing it. --Dijkstra -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
On 6/28/10 8:27 AM, Aahz wrote: In article4c285e7c$0$17371$426a7...@news.free.fr, Bruno Desthuilliersbruno.42.desthuilli...@websiteburo.invalid wrote: Aahz a écrit : In article4c2747c1$0$4545$426a7...@news.free.fr, Bruno Desthuilliersbdesth.quelquech...@free.quelquepart.fr wrote: Python has no pretention at elegance. That's not true at all. More precisely, I would agree with you if the emphasis is on pretention but not if the emphasis is on elegance; Python Zen, #9 (or #8 if you're a TrueHacker !-)) ...and this implies that Python has no focus on elegance because...? Um, yeah, seriously :) #1-#7 seem to all be quite about not just elegance, but how to define it :) -- ... Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -- http://mail.python.org/mailman/listinfo/python-list
Re: optparse TypeError
On Jun 28, 3:30 pm, dirknbr dirk...@gmail.com wrote: I get an int object is not callable TypeError when I execute this. But I don't understand why. parser = optparse.OptionParser(usage: %lines [options] arg1) parser.add_option(-l, --lines, dest=lines, default=10, type=int, help=number of lines) parser.add_option(-t, --topbottom, dest=topbottom, default=T, type=str, help=T(op) or B(ottom)) (options, args) = parser.parse_args() if len(args) != 1: parser.error(incorrect number of arguments) lines=options.lines tb=options.topbottom Dirk lines(args[0],topbottom=tb,maxi=lines) optparse is so old-fashioned. Use plac! $ cat x.py import plac @plac.annotations( lines=('number of lines', 'option', 'l', int), topbottom=('T(op) or B(ottom)', 'option', 't', str, 'TB')) def main(arg, lines=10, topbottom='T'): print arg, lines, topbottom if __name__ == '__main__': plac.call(main) $ python x.py -h usage: x.py [-h] [-l 10] [-t T] arg positional arguments: arg optional arguments: -h, --help show this help message and exit -l 10, --lines 10number of lines -t T, --topbottom T T(op) or B(ottom) (see http://pypi.python.org/pypi/plac) -- http://mail.python.org/mailman/listinfo/python-list
Python 2.6.x version module compatibility
Suppose I have a webapp running in a virtualenv (--no-site-packages) cloned off a Python 2.6.2 install, running under mod_wsgi. The virtual environment has various modules installed in it, some perhaps using C extensions. Question: If the Python installation gets upgraded to 2.6.5 (or 2.6.7 at some future point), and assuming mod_wsgi also gets compiled/installed against the new version, will the virtual environments have to be rebuilt and the modules re-installed? Or, are Python installations w/in the 2.6.x series backwards compatible enough that, in the general case, the webapp will continue to work as is? This is under Linux, if it makes a difference. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python as a scripting language. Alternative to bash script?
Thanks for the replies (and Benjamin). Not met with the subprocess idea. On 28 June 2010 16:29, D'Arcy J.M. Cain da...@druid.net wrote: Main queries are: Ease of calling out to bash to use something like imageMagick or Java? You don't need to call bash to call an external program. Check out the subprocess module. Will do. If you do need a shell to simplify calling a program (environment and wild card expansione.g.) don't call bash. I can get what I want from Python. No envars needed. Ease of grabbing return parameters? E.g. convert can return both height and width of an image. Can this be returned to the Python program? Just to set the terminology straight, a parameter is what you call the function with. The return value is what it returns. The program output is what it emits (prints.) My bad. I mean return values, though I do want program out from (for example) identify Programs return an integer value. This is also called the exit status. Sheer greed, for identify I may get either a return value or an exit status (bad input etc) :-) Looks like subprocess can hack it though. What you want is the output of the program. For this you need to capture the output and parse it. Look at the subprocess module. Will do. tks D'Arcy (and Benjamin) -- Dave Pawson XSLT XSL-FO FAQ. Docbook FAQ. http://www.dpawson.co.uk -- http://mail.python.org/mailman/listinfo/python-list
More MySQL Stuff
Hi; So I'm launching into a major rewrite of my shopping cart because I've finally woken up to the challenge of injection attacks. One of my major problems is that many column names are determined when the shopping cart is built. For example, how many photos are to be uploaded is determined that way, thus there will be a column such as pic1 and another pic2 up as many as the client desires. Now, I guess I could cap that at, say, 9, and create as many columns, but then there's the issue of creating columns for all the different mixins that I add. For example, when the shop is created, if it's a jewelry store, I automatically add columns appropriate to the same (ring size, etc.). Now, I guess I could just create a table with all those columns added in irrespective of what kind of store it is, then hide those that aren't used when I print to screen such things as product descriptions or the form the client uses to upload his data, but that's inelegant. Any other suggestions? TIA. beno -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6.x version module compatibility
On 6/28/10 9:06 AM, Ratufa wrote: Suppose I have a webapp running in a virtualenv (--no-site-packages) cloned off a Python 2.6.2 install, running under mod_wsgi. The virtual environment has various modules installed in it, some perhaps using C extensions. Question: If the Python installation gets upgraded to 2.6.5 (or 2.6.7 at some future point), and assuming mod_wsgi also gets compiled/installed against the new version, will the virtual environments have to be rebuilt and the modules re-installed? Or, are Python installations w/in the 2.6.x series backwards compatible enough that, in the general case, the webapp will continue to work as is? This is under Linux, if it makes a difference. ABI changes in minor releases (2.6.5 - 2.6.6, etc) are not allowed; so as long as the C extensions (and certainly the python code, unless someone messed up badly) were compiled with 2.6.x, they should work fine with later updates to 2.6. The exception of course would be if there's some bug or regression that happened, but its not *supposed* to happen. Conversely, if you upgrade to 2.7, you'll probably need to end up recompiling all the C extensions. -- ... Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -- http://mail.python.org/mailman/listinfo/python-list
Re: I strongly dislike Python 3
On 06/28/2010 04:36 PM, Stephen Hansen wrote: On 6/28/10 2:20 AM, Thomas Jollans wrote: On 06/28/2010 03:21 AM, Stephen Hansen wrote: On 6/27/10 6:11 PM, geremy condra wrote: On Sun, Jun 27, 2010 at 8:50 PM, Grant Edwardsinva...@invalid.invalid wrote: If you install a real shell on Windows, then the hash-bang line works fine. :) Might as well spare yourself the trouble and install linux or *bsd. It's probably easier. Not at all, bash via msys is trivial to install and use. Installing Linux is still a LOT easier than installing a working MSYS since you get proper package management with proper dependency resolution, while with MSYS, you end up downloading dozens of different inter-dependent GNU packages one-by-one until anything works. At least that's what it looked like a couple of months ago. Granted, cygwin has a nice installer. Huh? The hardest part about installing msys is adding mingw-get to the PATH. Then you just mingw-get install mingwrt w32api binutils gcc and you have your basic environment done. If there's something you want in addition, say gdb, you just mingw-get install gdb. You don't have to pick and choose various interdependent packages. It does allt he dependency stuff for the packages it can handle. Now, mingw-get is a bit newish (though I don't know when they came out with it), but before that you only had to pick and choose packages IIRC if you decided you wanted a really minimal msys. You could get a basic 'meh, basically everything normal' and just run with it and have nearly everything you'd expect in a bash-command-line sort of environment. mingw-get. That might be exactly the tool I wish I'd had. Does it install MSYS as well or only strictly MinGW components? To quote the information I did have (which is still on the MinGW homepage): Currently, the best way to download MSYS is to choose the MSYS components you want from the download page and to extract them one by one in an empty directory. Oh well Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: Python as a scripting language. Alternative to bash script?
On 06/28/2010 06:08 PM, Dave Pawson wrote: Thanks for the replies (and Benjamin). Not met with the subprocess idea. On 28 June 2010 16:29, D'Arcy J.M. Cain da...@druid.net wrote: Main queries are: Ease of calling out to bash to use something like imageMagick or Java? You don't need to call bash to call an external program. Check out the subprocess module. Will do. If you do need a shell to simplify calling a program (environment and wild card expansione.g.) don't call bash. I can get what I want from Python. No envars needed. Ease of grabbing return parameters? E.g. convert can return both height and width of an image. Can this be returned to the Python program? Just to set the terminology straight, a parameter is what you call the function with. The return value is what it returns. The program output is what it emits (prints.) My bad. I mean return values, though I do want program out from (for example) identify If you're working with images, have a look at the PIL (Python Imaging Library). Programs return an integer value. This is also called the exit status. Sheer greed, for identify I may get either a return value or an exit status (bad input etc) :-) Looks like subprocess can hack it though. What you want is the output of the program. For this you need to capture the output and parse it. Look at the subprocess module. Will do. tks D'Arcy (and Benjamin) -- http://mail.python.org/mailman/listinfo/python-list
Re: More MySQL Stuff
On 6/28/10 9:10 AM, Victor Subervi wrote: Hi; So I'm launching into a major rewrite of my shopping cart because I've finally woken up to the challenge of injection attacks. One of my major problems is that many column names are determined when the shopping cart is built. For example, how many photos are to be uploaded is determined that way, thus there will be a column such as pic1 and another pic2 up as many as the client desires. Now, I guess I could cap that at, say, 9, and create as many columns, Ah, you are now entering the realm of Normalization. If you think a table requires a variable number of columns, you have designed the table incorrectly: no table needs a variable number of columns. Basically, the crux of the matter is: a table does not need, and indeed often should not, contain every bit of detail about a certain product. Let's say you have a basic product table: (The syntax on this may not be exactly MySQL-esque, so you'll have to look it up and/or adjust: I'm doing the SQL just as an example): CREATE TABLE Products ( product_sku INTEGER PRIMARY KEY, product_name VARCHAR(200) NOT NULL, product_cost MONEY NOT NULL, product_description TEXT, ... ) Etcetera. Here, in this table, you include everything that is general, generic, universal to your products. A key important point: in no circumstance should the same piece of data ever be in two columns, or two tables at once (unless that piece of data is what's linking the two tables together-- a foreign key, but I won't go into that too much yet-- I don't even know if MySQL enforces relationships). Now, you want to handle pictures? Okay, great, we do: CREATE TABLE ProductPictures ( product_sku INTEGER NOT NULL, picture_num INTEGER NOT NULL, picture_desc TEXT, picture_data IMAGE, PRIMARY KEY (product_sku, picture_id) ) Now, you suddenly can have one picture per product: or a hundred. It doesn't matter anymore. If you want to get a list of all pictures for a product, you do: SELECT picture_id, picture_desc, picture_data FROM ProductPictures WHERE product_sku = sku ORDER BY picture_id (Also, notice that product_sku is the same name in every table, and that each table sort of has its own prefix? This is good practice. Even though product_sku in ProductPictures is in the pictures table, the value of that field is really a reference to a sku defined int he Products table). Another point: you'll notice that in ProductPictures, the primary key is a composite of two fields. Picture_id's may be duplicated in this table, but the combination of (product_sku, picture_num) will always be unique. but then there's the issue of creating columns for all the different mixins that I add. For example, when the shop is created, if it's a jewelry store, I automatically add columns appropriate to the same (ring size, etc.). Now, I guess I could just create a table with all those columns added in irrespective of what kind of store it is, then hide those that aren't used when I print to screen such things as product descriptions or the form the client uses to upload his data, but that's inelegant. Any other suggestions? It depends on just how generic you want this application to be. There's two approaches I've used: a pseudo-inheritance' approach where I have a Product table which has the generic information, and then a SpecificKindOfProduct table which adds some columns: this I only use though in cases where I can basically pre-define the SpecificKinds, and I'm doing this for optimization purposes (ie, indexing and such). So I might have like: CREATE TABLE JewelryProduct ( product_sku INTEGER NOT NULL, jewelry_ringsize INTEGER NOT NULL, ... ) And such. But I only really do that if there's a finite set of 'types' of products the application is for (and in such cases, I *love* PostgreSQL's table inheritance stuff) The other approach is to make a generic 'extra details' table, which looks basically like: CREATE TABLE ProductDetails ( product_sku INTEGER NOT NULL, detail_keyVARCHAR (200) NOT NULL, detail_value TEXT, PRIMARY KEY (product_sku, detail_key) ) This is a very, very simple table, its basically a set of arbitrary key/value pairs for a given product-- its the SQL version of a dictionary for every product :) In fact, even when I do have SpecificKindOfProduct tables as I mention above, I usually have an 'extra stuff' table here-- for extra stuff, because certain things always come up that just need to be noted. But don't abuse such tables too much, because you can't index on them as well. The one thing I wouldn't do is make a table with a bajillion columns that are hidden/optional depending on what kind of store it is. Better a 'master' table with some related smaller tables that may only be used for certain types of products. -- ... Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT)
Re: CONTROLLED DEMOLITION INC explosive-charge placement technician ?Tom ?Sullivan 911 TESTIMONIAL Video
In comp.lang.c++ small Pox smallpox...@gmail.com wrote: Academia and Scientific and Arts community is the BIGGEST RECIPIENT of Federal Grants from TAX PAYER MONEY What's so hard to understand in take your religion elsewhere, we don't want it here? Go away. -- http://mail.python.org/mailman/listinfo/python-list
Re: I strongly dislike Python 3
On 6/28/10 9:23 AM, Thomas Jollans wrote: Installing Linux is still a LOT easier than installing a working MSYS since you get proper package management with proper dependency resolution, while with MSYS, you end up downloading dozens of different inter-dependent GNU packages one-by-one until anything works. At least that's what it looked like a couple of months ago. Granted, cygwin has a nice installer. Huh? The hardest part about installing msys is adding mingw-get to the PATH. Then you just mingw-get install mingwrt w32api binutils gcc and you have your basic environment done. If there's something you want in addition, say gdb, you just mingw-get install gdb. You don't have to pick and choose various interdependent packages. It does allt he dependency stuff for the packages it can handle. Now, mingw-get is a bit newish (though I don't know when they came out with it), but before that you only had to pick and choose packages IIRC if you decided you wanted a really minimal msys. You could get a basic 'meh, basically everything normal' and just run with it and have nearly everything you'd expect in a bash-command-line sort of environment. mingw-get. That might be exactly the tool I wish I'd had. Does it install MSYS as well or only strictly MinGW components? To quote the information I did have (which is still on the MinGW homepage): Currently, the best way to download MSYS is to choose the MSYS components you want from the download page and to extract them one by one in an empty directory. Umm, I'm confused now. I have no idea, I think perhaps I last installed msys itself with the full-installer bit, and have since added certain mingw components with mingw-get, but I have no idea. Except I swear that's not what happened. I don't know, I retract all claims, and am going to go back to my OSX Terminal.app :) -- ... Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -- http://mail.python.org/mailman/listinfo/python-list
Re: More MySQL Stuff
On Mon, Jun 28, 2010 at 12:11 PM, Stephen Hansen me+list/pyt...@ixokai.iowrote: On 6/28/10 9:10 AM, Victor Subervi wrote: Hi; So I'm launching into a major rewrite of my shopping cart because I've finally woken up to the challenge of injection attacks. One of my major problems is that many column names are determined when the shopping cart is built. For example, how many photos are to be uploaded is determined that way, thus there will be a column such as pic1 and another pic2 up as many as the client desires. Now, I guess I could cap that at, say, 9, and create as many columns, Ah, you are now entering the realm of Normalization. If you think a table requires a variable number of columns, you have designed the table incorrectly: no table needs a variable number of columns. Basically, the crux of the matter is: a table does not need, and indeed often should not, contain every bit of detail about a certain product. Let's say you have a basic product table: (The syntax on this may not be exactly MySQL-esque, so you'll have to look it up and/or adjust: I'm doing the SQL just as an example): CREATE TABLE Products ( product_sku INTEGER PRIMARY KEY, product_name VARCHAR(200) NOT NULL, product_cost MONEY NOT NULL, product_description TEXT, ... ) Etcetera. Here, in this table, you include everything that is general, generic, universal to your products. A key important point: in no circumstance should the same piece of data ever be in two columns, or two tables at once (unless that piece of data is what's linking the two tables together-- a foreign key, but I won't go into that too much yet-- I don't even know if MySQL enforces relationships). Now, you want to handle pictures? Okay, great, we do: CREATE TABLE ProductPictures ( product_sku INTEGER NOT NULL, picture_num INTEGER NOT NULL, picture_desc TEXT, picture_data IMAGE, PRIMARY KEY (product_sku, picture_id) ) Now, you suddenly can have one picture per product: or a hundred. It doesn't matter anymore. If you want to get a list of all pictures for a product, you do: SELECT picture_id, picture_desc, picture_data FROM ProductPictures WHERE product_sku = sku ORDER BY picture_id (Also, notice that product_sku is the same name in every table, and that each table sort of has its own prefix? This is good practice. Even though product_sku in ProductPictures is in the pictures table, the value of that field is really a reference to a sku defined int he Products table). Another point: you'll notice that in ProductPictures, the primary key is a composite of two fields. Picture_id's may be duplicated in this table, but the combination of (product_sku, picture_num) will always be unique. but then there's the issue of creating columns for all the different mixins that I add. For example, when the shop is created, if it's a jewelry store, I automatically add columns appropriate to the same (ring size, etc.). Now, I guess I could just create a table with all those columns added in irrespective of what kind of store it is, then hide those that aren't used when I print to screen such things as product descriptions or the form the client uses to upload his data, but that's inelegant. Any other suggestions? It depends on just how generic you want this application to be. There's two approaches I've used: a pseudo-inheritance' approach where I have a Product table which has the generic information, and then a SpecificKindOfProduct table which adds some columns: this I only use though in cases where I can basically pre-define the SpecificKinds, and I'm doing this for optimization purposes (ie, indexing and such). So I might have like: CREATE TABLE JewelryProduct ( product_sku INTEGER NOT NULL, jewelry_ringsize INTEGER NOT NULL, ... ) And such. But I only really do that if there's a finite set of 'types' of products the application is for (and in such cases, I *love* PostgreSQL's table inheritance stuff) The other approach is to make a generic 'extra details' table, which looks basically like: CREATE TABLE ProductDetails ( product_sku INTEGER NOT NULL, detail_keyVARCHAR (200) NOT NULL, detail_value TEXT, PRIMARY KEY (product_sku, detail_key) ) This is a very, very simple table, its basically a set of arbitrary key/value pairs for a given product-- its the SQL version of a dictionary for every product :) In fact, even when I do have SpecificKindOfProduct tables as I mention above, I usually have an 'extra stuff' table here-- for extra stuff, because certain things always come up that just need to be noted. But don't abuse such tables too much, because you can't index on them as well. The one thing I wouldn't do is make a table with a bajillion columns that are hidden/optional depending on what kind of store it is. Better a 'master' table with some related smaller tables that may only be used for
N00b question: matching stuff with variables.
Hi, all. I've got a file which, in turn, contains a couple thousand filenames. I'm writing a web front-end, and I want to return all the filenames that match a user-input value. In Perl, this would be something like, if (/$value/){print $_ matches\n;} But trying to put a variable into regex in Python is challenging me -- and, indeed, I've seen a bit of scorn cast upon those who would do so in my Google searches (You come from Perl, don't you?). Here's what I've got (in ugly, prototype-type code): file=open('/tmp/event_logs_listing.txt' 'r') # List of filenames seek = form[serial].value# Value from web form for line in file: match = re.search((seek),(.*),(.*), line) # Stuck here Clearly, the line, above, is just plain ol' wrong, but I'm including it to give a hint of what I'm trying to do. What's the correct Python-esque way to go about this? Thanks! -Ken -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python as a scripting language. Alternative to bash script?
On 06/28/2010 05:48 AM, Dave Pawson wrote: Main queries are: Ease of calling out to bash to use something like imageMagick or Java? Ease of grabbing return parameters? E.g. convert can return both height and width of an image. Can this be returned to the Python program? Can Python access the exit status of a program? Sure. I've created a module called runcmd that does 90% of what I want (easy access to stdout, stderr, error code). I've attached it to this e-mail. Feel free to use it; this post puts my code into the public domain. I'd prefer the advantages of using Python, just wondering if I got so far with the port then found it wouldn't do something? Python really isn't a shell scripting language. So there are things that Bash does much better, such as spawning processes and piping them together. I've tried over the years to create a pythonic library that would let me do that, but haven't found a good syntax that I like. It turns out, though, that much of what I use piping for in Bash is to run external processes to do things that I could use python modules for. For example, I typically pipe stuff to cut a lot to get certain fields. For example: ps ax | cut -c1-5 In python I could simply take the output of ps ax and use python's own, superior, cutting routines (using my module): (err, stdout, stderr) = runcmd.run( [ 'ps', 'ax' ] ) for x in stdout.split('\n'): print x.strip().split()[0] Sure it's a couple more lines in this case, but in other cases, python's abilities make it simpler than bash. A great document on how you can exploit python's abilities (particularly generators) to replace bash pipelines is here: http://www.dabeaz.com/generators/ #!/usr/bin/python import subprocess import sys import fcntl import os import select import StringIO This module contains a single function run() that spawns a process with arguments, and returns it's errcode, stdout, and stderr. It currently has a number of deficiencies, including the lack of a way to kill the child. def _make_non_blocking(fd): Takes a file descriptor and sets it to non-blocking IO mode, allowing us to use the posix select() on it. Used by this module to allow us to read from a process as it writes to stderr and stdout @type fd: number @param fd: file descriptor number to set to nonblocking fl = fcntl.fcntl(fd, fcntl.F_GETFL) fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK) def run(cmd, **kwargs): Runs a command using the subprocess.Popen class, and returns the err, stdout, and stderr of the process. Optionally it can print to stdout the process's stderr and stdout, and can also call callbacks when stdout and stderr is available from the process. The following kwargs are useful: - print_stdout - if set to True will print process stdout to stdout as data arrives - print_stderr - if set to True will print process stderr to stdout as data arrives - stdin - Text to feed to process's stdin - stdout_callback - function to call with stdout data - stderr_callback - function to call with stderr data @type cmd: text or list @param cmd: the command to run, use a list if args are passed @type kwargs: keyword args @param kwargs: optional keyword arguments (see above) @rtype: tuple @return: Tuple of error code, stdout text, stderr text # Set flags depending on kwargs if print_stdout in kwargs: print_stdout=True else: print_stdout=False if print_stderr in kwargs: print_stderr=True else: print_stderr=False if stdout_callback in kwargs: stdout_callback=kwargs[stdout_callback] print setting stdout callback else: stdout_callback=None if stdout_callback in kwargs: stderr_callback=kwargs[stderr_callback] print setting stderr callback else: stderr_callback=None if shell in kwargs: shell=kwargs[shell] else: shell=False # create process object, set up pipes child = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0, shell=shell ) # give the process any stdin that we might have, then # close stdin to prevent deadlocks if stdin in kwargs: child.stdin.write(kwargs[stdin]) child.stdin.close() # get output pipes, make them non-blocking fo=child.stdout fe=child.stderr _make_non_blocking(fo.fileno()) eof=False stdout=StringIO.StringIO() stderr=StringIO.StringIO() # Loop, checking for data on process's stdout and stderr # until
PDF Generation With Reportlab
Hi All I am hoping there is someone out there that knows reportlab quite well. I posted this on the reportlab mailing list but there is not much activity on that list I am currently generating a pdf report using reportlab 2.3 and python 2.5.4. The report has a table that spans multiple pages. My problem is that the portions on the table that continues after the first page, is starting at a point not defined by me, so it creates a layer over the logo which is on each page. How do I specify the starting point of each page the table spans ? Normally I would use pagebreak and spacers but I cannot figure out how to fit this into the table structure. I also looked at using the myLaterPages function, but it does not seem that I can do this with the canvas. Here is a small extract of my current code doc = SimpleDocTemplate(test.pdf) Story = [Spacer(1, mm * 60)] #populate story with first page record_data = [] for var1, var2, var3, var4, var5 in cursor.fetchall(): Story.append(PageBreak()) Story.append(Spacer(1, mm * 15)) Story.append(Paragraph(var1, heading1)) Story.append(Spacer(1, mm * 5)) Story.append(Paragraph(var2, description)) Story.append(Spacer(1, mm * 5)) record_data.append([Paragraph('Header 1', grid_header), Paragraph('Header 2', grid_header), Paragraph('Header 3', grid_header), Paragraph('Header 4', grid_header), Paragraph('Header 5', grid_header)]) record_data.append([Paragraph(var1, grid), Paragraph(var2, grid), Paragraph(var3, grid), Paragraph(var4, grid), Paragraph(var5, grid)]) t = Table(record_data, style=[('GRID', (0, 0), (-1, - 1), 0.5, colors.HexColor('#00204E'))], colWidths=[65, 220, 50, 50, 40]) Story.append(t) doc.build(Story, onFirstPage=myFirstPage, onLaterPages=myLaterPages) myFirstPage and MyLaterPages are functions that use the canvas to draw the page header and footer. Any advice would be greatly appreciated. Cheers Albert -- http://mail.python.org/mailman/listinfo/python-list
Re: N00b question: matching stuff with variables.
On 06/28/2010 07:29 PM, Ken D'Ambrosio wrote: Hi, all. I've got a file which, in turn, contains a couple thousand filenames. I'm writing a web front-end, and I want to return all the filenames that match a user-input value. In Perl, this would be something like, if (/$value/){print $_ matches\n;} But trying to put a variable into regex in Python is challenging me -- and, indeed, I've seen a bit of scorn cast upon those who would do so in my Google searches (You come from Perl, don't you?). Here's what I've got (in ugly, prototype-type code): file=open('/tmp/event_logs_listing.txt' 'r') # List of filenames seek = form[serial].value# Value from web form for line in file: match = re.search((seek),(.*),(.*), line) # Stuck here without re: for line in file: if line.startswith(seek): # or: if seek in line... # do stuff with re and classic string formatting: for line in file: # or use re.match to look only at the beginning of the line match = re.search('(%s),(.*),(.*)' % seek, line) if match: #use match.group(n) for further processing You could also concatenate strings to get the regexp, as in: '('+seek+'),(.*),(.*)' Note that while using re is perl way to do strings, Python has a bunch of string methods that are often a better choice, such as str.startswith or the (xyz in vwxyz!) syntax. if you just want to get the matching lines, you could use list comprehension: matching = [ln for ln in file if ln.startswith(seek)] Just to present some of the ways you can do this in Python. I hope you're enjoying the language. -- Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: N00b question: matching stuff with variables.
On 6/28/10 10:29 AM, Ken D'Ambrosio wrote: Hi, all. I've got a file which, in turn, contains a couple thousand filenames. I'm writing a web front-end, and I want to return all the filenames that match a user-input value. In Perl, this would be something like, if (/$value/){print $_ matches\n;} But trying to put a variable into regex in Python is challenging me -- and, indeed, I've seen a bit of scorn cast upon those who would do so in my Google searches (You come from Perl, don't you?). First of all, if you're doing this, you have to be aware that it is *very* possible to write a pathological regular expression which will can kill your app and maybe your web server. So if you're letting them write regular expressions and they aren't like, smartly-trusted-people, be wary. Here's what I've got (in ugly, prototype-type code): file=open('/tmp/event_logs_listing.txt' 'r') # List of filenames seek = form[serial].value# Value from web form for line in file: match = re.search((seek),(.*),(.*), line) # Stuck here Now, if you don't need the full power of regular expressions, then what about: name, foo, bar = line.split(,) if seek in name: # do something with foo and bar That'll return True if the word 'seek' appears in the first field of what appears to be the comma-delimited line. Or maybe, if you're worried about case sensitivity: if seek.lower() in name.lower(): # la la la You can do a lot without ever bothering to mess around with regular expressions. A lot. Its also faster if you're doing simpler things :) If they don't need to do the full power of regular expressions, but just simple globbing? Then maybe change it to: seeking = re.escape(seek) seeking = seeking.replace(\\*, .*) seeking = seeking.replace(\\?, .) match = re.search(seeking + ,(.*),(.*), line) FIrst, we escape the user input so they can't put in any crazy regular expression characters. Then we go and *unescape* \\* and turn it into a .* -- becaues when a user enters *, the really mean .* in traditional glob-esque. Then we do the same with the question mark turning into a dot. Then! We go and run our highly restricted regular expression through basically just as you were doing before-- you just didn't concatenate the 'seek' string to the rest of your expression. If you must give them full regex power and you know they won't try to bomb you, just leave out the 'seeking = ' lines and cross your fingers. -- ... Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -- http://mail.python.org/mailman/listinfo/python-list
Re: N00b question: matching stuff with variables.
On Monday 28 June 2010 10:29:35 Ken D'Ambrosio wrote: Hi, all. I've got a file which, in turn, contains a couple thousand filenames. I'm writing a web front-end, and I want to return all the filenames that match a user-input value. In Perl, this would be something like, if (/$value/){print $_ matches\n;} I presume you're suitably sanitizing $value before you arbitrarily use it ;-)? file=open('/tmp/event_logs_listing.txt' 'r') # List of filenames seek = form[serial].value# Value from web form for line in file: match = re.search((seek),(.*),(.*), line) # Stuck here Not sure what you're trying to do, here, with the extra regex groups? If you just want to naively check for the presence of that user-input value, you can do: seek = sanitize(form[serial].value) for line in file: match = re.search(seek, line) # re.search(pattern, string, flags) if match is not None: print %s matches % line One thing that certainly confused me when I learned Python (coming from, among other things, Perl) was the lack of implicit variables -- is that what's tripping you up? Hope that helps, Rami Rami Chowdhury Given enough eyeballs, all bugs are shallow. -- Linus' Law +1-408-597-7068 / +44-7875-841-046 / +88-01819-245544 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python as a scripting language. Alternative to bash script?
On 6/28/2010 7:58 AM, Benjamin Kaplan wrote: How does a program return anything other than an exit code? Ah, yes, the second biggest design mistake in UNIX. Programs have argv and argc, plus environment variables, going in. So, going in, there are essentially subroutine parameters. But all that comes back is an exit code. They should have had something similar coming back, with arguments to exit() returning the results. Then the many small intercommunicating programs concept would have worked much better. C was like that once. In the 1970s, all you could return was an int or a float. But that got fixed. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Why Python3
Steven D'Aprano wrote: None of PyPy, Unladen Swallow or IronPython are dependencies for Python 3.x to be ready for prime time. Neither is C module support. I think this is being overoptimistic. For me, ready for prime time means I can rely on being able to find a way to do what I want to do with it. This includes being able to find third-party libraries that do what I want to do. Right now, I can't really rely on Python 3 in this way. snip For the rest of us, you can do a lot with just Python 3.1, with or without C modules. Whether it does *enough* to be considered for deployment depends on what you're deploying it to do. I for one would not hesitate to use Python 3.1 as a scripting language, or for any application where the standard library is all you need. You can do a lot with just the standard library. The thing is that, for me at least, this isn't sufficient, because I often don't know what all I'm going to need when I start off. I may decide to add some new feature that requires an extra library, and only then find out that I can't, because that library doesn't exist for Python 3. Some things are part of the standard lib, some aren't. I want to be able to start a project and be able to find what I need, whether that's part of the standard lib or not. -- --OKB (not okblacke) Brendan Barnwell Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail. --author unknown -- http://mail.python.org/mailman/listinfo/python-list
Re: Python as a scripting language. Alternative to bash script?
On 28 June 2010 18:39, Michael Torrie torr...@gmail.com wrote: On 06/28/2010 05:48 AM, Dave Pawson wrote: Main queries are: Ease of calling out to bash to use something like imageMagick or Java? Ease of grabbing return parameters? E.g. convert can return both height and width of an image. Can this be returned to the Python program? Can Python access the exit status of a program? Sure. I've created a module called runcmd that does 90% of what I want (easy access to stdout, stderr, error code). I've attached it to this e-mail. Feel free to use it; this post puts my code into the public domain. Thanks Michael. I'd prefer the advantages of using Python, just wondering if I got so far with the port then found it wouldn't do something? Python really isn't a shell scripting language. So there are things that Bash does much better, such as spawning processes and piping them together. I've tried over the years to create a pythonic library that would let me do that, but haven't found a good syntax that I like. I'm using xml quite a bit and tried xmlsh which does the job but has what I think of as irregular syntax? Bash is fine for smaller scripts, but I had to be really careful by the time I got to around 1200 loc. Hence my preference for Python. It turns out, though, that much of what I use piping for in Bash is to run external processes to do things that I could use python modules for. I kept thinking that.. Then I had to use Java/Python for some plain old calculations, so it kept nagging me that a cleaner approach would be a single language. Sure it's a couple more lines in this case, but in other cases, python's abilities make it simpler than bash. A great document on how you can exploit python's abilities (particularly generators) to replace bash pipelines is here: http://www.dabeaz.com/generators/ Thanks for the reference. I'm nearly there with the mix of return codes and output values, using subprocess. p1 = subprocess.Popen(['identify', '-format' , '%[fx:w]' , f ], stdout=subprocess.PIPE) resp1= p1.communicate() #print dir(p1) p2 = subprocess.Popen(['identify', '-format' , '%[fx:h]' , f ], stdout=subprocess.PIPE) resp2= p2.communicate() if (p1.returncode or p2.returncode): print Error ,p1.returncode sys.exit(2) else: width=int(resp1[0]) height=int(resp2[0]) print Height %s, width %s % (height, width) Not happy with the error handling yet, but this was the bit that I thought I'd struggle with. regards -- Dave Pawson XSLT XSL-FO FAQ. Docbook FAQ. http://www.dpawson.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: dynamically modify help text
On Jun 27, 2010, at 22:37 , Red Forks wrote: Read you doc file and set the __doc__ attr of the object you want to change. On Monday, June 28, 2010, Brian Blais bbl...@bryant.edu wrote: I know that the help text for an object will give a description of every method based on the doc string. Is there a way to add something to this text, specific to an object, but generated at run-time? I have an object that reads a file, and I would like part of that file to be shown if one does: help(myobject) python file: #= class A(object): pass help_text=this is some text a=A() a.__doc__=help_text #= in ipython: shows up here: In [5]:a? Type: A Base Class: class '__main__.A' String Form:__main__.A object at 0x13270f0 Namespace: Interactive File: /Library/Frameworks/Python.framework/Versions/5.0.0/ lib/python2.5/site-packages/IPython/FakeModule.py Docstring: this is some text but not with the help command: In [6]:help(a) Help on A in module __main__ object: class A(__builtin__.object) | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) also does the same thing with the regular python prompt. is there a reason for this? thanks, Brian Blais -- Brian Blais bbl...@bryant.edu http://web.bryant.edu/~bblais http://bblais.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: dynamically modify help text
On Mon, Jun 28, 2010 at 11:13 AM, Brian Blais bbl...@bryant.edu wrote: On Jun 27, 2010, at 22:37 , Red Forks wrote: Read you doc file and set the __doc__ attr of the object you want to change. On Monday, June 28, 2010, Brian Blais bbl...@bryant.edu wrote: I know that the help text for an object will give a description of every method based on the doc string. Is there a way to add something to this text, specific to an object, but generated at run-time? I have an object that reads a file, and I would like part of that file to be shown if one does: help(myobject) python file: #= class A(object): pass help_text=this is some text a=A() a.__doc__=help_text #= in ipython: shows up here: In [5]:a? Type: A Base Class: class '__main__.A' String Form: __main__.A object at 0x13270f0 Namespace: Interactive File: /Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/IPython/FakeModule.py Docstring: this is some text but not with the help command: In [6]:help(a) Help on A in module __main__ object: class A(__builtin__.object) | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) also does the same thing with the regular python prompt. is there a reason for this? __doc__ is normally defined on classes, e.g. `A`, not instances, e.g. `a`. help() looks for __doc__ accordingly. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python as a scripting language. Alternative to bash script?
On 06/28/2010 12:05 PM, Dave Pawson wrote: On 28 June 2010 18:39, Michael Torrie torr...@gmail.com wrote: Sure. I've created a module called runcmd that does 90% of what I want (easy access to stdout, stderr, error code). I've attached it to this e-mail. Feel free to use it; this post puts my code into the public domain. Request please Michael. Examples of usage in the docstring? Well the simplest form is as I showed in my e-mail: (err,stdout,stderr) = runcmd.run (['command','arg1','arg2', ... ]) An example where you need to pass stdin: input=some string\n (err,stdout,stderr) = runcmd.run (['cmd','arg1',], stdin=input) err is the return error code (int) and stdout and stderr are the strings the result from the process's output, both strings. There are some other features (or bugs probably) that you can get from the source code itself. I think at one time I wanted to be able to have callbacks that would do something with stdout and stderr (in a real-time, unbuffered way), but I have never used them and don't think they work. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python as a scripting language. Alternative to bash script?
John Nagle na...@animats.com writes: Programs have argv and argc, plus environment variables, going in. So, going in, there are essentially subroutine parameters. But all that comes back is an exit code. They should have had something similar coming back, with arguments to exit() returning the results. Then the many small intercommunicating programs concept would have worked much better. That's interesting but I'm having a hard time seeing how it would work. I think environment variables didn't exist in early versions of Unix, and argc/argv were passed to the child process on its stack. I guess the reverse side could involve the wait system call taking a callback parameter with a buffer to receive the returned data. But that still only happens when the child actually exits, and presumably intercommunicating netween programs should be bidirectional. But Unix has always had pipes for that. -- http://mail.python.org/mailman/listinfo/python-list
Re: More MySQL Stuff
On 6/28/2010 9:10 AM Victor Subervi said... Any other suggestions? http://www.databaseanswers.org/tutorial4_db_schema/index.htm -- http://mail.python.org/mailman/listinfo/python-list
Re: dynamically modify help text
On Mon, Jun 28, 2010 at 11:25 AM, Chris Rebert c...@rebertia.com wrote: On Mon, Jun 28, 2010 at 11:13 AM, Brian Blais bbl...@bryant.edu wrote: On Jun 27, 2010, at 22:37 , Red Forks wrote: Read you doc file and set the __doc__ attr of the object you want to change. On Monday, June 28, 2010, Brian Blais bbl...@bryant.edu wrote: I know that the help text for an object will give a description of every method based on the doc string. Is there a way to add something to this text, specific to an object, but generated at run-time? I have an object that reads a file, and I would like part of that file to be shown if one does: help(myobject) python file: #= class A(object): pass help_text=this is some text a=A() a.__doc__=help_text #= in ipython: shows up here: In [5]:a? Type: A Base Class: class '__main__.A' String Form: __main__.A object at 0x13270f0 Namespace: Interactive File: /Library/Frameworks/Python.framework/Versions/5.0.0/lib/python2.5/site-packages/IPython/FakeModule.py Docstring: this is some text but not with the help command: In [6]:help(a) Help on A in module __main__ object: class A(__builtin__.object) | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) also does the same thing with the regular python prompt. is there a reason for this? __doc__ is normally defined on classes, e.g. `A`, not instances, e.g. `a`. help() looks for __doc__ accordingly. Cheers, Chris -- Just to save the OP some trouble later on: this optimization is done for most of the __*__ methods. Overriding __add__ on an instance won't change the behavior of a + b. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why Python3
On Jun 28, 12:58 pm, OKB (not okblacke) brennospamb...@nobrenspambarn.net wrote: Steven D'Aprano wrote: None of PyPy, Unladen Swallow or IronPython are dependencies for Python 3.x to be ready for prime time. Neither is C module support. I think this is being overoptimistic. For me, ready for prime time means I can rely on being able to find a way to do what I want to do with it. This includes being able to find third-party libraries that do what I want to do. Right now, I can't really rely on Python 3 in this way. Hmm, i'd have to agree with OKB on this one however i also believe (as Steven alluded) we must be very careful *not* to sow discontent thought-out the Python community regarding 3.x. adoption. As we know (and have witnessed) negativity spreads like wildfire and positivity sort of moves at a snails pace -- or not at all. Its the same thing you see on major news outlets. People love to read and talk about other people's dirty laundry. You hardly ever hear the about the people who are really changing the world in positive ways (scientist, engineers, doctors, etc..) However don't just say... Well schmits, module xxyy is not 3.x compliant so i'll just skip Python 3.x. for the next 3 years!. Instead ask yourself... Ok, module xxyy is not 3.x compatible and thats real schmitty, however maybe *i* should volunteer my time and help move the module/package into 3.x compliance? lectureEven if you only put in a few hours into this effort every little bit helps. And if everyone would just put in a few hours we would be there very quickly. We need to stop being lazy, quit lamenting, quit bitching, and give back what was given us by investing our spare time into Python's evolution. Everyone who uses Python owes that to themselves and the Python community at large./lecture It would be nice to start a thread where everyone could cast votes for the most important modules. Then we can focus our efforts on this list. I'll bet in very short time we could bring Py3.x into prime time action. However, don't tell me we have a list *already* because we don't. What i am proposing will give people a *voice* making them *feel* more a part of the team. Motivation is the hardest obstacle to overcome when achieving community goals. We must give the people a voice!! Ask yourself...What have *I* invested into Python? *Maybe* you've never helped maintain or build community/stdlib modules, write documentation, or even fielded questions on one of the Python newsgroups? *Maybe* all you've done is to use Python to fulfill your programming needs? Sure you could say that merely *using* Python is giving back (yes that is true) however we need you to give a bit more than that, and really it won't be a whole lot more! *Maybe* you want to help but don't know where to start. These are all good questions and i hope someone will supply the much needed answers One thing is for sure, this group is lacking a strong leader that can direct and influence the work that needs to be done. Someone who has the respect and admiration of the community. Of course Guido would be the perfect choice and I wish he would stop by and say something but i am sure he is very busy. And besides, he has invested a *lifetime* into Python. Ask yourself. Anyone want to step up and really get this thing started? We shall call you the XBDFL. psst XBDFL: if you need a speech writer let me know! ;-) from community import PublicAddress pa = PublicAddress(volume=6, echo=4, reverb=8).open() pa.write( *ahem* Steve Holden?) pa.write(Steve! Holden!) pa.volume = 10 pa.write(Steve Holden!?!?) pa.write(Are you in the building, Steve Holden?) pa.write(Please report the Why Python3 thread because we need your input) pa.write(Thank you) pa.close() ...sorry to pick on you Steve ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
Bruno Desthuilliers wrote: Alexander Kapps a écrit : (snip) While I personally don't agree with this proposal (but I understand why some people might want it), I can see a reason. When disallowing direct attribute creation, those typos that seem to catch newcommers won't happen anymore. What I mean is this: class Foo(object): def __init__(self): self.somearg = 0 f = Foo() f.soemarg = 42 ---^ There, typo, but still working It's something like a custom __setattr__ that errors out when trying to assign to an attribute that doesn't exists, Chicken and egg problem, really : f.__dict__['somearg'] doesn't exists until self.somearg = 0 is executed. The problem is that Python's methods are only thin wrapper around functions (cf http://wiki.python.org/moin/FromFunctionToMethod) so there's no difference between self.somearg = 0 in Foo.__init__ and f.somearg = 42. IOW, there's no way to implement this proposal without completely changing Python's object model. I must be missing something. Can you please explain why the whole object model would need to change? This seems to work quite well: class TypoProtection(object): def __init__(self): self.foo = 42 self.bar = 24 def _setattr(self, name, value): if name in self.__dict__: self.__dict__[name] = value else: raise AttributeError, %s has no '%s' attribute \ % (self.__class__, name) self.__class__.__setattr__ = _setattr t = TypoProtection() t.foo = spam t.bar = ham t.parrot = dead Traceback (most recent call last): File typo.py, line 20, in module t.parrot = dead File typo.py, line 10, in _setattr raise AttributeError, %s has no '%s' attribute % (self.__class__, name AttributeError: class '__main__.TypoProtection' has no 'parrot' attribute So, IIUC, all what would need to be done is to add an implicit __setattr__ at the end of __init__ . (Just want to understand, still not advocating this proposal) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
Alexander Kapps wrote: Bruno Desthuilliers wrote: Alexander Kapps a écrit : (snip) While I personally don't agree with this proposal (but I understand why some people might want it), I can see a reason. When disallowing direct attribute creation, those typos that seem to catch newcommers won't happen anymore. What I mean is this: class Foo(object): def __init__(self): self.somearg = 0 f = Foo() f.soemarg = 42 ---^ There, typo, but still working It's something like a custom __setattr__ that errors out when trying to assign to an attribute that doesn't exists, Chicken and egg problem, really : f.__dict__['somearg'] doesn't exists until self.somearg = 0 is executed. The problem is that Python's methods are only thin wrapper around functions (cf http://wiki.python.org/moin/FromFunctionToMethod) so there's no difference between self.somearg = 0 in Foo.__init__ and f.somearg = 42. IOW, there's no way to implement this proposal without completely changing Python's object model. I must be missing something. Can you please explain why the whole object model would need to change? UHHM! Forget it. This of course doesn't work with setattr too. My stupidness. :-( -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
On 6/28/10 12:09 PM, Alexander Kapps wrote: This seems to work quite well: class TypoProtection(object): def __init__(self): self.foo = 42 self.bar = 24 def _setattr(self, name, value): if name in self.__dict__: self.__dict__[name] = value else: raise AttributeError, %s has no '%s' attribute \ % (self.__class__, name) self.__class__.__setattr__ = _setattr This will only work the first time you make an instance: thereafter, __setattr__ will be on the class and future instances will refuse to allow the creation of foo and bar, as they won't already exist in the new instance's dictionary. That said, you can certainly make a class that only allows pre-approved attributes and prevents the creation of on the fly ones. Something like (untested): class TypoProtection(object): ALLOWED_ATTRIBUTES = [foo, bar] def __setattr__(self, key, value): if key not in TypoProtection.ALLOWED_ATTRIBUTES: raise AttribuetError(TypoProtection does not have %s attribute. % (key,)) return object.__setattr__(self, key, value) Now, I would very rarely *do* such a thing, but you *could* if you wanted to. (You achieve a similar effect by abusing __slots__) -- ... Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
On 06/25/2010 09:39 PM, WANG Cong wrote: Thanks, I have to admit that I know nothing about Smalltalk. If you know nothing about Smalltalk then you really aren't in a position to talk about what is and is not OOP. Smalltalk is one of the original OOP languages and purists define OOP as the model that Smalltalk implemented. In many ways Python is like Smalltalk. Certainly it's more like Smalltalk than Java or C++. Although Python has a few pieces of syntactic sugar that aren't truly OO, Python is much more OO than C++ or Java, for the reasons that others have already posted. Some of your doubts concerning Python and OOP stem directly from your exposure to Java and C++'s paradigms Hmm, although this is off-topic, I am interested in this too. C++ does have metaprogramming, but that is actually static metaprogramming (using templates), not dynamic metaprogramming here. I am wondering if efficiency is the only reason why C++ doesn't have dynamic metaprogramming, since C++ is a static programming language I think if this limits C++ to implement its dynamic metaprogramming actually... I don't think C++ has any syntactic support for dynamic metaprogramming, but I did read an article in Doctor Dobb's Journal that talked about dynamic inheritance in C++. The Boost library provides some static metaprogramming facilities for C++. -- http://mail.python.org/mailman/listinfo/python-list
C++/Python function call
Hello every one: I have this python function defined as: def set_time_at_next_pps(self, *args, **kwargs): set_time_at_next_pps(self, usrp2::time_spec_t time_spec) - bool it was generated to do the same function as the c++: set_time_at_next_pps(usrp2::time_spec_t(0, 0)) I am new to python and don't know hoe to use this python syntax. Any hint or help please? Cheers Zoh _ http://clk.atdmt.com/UKM/go/19780/direct/01/ Do you have a story that started on Hotmail? Tell us now-- http://mail.python.org/mailman/listinfo/python-list
Re: Python dynamic attribute creation
On 06/27/2010 11:58 PM, Stephen Hansen wrote: To say you can't really know much about OOP without knowing much about Smalltalk seems basically, well, wrong. True. But you can't really criticize a language's implementation of OOP without a good understanding of the pure OO language. For example, in Smalltalk If/Then statements are actually methods of Boolean objects. From a certain point of view that's extremely appealing (consistent, anyway). Almost functional in nature. They are not implemented this way in Python, so that's one thing you could argue is not OO about Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: refactoring a group of import statements
On Jun 27, 10:20 pm, GrayShark howe.ste...@gmail.com wrote: Question: If you can't answer the question, why are you talking? Q: If you can't take advice without complaining, then why are you asking? I'm American Indian. That's what I was taught. We don't talk that much. But you get an answer when we do talk. Makes life simpler. Yes thats about as intelligent as me saying... I'm an American sprinter. We don't walk that much. But we move faster when we run. Makes winning easier. Yes, apparently it is *NOT* wise to swim with sharks! GrayShark, this is the second time i've seen you spit on those offering help. Whether or not my help was helpful to you does not matter. You're only going to thin the pool of answers by resorting to such childish behaviors. If you don't think an answer was helpful to you, just ignore it and move on. But i'm probably wasting my time again helping you so... -- http://mail.python.org/mailman/listinfo/python-list
Re: optparse TypeError
Michele Simionato michele.simion...@gmail.com writes: optparse is so old-fashioned. Use plac! The OP should be made aware that: * plac is a third-party library with (TTBOMK) no prospect of inclusion in the standard library * optparse is in the standard library and has been for many versions * argparse is a third-party library that is now accepted for inclusion in the standard library, intended as a full optparse replacement URL:http://www.python.org/dev/peps/pep-0389/ Choose accordingly. -- \ “If consumers even know there's a DRM, what it is, and how it | `\ works, we've already failed.” —Peter Lee, Disney corporation, | _o__) 2005 | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: C++/Python function call
On Monday 28 June 2010 12:46:13 Zohair M. Abu Shaban wrote: Hello every one: I have this python function defined as: def set_time_at_next_pps(self, *args, **kwargs): set_time_at_next_pps(self, usrp2::time_spec_t time_spec) - bool it was generated to do the same function as the c++: set_time_at_next_pps(usrp2::time_spec_t(0, 0)) I am new to python and don't know hoe to use this python syntax. Any hint or help please? Can you give us a little more information? What do you need to use it for? Cheers Zoh _ http://clk.atdmt.com/UKM/go/19780/direct/01/ Do you have a story that started on Hotmail? Tell us now Rami Chowdhury Given enough eyeballs, all bugs are shallow. -- Linus' Law +1-408-597-7068 / +44-7875-841-046 / +88-01819-245544 -- http://mail.python.org/mailman/listinfo/python-list