Re: Corectly convert from %PATH%=c:\\X; "c:\\a; b" TO ['c:\\X', 'c:\\a; b']
Its good to see what cpython did with the PATH. I now feel good about taking the simple approach. It would be crazy if that sort of quoting in the middle becomes something which works with too many applications - and others are expected to keep up with it. I guess I dont need to worry about unix PATHs now. Thanks, Chirayu. -- http://mail.python.org/mailman/listinfo/python-list
distutils
Hi, New to python, I' m trying to use distutils. And I get this error # python setup.py build Traceback (most recent call last): File "setup.py", line 89, in ? from distutils import core ImportError: No module named distutils I have Python 2.3.4 installed Any advice ? How does path work in python ? Thanks a lot for your help Guillaume -- http://mail.python.org/mailman/listinfo/python-list
Last rites declaration of Ioannes Paulus PP. II (Karol Wojtyla)
"The unforgiveable sins this earth must confront and overcome are Nationalism, capitalism, and hoarding. The idea of every nation should be forgot, price should be struck from the commons, and princes should be seen for the devils they are. The sins include our church, secret societies, and other religions which make of the spirit of God a divide." Last rites declaration of Ioannes Paulus PP. II (Karol Wojtyla) 2nd April 2005 -- o SECTION II: THE MISERY OF MAN WITHOUT GOD o SECTION III: OF THE NECESSITY OF THE WAGER o SECTION IV: OF THE MEANS OF BELIEF o SECTION V: JUSTICE AND THE REASON OF EFFECTS o SECTION VI: THE PHILOSOPHERS o SECTION VII: MORALITY AND DOCTRINE o SECTION VIII: THE FUNDAMENTALS OF THE CHRISTIAN RELIGION o SECTION IX: PERPETUITY o SECTION X: TYPOLOGY o SECTION XI: THE PROPHECIES o SECTION XII: PROOFS OF JESUS CHRIST o SECTION XIII: THE MIRACLES o SECTION XIV: APPENDIX: POLEMICAL FRAGMENTS PENSÉES by Blaise Pascal 1660 translated by W. F. Trotter PENSÉES SECTION I: THOUGHTS ON MIND AND ON STYLE 1. The difference between the mathematical and the intuitive mind.--In the one, the principles are palpable, but removed from ordinary use; so that for want of habit it is difficult to turn one's mind in that direction: but if one turns it thither ever so little, one sees the principles fully, and one must have a quite inaccurate mind who reasons wrongly from principles so plain that it is almost impossible they should escape notice. But in the intuitive mind the principles are found in common use and -- http://mail.python.org/mailman/listinfo/python-list
Re: string goes away
John J. Lee wrote: > Duncan Booth <[EMAIL PROTECTED]> writes: > [...] >>str.join(sep, list_of_str) > [...] > > Doesn't work with unicode, IIRC. > > str.join won't work if sep is unicode, but generally you know what type the separator is and str.join will quite happily join a list of strings where one or more is unicode and return a unicode result. If you know the separator is unicode then use unicode.join instead. -- http://mail.python.org/mailman/listinfo/python-list
Re: re module non-greedy matches broken
"lothar" wrote: > this is a bug and it needs to be fixed. it's not a bug, and it's not going to be "fixed". search, findall, finditer, sub, etc. all scan the target string from left to right, and process the first location (or all locations) where the pattern matches. -- http://mail.python.org/mailman/listinfo/python-list
Re: Change between Python 2.3 and 2.4 under WinXP
Franz Steinhäusler wrote: > My second question from my last post (PyQt on Python 2.4), I think, is > a little got under (i have installed both Python 2.3 and Python 2.4) > > Is there any possibility under WinXP, to alterntate quickly > (with batch file or similary) between python23 and python24. if you want to deploy programs that depend on a specific python version, exemaker is your friend: http://effbot.org/zone/exemaker.htm -- http://mail.python.org/mailman/listinfo/python-list
GUI - Qt Designer
Hi I am John M Bradbury. A message for John Bradbury, I am wondering if we are related? e-mail [EMAIL PROTECTED] www.johnmbradburyart.co.uk Best wishes John M Bradbury -- http://mail.python.org/mailman/listinfo/python-list
Re: Help me dig my way out of nested scoping
"Brendan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >F -is- in fact an iterative optimizer that minimizes A on x (B is the > derivative of A). So yes, F will call A and B on mulitple 'x's. In > that case, it seems the mutable object trick is the way to go. Thanks. As long as it calls A and B in that same order, rather than A several times and B several times, then my code, fleshed out, will probably work. > > I didn't follow your last sentence. What about the Python Cookbook? It is a book that is one place to find memoizer code which allows one to save several x,f(x) pairs at once for later reuse. But you don't seem to need it since an optimizer should never return to the exact same x except by accident. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list
DIY Spam Filter in Python
Hi all, I've no idea if this will be of any use to anyone. But since I've gone to the effort of writing it, I might as well make it publicly available... Until last year, spam filtering was a source of frustration for me. Freeware packages I tried (specifically, spamassassin and dspam) were difficult to use. Custom rules using procmail were a pain. Then I noticed that python came with email parsing capabilities in the email module. So I thought that maybe custom rules in python would be easier than (a) custom rules in procmail, or (b) deciphering the documentation of a package. And a lot more fun. It turned out to be very easy. I got the filter up in a few evenings, and I've been using it successfully, and slowly enhancing it, over a number of months. In short: a success story for "using the batteries" - at least in my opinion. Source code, and a bit of documentation, is at: http://members.ozemail.com.au/~pballard/diyspamfilter.html -- Regards, Peter Ballard Adelaide, AUSTRALIA http://members.ozemail.com.au/~pballard/ -- http://mail.python.org/mailman/listinfo/python-list
Question about Enthought python distribution
Hi! I have been using the python 2.3.3 distribution from Enthought Inc because it has most of the libraries I use included. Does anyone know when Enthought will release the python 2.4 distribution? Thanks. Ohkyu -- http://mail.python.org/mailman/listinfo/python-list
Tkinter - pixel or widget color
I would need to get at canvas pixel color under certain moving widget or better (= faster?) colors/"types" of underlying static widgets that are of polygon shape (not rectangle). How to arrange it without using higher math that must have to compute actual distance of each of point on a polygon? I have found find_overlapping() but its not what I need and do not found something like getColorPixel(). Pavel -- http://mail.python.org/mailman/listinfo/python-list
Raise Error in a Module and Try/Except in a different Module
I Have a function FUNC1 that is define in ModuleA. This function raise an exception EXCP1 (raise EXCP1), with EXCP1 a global variable in ModuleA. In ModuleB, I have some classes that call FUNC1. I would like to catch EXCP1 and make some processing. How can I do that. I tried in Module B import ModuleA ... class(): ... try: a = ModuleA.FUNC1 except ModuleA.EXCP1: print 'catch' But It does not work. What is wrong? -- http://mail.python.org/mailman/listinfo/python-list
import and scope inconsistency?
I would be very grateful for help on the following. I have the following modules in a program. Names changed to protect the innocent. 1.Simulation 2.Branches 3.MyFiles I import Branches, Myfiles and the publicly available module Numeric inside Simulation. Branches and MyFiles both contain class definitions. I can call MyFiles methods inside methods of the Brances classes. I cannot call Numeric methods inside methods of the Brances classes. 1. I was surprised I could call MyFiles methods in Branches methods. 2. Since I was used to using modules imported in the parent module I was surprised I couldn't use Numeric methods. What's going on? Thanks Jim O'Donnell -- http://mail.python.org/mailman/listinfo/python-list
Re: Raise Error in a Module and Try/Except in a different Module
On 4 Apr 2005 03:11:23 -0700, Issa-Ahmed SIDIBE <[EMAIL PROTECTED]> wrote: > I Have a function FUNC1 that is define in ModuleA. This function raise > an exception EXCP1 (raise EXCP1), with EXCP1 a global variable in > ModuleA. > > In ModuleB, I have some classes that call FUNC1. I would like to catch > EXCP1 and make some processing. How can I do that. > > I tried in Module B > > import ModuleA > ... > class(): >... >try: a = ModuleA.FUNC1 >except ModuleA.EXCP1: print 'catch' > > But It does not work. What is wrong? You're not *calling* FUNC1 here, you're just assigning a reference to it to the name 'a'. Try FUNC1() instead. -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Raise Error in a Module and Try/Except in a different Module
Issa-Ahmed SIDIBE wrote: I Have a function FUNC1 that is define in ModuleA. This function raise an exception EXCP1 (raise EXCP1), with EXCP1 a global variable in ModuleA. In ModuleB, I have some classes that call FUNC1. I would like to catch EXCP1 and make some processing. How can I do that. I tried in Module B import ModuleA ... class(): ... try: a = ModuleA.FUNC1 except ModuleA.EXCP1: print 'catch' But It does not work. What is wrong? I'm just back from holiday so rusty but I tried to do this w few weeks ago. What's the error? Jim -- http://mail.python.org/mailman/listinfo/python-list
Re: Raise Error in a Module and Try/Except in a different Module
Am Montag, 4. April 2005 12:11 schrieb Issa-Ahmed SIDIBE: Try: > import ModuleA > ... > class(): >... >try: a = ModuleA.FUNC1() ^^ <-- Actually call the method. >except ModuleA.EXCP1: print 'catch' HTH! -- --- Heiko. see you at: http://www.stud.mh-hannover.de/~hwundram/wordpress/ pgpSul6uhjT2y.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Raise Error in a Module and Try/Except in a different Module
You're not *calling* FUNC1 here, you're just assigning a reference to it to the name 'a'. Try FUNC1() instead. Oh yeah. -- http://mail.python.org/mailman/listinfo/python-list
Re: DIY Spam Filter in Python
Peter Ballard wrote: > I've no idea if this will be of any use to anyone. But since I've gone > to the effort of writing it, I might as well make it publicly > available... > > Until last year, spam filtering was a source of frustration for me. > Freeware packages I tried (specifically, spamassassin and dspam) were > difficult to use. Custom rules using procmail were a pain. > > Then I noticed that python came with email parsing capabilities in the > email module. So I thought that maybe custom rules in python would be > easier than (a) custom rules in procmail, or (b) deciphering the > documentation of a package. And a lot more fun. > > It turned out to be very easy. I got the filter up in a few evenings, > and I've been using it successfully, and slowly enhancing it, over a > number of months. > > In short: a success story for "using the batteries" - at least in my > opinion. > > Source code, and a bit of documentation, is at: > http://members.ozemail.com.au/~pballard/diyspamfilter.html > > -- > Regards, > > Peter Ballard > Adelaide, AUSTRALIA > http://members.ozemail.com.au/~pballard/ Pete mate, Nice work, but your Web page on your DIY Spam Filter doesn't mention SpamBayes, which is surely the definitive Pythonic spam filter, as well as being eerily effective - see http://spambayes.sourceforge.net Not sure that the Reverend Bayes would have agreed with your theology - a bit too post-modern for him, no doubt, but he was nevertheless a lovely little thinker. Tim C -- http://mail.python.org/mailman/listinfo/python-list
Re: import and scope inconsistency?
Am Montag, 4. April 2005 12:23 schrieb Jim: > I can call MyFiles methods inside methods of the Brances classes. > I cannot call Numeric methods inside methods of the Brances classes. > > 1. I was surprised I could call MyFiles methods in Branches methods. > 2. Since I was used to using modules imported in the parent module I was > surprised I couldn't use Numeric methods. 1. I can't answer you this one without looking at the actual code, but 2. You can never call any methods/classes which you imported in a "parent" module (actually, there's no such motion as parent module, as each module has its own namespace, and references to this namespace may appear anywhere else in another module). In case this worked sometime ago and you didn't explicitly import the module in the "child" module, you silently did something like the following: Mod1.py --- import Numeric import Mod2 # Put the namespace (module object) in another namespace Mod2.Numeric = Numeric Mod2.py --- What you need for your simulation program is probably something like the following: Simulation.py - import MyFiles import Branches import Numeric print MyFiles.Branches is Branches # True print MyFiles.Numeric is Numeric # True print Branches.Numeric is Numeric # True MyFiles.py -- import Branches import Numeric print Branches.Numeric is Numeric # True Branches.py --- import Numeric HTH! -- --- Heiko. listening to: aenima_13_aenima.mp3 see you at: http://www.stud.mh-hannover.de/~hwundram/wordpress/ pgp3EJqOZ4rfI.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: import and scope inconsistency?
You're putting a Reply-To header in your posts to the mailing-list, but the Reply-To address bounces. Please correct: on't put in a Reply-To header, or at least put in some address that doesn't bounce. -- --- Heiko. listening to: aenima_15_Third Eye.mp3 see you at: http://www.stud.mh-hannover.de/~hwundram/wordpress/ pgp4LVfom4iRJ.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
What's up with the PyFX Project??? (ex PyCG nVidia CG implementation)
Does anyone know why there's no progress on the pyfx project?? (http://graphics.cs.lth.se/pyfx) What are the pro and con's for such an implementation to actually program a 3d game (engine)?? I started off a while ago in c++ to play around a bit with directx opengl and cg but I'd rather like to program in a language such as python... PyGame doesn't meet my need's because i'd like to take adantage of the much faster directx technology. Any comments, hints? Greets TC -- http://mail.python.org/mailman/listinfo/python-list
Sending keytrokes to Windows app
Hello, I am trying to control a Windows application from a python script with SendKeys and Python 2.3. My problem is that the characters ':' and '\' are sent to the application as ';' and '+'. See code example below. I suspect that the problem has to do with the regional and keyboard settings in Windows. I am using the setting English (UK) with Finnish keyboard. If I change the settings to English (US) with US keyboard, everything works fine. Is there a way to either change the language and keyboard settings from my python script, or get Sendkeys to send the characters correctly? Or should I use another way to send the keystrokes to the application? Transcript of Python session: Python 2.3.5 (#62, Feb 8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import SendKeys >>> a='C:\\' >>> SendKeys.SendKeys(a) >>> C;+ Thank's in advance Marten Hedman Turku Centre for Biotechnology Turku, Finland -- http://mail.python.org/mailman/listinfo/python-list
Testing for EOF ?
I am reasonably new to python and am trying to read several lines of text from an open file. Typically in other languages I used to use code like: while not EOF() read_text_in ... How is this achieved with python ? Regards Pete -- http://mail.python.org/mailman/listinfo/python-list
Text file to SDE
We have recently purchased ARCSDE 9. I have attended the ARCSDE administrator for Oracle course, but it did not cover how to write data without an the arcgis interfaces. I was told however that I could write data say from a text file directly to the sde using python. Does anyone have a sample script on how to do this, or tell me where I can find this information. Thanks in advance Just me -- http://mail.python.org/mailman/listinfo/python-list
Re: import and scope inconsistency?
Heiko Wundram wrote: You're putting a Reply-To header in your posts to the mailing-list, but the Reply-To address bounces. Please correct: on't put in a Reply-To header, or at least put in some address that doesn't bounce. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Sending keytrokes to Windows app
On Apr 4, 2005 12:04 PM, Marten Hedman <[EMAIL PROTECTED]> wrote: > I am trying to control a Windows application from a python script with > SendKeys and Python 2.3. WATSUP might be worth a look, instead... http://www.tizmoi.net/watsup/intro.html -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Testing for EOF ?
On Apr 4, 2005 12:21 PM, Pete Moscatt <[EMAIL PROTECTED]> wrote: > I am reasonably new to python and am trying to read several lines of text > from an open file. my_file = open('whatever.txt', 'r') for line in my_file: print line # Or whatever -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Queue.Queue-like class without the busy-wait
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Thinking about cross-platform issues. I found this, from the venerable > Tim Peters to be enlightening for python's choice of design: > > "It's possible to build a better Queue implementation that runs only on > POSIX systems, or only on Windows systems, or only on one of a dozen > other less-popular target platforms. The current implementation works > fine on all of them, although is suboptimal compared to what could be > done in platform-specific Queue implementations. " > > Here is a link: > > http://groups-beta.google.com/group/comp.lang.python/messages/011f680b2dac320c,a03b161980b81d89,1162a30e96ae330a,0db1e52548493843,6b8d593c84ad4fd4,b6293a53f98252ce,82cddc89805b4b56,81c7289cc4cb4441,0906b24cc1534844,3ff6629391074ed4?thread_id=55b80d05e9d54705&mode=thread&noheader=1&q=queue+timeout+python#doc_011f680b2dac320c Interesting thread. How about leaving the current threading alone, but adding a pthreads module for those OSes which can use or emulate posix threads? Which is windows and most unixes? -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: Testing for EOF ?
On Apr 4, 2005 12:36 PM, Peter Moscatt <[EMAIL PROTECTED]> wrote: > Thanks Simon, > > So the code should look like: > > f=open(myfile,"r") > > for some_var in f: > text=f.readline() > print text > > Do I have this correct ? Nearly - you don't need the text=f.readline() bit. A file object (as returned to you by open()) is an iterator, and iterating over it gives you the lines directly. Why not give it a go? The nice thing about Python is how easy it is to try stuff like this out at the interactive prompt. Err, *one* of the nice things, that is. ;-) BTW, newbies are more than welcome here, but there is a python-tutor list[1] which might be more your speed if you are quite new to Python. There are also a number of tutorials available[2] . I'd recommend either the standard tutorial[3] or Dive Into Python[4] for someone like you who already knows how to program but doesn't know Python. Welcome to Python, and have fun. -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ [1] http://mail.python.org/mailman/listinfo/tutor [2] http://www.python.org/moin/BeginnersGuide/Programmers [3] http://www.python.org/doc/current/tut/ [4] http://diveintopython.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Change between Python 2.3 and 2.4 under WinXP
Fredrik Lundh wrote: Franz Steinhäusler wrote: My second question from my last post (PyQt on Python 2.4), I think, is a little got under (i have installed both Python 2.3 and Python 2.4) Is there any possibility under WinXP, to alterntate quickly (with batch file or similary) between python23 and python24. if you want to deploy programs that depend on a specific python version, exemaker is your friend: http://effbot.org/zone/exemaker.htm not to be biased toward your own products at all, or course :-) -- -- Lucas Raab lvraab"@"earthlink.net dotpyFE"@"gmail.com AIM:Phoenix11890 MSN:dotpyfe "@" gmail.com IRC:lvraab ICQ:324767918 Yahoo: Phoenix11890 -- http://mail.python.org/mailman/listinfo/python-list
Re: (win32) speedfan api control
On Apr 3, 2005 1:52 AM, Claudio Grondi <[EMAIL PROTECTED]> wrote: > May I ask how did you get the > "TJvXPCheckbox" and the other > values necessary to access the program > GUI ? (as I can see, there is no source > code of SpeedFan available) ? Winspector is good for this kind of thing. http://www.brunningonline.net/simon/blog/archives/001320.html -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: (win32) speedfan api control
On Apr 2, 2005 3:22 AM, tlviewer <[EMAIL PROTECTED]> wrote: (Snip Windows GUI automation stuff.) WATSUP includes a module for Windows GUI automation. It's probably worth a look - it might save you from doing all the research that I had to do! http://www.tizmoi.net/watsup/intro.html -- Cheers, Simon B, [EMAIL PROTECTED], http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Silly question re: 'for i in sys.stdin'?
On Sun, Apr 03, 2005 at 09:49:42PM -0600, Steven Bethard wrote: > Slick. Thanks! does isatty() actually work on windows? I'm a tiny bit surprised! Jeff pgp2TeZpqhdyV.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
boolean -> DNF
I need to transform boolean expressions to Disjunctive Normal Form. Right now I'm using BoolStuff[1], a small C program to this end. I'd like to skip BoolStuff and do it all in python but I have no idea where to start. Anyone out there with a PhD in computer science that can give me a starting point? alex [1] http://www3.sympatico.ca/sarrazip/dev/boolstuff.html -- Alex Polite http://flosspick.org -- http://mail.python.org/mailman/listinfo/python-list
Re: DIY Spam Filter in Python
Tim Churches wrote: > Peter Ballard wrote: [snip] > > Source code, and a bit of documentation, is at: > > http://members.ozemail.com.au/~pballard/diyspamfilter.html > Pete mate, > > Nice work, but your Web page on your DIY Spam Filter doesn't mention > SpamBayes, which is surely the definitive Pythonic spam filter, as well > as being eerily effective - see http://spambayes.sourceforge.net Yeah, I found out about SpamBayes a while ago, but it was after I already had my DIY filter up and running. -- Regards, Peter Ballard Adelaide, AUSTRALIA http://members.ozemail.com.au/~pballard/ -- http://mail.python.org/mailman/listinfo/python-list
Re: What's up with the PyFX Project??? (ex PyCG nVidia CG implementation)
tc wrote: Does anyone know why there's no progress on the pyfx project?? (http://graphics.cs.lth.se/pyfx) What are the pro and con's for such an implementation to actually program a 3d game (engine)?? I started off a while ago in c++ to play around a bit with directx opengl and cg but I'd rather like to program in a language such as python... PyGame doesn't meet my need's because i'd like to take adantage of the much faster directx technology. Any comments, hints? Greets TC Panda3D might be what you're looking for. http://panda3d.etc.cmu.edu. It's an open-source 3D engine. Python is the main language used to program the games. While you can use C++ or other languages, they aren't as well supported. -- -- Lucas Raab lvraab"@"earthlink.net dotpyFE"@"gmail.com AIM:Phoenix11890 MSN:dotpyfe"@"gmail.com IRC:lvraab ICQ:324767918 Yahoo: Phoenix11890 -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter - pixel or widget color
On Mon, Apr 04, 2005 at 10:43:11AM +0200, pavel.kosina wrote: > I would need to get at canvas pixel color under certain moving widget or > better (= faster?) colors/"types" of underlying static widgets that are > of polygon shape (not rectangle). I don't believe this information is available anywhere, unfortunately. Jeff pgpJe2gd1ST4h.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Europython 2005 is now accepting talk submissions
Europython 2005 is now accepting talk submissions! Find out more at http://www.europython.org Just as last year, we have a Refereed Paper Track. Last day for proposing a refereed paper is 22 April 2005. For regular talks, we have the following tracks: Business Education Python Frameworks Python Language Science Social skills and General Topics Zope/Plone We also have a special track for "Misfits" this year. It is for any topic that is Python related but doesn't fit in any of the above categories. Last day for submitting talks to the regular tracks is 1 May 2005. On top of this, we will have two tracks of Lightning Talks; one for Zope/plone and one for other topics. You can register talks for these all the time until the Lightning Talk sessions end, or the schedule is filled, whichever comes first. Europython 2005 will be held 27-29 June at the Chalmers University of Techchnology, Göteborg, Sweden. Registration will open in mid-April. We hope this will become the best Europython Conference ever! With your help it can. We are still seeking volunteers to help us with a number of things. We have a recent vacancy as track chair for Python Frameworks, and it is not too late to revive the Applications Track. We also need people to help out in the reception during the conference. Send an email to [EMAIL PROTECTED] Jacob Hallén Head organiser -- -- http://mail.python.org/mailman/listinfo/python-list
Re: Queue.Queue-like class without the busy-wait
Op 2005-04-02, Paul Rubin schreef : > Have you looked at this? A paper about adding asynchronous exceptions > to Python. > > http://www.cs.williams.edu/~freund/papers/02-lwl2.ps Looks interresting, but I doubt python will have it in the near future. I'm very pessimitic about python development in this area. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: unittest vs py.test?
Raymond Hettinger wrote: [Peter Hansen] (I'm not dissing py.test, and intend to check it out. Not to be disrepectful, but objections raised by someone who hasn't worked with both tools equate to hot air. Not to be disrespectful either, but criticism by someone who has completely missed my point (and apparently not read my posts) doesn't seem entirely fair. At no time in this thread have I objected to py.test. The sole point of my posts has been to object to those claiming unittest as "heavy" when in the same breath they seem to think you have to know all kinds of details about TestSuite, TestRunner, and TestResult objects just to use it. I tried to demonstrate that my way of using it appears to be on the same order of "lightness" as some of the samples that were being used to show how much lighter py.test was. Until you've exercised both packages, you haven't helped the OP whose original request was: "Is there anybody out there who has used both packages and can give a comparative review?" It seems possible to me that I might have helped him solely by pointing out that unittest might not be so "heavy" as some people claimed. I got the impression that he might be swayed by some unfounded claims not even to look further at unittest, which I felt would be a bad thing. (Not to say your comments are unfounded, as clearly they are valid... I happen to believe mine have been, in this thread, as well. I guess you're free to believe otherwise. Cheers.) -Peter -- http://mail.python.org/mailman/listinfo/python-list
Problems compiling PIL under Cygwin
Hi group, I'm trying to build PIL under Cygwin (for use with the Skencil vector graphics program), and I couldn't find a better forum for questions than this. I'm using Python 2.3.4, and when I run "python setup.py build_ext -i" I get the following output: running build_ext building '_imaging' extension gcc -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -DHAVE_LIBJPEG -DHAVE_LIBZ -I/usr/include/freetype2 -IlibImaging -I/usr/include -I/usr/local/include -I/usr/include/python2.3 -c libImaging/GifEncode.c -o build/temp.cygwin-1.5.12-i686-2.3/libImaging/GifEncode.o C:\cygwin\bin\python2.3.exe (1352): *** unable to remap C:\cygwin\bin\tk84.dll to same address as parent(0x76) != 0xBB 4 [main] python 1984 sync_with_child: child 1352(0x238) died before initialization with status code 0x1 282 [main] python 1984 sync_with_child: *** child state child loading dlls error: Resource temporarily unavailable Does anybody know what could be done to solve this? / martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Some notes about float approximations in mxNumber
Kay Schluehr wrote: > Hi Marc, > > I was a bit surprised to find the very slow Farey approximation by > means of the class in the mxNumber package. If the goal > was to reconstruct a rational from a float it is not a good choice and > should be replaced by a continued fractions approximation. The idea was to be able to create a Rational() from a float using a given upper bound on the denominator. The standard Rational() constructor already provides a way to construct a rational out of a Python or mxNumber float, but always uses maximum precision - which may not always be what the user wants (e.g. to work around rounding errors). Thanks for posting your faster version. I think it would be a good candidate for a Python Cookbook Entry and I'll see whether I can add something like this to one of the next mxNumber releases. > Some time > ago I implemented it by myself so it can be published here: > > > def cfrac(z,bound=10**-5,n=10): > ''' > creates a continued fraction from some number z. > @ bound - terminate cf if the rest is lower than the provided bound > @ n - terminate cf after n steps > ''' > l = [] > while 1: > a = int(z) > l.append(a) > y = z-a > if y<=bound or len(l)==n: > return l > z = 1./y > > > def fold(cf): > ''' > create u/v = cfrac(a0,a1,...,an) using following rules: > > 1. / u1 u0 \ / a1 1 \/ a0 1 \ >| | = | | * | | >\ v1 v0 / \ 1 0 /\ 1 0 / > > 2. The recursion rules >v(n+1) = v(n)*a(n+1)+v(n-1) >u(n+1) = u(n)*a(n+1)+u(n-1) > ''' > if len(cf)<2: > return Rational(0,1) > un = cf[0]*cf[1]+1 > vn = cf[1] > un_1 = cf[0] > vn_1 = 1 > for a in cf[2:]: > b = un > un = un*a+un_1 > un_1 = b > b = vn > vn = vn*a+vn_1 > vn_1 = b > return Rational(un,vn) > > > fold(cfrac(1./3)) > > 1/3 > fold(cfract(1525/42.)) > > 1525/42 > > import math > > fold(cfract(math.sqrt(2))) > > 3363/2378 > > > It is possible to provide this functionality in an even more efficient > manner because it is usefull to bound only the approximation error of > the rational, not the size of the continued fraction. > > def float2ratio(z, bound=10**-5): > ''' > convert a float into a Rational. > The approximation is bound by the error-limit 'bound'. > ''' > a = int(z) > y = z-a > z = 1./y > b = int(z) > un = a*b+1 > vn = b > un_1 = a > vn_1 = 1 > a= b > while 1: > y = z-a > if y return Rational(un,vn),k > z = 1./y > a = int(z) > x = un > un = un*a+un_1 > un_1 = x > x = vn > vn = vn*a+vn_1 > vn_1 = x > xn = float(un)/vn > yn = float(un_1)/vn_1 > if abs(xn-yn)<=bound: > return Rational(un,vn) > > math.sqrt(2) > > 1.4142135623730951 > > float2ratio(math.sqrt(2)) > > 1393/985 > 1393./985 > > 1.4142131979695431 > ^ > > float2ratio(math.sqrt(2),10**-10) > > 275807/195025 > 275807./195025 > > 1.4142135623637995 > ^ > > math.pi > > 3.1415926535897931 > > float2ratio(math.pi,10**-14) > > 245850922/78256779 > 245850922./78256779 > > 3.1415926535897931 > > Note that the algorithm needed only 13 iteration steps to approximate > pi > in this accuracy. > > Regards, > Kay > -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 04 2005) >>> Python/Zope Consulting and Support ...http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/ ::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! -- http://mail.python.org/mailman/listinfo/python-list
adodbapi return value
I'm trying to use the adodbapi module, but run into the following problem: After initalization (connection, cursor) I have the following call to a stored procedure (SQL Server, using SQLOLEDB.1 provider). m = u'BrReg' rs = u'' msg = u'' x = self.cur.callproc('__DocFetchBaseCategories', (0, 0, m, rs, msg)) print x >>> [0, 0, u'BrReg', u'', u''] print self.cur.returnValue >>> None print self.cur.rowcount >>> -1 The procedure is enclosed below. Strange thing is that if the variable 'm' is set to an empty string, everything works ok, the resultstate value (x[3]) becomes '_OK'. However having the variable 'm' set to 'BrReg' as indicated, seems to result in the returned set (x) not being updated. When executing the Stored Procedure in Query Analyzer, everything seems to be ok (BrReg is a valid value and results in both '_OK' resultstate and a set of values (record set)). When using the value m='', the returnValue when printed is 0. FRAGMENT OF SQL CODE create proc __DocFetchBaseCategories ( @TraceLevel int, @UserId int, @Module varchar(32), @Resultstate varchar(121) output, @Message varchar(255) output ) as begin if @Module <> '' begin select 1, C.Category, C.BaseCategory, C.CategoryDescription from _DerivedCategories D, _Categories C where D.Category like (@Module + '[_]%') and not D.BaseCategory like (@Module + '[_]%') and D.DerivedLevel = 1 and D.Category = C.Category end else begin select 1, Category, BaseCategory, CategoryDescription from _Categories where BaseCategory = '' end select @ResultState = '_OK', @Message = '' NormalExit: end The connection object reports 0 ADOerrors when I use the method printADOerrors on the connection object. Any help is appreciated. Nikolai Kirsebom -- http://mail.python.org/mailman/listinfo/python-list
Re: redundant importr
max(01)* wrote: Peter Hansen wrote: No it doesn't. I thought I was clear, but I can reword it for you: the files are compiled *in-memory* and the results are never written to disk. > *if* they are compiled, where are they put, if the corresponding *.py files are on a non-writeable directory? They are not put anywhere. ok, maybe it is an implementation-dependent issue after all. Not really. consider this: [snip] -rw-r--r--1 max2 max2 307 2005-04-02 17:45 imported.pyc see? Yes, but you don't, yet. :-) Obviously the .pyc file is being written, so my comments above, out of context, is wrong. Now please go put them back in context. You asked what would happen if the directory was not writable. That's the context in which to interpret my claims that the bytecode (the *result* of the compilation) is not written to disk. I'll try one last time, before giving up in abject failure and letting someone else take a stab at this: the compilation will occur every time if a .pyc file does not exist. The interpreter will attempt to write the results of the compilation process to disk in a .pyc file to cache it for the next time, to avoid having to recompile. *If* this is not possible, then no caching takes place, no .pyc file is written, and the next time you run the code, the compilation step will occur all over again (note: with the results being held in memory only while the program runs, then discarded). Please tell me it's clear now. :-) -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: redundant imports
Serge Orlov wrote: Mike Meyer wrote: The semantic behavior of "include" in C is the same as "from module import *" in python. Both cases add all the names in the included namespace directly to the including namespace. This usage is depreciated in Python ... Did you mean discouraged? Or it's really slated for deprecation? Deprecated basically means "the use of this is discouraged", though because it is often followed by a comment like "and it will be removed in a future release", people sometimes are misled into thinking "deprecate" refers to the pending act of removal rather than the discouragement itself. So, yes, its use is deprecated (though I'm not sure if that's by any official statement, or simply by widespread convention), but no, that doesn't mean it is going to go away any time soon. -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: unittest vs py.test?
Peter Hansen <[EMAIL PROTECTED]> wrote: >It seems possible to me that I might have helped him >solely by pointing out that unittest might not be so >"heavy" as some people claimed. I got the impression >that he might be swayed by some unfounded claims not >even to look further at unittest, which I felt would >be a bad thing. I'm the "him" referred to above. I've been using unittest ever since it was first added to the standard library (actually, now that I think about it, I believe I may have been using it even before then). And yes, I think unittest brings along a certain amount of baggage. There is something attractive about having the same basic framework work in many languages (PyUnit, JUnit, C++Unit, etc), but on the other hand, it does add ballast. I use it, I certainly don't hate it, but on the other hand, there are enough things annoying about it that it's worth investing the effort to explore alternatives. >From the few days I've been playing with py.test, I think I like what I see, but it's got other issues. The "optimization elides assert" issue we've been talking about is one. It's also neat that I can write unittest-style test classes or go the simplier route of just writing static test functions, but there's a certain amount of TIMTOWTDI (did I spell that right?) smell to that. I'm also finding the very terse default output from unittest (basicly a bunch of dots followed by "all N tests passed") highly preferable to py.test's verbosity. In short, I haven't made up my mind yet, but I do appreciate the input I've gotten. -- http://mail.python.org/mailman/listinfo/python-list
Re: Change between Python 2.3 and 2.4 under WinXP
Lucas Raab wrote: > not to be biased toward your own products at all, or course :-) I'm not aware of any other tool that solves that specific problem. -- http://mail.python.org/mailman/listinfo/python-list
Re: adodbapi return value
Found out what's wrong. The "Output Parameter Availablity" property of the connection has the value DBPROPVAL_OA_ATROWRELEASE. By closing the record set (reading out the result set first) the output parameters were correct. Made the modification directly in the executeHelper method of the Cursor object. Changed at the end of the method; if isStoredProcedureCall and parameters != None: return self._returnADOCommandParameters(self.cmd) to if isStoredProcedureCall and parameters != None: x = self.fetchall() rs.Close() return self._returnADOCommandParameters(self.cmd), x Guess this is not the right way. Any comments appreciated. Nikolai Kirsebom -- http://mail.python.org/mailman/listinfo/python-list
playing with pyGoogle - strange codec error
Hello, I am playing around with pyGoogle and encountered an error that I have never seen, and I am unsure how to correct for it. Here is a code snippet: for r in data.results: print 'Title: ',r.title print 'URL: ',r.URL print 'Summary: ',r.snippet print Everything works fine until I get to r.snippet. Here is the error: UnicodeEncodeError: 'ascii' codec can't encode character '\ua9' in position 119: ordinal not in range(128) Any help is appreciated. Thanks, Brian -- Nail a post to the Spalted Board. Free WW'ing software and forums. Regular freebies! http://www.spaltedboard.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How to reload local namespace definitions in the python interpreter?
Tim Jarman wrote: [EMAIL PROTECTED] wrote: Hi, I am a beginner using the python interpreter. To reduce typing effort, I created a module called "aliases.py" containing some aliases for objects I commonly use like - aliases.py : import filecmp, os, commands op = os.path go = commands.getoutput dc = filecmp.dircmp p1 = '/mnt/usbkey/flash/' p2 = '/mnt/fat32/myfiles/flash/' When I start up the interpreter, I can simply type - from aliases import * This works fine, but each time I change any of the definitions in aliases.py, I have to restart the interpreter and type "from aliases import *" again. Is there any way to reload these definitions without restarting the interpreter? -Slath reload(aliases) Unfortunately a simple reload of the module won't result in the required changes to the local namespace: $ cat test87.py val = 33 >>> from test87 import * >>> print val 33 >>> val = 42 >>> reload(test87) >>> print val 42 >>> See: http://www.python.org/doc/2.4.1/lib/built-in-funcs.html By the way, are you aware of the import ... as ... idiom? e.g. import os.path as op This would, of course, require the user to qualify the names by prefixing them with "op.". regards Steve -- Steve Holden+1 703 861 4237 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: boolean -> DNF
Am Montag, 4. April 2005 15:08 schrieb Alex Polite: > I'd like to skip BoolStuff and do it all in python but I have no idea > where to start. Anyone out there with a PhD in computer science that > can give me a starting point? I once wrote a library which implemented parsing boolean expressions (with a simple homegrown parser) and reprinting the tree (to print it in DNF-Form is a pretty simple algorithm once you have the tree structure, I didn't implement this, but if you ask me I will). I don't have access to it at the moment (because I created it at home), but I'll send it to you tonight if you just contact me off-list. -- --- Heiko. listening to: Nine Inch Nails - The Wretched see you at: http://www.stud.mh-hannover.de/~hwundram/wordpress/ pgpMqLIytwLHn.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: (win32) speedfan api control
>>It makes me curious if I can get also the >>temperatures into Python script for >>further processing > Winspector is good for this kind of thing. Thanks for the link to Winspector - with this tool it's really easy to find out the names required to get down to the window elements of a running application. In the special case of speedfan there seems to be no way to get the temperatures shown in Reading tab into a Python script, because the texts with the temperature values are not separate window elements. The only message sent to "TJvPanel" (it's the class of the element with the temperatures) is WM_PAINT with 0, 0 values, so the actual temperatures are "hidden" from beeing accessed as easy as the value of the checkbox. Knowing the rectangle of the "TJvPanel" it should be probably possible to OCR the text shown, but this is another story. By the way: is there a free tool (primary for Windows, but best for both Linux and Windows) able to get the text of the word under the current mouse pointer position like it is done e.g. by Babylon translator? Claudio "Simon Brunning" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] > On Apr 3, 2005 1:52 AM, Claudio Grondi <[EMAIL PROTECTED]> wrote: > > May I ask how did you get the > > "TJvXPCheckbox" and the other > > values necessary to access the program > > GUI ? (as I can see, there is no source > > code of SpeedFan available) ? > > Winspector is good for this kind of thing. > > http://www.brunningonline.net/simon/blog/archives/001320.html > > -- > Cheers, > Simon B, > [EMAIL PROTECTED], > http://www.brunningonline.net/simon/blog/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Newsgroup Programming
Chuck wrote: I've found and used the nntplib module for newgroup programming. Can anyone suggest a library, technique or reference on how to combine mutliple messages with attachments such as mp3's, .wmv, *.avi, etc.? Are you talking about reconstructing a long post like a .avi that has been split up into separate messages? If so then you'll need to concatenate all the message bodies and use uudecode on the result, I suspect. regards Steve -- Steve Holden+1 703 861 4237 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Silly question re: 'for i in sys.stdin'?
Jeff Epler wrote: On Sun, Apr 03, 2005 at 09:49:42PM -0600, Steven Bethard wrote: Slick. Thanks! does isatty() actually work on windows? I'm a tiny bit surprised! Hmm... I was just talking about using iter(f.readline, ''), but it does appear that isatty returns True for sys.stdin in the interactive prompt: ActivePython 2.4.1 Build 245 (ActiveState Corp.) based on Python 2.4.1 (#65, Mar 30 2005, 09:33:37) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. py> os.isatty(sys.stdin.fileno()) True and at least some other things return False: py> os.isatty(file('temp.txt').fileno()) False STeVe -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Cookbook, 2'nd. Edition is published
Cameron Laird wrote: >IT'S IN THERE. The answer to all questions--well, to >surprisingly many questions--is in the Second Edition. >Even questions about the Second Edition itself are >answered therein. So, the summary: if in doubt, as- >sume that the Second Edition has what you want. It even has been known to answer questions about the Third Edition, using the "from future" construct publishers have wanted for years. :-) This is a fantastic book and my single favourite Python paper reference. It examines problems, even those which at first seem trivial, with an unexpected rigour and invigorating sense of adventure. Alex Martelli and the others should be congratulated. -- robin -- http://mail.python.org/mailman/listinfo/python-list
Re: "specialdict" module
Michael Spencer wrote: > Georg Brandl wrote: > >> >> I think I like Jeff's approach more (defaultvalues are just special >> cases of default factories); there aren't many "hoops" required. >> Apart from that, the names just get longer ;) > > Yes Jeff's approach does simplify the implementation and more-or-less > eliminates > my complexity objection > > But why do you write: > > def __getitem__(self, key): > try: > return super(defaultdict, self).__getitem__(key) > except KeyError, err: > try: > return self.setdefault(key, >self._default[0](*self._default[1], > **self._default[2])) > except KeyError: > raise err > > rather than: > > def __getitem__(self, key): > return self.setdefault(key, >self._default[0](*self._default[1], > **self._default[2])) > > (which could catch AttributeError in the case of _default not set) > I'm sure there's a reason, but I can't see it. In your version, the default factory is called every time a value is retrieved, which might be a performance problem. >>>Alternatively, you could provide factory functions to construct the >>>defaultdict. >>> Someone (Michele?) recently posted an implementation of this >> >> >> Yes, I think this could be reasonable. > > > ...though this would more naturally complement a fixed-default dictionary IMO > Your design permits - even encourages (by providing convenient setters) the > default to change over the lifetime of the dictionary. I'm not sure whether > that's good or bad, but it's a feature worth discussing. It's certainly more in the spirit of Python -- we're consenting adults, and so we are allowed to change the default. mfg Georg -- http://mail.python.org/mailman/listinfo/python-list
Re: TOC of Python Cookbook now online (was Re: author index for Python Cookbook 2?)
[EMAIL PROTECTED] wrote: >I emailed the O'Reilly webmaster, and the table of contents are now >online at http://www.oreilly.com/catalog/pythoncook2/toc.html and also >listed below. Unfortunately there is no list of authors for the sections in the book. This is likely its only shortcoming! -- robin -- http://mail.python.org/mailman/listinfo/python-list
Re: distutils
Guillaume JULLIEN wrote: Hi, New to python, I' m trying to use distutils. And I get this error # python setup.py build Traceback (most recent call last): File "setup.py", line 89, in ? from distutils import core ImportError: No module named distutils I have Python 2.3.4 installed Any advice ? I assume that you are on Linux or FreeBSD or somesuch. Install the Python development package for your system. It usually has a name like python-dev or python-devel. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list
Extracting Font Outline informations
Hi, there is a Python library that makes me able to extract outline informations from font files? I'd like to manage TrueType and FreeType fonts ... I searched for som wrappers, but I didn't find anything ... bye -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about Enthought python distribution
Oh Kyu Yoon wrote: Hi! I have been using the python 2.3.3 distribution from Enthought Inc because it has most of the libraries I use included. Does anyone know when Enthought will release the python 2.4 distribution? The next release will be based on Python 2.3.5. They probably won't release a 2.4-based version for some time. They use this distribution as the base for the software they write for their clients, and they don't have current intentions to develop against 2.4 quite yet. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter -- http://mail.python.org/mailman/listinfo/python-list
Semi-newbie, rolling my own __deepcopy__
Hi, folks, First, the obligatory cheerleading -- then, my questions... I love Python! I am only an occasional programmer. Still, the logic of the language is clear enough that I can retain pretty much all that I have learned from one infrequent programming session to the next. That's quite an accomplishment for a language this powerful. Also, I'm finally beginning to grasp OOP. I could never quite get the hang of it in C++ or Java. Recently, I discovered __getitem__ and pickle. Oh, yeah. Anyway, my present problem is that I want to make copies of instances of my own custom classes. I'm having a little trouble understanding the process. Not that I think that it matters -- but in case it does, I'll tell you that I'm running Python 2.3.4 on a Win32 machine. I started naively, thinking that I could just call copy.deepcopy() and be done with it. After getting a TypeError from the interpreter, I read the deepcopy docs and discovered that I need to implement a __deepcopy__ method in my class. But the docs are a bit vague here. What exactly should this __deepcopy__ do? I tried looking for examples of __deepcopy__ code on the Net, but I'm not quite understanding what I'm finding there. I guess that I'm getting deeper into the guts of Python than I planned. AFAIK, I'm supposed to add a "def __deepcopy__(self, memo):" to my class definition. This will get called when I invoke copy.deepcopy(myObject). The object to be copied is self, I presume. What exactly is memo? The docs say that it's a dictionary which "keeps track of what has already been copied." Somewhere I remember reading that the namespace of an object is a dictionary. So is memo identical to the dictionary of the new object that I'm trying to create? What exactly do I add to memo? I think that I should make shallow copies of methods, but deep copies of data structures (the contents of which I'm likely to change). Do I iterate through and copy the items in dir(self)? Do I update memo manually, or does passing memo into copy() or deepcopy() automatically update memo's contents? Are there any items that I *shouldn't* copy from self to memo? Should __deepcopy__ return memo? Sorry for all the confusion -- and thanks for your help! -- Rainforest laid low. "Wake up and smell the ozone," Says man with chainsaw. John J. Ladasky Jr., Ph.D. -- http://mail.python.org/mailman/listinfo/python-list
(no subject)
#! rnews 2776 Newsgroups: comp.lang.python Path: news.xs4all.nl!newsspool.news.xs4all.nl!transit.news.xs4all.nl!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!central.cox.net!east.cox.net!filt02.cox.net!peer01.cox.net!cox.net!attga1!attga2!attws2!ip.att.net!NetNews1!xyzzy!nntp From: Harry George <[EMAIL PROTECTED]> Subject: Re: unittest vs py.test? X-Nntp-Posting-Host: cola2.ca.boeing.com Content-Type: text/plain; charset=us-ascii Message-ID: <[EMAIL PROTECTED]> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Lines: 49 Sender: [EMAIL PROTECTED] Organization: The Boeing Company References: <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> Mime-Version: 1.0 Date: Mon, 4 Apr 2005 15:30:36 GMT Xref: news.xs4all.nl comp.lang.python:370744 [EMAIL PROTECTED] (Roy Smith) writes: > Peter Hansen <[EMAIL PROTECTED]> wrote: > >It seems possible to me that I might have helped him > >solely by pointing out that unittest might not be so > >"heavy" as some people claimed. I got the impression > >that he might be swayed by some unfounded claims not > >even to look further at unittest, which I felt would > >be a bad thing. > > I'm the "him" referred to above. I've been using unittest ever since > it was first added to the standard library (actually, now that I think > about it, I believe I may have been using it even before then). > > And yes, I think unittest brings along a certain amount of baggage. > There is something attractive about having the same basic framework > work in many languages (PyUnit, JUnit, C++Unit, etc), but on the other > hand, it does add ballast. I use it, I certainly don't hate it, but > on the other hand, there are enough things annoying about it that it's > worth investing the effort to explore alternatives. > > From the few days I've been playing with py.test, I think I like what > I see, but it's got other issues. The "optimization elides assert" > issue we've been talking about is one. > > It's also neat that I can write unittest-style test classes or go the > simplier route of just writing static test functions, but there's a > certain amount of TIMTOWTDI (did I spell that right?) smell to that. > > I'm also finding the very terse default output from unittest (basicly > a bunch of dots followed by "all N tests passed") highly preferable to > py.test's verbosity. > > In short, I haven't made up my mind yet, but I do appreciate the input > I've gotten. > > I haven't used pytest, so no comparisons to offer. But for unittest, I've found a lot of the "baggage" can be automated. My mkpythonproj (http://www.seanet.com/~hgg9140/comp/index.html#L006) does that. When you generate a project, you get a unittest suite with a default test ready to run, and the mechanisms needed to add more. -- [EMAIL PROTECTED] 6-6M21 BCA CompArch Design Engineering Phone: (425) 294-4718 -- http://mail.python.org/mailman/listinfo/python-list
Re: Extracting Font Outline informations
TTFQuery, built on top of FontTools, allows you to do this. You can see use of the extraction in the OpenGLContext/scenegraph/text package, which uses TTFQuery to implement 3D text rendering. http://ttfquery.sourceforge.net/ http://pyopengl.sourceforge.net/context/ HTH, Mike Gabriele *Darkbard* Farina wrote: > Hi, > > there is a Python library that makes me able to extract outline > informations from font files? I'd like to manage TrueType and FreeType > fonts ... > > I searched for som wrappers, but I didn't find anything ... > > bye Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com -- http://mail.python.org/mailman/listinfo/python-list
Re: "specialdict" module
Michael Spencer: > Alternatively, you could provide factory functions to construct the defaultdict. > Someone (Michele?) recently posted an implementation of this Yes, here is the link for the ones who missed that thread: http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/a0bae9b887a4de41/7567d30b796423c7?q=simionato+defaultdict&rnum=1#7567d30b796423c7 -- http://mail.python.org/mailman/listinfo/python-list
Re: "specialdict" module
About not using super: you might have problems in multiple inheritance. Suppose I want to use both your defaultdict and a thirdpartdict. A subclass class mydict(defaultdict, thirdpartdict): pass would not work if thirdpartdict requires a non-trivial __init__ , since without super in defaultdict.__init__ you would just call dict.__init__ and not thirdpartdict. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Re: re module non-greedy matches broken
how then, do i specify a non-greedy regex <1st-pat>*? that is, such that non-greedy part *? excludes a match of <1st-pat> in other words, how do i write regexes for my examples? what book or books on regexes or with a good section on regexes would you recommend? Hopcroft and Ullman? "André Malo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > * "lothar" <[EMAIL PROTECTED]> wrote: > > > this response is nothing but a description of the behavior i reported. > > Then you have not read my response carefully enough. > > > as to whether this behaviour was intended, one would have to ask the module > > writer about that. > > No, I've responded with a view on regexes, not on the module. That is the way > _regexes_ work. Non-greedy regexes do not match the minimal-length at all, they > are just ... non-greedy (technically the backtracking just stacks the longest > instead of the shortest). They *may* match the shortest match, but it's a > special case. Therefore I've stated that the documentation is incomplete. > > Actually your expectations go a bit beyond the documentation. From a certain > point of view (matches always start most left) the matches you're seeing > *are* the minimal-length matches. > > > because of the statement in the documentation, which places no qualification > > that's the point. > > > on how the scan for the shortest possible match is to be done, my guess is > > that this problem was overlooked. > > In the docs, yes. But buy yourself a regex book and learn for yourself ;-) > The first thing you should learn about regexes is that the source of pain > of most regex implementations is the documentation, which is very likely > to be wrong. > > Finally let me ask a question: > > import re > x = re.compile('<.*?>') > print x.search('..').group(0) > > What would you expect to be printed out? or ? Why? > > nd -- http://mail.python.org/mailman/listinfo/python-list
Re: re module non-greedy matches broken
> what book or books on regexes A standard is Mastering Regular Expressions, 2nd ed, by xxx (sorry, forget) TJR -- http://mail.python.org/mailman/listinfo/python-list
Re: Semi-newbie, rolling my own __deepcopy__
[EMAIL PROTECTED] wrote: Hi, folks, First, the obligatory cheerleading -- then, my questions... I love Python! I am only an occasional programmer. Still, the logic of the language is clear enough that I can retain pretty much all that I have learned from one infrequent programming session to the next. That's quite an accomplishment for a language this powerful. Also, I'm finally beginning to grasp OOP. I could never quite get the hang of it in C++ or Java. Recently, I discovered __getitem__ and pickle. Oh, yeah. Anyway, my present problem is that I want to make copies of instances of my own custom classes. I'm having a little trouble understanding the process. Not that I think that it matters -- but in case it does, I'll tell you that I'm running Python 2.3.4 on a Win32 machine. I started naively, thinking that I could just call copy.deepcopy() and be done with it. After getting a TypeError from the interpreter, I read the deepcopy docs and discovered that I need to implement a __deepcopy__ method in my class. But the docs are a bit vague here. What exactly should this __deepcopy__ do? I tried looking for examples of __deepcopy__ code on the Net, but I'm not quite understanding what I'm finding there. I guess that I'm getting deeper into the guts of Python than I planned. AFAIK, I'm supposed to add a "def __deepcopy__(self, memo):" to my class definition. This will get called when I invoke copy.deepcopy(myObject). The object to be copied is self, I presume. What exactly is memo? The docs say that it's a dictionary which "keeps track of what has already been copied." Somewhere I remember reading that the namespace of an object is a dictionary. So is memo identical to the dictionary of the new object that I'm trying to create? What exactly do I add to memo? I think that I should make shallow copies of methods, but deep copies of data structures (the contents of which I'm likely to change). Do I iterate through and copy the items in dir(self)? Do I update memo manually, or does passing memo into copy() or deepcopy() automatically update memo's contents? Are there any items that I *shouldn't* copy from self to memo? Should __deepcopy__ return memo? Sorry for all the confusion -- and thanks for your help! -- Rainforest laid low. "Wake up and smell the ozone," Says man with chainsaw. John J. Ladasky Jr., Ph.D. If you google for: python __deepcopy__ cookbook you will find a couple of examples of this method in use, among them: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/259179 class deque(object): def __init__(self, iterable=()): if not hasattr(self, 'data'): self.left = self.right = 0 self.data = {} self.extend(iterable) [...snip methods...] def __deepcopy__(self, memo={}): from copy import deepcopy result = self.__class__() memo[id(self)] = result result.__init__(deepcopy(tuple(self), memo)) return result HTH Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: "specialdict" module
Michele Simionato wrote: > About not using super: you might have problems in multiple inheritance. > Suppose I want to use both your defaultdict and a thirdpartdict. A > subclass > > class mydict(defaultdict, thirdpartdict): >pass > > would not work if thirdpartdict requires a non-trivial __init__ , since > without super in defaultdict.__init__ you would just call dict.__init__ > and not thirdpartdict. Right. I thought about a combined defaultdict/keytransformdict, which seems to be easy to create with the current implementation: class defaultkeytransformdict(defaultdict, keytransformdict): pass At least I hope so. This is another argument against the initializing of defaultfactory or keytransformer in __init__. mfg Georg Here comes the current module (keytransformdict should be working now for all dict methods): # specialdict - subclasses of dict for common tasks # class NoDefaultGiven(Exception): pass class defaultdict(dict): __slots__ = ['_default'] def __init__(self, *args, **kwargs): self._defaulttype = 0 super(defaultdict, self).__init__(*args, **kwargs) def setdefaultvalue(self, value): def defaultfactory(): return value self._default = (defaultfactory, (), {}) def setdefaultfactory(self, factory, *args, **kwargs): if not callable(factory): raise TypeError, 'default factory must be a callable' self._default = (factory, args, kwargs) def cleardefault(self): def defaultfactory(): raise NoDefaultGiven self._default = (defaultfactory, (), {}) def __getitem__(self, key): try: return super(defaultdict, self).__getitem__(key) except KeyError, err: try: return self.setdefault(key, self._default[0](*self._default[1], **self._default[2])) except NoDefaultGiven: raise err class keytransformdict(dict): __slots__ = ['_transformer'] def __init__(self, *args, **kwargs): self._transformer = lambda x: x super(keytransformdict, self).__init__(*args, **kwargs) def settransformer(self, transformer): if not callable(transformer): raise TypeError, 'transformer must be a callable' self._transformer = transformer def __setitem__(self, key, value): print "setitem" super(keytransformdict, self).__setitem__(self._transformer(key), value) def __getitem__(self, key): print "getitem" return super(keytransformdict, self).__getitem__(self._transformer(key)) def __delitem__(self, key): super(keytransformdict, self).__delitem__(self._transformer(key)) def has_key(self, key): return super(keytransformdict, self).has_key(self._transformer(key)) def __contains__(self, key): return self.has_key(key) def get(self, key, default): return super(keytransformdict, self).get(self._transformer(key), default) def setdefault(self, key, default): return super(keytransformdict, self).setdefault(self._transformer(key), default) def pop(self, key, default): return super(keytransformdict, self).pop(self._transfomer(key), default) def update(self, other=None, **kwargs): if other is not None: if hasattr(other, "keys"): super(keytransformdict, self).update((self._transformer(k), other[k]) for k in other.keys()) else: super(keytransformdict, self).update((self._transformer(k), v) for (k, v) in other) if kwargs: super(keytransformdict, self).update((self._transformer(k), v) for (k, v) in kwargs.iteritems()) class sorteddict(dict): def __iter__(self): for key in sorted(super(sorteddict, self).__iter__()): yield key def keys(self): return list(self.iterkeys()) def items(self): return list(self.iteritems()) def values(self): return list(self.itervalues()) def iterkeys(self): return iter(self) def iteritems(self): return ((key, self[key]) for key in self) def itervalues(self): return (self[key] for key in self) -- http://mail.python.org/mailman/listinfo/python-list
Re: "specialdict" module
Georg Brandl wrote: > Michele Simionato wrote: >> About not using super: you might have problems in multiple inheritance. >> Suppose I want to use both your defaultdict and a thirdpartdict. A >> subclass >> >> class mydict(defaultdict, thirdpartdict): >>pass >> >> would not work if thirdpartdict requires a non-trivial __init__ , since >> without super in defaultdict.__init__ you would just call dict.__init__ >> and not thirdpartdict. > > Right. I thought about a combined defaultdict/keytransformdict, > which seems to be easy to create with the current implementation: > > class defaultkeytransformdict(defaultdict, keytransformdict): > pass > > At least I hope so. This is another argument against the initializing > of defaultfactory or keytransformer in __init__. > > mfg > Georg > > Here comes the current module (keytransformdict should be working now > for all dict methods): > > # specialdict - subclasses of dict for common tasks > # > > class NoDefaultGiven(Exception): > pass > > class defaultdict(dict): > __slots__ = ['_default'] > > def __init__(self, *args, **kwargs): > self._defaulttype = 0 ^ This must read "self.cleardefault()", of course. mfg Georg -- http://mail.python.org/mailman/listinfo/python-list
Dr. Dobb's Python-URL! - weekly Python news and links (Apr 4)
QOTW: "Paraphrasing Occam, I would say 'don't multiply base classes without necessity'. ;)" - Michele Simionato "The world diversifies, the world congeals." - Raymond Hettinger (commenting on the fact that py.test happily runs unittest test suites) "I can think of no better reason for a programmer to regularly learn languages: 'our tools warp our thinking.' A programmer is a professionally warped thinker." - Scott David Daniels Highlight of the week; Python 2.4.1 final is out: http://groups-beta.google.com/group/comp.lang.python.announce/msg/b82afbc729226433 The effbot was once asked how to find an object's name: "The same way as you get the name of that cat you found on your porch: the cat (object) itself cannot tell you its name, and it doesn't really care -- so the only way to find out what it's called is to ask all your neighbours (namespaces) if it's their cat (object) ... and don't be surprised if you'll find that it's known by many names, or no name at all!" Duncan Booth shows us how to ask the neighbours: http://groups-beta.google.com/group/comp.lang.python/msg/237dc92f3629dd9a Ian Bicking and David Hansson talk marketing: http://blog.ianbicking.org/why-web-programming-matters-most.html http://www.loudthinking.com/arc/000432.html Incidentally, when will a hero(ine) emerge to do for GUI toolkits what the PyWebOff has started for Web frameworks? A couple of nice decorator examples this week: Scott David Daniels suggests that a decorator might tidy up wxPython event handlers, and Oren Tirosh shows us how to hide globals from a function: http://groups-beta.google.com/group/comp.lang.python/msg/338134f3bd7c439c http://groups-beta.google.com/group/comp.lang.python/msg/d34e97cc2ae284d6 Guido demonstrates multimethods, and Ian Bicking gives us an alternative implementation using generic functions: http://www.artima.com/weblogs/viewpost.jsp?thread=101605 http://blog.ianbicking.org/more-on-multimethods.html Is Python supposed to be boring? http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/ccf712755b3af3f4/437f80709adcbd86?rnum=1#ba7ad3fb3f503426 Evan Jones shows us How to Use UTF-8 with Python: http://evanjones.ca/python-utf8.html Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. For far, FAR more Python reading than any one mind should absorb, much of it quite interesting, several pages index much of the universe of Pybloggers. http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog http://www.planetpython.org/ http://mechanicalcat.net/pyblagg.html comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Brett Cannon continues the marvelous tradition established by Andrew Kuchling and Michael Hudson of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ The Python Business Forum "further[s] the interests of companies that base their business on ... Python." http://www.python-in-business.org Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation.
setup distributed computing for two computer only
Hello, Is there any one who has experiance about how to setup distributed computing for 2 computer only. I really want to know from the start. Any suggestion appreciated. Sincerely Yours, Pujo -- http://mail.python.org/mailman/listinfo/python-list
Dr. Dobb's Python-URL! - weekly Python news and links (Apr 4)
QOTW: "Paraphrasing Occam, I would say 'don't multiply base classes without necessity'. ;)" - Michele Simionato "The world diversifies, the world congeals." - Raymond Hettinger (commenting on the fact that py.test happily runs unittest test suites) "I can think of no better reason for a programmer to regularly learn languages: 'our tools warp our thinking.' A programmer is a professionally warped thinker." - Scott David Daniels Highlight of the week; Python 2.4.1 final is out: http://groups-beta.google.com/group/comp.lang.python.announce/msg/b82afbc729226433 The effbot was once asked how to find an object's name: "The same way as you get the name of that cat you found on your porch: the cat (object) itself cannot tell you its name, and it doesn't really care -- so the only way to find out what it's called is to ask all your neighbours (namespaces) if it's their cat (object) ... and don't be surprised if you'll find that it's known by many names, or no name at all!" Duncan Booth shows us how to ask the neighbours: http://groups-beta.google.com/group/comp.lang.python/msg/237dc92f3629dd9a Ian Bicking and David Hansson talk marketing: http://blog.ianbicking.org/why-web-programming-matters-most.html http://www.loudthinking.com/arc/000432.html Incidentally, when will a hero(ine) emerge to do for GUI toolkits what the PyWebOff has started for Web frameworks? A couple of nice decorator examples this week: Scott David Daniels suggests that a decorator might tidy up wxPython event handlers, and Oren Tirosh shows us how to hide globals from a function: http://groups-beta.google.com/group/comp.lang.python/msg/338134f3bd7c439c http://groups-beta.google.com/group/comp.lang.python/msg/d34e97cc2ae284d6 Guido demonstrates multimethods, and Ian Bicking gives us an alternative implementation using generic functions: http://www.artima.com/weblogs/viewpost.jsp?thread=101605 http://blog.ianbicking.org/more-on-multimethods.html Is Python supposed to be boring? http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/ccf712755b3af3f4/437f80709adcbd86?rnum=1#ba7ad3fb3f503426 Evan Jones shows us How to Use UTF-8 with Python: http://evanjones.ca/python-utf8.html Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. For far, FAR more Python reading than any one mind should absorb, much of it quite interesting, several pages index much of the universe of Pybloggers. http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog http://www.planetpython.org/ http://mechanicalcat.net/pyblagg.html comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Brett Cannon continues the marvelous tradition established by Andrew Kuchling and Michael Hudson of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ The Python Business Forum "further[s] the interests of companies that base their business on ... Python." http://www.python-in-business.org Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation.
Re: Sending keytrokes to Windows app
In article <[EMAIL PROTECTED]>, Simon Brunning <[EMAIL PROTECTED]> wrote: >On Apr 4, 2005 12:04 PM, Marten Hedman <[EMAIL PROTECTED]> wrote: >> I am trying to control a Windows application from a python script with >> SendKeys and Python 2.3. > >WATSUP might be worth a look, instead... > >http://www.tizmoi.net/watsup/intro.html . . . More references: http://wiki.tcl.tk/8813 >. -- http://mail.python.org/mailman/listinfo/python-list
Re: re module non-greedy matches broken
On Apr 4, 2005 10:06 PM, Terry Reedy <[EMAIL PROTECTED]> wrote: > > what book or books on regexes > A standard is Mastering Regular Expressions, 2nd ed, by xxx (sorry, forget) Mastering Regular Expressions, by Jeffrey Friedl See http://www.regex.info/ Regards, -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info -- http://mail.python.org/mailman/listinfo/python-list
Symbol Referencing Error in Fortran 90
while compiling on: SunOS 5.8 Generic_108528-27 sun4u sparc SUNW,Sun-Fire-280R I get the following error: Undefined first referenced symbol in file matrixi_tst.o ld: fatal: Symbol referencing errors. No output written to a.out However, the compilation is successful when linking is suppressed. Can anyone help me get rid of this error.. Compiling with the verbose option gives the following message: ### command line files and options (expanded): ### -v tst.f90 ### f90: Note: LM_LICENSE_FILE = (null) ### f90: Note: NLSPATH = /local/SUNWspro/bin/../WS6U2/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/local/SUNWspro/bin/../WS6U2/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat /local/SUNWspro/bin/../WS6U2/bin/f90comp -y-o -ytst.o -ev -y-ftrap=common -m3 -dq -y-fbe -y/local/SUNWspro/bin/../WS6U2/bin/fbe -y-xarch=generic -y-s -H "/local/SUNWspro/bin/../WS6U2/bin/f90 -v " -y-xcache=generic -xcache=generic -I/local/SUNWspro/WS6U2/include/f90/v8 -p/local/SUNWspro/WS6U2/lib -y-verbose -xall tst.f90 ### f90: Note: LD_LIBRARY_PATH = (null) ### f90: Note: LD_RUN_PATH = (null) ### f90: Note: LD_OPTIONS = (null) /usr/ccs/bin/ld -t -R/local/SUNWspro/lib:/opt/SUNWspro/lib -o a.out /local/SUNWspro/WS6U2/lib/crti.o /local/SUNWspro/WS6U2/lib/crt1.o /local/SUNWspro/WS6U2/lib/values-xi.o -Y P,/local/SUNWspro/lib:/local/SUNWspro/WS6U2/lib:/usr/ccs/lib:/usr/lib tst.o -lfui -lfai -lfai2 -lfsumai -lfprodai -lfminlai -lfmaxlai -lfminvai -lfmaxvai -lfsu -lsunmath -lm -lc /local/SUNWspro/WS6U2/lib/crtn.o Undefined first referenced symbol in file matrixi_tst.o ld: fatal: Symbol referencing errors. No output written to a.out rm tst.o -- http://mail.python.org/mailman/listinfo/python-list
Re: LD_LIBRARY_PATH - how to set?
On Fri, 01 Apr 2005 01:13:03 GMT, rumours say that Joal Heagney <[EMAIL PROTECTED]> might have written: >>> $* >>>--- >> >> >> And you should change that last line to: >> >>"$@" >> > >Ah yes, because we want the arguments passed in as seperate words, not >as a whole string. No, this would happen if your last line was "$*" To summarize, suppose your script is called with the following arguments: "File with space.txt" arg2 arg3 Here follow "last lines" and the corresponding sys.argv[1:]: LAST LINE: $* SYS.ARGV : ["File", "with", "space.txt", "arg2", "arg3"] LAST LINE: "$*" SYS.ARGV : ["File with space.txt arg2 arg3"] LAST LINE: "$@" SYS.ARGV : ["File with space.txt", "arg2", "arg3"] For more information, see man 1 bash or man 1 ksh or man 1 sh. Don't know if this applies to *csh family. -- TZOTZIOY, I speak England very best. "Be strict when sending and tolerant when receiving." (from RFC1958) I really should keep that in mind when talking with people, actually... -- http://mail.python.org/mailman/listinfo/python-list
Re: DIY Spam Filter in Python
* [EMAIL PROTECTED] (Peter Ballard) in comp.lang.python: > Source code, and a bit of documentation, is at: > http://members.ozemail.com.au/~pballard/diyspamfilter.html BTW, 2 of the 3 files are links, so missing from the tar archive... -- DW -- http://mail.python.org/mailman/listinfo/python-list
Re: re module non-greedy matches broken
--- lothar <[EMAIL PROTECTED]> wrote: > how then, do i specify a non-greedy regex > <1st-pat>*? > > that is, such that non-greedy part *? > excludes a match of <1st-pat> > > in other words, how do i write regexes for my examples? Not sure if I completely understand your explanation, but does this get any closer to what your looking for? >>> vwre = re.compile("V[^V]*?W") >>> newdoc = "V1WVVV2WWW" >>> re.findall(vwre, newdoc) ['V1W', 'V2W'] That is: , then as few times as possible, then John Ridley Send instant messages to your online friends http://uk.messenger.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Re: terminating an inactive process
[Earl Eiland wrote] > I'm running a PyWin program that executes another program using > subprocess.Popen(). Unfortunately, this other program isn't well > behaved, and frequently terminates without terminating its process. > After this happens enough times, all my memory is tied up, and the > machine crashes. > > Using subprocess.poll(), I can keep my program from hanging, by timing > out the process, and starting anew. This still leaves the previous > process hogging memory. How do I kill the old process in Windows? You might be able to use or borrow code from my process.py module. process.py is very similar to Python 2.4's subprocess. It provides a ProcessOpen class (similar to subprocess' Popen). A ProcessOpen instance has wait() and kill() methods that work fine on Windows. Under the hood they are using the Win32 API WaitForSingleObject() and TerminateProcess() functions. http://starship.python.net/~tmick/ Yes, I haven't updated process.py in a while. :) It works fine with Python 2.3 and 2.4 (despite only saying Python 2.2 there). It *does* rely on the PyWin32 extensions being installed with you Python installation -- which you'll already have if you use ActivePython or which you can install separately from here: http://sourceforge.net/project/showfiles.php?group_id=78018 Cheers, Trent -- Trent Mick [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Semi-newbie, rolling my own __deepcopy__
Michael Spencer wrote: def __deepcopy__(self, memo={}): from copy import deepcopy result = self.__class__() memo[id(self)] = result result.__init__(deepcopy(tuple(self), memo)) return result I know this is not your recipe, but is there any reason to use self.__class__() instead of type(self)() if you know you're inside a new-style class? STeVe -- http://mail.python.org/mailman/listinfo/python-list
dynamic partial mirror, apt-get fails
Hi everybody, I am trying to implement a cgi script for mirroring a small part of a large collection of files (the debian distribution). The idea is to mirror only those files which are requested, by downloading them "on the fly" when the clients request them. Requests in the form "wget http://local.mirror.pt/~debian/cgi-bin/get.cgi?pool/main/a/abcde/abcde.deb"; work fine already. The script get.cgi verifies if the file exists. If it exists, the script simply sends a "Location: ..." directive to its standart output and exists. If the file does not exist, the script downloads it from one of several predefined locations, and after the downloading process has succeeded it sends a "Location: ..." directive to its standard output and exits. This is more or less what apt-proxy (and other proxies) do, except that my script is independent of the directory structure (it should work for any collection of files, not only for the debian distribution) and it can be run by an ordinary user (you don't have to be root in order to install it). Now, the problem is that the debian package manager (dselect or apt-get) does not work exactly like wget. Requests in the form "apt-get http://..."; fail with the strange message "302 Found". I looked a little bit into the source of both wget and apt-get and it seems to me that wget has code which deals specifically with the "Location: ..." directive, while apt-get has not. The questions are: Is my conclusion above correct ? Are future versions of apt-get going to accept "Location: ..." directives ? Should I try and modify the source of apt-get in order to teach it to handle these directives ? You can find all the details about my problem at my web page: http://cmaf.ptmat.fc.ul.pt/~barbaros -> english -> computers and programming -> deb_part_mirr Thank you. Cristian Barbarosie -- PLEASE NOTE: comp.infosystems.www.authoring.cgi is a SELF-MODERATED newsgroup. aa.net and boutell.com are NOT the originators of the articles and are NOT responsible for their content. HOW TO POST to comp.infosystems.www.authoring.cgi: http://www.thinkspot.net/ciwac/howtopost.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Symbol Referencing Error in Fortran 90
This message was also posted and replied to on comp.lang.fortran -- I think it's presence here is an accident. -- http://mail.python.org/mailman/listinfo/python-list
Re: setup distributed computing for two computer only
[EMAIL PROTECTED] wrote: > Is there any one who has experiance about how to setup distributed > computing for 2 computer only. I really want to know from the start. > Any suggestion appreciated. Please be more specific about "distributed computing"... --Irmen -- http://mail.python.org/mailman/listinfo/python-list
Re: help with python-devel!!!
* Michele Simionato wrote: > Just give (as root) > > # urpmi python-devel The OP mentioned that urpmi couldn't find a package by that name. So it might be worth querying for "libpython" if that fails: [EMAIL PROTECTED] urpmq libpython The following packages contain libpython: libpython2.3 libpython2.3-devel John Ridley Send instant messages to your online friends http://uk.messenger.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Eric3 under WinXP
Hello NG, (Win XP) I have successfully installed pyqt, but not qtext, which I need to run Eric3. The PyQT demo files run fine. I've downloaded QScintilla, compiled via MS-VC, but (I suppose I need the SIG), to translate or provide the Python interface with pyd Files. Eric complains, that qtext is not found. Has anyone success with getting this to work and how? Many thanks in advance for possible answers, -- Franz Steinhäusler DrPython (Project Developer) http://mitglied.lycos.de/drpython/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Semi-newbie, rolling my own __deepcopy__
Steven Bethard wrote: Michael Spencer wrote: def __deepcopy__(self, memo={}): from copy import deepcopy result = self.__class__() memo[id(self)] = result result.__init__(deepcopy(tuple(self), memo)) return result I know this is not your recipe, but is there any reason to use self.__class__() instead of type(self)() if you know you're inside a new-style class? STeVe I don't know - aren't they identical? I would write self.__class__ (without claiming that that's better) BTW, I had a different question about the method: wouldn't: result = self.__class__.__new__() or in your form: result = type(self).__new__() be better (i.e., clearer and possibly safer) than calling __init__ twice (but I haven't tried it!) Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: How to reload local namespace definitions in the python interpreter?
On Apr 4, 2005 11:10 AM, Steve Holden <[EMAIL PROTECTED]> wrote: > Tim Jarman wrote: > > [EMAIL PROTECTED] wrote: > > > > > >>Hi, > >> > >>I am a beginner using the python interpreter. To reduce typing effort, > >>I created a module called "aliases.py" containing some aliases for > >>objects I commonly use like - > >> > >>aliases.py : > >> > >> > >>import filecmp, os, commands > >> > >>op = os.path > > By the way, are you aware of the import ... as ... idiom? > > e.g. import os.path as op > > > > This would, of course, require the user to qualify the names by > prefixing them with "op.". > What the OP listed above requires that too. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: setup distributed computing for two computer only
Hello, There are two computer. For example one computer ask other computer to run function, procedure or object then receive the result. I want to know about what should I do to setup such system and what software I need to implement it. Sincerely Yours, Pujo -- http://mail.python.org/mailman/listinfo/python-list
Status of Chaco?
I recently had reason to look up Chaco again, but after searching the SciPy and Enthought websites, I see it seems to have gone missing. Looking over c.l.p, I can find only one quasi-recent message from Eric about at, from almost a year ago: > Chaco has moved to a new package. We hope to have it released within > the next few weeks. Is Chaco dead? Or just pining? -- Tim Lesher <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list
Re: setup distributed computing for two computer only
Am Montag, 4. April 2005 21:27 schrieb [EMAIL PROTECTED]: > Google for: Python Remote Objects or Python XMLRPC -- --- Heiko. listening to: Nine Inch Nails - The Downward Spiral see you at: http://www.stud.mh-hannover.de/~hwundram/wordpress/ pgpbsPKhjKOEY.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: help with python-devel!!!
Am Montag, 4. April 2005 20:54 schrieb John Ridley: > The OP mentioned that urpmi couldn't find a package by that name. So it > might be worth querying for "libpython" if that fails: This is why why I don't use a binary distribution... :-) (Differences in) Naming makes getting at devel-packages a guessing-game at best. -- --- Heiko. listening to: Nine Inch Nails - Hurt see you at: http://www.stud.mh-hannover.de/~hwundram/wordpress/ pgpIlx4oN486w.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: re module non-greedy matches broken
with respect to the documentation, the module is broken. the module does not necessarily deliver a "minimal length" match for a non-greedy pattern. "Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "lothar" wrote: > > > this is a bug and it needs to be fixed. > > it's not a bug, and it's not going to be "fixed". search, findall, finditer, sub, > etc. all scan the target string from left to right, and process the first location > (or all locations) where the pattern matches. > > > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: StopIteration in the if clause of a generator expression
[Steven Bethard] > and I often find myself alternating > between the two when I can't decide which one seems more Pythonic. Both are pythonic. Use a genexp when you need a generator and use a listcomp when you need a list. Raymond Hettinger -- http://mail.python.org/mailman/listinfo/python-list
Re: mini_httpd (ACME Labs) & Python 2.4.1 integration
We found the answer, just in case one was looking for it... I turns out that setting the environment params (CGI_PATH & CGI_LD_LIB_PATH) is not sufficient. One has to still add the path entry to the script itself... like so: #! /python2.4 May also work with ensuring env variable PYTHONPATH is set right. /venkat -- http://mail.python.org/mailman/listinfo/python-list
Re: How to reload local namespace definitions in the python interpreter?
Bill Mill wrote: On Apr 4, 2005 11:10 AM, Steve Holden <[EMAIL PROTECTED]> wrote: Tim Jarman wrote: [EMAIL PROTECTED] wrote: Hi, I am a beginner using the python interpreter. To reduce typing effort, I created a module called "aliases.py" containing some aliases for objects I commonly use like - aliases.py : import filecmp, os, commands op = os.path By the way, are you aware of the import ... as ... idiom? e.g. import os.path as op This would, of course, require the user to qualify the names by prefixing them with "op.". What the OP listed above requires that too. I believe the OP was suggesting from aliases import * which specifically loads the names in the module (or those specified in module.__all__) into the importing namespace for use without qualification. regards Steve -- Steve Holden+1 703 861 4237 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: How to execute a cmd line program without invoking console window?
this is very useful, thanks very much! -- http://mail.python.org/mailman/listinfo/python-list
Changing TEXT color from python
so i am writing a program in Python and i want to print out a few statements in Different colors for example "Print hello world in RED, and "GOOD BYE in blue" " how can i do this...and hopefully without including any external modules. thanks in advance -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing TEXT color from python
On 2005-04-04, GujuBoy <[EMAIL PROTECTED]> wrote: > so i am writing a program in Python and i want to print out a few > statements in Different colors > > for example "Print hello world in RED, and "GOOD BYE in blue" " > > how can i do this... Depends on what you're printing on. tty? curses os.popen('tput') printer? reportlab > and hopefully without including any external modules. I suppose you can pick an output device and hard-wire the escape sequences into your code. -- Grant Edwards grante Yow! S!! I hear SIX at TATTOOED TRUCK-DRIVERS visi.comtossing ENGINE BLOCKS into empty OIL DRUMS... -- http://mail.python.org/mailman/listinfo/python-list
Re: re module non-greedy matches broken
no - in the non-greedy regex <1st-pat>*? <1st-pat>, and are arbitrarily complex patterns. with character classes and negative character classes you do not need non-greediness anyway. "John Ridley" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > --- lothar <[EMAIL PROTECTED]> wrote: > > how then, do i specify a non-greedy regex > > <1st-pat>*? > > > > that is, such that non-greedy part *? > > excludes a match of <1st-pat> > > > > in other words, how do i write regexes for my examples? > > Not sure if I completely understand your explanation, but does this get > any closer to what your looking for? > > >>> vwre = re.compile("V[^V]*?W") > >>> newdoc = "V1WVVV2WWW" > >>> re.findall(vwre, newdoc) > ['V1W', 'V2W'] > > That is: , then as few times as possible, then > > > John Ridley > > Send instant messages to your online friends http://uk.messenger.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list