From philh at vision25.demon.co.uk Wed Sep 29 17:30:42 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Wed, 29 Sep 99 21:30:42 GMT Subject: What GUI-lib to use References: <37F1D710.47A82D23@bibsyst.no> Message-ID: <938640642snz@vision25.demon.co.uk> In article <37F1D710.47A82D23 at bibsyst.no> thomas at bibsyst.no "Thomas Weholt" writes: > Hi, > > I get the feeling Tk is the de facto standard for GUI-development in > Python. It is, IMO. > I`ve looked at Gtk and KDE, but find Gtk the most appealing to > use. Tk looks - well, rather old. My main concern is that the gtk-lib > is to premature to use for gui-development, that the libs. change too > much and that it`s hard to keep projects backwards-compatible. This > thoughts are based on "feelings", I`ve not dived into the code or coded > any gui so far using any of them. I`ve just seen/had problems with > installing programs using different gtk-versions, older not compatible > with new ones and vica versa. KDE is an option, but I`d rather use Gtk > for a number of reasons, most of which are based on personal taste > rather than any technical aspects. > > I want to develop GUIs to simple scripts fast, writing as little code as > possible, but still making it understandable. Looked at GLADE. How does > this work with Python? Glade produces XML output files that can be read by PyGtk. (At least, that's the theory, I haven't tried it in practice). > Could Tk get a more modern look perhaps and solve all our problems? > > Any ideas, thoughts ?? Wouldn't it be nice if you could code the GUI once, in a simple, high- level format, and then run it on Tk, Gtk and Qt without alteration? That's one of the goals of my parrot project. -- Phil Hunt - - - - - - - - - philh at vision25.demon.co.uk - Linux was 8 years old on 17th September! See: - http://www.vision25.demon.co.uk/prog/linuxbirthday.html From philh at vision25.demon.co.uk Thu Sep 16 16:58:24 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Thu, 16 Sep 99 20:58:24 GMT Subject: python call external program (WHAT THE?!) References: <65118AEEFF5AD3118E8300508B124877073BF5@webmail.altiris.com> <937352247snz@vision25.demon.co.uk> <004b01beffc1$a4158f80$f29b12c2@secret.pythonware.com> Message-ID: <937515504snz@vision25.demon.co.uk> In article <004b01beffc1$a4158f80$f29b12c2 at secret.pythonware.com> fredrik at pythonware.com "Fredrik Lundh" writes: > yet another Linux zealot wrote: > > # use Linux instead of MS rubbish > > looks like someone hasn't read the Linux Advocacy > mini-HOWTO in quite a while. for your convenience, > just follow this link: > > http://www.linuxdoc.org/HOWTO/mini/Advocacy.html > > make sure to read chapter 6 carefully. > > and yes, you might not be aware of this, but > Python runs on many platforms, and this news- > group is open for all Python users. if you have > a problem with that, go start your own news- > group. I am perfectly well aware that people run Python on platforms other that Linux; this should be evident, given that I am in fact currently developing a tool(*) whose aims include the ability to make Python GUI applications more portable across platforms. [*] on the subject of Parrot, my text-based GUI builder, I'm likely to have a working version of the Python/Tkinter backend up this weekend. Oh, and people who want to run Parrot on platforms other than Linux are welcome to do so. -- Phil Hunt - - - - - - - - - philh at vision25.demon.co.uk - Linux will be 8 years old on 17th September! See: - http://www.vision25.demon.co.uk/prog/linuxbirthday.html From bernhard at alpha1.csd.uwm.edu Mon Sep 13 11:56:42 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 13 Sep 1999 15:56:42 GMT Subject: Sparc Linux? References: <7TBC3.217$am6.53046@typhoon2.gnilink.net> Message-ID: On Sat, 11 Sep 1999 23:48:19 GMT, Damond Walker wrote: >Bernhard Reiter wrote in message ... > >>Not having done it, >>I guess that once you get Linux installed properly and a >>resonable c-compiler (gcc) working, python should not give you any >headaches. > Funny you say that. I've had some trouble in the past with compiling >some things on Sparc boxes running RedHat. SWI-Prolog is one example. The >thing dumps core after displaying the intro text. I had trouble with CLisp >in the past as well. Just to start with an answer, in my experience python is not a package which gives you headaches. You also had the problem is other packages, so my guess worked out this time. *puhhh* ;-> Bernhard -- Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard) Association for a Free Informational Infrastructure (ffii.org) From sdunn at digitalanvil.com Wed Sep 22 12:51:40 1999 From: sdunn at digitalanvil.com (Sean Dunn) Date: Wed, 22 Sep 1999 11:51:40 -0500 Subject: running python on a floppy? References: Message-ID: <37E9091B.FBA03640@digitalanvil.com> Daniel Goertzen wrote: > Do you guys think I could squeeze a linux kernel and a python interpreter > onto a floppy disk? I'm concerned that the interpreter might use some > gigantic shared libraries ... > > This will be for a web accessable embedded system. There's plenty of ram > for ramdisks and such. > > Thanks, > Dan. I realize this is an old post.. But try starting with # the "python on a disk" kit for Win32 (should be applicable to any os) http://bigbear.pc.helsinki.fi/harri/pythonkit/ and # Python for embedded systems http://www.abo.fi/~iporres/python/ and # A theory doc for the above http://www.abo.fi/~iporres/python/rparra.pdf Sean From pointal at lure.u-psud.fr Fri Sep 3 06:43:03 1999 From: pointal at lure.u-psud.fr (Laurent POINTAL) Date: Fri, 03 Sep 1999 10:43:03 GMT Subject: ORBit bindings/interface? References: <37CF4AD7.926E7377@ukans.edu> Message-ID: <37cfa5e8.359230816@news.u-psud.fr> On Thu, 02 Sep 1999 23:13:11 -0500, Justin Bradford wrote: >: Is there a project anywhere working on bindings (or some kind of >: higher level interface such as the FNORB [I think] model) for Python? >: If not, does anyone want to help me write it? >: >: Justin Here is a post I keep from the Fnorb list and which can interrest you: << Return-Path: Date: Fri, 7 May 1999 21:46:47 +0800 (CST) From: Michael Robinson Subject: Re: From Fnorb to ORBit... >I could be interrested into another Python ORB with more speed (our project >is for data acquisition), have you an URL about your work (seen nothing on >the ORBit page, neither on the netrinsics.com pages). The Python ORBit binding is under heavy development. The IDL compiler is almost finished for very simple interfaces (basic function call/return of simple types, no structs, no unions, no out/inout arguments). I plan to have something usable within a week or two. I'll make an announcement on the Fnorb and ORBit lists when it gets to that state. If you can provide a minimal list of CORBA features you require for your application, that will help me to prioritize development. -Michael Robinson >> --- Laurent POINTAL - CNRS/LURE - Service Informatique Experiences Tel/fax: 01 64 46 82 80 / 01 64 46 41 48 email : pointal at lure.u-psud.fr ou lpointal at planete.net From fberger1370 at my-deja.com Fri Sep 3 01:51:55 1999 From: fberger1370 at my-deja.com (fberger1370 at my-deja.com) Date: Fri, 03 Sep 1999 05:51:55 GMT Subject: Page can't be displayed-error Message-ID: <7qnnlp$ptd$1@nnrp1.deja.com> After working correctly for two month, my Python Script (which displays entries of a gadfly database) decided not to answer any more to requests. If I try to open it, I receive the message 'Page can't be displayed'. I'd be grateful for any suggestions what to do. Franziska Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From skaller at maxtal.com.au Tue Sep 21 12:17:00 1999 From: skaller at maxtal.com.au (skaller) Date: Wed, 22 Sep 1999 02:17:00 +1000 Subject: global in nested functions (viper) Message-ID: <37E7AF7B.8DEC7CC8@maxtal.com.au> The following file and viperi run demonstrate the current handling of the globals statement in viper. What happens is: global causes a variable to refer to the containing context, often a module, but in this demo, there is also a nested function, global then refers to the locals() of the containing function, unless the variable is _also_ declared 'global' in that function. This behavious is not strictly python compatible, but will only cause problems in nested functions. Any comments? [BTW: you can see a nested function q() being returned here, it is bound to the activation record of h() which created it.] [root at ruby] ~/viper>cat t_globals.py print "test globals and nested functions" x = 1 def f(y): global x,y z = 1 y = 2 x = 3 f(3) print x,y z = 900 def h(): global z x = 100 def q(): global z global x x = x + 1 z = z + 1 return x q() return q qq = h() print qq(),z print qq(),z [root at ruby] ~/viper>./viperi t_globals.py INSTALLING MODULE exceptions INSTALLING MODULE py_types EXECUTING PY_TYPES.PY install_modules: cannot find file for strop INSTALLING MODULE types Viperi 2.0.1 Copyright Maxtal P/L, John Skaller, Australia, 1999 test globals and nested functions 3 2 102 902 103 903 DONE From aahz at netcom.com Sun Sep 26 01:39:00 1999 From: aahz at netcom.com (Aahz Maruch) Date: 26 Sep 1999 05:39:00 GMT Subject: re vs. sgmllib (was Re: Moving from Perl to Python) References: <000601bf07cb$5e1ede20$602d153f@tim> Message-ID: <7skbhk$b06@dfw-ixnews16.ix.netcom.com> In article <000601bf07cb$5e1ede20$602d153f at tim>, Tim Peters wrote: > >Regexps are not Python's forte, and all of speed, clarity and >maintainability will increase in proportion to your zeal in purging them. That sounds like a Call To Action for rewriting sgmllib to use something other than re. Has anyone started any work in this area? -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From tim_one at email.msn.com Mon Sep 13 22:55:39 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 13 Sep 1999 22:55:39 -0400 Subject: List to string? Docstrings? In-Reply-To: Message-ID: <000a01befe5c$a07f5ba0$e7a0143f@tim> [Fran?ois Pinard, on text = reduce(operator.concat, chars) vs text = string.join(chars, '') ] > ... > Thinking more about it, it seems quite reasonable to guess that the reduce > method shows a quadratic time behaviour in the list size, because of all > intermediary results, Yes. > while string.join _may_ be implemented to use linear time in the list size. On most systems most of the time, string.join is linear-time in the length of the result string. See strop_joinfields in Modules/stropmodule.c for all the gore. Another possibility is to create a character array (array.array('c')), fill it with the chars via .fromlist(), then get the string out via .tostring(). string.join will almost always be faster, but using the character array method has better worst-case behavior (always linear-time). But if you're bursting your strings into characters to begin with because what you really wanted was a mutable string, it may be faster overall to do everything with a character array from the start instead. Or, maybe not. if-you-want-easy-answers-use-fortran-ly y'rs - tim From fredrik at pythonware.com Wed Sep 1 04:12:59 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 1 Sep 1999 08:12:59 GMT Subject: os.fork References: Message-ID: <02b601bef451$cf9fd780$f29b12c2@secret.pythonware.com> Curtis, Craig M. wrote: > Is there a compatible way to fork processes in Python that works in both a > Linux environment and Win32? > > It seems the win32 port does not support os.fork. not yet. but assuming what you're really looking for is fork+exec, you can use os.spawn (windows only). here's an example (you have to fill in the blanks yourself): def spawn(...): try: status = os.spawn(...) except NameError: # assume it's unix pid = os.fork() if pid == 0: os.exec(...) status = os.wait()[0] return status From mjackson at wc.eso.mc.xerox.com Thu Sep 9 23:17:40 1999 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 10 Sep 1999 03:17:40 GMT Subject: 1.5.2 NT install question(s) - partial answer References: <7r3hib$24f$1@news.wrc.xerox.com> Message-ID: <7r9t8k$inc$1@news.wrc.xerox.com> mjackson at wc.eso.mc.xerox.com (Mark Jackson) writes: > I've done this twice recently and encountered problems both times. > > On a fresh system (never had Python or Tcl/Tk) things (for example, > PySol) seem to work, but whenever I use Tkinter (specifically, when > _tkinter is imported) I get a warning box about not being able to find > tcl80.dll in the specified path. (tcl80.dll is present, in Program > Files\Tcl\bin.) What's wrong, and how do I put it right? Solution: put Tcl/bin into the PATH variable through the System environment tab. Made easier by reinstalling Python and Tcl outside Program Files (avoiding the evil space-in-filename issue) which however was not effective in itself. Thanks to those who suggested augmenting PATH> Not clear why this was necessary after an apparently trouble-free install on this particular system, but then it's NT. . . > On a system where 1.5.1 (with Tcl/Tk) had previously been installed, I > carefully uninstalled both before installing 1.5.2. Here both "import > _tkinter" and "inport Tkinter" are OK, but Tkinter._test() yields: > > TclError: Can't find a usable init.tcl in the following directories: > {} ./lib/tcl8.0 D:/tc18.0/library {D:/Program Files/library} > > This probably means that Tcl wasn't installed properly. > > (init.tcl is present, in Program Files\Tcl\lib\tcl8.0.) What's wrong, > and how do I put it right? Still working on this one. Reinstalling Python and Tcl outside Program Files changes the error message: >>> import Tkinter >>> Tkinter._test() Traceback (innermost last): File "", line 1, in ? File "D:\Python\Lib\lib-tk\Tkinter.py", line 1947, in _test root = Tk() File "D:\Python\Lib\lib-tk\Tkinter.py", line 886, in __init__ self.tk = _tkinter.create(screenName, baseName, className) TclError: Can't find a usable tk.tcl in the following directories: . D:/Tcl/lib/tk8.0 ./tk8.0 ./lib/tk8.0 ./library ./tk8.0/library ./library D :/Tcl/tk8.0/library D:/Tcl/lib/tk8.0/tk.tcl: bad event type or keysym "MouseWheel" bad event type or keysym "MouseWheel" while executing "bind Listbox { %W yview scroll [expr - (%D / 120) * 4] units }" (file "D:/Tcl/lib/tk8.0/listbox.tcl" line 179) invoked from within "source [file join $tk_library listbox.tcl]" (file "D:/Tcl/lib/tk8.0/tk.tcl" line 151) invoked from within "source D:/Tcl/lib/tk8.0/tk.tcl" ("uplevel" body line 1) invoked from within "uplevel #0 [list source $tkfile]" This probably means that Tk wasn't installed properly. Note that tk.tcl is present, in D:/Tcl/lib/tk8.0, contrary to the error message. I've exercised some of the Tk demos directly and they seem OK. Suggestions? -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson Spend the optimal amount of time on each decision and pretty soon you run out of life. - Steven Waldman From gerrit.holl at pobox.com Wed Sep 8 15:17:49 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Wed, 8 Sep 1999 21:17:49 +0200 Subject: Bug in time module? In-Reply-To: <37D5E25F.1F7F0A74@pc.jaring.my>; from lec on Wed, Sep 08, 1999 at 12:13:20PM +0800 References: <37D5E25F.1F7F0A74@pc.jaring.my> Message-ID: <19990908211749.B3782@optiplex.palga.uucp> On Wed, Sep 08, 1999 at 12:13:20PM +0800, lec wrote: > Is this considered a bug since there is no Feb 31, 1999 or Feb 29, 1999? > > >>> import time > >>> time.strptime('31/02/1999', "%d/%m/%Y") > (1999, 2, 31, 0, 0, 0, 2, 62, 0) > >>> time.asctime(time.strptime('31/02/1999', "%d/%m/%Y")) > 'Wed Feb 31 00:00:00 1999' > >>> time.strptime('29/02/1999', "%d/%m/%Y") > (1999, 2, 29, 0, 0, 0, 0, 60, 0) > >>> time.asctime(time.strptime('29/02/1999', "%d/%m/%Y")) > 'Mon Feb 29 00:00:00 1999' > >>> time.strptime('31/12/2040', "%d/%m/%Y") Traceback (innermost last): File "", line 1, in ? ValueError: unconverted data remains: '0' >>> time.strptime('31/12/2036', "%d/%m/%Y") (2036, 12, 31, 0, 0, 0, 6, 1, 0) >>> time.strptime('31/12/2037', "%d/%m/%Y") Traceback (innermost last): File "", line 1, in ? ValueError: format mismatch regards, Gerrit. -- Unix is easy: type 'man man' and the rest comes of itself. From fredrik at pythonware.com Wed Sep 22 06:37:32 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 22 Sep 1999 10:37:32 GMT Subject: Newbie Question References: <37E773E7.B3A0CEA0@ecs.soton.ac.uk> <37E8AF24.1CDE9916@isogmbh.de> Message-ID: <002f01bf04e6$7d6a4950$f29b12c2@secret.pythonware.com> Chris... wrote: > I've never heard of an 'atoi' function, but there exists 'int()' that > converts its argument (string or number) to a plain integer. atoi is in the string module, together with atof and atol: http://www.python.org/doc/current/lib/module-string.html (they're similar to their builtin counterparts, but atoi and atol can also be used with non-decimal numbers) From jeremy at cnri.reston.va.us Tue Sep 14 13:35:05 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Tue, 14 Sep 1999 13:35:05 -0400 (EDT) Subject: More Pythonic? In-Reply-To: <7rkh5u$1qq@dfw-ixnews13.ix.netcom.com> References: <7rkh5u$1qq@dfw-ixnews13.ix.netcom.com> Message-ID: <14302.34633.583713.527695@bitdiddle.cnri.reston.va.us> The way I dealt with this problem in my urllib replacement (see http://the-tech.mit.edu/~jeremy/python/urllib2.py) was to raise an exception where the exception instance is actually a valid HTTP response object. A typical usage would be something like this: try: resp = urllib2.urlopen('http://frob.nitz/') except HTTPError: print resp.code, resp.msg The following excerpt shows just the exception class, which extends the addinfourl object from the original urllib module. class HTTPError(URLError, addinfourl): """Raised when HTTP error occurs, but also acts like non-error return""" def __init__(self, url, code, msg, hdrs, fp): addinfourl.__init__(self, fp, hdrs, url) self.code = code self.msg = msg self.hdrs = hdrs self.fp = fp # XXX self.filename = url def __str__(self): return 'HTTP Error %s: %s' % (self.code, self.msg) def __del__(self): # XXX is this safe? what if user catches exception, then # extracts fp and discards exception? self.fp.close() Incidentally, have you taken a look at the urllib2 code before? If it isn't sufficient for your needs, I would be interested to get some comments or criticism. Jeremy From c.evans at clear.net.nz Tue Sep 28 04:56:16 1999 From: c.evans at clear.net.nz (Carey Evans) Date: 28 Sep 1999 20:56:16 +1200 Subject: newbie question: getting a module in a package References: <199909222352.QAA01837@hermes.aspectdv.com> Message-ID: <87yadr4dov.fsf@psyche.evansnet> "Mike Fletcher" writes: > It's rather awkward looking, but it seems to work here... the operation > seems a little arbitrary to me (why bother to check for non-empty list if > you're not using the values for anything?) It's documented, I just think > it's weird :) . It probably makes a little more sense when you consider how Python uses it, or how you'd do it in your own __import__. Doing something like >>> from spam.eggs import ham will call __import__ with something like: tmp = __import__('spam.eggs', globals(), locals(), ['ham']) and even if ham is not present in spam.eggs, spam.eggs will still be imported and put in sys.modules['spam.eggs']. It will fail just after that when it tries to do the equivalent of: locals()['ham'] = getattr(tmp, 'ham') Umm, maybe it's still wierd. Still, for good form I'd probably pass the name of at least one of the things I was looking for in spam.eggs to __import__. -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "This is where your sanity gives in..." From gerrit.holl at pobox.com Fri Sep 3 14:23:14 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Fri, 3 Sep 1999 18:23:14 GMT Subject: smtplib: subject? to? In-Reply-To: ; from Moshe Zadka on Fri, Sep 03, 1999 at 02:07:34PM -0400 References: <19990903142456.A2124@optiplex.palga.uucp> Message-ID: <19990903202313.A23408@optiplex.palga.uucp> On Fri, Sep 03, 1999 at 02:07:34PM -0400, Moshe Zadka wrote: > > > when I try to send mail with python, I can't get a To: and a Subject: header! > > How do I get them? > > SMTP expects an RFC-822 message, including a To: and Subject:. Python has > tools to parse rfc822, but not to write, so you will have to read > the docs, and use .write() like regular folk > Ah. But if I have to put a To: in the message, why do I have to give recipients? regards, Gerrit. From guido at cnri.reston.va.us Thu Sep 2 08:49:02 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 02 Sep 1999 08:49:02 -0400 Subject: Queue class deadlocking application References: Message-ID: <5l671t5vi9.fsf@eric.cnri.reston.va.us> Another tip: the CVS tree (http://python.org/download/cvs.hmtl) contains a bugfix for the threading machinery. Read the CVS log for Python/pystate.c for more info. The symptoms are different than your case though (invalid thread state rather than freezing)... --Guido van Rossum (home page: http://www.python.org/~guido/) From ATrepel at dspace.de Wed Sep 29 05:27:55 1999 From: ATrepel at dspace.de (Andreas Trepel) Date: Wed, 29 Sep 1999 09:27:55 GMT Subject: Serial IO under Win NT Message-ID: <137053459BA7D211B3930090272A62CA9CE4DB@newsintern.dspace.de> I tried to access the serial IO port with the 'open' command under Win NT and was really happy when it worked. Now I would like to know if it' s possible to set the baud rate and other properties of the serial device with any Python commands? Greetings, Andreas From fleck at informatik.uni-bonn.de Thu Sep 2 09:07:17 1999 From: fleck at informatik.uni-bonn.de (Markus Fleck) Date: 2 Sep 1999 13:07:17 GMT Subject: language interpreters/ interpreted languages weaknesses? References: <37CE562F.1A368670@strs.co.uk> <002701bef535$68a88920$f29b12c2@secret.pythonware.com> <37CE69C0.6AC977E0@strs.co.uk> Message-ID: <7qlsq5$fje@news.rhrz.uni-bonn.de> Ian Clarke wrote: > I am not talking about what the user notices, I am talking about > what the developer does - and I would venture that most Python > code is distributed with its source, where as this is rare with > Java code. It would be nice if the latest BSCW distribution contained more than the .pyc files. But unfortunately, it doesn't. Yours, Markus. -- //////////////////////////////////////////////////////////////////////////// Markus B Fleck - University of Bonn - CS Department IV - WHOIS MF5079 UNIX Administrator - comp.lang.python.announce Moderator \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ From alex at somewhere.round.here Fri Sep 10 14:25:04 1999 From: alex at somewhere.round.here (Alex) Date: 10 Sep 1999 14:25:04 -0400 Subject: Turing Compliant? References: <1275214276-477894@hypernet.com> <37D8F6D0.9690EF6C@arlut.utexas.edu> Message-ID: No, it doesn't add anything new. It might someday permit massive parallelism, but the computations you could perform could be done on a traditional computer in a formally equivalent way. For instance, roughly speaking, the idea for solving the Hamiltonian graph problem this way involves encoding every possible path through the graph on a separate strand of DNA, throwing them all in a beaker, and then doing chemistry on the mixture that weeds out all but the strands corresponding to a solution. This is formally equivalent to just iterating over the possible paths, testing each to see if it's Hamiltonian. Noone has got it to work on a really computationally hard problem yet, AFAIK. The Hamiltonian graph that was "solved" with DNA computing had seven vertices, I think. At any rate, you could pick out a Hamiltonian path by eye in less than a quarter hour, for sure. It took a week of lab work to do it with DNA computing. One problem with DNA computing is that as your solution space increases, the volume of the liquid you store the DNA strands in has to increase, too. If the strands are too concentrated, you run the risk of importune reactions between them. At some point, it will also get difficult to be sure that you've manufactured every candidate solution -- for the Hamiltonian path solution, they made strands of DNA that represented the graph's vertices, and arranged them in such a way that two strands could anneal if and only if the corresponding vertices had an edge between them. Then they threw those in the beaker and waited long enough to let all possible paths form. As the size of the graph grows, "long enough" can get very, very long. Alex. -- If cars were like computers, they would go 300 m.p.h. and get a hundred miles to the gallon and cost $50. Except that twice a month someone a thousand miles away would be able to blow up the car, killing everyone nearby. From spamfranke at bigfoot.de Wed Sep 1 06:28:53 1999 From: spamfranke at bigfoot.de (Stefan Franke) Date: Wed, 01 Sep 1999 10:28:53 GMT Subject: Pythom in embedded system? References: Message-ID: <37ccfed3.3577714@news.omnilink.de> On 1 Sep 1999 07:09:28 GMT, vnesek at maja.zesoi.fer.hr (Vjekoslav NESEK) wrote: >Anyway if not python, can you point me to some other free >interpeter suitable for embedding in such a limited system? Have a look at Lua: http://www.tecgraf.puc-rio.br/lua/ Stefan From zope-list at teleo.net Mon Sep 6 19:08:10 1999 From: zope-list at teleo.net (Patrick Phalen) Date: Mon, 6 Sep 1999 16:08:10 -0700 Subject: Fwd: LORAX (re: Anaconda -- new Red Hat installation procedure written in Python) Message-ID: <99090616235506.00548@quadra.teleo.net> Great. But ... but ... Python has nothing to do with nasty reptiles! ---------- Forwarded Message ---------- Subject: LORAX: Red Hat Linux Beta Release Date: Mon, 6 Sep 1999 18:08:56 -0400 (EDT) From: Cristian Gafton For the brave... the reckless... the foolish... those with extra hard disks... those with too much free time... those who miss fixing their own bugs... people who want to hack device drivers... people who need to see exceptions... and people who think Linux has gotten too easy... LORAX Red Hat, Inc. is looking for a few brave hackers to try, test, break, and experiment on our latest beta release. Featuring Anaconda, a brand new installation procedure written in Python and featuring both text and GTK+-based interfaces for your installation pleasure. LORAX is only available for ix86 platforms, and only available via the Internet. SPARC and Alpha versions will be available in the very near future (read *after* Labor day!). Get it now from ftp://ftp.redhat.com/pub/lorax. There has been a mailing list to discuss this beta release setup as lorax-list at redhat.com. To subscribe, send a message with the subject line of "subscribe" to lorax-list-request at redhat.com, respond to the confirmation request, sit back, relax and await barrage of messages which will help you whittle away your formerly enjoyable evenings. Cristian -- ---------------------------------------------------------------------- Cristian Gafton -- gafton at redhat.com -- Red Hat, Inc. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "How could this be a problem in a country where we have Intel and Microsoft?" --Al Gore on Y2K -- To unsubscribe: mail -s unsubscribe redhat-announce-list-request at redhat.com < /dev/null From news at dorb.com Wed Sep 22 00:59:28 1999 From: news at dorb.com (Darrell) Date: Wed, 22 Sep 1999 00:59:28 -0400 Subject: Marking translatable strings References: <7s339v$d78@dfw-ixnews3.ix.netcom.com><1aUF3.223$46.6340@typhoon.nyroc.rr.com><7s94hn$rjj@dfw-ixnews3.ix.netcom.com> <14312.15952.824486.865824@dolphin.mojam.com> Message-ID: <8mZF3.253$46.14568@typhoon.nyroc.rr.com> Good suggestion Skip. It works with one detractor. It has to assume the ")s" is the trailing format type. From with in PyString_Format this wasn't a problem. import UserDict class DefaultDict(UserDict.UserDict): def __init__(self, dict): UserDict.UserDict.__init__(self, dict) def __getitem__(self, key): return self.data.get(key,'%('+key+')s') d1=DefaultDict({'AA':'aa'}) d2=DefaultDict({'BB':'bb'}) d3=DefaultDict({'CC':'cc'}) s="%(AA)s %(BB)s %(CC)s"%d1 print s s=s%d2 print s s= s%d3 print s ############### aa %(BB)s %(CC)s aa bb %(CC)s aa bb cc -- --Darrell Skip Montanaro wrote in message news:14312.15952.824486.865824 at dolphin.mojam.com... > > Wish there was a dictionary formatter that wouldn't throw a keyError > > when it was missing a value. Then I could avoid the $& kluge. Better > > yet accept an error handler function. If the function isn't provided > > then throw the error. > > How about something like (from memory): > > import UserDict > class DefaultDict(UserDict.UserDict): > def __init__(self, default=""): > UserDict.UserDict.__init__(self) > self.default = default > > def __getitem__(self, key): > return self.data.get(key, self.default) > > ? Then you use it like > > d = DefaultDict("") > d.update(realdict) > print "%(AA)s %(BB)s" % d > > The extension to support an error function instead of a static default value > is straightforward and left as an exercise for the reader... ;-) > > Skip Montanaro | http://www.mojam.com/ > skip at mojam.com | http://www.musi-cal.com/~skip/ > 847-971-7098 | Python: Programming the way Guido indented... > > From mwh21 at cam.ac.uk Wed Sep 1 19:33:03 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 02 Sep 1999 00:33:03 +0100 Subject: Turing Compliant? References: <37CD7CBC.54AD295F@megsinet.net> <14285.34671.165473.168931@dolphin.mojam.com> <7qk4vr$khk$1@newshost.accu.uu.nl> Message-ID: wtanksle at dolphin.openprojects.net (William Tanksley) writes: > On 1 Sep 1999 21:14:35 GMT, Martijn Faassen wrote: > >Skip Montanaro wrote: [schnipp] > >Even-MSDOS-batchfiles-are-turing-complete-ly yours, > > You know, I'm not sure they are. > And then there's intercal... (the intercal manual is one of the funniest things I have ever read) one-of-these-days-I'll-post-on-topic-ly y'rs - Michael From guido at cnri.reston.va.us Mon Sep 27 17:06:15 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 27 Sep 1999 17:06:15 -0400 Subject: More Python books coming... Message-ID: <5lpuz483p4.fsf@eric.cnri.reston.va.us> I did a search for Python on Amazon.com and found several new Python books that are likely to hit the shelves soon. Here's the list: The Quick Python Book Daryl Harms, Kenneth McDonald. Published by Manning Publications. Expected September 1999. Python Essential Reference David Beazley. With a foreword by Guido van Rossum. Published by New Riders. Expected October 1999. Programming with Python Tim Altom. Published by Prima Publishing. Expected October 20, 1999. Python and Tkinter Programming John E. Grayson. Published by Manning Publications. Expected November 1999. Python Annotated Archives Martin Brown. Published by McGraw-Hill. Expected September 1999. Python Programming on Win 32 Mark Hammond, Andy Robinson. Published by O'Reilly. Expected September 1999. Sams Teach Yourself Python in 24 Hours Ivan Van Laningham. Published by Sams. Expected November 1999. We expect to have a bookstand at the Python conference in January where you can buy these and other Python books. I've also added this to http://www.python.org/doc/Books.html. --Guido van Rossum (home page: http://www.python.org/~guido/) From a.eyre at optichrome.com Mon Sep 27 11:06:59 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Mon, 27 Sep 1999 15:06:59 GMT Subject: Circular refs Message-ID: <000501bf08f9$f25e79e0$3acbd9c2@peridot.optichrome.com> Is there a reasonable fix for this? >>> class Noisy: ... def __init__(self, name): ... self._name = name ... print "Created " + self._name ... def __del__(self): ... print "Destroyed " + self._name ... >>> a = Noisy("a") Created a >>> b = Noisy("b") Created b >>> del a Destroyed a >>> del b Destroyed b Fair enough, but... >>> a = Noisy("a") Created a >>> b = Noisy("b") Created b >>> a.b = b >>> b.a = a >>> del a >>> del b [Sound of memory dripping onto the floor] -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From a.eyre at optichrome.com Mon Sep 27 12:56:43 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Mon, 27 Sep 1999 16:56:43 GMT Subject: Circular refs In-Reply-To: References: Message-ID: <000701bf0909$46bcb0b0$3acbd9c2@peridot.optichrome.com> > [snip - loads of kludges] I can dream up a million ways to kludge around this bug, but I was referring to a 'fix' to the Python source code. How hard can it be? -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From seanh at unforgettable.com Wed Sep 8 19:31:35 1999 From: seanh at unforgettable.com (Sean Hummel) Date: 8 Sep 1999 23:31:35 GMT Subject: main thread idle handler? Message-ID: <7r6rkn$oe8$0@216.39.145.40> Hi, I am implementing a module as an interface to our interface written in C. The problem is that I need access to callbacks from our "C" interface. My current solution is to queue up these callbacks from my "C" interface and expose an "idle" method from the module. Then in my main loop of my python code, I call the "idle" method, and fake the calls to my Python specified callbacks. However this is going to get more complex in the future because of the way I want to use this module. I'd prefer to be able to install an IDLE function which would get called from the main thread, frequently. Is this possible, to do, without modifying the source of Python? From robin at jessikat.demon.co.uk Fri Sep 3 05:23:14 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Fri, 3 Sep 1999 10:23:14 +0100 Subject: And Now For Something Completely Similar !!! References: <37CCDAF8.E79FE189@megsinet.net> <028f01bef450$9d976ba0$f29b12c2@secret.pythonware.com> <37CD22A5.4DD4B332@megsinet.net> <006f01bef47c$c0679b10$f29b12c2@secret.pythonware.com> <37CD9117.DD7E5100@megsinet.net> <37cd9f19.13139313@news.erols.com> <5l906p5vpj.fsf@eric.cnri.reston.va.us> <7qlud1$fje@news.rhrz.uni-bonn.de> <37CEDCB7.221493F6@prescod.net> Message-ID: <9U0O2IACO5z3Ewr+@jessikat.demon.co.uk> In article <37CEDCB7.221493F6 at prescod.net>, Paul Prescod writes >Robin Becker wrote: >> >> Is it really required to put all extensions into one lump. I find it a >> bother to have to download huge files some of which I don't use. > >I think that two major virtues of the "batteries included" model are: > > * everything tested together -- no version skews > > * easy to find what you need > >I can't see download size really overwhelming those factors. It's 1999 >after all. Python only takes a few minutes to download even on a slow >modem! > > Paul Prescod here in the UK telecoms isn't cheap for the home user during the day. At night it's cheaper and a download of 4mb may cost less than 50c. It's certainly better than it used to be, but $5 to try out the cygwin win32 stuff (as I did the other day) is certainly a potential barrier. -- Robin Becker From philh at vision25.demon.co.uk Tue Sep 14 05:06:23 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Tue, 14 Sep 99 09:06:23 GMT Subject: List Comprehensions Enhancement References: <37D9E932.66F2B0D3@cosc.canterbury.ac.nz> <7riudv$24g$1@c3po.schlund.de> Message-ID: <937299983snz@vision25.demon.co.uk> In article <7riudv$24g$1 at c3po.schlund.de> hannah at schlund.de "Hannah Schroeter" writes: > In article <37D9E932.66F2B0D3 at cosc.canterbury.ac.nz>, > Greg Ewing wrote: > >[...] > >print [3 * x for x in nums] > >print [x for x in nums if x > 2] > >print [(i, s) for i in nums for s in strs] > >print [(i, s) for i in nums for s in [f for f in strs if "n" in f]] > > The syntax looks a bit verbose, compared to e.g. Haskell's list > comprehension syntax which looks quite similar to the mathematical set > comprehensions: > > print [3 * x | x <- nums] > print [x | x <- nums, x > 2] > print [(i,s) | i <- nums, s <- strs] > print [(i,s) | i <- nums, s <- [f | f <- strs, 'n' `elem` f]] > > Also, I think there should be a clear separator between the > generators/predicates in your syntax too: > > print [(i,s) for i in nums, for s in strs] I agree, here. > or similar. Or use a Smalltalk-like collect reserved word, e.g.: print [collect 3 * x for x in nums] print [collect (i,s) for i in nums, for s in strs] -- Phil Hunt - - - - - - - - - philh at vision25.demon.co.uk - Linux will be 8 years old on 17th September! See: - http://www.vision25.demon.co.uk/prog/linuxbirthday.html From caldodge at ix.netcom.com Mon Sep 6 18:32:53 1999 From: caldodge at ix.netcom.com (Calvin Dodge) Date: Mon, 06 Sep 1999 16:32:53 -0600 Subject: CGIHTTPServer howto? References: <7qt9cn$rp7$1@bunyip.cc.uq.edu.au> Message-ID: <37D44115.EA834C@ix.netcom.com> Chui Tey wrote: > > Hi, > > I'm new to python and playing around with CGIHTTPServer. Executed test() and > got an instant http server (wow!). Next, I tried to execute a test cgi > script but couldn't get it to run. > > code 403 : CGI script is not executable ('/cgi-bin/cgitest.py') > > I'm running Win95, any pointers? > > #! 'C:\\PROGRAM FILES\\CHUITEY\\BIN\\PYTHON.EXE' Unfortunately, Windows (any version) does not recognize the above line as anything special (COMMAND.COM is far less sophisticated than _any_ UNIX shell). A batch file which calls python.exe with a python script filename as an argument _might_ work, and it might not. I had problems while playing with it, anyway. I had enough trouble with this that I cobbled together a simple server which is descended from CGIServer - and all it does is import the python file in question, then execute it. It's kinda ugly, but it works for me. Calvin -- "... she was a calligraphy enthusiast with a slight overbite and hair the color of strained peaches. I'll never forget the very first thing she said to me - she said: 'Hey, you've got weasels on your face'. THAT'S when I knew it was true love!" From corbet at montalcino.eklektix.com Wed Sep 22 23:31:46 1999 From: corbet at montalcino.eklektix.com (Jonathan Corbet) Date: Thu, 23 Sep 99 03:31:46 GMT Subject: Quote.py - Look up stock quotes Message-ID: Here's a tiny little thing, but maybe it will be useful to somebody. The module Quote simply looks up a publicly-traded stock by symbol, and returns an object with more information than you could ever want to know - price, change, one-year range, and lots of other stuff. Currently it uses quote.yahoo.com to get the info; I plan to make it able to use more than one service for reliability. This was developed for the LWN Linux Stocks Page -- http://lwn.net/stocks/ Enjoy, == Jonathan Corbet, Eklektix, Inc. corbet at eklektix.com #------- snip --------- # # A quick Python module to obtain stock quotes. # # Copyright 1999 Eklektix, Inc. This sofware is freely distributable under # the terms of the GNU Library General Public Licence (LGPL). # # Written by Jonathan Corbet, corbet at eklektix.com. Current version is available # at ftp.eklektix.com/pub/Quote. # # $Id: Quote.py,v 1.2 1999/09/14 17:22:39 corbet Exp $ # # Basic usage is: # # quote = Quote.Lookup (symbol) # # where 'symbol' is the stock symbol. The return value is an instance of the # Quote class, which has the following attributes: # # symbol The stock symbol for which the quote applies # name The name of the company # time Time of last trade (internal unix format) # value The current value of the stock # change Change in value since market opening # open Opening value of the stock # previous_close Previous day's closing value # percent_change Percentage change in value of the stock # high Today's high value # low Today's low value # volume Trading volume in shares # market_cap Market capitalization, in millions of dollars # year_high Highest value in last year # year_low Lowest value in last year # eps Earnings per share # pe_ratio Price to earnings ratio (-1 if no earnings) # # In case of errors (which happens, web server doesn't always respond) None is # returned. # # Currently this module only works with quote.yahoo.com. Future plans involve # making it work with other web quote services as well... # import urllib import string import time # # Here is the Quote class that we return. Pretty boring... # class Quote: pass # # The function that actually does quote lookups. # def Lookup (symbol): (qurl, decoder) = MakeUrl (symbol) response = urllib.urlopen (qurl) q = Quote () if decoder (q, response): return q return None # # Internal stuff below. # # # Yahoo: create a URL to look up a stock quote. # def MakeYahooURL (symbol): qurl = 'http://quote.yahoo.com/d/quotes.csv?s=%s&f=sl1d1t1c1ohgvj1pp2owern&e=.csv' \ % (symbol) return (qurl, DecYahooUrl) # # Yahoo: Decode a response to a Yahoo stock lookup. # def DecYahooUrl (q, response): # # Pull the info from the server, split it, and make sure it makes sense. # info = response.readline ()[:-2] # Get rid of CRLF sinfo = string.split (info, ',') if len (sinfo) < 15: return 0 # # Start decoding. # q.symbol = sinfo[0][1:-1] q.value = string.atof (sinfo[1]) q.time = YahooDate (sinfo[2], sinfo[3]) q.change = string.atof (sinfo[4]) q.open = string.atof (sinfo[5]) q.high = string.atof (sinfo[6]) q.low = string.atof (sinfo[7]) q.volume = string.atoi (sinfo[8]) # # Get the market cap into millions # try: q.market_cap = string.atof (sinfo[9][:-1]) except ValueError: q.market_cap = 0.0 # Weirdness happens if sinfo[9][-1] == 'B': q.market_cap = q.market_cap*1000 q.previous_close = string.atof (sinfo[10]) q.percent_change = string.atof (sinfo[11][1:-2]) # Zap training % q.open = string.atof (sinfo[12]) # # Pull apart the range. # range = string.split (sinfo[13][1:-1], '-') q.year_low = string.atof (range[0]) q.year_high = string.atof (range[1]) q.eps = string.atof (sinfo[14]) try: q.pe_ratio = string.atof (sinfo[15]) except ValueError: q.pe_ratio = -1 # Yahoo returns "N/A" for no earnings. q.name = sinfo[16][1:-1] # # We made it. # return 1 # # Convert date/times in Yahoo's format into an internal time. # def YahooDate (date, tod): # # Date part is easy. # sdate = string.split (date[1:-1], '/') month = string.atoi (sdate[0]) day = string.atoi (sdate[1]) year = string.atoi (sdate[2]) # # Pick apart the time. # stime = string.split (tod[1:-1], ':') hour = string.atoi (stime[0]) minute = string.atoi (stime[1][0:2]) if stime[1][-2:] == 'PM': hour = hour + 12 # # Time to assemble everything. # ttuple = (year, month, day, hour, minute, 0, 0, 0, -1) return time.mktime (ttuple) # # Create a URL to look somebody up. Returns a tuple with the URL and # a function to decode the result. Someday this will handle multiple # sources, but currently it only knows yahoo. # def MakeUrl (symbol): return MakeYahooURL (symbol) -- ----------- comp.lang.python.announce (moderated) ---------- Article Submission Address: python-announce at python.org Python Language Home Page: http://www.python.org/ Python Quick Help Index: http://www.python.org/Help.html ------------------------------------------------------------ From clgonsal at keeshah.penguinpowered.com Fri Sep 3 12:27:05 1999 From: clgonsal at keeshah.penguinpowered.com (C.Laurence Gonsalves) Date: Fri, 03 Sep 1999 16:27:05 GMT Subject: Newbies: Re: Returning none References: <000001bef265$fe64f340$192d153f@tim> <37CF5499.BA24C33E@prescod.net> <14287.48514.597162.933684@dolphin.mojam.com> Message-ID: On Fri, 3 Sep 1999 07:33:09 -0500 (CDT), Skip Montanaro wrote: > > Paul> #1. a=list.sort("abc"): "None object has no attribute foo" > > For those people who like to think that sort returns a new list, the > sort method could be modified to return the list, but this would make > people think that a and list pointed to different objects. Then > they'd complain that when modifying the object referred to by list, > the object referred to by a also changed. I think most people that have used Python for any length of time know it would be a Bad Thing if sort were to return the list it sorted, as that would create even more confusion. Having it return nothing instead of None would be better than the current behaviour though. In the above code, the "AttributeError: 'None' object has no attribute 'foo'" does not come at that line of code. It comes much later on when you try to say 'a.foo'. If the sort method instead returned *nothing*, then the above assignment would cause an exception to be raised on that line, instead of much later, or possibly not at all. ofile.write( str( list.sort() ) ) > It's worth noting is that those people who are clamoring for a > distinction between functions and procedures will have to figure out > how to implement procedures in the C runtime, not just at the Python > level. Yes, but design comes before implementation. > Paul> #2. alert( print_traceback() ): "None" > > This seems like a semantic problem on the programmer's part more than > anything. You're clearly asking the function to do something by > side-effect. Why would you also expect it to return a useful value? > If I wanted the traceback in a return value I'd expect the function to > be named "get_traceback" or "extract_tb" or something similar. True. But the function does return something. That's the problem. It returns None. It would be better if it returned nothing at all, rather than a useless value. Getting a "NoResultError" on that line of code would make the problem obvious. > Paul> #3. Forgetting to return a value. > > This is precisely the case that the default None return helps with. > If the programmer sees "None" when popping up the dialog box during > testing, it's a clear indication to go back and look at the function > that generated the data the dialog box is displaying. What if they notice a few weeks later that there are a bunch of None's in their database, or that they sent out a mass-email with "None" here and there in it? The point is, people would have a much greater chance of catching these errors if an exception was raised instead of an arbitrary default value being returned. The current behaviour is only slightly more useful than functions returning the string "Naughty naughty" by default. The current behaviour is also inconsistent with sequences and maps. If I say: x = [1,2,3][9] an IndexError is raised. If I say: x = {'foo':'bar'}['quux'] a KeyError is raised. But if I say: def foo(int y): pass x = foo() then x is set to 'None'. I think it would be better if an exception was raised instead. -- C. Laurence Gonsalves "Any sufficiently advanced clgonsal at kami.com technology is indistinguishable http://www.cryogen.com/clgonsal/ from magic." -- Arthur C. Clarke From skip at mojam.com Fri Sep 17 14:43:00 1999 From: skip at mojam.com (Skip Montanaro) Date: Fri, 17 Sep 1999 13:43:00 -0500 (CDT) Subject: lopping over Dictionaries In-Reply-To: <3uvE3.157430$5r2.248606@tor-nn1.netcom.ca> References: <3uvE3.157430$5r2.248606@tor-nn1.netcom.ca> Message-ID: <14306.35764.942350.115078@dolphin.mojam.com> >>>>> "Kevin" == Kevin Howe writes: Kevin> Is it possible to iterate through list of keys in a Dictionary? Yup. You were very close. You can do it a couple ways: tel = {'jack': 4098, 'sape': 4139} for name in tel.keys(): value = tel[name] or tel = {'jack': 4098, 'sape': 4139} for name, value in tel.items(): value = tel[name] If you don't really care what key and values are associated together, you can iterate over just the values as well: tel = {'jack': 4098, 'sape': 4139} for value in tel.values(): pass From nathan at islanddata.com Wed Sep 1 12:53:56 1999 From: nathan at islanddata.com (Nathan Clegg) Date: Wed, 01 Sep 1999 09:53:56 -0700 (PDT) Subject: Queue class deadlocking application Message-ID: When I had only one producer and one consumer, the Queue class was a great performer for me in my multithreaded (threading module) application. When I went up to four producers, I found the app deadlocking at seemingly random locations, freezing all threads. The only operations ever performed are put_nowait and get_nowait. The application freezes when the queue size is anywhere from 20-50 in size, and the data objects themselves are simple strings. The max queue size is 10,000. Again, with only one producer, no problems. Has anyone ever run into this before? Can someone say with some certainty that my problem lies not in Queue but another area? I have only one queue and it is the only shared data, so I have no implemented any mutexes or signals myself. Any ideas, hints, or questions? Thanks... ---------------------------------- Nathan Clegg nathan at islanddata.com From gerrit.holl at pobox.com Sat Sep 25 07:03:46 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Sat, 25 Sep 1999 13:03:46 +0200 Subject: python and I/O In-Reply-To: <%4YG3.3867$UD4.20078@news.rdc1.az.home.com> References: <%4YG3.3867$UD4.20078@news.rdc1.az.home.com> Message-ID: <19990925130345.A11328@optiplex.palga.uucp> Mike Linnen: > I am very new to python. I was wondering if the python lang allows access > to I/O ports. I would like to use the lang in a robotics application and I > need to do some data acquisition. I could write some C extensions to python > but I would like to know if it currently supports I/O. > use the open() builtin: NULL = open('/dev/null', 'w') NULL.write("This is being written to /dev/null") ZERO = open("/dev/zero", 'r') nulls = ZERO.read(5) print nulls # gives "\0\0\0\0\0" regards, Gerrit. -- RTFM: Read That FreshMeat From nolan at ethereal.dhis.org Thu Sep 30 19:13:22 1999 From: nolan at ethereal.dhis.org (Nolan Darilek) Date: 30 Sep 1999 18:13:22 -0500 Subject: Last question of the day (This one's easy!) Message-ID: <877ll88031.fsf@ethereal.dhis.org> Ok. I'll try to refrain from asking any other newbiish questions for awhile and let everyone recover. This one's much easier than my last one. Promise! :) As I'm sure several of you remember, I'm working on a MUD server in Python. Yesterday, when I was somewhat naive about how difficult it would be to implement a distributed server (That idea's been scratched, BTW.) one of my concerns was the speed of an interpretted language for this task. My initial argument for doing this project in an interpretted language vs. a traditional language was flexibility; I wanted the ability to drastically change the system without having to recompile, messing with dynamic loading, etc. I also reasoned that MUDs have been using interpretted languages for years. For example, LPMUD uses LPC, in which most of the MUD environment is written. (Though, admittedly, I know very little about this codebase, since it usually isn't used to build the type of game which I want.) Initially, I thought that if a MUD server could be written in Java (http://www.twistedmatrix.com) a Python version would be smaller, easily readable, etc. Now, however, I'm becoming concerned about how possible/practical this would be, and if I'm possibly using Python for something for which it isn't intended. I began doing research into Python's speed vs. Java, and had some concerns. I don't like to pose questions to newsgroups without doing some small level of research first. So, I started by reading the Java vs. Python analysis at http://www.python.org/~rmasse/papers/java-python96/. I read most of the paper, simply to have a little more firepower to throw around in any Python vs. Java religious wars which I may be involved in. :) What interested me, though, was the paper's comparison between Java's and C's respective runtime speeds. The paper included the following code to illustrate its point that Java code ran slower than similar C code: import java.util.Date; class BenchMark { public static void main (String argv[]) { System.out.println("Start Time: " + new Date().toString()); int i; Nothing bar; bar = new Nothing(); for (i = 0; i < 100000000; i++) bar.foo(); System.out.println("End Time: " + new Date().toString()); } } class Nothing { public static void foo () { return; } } I know that interpretted code is slower than compiled code; that isn't my concern. I did, however, write the following (Equivilant?) benchmark in Python: #!/usr/bin/python import time def foo(): return "" print time.ctime(time.time()) x = 1 while x <= 100000000: foo() x = x+1 print time.ctime(time.time()) Running the compiled Java code produces the following on my PPro 200: ethereal:~> java BenchMark Start Time: Thu Sep 30 17:53:00 CDT 1999 End Time: Thu Sep 30 17:53:41 CDT 1999 So we see that it takes roughly 41 seconds to loop through 100000000 method calls. Not bad. I ran py_compile on the Python module though, and here's what I get: ethereal:~> python test.pyc Thu Sep 30 17:56:53 1999 It is now almost 5:59, and the task is still running. So, it looks as if Python is much slower at this particular benchmark than Java. My first question is, should I even care? Since my program isn't going to repeatedly call 100000000 methods in a loop, should the fact that Python is slower at it concern me? I'm sure that there are other benchmarks, and some are more accurate than this little "poor man's benchmark" which I chose to run. Second, is there a way to speed up the above Python benchmark script? Am I doing something which is hindering its execution? Again, I did compile to bytecode, which sped up earlier tests greatly. Finally, and this is the question to which I'm almost afraid to see the answer . . . Is Python appropriate for this task? I learned Python almost a year ago, but have only recently worked with it extensively, and I really enjoy it. When I saw the Twisted Reality MUD server (see above URL) written in Java, I thought that it would be great to implement my ideas in an interpretted language. There are some features of Java which annoy me though, and I would very much like to do this in Python. Should I just continue scaling up my work and testing it, determining how the various components function and optimizing them if necessary? Or, should I seriously consider reimplementing my project in another language? Whew! That was a long QOTD, but one of my last for awhile, unless I need to comment on this one. :) Please understand; I'm not trying to initiate a religious/flamewar. I have some experience with embedding Python in other applications and extending it with additional functionality, but I've never developed a serious server application, and I've never really been concerned about runtime speed. So hopefully I won't start World War III. :) And, just as an aside, it is now 6:09 and the Python benchmark is still running. Hopefully I'm just blowing things way out of proportion, and I've gone about testing speeds in the completely wrong way. If you've read this far, thanks a bunch! :) From bsb at olis.north.de Wed Sep 29 11:17:26 1999 From: bsb at olis.north.de (Siggy Brentrup) Date: 29 Sep 1999 17:17:26 +0200 Subject: What GUI-lib to use In-Reply-To: garabik@melkor.dnp.fmph.uniba.sk.invalid's message of "29 Sep 1999 13:31:37 GMT" References: <37F1D710.47A82D23@bibsyst.no> <938615409.624335@cdwork.cvt.stuba.sk> Message-ID: <87aeq53fy1.fsf@baal.winnegan.north.de> garabik at melkor.dnp.fmph.uniba.sk.invalid (Radovan Garabik) writes: > Thomas Weholt wrote: > > : Could Tk get a more modern look perhaps and solve all our problems? > > yes... try tkstep (I do not know url... it is in debian) cat /usr/doc/tkstep8.0/copyright says: [...] The original sources obtained from ftp://ftp.debian.org were patched with Oliver Graf's TkStep 4.2 patches and additions (http://touchwood.ee.uts.edu.au/TkSTEP/TkSTEP.html). [...] From pinard at iro.umontreal.ca Tue Sep 14 22:02:44 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 14 Sep 1999 22:02:44 -0400 Subject: Strange writing not detected Message-ID: Hi, people. I made the following mistake (reduced, of course): >>> def f(a=0, a=0): ... print a ... >>> f(3) 0 In fact, I had many keywords arguments distributed over two lines, and just missed that one of them was repeated, and the results were unexpected. May I suggest that the byte compiler should refuse repeated arguments? This is Python 1.5.2. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From pup at pobox.com Tue Sep 7 10:31:47 1999 From: pup at pobox.com (Joel Burton) Date: Tue, 07 Sep 1999 14:31:47 GMT Subject: How to re replace string variables? Message-ID: I'm an experienced perl programmer, but new to Python. I'm trying to convert over a script that searches a text file, replacing all instances of variables (in this case, flagged by a leading $) with the string variable with that name. In perl, I would do this by s/\$([A-za-z]\w*)/${$1}/g which finds every instances of $xxx and replaces it with the scalar variable $xxx. However, I can't figure out how to do this in Python. Can I refer to a variable by referenced name? I could switch this so that all the variables are in a dictionary, so P['one'] = 'uno' P['two'] = 'dos', etc. With a string that looks like: "Is $one the same as $two"? But I get bogged down with errors when I try things like re.sub("(\$\w+)",P['\\1'], string) Because re module, when it gets the repl string/subroutine, hasn't resolved what \1 is. Any help would be very appreciated. Thanks! Joel Burton From cfelling at iae.nl Fri Sep 10 16:29:10 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 10 Sep 1999 22:29:10 +0200 Subject: Python example: possible speedup? References: <87puztv2gt.fsf@pc-hrvoje.srce.hr> Message-ID: <7rbpmm$12i$1@vvs.superst.iae.nl> Hrvoje Niksic wrote: > As a Python exercise, I wrote a simple program to "scratch an itch", > i.e. do something useful. However, I found that Python's lack of > speed really bytes me here, so I'd like to hear suggestions for > speedup. People who don't like that kind of topic, please skip to the > following article. Others, read on. although many have answered you already, I can't resist in posting yet another one. Your code takes almost 7 secs on my machine, mine takes a little over 1 sec, and it's still OO and generic. Besides, I didn't use any fance Python tricks, just the combination of lasy evaluation and bulk IO did the trick here. ----------------- #!/usr/bin/python import string class Dpkg_Munger: def munge_all(self, file): for raw_package in string.split(open(file).read(), '\n\n'): if raw_package!='': self.raw_package = '\n' + raw_package + '\n' self.munge_one(self) def __getitem__(self, key, find=string.find): i = find(self.raw_package, '\n'+key+':') if i == -1: raise IndexError i = i + len(key) + 3 if self.raw_package[i]==' ': i = i + 1 j = i - 1 while 1: j = find(self.raw_package,'\n',j+1) if self.raw_package[j+1] != ' ' and self.raw_package[j+1] != '\t': break return self.raw_package[i:j] class process_status(Dpkg_Munger): def __init__(self, file): self.installed = {} self.munge_all(file) def munge_one(self, package): name = package['Package'] status = package['Status'] if string.split(status, ' ')[2] == 'installed': self.installed[name] = 1 class process_available(Dpkg_Munger): def __init__(self, file, installed): self.installed, self.sizes = installed, {} self.munge_all(file) def munge_one(self, package): name = package['Package'] size = package['Installed-Size'] if self.installed.has_key(name): self.sizes[name] = string.atoi(size) def main(): installed = process_status('/var/lib/dpkg/status').installed sizes = process_available('/var/lib/dpkg/available', installed).sizes lst = sizes.keys() lst.sort(lambda a, b, sizes=sizes: cmp(sizes[b], sizes[a])) for pack in lst: print "%s: %d" % (pack, sizes[pack]) if __name__ == '__main__': main() -- groetjes, carel From aa126 at DELETE.fan.nb.ca Sat Sep 11 20:01:38 1999 From: aa126 at DELETE.fan.nb.ca (William Burrow) Date: 12 Sep 1999 00:01:38 GMT Subject: Text UI References: <65118AEEFF5AD3118E8300508B124877073BEE@webmail.altiris.com> Message-ID: On 11 Sep 1999 22:58:30 GMT, ?ukasz Kowalczyk wrote: >[ Robin Dunn ] >> In the Python sources, in the Modules directory there is a module for >> ncurses that can be built. > >Yes, but it's simply a wrapper around the libncurses library. I was looking >for something, uhm, more sophisticated ;) I recall a ghod-awful thing that was intended for DJGPP, I believe. Can't recall the name. It was slow as heck, but modern CPUs ought to make it bearable. If you can find it. -- William Burrow -- New Brunswick, Canada o Copyright 1999 William Burrow ~ /\ ~ ()>() From culliton at clark.net Wed Sep 22 10:04:20 1999 From: culliton at clark.net (Tom Culliton) Date: Wed, 22 Sep 1999 14:04:20 GMT Subject: Newbie Question References: <37E773E7.B3A0CEA0@ecs.soton.ac.uk> <37E8AF24.1CDE9916@isogmbh.de> <002f01bf04e6$7d6a4950$f29b12c2@secret.pythonware.com> Message-ID: In article <002f01bf04e6$7d6a4950$f29b12c2 at secret.pythonware.com>, Fredrik Lundh wrote: >Chris... wrote: >> I've never heard of an 'atoi' function, but there exists 'int()' that >> converts its argument (string or number) to a plain integer. > >atoi is in the string module, together with atof and atol: > >http://www.python.org/doc/current/lib/module-string.html > >(they're similar to their builtin counterparts, but atoi >and atol can also be used with non-decimal numbers) > > string.atoi(), string.atof(), ... are also substantially faster (about twice as fast by my tests) than int(), float() and the like. This is presumably because they don't need to waste time figuring out the type of the input argument. Generally I would recommednd using int() when you need to coerce a "number" of arbitrary type to an integer (like you would a C/C++ cast), and using string.atoi() to interpret strings as integers. From news at dorb.com Thu Sep 23 14:20:11 1999 From: news at dorb.com (Darrell) Date: Thu, 23 Sep 1999 14:20:11 -0400 Subject: Sequence traversal References: <37EA4AD5.1B54A185@tu-bs.de> <5RtG3.2121$46.35771@typhoon.nyroc.rr.com> Message-ID: Added the array index version it came up with .125 and 10.375 sec. def test3(): cnt=0 ml=min(len(l1),len(l2)) for x in xrange(ml): if (l1[x],l2[x])== searchKey: cnt=cnt+1 return cnt maxLoop: 1 Found: 1 Time: 0.0940 <=== map maxLoop: 1 Found: 1 Time: 0.1880 <=== cached map maxLoop: 1 Found: 1 Time: 0.1250 <=== array index ********** maxLoop: 100 Found: 1 Time: 5.7030 maxLoop: 100 Found: 1 Time: 0.0000 maxLoop: 100 Found: 1 Time: 10.3750 <== array index ############################# Changed: sz=1000000 maxLoop from 100 ==> 10 memory use 125meg Running just test3 the array index test, memory use was 33meg Just test2 the map+cache was about 90meg Just test1 the basic map, memory usage was 71meg ############################ maxLoop: 1 Found: 1 Time: 2.6100 maxLoop: 1 Found: 1 Time: 6.3280 maxLoop: 1 Found: 1 Time: 3.4060 ********** maxLoop: 10 Found: 1 Time: 19.7190 maxLoop: 10 Found: 1 Time: 0.0620 <== REM: It built a cache when it took 6.328 sec, I think that's fair. maxLoop: 10 Found: 1 Time: 34.6550 -- --Darrell From cgw at fnal.gov Fri Sep 24 13:22:48 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Fri, 24 Sep 1999 17:22:48 GMT Subject: Read stdout from shell command, was: Becoming root In-Reply-To: References: <19990924165114.A753@krikkit.vollmert.home> Message-ID: <14315.45928.346171.719977@gargle.gargle.HOWL> Will Ware writes: > The thing I'd really like to know is how to do the Python > equivalent of a shell command of this form: > > variable = `some shell command` > > where "some shell command" prints to standard output. > I find I do this quite frequently, usually using something like > os.popen('some shell command').readline()[:-1] and sure, it works, > but it's really ugly, Well, I agree that using popen is kind of ugly; generally if there's a way to get at the info by using some Python code rather than relying on an external program, that's always better, e.g. like using os.listdir instead of popen'ing the "ls" command, to take a silly example. But when you absolutely must use some shell command, then popen is the way to go. > and I'm always left with the nagging suspicion > that since I didn't explicitly close the os.popen(), it might still > be floating around. pipe = os.popen("the_command",'r') output = pipe.readlines() exit_status = pipe.close() This has the double advantage of not only explicitly closing the pipe object, but also collecting the exit status of the invoked command. If you want to be really proper, you'll use some try/except around this, in case the program isn't found, an IO error occurs, etc. HTH, cgw From poinot at onera.fr Wed Sep 1 03:19:31 1999 From: poinot at onera.fr (Marc POINOT) Date: Wed, 01 Sep 1999 09:19:31 +0200 Subject: Python Test Executive References: <7qh93m$38k$1@nnrp1.deja.com> Message-ID: <37CCD382.E668DC41@onera.fr> winkjj at my-deja.com wrote: > Has anyone done some work in this area? I have lots of ideas on how a > Python based test executive could be implemented, but unfortunately, I > am stuggling with the build yourself vs. buy off the shelf trade offs > and really don't have the time to invest in building the tooling from > the ground up. We have that kind a test tool here. It is composed in two parts, a server system that contains tests suites and results, connected to a SCM, RDBMS and Bug report tool. And a client part, which can be shipped to our customer for in site test. These tools are dedicated to our needs (large jobs, NQS, automatic LaTeX report, bindings with CVS...) This tool is not yet public, but I'll be glad to give you any information, pieces of code or tips you'd like to have. By the way, we also have a presentation of a test tool at the JPF001. It was and ADA testbench, maybe there are some extension to C/C++ now? The contact is prz at spacebel.be Marcvs [alias And all this is 100% Python] From ivnowa at hvision.nl Mon Sep 27 17:44:52 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Mon, 27 Sep 1999 21:44:52 GMT Subject: ScrolledText Widget In-Reply-To: <7skld8$92e$1@nnrp1.deja.com> References: <7skld8$92e$1@nnrp1.deja.com> Message-ID: <199909272143.WAA13352@axil.hvision.nl> On 26 Sep 99, rainer2207 at my-deja.com wrote: > I haven't seen any examples on how to use the ScrolledText widget. I'm > trying to create a toplevel window which displays the contents of a file. > Can anyone tell me how to use this widget or another way of doing this? > Thanks. The attached code doesn't read a file, but it might give you an idea of how ScrolledText works... --Hans Nowak (zephyrfalcon at hvision.nl) Homepage: http://fly.to/zephyrfalcon Python Snippets: http://tor.dhs.org/~zephyrfalcon/snippets/ The Purple Kookaburra Forum: http://www.delphi.com/kookaburra/ -------------- next part -------------- # from Tkinter import * from ScrolledText import ScrolledText class TextThingy (Frame): def __init__(self, master=None): Frame.__init__(self, master) self.pack() self.createWidgets() def createWidgets(self): self.entry = Entry(self) self.entry.pack(fill=X, pady=5) self.entry.bind("", self.blurb) self.text = ScrolledText(self, state=DISABLED, height=10) self.text.pack() def blurb(self, event): text = self.entry.get() + "\n" self.entry.delete(0, END) self.text.config(state=NORMAL) self.text.insert(END, text) self.text.config(state=DISABLED) TextThingy().mainloop() From wtanksle at dolphin.openprojects.net Tue Sep 14 21:12:47 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Wed, 15 Sep 1999 01:12:47 GMT Subject: List Comprehensions Enhancement References: <37D9E932.66F2B0D3@cosc.canterbury.ac.nz> <7riudv$24g$1@c3po.schlund.de> <37DDA62D.84BE5083@compaq.com> Message-ID: On Tue, 14 Sep 1999 13:34:37 +1200, Greg Ewing wrote: >William Tanksley wrote: >> On 13 Sep 1999 13:32:47 GMT, Hannah Schroeter wrote:> >My goal wasn't to make the syntax as compact (some might >say cryptic) as possible, but to import the idea and >make it blend in with the rest of the language. I liked it. >> >Also, I think there should be a clear separator [he suggested a comma] >> I agree -- my initial reaction was to put 'and' as the seperator. >There are problems with both of those. Using "," would >mean the expression couldn't be a tuple constructor without >using parentheses, which would be a potentially confusing >difference from the for statement. I hear you here -- but I tried to write a couple of comprehensions, and I found that I was putting parenthesis in when needed. It's kind of automatic after you've been working with Python for any amount of time. >And I'm not sure what >the parser would make of "x and for" given that "x and y" >is a legal expression. It's parsable, but given that it would require modifications to the parser I have to retract my suggestion. >Semicolons could perhaps be used, although that seems >somehow un-pythonic to me. I don't like it either. Commas have the advantage of looking like they're talking about sequences, which in this case they indeed are. >Another possibility is to turn the whole thing around >and write > [for i in nums: for s in strs: (i, s)] >but that loses the declarative flavour of having the >element expression up front. Agreed. It also looks a little too much like a normal Python statement, which it's not really. >> On a scale of one to ten I'd give it a tim. >Hey, wow! And I haven't even gotten onto case statements >with pattern matching yet... Hey, Greg! Make us a 'while' statement which reads lines out of a file. And why doesn't Python have a $_ variable? :-) >Greg -- -William "Billy" Tanksley From skaller at maxtal.com.au Sat Sep 4 14:16:35 1999 From: skaller at maxtal.com.au (John Max Skaller) Date: Sat, 04 Sep 1999 18:16:35 GMT Subject: Spanish Inquisition?! References: <37CFC38C.20A9C267@megsinet.net> Message-ID: <37d1605a.200545108@news.triode.net.au> On Fri, 03 Sep 1999 16:54:37 GMT, clgonsal at keeshah.penguinpowered.com (C.Laurence Gonsalves) wrote: >On Fri, 03 Sep 1999 08:48:12 -0400, David Oppenheimer >> P.S. Creating compiled code from Python that didn't require the >> interpreter to be distributed with it would be high magic indeed. > >Yeah, especially compiling those eval and exec functions... Thats no real problem. Any 'compiled' version of python, and Viperc is no exception, must have an inbuilt interpreter, and the usual set of builtin functions. This is required even without 'exec' and 'eval', in case the compiler cannot deduce enough to optimise the code. For example: for i in alist: print i is hard to optimise, since 'i' could be anything. Indeed, compiled python is likely to be interpreted python, with a lot of 'builtin' functions added by the compiler to replace parts of the python code. John Max Skaller ph:61-2-96600850 mailto:skaller at maxtal.com.au 10/1 Toxteth Rd http://www.maxtal.com.au/~skaller Glebe 2037 NSW AUSTRALIA From john.michelsen at gte.net Tue Sep 21 13:02:35 1999 From: john.michelsen at gte.net (John Michelsen) Date: Tue, 21 Sep 1999 17:02:35 GMT Subject: VisPy, funding? Message-ID: Hi all, I've been tossing around the idea of doing a clone of the Visual Basic gui builder for Python and Tk (call it Visual Python or VisPy or something). Since I don't have much code yet, this post is to enquire if there is any interest in the Python community to fund a prototype of such a beast. I think I could put together one in a week or so with the following: 1) A toolbox full of widgets (Tk, later Pmw), clicking on which puts them on a form where they can be moved and resized. 2) A properties bar where widget's options can be seen and modified by a combox or entry. 3) A bindings combobox where a widget can be picked and an event and some code is generated for the event. I've never seen a request for funding here for an open source project so I don't really know if this is appropriate, but I thought I'd give it a try anyways. :^) Maybe 1K for the prototype? Or just as good, airfair, hotel and registration for the 8th International Python Conference. :^) If interested you can check up on my resume at http://home1.gte.net/cpq2d451/resume.txt to see lots of other Tkinter stuff I've done. Thanks, John From janssen at parc.xerox.com Tue Sep 14 20:59:41 1999 From: janssen at parc.xerox.com (Bill Janssen) Date: Wed, 15 Sep 1999 00:59:41 GMT Subject: high school programming & python In-Reply-To: <$JL+lCAFvt33Ewr8@jessikat.demon.co.uk> References: <937300939snz@vision25.demon.co.uk> <$JL+lCAFvt33Ewr8@jessikat.demon.co.uk> Message-ID: Excerpts from ext.python: 14-Sep-99 Re: high school programming.. Robin Becker at jessikat.de (951) > You were lucky to have plugboards. We had to key things in with a bunch > of switches. Hard little metal toggle switches, too -- none of these posh molded plastic rocker switches! Bill From cdaniel at Level3.net Fri Sep 24 14:34:31 1999 From: cdaniel at Level3.net (Cliff Daniel) Date: Fri, 24 Sep 1999 14:34:31 -0400 Subject: os.popen results diff when executed in browser vs DOS In-Reply-To: <7sg8jb$a4k$1@nnrp1.deja.com> References: <7rtin6$9oa$1@nnrp1.deja.com> <7sg8jb$a4k$1@nnrp1.deja.com> Message-ID: <19990924143430.L19181@shell2.name> I'd try a couple things just to see if it worked. 1. use sys.stdout.write('blah blah
\n') or print 'a
 tag' [this should be unbuffered.]

campbeld2 at my-deja.com writes:
> I'm resubmitting this question on the off chance someone can help me,
> please. I suspect it is to do with nested stdout results, but I'm at a
> loss here.
> Thanks
>   Dyan
> 
> 
> In article <7rtin6$9oa$1 at nnrp1.deja.com>,
>   campbeld2 at my-deja.com wrote:
> > This sample program illustrates my dilema.
> >
> > I am trying to execute a command ( could be
> > any command ) within Python and capture the
> > output.  It works fine when I run it at command
> > level, however when I invoke the script in the
> > browser the code does not return any values from
> > the os.popen(...)readlines.  I tried try: and
> > except: but nothing is trapped.
> >
> > Any ideas?
> >
> > ------
> >
> > """
> >  test.py :
> >  returns correct results at command level (great)
> >  returns nothing through Browser !!!
> > """
> > import os
> >
> > print 'Content-Type: text/html\n\n',
> > for line in os.popen( 'cd','r' ).readlines():
> > 	print '

...within for loop \n\n' > > cd = line > > > > print '

cd = ', cd, '\n\n' > > > > #end of test.py > > > > Sent via Deja.com http://www.deja.com/ > > Share what you know. Learn what you don't. > > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > > -- > http://www.python.org/mailman/listinfo/python-list -- Cliff Daniel Level 3 Communications From cgw at fnal.gov Wed Sep 1 00:10:02 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Wed, 1 Sep 1999 04:10:02 GMT Subject: running python on a floppy? In-Reply-To: <37cc7e3b.1941695@nntp.best.ix.netcom.com> References: <37CA50EC.4FC03560@home.com> <37cc7e3b.1941695@nntp.best.ix.netcom.com> Message-ID: <14284.42778.543818.343109@buffalo.fnal.gov> Dennis Lee Bieber writes: > > I have two SCSI externals, and my DELL came with an IDE > internal. The closest I have come to the "CoD" is sometimes having the > SCSI drive on my Amiga thunk when it first tries to register a disk, > with the disk being "unreadable". In all instances, ejecting the disk, > waiting a moment for everything to reset, and reinserting the disk has > worked. It's fortunate for you that you've never experienced the "Click Of Death". But of course this kind of N=1 evidence doesn't prove much. It's like saying "My grandfather smoked 10 cigars a day and he lived to be 99". That's great, but it doesn't disprove that smoking causes cancer. The Click Of Death is very real, I've witnessed it on several different machines, as have several other people of my acquantance. Isn't it funny that Iomega's new drive is called the "Clik"? Couldn't have picked a worse name, if you ask me. In response to the original poster - trying to squeeze software onto floppies is still very much worth doing. ZIP drives have nowhere near the ubiquity of floppies. It's a rare machine that doesn't have a floppy drive. ZIPs seemed, a few years back, to be growing in popularity, but that trend seems to me to have slowed substantially - partly, in my opinion, because CD writers have become so cheap, and the cost per megabyte of ZIP media is too high, compared with CD media. And CD drives are much more prevalent than ZIPs. Most computers made in the last 5 years or so have a CD-Rom drive as part of the "baseline" configuration, with ZIP as a extra-cost option. Just my opinion, but I think ZIP disks are on the way out. Iomega stock certainly isn't worth what it used to be (last time I checked, anyhow). From doughellmann at home.com Thu Sep 9 20:18:24 1999 From: doughellmann at home.com (Doug Hellmann) Date: Fri, 10 Sep 1999 00:18:24 GMT Subject: equivalent of enum? References: <14296.14104.456361.61180@dolphin.mojam.com> Message-ID: <37D84F85.A37FAA9C@home.com> Skip Montanaro wrote: > > If you expect to have properties associated with particular pieces > (position, strength, etc), you might want to consider representing them by > instances of a specific ChessPiece class instead: This is probably the best advice for this situation. > In more direct answer to your question, there is no enum type in Python. > It's simple enough to declare objects that you treat as constants, however: There are a lot of times when having an enumeration is nice, and a class would be overkill. I forget where I've seen the idiom, and I certainly didn't make it up, but a really nice way to make an enum is to do something like: one, two, three = range(3) print one, two, three Works every time. If you forget to increase the range size when you add a new value, you will get a runtime error because the tuple unpack won't work. Doug From mal at lemburg.com Wed Sep 15 10:41:51 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Wed, 15 Sep 1999 16:41:51 +0200 Subject: Python speed and `pcre' References: <00af01bef543$0affe8f0$f29b12c2@secret.pythonware.com> <37CFB6C4.35578D33@lemburg.com> Message-ID: <37DFB02F.D097FC4@lemburg.com> Fran?ois Pinard wrote: > > "M.-A. Lemburg" writes: > > > [substrings] > > > Note that Python 1.5.2 already support such beasts... albeit rather well > > hidden (for obvious reasons ;-) and not fully interoperatable yet: > > > >>> s = '12345678901234567890' > > >>> snippet1 = buffer(s,8,3) > [...] > > You can always turn a buffer back into a string using the str() > > function. > > > Perhaps the string module should be extended to use "s#" > > more often... > > Hello. Thanks for the pointer, yet I'm just starting to understand your > reply, and it may take some while, still. The manual is very terse about > the `buffer' function, relating it to `buffer' methods, without explaining > any further what these are... Also, I do not understand the "s#" quote. > Sorry for being a bit opaque, here. Would someone suggest some magnetic > reference to me about these, which a beginner could afford to read and > understand? I'm not ready yet to dive into the interpreter sources :-). Sorry, buffer objects are still somewhat fuzzy and undocumented. All I can refer you to is the source code in Include/bufferobject.h and Objects/bufferobject.c. The "s#" quote was meant for experts: it refers to a format string passed to PyArg_ParserTuple() for converting Python objects to C data. "s#" tells the function to give back a char* Pointer and a length integer and to try to use the buffer interface of the object to fetch these from the object. By using "s#" you can make your function compatible to all objects implementing the buffer interface, ie. not only strings but also memory mapped files, buffers, etc. Hope that helps at least a bit, -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 107 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From jam at quark.emich.edu Fri Sep 17 14:36:50 1999 From: jam at quark.emich.edu (Jeff) Date: Fri, 17 Sep 1999 14:36:50 -0400 Subject: Newbie: Where can I find this module? In-Reply-To: <37E2712E.3EF8A9F5@alliedsignal.com>; from H. P. Friedrichs on Fri, Sep 17, 1999 at 09:49:51AM -0700 References: <37E2712E.3EF8A9F5@alliedsignal.com> Message-ID: <19990917143650.D8674@quark.emich.edu> On Fri, Sep 17, 1999 at 09:49:51AM -0700, H. P. Friedrichs wrote: > I have a redhat 5.0 linux box on which I've written some python scripts. > I also have mysql up and running on the same box. I'd like to be able to > access the mysql tables from python. > > I checked the web and found a site with some sample code to let me do > this. The first line of the sample imports a module called "mysqldb". > > Where can I find that? I presumed it might be on the MySQL website, but > it's not readily apparent to me if it is. I have also conducted other > net searches without luck. Can anyone clarify? > > Thanks > Pete > try regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From aahz at netcom.com Wed Sep 8 17:12:29 1999 From: aahz at netcom.com (Aahz Maruch) Date: 8 Sep 1999 21:12:29 GMT Subject: binary mail with python References: <036101bef9e7$b907a480$b4bb32c1@clara.ircom.unilim.fr> <19990908211233.A3782@optiplex.palga.uucp> Message-ID: <7r6jft$lq8@dfw-ixnews3.ix.netcom.com> In article <19990908211233.A3782 at optiplex.palga.uucp>, Gerrit Holl wrote: >On Wed, Sep 08, 1999 at 12:48:44PM +0200, Daniel ARGOLLO wrote: >> >> I am searching for any python package that can pack different binary >> files into a MIMI file to be sent with the mail suport of python.... > >Maybe you're looking for mimimy? I've never used it, but the name >means a lot (did I say it right?). First of all, it's "MIME". The two Python libraries are mimetools and MimeWriter. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From stephan at pcrm.win.tue.nl Mon Sep 13 04:39:00 1999 From: stephan at pcrm.win.tue.nl (Stephan Houben) Date: 13 Sep 1999 08:39:00 GMT Subject: mmap interface in Python References: <877llyzvld.fsf@pc-hrvoje.srce.hr> Message-ID: On 10 Sep 1999 16:31:42 +0200, Hrvoje Niksic wrote: >When discussing Python speed, many people advised me to "slurp the >whole file in". The only reason why I didn't like that is the obvious >one -- it burns a lot of memory for large files. > >But then I remembered: in C under Unix, I would use mmap() to map the >file to memory, and operate on that memory. I don't see why the same >thing couldn't be available in Python -- under Unix at least. It sounds cool, but I'm not sure if it buys you all that much performance-wise. If you're afraid to "burn too much memory", well, the memory gets swapped out, so who cares? If you want to do a regular expression match, the match() function will scan the entire file anyhow and cause it to be loaded into core. So in that case, you don't win anything either. Finally, by ussing mmap(), you loose compatibility with lesser OSes. So I'm not sure if you really want this, although it might be cool to mmap() some of the special files in Linux... Greetings, Stephan From dboddin at uumail.de Mon Sep 6 13:54:17 1999 From: dboddin at uumail.de (E-14) Date: Mon, 6 Sep 1999 19:54:17 +0200 Subject: accessing parallel interface Message-ID: <7r0v0k$o98$1@newsread.do.de.uu.net> How can access the parallel interface, to set and read bits. I wonna connect an A/D converter, speed isn't important. Detlef From mcg at halcyon.com Sat Sep 11 17:12:38 1999 From: mcg at halcyon.com (Michael C. Gilbert) Date: Sat, 11 Sep 1999 14:12:38 -0700 Subject: Sparc Linux? Message-ID: Hi -- Thinking about buying an old Sparc Station with SparcLinux. Any trouble running installing 1.5.2 on that? -- Michael From lynn at siprelle.com Tue Sep 14 19:53:29 1999 From: lynn at siprelle.com (Lynn Siprelle) Date: Tue, 14 Sep 1999 16:53:29 -0700 Subject: [Newbie] test_signal hangs Message-ID: <37DEDFF7.1DC7C4B3@siprelle.com> Hi there-- I'm totally new to Python, haven't even written a Hello World yet, because I'm still trying to get it up and running on my fershlugginer system. I'm wanting to experiment with Python and Zope on my iServer websites. OK, so I figured out how to compile Python (the iServer environment tricks the configure script into thinking it's on a NeXT box, so you have to go in and manually change configure.h to comment out the dyld stuff). And now I'm trying to run the test set, but it hangs on test_signal--I let it run for more than an hour, and it just sat there. Should I even care? Or is this a real problem? From tim_one at email.msn.com Fri Sep 17 01:42:59 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 17 Sep 1999 01:42:59 -0400 Subject: Marking translatable strings In-Reply-To: Message-ID: <000101bf00cf$801bd080$d12d153f@tim> [Fran?ois Pinard, on internationalization of strings in program text] I know less than nothing about this -- always figured that if American English was good enough for God, it's good enough for everyone else . So I'll just touch on some Python issues: > ... > [Python] has eight type of strings: ', ", ''', """, r', r", r''' and > r"""; and I thought that maybe we could just discipline ourselves to > give more meaning to all these differences ... Indeed, the number of ways to spell strings in Python is quite unPythonic! The language generally avoids offering gratuitous choices. Too late now, though -- all ways of spelling strings are already used in all conceivable contexts, and no rational discipline can be imposed a posteriori. For the purpose of finding Python strings, note that under the covers it was deliberately designed so that there's really just one basic string-recognizing state machine. ' vs ", and ''' vs """, make no difference at all to lexing, and r- vs not-r makes no difference either. The only difference in lexing is that the 4 single-quoted varieties (', r', ", r") refuse to span lines except via backslash+newline, while the 4 triple-quoted varieties don't treat newline specially. > ... > Surely, since doc strings use """ exclusively, ... Really sorry, but you can't rely on that. I've seen all 8 flavors of strings used as docstrings -- what makes a string a docstring is not how it's spelled, but where it appears (if the first executable stmt in a module, class or def is a string, that's a docstring; and nothing else is). > ... > The most comfortable (the less intrusive) way would be to call: > > _(TEXT) > > to get the translation of text. I agree with everyone else that the special meaning of "_" in interactive mode is unlikely to create a problem for you. > ... > Experience shows that horizontal space is often a valuable resource while > writing code, so we should try to be economical there for overall > legibility, much more than typability. I like the way you think . Really, Python takes pride in its legibility, so worrying about that is very welcome here. Note one odd thing: since Python doesn't support assignment expressions, horizontally-challenged 8-line "if" stmts simply don't occur. So there's less horizontal pressure here than you may be used to. OTOH, Python doesn't support augmented assignments (+= & friends) yet either, and that adds horizontal pressure (but less, I think, than the lack of assigment expressions relieves). > ... > and we could use''"TEXT" or ""'TEXT' for strings needing to be marked > only, and translated only later. I don't understand the distinction here, so just noting that there's nothing in the compiled code that can distinguish an instance of ''"TEXT" in the source from an instance of "TEXT" or even of '' "TEXT"""""""r'''''' Catenation of adjacent string literals is a compile-time "optimization", or more accuractely slavish aping of C rules -- as if someone thought C were a pleasant string language . > ... > One reason to modify the interpreter would be for speed, maybe, > by ensuring that a given string is translated only once even in a loop, > like for what _() currently does in C when compiled with GNU C. It might > depend on how exactly strings are intern'ed within Python, which I do not > know. You can force interning via calling the intern() builtin. By default, the only strings that get interned are those literals that "look like" they *may* be attribute names. For example, "Pinard" is interned by magic, but "F. Pinard" is not. In any case, automatic interning is purely an internal optimization, and the rules can-- and do --change from release to release. So don't even think about relying on their specific incarnation today. Within a code block (def, class or module body), but not across code blocks, all string literals are accumulated and stored uniquely in a vector of constants attached to the code object. So, e.g., within a single def, 112 instances of "F. Pinard" will all resolve to a single string object. If you use a runtime translation function, it can exploit this via a cache, as in def _(s, cache={}}: translated = cache.get(s, None) if translated is None: translated = cache[s] = translateit(s) return translated Caching on the address of s (id(s)) would be quicker, but while that's safe for string literals, it can create false hits if _ is ever applied to computed strings (two instances of which may have the same address if their lifetimes are disjoint). Explicit interning can worm around that, but interned strings are effectively immortal. So there are puzzles here. It's also possible to write a little bytecode optimizer to traverse the code object's constant vector and translate the strings it finds once and for all; the puzzle there is which strings to leave alone. > ... > it would be nice if internationalization could be achieved > portably to all flavours of Python, just doing nothing on older > implementations, anyway, or doing it slower. That is, that the string > syntax should not be modified. Python favors explicit approaches. Another advantage is that a fully explicit scheme should work unchanged for JPython too (a variant of Python that compiles directly to Java bytecode). > ... > Problems arise when languages have purely dynamic scoping, because textual > domains are lexically scoped by intent. I did internationalize a rather > big Scheme program already, but it was all within a single textual domain, > so I did not hit any wall there. But I would guess that Scheme is much > simpler than Emacs LISP, in actual practice -- I'm not sure. Scheme, unlike elisp, is lexically scoped. So, yes, Scheme is much friendlier than elisp in this respect. elisp also has interesting complications due to, e.g., buffer-local vrbls vs global vrbls of the same name, which is a novel kind of dynamic scoping (novel because it can't be resolved either by reference to the static source text or by staring at the runtime call stack!). > Python should be simple as well. Yet, after the XEmacs > internationalisation failure, one good lesson, that we would be foolish > to not retain, is that we should take time to think things out, before > starting to think too big. "Do the simplest thing that could possibly work" is good advice in such situations. We'll fix it later . > ... > It is not clear to me how doc strings are used in Python. It's not yet clear to anyone. They were inspired by elisp, but because our Benevolent Dictator didn't decree every detail of how they were to be used, people have thrashed for years wondering what to do with them. The saving grace is that they're available for runtime introspection & manipulation via __doc__ attributes, so any explicit scheme that can be applied to runtime strings can be applied to them as well. If you register a module's translation domain via binding a conventionally-named module attribute (let's pick one at random, say "_domain"), any tool mucking with docstrings should be able to find that. If you can get at a code body at runtime, you can get a handle to the code's global namespace, which is an ordinary Python dict that almost always corresponds to the module namespace in which the code body was defined. Then you can simply look up "_domain" in that dict. Python maintains a lot of info for runtime introspection so you don't have to invent elaborate & delicate compile-time schemes for retaining it yourself. so-easy-it-will-probably-write-itself-ly y'rs - tim From greg.ewing at compaq.com Wed Sep 1 00:11:08 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Wed, 01 Sep 1999 16:11:08 +1200 Subject: creating a list of class instances from file / stdin (AGAIN) References: <37C7D49B.CA7DEAE1@pcc.net> Message-ID: <37CCA75C.71D6590F@compaq.com> Stephen wrote: > > What is the syntax to do: > for line in mb_list: > create an instance of this class and append it to a new list???? > Can I combine the mb_list.append statement above to create instances of > the class while reading the input? Sure, you can: data = [] for line in mb_program.readlines(): f1, f2, f3 = string.split(line) data.append(MyClass(f1, f2, f3)) Hope that helps, Greg From guido at cnri.reston.va.us Fri Sep 24 15:06:56 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 24 Sep 1999 15:06:56 -0400 Subject: decomposing an intersecting polygon? References: <240919991023082871%joe@strout.net> Message-ID: <5lso4486y7.fsf@eric.cnri.reston.va.us> Joe Strout writes: > I'm looking for an algorithm to decompose a self-intersecting 2D > polygon into a set of non-intersecting polygons, according to the > "odd-even" winding rule. That is, if the polygon defines a > five-pointed star by five lines, the center of the star should not be > filled. I'm not sure if it uses the odd-even rule, nor how easily it can be converted to what you're looking for, but there's code in Grail that checks whether a point is inside or outside a polygon. I'll copy it here: def poly_pointin(self, x, y): """Is point (x,y) inside polygon with vertices coords? From C code by Paul Bourke at Determining whether or not a point lies on the interior of a polygon. The algorithm is a little pesky because a point on an edge of the polygon doesn't appear to be treated as *in* the polygon. Not doing anything about this at the moment. """ counter = 0 p1 = self.coords[0] for i in range(1,len(self.coords)): p2 = self.coords[i] if y > min(p1[1], p2[1]): if y <= max(p1[1], p2[1]): if x <= max (p1[0], p2[0]): if p1[1] != p2[1]: xintersect = \ (y-p1[1])*(p2[0]-p1[0])/(p2[1]-p1[1])+p1[0] if p1[0] == p2[0] or x <= xintersect: counter = counter + 1 p1 = p2 return counter % 2 --Guido van Rossum (home page: http://www.python.org/~guido/) From cgw at fnal.gov Sat Sep 18 14:52:20 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Sat, 18 Sep 1999 18:52:20 GMT Subject: Any good debuggers for Python? (was Re: using python debugger (pdb) inside emacs debugger mode ...) In-Reply-To: <199909172318.QAA17505@hpcll563.cup.hp.com> References: <199909172318.QAA17505@hpcll563.cup.hp.com> Message-ID: <14307.57188.583343.140730@gargle.gargle.HOWL> Ovidiu Predescu writes: > I would still like to have a pdb-mode for source files, similar > with gdb-mode Could you elaborate a little bit on what you would like this mode to do? Do you mean being able to click on expressions in the source buffer and print out their values, etc? This might not be too hard to add to pdb.el without needing any big modifications to pdb.py, in particular I'm not sure that gdb annotations are required. Or are you talking about something else? > > A better thing might be to have gdb support debugging Python programs, just > like it supports the other languages, but this is a different topic. It's probably safe to say that this will never happen, support for Python debugging would be just *too* different than the languages GDB already supports. But what would be good would be to have a Python debugger that presents the identical interface as GDB, so that it could be used in contexts where GDB is used (like XEmacs, and the other various GUI front-ends to GDB that are out there).... This is something I'd like to work on but quite honestly I haven't had the time recently, possibly in a few months when I finish up some current projects, I'll be able to get back to my "PyGDB" project. From stephan at pcrm.win.tue.nl Mon Sep 27 10:16:00 1999 From: stephan at pcrm.win.tue.nl (Stephan Houben) Date: 27 Sep 1999 14:16:00 GMT Subject: Python compilers? References: <87aeq86am8.fsf@ethereal.dhis.org> Message-ID: On 27 Sep 1999 03:07:27 -0500, Nolan Darilek wrote: >I've been programming with C++ for nearly a year, and after seeing how >other languages are structured, and their benefits, I'm becoming >disenchanted with it. > >So, I've been searching for another language. One item which I would >like to have, though, is the ability to compile to native code. While >I completely agree with open source philosophies, I'd like to have the >option to not release source if, for example, I was working on a game >and wanted to dissuade the lazy from peeking at the script source for >the solution. :) I know about freeze, but the created binaries are >extremely large, which makes sense considering how they are made. :) > Well, you could of course code in Perl. That will teach them trying to read your code! <1.5 wink> >So, are there any native Python compilers? Someone on IRC mentioned a project >called Viper, and my searches seem to indicate that it is under >development, but is there any information on the web about its status? I don't think it's ready for prime time... and that's probably an understatement. >One final question. How compatible/cross-platform are Python >bytecodes? If I wanted to distribute applications in Python while >hiding the sources from the user, would it be possible to distribute >.pyc files, or the bytecodes specific to a specific version/platform? > Python's .pyc files are completely cross-platform, so you can just distribute them. However, the bytecode format might change between versions. IMHO, you have basically 4 options, in order of diminishing ease-of-implementation. 1. Don't bother about people reading the source. Remember, they are just spoiling their own gaming fun. The popular "nethack" game has source available, and yes, some people do indeed read it. That's up to them 2. Use CPython and distribute the .pyc files. Make sure that you have .pyc files available for all recent Python versions. Also note that Python bytecode is relatively easy to disassemble and "reverse engineer". Again, people who do that are spoiling their own game. 3. Use JPython and distribute the Java .class files. I think there are event .class -> C converters. This doesn't buy you anything speedwise compared to plain CPython, but it gives you more obfuscation. 4. Have the "meat" of the program run on a server under your control, and only distribute a client that connects to the server program. This is the only setup that is *really* safe, but it's going to be a big hassle both for you and your players. Only do this if you offer a monetary prize when winning the game. Greetings, Stephan From news at dorb.com Mon Sep 27 11:40:50 1999 From: news at dorb.com (Darrell) Date: Mon, 27 Sep 1999 11:40:50 -0400 Subject: Circular refs References: <000501bf08f9$f25e79e0$3acbd9c2@peridot.optichrome.com> Message-ID: Instead of letting Noisy hold the offending references keep them in a dictionary and let Noisy hold a key to find it. OR: Untested code that I half expect to be beaten up for. Add a destroy method to class Noisy that cleans out it's data members. def destroy(self): for k in self.__dict__.keys(): setattr(self, k, None) Also check out tools for finding this sort of thing such as cyclops which is a variation on plumbo. -- --Darrell Adrian Eyre wrote in message news:000501bf08f9$f25e79e0$3acbd9c2 at peridot.optichrome.com... > Is there a reasonable fix for this? > > >>> class Noisy: > ... def __init__(self, name): > ... self._name = name > ... print "Created " + self._name > ... def __del__(self): > ... print "Destroyed " + self._name > ... > >>> a = Noisy("a") > Created a > >>> b = Noisy("b") > Created b > >>> del a > Destroyed a > >>> del b > Destroyed b > > Fair enough, but... > > >>> a = Noisy("a") > Created a > >>> b = Noisy("b") > Created b > >>> a.b = b > >>> b.a = a > >>> del a > >>> del b > [Sound of memory dripping onto the floor] > > -------------------------------------------- > Adrian Eyre > Optichrome Computer Solutions Ltd > Maybury Road, Woking, Surrey, GU21 5HX, UK > Tel: +44 1483 740 233 Fax: +44 1483 760 644 > http://www.optichrome.com > -------------------------------------------- > From khalsa at acay.com.au Mon Sep 6 05:51:12 1999 From: khalsa at acay.com.au (Gurvijay Singh Bhatti) Date: Mon, 06 Sep 1999 19:51:12 +1000 Subject: Class in class Message-ID: <37D38E90.2E5713A9@acay.com.au> Dear everyone, Like C++ and Java, is it possible to declare a class in a class? If it is then could you tell how? regards GSB From yopen at my-Deja.com Fri Sep 3 18:02:44 1999 From: yopen at my-Deja.com (Bill Wilkinson) Date: Fri, 3 Sep 1999 17:02:44 -0500 Subject: CONTEST: PyWin crashes with pure Python code! References: <816010E2456BD111A48700805FBBE2EEFDF5A3@ex-quebec-u1.baan.com> Message-ID: <#rQuwel9#GA.224@cpmsnbbsa03> I am on a PIII 450 with 128 ram. and am unable to reproduce a crash, even with greatly increasing the size of Christian's file. I am starting to suspect some sort of dll mismatch. Can you tell me: a. What service pack you are running. b. Whether you have VC++ installed. and if so, do you have any of the service updates installed? Gaetan Corneau wrote in message news:816010E2456BD111A48700805FBBE2EEFDF5A3 at ex-quebec-u1.baan.com... > It crashes on my IntelliStation (twin PIII 500Mhz, 256Mb RAM, 5Gb free disk > space). > > The last trace I get is "818800". I tries it on a 50Mb file I generated, and > it worked fine. > > I don't understand... > ______________________________________________________ > Gaetan Corneau > Software Developer (System Integration Team) > BaaN Supply Chain Solutions > E-mail: Gaetan_Corneau at baan.com > Compuserve: Gaetan_Corneau at compuserve.com > ICQ Number: 7395494 > Tel: (418) 266-8252 > ______________________________________________________ > "Profanity is the one language all programmers know best" > From mkrisch at radiata.com Wed Sep 22 18:48:01 1999 From: mkrisch at radiata.com (Mark Krischer) Date: Thu, 23 Sep 1999 08:48:01 +1000 Subject: lists and append, and loop iteration References: <37E8860B.C024C4F8@radiata.com> <14312.40896.797841.421283@gargle.gargle.HOWL> Message-ID: <37E95CA1.7EAB9685@radiata.com> Charles G Waldman wrote: > I would write > > dict['new_key'] = dict.get('new_key',[]) + [new_value] thanks, that's just the kind of elegant trick i was looking for! --mk From jasbahr at NOSPAM.origin.ea.com Mon Sep 27 20:00:52 1999 From: jasbahr at NOSPAM.origin.ea.com (Jason Asbahr) Date: 27 Sep 1999 19:00:52 -0500 Subject: More Positions Available for Python Game Programmers Message-ID: Electronic Arts (and its subsidiary Origin Systems) is looking to hire talented Python programmers who are interested in working on massively multiplayer online games. Top salaries, benefits, and relocation (to Austin, Texas) are included. Please contact Jeff Anderson of Origin Systems, Inc. at 512-434-6726. Resumes by email are encouraged, please send them to: janderson at origin.ea.com -- Jason L. Asbahr Origin Systems, Inc. jasbahr(@)origin.ea.com < Remove anti-spam text to reply. > From doughellmann at home.com Thu Sep 9 20:09:07 1999 From: doughellmann at home.com (Doug Hellmann) Date: Fri, 10 Sep 1999 00:09:07 GMT Subject: Python example: possible speedup? References: <87puztv2gt.fsf@pc-hrvoje.srce.hr> <87aeqw2vrc.fsf@pc-hrvoje.srce.hr> Message-ID: <37D84D5A.B2562946@home.com> Hrvoje Niksic wrote: > > Timothy R Evans writes: > > > I had a very similar problem, I have this University project to > > visualise the Debian package file, so I needed to read in into > > useful language (C was discard as fast but too much work). The read > > tiem was really slow, so I only do it once. After loading the file > > and creating a data structure that stores the information, I pickle > > it. Read time drops by an order of magnitude. Not so applicable to > > your situation possibly but you could use it if you don't install > > new packages often. > > Thanks for the suggestion. However, I do install new packages often, > so that's not really an option. Probably not every time you run your app, though. You could parse the data, pickle the results, and keep up with the mod times on the two files. If the source data is newer than the pickle database you have to update the pickle data. That would slow down some of your processing, but in most cases would still let you take advantage of the faster pickle version. Doug From gmcm at hypernet.com Fri Sep 3 10:19:14 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 3 Sep 1999 09:19:14 -0500 Subject: NAN In-Reply-To: <37CEFF67.B487F3FF@kla-tencor.com> Message-ID: <1275758007-72447266@hypernet.com> Ken Koller wrote: > Is there a constant defined as NAN for floats? > > I noticed that 1.0E500 returns the string '1.#INF' and -1.0E500 > returns '-1.#INF' I was just wondering if you could do something > like: > > f = math.NAN > f = math.INF > f = -math.INF > > etc... > > I realize that NAN is implementation dependent and that Python > shouldn't care about the IEEE type implementations. > > Seems like it could be useful to have a constant defined for these. Some months ago the Timbot (aka Tim Peters) posted some truly esoteric code that tries to discover what these are for your platform and C library. Deja news or the search at python.org should find it. - Gordon From bowman at montana.com Fri Sep 10 23:04:12 1999 From: bowman at montana.com (bowman) Date: Fri, 10 Sep 1999 21:04:12 -0600 Subject: high school programming & python References: Message-ID: <9DjC3.639$JG2.4104@newsfeed.slurp.net> Les Schaffer wrote in message news:m2hfl2y2tt.fsf at netmeg.net... > 2.) the AP tests which kids take, according to her, require for > advnace placement in a comp sci class that they know the basics of C++ > up through objects. Among my co-workers are several recent graduates and a former college instructor. According to them, at the local university, a language other than C or C++ is a prerequisite for the C courses. I can't speak for the AP tests, but it would seem to me a good grounding in an excellent didactic language like Python would be more valuable than a half baked exposure to C++. My first exposure was Fortran IV thirty five years ago, and some days I don't think I'm even ready for C++ yet. From davidopp at megsinet.net Sun Sep 5 14:22:54 1999 From: davidopp at megsinet.net (David Oppenheimer) Date: Sun, 05 Sep 1999 14:22:54 -0400 Subject: V - GUIDO !!! was Re: Pirate -> RAD References: <7qno38$6uk$1@news.is.co.za> <37D17998.5CF4@warande.uu.nl> <37D1F135.6F242B93@megsinet.net> <936540416snz@vision25.demon.co.uk> Message-ID: <37D2B4FD.9F6D9098@megsinet.net> Dear Phil, I don't know quite how such a program could utilize Parrot. I am not averse to making such a program as V - GUIDO compatible with the other major GUI tool kits such as Tkinter and PyGtk except for the fact that this would involve a tremendous amount of additional work for each GUI tool kit (Unless Parrot does some kind of "magic" so that I wouldn't even have to concern myself with that). There are different looks and feels to all of the GUI tool kits out there. How would Parrot account for these differences? Would a user of V- GUIDO choose which kind of code they wanted the program to output, and then a Paxo file with an argument for that type of output be sent to Parrot and then Parrot would do this on its own? I don't know how much additional work would be involved to maintain compatibility as the tool kits themselves change. It would help to understand exactly how Parrot works and how Paxo works. I am not averse to incorporating useful existing code into this program just as long as it makes things easier not just more complicated. The advent of a WYSIWYG GUI tool such as V - GUIDO will be a great advance and may help to give Python a bigger following. The trick will be to make it easy enough for a beginner to use and at the same time powerful enough for an advanced programmer to want to use it too. I have been looking at several GUI makers out there to figure out which features would be good to include. Would it be appropriate to bring the the GUI SIG back from the dead and make this a formal ongoing project? Instead of arguing about which GUI tool kit is better, we could focus our energies on creating V - GUIDO and making it compatible with all of the major GUI tool kits. Sincerely, David Oppenheimer "Any Sufficiently Advanced Technology Is Indistinguishable From Magic." - Arthur C. Clarke P.S. Lets make some magic happen ! Phil Hunt wrote: > In article <37D1F135.6F242B93 at megsinet.net> > davidopp at megsinet.net "David Oppenheimer" writes: > > I have an idea for creating a WYSIWYG GUI builder for Python that > > will allow you > > to create slick looking GUI's just by dragging and dropping elements into a > > visual > > design space that will output code into wxPython. > > Why just wxPython? Python has lots of GUI toolkits, e.g. Tkinter, > PyGtk, etc. Why not work with all of them? > > > After a user was satisfied > > with > > the appearance of the GUI, the program would output the code into > > wxPython code > > which would be seamlessly integrated with the code that had already > > been written inside of a design space (make it so that it would > > work flawlessly as either a > > component of the major IDE's including PythonWin, IDLE, Python in > > a DOS box or > > have it callable from a command line). It will also be able to > > take written > > code > > and show a preview of what your GUI would look like without having > > to first save the program and run it thru the Python interpreter. > > This would allow you to > > instantly see the effect of changes made to your code. It would be > > awesome to > > integrate it seamlessly with the PythonWin IDE and also be callable > > from the > > command line in IDLE or Python in a DOS box. > > > > If you would like to join with me in this creative endeavor > > (code name V - GUIDO which stands for Visual Graphical User > > Interface Development Optimizer), I would be happy to share the > > details with you. > > I like the name! > > > Sincerely, > > > > David Oppenheimer > > > > P.S. This is still just in the brainstorming stage right now. I am doing > > conceptual planning right now; features, how it should look, how it should act, > > etc. I would ask anyone who is serious about doing such a project to join > > forces > > with me and see if we can make something happen. > > I think there is a lot of potential for V-GUIDO to work with Parrot. > > For example, V-GUIDO could use Parrot's XML output format > (i.e. ``Paxo'' format) as its file format. > > This would mean that V-GUIDO wouldn't have to include a code generator; > it could use Parrot's. Also, V-GUIDO would be able to produce code > for any of Parrot's backends; these will include Tkinter and wxWindows, > and other Python and non-Python backends. > > e.g: > > [V-Guido] --> (Paxo file) --> [Parrot] --> (Python/wxWindow code) > or > --> (Python/Tkinter code) > or > --> other formats > > Alternately V-GUIDO and Parrot could both use the Glade XML format. > > -- > Phil Hunt - - - - - - - - - philh at vision25.demon.co.uk > - Linux will be 8 years old on 17th September! See: - > http://www.vision25.demon.co.uk/prog/linuxbirthday.html From phd at emerald.netskate.ru Wed Sep 1 05:13:31 1999 From: phd at emerald.netskate.ru (Oleg Broytmann) Date: Wed, 1 Sep 1999 13:13:31 +0400 (MSD) Subject: CGI speedup strategies In-Reply-To: <37CCE7C9.D340BBF5@strs.co.uk> Message-ID: On Wed, 1 Sep 1999, Ian Clarke wrote: > I have always been dissatisfied with the way that CGI scripts work, Many people feel simillary... > loading the interpreter and then the script, not to mention making SQL > connections, loading databases etc - and this for *each and every* > access. Ok, software like modpython (or is is pyApache?) allieviates It is PyApache, and there is hing called httpdapy. > some of this overhead, but it is still far from ideal. > > Has anyone tried actually implementing a Python webserver which just > starts a new thread and runs a piece of Python code in it every time > someone makes a HTTP request? This server could then cache any objects > (such as files, or SQL connections) in memory to be used by any Python > scripts (this would obviously require all code to be thread-safe). Have you heared of Medusa? Zope? Seems Zope is THE answer for ll your questions. www.zope.org. > Can anyone think of any problems with this technique? > > Ian. > > -- > Ian Clarke - http://www.gnu.demon.co.uk/ > "A subversive is anyone who can out-argue their government" Oleg. ---- Oleg Broytmann http://members.xoom.com/phd2/ phd2 at earthling.net Programmers don't die, they just GOSUB without RETURN. From skip at mojam.com Mon Sep 13 18:02:35 1999 From: skip at mojam.com (Skip Montanaro) Date: Mon, 13 Sep 1999 17:02:35 -0500 (CDT) Subject: List to string? Docstrings? In-Reply-To: References: Message-ID: <14301.29819.582168.558337@dolphin.mojam.com> Fran?ois> 1) For converting a string into a list, I used: Fran?ois> chars = list(text) Fran?ois> For getting back the string from the list, I tried: Fran?ois> import operator Fran?ois> text = reduce(operator.concat, chars) The normal idiom for smashing a list into a string is import string text = string.join(chars, "") but your method is just as effective. The operator module and the reduce builtin function are new additions to Python relative to the string module. I think that would explain why most people use string.join instead of your solution. Fran?ois> 2) I still miss the purpose of __doc__ strings. It's true Fran?ois> that I can write: Fran?ois> print module.__doc__ Fran?ois> print function.__doc__ Fran?ois> and sometimes get useful information from these. But what Fran?ois> would I be loosing, for my own things, if I was using mere Fran?ois> `#' comments instead? Only that you deny other programs the opportunity to present you with useful information. For example, IDLE could presumably import a module and display an object's doc string in a popup window if you asked for it. It couldn't do that with comments. Similarly, batch-oriented documentation tools can assemble a bunch of doc strings together into a more-or-less cohesive whole based upon traversing a module's dict recursively, emitting the whole mess as HTML, LaTex, nroff or what-have-you. There is a tool floating around called gendoc that does this sort of thing I believe. Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/~skip/ 847-971-7098 | Python: Programming the way Guido indented... From aahz at netcom.com Wed Sep 8 21:39:50 1999 From: aahz at netcom.com (Aahz Maruch) Date: 9 Sep 1999 01:39:50 GMT Subject: Inspecting long running programs References: <19990909111034.12856@nms.otc.telstra.com.au> Message-ID: <7r7356$3b4@dfw-ixnews8.ix.netcom.com> In article <19990909111034.12856 at nms.otc.telstra.com.au>, Greg McFarlane wrote: > >If the program is not running Tkinter, but using select.select say, >you could create a "debug socket" which would listen for connections >and eval() any input received on that socket. This would be a little >more work that the Tkinter method, but would give the same >functionality. asyncore (which Medusa is built on) includes this functionality. It can be kind of trippy to just telnet to a blind socket and get a Python interpreter session. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From bwarsaw at cnri.reston.va.us Fri Sep 17 15:16:26 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Fri, 17 Sep 1999 15:16:26 -0400 (EDT) Subject: JPython and groupdict? References: <7rtn97$rju$1@news1.news.iol.ie> Message-ID: <14306.37770.230274.373916@anthem.cnri.reston.va.us> >>>>> "w" == war writes: w> I wonder can anyone let me know if I can get the following w> Python to run in JPython: groupdict() is in the current CVS snapshot of JPython, and will be included in the next beta release (which will probably be out sometime next week). Also, JPython questions are best asked on the mailing list jpython-interest at python.org. See for details: http://www.python.org/mailman/listinfo/jpython-interest -Barry From menion at mindless.com Wed Sep 29 20:26:10 1999 From: menion at mindless.com (joshua M. Schmidlkofer) Date: Wed, 29 Sep 1999 18:26:10 -0600 Subject: Python, MySQL, and MySQLmodule.c 1.4 - Python Version. Message-ID: <37F2AE22.AC3505FE@mindless.com> We are trying - mind you with no success - to get Python to speak properly with MySQL, under the Redmond curse [WinNT 4.0]. Can anyone help me? If windows were a knife I would be badly injured and bleeding because the lack of any form of proper handle. thanks, Joshua We are using: MySQL - the registed version 3.22.xx? The latest as of Sept 1, 99 Python - 1.52 MySQLmodule.c - 1.4, the one from the Mysql.[com||org] website on the contrib page. The author says that under NT, 'good luck'. However, I am a glutton for punishment. Nt4.0, with SP5. [that's probably it, it's probably a stupid ploy by M$ to get people to use VB]. From tim_one at email.msn.com Sat Sep 11 16:42:57 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 11 Sep 1999 16:42:57 -0400 Subject: Python or Java or "X" from me and my little job In-Reply-To: <37DAA2AB.1ABFA8E9@megsinet.net> Message-ID: <000a01befc96$3a9834a0$6aa2143f@tim> >>> 2)Should I go with JAVA instead? [Gordon McMillan, communicating Stiff Truth with hirsute precision] >> Not unless you shave with a belt sander and use a gasoline-based >> aftershave. [David Oppenheimer] > Q: Are trying to point out that Java isn't the right tool for the job > or are you implying that Java is for insane people or both? Writing "lightweight sysadmin" tools in a language desiged to prevent you from making any changes to the system would be certifiably insane. I happen to know that Gordon does shave with a belt sander (see his Java book), but his aftershave is extract of cayenne pepper in a base of cinnamon oil. but-only-because-it's-cheaper-than-gasoline-ly y'rs - tim From bob at horvath.com Tue Sep 28 23:03:54 1999 From: bob at horvath.com (Bob Horvath) Date: Wed, 29 Sep 1999 03:03:54 +0000 Subject: re vs. sgmllib (was: Moving from Perl to Python) References: <000001bf088c$2708e040$ec2d153f@tim> Message-ID: <37F1819A.DD5CF81@horvath.com> Tim Peters wrote: > [Jon Fernquest] > > Since regular expressions are just a short-hand way of specifying > > (practically only *some*) regular languages whereas finite state > > machines can specify any regular language the next logical step > > would be a set of finite state tools like those that Xerox sells > > (for several thousands of dollars I might add). > > Then I hope we can skip the next logical step and leapfrog illogically to a > real parser . Part of the problem here is that what people want to > parse these days-- from programming language fragments to SGML --isn't > regular. That doesn't stop them from trying to do it with regexps, and > input-sensitive bug-ridden code is the result. Heck, most people find it a > challenge to write a correct regexp to match a Python string -- or even a C > /**/ comment. Not that regular languages aren't useful, but I expect their > appropriate non-trivial applications will always be a wizard art. I have not had the time to check out the Python parsers as much as I would like, but I have played around with JavaCC and liked it. If there were something in Python that was similar to JavaCC, this would be very nice. None of the Python parsers seem to jump out as being "the one to use". Perhaps I need to spend some more time - a nudge in the right direction would be appreciated? > > Note that Perl is in the process of adding recursive "regexps". > > the-mind-boggles-ly y'rs - tim Recursive regexps? Yikes! From robin at jessikat.demon.co.uk Tue Sep 14 06:48:25 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Tue, 14 Sep 1999 11:48:25 +0100 Subject: Different Shaped Windows? References: <37DE0F7E.714FD6F7@megsinet.net> Message-ID: In article <37DE0F7E.714FD6F7 at megsinet.net>, David Oppenheimer writes >Dear Group, > >From a posting in another newsgroup, I am told that you can: > >===================================== >"create windows that have different shapes than the >ordinary "square" ones. You can do than thanks to the "regions" : What >does >that mean? >In Win32 you can define regions and than assign them to already created >windows. For example: > >SetWindowRgn(handle, CreateEllipticRgn(0,0,100,200), true) > >will create an elliptic window. MSDN has more info about regions. You >can apply all sorts of operations to your regions like intersection, >addition, etc. to obtain different shapes. >================================================= > >Question is: Can this same task (creating a non rectangular window) be >accomplished with any of the GUI toolkits available to Python such as >Tkinter or wxPython? > >David O. > > > there's a Tk extension called TkTrans which works with 8.0.5 at least to create shaped toplevels. -- Robin Becker From gmcm at hypernet.com Tue Sep 21 17:01:05 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 21 Sep 1999 17:01:05 -0400 Subject: Difficulty with `cmp', still In-Reply-To: Message-ID: <1274174979-62990182@hypernet.com> Fran?ois Pinard wrote: > Hi, people. I feel a bit opaque, as I cannot quickly get this > code to work: Oh no, don't feel opaque. > # Return the comparison value of two versions, of two file names > # with versions. > def compare_versions(a, b): > a0, a1, a2, a3, a4 = _weights(a) > b0, b1, b2, b3, b4 = _weights(b) > print dir(__builtins__) > cmp = __builtins__.cmp # because of `import cmp' > above return cmp(a0, b0) or a1 - b1 or a2 - b2 or a3 - b3 or > a4 - b4 > > > When used in batch, I get "AttributeError: cmp". When used > interactively, everything seems to work fine, and > `compare_versions' does what it should. The `print' statement is > a mere try to understanding the problem, and it has the effect of > adding this line to the output, just before the traceback: > > > ['clear', 'copy', 'get', 'has_key', 'items', 'keys', 'update', > 'values'] > > > If I do the same `print' interactively, I get (refilled in this > message): > > > ['ArithmeticError', 'AssertionError', 'AttributeError', > 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', > 'FloatingPointError', 'IOError', 'ImportError', 'IndexError', > 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', > 'NameError', 'None', 'NotImplementedError', 'OSError', > 'OverflowError', 'RuntimeError', 'StandardError', 'SyntaxError', > 'SystemError', 'SystemExit', 'TypeError', 'ValueError', > 'ZeroDivisionError', '_', '__debug__', '__doc__', '__import__', > '__name__', 'abs', 'apply', 'buffer', 'callable', 'chr', 'cmp', > 'coerce', 'compile', 'complex', 'delattr', 'dir', 'divmod', > 'eval', 'execfile', 'exit', 'filter', 'float', 'getattr', > 'globals', 'hasattr', 'hash', 'hex', 'id', 'input', 'int', > 'intern', 'isinstance', 'issubclass', 'len', 'list', 'locals', > 'long', 'map', 'max', 'min', 'oct', 'open', 'ord', 'pow', 'quit', > 'range', 'raw_input', 'reduce', 'reload', 'repr', 'round', > 'setattr', 'slice', 'str', 'tuple', 'type', 'vars', 'xrange'] > > > So far that I know, I'm not playing tricks nor trying to more > clever than Python, I would think my code is rather straight. > I'm surely not trying to play with the builtin lists, the most I > do is trying to get the `cmp' from it. I do not see how or why > the builtin list get reduced when my code is executed in batch, > and why `cmp' is disappearing. Would someone have a suggestion > or an idea of what I should study to grasp what is happening? It's a wrinkle in the space-time continuum that interactive is smart enough to navigate, but batch mode falls right into. You need to: import __builtin__ and use __builtin__.cmp This is the real source of the builtins (it's a module). __builtins__ is a dictionary. Recall things like eval and exec, where you can pass a globals dict. If this dict is empty, Python will stuff an entry "__builtins__" into it for the eval'ed / exec'ed code to use. I'm not really sure of the sequence of events here, but apparently the shortcut hasn't been properly prepared when you try to use it! BTW, I fell for it, and voluteered to carry out the BDFL's "suggestion". - Gordon From pj at sgi.com Thu Sep 9 18:12:59 1999 From: pj at sgi.com (Paul Jackson) Date: 9 Sep 1999 22:12:59 GMT Subject: question about the safety of os.popen() References: <37D823B9.9D4337EE@dnr.state.ak.us> Message-ID: <7r9bdb$3116b@fido.engr.sgi.com> |> mail = os.popen("/usr/sbin/sendmail -t", "w") |> |> I believe that this method of using os.popen() is relatively |> safe since it does not pass any user input directly to the This is not safe, if it might be run by a setuid or setgid program. >From my internal SGI mail archives, discussing a quite unrelated piece of code, comes the following ancient (circa 1994) paragraph, that happens to explain the problem: |> In the original bug report, and this is popularly known, |> you set IFS='/:' and run vi, then do a ``preserve'' command |> which causes vi to run expreserve. expreserve in turn does |> a popen() to send mail to the user. Becauses popen does |> something like ``/bin/sh ...'' the IFS goes into effect and |> turns ``/usr/bin/mail'' into something morally equivalent to |> ``usr bin mail''. The bad guy has a shell script called |> ``usr'' in the local directory that then gets run with the |> permissions of expreserve (setgid sys, big deal!). As I recall, you end up wanting to purge the environment of more than just IFS before safely invoking a subshell (os.popen or os.system) See also os.fork(), os.execl(), and the Python source popen2.py, for safer alternatives and implementation ideas (mainly, avoid the intermediate shell). Now if you not concerned with safe setuid/gid usage, then I believe its quite safe - the user can't get anymore done by confusing your code than they could do directly anyway. -- ======================================================================= I won't rest till it's the best ... Software Production Engineer Paul Jackson (pj at sgi.com; pj at usa.net) 3x1373 http://sam.engr.sgi.com/pj From jam at quark.emich.edu Thu Sep 16 15:46:20 1999 From: jam at quark.emich.edu (Jeff) Date: Thu, 16 Sep 1999 15:46:20 -0400 Subject: cgi post question In-Reply-To: ; from Felicia Neff on Thu, Sep 16, 1999 at 12:08:23PM -0400 References: Message-ID: <19990916154620.B8285@quark.emich.edu> On Thu, Sep 16, 1999 at 12:08:23PM -0400, Felicia Neff wrote: > Yes, this is yet another newbie question: > > I am trying to write a CGI script that takes input from a POST, modifies > some of the input and then POSTs that info to another CGI script. I know > that perl has a function that will do this. Is there such a function in > python (and if it is do_POST() from the CGIHTTPServer module, is there any > more documentation besides that at > http://www.python.org/doc/current/lib/module-CGIHTTPServer.html?)? > > Thanks -- Felicia > hmm.. well, I can't offer any code that I've written to do this, but my suggestion would be to use the built-in libraries as much as possible. if you are using cgi scripts via apache or something, most of the work is already done for you-- iirc, you get the POST data on 'sys.stdin'.. you can simply call 'sys.stdin.read()' and pass it into the FieldStorage class or something. my advise would be to get something working in it's simplest form before adding features like posting the results of one form into another. questions: what are you trying to accomplish? a poll system? some kind of order system? why do you need to modify the data and pass it to another module? can you do it all inline to simplify the process a little? other than the newsgroups, the documentation on python.org is indeed 'all' of the documentation.. what specifically about using that module do you not understand? is the problem with the module itself or with how it's documented? regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From bthomas at trey-industries.com Tue Sep 14 13:50:38 1999 From: bthomas at trey-industries.com (Ben Thomas) Date: Tue, 14 Sep 1999 17:50:38 GMT Subject: Python or Java or "X" from me and my little job References: <37DA8D01.3D6616A@trey-industries.com> <37DD356F.86D56591@trey-industries.com> <7rlsvn$ct0$1@ites.inria.fr> Message-ID: <37DE8A37.9406E040@trey-industries.com> Wow! I better get some knowledge on shell scripts too. Good grief, starting out at square one again. Well, I almost have the script written in Python, after that I will write a shell script and compare it. Thanks for the help. Ben Cedric Adjih wrote: > Ben Thomas wrote: > > Actually I just want to > > 1)get current date and come up with its string like: 01251999 > > 2)zip some files and name the archive 01251999 > > 3)ftp the archive off site > > > > this is my first task but I know there will be others. It isn't hard to code > > I am just new to Python. > > Well if all you need to do is that simple, maybe sticking > with shell scripts would do. For instance: > > #! /bin/sh > FILENAME=archive-`date +"%Y-%m-%d"`.zip > FILELIST=`find /home/mydir -type f -mtime 1` > zip -r $FILENAME $FILELIST || exit 1 > ncftpput -u thomas -p MYPASSWRD ftp.myserver.net /home/thomas $FILENAME > > You need to read the man pages for each of the programs, and are better > using the standard "tar" + "gzip" if you compress files for Unix only > (using something like "tar -czvpf $FILENAME $FILELIST") > You can do more complicated change checking using 'md5sum', 'sort', > 'comm' etc... > Only after that you might want to switch to Python :-) > > -- Cedric > Not speaking for INRIA. From fredrik at pythonware.com Wed Sep 29 05:19:02 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 29 Sep 1999 09:19:02 GMT Subject: What GUI-lib to use References: <37F1D710.47A82D23@bibsyst.no> Message-ID: <00a301bf0a5b$b0acce80$f29b12c2@secret.pythonware.com> Thomas Weholt wrote: > Could Tk get a more modern look perhaps and solve all our problems? maybe, but that depends on what "more modern look" means. From skip at mojam.com Thu Sep 16 00:31:23 1999 From: skip at mojam.com (Skip Montanaro) Date: Wed, 15 Sep 1999 23:31:23 -0500 (CDT) Subject: TreeCtrl Object (win32ui) In-Reply-To: <5llna74j55.fsf@eric.cnri.reston.va.us> References: <7rm9bb$1rh$1@nnrp1.deja.com> <7ro8ql$eao$1@nnrp1.deja.com> <5llna74j55.fsf@eric.cnri.reston.va.us> Message-ID: <14304.29339.755635.920928@dolphin.mojam.com> Guido> Yes. IDLE 0.5 has a TreeWidget module that works with Tkinter. Guido> It is not in any distribution yet, you need to get it via the CVS Guido> archives, see http://www.python.org/download/cvs.html. IDLE is Guido> in Tools/idle/. Just in case you have already linked up to the CVS repository and it doesn't say anything in the cvs.html page (I'm on a slowish modem at the moment, so can't be bothered to check and will forget by tomorrow morning), be sure you use the -d flag to insure you get any recently created directories, e.g.: cvs update -d . Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/~skip/ 847-971-7098 | Python: Programming the way Guido indented... From greg.ewing at compaq.com Tue Sep 28 17:06:45 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Wed, 29 Sep 1999 09:06:45 +1200 Subject: Tkinter "scrollregion" verbosity References: <19990918073158.A171346@vislab.epa.gov> <19990920150017.42437@nms.otc.telstra.com.au> Message-ID: <37F12DE5.B4E35B1B@compaq.com> Greg McFarlane wrote: > > Maintaining this list across versions of Tk (and Blt > and Tix and ...) would become a nightmare, so "always a string" is > probably as good as you'll get :) Methods could be provided for commonly used non-string attributes. Should be, I would say. Also, how about variants of cget() which return different types, e.g. cgeti() for getting integer attributes, to fill any gaps in the set of methods. Greg From ovidiu at cup.hp.com Fri Sep 17 19:18:46 1999 From: ovidiu at cup.hp.com (Ovidiu Predescu) Date: Fri, 17 Sep 1999 16:18:46 -0700 Subject: Any good debuggers for Python? (was Re: using python debugger (pdb) inside emacs debugger mode ...) In-Reply-To: Your message of "Fri, 17 Sep 1999 16:51:06 EDT." <19990917165106.A97011@vislab.epa.gov> Message-ID: <199909172318.QAA17505@hpcll563.cup.hp.com> On Fri, 17 Sep 1999 16:51:06 -0400, Randall Hopper wrote: > |This is in emacs 20.3, but emacs 20.4 has the same gud.el > > I'd like one for Emacs myself (ala gdb/dbx with source tracking). GNU if > possible but I'll do XEmacs if needed. However, no luck with the brief try > I gave PDB/pdb.el/XEmacs. User friendly PDB is not (see attached for your > amusement). I'm using pdb with Xemacs here with no problem. Is a little different from the gdb interface but is definitely more usable that pdb in command line. I'm using Xemacs 21.1.6 with pdb.el that comes with it. I would still like to have a pdb-mode for source files, similar with gdb-mode, but I guess the gdb-mode uses the gdb annotations to be able to do that, which pdb doesn't have. A better thing might be to have gdb support debugging Python programs, just like it supports the other languages, but this is a different topic. Greetings, Ovidiu -- Ovidiu Predescu http://andromeda.cup.hp.com/ (inside HP's firewall only) http://www.geocities.com/SiliconValley/Monitor/7464/ From AKiss at GEOMETRIA.hu Wed Sep 8 04:11:54 1999 From: AKiss at GEOMETRIA.hu (Kiss, Arpad) Date: Wed, 8 Sep 1999 10:11:54 +0200 Subject: 1.5.2 NT install question(s) Message-ID: <01BEF9E2.947FA130@exchange1.geometria.hu> Hi, Try to set the TK_LIBRARY and TCL_LIBRARY. Arpad Mark Jackson wrote in message news:<7r3hib$24f$1 at news.wrc.xerox.com>... > I've done this twice recently and encountered problems both times. > > On a fresh system (never had Python or Tcl/Tk) things (for example, > PySol) seem to work, but whenever I use Tkinter (specifically, when > _tkinter is imported) I get a warning box about not being able to find > tcl80.dll in the specified path. (tcl80.dll is present, in Program > Files\Tcl\bin.) What's wrong, and how do I put it right? > > On a system where 1.5.1 (with Tcl/Tk) had previously been installed, I > carefully uninstalled both before installing 1.5.2. Here both "import > _tkinter" and "inport Tkinter" are OK, but Tkinter._test() yields: > > TclError: Can't find a usable init.tcl in the following directories: > {} ./lib/tcl8.0 D:/tc18.0/library {D:/Program Files/library} > > This probably means that Tcl wasn't installed properly. > > (init.tcl is present, in Program Files\Tcl\lib\tcl8.0.) What's wrong, > and how do I put it right? > > Thanks in advance. Sorry to be asking such trivial-seeming questions, > but I found nothing helpful through python.org. And I haven't dealt > with the innards of NT enough for its design coherence to become > manifest (yeah, right). > > -- > Mark Jackson - http://www.alumni.caltech.edu/~mjackson > Spend the optimal amount of time on each decision > and pretty soon you run out of life. > - Steven Waldman > > > > -- > http://www.python.org/mailman/listinfo/python-list > From warren at nightwares.com Fri Sep 10 12:40:37 1999 From: warren at nightwares.com (Warren 'The Howdy Man' Ockrassa) Date: Fri, 10 Sep 1999 11:40:37 -0500 Subject: And now for something completely boneheaded... References: <37D623A2.DC09F0CC@nightwares.com> <37D9200A.19E5277B@home.com> Message-ID: <37D93485.50B4893C@nightwares.com> "Eric B." wrote: > try: > >>> import sys #or import > >>> dir(sys) # or dir() Got 'er, thanks. :) When I tried (as suggested by others, in addition to your posting) module.__dict__ lo and behold, those documentation strings which follow functions made a *lot* more sense...! Using a language which *encourages* internal documentation like that is dern near enough to bring a tear to my eye... Beautiful... --WthmO From wtanksle at dolphin.openprojects.net Thu Sep 2 13:39:40 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Thu, 02 Sep 1999 17:39:40 GMT Subject: language interpreters/ interpreted languages weaknesses? References: <7qi3q3$n1d$1@nnrp1.deja.com><37CCE10D.D07D023B@strs.co.uk><7qjgq8$k1i$1@newshost.accu.uu.nl> <14285.38262.884171.416195@dolphin.mojam.com> <7qm25l$ig9$1@nnrp1.deja.com> Message-ID: On Thu, 02 Sep 1999 14:38:48 GMT, Mr Kelvin Lee wrote: >btw... are 'scripting languages' the same things as 'interpreted >lanaguages?? No. Scripting is the act of directing something's actions; thus calling something a scripting language implies that it's used for directing something outside of the language. In the old days, the only way to script an application was for the application to include its own scripting language. Nowadays, any language can be used to script, and we refer to languages which are designed for that purpose as scripting languages. Python will not lose any of its ability to script when someone makes a compiler for it. And BTW, the definition "if you can't change a running program then it's compiled..." is faulty -- there are many interpreted languages you can't change at runtime, and there are many Lisp compilers. >KL. -- -William "Billy" Tanksley From bthomas at trey-industries.com Tue Sep 14 11:31:04 1999 From: bthomas at trey-industries.com (Ben Thomas) Date: Tue, 14 Sep 1999 15:31:04 GMT Subject: python call external program (WHAT THE?!) References: <37DE6156.FD4384C6@trey-industries.com> <37DE68B7.49D0C5A5@mach.uni-karlsruhe.de> Message-ID: <37DE6980.2FC85A6F@trey-industries.com> I just tried but putting the batch file in three places on a drive. The I tried them all. system('d:\mybat.bat') = ok system('d:\data\mybat.bat') = ok system('d:\data\vacman\mybat.bat') = fails, it works fine from DOS prompt! what gives? Ben Andreas Cardeneo wrote: > Ben Thomas wrote: > > > > very simple question: > > > > What would I do to have Python execute something from the DOS command > > line. I am very new to python but I bet it is in a moudule but don't > > know the command or the modules to look in. I want to > > > > dir >%myvar.txt > > > > #this code would run dir from the command line and pass the var "myvar" > > , dir would dump a listing of the files into a text file called xxxx.txt > > > > pointers? > > > > Ben > > Hi Ben, > > you should use the system() function from the "os" module. > > os.system("dir *.txt") shows all files in the current directory matchin > *.txt. > The function returns the exit code. > > Bye, > Andreas > > -- > Andreas Cardeneo Universit?t Karlsruhe (TH) > Tel: +49 721 608-4576 Institut f?r F?rdertechnik und Logistiksysteme > Fax: +49 721 75 83 78 Hertzstra?e 16 - 76187 Karlsruhe > eMail: Andreas.Cardeneo at mach.uni-karlsruhe.de From george.russell at clara.net Mon Sep 27 21:40:23 1999 From: george.russell at clara.net (George Russell) Date: Tue, 28 Sep 1999 01:40:23 GMT Subject: NewBie - GetOpts Message-ID: <37f0192c.6314994@news.clara.net> I'm trying to get a filename passed in as an argument - ie myprog -f myfile So far, I have imported getopt optlist=getopt.getopt(sys.argv[1:],'f:') which reads the switch and the argument into a data structure from which I can't actually access (since I don't even know what kind of structure - a sequence? a list? a tuple? an array / vector?)(what is a tuple?) I'm new to python, and things have been going very well so far. print optlist gives ([('-f','filename')],[]) I think this has two lists, one empty. Inside what data structure? Can anyone show me howto access the data? Or point me to the right place in the tutorial / library reference, or some example code. Thanks. George Russell From pinard at iro.umontreal.ca Thu Sep 23 12:50:17 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 23 Sep 1999 12:50:17 -0400 Subject: Sequence traversal In-Reply-To: Sven Havemann's message of "Thu, 23 Sep 1999 17:44:21 +0200" References: <37EA4AD5.1B54A185@tu-bs.de> Message-ID: Sven Havemann writes: > List traversal is elegant in python! - But what if I want to step > through two sequences in parallel? Tee hee! A question I know how to answer! :-) :-) > I assume that indexing in a list l is not too efficient (O(log len(l))?), > while stepping through l using 'for i in l' will certainly be O(1). Indexing is efficient. A list, despite its name, is allocated in a memory array, so any item is accessed in constant time. When the list grows, the array might sometimes be reallocated -- some extra-space is included at the end to foresee possible further grows. A tuple is also allocated as a memory array, but with no extra-space, because a tuple cannot grow. > l1 = list("Names ") > l2 = [4,2,1,5,3,9] You might like to replace: > for i in range(len(l1)): # not so cool > if l1[i]=='a' and l2[i]==2: print "a and 2 found!" with: if ('a', 2) in map(None, l1, l2): print "a and 2 found!" -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From mcfletch at vrtelecom.com Mon Sep 27 11:34:04 1999 From: mcfletch at vrtelecom.com (Mike Fletcher) Date: Mon, 27 Sep 1999 15:34:04 GMT Subject: PythonWin,Slider control.... In-Reply-To: <7slfak$300@journal.concentric.net> References: <7slfak$300@journal.concentric.net> Message-ID: Well, here's an example, doesn't do anything (I just ripped it out of one of my projects, replacing an OLE control with the slider and calling the CreateWindow method instead of CreateControl. *Mark* The docs for win32ui.CreateSliderCtrl for some reason say to use PySliderCtrl::Create which doesn't exist. The docs for PySliderCtrl correctly name the creation function as CreateWindow (though why it's different from the OLE control I do not know). Feel free to include the (rather trivial) demo below if you would like to do so. Cheers, and hope this helps, Mike (There are wrapping problems in the code, but you should be able to figure those out :) )... 8<_____________________________ exampleslider.py ______________ import win32con, win32ui from pywin.mfc import dialog class MyDialog(dialog.Dialog): ''' Example using simple controls ''' _dialogstyle = (win32con.WS_MINIMIZEBOX | win32con.WS_DLGFRAME | win32con.DS_MODALFRAME | win32con.WS_POPUP | win32con.WS_VISIBLE | win32con.WS_CAPTION | win32con.WS_SYSMENU | win32con.DS_SETFONT ) _buttonstyle = (win32con.BS_PUSHBUTTON | win32con.WS_TABSTOP | win32con.WS_CHILD | win32con.WS_VISIBLE) ### The static template, contains all "normal" dialog items DIALOGTEMPLATE = [ # the dialog itself is the first element in the template ["Example slider", (0, 0, 50, 43), _dialogstyle, None, (8, "MS Sans Serif")], # rest of elements are the controls within the dialog # standard "Close" button [128, "Close", win32con.IDCANCEL, (0, 30, 50, 13), _buttonstyle], ] ### ID of the control to be created during dialog initialisation IDC_SLIDER = 9500 def __init__(self ): dialog.Dialog.__init__(self, self.DIALOGTEMPLATE) def OnInitDialog(self): rc = dialog.Dialog.OnInitDialog(self) # now initialise your controls that you want to create # programmatically, including those which are OLE controls # those created directly by win32ui.Create* # and your "custom controls" which are subclasses/whatever win32ui.EnableControlContainer() self.slider = win32ui.CreateSliderCtrl( ) self.slider.CreateWindow( win32con.WS_TABSTOP | win32con.WS_VISIBLE, (0,0,100,30), self._obj_, self.IDC_SLIDER ) return rc ### if __name__ == "__main__": dia = MyDialog() dia.DoModal() -----Original Message----- From: python-list-request at cwi.nl [mailto:python-list-request at cwi.nl]On Behalf Of BGV Sent: September 26, 1999 11:50 AM To: python-list at cwi.nl Subject: PythonWin,Slider control.... Has anyone managed to generate a window with a slider control in PythonWin using CreateSliderCtrl in win32ui? I can't seem to get it to work. TIA BGV From jam at quark.emich.edu Mon Sep 20 10:22:36 1999 From: jam at quark.emich.edu (Jeff) Date: Mon, 20 Sep 1999 10:22:36 -0400 Subject: CygWin version In-Reply-To: ; from Hirsch, John on Sun, Sep 19, 1999 at 09:44:42PM +1000 References: Message-ID: <19990920102236.A12848@quark.emich.edu> On Sun, Sep 19, 1999 at 09:44:42PM +1000, Hirsch, John wrote: > Sorry to appear so stupid, But if I open an MS-DOS window then install > Doskey it installs OK and works. But if I then start Python in the same DOS > window, Doskey does not seem to work within Python what is my problem.? > I believe what the documentation is referring to is being able to use the cygwin compiled version of 'readline' in the win32 environment, which you ought to be able to find binaries of on the net. readline does what doskey does for DOS-- unlike doskey, however, it allows programmers to hook into it as a generic library, and with the cygwin compiler (a 'gcc' that runs under win32) it can run cross-platform in UNIX and win32 environments. in short, you (probably) need readline ;) hope that helps. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From vdcappel at imec.be Wed Sep 22 10:01:48 1999 From: vdcappel at imec.be (vdcappel at imec.be) Date: Wed, 22 Sep 1999 14:01:48 GMT Subject: Dynamic loading on HP-UX 10 (yet again) Message-ID: <7sang4$98j$1@nnrp1.deja.com> I had a problem with dynamically loading a module compiled with HP's ANSI C++ (aCC) compiler into python. The dynamic loader couldn't find a symbol called __head, and indeed this symbol isn't defined in any library --- I expect a bug in the HP software. However, __head is not even used anywhere, and therefore this patch to Python 1.5.2 works: diff -u Python-1.5.2/Python/importdl.c Python-1.5.2_n/Python/importdl.c --- Python-1.5.2/Python/importdl.c Wed Jan 27 18:53:10 1999 +++ Python-1.5.2_new/Python/importdl.c Wed Sep 22 14:05:03 1999 @@ -725,9 +725,9 @@ shl_t lib; int flags; - flags = BIND_FIRST | BIND_DEFERRED; + flags = /* BIND_FIRST | */ BIND_DEFERRED; if (Py_VerboseFlag) { - flags = DYNAMIC_PATH | BIND_FIRST | BIND_IMMEDIATE | + flags = DYNAMIC_PATH | /* BIND_FIRST | */ BIND_IMMEDIATE | BIND_NONFATAL | BIND_VERBOSE; printf("shl_load %s\n",pathname); } Has anyone else encountered the same problem? Does this patch work for you? For the sake of completeness: $ python Python 1.5.2 (#6, Sep 22 1999, 14:05:17) [C] on hp-uxB Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> $ uname -a HP-UX yeti B.10.20 E 9000/879 unknown Happy, arnie. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From gmcm at hypernet.com Wed Sep 8 17:57:58 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 8 Sep 1999 16:57:58 -0500 Subject: Infinity and you (was Re: Turing Compliant?) In-Reply-To: Message-ID: <1275298483-100087660@hypernet.com> William Tanksley wrote: > On 06 Sep 1999 22:20:33 -0400, Alex wrote: > > >Poor William. First manically flamed on slashdot, > > You noticed! :-) > > That was a pathetic flame, though -- it appeared to be more of a > protest against The System than against myself or my post. What a > rube. My already low opinion of /. went thru the floor when I saw the flame was boosted because it was "humorous". I'd call /. a sports-bar for geeks, but that would be an insult to sports-bars. - Gordon From greg.ewing at compaq.com Mon Sep 6 17:21:28 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Tue, 07 Sep 1999 09:21:28 +1200 Subject: Parrot-0.0.1 References: <935279776snz@vision25.demon.co.uk> <7ps4ma$n06$1@wagner.wagner.home> <935457373snz@vision25.demon.co.uk> <7qh7b6$g9g$1@wagner.wagner.home> <37CEFA88.430F28EA@compaq.com> <37D2F842.2E55763@compaq.com> <37d35d1d.28540328@news.erols.com> Message-ID: <37D43058.F6FA63A3@compaq.com> Robert Kern wrote: > > Umm... Add a self argument to f. Yes, of course, sorry. I must never post untested code, however trivial. I must never post untested code, however trivial. I must never post untested code, however trivial. ... Greg From greg.ewing at compaq.com Thu Sep 30 18:08:51 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 01 Oct 1999 10:08:51 +1200 Subject: Circular refs References: <000001bf0a47$95c5fec0$ce2d153f@tim> Message-ID: <37F3DF73.423A54E@compaq.com> Tim Peters wrote: > > The prime thing that killed adopting lexical > closures was the cyclic trash problem then, and Greg Ewing just bumped into > that again recently in his implementation. Er, my implementation is actually a *solution* to the cyclic trash problem. Greg From nascheme at enme.ucalgary.ca Wed Sep 22 20:33:52 1999 From: nascheme at enme.ucalgary.ca (Neil Schemenauer) Date: Thu, 23 Sep 1999 00:33:52 GMT Subject: Garbage Collection in Python - current status of issue? References: <37E8ECAD.54CEA947@strs.co.uk> Message-ID: Ian Clarke wrote: >The FAQ (and related pages), however, while pointing out what the >various arguments and counter-arguments are, do not indicate whether >there is any ongoing work in this area - so is there any ongoing work in >this area? What is the current status of this issue? I have a patch for Linux (it probably works on other Unixes too): http://www.acs.ucalgary.ca/~nascheme/python/gc.html I've been using GC with Python for a while now. It works fine for me. I haven't had the time (or the interest) to do a Windows port yet. Maybe if someone requests it. Neil From ivnowa at hvision.nl Wed Sep 22 04:44:28 1999 From: ivnowa at hvision.nl (ivnowa at hvision.nl) Date: Wed, 22 Sep 1999 08:44:28 GMT Subject: lists and append, and loop iteration In-Reply-To: <37E8860B.C024C4F8@radiata.com> References: <37E8860B.C024C4F8@radiata.com> Message-ID: <199909220841.KAA05325@axil.hvision.nl> On 22 Sep 99, at 17:32, Mark Krischer wrote: > this might be a newbie a question, but is there a reason why append > doesn't create a list if the list doesn't exist? > > it seems to add a bit of complexity to have to do something like: > > dict = {} > > if 'new_key' not in dict.keys(): > dict['new_key'] = [new_value] > else: > dict['new_key'].append(new_value) > > it seems like i should just be able to say "list.append(new_value)" and > if list doesn't exist, > i get "list[0] = [new_value] I don't think the dict can "see" the append... what you're doing is trying to get a value from a dict, then doing something with that value. So essentially it's two steps: a = dict['new_key'] a.append(new_value) even though you can write them as one step with dict['new_key'].append(new_value). If 'new_key' doesn't exist, nothing is returned, so there's nothing to append to. > am i missing something fundamental that this would completely break? > > > and while i'm bending your ear, let me ask a second question. > > if i do: > for element in list: > do something with element > > is there any to find out what my current index is? i've basically been > doing something like: > list.index(element) > > this happens to work fine for what i'm doing now, but only because i > don't care about doubles in the list, but should that ever be a problem, > how will i know which element i'm dealing with. > > i figure i can always do: > for i in range(len(list)): > do something with list[i] > > but it just feels like i should be able to things the other way as well. No other way that I know of... you can work around this, by keeping a counter, but using range() is better. --Hans Nowak (ivnowa at hvision.nl) Homepage: http://fly.to/zephyrfalcon Snippets: http://tor.dhs.org/~zephyrfalcon/snippets/ From mal at lemburg.com Wed Sep 29 16:29:04 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Wed, 29 Sep 1999 22:29:04 +0200 Subject: keys and values lining up References: <5l905p9a4c.fsf@eric.cnri.reston.va.us> Message-ID: <37F27690.70A0279B@lemburg.com> Guido van Rossum wrote: > > Michael Haggerty writes: > > > There's always > > > > >>> d = {'key1' : 'val1', 'key2' : 'val2', 'key3' : 'val3'} > > >>> apply(map, [None] + d.items()) > > [('key1', 'key2', 'key3'), ('val1', 'val2', 'val3')] > > > > if you have to go the items() route. > > I don't know how well that will work for a really large dictionary, > because all arguments get pushed on the stack (not the C stack, but > still...). > > But it's a really cool trick (by which I meant I hadn't tought of it > :-). Might be worth noting in the Python book of idioms. > > Of course, if you have NumPy, there's always > > keys, values = transpose(d.items()) > > which probably beats everything else. Or maybe the lists() and tuples() function in mxTools (available from my Python Pages): >>> d = {'key1' : 'val1', 'key2' : 'val2', 'key3' : 'val3'} >>> import NewBuiltins # provided by mxTools >>> lists(d.items()) (['key1', 'key2', 'key3'], ['val1', 'val2', 'val3']) >>> tuples(d.items()) [('key1', 'key2', 'key3'), ('val1', 'val2', 'val3')] depends on what you want to do with the result... (and yes tuples() and lists() is written in C too). -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 93 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From yopen at my-Deja.com Fri Sep 3 21:44:42 1999 From: yopen at my-Deja.com (Bill Wilkinson) Date: Fri, 3 Sep 1999 20:44:42 -0500 Subject: Using Python in ASP scripts References: Message-ID: Have you read this bit? http://starship.python.net/crew/aaron_watters/pws.html It might help. Nikolai Kirsebom wrote in message news:dBYz3.682$XR4.5942 at news1.online.no... > I have two NT 4.0 PC's running IIS 4.0 where I'm using Python in ASP > scripts. On the one machine I have no problems running the scripts - > however on the other machine I can't get the scripts running. If I change > the LANGUAGE token to something else (VBScript) it works - so obviously it > must have something to do with the 'registration' of Python as the scripting > language. I've executed the pyscript.py and it reported all ok. > > When I select the 'asp' page containing the python-code, the browser seems > to 'hang' - waiting for response from the server, and it seems to wait > endlessly. > > Does anyone have any hints on where to look (variables, paths, IIS-config, > access ????). > > Thanks for any help. > > Nikolai > > > From MHammond at skippinet.com.au Fri Sep 10 03:58:04 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Fri, 10 Sep 1999 17:58:04 +1000 Subject: ASP with Python question References: <37d87ed7@news.interq.or.jp> Message-ID: <7radmm$euq$1@m2.c2.telstra-mm.net.au> Glen Malley wrote in message <37d87ed7 at news.interq.or.jp>... >It would really suck if the Session was the only object >not working, because it's the only object I need...;-P Im afraid it really sucks :-) This is the only known bug in the Active Scripting support :-( Mark. From Elie.Naulleau at westgroup.com Thu Sep 23 14:02:22 1999 From: Elie.Naulleau at westgroup.com (Elie Naulleau) Date: Thu, 23 Sep 1999 13:02:22 -0500 Subject: Python and Swig Message-ID: <37EA6B2E.DE7A09AA@westgroup.com> I am experiencing some linking problems. I am using Python. I need to incorporate C functions accessible from Python. To do this I am using swig (www.swig.org). If I follow the steps advised by the documentation, everything is fine till the linking stage: swig -python stemmer.i OK gcc -c stemmer.c stemmer_wrap.c -I/csr0/gnu/lib/python1.5/config -I/csr0/gnu/include/python1.5/ OK ld -shared stemmer.o stemmer_wrap.o -o stemmermodule.so error -shared in not recognized by Solaris linker, it is likely to be -d y So I do it again: ld -d y stemmer.o stemmer_wrap.o -o stemmermodule.so Undefined first referenced symbol in file Py_InitModule4 stemmer_wrap.o PyExc_TypeError stemmer_wrap.o exit stemmer_wrap.o tolower stemmer.o malloc stemmer_wrap.o sprintf stemmer_wrap.o PyString_FromString stemmer_wrap.o PyType_Type stemmer_wrap.o .umul stemmer.o .urem stemmer.o .rem stemmer.o Py_BuildValue stemmer_wrap.o PyErr_Occurred stemmer_wrap.o PyString_AsString stemmer_wrap.o sscanf stemmer.o PyModule_GetDict stemmer_wrap.o qsort stemmer_wrap.o fclose stemmer.o _Py_NoneStruct stemmer_wrap.o strncat stemmer_wrap.o PyArg_ParseTuple stemmer_wrap.o PyErr_SetString stemmer_wrap.o strncmp stemmer_wrap.o printf stemmer.o __iob stemmer_wrap.o PyDict_SetItemString stemmer_wrap.o realloc stemmer_wrap.o free stemmer_wrap.o strcmp stemmer.o fgets stemmer.o fopen stemmer.o strcpy stemmer.o PyInt_FromLong stemmer_wrap.o strlen stemmer.o PyExc_NameError stemmer_wrap.o PyInt_AsLong stemmer_wrap.o fprintf stemmer_wrap.o ld: fatal: Symbol referencing errors. No output written to stemmermodule.so I running Solaris 2.5, gnu compiler, Sun solaris ld Reading ld man page did not help. Neither compiling object files with gcc -shared Any help ? Thanks Elie Naulleau Elie.Naulleau at westgroup.com From hniksic at srce.hr Tue Sep 14 12:07:47 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 14 Sep 1999 18:07:47 +0200 Subject: More random python observations from a perl programmer References: <000601befe4c$3e585ae0$54a2143f@tim> Message-ID: <87u2oxeass.fsf@pc-hrvoje.srce.hr> "Tim Peters" writes: > [Hrvoje Niksic] > > ... > > I don't see the purpose of raw_input() and input() when > > sys.stdin.readline() and eval(sys.stdin.readline()) are available. > > Convenience; My point exactly. How often do you really need input()? Using it to input numbers is wrong and potentially very dangerous, as shown before. I think the additional verbosity of eval(sys.stdin.readline()) is a very good indication of what is really going on. > similarly there's no "purpose" to print given that > sys.stdout.write() is also available. I find `print' very convenient. I would find it more convenient if there were a way for it to print to stderr, though. From ivanlan at callware.com Fri Sep 3 23:55:21 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Sat, 4 Sep 1999 03:55:21 GMT Subject: calling python interpreter Message-ID: <37D09829.FF030FC2@callware.com> Hi All-- Greg Ewing wrote: > [bobbit] > cvx my_script > > is fast enough not to be a bother, considering the > rate at which I can write executable scripts! > > (If you're wondering, cvx is named after a PostScript > operator and stands for "convert to executable".) > Um, shouldn't that be my_script cvx ???-) -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From phd at emerald.netskate.ru Thu Sep 9 10:38:51 1999 From: phd at emerald.netskate.ru (Oleg Broytmann) Date: Thu, 9 Sep 1999 18:38:51 +0400 (MSD) Subject: Query system date In-Reply-To: <7r8fjh$dno$1@nnrp1.deja.com> Message-ID: On Thu, 9 Sep 1999 mdperry_26 at my-deja.com wrote: > I am new to python and I am trying to figure out how to return the > computers system date and time and then format it as MM-DD-YYYY. I have > searched the documentation up and down and have not found anything about > how to accomplish this. Any help would be greatly appeciated. Reread docs on builtin "time" module. You need time.time(), localtime() and so on... > Thanks, > > Mark. Oleg. ---- Oleg Broytmann Netskate/Inter.Net.Ru phd at emerald.netskate.ru Programmers don't die, they just GOSUB without RETURN. From aahz at netcom.com Tue Sep 14 19:51:42 1999 From: aahz at netcom.com (Aahz Maruch) Date: 14 Sep 1999 23:51:42 GMT Subject: More Pythonic? References: <7rkh5u$1qq@dfw-ixnews13.ix.netcom.com> <14302.34633.583713.527695@bitdiddle.cnri.reston.va.us> Message-ID: <7rmn2e$jrq@dfw-ixnews7.ix.netcom.com> In article <14302.34633.583713.527695 at bitdiddle.cnri.reston.va.us>, Jeremy Hylton wrote: > >The way I dealt with this problem in my urllib replacement (see >http://the-tech.mit.edu/~jeremy/python/urllib2.py) was to raise an >exception where the exception instance is actually a valid HTTP >response object. > >A typical usage would be something like this: > >try: > resp = urllib2.urlopen('http://frob.nitz/') >except HTTPError: > print resp.code, resp.msg Aside from the obvious glitch that you need to use urllib2.HTTPError, your code generates a NameError on resp. I think I know how to fix it, but I'd like you to tell me in case I miss something obvious. Overall, your code looks similar to the code I was planning to write, but the big feature your code is missing is the stack of redirects. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From donn at u.washington.edu Fri Sep 3 16:32:30 1999 From: donn at u.washington.edu (Donn Cave) Date: 3 Sep 1999 20:32:30 GMT Subject: smtplib: subject? to? References: <19990903202313.A23408@optiplex.palga.uucp> <19990903142456.A2124@optiplex.palga.uucp> Message-ID: <7qpb8u$ej8$1@nntp6.u.washington.edu> Quoth Gerrit Holl : | On Fri, Sep 03, 1999 at 02:07:34PM -0400, Moshe Zadka wrote: | > SMTP expects an RFC-822 message, including a To: and Subject:. Python has | > tools to parse rfc822, but not to write, so you will have to read | > the docs, and use .write() like regular folk | | But if I have to put a To: in the message, why do I have to give recipients? Basically, one is for RFC822 and the other is for SMTP. The SMTP service actually delivers the mail, possibly to the same address as show in "To" but at your discretion. You may also add the address(es) shown in "Cc", or addresses that appear nowhere in the header (``blind CC''). It's kind of a creepy system, but to my knowledge the SMTP service is not expected to understand anything about the RFC822 data. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From gmcm at hypernet.com Wed Sep 8 18:40:56 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 8 Sep 1999 17:40:56 -0500 Subject: Security considerations of execfile() In-Reply-To: <7r6ev2$j$1@nnrp1.deja.com> Message-ID: <1275295904-100242755@hypernet.com> Preston Landers wrote: > > I'm thinking of using the execfile() built-in function in one my > programs (Pagecast) and I'm wondering about some security > considerations. > > Basically, the program will execute all files with a certain > extension in a certain directory as Python code. ... > My question is what kind of security, if any, does execfile() > provide (my guess: none) and should I consider working with the > rexec module? ... Can't really say much about rexec (except I understand it's quite restrictive) 'cause I haven't used it. I've used plain execfile without worry in a sort of similar situation, but only I (and root) could put things in the magic directory. You can pass execfile a dictionary to use instead of globals. The trick is, though, that if the dict does NOT have something called "__builtins__" in it, Python will stick the real __builtins__ in there. I'm not sure what kind of attack you're worried about. Personally, not being the paranoid type, I'd be inclined to use just OS security if I could. - Gordon From a.eyre at optichrome.com Thu Sep 16 11:12:53 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Thu, 16 Sep 1999 15:12:53 GMT Subject: bsddb module In-Reply-To: <5liu5b4htd.fsf@eric.cnri.reston.va.us> References: <5liu5b4htd.fsf@eric.cnri.reston.va.us> Message-ID: <001101bf0055$f2fe5e80$3acbd9c2@peridot.optichrome.com> > You are probably confused by the BSDDB versioning. The bsddb module > that comes with the Python source code requires Berkeley-db *version > 1.85*. I don't know where to find that, but I expect that there are > plenty of ftp archives that have it (do a websearch). Anyway, the > copy of bsddb 1.85 that I have has a plain vanilla BSD style license > allowing commercial use etc. -- so I'm confident that the installer is > fine. I managed to find it, but it seems to need a bit of work to port to win32. Is the version that you use available via CVS? -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From henk_p at my-deja.com Tue Sep 28 10:38:45 1999 From: henk_p at my-deja.com (henk_p at my-deja.com) Date: Tue, 28 Sep 1999 14:38:45 GMT Subject: How does a CGI script get complete request header text ? References: <7sju0v$pc2$1@nnrp1.deja.com> <7sntje$b32$1@nnrp1.deja.com> Message-ID: <7sqjti$7tu$1@nnrp1.deja.com> interesting. I'm curious, though: how does mod_psi compare to mod_fastcgi and mod_pcgi? Well, maybe you can give it a try, download at: http://huizen.dds.nl/~d50/psi_0.01.tar.gz I created it because I could not get mod_fastcgi to work on my freebsd3.2 box. The fastcgi module keeps crashing the python interpreter It is different from pcgi in that it doesn't need a 'wrapper' executable to connect apache to the script. So it doesn't have the overhead of forking the wrapper for each request. Sent via Deja.com http://www.deja.com/ Before you buy. From JohnH at PHM.GOV.AU Thu Sep 30 20:25:37 1999 From: JohnH at PHM.GOV.AU (Hirsch, John) Date: Fri, 1 Oct 1999 10:25:37 +1000 Subject: Python Win32 book Message-ID: Hi Just to let you know that the 'Python programming on Win32' book will not be released until early next year according to ORA customer service not September this year. From carvdawg at patriot.net Sat Sep 11 17:03:43 1999 From: carvdawg at patriot.net (Harlan Carvey, CISSP) Date: Sat, 11 Sep 1999 17:03:43 -0400 Subject: new to python Message-ID: <37DAC3AF.7A6FE617@patriot.net> I'm just starting Python programming, on NT. I was wondering if anyone has example scripts used for NT sysadmin'ing... C From warren at nightwares.com Tue Sep 7 20:47:13 1999 From: warren at nightwares.com (Warren 'The Howdy Man' Ockrassa) Date: Tue, 07 Sep 1999 19:47:13 -0500 Subject: Python interface to Groupwise mailoxes? References: Message-ID: <37D5B211.E9C7C9F3@nightwares.com> "S. Blakey" wrote: > Even some good documentation of Novell's proprietary crap would > appreciated. That's the problem. Novell's way of doing things is, well, Novell's. I've tried to hack into my GroupWise box at work using non-Novell tools, in non-MS IDEs, and had nothing but grief. However note that Novell *does* market a POP server which *in theory* makes their G'Wise mailboxen available to any POP3 client. It's spendy -- about US$1300 for a 50-seat license as I recall -- but it opens the gateway, so to speak, and in large companies or companies with many users on many OSen or many users travelling amortizes well. I am still pushing hard at work for that implementation, as the current scheme is intolerable (G'Wise client hoses NT4's networking, surprise.) Don't know if they have a gateway for SMTP for sending stuff. Sigh. Their site used to have lots of info like that available, but recently they seem to have buried the relevant docs under a lot of noise, so it's darn near impossible to find even the POP server, which in fact they released under the aegis of being something like "Netscape mail server for Novell", when you search their site. I found the POP server before AOL sucked up Mozilla though, and that might be a factor too. Short answer: If anyone has figured out Novell's server scheme for mail I'd sure love to know about it, but I fear it has not been done yet. (Or did I see a Red Hat install go by a while back which included a G'Wise client?) -- warren ockrassa | nightwares | mailto:warren at nightwares.com http://www.nightwares.com/ From skip at mojam.com Thu Sep 2 17:20:05 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 2 Sep 1999 16:20:05 -0500 (CDT) Subject: CGI speedup strategies In-Reply-To: References: <37CCE7C9.D340BBF5@strs.co.uk> <036801bef458$d262c3e0$f29b12c2@secret.pythonware.com> Message-ID: <14286.59784.375719.89442@dolphin.mojam.com> Phillip> Fredrik Lundh wrote: >> http://www.nightmare.com/medusa (non-threaded, ultra-fast) >> http://www.zope.org (threaded, based on medusa) Phillip> I looked at both of these a while back, and decided I didn't Phillip> like them because they didn't have the same sort of interface Phillip> that SocketServer does. So I wrote one that (sort of) has the Phillip> same interface, but it is unfortunately not complete: I could have sworn I saw something posted within the past month that was some sort of melding of the SocketServer asyncore modules, but when I searched for it at Deja News, nothing turned up. Was I dreaming? Pointers appreciated. Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/~skip/ 847-971-7098 | Python: Programming the way Guido indented... From rainer2207 at my-deja.com Sun Sep 12 23:43:18 1999 From: rainer2207 at my-deja.com (rainer2207 at my-deja.com) Date: Mon, 13 Sep 1999 03:43:18 GMT Subject: SAX Parser Installation Message-ID: <7rhrsk$s3u$1@nnrp1.deja.com> I'm having trouble getting the SAX Parser to work on a Win98/IDLE machine. Can anyone tell me how to install it? Thanks. Rainer Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From wade at lightlink.com Mon Sep 6 15:20:08 1999 From: wade at lightlink.com (wade at lightlink.com) Date: Mon, 06 Sep 1999 19:20:08 GMT Subject: how often does re.compile compile? Message-ID: <7r1451$3n7$1@nnrp1.deja.com> Hello, I'm a recovering Perl user who's using the re module to parse a bunch of text. (Miscellaneously tagged.) Looking at other people's code, I notice folks tend to do their re.compile()'s at the global level. I've got one pattern that is used only within one function. If I say re.compile() inside the function definition, does the pattern get compiled afresh every time the function is called? Thanks -- -- Wade Leftwich Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From MHammond at skippinet.com.au Tue Sep 7 20:29:27 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 8 Sep 1999 10:29:27 +1000 Subject: How to get the python sourcecode line, when debuging the Python C sources? References: <7r3bqk$hbv$1@newshost.germany.net> Message-ID: <7r4alh$7gl$1@m2.c2.telstra-mm.net.au> Stefan Knappmann <101.139915 at germanynet.de> wrote in message >Does anybody know in which C variable I can find the Python Stack? >Or how to get the activ Python source code line from within the C >debugger? Move down the stack to eval2() in ceval.c. f->f_lineno will tell you the line number. f->f_code->co_filename + 20 bytes is the start of the ASCII string containing the filename. Adding something like "(char *)(((char *)f->f_code->co_filename))+20)" to the watch window should do the trick. Mark. From jblake at stamp-coin.com Thu Sep 9 04:52:22 1999 From: jblake at stamp-coin.com (jonathon) Date: Thu, 9 Sep 1999 08:52:22 +0000 (UTC) Subject: Python Error Messages Message-ID: Why are PythonError messages so annoying? I've been trying to debug a script for the last four days, to no avail. With two of the four databases I run it on, the script does just what it is supposed to. On the other two databases, it doesn't. The current exasperating error message: Traceback (innermost last) File "mass.py", line 21102 in ? print changed_field, " is record_list[28] " File "mass.py", line 20610 in print_web_page table_prefix = " " TypeError: illegal argument type for built in operation. ********************************************************** Line 21100 et al are: if temp_field == changed_field : good_datafile.write( temp_line + '\n' ) test_datafile.write( test_line + '\n' ) # line 21102 check_point = print_country(record_list, temp_line) check_point = create_country_table( record_list, country_line ) check_point = print_web_page ( record_list ) else: error_file.write( temp_line + '\n' ) *** Line 20607 et al are: make_table = '

' table_prefix = " " # line 20610 title_name = (title_prefix + country_name + bang_two + scott_data + bang_two + michel_data ) add_keywords = ( pre_keywords + country_name + country_section_name + scott_data + michel_data + y_t_data + s_g_data + minkus_data + end_of_line ) file_description = ( pre_describe + description_prefix + country_name + bang_two + country_section_name + bang_two + scott_data + bang_two + michel_data + end_of_line ) *************** Now what is infuriating, is that the script has run over this particular code sequence at least 4000 times, before giving me this error. For those that want to look at the script in its entirety, it is at http://www.stamp-coin.com/python/python_errors/index.html. [ 22000 lines for the script. The approxomate file size of the data files is lsited there. ] ****************************** I don't have the error message for the other frustration, but the python script was truncating a record, for no apparant reason. Worse still, none of the previous records had been truncated. One of them is a simple assignment, the other is a simple writeline to file. Questions: What would trigger these error messages, when there were no apparant problems earlier? How do I do exception handling that maintains something sane, when the script obviously isn't? One thing i have noticed, is that the print statements I put in, to try to follow what was happening, tend to indicate that the actual problem is more than a couple of lines away from the line(s) that are quoted on the screen. xan jonathon From andy at robanal.demon.co.uk Sat Sep 18 18:54:25 1999 From: andy at robanal.demon.co.uk (Andy Robinson) Date: Sat, 18 Sep 1999 22:54:25 GMT Subject: Marking translatable strings References: Message-ID: <37e708ce.4562650@news.demon.co.uk> Fran?ois Pinard wrote: >Hello, people. > >So, I want the big picture right now. That is: a technique for marking >strings for automatic extraction and building of PO files, and a technique >for using PO files from within Python scripts. I foresee that Python >introduces an usual difficulty in that the textual domain for translations >may vary quite unexpectedly, when the control dynamically flies between >independent packages under different textual domains. Big picture: are you looking for run-time translation, or 'build-time'? i.e. should a Python application be able to switch languages in mid-run when a user hits a menu item? The latter can actually be easier - each string needs to be replaced with a lookup into a mapping from (language, message_id) -> local message, and it is really quick to test. Also do you want an automatic and theoretically perfect tool to understand every context in which quotes occur and do the right thing, or a practical one to reduce the cost of internationalizing apps by 90%. I made the mistake of hard-coding messages into a Delphi app I later had to painstakingly internationalise. I considered doing something semi-automatic so I could use the English messages as the key, but then hit a situation where a simple English message was used twice in two different contexts. Now, I have a function 'tr' - short for translate - and an explicit constant, and do stuff like ShowMessage(tr(USER_FORGOT_THE_FLOPPY)); But this involves adding USER_FORGOT_THE_FLOPPY to a separate file every time. In Python, I'd be tempted to have a special tag to use at the beginning of the string I wanted internationalized, say "@@@USER_FORGOT_THE_FLOPPY". Then I'd write a script to walk through the project finding these, and on each occurrence (a) replace it with a function to do a run-time lookup into a constants database, or a constant in a module, and (b) add the string to my database or the source of my constants module. We end up with a database in no particular language e.g. { ... ("LINGO", "USER_FORGOT_THE_FLOPPY") : "USER_FORGOT_THE_FLOPPY" ... } Of course someone else needs to sit down later and add entries for all the languages you wish to support (including your own native one), but it does not have to be the programmer. And your app can at least run in development at each stage before running the database-builder script. Tagging the strings which really are messages and using 'constants' seems a lot safer than messing with the language. Come to think of it, this could be quite a useful Python package - we could kick it off with a few dozen common error messages in several languages to get people going! Python-parsing-Python-beats-Delphi-parsing-Delphi'ly yours, Andy Robinson From da at ski.org Mon Sep 27 11:16:58 1999 From: da at ski.org (David Ascher) Date: 27 Sep 1999 10:16:58 -0500 Subject: README: Python-URL! - the weekly guide to Python resources (Sep 27) Message-ID: <97BA604195CAFA9B.690B8AB0E422F93C.097AABEA8F5976F1@lp.airnews.net> Python grows up in several ways this week: The standard Python documentation is available in book form by toExcel.com, and the royalties go to the PSA. According to Guido they're nicely done. http://www.toexcel.com/bookstore/book_detail.asp?isbn=1583483756 http://www.toexcel.com/bookstore/book_detail.asp?isbn=158348373X http://www.toexcel.com/bookstore/book_detail.asp?isbn=1583483748 Barry Warsaw releases JPython 1.1b3, which once again allows optional access to non-public Java class members. http://www.jpython.org/ Comp.lang.python.announce is flooded by announcements of new software. http://www.egroups.com/listsaver/python-announce-list/ Greg Ewing implements the extended call syntax that Guido had agreed to consider for 1.6 (he wins the grammar-hacker award of the month!). http://www.deja.com/getdoc.xp?AN=528523696 In a thread on Donn Cave, master of fork & friends, points us to his tool to invoke shell commands on Unix and get the output. http://www.deja.com/getdoc.xp?AN=529129001 The IDLE part of the CVS tree is now mirrored nightly, for those who want IDLE but don't care for the rest of the Python CVS tree. http://starship.python.net/crew/da/idledists/ Dr. Dobb's Journal's Python Resource CD-ROM is a nice collection of Python distributions, tools, software, documentation and articles http://www.digitalriver.com/dr/v2/ec_MAIN.Entry10?SP=10023&PN=1&V1=164146&xid=2823 The Python-URL! and Tcl-URL! archives are back, thanks to Jean-Claude Wippler http://mini.net/cgi-bin/url/ Reminder: The Python Conference is accepting paper submissions until the end of the month. http://www.python.org/workshops/2000-01/cfp.html http://www.deja.com/getdoc.xp?AN=525600398 ========================================================================= Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the center of Pythonia http://www.python.org Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Consortium emerges as an independent nexus of activity http://www.python.org/consortium Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing trick of the trade: http://www.dejanews.com/dnquery.xp?QRY=&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=threaded&showsort=date&maxhits=100&groups=comp.lang.python Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://www.dejanews.com/dnquery.xp?QRY=~g%20comp.lang.python%20Python-URL%21 Suggestions/corrections for next week's posting are always welcome. http://www.egroups.com/list/python-url-leads/ To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. -- The Python-URL! Team-- -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From fredrik at pythonware.com Sat Sep 4 05:22:07 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 4 Sep 1999 09:22:07 GMT Subject: termios disappears during object deletion References: Message-ID: <00a601bef6b7$901a3fc0$f29b12c2@secret.pythonware.com> Brien Barton wrote: > Can anyone explain this behavior?? For some reason, the termios and TERMIOS > modules get wiped out when python is running the __del__ method during > program termination. I've tried this with Python 1.5.1 on Linux and with > Python 1.5.2 on SGI IRIX. If you explicitly delete the object, you don't > have this problem. > > ~> cat test.py > import math, termios, TERMIOS > > print 'math=', math > print 'termios=', termios > print 'TERMIOS=', TERMIOS > > class Test: > def __del__(self): > print 'deleting Test object ...' > print 'math=', math > print 'termios=', termios > print 'TERMIOS=', TERMIOS starting with 1.5.1, Python performs a relatively aggressive cleanup when the interpreter is shut down: http://www.python.org/doc/essays/cleanup.html among other things, this means that destructors must hang on to all global resources they are using, e.g.: def __del__(self, math=math, termios=termios, TERMIOS=TERMIOS): ... From nolanl at my-deja.com Sun Sep 12 13:43:03 1999 From: nolanl at my-deja.com (nolanl at my-deja.com) Date: Sun, 12 Sep 1999 17:43:03 GMT Subject: Examples using urllib, htmllib Message-ID: <7rgon4$4a0$1@nnrp1.deja.com> Can someone point me to some example Python scripts that I can download that show accessing the web using the urllib, and htmllib. I'm interested in automating the login, downloading, uploading and logoff tasks that I have to do manually now. One problem I may have is that the logon and other operations at the web site in question (Freediskspace.com) appear to be Java applets so if you have pointers on that too, they'd be appreciated. thanks Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From garry at research.att.com Wed Sep 22 15:26:28 1999 From: garry at research.att.com (Garrett G. Hodgson) Date: Wed, 22 Sep 1999 19:26:28 GMT Subject: high school programming & python References: <937300939snz@vision25.demon.co.uk> <$JL+lCAFvt33Ewr8@jessikat.demon.co.uk> <37DF9080.21A8D285@calibre-dd.com> Message-ID: <37E92D64.6C2C3288@research.att.com> Stephen J King wrote: > > Robin Becker wrote: > > >> You were lucky to have plugboards. We had to key things in with a bunch > > >> of switches. > > > > > >Hard little metal toggle switches, too -- none of these posh molded > > >plastic rocker switches! > > Luxury! When we was kids all we 'ad was old wires which we 'ad to strip > with our teeth and wrap around dirty binding posts with our bare > fingers. you had *fingers*? -- Garry Hodgson "Hey, mister, can ya tell me, garry at sage.att.com where a man might find a bed?" Software Innovation Services He just grinned and shook my hand, AT&T Labs "No", was all he said. From a.eyre at optichrome.com Mon Sep 27 11:30:37 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Mon, 27 Sep 1999 15:30:37 GMT Subject: May I embed IDLE into my Windows application? In-Reply-To: <7qmq5v$cvv$1@newsource.ihug.co.nz> References: <7qmq5v$cvv$1@newsource.ihug.co.nz> Message-ID: <000601bf08fd$40104760$3acbd9c2@peridot.optichrome.com> > When I use _tkinter_d.pyd, it doesn't crash, but IDLE still > doesn't work. I want Python as an extension language embedded > in my application, I have to embed an editor. Do you have any > suggestion? I found that if sys.argv is empty, then IDLE will not run. Use: PyObject* tmp = Py_BuildValue("[s]", "dummy"); PySys_SetObject("argv", tmp); Py_DECREF(tmp); You also need to trap stderr to see why it doesn't work. Set sys.stderr to be something else. -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From mal at lemburg.com Thu Sep 9 05:31:21 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Thu, 09 Sep 1999 11:31:21 +0200 Subject: Creating a python object from C References: <7r7hs3$qn8$1@news.is.co.za> Message-ID: <37D77E69.1BC529E0@lemburg.com> Jacques Oosthuizen wrote: > > Is it possible to instantiate a python object from a C module.!!!! Yes, all you have to do is call the Python class object with the constructor arguments, e.g. use PyObject_Call*(). It will then return an instance. -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 113 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From skip at mojam.com Tue Sep 7 14:51:46 1999 From: skip at mojam.com (Skip Montanaro) Date: Tue, 7 Sep 1999 13:51:46 -0500 (CDT) Subject: CGIHTTPServer howto? In-Reply-To: <37d54d12.1058989@read.news.global.net.uk> References: <7qt9cn$rp7$1@bunyip.cc.uq.edu.au> <37D44115.EA834C@ix.netcom.com> <7r2ndf$b01$1@bunyip.cc.uq.edu.au> <37d54d12.1058989@read.news.global.net.uk> Message-ID: <14293.24207.709110.125953@dolphin.mojam.com> Dave> If you want a full blown HTTP server written in python then take a Dave> look at medusa (I dont have the URL to hand, but it is listed in Dave> the third-party modules on the python site). One of the easier URLs to remember: http://www.nightmare.com/medusa/ ! Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/~skip/ 847-971-7098 | Python: Programming the way Guido indented... From egelando at online.no Fri Sep 24 04:44:20 1999 From: egelando at online.no (Egeland) Date: Fri, 24 Sep 1999 10:44:20 +0200 Subject: Keybindings: Recognizing Control, Alt, etc on different platforms Message-ID: <%WGG3.573$pn4.3098@news1.online.no> Hi all. My app uses the "" binding, and I must know in the callback procedure if thats a Control-k or plain k coming in. On Linux, say, I can use the clause if event.keysym=="k" and event.state==4: # Control-k, not just 'k' # do something but that wont work on win32. Is there some platform independent way of recognizing modifications like Control, Alt, and Shift ? Thanks in advance, Anders Moe From philwise at geocities.com Wed Sep 1 15:22:13 1999 From: philwise at geocities.com (Phil Wise) Date: Wed, 01 Sep 1999 19:22:13 GMT Subject: Doing POST opperations from Python References: Message-ID: <37cd7cc4.8655980@news.freeserve.net> On Wed, 01 Sep 1999 09:53:09 -0500, "Jeffrey Kunce" Anounced to the internet: :->>I am trying to produce POST requests within python :-> :->Skip gave you a good answer. :->Let me provide some example code. :->Look at urlpost.py at http://starship.python.net/~jjkunce/ :-> :-> --Jeff :-> :-> :-> Thanks for all the replys. "640K ought to be enough for anybody" - Bill Gates 1981 From m.faassen at vet.uu.nl Wed Sep 29 09:45:34 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 29 Sep 1999 13:45:34 GMT Subject: python as a first language? References: Message-ID: <7st55u$dca$1@newshost.accu.uu.nl> Craig Hagerman wrote: > Hi, > I want to get some feedback on how good Python is to learn for a beginner. > I am interested in learning programming (OOP especially). I studied (bit > didn't really learn) Fortran ages ago, studied formal logic (math) in > university and have been playing around with web technologies (Javascript > et al) and now want to try out bigger and better things. > What are people's > thinking regarding Perl vs Python for a beginner, Not to start a flame war, but Python may be easier to learn for a beginner, as Python has less special cases (in its syntax) than Perl. Python also has a well-integrated object oriented system, while Perl's is rather unconventional.. Perl tends to produce programs that are a bit faster, and offers more extension modules (though Python already offers plenty). For the rest Perl and Python are about equal. > or how about Python > compared to Eiffel or Sather for this purpose? Any good suggestions for > what road I should head up first? It's hard to say. I haven't done more than glance at the Eiffel and Sather references in the past, but they both seem to be well-designed languages. Eiffel and Sather are less dynamic than Python. The advantage of this is that they can compile to faster code, and that, once you have a well-designed system, you can set it in stone and build on it without further worries. Python is very flexible and dynamic; your objects can (under usual circumstances) always be changed during the running of the program. The disadvantage of this is that Python code doesn't run as quickly as code written in some other languages (but still more than quick enough for most tasks), and that you set some interfaces in stone (other programmers could always mess around with them, if they were malicious or stupid). But the advantage the flexibility is that you can very rapidly code something that works, without getting trapped in design paralysis (something that often happens to me when I write C++ code). The quick result nature of Python, combined with the clean design, may make it especially suited towards beginners. Beginners expect quick results to remain motivated enough to continue learning. At the same time it's bad to foist something onto beginners that teaches them bad programming practices, but Python is just fine in this respect as well. Though of course you can write messy code in any language. Regards and good luck, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From da at ski.org Mon Sep 13 03:54:18 1999 From: da at ski.org (David Ascher) Date: 13 Sep 1999 02:54:18 -0500 Subject: README: Python-URL! - the weekly guide to Python resources (Sep 13) Message-ID: This week's dispatch from the world of spam, spam and spam 'n eggs: Frank Willison, O'Reilly's editor in chief, muses about the open source communities in his column, and wears a subversive t-shirt when he talks to TechNetCast: http://www.oreilly.com/frank/ http://www.technetcast.com/tnc_program.html?program_id=38 Mike Olson gives a one-page (well, one HTML page!) introduction to CORBA, ORBs, etc. in LinuxWorld: http://www.linuxworld.com/linuxworld/lw-1999-09/lw-09-corba_1.htmlc Remco Gerlich reveals how to use Python's underappreciated line-completion tool automatically: http://www.deja.com/getdoc.xp?AN=522511625 Jeffrey Kunce gives some sample code to interface to Novell's Groupwise mailboxes: http://www.deja.com/getdoc.xp?AN=522571735 In a continuing heroic effort to answer as many questions as the bots, Robert Kern points out the best resources for folks wishing to learn how to program using Python: http://www.deja.com/getdoc.xp?AN=523189453 The regularly expressed problem of finding strings is match()'ed by, naturally speaking, Tim Peters: http://www.deja.com/getdoc.xp?AN=523934915 Once again, Greg Ewing discreetly throws a grenade into the jello bowl. This time, it's an implementation of a perennial favorite topic from the functional subspace, list comprehensions: http://www.deja.com/getdoc.xp?AN=523672423 ========================================================================= Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the center of Pythonia http://www.python.org Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Consortium emerges as an independent nexus of activity http://www.python.org/consortium Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing trick of the trade: http://www.dejanews.com/dnquery.xp?QRY=&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=threaded&showsort=date&maxhits=100&groups=comp.lang.python Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://www.dejanews.com/dnquery.xp?QRY=~g%20comp.lang.python%20Python-URL%21 Suggestions/corrections for next week's posting are always welcome. http://www.egroups.com/list/python-url-leads/ To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. -- The Python-URL! Team-- -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From moshez at math.huji.ac.il Tue Sep 7 03:17:48 1999 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 7 Sep 1999 09:17:48 +0200 (GMT+0200) Subject: Infinite Cardinals and Pseudo-Mathematics Message-ID: [A Parody of TomC's Post about Quoting Strategies] The following message will be posted periodically until observed clue-levels in these parts improve, or until the heat death of the Universe arrives. EXECUTIVE SUMMARY: To send more accurate messages about infinities, please try to make sure you do not make a mess out of the fairly simple concepts of mathematical infinities. This isn't History. People expect accurate statements, backed by proofs not wild assumptions. LONG STORY: Wouldn't you like to make your messages corrrect? If so, I have some posting tips for you. If not, just ignore this. (Of course, if you don't want your messages to be accurate, it's not clear why to bother to send them in the first place. :-) I'm going to take a bit of time to explain this, because newcomers to comp.lang.python often lack the necessary mathematical skills were I to send a superbrief message. Here's the issue: you appear to have sent a mish-mash of mathematical facts. Worst of all, you have done so by not having a firm grasp of the definitions of the terms you used. That is what mathematics is about, you know. :-) If all you want to do is appear mathemtically knowledgable, that's one thing, but here you seem to be spouting nonsense just to fill up a message. This is neither an on-topic post, nor one with any useful information. Here's why. First of all, this spreads mathematical disinformation about infinities -- you're supposed to know the basic definitions of which you're talking. Otherwise you'll probably seem like a clueless newbie to the rest of us. This isn't really an issue of exclusivity (I know that more then a handful of people know this stuff nowadays), so much as it is an issue of keeping things accurate. Second, putting forth statements like "there might be only two infinities" does little good. It misleads others to think that this was what Goedel or Cohen proved, when what they proved that there might be no infinities between aleph null and the continuum. For example, here's how an explanation about infinities should look if you'd like them to be more effective. A cardinality of a set is usually taken to be the minimal ordinal which is equi-potent with the set. This, of course, implies the Axiom of choice. In particular, we have that any set is equi-potent with its cardinality, and thus when a set is infinite, the cardinality is infinite. Of course, with no axiom of choice the mechanisms to prove the axiom of cardinality are so ugly, we wouldn't want to think about it. However, a short look at the relevant texts will show that at least the last statement of the previous paragraph is still true. On the other hand, this has nothing to do with whether a Turing Machine needs infinite memory: it does not. After $n$ steps, a Turing Machine (say, for simplicity, with one ended strip), will only need the first $n$ places of the strip. This implies that every Turing Machine that stops needs only a finite amount of memory. Of course, it will need a different amount of memory for every input, and in general, that amount is infinite. Notice how in the text above, sound mathematical arguments are presented, with a reference to relevant texts where it would be to encumbered to present the argument. This is the way it should be. If you are receiving this message in response to a news posting, please understand that all universities provide courses about this subjects, so it is seldom necessary to make wild guesses. Some high schools also offer classes on these subjects. Here's a section about the basic mathematical infinities. Perhaps you were unaware of these facts before you got swallowed by an arguement. It's not only a good read; it's critical to understanding the terms you are talking about. Two mathematical sets, A and B, are said to be equi-potent if there is a one-to-one and onto function from A to B. Equi-potency is easily seen to be reflexive (A is equi-potent to A), symmetric (if A is equi-potent to B, B is equi-potent to A) and transitive (if A is equi-potent to B, and B is equi-potent to C, then A is equi-potent to C). A is said to be no more potent then B is there is a one-to-one function from A to B. A clever argument, which we will not repeat here, shows that is A is no more potent then B and B is no more potent then A, then A and B are equi-potent. B is said to be more potent then A if A is no more potent then B, but they are not equi-potent. Cantor's diagonal argument proves that A is less potent then the set of all functions from A to the set {0, 1}. Aleph null is the set of natural numbers. A set is said to be of cardinality aleph null is it is equi-potent with the natural numbers. The continuum is the set of functions from the natural numbers to {0, 1}. A set is said to be of the power of the continuum if it is equi-potent to that set. The continuum hypothesis is that there are no sets which are less potent the the continuum and more potent then aleph null. This has been proved to be independant of the other axioms of set theory. It's even more annoying when people say obviously incorrect things, or agree with previous such things. Please don't do that. I'm honestly not trying to annoy you! I'm just trying to give tips about what works well in mathematics, and what doesn't. This used to be standard fare before one said anything said anything about infinities, but now something seems to be lost. -- This is a parody, and should not be taken seriously. However, the gist of it is true: please try to have a mathematical clue before saying anything about infinities. There are traps for the uninitiated! From warren at baker.ie Fri Sep 17 11:38:52 1999 From: warren at baker.ie (war]) Date: Fri, 17 Sep 1999 16:38:52 +0100 Subject: JPython and groupdict? Message-ID: <7rtn97$rju$1@news1.news.iol.ie> I wonder can anyone let me know if I can get the following Python to run in JPython: [In Python] >>> import re >>> re.compile('a(?P.*)c').match('abc').groupdict() {'mid': 'b'} [JPython] >>> import re >>> re.compile('a(?P.*)c').match('abc').groupdict() Traceback (innermost last): File "", line 1, in ? AttributeError: instance of 'org.python.modules.MatchObject' has no attribute 'g roupdict' Thanks in advance, Warren. From gmcm at hypernet.com Sat Sep 25 09:18:25 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 25 Sep 1999 09:18:25 -0400 Subject: string.split and re.split inconsistency In-Reply-To: <7sif27$guu$1@dokkum.cs.uu.nl> Message-ID: <1273857204-9580684@hypernet.com> Han-Wen Nienhuys writes: > Is there any particular reason why string.split and re.split tke > arguments in different order? I think it is confusing, and would > prefer to have it fixed (although I realise that a backwards > compatible fix is hard) > > libre has split(pattern, string) and libstring has split(string, > sep) In string split, the string is the "object" and sep is a qualifier. In re, the "object" is the pattern. If you compile the pattern, it already has a split method (that takes a string). In 1.6, split will be a method of string objects. So the confusion will go away, just not the way you want. (Your solution would make split inconsistent with the other functions in whichever module you changed). - Gordon From nosleep at atl.mediaone.net Sat Sep 11 12:37:28 1999 From: nosleep at atl.mediaone.net (Kristopher Johnson) Date: Sat, 11 Sep 1999 16:37:28 GMT Subject: yacc/lex for Python Message-ID: <37DA861F.57212BC3@atl.mediaone.net> Are there any lex- or yacc-like tools available for Python? - Kris From jfisher at are.berkeley.edu Fri Sep 3 15:51:01 1999 From: jfisher at are.berkeley.edu (John Fisher) Date: Fri, 03 Sep 1999 19:51:01 GMT Subject: Printing data members of a class References: <7qk6f6$8cj$1@nnrp1.deja.com> Message-ID: <7qp8qv$u2j$1@nnrp1.deja.com> In article , Michael Hudson wrote: > John Fisher writes: > > > > >>> class x: > > ... data = array([1, 2]) > > Honk! Honk! You don't actually write it like that do you? You're > setting yourself up for the famous mutable class attribute problem. Oh, no! The utility of that class would be pretty limited anyway. I was just trying to fabricate the simplest example that illustrated my problem. > A point to bear in mind: __repr__ must return a string. Don't do this: > > class x: > ... > def __repr__(self): > print self.data > > do this: > > class x: > ... > def __repr__(self): > return `self.data` > > This trips me up every now and again. Heh heh. How about: class x: ... def __repr__(self): print self.data, return '' But seriously, thanks for the replies, guys. > HTH, > Michael > John Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From jeremy at cnri.reston.va.us Tue Sep 7 10:04:21 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Tue, 7 Sep 1999 10:04:21 -0400 (EDT) Subject: "if" syntax error In-Reply-To: <7r1i82$7s2@dfw-ixnews8.ix.netcom.com> References: <37D138C1.3EABC811@dialnet.net> <7qrkg4$6g1@dfw-ixnews21.ix.netcom.com> <37D42D1D.8A10016A@hotmail.com> <7r1i82$7s2@dfw-ixnews8.ix.netcom.com> Message-ID: <14293.7013.621596.946861@bitdiddle.cnri.reston.va.us> >>>>> "AM" == Aahz Maruch writes: AM> In article <37D42D1D.8A10016A at hotmail.com>, Andrew Kesterson AM> wrote: >> Ugh... I'm a C programmer by nature.. Python's indentation >> rules are going to take some DEFINITE getting used to.... AM> Yup. I still hate it. OTOH, it does lead to more readable AM> code, IMO. -- --- Aahz (@netcom.com) Does that mean you hate readable code? Jeremy From gmcm at hypernet.com Tue Sep 21 14:29:42 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 21 Sep 1999 14:29:42 -0400 Subject: Python at work In-Reply-To: <37E7B894.4CE9849F@EarthLink.Net> Message-ID: <1274184062-62443636@hypernet.com> Greg Copeland wrote: > I'm a consultant and currently wanting to use Python and wxPython > on a Win32 platform (Win95 more than likely). The plan is to use > this as a client interface to an Access97 database (thus the need > for ODBC). I have created a simple Access database and tried a > couple of SQL queries against it from Python. Things do seem to > work. Now, having said that, are there any glaring issues that > I'm missing. I certainly don't want to offer this solution to my > client only to have it blow up in my face because of some obtuse > issue; especially if it's currently well known. In short, does > the above sound like reliable combination? Are there any issues > that should raise a flag or cause alarm? If you are planning on having the DB open by multiple users, get off of Access and onto a real DB (Access is not a server - Sybase's SQLAnywhere will kick it's butt). Also use Marc- Andre Lemburg's mxODBC module for ODBC (take the Starship link off python.org and look for him in the Crew Quarters), because it's a good deal more sophisticated. If it's all on one desktop, use whatever feels best! (Most of mxODBC's advanced features will be lost on Access). - Gordon From tim_one at email.msn.com Wed Sep 22 00:54:29 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 22 Sep 1999 00:54:29 -0400 Subject: YA-Newbie: baffled by deepcopy/pickle issues... In-Reply-To: <8E48C2767PaCmAnRDLM@161.48.81.148> Message-ID: <000101bf04b6$8d8ab520$342d153f@tim> [Fred Pacquier] > I'm working on my first sizable app in Python/wxPython, and I was making > good progress until I hit this snag. > > ... [much background but no code and no tracebacks] ... > > Any hints on how to track this one down ? Thanks, Easy: create a *small* app that displays the same symptoms. The answer will likely become obvious in the process of doing that. If it doesn't, you'll have a small piece of executable code to post, and the answer will be obvious to someone else. code-fixes-itself-if-you-let-it-ly y'rs - tim From MHammond at skippinet.com.au Tue Sep 7 20:49:30 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 8 Sep 1999 10:49:30 +1000 Subject: Initial thrashing about question...embedding Python References: <37d7ad42.1540192@news.newsguy.com> Message-ID: <7r4br5$8va$1@m2.c2.telstra-mm.net.au> Owen F. Ransen wrote in message <37d7ad42.1540192 at news.newsguy.com>... >If I embed Python in a Windows app which does not >have a text output screen, where does all the printed >output go? As for normal Python, it goes to whereever sys.stdout or sys.stderr is pointing. In most GUI apps, this goes nowhere until you explicitely change it. Pythonwin for example simply defines an instance with a "write" method, and sets sys.stderr and sys.stdout to that. This class instance then manages writing it to the GUI window. In the sort term (ie, while developing) you may find the win32 module "win32traceutil" useful - add this as the first line of Python code executed, and all output will be redirected to another process (you can see the output by running win32traceutil as a script in another process). Again, this is what I use for Pythonwin when I manage to break its startup code during development - at least I can see the tracebacks that prevent my real object from being instantiated. Mark. From " HPeter.Friedrichs" at alliedsignal.com Mon Sep 13 18:11:21 1999 From: " HPeter.Friedrichs" at alliedsignal.com (H. P. Friedrichs) Date: Mon, 13 Sep 1999 15:11:21 -0700 Subject: How do you exit python during execution of script? References: <37DD64AE.2CCA341@alliedsignal.com> <7rjq2g$oe1@dfw-ixnews14.ix.netcom.com> Message-ID: <37DD7688.B43910B4@alliedsignal.com> Why does this generate an exception? import sys try: print "normal operation" sys.exit() # I want to leave the script here except: print "something went wrong" sys.exit() # instead, I dump out here...why? #...script continues here.... #..... #.... Aahz Maruch wrote: > In article <37DD64AE.2CCA341 at alliedsignal.com>, > H. P. Friedrichs wrote: > > > >Is 'exit' an option? If so, how do you use it? > > import sys > sys.exit() > -- > --- Aahz (@netcom.com) > > Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) -- ----------------------------------------------- | The opinions expressed here are my own, | | and not necessarily those of my employer. | ----------------------------------------------- From jesse at student.usyd.edu.au Tue Sep 14 10:37:43 1999 From: jesse at student.usyd.edu.au (Jesse Sweeney) Date: Tue, 14 Sep 1999 14:37:43 GMT Subject: equivalent of enum? References: <14296.14104.456361.61180@dolphin.mojam.com> <37DE4A92.D4F50CE9@strs.co.uk> Message-ID: <37de5928.24771401@news.usyd.edu.au> On Tue, 14 Sep 1999 14:16:03 +0100, Ian Clarke wrote: > >> In more direct answer to your question, there is no enum type in Python. >> It's simple enough to declare objects that you treat as constants, however: > >I have always been a little dissatisfied with the way enums are normally >implemented, namely with an integer. Why not make an "enum collection" >type (I am sure there must be a better name). In essence this would be >an object which had several enums, say: > >Sex: (male | female) >employed?: (yes | no) >os: (linux | windows | macos) > >etc. Normally these would be treated as 3 enums and would be stored as >three integers - 3 X 32 bits, or 96 bits, yet you can actually store >this data using just 4 bits (and that would contain a little bit of >redundancy). The first bit would determine male or female, the second >bit employed or unemployed, and the third and fourth bits would store >the os. > >In practice this could be implemented by creating an enum class. We >could then create a function which takes an object containing enums (and >possibly allow these to be mixed with other data types) and compresses >the data bit by bit. In the end we would get really efficient data >storage. This is the equivalent of a C struct with bit fields (and I assume you could implement it that way for a Python extension type). However, the general consensus[1] over in C-land is that using bit fields is usually not a great idea, or at least usually a misguided one. The reason being that although the data space is reduced, the size of the code generally increases. Also, since integers conveniently fit so nice and snugly into CPU registers, accessing fields in C is typically a fair bit slower than accessing the separate ints or chars. Cheers, Jesse. [1] Offtopic trivia of the day: I recently learned that 'consensus' is the most frequently misspelled word in the English language. 'Brunet' comes in second. From quentin at att.com Thu Sep 30 04:00:31 1999 From: quentin at att.com (Quentin Stafford-Fraser) Date: Thu, 30 Sep 1999 09:00:31 +0100 Subject: ANN: PyGarmin - Python classes for talking to Garmins Message-ID: <37F3189F.79D8413E@att.com> PyGarmin - Python classes for talking to Garmins ================================================ I've written some Python classes which implement much of the protocol used by Garmin GPS receivers to talk to each other and to PCs. It's based on the official Garmin spec. It's certainly not complete yet, but it allowed me to write a small app which transfers waypoints and track information to and from my GPS 12XL. You can find out more at http://www.uk.research.att.com/~qsf/garmin/ . Let me know if it's useful! Quentin -- ---------------------------- Dr Quentin Stafford-Fraser AT&T Laboratories Cambridge http://www.uk.research.att.com/~qsf From 71351.356 at compuserve.com Sat Sep 25 10:27:06 1999 From: 71351.356 at compuserve.com (T. C. Mits) Date: Sat, 25 Sep 1999 10:27:06 -0400 Subject: Source line number for log purpose (newbie) References: <7shiqh$d96$1@ssauraaa-i-1.production.compuserve.com> <19990925130431.B11328@optiplex.palga.uucp> <7sig2t$oar$1@ssauraaa-i-1.production.compuserve.com> Message-ID: <7simbr$7s3$1@ssauraac-i-1.production.compuserve.com> Ok. I looked in Exception library and don't see the relevance. I am logging normal code, not exceptions. For example, log.prtl( SERIOUS, "About to create dest file %s" % newfilename) In this case, to help maintainers of the code, I want to also log the line number where this statement is found in the source. I'm now thinking this has to done by digging into the Python extension mechanisms and system variables deep in the system? T. C. Mits <71351.356 at compuserve.com> wrote in message news:7sig2t$oar$1 at ssauraaa-i-1.production.compuserve.com... > Thanks, I'll look at the Exception module again. > > Gerrit Holl wrote in message > news:19990925130431.B11328 at optiplex.palga.uucp... > > T. C. Mits: > > > In c there was a way to get the current source line number via a macro, > > > __LINE__. > > > > > > I need to be able to do the same thing. I created a logger class that > uses > > > a level setting. At high levels I want to > > > log the source line number where the inline log.prtl( level, msg) method > > > call appears. > > > > > > I'm sure this is easy but am getting lost digging through the Python > source > > > and docs. > > > > > > > That's possible via the 'Exception' module. > > > > regards, > > Gerrit. > > -- > > RTFM: Read That FreshMeat > > > > > > From bwarsaw at cnri.reston.va.us Mon Sep 20 20:47:04 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Mon, 20 Sep 1999 20:47:04 -0400 (EDT) Subject: Marking translatable strings References: <7s339v$d78@dfw-ixnews3.ix.netcom.com> Message-ID: <14310.54664.634772.150567@anthem.cnri.reston.va.us> >>>>> "AM" == Aahz Maruch writes: AM> Y'know, it might help those of us with an interest in I18N but AM> little actual experience if you posted some resources that AM> gave information about what the heck a "PO file" is and how AM> one is suposed to generate and access it in other languages. AM> (Yes, I could search the web, but it'd be difficult for me to AM> determine which sites are the most useful.) I thought I had included a link to the GNU gettext package. Between it, the Solaris manpages, and Martin von Loewis' paper from IPC6, you've about exhausted my knowledge of internationalization issues. Hopefully some other folks will have more useful information, but here are two links: GNU gettext (follow the online manual link) http://www.gnu.org/software/gettext/gettext.html Martin's paper (search down towards the end of the page) http://www.python.org/workshops/1997-10/proceedings/ -Barry From doughellmann at home.com Wed Sep 8 21:14:31 1999 From: doughellmann at home.com (Doug Hellmann) Date: Thu, 09 Sep 1999 01:14:31 GMT Subject: carriage return / Tkinter References: <7r5s4q$91n$1@nntp3.uunet.ca> Message-ID: <37D70B2E.B0DED81D@home.com> Greg Wilson wrote: > > Hi. I've created an Entry widget using Tkinter, and would like a command > run when the user presses carriage return --- how do I do this? > Thanks, > Greg Bind your callback to the event '': entry.bind('', my_handler) def my_handler(event): print 'Got a "" event.' Doug From mwh21 at cam.ac.uk Fri Sep 3 09:48:19 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: Fri, 3 Sep 1999 14:48:19 +0100 Subject: UK Python Programming Job Opportunity In-Reply-To: <7qof8u$mh2$1@newsreader1.core.theplanet.net> References: <7qof8u$mh2$1@newsreader1.core.theplanet.net> Message-ID: On Fri, 3 Sep 1999, John Parkey wrote: > If there is anybody who is interested in a 6-9 month contract using Python, > in Bucks UK, please drop me a line. Not yet... > jparkey at rapidbs.com > > (I hope nobody is offended by my posting this to the newsgroup?) Well, I'm certainly not, and I'll be even less offended if you are still doing it in twenty months or so when I graduate... Regards, Michael From fredrik at pythonware.com Tue Sep 28 04:58:25 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 28 Sep 1999 08:58:25 GMT Subject: Python Berkley DB and speed issues References: <37F06752.7D98775@bibsyst.no> Message-ID: <009001bf098f$a1599840$f29b12c2@secret.pythonware.com> Thomas Weholt wrote: > Was just wondering about how Python is when it comes to speed using it`s > built-in dictionaries. I`m converting a perl-project where a Berkley DB > hash-table stored several million entries about files stored on cd-roms. > The speed in the perl-project was ok, and it seems like Python has a > very similar approach to this method, using pickle- and shelve-modules ( > or Berkley DB). My question is : will the speed drop as the data gets > larger, using pickle and shelve, or do I have to use Berkely DB? note that shelve runs on top of a hashed database engine, such as Berkeley DB (via dbhash/bsddb) or gdbm. if no such engine is installed, it falls back to a "slow-and-simple" pure Python implementation: http://www.python.org/doc/current/lib/module-anydbm.html From fdrake at acm.org Tue Sep 7 15:28:10 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Tue, 7 Sep 1999 19:28:10 GMT Subject: CGIHTTPServer howto? In-Reply-To: <37d54d12.1058989@read.news.global.net.uk> References: <7qt9cn$rp7$1@bunyip.cc.uq.edu.au> <37D44115.EA834C@ix.netcom.com> <7r2ndf$b01$1@bunyip.cc.uq.edu.au> <37d54d12.1058989@read.news.global.net.uk> Message-ID: <14293.26442.739967.306563@weyr.cnri.reston.va.us> Dave writes: > python library as it stands (or at least the fact that it is UNIX > specific should be documented). It would be better off included with I've adjusted the documentation source to reflect this; thanks for pointing it out. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From davidopp at megsinet.net Fri Sep 3 08:48:12 1999 From: davidopp at megsinet.net (David Oppenheimer) Date: Fri, 03 Sep 1999 08:48:12 -0400 Subject: Spanish Inquisition?! Message-ID: <37CFC38C.20A9C267@megsinet.net> In a previous thread (about languages interpreted versus languages compiled) there was talk of the Spanish Inquisition. I am guessing that this is 1) a joke or 2) the code name for a "secret" project to create compiled code from python code and thereby permanently blur the line for Python. Anyone know anything about this? I know no one ever expects the Spanish Inquisition, but if its coming I'd like to know about it. David O. "Any Sufficiently Advanced Technology Is Indistinguishable From Magic" - Arthur C. Clarke P.S. Creating compiled code from Python that didn't require the interpreter to be distributed with it would be high magic indeed. From guido at cnri.reston.va.us Thu Sep 2 08:44:40 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 02 Sep 1999 08:44:40 -0400 Subject: And Now For Something Completely Similar !!! References: <37CCDAF8.E79FE189@megsinet.net> <028f01bef450$9d976ba0$f29b12c2@secret.pythonware.com> <37CD22A5.4DD4B332@megsinet.net> <006f01bef47c$c0679b10$f29b12c2@secret.pythonware.com> <37CD9117.DD7E5100@megsinet.net> <37cd9f19.13139313@news.erols.com> Message-ID: <5l906p5vpj.fsf@eric.cnri.reston.va.us> kernr at mail.ncifcrf.gov (Robert Kern) writes: > On Wed, 01 Sep 1999 16:48:24 -0400, David Oppenheimer > wrote: [...] > >2) Why isn't a module which has broad appeal like the Python Imaging Library > >included with the core Python 1.5.2 package? > > Release schedules, lean&mean-ness, not enough people needing to > manipulate images in Python, etc. You said it. The key issues here are independent developers and independent development schedules; I can't afford to repackage Python each time a new PIL comes out and I certainly don't want to have to wait until PIL is stable before releasing Python. This is a fact of life, and it's how most software distributions are done. I *do* package a Tcl/Tk version with Python 1.5.2 for Windows (as you noetd latest in your post); this was done because (1) Tcl/Tk 8.0.5 was pretty stable at the time, and (2) I needed Tcl/Tk in order to make IDLE usable. It turns out that Tcl/Tk 8.1 and 8.2 are not compatible with standard Python 1.5.2, so this ended up being a good decision; nevertheless I may decide to drop this in the future (or I may decide to keep it) depending on the pace of development in the Tcl/Tk world. Note that this opens up a market for "packaging companies" (like Red Hat does for Linux) which bundle stable versions of lots of software together for ease of installation. More power to them...! > >For that matter why not include > >NumPy also. > > > That one, I'd have to agree with. I think that NumPy arrays and > ufuncs should become core datatypes. They're just too useful. > Yeah... This is actually in my plans for Python 1.6 (although I haven't started working on it honestly). --Guido van Rossum (home page: http://www.python.org/~guido/) From MHammond at skippinet.com.au Thu Sep 2 01:32:25 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Thu, 2 Sep 1999 15:32:25 +1000 Subject: Adding manual access to IDLE References: <37CB245C.3AF@loop.com> <37CDB31B.EFF@loop.com> Message-ID: <7ql25d$si5$1@m2.c2.telstra-mm.net.au> Jesse Weinstein wrote in message <37CDB31B.EFF at loop.com>... >I realise that my code is rather unportable ;) but I don't know how to >get more portable code, such as portable browser or doc location. If >anyone can help, it would be gratefully apreacieated. I can help with _less_ portable code For Windows, it may make sense to attempt an import of "win32api" - if that succeeds, you have access to WinExec() which will invoke the correct program registered for HTML, and also to the registry functions that you can use to get the location of the help files (assuming they have not been moved since installation. Mark. From jsouto at dnet.br Sat Sep 11 09:24:27 1999 From: jsouto at dnet.br (Jairo Souto) Date: Sat, 11 Sep 1999 10:24:27 -0300 (EST) Subject: Text UI Message-ID: dwalker at iximd.com wrote: > [snip] > It's not perfect, could stand to be looked over by a real Pythoneer, but > it works for my use right now. I have webspace so I probably should put it > up for anyone to come and get it. In the meantime, if someone wants to play > with it, send me email and I'll send it to ya right away. > > Damond yes. I want look at it as I need to go on ttys for an internal mysql application. --Jairo Souto jsouto at dnet.br (+55) (38) 9971-0014 From kernr at mail.ncifcrf.gov Wed Sep 1 18:28:19 1999 From: kernr at mail.ncifcrf.gov (Robert Kern) Date: Wed, 01 Sep 1999 22:28:19 GMT Subject: Printing data members of a class References: <7qk6f6$8cj$1@nnrp1.deja.com> Message-ID: <37cda459.14483153@news.erols.com> On Wed, 01 Sep 1999 21:39:53 GMT, John Fisher wrote: >Hey folks, > >I'm trying to set up a class so that when instances of it are printed, a >Python prints just a certain data member of the instance. For example: > >>>> class x: >... data = array([1, 2]) > >>>> y = x() >>>> y >[1 2] > >or at least >>>> print y >[1 2] > >I've tried playing around with repr, and defining __repr__() in the >class, but haven't had any luck yet. I'd appreciate any suggestions on >how to do this. from Numeric import * # That is what you're using, right? class x: data = array([1, 2]) def __str__(self): return str(self.data) __repr__ = __str__ # If you must; it would be better to have __repr__ return a string # that could be meaningfully eval'ed, but if you need the # behaviour in your first example, this is how to do it. >Thanks! > >John Robert Kern | ----------------------|"In the fields of Hell where the grass grows high This space | Are the graves of dreams allowed to die." intentionally | - Richard Harter left blank. | From moshez at server.python.net Sat Sep 4 02:06:29 1999 From: moshez at server.python.net (Moshe Zadka) Date: Sat, 4 Sep 1999 02:06:29 -0400 (EDT) Subject: raw_input() and readline Message-ID: The documentation of raw_input() says it trys to use readline whenever available, but there seems to be a problem: file t.py: print raw_input() If I use python >>> execfile("t.py") Then I have readline functionality, but if I use python t.py I don't have any readline functionality. I would appreciate any help. From bob at horvath.com Sat Sep 25 08:53:20 1999 From: bob at horvath.com (Bob Horvath) Date: Sat, 25 Sep 1999 12:53:20 +0000 Subject: wxPython on Debian Linux References: <37E8C20A.F4051E56@horvath.com> <87u2omg1yc.fsf@baal.winnegan.fake> <87hfkkrth1.fsf@baal.winnegan.fake> Message-ID: <37ECC5C0.F64195A2@horvath.com> Siggy Brentrup wrote: > Lars Marius Garshol writes: > > > * Bob Horvath > > | > > | I haven't tried it myself, but itsn't it at > > | > > | http://www.debian.org/Packages/unstable/interpreters/python-wxwin.html > > > > * Siggy Brentrup > > [...] > > > | But you can always get the source package and build you own local > > | .deb. > > > If you do, please let me know. > > No chance, I have python installed locally updating the sources > regularly from the CVS tree and am using Tkinter and Pmw 0.8.1. > > Taking too much space, Bob? Bope, I just istalled it. Very nice! > > > CU > Siggy > > -- > noch nichts Aufregendes: > > Siggy Brentrup - bsb at baal.infodrom.north.de - voice: +49-441-6990134 From bowman at montana.com Tue Sep 14 09:58:54 1999 From: bowman at montana.com (bowman) Date: Tue, 14 Sep 1999 07:58:54 -0600 Subject: French pun on Python! :-) References: Message-ID: <37DE549E.2FBDB88A@montana.com> Fran?ois Pinard wrote: > > for the word `piton'. A `piton' is a familiar word to design any mechanical > device on which someone pushes, like an electrical button, or often, one And a 'piton' is a small mechanical aid one hammers into obscure cracks to allow climbing an otherwise impossible pitch. Maybe the IS a parallel here. -- Bear Technology Making Montana safe for Grizzlies http://people.montana.com/~bowman/ From khowe at performance-net.com Fri Sep 17 14:07:18 1999 From: khowe at performance-net.com (Kevin Howe) Date: Fri, 17 Sep 1999 15:07:18 -0300 Subject: lopping over Dictionaries Message-ID: <3uvE3.157430$5r2.248606@tor-nn1.netcom.ca> Is it possible to iterate through list of keys in a Dictionary? something like this: tel = {'jack': 4098, 'sape': 4139} for (name, value) in tel.keys: print name, value Thanks From MHammond at skippinet.com.au Tue Sep 14 19:29:01 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 15 Sep 1999 09:29:01 +1000 Subject: TreeCtrl Object (win32ui) References: <7rm9bb$1rh$1@nnrp1.deja.com> Message-ID: <7rmlor$jk4$1@m2.c2.telstra-mm.net.au> Ian wrote in message <7rm9bb$1rh$1 at nnrp1.deja.com>... >If I were to be doing this in C++ I would use the HitTest function >and pass to it the point at which the right mouse button was depressed. >This function doesn't appear to be available through win32ui.pyd. Is >there another way around this? Nope - I struggled with the same thing - the half-baked registry editor stopped where it is for exactly that reason :-( Please feel free to either add the missing methods yourself, or tell me exactly what you need added to make this work. >I'm new to using this library (1 week) and this has been the first >real roadblock I have faced. My prototype application has really >advanced very quickly and I think it would have taken me at least >3-5 times as long if I were to be using C++. Great work Mark and >all those who have (and continue to) help you. Thanks :-) Mark. From aahz at netcom.com Sun Sep 26 11:50:42 1999 From: aahz at netcom.com (Aahz Maruch) Date: 26 Sep 1999 15:50:42 GMT Subject: Intelligent datastructure? References: Message-ID: <7slfci$snu@dfw-ixnews8.ix.netcom.com> In article , Magnus L. Hetland wrote: > >I only have two datatypes - integers and sequences. The thing I have >been thinking about lately is the implementation of the sequences. I >want them to be usable both as simple lists or arrays, and as general >hash-tables (with numeric keys) without the user having to care about >the difference... Thus, you could make yourself a sequence like this: > > s = [1,2,3] > >and then do something like > > s[100] = 4 > >without getting any complaints. (I think I will only allow positive >integers as indices, but I'm not sure...) > >If I now reference s[50], for instance, or s[400], I would like to get >0, which is the default value for all variables (or elements). > >I would like feedback on that strategy (of basically allowing anything >to be done without throwing index-exceptions or stuff like that), but >what I am mainly interested in is the task of making these sequences >"intelligent". Being generally interested in simple code, if I were in your shoes I'd probably just use a dict-based class. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From aa8vb at yahoo.com Thu Sep 9 09:32:06 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Thu, 9 Sep 1999 09:32:06 -0400 Subject: tkinter: identifying callback button? In-Reply-To: <7r7anm$21a7$1@hub.org>; from Lewis on Thu, Sep 09, 1999 at 03:49:10AM +0000 References: <7r7anm$21a7$1@hub.org> Message-ID: <19990909093206.A1428575@vislab.epa.gov> Lewis: |I have a bunch of (named) buttons which call the same callback. |I've been trying to figure out how (or if) I can get the callback |function to be able to identify which one. | | for x in range(0,5): | b = Button(frame,text='#%s' % x,command=self.xxx, name='b%s' % x) | b.pack() I asked this several months ago. Here are the answer highlights: 1) Use a generic callable object as a wrapper (__call__) 2) Use a specific callback class object 3) Use a lambda or function (written in-line or generated by a function) 4) Write python call code as a string and "exec" it in a lambda or function They sound tricky, but they're really not. The attached simple code shows how to use these techniques for both full and partial resolution of callback arguments at registration time. (Note: "partial" means specifying some of the arguments at registration time, while leaving others until invocation time -- e.g. for cases where your Tk callback takes arguments). My personal favorite for full resolution is #1 (callable object). Clean appearance, and no custom code to write per-callback to make it fly. Randall -------------- next part -------------- #!/usr/bin/env python # # closure.py - Demonstrate various ways to generate and use # parameterized callback functions. # # Examples are shown for both total and partial resolution # of callback arguments at registration time. # # Techniques: lambdas, callable objects, deferred execution. # class Call: """Instances of this class store a function as well as a list of arguments. When they are called, the function will be called together with the arguments used for creating the instance. Slightly different than lambda, but nicer syntax.""" def __init__ (self, func, *args): self.func = func # save the function (or bound method, or ...) self.args = args # save the arguments to use def __call__ (self): apply (self.func, self.args) # call function, using args as arguments. class CallbackHookFull: """ Demonstrates various ways to do full resolution of callback arguments at registration time, and return/invoke the callback. """ def ExecCommand(self,command): exec command def DoIt(self,color): """ The callback we eventually want to end up calling, but with no args. """ print color def Invoke(self): self.doit_cb() #--------------------------------------------------------------------- def Register1( self, color ): """ Generate a callable class that'll invoke the callback w/ args """ self.doit_cb = Call( self.DoIt, color ) #--------------------------------------------------------------------- class ColorCallback: def __init__( self, obj, color ): self.obj = obj self.color = color def callback( self ): self.obj.DoIt( self.color ) def Register2( self, color ): """ Wrap the args in a class, and have a class method with the appropriate signature do the calling. """ self.doit_cb = CallbackHookFull.ColorCallback( self, color ).callback #--------------------------------------------------------------------- def Register3a( self, color ): """ Generate a closure which is a wrapper around the invocation w/ args """ self.doit_cb = lambda callback=self.DoIt, color=color: \ callback(color) #--------------------------------------------------------------------- def Register4a( self, color ): self.doit_cb = lambda callback=self.DoIt, color=color: \ callback(color) #--------------------------------------------------------------------- def Register5a( self, color ): """ Build a string with the invocation we want, and then build a closure that will interpret that string when invoked. """ self.doit_cb = lambda self=self, command="self.DoIt('"+color+"')": \ self.ExecCommand(command) #--------------------------------------------------------------------- def BuildCallback3b( self, callback, color ): return lambda callback=callback, color=color: callback(color) def Register3b(self,color): """ Nicer-looking 3a with lambda generated by a function """ self.doit_cb = self.BuildCallback3b( self.DoIt, color ); #--------------------------------------------------------------------- def BuildCallback4b( self, callback, color ): def _( callback=callback, color=color ): callback(color) return _ def Register4b(self,color): """ Same as the 3b, but use def instead of lambda; exactly the same because functions are just named lambdas. """ self.doit_cb = self.BuildCallback3b( self.DoIt, color ); #--------------------------------------------------------------------- def BuildCallback5b( self, callback, color ): return lambda self=self, command=callback+"('"+color+"')" : \ self.ExecCommand(command) def Register5b(self,color): """ Nicer-looking 5a with lambda generated by a function """ self.doit_cb = self.BuildCallback5b( "self.DoIt", color ) #=============================================================================== class CallbackHookPartial: """ Demonstrates various ways to do partial resolution of callback arguments at registration time (i.e. for cases where the callback takes argument(s) at invocation time as well as registration time), and return/invoke the callback. """ def ExecCommand(self,command): exec command def DoIt(self, color, what_to_paint): """ The callback we eventually want to end up calling, but with one arg (what_to_paint) instead of two. """ print what_to_paint + " = " + color def Invoke(self): self.doit_cb( "walls" ) #--------------------------------------------------------------------- class ColorCallback: def __init__( self, callback, color ): self.cb = callback self.color = color def callback( self, what_to_paint ): self.cb( self.color, what_to_paint ) def Register2( self, color ): """ Wrap the args in a class, and have a class method with the appropriate signature be the callback. """ self.doit_cb = CallbackHookPartial.ColorCallback(self.DoIt, color).callback #--------------------------------------------------------------------- def Register3a( self, color ): """ Generate a closure which is a wrapper around the invocation w/ args """ self.doit_cb = lambda what_to_paint, callback=self.DoIt, color=color: \ callback(color, what_to_paint) #--------------------------------------------------------------------- def BuildCallback3b( self, callback, color ): return lambda what_to_paint, callback=self.DoIt, color=color: \ callback(color, what_to_paint) def Register3b(self,color): """ Nicer-looking 3a with lambda generated by a function """ self.doit_cb = self.BuildCallback3b( self.DoIt, color ); #--------------------------------------------------------------------- def BuildCallback4b( self, callback, color ): def _( what_to_paint, callback=self.DoIt, color=color ): \ callback(color, what_to_paint) return _ def Register4b(self,color): """ Same as the 3b, but use def instead of lambda; exactly the same because functions are just named lambdas. """ self.doit_cb = self.BuildCallback3b( self.DoIt, color ); if __name__ == "__main__": cb = CallbackHookFull() cb.Register1('orange') cb.Invoke() cb.Register2('white') cb.Invoke() cb.Register3a('blue') cb.Invoke() cb.Register5a('red') cb.Invoke() cb.Register3b('green') cb.Invoke() cb.Register4b('purple') cb.Invoke() cb.Register5b('yellow') cb.Invoke() print "--------" cb = CallbackHookPartial() cb.Register2('white') cb.Invoke() cb.Register3a('blue') cb.Invoke() cb.Register3b('green') cb.Invoke() cb.Register4b('purple') cb.Invoke() From dhellmann at zcentral.com Thu Sep 23 21:06:55 1999 From: dhellmann at zcentral.com (Doug Hellmann) Date: Fri, 24 Sep 99 01:06:55 GMT Subject: pybox utility library Message-ID: pybox This library consists of lots of Python utility classes and scripts including a base class for creating command line applications with formatted help output and argument handling, a user preference file management class, and a class for accessing the win32 registry with a higher level of abstraction than the win32api module provides. See http://members.home.net/doughellmann/pybox/index.html for more details. (Previous users of the pybox library please notice that the web site has moved.) Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.

pybox utility library - Python utility classes and scripts; such as a base class for creating command line applications with formatted help output and argument handling, user preferences management, and a high-level Win32 registry access class. (23-Aug-99) -- ----------- comp.lang.python.announce (moderated) ---------- Article Submission Address: python-announce at python.org Python Language Home Page: http://www.python.org/ Python Quick Help Index: http://www.python.org/Help.html ------------------------------------------------------------ From billtut at microsoft.com Fri Sep 17 01:42:30 1999 From: billtut at microsoft.com (Bill Tutt) Date: Fri, 17 Sep 1999 05:42:30 GMT Subject: CygWin version Message-ID: <4D0A23B3F74DD111ACCD00805F31D8100DB91215@RED-MSG-50> If your on 95 running doskey will give you command history. NT has the equivalent of doskey always on. Bill > -----Original Message----- > From: Hirsch, John [mailto:JohnH at PHM.GOV.AU] > Sent: Thursday, September 16, 1999 6:07 AM > To: python-list at cwi.nl > Subject: CygWin version > Importance: High > > > Hi all > In the Python tutorial it says "The interactive editing and history > described here are optionally available in the Unix and > CygWin versions of > the interpreter." > Is there a CygWin version of the interpreter and if so where > can I get it. > If not is there another way to get interactive editing and > history in the > command line interpreter. > Thanks in advance > > Jonathan Hirsch > johnh at phm.gov.au > > > From herzog at online.de Sat Sep 4 05:01:19 1999 From: herzog at online.de (Bernhard Herzog) Date: 04 Sep 1999 11:01:19 +0200 Subject: Returning none References: <1275758005-72447341@hypernet.com> <5ORz3.14$JG1.2704@news.shore.net> Message-ID: clgonsal at keeshah.penguinpowered.com (C.Laurence Gonsalves) writes: > def new_apply( f, a ): > try: > result = old_apply( f, a ) > except NoResultError: > return > else: > return result There's one problem with this approach. If the NoResultError is raised whithin f, new_apply should reraise the exception and not just silently return nothing. You could, of course, examine the traceback object to find out where the exception was raised, but that's very ugly and probably implementation dependent. -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://www.online.de/home/sketch/ From davidopp at megsinet.net Wed Sep 29 12:19:48 1999 From: davidopp at megsinet.net (David Oppenheimer) Date: Wed, 29 Sep 1999 12:19:48 -0400 Subject: More Python books coming... References: <5lpuz483p4.fsf@eric.cnri.reston.va.us> Message-ID: <37F23C23.1DD36623@megsinet.net> I found a free e-book that has recently been published on paper and sells for $39.95. I will e-mail this book (about a 1 meg e-mail) to anyone that writes me and requests it. Sincerely, David Oppenheimer Guido van Rossum wrote: > I did a search for Python on Amazon.com and found several new Python > books that are likely to hit the shelves soon. Here's the list: > > The Quick Python Book > Daryl Harms, Kenneth McDonald. Published by Manning > Publications. Expected September 1999. > > Python Essential Reference > David Beazley. With a foreword by Guido van Rossum. Published > by New Riders. Expected October 1999. > > Programming with Python > Tim Altom. Published by Prima Publishing. Expected October 20, > 1999. > > Python and Tkinter Programming > John E. Grayson. Published by Manning Publications. Expected > November 1999. > > Python Annotated Archives > Martin Brown. Published by McGraw-Hill. Expected September 1999. > > Python Programming on Win 32 > Mark Hammond, Andy Robinson. Published by O'Reilly. Expected > September 1999. > > Sams Teach Yourself Python in 24 Hours > Ivan Van Laningham. Published by Sams. Expected November 1999. > > We expect to have a bookstand at the Python conference in January > where you can buy these and other Python books. I've also added this > to http://www.python.org/doc/Books.html. > > --Guido van Rossum (home page: http://www.python.org/~guido/) From Doug at news.vex.net Sun Sep 12 13:03:28 1999 From: Doug at news.vex.net (Lewis) Date: 12 Sep 1999 17:03:28 GMT Subject: ANN: Tk Slashdot Headline Viewer Message-ID: <7rgmd0$2htg$1@hub.org> Inspired by the Slashdot headline viewer demo in the wxPython package, i decided to implement my own in Tkinter. My implementation, while simpler, is much cuter. (-: Should anyone care to try it out, you can snag it from.... http://www.vex.net/~x/python_stuff.html#slashdot ... From mkrisch at radiata.com Thu Sep 23 22:44:09 1999 From: mkrisch at radiata.com (Mark Krischer) Date: Fri, 24 Sep 1999 12:44:09 +1000 Subject: Becoming root within a Python script References: <87zoydrw4u.fsf@baal.winnegan.fake> Message-ID: <37EAE579.2499F85C@radiata.com> why don't you call the python script using sudo, or make a wrapper script that calls sudo .py (sudo lets a user run an executable as root--i know it exists on linux, i assume it can be compiled for other unices....) --mk Siggy Brentrup wrote: > > Fran?ois Pinard writes: > > > Hi, people. I have a small problem, for which I see no elegant solution yet. > > Is there a common idiom I could use? > > > > I would like, within a executing Python started as non-root, ask for the root > > password, and then, continue executing part of the script while being root, > > becoming the previous again after some sub-job is done. > > > > Of course, I can kludge something in, but I would prefer something nice. :-) > > What you are asking for requires suid root scripts, a really bad thing > modern Unices don't allow any more. > > You have to hack up a wrapper written a compiled language, which > starts the interpreter with root priveledge. > > A while ago I did some work on such a beast using an md5 registry for > trusted scripts, but after rethinking I threw it away - just to big a > security risk. > > CU > Siggy > > -- > noch nichts Aufregendes: > > Siggy Brentrup - bsb at baal.infodrom.north.de - voice: +49-441-6990134 From davidopp at megsinet.net Tue Sep 7 20:23:59 1999 From: davidopp at megsinet.net (David Oppenheimer) Date: Tue, 07 Sep 1999 20:23:59 -0400 Subject: 1.5.2 NT install question(s) References: <7r3hib$24f$1@news.wrc.xerox.com> Message-ID: <37D5AC9E.44A69F13@megsinet.net> I would strongly recommend installing Python in a pathway without spaces, as recommended by Robert Kern. Additionally the following may help: It can't find the module because it's not on the PYTHONPATH. Execute this python code to see what directories are in your PYTHONPATH: At a python command line: >>> import sys >>> print sys.path To fix it add this to your autoexec.bat: set PYTHONPATH=c:\Tcl\bin (This is after you go back and install Tcl to the pathway C:\) or add the directory to the value in the Registry at HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\1.5\PythonPath or as a subkey. Hope that helps, David Oppenheimer Mark Jackson wrote: > I've done this twice recently and encountered problems both times. > > On a fresh system (never had Python or Tcl/Tk) things (for example, > PySol) seem to work, but whenever I use Tkinter (specifically, when > _tkinter is imported) I get a warning box about not being able to find > tcl80.dll in the specified path. (tcl80.dll is present, in Program > Files\Tcl\bin.) What's wrong, and how do I put it right? > > On a system where 1.5.1 (with Tcl/Tk) had previously been installed, I > carefully uninstalled both before installing 1.5.2. Here both "import > _tkinter" and "inport Tkinter" are OK, but Tkinter._test() yields: > > TclError: Can't find a usable init.tcl in the following directories: > {} ./lib/tcl8.0 D:/tc18.0/library {D:/Program Files/library} > > This probably means that Tcl wasn't installed properly. > > (init.tcl is present, in Program Files\Tcl\lib\tcl8.0.) What's wrong, > and how do I put it right? > > Thanks in advance. Sorry to be asking such trivial-seeming questions, > but I found nothing helpful through python.org. And I haven't dealt > with the innards of NT enough for its design coherence to become > manifest (yeah, right). > > -- > Mark Jackson - http://www.alumni.caltech.edu/~mjackson > Spend the optimal amount of time on each decision > and pretty soon you run out of life. > - Steven Waldman From madq968 at djeksta.comNOSPAM Thu Sep 30 16:53:44 1999 From: madq968 at djeksta.comNOSPAM (madQ) Date: 30 Sep 1999 20:53:44 GMT Subject: Download Ia.n.i.!!! It's free! Message-ID: <7t0iko$kdr$17@nslave1.tin.it> Download Ia.n.i. RemoteControlSystem 1.2 beta. It's free!!! New site: http://jump.to/IaniProject From zessin at my-deja.com Sat Sep 4 05:14:35 1999 From: zessin at my-deja.com (Uwe Zessin) Date: Sat, 04 Sep 1999 09:14:35 GMT Subject: PYTHON on ALPHA VMS 7.2? References: <37D005D9.38C27D05@msx.upmc.edu> Message-ID: <7qqnto$u71$1@nnrp1.deja.com> In article <37D005D9.38C27D05 at msx.upmc.edu>, Jack Lewis wrote: > Has anyone successfully built PYTHON on ALPHA VMS 7.2 ? > > As well as been able to compile and link 'C' programs with Embedded > PYTHON calls? > I can't seem to get past the link errors: > > %LINK-W-NUDFSYMS, 2 undefined symbols: > %LINK-I-UDFSYM, CTL$GL_IMGHDRBF > %LINK-I-UDFSYM, _PYIMPORT_INITTAB > %LINK-W-USEUNDEF, undefined symbol _PYIMPORT_INITTAB referenced > in psect PYIMPORT_INITTAB offset %X00000000 > in module IMPORT file > DSA900:[PYTHON.PYTHON-1_5_2.VMS.O_ALPHA]PYTHON.OLB;10 > %LINK-W-USEUNDEF, undefined symbol CTL$GL_IMGHDRBF referenced > in psect $LINK$ offset %X00000010 > in module VMS__GETBUILDINFO file > DSA900:[PYTHON.PYTHON-1_5_2.VMS.O_ALPHA]VMS.OLB;10 I didn't got to test BUILD_DEMO.COM whether it works on OpenVMS Alpha. Please take the original file, modify it as show below and try again: '_OLBDIR'PYTHON.OLB /library, - ! again for strdup() lookup PYTHON_VMS:CONFIG.OPT /options - ! created by CONFIG_INITTAB2MAR.COM 'SYSEXE_LINK' $! (This change will make the procedure stop working on VAX - consider it as a quick hack!) CTL$GL_IMGHDRBF is resolved by using /SYSEXE and _PYIMPORT_INITTAB is resolved by CONFIG_INITTAB.OBJ - the General Manual for Python on OpenVMS explains the last part. --- I will be out of town for the next 2 weeks - if it does not work, free feel to contact me after 20-SEP-1999. -- Uwe Zessin Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From warren at nightwares.com Fri Sep 10 23:17:19 1999 From: warren at nightwares.com (Warren 'The Howdy Man' Ockrassa) Date: Fri, 10 Sep 1999 22:17:19 -0500 Subject: high school programming & python References: Message-ID: <37D9C9BF.A5184784@nightwares.com> Les Schaffer wrote: > I am tutoring a high school kid in programming this semester -- he is > doing an independent study. Heh, I've written instructional software for grade/middle schools, and have a friend whose son is doing Pascal right now in Grade 9 (15 yrs. old for non-US system reference). > they \quote use \unquote C++, having recently changed from pascal. but > they dont teach any class/object stuff. when i asked her how far they > get in the class, she said "up through arrays". That makes no sense. Might as well teach the monkeys assembler. To teach C++ and ignore OOP is like teaching English grammar and ignoring literary classics. Worse. Python is a *superb* interface language for both coding in general and OOP as well; that is how Guido designed it. (In fact I have direct experience with languages written by corp folks deriving lots of profit, and have seen nothing quite so elegant nor addressable as Python; Guido van Rossum is, to my eyes, a genius on par with Linus Torvalds.) Python can begin as a simple CLI code emulating "cal" on non-*nix systems and work up to massive GUI applications, such as, gamewise, PySol or, webwise, grail. (Many, many other completed apps in between, as well as more modules than I think *anyone* can enumerate to describe its full functionality, including full 3-D rendering engines.) This is beyond doubt simultaneously the most accessible OS-addressing language I have ever encountered, the most GUI-capable, the most coder-friendly, and the most powerful/flexible/extensible. When you count its release platforms as well... well. I have only rippled its surface, mind you. But I know my intiuition. I think this is the best language going *anywhere*. > they dont do any graphical/GUI coding at all. That is a massive error. Console window apps are useful, and knowing how to do them is good, but such "instruction" has no place in 1999 soon to be 2000. The result is a class of kids disenfranchised with coding because they can't even do what you can do with HTML, for God's sake. > 1.) very few kids in the high school are interested in taking a > programming class. I think the fault there is in presentation. Instead of offering a "programming" class, how about a "Web class"? How can you do this great Web stuff? Take this class and find out! > 2.) the AP tests which kids take, according to her, require for > advnace placement in a comp sci class that they know the basics of C++ > up through objects. the question then is whether something like > learning/using python would enable a student still to place in the AP > tests if they desired. Oh god. The process and the mechanism, once it is understood, maps very well. With knowledge of OOP -- regardless of its derivation -- all OOP langs are accessible, provided you have a lang ref to thumb through, and a reasonable amount of time. (Of course C and C++ hurt, badly and desperately, to try to understand.) I can tell you this. We would never hire someone with pure academic knowledge of one language. Our employability base would have to include portability of knowledge -- a generalization of technique lost in the intricacies of C++. (In fact strict C++ knowledge would probably be a deficit.) Javaesque and CGI coders we want. C++ academics are too specialized to suit our needs. I don't think I'm the only one to feel that way, and I know for certain that I am not the only potential recommender of hirees in the US corporate world to believe this. Note I am a complete newbie to Python, but I am not new to coding in general, and so while I know little now of Python techniques I can assure you professionally that this is a language which will be used in US$100,000 bids for clients. It is faster than C++ can ever be at prototyping and it is possible for a .py prototype to be so successful that no C++ engine needs to be built. My young friend's teacher is being gradually seduced to this language, and for good reason. After all four lines to a GUI hello world is vastly superior to what it takes in any other HLL... or VHLL... Your HS teacher is badly out of date, methinks. FWIW when I took a HS "programming" course in 1984 -- 1984! -- it was using Commodore machines with tape loads, pure BASIC as in 10 print "hello" 20 goto 10, and our teacher referred to ASCII as a-ess-cee-double-i; he also had a cache of slide rules. No kidding. We wrote our code on quadrille paper for the line spacing; damn near Fortran in most ways. Point is that some HS programming teachers, especially if they are older, might not be in touch with current tech. This is not, after all, porting, polishing and specing a 351 hemi engine as in auto shop, where tech proceeds slowly. This is 2000 and beyond, and some languages are just not viable any more, just as some perspectives are not. For what it is worth, professionally, I would not hire this teacher of which you speak to code any kind of program I ever needed for a multi-kilobuck client. I would only hire students s/he had that didn't fit the mold. -- Warren Ockrassa | Becker Communications | http://www.beckerinc.com/ From framiere at yahoo.fr Tue Sep 28 11:11:26 1999 From: framiere at yahoo.fr (Florent Ramière) Date: Tue, 28 Sep 1999 17:11:26 +0200 Subject: Non blocking print Message-ID: <7sqlu2$mt8$1@oceanite.cybercable.fr> Hello, I would like to know how to use a non bloking IO, like print. In perl I would have used $|=0, what should I use in python ? Thanks for you answers... Florent Rami?re From Andreas.Cardeneo at mach.uni-karlsruhe.de Tue Sep 14 11:24:39 1999 From: Andreas.Cardeneo at mach.uni-karlsruhe.de (Andreas Cardeneo) Date: Tue, 14 Sep 1999 17:24:39 +0200 Subject: python call external program References: <37DE6156.FD4384C6@trey-industries.com> Message-ID: <37DE68B7.49D0C5A5@mach.uni-karlsruhe.de> Ben Thomas wrote: > > very simple question: > > What would I do to have Python execute something from the DOS command > line. I am very new to python but I bet it is in a moudule but don't > know the command or the modules to look in. I want to > > dir >%myvar.txt > > #this code would run dir from the command line and pass the var "myvar" > , dir would dump a listing of the files into a text file called xxxx.txt > > pointers? > > Ben Hi Ben, you should use the system() function from the "os" module. os.system("dir *.txt") shows all files in the current directory matchin *.txt. The function returns the exit code. Bye, Andreas -- Andreas Cardeneo Universit?t Karlsruhe (TH) Tel: +49 721 608-4576 Institut f?r F?rdertechnik und Logistiksysteme Fax: +49 721 75 83 78 Hertzstra?e 16 - 76187 Karlsruhe eMail: Andreas.Cardeneo at mach.uni-karlsruhe.de From guido at CNRI.Reston.VA.US Wed Sep 22 19:36:10 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Wed, 22 Sep 1999 19:36:10 -0400 Subject: Standard Python documentation in book form! Message-ID: <199909222336.TAA16411@eric.cnri.reston.va.us> I am pleased to announce that toExcel.com is selling nicely printed and bound copies of the key Python 1.5.2 documentation: library reference, language reference, and tutorial. The books are printed on demand. I have received review copies and the print quality is very good. Especially the library reference (496 pages) is well worth your money if you want hardcopy! Royalties go to the PSA. --Guido van Rossum (home page: http://www.python.org/~guido/) From mlh at idt.ntnu.no Fri Sep 3 09:01:32 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 03 Sep 1999 15:01:32 +0200 Subject: More random python observations from a perl programmer References: <37bc1339@cs.colorado.edu> <19990819174800.D5227@xs4all.nl> <37bc313b@cs.colorado.edu> Message-ID: "Rich Salz" writes: > >No, I'm sorry, the expressivity of "break LABEL" and "continue LABEL" > >are much clearer than the cicumlocutions necessary for exceptions. > > You sure? I wasn't aware that I could break and return a value, such as > the name of the file that wasn't found. At least not without a lot of > circuml^H^H^H^H^H global variables. > Acutally - in the line of considering labelled breaks expressive... The most expressive construct in this venue would be GOTO, no? -- Magnus Making no sound / Yet smouldering with passion Lie The firefly is still sadder / Than the moaning insect Hetland : Minamoto Shigeyuki From skip at mojam.com Thu Sep 23 14:19:52 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 23 Sep 1999 13:19:52 -0500 (CDT) Subject: The DirtyExeT proposal In-Reply-To: <7sdof1$414@mail.psy.uva.nl> References: <7sdof1$414@mail.psy.uva.nl> Message-ID: <14314.28488.503761.107726@dolphin.mojam.com> Ionel> Objective: Ionel> ---------- Ionel> Package a Python application that (comprises | depends upon) Ionel> several Python source files into a single EXE file. This process Ionel> should be automatic, customizable and largely independent of the Ionel> concrete Python application at hand. Ionel> Comments: Ionel> --------- Ionel> 1. I hope the wizards of the Python community will find an easy Ionel> way to implement this idea and give us the tool to create bulky Ionel> standalone applications with a click of the mouse. Ionel, Check out any of a variety of freeze/xfreeze/squeeze references in the archives of the list. Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From ionel at psy.uva.nl Thu Sep 23 13:34:45 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Thu, 23 Sep 1999 19:34:45 +0200 Subject: The DirtyExeT proposal Message-ID: <7sdof1$414@mail.psy.uva.nl> DirtyExeT is a proposal I hereby submit to your attention. Objective: ---------- Package a Python application that (comprises | depends upon) several Python source files into a single EXE file. This process should be automatic, customizable and largely independent of the concrete Python application at hand. Context: -------- One has a working Python application. He wants to demonstrate it to a potential client, or in some other context. In order to do that he should make sure that Python is installed on the client's machine, as well as many of the libraries he use, and he should also check the environment settings. Because it is rarely the case that everything is setup on the target machine, one must often undertake the effort of packing up his working environment, dress it up with smart install scripts and hope it will work when unfolded elsewhere. An automated and elegant solution is needed. Ideally, a certain command should be available in Python that transforms an application into a selfcontained, standalone exe file. Size is not important in many situations, but functionality and time to market/client. Solution: --------- A Python application, APP, is basically defined by its main module, app.py. The task of identifying the dependencies of APP, can be automated by recursively looking at the import statements. APP is thus constituted by a set of named files; more specifically, we shall consider the set of p-code files. ------------------------------------------------------------------- The basic idea of the DirtyExe method is to (attach|append) these files to the body of a special Python.exe interpreter, and then fix the result to remain a valid exe. ------------------------------------------------------------------- This approach avoids a true compilation step, is fast, can be quite effective and it has been already proved in practice [1]. I will hereby suggest what modifications to the Python interpreter are necessary and how it might work. On Win32, an EXE may contain resources and there is a mechanism to use them. In order to allow the interpreter to accept and use p-code patches one needs to augment its implementation for the routine. The modified import will look for the files not just on the disk but firstly in its own table of resources. Moreover, the interpreter should always start by executing a p-code resource string called, for example, "PYTHONSTARTUP". By now, the EXE is already dirty as it contains not only host specific object code but also Python specific object code (the content of the PYTHONSTARTUP string). Such an EXE may be changed to contain arbitrary Python applications in its resources table. It is left to the patching phase to actually manipulate these resources and thus create custom applications. --- On other platforms than Win32, the p-code files pending to an apllication could, in principle, be appended to PYTHON.EXE as new global variables. Being able to actually use this code requires that the EXE uses a global PYTHONSTARTUP string containing p-code, and this string can be replaced by the code of the new, custom application. When there is no distinction between object code and some form of resources, it might be a bit more difficult to handle the symbol table of the exe in order to add new global variables. Yet, it should be doable because it's just appending new records and shifting around some addresses for some of the existing ones. (Python.exe is thus turned into a willing host for python applications. :-) --- Conclusion: ----------- A method is suggested by which an EXE file that contains a Python interpreter can be augmented with pseudo code files representing a custom application. The net effect is that developers will be able to get standalone executables. Comments: --------- 1. I hope the wizards of the Python community will find an easy way to implement this idea and give us the tool to create bulky standalone applications with a click of the mouse. 2. This method really fits Python: just think about python(.exe) eating up your p-code, :-) 3. For the sophisticated, several kinds of python.exe builds may be designed, as some libraries are included or not. 4. For the casual user, and, attention, for the students preparing their term projects, such a tool would be quite a compelling reason to use Python, because it hides its actual source code. For example, they might claim to have coded it in C++... They should not, of course, do such things. :-) 5. For the professionals, they would have an easier time with clients locked in their respect for the "compiled" languages. The clients will not be able to tell a Pythonish composit from a "genuine" exe. 6. There is some other work to be done that I did not even mention: checking for the distinction btw. console and windowed applications, accompanying the resulting exe with binary files that might be required, etc. ... ionel ---------------------------------------------------------------------------- ----- [1] For a supposed implementation of the DirtyExe idea, see the enviroment "Dialect Standard Edition", at http://www.aristar.com/DeveloperTools.html. The DirtyExe method is nowhere explicitly pointed to, but if you made an exe with their tool you'll see that there is no other way to do it. I was annoyed of that little bastard, Dialect, not mentioning its parents, i.e. Python, but I was impressed of its ease in creating EXEs. This posting is the resolution of this conflicting thoughts. From yopen at my-Deja.com Sat Sep 4 15:10:53 1999 From: yopen at my-Deja.com (Bill Wilkinson) Date: Sat, 4 Sep 1999 14:10:53 -0500 Subject: New to Python...looking for scripting language References: <37D12E9D.EDB193B8@patriot.net> <37D168BB.D4C90858@patriot.net> Message-ID: <#A8jdjw9#GA.278@cpmsnbbsa02> sure..... I can put some on my site as examples. I don't know if you would find the ones I have very useful. But, I will post the ones that I can when I go back to the office tuesday. Harlan Carvey, CISSP wrote in message news:37D168BB.D4C90858 at patriot.net... > Bill, > > Thanks for your input. Do you have any examples of your admin scripts > available? > > Carv > > Bill Wilkinson wrote: > > > Python is one of the languages that works with the Windows Scripting Host. > > It exposes several objects that are quite handy for doing the things you > > want. There is a File System Object and such like. WSH will be built in to > > Win2000, but for now it is a seperate download.... (I am not sure, but it > > might be included with the Pythonwin files) > > > > Also, using Pythonwin you can do some of the things you mention easily > > without the WSH. > > In my opinion, Python is ideal for NT scripting. I use it for all my admin > > scripts. > > > > Bill Wilkinson > > Harlan Carvey, CISSP wrote in message > > news:37D12E9D.EDB193B8 at patriot.net... > > > Hey all, > > > > > > I am looking for a scripting language for NT environments. I am NOT > > > trying > > > to start a language war. > > > > > > I have been to the Python.org site quite a bit, and haven't found what I > > > am looking > > > for, so I will post here. > > > > > > With Python, can I: > > > - access the Registry (get, and set values, create keys, etc)? > > > - access the services (get a list of running services)? > > > - access the audit policy (get and set that policy)? > > > - search for files on the remote hard drive? > > > - access permissions on the remote system? > > > > > > I haven't seen modules that allow this...nor have I seen example > > > scripts. I am not > > > a MS/C++ programmer, and I want to be able to leave scripts for > > > sysadmins who > > > aren't either. They need to be able to maintain the scripts. > > > > > > Thanks, > > > > > > H. Carvey > > > > From rvollmert at gmx.net Fri Sep 24 10:51:14 1999 From: rvollmert at gmx.net (Robert Vollmert) Date: Fri, 24 Sep 1999 16:51:14 +0200 Subject: Becoming root within a Python script In-Reply-To: ; from Will Ware on Fri, Sep 24, 1999 at 04:14:15AM +0000 References: Message-ID: <19990924165114.A753@krikkit.vollmert.home> On Fri, Sep 24, 1999 at 04:14:15AM +0000, Will Ware wrote: [snip] > if os.popen('whoami').readline()[:-1] == 'root': [snip] > Dumb question for those wiser than myself: > The os.popen().readline()[:-1] construction is pretty ugly. > Is there a better way to do it? How about 'if os.getuid() == 0:' ? -- Robert Vollmert rvollmert at gmx.net From guido at cnri.reston.va.us Thu Sep 2 08:28:53 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 02 Sep 1999 08:28:53 -0400 Subject: tkinter & threads References: Message-ID: <5lemgh5wfu.fsf@eric.cnri.reston.va.us> Robin Becker writes: > Is Tkinter thread safe? I looked at Guido's brownian demo and there are > no special precautions about locking the canvas. Also I believe there is > some restriction on which thread Tk can live in. This is a 1.5.2 feature; I added enough locks to _tkinter to make it thread-safe. However on Windows there are still problems (you can only call update() and friends from the main thread) and I think I've seen one report from non-Windows where things broke under certain circumstances. The Brownian demo is there specifically to show that Tkinter is now thread-safe. --Guido van Rossum (home page: http://www.python.org/~guido/) From cors at recercai.com Tue Sep 7 16:39:45 1999 From: cors at recercai.com (Carlos Ors) Date: Tue, 7 Sep 1999 22:39:45 +0200 Subject: Problem with python embedded Message-ID: <37d523e1.0@sahara.cablecat.com> I try running the SimpleEmbedded.java but I get next error: 'import exceptions' failed; using string-based exceptions How can I solve this problem? Thanks in advance. Please (if you can) answer me to karlos at softhome.net From ivanlan at callware.com Fri Sep 17 11:30:49 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Fri, 17 Sep 1999 15:30:49 GMT Subject: Splitting c.l.py (was Re: python call external program (WHAT THE?!)) References: <7rr088$74b@dfw-ixnews8.ix.netcom.com> <7rs3oo$5jt$1@news.udel.edu> Message-ID: <37E25EA9.A0BE7BF6@callware.com> Hi All-- Terry Reedy wrote: > > Rather than splitting the group, what might be helpful are agreed-upon > 'designators' such as WIN, W95, WNT, UNX, TK consistently placed at the > head of subject lines when appropriate. > Splitting the group sucks. The community is not a paramecium; there's no point to fission without syzygy. It might be helpful with the WIN, W95 etc. markers, but I belong to another mailing list in which such marking is enforced, and what it does as far as I can tell is restrict what you think you can say to a set of pre-ordained categories. Then somebody comes in with something that doesn't fit in a box, so they dump the category markers, and get flamed. So I guess I'm against that too. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From MSteed at altiris.com Fri Sep 10 12:05:08 1999 From: MSteed at altiris.com (Mike Steed) Date: Fri, 10 Sep 1999 10:05:08 -0600 Subject: Text UI Message-ID: <65118AEEFF5AD3118E8300508B124877073BEE@webmail.altiris.com> One possibility worth investigating is wxWindows, which includes a curses port. I have not used the curses port, nor I do not know whether the Python interface will work with it.... wxWindows: http://www.wxwindows.org/ wxPython: http://alldunn.com/wxPython/ -Mike > -----Original Message----- > From: smithy at promail.pl [mailto:smithy at promail.pl] > Sent: Friday, September 10, 1999 9:54 AM > To: python-list at python.org > Subject: Text UI > > > As in subject - I'm seeking a console-based user interface toolkit for > Python. All I found by now is snack.py module, an interface to newt. > Unfortunately, this is a very simple toolkit and almost the > same functionality > is achievable with dialog or whiptail in bash scripts. > > What I'm looking for is an event-driven user interface > library. Something > resembling the Borland's TurboVision from DOS (I need this > under Linux). > > Has anyone written something like this? A search on > python.org, yahoo and > a few other search engines gave no results. > > -- > ?ukasz Kowalczyk > lukowtempac.fuw.edu.pl > http://tempac.fuw.edu.pl/~lukow/ From hirsch at noreaster.cit.cornell.edu Tue Sep 21 13:11:45 1999 From: hirsch at noreaster.cit.cornell.edu (Matthew Hirsch) Date: Tue, 21 Sep 1999 13:11:45 -0400 Subject: Thanks References: <37E7809E.A871480C@noreaster.cit.cornell.edu> Message-ID: <37E7BC4F.C5DE4F1D@noreaster.cit.cornell.edu> Thanks guys. I really appreciate your help. Matt From m.faassen at vet.uu.nl Thu Sep 2 06:21:31 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 2 Sep 1999 10:21:31 GMT Subject: language interpreters/ interpreted languages weaknesses? References: <7qi3q3$n1d$1@nnrp1.deja.com> <37CCE10D.D07D023B@strs.co.uk> <7qjgq8$k1i$1@newshost.accu.uu.nl> Message-ID: <7qlj3b$p7u$1@newshost.accu.uu.nl> William Tanksley wrote: [snip] > Java's not interpreted, though -- I've never seen ANY Java interpreter. > Java is always compiled, usually to bytecode, and then the bytecode > machine is emulated. Um, I was under the impression that this is what a modern interpreter actually does? Parse the source to bytecode and execute the bytecode. After all, Python does the same, right? Regards, Martijn From celkaim at microform.fr Mon Sep 27 11:36:15 1999 From: celkaim at microform.fr (Cyril Elkaim) Date: Mon, 27 Sep 1999 17:36:15 +0200 Subject: Locking some methods from certain clients Message-ID: <37EF8EEF.F8AF3D31@microform.fr> Hi, I've the following question: I want to lock the accesse of some method of an object from other objects using it. But on a class by class basis. What I want is the possibility to know the class-name of a caller and if this caller is on my access list let it use my method. Something like this: class callee: def method(self): if __caller__ == "agreed": execute... else: raise callError, "caller no authorized to execute" this class will be able to call the method class aggreed: def run(self): x = callee() x.method() this class not class other: def ren(self): x = callee() c.method() It's something like the export clause in Eiffel. Thanks in advance Cyril Elkaim From steinme at norway.eu.net Tue Sep 21 15:58:03 1999 From: steinme at norway.eu.net (Stein M. Eliassen) Date: Tue, 21 Sep 1999 19:58:03 GMT Subject: make test failed in time_test References: <37E7DB67.5DE00C61@norway.eu.net> <00b601bf0469$0e96e330$f29b12c2@secret.pythonware.com> Message-ID: <37E7E34B.CABD4689@norway.eu.net> Fredrik Lundh wrote: > hope this helps! It's working now. Thanks! From g.gruber at xsoft.co.at Mon Sep 6 09:17:58 1999 From: g.gruber at xsoft.co.at (Gerhard W. Gruber) Date: Mon, 06 Sep 1999 15:17:58 +0200 Subject: Dictionaries with invalid key? Message-ID: <37D3BF06.4A49572@xsoft.co.at> Usually a dictionary conists of a key and a value. I thought that keys are strings. Now I wrote some code that managed to create a key that is a number instead of a string. Is this a bug or is this ok? -- bye, Gerhard email: sparhawk at eunet.at g.gruber at xsoft.co.at From nessus at mit.edu Wed Sep 29 12:59:53 1999 From: nessus at mit.edu (Douglas Alan) Date: 29 Sep 1999 12:59:53 -0400 Subject: When Good Regular Expressions Go Bad References: <000101bf0a47$98084da0$ce2d153f@tim> Message-ID: "Tim Peters" writes: > > It seems to me that even when a regular expression fails to match a > > string, you might want to know just how far it was able to get before > > getting stuck. (And indeed I do!) > I confess I'm at a loss to think of a compelling use for it, though. Here's what I'd like to use it for: I'm writing a function that does a directory walk. The client of the function can provide a regular expression, indicating the pathnames on which they would like to match. I would like to optimize the function by pruning any directories for which the contents could not possibly match the regular expression. Sure, the function could instead accept a filtering function as an argument, instead of the regular expression, and the client could then provide their own pruning, or I could just require that the regular expression also match directories to be descended into. But these interfaces are not nearly so nice. |>oug From robin at alldunn.com Sun Sep 26 18:57:56 1999 From: robin at alldunn.com (Robin Dunn) Date: Sun, 26 Sep 1999 15:57:56 -0700 Subject: wxPython problems References: <7sjl5n$4gc$1@sunsite.icm.edu.pl> Message-ID: <6yxH3.1168$Ir.64618670@news.randori.com> > I got strange problem with wxPython on RH6.0. I've written the small > application and each time I run it the some texts ( eg. buttons' captions > and labels ) look in other way. I mean that the font's size and,style > changes each time and I have no idea why it happens. > I've noticed this too, (some labels are bold but should not be) but I've only seen it when running in a VMWare virtual machine and just thought that it was something to do with a beta X-Server. Other GTK apps were doing it too, not just wxPython. -- Robin Dunn Software Craftsman robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! From pinard at iro.umontreal.ca Thu Sep 2 09:33:14 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: Thu, 2 Sep 1999 13:33:14 GMT Subject: Python speed and `pcre' In-Reply-To: "Fredrik Lundh"'s message of "Thu, 2 Sep 1999 14:59:49 +0200" References: <00af01bef543$0affe8f0$f29b12c2@secret.pythonware.com> Message-ID: "Fredrik Lundh" ?crit: > Fran?ois Pinard wrote: > > I do not fully understand the cost of splitting. If strings are immutable, > > there is really no need to copy a slice contents. > except that 1) each string needs an extra reference pointer (as long > as we're using refcounting, at least), and 2) that people can easily > end up in situations where huge strings are clogging up all available > memory, just because some part of their program is hanging on on to a > 2-character substring... Exactly my say. The inefficiency is related to the chosen implementation of the garbage collector. It is not "modern" to push such considerations into the programming style of everybody, when the language syntax much invites for something cleaner and simpler. > (fwiw, the unicode string type implements substring support, using it > for the "split" and "slice" methods. still not sure if that's really > a great idea...) In general, simplicity is a great idea. The language implementor gets all the trouble! :-) > > Somewhere, it is said that some extra-space is allocated at end of > > sequences, to allow for some peaceful growth. Does `str=str+str1' > > at least attempt to use of this extra-space? It should, in my opinion. > how? before you tell me, consider that strings are immutable, > and variable names are references. Yes, of course. Given strings are immutable, an implementation could have: ref=str str=str+str1 and have `ref' points to a substring of `str', without copy most of the time, when `str1' is small. Once again, the chosen implementation induces inefficiencies, which are then translated into stylistic issues for all users. This is not ideal. One might well explain at length how the gargabe collection occurs, but if the language is really healthy, users should not have to fly at such down a level. It is very interesting to know for the general culture of the community, of course, but it should not influence programming style. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From jlj at cfdrc.com Thu Sep 2 10:08:41 1999 From: jlj at cfdrc.com (Lyle Johnson) Date: Thu, 02 Sep 1999 14:08:41 GMT Subject: Parrot-0.0.1 References: <935279776snz@vision25.demon.co.uk> <7ps4ma$n06$1@wagner.wagner.home> <37c2a462.349531009@192.77.87.74> <935523275snz@vision25.demon.co.uk> <7qh7jk$gaa$1@wagner.wagner.home> <936222198snz@vision25.demon.co.uk> Message-ID: <37ce82e6.85623249@192.77.87.74> On Wed, 01 Sep 99 21:43:18 GMT, philh at vision25.demon.co.uk (Phil Hunt) wrote: >In article <7qh7jk$gaa$1 at wagner.wagner.home> > vitus at wagner.rinet.ru "Victor Wagner" writes: >> Phil Hunt wrote: >> : The Parrot tool has other potential advantages, e.g: >> : 1. you only have to learn one syntax, that can then be used for >> : lots of languages and GUI libraries. >> >> Which is completely useless, > >Fine, I'm not forcing you to use it. > > >-- >Phil Hunt....philh at vision25.demon.co.uk > You know, it just warms my heart to see people criticize newly announced projects just because that project is not useful for the criticizer. Maybe that's the norm on some other newsgroups but we're generally a little more cordial on comp.lang.python. Phil, good luck with "Parrot". It sounds like it will fill a previously unaddressed (or at least under-addressed) need to migrate between different user interface toolkits easily, a pretty cool idea. From thatcher at bmd.clis.com Sun Sep 12 22:18:03 1999 From: thatcher at bmd.clis.com (Robert Thatcher) Date: Mon, 13 Sep 1999 02:18:03 GMT Subject: Free Wallpaper, Clip Art and Backgrounds by Robert Thatcher Message-ID: <37dc5457.1@newport> Free Wallpaper, Clip Art and Backgrounds by Robert Thatcher at http://www.clis.com/thatcher/index.htm From wtanksle at dolphin.openprojects.net Tue Sep 14 21:03:04 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Wed, 15 Sep 1999 01:03:04 GMT Subject: high school programming & python References: <937300939snz@vision25.demon.co.uk> <$JL+lCAFvt33Ewr8@jessikat.demon.co.uk> <7rmmjr$qv6@dfw-ixnews11.ix.netcom.com> Message-ID: On 14 Sep 1999 23:43:55 GMT, Aahz Maruch wrote: >Robin Becker wrote: >> writes >>>Machine language! You young people today don't know what hardship >>>is... when I were a lad, we had to manually patch the ALU using >>>plug boards to change the logic. >>You were lucky to have plugboards. We had to key things in with a bunch >>of switches. >You were lucky to have switches. We had to rewire the traces. Traces indeed. They didn't let us touch the traces; we had to hand-orient a jar of magnetic filings using a hammer and the earth's magnetic field. And then hand it over to the DP professionals, and hope they didn't decide to shake the jar. > --- Aahz (@netcom.com) -- -William "Billy" Tanksley From cdaniel at xcom.net Wed Sep 15 02:58:57 1999 From: cdaniel at xcom.net (Cliff Daniel) Date: Wed, 15 Sep 1999 06:58:57 GMT Subject: Threads + Re(gex) Baffled!?!?!? Message-ID: <37df3dfb.8684516@news.sjo.level3.net> I'm totally baffled right now, wrt threads. I have built a test program using sockets to pull down just a few lines of text, parse it and junk the result. For practical purposes I have spawned 15 worker threads who each will connect to a different host (480 Hosts total). They would then execute code similar to this: --------------------------------------- Sock.send('some-command') Reply = ReadUntil('> ', Sock, Timeout) if Reply == '': return(-1) else: tmp = re.split('\r\n', Reply) for line in tmp: m = pat.match(line) .etc. Upon running the script you see nice and speedy results at first with very little cpu usage. However, the cpu usage grows continously until the program ends. I have noticed that when the bloating occurs the a lot of the cpu time is spent in the kernel which would lead me to believe this is some sort of locking issue hidden within the 're' module? When I put a 'continue' in front of the pat.match() every thing works just fine. With re: CPU states: 12.5% idle, 18.8% user, 46.4% kernel 26.54% test.py Without: CPU states: 19.1% idle, 35.8% user, 10.6% kernel, 0.76% test.py The pattern I'm matching is as follows: pat = re.compile('\s+(\w+)\s+\(.+?\):\s+(\d+)\s+(\d+)') Is there any known issues with locking and 're'? The system is an UE5000 with 8 cpus, Solaris 2.6, Python 1.5.2 If anyone has any ideas about this I desperately need some help. I hate to have to dump this entire project for performance reasons. I've stripped out EVERYTHING in the program just to reproduct this to rule out my code. Regards, Cliff From davidopp at megsinet.net Thu Sep 16 02:45:14 1999 From: davidopp at megsinet.net (David Oppenheimer) Date: Thu, 16 Sep 1999 02:45:14 -0400 Subject: high school programming & python References: <37DF9080.21A8D285@calibre-dd.com> <37DFED78.6B258366@bioreason.com> Message-ID: <37E091FA.10EFE3D8@megsinet.net> James Whitley Moore wrote: > Why not end this thread in the usual way? > > I never wanted to be a high-level language programmer. > > I always wanted to be. . . > A World Class Skydiver and All Around Daredevil. (Being a beach bum wouldn't be so bad either. I was watching a baseball game with a friend when a commercial for a local tech school came on the air and it went something like this "....So you went and got a four year degree and what did it get you? ... A job serving drinks? " I looked at my friend and said to him ... "Man, I would love a job like that... wear a swimsuit to work, get a tan, hang out on the beach, and get paid for it. That would be the life!" David O. From billjoeckel at hotmail.com Sat Sep 11 13:58:56 1999 From: billjoeckel at hotmail.com (billjoeckel at hotmail.com) Date: Sat, 11 Sep 1999 17:58:56 GMT Subject: hiring python-solaris for web project Message-ID: <7re58s$fhl$1@nnrp1.deja.com> Hi! My name is Bill Joeckel with Tri-Com Technical Services, I have a client that has a contract opening for a python-solaris developer for a web project. The skills specifically looking for python cgi style web development, mail handling software to provide confirmations of actions on the web site and announcements to users, ODBC connectivity to Db2 and software to process data files exchanged via FTP.Call work 18002806919 or at home call anytime 19132561985. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From bowman at montana.com Sun Sep 5 00:32:23 1999 From: bowman at montana.com (bowman) Date: Sat, 04 Sep 1999 22:32:23 -0600 Subject: A scrollable Frame or Canvas widget References: <37C73097.8165F42C@uniserve.com> <37D1EA28.DF1A0EEF@alum.mit.edu> Message-ID: <37D1F257.2F015097@montana.com> pehr anderson wrote: > > I'm trying to throw a phalnx of textboxes for a form that is bigger > than the available window size. I need to be able to scroll the whole > mess, but I'm trapped with the lack of docs and no understanding of tcl. For a good example, look in your distro under Demo/tkinter/matt for the oddly named: canvas-with-scrollbars.py -- Bear Technology Making Montana safe for Grizzlies http://people.montana.com/~bowman/ From Howard at quercus.demon.co.uk Sat Sep 18 11:46:23 1999 From: Howard at quercus.demon.co.uk (Howard Oakley) Date: Sat, 18 Sep 1999 16:46:23 +0100 Subject: [Mac] Python mode for Alpha editor References: <01HW.B4090E63001D90290D2F1590@news1.radix.net> Message-ID: In article <01HW.B4090E63001D90290D2F1590 at news1.radix.net>, "T. Bridgman" wrote: >There is in fact a Python mode for Alpha but it doesn't seem to work in release >7.0 or later. Does this version work with 7.+? It has been developed with 7.2, and I have tried to follow the compatibility guidelines for future releases using Tcl 8.x. So it should work fine - if not, please let me know. Howard. From gmcm at hypernet.com Fri Sep 24 07:32:05 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 24 Sep 1999 07:32:05 -0400 Subject: Dialect, A Python derived environment (and language ?) In-Reply-To: <000001bf064f$ba05f980$cc2d153f@tim> References: <7sciqs$n2e@mail.psy.uva.nl> Message-ID: <1273949950-4000037@hypernet.com> [Tim, on http://www.aristar.com/DeveloperTools.html] > > (Nice feature: makes an exe right away.) > > Very easily, too! Just click "make an .exe" in the IDE, and it > makes one. Just what I've been waiting for: instead of a > burdensome 20-byte cross-platform > > print "Hello world" > > file, you can get the same effect now with a self-contained 685Kb > Windows-only .exe: Gee, just ran your app thru Installer. For the exe that's Run+CArchive([HelloWorld.py]) it comes out to 24K. For the one that's got python15.dll etc. built-in, it's still only 277K. - Gordon From fredp at multimania.com.nospam Wed Sep 22 08:57:16 1999 From: fredp at multimania.com.nospam (Fred Pacquier) Date: 22 Sep 1999 12:57:16 GMT Subject: YA-Newbie: baffled by deepcopy/pickle issues... References: <000101bf04b6$8d8ab520$342d153f@tim> Message-ID: <8E499CFF7PaCmAnRDLM@161.48.81.148> tim_one at email.msn.com (Tim Peters) said : >> Any hints on how to track this one down ? Thanks, > >Easy: create a *small* app that displays the same symptoms. The answer >will likely become obvious in the process of doing that. If it doesn't, >you'll have a small piece of executable code to post, and the answer >will be obvious to someone else. >code-fixes-itself-if-you-let-it-ly y'rs - tim It's what I usually do, but this time I half-hoped I could avoid it, because there's a lot of dumbing-down work implied at this stage of the app. But I guess I'm just going to have to bite the bullet... thanks-for-the-grow-up-and-face-reality-ly yrs - fp :-)) -- YAFAP : http://www.multimania.com/fredp/ From Markus_Ewald at gmx.net Wed Sep 8 07:05:21 1999 From: Markus_Ewald at gmx.net (Markus Ewald) Date: Wed, 08 Sep 1999 13:05:21 +0200 Subject: Calling Python functions from C Message-ID: <37D642F1.9FAE941C@gmx.net> I'm trying to use Python for various things in a game. One of these things is controlling particles. I had used SeeR (http://home.elka.pw.edu.pl/~ppodsiad/seer/) in the past which could easily compile its scripts into bytecode and keep them in memory, you could then easily call functions in the script. Only bad thing was it had some funny floating point bugs which ...well... caused some undesired effects on my particles ;) So, two questions: My game kept pointers to its particles in a simple linked list. Each particle type (rain, smoke...) had a script which contained functions for creating, moving, rendering and destroying the particle. To add a particle my game just called the creation function in the script for that particle-type, which just malloced as much memory as the particle would need, set some initial values and return the pointer to my game. This, of course, wouldn't be possible in that way using Python, so what is the best (quickest) solution ? Write a Python module for storing particles and let the script keep them ? Other question: How can I keep a compiled Python script in memory and call functions (not executing the whole thing) in it ? I didn't find any example on the net until now and have already tried alot... like getting a callable object from a script from a _node to a CodeObject to a PyObject with PyParser_SimpleParseFile(); PyNode_Compile(); PyEval_EvalCode(); and then calling functions to execute something in it... PyImport_ExecCodeModule(); PyObject_CallFunction(); well, didn't work ;..( Thanks, and if anyone knows an url with something about embedding python, i'd be happy :) -Markus- From news at dorb.com Mon Sep 27 11:10:38 1999 From: news at dorb.com (Darrell) Date: Mon, 27 Sep 1999 11:10:38 -0400 Subject: module location References: <7sj6ii$1jc$1@essle.valdyas.org> Message-ID: Two approaches I know of: Define a module to hold an interface to some component. abstractDB.py It imports the specific version of db and provides any glue. All access to DB is via abstractDB which can be imported by a module deeply buried in some package. Remindes me of this sort of thing: import myPackage.myMod myMod=myPackage.myMod Or: pass an instance that provides the desired interface to the lower level packages. This is the most common and probably most flexible. -- --Darrell Boudewijn Rempt wrote in message news:7sj6ii$1jc$1 at essle.valdyas.org... > I'm working on my first large(ish) python project - a linguistics database > application - and I'm trying to keep my sources ordered, and my layers > separated, and having some problems doing it right. > > So I've got a database access module, a middleware module, an abstract > gui module, and finally the actual application, which binds the gui to > the middleware. Currently, I've laid my project out as follows: > > lng (contains start script, readme, on so on) > /kuralib (contains the actual app > /db (database layer) > /gui (gui widgets) > /lng (middleware - table and record objects) > > But now my problem is that the middleware also needs to access the db > layer - as does the application itself (for connecting and so on). What's > the received wisdom in this case? Do I make the db layer a separate > module which I install in /usr/lib/python/site-packages, or do I make > db a submodule of lng, and pass the connection on to the main application? > > I really want to keep everything as separate as possible, to ease the > task of people who want to port the application to windows - something > I won't be doing myself. > > -- > > Boudewijn Rempt | http://www.xs4all.nl/~bsarempt From evan at tokenexchange.com Fri Sep 3 11:58:13 1999 From: evan at tokenexchange.com (Evan Simpson) Date: Fri, 3 Sep 1999 10:58:13 -0500 Subject: Newbies: Re: Returning none References: <000001bef265$fe64f340$192d153f@tim> <37CF5499.BA24C33E@prescod.net> Message-ID: Michael Hudson wrote in message news:Pine.LNX.4.10.9909031629210.21765-100000 at atrus.jesus.cam.ac.uk... > Got bored. [and implemented the whole damn thing!] Wow. That looks ... remarkably painless. Why don't you think it's a good idea? From eddthompsonNOzlSPAM at ssi.parlorcity.com Fri Sep 3 07:16:36 1999 From: eddthompsonNOzlSPAM at ssi.parlorcity.com (EuphoriaDJ) Date: Fri, 03 Sep 1999 04:16:36 -0700 Subject: multiOS install Message-ID: <26f15c5e.d9be7115@usw-ex0102-015.remarq.com> I am working on a prayer book parser, it will either remind a person that it is time to pray and what prayer it is time for or it will just tell the user what prayer should be said at the time. Most of the code is pretty streight foreward but I want to be able to give this to people who can run it on other OS's I think on the Mac there is a program that turns your python into native code so that you do not need python libs is this true and is it availible for Windoze also? next is there anything special I should do for linux user to help with install TKs remove N * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From carvdawg at patriot.net Sat Sep 4 10:37:17 1999 From: carvdawg at patriot.net (Harlan Carvey, CISSP) Date: Sat, 04 Sep 1999 10:37:17 -0400 Subject: New to Python...looking for scripting language Message-ID: <37D12E9D.EDB193B8@patriot.net> Hey all, I am looking for a scripting language for NT environments. I am NOT trying to start a language war. I have been to the Python.org site quite a bit, and haven't found what I am looking for, so I will post here. With Python, can I: - access the Registry (get, and set values, create keys, etc)? - access the services (get a list of running services)? - access the audit policy (get and set that policy)? - search for files on the remote hard drive? - access permissions on the remote system? I haven't seen modules that allow this...nor have I seen example scripts. I am not a MS/C++ programmer, and I want to be able to leave scripts for sysadmins who aren't either. They need to be able to maintain the scripts. Thanks, H. Carvey From init__self at my-deja.com Tue Sep 7 16:30:50 1999 From: init__self at my-deja.com (Python Addict) Date: Tue, 07 Sep 1999 20:30:50 GMT Subject: Feast or famine! Message-ID: One moment the book by Mark Lutz is the only Python book on the shelf and before you know it, you've got tons of them! Well, you will in a few weeks. A casual stroll around the usual places has found these soon-to-be-released titles: - Python Annotated Archives Martin Brown ISBN: 0072121041 (If it's anything like his excellent Perl book, this is going to fill a void. Let's hope it sells well and we get a Python: The Complete Reference too!) - Python and Tkinter Programming ISBN: John E. Grayson 1884777813 - Python Programming on Win 32 Mark Hammond, Andy Robinson, Robert Denn ISBN: 1565926218 (Again, much needed. If it's like the Unix-ish one, it'll be wonderful) - Python Reference Manual; February 19, 1999, Release 1.5.2 Guido Van Rossum, Fred L., Jr. Drake ISBN: 1583483748 (What's all this then? No piccie on Amazon.com or description) - Quick Python Book Daryl D. Harms, Kenneth McDonald ISBN: 1884777740 I-wonder-if-Amazon-will-do-a-bulk-discount-ly-yr's, Addicted. From zeevkotzer-withouth-this at hotmail.com Sat Sep 4 14:22:47 1999 From: zeevkotzer-withouth-this at hotmail.com (Zeev kotzer) Date: Sat, 4 Sep 1999 20:22:47 +0200 Subject: Changing the current thread priority under Win32 Message-ID: <7qro4h$611$1@news.netvision.net.il> Anybody has the magic python lines that can set/reduce the priority of a single-threaded python script, running on WinNT? Thx in advance! From bobklin at idt.net Sat Sep 4 12:50:51 1999 From: bobklin at idt.net (Bob Kline) Date: Sat, 4 Sep 1999 12:50:51 -0400 Subject: Failure building MySQLdb Message-ID: <7qrimc$bkn@nnrp3.farm.idt.net> I'm trying to build MySQLdb version 0.0.3. The README is a bit sparse. It says: "To build: python build.py To install: follow additional instructions after build. Uh, that's it." OK, worked fine on Linux (2.2.5). On NT the following diagnostics are spewed out: cp: f:\python/lib/python1.5/config/Makefile.pre.in: No such file or directory make: Makefile.pre.in: No such file or directory make: *** No rule to make target `Makefile.pre.in'. Stop. make: *** No targets specified and no makefile found. Stop. Traceback (innermost last): File "build.py", line 14, in ? import MySQLdb File "MySQLdb.py", line 19, in ? from _mysql import * ImportError: No module named _mysql The version of Python: Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Installed from py152.exe and python-win32all-125.exe, downloaded from http://www.python.org/download/download_windows.html. Obviously the NT installation is missing some pieces. Can I get a tip on where to look for the missing pieces? If it's in the FAQ (I looked) just whack me over the head and give me a string to search for. Thanks. Bob Kline bkline at rksystems.com From salhir at earthlink.net Thu Sep 2 23:28:47 1999 From: salhir at earthlink.net (Sinan Si Alhir) Date: Thu, 02 Sep 1999 22:28:47 -0500 Subject: UML References: <3F8BA119B48AD11197470008C7A493CB98B52F@HQOBGEX1> Message-ID: <37CF406F.4EAB7454@earthlink.net> ScherBi at BAM.com and comp.lang.python - Various papers at http://home.earthlink.net/~salhir may be of interest to you: * What is the Unified Modeling Language (UML)? (http://home.earthlink.net/~salhir/#whatistheuml) * Applying the Unified Modeling Language (UML) (http://home.earthlink.net/~salhir/#applyingtheuml) * The Foundation of the Unified Modeling Language (UML) (http://home.earthlink.net/~salhir/#thefoundationoftheuml) * Succeeding with the Unified Modeling Language (UML) (http://home.earthlink.net/~salhir/#succeedingwiththeuml) * The Object-Oriented Paradigm (http://home.earthlink.net/~salhir/#theobjectorientedparadigm) * Extending the Unified Modeling Language (UML) (http://home.earthlink.net/~salhir/#extendingtheuml) This paper elaborates on extending the UML and explores the necessity, sufficiency, and consistency of the UML?s extension mechanisms to conclude that there are inconsistencies with the UML?s extension mechanisms.. * "The True Value of the Unified Modeling Language (UML)" [Distributed Computing magazine, July 1998] (http://home.earthlink.net/~salhir/#thetruevalueoftheuml) * "Unified Modeling Language Extension Mechanisms" [Distributed Computing magazine, December 1998] (http://home.earthlink.net/~salhir/#umlextensionmechanisms) This paper also very briefly introduces the Core Modeling Language (CML). * "Reuse and the Unified Modeling Language (UML)" (http://home.earthlink.net/~salhir/#reuseandtheuml) * "The Unified Modeling Language (UML) - One Year After Adoption of the Standard" (http://home.earthlink.net/~salhir/#theumloneyearafteradoptionofthestandard) * "Understanding the Unified Modeling Language" [Methods & Tools, April 1999] (http://home.earthlink.net/~salhir/#understandingtheuml) * "From the Unified Modeling Language (UML) to C++" [Visual C++ Developers Journal (Online), June 1999] (http://home.earthlink.net/~salhir/#fromtheumltocpp) I welcome your comments and questions. Thank you. Sincerely, Sinan Si Alhir Email: mailto:salhir at earthlink.net WWW: http://home.earthlink.net/~salhir -- --- --- Read what people are saying about "UML in a Nutshell" (Comments and Feedback) [http://home.earthlink.net/~salhir/#umlinanutshell] ScherBi at BAM.com wrote: > > >Thanks for your reply Bill. > You're quite welcome. > > >I'll try it the other way around. Is the UML something like a OO > >Database or something like XML? Or anything in between? > > For starters, the 'L' stands for language in both. Let me quote from > _UML_In_A_Nutshell_ here: > > "The UML is a modeling language for specifying, visualizing, constructing, > and documenting the artifacts of a system-intensive process" > > Note the 'system-intensive process'; it's not directed solely at software > design, but that seems to be where it has had it's greatest impact. Other > applications may be business process modeling, factory process modeling, > etc. > > >1.) Object Primer(Scott W. Ambler SIGS Books/ > > Cambridge University Press, 1995) > >2.) UML in a Nutshell (OReilly) > > >Which - or would you recommend both? > > I've not seen _Object_Primer_, but I'm quite happy with the Nutshell book. > I've seen others I didn't like as much. > > >I started documenting my work on AI in a simple word processor, then > >thinking of creating a database (to get hold of the code and my > >thoughts) and recently I heard something about CASE tools and UML. > >I'm really in great need of a tool which helps me to keep overview and > >organize my work. > > A UML tool, I think, could only be a part of the solution here. It's not > going to provide a database to hold code. There are mechnisms for handling > documentation, however these bits of documentation are typically attached to > specific 'objects' within the tool. > > >>I use UML, via ObjectDomain (www.objectdomain.com). > >>I am involved in developing .... > >>.. In other words, create classes and class diagrams in > >>UML, design the class interfaces, and play around with the design at this > >>level. When you think you have it right, generate the stub code and fill > in > >>the methods. You can fill in the methods without getting caught up in the > >>interface issues, which makes things much easier. > > >Feels like UML is a sort of IDE?? > No, but a CASE tool which uses UML as it's modeling language is a bit like > an IDE. Again uml is just a language, like Python, C, or Latin. > > >>..where you understand the hierarchy and the operations, then > >>reverse engineer it into objectdomain. You can then automatically > generate > >>a class diagram. > > >Something like a class browser used in C/C++ IDE's like Watcom? > Yes, I suppose. But it shows you the class hierarchies in UML. > > >>And no, I don't work for ObjectDomain. It's the only UML tool I know of > the > >>generates and reverse engineers Python. OD is written in Java. I don't > > >Whats so wrong about Java? When you use different OS's - Java should a > >logical way to go. > > It's a bias born of experience ;-). The idea, the promise, the goal of Java > is noble and worthy. The reality of Java falls short. I would prefer a > native code version. It would stand alone( no jvm version dependencies), > and it would execute faster. I suspect it would be more stable, also. That > said, I'm quite happy with OD, but if they came out with a native code > version for a suitable platform, I would drop the Java version immediatly. > > UML is a big thing. I'm still a UML neophyte, but I'm getting use out of > it. It took time, reading and experimenting, to get to this point, but it > has been worth it. Not only have I begun to learn UML, but my OO > programming skills and understanding have improved too. My company has > found enough value in it to send me out for training. If you think UML > might work for you, I can't stress enough the value in downloading a tool, > like OD, and giving it a spin. > > >Thanks for your patience > Your welcome, > > Bill Scherer From lewisjd at msx.upmc.edu Fri Sep 3 13:31:06 1999 From: lewisjd at msx.upmc.edu (Jack Lewis) Date: Fri, 03 Sep 1999 13:31:06 -0400 Subject: PYTHON on ALPHA VMS 7.2? Message-ID: <37D005D9.38C27D05@msx.upmc.edu> Has anyone successfully built PYTHON on ALPHA VMS 7.2 ? As well as been able to compile and link 'C' programs with Embedded PYTHON calls? I can't seem to get past the link errors: %LINK-W-NUDFSYMS, 2 undefined symbols: %LINK-I-UDFSYM, CTL$GL_IMGHDRBF %LINK-I-UDFSYM, _PYIMPORT_INITTAB %LINK-W-USEUNDEF, undefined symbol _PYIMPORT_INITTAB referenced in psect PYIMPORT_INITTAB offset %X00000000 in module IMPORT file DSA900:[PYTHON.PYTHON-1_5_2.VMS.O_ALPHA]PYTHON.OLB ;10 %LINK-W-USEUNDEF, undefined symbol CTL$GL_IMGHDRBF referenced in psect $LINK$ offset %X00000010 in module VMS__GETBUILDINFO file DSA900:[PYTHON.PYTHON-1_5_2.VMS.O_ALPHA ]VMS.OLB;10 From philippe.boite at pacwan.fr Sat Sep 4 07:45:36 1999 From: philippe.boite at pacwan.fr (Philippe Boite) Date: Sat, 4 Sep 1999 13:45:36 +0200 Subject: Spanish Inquisition?! References: <37CFC38C.20A9C267@megsinet.net> Message-ID: <7qr293$1v7t$1@news5.isdnet.net> The Spanish Inquisition is a famous sketch by the Monty Pythons. Somebody says : - I wouldn't expect the Spanish Inquisition... And then enter 3 red Spanish inquisitors, one of theme saying : - Nooobody expects the Spanish Inquisition... Python was named after the Monty Pythons, so there are a lot of references to them, for example in the tutorial : - The Parrot sketch - And nice red uniforms... There are also often references in this ng (for a recent example, the lumberjack song). David Oppenheimer a ?crit dans le message : 37CFC38C.20A9C267 at megsinet.net... > In a previous thread (about languages interpreted versus languages > compiled) there was talk of the Spanish Inquisition. I am guessing that > this is 1) a joke or 2) the code name for a "secret" project to create > compiled code from python code and thereby permanently blur the line for > Python. Anyone know anything about this? > > I know no one ever expects the Spanish Inquisition, but if its coming > I'd like to know about it. > > David O. > > "Any Sufficiently Advanced Technology Is Indistinguishable From Magic" > - Arthur C. Clarke > > P.S. Creating compiled code from Python that didn't require the > interpreter to be distributed with it would be high magic indeed. > From gmcm at hypernet.com Thu Sep 9 14:01:40 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 9 Sep 1999 13:01:40 -0500 Subject: Embedding question (doing Python from C) In-Reply-To: <37D7CE73.43898B33@ncsa.uiuc.edu> Message-ID: <1275226148-104438625@hypernet.com> Randy Heiland writes: > I have a C++ server executing Python scripts using just > PyRun_SimpleString and it works great -- mostly. However, it > doesn't handle more complicated Python commands/constructs, e.g., a > 'for' loop. Can someone offer advice? What seems to be the problem? PyRun_SimpleString can't hack Windows line endings (should just be '\n'), and requires a null-terminated string, but said SimpleString's contents can be arbitrarily complex Python code. - Gordon From philh at vision25.demon.co.uk Sat Sep 11 20:27:58 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Sun, 12 Sep 99 00:27:58 GMT Subject: yacc/lex for Python References: <37DA861F.57212BC3@atl.mediaone.net> Message-ID: <937096078snz@vision25.demon.co.uk> In article <37DA861F.57212BC3 at atl.mediaone.net> nosleep at atl.mediaone.net "Kristopher Johnson" writes: > Are there any lex- or yacc-like tools available for Python? Oodles of 'em. My Parrot program uses John Aycock's parsing framework. See http://www.vision25.demon.co.uk/prog/parrot.html for details. -- Phil Hunt - - - - - - - - - philh at vision25.demon.co.uk - Linux will be 8 years old on 17th September! See: - http://www.vision25.demon.co.uk/prog/linuxbirthday.html From jayseye at my-deja.com Wed Sep 15 10:01:01 1999 From: jayseye at my-deja.com (jayseye at my-deja.com) Date: Wed, 15 Sep 1999 14:01:01 GMT Subject: TreeCtrl Object (win32ui) References: <7rm9bb$1rh$1@nnrp1.deja.com> Message-ID: <7ro8ql$eao$1@nnrp1.deja.com> Does Python offer a cross-platform Tree control, or does it only provide access to the Win32 control when running under Windows? Thanks. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From tim_one at email.msn.com Sun Sep 19 16:08:06 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 19 Sep 1999 16:08:06 -0400 Subject: Force anything to be a string. In-Reply-To: <99091911524208.00550@quadra.teleo.net> Message-ID: <000201bf02da$affbbce0$102d153f@tim> [Patrick Phalen, on inadvertently stomping builtin function names] > ... > How *hard* would it be to implement a warning message for this and is > it worth it? What marks the difference between a warning and > an error message? It's irritatingly difficult, but only because Python has no warning msgs today. So it means inventing a whole bunch of machinery and conventions where none currently exist. I think it should be done anyway, but since I'm not volunteering my own time to do it can't whine if nobody else does. Note that Macs don't have a concept of stdout or stderr, and at least under Windows the "no DOS box" pythonw variant doesn't have a visible stdout or stderr. So there's currently no good place to direct warnings even if there were some. That's not a new problem (there's no good place to direct fatal error msgs either!), but I think Guido would rather see machinery get invented to address that first. don't-everyone-rush-in-all-at-once-now-ly y'rs - tim From philh at vision25.demon.co.uk Tue Sep 14 19:37:27 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Tue, 14 Sep 99 23:37:27 GMT Subject: python call external program (WHAT THE?!) References: <65118AEEFF5AD3118E8300508B124877073BF5@webmail.altiris.com> Message-ID: <937352247snz@vision25.demon.co.uk> In article <65118AEEFF5AD3118E8300508B124877073BF5 at webmail.altiris.com> MSteed at altiris.com "Mike Steed" writes: > > From: Ben Thomas [mailto:bthomas at trey-industries.com] > > Sent: Tuesday, September 14, 1999 9:31 AM > > To: python-list at python.org > > Subject: Re: python call external program (WHAT THE?!) > > > > > > I just tried but putting the batch file in three places on a > > drive. The I tried > > them all. > > > > system('d:\mybat.bat') = ok > > system('d:\data\mybat.bat') = ok > > system('d:\data\vacman\mybat.bat') = fails, it works fine > > from DOS prompt! > > > > > > what gives? > > Ben > > What gives is that \v is an escape code (representing, I believe, the ASCII > VT character). There are a few ways around this. > > # Use raw strings > system(r'd:\data\vacman\mybat.bat') > > # Escape your backslashes > system('d:\\data\\vacman\\mybat.bat') > > # Use forward slashes (at least this works on WinNT) > system('d:/data/vacman/mybat.bat') You missed out: # use Linux instead of MS rubbish system('/usr/local/data/myshell.sh') -- Phil Hunt - - - - - - - - - philh at vision25.demon.co.uk - Linux will be 8 years old on 17th September! See: - http://www.vision25.demon.co.uk/prog/linuxbirthday.html From arnold at dstc.edu.au Wed Sep 1 02:12:30 1999 From: arnold at dstc.edu.au (David Arnold) Date: Wed, 1 Sep 1999 06:12:30 GMT Subject: threads on Solaris In-Reply-To: Your message of "Mon, 30 Aug 1999 18:38:26 EST." <199908302338.AA04307@ch1d2833nwk> References: <199908302338.AA04307@ch1d2833nwk> Message-ID: <199909010612.QAA06055@piglet.dstc.edu.au> -->"Ted" == Ted Horst writes: Ted> Does anyone know why I get 4 threads when I start the Ted> interpreter under Solaris (as reported by /bin/ps -aL) ? Ted> This is python 1.5.2 built with a SUNPro compiler (sorry, I Ted> don't have the config options). i see the same behaviour, also SUNPro, but i *know* mine is configured with the thread module enabled, which i imagine has something to do with it? Ted> SunOS ch1d2964syb 5.6 Generic_105181-12 sun4u sparc SunOS fig.dstc.edu.au 5.6 Generic_105181-11 sun4u sparc using dbx, i see that there are 3 threads and 4 LWPs active: (dbx) threads > t at 1 a l at 1 ?() running in _libc_read() t at 2 b l at 2 ?() running in __signotifywait() t at 3 ?() sleep on (unknown) in _swtch() (dbx) lwps >l at 1 running in _libc_read() l at 2 running in __signotifywait() l at 3 running in ___lwp_cond_wait() l at 4 running in _door_return() (dbx) thread t at 1 (lwp l at 1) is the interpreter's interactive prompt waiting for me to type something. idly speculating, t at 2 could handle signal delivery? l at 3 (in the cond_wait, actually a cond_timedwait) is called by a function _age ... no real clues on what that might be doing. what t at 3 and l at 4 are doing i've no idea (no useful call stack from dbx). but at least your observed behaviour isn't unique ;-) d From wtanksle at dolphin.openprojects.net Sat Sep 25 21:20:41 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Sun, 26 Sep 1999 01:20:41 GMT Subject: Moving from Perl to Python References: Message-ID: On Sun, 26 Sep 1999 00:35:25 +0000 (UTC), jonathon wrote: >On 25 Sep 1999, Harry George wrote: >>I also have the perl books and like cookbook. I'm in the process of > [ Text deleted ] >>Except for copyright issues, I'd say just redo all the Perl > A request to translate all the Perl Books into Python? I think he just wanted the Perl Cookbook, which would indeed be great (except, of course, for the parts which are trivial in Python -- we don't need no hashes-and-list man page ;-). > Other interesting/useful language translations might be > _Numerical Fortran_/_Numerical C_/_Numerical Pascal_ > << Or has this been done? >> That's facinating indeed -- but I suspect that NumPy already has all of those implemented (in C and linked to Python). > Donald Knuth's _The Art Of Programming_ Python instead of MX. > << At one time, Bill Gates automatically hired anybody who had > worked through 75% or more of the questions in that book. >> No, all they had to do was read through the whole series and be able to prove it. 75% solution rate would be amazing. However, he didn't say he'd hire you; he said, "send your resume to me." I can't see any employer turning anyone who's done that away, though. Impossible -- the purpose of MIX is to provide an assembly language which allows the algorithms to be demonstrated at a low level. If Knuth used Python for everything else, he'd still have to invent an assembly language for the chapters on code generation. (See his homepage for more details.) > Sedgewick's book on algorithms. Don't remember the title > offhand. :-( "Algorithms". A very good idea. > xan > jonathon -- -William "Billy" Tanksley From gregm at iname.com Wed Sep 1 07:44:13 1999 From: gregm at iname.com (Greg McFarlane) Date: Wed, 1 Sep 1999 21:44:13 +1000 Subject: position on the screen In-Reply-To: <37cc6b98.873539@news.telepac.pt>; from Xana on 31 Aug 1999 at 11:59:54PM References: <37cc6b98.873539@news.telepac.pt> Message-ID: <19990901214413.34597@nms.otc.telstra.com.au> On 31 Aug, Xana wrote: > I'm working with PythonMegaWidgets and i have a problem using > Pwm.dialog boxes. > Can anyone tell me if (and how) I can define the position in wich the > window will appear in the screen ? You can use the same methods as any Tkinter.Toplevel. For example: import Pmw d = Pmw.Dialog(buttons = ('Yes', 'No', 'Dunno')) d.geometry('+400+400') will position the dialog window 400 pixels down and across from the top left corner of the screen. If you want to display the dialog modally (ie: disallow any user inputs except to the dialog), use the activate method with the geometry option. For example, d.activate(geometry = '+400+400') See the Pmw.MegaToplevel manual page for the full story. -- Greg McFarlane INMS Telstra Australia gregm at iname.com From hschroeder at gmx.net Sat Sep 25 15:19:31 1999 From: hschroeder at gmx.net (Henning Schroeder) Date: Sat, 25 Sep 1999 21:19:31 +0200 Subject: GUI-builder for PyQt/PyKDE Message-ID: <387js7.klc.ln@odin.henning-schroeder.de> Hi there, the above subject is no inquiry on such a thing. Actually I am working on a visual IDE based on the Qt and KDE bindings for Python. Therefore I implemented a small component library which fits the needs for visual development. I call the library ViPyl. It consists mainly of some wrapper classes around Qt widgets and adds property support to them. Unique and easy event handling is under development and currently not available. So it is not ready for real development yet. If you are interested int ViPyl and the GUI builder look at the following page for some screenshots and for an alpha version to download: http://www.henning-schroeder.de/en/python/vipyl/ Suggestions are welcome! Henning From fleck at informatik.uni-bonn.de Tue Sep 21 02:43:55 1999 From: fleck at informatik.uni-bonn.de (Markus Fleck) Date: 21 Sep 1999 06:43:55 GMT Subject: ANN: Python Announcements... Message-ID: <7s79fb$nfg@news.rhrz.uni-bonn.de> Dear fellow Pythoneers, the articles queue for comp.lang.python.announce has been stalled since August 22, 1999 - mostly due to a temporary lack of time on my part. There is currently a backlog of about 80 messages. You can help to speed up the moderation process significantly by adhering to the posting guidelines that are posted bi-weekly to comp.lang.python and comp.lang.python.announce. In particular, life would become a lot easier for me if all submitted announcements already included the requested HTML mark-up footer (which is used to give a one-sentence summary of each announcement at the www.python.org home page). You can always find the latest version of the comp.lang.python.announce posting guidelines at the following URL: . Currently pending announcements will not be sent out all at once, but will be distributed over the next few days, so as to avoid overloading the inboxes of those people who have subscribed to comp.lang.python.announce via the "python-announce-list" mailing list. If you want to convert your mailing list subscription to digest format, or temporarily suspend your mailing list subscription, you should do so now by visiting the list's Mailman web page at . I appreciate your patience, and the offers for help that I have received. Of course, I am truly delighted to see so many announcements being posted to comp.lang.python.announce - and all the time we're getting closer to having the 1000th posting to comp.lang.python.announce by Y2K... -:^) Happy hacking, -- Markus Fleck (Moderator) from sys import*;from string import*;a=argv;[s,p,q]=filter(lambda x:x[:1]!= '-',a);d='-d'in a;e,n=atol(p,16),atol(q,16);l=(len(q)+1)/2;o,inb=l-d,l-1+d while s:s=stdin.read(inb);s and map(stdout.write,map(lambda i,b=pow(reduce( lambda x,y:(x<<8L)+y,map(ord,s)),e,n):chr(b>>8*i&255),range(o-1,-1,-1))) -- RSA in Python (or so I've been told ) -- ----------- comp.lang.python.announce (moderated) ---------- Article Submission Address: python-announce at python.org Python Language Home Page: http://www.python.org/ Python Quick Help Index: http://www.python.org/Help.html ------------------------------------------------------------ From druid at primenet.com Tue Sep 28 20:29:04 1999 From: druid at primenet.com (Michael A. Davis) Date: 29 Sep 1999 00:29:04 GMT Subject: Problem installing Python on AIX References: <7sr2i2$hto$1@fir.prod.itd.earthlink.net> Message-ID: <7srmgg$rtl$1@nnrp03.primenet.com> In article <7sr2i2$hto$1 at fir.prod.itd.earthlink.net>, Jamey Cribbs wrote: >I am attempting to install Python 1.5.2 on AIX version 4.2.1. When I run >./configure, I am getting errors in the config.log stating: > >ld: 0706-006 Cannot find or open library file: -l m > ld:open(): A file or directory in the path name does not >exist. > >After this, the make also bombs out. Does anyone have an idea what is >wrong? I can email the log file if that will help. I am no AIX guru, but managed to reproduce this error message on with a tiny C program: ------------------------------------------------------------------- $ cat quiz.c #include #include int main(int argc, char ** argv) { printf("%f\n", pow(2.3,1.5)); } $ xlc -o quiz quiz.c -la ld: 0706-006 Cannot find or open library file: -l a ld:open(): A file or directory in the path name does not exist. $ echo $LIBPATH ------------------------------------------------------------------- I'd say you don't have libm.a on your LIBPATH. Mike druid at primenet.com > >Any help would be greatly appreciated. > >Jamey Cribbs >cribbsjg at earthlink.net > > > -- ------------------------------------------------------------------------------- --mad druid at primenet.com From philh at vision25.demon.co.uk Fri Sep 3 16:28:55 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Fri, 03 Sep 99 20:28:55 GMT Subject: Pirate -> RAD References: <7qno38$6uk$1@news.is.co.za> Message-ID: <936390535snz@vision25.demon.co.uk> In article <7qno38$6uk$1 at news.is.co.za> jacques at integra.co.za "Jacques Oosthuizen" writes: > Hi All > > I am busy working on a tool I named Pirate ("Python RAD") it has a component > library similar to Delphi and shall in the future work with win32,gtk,qt. It > will have a IDE. > > Before I do to much and work to hard on it, will anyone be interested in > using a > tool like this. Possibly. It depends what features it has, and how easy it is to fit in with other software. -- Phil Hunt - - - - - - - - - philh at vision25.demon.co.uk - Linux will be 8 years old on 17th September! See: - http://www.vision25.demon.co.uk/prog/linuxbirthday.html From hnowak at cuci.nl Sat Sep 4 03:58:54 1999 From: hnowak at cuci.nl (Hans Nowak) Date: Sat, 4 Sep 1999 07:58:54 GMT Subject: Snippets site temporarily (?) down Message-ID: <199909040800.KAA18341@dionysus.fw.cuci.nl> OK, the title says it all... Well, in fact it's not just my snippets page, it's the whole damn hvision.nl site that's down. Again. I have been thinking about moving the site elsewhere, since this isn't the first time that this happens. I do not want to have annoying popup ads and such, though (geocities/xoom/etc). Anyone has some free webspace I can use? --Hans Nowak (zephyrfalcon at hvision.nl) Homepage: http://fly.to/zephyrfalcon Python Snippets: http://www.hvision.nl/~ivnowa/snippets/ The Purple Kookaburra Forum: http://www.delphi.com/kookaburra/ From guido at cnri.reston.va.us Thu Sep 2 08:27:00 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 02 Sep 1999 08:27:00 -0400 Subject: Queue class deadlocking application References: Message-ID: <5lhfld5wiz.fsf@eric.cnri.reston.va.us> No real help here, but (1) this is an issue for the thread-sig, and (2) you need to provide details about your platform and Python configuration; threads are (unfortunately) very platform dependent and not all platforms have quality thread implementations. --Guido van Rossum (home page: http://www.python.org/~guido/) From davidopp at megsinet.net Fri Sep 3 02:31:55 1999 From: davidopp at megsinet.net (David Oppenheimer) Date: Fri, 03 Sep 1999 02:31:55 -0400 Subject: OH, I'm A Lumberjack And I'm OK... References: <37CE2648.D4254FCC@megsinet.net> <37ceeef4.5698550@news.erols.com> <37CF55DC.816F38F5@megsinet.net> Message-ID: <37CF6B5A.DC88A5E5@megsinet.net> OK, I lied, here's yet another post in my continuing struggle to run painter.py I took Robin's PYTHONPATH suggestion and now my traceback is as follows: >>> Traceback (innermost last): File "C:\Python\Pythonwin\pywin\framework\scriptutils.py", line 237, in RunScript exec codeObject in __main__.__dict__ File "C:\Python\scripts\painter.py", line 65, in ? im = Image.open(sys.argv[1]) IndexError: list index out of range I have now gotten to line 65 before I get an error (this is a tremendous improvement of 53 lines more of code processed before an error kills the program). All Hail Robin Dunn, Master of wxPython and all around troubleshooter. Got any ideas what the heck this last error means Robin? David O. Robin Dunn wrote: > > > > PATHS (yes, I took the suggestion to place my Python & related files > in > > pathways that have no spaces) > > > > Path to Python executable: C:\Python > > Path to Tcl executable: C:\Tcl\bin > > Path to PIL: C:\Python\PIL > > Path to Tkinter: C:\Python\Lib\lib-tk > > Path to Painter (a program that I am more than curious to see work, I am > almost > > obsessed now): C:\Python\scripts\painter.py > > > > My Traceback (error message): > > > > >>> Traceback (innermost last): > > File "C:\Python\Pythonwin\pywin\framework\scriptutils.py", line 237, in > > RunScript > > exec codeObject in __main__.__dict__ > > File "C:\Python\scripts\painter.py", line 12, in ? > > import Image, ImageTk > > ImportError: No module named Image > > > > My Autoexec.bat settings: > > > > PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\WINDOWS; > > set PATH=%PATH%C:\mingw32\bin; > > set PATH=%PATH%C:\PYTHON;C:\PYTHON\PIL;C:\TCL\BIN;C:\PYTHON\LIB\LIB-TK; > > > > It can't find the module because it's not on the PYTHONPATH. Execute this > python code to see what directories are in your PYTHONPATH: > > import sys > print sys.path > > To fix it add this to your autoexec.bat: > > set PYTHONPATH=c:\Python\PIL > > or add the directory to the value in the Registry at > > HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\1.5\PythonPath > > or as a subkey. > > -- > Robin Dunn > Software Craftsman > robin at AllDunn.com > http://AllDunn.com/robin/ > http://AllDunn.com/wxPython/ Check it out! From aa8vb at yahoo.com Mon Sep 20 08:18:16 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Mon, 20 Sep 1999 08:18:16 -0400 Subject: Any good debuggers for Python? (was Re: using python debugger (pdb) inside emacs debugger mode ...) In-Reply-To: <199909182333.QAA12325@hercules.cup.hp.com>; from Ovidiu Predescu on Sat, Sep 18, 1999 at 04:33:01PM -0700 References: <14307.57188.583343.140730@gargle.gargle.HOWL> <199909182333.QAA12325@hercules.cup.hp.com> Message-ID: <19990920081816.A350855@vislab.epa.gov> Ovidiu Predescu: |I didn't figure out exactly all the details, but the basic idea is to use |GDB to handle all the interaction with the user instead of pdb. pdb |becomes only a debugging engine that's loaded in a Python program and |knows how to setup breakpoints, continue the program etc. All these |operations are published in a simple Python API that could be called from |GDB. I believe this is how DDD/PyDB works as well (providing the user with a graphical Python debugger). |What I'm working on right now is adding scripting language support to GDB |so that this kind of functionality could be implemented in GDB using an |interpreted language and not C. The language I'm embedding is surprise, |Python ;-). This work is part of the WDB project here, at HP, but all the |work we're doing is going back in the FSF main tree. For more information |on WDB, take a look at: | |http://www.hp.com/esy/lang/tools/Debuggers/index.html Sounds interesting. Hope to hear more about this later. -- Randall Hopper aa8vb at yahoo.com From fredrik at pythonware.com Thu Sep 23 03:17:56 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 23 Sep 1999 07:17:56 GMT Subject: Newbie Question References: <37E773E7.B3A0CEA0@ecs.soton.ac.uk> <37E8AF24.1CDE9916@isogmbh.de> <002f01bf04e6$7d6a4950$f29b12c2@secret.pythonware.com> Message-ID: <00a001bf0593$c37a8060$f29b12c2@secret.pythonware.com> Tom Culliton wrote: > string.atoi(), string.atof(), ... are also substantially faster (about > twice as fast by my tests) than int(), float() and the like. that was true in earlier versions, but as of 1.5.2, int/float is a little bit faster than atoi/atof. (if you write the latter as "string.atoi" etc, the extra lookup time makes the builtin versions about twice as fast on my box). > Generally I would recommednd using int() when you need to > coerce a "number" of arbitrary type to an integer (like you > would a C/C++ cast), and using string.atoi() to interpret strings > as integers. good advice! From claird at starbase.neosoft.com Tue Sep 14 20:46:54 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 15 Sep 1999 00:46:54 GMT Subject: high school programming & python References: <937300939snz@vision25.demon.co.uk> <$JL+lCAFvt33Ewr8@jessikat.demon.co.uk> <7rmmjr$qv6@dfw-ixnews11.ix.netcom.com> Message-ID: <2BAF9178787E2D18.F80B717C3A0115B2.701123DC5A66FDBE@lp.airnews.net> In article <7rmmjr$qv6 at dfw-ixnews11.ix.netcom.com>, Aahz Maruch wrote: >In article <$JL+lCAFvt33Ewr8 at jessikat.demon.co.uk>, >Robin Becker wrote: >>In article <937300939snz at vision25.demon.co.uk>, Phil Hunt >> writes >>>In article >>> nospam at bitbucket.com "Phil Mayes" writes: >>>> >>>> This is, as you imply, a fallacious argument; if carried to its logical >>>> extreme, we shouldn't teach C because students will be spoiled and not >>>> want to use assembler. In fact, assembler spoils people for machine >>>> language :-) >>> >>>Machine language! You young people today don't know what hardship >>>is... when I were a lad, we had to manually patch the ALU using >>>plug boards to change the logic. >> >>You were lucky to have plugboards. We had to key things in with a bunch >>of switches. > >You were lucky to have switches. We had to rewire the traces. . . . If a mercury delay line won't pass it, it's not worth computing. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From greg.ewing at compaq.com Mon Sep 6 18:00:26 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Tue, 07 Sep 1999 10:00:26 +1200 Subject: Class in class References: <37D38E90.2E5713A9@acay.com.au> Message-ID: <37D43979.E7A7B4AE@compaq.com> Gurvijay Singh Bhatti wrote: > > Dear everyone, > > Like C++ and Java, is it possible to declare a class in a class? If it > is then could you tell how? class Foo: ... class Blarg: ... The class Blarg is now a class attribute of class Foo, so you can refer to it as Foo.Blarg, or as self.Blarg within any method of class Foo. Greg From paul at prescod.net Sat Sep 4 07:35:29 1999 From: paul at prescod.net (Paul Prescod) Date: Sat, 4 Sep 1999 11:35:29 GMT Subject: Returning none References: <000601bef688$f83412e0$ce2d153f@tim> Message-ID: <37D10401.B6360540@prescod.net> Tim Peters wrote: > > Let's shift the ground of the debate: I'd bet Guido's life that this won't > go into 1.6, and I think most long-timers would agree with that regardless > of their opinion of the technical merits pro or con (new keyword?! more > likely Tom Christiansen posts 10 energetic msgs bemoaning the lack of Python > docs in PowerPoint format ). But what about Python2? If there were a > clean way to plug the hole in that, would you object? I want to point out that in the first message bearing this now disgraced subject line I did say that this should be a version 2, not 1, change. Forseeing the current flamage I said: > This is obviously an incompatible change so I propose it for Python 2. Paul Prescod From ashwood at usc.edu Fri Sep 3 19:37:23 1999 From: ashwood at usc.edu (Joseph Ashwood) Date: Fri, 3 Sep 1999 16:37:23 -0700 Subject: Win32 Specific: SimpleMAPI References: Message-ID: I think the phrase DUH comes to mind, I found the function I wrote called InitSimpleMAPI, so I obviously don't need that one. Sorry about that. Joseph Joseph Ashwood wrote in message news:eK104el9#GA.277 at cpmsnbbsa03... > Someone on here has to know thet answer, I just can't seem to find it. I'm > looking to call the SimpleMAPI functions: InitSimpleMAPI, MAPILogon, and > MAPIAddress. Could someone please shed some light on how to do this? > Joseph > > From mlh at idt.ntnu.no Sun Sep 19 12:19:19 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 19 Sep 1999 18:19:19 +0200 Subject: My own pyhton in CGI... Message-ID: I'm having a problem - I want to use the newest version of Python for CGI, and the one installed by the techies around here is a bit old... So - I installed my own in my home directory (which works just fine) but when I try to write something like #!/my/home/directory/foo/bar/python it doesn't work. It there a standard problem/solution here, or must I dig more deeply into it? (I think I have set the permissions for the python and its super-directories properly...) -- Magnus Lie Please forward all spam to Hetland uce at ftc.org From tim_one at email.msn.com Sat Sep 25 23:01:02 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 25 Sep 1999 23:01:02 -0400 Subject: Moving from Perl to Python In-Reply-To: Message-ID: <000601bf07cb$5e1ede20$602d153f@tim> [Harry George, on converting Perl to Python] > ... > 2. Work out the regular expression tricks early -- I'm currently > looking for a python idiom for > s/@@([a-z]+)@@/$lookup{$1}/g > > Python needs a Cookbook. Except for copyright issues, I'd say just > redo all the Perl Cookbook examples in python -- or maybe O'Rielly has > one in the works already. Translation of that Perl into Python is straightforward but unsatisfying: import re lookup = { ... } pattern = re.compile(r"@@([a-z]+)@@") # s is input string, t is output string t = pattern.sub(lambda m: lookup.get(m.group(1), ""), s) The point to using lookup.get with an empty-string default is to slavishly mimic Perl's behavior of "erasing" the entire match string if lookup doesn't contain the key. I would much rather see an exception raised in that case, and only partly because Python would prefer to raise one . Over the long term, it's more fruitful to write Python from the start than to mimic dubious Perl features. For example, the data you're starting with probably didn't come with @@xyz@@ thingies naturally, but that notation was invented because someone knew it would be easy to substitute using Perl s///g. If the project started in Python, you'd be more likely to use %(xyz)s notation in the data, so that substitutions could be done simply and much more quickly via Python's t = s % lookup idiom. Regexps are not Python's forte, and all of speed, clarity and maintainability will increase in proportion to your zeal in purging them. so-ends-chapter-1-of-the-what-not-to-cook-book-ly y'rs - tim From pinard at iro.umontreal.ca Mon Sep 13 17:37:53 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 13 Sep 1999 17:37:53 -0400 Subject: List to string? Docstrings? Message-ID: Hello, people. Still learning Python. I wrote around 6000 Python lines in the last 10 days! :-) I have two quick questions for you. 1) For converting a string into a list, I used: chars = list(text) For getting back the string from the list, I tried: import operator text = reduce(operator.concat, chars) but still, I wonder if you would not have a better suggestion... 2) I still miss the purpose of __doc__ strings. It's true that I can write: print module.__doc__ print function.__doc__ and sometimes get useful information from these. But what would I be loosing, for my own things, if I was using mere `#' comments instead? -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From donn at u.washington.edu Fri Sep 24 14:28:19 1999 From: donn at u.washington.edu (Donn Cave) Date: 24 Sep 1999 18:28:19 GMT Subject: SIGCHLD, fork, listen References: <37EC1ACA.8963554B@hk.rfa.org> <7sd6q4$gqq$1@salome.rfa.org> <7sdqfn$m0o$1@nntp6.u.washington.edu> Message-ID: <7sgfs3$ejg$1@nntp6.u.washington.edu> Quoth Bill Eldridge : | Another option would be to use inetd, but I need to | do some host/address verification, and couldn't figure | out how to latch onto that kind of socket info from | a new spawned inetd handler using Python. Ideas? Would this work? sock = socket.fromfd(0) print sock.getpeername() inetd should give you the socket descriptor on unit 0. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From srenner at lycosmail.com Tue Sep 7 11:11:53 1999 From: srenner at lycosmail.com (srenner at lycosmail.com) Date: Tue, 07 Sep 1999 15:11:53 GMT Subject: Suitability for games? References: <37D5086C.69204F4C@jonjh.freeserve.co.uk> <7r2vlu$68m$1@newshost.accu.uu.nl> Message-ID: <7r39ur$kdt$1@nnrp1.deja.com> This is the general > principle -- Python can still perform quite well as a higher level > controlling system (which can include a lot -- GUI, loading/saving, > scripting of in-game objects and events, etc), even when it's not > fast enough to do low level graphics manipulation. You use a C or C++ > library for that, but you can wrap those with Python. "A C or C++ library" meaning Mesa or another OpenGL implementation, if you want to use hardware accelerated graphics. PyOpenGL is available and being maintained actively by David Ascher. I help maintain the demo directory. If anyone has trouble installing or running the module, I'll try to help -- mail me. > > For object scripting, there are some interesting developments. Python does > not have 'simulated threads' by default. [ Discussion of threads] > So I'd recommend Python for game scripting. . . Well, threads are interesting, but the rendering has to all happen in a single process -- one can't very well have multiple streams of OpenGL calls being shuffled together. The new nvidia chip has 4 pixel pipelines. Presumably each pipeline has a separate context (state machine) and so the chip could be driven by 4 renderering threads. But you would want to balance the loads so that each pipeline was doing about the same amount of work per frame. It's not like Guido's Brownian motion demo with one thread per 'object', because the objects will have to be in heirarchies for any reasonably sized and detailed scene. Now, one might have two phases, rendering and 'world update', with objects updating themselves in threads, but the rendering can't be split. As long as the update doesn't step on the renderer . . . Actually that sounds good. Watch the PyOpenGL demo directory for an implementation. sr Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From olipt at mayo.edu Thu Sep 30 16:04:08 1999 From: olipt at mayo.edu (Travis Oliphant) Date: Thu, 30 Sep 1999 15:04:08 -0500 Subject: Memory Error In-Reply-To: <37F385AC.7057E983@v1.wustl.edu> References: <37F385AC.7057E983@v1.wustl.edu> Message-ID: > Hi, > > I'm passing fairly large arrays around (using Numeric Py) > and I'm getting the error: > > MemoryError: can't allocate memory for array > > although I have plenty of memory left on my SGI (Indigo2 > with 448 megs). Why would I be seeing this message although > the machine hasn't even starting swapping? Is there a default > stack size I can adjust somehow? > I don't know exactly what's happening for you here. But, let's investigate. I'll assume you are using NumPy 11. A grep through the source shows that this error is used three times in arrayobject.c: All three times it is used is in PyArrayFromDimsAndData when malloc fails while trying to allocate memory for the dimensions, or the strides, or the data from the heap. So, I don't think it is a stack-size question unless malloc works in an unfamiliar way on an Indigo2. Most likely it is failing when allocating data memory based on the dimensions variable based to the C-routine PyArrayFromDimsAndData. To further analyze your problem, I will need to know what command you are using to get the failure you describe since PyArrayFromDimsAndData is used several times in the source. Sorry I can't be of more help. Travis From pinard at iro.umontreal.ca Tue Sep 14 21:05:52 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 14 Sep 1999 21:05:52 -0400 Subject: timesync with python? In-Reply-To: "Fredrik Lundh"'s message of "Thu, 9 Sep 1999 12:01:50 GMT" References: <37D66AF3.6A3E96F7@phoenix-edv.netzservice.de> <002701befabb$1a884880$f29b12c2@secret.pythonware.com> Message-ID: Holger Jannsen wrote: > But I also thought that someone has an idea about that before and did > it likely better than me. So, do you know a weblink to a script which > already nearly does what I need? Perhaps directly with interrogation at > port 37 NTP? "Fredrik Lundh" writes: > from the eff-bot archives: > import socket, time > HOST = "my.server" > PORT = 37 > TIME1970 = 2208988800L # 1970-01-01 00:00:00 > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > s.connect(HOST, PORT) > b = s.recv(4) > t0 = ord(b[3]) + (ord(b[2])<<8) + (ord(b[1])<<16) + (ord(b[0])<<24L) > t1 = int(time.time()) + TIME1970 > dt = int(t0 - t1) > print "delta is", dt, "seconds" Isn't that fun? I just coded this, a few days ago. My formulation is almost identical, yet a tiny bit cleaner, maybe: import socket, struct, time def time_delta(machine): client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client.connect(machine, socket.getservbyname('time', 'tcp')) data = client.recv(4) client.close() remote_secs = int(struct.unpack('!I', data)[0] - 2208988800L) local_secs = int(time.time()) return remote_secs - local_secs -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From hnowak at cuci.nl Tue Sep 7 17:00:44 1999 From: hnowak at cuci.nl (Hans Nowak) Date: Tue, 7 Sep 1999 21:00:44 GMT Subject: Snippets site has moved! Message-ID: <199909072102.XAA20264@dionysus.fw.cuci.nl> Due to problems with my previous host (hvision.nl), which has proven to be more than a little unstable, I deciced to move my snippets site. The new URL is http://tor.dhs.org/~zephyrfalcon/snippets/ Thanks to Blake Winton for offering me the account and the web space. (Lots of people suggested the Python Starship as the new snippet home, but I am not a PSA member. :-/ ) I will remove the HTML from the old address as soon as possible. By the way, I haven't been able to add any new snippets yet (counter is currently at 130). I do have a lot of them on my harddisk, unprocessed, some of which I hope to add soon. New snippets are always welcome, by the way. One more thing: The site still mentions hey_psst at usa.net as the email address to contact me about snippets, and while this address is still valid, I do not check it too often (due to my slow Internet connection; usa.net isn't that fast). You will get an answer more quickly if you contact me at zephyrfalcon at hvision.nl. I will get rid of the usa.net address in the near future. --Hans Nowak (zephyrfalcon at hvision.nl) Homepage: http://fly.to/zephyrfalcon Python Snippets: http://www.hvision.nl/~ivnowa/snippets/ The Purple Kookaburra Forum: http://www.delphi.com/kookaburra/ From aahz at netcom.com Sun Sep 19 12:34:07 1999 From: aahz at netcom.com (Aahz Maruch) Date: 19 Sep 1999 16:34:07 GMT Subject: Marking translatable strings References: Message-ID: <7s339v$d78@dfw-ixnews3.ix.netcom.com> In article , =?ISO-8859-1?Q?Fran=E7ois_Pinard?= wrote: > >So, I want the big picture right now. That is: a technique for marking >strings for automatic extraction and building of PO files, and a technique >for using PO files from within Python scripts. I foresee that Python >introduces an usual difficulty in that the textual domain for translations >may vary quite unexpectedly, when the control dynamically flies between >independent packages under different textual domains. Y'know, it might help those of us with an interest in I18N but little actual experience if you posted some resources that gave information about what the heck a "PO file" is and how one is suposed to generate and access it in other languages. (Yes, I could search the web, but it'd be difficult for me to determine which sites are the most useful.) Personally, if you want to accomplish anything useful in the 1.6 timeframe, I think you'll be best off creating some sort of I18N module or package and constructing an automatic approach that relies on strings being used through this package if they are intended to be internationalized. This does ignore the big problem of doc strings, but IMO doc strings should be used more by programmers than end-users -- I *don't* like them for printing output. In any event, I don't think you can solve this problem in the pre-2.0 timeframe, though it's certainly worth laying the groundwork now. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From aahz at netcom.com Tue Sep 7 20:49:22 1999 From: aahz at netcom.com (Aahz Maruch) Date: 8 Sep 1999 00:49:22 GMT Subject: How to get the python sourcecode line, when debuging the Python C sources? References: <7r3bqk$hbv$1@newshost.germany.net> <7r4alh$7gl$1@m2.c2.telstra-mm.net.au> Message-ID: <7r4bqi$jds@dfw-ixnews11.ix.netcom.com> In article <7r4alh$7gl$1 at m2.c2.telstra-mm.net.au>, Mark Hammond wrote: >Stefan Knappmann <101.139915 at germanynet.de> wrote in message >> >>Does anybody know in which C variable I can find the Python Stack? >>Or how to get the activ Python source code line from within the C >>debugger? > >Move down the stack to eval2() in ceval.c. f->f_lineno will tell you the >line number. f->f_code->co_filename + 20 bytes is the start of the ASCII >string containing the filename. Adding something like "(char *)(((char >*)f->f_code->co_filename))+20)" to the watch window should do the trick. And people wonder why I think C is a dead language. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From cjc26 at nospam.cornell.edu Wed Sep 1 22:10:32 1999 From: cjc26 at nospam.cornell.edu (Cliff, or a close facsimile) Date: 2 Sep 1999 02:10:32 GMT Subject: All rise for judge Timothy Peters... References: <000201bef43e$b8af52c0$df2d153f@tim> Message-ID: Note how the Timbot tries to distract us from the fact that no human records of him exist. but-the-mobile-exoskeleton-should-be-ready-real-soon-now-ly yr's, Cliff Pada Wed, 1 Sep 1999 01:56:23 -0400, Tim Peters bilang: | You be the judge! Here are some pictures of me from last year: | | http://www.puer.to/bae/p/txtipe01.htm | | I turned to singing after the embarrassment of having been picked in the 26th | round of the 1995 June draft by a Minnesota Twins farm team: | | http://www.miraclebaseball.com/pete19.html | | All in all, becoming a judge was the best career move I made since I got fired | for that "New Coke" disaster. | | thanks-for-caring-and-they're-guilty-as-charged-ly y'rs - tim -- cliff crawford http://www.people.cornell.edu/pages/cjc26/ There are more stars in the sky than there are -><- grains of sand on all the beaches of the world. From fredrik at pythonware.com Fri Sep 17 09:37:40 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 17 Sep 1999 13:37:40 GMT Subject: cgi post question References: Message-ID: <006401bf0111$f2487590$f29b12c2@secret.pythonware.com> Felicia Neff wrote: > I am trying to write a CGI script that takes input from a POST, modifies > some of the input and then POSTs that info to another CGI script. I know > that perl has a function that will do this. Is there such a function in > python (and if it is do_POST() from the CGIHTTPServer module, is there any > more documentation besides that at > http://www.python.org/doc/current/lib/module-CGIHTTPServer.html?)? CGIHTTPServer is a web server implementation. you're probably more helped by the urllib client library: http://www.python.org/doc/current/lib/module-urllib.html import urllib ... result = urllib.urlopen(myurl, mydata) (currently limited to application/x-www-form-urlencoded posts, by some strange reason). hope this helps! From bernhard at alpha1.csd.uwm.edu Wed Sep 8 14:52:00 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 8 Sep 1999 18:52:00 GMT Subject: Programmers Editor References: <37D5916B.606E@zeusedit.com> <00da01bef9e0$6e1b5c70$f29b12c2@secret.pythonware.com> Message-ID: On Wed, 8 Sep 1999 09:52:14 GMT, Fredrik Lundh wrote: >Bernhard Reiter wrote: > The gist of it is that Python is absolutely free, even > for commercial use (including resale). >and the newsgroup has always reflected that, as >long as the emphasis has been on Python. That's fine. IMO the emphasis was the last post was not entirely on python. (see my other post.) >but to help them, it's probably better to put up >a site somewhere comparing different tools (or >just pointing to them) That would be nice. As an FAQ: Which (free software?) editors or development tools are known to be used by a lot of python developers. Or are suitable/integrated with python on Unix/Mac/Win. It is just good to know which editors can do python syntax highlighting. It might be too much work, too. Next time I shall save my bytes for more hacking. ;-) Bernhard -- Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard) Association for a Free Informational Infrastructure (ffii.org) From philh at vision25.demon.co.uk Sat Sep 4 21:30:32 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Sun, 05 Sep 99 01:30:32 GMT Subject: Pirate -> RAD References: <7qno38$6uk$1@news.is.co.za> <37D17998.5CF4@warande.uu.nl> Message-ID: <936495032snz@vision25.demon.co.uk> In article <37D17998.5CF4 at warande.uu.nl> M.Oti at warande.uu.nl "Martin Oti" writes: > > PS3: Pirate and Parrot. How ironic. ;) Is this a coincidence? Yes, AFAIK. Parrot is named after the Parrot Sketch. -- Phil Hunt - - - - - - - - - philh at vision25.demon.co.uk - Linux will be 8 years old on 17th September! See: - http://www.vision25.demon.co.uk/prog/linuxbirthday.html From aahz at netcom.com Sat Sep 4 13:22:12 1999 From: aahz at netcom.com (Aahz Maruch) Date: 4 Sep 1999 17:22:12 GMT Subject: "if" syntax error References: <37D138C1.3EABC811@dialnet.net> Message-ID: <7qrkg4$6g1@dfw-ixnews21.ix.netcom.com> In article <37D138C1.3EABC811 at dialnet.net>, Andrew Kesterson wrote: > >CGIHeaders = cgi.FieldStorage() >if CGIHeaders["Listing_Type"].value == "Residential": > >when I compile it, I get this error: > > File "C:\Program Files\Python\Source\Skydev\addlisting.py", line 82 > if CGIHeaders["Listing_Type"].value == "Residential": > ^ > SyntaxError: invalid syntax Is this the actual indentation within the program? I ran into a similar problem yesterday (not in *my* code ;-) that essentially looked like this: class foo(): def a(): pass def b(): pass def c(): pass Note that "def b()" is outdented an extra level. You can also run into similar problems if you mix tabs and spaces. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From bernhard at alpha1.csd.uwm.edu Thu Sep 9 14:42:51 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 9 Sep 1999 18:42:51 GMT Subject: Programmers Editor References: <37D5916B.606E@zeusedit.com> <00da01bef9e0$6e1b5c70$f29b12c2@secret.pythonware.com> <3dg10p1b5j.fsf@amarok.cnri.reston.va.us> Message-ID: On 08 Sep 1999 15:00:24 -0400, Andrew M. Kuchling wrote: >Just follow up to this posting with notes on >configuring your editor of choice. vim after version 5.x comes with python syntax highlighting rules, just open a file with ".py" ending and vim will know that it is python. You might need to give vim your background complextion and turn syntax on though. The commands to turn it on usually go in the ~/.vimrc note that I have the background set to dark, too. (light is the other option.) " Switch syntax highlighting on, when the terminal has colors " Also switch on highlighting the last used search pattern. if &t_Co > 2 || has("gui_running") set background=dark syntax on set hlsearch endif If you use the terminal program version of vim (called vim) your terminal has to do color and the TERM entry and terminfo/termcap information have to be correct of course. The GUI versions (gvim) can do color themselfs. If you compile vim you can disable syntax highlighting. Someone should elaborate on the tab use in vim a bit. Bernhard -- Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard) Association for a Free Informational Infrastructure (ffii.org) From lmariusg at ifi.uio.no Wed Sep 22 12:47:28 1999 From: lmariusg at ifi.uio.no (Lars Marius Garshol) Date: 22 Sep 1999 18:47:28 +0200 Subject: wxPython on Debian Linux Message-ID: Does anyone know how to find this? Searches on deja.com, debian.org and the wxPython site have so far been unsuccessful. (Yeah, I've tried what it says on the site, and also searched in dselect, all to no avail.) Any help would be most gratefully received. --Lars M. From eugene.leitl at lrz.uni-muenchen.de Fri Sep 10 14:20:23 1999 From: eugene.leitl at lrz.uni-muenchen.de (eugene.leitl at lrz.uni-muenchen.de) Date: Fri, 10 Sep 1999 11:20:23 -0700 (PDT) Subject: [MMTK] ANN: Biopython.org (Call for Participation) Message-ID: From: Jeffrey Chang The Biopython Project (http://www.biopython.org/) is a new open collaborative effort to develop freely available Python libraries and applications that address the needs of current and future work in bioinformatics, including sequence analysis, structural biology, pathways, expression data, etc. When available, the source code will be released as open source (http://www.biopython.org/License.shtml) under terms similar to Python. This is a Call for Participation for interested people to join the project. We are hoping to attract people from a diverse set of backgrounds to help with code development, site maintenance, scientific discussion, etc. This project is open to everyone. If you're interested, please visit the web page, join the biopython mailing list, and let us know what you think! Jeffrey Chang Andrew Dalke _______________________________________________ mmtk maillist - mmtk at starship.python.net http://starship.python.net/mailman/listinfo/mmtk From MHammond at skippinet.com.au Fri Sep 10 20:56:44 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Sat, 11 Sep 1999 10:56:44 +1000 Subject: ASP with Python question References: <37d87ed7@news.interq.or.jp> <7radmm$euq$1@m2.c2.telstra-mm.net.au> <37d8c687@news.interq.or.jp> Message-ID: <7rc9d2$ch6$1@m2.c2.telstra-mm.net.au> Glen Malley wrote in message <37d8c687 at news.interq.or.jp>... >Mark Hammond wrote: >> >>>It would really suck if the Session was the only object >>>not working, because it's the only object I need...;-P >> >>Im afraid it really sucks :-) This is the only known bug in the Active >>Scripting support :-( > >Hrm, color me an unhappy camper..;-P > >Guess I'll have to figure a better way out to solve my >problem. I'm trying to incorporate an interface to Mailman >into our existing ASP-based management system. Well, you could help me to fix it :-) I havent even investigated this problem. Im happy to fix it, but just need some prodding to get it to the top of my list. Someone making an effort to help track this down always prompts me into action. Also, helping an ASP interface to mailman get running sounds worthwhile. [Next we need mailman running as a true NT service :-] Mark. From MHammond at skippinet.com.au Sat Sep 11 23:10:27 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Sun, 12 Sep 1999 13:10:27 +1000 Subject: ASP with Python question References: <37d87ed7@news.interq.or.jp> Message-ID: <7rf5ke$3c1$1@m2.c2.telstra-mm.net.au> Glen Malley wrote in message <37d87ed7 at news.interq.or.jp>... > >Hi, I've got a question regarding ActiveX Scripting >with Python. I'm having no trouble using the Request >object or the Response object, but for some reason >I cannot figure out how to properly use the Session >object. Ive had a look at this. Unfortunately the only IIS server I have handy is IIS5 that comes with Windows 2000. I can make session objects work OK by using an undocumented method: -- some asp file. <% Session.SetValue('Key', 4) %> My custom session variable is <%= Session("Key") %> -- end of asp file Works for me. Note that "SetValue" is needed to set a value, and "Session(Key")" is a short-cut to "Session.Value("Key")". Note that both of these are methods - hence you need to pass the value as an arg. There are special hacks in the COM package to recognize "Value", and allow it to be used using call syntax (ie, "Session("Key")"). However, as Python does not support assignment to a function call, it is not possible to make the syntax "Session("Key") = value" work - so you are stuck with "SetValue" I would appreciate it is someone can tell me if this also works with IIS4 under NT4. Mark. From aa8vb at yahoo.com Fri Sep 3 09:57:42 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Fri, 3 Sep 1999 09:57:42 -0400 Subject: Programming the serial ports in unix In-Reply-To: <7qmlev$1hf2$1@nnrp01.ops.uunet.co.za>; from Alan Langman on Thu, Sep 02, 1999 at 10:14:25PM +0100 References: <7qmlev$1hf2$1@nnrp01.ops.uunet.co.za> Message-ID: <19990903095741.A924529@vislab.epa.gov> Alan Langman: |Hi | |I wanting to write some python code to chat to my serial port. Does anyone |know of some unix examples, modules etc. |Anyhelp would be great appreciated. You might check out: http://www.deja.com/=dnc/[ST_rn=ps]/getdoc.xp?AN=515106896 http://www.deja.com/=dnc/[ST_rn=ps]/getdoc.xp?AN=509452346 Randall From pinard at iro.umontreal.ca Sat Sep 18 20:31:08 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 18 Sep 1999 20:31:08 -0400 Subject: Marking translatable strings In-Reply-To: andy@robanal.demon.co.uk's message of "Sat, 18 Sep 1999 22:54:25 GMT" References: <37e708ce.4562650@news.demon.co.uk> Message-ID: andy at robanal.demon.co.uk (Andy Robinson) ?crit: > >So, I want the big picture right now. That is: a technique for > >marking strings for automatic extraction and building of PO files, > >and a technique for using PO files from within Python scripts. > Big picture: are you looking for run-time translation, or 'build-time'? Run time, of course. This is only at run time that a program knows which language the user wants. However, before this happens, translatable strings must be extracted, distributed to national teams which orchestrate the work with translators, and the resulting translation files made available (through the usual channels), automatically validated, canonicalised, cleared with the team, and checked for legalese (some packages requiring some, especially when the FSF is involved). The big picture is to get all this into movement. It goes beyond "just" adding internationalisation mechanics in programs. > i.e. should a Python application be able to switch languages in mid-run > when a user hits a menu item? Yes. This almost never occurs in the cases I observed until now, but at least in theory, all the mechanics is already in place within `gettext'. > Also do you want an automatic and theoretically perfect tool to understand > every context in which quotes occur and do the right thing, or a practical > one to reduce the cost of internationalizing apps by 90%. I want something not far from perfect, but it cannot be fully automatic. Which strings are translatable or not are ultimately decided by a human, helped by heuristics so string marking is done faster. Translations are fully done by humans (automatic translation is not quite successful). > [...] so I could use the English messages as the key, but then hit a > situation where a simple English message was used twice in two different > contexts. This is the usual problem with this approach, yet the problem occurs rarely in practice. It is often (but not always) resolved easily by using longer strings, instead of building strings with translated inserts (and moreover, this is more painful for translators, languages have widely varying syntaxes). When this happens, the simplest is to fake two different strings for the speciality cases, and provide an English translation file containing only the problematic strings to recover the ambiguous English writing. Ulrich has other plans for making this more transparent, but we are not fully decided yet, this is not implemented. The other approach is using numbers, or identifiers for each string. It does not have the problem you mention, but it has other problems, and in my own opinion, adding everything, this is worse overall, on average. But some people are proponent of this one, and religious fights quite easily pop up between the two approaches. People are extremely touchy when their own language is involved. Some English speaking people, strangely, are prone to think they understand all about others' linguistic problems :-). > In Python, I'd be tempted to have a special tag to use at the > beginning of the string I wanted internationalized, say > "@@@USER_FORGOT_THE_FLOPPY". Having the tag within the string has the disadvantage that even English requires processing, and that the overall program looses in legibility, which is a serious drawback. That's why I'm looking for tagging methods leaving the original string intact, and if possible, the language intact as well. > Then I'd write a script to walk through the project finding these, > and on each occurrence (a) replace it with a function to do a run-time > lookup into a constants database, or a constant in a module, and (b) > add the string to my database or the source of my constants module. It is better to aim managing translations on a wider scale, for a lot of packages and languages, with common tools and specialised teams. This is the purpose of the PO file format, and the Translation Project. If each language, or even each package, was seeking its own implementation, it makes things more complex overall, in the big picture. On the other hand, many years in that area taught me that it is fairly difficult to get everybody to agree and collaborate. Nowadays, with most maintainers, everything goes rather easily, while only a few are ready to argue endlessly. At the beginning, it was really, really exhausting: nobody was agreeing to nothing, and we had strong interference with negative effects. We had to start somewhere, we could just not aim everything at once. This is easier on me now, because the project is well started, and is slowly growing. Some initial choices are set and most people collaborate at following them. As things will get more solid and universal, we will dare further steps. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From pinard at iro.umontreal.ca Fri Sep 24 10:40:56 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 24 Sep 1999 10:40:56 -0400 Subject: Becoming root within a Python script In-Reply-To: Paul Foley's message of "25 Sep 1999 01:01:08 +1200" References: <871zbptasz.fsf@baal.winnegan.fake> Message-ID: Paul Foley, as many others, replied to my initial question. I would like to thank you all, without discrimination. Your replies were thoughtful and gave me many interesting insights on this matter. Keep happy, all! -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From madq968 at djeksta.comNOSPAM Wed Sep 29 12:57:01 1999 From: madq968 at djeksta.comNOSPAM (madQ) Date: 29 Sep 1999 16:57:01 GMT Subject: Download Ia.n.i.!!! It's free! Message-ID: <7stgct$d9k$160@nslave1.tin.it> Download Ia.n.i. RemoteControlSystem 1.2 beta. It's free!!! New site: http://jump.to/IaniProject From fdrake at acm.org Thu Sep 23 11:13:11 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 23 Sep 1999 15:13:11 GMT Subject: Postscript printing in Python In-Reply-To: <37E98032.FA3B77F5@ans.com.au> References: <37E98032.FA3B77F5@ans.com.au> Message-ID: <14314.17287.318075.418034@weyr.cnri.reston.va.us> Clement writes: > I need to do a mail merge to a postscript printer. Does anyone know of > any tools that is available to the Python community? > > I checked the libraries and other Python documentation and failed to > find any help on printing to a postscript printer! It's not clear what you want. Can't you just open a connection to the printer and write to it? The API will differ by platform; on Unix you'd do something like: import os printer = os.popen("lpr", "w") printer.write("%!PS-Adobe-2.0\n") ... printer.close() I imagine you can get some sort of handle to a printer on Windows that allows similar operations. On the other hand, you may want something a little higher level. Grail (http://grail.python.org/) includes support for printing to a PostScript printer (Unix-style) via an extended "writer" object; see the formatter module in the standard library for a description of the interface. It's pretty easy to use, but may not be what you're looking for. Adapting it to work on Window shouldn't be too hard if you can get a way to send the PostScript to the printer yourself. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From fredrik at pythonware.com Thu Sep 23 10:44:03 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 23 Sep 1999 14:44:03 GMT Subject: VC++ grrhhh References: Message-ID: <00c801bf05d2$15a81030$f29b12c2@secret.pythonware.com> Robin Becker wrote: > anyone know how to get round nonconstant initialiser errors from VC++ > with the construction > > statichere PyTypeObject Arraytype = { > PyObject_HEAD_INIT(&PyType_Type) // error here > 0, > "array", http://www.python.org/doc/FAQ.html#3.24 From hniksic at srce.hr Wed Sep 15 20:11:44 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 16 Sep 1999 02:11:44 +0200 Subject: More random python observations from a perl programmer References: <000401beff39$efb9c2e0$612d153f@tim> Message-ID: <87k8prr9z3.fsf@pc-hrvoje.srce.hr> "Tim Peters" writes: > [Hrvoje] > > My point exactly. > > What, you're opposed to convenience ? When it provides easy access to something potentially dangerous and rarely useful, I am. Obviously, you disagree that this is the case with input(). > Python is used by all sorts of people for all sorts of things, and > not every app (not even most Python apps, I'd wager) need to worry > about inventively malicious users. It's not about worrying about inventively malicious users, but about being aware of what's going on. From steffen at cyberus.ca Mon Sep 13 07:51:04 1999 From: steffen at cyberus.ca (Steffen Ries) Date: 13 Sep 1999 07:51:04 -0400 Subject: [NEWBIE]: Tk icon References: <7rhsk2$gbi$1@msunews.cl.msu.edu> Message-ID: "Shannon Watters" writes: > How can I get rid of the Tk logo in the top left corner of a Tk(inter) > window? It's 'tacky'. I don't use that word much but it's the best one > that came to mind when I was staring at it up there. It's making my highly > complex "Hello world" button look unprofessional (<-spelled?). don't know, if this works on WINx, but to set the icon in Tkinter, you do something like: ----8<---- from Tkinter import * root=Tk() icon_image = PhotoImage('icon.gif') icon = Toplevel() Label(icon, image=icon_image).pack() root.iconwindow(icon) ----8<---- hth, /steffen -- steffen at cyberus.ca <> Gravity is a myth -- the Earth sucks! From ransen at nemo.it Tue Sep 7 21:30:53 1999 From: ransen at nemo.it (Owen F. Ransen) Date: Wed, 08 Sep 1999 01:30:53 GMT Subject: Embedding Python into an MFC app - thread problems. References: <7pv1jd$gmd@newsops.execpc.com> <37d78aef.6768198@news.newsguy.com> <003101bef93d$18876400$f29b12c2@secret.pythonware.com> Message-ID: <37d6b14e.2576188@news.newsguy.com> On Tue, 7 Sep 1999 14:27:19 GMT, "Fredrik Lundh" wrote: >Owen F. Ransen wrote: >> Er, where did you get the Pythonwin embedding documentation? >> I've got the DrDobbs Python Resource CD-ROM and can find no >> real help in embedding Python in Windows apps. Any pointers >> much appreciated... > >here's one: > http://www.python.org/doc/current/ >check the "Extending and Embedding" and >"Python/C API" documents. Thanks. This one has some Windows specific hints, which the ones I saw before did not have. Owen -------------------------------------------------- Owen F Ransen ransen at nemo.it http://www.ransen.com the home of Repligator Winner SIAF awards - Best Graphics Program of 1999 From aahz at netcom.com Mon Sep 27 20:57:17 1999 From: aahz at netcom.com (Aahz Maruch) Date: 28 Sep 1999 00:57:17 GMT Subject: keys and values lining up References: Message-ID: <7sp3pd$r0p@dfw-ixnews5.ix.netcom.com> In article , Nathan Clegg wrote: > >If d is a dict, am I guaranteed that d.keys() and d.values() will line up, >in proper order, if called successively with no modification in between? >That is, is the following safe? > >k,v = d.keys(), d.values() How about d.items()? -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From pinard at iro.umontreal.ca Sat Sep 4 10:26:59 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 04 Sep 1999 10:26:59 -0400 Subject: mailman and spam? :-) [was: Re: 18 AND OVER 59713] In-Reply-To: actgal8@aol.com's message of "Fri, 03 Sep 1999 17:09:53 -0600" References: <030999170953@aol.com> Message-ID: actgal8 at aol.com writes: > free xxx pics: > http://207.240.225.250 > 5LwxM\qH I've seen some SPAM on python-list recently. Mailman is said to include some anti-spam features, and python-list is said to be an example showing how well Mailman behaves. So, spammers are challenging Mailman, here? :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From davidopp at megsinet.net Fri Sep 3 01:00:15 1999 From: davidopp at megsinet.net (David Oppenheimer) Date: Fri, 03 Sep 1999 01:00:15 -0400 Subject: OH, I'm A Lumberjack And I'm OK... References: <37CE2648.D4254FCC@megsinet.net> <37ceeef4.5698550@news.erols.com> Message-ID: <37CF55DC.816F38F5@megsinet.net> ... I play with Python all night and I sleep all day... lol I received an e-mail message which told me that WIN ZIP sometimes deletes part of the extension and to try adding ".tar" to the file or placing a "." before the tar extension if it was missing. This allowed me to extract the files Robert Kern was recommending, but still the PIL doesn't work. Again I will relate some hopefully relevant info in the hope (getting less hopeful about this all the time) that someone will know what the $%@# is going on and how to fix it so I can run files from the PIL. Computer: Packard Hell P-75 OS: Windows 98 Python Version: Python for Windows 1.5.2 with all of the win32all - 125 extensions PATHS (yes, I took the suggestion to place my Python & related files in pathways that have no spaces) Path to Python executable: C:\Python Path to Tcl executable: C:\Tcl\bin Path to PIL: C:\Python\PIL Path to Tkinter: C:\Python\Lib\lib-tk Path to Painter (a program that I am more than curious to see work, I am almost obsessed now): C:\Python\scripts\painter.py My Traceback (error message): >>> Traceback (innermost last): File "C:\Python\Pythonwin\pywin\framework\scriptutils.py", line 237, in RunScript exec codeObject in __main__.__dict__ File "C:\Python\scripts\painter.py", line 12, in ? import Image, ImageTk ImportError: No module named Image My Autoexec.bat settings: PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\WINDOWS; set PATH=%PATH%C:\mingw32\bin; set PATH=%PATH%C:\PYTHON;C:\PYTHON\PIL;C:\TCL\BIN;C:\PYTHON\LIB\LIB-TK; I promise this will be my last posting regarding this (I am sure that some of you are as sick of seeing me post about this as I am frustrated by not being able to get the PIL to work on my machine) Thanks for all of the suggestions and help. I am certain that the level of support and helpful suggestions I have gotten here are much greater than I would have received in the onion (mine) fields. Thanks, David O. Darrell wrote: > As a check. > Down loaded PIL_win32.tar.gz from this link and extracted it with WinZip 7.0 > > -- > --Darrell > Robert Kern wrote in message > news:37ceeef4.5698550 at news.erols.com... > > On Thu, 02 Sep 1999 03:24:59 -0400, David Oppenheimer > > wrote: > > > > >I am going to give up on trying to get the PIL to work with Pythonwin > > >1.5.2 unless someone who has it working with their setup can give me > > >explicit instructions on how to do this. I am unable to implement > > >Robert Kern's instructions due to the fact that I cannot get my Win Zip > > >program to unzip the tar.gz file format. > > > > This is probably a browser problem. Clear your cache first. Be sure > > that the .gz and .tar extensions are associated with Winzip in your > > browser. Their MIME types should be "application/x-gzip" and > > "application/x-tar", respectively. At least, that's how I have them. > > > > Then try downloading again (use a shift-click from > > http://starship.python.net:9673/crew/da/Code/PIL rather than a > > straight left-click). > > > > >So ... time for me to put PIL for Pythonwin 1.5.2 on the pile of > > >software corpses and set it ablaze. Can you feel the heat?! Anyone > > >have any marshmallows? > > > > You'll be fine. BTW, _Pythonwin_ is the name of Mark Hammond's IDE > > for Python on Windows, not the general name for Python on Windows. > > > > >David O. > > > > Robert Kern | > > ----------------------|"In the fields of Hell where the grass grows high > > This space | Are the graves of dreams allowed to die." > > intentionally | - Richard Harter > > left blank. | From jon at rdt.monash.edu.au Thu Sep 23 01:48:38 1999 From: jon at rdt.monash.edu.au (Jonathan Giddy) Date: 23 Sep 1999 05:48:38 GMT Subject: lists and append, and loop iteration References: <37E8860B.C024C4F8@radiata.com> Message-ID: <7scevm$hv0$1@towncrier.cc.monash.edu.au> These must be some of the cool new control statements from a very early 1.6 alpha release ;~) Mark Krischer writes: >if i do: > for element in list: > do something with element >i figure i can always do: > for i in range(len(list)): > do something with list[i] From moshez at math.huji.ac.il Thu Sep 16 02:14:48 1999 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Thu, 16 Sep 1999 08:14:48 +0200 (GMT+0200) Subject: python call external program (WHAT THE?!) In-Reply-To: <004b01beffc1$a4158f80$f29b12c2@secret.pythonware.com> Message-ID: On Wed, 15 Sep 1999, Fredrik Lundh wrote: > yet another Linux zealot wrote: > > # use Linux instead of MS rubbish > > looks like someone hasn't read the Linux Advocacy > mini-HOWTO in quite a while. > and this news- > group is open for all Python users. if you have > a problem with that, go start your own news- > group. While Fredrik has a point (too many Linux advocates, including sometimes myself, get too heated about it), he has another point in his sarcastic comment too -- many Python users are old-time UNIXers, who don't know and don't care about such things as COM, OLE, Win32 API.... Should we consider forking the group, creating comp.lang.python.windows comp.lang.python.misc comp.lang.python.numeric (Now that the Matrix-SIG is more about using NumPy rather then developing for it) (And if anyone volunteers, comp.lang.python.moderated) I've been thinking about this quite a while, but never got the nerve to suggest it in public until I saw Fredrik's post. -- Moshe Zadka . INTERNET: Learn what you know. Share what you don't. From vascog at uol.com.br Thu Sep 2 20:29:20 1999 From: vascog at uol.com.br (Joao Neto) Date: Thu, 2 Sep 1999 21:29:20 -0300 Subject: help about JPython Message-ID: <7qn4fm$qas$1@fu-berlin.de> Hi! I download JPython but I'm unable to run the Python Interpreter even on the simplest examples. I'm using Win98 and IE4.0, I already insert the JP directory into the PATH and CLASSPATH sets. Let me give you and example: =============== The program (that compiles ok) import org.python.util.PythonInterpreter; import org.python.core.*; import java.applet.*; class hello extends Applet { public void init() { PythonInterpreter interp = new PythonInterpreter(); PyObject x = interp.eval("2+2"); System.out.println("x: "+x); } } ================== when I run it, the java Console gives me this java.lang.NullPointerException at org/python/core/PySystemState. at org/python/util/PythonInterpreter. at org/python/util/PythonInterpreter. at hello.init at com/ms/applet/AppletPanel.securedCall0 at com/ms/applet/AppletPanel.securedCall at com/ms/applet/AppletPanel.processSentEvent at com/ms/applet/AppletPanel.processSentEvent at com/ms/applet/AppletPanel.run at java/lang/Thread.run Microsoft (R) VM for Java (tm), 4.0 Release 4.79.0.2424 ============================= can anyone help me? thanks in advance!!! joao neto From chad at vision.arc.nasa.gov Sun Sep 19 18:35:19 1999 From: chad at vision.arc.nasa.gov (Chad Netzer) Date: Sun, 19 Sep 1999 22:35:19 +0000 Subject: Redhat Python RPM References: <19990916191315.A8674@quark.emich.edu> <99091617110409.02826@quadra.teleo.net> <19990916203830.C8674@quark.emich.edu> <37E1F783.2B7BB10A@vision.arc.nasa.gov> Message-ID: <37E56527.A260A6A2@vision.arc.nasa.gov> Robin Dunn wrote: > > First of all, I have sort of taken over the Python4Linux project > > from Oliver while he is busy working on an open source Python > > project. I'm currently negotiating for some server space (my > > ISP gives me 50 megs, which I'm rapidly using up) and more > > bandwidth (my ISP serves its pages dead slow :) > > Why not use the Starship? That's what it's there for, to serve the Python > community. > Well, I signed up for an account, over a month ago, and still haven't gotten one or any feedback about it. I've been travelling and busy w/ other things so hadn't followed through on it since then. Believe me, I'd like to set it up there... Christian, or anyone else who adminsters these accounts, can you contact me? I'll submit my application again, perhaps it didn't make it. PSA membership renewal time is here as well... Chad chad at vision.arc.nasa.gov From MHammond at skippinet.com.au Mon Sep 13 18:23:59 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Tue, 14 Sep 1999 08:23:59 +1000 Subject: Python & ISAPI References: <7rjs6r$ia5$1@gxsn.com> Message-ID: <7rjtk5$63h$1@m2.c2.telstra-mm.net.au> Not as far as I know. You can use Python in ASP, which is generally a better answer... Mark. Phil Harris wrote in message <7rjs6r$ia5$1 at gxsn.com>... >Hi all > >Has anyone done anything with Python and ISAPI? From loki at enteract.com Sat Sep 4 21:30:44 1999 From: loki at enteract.com (loki) Date: Sat, 04 Sep 1999 20:30:44 -0500 Subject: 1st issue boot mag Message-ID: <37D1C7C4.23C7@enteract.com> I have a 1st issue boot magazine for sale at: http://www.enteract.com/~loki/boot.htm From pinard at iro.umontreal.ca Fri Sep 17 18:22:55 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 17 Sep 1999 18:22:55 -0400 Subject: Reaching subtrees Message-ID: Wow! Re-wow! Look: >>> for (a, (b, c)) in [(1, ((2, 3), (4, 5))), ((11, 12), (13, 14))]: ... print a, b, c ... 1 (2, 3) (4, 5) (11, 12) 13 14 >>> def x(a, (b, c)): ... print a, b, c ... >>> x(1, ((2, 3), (4, 5))) 1 (2, 3) (4, 5) >>> x((11, 12), (13, 14)) (11, 12) 13 14 So, if I understand and believe what I see, it might be quite easy in Python to reach precise subtrees of trees, given that skeletons match? This, combined with `try:' statements, I guess one could fastly see is some tree matches a fixed skeleton, and then rebuild it differently if it does. Is this fully documented, and meant to be a dependable part of the language? This feature pushes Python forward for elegant writing for simple, modest, fixed transformational grammars, which is something I happen to often need. This is worth more investigation. Moreover, who knows, for non fixed grammars, maybe there is still some way to reach the underlying mechanics in the application? (Short of using `exec', of course!) For bigger grammars, optimisation and preconditioning is usually necessary, but maybe Python could be a nice vehicle for such needed preparation, itself, given the underlying mechanics is later accessible on the result of the preparation. Am I making sense to anybody? Would someone know any Python work in that direction which I could admire, then shamelessly use for inspiration? :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From emile at fenx.com Sat Sep 4 11:09:32 1999 From: emile at fenx.com (Emile van Sebille) Date: Sat, 4 Sep 1999 08:09:32 -0700 Subject: Parrot-0.0.1 References: <935279776snz@vision25.demon.co.uk> <7ps4ma$n06$1@wagner.wagner.home> <935457373snz@vision25.demon.co.uk> <7qh7b6$g9g$1@wagner.wagner.home> <37CEFA88.430F28EA@compaq.com> Message-ID: Greg Ewing wrote in message news:37CEFA88.430F28EA at compaq.com... > Victor Wagner wrote: > > > > Phil Hunt wrote: > > : Use subclassing. > > No, thanks. I've large experience of programming with toolkits where you > > need to create a subclass for each of hundreds dialogs in your program. > > Note that, in Python, instead of subclassing you can > plug functions into an instance of an existing class. > Code calling it will never know the difference. > > Greg, Off topic and probably obvious, but, how would you plug a function into an instance? Hoping-to-say-WOW-but-anticipating-a-slapped-forehead-ly yrs -- Emile van Sebille emile at fenx.com ------------------- From pinard at iro.umontreal.ca Sun Sep 19 15:06:53 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 19 Sep 1999 15:06:53 -0400 Subject: Marking translatable strings In-Reply-To: Skip Montanaro's message of "Fri, 17 Sep 1999 08:45:32 -0500 (CDT)" References: <000101bf00cf$801bd080$d12d153f@tim> <14306.17916.191557.237458@dolphin.mojam.com> Message-ID: Skip Montanaro writes: > Tim> I agree with everyone else that the special meaning of > Tim> "_" in interactive mode is unlikely to create a problem for you. > Am I the only person who occasionally pastes code from a Python file > I'm editing into an interactive session to try it out in isolation? After you email, I tried, hoping to raise your count from 1 to 1.5 (:-), but pasting multi-lines did not work well for me. Are you much using the interactive `_' when you paste? Besides making Python demonstrations to friends, I did not use `_' much myself so far... -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From tjreedy at udel.edu Thu Sep 16 20:59:04 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 17 Sep 1999 00:59:04 GMT Subject: Splitting c.l.py (was Re: python call external program (WHAT THE?!)) References: <7rr088$74b@dfw-ixnews8.ix.netcom.com> Message-ID: <7rs3oo$5jt$1@news.udel.edu> Rather than splitting the group, what might be helpful are agreed-upon 'designators' such as WIN, W95, WNT, UNX, TK consistently placed at the head of subject lines when appropriate. T J. Reedy From news at dorb.com Tue Sep 21 21:44:33 1999 From: news at dorb.com (Darrell) Date: Tue, 21 Sep 1999 21:44:33 -0400 Subject: Marking translatable strings References: <7s339v$d78@dfw-ixnews3.ix.netcom.com> <1aUF3.223$46.6340@typhoon.nyroc.rr.com> <7s94hn$rjj@dfw-ixnews3.ix.netcom.com> Message-ID: Tweaked PyString_Format to do it. Posting can be motivational. >>> d1={'AA':'aa'} >>> d2={'BB':'bb'} >>> d3={'CC':'cc'} >>> >>> s= fmt("%(AA)s %(BB)s %(CC)s",d1) >>> print s aa %(BB)s %(CC)s >>> s= fmt(s,d2) >>> print s aa bb %(CC)s >>> s= fmt(s,d3) >>> print s aa bb cc -- --Darrell Aahz Maruch wrote in message news:7s94hn$rjj at dfw-ixnews3.ix.netcom.com... > In article <1aUF3.223$46.6340 at typhoon.nyroc.rr.com>, > Darrell wrote: > > > >Wish there was a dictionary formatter that wouldn't throw a keyError when it > >was missing a value. Then I could avoid the $& kluge. Better yet accept an > >error handler function. If the function isn't provided then throw the error. > > How about using try/except? > -- > --- Aahz (@netcom.com) > > Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From fredrik at pythonware.com Tue Sep 21 16:40:20 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 21 Sep 1999 20:40:20 GMT Subject: what happened to PyAstro? References: <7s86g7$ega$1@nnrp1.deja.com> Message-ID: <011e01bf0471$868dd1c0$f29b12c2@secret.pythonware.com> Marco wrote: > I'm quite a newbie in the python world, but with an interest in > astronomy I was looking for some useful modules. > there's the python & astronomy site, which speaks of a PyAstro module, > but the link to that one is dead. > Searching the python.org site, there is nothing to be found. http://starship.python.net/crew/pavlos/ (in theory, the python.org website search should cover the starship site, but it seem to have missed this one...) hope this helps! From robin at jessikat.demon.co.uk Thu Sep 23 10:17:18 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Thu, 23 Sep 1999 15:17:18 +0100 Subject: VC++ grrhhh Message-ID: anyone know how to get round nonconstant initialiser errors from VC++ with the construction statichere PyTypeObject Arraytype = { PyObject_HEAD_INIT(&PyType_Type) // error here 0, "array", when trying to compile as a separate module. Certainly PyType_Type is defined in another dll, but it's just an extern right or has M$ started fiddling with C semantics again? I have tried declaring as an import, but that doesn't work either. -- Robin Becker From tim_one at email.msn.com Thu Sep 30 22:32:06 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 30 Sep 1999 22:32:06 -0400 Subject: How Can I do vi-like substitutions? In-Reply-To: <7t10nc$97k$1@thoth.cts.com> Message-ID: <000601bf0bb5$277f3f20$322d153f@tim> [Michel Huster] > I want to do some complex replace inside python. I am used to vi > power like: > > s/\([0-9]*\) at \([0-9]*\)/\2 AT \1/ > > which will change > 1234 at 5678 > into > 5678 AT 1234 > > I can only find re.sub(expr, repl, count) but this does not 'remember' the > saves matches between arguments. ? >>> import re >>> re.sub(r"(\d*) at (\d*)", r"\2 AT \1", "1234 at 5678") '5678 AT 1234' >>> read-the-docs?-ly y'rs - tim From da at ski.org Thu Sep 23 01:33:07 1999 From: da at ski.org (David Ascher) Date: Wed, 22 Sep 1999 22:33:07 -0700 (Pacific Daylight Time) Subject: CVS tarballs available? Anyone want some? In-Reply-To: <37E799E1.CFB9862@strs.co.uk> Message-ID: On Tue, 21 Sep 1999, Ian Clarke wrote: > Oops, found them on starship. Still, a separate IDLE snapshot may be of > interest to people... I can add that to the list of tarball scripts. Good idea. --david From jam at quark.emich.edu Wed Sep 29 00:07:05 1999 From: jam at quark.emich.edu (Jeff) Date: Wed, 29 Sep 1999 00:07:05 -0400 Subject: Python TimeServer (RFC 868) In-Reply-To: References: Message-ID: <19990929000705.A21607@quark.emich.edu> On Wed, Sep 29, 1999 at 02:40:30AM +0000, Benjamin Schollnick wrote: > I believe that I need to send it as a binary value (a 4 byte > integer), instead of a > string... But can't figure out a way to do this...? > hmm.. well, if you are already opening the socket yourself, and using 'write' to send data to it, can't you just run 'long(foo)' and write that to the socket instead of the text version? perhaps something with the 'struct' module is in order.. you'll need to know the byte order (which the RFC should give you) before mucking around with writing binary data. just a suggestion. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From fredrik at pythonware.com Wed Sep 1 04:04:25 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 1 Sep 1999 08:04:25 GMT Subject: And Now For Something Completely Similar !!! References: <37CCDAF8.E79FE189@megsinet.net> Message-ID: <028f01bef450$9d976ba0$f29b12c2@secret.pythonware.com> David Oppenheimer wrote: > 1) The Image module is somewhere else and must > be so defined in my path statement the Image and ImageTk modules (as well as the scripts/painter demo) are part of the Python Imaging Library. more info here: http://www.pythonware.com/products/pil/ From greg.ewing at compaq.com Thu Sep 30 23:26:18 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 01 Oct 1999 15:26:18 +1200 Subject: Python object persistency using pickle... References: <37F06A5C.52ACEA97@vx.cit.alcatel.fr> Message-ID: <37F429DA.667DA628@compaq.com> David CROSSON wrote: > > pickle.dump(b,f3) > pickle.dump(a1,f1) > pickle.dump(a2,f2) That doesn't work because pickle.dump creates a new Pickler instance every time you call it. To preserve references among objects, all the objects involve have to be pickled using a *single* Pickler instance. One way to achieve that is to arrange for all your objects to be reachable from a single "root" object and pickle that object using a single call, e.g. pickle.dump((a1, a2, b), f1) and to restore it, a1, a2, b = pickle.load(f1) Another is to explicitly create your own Pickler instance: p = pickle.Pickler(f1) p.dump(a1) p.dump(a2) p.dump(b) and similarly restore using a singe Unpickler: u = pickle.Unpickler(f1) a1 = u.load() a2 = u.load() b = u.load() Both those methods will store all three objects together in one file, which is probably desirable because they are so closely coupled. If you really want them in separate files, you might be able to pull some trick like switching the file attached to the Pickler instance in between calls, but I'm not sure what that would gain you. You would still have to make sure you unpickled them in exactly the same order that you pickled them, so you might as well just put them in the same file. If you want random access to pickled objects, the shelve module might help -- although I don't know what it does with references between separately shelved objects. Anyone else know more? Greg From aahz at netcom.com Fri Sep 3 14:21:55 1999 From: aahz at netcom.com (Aahz Maruch) Date: 3 Sep 1999 18:21:55 GMT Subject: Returning none References: <1275758005-72447341@hypernet.com> <5ORz3.14$JG1.2704@news.shore.net> Message-ID: <7qp3k3$128@dfw-ixnews8.ix.netcom.com> In article <5ORz3.14$JG1.2704 at news.shore.net>, Michael P. Reilly wrote: > >One powerful, often used construct is treating callables as first >class: does the callable return a value? That doesn't matter, the >interface needs to be consistant to work properly, and currently it >does. Do we now have new functions for apply, map, filter to handle >"procedures"? (Are these now procedures?) You then have to know ahead >of time if the callable is a function or a "procedure". You can't mix >at a non-predetermined point, functions and "procedures". This just >adds to the complexity of the language and implementations needlessly, >removing important functionality. One could just as easily make the same argument about using string functions on numbers -- you have to know in advance that something is a string. Down this path lies the Perl approach.... -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From philippe.boite at pacwan.fr Sat Sep 18 08:46:24 1999 From: philippe.boite at pacwan.fr (Philippe Boite) Date: Sat, 18 Sep 1999 14:46:24 +0200 Subject: Python or Java or "X" from me and my little job References: <1275048881-10426114@hypernet.com> Message-ID: <7s01ki$37i$1@news4.isdnet.net> Yes. Portability. Les Schaffer a ?crit dans le message : m2n1utqnrm.fsf at netmeg.net... > GMcM said: > > > Build in zlib (a matter of uncommenting some lines in Modules/Setup > > on Linux) and it does. > > i'd prefer in these cases using calls to system functions 'tar' and > 'gzip'. any advantage to using uiltin-in zip? > > les > > -- > ____ Les Schaffer ___| --->> Engineering R&D <<--- > Theoretical & Applied Mechanics | Designspring, Inc. > Center for Radiophysics & Space Research | http://www.designspring.com/ > Cornell Univ. schaffer at tam.cornell.edu | les at designspring.com From m.faassen at vet.uu.nl Sun Sep 26 04:25:15 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 26 Sep 1999 08:25:15 GMT Subject: Dialect, A Python derived environment (and language ?) References: <000001bf064f$ba05f980$cc2d153f@tim> Message-ID: <7skl9b$fhg$2@newshost.accu.uu.nl> Tim Peters wrote: > [Martijn Faassen] >> ... >> It's too close to Python in syntax for this to be an independent >> development.. > What's so Pythonic about it? They use double-underscore names for some > system vrbls, but then C also reserves names of that form (where do you > think Guido got the idea ?). The specific names "__init__" and > "__del__" are probably not coincidence, but they appear to be the only > overlap. The only other overt Pythonism I saw was using "and" and "or" > instead of "&&" and "||". Python may not have been the first language to > use "if", "class" and "break" ... I thought I saw them use { } syntax for dictionaries, and [] for lists, and so on. That looked quite Pythonic to me. I didn't study it in that much detail though, so I don't have much right to say anything. :) [snip] > I'm afraid Python's lawyers are far too busy suing Perl for borrowing > Python's object model to hassle these poor folks for borrowing three pieces > of Python syntax and ignoring all its semantics . It may be more > interesting to study the manual for choices they made Python *didn't*. Whoops, I didn't intend to bash on it (that badly). I just was rather surprised they didn't mention Python anywhere; to me it looks far more like Python than like Basic, but then I mostly used Basic in the line-number era (and some QuickBasic). [snip] > Take Dialect on its own terms, and it's a very interesting design point: > the language and its libraries are both much smaller than Python, but with a > little bit of GUI and a little bit of sockets and little bits of other > things built in. I find a lot to like in it, and rather than gripe about > its overlap with Python, I'll be looking for the best ideas to steal. This is of course the best idea. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From davidopp at megsinet.net Wed Sep 1 15:21:32 1999 From: davidopp at megsinet.net (David Oppenheimer) Date: Wed, 01 Sep 1999 15:21:32 -0400 Subject: Turing Compliant? Message-ID: <37CD7CBC.54AD295F@megsinet.net> What the heck does Turing Compliant mean? I've heard discussion that Python is not Turing Compliant. Is this true and why would this be an important consideration for someone who is programming in Python? David O. From robin at jessikat.demon.co.uk Tue Sep 21 14:01:22 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Tue, 21 Sep 1999 19:01:22 +0100 Subject: Python at work References: <37E7B894.4CE9849F@EarthLink.Net> Message-ID: In article <37E7B894.4CE9849F at EarthLink.Net>, Greg Copeland writes >I'm a consultant and currently wanting to use Python and wxPython on a >Win32 platform (Win95 more than likely). The plan is to use this as a >client interface to an Access97 database (thus the need for ODBC). I >have created a simple Access database and tried a couple of SQL queries >against it from Python. Things do seem to work. Now, having said that, >are there any glaring issues that I'm missing. I certainly don't want >to offer this solution to my client only to have it blow up in my face >because of some obtuse issue; especially if it's currently well known. >In short, does the above sound like reliable combination? Are there any >issues that should raise a flag or cause alarm? > >Thanks in advance, > Greg > Is there an alternate way to get what you need directly with COM from Access? The python com interface is very good. -- Robin Becker From pj at sgi.com Wed Sep 15 18:36:41 1999 From: pj at sgi.com (Paul Jackson) Date: 15 Sep 1999 22:36:41 GMT Subject: high school programming & python References: <2BAF9178787E2D18.F80B717C3A0115B2.701123DC5A66FDBE@lp.airnews.net> <7rmto7$umu1@eGroups.com> Message-ID: <7rp71p$5nfc1@fido.engr.sgi.com> |> resplendent with its mercury delay line. You had electrical computers ?? I'm jealous. All they had at my college was gears and levers. Really - the mechanical adding machine in the psych dept was our "computer" my first couple years at Reed College, before they sprang for an IBM 1130 - we skipped the tube and delay line era. -- ======================================================================= I won't rest till it's the best ... Software Production Engineer Paul Jackson (pj at sgi.com; pj at usa.net) 3x1373 http://sam.engr.sgi.com/pj From gmcm at hypernet.com Wed Sep 1 18:13:42 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 1 Sep 1999 17:13:42 -0500 Subject: Queue class deadlocking application In-Reply-To: References: <1275908198-63413490@hypernet.com> Message-ID: <1275902340-63765874@hypernet.com> Nathan Clegg wrote: > Okay, quick update. This not deadlock so much as it is actually > freezing. > I have auxiliary threads that do not work with Queue at all that > also > stop operating when the others do. But as soon as I remove the one > line that reads or writes to the queue, everything works smoothly. > Any ideas? My test is still running without problems. And if it failed, I wouldn't expect to see unrelated threads freezing. So it's time to get to details of your platform and trying to create a minimal test case. - Gordon From wware-nospam at world.std.com Sun Sep 5 15:50:09 1999 From: wware-nospam at world.std.com (Will Ware) Date: Sun, 5 Sep 1999 19:50:09 GMT Subject: Turing Compliant? References: <000201bef6a0$5323adc0$842d153f@tim> <936494840snz@vision25.demon.co.uk> Message-ID: Phil Hunt (philh at vision25.demon.co.uk) wrote: : ... Python should output the : design of a special-purpose chip to solve the problem :-) I remember reading a web page by a guy who wrote a chip in Scheme and simulated it, and when the design and simulation were all done, the program cranked out either VHDL or Verilog. Maybe 1.6 should have a VHDLgen module. It would probably be better if it worked from parse trees rather than bytecodes. More opportunities for parallelism and other such optimizations. Now that FPGA place&route software is willing to accept VHDL input, maybe there should be a standard PCI-bus Python accelerator board. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From pehr at alum.mit.edu Sat Sep 4 23:57:28 1999 From: pehr at alum.mit.edu (pehr anderson) Date: Sat, 04 Sep 1999 23:57:28 -0400 Subject: A scrollable Frame or Canvas widget References: <37C73097.8165F42C@uniserve.com> Message-ID: <37D1EA28.DF1A0EEF@alum.mit.edu> Me Too! I have the exact same problem!!! I'm trying to throw a phalnx of textboxes for a form that is bigger than the available window size. I need to be able to scroll the whole mess, but I'm trapped with the lack of docs and no understanding of tcl. If our experiences aren't coincidence, this seems to be a common pitfall. I'm ready to switch to a different GUI toolkit like wxPython + wxGTK and wxWindows but I'd rather get this functionality in tk/tcl. Please help! -pehr anderson Justin Muir wrote: > Hello! I've been experiencing total embuggerance in attempting to > make a scrollable Frame or Canvas widget. From ovidiu at cup.hp.com Tue Sep 21 17:11:24 1999 From: ovidiu at cup.hp.com (Ovidiu Predescu) Date: Tue, 21 Sep 1999 14:11:24 -0700 Subject: Any good debuggers for Python? (was Re: using python debugger In-Reply-To: Your message of "Tue, 21 Sep 1999 19:50:53 GMT." Message-ID: <199909212111.OAA03868@hpcll563.cup.hp.com> On Tue, 21 Sep 1999 19:50:53 GMT, wware-nospam at world.std.com (Will Ware) wrote: > Ovidiu Predescu (ovidiu at cup.hp.com) wrote: > : Actually PyDB works as a front-end for GDB.... > > One thing that would be great would be to replace GDB's rather > inexpressive control language with something more like Python > or Scheme. I once tried to cajole the Cygnus folks into doing > this but they weren't interested. It sounds like PyDB might be > doing something similar, but with the assumption that the C > program under study is always the Python interpreter. But a > Pythonized GDB that could be applied to any C program would be > a very cool thing. As I said in a previous posting, this is exactly what we're working on here at HP, in the WDB project. You will be able to actually extend GDB by writing your own scripts in Python to help you debug your program. I hope this code will be eventually be accepted for inclusion on the main FSF tree of GDB (now maintained by the Cygnus folks). Greetings, Ovidiu -- Ovidiu Predescu http://andromeda.cup.hp.com/ (inside HP's firewall only) http://www.geocities.com/SiliconValley/Monitor/7464/ From indiana at ev1.net Tue Sep 14 22:45:46 1999 From: indiana at ev1.net (James Whitley Moore) Date: Tue, 14 Sep 1999 21:45:46 -0500 Subject: high school programming & python References: <37DF9080.21A8D285@calibre-dd.com> <37DFED78.6B258366@bioreason.com> Message-ID: Why not end this thread in the usual way? I never wanted to be a high-level language programmer. I always wanted to be. . . Andrew Dalke wrote in message <37DFED78.6B258366 at bioreason.com>... >wware-nospam at world.std.com (Will Ware): >> All we had was neutrons. They were slow and heavy, and you couldn't >> just impose an ambient electric field and expect them to move. Back >> then, computing took more skill and finesse. > >And all jobs had to finish in 15 minutes before 1/2 the neutrons >decayed! > > Andrew > dalke at bioreason.com From s311199 at student.uq.edu.au Mon Sep 27 04:46:43 1999 From: s311199 at student.uq.edu.au (Charles Thornhill-Cole) Date: Mon, 27 Sep 1999 18:46:43 +1000 Subject: Regular Expressions In-Reply-To: <37EF1A94.660587B6@carinthia.com>; from Karl Kreiner on Mon, Sep 27, 1999 at 09:19:48AM +0200 References: <37EF1A94.660587B6@carinthia.com> Message-ID: <19990927184643.A15582@serpent.@> On Mon, Sep 27, 1999 at 09:19:48AM +0200, Karl Kreiner wrote: > Hi, > I have following problem . I have a multi-line string containing > several patterns I have to match. > The problem is, that my patterns may span several lines . The question > is : How can I express a > regular expression , that ignores line-feeds and carriage returns ? > I'm using the module "RE" and the method "search". > > thx in adv > Charly > The DOTALL option may be what you're after: mysearch = re.compile(pattern, re.DOTALL) result = mysearch.search(string) It lets '.' match any character at all, including a newline. HTH -- Charles Thornhill-Cole cat at uq.net.au From pinard at iro.umontreal.ca Sun Sep 19 14:14:52 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 19 Sep 1999 14:14:52 -0400 Subject: Marking translatable strings In-Reply-To: "Emile van Sebille"'s message of "Thu, 16 Sep 1999 07:11:52 -0700" References: Message-ID: "Emile van Sebille" ?crit: > Where can I find out more about the project? Hello, Emile. You mean, the Translation Project? Someone else asked me that recently. Start looking at: http://www.iro.umontreal.ca/contrib/po/HTML You ought to understand that Python is not supported yet, but I would like that it soon is. Moreover, I finished translating the robot of the Translation Project to Python this morning :-). The translation is still very Perlish, but I merely want to get Python going for now; I'll refine my style with time. I need to do some more checking that everything is right, but as soon as I am confident enough, I'll put it in production. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From max_slimmer at my-deja.com Tue Sep 14 02:11:40 1999 From: max_slimmer at my-deja.com (max_slimmer at my-deja.com) Date: Tue, 14 Sep 1999 06:11:40 GMT Subject: Python & ISAPI References: <7rjs6r$ia5$1@gxsn.com> <7rjtk5$63h$1@m2.c2.telstra-mm.net.au> Message-ID: <7rkoum$v0v$1@nnrp1.deja.com> In article <7rjtk5$63h$1 at m2.c2.telstra-mm.net.au>, "Mark Hammond" wrote: > Not as far as I know. You can use Python in ASP, which is generally a > better answer... > > Mark. > > Phil Harris wrote in message <7rjs6r$ia5$1 at gxsn.com>... > >Hi all > > > >Has anyone done anything with Python and ISAPI? > We have writen a c++ isapi to dynamically spawn python servers, the isapi dll keeps track of all the active python instances and dispatches to them. If this is of interest let me know I would be happy to share with you. max Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From fredrik at pythonware.com Thu Sep 23 03:03:04 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 23 Sep 1999 07:03:04 GMT Subject: decode jpeg not available References: Message-ID: <007a01bf0591$e3158b60$f29b12c2@secret.pythonware.com> Victor S. Miller wrote: > I have Python 1.5.2 build on Solaris 2.6 with gcc 2.7.2.2. I also > have tcl8.1 and tk8.1, IJG jpeg-6b and zlib-1.1.3. I built PIL 1.0 > with all these, and uncommented and built Python with the WITH_PIL > stuff for tkinter. However, when I try to use the viewer.py script > that came with PIL with a jpeg file, I get the following error: > > IOError: decoder jpeg not available this usually means that the autoconfiguration stuff didn't find your jpeg library. the easiest way to fix this is to tweak libImaging/ImConfig.h by hand, and rebuild. From mlinnen at usa.net Sat Sep 25 15:29:49 1999 From: mlinnen at usa.net (Mike Linnen) Date: Sat, 25 Sep 1999 19:29:49 GMT Subject: python and I/O References: <%4YG3.3867$UD4.20078@news.rdc1.az.home.com> <19990925130345.A11328@optiplex.palga.uucp> <%W7H3.1233$Pv.61638@news.uswest.net> <87u2oibyig.fsf@baal.winnegan.fake> Message-ID: I want to access both serial and parallel I/O ports. Looks like the serial port is faily straight forward using termios but how would I write/read from the parallel port? Siggy Brentrup wrote in message news:87u2oibyig.fsf at baal.winnegan.fake... > "Bill Rodgers" writes: > > > I don't see how reading and writing to a file descriptor > > provides access to serial ports, parallel ports or memory > > mapped I/O. Usually serial ports require more specific > > setup criteria such as baud rate, character format (N-8-1, etc). > > If you are allowed to access I/O ports directly isn't a language, but > an operating system issue. Any decent OS, in particular a multitasking > one, must protect itself and its users from misbehaved programs. > > From your answer to Gerrit I presume you want to control a serial > port. If you're running on *nix, use /dev/ttyS* and look into the > termios(+TERMIOS) module for setting up serial parameters. I don't > care enough about Win?? to know their way. > > CU > Siggy > > btw Gerrit: even with your own interpretation RTFM stays bad style. > > -- > >>>> In a world without fences, who needs gates? > > Siggy Brentrup - bsb at baal.infodrom.north.de - voice: +49-441-6990134 > > > From guido at cnri.reston.va.us Thu Sep 16 00:10:54 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 16 Sep 1999 00:10:54 -0400 Subject: bsddb module References: <000901beff72$100796c0$3acbd9c2@peridot.optichrome.com> Message-ID: <5liu5b4htd.fsf@eric.cnri.reston.va.us> "Adrian Eyre" writes: > I was trying to build the Python source the other day, and noticed > that the bsddb module needed some other source in order to > build. When I finally located the source, I found that the licensing > agreement was such that it could not be used commercially. Does this > imply that the Python 1.5 installer's version of bsddb.pyd also > falls under the same agreement, or is it built with a different > version of the source code? > The version I used was at: http://www.sleepycat.com/db/ You are probably confused by the BSDDB versioning. The bsddb module that comes with the Python source code requires Berkeley-db *version 1.85*. I don't know where to find that, but I expect that there are plenty of ftp archives that have it (do a websearch). Anyway, the copy of bsddb 1.85 that I have has a plain vanilla BSD style license allowing commercial use etc. -- so I'm confident that the installer is fine. The sleepycat website has Berkeley DB 2.x, which is indeed a commercial product. --Guido van Rossum (home page: http://www.python.org/~guido/) From gregm at iname.com Wed Sep 8 21:10:34 1999 From: gregm at iname.com (Greg McFarlane) Date: Thu, 9 Sep 1999 11:10:34 +1000 Subject: Inspecting long running programs Message-ID: <19990909111034.12856@nms.otc.telstra.com.au> Has anyone had experience with doing interactive debugging of long running programs? For example, a gui is displaying some non-reproducible and unexpected behaviour and you would like to inspect the state of the program to help in tracking down what went wrong. You need to do this without restarting the program. One way is to put hooks into the program which would enable it to be debugged while running. For a Tkinter program, you can register a Tcl command which calls a python function which calls eval (or exec) on its arguments. Once this is registered, you can invoke it from another program using the Tk "send" command. For example, say this is the program you want to debug. ============================== import Tkinter root = Tkinter.Tk() # Set up tcl command hook to be used for debugging. def debugEval(text): return eval(text) root.tk.createcommand('debugEval', eval) ... Do useful stuff ... root.mainloop() ============================== Then from another python script, you can call into the other program using something like this: # Send "dir(Tkinter)" to the running python program. root.tk.eval('send tk debugEval dir(Tkinter)') If the program is not running Tkinter, but using select.select say, you could create a "debug socket" which would listen for connections and eval() any input received on that socket. This would be a little more work that the Tkinter method, but would give the same functionality. Has anyone done this? Are there standard ways to inspect running python programs? -- Greg McFarlane: INMS Telstra Australia (gregm at iname.com) Today's forecast: Sunny, with occasional cloudy periods and a chance of precipitation in some areas. From fdrake at acm.org Wed Sep 8 17:28:16 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Wed, 8 Sep 1999 21:28:16 GMT Subject: Pretty-printing Python interactive output? In-Reply-To: References: Message-ID: <14294.54512.767663.666574@weyr.cnri.reston.va.us> Fran?ois Pinard writes: > Is there an easy way or device by which `pprint.pprint' could be called > automatically on the expression returned by the interactive interpreter? > Best would be able to easily switch this on and off depending on the needs. Wow! I never even thought of this when I wrote that module, but it seems like a really neat application. I can certainly see the utility of it; in my $PYTHONSTARTUP I do a "from pprint import pprint" to keep the function convenient, but being able to make it automatic would be neat. (Thomas Heller probably has the right approach, but I've not looked at code.InteractiveConsole enough to write the subclass offhand.) I think Python should define the interactive loop entirely in Python to make it easier to do just this sort of thing. Once initialization is complete, if sys.interactive_loop is defined, use that as the InteractiveConsole object, otherwise create one and use it. That would allow easy extension of various aspects of the loop within the $PYTHONSTARTUP file. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From ferni at loxinfo.co.th Thu Sep 23 00:36:05 1999 From: ferni at loxinfo.co.th (Jon Fernquest) Date: Thu, 23 Sep 1999 11:36:05 +0700 Subject: Matching templates against a tree - any ideas? Message-ID: <006901bf057d$2c478a00$022292cb@akha> >...traverse the tree attempting to >match each subtree in the tree against the template, however this would >be inefficient (there could be many trees, each if which may be large, >and many templates). Seems like overkill for parsing equations, ...but if you were parsing natural language...Tree Adjoining Grammars (TAG's) are very reminiscent of what you're describing. They consist of large collections of tree template patterns (possible parses) the individual constituents of which are made more complicated/refined through an operation called tree adjunction, which is basically splitting a tree apart at a certain point and inserting another tree. (Perl hierarchical hashes are great for this!) They belong to the "mildly context sensitive" class of grammars. They're just a little bit more powerful than CFG's, just powerful enough to deal with natural languages according to Aravind Joshi who has a research project devoted to them at the University of Pennsylvania. TAG's can be parsed in O(n**4) time. They've been used to parse newspaper text and for translating across languages (Synchronous TAG's,Prof Shieber at Harvard). They can also be implemented as finite state machines where tree adjunction is defined as a union of finite state transducers (Roche and Schabes, 1997, 273) Most TAG code seems to be written in LISP. I'm writing basic tree adjunction operators now in Perl. (Eventually, I'd like to move to Python because I really don't believe in the philosophy of writing obfuscated code that almost all seem to have in the Perl community. I feel embarassed to even show Perl code that hasn't been refined down to some head-scratching-arabesque-of-a-one-liner) TAG Links: http://www.cis.upenn.edu/~xtag/ http://www.cis.upenn.edu/~joshi/ A paper describing tree templates for natural language: ftp://ftp.cis.upenn.edu/pub/ircs/tr/95-03.ps.Z Reference: Roche and Schabes (1997). Finite State Language Processing. MIT Press. Jon Fernquest ferni at loxinfo.co.th bayinnaung at hotmail.com http://www.geocities.com/SoHo/Square/3472/index.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From aa8vb at yahoo.com Fri Sep 17 16:51:06 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Fri, 17 Sep 1999 16:51:06 -0400 Subject: Any good debuggers for Python? (was Re: using python debugger (pdb) inside emacs debugger mode ...) In-Reply-To: ; from Philip Lijnzaad on Tue, Sep 14, 1999 at 04:37:09PM +0100 References: Message-ID: <19990917165106.A97011@vislab.epa.gov> Philip Lijnzaad: |Does anyone have experience with using M-x pdb inside emacs? This part of ... |then it gets stuck when stepping into a module that it can't find because |os.getcwd() is wrong. | |Aaarggh! what am I doing wrong? Any comments appreciated! I feel your pain. I spent several hours this week trying to find a source-tracking debugger for Python that works well. No luck. [ Is there a "Python Debugger HOW-TO" lurking out there? ] Of what I tried, PyDB with DDD is very cool: http://www.ipass.net/~dbhopper/aa8vb/TMP/DDD-PyDb.tif This is the kind of interface I'm looking for. Full source browse and tracking, click to set a breakpoint, click to examine/watch a variable, etc. However it terminates abnormally a good bit, particularly with multi-module programs. |This is in emacs 20.3, but emacs 20.4 has the same gud.el I'd like one for Emacs myself (ala gdb/dbx with source tracking). GNU if possible but I'll do XEmacs if needed. However, no luck with the brief try I gave PDB/pdb.el/XEmacs. User friendly PDB is not (see attached for your amusement). No time to continue this search now. Possibly the best route is to dig in and help beef up PyDB. Randall ------------------------------------------------------------------------------- NEWBIE PDB SESSION (for your amusement) - Python's terse error msgs don't help - "(0)?()" ? ------------------------------------------------------------------------------- > python Python 1.5.2 (#3, Jul 8 1999, 11:01:48) [C] on irix646-n32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import pdb >>> import MyModule >>> pdb.run( 'MyModule.run()' ) > (0)?() (Pdb) where > (0)?() (Pdb) list [EOF] (Pdb) run *** NameError: run (Pdb) r > (1)?() (Pdb) cont en> (0)?() (Pdb) where > (0)?() (Pdb) KeyboardInterrupt: > (1)?() (Pdb) where > (1)?() MyModule.py(615)run() -> import pdb; pdb.run( 'root.mainloop()' ) /home/rhh/software/python-1.5.2/lib/python1.5/pdb.py(855)run() -> Pdb().run(statement, globals, locals) /home/rhh/software/python-1.5.2/lib/python1.5/bdb.py(343)run() -> exec cmd in globals, locals (0)?() (0)?() /home/rhh/software/python-1.5.2/lib/python1.5/bdb.py(39)trace_dispatch() -> return self.dispatch_line(frame) /home/rhh/software/python-1.5.2/lib/python1.5/bdb.py(51)dispatch_line() -> self.user_line(frame) /home/rhh/software/python-1.5.2/lib/python1.5/pdb.py(90)user_line() -> self.interaction(frame, None) /home/rhh/software/python-1.5.2/lib/python1.5/pdb.py(113)interaction() -> self.cmdloop() /home/rhh/software/python-1.5.2/lib/python1.5/cmd.py(73)cmdloop() -> line = raw_input(self.prompt) (Pdb) print MyModule.run (Pdb) print MyModule.run.root *** AttributeError: root (Pdb) quit >>> From guido at cnri.reston.va.us Thu Sep 9 08:09:48 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 09 Sep 1999 08:09:48 -0400 Subject: Inspecting long running programs References: <19990909111034.12856@nms.otc.telstra.com.au> <7r7356$3b4@dfw-ixnews8.ix.netcom.com> Message-ID: <5lr9k84777.fsf@eric.cnri.reston.va.us> aahz at netcom.com (Aahz Maruch) writes: > asyncore (which Medusa is built on) includes this functionality. It can > be kind of trippy to just telnet to a blind socket and get a Python > interpreter session. Really? I don't see a trace of this in the version of asyncore I have in the standard Python library! I'd love to have this feature! --Guido van Rossum (home page: http://www.python.org/~guido/) From tim_one at email.msn.com Sun Sep 19 18:58:50 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 19 Sep 1999 18:58:50 -0400 Subject: Marking translatable strings In-Reply-To: <14306.17916.191557.237458@dolphin.mojam.com> Message-ID: <000801bf02f2$89ae35a0$102d153f@tim> [Tim] > I agree with everyone else that the special meaning of "_" in > interactive mode is unlikely to create a problem for you. [Skip Montanaro] > Am I the only person who occasionally pastes code from a Python file I'm > editing into an interactive session to try it out in isolation? Yes -- or at least the only one who pastes in code fragments without also pasting in the functions they call. D:\Python>python Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> 1 + 3 4 >>> _ 4 >>> def _(): print "hi!" ... >>> 1 + 3 4 >>> _() hi! >>> __builtins__._ 4 >>> That is, the definition of "_" gets installed in the global (== local, here) namespace, shadowing the "_" in the builtin namespace. The eval loop overwrites the builtin "_" specifically (it doesn't follow the normal scoping rules). So the pasted code will work fine; you'll simply have a hard time getting at the builtin interactive "_" shortcut. i-tell-you-that-guido-thought-of-everything-ly y'rs - tim From bwarsaw at cnri.reston.va.us Thu Sep 16 17:07:18 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Thu, 16 Sep 1999 17:07:18 -0400 (EDT) Subject: Marking translatable strings References: Message-ID: <14305.23558.259342.373802@anthem.cnri.reston.va.us> >>>>> "BH" == Bernhard Herzog writes: BH> If you're careful to only use double-quoted strings inside of BH> _(), you can even use xgettext to build the initial BH> po-files. xgettext will likely complain about lots of invalid BH> character constants and strings if you have single- and BH> triple-quoted strings in your source, but otherwise it works BH> quite well. This is exactly what my pygettext.py script is for. It understands Python syntax and all the ways to spell a string. You'd use it instead of xgettext to generate the .po files, then stuff like the GNU gettext tools and Martin's intl module from there. http://www.python.org/~bwarsaw/software/Code/pytgettext.py -Barry From jhauser at ifm.uni-kiel.de Wed Sep 22 05:55:30 1999 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 22 Sep 1999 11:55:30 +0200 Subject: lists and append, and loop iteration References: <37E8860B.C024C4F8@radiata.com> <14312.40896.797841.421283@gargle.gargle.HOWL> Message-ID: <87ln9ztgml.fsf@ifm.uni-kiel.de> Charles G Waldman writes: > I would write > > dict['new_key'] = dict.get('new_key',[]) + [new_value] > This is a trick, because it does only supress the exception. But has the same effect :-) I could not write >>> dict={} >>> dict['new_key'] = dict.get('new_key',[]).append(['new_value']) >>> dict {'new_key': None} To this refered my last note about the reference of a. Although I do not understand this. If I get not an empty list, why can I do an append? Questioned, __Janko -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From stadt at cs.utwente.nl Wed Sep 22 04:15:43 1999 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Wed, 22 Sep 1999 10:15:43 +0200 Subject: cgi authentication References: Message-ID: <37E8902F.45998A4D@cs.utwente.nl> "Magnus L. Hetland" wrote: > > "Dan Grassi" writes: > > > I need to do authentication from Python, for various reasons using Apache > > and .htaccess is not a workable solution. I can get the request to show up > > with the following code but I can not figure out how to access the returned > > name/password pair. Yes, I have looked hard for the info on the web and in > > the books. "-) > > Well - I have had the same problem, and AFAIK, Apache refuses to give > you the password (ostensibly for security reasons...) There is a > patched version available somewhere... > > > > > Can anyone help? > > > > -- > > Magnus > Lie Please forward all spam to > Hetland uce at ftc.org If all else fails, then you'll have to do it yourself, by simply using:
Login: Password: Then in SomeScript you can work with the variables 'login' and 'password'. I guess you must have thought of this. But one never knows :-) But you'll have to make your own (encrypted?) password file for this to work (or get the source of htpasswd to find out how passwords are encrypted for use with .htaccess). Richard. From ovidiu at cup.hp.com Tue Sep 21 11:41:33 1999 From: ovidiu at cup.hp.com (Ovidiu Predescu) Date: Tue, 21 Sep 1999 08:41:33 -0700 Subject: Any good debuggers for Python? (was Re: using python debugger (pdb) inside emacs debugger mode ...) In-Reply-To: Your message of "Mon, 20 Sep 1999 08:18:16 EDT." <19990920081816.A350855@vislab.epa.gov> Message-ID: <199909211541.IAA00633@hpcll563.cup.hp.com> On Mon, 20 Sep 1999 08:18:16 -0400, Randall Hopper wrote: > Ovidiu Predescu: > |I didn't figure out exactly all the details, but the basic idea is to use > |GDB to handle all the interaction with the user instead of pdb. pdb > |becomes only a debugging engine that's loaded in a Python program and > |knows how to setup breakpoints, continue the program etc. All these > |operations are published in a simple Python API that could be called from > |GDB. > > I believe this is how DDD/PyDB works as well (providing the user with a > graphical Python debugger). Actually PyDB works as a front-end for GDB. It sets up breakpoints inside the interpreter and analyzes the internal C data structures to discover the state of the Python program. The thing I was thinking of is a much tighter integration between GDB and the Python program, as GDB would make calls into the Python program to find out about its state. > |What I'm working on right now is adding scripting language support to GDB > |so that this kind of functionality could be implemented in GDB using an > |interpreted language and not C. The language I'm embedding is surprise, > |Python ;-). This work is part of the WDB project here, at HP, but all the > |work we're doing is going back in the FSF main tree. For more information > |on WDB, take a look at: > | > |http://www.hp.com/esy/lang/tools/Debuggers/index.html > > Sounds interesting. Hope to hear more about this later. Sure, I'll let you all know when I have something you can play with. Greetings, Ovidiu -- Ovidiu Predescu http://andromeda.cup.hp.com/ (inside HP's firewall only) http://www.geocities.com/SiliconValley/Monitor/7464/ From aahz at netcom.com Wed Sep 8 13:46:14 1999 From: aahz at netcom.com (Aahz Maruch) Date: 8 Sep 1999 17:46:14 GMT Subject: And now for something completely boneheaded... References: <37D623A2.DC09F0CC@nightwares.com> Message-ID: <7r67d6$nor@dfw-ixnews15.ix.netcom.com> In article <37D623A2.DC09F0CC at nightwares.com>, Warren 'The Howdy Man' Ockrassa wrote: > >It's... the obvious question of the day. Or perhaps the hour. >So I have > > import sys > >From that how can I find out what sys can do? Here's a different answer: Go to http://www.python.org/doc/current/lib/lib.html and select the link for the sys module. (Note that I strongly suggest downloading the docs to your local drive to make browsing faster.) -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From mwh21 at cam.ac.uk Fri Sep 3 09:45:55 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: Fri, 3 Sep 1999 14:45:55 +0100 Subject: Spanish Inquisition?! In-Reply-To: <37CFC38C.20A9C267@megsinet.net> References: <37CFC38C.20A9C267@megsinet.net> Message-ID: On Fri, 3 Sep 1999, David Oppenheimer wrote: > In a previous thread (about languages interpreted versus languages > compiled) there was talk of the Spanish Inquisition. I am guessing that > this is 1) a joke or 2) the code name for a "secret" project to create > compiled code from python code and thereby permanently blur the line for > Python. Anyone know anything about this? I'm presuming it was a joke. There are various bits of vaguely relavent vapour - Swallow & Viper are two of them. dejanews is your friend... > P.S. Creating compiled code from Python that didn't require the > interpreter to be distributed with it would be high magic indeed. No kidding. Regards, Michael From tim_one at email.msn.com Wed Sep 22 01:34:35 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 22 Sep 1999 01:34:35 -0400 Subject: Matching templates against a tree - any ideas? In-Reply-To: <37E7A272.51E5C4E1@strs.co.uk> Message-ID: <000401bf04bc$282158a0$342d153f@tim> [Ian Clarke, wants to do tree pattern-matching] [John Skaller, suggests a parsing approach] Note that John Aycock's "Compiling Little Languages" Python framework (see DejaNews) is built on an Earley parser, constructing a parse tree from input that matches an arbitrary context-free grammar. In its latest version it carries that one more step, exactly as John Skaller suggests, using the Earley parser again to support pattern-based covering of the parse tree, where "Patterns are just trees linearized into prefix form, which use parentheses to denote subtrees". Elegant! Very easy to use once you get the hang of it. Slow. Note that algebraic simplification (which appears to be your real thrust) is a field unto itself; general pattern-based approaches aren't going to beat focused domain-specific knowledge. factoring-by-patterns-is-like-doing-arithmetic-in-base-1-ly y'rs - tim From gmcm at hypernet.com Thu Sep 2 10:10:21 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 2 Sep 1999 09:10:21 -0500 Subject: language interpreters/ interpreted languages weaknesses? In-Reply-To: <37CE69C0.6AC977E0@strs.co.uk> Message-ID: <1275844938-67218635@hypernet.com> /F wrote: > > that's what *you* think. lots of people are running > > Python programs without ever noticing, and without > > ever seeing the source code. you might have done > > that, too. Ian Clarke wrote: > I am not talking about what the user notices, I am talking about > what the developer does - and I would venture that most Python code > is distributed with its source, where as this is rare with Java > code. Whether the end-user notices this is not relevant. You can use a number of tools to package up Python apps in compiled form, (including freeze in the Tools directory). Both Fredrik and I are authors of utilities of this kind, and I can certainly assure you that many developers are using our tools. Arguing that there's a "social" component to the distinction between interpreted and compiled, and then arguing that it's what the 'developer does', not what the 'user notices', indicates a fondness for disputation in excess of any regard for relevance. - Gordon From tim_one at email.msn.com Wed Sep 22 00:54:24 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 22 Sep 1999 00:54:24 -0400 Subject: Difficulty with `cmp', still In-Reply-To: Message-ID: <000001bf04b6$8b379d60$342d153f@tim> [Fran?ois Pinard] > Hi, people. I feel a bit opaque, as I cannot quickly get this > code to work: > > > # Return the comparison value of two versions, of two file names > with versions. > def compare_versions(a, b): > a0, a1, a2, a3, a4 = _weights(a) > b0, b1, b2, b3, b4 = _weights(b) > print dir(__builtins__) > cmp = __builtins__.cmp # because of `import cmp' above > return cmp(a0, b0) or a1 - b1 or a2 - b2 or a3 - b3 or a4 - b4 Answers to two questions you didn't ask : 1. Mucking with double-underscore names is a disease. There are a few names like that meant for routine use, primarily special class methods (like __len__ and __add__). But most double-underscore names expose obscure pieces of the internals, and should almost never be used unless you're, say, writing a Python debugger in Python. Everyday programs don't need them and are better off avoiding them. In this case, I suggest avoiding __builtins__ by changing the way you import the conflicting name: import cmp file_cmp = cmp.cmp # assign a local, non-conflicting name del cmp # get the jerk out of our namespace, unshadowing the builtin or by writing a trivial wrapper with a non-conflicting name: def file_cmp(f1, f2, shallow=1): import cmp # the import only affects this function's locals return cmp.cmp(f1, f2, shallow) 2. You're familiar with lexicographic comparison of strings (keep going "left to right" until finding unequal chars). In Python, strings are sequences of characters, and lexicographic comparison is used for *all* builtin sequence types, not just strings. I don't know what type your _weights function returns, but it looks like sequences, so barring something subtle the above is likely equivalent to the simpler: return cmp(_weights(a), _weights(b)) > When used in batch, I get "AttributeError: cmp". When used interactively, > everything seems to work fine, and `compare_versions' does what it should. > The `print' statement is a mere try to understanding the problem, and it > has the effect of adding this line to the output, just before the > traceback: > ... > If I do the same `print' interactively, I get (refilled in this message): > ... > So far that I know, I'm not playing tricks nor trying to more clever than > Python, I would think my code is rather straight. I'm surely not trying > to play with the builtin lists, the most I do is trying to get the `cmp' > from it. I do not see how or why the builtin list get reduced when my > code is executed in batch, and why `cmp' is disappearing. Would someone > have a suggestion or an idea of what I should study to grasp what is > happening? The module __builtin__ contains all the builtin functions compiled into Python. But there's a layer of indirection between that and what a module *sees* as being the builtin namespace, primarily to support a bulletproof restricted execution mode (e.g., some apps can't afford to let Python code run the builtin "open" function). So rather than reference __builtin__ directly, the implementation looks up the related name __builtins__, which the runtime always arranges to bind to an appropriate mapping object (either a module or a dict). It may or may not resolve to the module __builtin__, or to __builtin__'s global dict. It will *usually* resolve to one of those two, but you can't count on that. The point is that it's a detail of the implementation, and is there for Python's convenience more than yours . Don't touch it, and you won't get surprised. The language reference manual's section 4.1 ("Code blocks, execution frames, and namespaces") is the key to much of Python's semantics (including the __builtin__ vs __builtins__ distinction), as it defines "what names mean". So that's the section to study if you want a deep understanding. if-you-want-a-shallow-one-read-"learning-perl"-ly y'rs - tim From philh at vision25.demon.co.uk Thu Sep 2 18:15:22 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Thu, 02 Sep 99 22:15:22 GMT Subject: And Now For Something Completely Similar !!! References: <5l906p5vpj.fsf@eric.cnri.reston.va.us> Message-ID: <936310522snz@vision25.demon.co.uk> In article <5l906p5vpj.fsf at eric.cnri.reston.va.us> guido at cnri.reston.va.us "Guido van Rossum" writes: > kernr at mail.ncifcrf.gov (Robert Kern) writes: > > On Wed, 01 Sep 1999 16:48:24 -0400, David Oppenheimer > > wrote: > [...] > > >2) Why isn't a module which has broad appeal like the Python Imaging Library > > >included with the core Python 1.5.2 package? > > > > Release schedules, lean&mean-ness, not enough people needing to > > manipulate images in Python, etc. > > You said it. The key issues here are independent developers and > independent development schedules; I can't afford to repackage Python > each time a new PIL comes out and I certainly don't want to have to > wait until PIL is stable before releasing Python. Indeed. And if you did the same thing for all libraries which use Python, the whole release process would rapidly become unmanageable. How about a compromise? At the time of each Python release, take a snapshot the latest versions of some Python packages, such as PIL, PySol, etc, and release them as a ``Python Goodies'' tarball. This would: 1. make a convenient method where people could install lots of useful Python software in one go 2. make it obvious that the Goodies aren't part of the Python distro itself 3. allow people to see major programs written in Python -- this helps to dispell the notion that Python is just a scripting language, and also makes available lots of source code, which might be useful to look at if you are learning Python. > Yeah... This is actually in my plans for Python 1.6 (although I > haven't started working on it honestly). Any ideas on release date? -- Phil Hunt - - - - - - - - - philh at vision25.demon.co.uk - Linux will be 8 years old on 17th September! See: - http://www.vision25.demon.co.uk/prog/linuxbirthday.html From fredrik at pythonware.com Tue Sep 7 04:46:17 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 7 Sep 1999 08:46:17 GMT Subject: Tkinter-related problem References: <19990906215844.A353@krikkit.vollmert.home> Message-ID: <01c101bef90d$742ed570$f29b12c2@secret.pythonware.com> Robert Vollmert wrote: > Xlib: unexpected async reply (sequence 0x18d)! > Xlib: unexpected async reply (sequence 0x18e)! > X Error of failed request: BadGC (invalid GC parameter) > Major opcode of failed request: 60 (X_FreeGC) > Resource id in failed request: 0x2c00009 > Serial number of failed request: 404 > Current serial number in output stream: 407 just guessing, but are you using threads? iirc, the "unexpected async reply" indicates that multiple threads (or processes) are using the same X server connection. From godzilla at netmeg.net Thu Sep 9 21:22:39 1999 From: godzilla at netmeg.net (Les Schaffer) Date: Fri, 10 Sep 1999 01:22:39 GMT Subject: Python example: possible speedup? References: <7r98lk$kug@dfw-ixnews6.ix.netcom.com> Message-ID: > What if you use range(100000) or range(1000000)? elapsed time (sec) trying NUM = 10 a=a+'h' --> 0.000987 cStringIO --> 0.000954 a.append('h') --> 0.001573 trying NUM = 100 a=a+'h' --> 0.004399 cStringIO --> 0.005185 a.append('h') --> 0.007262 trying NUM = 1000 a=a+'h' --> 0.056781 cStringIO --> 0.054581 a.append('h') --> 0.072653 trying NUM = 10000 a=a+'h' --> 3.217044 cStringIO --> 0.535160 a.append('h') --> 0.907285 trying NUM = 100000 a=a+'h' --> 324.303910 cStringIO --> 5.138107 a.append('h') --> 7.676265 trying NUM = 1000000 still running :-) [ i want skip m's computer !!! :-) ] -- ____ Les Schaffer ___| --->> Engineering R&D <<--- Theoretical & Applied Mechanics | Designspring, Inc. Center for Radiophysics & Space Research | http://www.designspring.com/ Cornell Univ. schaffer at tam.cornell.edu | les at designspring.com From digitome at iol.ie Sat Sep 4 05:01:27 1999 From: digitome at iol.ie (Sean Mc Grath) Date: Sat, 04 Sep 1999 09:01:27 GMT Subject: Turing Compliant? References: <000201bef6a0$5323adc0$842d153f@tim> Message-ID: <37d0de12.934673@news.iol.ie> >[Kristopher Johnson] >> But can Python efficently solve the Traveling Salesman Problem, >> or other NP-complete problems? > >If it were thought possible to solve such things efficiently, they wouldn't >be NP-complete <0.5 wink>. > [Tim Peters] >TSP in particular has had person-centuries of intellectual effort tossed at >it, and the best algorithms known will certainly run faster in almost >anything other than Python. > I have had a situation where an NP complete problem was being tackled in which the speed of Python was raised as an issue. Suggestions were made that the algorithm be rewritten in something faster like C. The danger in this line of thinking is not realizing that the computational effort involved in big NP complete problems is *so* huge that even in optimized micro-code, the algorithm might take a million years to run. Tweezers or shovel -- it makes little difference when you are trying to move a universe... regards, From malcolmt at smart.net.au Wed Sep 29 04:43:28 1999 From: malcolmt at smart.net.au (Malcolm Tredinnick) Date: Wed, 29 Sep 1999 18:43:28 +1000 Subject: When Good Regular Expressions Go Bad In-Reply-To: <000101bf0a47$98084da0$ce2d153f@tim>; from Tim Peters on Wed, Sep 29, 1999 at 02:55:19AM -0400 References: <000101bf0a47$98084da0$ce2d153f@tim> Message-ID: <19990929184328.A833@Ridcully.home> On Wed, Sep 29, 1999 at 02:55:19AM -0400, Tim Peters wrote: > [Douglas Alan] > > ... > > It seems to me that even when a regular expression fails to match a > > string, you might want to know just how far it was able to get before > > getting stuck. (And indeed I do!) For instance, let's say that I have > > the regular expression "^foo.bar", and I try to match it on the > > string "fooxbaz". It might be useful to be able to find out that > > the regular expression was able to get all the way through "fooxb" > > before giving up the ghost. > > I believe this would be easy to add to any regexp engine I've ever seen, and > also believe I've never seen one that keeps track of it. I confess I'm at a > loss to think of a compelling use for it, though. Isn't there a problem here with which "failing match" you are going to report on? Do you take the longest failing match (which will probably be horrendously expensive in a complexity sense, since you will have to scan the entire candidate string), or the leftmost failing match (which could be uninteresting a lot of the time) or what? While I agree it's sort of a useful thing to have sometimes (error recovery during parsing - something like detecting possible spelling errors), it needs to be defined a little better before being implemented. Cheers, Malcolm Tredinnick. From mal at lemburg.com Mon Sep 27 17:36:03 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Mon, 27 Sep 1999 23:36:03 +0200 Subject: error in compiling with gcc 2.95.1 References: Message-ID: <37EFE343.4A590E1E@lemburg.com> Szilveszter Juhos wrote: > > PYTHONPATH= ./python ./Lib/test/regrtest.py > Fatal Python error: unlock_import: not holding the import lock > Abort - core dumped > > Have anybody seen something similar like this? Irix 6.2 Python 1.5.2, gcc > 2.95.1 . With gcc 2.8.1/ SGI cc 7.1 compiles fine, but there are other > bugs (as mentioned in the source distr. README). gcc 2.95.1 seems to have a few optimization bugs. I've had reports about my mxDateTime package dumping core when compiled with -On (n>2). Also, shared libs compiled with gcc 2.95.1 are rather unstable when used with code compiled using earlier gcc versions. -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 98 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From cjc26 at nospam.cornell.edu Mon Sep 13 20:48:39 1999 From: cjc26 at nospam.cornell.edu (Cliff, or a close facsimile) Date: 14 Sep 1999 00:48:39 GMT Subject: formatting plain text to html References: <87btb6bmqb.fsf@iname.com> Message-ID: Pada 13 Sep 1999 21:06:04 +0100, david.maslen at iname.com bilang: | I have a bunch of plain text notes. I want to format them so that any | URL references ie. 'http://www.python.org/' are replaced by | 'http://www.python.org/' | | There are probably a few other niceties such as replacing linefeeds | with

, but that isn't so important. | | Should I just get started with the strings and re modules? Or is there | some code in existance that will make this task easier? I don't know, but the following seems to work: >>> teststr='look at my webpage http://www.python.org/ I am so l33t' >>> re.sub('(http://[\w\-\?%~./]+)', r'\1', teststr) 'look at my webpage http://www.python.org/" I am so l33t' Are there any other characters permitted in URL's? -- cliff crawford http://www.people.cornell.edu/pages/cjc26/ There are more stars in the sky than there are -><- grains of sand on all the beaches of the world. From olipt at mayo.edu Mon Sep 6 21:05:12 1999 From: olipt at mayo.edu (Travis Oliphant) Date: Mon, 6 Sep 1999 20:05:12 -0500 Subject: Turing Compliant? In-Reply-To: References: <37CD7CBC.54AD295F@megsinet.net> <7r0q9d$sp6$1@nnrp1.deja.com> <14291.65246.743544.70969@buffalo.fnal.gov> <7r1ibf$eb1@dfw-ixnews14.ix.netcom.com> Message-ID: > On 6 Sep 1999 23:22:23 GMT, Aahz Maruch wrote: > >Charles G Waldman wrote: > >>jhefferon at my-deja.com writes: > > >>> Not infinite. Unbounded. > > >>I'd be interested to hear what the difference is, according to you, > >>between "infinite" and "unbounded". According to me, they are the > >>same thing. "finite"=="bounded" => !finite==!bounded. > > >Consider the real numbers in the range 0.0 through 1.0. They are > >bounded but infinite. > > ...but he's speaking of memory, an item which has to be enumerated in > order to be measured. Thus, unbounded memory is infinite memory. > > Oh, and for an equally technical nit-pick: contrary to your claim, none of > the numbers in the range between 0.0 and 1.0 are infinite. The > cardinality of the set, OTOH, is infinite and unbounded. We won't even bring up that the cardinality of this set is even larger than the simply unbounded enumerable sets. I suppose I shouldn't go there but the infinitity of infinities is a concept that has always enchanted me. Travis From dwalker at iximd.com Mon Sep 13 08:11:08 1999 From: dwalker at iximd.com (Damond Walker) Date: Mon, 13 Sep 1999 12:11:08 GMT Subject: Text UI References: <65118AEEFF5AD3118E8300508B124877073BEE@webmail.altiris.com> Message-ID: William Tanksley wrote in message ... > >This last is a problem for me -- I'd like to have color available. I need >it if I'm going to use this as part of my game, Omega. > I tried the keep the curses stuff limited to one class so that it would act as a wrapper. it would be a trivial matter (I think) to convert this one class to ncurses or slang, or even a "real" GUI using tkinter. Additional code can be put in place to say: try the "standard" ncurses module, if the import fails, step down to the curses module. > >It sounds great. > Go to http://iximd.com/~dwalker and hit the tinter.py link. It's a 29k text file. > >That works for me. I like LGPL. I like the Python license better, but >LGPL is certainly useful. > I'm not married to the LGPL either... But I'll probably be changing that in the near future anyway. Because I really don't care how people use it. Damond From jfisher at are.berkeley.edu Wed Sep 1 17:39:53 1999 From: jfisher at are.berkeley.edu (John Fisher) Date: Wed, 01 Sep 1999 21:39:53 GMT Subject: Printing data members of a class Message-ID: <7qk6f6$8cj$1@nnrp1.deja.com> Hey folks, I'm trying to set up a class so that when instances of it are printed, a Python prints just a certain data member of the instance. For example: >>> class x: ... data = array([1, 2]) >>> y = x() >>> y [1 2] or at least >>> print y [1 2] I've tried playing around with repr, and defining __repr__() in the class, but haven't had any luck yet. I'd appreciate any suggestions on how to do this. Thanks! John Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From ken.koller at kla-tencor.com Mon Sep 13 18:58:59 1999 From: ken.koller at kla-tencor.com (Ken Koller) Date: Mon, 13 Sep 1999 15:58:59 -0700 Subject: error in module re? References: <937225378.3989@mhs0096x.mchh.siemens.de> Message-ID: <37DD81B3.59A983F8@kla-tencor.com> I think you need to use a raw string such as r'\2-\1' or escape the slash '\\2-\\1' re.sub('(a+)\s(b+)', r'\2-\1', 'aaa bbb') or re.sub('(a+)\s(b+)', '\\2-\\1', 'aaa bbb') "Chris..." wrote: > Dear Pythoners... > > Is this an implementation or documentation error? > >>> import re > >>> re.sub('(a+)\s(b+)', '\2-\1', 'aaa bbb') > '\002-\001' > instead of > 'bbb-aaa' > The documentation says, that you can use backreferences in replacement > string, but only \g works. > > My version is: > Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 > > bye > Chris... From davidopp at megsinet.net Wed Sep 22 20:05:58 1999 From: davidopp at megsinet.net (David Oppenheimer) Date: Wed, 22 Sep 1999 20:05:58 -0400 Subject: Please Help Convert This Code Message-ID: <37E96EE5.95270EA9@megsinet.net> Dear Group, I would really appreciate it if someone could help convert this Tkinter code into equivalent wxPython code. Need this to be done to create a drag and drop GUI maker that will have Tkinter AND wxPython as output choices. Thanks in advance. David O. from Tkinter import * def write_defaults(Widget): widget = Widget() widget.place(x=0, y=0) filename = "%s.txt" % Widget.__name__ file = open(filename, "w") for key in widget.keys(): if widget[key] == "": widget[key] = None print widget[key] file.write("%s = %s\n" % (key, widget[key]) ) file.close() if __name__ == "__main__": root = Tk() widgets = [ Button, Canvas, Checkbutton, Entry, Frame, Label, Listbox, #Menu, Menubutton, Message, Radiobutton, Scale, Scrollbar] for widget in widgets: write_defaults(widget) root.mainloop() From randall_burns_hp at my-deja.com Thu Sep 2 21:01:40 1999 From: randall_burns_hp at my-deja.com (randall_burns_hp at my-deja.com) Date: Fri, 03 Sep 1999 01:01:40 GMT Subject: How to sell Python to your boss? References: Message-ID: <7qn6lf$ef0$1@nnrp1.deja.com> In article , Petri Mikael Kuittinen wrote: > I'm fortunate to have a boss who is very enthusiastic about Python. (We'd really like to find more developers who share his enthusiasm form Python-I'd be happy to talk to folks about the opportunities doing e-commerce here at HP). > I can understand my bosses opinion. He wants to protect the interest > of this firm. If I would leave the firm, then someone else would have > tp spend time learning Python in order to modify my program code. > > For several months I have tried to get my colleagues excited to learn > Python, but so far nobody has been interested to learn new languages, > except for some mild interest towards Java (which is IMHO an > overly-hyped language). We use Java also-but we've found Python to ease both development and maintenance. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From stephan at pcrm.win.tue.nl Fri Sep 24 03:19:38 1999 From: stephan at pcrm.win.tue.nl (Stephan Houben) Date: 24 Sep 1999 07:19:38 GMT Subject: Becoming root within a Python script References: <87zoydrw4u.fsf@baal.winnegan.fake> <37EAE579.2499F85C@radiata.com> Message-ID: On 24 Sep 1999 00:29:02 -0400, Fran?ois Pinard wrote: >Mark Krischer ?crit: > >> why don't you call the python script using sudo, or make a wrapper >> script that calls sudo .py > >I would prefer not run the script as root, but just become root, here and >there, once in a while, in precise and unusual circumstances. And give >the root password when those times come, and only then. I'm not found on One thing you can do -- although I'm not sure if this is what you want -- is to have the script started with a setuid wrapper anyway, and then swap the real and the effective user id, until the time comes when you want to do something as "root", and then you swap them back. This is not really Python-specific, and I guess you need to write a Python wrapper for the system call setreuid(). But if you do that (supposing you put that wrapper in a module uid), code might look like this (obviously untested): import os import uid # implementing uid is left as an exercise for the reader def swapreuid(): """Swap real and effective user id. """ ruid = os.getuid() # get real user id euid = os.geteuid() # get effective user id uid.setreuid(euid, ruid) Then make sure you get started with the effective uder id as "root", and then do a swapreuid() the first thing in your script. This will set the effective user id back to that of the user. Then, when you have to do root magic, swap them back so you can do the magic. IIRC, this won't work with sudo, since sudo also sets the real uid to "root" . So you really have to use a wrappper. By the way, I think that it is even more secure to have the wrapper swap the real and effective user id, instead of doing this in the first line of the script. Whether this is *really* secure, I can't tell. Obviously, it also depends on the contents of your script. OK, I hope this is somewhat helpful. If it's not, please delete this post. ;-) Greetings, Stephan From towen at I_should_put_my_domain_in_etc_NNTP_INEWS_DOMAIN Thu Sep 30 19:33:59 1999 From: towen at I_should_put_my_domain_in_etc_NNTP_INEWS_DOMAIN (Todd Owen) Date: 30 Sep 1999 15:33:59 -0800 Subject: where is panelmodule? Message-ID: <37f31267.0@news.highway1.com.au> g'day. I found a mention of something called panelmodule (the README for cursesmodule 1.4 says "is fully functional with the panelmodule 1.1"). But I can't find this ellusive module anywhere! Does anybody know where I can find it? TIA - Todd From jam at quark.emich.edu Thu Sep 30 10:04:23 1999 From: jam at quark.emich.edu (Jeff) Date: Thu, 30 Sep 1999 10:04:23 -0400 Subject: 'ipfw' IOCTLS available as python module? Message-ID: <19990930100423.D22550@quark.emich.edu> greetings all, I have need to write a firewall configuration script in python, and one of my design goals is that python not act as just another /bin/bash replacement. what I'd like is a module that knows how to directly make the ioctl calls described in the ipfw(4) man page (so I don't have to resort to 'os.system("/sbin/ipchains -F")', which looks ugly). I am willing to work on the project, but I thought I saw *something* whiz by on the mailing list regarding this same issue. however my searcg via python.org didn't turn up anything. does anyone have any pointers they'd be willing to share? regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From thomas at bibsyst.no Tue Sep 28 07:27:46 1999 From: thomas at bibsyst.no (Thomas Weholt) Date: Tue, 28 Sep 1999 13:27:46 +0200 Subject: Python Berkley DB and speed issues References: <37F06752.7D98775@bibsyst.no> <37F08369.746D535@lemburg.com> Message-ID: <37F0A632.895A9271@bibsyst.no> > > Hmm, millions of records... you must have a *large* CD collection ;-) > > -- > Marc-Andre Lemburg Well, yes, but the fact is that each file is scanned and stored. When you have lots of clipart, images and source-code, that soon becomes alot of data. I`ve implemented a "pattern-scheme" so that users can define patterns to look for, ignore or warn about, so that the level of details can be modified. It works pretty well right now. Thanks for your input. Thomas From justin at ukans.edu Fri Sep 3 13:49:43 1999 From: justin at ukans.edu (Justin Bradford) Date: Fri, 3 Sep 1999 17:49:43 GMT Subject: ORBit bindings/interface? In-Reply-To: References: Message-ID: > ILU supports this already and is fairly widely used in the Python > community. See ftp://ftp.parc.xerox.com/pub/ilu/ilu.html for details. I want to use these bindings in Gnome applications, so I need ORBit support specifically (ie. I don't want the user to have to run ILU to communicate to ORBit to talk to the rest of the Gnome applications). Or is there something I'm missing? Justin From init__self at my-deja.com Thu Sep 16 13:11:49 1999 From: init__self at my-deja.com (Python Addict) Date: Thu, 16 Sep 1999 17:11:49 GMT Subject: high school programming & python References: <937300939snz@vision25.demon.co.uk> <37E0F23E.B0199331@strs.co.uk> Message-ID: Rats! You had rats? You lucky buggers. We didn't even have ones, we just had zeros. And sometimes They forced us to use the letter O instead. Rats == luxury. From bsb at baal.infodrom.north.de Sun Sep 19 06:03:20 1999 From: bsb at baal.infodrom.north.de (Siggy Brentrup) Date: 19 Sep 1999 12:03:20 +0200 Subject: NCDaudio aka nas Message-ID: <87iu57p6af.fsf@baal.infodrom.north.de> Hi Pythoneers, after searching the archives (and the NIST registry) revealed no results, I'm asking here before starting my own effort with SWIG. Did anybody package an python interface to NCDaudio aka Network Audio System ? >From Debian's nas/copyright: > This is the Debian GNU/Linux prepackaged version of NAS, the Network > Audio System. The Network Audio System was written by Jim Fulton, > Greg Renda, and Dave Lemke at Network Computing Devices, Inc. > This package was put together by Ian Murdock , > and then updated by Michael Nonweiler , using > sources obtained from: ftp.x.org:/contrib/audio/nas/nas-1.2p4.tar.gz CU Siggy -- noch nichts Aufregendes: Siggy Brentrup - bsb at baal.infodrom.north.de - voice: +49-441-6990134 From steinme at norway.eu.net Tue Sep 21 15:24:23 1999 From: steinme at norway.eu.net (Stein M. Eliassen) Date: Tue, 21 Sep 1999 21:24:23 +0200 Subject: make test failed in time_test Message-ID: <37E7DB67.5DE00C61@norway.eu.net> hi, I'm running Slackware 4.0 and trying a 'make test' with python v1.5.2. when I got this: test test_time crashed -- exceptions.AttributeError : altzone what's this and how do I fix it? Stein From scarblac-spamtrap at pino.selwerd.cx Mon Sep 13 05:05:53 1999 From: scarblac-spamtrap at pino.selwerd.cx (Remco Gerlich) Date: 13 Sep 1999 09:05:53 GMT Subject: equivalent of enum? References: <14296.14104.456361.61180@dolphin.mojam.com> Message-ID: Skip Montanaro wrote: > If you expect to have properties associated with particular pieces > (position, strength, etc), you might want to consider representing them by > instances of a specific ChessPiece class instead: I'm not going to make a chess playing engine, mostly store games, put comments into them, etc. But a property that they do have is the way they move. I'm new to Python, this is the first thing of more than a few lines that I want to program, and I'm still searching for the right mindset :-). Maybe an empty ChessPiece superclass, and then subclasses for each piece type, so it can return a list of squares it can move to? Hmm. I think I'll just make some functions for that, OO is overkill there, in my opinion. > whiterook = Rook(5, "h", "8", "white") > whitenight = Knight(3, "h", "7", "white") > ... This is probably over-killing a bit. The base object that I'll use is the Position; most move possibilities depend on the rest of the position anyway. It'll just hold a list of squares, with piece numbers. This is also easier because you can give a rook that hasn't moved yet a different number from one that has moved, because of castling rules; to let an object change itself like that feels icky to me :). This may give rise to a lot of if/elsif/elsif/elsif/if/... type of code, but then, the rules of chess are unlikely to change soon so it's not a big problem :). > In more direct answer to your question, there is no enum type in Python. > It's simple enough to declare objects that you treat as constants, however: > > whiterook = 1 > whiteknight = 2 Yes, that is what I'll do. I like the emptysquare, whiterook, whiteknight = range(3) idiom from the other post :). -- Remco Gerlich, scarblac at pino.selwerd.cx Murphy's Rules, "Life in the fast lane": In the fifth edition of FBI's Tunnels & Trolls, an average man may make 10-second sprints topping 60 miles per hour. An exceptional runner could sprint at 118 mph. From jeremy at cnri.reston.va.us Tue Sep 21 18:51:29 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Tue, 21 Sep 1999 18:51:29 -0400 (EDT) Subject: global in nested functions (viper) In-Reply-To: <9XRF3.2$Ae3.15469@news-dal.corridex.com> References: <37E7AF7B.8DEC7CC8@maxtal.com.au> <5l67149gwc.fsf@eric.cnri.reston.va.us> <9XRF3.2$Ae3.15469@news-dal.corridex.com> Message-ID: <14312.3057.617522.176041@bitdiddle.cnri.reston.va.us> >>>>> "ES" == Evan Simpson writes: ES> This sounds relevent to one of my many proposals to make work ES> for other folks . Perhaps instead of causing a reference ES> to the (grand-)*parent's locals, this could simply copy the ES> object into a local variable at definition time? This wouldn't help for code that uses assignment. The expected behavior of 'x = 2' is that all code that can access x will see the new value. Copying into a local variable would make changes visible only in the local scope. The problem with the earlier proposal -- that global means look in the locals of the containing function unless it also contains a global decl -- is that you need to add a global decl to every scope between the one where the variable is created and the one where it is used. It seems less tedious to define global to mean the nearest enclosing scope. Jeremy From aahz at netcom.com Mon Sep 6 10:27:10 1999 From: aahz at netcom.com (Aahz Maruch) Date: 6 Sep 1999 14:27:10 GMT Subject: Python speed and `pcre' References: <000301bef83b$9d7fa620$da2d153f@tim> Message-ID: <7r0ivu$95j@dfw-ixnews21.ix.netcom.com> In article <000301bef83b$9d7fa620$da2d153f at tim>, Tim Peters wrote: > >The design issues are more complicated than that, alas. Here's one you >weren't thinking of : for easy chatting with C, under the covers a >Python string is always terminated with a null byte. You can't see that >from Python code (it's not counted in the string length, and you can't index >to it), but your C code can rely on it. Hmmm.... From what I've seen, Python strings work perfectly well with null bytes in the middle. Are there any circumstances under which that does not hold true? -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From daniels at mindspring.com Sun Sep 12 22:20:46 1999 From: daniels at mindspring.com (Alan Daniels) Date: 13 Sep 1999 02:20:46 GMT Subject: equivalent of enum? References: <14296.14104.456361.61180@dolphin.mojam.com> <37D84F85.A37FAA9C@home.com> Message-ID: On Fri, 10 Sep 1999 00:18:24 GMT, the infinitely wise Doug Hellmann (doughellmann at home.com) spoke forth to us, saying... [snip...] > one, two, three = range(3) > print one, two, three This is a handy little trick (thanks for posting it!), and not to be picky, but the indexing will start at zero instead of one, which could trip up people new to Python. So this would be better as: zero, one, two = range(3) Or, maybe: one, two, three = range(1, 4) Also, just as a matter of style, I use all CAPS when the number I'm defining is meant to be a constant. Using ranges is sure going to beat naming all the enum values by hand, though. :=) -- ======================= Alan Daniels daniels at mindspring.com daniels at cc.gatech.edu From evan at tokenexchange.com Thu Sep 2 12:52:30 1999 From: evan at tokenexchange.com (Evan Simpson) Date: Thu, 2 Sep 1999 11:52:30 -0500 Subject: break LABEL vs. exceptions + PROPOSAL References: <37bc1339@cs.colorado.edu> <19990819174800.D5227@xs4all.nl> <37bc313b@cs.colorado.edu> Message-ID: Here's a (shamelessly unmotivated) example which I find more expressive than it would be with "break LABEL": Found, Panic = 'Found', 'Panic' try: for thingy in whatzits: for bit in thingy: if bit.is_wanted(): raise Found, bit if hasattr(bit, 'panic'): raise Panic, bit.panic if thingy.other_bit.is_wanted() raise Found, thingy.other_bit if hasattr(thingy, 'panic'): raise Panic, thingy.panic else: print "Not found" except Found, it: print "Found", it except Panic, why print "Panic!", why In particular, "break LABEL" doesn't allow you to provide information about *why* you're leaving the loop, and *what* caused that condition without explicitly setting up variables to hold that information and then checking the reason, post-loop. Exceptions are more general, too; there doesn't have to be a loop. The only things I don't like about this are the unnecessary involvement of the fairly heavy exception machinery, the need to "declare" my break reasons as variables to ensure an "is" match, and the possibility of a subtle typo turning my local "break" into an uncaught exception. Rather than "break LABEL", I would like to see a construction like the following: (in 2.0, of course ) try: ... break , ... continue , : continue , : The first argument to "break" and "continue" is required to be a string, and each "break" string is required to match a string in a containing try's "continue". This makes it clear that we're breaking out of the suite rather than raising an exception, and could be implemented efficiently and trivially with jump, load, and store bytecodes. Rich Salz wrote in message news:rst6om9lj7141 at corp.supernews.com... > >No, I'm sorry, the expressivity of "break LABEL" and "continue LABEL" > >are much clearer than the cicumlocutions necessary for exceptions. > > You sure? I wasn't aware that I could break and return a value, such as > the name of the file that wasn't found. At least not without a lot of > circuml^H^H^H^H^H global variables. From linux_12345 at yahoo.com Thu Sep 2 07:24:20 1999 From: linux_12345 at yahoo.com (linux_12345 at yahoo.com) Date: Thu, 02 Sep 1999 05:24:20 -0600 Subject: BRIGHTGATE.COM 54041 Message-ID: <020999052420@yahoo.com> Brightgate Metasearch is the newest meta-search site on the net. It searches over 18 (most used) search engines on the Internet, well above the average of all other metasearch sites. There is also an option to submit a url to 30+ search engines. Of course, do not forget the MP3 and Files search options, if you are looking for that special MP3 or file then chances are you will find it with Brightgate Metasearch. http://www.brightgate.com From davis at space.mit.edu Sat Sep 11 05:58:33 1999 From: davis at space.mit.edu (John E. Davis) Date: 11 Sep 1999 09:58:33 GMT Subject: How to get the python sourcecode line, when debuging the Python C sources? References: <7r3bqk$hbv$1@newshost.germany.net> <7r4alh$7gl$1@m2.c2.telstra-mm.net.au> <7r4bqi$jds@dfw-ixnews11.ix.netcom.com> Message-ID: On 8 Sep 1999 00:49:22 GMT, Aahz Maruch wrote: >>string containing the filename. Adding something like "(char *)(((char >>*)f->f_code->co_filename))+20)" to the watch window should do the trick. It is not necessary to use the initial cast since (char *)f->f_code->co_filename + 20 is already a `char *'. >And people wonder why I think C is a dead language. Not really. What this expression does it actually somewhat complicated. For example, suppose X is some object in the python language, e.g., X = 3.0 How would you form a string from the last 3 bytes of the 8 byte object represented by X in pure python? In C you would use `(char *)&X + 5'. Why you would want to do this another issue. --John From gerrit.holl at pobox.com Wed Sep 8 15:12:33 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Wed, 8 Sep 1999 21:12:33 +0200 Subject: binary mail with python In-Reply-To: <036101bef9e7$b907a480$b4bb32c1@clara.ircom.unilim.fr>; from Daniel ARGOLLO on Wed, Sep 08, 1999 at 12:48:44PM +0200 References: <036101bef9e7$b907a480$b4bb32c1@clara.ircom.unilim.fr> Message-ID: <19990908211233.A3782@optiplex.palga.uucp> On Wed, Sep 08, 1999 at 12:48:44PM +0200, Daniel ARGOLLO wrote: > Hi There!!!! > > > I am searching for any python package that can pack different binary files into a > MIMI file to be sent with the mail suport of python.... > Maybe you're looking for mimimy? I've never used it, but the name means a lot (did I say it right?). regards, Gerrit. -- Unix is easy: type 'man man' and the rest comes of itself. From jam at quark.emich.edu Thu Sep 16 15:52:52 1999 From: jam at quark.emich.edu (Jeff) Date: Thu, 16 Sep 1999 15:52:52 -0400 Subject: newbie - CGI.pm equivalent HTML Forms generator? In-Reply-To: ; from Kevin Howe on Thu, Sep 16, 1999 at 02:46:52PM -0300 References: Message-ID: <19990916155252.C8285@quark.emich.edu> On Thu, Sep 16, 1999 at 02:46:52PM -0300, Kevin Howe wrote: > Hi, > > I am a Perl programmer who is learning Python, and was wonder if their is a > Python package/object/module which allows easy creation of HTML Form > Elements. > > Thanks, > Kevin > there are *many* ways to implement python-based dynamic webpages. rather than listing 'everything', check out for pointers to modules that do this. I like medusa a lot, which you can find at , and there are lots of people that like Zope, which you can find at . there are also nice clean simple modules in the standard library (like 'cgi.py') that will let you use 'print' statements to accomplish the HTML and still parse query strings and POST data. if you want to try medusa, I posted some code recently to the medusa mailing list that might help you get started. I can send you the code via email if you'd like. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From srenner at lycosmail.com Tue Sep 7 22:16:58 1999 From: srenner at lycosmail.com (srenner at lycosmail.com) Date: Wed, 08 Sep 1999 02:16:58 GMT Subject: idle 0.5: correction References: <7r42s9$88m$1@nnrp1.deja.com> Message-ID: <7r4guh$i70$1@nnrp1.deja.com> In article <7r42s9$88m$1 at nnrp1.deja.com>, srenner at lycosmail.com wrote: > Thanks to CVS I don't know when the class browser first appeared in idle > Thanks to ...Tools/idle/cvs/Entries I know exactly when: /ClassBrowser.py/1.10/Fri Jun 25 17:08:19 1999// sr Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From garry at research.att.com Thu Sep 2 10:31:56 1999 From: garry at research.att.com (Garrett G. Hodgson) Date: Thu, 2 Sep 1999 14:31:56 GMT Subject: language interpreters/ interpreted languages weaknesses? References: <7qi3q3$n1d$1@nnrp1.deja.com> <37CCE10D.D07D023B@strs.co.uk> <7qjgq8$k1i$1@newshost.accu.uu.nl> <14285.38262.884171.416195@dolphin.mojam.com> Message-ID: <37CE8A5C.586F56F3@research.att.com> Skip Montanaro wrote: > The only thing that makes Java "more compiled" than Python or Perl is > that you have to explicitly run a separate compiler over the source to > create a .class file. that's the real beauty of java. all the convenience of having to go through a separate compilation step, combined with the blistering performance of an interpreted language. what a deal. -- Garry Hodgson "Hey, mister, can ya tell me, garry at sage.att.com where a man might find a bed?" Software Innovation Services He just grinned and shook my hand, AT&T Labs "No", was all he said. From tim_one at email.msn.com Sun Sep 19 13:35:27 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 19 Sep 1999 13:35:27 -0400 Subject: Force anything to be a string. In-Reply-To: Message-ID: <000001bf02c5$5d191140$102d153f@tim> [jonathon, finds that "str" has been rebound] > ... > A little poking around, and I found an object called > str in two modules that the script calls. After changing > the name of those variables, that error disappeared. :-) This sounds like you fixed the symptom, but not the real cause: it shouldn't make any difference to *your* module what other modules happen to name their variables. Are you, by any chance, doing from OtherModule import * ? Then you're simply paying the price for being lazy <0.6 wink> -- that's *inviting* OtherModule to stomp all over your names. "import *" is a convenience for interactive mode, and should almost never be used in a script (there are a very few modules that were designed to be used that way, but until you're a Python expert better to pretend it's illegal). [Tim] >> ... builtin function names are not reserved, which is both a feature >> and a bug <0.7 [wink]>. > A bug, IMNSHO. A really bad bug, since I wasn't even using a > module I wrote. If you used "import *", you dug your own grave and so get no sympathy. If Python did reserve the builtin function names, then either (a) no builtin function could ever be added to the language again; or, (b) adding a new builtin function would break existing code that happened to use the same name. Neither is tolerable. I'd like to see a warning msg, though (it can't be made an error, at least not by default). >> >>> str = 'oops' >> >>> str(42) >> Traceback (innermost last): >> File "", line 1, in ? >> TypeError: call of non-function (type string) >> >>> >> >> The error msg there should look familiar. It's telling you that the >> syntax looks like a call, but the object in the caller's position *can't* >> be called ("call of non-function"); and it's also giving the type of the >> object that can't be called (str is of "type string"). > Another piece of wisdom to add to the list of things I > couldn't find in _The Python Library Reference Manual_. There are about 900 distinct error msgs in the Python implementation, and while some of them could certainly be wordier, this one looks pretty darned good to me! I didn't explain it because I thought it was unclear, but to nudge you into really *reading* the error msg and think about what it's saying. "call of non-function" doesn't have a heck of a lot of *possible* meanings, after all . The "(type string)" part may be obscure (a disconnected sentence fragment) the first time you see it, but playing around in interactive mode provoking this msg quickly makes its meaning obvious. It won't confuse you the 2nd time you see it. If the Python doc set contained a 450-page manual detailing every error msg (figuring a half page per msg), would you have read it <0.9 wink>? rhetorical-question-cuz-nobody's-gonna-write-that-anyway-ly y'rs - tim From robin at jessikat.demon.co.uk Thu Sep 16 11:01:54 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Thu, 16 Sep 1999 16:01:54 +0100 Subject: Marking translatable strings References: Message-ID: In article , Emile van Sebille writes >Hi Francois, > .... >If a change to the language is in the offing, why not introduce >something like a t"TEXT" structure that behaves as r"..." but also >serves as a marker. Then we'd have 12 ways to express a quoted string. >;-) > More generally wouldn't one need to allow for quoted strings prefixed by either nothing, r or t or rt or tr and if that's the case why stop at only three prefix symbols (counting empty). >Otherwise, It sounds interesting. Where can I find out more about the >project? > >Regards, >-- > >Emile van Sebille >emile at fenx.com >------------------- > > >Fran?ois Pinard wrote in message >news:oq4sgvf0m1.fsf at titan.progiciels-bpi.ca... >> Hello, people. >> >> I had a real strange idea :-). I first quickly dismiss it, but it is >so >> simple that I prefer to ponder it again, and share and debate it a >little >> first, maybe. >> >> My friends know that I've been working at software >internationalisation for >> many years now, with a stress on program messages. Of course, I want >to >> include Python in the realm of my possibilities, and myself start >writing >> internationalised scripts soon, in such a way that everything links >nicely >> with the Translation Project. >> >> So, I want the big picture right now. That is: a technique for >marking >> strings for automatic extraction and building of PO files, and a >technique >> for using PO files from within Python scripts. I foresee that Python >> introduces an usual difficulty in that the textual domain for >translations >> may vary quite unexpectedly, when the control dynamically flies >between >> independent packages under different textual domains. >> >> I started a discussion with Guido about this, but I'm a slow thinker, >and >> would not like to rush things before feeling rather solid, as Guido's >time >> is precious. But on this forum, I thought I could dare exploring >ideas, >> asking for your forgiveness for any blunder I could make while >thinking. :-) >> >> 1) Marking strings >> --------------- >> >> There are many circumstances where strings translation could be >delayed >> from where they textually occur, and that language syntactic >considerations >> could make the marking difficult in a few cases. In C, there is a >> pre-processor between the sources and the compiler, so it is easy to >introduce >> an identity macro which special name is recognised by the string >extractor, >> and which vanishes before the compiler sees it. We use: >> >> #define N_(Text) Text >> >> for that purpose. In languages where such preprocessing is difficult, >like >> for `ksh' or `bash', strings are especially marked in the syntax, like >in: >> >> $"translatable text" >> >> but this requires a modification to the interpreter. Emacs, with >`defsubst', >> also allows for macro expansion, and we then use tricks as in C >(anywhere >> except for doc strings). Some other flavours of LISP are also open to >> such tricks. >> >> Python has no preprocessing, no special string syntax for markability, >> and moreover, it has doc strings! So, at first glance, it looks >difficult. >> However, and this is where my strange idea comes to play, it has eight >> type of strings: ', ", ''', """, r', r", r''' and r"""; and I thought >> that maybe we could just discipline ourselves to give more meaning to >all >> these differences, since after all, if we except some ending backslash >> considerations, all eight types are equally capable of representing >> any string. >> >> I'm a strange, anal man, who needs a reason behind the slightest >choices, >> and believe me, eight types of strings gave me a lot of food for this >> mania, all along while writing. I'm still exploring! :-) Yet, after >having >> played with Python for almost 10 days, now, I came to realise that I'm >more >> naturally tempted to stick to the 'TEXT' notation for computer strings >and >> "TEXT" notation for human strings, the reasons being that there might >> be a lot of apostrophes in human text, and that traditionally, we more >> usually quote sentences with "TEXT", while we quote words with `TEXT' >> (note the grave accent at the left). >> >> So, the bizarre idea I got is that one could be to formalize this into >> a rule: strings of type ", """, r" and r""" could be all markable as >> translatable, while strings of type ', ''', r' and r''' would not be. >> On the other hand, this might be overkill, as maybe people are used to >> freely mix types ' and ", and this change could be seen as stressful. >> Could we choose better? >> >> Surely, since doc strings use """ exclusively, there is no choice as >to retain >> type """ for translability, wherever it appears. However, forcing the >use >> of """ everywhere we want translatibility is an overhead of four >characters >> (just compare "TEXT" with """TEXT"""), while C use three or four >characters >> (compare "TEXT" with _("TEXT") or N_("TEXT"), and bash uses only one >(compare >> "TEXT" with $"TEXT"). I would like Python to be as comfortable as >possible. >> If I could plainly use "TEXT" instead of 'TEXT' to mark >translatability, >> I would have an overhead of zero characters, which would be better >than >> everything, but I'm not sure if this constraint would be acceptable to >> Python writers. >> >> Another possibility is to use ''"TEXT" instead of "TEXT", making an >overhead >> of two characters: that is the compile time concatenation of '' with >"TEXT". >> This combination is quite unlikely to me, and a bit uglier. >> >> 2) Translating strings >> ------------------- >> >> (Oops, I just received a phone call forcing me to leave fairly soon, >so I >> have to be very concise for the remainder of this message. Let's >rather >> develop these in the possible thread that might follow from this >message.) >> >> What would be the most comfortable for me, short of having the Python >> interpreter modified, is to merely use a function to force the actual >> translation of a string. The most comfortable (the less intrusive) >way >> would be to call: >> >> _(TEXT) >> >> to get the translation of text. It resembles C, but it overloads `_', >> which already has a preset meaning, interactively. If I could push >the >> preset `_' somewhere else, maybe on `__', I would do it and reserve >`_' >> for translation, which would be much, much more common in the long >run. >> >> Using a function would allow us to build the whole translation chain >> (administrating the translations with teams, etc.), yet if the syntax >> could be relieved with the help of Guido, I guess this would be >welcome. >> We might need to experiment first. >> >> 3) Setting the textual domain >> -------------------------- >> >> In a quick word, I guess that this problem could be fairly easily >solved >> through the handy scope rules for resolution of names in Python. Each >module >> could have a standard global variable name setting which textual >domain to >> use within it. So, even with the control flying like hell between >modules, >> it would not be a problem on average. But there are problematic >cases, >> like for when untranslated strings are transmitted to other modules, >for >> being translated there, or even maybe for plain doc strings. This >requires >> good thought. This problem is more difficult that many might thing at >first. >> >> OK, I have to rush away now. Thanks for listening! :-) >> >> -- >> Fran?ois Pinard http://www.iro.umontreal.ca/~pinard >> >> >> > > -- Robin Becker From piller at jlab.org Wed Sep 8 14:51:23 1999 From: piller at jlab.org (Chip Piller) Date: Wed, 08 Sep 1999 14:51:23 -0400 Subject: help with serial port I/O Message-ID: <37D6B02B.493ED51@jlab.org> Hi, I am running RedHat Linux 6.0. I have an instrumentation amplifier that can be controlled by the serial port. I can successfully setup the serial line and read and write to the device using the minicom serial communications program. I want to write a simple program that will write a command to the device, wait for one second, and then read the response from the device. I tried the following code: #!/usr/bin/python udl = open('/dev/ttyS1','r+') udl.write('sen 22\r') #change instrument sensitivity setting udl.write('mag\r') #query instrument for signal magnitude val = udl.readline() print 'magnitude readback = ' print val udl.close() Here is the output: [root at piller1 python]# ./test3 magnitude readback = sen 22 [root at piller1 python]# The code does write the sen 22 command to the instrument and changes the value, but not on the first try, I usually have to run the program twice. I have not had success with getting any readback from the device using Python. Help or suggestions please! Chip From cfelling at iae.nl Fri Sep 10 21:49:20 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 11 Sep 1999 03:49:20 +0200 Subject: Python example: possible speedup? References: <000b01befb24$05ca6fe0$f0a0143f@tim> <87g10my6v2.fsf@pc-hrvoje.srce.hr> Message-ID: <7rccf0$g5$1@vvs.superst.iae.nl> Hrvoje Niksic wrote: > "Tim Peters" writes: >> Was the Perl code to which you're comparing it as general as your >> Python code? why is it that all of a sudden Tim's postings don't make it to the newsgroup? I don't recall having seen the above before, and i got the same impression in other treads as well. And as you all know, whithout Tim's postings there is hardly any point in reading the newsgroup at all:) > Robert's solution is ideologically similar to the `grep' solution > proposed below. I seem to have missed this grep solution too. or was it part of Tim's posting? -- groetjes, carel From delgado at Mathematik.Uni-Bielefeld.DE Wed Sep 22 08:54:21 1999 From: delgado at Mathematik.Uni-Bielefeld.DE (Olaf Delgado) Date: Wed, 22 Sep 1999 14:54:21 +0200 Subject: May I loop over a changing list? Message-ID: Hi folks! I am whondering whether the following is considered good (and, more important: save) programming style in python: >>> def countdown(n): ... a = [ n ] ... for x in a: ... if x > 0: ... a.append(x-1) ... return a ... >>> countdown(10) [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0] If my understanding of what 'for x in y' is meant to do is correct, the for loop should be equivalent to something like i = 0 while i < len(a): x = a[i] if x > 0: a.append(x-1) i = i+1 I think appending to a list while looping over it is a neat way to emulate a simple queue. The actual example is not quite clever, of course. I actually use similar pieces of code for doing breadth-first traversals of graphs. Cheers, Olaf From pinard at IRO.UMontreal.CA Thu Sep 16 19:13:48 1999 From: pinard at IRO.UMontreal.CA (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 16 Sep 1999 19:13:48 -0400 Subject: Marking translatable strings References: Message-ID: Bernhard Herzog ?crit: > > 1) Marking strings > > eight type of strings: ', ", ''', """, r', r", r''' and r""" > Note, that all these different types are only different at the lexical > level. The tokenizer treats them all as STRING-tokens, so could end up > with a lot of changes to Pythons internals to distinguish them at any > higher level. Python internal changes are unwanted merely for marking. Marking strings is mainly so tools like `xgettext' could extract them. Of course, it does not know Python currently, put this could be improved. I had my own version for making experiments, with Emacs LISP, and other languages, waiting for Ulrich to get back to `gettext' maintainance, if he ever takes a little break from GNU `libc' :-). > triple quotes are easier to type than the C-versions because you just > have to hit the same key several times instead of different keys scattered > all over the keyboard. Surely. The problem is not really the typing, but the legibility of sources. Translatability marks should really be as little obtrusive as possible, because in the long run, they are meant to clutter sources all over. Experience shows that horizontal space is often a valuable resource while writing code, so we should try to be economical there for overall legibility, much more than typability. > With your suggestion about """ you'd expect 'print """red"""' to print > rouge if your program was properly localized for french, don't you. Yes. I am assuming that people normally use """ for long strings, and that it is very unlikely that people resort to 'print """red"""' in practice. But even then, this once consumes too much horizontal space. I think we need something shorter. I'm still away from home and did not scrutinise all this email thread yet, but so far, I guess we could use _(STRING), with any type of STRING, as both a marker and a gettext caller, and we could use ''"TEXT" or ""'TEXT' for strings needing to be marked only, and translated only later. And doc strings. This would be acceptable overall, I guess. > A special translated string literal means that the Python interpreter > would have to generate special bytecode to translate it everytime it's > executed. It is not impossible that we could go without any need to modify the interpreter, at least for prototypes of internationalized packages. One reason to modify the interpreter would be for speed, maybe, by ensuring that a given string is translated only once even in a loop, like for what _() currently does in C when compiled with GNU C. It might depend on how exactly strings are intern'ed within Python, which I do not know. In any case, it would be nice if internationalization could be achieved portably to all flavours of Python, just doing nothing on older implementations, anyway, or doing it slower. That is, that the string syntax should not be modified. > > 2) Translating strings > I dont't think the potential collision with _ in an interactive Python > session is a problem. Nice! Thanks for alleviating this one :-). > I've used Martin von L?wis' intl module (a wrapper for GNU gettext) [...] I should at least study what's available. My main goal is to reach a global picture soon, because I would like to start internationalizing all this Python code I'm currently writing. Besides many small and some bigger programs here, I surely intend to internationalise the Translation Project robot suite, after I will have finished to convert it to Python. The Mailman author (or one contributor? I do not know all people yet! :-) wrote to me that he wants to get Mailman internationalised, and that would be a major exercise that would be worth tackling soon, to uncover difficulties and problems. I guess I would like to dive in this, or at least, to participate to the effort of those who are already swimming! :-) > If you're careful to only use double-quoted strings inside of _(), > you can even use xgettext to build the initial po-files. This would not be neat enough to my taste. I'm quite ready to modify xgettext, or alter my own extractor in the meantime, to do things properly. > The only problem I can see with this is that you couldn't get xgettext to > recognize doc-strings, because you can't mark them with _() or rather N_(). > Actually translating the doc-strings isn't a problem, because tools that > access the doc-strings could just pass them through _(). Doc strings are recognizable by their location: at the start of a module or after a def, when sextuple-quoted (hi hi! ' is single-quote, " is double-quote, ''' is triple-quote, so we could say that """ is sextuple-quote, or maybe just sex-quote for short :-). If we retain the suggestion that we have ''"TEXT" and ""'TEXT', then we coud say that ''" is quadruple-quote and ""' is quintuple-quote, so giving a meaning to the missing multipliers... If I understand things correctly, `xgettext'-type tools for Python might extract all 4-quoted and 5-quoted strings, as well as 6-quoted strings when in doc string position, as well as strings given to some keyword functions (like `_'), exactly as in `xgettext' currently. > > 3) Setting the textual domain > With intl, you'd could just define _ locally (i.e. on module level) as > def _(text): > return dgettext("domain", text) I hope it might be that simple. In Emacs LISP, it is a real difficulty, and notable internationalisation efforts failed because of this oversight, if I correctly get the stories told to me. When Richard and I discussed the matter a few times, I realised that it is difficult to grasp even for people who know Emacs LISP rather well :-). And he keeps forgetting :-(. > > But there are problematic cases, like for when untranslated strings > > are transmitted to other modules, for being translated there, or even > > maybe for plain doc strings. > But this isn't a python-specific problem, is it? You'd have similar > problems with C-libraries, or with passing such strings from say a > third-party plugin to the main program. I was not thinking of Python specifically, but I was not thinking C either, where the above problem does not exist in practice. In bash, say, it is sufficient to have a stack of textual domains, when getting in or out of nested scripts, but this is already implemented through forking. Sourcing may cause some uncertainty, especially in the context of shell functions. Problems arise when languages have purely dynamic scoping, because textual domains are lexically scoped by intent. I did internationalize a rather big Scheme program already, but it was all within a single textual domain, so I did not hit any wall there. But I would guess that Scheme is much simpler than Emacs LISP, in actual practice -- I'm not sure. Python should be simple as well. Yet, after the XEmacs internationalisation failure, one good lesson, that we would be foolish to not retain, is that we should take time to think things out, before starting to think too big. > For doc-strings you could probably get away with a global variable. It is not clear to me how doc strings are used in Python. Some people were kind enough to reply to one question in a previous thread of this mailing list, but I still have some study to do before I understand all the replies. As this area is a bit fuzzy to me, I would fear some oversight if we were ignoring them too soon... Thanks a lot, Bernhard, for having taken the time to share your thoughts! -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From python-list at teleo.net Fri Sep 24 13:20:49 1999 From: python-list at teleo.net (Patrick Phalen) Date: Fri, 24 Sep 1999 10:20:49 -0700 Subject: SIGCHLD, fork, listen References: <37EC1ACA.8963554B@hk.rfa.org> Message-ID: <99092410263106.00548@quadra.teleo.net> On Fri, 24 Sep 1999, Bill Eldridge wrote: > Another option would be to use inetd, but I need to > do some host/address verification, and couldn't figure > out how to latch onto that kind of socket info from > a new spawned inetd handler using Python. Ideas? Consider using Dan Bernstein's open source tcpserver/tcpclient suite, a reliable replacement for inetd. It also has tcpwrapper-style access control features. ftp://koobera.math.uic.edu/www/ucspi-tcp.html From balance_is_healthy at my-deja.com Tue Sep 28 06:03:39 1999 From: balance_is_healthy at my-deja.com (balance_is_healthy at my-deja.com) Date: Tue, 28 Sep 1999 10:03:39 GMT Subject: where did www.python.org go ? Message-ID: <7sq3pn$sbj$1@nnrp1.deja.com> Hi where did... go ? have they moved ? other advices on recources are welcomed. No files please. thanks Henrik Sent via Deja.com http://www.deja.com/ Before you buy. From peter.stoehr at sdm.de Mon Sep 13 07:12:05 1999 From: peter.stoehr at sdm.de (Peter Stoehr) Date: Mon, 13 Sep 1999 13:12:05 +0200 Subject: Announcing: A Python Curses-Based Telnet Client References: Message-ID: <37DCDC05.8E25CCBE@sdm.de> Hi Moshe, it would be great if you can send me a copy of your "Python Cursed-Based Telent Client". Thanks in advance Peter Moshe Zadka schrieb: > > Is now available. > > I don't have any good public place to put it yet, so > mail me if you're interested. > > -- > Moshe Zadka . > INTERNET: Learn what you know. > Share what you don't. -- Dr. Peter Stoehr mailto:peter.stoehr at sdm.de sd&m AG http://www.sdm.de software design & management Thomas-Dehler-Strasse 27, D-81737 Muenchen, Germany Tel ++49 89 63812-783, Fax -444 From banderson at boi.hp.com Wed Sep 15 13:50:58 1999 From: banderson at boi.hp.com (Bill Anderson) Date: Wed, 15 Sep 1999 11:50:58 -0600 Subject: How to sell Python to your boss? References: <7qn667$e30$1@nnrp1.deja.com> Message-ID: <37DFDC82.5D263234@boi.hp.com> randall_burns_hp at my-deja.com wrote: > > In article , > Petri Mikael Kuittinen > wrote: > > I have lots of programming experience in C, and > >much less in Python. Despite this I am confident > >that I would be able to implement > > the prototype using Python many times faster > >than using C. > Well, I agree that you are representative of a > big constituency out there. We've been making > substantial use of Python at HP/Cupertino and our > experience so far indicates that Python can be > used to develop programs rapidly that can be > maintained easily. Some of us, a growing number in fact, are using Python extensively at teh Boise site as well. :-) > So far, one of our biggest issues has been finding > developers enthusiastic about developing in > Python. I've seen lots of folks who are rather > pessimistic about Python's future(my current boss > is not among them). > > If anyone would like to talk to me about Python > opportunities at HP/Cupertino, I'd be happy > to speak with them(we are doing some substantial > e-commerce applications in Python). Are you using Zope for any of it? -- Bill Anderson Linux/Unix Administrator, Security Analyst ESBU (ARC) banderson at boi.hp.com My opinions are just that; _my_ opinions. From mgr at propack-data.com Fri Sep 3 03:48:38 1999 From: mgr at propack-data.com (Matthias Grutzeck) Date: Fri, 03 Sep 1999 09:48:38 +0200 Subject: getpass.getpass() bugged? References: <7qm5q0$lct$1@nnrp1.deja.com> Message-ID: <37CF7D56.C8E2175F@propack-data.com> super_banane at yahoo.com wrote: > >>> import getpass > >>> getpass.getpass() > Password: hello > 'hello' > >>> Without assigning the returnvalue to a variable the interpreter will show you the result of the call. If you have a look at the my example, you will see the behaviour... Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import getpass >>> getpass.getpass() Password: 'hello' >>> s=getpass.getpass() Password: >>> print s hello >>> Hope that helps Matthias -- Matthias Grutzeck Fon. +49 (721) 9650 6 Propack Data GmbH Fax. +49 (721) 9650 888 Vincenz-Prie?nitz-Str. 1 eMail: mgr at propack-data.com D-76131 Karlsruhe / Germany info: http://www.propack-data.com/ From thomas at bibsyst.no Wed Sep 29 06:05:23 1999 From: thomas at bibsyst.no (Thomas Weholt) Date: Wed, 29 Sep 1999 10:05:23 GMT Subject: What GUI-lib to use References: <37F1D710.47A82D23@bibsyst.no> <00a301bf0a5b$b0acce80$f29b12c2@secret.pythonware.com> Message-ID: <37F1E463.6ABD1DE6@bibsyst.no> Fredrik Lundh wrote: > > Thomas Weholt wrote: > > Could Tk get a more modern look perhaps and solve all our problems? > > maybe, but that depends on what "more > modern look" means. > More like Gtk and KDE. Hotbuttons, themes and all the other crap stolen from Windows. One of my points is that it`s easier to "sell" programs/scripts with a modern look, even if they`re free. If anybody can point me to a page showing off Tk-based apps. that don`t look aged/out-dated, I`d be more than happy to check it out. I don`t mean to offend any die-hard Tk-users, I`d love to use a library that`s well supported in Python and as a whole, as Tk seem to be, but I still want to make nice looking apps too. Thomas Weholt From culliton at clark.net Fri Sep 10 10:02:37 1999 From: culliton at clark.net (Tom Culliton) Date: Fri, 10 Sep 1999 14:02:37 GMT Subject: Programmers Editor References: <37D5916B.606E@zeusedit.com> <00da01bef9e0$6e1b5c70$f29b12c2@secret.pythonware.com> <3dg10p1b5j.fsf@amarok.cnri.reston.va.us> Message-ID: <1c8C3.1288$Ym5.38497@iad-read.news.verio.net> In article , Stephan Houben wrote: >On 08 Sep 1999 15:00:24 -0400, Andrew M. Kuchling > wrote: >>Anyway, if someone wanted to >>contribute info on editing Python with Zeus, KDevelop, or whatever, it >>would be very helpful. Just follow up to this posting with notes on >>configuring your editor of choice. > >JED is a very nice editor. It comes with Python support right out >of the box. I actually didn't need anything to configure to work >comfortably with it. (OK I chose another colour scheme in the menu.) > >But make sure you get the latest version (0.98). >0.97 comes with some older Linux distributions (in my case, RH 6.0), >but is much less nice. The latest stable version is actually 0.98-7 available from: ftp://space.mit.edu/pub/davis/jed/v0.98/ The LATEST version is B0.99-8 which despite being called a "beta" version is at least as stable as 0.98-7 and has even nicer Python support. It is available from: ftp://space.mit.edu/pub/davis/jed/v0.99/ >It is also much more light-weight then Emacs. But then again, there's >no kitchen-sink built-in. If Emacs is the editor equivalent of T-Rex, then Jed is Velacoraptor. Smaller, quicker, more agile, and just as deadly. I'd hate to have to live without an emacs like editor, but living with full blown emacs is another nightmare altogether. I'm actually using it (GNU Emacs) to compose this message since my ISP doesn't have a decent version of Jed installed. When there's any load on the machine, it burps, and farts, and garbage collects, and auto saves, and freezes for long stretches. Not due to code bugs, but just because it's so bloated that it can't get enough cpu or memory. Jed by contrast is about 1/4 the size in memory, uses about 1/2 to 1/4 the amount of CPU for an equivalent editting task, and in places where Emacs is painfully sluggish, Jed is peppy and fast. I guess you could call me a fan... ;-) From conversy at lri.fr Thu Sep 2 05:49:22 1999 From: conversy at lri.fr (Stephane Conversy) Date: Thu, 02 Sep 1999 11:49:22 +0200 Subject: Tkinter and window manager References: <37CA844C.AE3F285@lri.fr> <038801bef459$434bcb60$f29b12c2@secret.pythonware.com> <37CCEF04.72D60C8@lri.fr> Message-ID: <37CE4822.56E93593@lri.fr> there are two things: First: I want to be notified when a document window is raised on top of the windows stack. Looking the Xlib and tk doc, we can see that a event is triggered when XRaiseWindow() is called (which I think is called by the window manager when one clicks on the bar). The problem is that when I bind a toplevel to I don't receive any events. Second: The palette must stay on top of the other window. I think I can do that by calling tkraise on the palette window each time a document window is raised. So the problem is: How to catch that a document window has been raised ? Thinking about it a little bit more, and after I saw that this little script in tk doesn't work: toplevel .t proc toto {} { puts "yep" } bind .t toto that is, it soesn't write "yep" when the toplevel is raised, I guess it's a reparent problem, because it's the window created by the wm that receives ... stef > True, but one a FocusIn event, you could make palette rise above the > other windows. > def coconut_dropped(self, event): > event.widget.tkraise() > > But if you are asking "how can I have one window affect the widgets > in another window?" That's is much more of a design issue. I would > suggest having an "application" object which abstracts what you need > done and calling methods on that object from the palette. > > class DrawApp: > def __init__(self, *args): > self.process_arguments(args) > self.current_operation = 'pointer' > def change_to_pen(self): > self.current_operation = 'drawWithPen' > def change_to_brush(self): > self.current_operation = 'drawWithBrush' > def start_polygon(self): > self.current_operation = 'drawPolygon' > self.operation_data = [] > self.op_state = 'waitingForFirstPoint' > ... > > This makes the palette definition seperate from the implimentation of > the canvas operations. > > This approach can also work with multiwindow focus: the palette affects > the last/current window (different "DrawApp" objects) with the focus. > > -Arcege -- St?phane Conversy http://www-ihm.lri.fr/~conversy/ mailto:conversy at lri.fr From holger at phoenix-edv.netzservice.de Thu Sep 16 07:04:48 1999 From: holger at phoenix-edv.netzservice.de (Holger Jannsen) Date: Thu, 16 Sep 1999 11:04:48 GMT Subject: timesync with python? References: <37D66AF3.6A3E96F7@phoenix-edv.netzservice.de> <002701befabb$1a884880$f29b12c2@secret.pythonware.com> Message-ID: <37E0CED0.8F00D422@phoenix-edv.netzservice.de> High, another question I couldn't solve: I'm searching for a function to set local time, but couldn't find it in description of module 'time' neither other documentations. Any hints? Thanx, Holger From marshall.taylorNOcpSPAM at beenz.com Thu Sep 9 18:26:15 1999 From: marshall.taylorNOcpSPAM at beenz.com (Marshall T.) Date: Thu, 09 Sep 1999 15:26:15 -0700 Subject: Module to open URLs that set cookies? Message-ID: <15d84bec.887c3642@usw-ex0107-051.remarq.com> Hello, I would like to know how to write an http client that will accept cookies when opening webpages. I'm attempting to write a module that open a page and note the latency in doing so. I've been successful in doing this with the sockets and urllib library modules, but have been foiled by pages that set cookies. Is there a canned library for doing this in Python? Thanks for your time, Marshall T. * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From davidopp at megsinet.net Thu Sep 2 03:24:59 1999 From: davidopp at megsinet.net (David Oppenheimer) Date: Thu, 02 Sep 1999 03:24:59 -0400 Subject: Bring Out Yer Dead Message-ID: <37CE2648.D4254FCC@megsinet.net> I am going to give up on trying to get the PIL to work with Pythonwin 1.5.2 unless someone who has it working with their setup can give me explicit instructions on how to do this. I am unable to implement Robert Kern's instructions due to the fact that I cannot get my Win Zip program to unzip the tar.gz file format. So ... time for me to put PIL for Pythonwin 1.5.2 on the pile of software corpses and set it ablaze. Can you feel the heat?! Anyone have any marshmallows? David O. From phd at emerald.netskate.ru Sun Sep 12 07:07:36 1999 From: phd at emerald.netskate.ru (Oleg Broytmann) Date: Sun, 12 Sep 1999 15:07:36 +0400 (MSD) Subject: Problem installing PyGresql in Python 1.5.2-2 on RH 5.0 In-Reply-To: <1103_937113988@ns1.dicksonstreet.com> Message-ID: On Sun, 12 Sep 1999, Felix Thibault wrote: > I copied pgmodule.c into my config directory (that is:/usr/local/lib/python1.5/config/) and added a line to Setup, but when I did 'make Makefile.pre.in', judging from > the output and 'ps' in another virtual terminal 'make do-it-again' (from Makefile.pre.in) just kept making itself over and over. I tried just make'ing the Makefile after I > killed it, but that looped, too. I tried a couple of other things but I always had to kill it while it was making 'do-it-again'? > I think I installed Tkinter the same way (except I only had to uncomment the lines in Setup, they were already there) without a similiar problem. > > Does this sound familiar to anyone? > (the line I added to Setup is : _pg pgmodule.c -I/usr/include/pgsql -L/usr/lib -lpq ) After adding the line do "cd ..; make" - just make, not make Makefile.pre.in. > Thanks in advance- > Felix Oleg. ---- Oleg Broytmann Netskate/Inter.Net.Ru phd at emerald.netskate.ru Programmers don't die, they just GOSUB without RETURN. From mal at lemburg.com Fri Sep 3 10:46:36 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 03 Sep 1999 16:46:36 +0200 Subject: UK Python Programming Job Opportunity References: <7qof8u$mh2$1@newsreader1.core.theplanet.net> Message-ID: <37CFDF4C.1D96A89A@lemburg.com> John Parkey wrote: > > If there is anybody who is interested in a 6-9 month contract using Python, > in Bucks UK, please drop me a line. > > jparkey at rapidbs.com > > (I hope nobody is offended by my posting this to the newsgroup?) I hope we get more and more of these postings :-) -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 123 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From gtnorton at my-deja.com Fri Sep 3 15:47:10 1999 From: gtnorton at my-deja.com (gtnorton at my-deja.com) Date: Fri, 03 Sep 1999 19:47:10 GMT Subject: Any trouble with Tcl/Tk 8.2 ? References: <7qn33a$c2m$1@nnrp1.deja.com> <7qo8q5$oqmb@eGroups.com> Message-ID: <7qp8jp$tvf$1@nnrp1.deja.com> In article <7qo8q5$oqmb at eGroups.com>, john.grayson at gsc.gte.com wrote: > john.grayso- at gsc.gte.com wrote: > original article:http://www.egroups.com/group/python-list/?start=66500 > > I was looking to download the new Tcl/Tk 8.2 > > Anyone aware of any bugs or problems with it when used with Python? > > Is it worth it?, or should I just stick with the Tcl/Tk 8.0 that came > > with Python. > > Thanks, > > gtnorton > Stick with 8.0.5 for the moment. I've have problems trying to use > 8.1 and 8.2 and I have not had time to investigate further. I believe > that Guido has seen these problems already... > > john > > ********THANKS, JOHN******** Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From akuchlin at mems-exchange.org Wed Sep 8 14:20:38 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 08 Sep 1999 14:20:38 -0400 Subject: Feast or famine! References: Message-ID: <3dk8q11czt.fsf@amarok.cnri.reston.va.us> init__self at my-deja.com (Python Addict) writes: > - Python Reference Manual; February 19, 1999, Release 1.5.2 > Guido Van Rossum, Fred L., Jr. Drake > ISBN: 1583483748 > (What's all this then? No piccie on Amazon.com or description) Looks like the online manual, typeset and bound by the company behind www.toexcel.com. Other titles available, like the reference manual and tutorial, are listed at http://www.toexcel.com/bookstore/author.asp?author%5Fid=1436 . (I assume you arranged this, Guido?) Time to start a Python shelf, I guess. -- A.M. Kuchling http://starship.python.net/crew/amk/ Dreams are tricky buggers. You can't trust them. -- Hob Gadling, in SANDMAN #59: "The Kindly Ones:3" From fredrik at pythonware.com Tue Sep 7 07:12:07 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 7 Sep 1999 11:12:07 GMT Subject: [Newbie] Win95 Python 1.5.2 with Tk, not recognised References: <7r2o30$nb1$1@bunyip.cc.uq.edu.au> Message-ID: <01ff01bef921$d3a4ea30$f29b12c2@secret.pythonware.com> > I had to comment out the reference to mousewheel event in listbox.tcl and > textbox.tcl to get Tkinter() to work. Why? The download came from 1.5.2 from > the python.org site with Tcl8.0. The error message raised was that > mousewheel event was not recognised. version mismatch; for more info, see: http://www.pythonware.com/people/fredrik/fyi/fyi02.htm From nharlow at my-deja.com Thu Sep 2 14:02:25 1999 From: nharlow at my-deja.com (nharlow at my-deja.com) Date: Thu, 02 Sep 1999 18:02:25 GMT Subject: Generating an event in Tkinter References: <7qfc5l$mll$1@nnrp1.deja.com> <011701bef37e$bcd9ece0$f29b12c2@secret.pythonware.com> <7qhl27$cgp$1@nnrp1.deja.com> <022101bef44f$8e98b9c0$f29b12c2@secret.pythonware.com> <7qk0ci$3m9$1@nnrp1.deja.com> <014801bef523$808828a0$f29b12c2@secret.pythonware.com> Message-ID: <7qme39$s4a$1@nnrp1.deja.com> Thank you so much for all your help. It was the widget.update() that did it for me. Thanks. I look forward to seeing your Tkinter book from O'Reilly. Nick Harlow In article <014801bef523$808828a0$f29b12c2 at secret.pythonware.com>, "Fredrik Lundh" wrote: > wrote: > > import time > > name="Analyze" > > while i< 100: > > print "%s: This is %s time through the loop"%(name,i+1) > > widget.event_generate("<>") > > widget.bind("<>", lambda e, y=1, x=time.sleep: x(y)) > > i=i+1 > > > It just locks up; I don't even get any errors. > > no errors at all? not even some- > thing like: > > Traceback (innermost last): > File "example.py", line 3, in ? > while i< 100: > NameError: i > > ??? > > if I set "i" to 0, and create a widget, > your program works just fine. or in > other words, the loop will now send > 100 events to the widget, which, > whenever it gets around to check > the event queue, will block for > one second per event. > > the following version increases the > chance that the widget actually gets > around to process your event: > > from Tkinter import * > import time > > widget = Tk() > widget.bind("<>", lambda e, y=1, x=time.sleep: x(y)) > > name="Analyze" > > for i in range(100): > print "%s: This is %s time through the loop"%(name,i+1) > widget.event_generate("<>") > widget.update() # process events > > mainloop() > > btw, I think you might be better off using a > timer [1], but that's me... > > > > 1) http://www.pythonware.com/library/tkinter/introduction/basic- widget-methods.htm > => alarm handlers and other non-event callbacks > > Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From gerrit.holl at pobox.com Sat Sep 11 10:35:30 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Sat, 11 Sep 1999 16:35:30 +0200 Subject: whrandom.randint(): no LONGs? Message-ID: <19990911163530.A11476@optiplex.palga.uucp> Hello, whrandom.randint() always try to convert the given arguments to a integer. Why? I'm not able to use Longs now. I don't require it directly, but it might be a useful thing to know the "why". I can learn from it... regards, Gerrit. -- Unix is easy: type 'man man' and the rest comes of itself. From ransen at nemo.it Tue Sep 7 18:13:43 1999 From: ransen at nemo.it (Owen F. Ransen) Date: Tue, 07 Sep 1999 22:13:43 GMT Subject: Embedding Python into an MFC app - thread problems. References: <7pv1jd$gmd@newsops.execpc.com> Message-ID: <37d78aef.6768198@news.newsguy.com> On Tue, 24 Aug 1999 16:16:44 -0500, "John DeFord" wrote: >I've embedded Python + win32 extensions into my MFC app with the following >code scrap in my app's InitInstance member (taken from Pythonwin embedding >documentation): >John Er, where did you get the Pythonwin embedding documentation? I've got the DrDobbs Python Resource CD-ROM and can find no real help in embedding Python in Windows apps. Any pointers much appreciated... TIA Owen -------------------------------------------------- Owen F Ransen ransen at nemo.it http://www.ransen.com the home of Repligator Winner SIAF awards - Best Graphics Program of 1999 From tim_one at email.msn.com Sun Sep 19 18:58:44 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 19 Sep 1999 18:58:44 -0400 Subject: Lazy file.readlines()? In-Reply-To: <87emfzmzor.fsf@slip-32-101-160-116.ma.us.ibm.net> Message-ID: <000601bf02f2$85f30260$102d153f@tim> [meow, about his or her qio module at http://members.xoom.com/meowing/python/ ] > ... > Also added some convenience features like user-specified line > terminators, automatic chopping, and a way to read SMTP-like sockets > wicked fast. Yes, qio.readline() is about the most frightening function in the Python universe now . > After adding the requisite bloat, vanilla qio.readline() is still > about 5-8 times as fast as native Python looping through big text > files (where stdio is glibc's). I compiled it for Win32 (btw, "mode_t" was not defined, & there are about a half dozen warnings about mixing signed and unsigned ints), with optimization cranked up. Under Win95 it was between 2-3 times as fast as 1.5.2 Python doing a native readline() loop over an 11Mb text file. It's hard to believe that MS's grudging implementation of stdio is that much better than glibc's, so not sure what to make of this -- possibly that *nothing* can run really fast under Windows <0.9 wink>. > ... > Details at Nice work! if-only-windows-had-any-text-files<0.7-wink>-ly y'rs - tim From englim at pc.jaring.my Wed Sep 8 00:13:20 1999 From: englim at pc.jaring.my (lec) Date: Wed, 08 Sep 1999 12:13:20 +0800 Subject: Bug in time module? Message-ID: <37D5E25F.1F7F0A74@pc.jaring.my> Is this considered a bug since there is no Feb 31, 1999 or Feb 29, 1999? >>> import time >>> time.strptime('31/02/1999', "%d/%m/%Y") (1999, 2, 31, 0, 0, 0, 2, 62, 0) >>> time.asctime(time.strptime('31/02/1999', "%d/%m/%Y")) 'Wed Feb 31 00:00:00 1999' >>> time.strptime('29/02/1999', "%d/%m/%Y") (1999, 2, 29, 0, 0, 0, 0, 60, 0) >>> time.asctime(time.strptime('29/02/1999', "%d/%m/%Y")) 'Mon Feb 29 00:00:00 1999' From da at ski.org Wed Sep 29 13:01:00 1999 From: da at ski.org (David Ascher) Date: Wed, 29 Sep 1999 10:01:00 -0700 (Pacific Daylight Time) Subject: Is togl missing from PyOpenGL binary? In-Reply-To: Message-ID: On Wed, 29 Sep 1999, Olaf Delgado wrote: > Hi folks! > > I have installed Python 1.5.2 and PyOpenGL 1.5.5 (I think) in binary form > on my Windows box. Now many of the example programs require togl (and I > would like to use it too), but tcl (I have installed the tcl version that > came with python) complains it can't find it. Searching for togl.* didn't > reveal anything, so I'm pretty sure there is no dll anywhere. I suppose > none of the binaries (which I got from the standard places pointed to at > www.python.org) have not been compiled with togl either. Can the people > who have kindly provided the binaries confirm this? Does anyone have a > togl.dll handy? I think it should be in the binary distribution anyway, > unless, of course, there are important reasons to exclude it. It is in the installer, but the installer fails sometimes for unexplained reasons. I've just put a page describing how to fix this manually at: http://starship.python.net:9673/crew/da/Code/PyOpenGL/Togl Good luck. can't-wait-for-distutils-to-do-that-job'ly yours, david From Marcus.Bergmann at isst.berlin.fhg.de Wed Sep 15 06:07:49 1999 From: Marcus.Bergmann at isst.berlin.fhg.de (Marcus Bergmann; isst.fhg.de) Date: Wed, 15 Sep 1999 12:07:49 +0200 Subject: make test fails Message-ID: <37DF6FF5.625B8F96@isst.berlin.fhg.de> Hi, i've got trouble during the installation of Python 1.5.2. I configured with "./configure --prefix=/opt/PYTHON-1.5.2 --with-gcc --with-threads". Then i did run "make". Both worked fine. But "make test" fails with "test_popen2". The OS ist Solaris 2.6 on a Sun Ultra2. Who can help me out? Thanks -- Mit freundlichen Gr??en Marcus Bergmann ISST | Telefon : 030/24306-463 Bereich- | Telefax : 030/24306-599 Mollstr. 1 | E-Mail : Marcus.Bergmann at isst.fhg.de 10178 Berlin | DFN-Mail : G=Marcus;S=Bergmann;O=ISST;P=FHG;A=D400;C=de From mwh21 at cam.ac.uk Thu Sep 2 05:55:38 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 02 Sep 1999 10:55:38 +0100 Subject: adding to dictionaries References: <37CE4626.8FCEA15B@xsoft.co.at> Message-ID: "Gerhard W. Gruber" writes: > Is it possible to add an entry to an already existing dictioniary? Umm... yes? d={1:2} d[2]=3 d[2] => 3 although I can't help thinking that's not what you're asking... confused-ly y'rs, Michael From algaba at my-deja.com Sat Sep 18 04:58:00 1999 From: algaba at my-deja.com (Manuel Gutierrez Algaba) Date: Sat, 18 Sep 1999 08:58:00 GMT Subject: TCL code producing python code Message-ID: <7rvk6m$nt6$1@nnrp1.deja.com> Usually there're flame wars between TCL and python. Today I've found a nice way of working together to get the easiest. I use my consdiag to generate lots of classes. The problem is that I have to write a lot of python code. But using TCL is much easier, for example this code: #!/usr/bin/tcl proc escribe {t} { puts $t } proc escribenonl {t} { puts -nonewline $t } proc escribecoma {t} { puts "$t," } proc gensimple {t modulo clase atributos} { escribe "def genera_$t\(con_atributos =None, con_funciones=None):" escribe "\tc = a_simple_class()" escribe "\tc.do_name_clase($modulo.$clase.__name__)" escribenonl "\tc.do_attributes(\[" foreach i $atributos { escribecoma "\'$i\'" } escribe "\])" escribe "\tif not con_funciones is None:" escribe "\t\tc.do_functions\($modulo.$clase\)" escribe "\tc.do_lines\(\)" escribe "\treturn c" } escribe "from consdiag import * import dibcla import nucleo import serv_sok" gensimple nucleo nucleo nucleo [list puerto_clips puerto_visualizador \ temporizador mapa_X mapaY] proc genera_acceso { t n} { escribe "\tv=genera_$t\(\)" escribe "\tv.generate_latex_code\(\'result$n.tex\'\)" } escribe "def genera_fic():" genera_acceso nucleo 1 escribe "if __name__=='__main__': \tgenera_fic() " Produces a bit of : from consdiag import * import dibcla import nucleo import serv_sok def genera_nucleo(con_atributos = None, con_funciones = None): c = a_simple_class() c.do_name_clase(nucleo.nucleo.__name__) c.do_attributes(['puerto_clips', 'puerto_visualizador', 'temporizador', 'mapa_X', 'mapa_Y', 'mapa_Z', 'periodo_actualizacion_mapa', 'dimensiones', 'turnador', 'interprete', 'maximo_ciclos', 'dicc_jugadores']) if not con_funciones is None: c.do_functions(nucleo.nucleo) c.do_lines() return c def genera_servidor_de_socket(con_atributos = None, con_funciones = None): c = a_simple_class() c.do_name_clase(serv_sok.servidor_de_socket.__name__) c.do_attributes(['funcion_a_ejecutar', 'tiempo', 'conn']) if not con_funciones is None: c.do_functions(serv_sok.servidor_de_socket) c.do_lines() return c def genera_asociacion_nucleo_servidor_de_sockets(): n = genera_nucleo() g = genera_servidor_de_socket() e = union_association() e.add_union(n, g, "1:1", "1:1") return e def genera_fic(): t = genera_nucleo() t.generate_latex_code('result1.tex') t = genera_asociacion_nucleo_servidor_de_sockets() t.generate_latex_code('result2.tex') if __name__=='__main__': genera_fic() I think that this way of producing python code by TCL will save me some hundreds lines. I hope this may be useful for anyone else. -- ------------- Manolo Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From clement at ans.com.au Thu Sep 23 09:10:23 1999 From: clement at ans.com.au (Clement) Date: Thu, 23 Sep 1999 23:10:23 +1000 Subject: Python and Postscript Message-ID: <37EA26BF.63766B3C@ans.com.au> Hi, Does anyone know of tools to print forms on a postscript printer in Python? -- Regards Clement From adjih at crepuscule.com Wed Sep 22 09:35:55 1999 From: adjih at crepuscule.com (Cedric Adjih) Date: 22 Sep 1999 13:35:55 GMT Subject: Linux Dependencies! Grrr...What now? References: <37E8066F.1C13BF33@alliedsignal.com> Message-ID: <7salvr$6du$1@ites.inria.fr> H. P. Friedrichs <" HPeter.Friedrichs"@alliedsignal.com> wrote: > While I have having successfully written some scripts for python 1.4 (on > my rh5.0 linux box), and successfully installing mysql, I have been > trying for a week to figure out how to get the mysqldb module to work > (to allow python to talk to mysql). > First, I found out that mysqldb will only work with python 1.5.2...which > necessitated an upgrade. Dependencies! Dependencies! I ended up > installing python, python-devel, blt, tix _tkinter and tkinter. (I've > been warned that as the result of my upgrade, I have now "broken" > netcfg, but I'll deal with that on another day.) > Now I go to install mysqldb, and it complains, among other things, of > missing files and directories. Looks like I need mysql-devel. > Dependencies! Dependencies! > I go to the web and find it. I try to install the rpm, and it won't. It > seems I need glibc6 (2.0 and 2.1). But what about everything compiled > with the existing library? What happens if I "upgrade" to glibc6? What > do I risk breaking by doing that? I don't know. Installing newer libraries on a older system seems prone to lead to upgrade escalation. The only solution I found pratical is to have a /usr/local or /home//External, and to recompile every development tool/library that doesn't work out of the box with --prefix=/home//External (gtk, glib, swig, wxWindows, PIL, wxgtk...), and some proper LD_LIBRARY_PATH/PATH settings. If it is possible, just take the source rpms, extract them, and try to compile manually. Sorry I can't help more. -- Cedric From cors at recercai.com Wed Sep 8 16:42:45 1999 From: cors at recercai.com (Carlos Ors) Date: Wed, 8 Sep 1999 22:42:45 +0200 Subject: how can I implement a java interface with a jpython class? Message-ID: <37d67617.0@sahara.cablecat.com> I'm working with python embedded in java (I'm just working with PythonInterpreter java class). I have a java interface and I want to implement it with a python class. How can I do it? Where can I find documentation/exemples about all classes that are there in org.python.core? Thank you in advance! Please, answer me (if you can) to karlos at softhome.net From bthomas at trey-industries.com Mon Sep 13 13:36:39 1999 From: bthomas at trey-industries.com (Ben Thomas) Date: Mon, 13 Sep 1999 17:36:39 GMT Subject: Python or Java or "X" from me and my little job References: <37DA8D01.3D6616A@trey-industries.com> Message-ID: <37DD356F.86D56591@trey-industries.com> Actually I just want to 1)get current date and come up with its string like: 01251999 2)zip some files and name the archive 01251999 3)ftp the archive off site this is my first task but I know there will be others. It isn't hard to code I am just new to Python. Ben "Magnus L. Hetland" wrote: > Ben writes: > > > I am new to Linux. I have Python 1.5.2 up and working. I want to have > > Python grab some files, ZIP them, and FTP them offsite. I will let CRON > > start the job every night. Since I am just getting to look at Python, I > > wanted to ask to make sure I don't pick the wrong tool for the job. > > > > > > 1)Am I selelcting a good tool to get light weight sys admin jobs done? > > Well... If it is a light weight sysadmin-job, maybe a simple shell > script would do it? (Then you could move it to Python if it grew...) > > I mean - if the set of files is fixed (or given as a command-line > argument) I guess this thing you are talking about could be done in > two lines in any standard shell (assuming that you have a good ftp > client like ncftp.) > > -- > > Magnus > Lie Please forward all spam to > Hetland uce at ftc.org From bwarsaw at python.org Thu Sep 16 13:14:05 1999 From: bwarsaw at python.org (bwarsaw at python.org) Date: Thu, 16 Sep 1999 13:14:05 -0400 (EDT) Subject: Marking translatable strings References: Message-ID: <14305.9565.35913.349267@anthem.cnri.reston.va.us> >>>>> writes: > I had a real strange idea :-). I first quickly dismiss it, but > it is so simple that I prefer to ponder it again, and share and > debate it a little first, maybe. Not so strange! There's a big push to internationalize Mailman and I've promised it as an important goal for the next release. Unfortunately I haven't had much time to work on Mailman lately so my few tentative steps haven't even made it into the CVS tree yet. There's been discussion on the mailman-developers at python.org list and you can peruse the archives for much of the current thinking. Sorry I don't have time to give exact URLs but the archives are available at: http://www.python.org/pipermail/mailman-developers Just a few quick comments, and then a pointer to some code... > Python has no preprocessing, no special string syntax for > markability, and moreover, it has doc strings! So, at first > glance, it looks difficult. The first attempts in the Mailman community for marking strings followed the reasoning you did. I don't like it because I want to be able to use any string spelling as translatable strings. Anything else would be way to error prone in a project that has so many hands on it. I considered lobbying Guido for another string prefix, say i"..." to mark translatable strings, but decided against that for a number of reasons. The approach I think I will take is one that you also suggested, using _("text") as the marker for translatable strings. This has the advantage that `_' is a perfectly good name for a function, which could be the identity function if, say the end user doesn't have the I18N stuff installed on their system. But it could also easily be the name of the function that does the string lookup, returning the translated string. Yes _ has the disadvantage of already having meaning in interactive mode, but I wasn't too concerned about that (maybe I'm being naive tho', as I mentioned I haven't really gotten /that/ far yet). If it's a problem __("text") would be fine (double underscore). What I /have/ done is start work on a pygettext.py script that is in the spirit of GNU gettext. Instead it knows a lot about Python syntax, including the 9 billion ways to spell `string'. pygettext uses Python's standard tokenize module to scan through a file of Python code, search for _(text) matches, where text is any of 'text', "text", '''text''', etc. The output is pretty close to .po style, with strings normalized to .po format. The output formatter may still have some bugs in it. Since I don't envision much time to hack on this in the near future, I'll just go ahead and post the code on my pyware page: http://www.python.org/~bwarsaw/software/pyware.html Give me about 10 minutes and then feel free to grab it. I'd love to get any comments or patches that you might come up with. -Barry From warren at nightwares.com Wed Sep 8 04:51:46 1999 From: warren at nightwares.com (Warren 'The Howdy Man' Ockrassa) Date: Wed, 08 Sep 1999 03:51:46 -0500 Subject: And now for something completely boneheaded... Message-ID: <37D623A2.DC09F0CC@nightwares.com> It's... the obvious question of the day. Or perhaps the hour. So I have import sys >From that how can I find out what sys can do? I have tried things like sys.methods and sys.functions and sys.* and even, in a moment of extreme desperation sys.incest and we won't talk any more about that. I have received no joy in response. So with a given module, once imported, what is the way by which I can find out what's defined in the module and, ideally, how to access it? What is the obvious which I am missing? TIA! -- warren ockrassa | nightwares | mailto:warren at nightwares.com http://www.nightwares.com/ From kaine_the_bloody at my-deja.com Thu Sep 9 19:33:36 1999 From: kaine_the_bloody at my-deja.com (Kaine) Date: Thu, 09 Sep 1999 23:33:36 GMT Subject: WYSIWYG GUI maker V - Guido References: <37D5AA97.2C4BF97D@megsinet.net> Message-ID: <7r9g4g$803$1@nnrp1.deja.com> In article <37D5AA97.2C4BF97D at megsinet.net>, David Oppenheimer wrote: > Dear Group, > > Looking for input here. What kinds of features and functionalities > would you want to have in a WYSIWYG GUI maker? > > Thanks, > > David O. > > Component based architecture. This could be corba objects. Drag and drop. The class library should be extensible. A good editor would be nice or integration with EMACS. A class browser. A project manager. Basically just copy Delphi's IDE. :) Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From aahz at netcom.com Thu Sep 16 00:44:24 1999 From: aahz at netcom.com (Aahz Maruch) Date: 16 Sep 1999 04:44:24 GMT Subject: high school programming & python References: <37DFED78.6B258366@bioreason.com> Message-ID: <7rpsj8$sqt@dfw-ixnews6.ix.netcom.com> In article , James Whitley Moore wrote: > >Why not end this thread in the usual way? >I never wanted to be a high-level language programmer. >I always wanted to be. . . Oh, I'm a programmer and I'm OK I code all night and I sleep all day -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From kern at caltech.edu Sat Sep 25 03:27:10 1999 From: kern at caltech.edu (Robert Kern) Date: Sat, 25 Sep 1999 00:27:10 -0700 Subject: CygWin version References: <37EC7864.73882599@caltech.edu> Message-ID: <37EC794E.AEB55676@caltech.edu> Pardon the last post. It was from me (Robert Kern). Serves me right for using the computer lab to read USENET. Duf wrote: No, I wrote. > Sorry for piggybacking. > Posted and e-mailed. Umm... I don't seem to have things configured right on my end. The e-mail didn't go through. :-( [etc.] > -- > Robert Kern > kern at caltech.edu Ditto. From amk at mira.erols.com Mon Sep 6 16:38:30 1999 From: amk at mira.erols.com (A.M. Kuchling) Date: 6 Sep 1999 20:38:30 GMT Subject: how often does re.compile compile? References: <7r1451$3n7$1@nnrp1.deja.com> Message-ID: On Mon, 06 Sep 1999 19:20:08 GMT, wade at lightlink.com wrote: >only within one function. If I say re.compile() inside the function >definition, does the pattern get compiled afresh every time the function >is called? Maybe. There's a cache containing the most recent 20-odd patterns, so if you're using fewer patterns, the re.compile() will do a dictionary lookup, find the precompiled cached pattern, and just return it without doing any more work, but the common idiom is to precompile them yourself. -- A.M. Kuchling http://starship.python.net/crew/amk/ Actors... I don't like actors. It's a profession based on lies and disrespect. Pretending to be what you are not. -- The emperor Augustus in SANDMAN #30: "August" From pointal at lure.u-psud.fr Fri Sep 3 06:40:03 1999 From: pointal at lure.u-psud.fr (Laurent POINTAL) Date: Fri, 03 Sep 1999 10:40:03 GMT Subject: Pirate -> RAD References: <7qno38$6uk$1@news.is.co.za> Message-ID: <37cfa533.359049255@news.u-psud.fr> On Fri, 3 Sep 1999 08:00:45 +0200, "Jacques Oosthuizen" wrote: >: Hi All >: >: I am busy working on a tool I named Pirate ("Python RAD") it has a component >: library similar to Delphi and shall in the future work with win32,gtk,qt. It >: will have a IDE. >: >: Before I do to much and work to hard on it, will anyone be interested in >: using a tool like this. Yes (and I think many people are interested). Maybe you can work with the Parrot author... A+ Laurent. From fredrik at pythonware.com Wed Sep 1 05:03:11 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 1 Sep 1999 09:03:11 GMT Subject: CGI speedup strategies References: <37CCE7C9.D340BBF5@strs.co.uk> Message-ID: <036801bef458$d262c3e0$f29b12c2@secret.pythonware.com> Ian Clarke wrote: > Has anyone tried actually implementing a Python webserver which just > starts a new thread and runs a piece of Python code in it every time > someone makes a HTTP request? This server could then cache any objects > (such as files, or SQL connections) in memory to be used by any Python > scripts (this would obviously require all code to be thread-safe). http://www.nightmare.com/medusa (non-threaded, ultra-fast) http://www.zope.org (threaded, based on medusa) From cjc26 at nospam.cornell.edu Sun Sep 12 22:03:07 1999 From: cjc26 at nospam.cornell.edu (Cliff, or a close facsimile) Date: 13 Sep 1999 02:03:07 GMT Subject: Python example: possible speedup? References: <000801befc94$69181d60$6aa2143f@tim> Message-ID: Pada Sat, 11 Sep 1999 16:29:56 -0400, Tim Peters bilang: | I'm sure your absence from the list of approved readers is a | temporary glitch due to inferior operating systems (like Windows, MacOS, | EPOC32, Unix, Linux and BeOS) You just ruled out a whole bunch of OS's there...so what does the timbot run on then? ITS? A Lisp Machine? AmigaOS? -- cliff crawford http://www.people.cornell.edu/pages/cjc26/ There are more stars in the sky than there are -><- grains of sand on all the beaches of the world. From tim_one at email.msn.com Mon Sep 27 21:35:12 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 27 Sep 1999 21:35:12 -0400 Subject: Circular refs In-Reply-To: <000701bf0909$46bcb0b0$3acbd9c2@peridot.optichrome.com> Message-ID: <000801bf0951$b5b67da0$18a0143f@tim> [Adrian Eyre, on immortal cyclic trash] > I can dream up a million ways to kludge around this bug, but I > was referring to a 'fix' to the Python source code. How hard can > it be? It's unclear, but I can give you a lower bound: in all the years people have been whining about how easy this is to "fix", nobody has managed to fix it. your-turn-ly y'rs - tim From fredp at multimania.com.nospam Wed Sep 29 04:56:37 1999 From: fredp at multimania.com.nospam (Fred Pacquier) Date: 29 Sep 1999 08:56:37 GMT Subject: YA-Newbie: Progress (but still baffled by deepcopy/pickle issues...:) References: <8E48C2767PaCmAnRDLM@161.48.81.148> Message-ID: <8E5062134PaCmAnRDLM@161.48.81.148> Following-up on myself: Thanks to hints by Tim Peters (ly-yrs) and Jeremy Hylton, I have now identified the specific point of failure in my code, and a workaround, so I can now resume development -- thanks ! The uncomfortable part of the sitiation is that while I've found what doesn't work and what works as a replacement, I still don't understand why one solution fails and not the other. This bothers me, so I'll try to explain here what's going on in case someone gets interested and can shed some light on the matter... As I said it's a card game, with a simple object structure. The problem happens with this combination: First I have 3 module-global variables that hold wxWindows bitmap handles: Faces1 = wxBitmap(...) # card faces held in 2 separate bitmaps Faces2 = wxBitmap(...) CardBack = wxBitmap(...) Then I have the Card class : class Card : def __init__(self, index) : self.color = ... self.rank = ... if ... : self.src = Faces1 else : self.src = Faces2 self.Xoffset = ... self.Yoffset = ... ... The point in this pseudocode is that each Card instance holds a reference to the Bitmap the card image is to be fetched from (and its offsets in it). Next is the Stack class. It is essentially a list of Card instances, with a few simple data attributes (integers) and methods for displaying, moving around, etc, as in : class Stack : def showrow(self, row) : srcDC.SelectObject(self.Cards[row].src) dstDC.Blit(destx, desty, self.Cw, self.Ch, srcDC,self.Cards[row].Xoffset,self.Cards[row].Yoffset,xCOPY) srcDC.SelectObject(wxNullBitmap) The game state is almost entirely contained in a list of a dozen Stack instances (Cols), so saving and restoring it should be as easy as: def OnGameSave(self, event): SaveGame.Cols = deepcopy(self.Cols) def OnGameRestore(self, event): self.Cols = deepcopy(SaveGame.Cols) self.Refresh(1,None) Unfortunately, as I mentioned initially, it's only that easy ONCE. If the state is saved once, and restored once, all is well. If it is restored twice, or saved twice, all is wrong. I could not be more precise in my first message but now I know exactly _what_ is wrong : the Faces1 and Faces2 bitmaps are "gone" (but, strangely, not CardBack...). All the object instances and references (addresses, like Card.src) are correct, but there is nothing to display except card backs, and it's time to bail out or wxPython will crash... The difference between Faces1/Faces2 and CardBack being that the latter is not referenced by Card instances, on a hunch I tried the following changes: # new global CardFaces = (Faces1, Faces2) # in Card __init__: if ... : self.src = 0 # store an index instead of bitmap ref. else : self.src = 1 # in Stack showrow(): srcDC.SelectObject(CardFaces[self.Cards[row].src]) This seems to work flawlessly, although I don't understand why. Does anyone ? If anybody is interested in debugging, I have a trimmed-down module of about 300 lines that exhibits both behaviours -- just mail me, but BEWARE the .nospam suffix in my return address (sorry Jeremy :) Thanks for your attention, fp -- YAFAP : http://www.multimania.com/fredp/ From fredrik at pythonware.com Fri Sep 17 03:09:16 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 17 Sep 1999 07:09:16 GMT Subject: Problem compiling Python on Linux References: <7rrep5$n2e$1@newssrv.otenet.gr> Message-ID: <008001bf00db$8f857830$f29b12c2@secret.pythonware.com> Seby Carta wrote: > Hi , i have a problem with my Slackware linux and python 1.5.2, exactily > with thread and python. > When i run the command: > > >>>import threading > > Python tell me that he doesn't find thread module, i searched in my hdd..and > module thread.py isn.t!! why??, python's probably built without thread support. see the README file provided with the source for more details. (look for --with-thread) > not the same problem with python for window... he find above module and the > thread.py is present on my hdd. thread is a C module, so I find the latter a bit unlikely. maybe you meant "threading.py" (the higher-level interface to threads)? From tim_one at email.msn.com Thu Sep 30 23:05:51 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 30 Sep 1999 23:05:51 -0400 Subject: When Good Regular Expressions Go Bad In-Reply-To: <14323.30395.394477.753318@dolphin.mojam.com> Message-ID: <000701bf0bb9$def95240$322d153f@tim> [Douglas Alan] > It seems to me that even when a regular expression fails to match a > string, you might want to know just how far it was able to > get before getting stuck. [Tim sez probably easy to add, but seems of dubious utility] [Skip Montanaro] > Take a look at > > http://www.musi-cal.com/fast-itineraries.shtml OK, I have. > I want to let people set up schedule submissions and give them some help > when they format their schedules incorrectly. Currently I use three > regular rexpressions per selected format, the one that will match a > correctly formatted line and two shorter ones. When the real thing fails > I use the shorter ones to try and give the user some idea of where they > might have gone astray. Of course, users aren't told that regular > expressions underly the pattern matcher. I don't see how this relates to Douglas's idea, unless perhaps the two "shorter ones" can match only proper prefixes of strings matched by "the real regexp", and also one of the other. Of course people will enter highly structured data incorrectly, and of course you want to help them get it straight. Those are two reasons not to use regexps at all <0.1 wink>. 0.9 seriously! I entered: 3/40 @ 7:30pm, Knitting Factory, New York, NY (with Doctor Nerve/Meridian Arts Ensemble and it got rejected, without a clue as to why. Error detection and recovery is a Real Pain even with a Real Parser; a mechanical trick like "report rightmost progress" isn't going to turn the infinitely feebler regexp gimmick into a solution. What you have here is a classical "frame" problem: a number of information "slots" that need to be filled in. You picked a rigid format to ease your own implementation, perhaps because you've been hoodwinked into believing that "a regexp" *should* be "the solution". Well, it isn't. It may be *part* of a solution, though: for each slot that needs to be filled in, use a tiny regexp to search over the input, removing the data that matches then moving on to the next tiny regexp. In this way, e.g., you would first search for "a date", and in my example above would properly complain back to me that you couldn't find a properly formed date. It's a little more code for you to write, but much better for your users, and much more flexible over the long term. > compellingness-is-in-the-eyes-of-the-programmer-ly y'rs, usability-is-in-the-frustration-of-the-user-ly y'rs - tim From dubious at jonjh.freeserve.co.uk Tue Sep 7 08:43:25 1999 From: dubious at jonjh.freeserve.co.uk (Rev. Jon Harford) Date: Tue, 07 Sep 1999 12:43:25 +0000 Subject: Suitability for games? Message-ID: <37D5086C.69204F4C@jonjh.freeserve.co.uk> How suitable would Python be for games that move faster than Solitaire? From m.faassen at vet.uu.nl Thu Sep 16 10:06:13 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 16 Sep 1999 14:06:13 GMT Subject: high school programming & python References: <37DF9080.21A8D285@calibre-dd.com> <37DFE857.2784E45@callware.com> Message-ID: <7rqtgl$brk$1@newshost.accu.uu.nl> Ivan Van Laningham wrote: > Whippersnappers. Arrogant young punks. > All *I* had to work with was an undifferentiated sea of quarks! You mean you didn't need to pull them out of their virtual states? They were already there? Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From argollo at ircom.unilim.fr Fri Sep 3 06:30:54 1999 From: argollo at ircom.unilim.fr (Daniel ARGOLLO) Date: Fri, 3 Sep 1999 12:30:54 +0200 Subject: Freeze and SWIG Message-ID: <028001bef5f7$670b17a0$b4bb32c1@clara.ircom.unilim.fr> Hi there, I've got a problem.... I'm trying to freese a python project that uses some external Cpp code (in DLLs). The C code was wrapped with SWIG, it means that, for a my_class class, there is a my_class.py and incide an import my_classc statement. When i freeze my python code, it gives me an error message, because freeze trys to import a my_classc module that does not exist. Does anybody have a solution for this???? ------------------------------------------------------- Daniel ARGOLLO IRCOM - Universit? de Limoges argollo at ircom.unilim.fr -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/gif Size: 4638 bytes Desc: not available URL: From tre17 at student.canterbury.ac.nz Sun Sep 12 19:08:55 1999 From: tre17 at student.canterbury.ac.nz (tre17 at student.canterbury.ac.nz) Date: 13 Sep 1999 11:08:55 +1200 Subject: Tkinter & refreshing windows References: <199909121353.PAA08746@dionysus.fw.cuci.nl> Message-ID: "Hans Nowak" writes: > Hello, > > When working with Tkinter I noticed that on certain occasions, Tk > doesn't refresh the screen until it's done with a certain task. Hmm, > that doesn't sound very clear. :) An example: I'm currently working > on a program that accepts user input, then filters a lot of data > based on this input, then displays the results. Since the filtering > took a few seconds, I thought it would be a good idea to display the > current search results in a listbox while filtering, i.e. for every > "record" that passed the test, a string is added to the listbox. You > would be able to see some results while the filtering was still going > on. > > However, that doesn't seem to work at all. The program starts > executing the filtering, and doesn't display anything until > everything is done. In fact, trying to change the text of a label, > directly before the filtering starts, doesn't work either. > > I don't know if this is Windows-related (I'm using Win95 :( ), but > this is a well-known problem in Delphi, and there you have the > Refresh() method. Is there a similar method for Tkinter, to force an > update of the screen display? > > TIA, > > --Hans Nowak (zephyrfalcon at hvision.nl) > Homepage: http://fly.to/zephyrfalcon > Python Snippets: http://tor.dhs.org/~zephyrfalcon/snippets/ > The Purple Kookaburra Forum: http://www.delphi.com/kookaburra/ The `update' command is what you're looking for. For an example, consider the following code: ============================= #!/usr/bin/python from Tkinter import * import time def loop(): for x in range(5): print x l.insert('end', 'Foo %d' % x) root.update() time.sleep(1) root = Tk() l = Listbox(root) l.pack(fill='both', expand=1) b = Button(root, text='Start', command=loop) b.pack(fill='x', expand=1) root.mainloop() ============================= The alternative if you want your interface to remain fully responsize rather then just updating every now and then, is to use multi-threading. I seem to remember seeing something about Tkinter being thread safe now, but I'vbe never used threads and Tkinter. -- Tim Evans tre17 at student.canterbury.ac.nz From dwalker at iximd.com Sat Sep 11 08:25:54 1999 From: dwalker at iximd.com (Damond Walker) Date: Sat, 11 Sep 1999 12:25:54 GMT Subject: Text UI References: <65118AEEFF5AD3118E8300508B124877073BEE@webmail.altiris.com> Message-ID: William Tanksley wrote in message ... [snip] > >That's cool. It would be nice to have a standard Python text mode >interface (wxPython would be the best imaginable ;-). > Acouple weeks ago I wrapped up an initial version of a Text based UI for Python and Curses. It uses plain curses (not ncurses). It's event based, supports the notion of a container (either full screen, or dialog based), controls (has labels, command buttons, text boxes, a progress bar), and is 100% Python. Before a dialog is painted to the screen, it will gather the text that is about to be covered by the dialog. When the dialog goes away, it automagically repaints the screen. It's not perfect, could stand to be looked over by a real Pythoneer, but it works for my use right now. I have webspace so I probably should put it up for anyone to come and get it. In the meantime, if someone wants to play with it, send me email and I'll send it to ya right away. I was thinking of putting it out under the LGPL but that remains to be seen. Damond From swgeorge at my-deja.com Thu Sep 23 12:46:58 1999 From: swgeorge at my-deja.com (swgeorge at my-deja.com) Date: Thu, 23 Sep 1999 16:46:58 GMT Subject: Freezing script gives error message: Message-ID: <7sdlht$e0f$1@nnrp1.deja.com> Folks, Does anybody know why I am getting the following error message: Error: needed directory D:\Program Files\Python\lib\python1.5\config not found. Used '.\tools\freeze\freeze.py -h for help. What am I missing that freeze needs from the source directories? I have Python 1.5.2 downloaded from the python website and have downloaded the sources too. There does not seem to be a python1.5 directory in either. If you can help me it would be greatly apprecitated. Thank you, Spencer George swgeorge at us.ibm.com Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From fdrake at acm.org Wed Sep 29 10:37:58 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Wed, 29 Sep 1999 14:37:58 GMT Subject: What GUI-lib to use In-Reply-To: <37F1D710.47A82D23@bibsyst.no> References: <37F1D710.47A82D23@bibsyst.no> Message-ID: <14322.9286.610984.493427@weyr.cnri.reston.va.us> Thomas Weholt writes: > I want to develop GUIs to simple scripts fast, writing as little code as > possible, but still making it understandable. Looked at GLADE. How does > this work with Python? We've had good results with glade so far, but can't say that we've built any large applications that way. > Could Tk get a more modern look perhaps and solve all our problems? I'm afraid you'd have to talk to the Tcl/Tk people about that one. I would not expect large changes. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From fredrik at pythonware.com Thu Sep 9 08:01:50 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 9 Sep 1999 12:01:50 GMT Subject: timesync with python? References: <37D66AF3.6A3E96F7@phoenix-edv.netzservice.de> Message-ID: <002701befabb$1a884880$f29b12c2@secret.pythonware.com> Holger Jannsen wrote: > But I also thought that someone has an idea about that before > and did it likely better than me. So, do you know a weblink > to a script which already nearly does what I need? Perhaps > directly with interrogation at port 37 NTP? from the eff-bot archives: import socket, time HOST = "my.server" PORT = 37 TIME1970 = 2208988800L # 1970-01-01 00:00:00 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(HOST, PORT) b = s.recv(4) t0 = ord(b[3]) + (ord(b[2])<<8) + (ord(b[1])<<16) + (ord(b[0])<<24L) t1 = int(time.time()) + TIME1970 dt = int(t0 - t1) print "delta is", dt, "seconds" From greg.ewing at compaq.com Thu Sep 2 18:36:31 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 03 Sep 1999 10:36:31 +1200 Subject: Parrot: Why the clunky syntax? References: <935279776snz@vision25.demon.co.uk> <935454399snz@vision25.demon.co.uk> <37C2B9CE.95AA5FEC@lri.fr> <37C9FF53.DD466783@compaq.com> <19990830150321.C6858@optiplex.palga.uucp> <7qg7ek$k5e$1@newshost.accu.uu.nl> Message-ID: <37CEFBEF.58EAB14@compaq.com> Martijn Faassen wrote: > > So what Greg was asking, why not use a more Pythonesque syntax for parrot, > where indentation has actual meaning? That's one part of it. I was also wondering about the '@'. What meaning does Parrot assign to it? Greg From gmcm at hypernet.com Wed Sep 8 08:37:57 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 8 Sep 1999 07:37:57 -0500 Subject: Bug in time module? In-Reply-To: <37D5E25F.1F7F0A74@pc.jaring.my> Message-ID: <1275332084-98066501@hypernet.com> lec wrote: > Is this considered a bug since there is no Feb 31, 1999 or Feb 29, > 1999? > > >>> import time > >>> time.strptime('31/02/1999', "%d/%m/%Y") to which Berthold added: > More very strange things happen for me on linux: [snip everyday is Sunday] The only editing Python's time module does is to ensure that you've passed the right number and kind of args. Everything else is the result of your platform's implementation of strptime. If you want something _good_, you should probably use MA Lemburg's mxDateTime. - Gordon From dozier at abs.net Fri Sep 17 15:17:29 1999 From: dozier at abs.net (Bill Dozier) Date: Fri, 17 Sep 1999 15:17:29 -0400 Subject: [Bug,Mac] Bug in Python 1.5.x ?time origin error References: Message-ID: This was brought up in the MacPython SIG mailing list. If I am remembering correctly, you are correct in your suspicion as to the cause. In article , Howard at quercus.demon.co.uk (Howard Oakley) wrote: >Gentlepersons, > >I have a bug report on Python for Mac versions 1.5.1 and 1.5.2b1. The date >functions seem to have systematic errors of 1 day short of 4 years (is this >because the Unix and Mac OS origins of time differ by this amount?). From gmcm at hypernet.com Thu Sep 16 13:38:04 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 16 Sep 1999 13:38:04 -0400 Subject: python call external program (WHAT THE?!) In-Reply-To: <19990916100419.A7870@quark.emich.edu> References: <37E0F448.695EF4D0@trey-industries.com>; from Ben Thomas on Thu, Sep 16, 1999 at 01:47:44PM +0000 Message-ID: <1274619158-36273305@hypernet.com> Jeff wrote: > if you are trying to write portable code, I would go with the > suggestion below of using forward slashes in path names... if it > doesn't work by default under windows, you can write yourself a > simple function that *can* do it for you, and filter all your > pathnames through it-- the '/' is more natural anyway. have a > look at the 'os.path' module > . Forward slashes work fine on Windows when the run through the C library. When passed to os.system, however, they fail messily, because that goes nowhere near the C library, and the Windows API breaks up the string at each slash, thinking they are options. - Gordon From clgonsal at keeshah.penguinpowered.com Thu Sep 2 20:51:35 1999 From: clgonsal at keeshah.penguinpowered.com (C.Laurence Gonsalves) Date: Fri, 03 Sep 1999 00:51:35 GMT Subject: Returning none References: <000101bef12c$19566520$ad2d153f@tim> Message-ID: On Mon, 30 Aug 1999 20:30:11 GMT, Michael P. Reilly wrote: > > I'm guessing that most everyone has forgotten what "None" _is_. From > Python Reference Manual: 3.2 "The standard type hierarchy": > > None > This type has a single value. There is a single object with > this value. This object is accessed through the built-in name > None. It is used to signify the absence of a value in many > situations, e.g., it is returned from functions that don't > explicitly return anything. Its truth value is false. > > The key here folks is "the absense of a value". None means "nothing at > all" that the "procedure" proponents are all for. It's doing exactly > what you want, you may just be thinking of it incorrectly (we all are > probably thinking of None incorrectly at times). > > If you want to not include "return" in your functions, or to require > that your code must "return None" that's fine. I think that the > argument is that the language is not going to improve by requiring > procedures. But None *isn't* nothing at all. If it was, [None] would be the same as [], and calling str(None) would be the same as str(). They're different though. None is *something*. You can copy it around, put it into lists/tuples/maps/attributes, and pass it to functions. That can cause problems if you meant to pass the result of some computation, and your function was incorrectly not returning the result, but instead the default None. -- C. Laurence Gonsalves "Any sufficiently advanced clgonsal at kami.com technology is indistinguishable http://www.cryogen.com/clgonsal/ from magic." -- Arthur C. Clarke From arcege at shore.net Fri Sep 3 20:41:15 1999 From: arcege at shore.net (Michael P. Reilly) Date: Sat, 04 Sep 1999 00:41:15 GMT Subject: getpass.getpass() bugged? References: <7qm5q0$lct$1@nnrp1.deja.com> Message-ID: super_banane at yahoo.com wrote: : The getpass.getpass() function should : be requesting a password without echoing it... : but unfortunately it does: :>>> import getpass :>>> getpass.getpass() : Password: hello : 'hello' :>>> : Python I use is v1.5.2 : Same behaviour on Solaris 2.6 and HPUX-10.20. : Works fine with Python v1.5.1 on Linux, though. I don't see a problem on my like system. Python 1.5.2 (#6, Apr 20 1999, 10:35:35) [GCC 2.7.2.2] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import os, getpass >>> getpass.getpass() Password: 'hello' >>> os.uname() ('SunOS', 'golem', '5.6', 'Generic_105182-05', 'i86pc') >>> This sounds more like a problem with the terminal emulation (for example emacs' bad shell modes). -Arcege From aahz at netcom.com Wed Sep 22 13:02:23 1999 From: aahz at netcom.com (Aahz Maruch) Date: 22 Sep 1999 17:02:23 GMT Subject: Help with RegExps References: <37E8B7B3.F4A9143@isogmbh.de> Message-ID: <7sb22v$kmi@dfw-ixnews12.ix.netcom.com> In article <37E8B7B3.F4A9143 at isogmbh.de>, Chris... wrote: > > I am looking for an regular expression that changes text, only if it >is not anywhere between '<' and '>'. >For example, add syntax highlighting to HTML-file: > 'some text ref # this is a comment' >should be changed to > 'some text ref # this is a >comment' Try using htmllib instead; already packages all the regexes for you. (Make sure to use 1.5.2; there are a couple of bugs in 1.5.1) -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From abkout at my-deja.com Thu Sep 30 19:07:14 1999 From: abkout at my-deja.com (abkout at my-deja.com) Date: Thu, 30 Sep 1999 23:07:14 GMT Subject: checking for end of file? Message-ID: <7t0qeo$q9f$1@nnrp1.deja.com> Hello, I've probably missed something obvious, but how can I test for an end of file in a Python script? (without attempting to read something from it) Bob Koutsky Sent via Deja.com http://www.deja.com/ Before you buy. From NOSPAMcraig at osa.att.ne.jp Wed Sep 29 06:32:51 1999 From: NOSPAMcraig at osa.att.ne.jp (Craig Hagerman) Date: 29 Sep 1999 10:32:51 GMT Subject: python as a first language? Message-ID: Hi, I want to get some feedback on how good Python is to learn for a beginner. I am interested in learning programming (OOP especially). I studied (bit didn't really learn) Fortran ages ago, studied formal logic (math) in university and have been playing around with web technologies (Javascript et al) and now want to try out bigger and better things. What are people's thinking regarding Perl vs Python for a beginner, or how about Python compared to Eiffel or Sather for this purpose? Any good suggestions for what road I should head up first? Cheers, Craig From darcy at vex.net Thu Sep 23 09:14:06 1999 From: darcy at vex.net (D'Arcy J.M. Cain) Date: 23 Sep 1999 13:14:06 GMT Subject: SIGCHLD, fork, listen References: <7sd6q4$gqq$1@salome.rfa.org> Message-ID: <7sd92t$19fn$1@hub.org> bill wrote: > I'm trying to set up a fairly "simple" > server that listens for a socket connection, > forks off a process and goes back to listening. > This works fine for multiple clients, except > I get zombies. I try redefining SIGCHLD as > SIG_IGN, but this doesn't work (as apparently > is what's expected under POSIX). I then > try redefining it with my own function that > includes a WAIT. Fine, except "listen" > doesn't get signalled when the child process > dies, only when the next socket connection > occurs. (which could be hours later, not > good). How are you creating your server? Are you using SocketServer? This supposedly does what you want. Here is a simple echo server using it. ---------------------------- echod ---------------------------- #! /usr/bin/env python HOST = '' PORT = 51000 from SocketServer import * class echohandler(ForkingMixIn, StreamRequestHandler): def handle(self): self.wfile.write(self.rfile.readline(16384)) if __name__=='__main__': from socket import * server = TCPServer((HOST, PORT), echohandler) server.serve_forever() --------------------------------------------------------------- However, on a simple test, I find that this doesn't actually fork. If someone can suggest why this doesn't fork, you should be able to use this instead. Note I tried reversing the order of the inherited classes with no difference. The simple test, btw, is to telnet to the port from two windows and type a line into the second one then the first. The second one doesn't echo until I type in something into the first session. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From chapman at bioreason.com Wed Sep 1 10:58:14 1999 From: chapman at bioreason.com (Mitch Chapman) Date: Wed, 01 Sep 1999 08:58:14 -0600 Subject: threads on Solaris References: <199908302338.AA04307@ch1d2833nwk> <199909010612.QAA06055@piglet.dstc.edu.au> Message-ID: <37CD3F06.6010E28A@bioreason.com> David Arnold wrote: > > -->"Ted" == Ted Horst writes: > > Ted> Does anyone know why I get 4 threads when I start the > Ted> interpreter under Solaris (as reported by /bin/ps -aL) ? > > Ted> This is python 1.5.2 built with a SUNPro compiler (sorry, I > Ted> don't have the config options). > > i see the same behaviour, also SUNPro, but i *know* mine is configured > with the thread module enabled, which i imagine has something to do > with it? Yes. Multithreaded C apps also display this behavior. I don't develop on Solaris any more, so take this with a grain of salt, but: There's a main thread, a thread for catching signals, and (I think) a reaper thread which finalizes exited threads. And of course any threads your application explicitly creates. I can't remember the conditions under which you get the reaper thread. I think it's either when you *do* have daemon threads (threads on which you don't intend to wait) or when you don't :) -- Mitch Chapman chapman at bioreason.com From Gareth.McCaughan at pobox.com Tue Sep 7 18:42:57 1999 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: 07 Sep 1999 23:42:57 +0100 Subject: Turing Compliant? References: <37CD7CBC.54AD295F@megsinet.net> <7r0q9d$sp6$1@nnrp1.deja.com> <14291.65246.743544.70969@buffalo.fnal.gov> <7r1ibf$eb1@dfw-ixnews14.ix.netcom.com> Message-ID: <86puzul4we.fsf@g.local> William Tanksley wrote: > Not to mention the number of infinities -- are there more than two of them > (countable and uncountable)? Cohen proved that the question isn't > answerable -- the first proof-by-example of Godel's Law. I'm afraid this is very badly garbled. 1. It's been known ever since Cantor that there are infinitely many different infinities. 2. Cohen proved that ZF (or indeed ZFC) can't prove that there aren't any infinities between the size of Z and the size of R. 3. Goedel had already proved that ZF/ZFC also can't prove that there *are* any infinities between the size of Z and the size of R. 4. I've never heard the name "Goedel's Law" before. It's usually called "Goedel's Incompleteness Theorem" or, better, "Goedel's First Incompleteness Theorem". 5. I don't believe that the continuum hypothesis (the statement that there are no infinite cardinals bigger than Z and smaller than R) was the first concrete statement to be shown independent of the axioms of a serious foundational axiom system. In particular, Goedel's "Second Incompleteness Theorem" -- published in the same paper as the First, in 1931 -- implies that e.g. "ZFC is consistent" can't be proved in ZFC unless ZFC is inconsistent. (And, clearly, if ZFC is consistent then it also can't prove "ZFC is not consistent".) ("ZFC" is the name given to the usual axiomatisation of set theory. There are others, with slightly different properties. By "Z" and "R" I mean the integers and the reals, respectively. There's also an axiomatic set theory called "Z", which I'm not talking about.) -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From m.faassen at vet.uu.nl Sun Sep 5 13:48:53 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 5 Sep 1999 17:48:53 GMT Subject: language interpreters/ interpreted languages weaknesses? References: <7qi3q3$n1d$1@nnrp1.deja.com> <37CCE10D.D07D023B@strs.co.uk> <7qjgq8$k1i$1@newshost.accu.uu.nl> <7qlj3b$p7u$1@newshost.accu.uu.nl> Message-ID: <7quae5$q02$2@newshost.accu.uu.nl> William Tanksley wrote: > On 2 Sep 1999 10:21:31 GMT, Martijn Faassen wrote: >>William Tanksley wrote: >>> Java's not interpreted, though -- I've never seen ANY Java interpreter. >>> Java is always compiled, usually to bytecode, and then the bytecode >>> machine is emulated. >>Um, I was under the impression that this is what a modern interpreter >>actually does? Parse the source to bytecode and execute the bytecode. >>After all, Python does the same, right? > If you assume Python is an interpreter, then yes, that's a counterexample. > My point is that Python isn't an interpreter -- or rather, isn't one by > any meaningful definition of the word. But I thought a meaningful definition is: an interpreter is something that executes a program without a compilation to native machine code; instead some intermediate format is used (or even the source is executed 'directly'). Of course emulated processors muddle the picture but it's not that useless a definition either, as you seem to claim. Regards, Martijn From alex at somewhere.round.here Thu Sep 30 19:07:12 1999 From: alex at somewhere.round.here (Alex) Date: 30 Sep 1999 19:07:12 -0400 Subject: Large Numeric arrays References: <37F385AC.7057E983@v1.wustl.edu> Message-ID: > I'm passing fairly large arrays around (using Numeric Py) > and I'm getting the error: > > MemoryError: can't allocate memory for array I have run into this problem before when writing C. I would have something like unsigned long int big_array[20][20][20][20][20]; and my program would segfault before it even started executing the main() function, even though I had plenty of memory. The problem went away when I made big_array an (unsigned long int)***** and assigned the array elements in slices at execution time. My theory was that the program wanted to lay the whole array down contiguously, and there was no contiguous chunk of memory available for that, even though the total memory available was more than enough. I know very little of the Numeric internals, but the manual says "Arrays created from scratch are always contiguous; non-contiguous arrays are the result of indexing and other structural operations." Perhaps you could make your arrays in slices, and then glom the slices together? Alex. From skip at mojam.com Thu Sep 9 17:53:23 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 9 Sep 1999 16:53:23 -0500 (CDT) Subject: Python example: possible speedup? In-Reply-To: <7r98lk$kug@dfw-ixnews6.ix.netcom.com> References: <7r98lk$kug@dfw-ixnews6.ix.netcom.com> Message-ID: <14296.11347.433292.287485@dolphin.mojam.com> Aahz> I'll test this if I have to, but do you know off-hand how this Aahz> compares to [list append] .... Aahz> What if you use range(100000) or range(1000000)? Executing import cStringIO, time, string def doit(n, r): print "doing", n, "iterations - range function ==", r c = time.clock() for i in r(n): pass print "loop overhead:", time.clock() - c c = time.clock() a=cStringIO.StringIO() for i in r(n): a.write('h') a=a.getvalue() print "cStringIO:", time.clock() - c c = time.clock() a = [] for i in r(n): a.append('h') a = string.join(a,'') print "list append:", time.clock() - c print for i in [1000, 5000, 10000, 50000, 100000, 1000000]: doit(i, range) doit(i, xrange) I got doing 1000 iterations - range function == loop overhead: 0.0 cStringIO: 0.01 list append: 0.01 doing 1000 iterations - range function == loop overhead: 0.0 cStringIO: 0.01 list append: 0.01 doing 5000 iterations - range function == loop overhead: 0.01 cStringIO: 0.03 list append: 0.04 doing 5000 iterations - range function == loop overhead: 0.01 cStringIO: 0.03 list append: 0.04 doing 10000 iterations - range function == loop overhead: 0.02 cStringIO: 0.06 list append: 0.08 doing 10000 iterations - range function == loop overhead: 0.02 cStringIO: 0.07 list append: 0.08 doing 50000 iterations - range function == loop overhead: 0.11 cStringIO: 0.32 list append: 0.42 doing 50000 iterations - range function == loop overhead: 0.1 cStringIO: 0.32 list append: 0.39 doing 100000 iterations - range function == loop overhead: 0.22 cStringIO: 0.65 list append: 0.92 doing 100000 iterations - range function == loop overhead: 0.18 cStringIO: 0.63 list append: 0.88 doing 1000000 iterations - range function == loop overhead: 2.22 cStringIO: 6.55 list append: 10.27 doing 1000000 iterations - range function == loop overhead: 1.77 cStringIO: 6.35 list append: 10.04 which suggests there is a performance boost for cStringIO vs list append and xrange vs range for large numbers, but that for loops with less than about 10,000 iterations, it probably doesn't matter what you use. Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/~skip/ 847-971-7098 | Python: Programming the way Guido indented... From bellings at badlands.NoDak.edu Tue Sep 7 20:39:48 1999 From: bellings at badlands.NoDak.edu (Brent A Ellingson) Date: 8 Sep 1999 00:39:48 GMT Subject: language interpreters/ interpreted languages weaknesses? References: <7qi3q3$n1d$1@nnrp1.deja.com> Message-ID: <7r4b8k$brh$1@news.ndsu.nodak.edu> Mr Kelvin Lee (kelvin at scientist.com) wrote: : What are the most popular interpreted languages around? I was under the impression that the most popular interpreted language, by a /very/ large margin, is Intel 80386 machine code. From the small amount I've read, I was led to believe that all modern PCs basically have specialized RISC chips which do nothing but run a small, thin, very fast x86 interpreter all day, every day. That may be simplifying things a lot, but it might give you some idea how silly the distinction between "interpreted" vs. "compiled" is. -- Brent Ellingson (bellings at badlands.NoDak.edu) "It is amazing how complete is the delusion that beauty is goodness." -- Leo Tolstoy From m.faassen at vet.uu.nl Tue Sep 7 08:15:58 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 7 Sep 1999 12:15:58 GMT Subject: Suitability for games? References: <37D5086C.69204F4C@jonjh.freeserve.co.uk> Message-ID: <7r2vlu$68m$1@newshost.accu.uu.nl> Rev. Jon Harford wrote: > How suitable would Python be for games that move faster than Solitaire? I've done some thinking about this, though I have little practical experience. It depends on what kind of game you're talking about, to start with. A whole lot depends on that. Python probably isn't fast enough to do a vast amount of 3d calculations, but it's fast enough to *drive* these calculations. This is the general principle -- Python can still perform quite well as a higher level controlling system (which can include a lot -- GUI, loading/saving, scripting of in-game objects and events, etc), even when it's not fast enough to do low level graphics manipulation. You use a C or C++ library for that, but you can wrap those with Python. For object scripting, there are some interesting developments. Python does not have 'simulated threads' by default. These are non-OS threads where the Python interpreter itself does the switching, first executing for instance 100 bytecodes of 1 thread, then 100 of another, and so on. But, Will Ware has released MicroThreads which does accomplish this. So look into this if you're interested in driving a lot of objects in your game with Python scripts. Microthreads seem to be better suited for this purpose than the usual threads, which usually don't assume that large an amount of threads. Microthreads can be found at: http://world.std.com/~wware/uthread.html There was talk about integrating MicroThreads into Christian Tismer's 'stackless Python', and there is also talk about integrating *that* with Python proper, but that's of course a lot of assumptions. :) So I'd recommend Python for game scripting, and for the code that structures and drives lower level speedy code. For the lower level code Python isn't very suited though. Regards, Martijn From aaron_watters at my-deja.com Sat Sep 25 16:44:47 1999 From: aaron_watters at my-deja.com (aaron_watters at my-deja.com) Date: Sat, 25 Sep 1999 20:44:47 GMT Subject: Gadfly and Python on the Mac References: Message-ID: <7sjc7t$dqj$1@nnrp1.deja.com> In article , "JMartin" wrote: > Does Gadfly run on a Mac with Python? I get errors when I try to install it. Please report the problems you have to gadfly-rdbms at egroups.com (the gadfly mailing list). Also make sure you are using gadfly 1.0. I *thought* gadfly 1.0 ran on the mac, but maybe the people who reported this made some minor changes to make it work. Anyway, if there is a problem, I'd like to fix it. I know it can be *made* to work without difficulty. -- Aaron Watters === I pity the foo'. Sent via Deja.com http://www.deja.com/ Before you buy. From aahz at netcom.com Tue Sep 14 00:04:00 1999 From: aahz at netcom.com (Aahz Maruch) Date: 14 Sep 1999 04:04:00 GMT Subject: Query: Pass variable to DOS bat file References: <37ddbf00.23343510@nntp.ix.netcom.com> Message-ID: <7rkhfg$5dg@dfw-ixnews7.ix.netcom.com> In article <37ddbf00.23343510 at nntp.ix.netcom.com>, Milas Omdalen wrote: > >Seeking to implement a rather long menu of zipped file choices. The >basic dos bat file does not handle large menu choices very well. But I >don't see a way to use the zip program in Python. > >Can I call dos programs from within Python script? import os os.system('unzip foo') >Can I use a Python unzip program? That might be better; take a look at the gzip module. I think there's also a tar module somewhere. Unfortunately, this is not compatible with pkzip. >Can I pass the menu choice chosen in the Python script to the dos bat >file? Python: os.system ( 'batch foo bar' ) Batch: echo %1 echo %2 >I see that I can call the Python script file from my bat file. Maybe >use Global variables? I thought of saving the variable in a file, an >awfully roundabout implementation. This is probably not a good idea. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From bob at horvath.com Wed Sep 22 07:48:26 1999 From: bob at horvath.com (Bob Horvath) Date: Wed, 22 Sep 1999 11:48:26 +0000 Subject: wxPython on Debian Linux References: Message-ID: <37E8C20A.F4051E56@horvath.com> Lars Marius Garshol wrote: > Does anyone know how to find this? > > Searches on deja.com, debian.org and the wxPython site have so far > been unsuccessful. (Yeah, I've tried what it says on the site, and > also searched in dselect, all to no avail.) > > Any help would be most gratefully received. I haven't tried it myself, but itsn't it at http://www.debian.org/Packages/unstable/interpreters/python-wxwin.html From arcege at shore.net Wed Sep 15 17:05:20 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 15 Sep 1999 21:05:20 GMT Subject: screen FLY by, where is the pause? Debug needed References: <37DF9AAC.7541897A@trey-industries.com> Message-ID: Ben Thomas wrote: : I am woirking on my first python script. I am trying to find out why I : am not geting the results I expect. Is there a way to pause these : 'system' calls so the screens don't fly by so fast? I can't see the dos : error messages. I checked my book and deja but I don't see the answer. You can either call input() or raw_input(), or possibly even call os.system('pause'); I would still to raw_input() tho. -Arcege From aardvark_three at yahoo.com Wed Sep 8 08:59:06 1999 From: aardvark_three at yahoo.com (jims) Date: Wed, 8 Sep 1999 08:59:06 -0400 Subject: Choosing a MySQL interface Message-ID: Hello all I'm a bit of a Python newbie, and am building an app that uses a MySQL database (the latest version) as the back end. I wonder if anyone can tell me whuich is the currently "correct" way to connect to a MySQL database using Python. There appear to be several methods available (like here and here) but I can't tell which one is the right one to use at this time. It would be nice if someone could post up-to-date instructions on using MySQL as a backend for Python programs. I can't seem to find any, and I've looked for a few days now. thanks jim -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidopp at megsinet.net Mon Sep 20 00:36:56 1999 From: davidopp at megsinet.net (David Oppenheimer) Date: Mon, 20 Sep 1999 00:36:56 -0400 Subject: PythonWin & Windows MFC Message-ID: <37E5B9E7.93034953@megsinet.net> Is there any good information anywhere about how to use PythonWin with MFC to create an event driven program with an attractive GUI? Thanks, David O. From davidopp at megsinet.net Sun Sep 26 01:44:20 1999 From: davidopp at megsinet.net (David Oppenheimer) Date: Sun, 26 Sep 1999 01:44:20 -0400 Subject: Moving from Perl to Python References: Message-ID: <37EDB2B4.2563A5DB@megsinet.net> William Tanksley wrote: > > > I think he just wanted the Perl Cookbook, which would indeed be great > (except, of course, for the parts which are trivial in Python -- we don't > need no hashes-and-list man page ;-). > Hashes?! We don't need no stinking hashes! David O. From bjorn at roguewave.com Wed Sep 1 02:30:51 1999 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Wed, 1 Sep 1999 00:30:51 -0600 Subject: lex / yacc for Python Message-ID: <51C9F3C392D0D111A15600A0C99E64A9AF54F3@localhost> There is of course also possible to do the lexing and parsing in flex/bison ;-) The nodes in C++, SWIG to wrap them, and implement compiler passes in python. If you know lex/yacc and don't feel like learning error tracking for a new system (in addition to extra syntax etc.) You might want to give it a try. It actually works remarkably well (couple of rough spots, but what'd you expect ;-) If you'd like to take a quick look at a very premature project (the parts you are interested in are working), let me know and I can send you a copy. Quick question to other language implementors: I'm almost done writing the core language evaluator (using a rather interesting version of the visitor pattern that is much simpler, and can't be modeled in less dynamic language). The question is what do I do next? Type inference has been an intest of mine for some years now, so I was wondering if it should go first, probably followed by the pretty printer (does anyone know of any current reasearch on minimizing the generated interface descriptions? -- where I should go to find it?) If going to a third language, the options are Python (I'm even starting to understand the internals *sigh*), i.e. something similar to P-code, wher I either write the runtime envionment or use someone elses. I could also use C, C++,... if I wanted speed rather than quality at this point. I'm planning to table optimizations for the time being, but I will still do some fairly complete records of how the core language operates on the python evaluator.... => Bool :-) > -----Original Message----- > From: Mike Fletcher [SMTP:mcfletch at vrtelecom.com] > Sent: Tuesday, August 31, 1999 7:50 PM > To: python-list at python.org > Subject: RE: lex / yacc for Python > > Normally I point new users not to mcf.pars (which I haven't touched in > ages > (though I still use it daily at work)) and point them to simpleparse, > which > generates tuples for use with the mxTextTools engine. > > Neither system is a lexx/yacc style system. They use very similar general > pattern matching machinery which does not use lexxing machinery at all > (i.e. > no tokenisation pass). Both systems are targeted at (moderately) fast > parsing of a very limited class of grammars. > > http://members.home.com/mcfletch/programming/simpleparse/simpleparse.html > > As noted on your page, mcf.pars is still available as part of mcf.vrml, > but > the version of mcf.vrml on starship.python.net is actually an old version > of > that package. I would have to check to see if the mcf.pars package > changed > between that version and later versions of mcf.vrml. > > Cheers, > Mike > > -----Original Message----- > From: python-list-request at cwi.nl [mailto:python-list-request at cwi.nl]On > Behalf Of Andrew M. Kuchling > Sent: August 31, 1999 5:50 PM > To: python-list at cwi.nl > Subject: Re: lex / yacc for Python > > > "Jacques Oosthuizen" writes: > > Any one know if there is such a beast > > Quite a few, actually; many Python users seem to be language geeks. > A list of parsing systems is at: > > http://starship.python.net/crew/amk/python/string.html#parsing > > I've never used any of them, and don't know which ones are still > maintained, which are toys, and which are the most powerful. Good luck! > > -- > A.M. Kuchling http://starship.python.net/crew/amk/ > This isn't life in the fast lane, it's life in the oncoming traffic. > -- Terry Pratchett, in alt.fan.pratchett > > > > > -- > http://www.python.org/mailman/listinfo/python-list From wware-nospam at world.std.com Fri Sep 24 00:14:15 1999 From: wware-nospam at world.std.com (Will Ware) Date: Fri, 24 Sep 1999 04:14:15 GMT Subject: Becoming root within a Python script References: Message-ID: =?ISO-8859-1?Q?Fran=E7ois_Pinard?= (pinard at iro.umontreal.ca) wrote: : I would like, within a executing Python started as non-root, ask for the root : password, and then, continue executing part of the script while being root, : becoming the previous again after some sub-job is done. In another post you said you hoped to avoid using 'su'. Can't help you there, but I did find a pretty simple version that seems to work well, at least on my Linux box: ---- begin ---- import os, sys if os.popen('whoami').readline()[:-1] == 'root': print 'Hey, look, I am logged in as root!' else: print 'I am the normal user, about to do some root stuff.' os.system('su -c "python %s"' % sys.argv[0]) print 'Normal user again, done doing root stuff.' ---- end ---- Dumb question for those wiser than myself: The os.popen().readline()[:-1] construction is pretty ugly. Is there a better way to do it? Aside from the typing and the esthetics, I'm not altogether certain that the pipe will be correctly refcounted away and dealloced. I find myself doing similar things often enough, I'd prefer to hear a better way. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From MHammond at skippinet.com.au Tue Sep 7 20:26:12 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 8 Sep 1999 10:26:12 +1000 Subject: CONTEST: PyWin crashes with pure Python code! References: <816010E2456BD111A48700805FBBE2EEFDF5A4@ex-quebec-u1.baan.com> Message-ID: <7r4aff$79u$1@m2.c2.telstra-mm.net.au> Gaetan Corneau wrote in message <816010E2456BD111A48700805FBBE2EEFDF5A4 at ex-quebec-u1.baan.com>... Just to let people know what is going on here - we have been discussing this in email. It _appears_ we have a DLL version conflict or some other external influence at work. People who have MSVC 6 installed seem unable to recreate the problem at all. Adding fuel to this is that one person in particular could create the crash, then installed VC6 and could no longer create it. At this stage we are still waiting for some more information from people on this - as there are now only a couple of people who can create this problem it is taking a little longer than we hoped. Mark. From aiki108 at netscape.net Thu Sep 30 12:59:31 1999 From: aiki108 at netscape.net (David Fisher) Date: Thu, 30 Sep 1999 11:59:31 -0500 Subject: python UDPServer References: <7srhvi$v6a$1@nnrp1.deja.com> Message-ID: <7t04tg$1bu$1@newsreader.wustl.edu> >That is, the script comes to a screeching halt >when, in the course of performing the >initialization for a UDPServer, it defaults to the >initialization behaviour (for the most part) of a >TCPServer, which does a listen(). This is a bad >thing(tm) for a UDP socket. You're right. UDPServer should override server_activate(). And in version 1.5.2 is does. Like this from Lib/SocketServer.py: class UDPServer(TCPServer): """UDP server class.""" socket_type = socket.SOCK_DGRAM max_packet_size = 8192 def get_request(self): data, client_addr = self.socket.recvfrom(self.max_packet_size) return (data, self.socket), client_addr def server_activate(self): # No need to call listen() for UDP. pass Your code runs fine on my win98/python1.5.2, except that the method is called serve_forever() not server_forever(). You can edit the UDPServer class in Lib/SocketServer.py to the above. or upgrade to 1.5.2. On Linux the file is probably in /usr/lib/Python1.5. dnf From jam at quark.emich.edu Thu Sep 16 16:11:15 1999 From: jam at quark.emich.edu (Jeff) Date: Thu, 16 Sep 1999 16:11:15 -0400 Subject: Problem compiling Python on Linux In-Reply-To: <7rrep5$n2e$1@newssrv.otenet.gr>; from Seby Carta on Thu, Sep 16, 1999 at 10:04:33PM +0300 References: <7rrep5$n2e$1@newssrv.otenet.gr> Message-ID: <19990916161115.E8285@quark.emich.edu> On Thu, Sep 16, 1999 at 10:04:33PM +0300, Seby Carta wrote: > Hi , i have a problem with my Slackware linux and python 1.5.2, exactily > with thread and python. > When i run the command: > > >>>import threading > > Python tell me that he doesn't find thread module, i searched in my hdd..and > module thread.py isn.t!! why??, > not the same problem with python for window... he find above module and the > thread.py is present on my hdd. > > Please...help me .. if you can.... > > Thank you anywere. > > Seby > it sounds like you need to tell python to compile with the threading module support enabled-- for whatever reason the configure script isn't able to find it. are you sure your system has the right thread support built in? what version of libc do you have installed? I don't have any slackware boxen left (they have been changed to redhat based machines), so I can test these things myself. does the README file included with the source explain what you need to do? it may be as simple as modifying the Setup file to tell it what you want. if you try all this and still have trouble, post to the list again. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From gmcm at hypernet.com Sun Sep 5 22:12:04 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sun, 5 Sep 1999 21:12:04 -0500 Subject: Using Python in ASP scripts In-Reply-To: Message-ID: <1275542437-85413535@hypernet.com> Nikolai Kirsebom wrote: > I have two NT 4.0 PC's running IIS 4.0 where I'm using Python in ASP > scripts. On the one machine I have no problems running the scripts > - however on the other machine I can't get the scripts running. If > I change the LANGUAGE token to something else (VBScript) it works - > so obviously it must have something to do with the 'registration' of > Python as the scripting language. I've executed the pyscript.py and > it reported all ok. Sounds like this is related to a problem I had running any of the axscript stuff. I had at one time installed MS's script debugger. Not only did the axscript stuff not work, but I couldn't update any of the related MS components. While I didn't have to re-install NT, I did have to remove and then reinstall everything having to do with networking. - Gordon From tjreedy at udel.edu Thu Sep 30 22:35:56 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 1 Oct 1999 02:35:56 GMT Subject: newbee References: Message-ID: <7t16mc$1il$1@news.udel.edu> In article , ericholmes108 at hotmail.com says... > >hi > >i want to know how to get started with python the language. Visit www.python.org and look for tutorial and stuff specific to your platform. From cnetzer at mail.arc.nasa.gov Thu Sep 30 20:29:16 1999 From: cnetzer at mail.arc.nasa.gov (Chad Netzer) Date: Fri, 01 Oct 1999 00:29:16 +0000 Subject: lzw.py References: <37F384C4.9486B017@darwin.in-berlin.de> Message-ID: <37F4005C.385FFC8E@mail.arc.nasa.gov> "Dinu C. Gherman" wrote: Here is what the FSF says that Unisys is saying about their patent (ahem): No license or license fees are required for non-commercial, not-for-profit GIF-based applications or for non-commercial, not-for-profit GIF-freeware, so long as the LZW capability provided is only for GIF. However, a license is required if freeware is incorporated into, or sold or distributed with a commercial or for-profit product, introduced in 1995 [or later], or enhancements of products that were introduced prior to 1995. I got this at: http://www.gnu.org/philosophy/gif.html There is more to it (IBM and Unisys both are involved, IBM licensing position is unclear). The uncompressing part of the LZW algorithm is apparently NOT patented, BTW. In any case, it is a bummer, but you can modify your algorithm and release it; it is mainly for learning anyway, right? I wrote some nice coding algorithms in school (arithmetic, huffman, lz77, each with various adaptability enhancements) and learned a lot. The LZW algorithm is really no longer top-notch; computing power is such that you can easily write algorithms that make assumptions of bigger resources that are probably not covered by the LZW patent (which dealt w/ tree-pruning and pointer rescaling, etc.) I really should go back and play with these ideas w/ Python. Dealing w/ C made many implementation details VERY cumbersome (especially given that I was exploring adaptive models), but the Python abstractions may make things very elegant (if a bit slower :) Chad Netzer chad at vision.arc.nasa.gov From guido at cnri.reston.va.us Wed Sep 15 23:42:14 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 15 Sep 1999 23:42:14 -0400 Subject: TreeCtrl Object (win32ui) References: <7rm9bb$1rh$1@nnrp1.deja.com> <7ro8ql$eao$1@nnrp1.deja.com> Message-ID: <5llna74j55.fsf@eric.cnri.reston.va.us> jayseye at my-deja.com writes: > Does Python offer a cross-platform Tree control, > or does it only provide access to the Win32 control > when running under Windows? Yes. IDLE 0.5 has a TreeWidget module that works with Tkinter. It is not in any distribution yet, you need to get it via the CVS archives, see http://www.python.org/download/cvs.html. IDLE is in Tools/idle/. --Guido van Rossum (home page: http://www.python.org/~guido/) From skip at mojam.com Wed Sep 22 12:44:20 1999 From: skip at mojam.com (Skip Montanaro) Date: Wed, 22 Sep 1999 11:44:20 -0500 (CDT) Subject: Linux Dependencies! Grrr...What now? In-Reply-To: <19990922123456.B15540@quark.emich.edu> References: <37E8066F.1C13BF33@alliedsignal.com> <19990922123456.B15540@quark.emich.edu> Message-ID: <14313.1892.521554.125304@dolphin.mojam.com> >> (I've been warned that as the result of my upgrade, I have now >> "broken" netcfg, but I'll deal with that on another day.) The fix is pretty trivial. There are two functions in /usr/lib/rhs/netcfg/netcfg.py that have broken defs. I appended the changes I made. Haven't had a problem with netcfg since then. Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/~skip/ 847-971-7098 | Python: Programming the way Guido indented... *** netcfg.py~ Mon Aug 17 12:31:42 1998 --- netcfg.py Fri Jul 16 12:33:32 1999 *************** *** 138,142 **** return '' ! def LinespeedMenu(master=None, variable, width='20'): speedlist = [] for speed in ['1200', '2400', '4800', '9600', '19200', '38400', --- 138,142 ---- return '' ! def LinespeedMenu(master=None, variable=None, width='20'): speedlist = [] for speed in ['1200', '2400', '4800', '9600', '19200', '38400', *************** *** 146,150 **** return LabelledMenu(master, 'Line speed:', variable, width, speedlist) ! def ModemportMenu(master=None, variable, width='20'): portlist = [] try: --- 146,150 ---- return LabelledMenu(master, 'Line speed:', variable, width, speedlist) ! def ModemportMenu(master=None, variable=None, width='20'): portlist = [] try: From ferni at loxinfo.co.th Sun Sep 26 23:42:22 1999 From: ferni at loxinfo.co.th (Jon Fernquest) Date: Mon, 27 Sep 1999 10:42:22 +0700 Subject: Matching templates against a tree - any idea? References: Message-ID: <005301bf089a$5ba21d40$1a2292cb@akha> Fernando Pereira wrote: >[Matching templates against a tree]...has been the subject >of much research. For a recent textbook, check out >Franz Baader and Tobia Nipkow's "Term Rewriting and All That", Thanks for making the posting on term rewriting systems. 1. Do you think it's possible to make a rewriting system extension to an existing language like Python or Perl? Everything seems to be in ML and ML extensions such as Isabelle right now. It's so easy to cook up (or integrate components into) whole systems in Python (or Perl) and since so many people use them in their day to day work modules have a greater chance of being used. 2. Are these term rewriting systems a broader category that would allow someone to implement for example different linguistic tools? What about non-roman script text processing? The composition of the Burmese *orthographic* syllable from underlying glyphs cannot be described by a context free grammar. There are even cross syllable dependencies/non-linearities, syllable n sometimes has glyphs in syllable n-1...and I assume this holds for all other Indic scripts. There are so many problems associated with these scripts ranging from sorting to word-wrap to what will be chosen as an item in the dictionary, it would be nice to have a generalized framework in which to think about them. Do you think rewriting systems (or discrimination nets/tries) might be a viable approach? There are so many different logical sets of tokens, display tokens, ordering/sorting/spelling tokens (a,b,c,d,e..), phonetic tokens, transliteration into roman script, transliteration of English words into Burmese... that have to be translated between in any application that features Burmese text (also applicable to Indian scripts in general) Meanwhile, people type fonts into documents. For one character/glyph there are about 8 different keys on the keyboard chosen based on context. Everyone thinks that unicode is going to solve all their problems. Unicode is only an encoding. I wrote sets of cascaded finite state transducers to do these translations but maybe term rewriting rules are the solution? Thanks again for the interesting posting. Jon Fernquest bayinnaung at hotmail.com (on the road right now) From " HPeter.Friedrichs" at alliedsignal.com Thu Sep 16 14:02:16 1999 From: " HPeter.Friedrichs" at alliedsignal.com (H. P. Friedrichs) Date: Thu, 16 Sep 1999 11:02:16 -0700 Subject: Newbie:Wants to access MySQL with Python Message-ID: <37E130A8.C5FC1B7F@alliedsignal.com> Hi: I have a Redhat linux box running mysql. I'd like to access a database using python (for cgi purposes). Supposedly, MySQLdb should help me do this. I downloaded MySQLdb, and attempted to build it per the instructions. The script build.py errors out when it can't find: /usr/lib/python1.4/config/Makefile.pre.in What is Makefile.pre.in? "Makefile" exists in the above directory, but Makefile.pre.in does not. What do I do next? Is there a different python module available to access MySQL? Thanks in advance Pete -- ----------------------------------------------- | The opinions expressed here are my own, | | and not necessarily those of my employer. | ----------------------------------------------- From tim_one at email.msn.com Sat Sep 4 02:40:06 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 4 Sep 1999 02:40:06 -0400 Subject: Turing Compliant? In-Reply-To: <37D09D5B.D31636BF@atl.mediaone.net> Message-ID: <000201bef6a0$5323adc0$842d153f@tim> [Kristopher Johnson] > But can Python efficently solve the Traveling Salesman Problem, > or other NP-complete problems? If it were thought possible to solve such things efficiently, they wouldn't be NP-complete <0.5 wink>. TSP in particular has had person-centuries of intellectual effort tossed at it, and the best algorithms known will certainly run faster in almost anything other than Python. OTOH, 1) If you're looking to write a nice framework in which to enter, visualize, and report TSP problems & results, Python can do everything including dynamically generate optimized native machine code tailored to each problem instance (if you're looking for peak efficiency, anything less is wimpy compromise ). 2) For problems that haven't yet been studied to distraction, a language like Python (other very high level languages fit here too, but Python is particularly well suited to this) lets you try out dozens of approaches with little effort. Over the years I've found hard-problem heuristics that allowed my Python program to run 1000x faster than a colleague's micro-optimized C, because I can code up & test 20 approaches in the time it takes them to remember how to declare a vector of functions returning a vector of pointers to pointers to structs <0.9 wink>. > That's the true measure of a language It's one measure of many, and Python does fine here. > (other than being able to compile its own compiler, of course). Which is another measure of many. It's too easy for Python to bother to compile itself, so it usually compiles Perl instead . ok-ok-perl-can't-even-be-parsed-ly y'rs - tim From lutz at rmi.net Tue Sep 7 15:01:09 1999 From: lutz at rmi.net (Mark Lutz) Date: Tue, 7 Sep 1999 19:01:09 GMT Subject: O'Reilly conference writeup Message-ID: <199909071901.NAA27541@shell.rmi.net> Just noticed: the latest installment of Frank Willison's column includes a few words about the open source movement, the recent O'Reilly Python conference, zope, and more. See: http://www.oreilly.com/frank/ And while I'm at it, a belated thanks to the conference organizers, especially David Ascher, for putting together a great event. --Mark Lutz From jam at quark.emich.edu Thu Sep 16 16:08:26 1999 From: jam at quark.emich.edu (Jeff) Date: Thu, 16 Sep 1999 16:08:26 -0400 Subject: python call external program (WHAT THE?!) In-Reply-To: <65118AEEFF5AD3118E8300508B124877073BF7@webmail.altiris.com>; from Mike Steed on Thu, Sep 16, 1999 at 12:04:16PM -0600 References: <65118AEEFF5AD3118E8300508B124877073BF7@webmail.altiris.com> Message-ID: <19990916160826.D8285@quark.emich.edu> On Thu, Sep 16, 1999 at 12:04:16PM -0600, Mike Steed wrote: > > Just to be nit-picky, forward slashes work fine in argv[0] when passed to > os.system (at least on WinNT, don't know about Win9x). So > os.system('c:/temp/junk.bat') works, but os.system('del c:/temp/*.*') and > the like will probably fail, depending on the executable. > > Of course, it is safest and most portable to use os.path. > > M. > ok, so the problem is actually in the effort to execute external (command.com) batch files, instead of implementing them in python directly. to the original poster: what is in the batch files? can you just make simple os.system() calls to get the job done? this will eliminate the path problem entirely. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From davidopp at megsinet.net Tue Sep 14 05:03:59 1999 From: davidopp at megsinet.net (David Oppenheimer) Date: Tue, 14 Sep 1999 05:03:59 -0400 Subject: Different Shaped Windows? Message-ID: <37DE0F7E.714FD6F7@megsinet.net> Dear Group, >From a posting in another newsgroup, I am told that you can: ===================================== "create windows that have different shapes than the ordinary "square" ones. You can do than thanks to the "regions" : What does that mean? In Win32 you can define regions and than assign them to already created windows. For example: SetWindowRgn(handle, CreateEllipticRgn(0,0,100,200), true) will create an elliptic window. MSDN has more info about regions. You can apply all sorts of operations to your regions like intersection, addition, etc. to obtain different shapes. ================================================= Question is: Can this same task (creating a non rectangular window) be accomplished with any of the GUI toolkits available to Python such as Tkinter or wxPython? David O. From bwinton at tor.dhs.org Wed Sep 1 19:16:05 1999 From: bwinton at tor.dhs.org (Blake Winton) Date: Wed, 01 Sep 1999 23:16:05 GMT Subject: Adding manual access to IDLE References: <37CB245C.3AF@loop.com> Message-ID: On Mon, 30 Aug 1999 17:39:56 -0700, JW wrote: >I am a very new user of Python, and although IDLE is a godsend(Ooh, >colors!), it was curiously missing any access to the Python >Documentation. I added a simple command to open the docs, but it is >pretty ugly, and I wonder if anyone else has noticed this problem or has >any sugestions about dealing with it? > >These are my alterations in the IDLE source: > os.system("C:\INTERNET\NETSCAPE\NAVIGA~1\PROGRAM\NETSCAPE.EXE >C:\python\doc\index.html") #JW Looks fine to me, up until this point... I don't have Netscape installed, and if I did, it wouldn't be on C:\... (It would probably be at /opt/netscape/bin/netscape) I like the idea, though, and am now wishing for a decent HTML Text Widget in Tkinter. (I know that Gnome has one, but I'ld like to maintain the cross-platformness of IDLE.) Oh well, I've got some vacation coming up, perhaps I'll build one. ;) Oh, yeah, and the docs are on a different place on my machine as well. Later, Blake. -- One Will. One Dream. One Truth. One Destiny. One Love. From hniksic at srce.hr Wed Sep 8 13:31:11 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 08 Sep 1999 19:31:11 +0200 Subject: Python example: possible speedup? In-Reply-To: Skip Montanaro's message of "Wed, 8 Sep 1999 11:53:20 -0500 (CDT)" References: <87puztv2gt.fsf@pc-hrvoje.srce.hr> <14294.37495.703177.461853@dolphin.mojam.com> Message-ID: <87906h5mzk.fsf@pc-hrvoje.srce.hr> Skip Montanaro writes: [...] Thanks for your comments. The package files aren't *humongous*, but they aren't exactly small either. One file is 700K, and the other is 3M large. It would be really nice if it were possible to process them in a stream. But I'll try it, for the sake of argument, and see if the speedup is worth it. > Also, instead of calling next_header on a line-by-line basis, how > about calling it once per package and returning a dict containing > the header names as keys? I'll try this too, and get back to you. That change will actually make the code more correct because it will no longer assume that `Package' header comes before `Status' and `Installed-Size' headers. From gherman at darwin.in-berlin.de Wed Sep 15 07:23:14 1999 From: gherman at darwin.in-berlin.de (Dinu C. Gherman) Date: Wed, 15 Sep 1999 13:23:14 +0200 Subject: Printing strings with null-bytes in Pythonwin? Message-ID: <37DF81A2.9B3A4793@darwin.in-berlin.de> Is is possible that Pythonwin has a problem with strings containing null-bytes? Or is the behaviour below to be expected as one cannot display null bytes in any meaning- ful way, so to say? If I run the following code from a script: str = ['\000'] * 4 # str = ['a'] * 4 print `str` from string import join print join(str, '') I get this traceback, pointing to a file winout.py which does not seem to mention any problems with null-bytes: """ Traceback (innermost last): File "C:\Program Files\Python\Pythonwin\pywin\framework\scriptutils.py", line 237, in RunScript exec codeObject in __main__.__dict__ File "C:\Usr\gherman\Misc\nullbytes.py", line 5, in ? print join(str, '') File "C:\Program Files\Python\Pythonwin\pywin\framework\winout.py", line 207, in write return self.template.write(msg) File "C:\Program Files\Python\Pythonwin\pywin\framework\winout.py", line 396, in write self.HandleOutput(message) File "C:\Program Files\Python\Pythonwin\pywin\framework\winout.py", line 381, in HandleOutput return self.QueueFlush() File "C:\Program Files\Python\Pythonwin\pywin\framework\winout.py", line 364, in QueueFlush self.currentView.ReplaceSel(self.outputQueue.get_nowait()) TypeError: ReplaceSel, argument 1: expected string without null bytes, string found """ If you write the same in an interactive Pythonwin window you'll get the following, indicating that the problem only occurs when you actually try to print the string containing null-bytes: >>> str = ['\000'] * 4 >>> print `str` ['\000', '\000', '\000', '\000'] >>> from string import join >>> join(str, '') '\000\000\000\000' >>> print join(str, '') Traceback (innermost last): File "C:\Program Files\Python\Pythonwin\pywin\framework\interact.py", line 372, in keyhandler_enter self.DrawPrompt() File "C:\Program Files\Python\Pythonwin\pywin\framework\interact.py", line 120, in DrawPrompt self.flush() File "C:\Program Files\Python\Pythonwin\pywin\framework\winout.py", line 212, in flush return self.template.flush() File "C:\Program Files\Python\Pythonwin\pywin\framework\winout.py", line 399, in flush self.QueueFlush() File "C:\Program Files\Python\Pythonwin\pywin\framework\winout.py", line 364, in QueueFlush self.currentView.ReplaceSel(self.outputQueue.get_nowait()) TypeError: ReplaceSel, argument 1: expected string without null bytes, string found >>> If the reasoning at the beginning is the official one (null- bytes cannot be displayed anyway), it's interesting to note the difference to a Python interpreter running on Linux, where you get as boring a result as can be expected, but at least it does not fail: >>> str = ['\000'] * 4 >>> print `str` ['\000', '\000', '\000', '\000'] >>> from string import join >>> join(str, '') '\000\000\000\000' >>> print join(str, '') >>> Just curious, Dinu -- Dinu C. Gherman ................................................................ "An average of more than 15 % of adults in 12 industrialized countries are functionally illiterate; in Ireland, the United Kingdom and the United States, the rates are over 20 %." (The State of the World's Children 1999, UNICEF, http://www.unicef.org/sowc99) From nascheme at ucalgary.ca Wed Sep 15 19:21:02 1999 From: nascheme at ucalgary.ca (Neil Schemenauer) Date: Wed, 15 Sep 1999 23:21:02 GMT Subject: Lazy file.readlines()? References: <87hfl546rx.fsf@pc-hrvoje.srce.hr> <014801befa94$26f225e0$f29b12c2@secret.pythonware.com> Message-ID: Fredrik Lundh wrote: >Hrvoje Niksic wrote: >> > - reading a file one line at a time (self.__fp.readline()) >> >> I don't see an alternative to this, except to read the whole file at >> once, which I am trying to avoid, as the files are large. > >note that: > > lines = fp.readlines(16384) > if not lines: > break > for line in lines: > ... > >is usually much faster than > > line = fp.readline() > if not line: > break > ... What would be cool is if readlines() returned a lazy sequence object (ie. only read as much is needed using a certain block size). This should give the advantages of readlines() without the concern about sucking up a huge file all at once. I implemented this idea (probably badly) in pure Python and got about a 2x speedup verses readline(). It is a small module so I will post it here. being-lazy-has-its-advantages'ly Neil import string class BlockFile: def __init__(self, file, blocksize=1024*40, sep='\n'): self.file = file self.blocksize = blocksize self.sep = sep self.line = -1 self.lines = [] self.end = '' def __getitem__(self, i): try: self.line = self.line+1 return self.lines[self.line] except IndexError: self.line = 0 self._get_block() return self.lines[0] def _get_block(self): data = self.file.read(self.blocksize) if len(data) == 0: raise IndexError self.lines = string.split(data, self.sep) self.lines[0] = self.lines[0] + self.end if len(data) == self.blocksize: self.end = self.lines[-1] del self.lines[-1] # this _should_ be fast else: self.end = '' def test_block(input): for l in BlockFile(open(input)): pass def test_normal(input): f = open(input) while 1: l = f.readline() if not l: break def measure(function, *args): import time t1 = time.time() apply(function, args) t2 = time.time() apply(function, args) return t2-t1 if __name__ == '__main__': import sys print 'block time', measure(test_block, sys.argv[1]) print 'normal time', measure(test_normal, sys.argv[1]) From kuncej at mail.conservation.state.mo.us Mon Sep 13 15:04:28 1999 From: kuncej at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Mon, 13 Sep 1999 14:04:28 -0500 Subject: Examples using urllib, htmllib Message-ID: >Can someone point me to some example Python >scripts that I can download that show accessing >the web using the urllib, and htmllib. I'm a simple example: urlpost.py at http://starship.python.net/~jjkunce/ >One problem I may have is that the ... operations >at the web site i...appear to be Java applets uh oh. That may be a problem. I've been using python's COM capabilities to access https sites, and to automate browsing through some pretty tricky javascript pages. I don't know if it would help with java applets, though. See msiecom.py at the same site. --Jeff From aa8vb at yahoo.com Wed Sep 15 11:55:42 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Wed, 15 Sep 1999 11:55:42 -0400 Subject: Python, FastCGI and FreeBSD In-Reply-To: <7ro4d9$apg$1@nnrp1.deja.com>; from henk_p@my-deja.com on Wed, Sep 15, 1999 at 12:45:32PM +0000 References: <7ro4d9$apg$1@nnrp1.deja.com> Message-ID: <19990915115542.A1922501@vislab.epa.gov> henk_p at my-deja.com: |I am experiencing this strange problem with a Python script running as a |fastCGI application under FreeBSD 3.2. For some reason when the fastcgi |process manager in Apache starts the script, it (or the Python |interpreter) immediately crashes. It does not matter what the script |contains, it always crashes upon initialization. ('Uncaught signal 11, |Segmentation Fault' as it says in the apache error log) Hard to say. I've not seen this with the Python 1.5.2 package running on FreeBSD 3.2, though I've not run Python underneath a web server -- only in the background and interactive. Try adding "-v" to the Python invocation for the script. For example, if the first line is of the form '#!.....python', change it to '#!/usr/local/bin/python -v'. This may give you an idea what it's in the process of doing when it SEGVs (loading a corrupted shared library, etc.). Randall From clgonsal at keeshah.penguinpowered.com Thu Sep 2 19:36:27 1999 From: clgonsal at keeshah.penguinpowered.com (C.Laurence Gonsalves) Date: Thu, 02 Sep 1999 23:36:27 GMT Subject: Returning none References: <000001bef265$fe64f340$192d153f@tim> <37CC79C5.1BFDC710@compaq.com> <7qidi6$nbb$1@towncrier.cc.monash.edu.au> Message-ID: On 1 Sep 1999 05:28:38 GMT, Jonathan Giddy wrote: > Greg Ewing writes: > >The compiler knows whether the result of any given > >call gets used or not. Suppose it generates CALL_FUNCTION > >when the result is used, and a new opcode CALL_PROCEDURE > >when it doesn't. > > > >CALL_PROCEDURE checks that the result is NotARealObject > >(I'll call it Void from now on) and raises an exception > >otherwise. CALL_FUNCTION does the opposite. > > This requires that we always use the result of a call to a real function, > even if we just assign it to a dummy variable. And that means someone > will one day spend time trying to find where the dummy variable is used, > instead of instantly being aware that the function is only called for its > side effects. > > For example, FileObject.close needs to be a function to return the exit > status of a popen process. Hence, every file close will need to be > assigned (or used in some way). That's why I suggested the addition of a new type of statement, similar to 'EVAL' statements in Modula-3. In Modula 3, a function call is not a legal statement (but a procedure call is). If you reall want to call a function though without getting the result you would say: EVAL MyFunctionWithAUselessResult(); Since 'eval' is already used for something in Python, I'd suggested that the Python equivalent could be called 'discard'. discard inFile.close() -- C. Laurence Gonsalves "Any sufficiently advanced clgonsal at kami.com technology is indistinguishable http://www.cryogen.com/clgonsal/ from magic." -- Arthur C. Clarke From skip at mojam.com Fri Sep 3 14:01:38 1999 From: skip at mojam.com (Skip Montanaro) Date: Fri, 3 Sep 1999 13:01:38 -0500 (CDT) Subject: Returning none In-Reply-To: References: <1275758005-72447341@hypernet.com> Message-ID: <14288.2906.802899.222390@dolphin.mojam.com> G> So put me firmly in the camp that favors a stronger PyLint (I just G> recently got bit by a rarely used bare return in some released code). C> This is akin to saying array-bounds checking should be done by PyLint C> rather than the runtime. The problem is, a lot of these checks simply C> can't be done statically. I'll assert here without proof that the primary mistake programmers are likely to make in this regard is to include both "return " and "return" (or the terminating byte code) in the same function. This sort of error a program like PyLint could indeed check. There's be no need to add the overhead of checking for incorrect function/procedure return semantics at run-time. C> In fact, while I was originally proposing some compile-time checks as C> well, I've basically given up on those. They were mostly incomplete C> (Python is too dynamic to be able to do much static checking in this C> situation) and Tim found a real problem with them. Perhaps I missed something (this thread is getting rather long and drawn out). What sort of situation would PyLint miss that my proposed static check wouldn't catch? Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/~skip/ 847-971-7098 | Python: Programming the way Guido indented... From tim_one at email.msn.com Mon Sep 13 22:37:42 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 13 Sep 1999 22:37:42 -0400 Subject: Queue not releasing memory In-Reply-To: Message-ID: <000601befe5a$1ebbf9e0$e7a0143f@tim> [Nathan Clegg] > ... > I do need the thread-safety of the Queue class. The large size > requirement is only an extreme situation, which is why it is important > that it backs down afterward. Still unclear why "backing down" is important. The VM high-water mark is really of no practical interest on most systems. Python isn't using the memory any more, so it's not costing anything except a hole in the address space (which your libc malloc may or may not release to the OS someday, or may or may not reuse for its own purposes again -- why do you care?). > ... > Is there no way to remove an element from a list without making a copy? Python lists are contiguous vectors of C pointers. If you remove an element from "the front" (as Queue does), all the remaining elements have to "slide left" one position. If it's not the queueness but the thread safety that attracts you, subclass Queue and remove elements from "the rear" (i.e., use x.pop() instead of del x[0] -- then it acts like a stack instead of a queue). Then copying will rarely be needed. If you want both a queue and no-copying, implement a two-pointer circular buffer. > append() doesn't need a copy. It usually doesn't; it certainly may. > I was under the impression that lists were internally represented by a > more dynamic form. I believe you . purge-your-soul-of-falsehoods-and-fear-of-artificial-integers-ly y'rs - tim From jam at quark.emich.edu Thu Sep 16 18:23:54 1999 From: jam at quark.emich.edu (Jeff) Date: Thu, 16 Sep 1999 18:23:54 -0400 Subject: Redhat Python RPM In-Reply-To: <37E149D4.B7168314@callware.com>; from Ivan Van Laningham on Thu, Sep 16, 1999 at 07:49:40PM +0000 References: <37E149D4.B7168314@callware.com> Message-ID: <19990916182354.B8531@quark.emich.edu> On Thu, Sep 16, 1999 at 07:49:40PM +0000, Ivan Van Laningham wrote: > Hi All-- > Who has the RPM for Redhat 6.0? The one that doesn't break RHs stuff? > > -ly y'rs, > Ivan I use the versions from andrich, and I haven't had any troubles with the redhat tools.. anything in particular I should test to see? what exactly is getting broken? regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From fn at panix.com Thu Sep 16 12:08:23 1999 From: fn at panix.com (Felicia Neff) Date: Thu, 16 Sep 1999 12:08:23 -0400 Subject: cgi post question Message-ID: Yes, this is yet another newbie question: I am trying to write a CGI script that takes input from a POST, modifies some of the input and then POSTs that info to another CGI script. I know that perl has a function that will do this. Is there such a function in python (and if it is do_POST() from the CGIHTTPServer module, is there any more documentation besides that at http://www.python.org/doc/current/lib/module-CGIHTTPServer.html?)? Thanks -- Felicia ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fn at panix.com Felicia Neff From davidopp at megsinet.net Thu Sep 16 03:01:06 1999 From: davidopp at megsinet.net (David Oppenheimer) Date: Thu, 16 Sep 1999 03:01:06 -0400 Subject: [Fwd: Article Submissions Wanted at Dr. Dobbs] Message-ID: <37E095A6.FF9B2267@megsinet.net> Couldn't resist the urge to post this. David O. -------------- next part -------------- An embedded message was scrubbed... From: "Antony Chesworth" Subject: Article Submissions Wanted at Dr. Dobbs Date: Thu, 16 Sep 1999 00:25:38 +0100 Size: 1310 URL: From aboukirev at iname.com Sun Sep 5 19:57:36 1999 From: aboukirev at iname.com (Alexei Boukirev) Date: Sun, 5 Sep 1999 18:57:36 -0500 Subject: Python speed and `pcre' References: <00af01bef543$0affe8f0$f29b12c2@secret.pythonware.com> Message-ID: <5FDA3.8705$6k7.2096@nntp0.chicago.il.ameritech.net> Fredrik Lundh wrote in message news:00af01bef543$0affe8f0$f29b12c2 at secret.pythonware.com... > Fran?ois Pinard wrote: > > I do not fully understand the cost of splitting. If strings are immutable, > > there is really no need to copy a slice contents. > > except that 1) each string needs an extra reference pointer > (as long as we're using refcounting, at least), and 2) that people > can easily end up in situations where huge strings are clogging > up all available memory, just because some part of their program > is hanging on on to a 2-character substring... > > (fwiw, the unicode string type implements substring > support, using it for the "split" and "slice" methods. > still not sure if that's really a great idea...) > > > Somewhere, it is said that some extra-space is allocated at end of sequences, > > to allow for some peaceful growth. Does `str=str+str1' at least attempt > > to use of this extra-space? It should, in my opinion. > > how? before you tell me, consider that strings are immutable, > and variable names are references. Ah-h! Here goes the difference from Perl. Perl strings (to my knowledge) are mutable. They consist of series of chunks - greatly speeds up all splits/joins/substring replacement (same things with Perl arrays). A little slower on iterating through string contents. Also, Perl DOES optimize compiled regexps, there's a great deal of analisys done by regexp compiler to do that (anchors, long constant substrings, branching prediction). Alexei From cfelling at iae.nl Sun Sep 19 12:33:07 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 19 Sep 1999 18:33:07 +0200 Subject: Force anything to be a string. References: Message-ID: <7s3383$gn9$1@vvs.superst.iae.nl> jonathon wrote: > On Sat, 18 Sep 1999, Tim Peters wrote: ... >>Using the builtin str function was the correct approach from the start. >>From the error msgs you're getting, it looks most likely that you >>accidentally rebound the name "str" to a string, so "str" no longer refers ... > A little poking around, and I found an object called > str in two modules that the script calls. After changing > the name of those variables, that error disappeared. :-) >>to the builtin function (builtin function names are not reserved, which is >>both a feature and a bug <0.7>). > A bug, IMNSHO. A really bad bug, since I wasn't even using a module I wrote. You probably used `from other_module import *', you naughty boy:) >From the docs I learned not to do that unless the imported module was specifically designed for that construct, like Tkinter. -- groetjes, carel From 71351.356 at compuserve.com Mon Sep 27 21:12:39 1999 From: 71351.356 at compuserve.com (T. C. Mits) Date: Mon, 27 Sep 1999 21:12:39 -0400 Subject: Python guide Brain posted Message-ID: <7sp529$ipg$1@ssauraab-i-1.production.compuserve.com> FYI: I created an initial version of a guide to the Python language using Natrificial's TheBrain technology. Its posted to their ThinkTank (a database of user created Brains) at: I won't quote what the Brain is and all that (see www.theBrain.com); it may appear I'm directly advocating something or spamming. Anyway, I think its pretty usable, especially for Python Newbies, like me. Any suggestions on its layout would be appreciated. Unfortunately, a 'guide' Brain in contrast to a web hosted 'Web Site' Brain, requires Windows and a two meg download for a trial version of the client which doesn't overwrite DLLs!). They state that other platforms, like Unix and palm computers, are under development. Me. From john.grayson at gsc.gte.com Tue Sep 14 21:45:43 1999 From: john.grayson at gsc.gte.com (john.grayson at gsc.gte.com) Date: Wed, 15 Sep 1999 01:45:43 GMT Subject: high school programming & python In-Reply-To: <2BAF9178787E2D18.F80B717C3A0115B2.701123DC5A66FDBE@lp.airnews.net> References: <2BAF9178787E2D18.F80B717C3A0115B2.701123DC5A66FDBE@lp.airnews.net> Message-ID: <7rmto7$umu1@eGroups.com> > If a mercury delay line won't pass it, it's not worth computing. Ooh! This gives me goosebumps! When I first started at Thames Polytechnic in London, they still were keeping their Elliot system running, resplendent with its mercury delay line. Plus! (MS reference?) they changed multiple triodes every day. You havn't lived until you have compiled Algol with paper tape for the intermediate... From arcege at shore.net Sun Sep 26 08:34:39 1999 From: arcege at shore.net (Michael P. Reilly) Date: Sun, 26 Sep 1999 12:34:39 GMT Subject: Read stdout from shell command, was: Becoming root References: <19990924165114.A753@krikkit.vollmert.home> <7sgbor$13vk$1@nntp6.u.washington.edu> Message-ID: Donn Cave wrote: : Quoth wware-nospam at world.std.com (Will Ware): : ... : | The thing I'd really like to know is how to do the Python : | equivalent of a shell command of this form: : | : | variable = `some shell command` : | : | where "some shell command" prints to standard output. : | I find I do this quite frequently, usually using something like : | os.popen('some shell command').readline()[:-1] and sure, it works, : | but it's really ugly, and I'm always left with the nagging suspicion : | that since I didn't explicitly close the os.popen(), it might still : | be floating around. : Empirically, the pipe file descriptor does close when the object goes : out of scope, from what I see with other file descriptor unit numbers : allocated subsequently by pipe() or open(). : I rolled my own pipe/fork/exec system a ways back and use it a lot, : and you're welcome to it - : ftp://ftp.u.washington.edu/pub/user-supported/donn/cmdproc.py : I use it mostly the way you describe, to store the output of a : command in a variable. The long way to spell it is : variable = cmdproc.RaiseCommand('/bin/sh', : ('sh', '-c', 'some shell command')).expand() : (Actually I often invoke the command directly rather than through the : shell, but the above example serves to illustrate both.) : The RaiseCommand class also raises an exception when the command exits : with an error, with the exception value set to the diagnostic (unit 2) : output. I think that's the feature that really sets this apart from : just another way to spell popen(). There is also the standard library module "commands", which does all but remove the trailing newline (if present). It uses os.popen (and implicit Bourne syntax), but does quote the arguments for you. (Although, Donn's would probably be more efficient. :) -Arcege From bernhard at alpha1.csd.uwm.edu Wed Sep 1 16:13:50 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 1 Sep 1999 20:13:50 GMT Subject: language interpreters/ interpreted languages weaknesses? References: <7qi3q3$n1d$1@nnrp1.deja.com> <37CCE10D.D07D023B@strs.co.uk> Message-ID: On Wed, 01 Sep 1999 09:17:17 +0100, Ian Clarke wrote: >> Are there any other major weaknesses of interpreted languages over >> conventional languages such as C, C++, Ada etc.? >Speed is the only one I can think of It is harder to do type-checking for the whole program, because most interpreted languages also have syntax allowing more dynamic constructs and require less declaration. >> What are the most popular interpreted languages around? Beside from the other suggestions. Basic, shell and lisp/scheme probably deserve mentioning. Bernhard -- Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard) Association for a Free Informational Infrastructure (ffii.org) From arcege at shore.net Fri Sep 10 17:23:00 1999 From: arcege at shore.net (Michael P. Reilly) Date: Fri, 10 Sep 1999 21:23:00 GMT Subject: Python-based IRC bots..and a #python channel References: <37D879A1.EE4D10DE@op.net> <19990910223230.A849@optiplex.palga.uucp> Message-ID: Gerrit Holl wrote: :> Also, is there an :> "official" #python channel somewhere? If there isn't, we should :> establish one. Any info would be greatly appreciated. :> : I agree that we should establish one. But why should it be "official"? Can't we : all just go to #python? It grows to the 'official' one of itself then. I seem to remember there being a #python channel on EFnet some time ago. I'm not sure what happened to it tho (I don't see it there now). -Arcege From robin at jessikat.demon.co.uk Wed Sep 1 14:12:40 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Wed, 1 Sep 1999 19:12:40 +0100 Subject: tkinter & threads Message-ID: Is Tkinter thread safe? I looked at Guido's brownian demo and there are no special precautions about locking the canvas. Also I believe there is some restriction on which thread Tk can live in. -- Robin Becker From legion at dialnet.net Sat Sep 4 11:20:33 1999 From: legion at dialnet.net (Andrew Kesterson) Date: Sat, 04 Sep 1999 10:20:33 -0500 Subject: "if" syntax error Message-ID: <37D138C1.3EABC811@dialnet.net> I've got a CGI script (python) set to check the value of form element "Listing_Type", and it does it as thus: CGIHeaders = cgi.FieldStorage() if CGIHeaders["Listing_Type"].value == "Residential": when I compile it, I get this error: File "C:\Program Files\Python\Source\Skydev\addlisting.py", line 82 if CGIHeaders["Listing_Type"].value == "Residential": ^ SyntaxError: invalid syntax There is NO WAY that this is invalid syntax! I've used if comparisons like that one hundreds of times and compiled fine! What's going on? Or is it just that my CGI *really* doesn't want to run from command line? -- "I never came across anyone in whom the moral sense was dominant who was not heartless, cruel, vindictive, log-stupid and entirely lacking in the smallest sense of humanity. Moral people, as they are termed, are simply beasts. I would sooner have fifty unnatural vices than one unnatural virtue." --Oscar Wilde From fdrake at acm.org Fri Sep 10 12:13:58 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 10 Sep 1999 16:13:58 GMT Subject: And now for something completely boneheaded... In-Reply-To: <37D9136B.9298EFD1@nightwares.com> References: <37D623A2.DC09F0CC@nightwares.com> <37D7E456.728C0BC1@nightwares.com> <37d7f333.949751@news.erols.com> <37D9136B.9298EFD1@nightwares.com> Message-ID: <14297.11846.480435.373371@weyr.cnri.reston.va.us> Robert Kern wrote: > Hmmm. I think it may be time to reconsider the > distribution/documentation split. Warren 'The Howdy Man' Ockrassa writes: > Sigh, no, it's not; all that information is included, in HTML form, in > the "Doc" directory in the Win32 install. The split Robert is referring to doesn't exist for Windows users working from the binary installer. The source package (used by many Unix users) does not include any documentation, but used to include the LaTeX source and pre-generated PostScript for all the standard manuals. I still think the split is the right thing. Most people don't *want* the LaTeX source or even the PostScript. Using a separate distribution for the documentation allows users to select the formats they're interested in without having to download a lot of other material. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From super_banane at yahoo.com Thu Sep 2 11:40:50 1999 From: super_banane at yahoo.com (super_banane at yahoo.com) Date: Thu, 02 Sep 1999 15:40:50 GMT Subject: getpass.getpass() bugged? Message-ID: <7qm5q0$lct$1@nnrp1.deja.com> The getpass.getpass() function should be requesting a password without echoing it... but unfortunately it does: >>> import getpass >>> getpass.getpass() Password: hello 'hello' >>> Python I use is v1.5.2 Same behaviour on Solaris 2.6 and HPUX-10.20. Works fine with Python v1.5.1 on Linux, though. -- Nicolas Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From akuchlin at mems-exchange.org Tue Sep 21 15:26:58 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 21 Sep 1999 15:26:58 -0400 Subject: Python for younger children References: <37E70E89.55132AEA@bosware.com.au> <37E728B1.8ACA53FB@webone.com.au> Message-ID: <3d1zbsvzel.fsf@amarok.cnri.reston.va.us> Stuart Hungerford writes: > I'd be interested to hear your experiences, my 10 and 8 year old are > keen to learn as well. I've downloaded Alice (see www.alice.org) > which > uses Python to manipulate 3D graphics objects, but I'm sure there > must > be a simpler approach. There's a turtle.py module in Python 1.5.2 that requires Tk. Try this: amarok lib-tk>python Python 1.5.2 (#80, May 25 1999, 18:06:07) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> from turtle import * >>> reset() >>> forward(30) >>> right(90) For some reason it only shows the turtle when it's actually moving; someone should implement showturtle()/hideturtle(). -- A.M. Kuchling http://starship.python.net/crew/amk/ The NSA response was, "Well, that was interesting, but there aren't any ciphers like that." -- Gus Simmons, "The History of Subliminal Channels" From bsb at baal.infodrom.north.de Sat Sep 25 15:07:51 1999 From: bsb at baal.infodrom.north.de (Siggy Brentrup) Date: 25 Sep 1999 21:07:51 +0200 Subject: python and I/O In-Reply-To: "Bill Rodgers"'s message of "Sat, 25 Sep 1999 11:57:03 -0600" References: <%4YG3.3867$UD4.20078@news.rdc1.az.home.com> <19990925130345.A11328@optiplex.palga.uucp> <%W7H3.1233$Pv.61638@news.uswest.net> Message-ID: <87u2oibyig.fsf@baal.winnegan.fake> "Bill Rodgers" writes: > I don't see how reading and writing to a file descriptor > provides access to serial ports, parallel ports or memory > mapped I/O. Usually serial ports require more specific > setup criteria such as baud rate, character format (N-8-1, etc). If you are allowed to access I/O ports directly isn't a language, but an operating system issue. Any decent OS, in particular a multitasking one, must protect itself and its users from misbehaved programs. >From your answer to Gerrit I presume you want to control a serial port. If you're running on *nix, use /dev/ttyS* and look into the termios(+TERMIOS) module for setting up serial parameters. I don't care enough about Win?? to know their way. CU Siggy btw Gerrit: even with your own interpretation RTFM stays bad style. -- >>>> In a world without fences, who needs gates? Siggy Brentrup - bsb at baal.infodrom.north.de - voice: +49-441-6990134 From tim_one at email.msn.com Fri Sep 10 02:16:27 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 10 Sep 1999 02:16:27 -0400 Subject: Python Error Messages In-Reply-To: Message-ID: <000201befb54$03f58800$a52d153f@tim> [jonathon] > Why are PythonError messages so annoying? Because the tracebacks you're getting aren't showing the lines of code that are actually failing. I can explain why that's happening, but it's obscure: when Python goes to print a traceback, it uses the platform libc fgets function to read one line at a time, until the target line number is reached. It passes fgets a buffer big enough to hold 1000 characters. fgets won't actually read a full line if it sees 1000 characters go by without seeing a newline, so any line of code in your .py file that's longer than 1000 characters will screw up the line count hopelessly. There are 7 lines of code in the script more than 1000 characters long, and that's the source of your traceback woes. The long lines are at: 744 745 746 20628 20629 20632 20633 Break those lines into non-insane pieces, and the traceback problem will go away. > I've been trying to debug a script for the last four days, > to no avail. This is a 21,000+ line script, without a class or module of its own, no testing framework or even hooks, and hard-coded little integers on nearly every line. In all honesty, you may well spend the next four months trying to debug it. > With two of the four databases I run it on, the script does just what it > is supposed to. On the other two databases, it doesn't. The most likely cause is that the latter databases contain data that the code doesn't handle correctly, data in a form or combination that simply never appeared in the former two databases. That's almost certainly not a Python problem, but logical errors in the code. > The current exasperating error message: > > Traceback (innermost last) > File "mass.py", line 21102 in ? > print changed_field, " is record_list[28] " > File "mass.py", line 20610 in print_web_page > table_prefix = "

' caption = '"Stamp Data"
" table_break = " " table_suffix = "
" > TypeError: illegal argument type for built in operation. The 3 long lines at 744, 745 & 746 are each getting counted as two lines by fgets, so the traceback is actually showing you line 20610-3 = 20607. The true line 20610 is title_name = (title_prefix + country_name + bang_two + scott_data + bang_two + michel_data ) One of title_prefix etc probably isn't a string (mostly likely is an integer, or None). IOW, the code is assuming that earlier code bound these names to strings, but earlier code didn't. > Now what is infuriating, is that the script has run over this > particular code sequence at least 4000 times, before giving me > this error. That's normal for a data-dependent error. > Questions: > > What would trigger these error messages, when there were no > apparant problems earlier? The overwhelmingly most likely cause is errors in the code that didn't show up before simply because the pattern of data that triggers them didn't show up before. > How do I do exception handling that maintains something sane, > when the script obviously isn't? I don't mean to be abrasive, but the plain truth is that the script is already a maintenance nightmare. Without a rational design you're not going to patch in robust behavior after the fact. This script should be 10x shorter than it is, and 10x faster too -- whoever wrote it was clearly not an experienced Python programmer, and didn't do any of the things an experienced one would have done to make recovering from errors pleasant. Consider cutting your losses -- if you're the author, sorry, but you bit off more than you're ready to chew. Strongly consider hiring a Python consultant to get you on the right track with this (not a plug -- I don't work for money or love ). > One thing i have noticed, is that the print statements I put > in, to try to follow what was happening, tend to indicate > that the actual problem is more than a couple of lines away > from the line(s) that are quoted on the screen. Right; see above. > ... > For the curious the other obnoxious error is: > "IndexError: string index out of range" > > Obnoxious, because: > A) It is supposed to be looking at a list, not a string. The msg is almost certainly telling you the truth: you may *expect* it to be looking at a list, but it's telling you as plain as day that you actually gave it a string. That's a great clue, not a plague . > B) The actual error is several hundred lines from where > the message occurs. ? Sorry, don't know what that means. if-you-thought-this-was-fun-try-rewriting-in-perl-ly y'rs - tim From jblake at stamp-coin.com Sun Sep 19 01:39:33 1999 From: jblake at stamp-coin.com (jonathon) Date: Sun, 19 Sep 1999 05:39:33 +0000 (UTC) Subject: Force anything to be a string. In-Reply-To: <000101bf0232$7792e840$072d153f@tim> Message-ID: On Sat, 18 Sep 1999, Tim Peters wrote: >[jonathon] >> Question: >> >> 1: How can I ensure that string_check becomes a string, >> and not remain an integer? [ Other than error trapping at >> the source. An option not available, since this script reads >> files with bad data in them, to correct them. ] > >Using the builtin str function was the correct approach from the start. >>From the error msgs you're getting, it looks most likely that you >accidentally rebound the name "str" to a string, so "str" no longer refers Aaarrgh. I ran the script with the statement print str, " is the trapped string." I totally expected the script to fail. Instead, it printed out a string "MMMMM" A little poking around, and I found an object called str in two modules that the script calls. After changing the name of those variables, that error disappeared. :-) >to the builtin function (builtin function names are not reserved, which is >both a feature and a bug <0.7>). A bug, IMNSHO. A really bad bug, since I wasn't even using a module I wrote. >The error msg there should look familiar. It's telling you that the syntax >looks like a call, but the object in the caller's position *can't* be called >("call of non-function"); and it's also giving the type of the object that >can't be called (str is of "type string"). Another piece of wisdom to add to the list of things I couldn't find in _The Python Library Reference Manual_. >diagnosis-may-be-easier-than-cure-ly y'rs - tim I found a neat little script xref.py, that produces a cross reference for a file. Threw it at my program, and then the modules, and found the very_badly_named_variables, that were causing those error messages. xan jonathon From actgal8 at aol.com Fri Sep 3 19:09:53 1999 From: actgal8 at aol.com (actgal8 at aol.com) Date: Fri, 03 Sep 1999 17:09:53 -0600 Subject: 18 AND OVER 59713 Message-ID: <030999170953@aol.com> free xxx pics: http://207.240.225.250 5LwxM\qH From stadt at cs.utwente.nl Wed Sep 22 09:23:25 1999 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Wed, 22 Sep 1999 15:23:25 +0200 Subject: cgi authentication References: <37E8902F.45998A4D@cs.utwente.nl> <00a401bf04d4$ad71d6c0$f29b12c2@secret.pythonware.com> Message-ID: <37E8D84D.A94F8906@cs.utwente.nl> Fredrik Lundh wrote: > > Richard van de Stadt wrote: > > Then in SomeScript you can work with the variables 'login' and > > 'password'. I guess you must have thought of this. But one > > never knows :-) > > > > But you'll have to make your own (encrypted?) password file > > for this to work (or get the source of htpasswd to find out > > how passwords are encrypted for use with .htaccess). > > iirc, they use crypt (just like /etc/password). given > that you've enabled the crypt module, you can use > something like this: > > def login(user, password, encrypted_password): > "Check if user would be able to login using password" > pw1 = encrypted_password > pw2 = crypt.crypt(password, pw1[:2]) > return pw1 == pw2 > > (derived from an example in "(the eff-bot guide to) > The Standard Python Library" -- out soon!). > > finding the password file is left as an exercise... > > 1) How does one enable the crypt module if it is not available in the Python library? Do I have to ask our Python maintainer to rebuild it? 2) The crypt-statement looks strange to me. Why are the first 2 characters of the encrypted password (apparently retrieved from the password file) feeded into crypt()? Or is this just the standard way password encryption is done? Richard. From tjreedy at udel.edu Sat Sep 25 01:20:55 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 25 Sep 1999 05:20:55 GMT Subject: A more straightforward solution wanted References: Message-ID: <7shm3n$hbi$1@news.udel.edu> jblake at stamp-coin.com says... > I'm bashing my head trying to think of a more straightforward > way to do the following: ... > Is there a more straightforward method of doing this, other > than using yet another database, for the lookup functions, etc? One possibility: use Python dictionaries For instance, after > if scott_number = 1: > return_list[44] = " " mentally replace > if scott_suffix = " ": > return_list[45] = 1 > return_list[46] = "Type A" > return_list[51] = " " > return_list[52] = 1 > return_list[53] = " " > elif scott_suffix = "a": > return_list[45] = 1 > return_list[46] = "Type B" > return_list[51] = " " > return_list[52] = 1 > return_list[53] = "b" > else: > return_list[45] = 1 > return_list[46] = "Type A/Italic Z" > return_list[51] = " " > return_list[52] = 1 > return_list[53] = "a" with (return_list[45], return_list[46], return_list[51], return_list[52], return_list[53]) = {" ":(1,"Type A"," ",1," "), "a":(1,"Type B"," ",1,"b")}.get( scott_suffix, (1,"TypeA/Italic Z"," ",1,"a")) Now, the dictionary and default each depend on the scott_number 1 to 5, so each can be replaced by a list of choices indexed by scott_number. IE, (untested) #before loop, so execute only once list_of_dicts = [ "dummy list item for unused index 0", {" ":(1,"Type A"," ",1," "),"a":(1,"Type B"," ",1,"b")}, {#dict for scott_number 2}, #etc for 3, 4, and 5 ] list_of_default_tuples = [ "dummy for 0", (1,"TypeA/Italic Z"," ",1,"a), #etc for 2,3,4,5 ] ... Then, within loop (or func called for each line), possible after checking scott_number in range 1...5, (return_list[45], return_list[46], return_list[51], return_list[52], return_list[53]) =\ list_of_dicts[scott_number].get( scott_suffix, list_of_default_tuples[scott_number]) This compresses about 100 lines to less than 20. Terry J. Reedy From tom22 at verio.com Wed Sep 1 15:18:35 1999 From: tom22 at verio.com (Tom) Date: Wed, 01 Sep 1999 12:18:35 -0700 Subject: Newby:Looking for an article describing C++ vs. Python Message-ID: <37CD7C0B.351D5E8D@verio.com> Hi, This is from a real newby to Python and should not be considered flame bait. I have programmed in C for years and have recently begun using C++ and classes, etc. I am interested in Python/Perl/Tlc as a scripting language but without having studied either of them I would like to know, for example, what kinds of things that you can do in C++ that you can not do in Python. I know that the Python language is written in C and I know that a compiled language will tend to run faster that an interperted language. Is there an article where someone has done a comparison of C++ to Python? Thanks Tom From fredrik at pythonware.com Thu Sep 2 08:39:32 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 2 Sep 1999 12:39:32 GMT Subject: language interpreters/ interpreted languages weaknesses? References: <37CE562F.1A368670@strs.co.uk> <002701bef535$68a88920$f29b12c2@secret.pythonware.com> <37CE69C0.6AC977E0@strs.co.uk> Message-ID: <009701bef540$356cfe00$f29b12c2@secret.pythonware.com> > I am not talking about what the user notices, I am talking about > what the developer does hmm. I'm pretty sure you used the word "user" in your last post. sorry for not understanding that you really meant something else. over and out /F From mwh21 at cam.ac.uk Fri Sep 3 13:24:49 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 03 Sep 1999 18:24:49 +0100 Subject: Newbies: Re: Returning none References: <000001bef265$fe64f340$192d153f@tim> <37CF5499.BA24C33E@prescod.net> Message-ID: "Evan Simpson" writes: > Michael Hudson wrote in message > news:Pine.LNX.4.10.9909031629210.21765-100000 at atrus.jesus.cam.ac.uk... > > Got bored. > [and implemented the whole damn thing!] > > Wow. That looks ... remarkably painless. That's why I did it. Hacking the source to Python can be almost as much fun as hacking Python. If only all C code in the world was written by Guido. > Why don't you think it's a good idea? Because it would annoy me. It adds a complication to Python's simple conceptual model that, as John Skaller eloquently explained, is one of it's main attractions. Another problem is that given a "callable object" `f', there is no way to check whether it returns Nothing other than by try:-ing it; and that sucks, IMHO. You can't even compare it; if f() == Nothing: raises TypeError. Perhaps the test at the end of the CALL_FUNCTION should be extended to allow COMPARE_OP. But that's inconsistent; there's no satisfactory resolution IMHO, so I vote for the status quo. I-feel-this-proposal-is-unlikely-to-be-accepted-ly y'rs Michael From campbeld2 at my-deja.com Fri Sep 17 10:20:36 1999 From: campbeld2 at my-deja.com (campbeld2 at my-deja.com) Date: Fri, 17 Sep 1999 14:20:36 GMT Subject: os.popen results diff when executed in browser vs DOS Message-ID: <7rtin6$9oa$1@nnrp1.deja.com> This sample program illustrates my dilema. I am trying to execute a command ( could be any command ) within Python and capture the output. It works fine when I run it at command level, however when I invoke the script in the browser the code does not return any values from the os.popen(...)readlines. I tried try: and except: but nothing is trapped. Any ideas? ------ """ test.py : returns correct results at command level (great) returns nothing through Browser !!! """ import os print 'Content-Type: text/html\n\n', for line in os.popen( 'cd','r' ).readlines(): print '

...within for loop \n\n' cd = line print '

cd = ', cd, '\n\n' #end of test.py Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From davidopp at megsinet.net Sun Sep 5 00:27:33 1999 From: davidopp at megsinet.net (David Oppenheimer) Date: Sun, 05 Sep 1999 00:27:33 -0400 Subject: V - GUIDO !!! was Re: Pirate -> RAD References: <7qno38$6uk$1@news.is.co.za> <37D17998.5CF4@warande.uu.nl> Message-ID: <37D1F135.6F242B93@megsinet.net> I have an idea for creating a WYSIWYG GUI builder for Python that will allow you to create slick looking GUI's just by dragging and dropping elements into a visual design space that will output code into wxPython. After a user was satisfied with the appearance of the GUI, the program would output the code into wxPython code which would be seamlessly integrated with the code that had already been written inside of a design space (make it so that it would work flawlessly as either a component of the major IDE's including PythonWin, IDLE, Python in a DOS box or have it callable from a command line). It will also be able to take written code and show a preview of what your GUI would look like without having to first save the program and run it thru the Python interpreter. This would allow you to instantly see the effect of changes made to your code. It would be awesome to integrate it seamlessly with the PythonWin IDE and also be callable from the command line in IDLE or Python in a DOS box. If you would like to join with me in this creative endeavor (code name V - GUIDO which stands for Visual Graphical User Interface Development Optimizer), I would be happy to share the details with you. Sincerely, David Oppenheimer P.S. This is still just in the brainstorming stage right now. I am doing conceptual planning right now; features, how it should look, how it should act, etc. I would ask anyone who is serious about doing such a project to join forces with me and see if we can make something happen. Martin Oti wrote: > Jacques Oosthuizen wrote: > > > > Hi All > > > > I am busy working on a tool I named Pirate ("Python RAD") it has a component > > library similar to Delphi and shall in the future work with win32,gtk,qt. It > > will have a IDE. > > > > Before I do to much and work to hard on it, will anyone be interested in > > using a > > tool like this. > > Absolutely! I'm new to Python and the more I find out about it, the more > I like it. :) One major aspect which I miss is a good RAD GUI-building > tool. > > I use Visual Basic at work, mainly for within-company scripting and > automation tasks, and I often need to whip stuff up pretty fast. I've > already started to use Python as much as possible and with a RAD > GUI-building tool I will be able to ditch VB for good. :) There are some > lovely Python GUI toolkits out there, but I'm no expert programmer and I > need to whip GUIs up pretty fast. > > Considering the masses of Visual basic programmers out there, I think a > visual RAD GUI-builder/IDE for Python will have a large audience. It > would be particularly handy for those (like me ;) who would also like > VB-like functionality on Linux. Indeed, considering that KOffice will > use Python as it's extension language, Python could then become the > scripting-language-for-the-masses on Linux the way VB is on MS Windows. > > Martin > > PS: A zillion thanks to Mark Hammond for the PyWin IDE, Robin Dunn for > wxPython (which I only just discovered yesterday), and the entire Python > community for a great programming/scripting language/tool. :) > > PS2: I don't know what this would involve, but it would be handy if the > GUI-Builder could also interface with (soon to be) existing Python GUI > toolkits (like TkInter, wxPython and Parrot). I have no clue how > difficult it would be to separate the front-end from the back-end. > > PS3: Pirate and Parrot. How ironic. ;) Is this a coincidence? > > ------------ > Trying is the first step towards failure. > -- Homer Simpson From cmedcoff at sprynet.com Sat Sep 18 21:02:06 1999 From: cmedcoff at sprynet.com (Charles Medcoff) Date: Sat, 18 Sep 1999 21:02:06 -0400 Subject: Seeking GUI advice Message-ID: <7s1bs8$7jp$1@nntp2.atl.mindspring.net> I don't want to start a flame war but I'm looking for advise on what GUI to use with Python. I'm pretty much a newbie still at this point. I've only written a few simple scripts for source control, builds, etc. to help out my C++ development. I'm getting interested in using the GUI aspects of python. I've used Tk a little bit. There isn't any really great documentation for Tkinter IMHO although I do appreciate the efforts of Fredrik Lundh. I understand that he may be publishing a Tkinter book this fall. Is this true? I do most all of my work on the Windows platform and usually use Pythonwin for my development but I'd like to create portable scripts if possible. Beside there isn't any good documentation for Pythonwin's GUI either IMHO. (Thanks for a cool development environment though;) I guess I'm looking for some documentation that does a fair amout of hand holding alla "Learning Python". I kind of thought that Tkinter was being swamped out by Pythonwin, and wxPython. Is this true? Is there something else available? Is here something else Python developers are going to standardize on? Any advise appreciated. Chuck From moun at usenix.org Fri Sep 10 20:20:07 1999 From: moun at usenix.org (Moun Chau) Date: Sat, 11 Sep 1999 00:20:07 GMT Subject: DSL Conference Hotel & Pre-Reg Savings Deadline - Sept 13, 1999 Message-ID: 2ND CONFERENCE ON DOMAIN SPECIFIC LANGUAGES (DSL '99) October 3-5, 1999 Omni Hotel, Austin, Texas, USA Sponsored by USENIX, The Advanced Computing Systems Association In cooperation with ACM SIGPLAN and ACM SIGSOFT --------------------------------------------------------- Hotel and Registration Savings Rate Ends Monday, September 13, 1999 --------------------------------------------------------- The Omni Hotel is offering the USENIX Conference special rate through Monday only, and after that the rate will increase. Please make sure to say that you are attending the USENIX Conference to get the discount rate. Single/Double Occupancy - $125 Omni Austin Hotel - Downtown 700 San Jacinto at 8th Street Austin, TX 78701 1-800-843-6664 Local telephone: 1-512-476-3700 DSL Conference Topics include: * Different Approaches To DSL Construction * New DSLs For Problem Domains such as Specifying Hardware Circuits and Robot Control Protocols * Creating Data-Intensive Web Sites and Collaborative Applications * Domain-Specific Languages for Programming and Security in Active Networks, by Carl A. Gunter, University of Pennsylvania * A Methodology for Designing Domain-Specific Languages Using Program Specialization, by Charles Consel, IRISA/University of Rennes * Language Technology for Performance and Security * The Next 700 Markup Languages --------------------------------------------------------- See USENIX website for complete conference details and Online Registration http://www.usenix.org/events/dsl99 --------------------------------------------------------- From mavip5 at inet.polyu.edu.hk Fri Sep 10 01:33:33 1999 From: mavip5 at inet.polyu.edu.hk (Li Dongfeng) Date: Fri, 10 Sep 1999 13:33:33 +0800 Subject: Reading plain text file database tables References: <37D7508A.B02789A7@inet.polyu.edu.hk> Message-ID: <37D8982D.59CD3D15@inet.polyu.edu.hk> I have come up with a rarther ugly, slow, but working RE solution for the problem. The two functions can read comma delimited tables and space delimited tables. Quotation, backslash escape are considered. Python source below. ----------------------------------------------------------- def cut_comma(lines): """This function is used to read comma delimited files(.csv). Input: the rows of the data file in a list 'lines'. Output: a list of list x, x[i] is the i'th row of the input, x[i][j] is the j'th data item on the i'th row. The scanning respects quoting, e.g., the row "Bond, James", 13, 45 will be recognized as three column ["Bond, James", "13", "45"] successfully. Escape characters like 'That\'s absolutely possible.', 1999, 8, 30 are treated correctly. Shortcoming: very slow when reading large datasets. On a SUN Sparc 2, reading 10000 lines of input took 20 seconds. Suggestion is welcome. Author: Li Dongfeng, ldf at statms.stat.pku.edu.cn Last modified: 1999.9.10 """ r = re.compile(r""" \s* # data item can start with any number of spaces (?P # start of data item we need to extract '' | "" # empty string | '.*?[^\\]' # matches any thing enclosed in '...'(can have comma) # but the last "'" have no '\' before it. Find first ending ' | ".*?[^\\]" # matches any thing enclosed in "..."(can have comma) # but the last '"' have no '\' before it | [^"',][^,]*? # matches anything that do not contain a comma, #and not starting with "'" or '"' or comma | "[^,]*?(?!.*?[^\\]") # anything starting with '"' and have no comma, # no matching '"' behind | '[^,]*(?!.*?[^\\]') # anything starting with "'" and have no comma, # no matching "'" behind | # can be empty between two commas ) (?:\s* , # end with a comman(can have spaces before it) ) """, re.VERBOSE) r2=re.compile(r"""^(['"]).*\1$""", re.MULTILINE) # anything quoted def quote(match): return eval(match.group()) if type(lines) is type(()) or type(lines) is type([]): # sub comma with newline, but respect string quoting x = map(lambda s, r=r: r.sub("\\g\n", s), lines) # unquote all quoted x = map(lambda s, r=r2, f=quote: r.sub(f, s), x) # split the rows x = map(lambda s: string.split(s, "\n"), x) else: x = r.sub("\\g\n", lines) x = r2.sub(quote, x) x = string.split(x, "\n") return x def cut_space(lines): """This function is used to read space delimited files. Input: the rows of the data file in a list 'lines'. Output: a list of list x, x[i] is the i'th row of the input, x[i][j] is the j'th data item on the i'th row. Any number of spaces(space, tab) can be used between two data items. The scanning respects quoting, e.g., the row "James Bond" 13 45 will be recognized as three column ["James Bond", "13", "45"] successfully. Escape characters like 'That\'s absolutely possible.' 1999 8 30 are treated correctly. Shortcoming: very slow when reading large datasets. On a SUN Sparc 2, reading 10000 lines of input took 20 seconds. Suggestion is welcome. Author: Li Dongfeng, ldf at statms.stat.pku.edu.cn Last modified: 1999.9.10 """ r = re.compile(r""" (?P # start of data item we need to extract '' | "" # empty string | '.*?[^\\]' # matches any thing enclosed in '...'(can have comma) # but the last "'" have no '\' before it. Find first ending ' | ".*?[^\\]" # matches any thing enclosed in "..."(can have comma) # but the last '"' have no '\' before it | [^"'\s][^\s]*? # matches anything that do not contain a space, #and not starting with "'" or '"' or space | "[^\s]*?(?!.*?[^\\]") # anything starting with '"' and have no space, # no matching '"' behind | '[^\s]*(?!.*?[^\\]') # anything starting with "'" and have no space, # no matching "'" behind ) (?:\s+) # end with a space """, re.VERBOSE) r2=re.compile(r"""^(['"]).*\1$""", re.MULTILINE) # anything quoted def quote(match): return eval(match.group()) if type(lines) is type(()) or type(lines) is type([]): # sub comma with newline, but respect string quoting x = map(lambda s, r=r: r.sub("\\g\n", s), lines) print x[0] # unquote all quoted x = map(lambda s, r=r2, f=quote: r.sub(f, s), x) print x[0] # split the rows x = map(lambda s: string.split(s, "\n"), x) print x[0] else: x = r.sub("\\g\n", lines) x = r2.sub(quote, x) x = string.split(x, "\n") return x ------------------------------------------------------------------------- Li Dongfeng wrote: > > Do we have a module to read plain text file > database tables? > > All the data management software, e.g. excel, > dBase, SAS, etc., support input/output a table > from/to a plain text file, fields can be separated > by their column position, by spaces, by tabs, > by commas, etc. > > How can we read this kind of file into a matrix like > structure(list of lists)? I have written one reading > files with fixed-width fields. For delimited files, > simply using string.split work most of the time, but > fails reading lines like > > "Peter Thomson" 25 36 > > or even > > "Peter\" Thomson" 25 36 > > I think this is a common task, so maybe someone has > already given a very good solution. > > Li Dongfeng From MHammond at skippinet.com.au Fri Sep 3 19:50:16 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Sat, 4 Sep 1999 09:50:16 +1000 Subject: Announce: CVS Access to source code for Python for Windows Extensions Message-ID: <7qpmso$4jj$1@m2.c2.telstra-mm.net.au> All source code for the Python for Windows extensions are now being managed by CVS. Anyone can use anonymous access to ensure they always have the most recent sources available. There is also a "checkins" mailing list provided, so you can be informed of all CVS checkins made into this repository as they happen (or daily if you use the digest mode!) All the gory details can be found via http://starship.python.net/crew/mhammond/cvs.html Many thanks to the Python Pros (http://www.pythonpros.com) for assisting in providing this service. Mark. From nhead at houbits.com Wed Sep 15 03:09:27 1999 From: nhead at houbits.com (Nigel Head) Date: Wed, 15 Sep 1999 09:09:27 +0200 Subject: [Newbie] test_signal hangs References: <37DEDFF7.1DC7C4B3@siprelle.com> Message-ID: <37DF4626.B0E86158@houbits.com> Lynn: > And now I'm trying to run the test set, but it hangs on > test_signal--I let it run for more than an hour, and it just sat there. > > Should I even care? Or is this a real problem? I had exactly the same problems (manual edits to configure - just doing configure.h by hand didn't work for me - and hanging of test_signal). I also had sporadic failures of other tests, which would all run when called individually -- this I put to down to the draconian limitations on virtual address space that the iServer boxes appear to apply! I ended up just deleting test_signal to get the rest of the test suite to run and ignoring the problem. It seems to be a non-issue at least as far as running Zope is concerned (saying this will probably get it to come back and bite me now though :->). Regards, and apologies for the slightly off topic Zope parts of the reply, Nigel. PS: Make sure to read the docs in doc/FAQ.txt before you try installing Zope - you'll have trouble if you don't. The relevant point is attached below -- note however that the makefile.pre.in that needs patching is NOT either of the ones in the Zope tree but the one from the python installation which gets copied across during the Zope build. PPS: I also found it necessary to build python with the full prefix (/home/usr/.....) and run Zope in non-virtual mode for things to work smoothly - if you find a way to build so that it'll run in the chroot'ed environment I'd love to hear about it. PPS: After all this I shall be moving away from Iserver -- I've found another bunch who offer completely naked RedHat boxes, with unrestricted root account for the same price -- this way I'll be able to run Zserver on port 80, instead of hiding behind Apache. If you're interested let me know in private email and I'll pass on the details - don't want to be flamed for introducing commercial stuff here. ------------------ Zope Installation Frequently Asked Questions -------------------------------------------- Installing Zope 1. I am trying to build Zope on my BSD based system, but I keep getting "symbol not found" errors and the build scripts stop. What do I do? On some BSD based systems (BSDI, BSD/OS), you need to edit the Makefile.pre.in files in your Zope installation to add -rdynamic to the LDSHARED makefile variable. On some systems it may also be necessary to change the file named 'do.py' located in the 'inst' directory of your Zope installation, changing the line: do('make') to: do('make -k'). From psd2300 at saintjoe.edu Thu Sep 16 13:56:51 1999 From: psd2300 at saintjoe.edu (Phil Schroeder) Date: Thu, 16 Sep 1999 12:56:51 -0500 Subject: high school programming & python References: <37DF9080.21A8D285@calibre-dd.com> <37DFED78.6B258366@bioreason.com> Message-ID: <37E12F63.68737737@saintjoe.edu> James Whitley Moore wrote: > > Why not end this thread in the usual way? > > I never wanted to be a high-level language programmer. > > I always wanted to be. . . a race car driver. heck, maybe now i can write a python script to do it for me. -phil schroeder measly college student From drushby at email.com Thu Sep 30 23:56:40 1999 From: drushby at email.com (David Rushby) Date: Thu, 30 Sep 1999 23:56:40 -0400 Subject: PC Speaker Sound Message-ID: I know this is an offbeat question, but how does one go about generating PC speaker tones from Python? Is there a function like GWBasic's SOUND? Thanks. From jblake at stamp-coin.com Thu Sep 9 20:34:51 1999 From: jblake at stamp-coin.com (jonathon) Date: Fri, 10 Sep 1999 00:34:51 +0000 (UTC) Subject: Python Error Messages In-Reply-To: <14295.35617.292624.957926@gargle.gargle.HOWL> Message-ID: On Thu, 9 Sep 1999, Charles G Waldman wrote: >jonathon writes: > > > > The current exasperating error message: >It seems pretty likely to me (but this is just a guess!) that the >error is on the line: > >add_keywords = ( pre_keywords + country_name + country_section_name + > scott_data + michel_data + y_t_data + s_g_data + minkus_data + > end_of_line ) That wasn't the error. Some of the errors turned out to be the result of my not setting "return return_object" in a couple of defs. Python very nicelly returned NULL. Still haven't managed to track the rest down. :-( For the curious the other obnoxious error is: "IndexError: string index out of range" Obnoxious, because: A) It is supposed to be looking at a list, not a string. B) The actual error is several hundred lines from where the message occurs. >What seems most annoying to me, and I really don't have a clue about, >is why you're getting an off-by-one error on the line number. Is >there something strange about this file perhaps? The file it is reading is roughly 4 MB in size. Each line is roughly 420 characters long. >By the way, I'd write the line in question as: > >add_keywords = "%s%s%s%s%s%s%s%s%s" % (pre_keywords, country_name, > country_section_name, scott_data, michel_data, y_t_data, > s_g_data, minkus_data, end_of_line ) Did that, and replaced most, if not all of the similar lines. Didn't fix the error, since it wasn't the error, but it did speed up the script by a considerable margin. :-) xan jonathon From clgonsal at keeshah.penguinpowered.com Fri Sep 3 12:54:37 1999 From: clgonsal at keeshah.penguinpowered.com (C.Laurence Gonsalves) Date: Fri, 03 Sep 1999 16:54:37 GMT Subject: Spanish Inquisition?! References: <37CFC38C.20A9C267@megsinet.net> Message-ID: On Fri, 03 Sep 1999 08:48:12 -0400, David Oppenheimer wrote: > David O. > > "Any Sufficiently Advanced Technology Is Indistinguishable From Magic" > - Arthur C. Clarke That looks awfully familiar... > P.S. Creating compiled code from Python that didn't require the > interpreter to be distributed with it would be high magic indeed. Yeah, especially compiling those eval and exec functions... -- C. Laurence Gonsalves "Any sufficiently advanced clgonsal at kami.com technology is indistinguishable http://www.cryogen.com/clgonsal/ from magic." -- Arthur C. Clarke From jetman3 at netzero.net Fri Sep 24 07:15:39 1999 From: jetman3 at netzero.net (The Jetman) Date: Fri, 24 Sep 1999 07:15:39 -0400 Subject: [PyWin] Does Win32RAS Work ? References: <7scon8$p5a$1@nnrp1.deja.com> Message-ID: G. Lewis wrote in message <7scon8$p5a$1 at nnrp1.deja.com>... > > >> Have spent a couple of hours trying to narrow down a >> prob w/ Win32RAS and I'm at the point where I suspect it simply >> doesn't work. Have trimmed down the rastest script to simply > >Works for me, though i don't use it for much. I just use it in a script to >check if i have a connection like this... > > import win32ras > cons = win32ras.EnumConnections() > if not cons: > print 'No Connection...' > >Hehe, that's all i use it for! But it works for that at least.... > > > > >Sent via Deja.com http://www.deja.com/ >Share what you know. Learn what you don't. It's been hit and miss for me and I wanted to use it for something paying I'm posting this msg via a RAS connection that I established w/ win32ras, but PyWin itself expired just as the connection was made, apparently due to a fault in the VC R/T lib. As originally coded, the rastest script fails catastrophically on my Win95 system. But I'm going to keep trying for a while longer....Jet -- ================================================================ In Paris, they simply stared when I spoke to them in French; I never did succeed in making those idiots understand their own language. - Mark Twain, The Innocent Abroad,1869 ======================================= jetman3 at netzero.net == From nolan at ethereal.dhis.org Thu Sep 30 00:39:50 1999 From: nolan at ethereal.dhis.org (Nolan Darilek) Date: 29 Sep 1999 23:39:50 -0500 Subject: Nolan's question of the day: distributed servers? Message-ID: <87btal3td5.fsf@ethereal.dhis.org> I've kept up a good tradition (Maybe not, depending on your point of view :) of asking one question per day. Here's today's. :) My current big project is a MUD server in Python. I have some interesting ideas, only one of which I'll bore you all with. :) I honestly don't know how Python will perform in this area. I'm not aiming my code at lower-end processors though, so I'm not terribly worried, but in order to alleviate some of this, I'm trying to either use an existing object distribution scheme such as CORBA/ILU, or *shudder* write my own. :) Let me start by saying that I am not intimately familiar with CORBA or ILU. I know what they were meant to accomplish, and I could probably write a simpler program using them, but my needs are slightly different, and I don't know if these schemes will handle them. Basically, persistent objects are loaded into Namespaces. A Namespace is a class which stores all objects in a specified location (Location meaning a database) as local variables. So, if you had an object called Ball in a database which is stored in a file called "objects.db", you could do: # Open the database and load all objects. root = Namespace("objects.db") # Access our Ball. ball = root.Ball # And then bounce it. ball.bounce() Since a namespace itself is a persistent object, databases can store other namespaces. However, namespaces don't just access databases; they can also access servers. So, you could do: root.server1 = Namespace("thematrix.mud.org", "4000) and then all objects which are available to the server thematrix.mud.org 8000 would be available. Initially this scheme will require a trusted environment, and security should be implemented later. So, a network of namespaces will exist, each accessing either a database or a server. My current concern, though, is that the server shouldn't have to know how every single object on every single server works before it starts. From what I've seen of CORBA (And correct me if I'm wrong.) class interfaces need to be specified before hand and compiled to skeletons. This wouldn't work for me, since if someone on server x decides to code, say, a flying car, making a skeleton wouldn't be practical. So my current questions are, is it possible to somehow export a dynamic interface in realtime, as opposed to carefully specifying an interface beforehand and loading it into the server? Another idea which I have been considering is breaking the object into two components, an exportable version and a server-resident version. So, if someone gets a ball from another server, the user's server is only sent a ball with its description and a list of commands/methods. If the user chooses to bounce the ball, the user's server passes the bounce request to the server which originated the ball, the ball processes the method and returns its results to the user. This method seems somewhat unclean though, since the person's ball wouldn't bounce if the server which originated it was down. If, instead, the user's server knew how to bounce the ball, the server would be able to work independently. Another option would be to pickle requested objects and dump them over the network to the originating server, possibly using zlib for speed. So, if someone requests a copy of root.server1.ball, the ball object would be pickled at the destination and sent across the network. Perhaps this would be the best solution, since both sides of the connection would have a copy of the object, though changes in one would still need to effect the other, which may prove difficult. Has anyone done something like this? If so, do you have any recommendations? Thanks for listening/reading the somewhat confusing and confused rants of a newbie. :) From m.faassen at vet.uu.nl Mon Sep 27 14:43:55 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 27 Sep 1999 18:43:55 GMT Subject: Python compilers? References: <87aeq86am8.fsf@ethereal.dhis.org> Message-ID: <7sodtb$oau$1@newshost.accu.uu.nl> Nolan Darilek wrote: [snip] > So, are there any native Python compilers? Someone on IRC mentioned a project > called Viper, and my searches seem to indicate that it is under > development, but is there any information on the web about its status? John Skaller is actively working on it, last I heard. He is first working on viperi, however, a Python interpreter, after that he plans to move on to viperc, a Python compiler. viperi seems to actually run Python code, but I don't think viperc is out of the design phase yet. John wants to do all kinds of grand things with viper, such as type inference and other advanced code analysis. > Also, What is swallow? I tried doing a websearch for swallow and > Python, and ended up with tons of Holy Grail references, but nothing > to answer my question. :) I ask because I've seen swallow coupled with > viper in a few messages; is swallow another python/pseudopython > interpreter/compiler? Swallows was an earlier vaporware project that I came up with. The idea behind Swallow is to implement a compiler for a limited subset of Python (along with nonintrusive type annotations). This could be used to create Python based fast extension modules. Currently I lack the time to do a lot about it, though. Maybe later, but currently it is complete vaporware! No website. :) Cool that people ask, though.. What some posts and a cool name can do. :) There *are* actual Python to C compilers out there; others can point you to the relevant web pages better than I could. The disappointment here is that they tend to create executables that aren't significantly faster than Python. That's why for Swallow I think the subset part + type annotations were essential (as concepts). My hope is that this could lead to translation to actually *fast* C (or native) code. And the restrictions also allow us to skip the difficult parts of type inferencing and dealing with lots of Python's dynamism. > One final question. How compatible/cross-platform are Python > bytecodes? If I wanted to distribute applications in Python while > hiding the sources from the user, would it be possible to distribute > .pyc files, or the bytecodes specific to a specific version/platform? As far as I'm aware Python's bytecodes are fully portable to other platforms. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From sitric at home.com Fri Sep 10 09:37:10 1999 From: sitric at home.com (Eric B.) Date: 10 Sep 1999 06:37:10 PDT Subject: How do I connect to Postgress from Windows version of Python 1.5.2 ?? Message-ID: <37D90926.ED4DAE31@home.com> We have Postgress running on a Linux box and I am trying to connect to it from my Windows 98 machine using Python 1.5.2 (Windows package). I looked into "PyGress" but that seemed to be set up for a non-Windows flavor of Python. Can anyone help me? Thanx!!! -Eric B. (sitric at home.com) From hniksic at srce.hr Sun Sep 19 18:29:02 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 20 Sep 1999 00:29:02 +0200 Subject: Marking translatable strings References: Message-ID: <87vh964jtd.fsf@pc-hrvoje.srce.hr> Fran?ois Pinard writes: > Python should be simple as well. Yet, after the XEmacs > internationalisation failure, one good lesson, that we would be > foolish to not retain, is that we should take time to think things > out, before starting to think too big. I'm curious -- what "XEmacs internationalization failure" are you talking about? From junkster at nospam.rochester.rr.com Tue Sep 28 22:40:30 1999 From: junkster at nospam.rochester.rr.com (Benjamin Schollnick) Date: Wed, 29 Sep 1999 02:40:30 GMT Subject: Python TimeServer (RFC 868) Message-ID: Hi Folks! I've been messing around with a python timeserver that I've written.... There's only one problem, I've got the time standardized, and seems to work correctly. But time clients don't seem to want to communicate with it. I'm not exactly certain of the problem, but I suspect something. I'm dumping the "seconds" value, in otherwords, the seconds are being output to the socket, as a text value. I believe that I need to send it as a binary value (a 4 byte integer), instead of a string... But can't figure out a way to do this...? Any suggestions? Or examples of a working timeserver in python >g< - Benjamin ================================ Please feel free to copy any and or all of this sig. A little something for spam bots: root at localhost postmaster at localhost admin at localhost abuse at localhost postmaster at 127.0.0.1 Chairman William Kennard: bkennard at fcc.gov Commissioner Susan Ness: sness at fcc.gov Commissioner Harold Furchtgott-Roth: hfurchtg at fcc.gov Commissioner Michael Powell: mpowell at fcc.gov Commissioner Gloria Tristani: gtristan at fcc.gov consumerline at ftc.gov fccinfo at fcc.gov ssegal at fcc.gov From mal at lemburg.com Fri Sep 3 07:53:40 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 03 Sep 1999 13:53:40 +0200 Subject: Python speed and `pcre' References: <00af01bef543$0affe8f0$f29b12c2@secret.pythonware.com> Message-ID: <37CFB6C4.35578D33@lemburg.com> [substrings] Note that Python 1.5.2 already support such beasts... albeit rather well hidden (for obvious reasons ;-) and not fully interoperatable yet: >>> s = '12345678901234567890' >>> snippet1 = buffer(s,8,3) >>> print snippet1 901 >>> snippet2 = buffer(s,14,4) >>> print snippet2 5678 >>> import string >>> string.join(snippet1,snippet2) '95678056781' >>> string.split(snippet2,'6') ['5', '78'] >>> string.join([snippet1,snippet2]) Traceback (innermost last): File "", line 1, in ? TypeError: first argument must be sequence of strings You can always turn a buffer back into a string using the str() function. Perhaps the string module should be extended to use "s#" more often... -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 123 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From jmrober1 at ingr.com Tue Sep 7 14:26:45 1999 From: jmrober1 at ingr.com (Joseph Robertson) Date: Tue, 07 Sep 1999 13:26:45 -0500 Subject: case for open lang on win32 - fill in the table References: <7r0049$bfh$1@nnrp1.deja.com> <7r0d3t$chk$1@newshost.accu.uu.nl> <7r1hab$9bd$1@m2.c2.telstra-mm.net.au> <7r3fhd$oqb$1@nnrp1.deja.com> Message-ID: <37D558E5.3D1D7BDF@ingr.com> nielsenjf at my-deja.com wrote: > power and cross-platform (Where I work we're going 100% microsoft and > 100% visual basic). The main argument being visual basic/vbscript is so > easy to use and the only other viable option is C++ which is too hard > (in their opinion). Good grief, man get out of there FAST! 100%VB yuk. Also sounds like a group that doesn't know how to use the "right tool for the job". > IMHO, python has a feel similar vb/vbscript except it doesn't have > the vb world's limitations. Python is many orders of magnitude better than VB... > For example, you can do everything COMwise in C++. > Choose any other language and you start to make compromises. > What is there that you can do in C++ that you can't do in python? > In what cases is visual basic(a probably weaker language) better than > python to use? Real world example: I have several VB apps that I "inherited" over the years. One is fairly large, and was using DAO simply to handle the large text files (via ISAM) and provide sorting, searching, etc. Using Mark Hammonds' Python-COM support I have ripped the DAO nonsense, made a mess into a logical class heirarchy, and provided common base functionality available to other supporting apps. So I have 4 major Python-COM objects for this app and VB is just the GUI to tie it all together. The app is faster, handles very large (90K+lines) flatfiles, reusable, smaller, and cleaner(more logical). Once I get a descent grid done in Tk even VB can be removed. Did I mention portable, the COM code are merely wrappers, so the base code is there for any platform to use. And Python runs on about 28 more platfoms than VB. Point is, use VB for its strength...GUI frontends, and Python for its strength...strong, fast core functionality. 6 versions and VB string handling still suks roks... As an added bonus, I also recreated 2 of the COM objects on VC++6.0, and it took about 3 times as long to do it, and I started with a working Python object. Needless to say I am a firm Python-COM believer. Thanks, Mark! Joe Robertson jmrober1 at ingr.com From hniksic at srce.hr Fri Sep 10 14:11:13 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 10 Sep 1999 20:11:13 +0200 Subject: Python example: possible speedup? References: <000b01befb24$05ca6fe0$f0a0143f@tim> Message-ID: <87g10my6v2.fsf@pc-hrvoje.srce.hr> "Tim Peters" writes: > Was the Perl code to which you're comparing it as general as your > Python code? The Perl code was almost equivalent to the first posted version of Python code -- the only important difference is that it used a functional approach rather than OOP. I can mail it to you if you are curious. Generality is important to me because another day I might wish to do something else with those files, like draw a tree of dependencies, or something. In that case, I'd surely want to reuse the existing reader/parser. Speed is good, but not so good to justify loss of code reuse. Robert's solution is ideologically similar to the `grep' solution proposed below. From robin at jessikat.demon.co.uk Sun Sep 12 00:02:38 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Sun, 12 Sep 1999 05:02:38 +0100 Subject: Matching strings with regexps References: <37D8982D.59CD3D15@inet.polyu.edu.hk> <000001befcb7$83e9b9a0$4c2d153f@tim> Message-ID: In article <000001befcb7$83e9b9a0$4c2d153f at tim>, Tim Peters writes > ... > >give-a-man-a-meal-and-you've-fed-him-for-a-day- > give-a-man-a-regexp-and-you-may-as-well-kill-him-ly y'rs - tim > > ... so to turn a dead man into a zombie we pose the timbot the problem of recognizing those regular expressions which he so kindly quoted for us to immediately forget and then whine later that we lost the ref. -mind numbedly yrs- Robin Becker From da at ski.org Tue Sep 28 17:41:34 1999 From: da at ski.org (David Ascher) Date: Tue, 28 Sep 1999 14:41:34 -0700 (Pacific Daylight Time) Subject: Global confusion In-Reply-To: <816010E2456BD111A48700805FBBE2EEFDF634@ex-quebec-u1.baan.com> Message-ID: On Tue, 28 Sep 1999, Gaetan Corneau wrote: > # Function to add a paragraph > def AddParagraph(style, text): > Srv.ActiveDocument.Paragraphs[nbPar].Range.InsertParagraphAfter() > Srv.ActiveDocument.Paragraphs[nbPar].Range.Style = > Srv.ActiveDocument.Styles(style) > Srv.ActiveDocument.Paragraphs[nbPar].Range.InsertAfter(text) > nbPar = nbPar + 1 > NameError: nbPar > > I looked in my "Learning Python" book and told my friend to insert "global > nbPar" as the first line of the "AddParagraph" function. > It works, but I don't understand why he has to do that... > > Anybody who can exlain? The problem is that because nbPar is *assigned to* in the function body, Python tags all references to 'nbPar' within that function as references to a local variable (which fails, because nbPar doesn't have a 'local' value inside the function when the nbPar + 1 is evaluated. The general rule about Local-Global-Builtin namespaces applies to variables which are not otherwise tagged. The global declaration is one such (explicit) tagging, which is needed to counter the effect of the (implicit) tagging done by Python at compilation time. Side note 1: in the next version of Python, a different error message UnboundLocalError (or such) will be raised instead. Side note 2: JPython does something else altogether. Side note 3: Since you do want to modify the global variable, adding the global declaration is the right thing to do. Hope this helps. --david ascher From yopen at my-Deja.com Mon Sep 6 22:55:51 1999 From: yopen at my-Deja.com (Bill Wilkinson) Date: Mon, 6 Sep 1999 21:55:51 -0500 Subject: Printing under Pythonwin References: <37D4FC28@pcmgw.phm.gov.au> Message-ID: This kind of printing from Pythonwin is not implemented yet.... Perhaps soon though... In the mean time, you can open up your py files in word or wordpad and print them from there.... Or do what I do and write a script that uses py2html to convert them to html and then print them out.... This way you can get color printouts....(if that is important to you). fwiw Pythonwin is incredibly feature rich. Source printing is sure to follow soon... :) John Hirsch wrote in message news:37D4FC28 at pcmgw.phm.gov.au... > > I have a problem printing from the pythonwin editor. > The Print, Print Preview and Page Setup are greyed out. > I am printing on a network printer and have no problem printing from > other programs. > Thanks for any help. > > From Doug at news.vex.net Mon Sep 13 01:26:06 1999 From: Doug at news.vex.net (Lewis) Date: 13 Sep 1999 05:26:06 GMT Subject: Examples using urllib, htmllib References: <7rgon4$4a0$1@nnrp1.deja.com> Message-ID: <7ri1te$2ki7$1@hub.org> On Sun, 12 Sep 1999 17:43:03 GMT, nolanl at my-deja.com wrote: >Can someone point me to some example Python >scripts that I can download that show accessing >the web using the urllib, and htmllib. I'm I have a couple of scripts with extremely sloppy code at http://www.vex.net/~x/python_stuff.html which might have a few hints for you. One is a simple web page 'crawler' which seeks and downloads background images, using urllib. There is also a file upload CGI which is not what you want, but demonstrates a bit at least how web uploads work somewhat. Good luck. From 71351.356 at compuserve.com Sat Sep 25 08:39:54 1999 From: 71351.356 at compuserve.com (T. C. Mits) Date: Sat, 25 Sep 1999 08:39:54 -0400 Subject: Source line number for log purpose (newbie) References: <7shiqh$d96$1@ssauraaa-i-1.production.compuserve.com> <19990925130431.B11328@optiplex.palga.uucp> Message-ID: <7sig2t$oar$1@ssauraaa-i-1.production.compuserve.com> Thanks, I'll look at the Exception module again. Gerrit Holl wrote in message news:19990925130431.B11328 at optiplex.palga.uucp... > T. C. Mits: > > In c there was a way to get the current source line number via a macro, > > __LINE__. > > > > I need to be able to do the same thing. I created a logger class that uses > > a level setting. At high levels I want to > > log the source line number where the inline log.prtl( level, msg) method > > call appears. > > > > I'm sure this is easy but am getting lost digging through the Python source > > and docs. > > > > That's possible via the 'Exception' module. > > regards, > Gerrit. > -- > RTFM: Read That FreshMeat > > From jblake at stamp-coin.com Fri Sep 24 17:38:26 1999 From: jblake at stamp-coin.com (jonathon) Date: Fri, 24 Sep 1999 21:38:26 +0000 (UTC) Subject: A more straightforward solution wanted Message-ID: I'm bashing my head trying to think of a more straightforward way to do the following: Read a file. Validate that the data in the file is correct. If it is correct, add several fields to each record, content of the added fields depends upon the content in the fields allready present. Here is _one_ short example of what the functions currently look like. It also happens to be one of the more straight forward ones. In most of the others, the values are vastly different. Is there a more straightforward method of doing this, other than using yet another database, for the lookup functions, etc? << I hesitate to create a database with the data to be added, because I'm not sure how many more fields will eventually be requested for the database that the output of the script currently goes to. The other question is what to use for the lookup database. >> def vryburg ( record_list ): return_list = record_list return_list[2] = "Vryburg" return_list[30] = 216501 temp_number = return_list[31] scott_number = return_list[6] scott_suffix = return_list[7] if temp_number == 0 : return_list[38] = "regular issues" return_list = valid_scott_number_range( return_list, 1, 5) return_list[91] = "Cape Of Good Hope" return_list[92] = "Vryburg: Boer Occupation" return_list = valid_scott_prefix( return_list, "N", "Issued in Vryburg Under Boer Occupation") if return_list[26] in [ "sp-", "sp+" ]: print "Invalid Scott Number" else: return_list[50] = "SACC " if scott_number = 1: return_list[44] = " " if scott_suffix = " ": return_list[45] = 1 return_list[46] = "Type A" return_list[51] = " " return_list[52] = 1 return_list[53] = " " elif scott_suffix = "a": return_list[45] = 1 return_list[46] = "Type B" return_list[51] = " " return_list[52] = 1 return_list[53] = "b" else: return_list[45] = 1 return_list[46] = "Type A/Italic Z" return_list[51] = " " return_list[52] = 1 return_list[53] = "a" elif scott_number = 2: return_list[44] = " " if scott_suffix = " ": return_list[45] = 2 return_list[46] = "Type A" return_list[51] = " " return_list[52] = 2 return_list[53] = " " elif scott_prefix = "a" return_list[45] = 2 return_list[46] = "l for 1" return_list[51] = " " return_list[52] = 2 return_list[53] = "c" elif scott_suffix = "b": return_list[45] = 2 return_list[46] = "Type B1" return_list[51] = " " return_list[52] = 2 return_list[53] = "b" else: return_list[45] = 2 return_list[46] = "Type A/Italic Z" return_list[51] = " " return_list[52] = 2 return_list[53] = "a" elif scott_number = 3: return_list[44] = " " if scott_suffix = " ": return_list[45] = 3 return_list[46] = "Type B" return_list[51] = " " return_list[52] = 3 return_list[53] = " " else return_list[45] = 3 return_list[46] = "Type B/Italic Z" return_list[51] = " " return_list[52] = 3 return_list[53] = "b" elif scott_number = 4 if scott_suffix = " ": return_list[45] = 4 return_list[46] = "Type A" return_list[51] = " " return_list[52] = 4 return_list[53] = " " elif scott_suffix = "a": return_list[45] = 4 return_list[46] = "Type B" return_list[51] = " " return_list[52] = 4 return_list[53] = "b" else return_list[45] = 4 return_list[46] = "Type A/Italic Z" return_list[51] = " " return_list[52] = 4 return_list[53] = "a" elif temp_number == 501 : return_list[38] = "Vryburg Occupation Issues" return_list = valid_scott_number_range( return_list, 1, 4) return_list[91] = "Cape Of Good Hope" return_list[92] = "Vryburg: Boer Occupation" return_list = valid_scott_prefix( return_list, "N", "Issued in Vryburg Under Boer Occupation") if return_list[26] in [ "sp-", "sp+" ]: print "Invalid Scott Number" else: return_list[50] = "SACC " if scott_number = 1: return_list[44] = " " if scott_suffix = " ": return_list[45] = 1 return_list[46] = "Type A" return_list[51] = " " return_list[52] = 1 return_list[53] = " " elif scott_suffix = "a": return_list[45] = 1 return_list[46] = "Type B" return_list[51] = " " return_list[52] = 1 return_list[53] = "b" else: return_list[45] = 1 return_list[46] = "Type A/Italic Z" return_list[51] = " " return_list[52] = 1 return_list[53] = "a" elif scott_number = 2: return_list[44] = " " if scott_suffix = " ": return_list[45] = 2 return_list[46] = "Type A" return_list[51] = " " return_list[52] = 2 return_list[53] = " " elif scott_prefix = "a" return_list[45] = 2 return_list[46] = "l for 1" return_list[51] = " " return_list[52] = 2 return_list[53] = "c" elif scott_suffix = "b": return_list[45] = 2 return_list[46] = "Type B1" return_list[51] = " " return_list[52] = 2 return_list[53] = "b" else: return_list[45] = 2 return_list[46] = "Type A/Italic Z" return_list[51] = " " return_list[52] = 2 return_list[53] = "a" elif scott_number = 3: return_list[44] = " " if scott_suffix = " ": return_list[45] = 3 return_list[46] = "Type B" return_list[51] = " " return_list[52] = 3 return_list[53] = " " else return_list[45] = 3 return_list[46] = "Type B/Italic Z" return_list[51] = " " return_list[52] = 3 return_list[53] = "b" elif scott_number = 4 if scott_suffix = " ": return_list[45] = 4 return_list[46] = "Type A" return_list[51] = " " return_list[52] = 4 return_list[53] = " " elif scott_suffix = "a": return_list[45] = 4 return_list[46] = "Type B" return_list[51] = " " return_list[52] = 4 return_list[53] = "b" else return_list[45] = 4 return_list[46] = "Type A/Italic Z" return_list[51] = " " return_list[52] = 4 return_list[53] = "a" elif scott_number = 5: return_list[5] = "Vryburg: British Occupation" return_list[92] = "Vryburg: British Reoccupation" return_list[45] = 1 return_list[46] = " " return_list[51] = " " return_list[52] = 2 return_list[53] = "a" else: return_list[38] = "Miscellaneous: Other" return_list[31] = 999 return_list[28] = "Sec" return return_list # This top listing of the tupple is the authoratative one. # # record_list # # This is a list # 0 This is a null --- i forgot that lists start with zero, not one. # 1 string_record_id # 2 temp_country_text : var_country_name # 3 string_country_number # 4 string_country_section # 5 temp_scott_prefix # 6 string_scott_number # 7 temp_scott_suffix # 8 temp_michel_prefix # 9 string_michel_number # 10 temp_michel_suffix # 11 temp_grade : var_grade # 12 temp_mint_used : var_mint # 13 string_quantity # 14 string_price # 15 temp_description # 16 temp_certificate # 17 temp_date # 18 string_cost # 19 temp_additional_description # 20 temp_list_field # 21 temp_stamp_finder # 22 temp_photo # 23 temp_image # 24 temp_deleted # 25 temp_del_date # 26 var_field_list # 27 date_today # the following are for internal program use only # 28 temp_field_list # 29 temp_record_id [ This is slated for elimination ] # 30 temp_country_number : var_country_number # 31 temp_country_section : var_country_section : this is a number # 32 temp_scott_number # 33 temp_quantity # 34 temp_price # 35 temp_cost # 36 var_graphic_url # 37 var_html_url # 38 name_country_section # 39 ultimate_file_destination # 40 standard_computer_stamp_number # # Fields between 40 & 70 are for parsing stamp catalog numbers # 41 Y_T_prefix # 42 Y_T_number # 43 Y_T_suffix # 44 stanley_gibbons_prefix # 45 stanley_gibbons_number # 46 stanley_gibbons_suffix # 47 minkus_prefix # 48 minukus_number # 49 minkus_suffix # 50 specialized_catalog_1_name # 51 specialized_catalog_1_prefix # 52 specialized_catalog_1_number # 53 spcialized_catalog_1_suffix # 54 specialized_catalog_2_name # 55 specialized_catalog_2_prefix # 56 specialized_catalog_2_number # 57 spcialized_catalog_2_suffix # 58 specialized_catalog_3_name # 59 specialized_catalog_3_prefix # 60 specialized_catalog_3_number # 61 spcialized_catalog_3_suffix # 62 specialized_catalog_4_name # 63 specialized_catalog_4_prefix # 64 specialized_catalog_4_number # 65 spcialized_catalog_4_suffix # 66 specialized_catalog_5_name # 67 specialized_catalog_5_prefix # 68 specialized_catalog_5_number # 69 spcialized_catalog_5_suffix # # The following are for internal file manipulation # 70 expiration_date # today's date + 10 days # 71 read_bad_data_from_here # 72 the_c_base_is # 73 the_scratch_file_is # 74 the_graphic_prefix_is # 75 the_error_file_is # 79 the_test_file_is # 77 number_columns # 78 " " # 79 scott_prefix_name # 80 validate_line # The following are background details about the stamp issue # 81 date_of_issue # 82 denomination_of_issue # 83 currency_of_issue # 84 background_colour # 85 foreground_color # 86 watermark # 87 type_of_printing # 88 type_of_paper # 89 luminesence # 90 specialized_catalog_1_country_name # 91 specialized_catalog_2_country_name # 92 specialized_catalog_3_country_name # 93 specialized_catalog_4_country_name # 94 specialized_catalog_5_country_name # 95 stanley_gibbons_country_name # 96 michel_country_name # 97 y_t_country_name # 98 minkus_country_name # 99 scott_country_name # 100 topical_category_1 # 101 topical_category_2 # 102 topical_category_3 # 103 topical_category_4 # 104 topical_category_5 # 105 topical_category_6 # 106 topical_category_7 # 107 topical_category_8 # 109 topical_category_9 # 110 topical_category_10 From kernr at mail.ncifcrf.gov Mon Sep 13 01:45:55 1999 From: kernr at mail.ncifcrf.gov (Robert Kern) Date: Mon, 13 Sep 1999 05:45:55 GMT Subject: ANN: PyFT 0.5 - Python Wrapper for FreeType Message-ID: <37dc8d9e.43792124@news.erols.com> I haved used SWIG to wrap the FreeType library, a TrueType font rendering engine. It can be used to render text onto a 2-color bitmap or anti-aliased text onto a 256-grayscale pixmap. These readily convert to PIL Images. Information on FreeType is on their site http://www.freetype.org Documentation on PyFT is available on http://starship.python.net/crew/kernr/PyFT.html PyFT is located here: http://starship.python.net/crew/kernr/Projects.html Robert Kern

PyFT 0.5 - Wrappers for the FreeType library for rendering TrueType fonts (13-Sep-99) -- Robert Kern | ----------------------|"In the fields of Hell where the grass grows high This space | Are the graves of dreams allowed to die." intentionally | - Richard Harter left blank. | From vapicel at tin.it Mon Sep 6 22:55:46 1999 From: vapicel at tin.it (vapicel at tin.it) Date: Mon, 06 Sep 1999 19:55:46 PDT Subject: red and white WINE STRICTLY KOSHER Message-ID: <7r0uoa$das$5876@nslave1.tin.it> Dear friend, This is a special offer to give you the opportunity to taste a special wine "strictly Kosher " product in Tuscany in Pitigliano (GR). Pitigliano is a small town on the tuscan hill, where a flourishing Jewish community had lived and grown since the Middle Ages and there Jews found a quiet refuge. For this reason Pitigliano was called "Little Jerusalem". In the ancient Jewish area, there is the Synagogue and its entrance door is shown on the label of the bottle. Only untill 15 September 1999 will be possible to buy two bottle of this wine (1 red and 1 white) at special price of U.S.$ 24.00. transport not includet. Booking and payment: Will be necessary to book by e-mail, so will be possible for us to calculate the cost of transport. After we have receiving the booking's e-mail with the exact address, in 24 hours, you will receive by e-mail the exact complete cost and the form of payment. best regards Vincenzo Apicella From greg.ewing at compaq.com Mon Sep 6 18:07:44 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Tue, 07 Sep 1999 10:07:44 +1200 Subject: how often does re.compile compile? References: <7r1451$3n7$1@nnrp1.deja.com> Message-ID: <37D43B30.F31F6E0D@compaq.com> "A.M. Kuchling" wrote: > > wade at lightlink.com wrote: > >If I say re.compile() inside the function > >definition, does the pattern get compiled afresh every time the function > >is called? The re.compile call certainly gets executed on every call. > There's a cache containing the most recent 20-odd > patterns, so if you're using fewer patterns, the re.compile() will ... > find the precompiled cached pattern If you don't want to rely on that, you can use the standard hack for creating local precomputed things: def f(..., pat = re.compile(my_expr)): ... Just make sure you don't accidentally call f with one too many parameters :-) Greg From tim_one at email.msn.com Sat Sep 25 21:21:56 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 25 Sep 1999 21:21:56 -0400 Subject: Dialect, A Python derived environment (and language ?) In-Reply-To: <1273949950-4000037@hypernet.com> Message-ID: <000401bf07bd$86475b60$602d153f@tim> [Tim, notes that the Dialect IDE http://www.aristar.com/DeveloperTools.html makes a 685Kb executable out of the 21-byte Dialect program print "Hello world" ] [Gordon McMillan] > Gee, just ran your app thru Installer. For the exe that's > Run+CArchive([HelloWorld.py]) it comes out to 24K. For the > one that's got python15.dll etc. built-in, it's still only 277K. Bloating size by a mere factor of 13,507 is a killer advantage for sure . OTOH, all of Dialect's std libraries (primarily GUI, files, sockets and some Windowsisms) are included in the Dialect exe, so e.g. there's no significant additional size penalty for a "Hello world" that instead pops up a dialog box with a button or two. If they bother to compress anything (doesn't look like they do now), the difference between 685 and 277 won't last. Now if a Dialect *fan* were to post here, I'd say they'd say this misses the point entirely. The point for them is that *making* the .exe is a no-brainer: select File -> Make EXE in the IDE, then click "Make Now" after confirming that the IDE guessed reasonable answers to the four questions it asks in the box that pops up (name of main module, which directory it lives in, path to Dialect interpreter, and output exe name). It was so easy, even I managed to do it the first time. every-language-on-earth-does-*something*-better-than-python-ly y'rs - tim From amir_e_a at netvision.net.il Sun Sep 19 12:55:45 1999 From: amir_e_a at netvision.net.il (Amir E. Aharoni) Date: Sun, 19 Sep 1999 18:55:45 +0200 Subject: indentation in XEmacs Message-ID: <37E51590.DB041B1D@netvision.net.il> Hello Can anyone please tell me how do i configure XEmacs to auto-indent with tabs instead of spaces? I have (custom-set-variables '(tab-width 4) '(indent-tabs-mode t)) in my ~/.emacs, but it still uses four spaces for indentation. My configuration: RH Linux 6.0 on a Pentium / XEmacs 21.1 May 1999 / python-mode 3.105 -- mailto:amir_e_a at netvision.net.il Amir Elisha Aharoni, the Original Israelite "Barkeep! Put all my meals in one plate. Don't ask me what kind of music I play. I play the good kind." - Oliver Lake From thomas at bibsyst.no Tue Sep 28 02:59:30 1999 From: thomas at bibsyst.no (Thomas Weholt) Date: Tue, 28 Sep 1999 08:59:30 +0200 Subject: Python Berkley DB and speed issues Message-ID: <37F06752.7D98775@bibsyst.no> Hi, Was just wondering about how Python is when it comes to speed using it`s built-in dictionaries. I`m converting a perl-project where a Berkley DB hash-table stored several million entries about files stored on cd-roms. The speed in the perl-project was ok, and it seems like Python has a very similar approach to this method, using pickle- and shelve-modules ( or Berkley DB). My question is : will the speed drop as the data gets larger, using pickle and shelve, or do I have to use Berkely DB? We`re talking millions of entries here. The whole thing will be indexed, so that you look up a seperate table for words appearing in file-entries and get a list of keys back. It`s not a problem to use Berkley DB, but if I don`t have to ... I`ll prefer to use the built-in stuff. People advised me to use a bigger databasesystem instead of the built-in stuff and Berkley DB, but it worked fine. Berkley DB is a standard core-module with Python 1.5 isn`t it? Any experience with similar problems? If anybody has any input on how to solve/optimize this problem, I`ll appreciate it. The whole thing is going to be a cd-indexing project released under the GPL-licence, with advanced search, report and scanning-features ( Allready got a working Perl-version, but want to move it to Python as soon as possible :-> ). Thomas Weholt From sblakey at u.washington.edu Tue Sep 7 20:05:48 1999 From: sblakey at u.washington.edu (S. Blakey) Date: Tue, 7 Sep 1999 17:05:48 -0700 (PDT) Subject: Python interface to Groupwise mailoxes? Message-ID: Is there an existing python interface to Novell'sGroupwise mailboxes? The excellent library reference mentions the mailbox module (section 12.18) which provides access to many standard mbox formats, but I see no reference to this one. Failing an existing python module, are there ANY open-source programs that interface with Groupwise that I can use as a starting point to build such a module? Even some good documentation of Novell's proprietary crap would appreciated. From emile at fenx.com Wed Sep 1 18:51:00 1999 From: emile at fenx.com (Emile van Sebille) Date: Wed, 1 Sep 1999 15:51:00 -0700 Subject: language interpreters/ interpreted languages weaknesses? References: <7qi3q3$n1d$1@nnrp1.deja.com><37CCE10D.D07D023B@strs.co.uk><7qjgq8$k1i$1@newshost.accu.uu.nl> <14285.38262.884171.416195@dolphin.mojam.com> Message-ID: Skip Montanaro wrote in message news:14285.38262.884171.416195 at dolphin.mojam.com... > So, aside from the differences in how you get from source to running > program, depending on your definitions, they can all be called compiled or > interpreted languages. > >From my perspective, <25+years business basic> it's interpretive if it politely stops when it hits a bug, and waits for you to fix the program and continue. If-you-can't-change-a-running-program-then-it's-compiled-ly yrs -- Emile van Sebille emile at fenx.com ------------------- From souvienne at my-deja.com Sat Sep 4 03:42:50 1999 From: souvienne at my-deja.com (souvienne at my-deja.com) Date: Sat, 04 Sep 1999 07:42:50 GMT Subject: Chinese Interpreters needed!!! Message-ID: <7qqihq$qt3$1@nnrp1.deja.com> Language Line Services is the world's largest provider of over-the-phone interpretation (OPI), helping people communicate regardless of the language they speak. Language Line Services provides OPI from English into 140 languages, 24 hours a day, seven days a week. Our clients are hospitals, law enforcement agencies, insurance companies, credit card companies, court system, immigration, and 911 centers throughout the United States and Canada. Language Line customers call the Monterey Communications Center where an English-speaking Answer Point takes their language request and connects the client to the appropriate interpreter. Once the interpreter is connected, a three-way telephone conversation among the client, their non-English speaking customer and the Interpreter ensues. All of our interpreters work from their home offices throughout the United States and Canada. Language Line Interpreters gain experience in a wide range of subjects while helping Language Line customers and non-English speakers communicate. We are currently looking for interpreters for Mandarin Chinese, and Cantonese. The person must be fluent in English and Mandarin Chinese or Cantonese, and has good customer service skills. Interpretation experience is a plus. We pay $12.50/hr, and we need someone who can work 40 hours per week during the daytime. Currently there are no openings for part-time position. Please e-mail your resume to cathylo at languageline.com Or fax it to 1-800-496-5330 Attn: Cathy Lo Thank you. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From " HPeter.Friedrichs" at alliedsignal.com Tue Sep 21 18:28:00 1999 From: " HPeter.Friedrichs" at alliedsignal.com (H. P. Friedrichs) Date: Tue, 21 Sep 1999 15:28:00 -0700 Subject: Linux Dependencies! Grrr...What now? Message-ID: <37E8066F.1C13BF33@alliedsignal.com> While I have having successfully written some scripts for python 1.4 (on my rh5.0 linux box), and successfully installing mysql, I have been trying for a week to figure out how to get the mysqldb module to work (to allow python to talk to mysql). First, I found out that mysqldb will only work with python 1.5.2...which necessitated an upgrade. Dependencies! Dependencies! I ended up installing python, python-devel, blt, tix _tkinter and tkinter. (I've been warned that as the result of my upgrade, I have now "broken" netcfg, but I'll deal with that on another day.) Now I go to install mysqldb, and it complains, among other things, of missing files and directories. Looks like I need mysql-devel. Dependencies! Dependencies! I go to the web and find it. I try to install the rpm, and it won't. It seems I need glibc6 (2.0 and 2.1). But what about everything compiled with the existing library? What happens if I "upgrade" to glibc6? What do I risk breaking by doing that? -- ----------------------------------------------- | The opinions expressed here are my own, | | and not necessarily those of my employer. | ----------------------------------------------- From tim_one at email.msn.com Tue Sep 14 22:55:58 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 14 Sep 1999 22:55:58 -0400 Subject: Python Error Messages In-Reply-To: Message-ID: <000101beff25$d65dd8e0$612d153f@tim> [Tim, explains that source file lines longer than 1000 chars screw up Python tracebacks] [Fran?ois Pinard] > Seriously, couldn't we consider this as an implementation bug? If > fgets did not return a whole line, the line count should not get > incremented. I'm afraid I gave such a dry account of it that it came off looking like a bit of conventional wisdom Python programmers "are just supposed to know". Sorry about that -- it was a surprise to me too, and my explanation was derived from having tracked down the cause just minutes before posting. That is, I agree it's a bug, and already entered a bug report and submitted a patch to repair it. A fix should appear in the CVS tree "soon". Since nobody reported this before, and tens of thousands of Python programmers must have stared at hundreds of tracebacks each, I believe we can safely conclude that the danger of running without the fix would be hard to underestimate . in-the-meantime-just-set-word-wrap-in-.py-files-to-999-ly y'rs - tim From skaller at maxtal.com.au Tue Sep 28 15:26:38 1999 From: skaller at maxtal.com.au (skaller) Date: Wed, 29 Sep 1999 05:26:38 +1000 Subject: May I loop over a changing list? References: <14312.58596.157032.657963@gargle.gargle.HOWL> <14312.60400.366044.933684@dolphin.mojam.com> Message-ID: <37F1166E.A2A4AF2C@maxtal.com.au> Olaf Delgado wrote: > Of course, the interpreter > might do some clever optimization for builtin types, or there might be > alternative ways to implement for loops in future versions of python. > > So, the _real_ question (tm) here is: is the passage in the tutorial a > "Don't do it, it's undefined." or a "Oh no, kiddy, this will confuse your > little mind."? This is a long standing problem with python. The 'reference manual' documents what the current version of the interpreter does, rather than providing a language specification. However, the manual is now in a reasonable state, and a more formal partition between language semantics and implementation details could be implemented, if only the two could be disentangled :-) -- John Skaller, mailto:skaller at maxtal.com.au 1/10 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller downloads: http://www.triode.net.au/~skaller From hniksic at srce.hr Fri Sep 10 14:06:22 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 10 Sep 1999 20:06:22 +0200 Subject: Python example: possible speedup? References: <87puztv2gt.fsf@pc-hrvoje.srce.hr> <87aeqw2vrc.fsf@pc-hrvoje.srce.hr> <37D84D5A.B2562946@home.com> Message-ID: <87k8pyy735.fsf@pc-hrvoje.srce.hr> Doug Hellmann writes: > > Thanks for the suggestion. However, I do install new packages > > often, so that's not really an option. > > Probably not every time you run your app, though. I use the application to see which packages waste too much space, so that I know which ones to remove. Not to mention that I run nightly updates of my Debian system. It is practically *guaranteed* that the files will have changed between two runs of the program. Sorry. I like the idea of pickling/marshalling, and I'd love to be able to use it here. But it can't work that way. > You could parse the data, pickle the results, and keep up with the > mod times on the two files. If the source data is newer than the > pickle database you have to update the pickle data. The problem is that to "update" the pickle data (which I'd have to do every time, as explained above), I have to parse the text files. And it's the parsing that's slow, not the post-processing. If I need to parse them every time, then I don't need pickling. From I.Clarke at strs.co.uk Thu Sep 16 09:35:58 1999 From: I.Clarke at strs.co.uk (Ian Clarke) Date: Thu, 16 Sep 1999 14:35:58 +0100 Subject: high school programming & python References: <937300939snz@vision25.demon.co.uk> Message-ID: <37E0F23E.B0199331@strs.co.uk> > Machine language! You young people today don't know what hardship > is... when I were a lad, we had to manually patch the ALU using > plug boards to change the logic. Plug boards! You young people today don't know what hardship is... when I were a lad, we had to manually train rats the two (we had only discovered two) logic gates so that they could operate the strings and levers to perform even the most basic calculation. I can recall waiting three hours to find out what 13 squared was. Worse - the smell was unbelievable (so much so that the rats demanded that we programmers washed once in a while). Ian. From henk_p at my-deja.com Mon Sep 27 10:05:41 1999 From: henk_p at my-deja.com (henk_p at my-deja.com) Date: Mon, 27 Sep 1999 14:05:41 GMT Subject: How does a CGI script get complete request header text ? References: <7sju0v$pc2$1@nnrp1.deja.com> Message-ID: <7sntje$b32$1@nnrp1.deja.com> In article <7sju0v$pc2$1 at nnrp1.deja.com>, rturpin at my-deja.com wrote: > Is there a way for a CGI script to get the complete header text, rather > than just the preparsed contents that are provided in the environment > variables?. This is not possible. The apache mod_cgi module does not pass these headers down to the script. It uses the original header to build the environment for the script. If you really need the headers (and the info you need cannot be reconstructed from the env. vars, query string or POST data) then you would need to write your own cgi like module for apache. At the moment I am working on a module for apache called mod_psi. (Python Script Interface). with this module requests for url with extension .psi are routed to a pythons script listening on some port. (This way the script is persistent over multiple requests, so I can keep my db connections open). At the moment this passes the normal cgi headers to the python script. It would be very easy to also pass the original client request headers. I you are interested, mail me at csg6031 at wing.rug.nl, I will mail you the psi_mod source (C) and hello world example (python). Henk. Sent via Deja.com http://www.deja.com/ Before you buy. From tratt at dcs.kcl.ac.uk Wed Sep 1 05:16:19 1999 From: tratt at dcs.kcl.ac.uk (Laurence Tratt) Date: Wed, 01 Sep 1999 10:16:19 +0100 Subject: CGI speedup strategies References: <37CCE7C9.D340BBF5@strs.co.uk> Message-ID: In message <37CCE7C9.D340BBF5 at strs.co.uk> Ian Clarke wrote: > Has anyone tried actually implementing a Python webserver which just > starts a new thread and runs a piece of Python code in it every time > someone makes a HTTP request? When I had a need for such a thing, I messed around with the *HTTPServer stuff in the standard distribution to get what I wanted; because of, er, moving targets it ended up pretty messy but it's one way of doing things quickly if you have esoteric needs. Making it run threaded was trivial, although you still have to be aware of the standard threading problems . Laurie -- http://eh.org/~laurie/comp/python/ From srenner at lycosmail.com Sun Sep 12 15:31:52 1999 From: srenner at lycosmail.com (srenner at lycosmail.com) Date: Sun, 12 Sep 1999 19:31:52 GMT Subject: ANN: Tk Slashdot Headline Viewer References: <7rgmd0$2htg$1@hub.org> Message-ID: <7rgv38$8m8$1@nnrp1.deja.com> It works! Although I'm not sure what it's for -- why not just read Slashdot directly? But it definitely works. Also I am trying the folding editor. Would you consider modifying IDLE's class browser into a folding code editor? Because somebody should. Keep up the good work, sr Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From aprasad at magix.com.sg Sun Sep 12 05:45:00 1999 From: aprasad at magix.com.sg (Ajith Prasad) Date: Sun, 12 Sep 1999 17:45:00 +0800 Subject: Sun's StarOffice & Python Message-ID: <7rgk53$dbm$1@coco.singnet.com.sg> With Sun making the StarOffice application suite available for a free download and making its source-code available, I presume that there would now be a viable alternative to MS Office with a growing user base. Is anyone working on Python connectivity to StarOffice? Thanks in advance. From vnesek at maja.zesoi.fer.hr Wed Sep 1 03:09:28 1999 From: vnesek at maja.zesoi.fer.hr (Vjekoslav NESEK) Date: 1 Sep 1999 07:09:28 GMT Subject: Pythom in embedded system? Message-ID: Hi, I would like to ask all you python source code hackers: 1) Is it possible to remove all os dependant (just ansii c) code from distributions, leaving only core intepreter? 2) Is it possible to run it on 16bit machine 3) What is a minimum RAM requirements for such trimmed down Python? 4) How slow would it be on lets say 16Mhz 80x86? I am asking because I would like to use python for glue code in embedded system. It is not a real time embedded system. Anyway if not python, can you point me to some other free interpeter suitable for embedding in such a limited system? Thanks, -- // Vjeko (vnesek at zesoi.fer.hr) import java.advertising.*; new URL("http://diana.zesoi.fer.hr/~vnesek/"); From pj at sgi.com Wed Sep 29 17:12:14 1999 From: pj at sgi.com (Paul Jackson) Date: 29 Sep 1999 21:12:14 GMT Subject: More Python books coming... References: <5lpuz483p4.fsf@eric.cnri.reston.va.us> <37F23C23.1DD36623@megsinet.net> Message-ID: <7stvbe$bk3hq@fido.engr.sgi.com> |> I found a free e-book ... I will e-mail this book ... Perhaps you could briefly describe this e-book? Say title, author, date of writing and a few word summary? -- ======================================================================= I won't rest till it's the best ... Software Production Engineer Paul Jackson (pj at sgi.com; pj at usa.net) 3x1373 http://sam.engr.sgi.com/pj From tim_one at email.msn.com Wed Sep 8 20:57:46 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 8 Sep 1999 20:57:46 -0400 Subject: Python example: possible speedup? In-Reply-To: <19990908230036.A3530@krikkit.vollmert.home> Message-ID: <000001befa5e$5493e140$362d153f@tim> [Hrvoje Niksic, writes a pretty text-crunching program in Python that's-- horrors! --slower than a Perl workalike] [Robert Vollmert, among others, does various irksome things to speed it up, and remarks ...] > The main speed advantage seems to be that the files aren't > processed line by line, which is of course very memory consuming. This probably bears repetition about once a month : Python does line-at-a-time input on top of the platform's stdio package. On the popular platforms, Perl does line-at-a-time input by breaking into the platform's stdio package, peeking and poking C FILE structs directly in platform-specific ways. This can give Perl a huge speed advantage on line-at-a-time input; indeed, on Windows, Perl does line-at-a-time input faster than pure optimized C/C++ code using Microsoft's fgets, and about 3x faster than Python under Win95. Perl's speed advantage here is directly proportional to the stupidity of the platform's stdio implementation ("read a line from a file? who on earth would want to do that?" ). eschew-files-embrace-3d-buttons-ly y'rs - tim From nathan at islanddata.com Mon Sep 13 12:13:49 1999 From: nathan at islanddata.com (Nathan Clegg) Date: Mon, 13 Sep 1999 09:13:49 -0700 (PDT) Subject: Queue not releasing memory In-Reply-To: <000401befd03$3813bf20$492d153f@tim> Message-ID: On 12-Sep-99 Tim Peters wrote: > Python has no control over when your OS decides that released memory is > available to something else. If you name your OS, perhaps someone will > know > how to influence it reliably. The results I described were under Linux, glibc 2.1.1. The target platform for this application, however, is Solaris 2.7, which is worse. Under Solaris, the memory is not reclaimed when the queue is deleted. The entire python process must terminated. Not excited about this. I just did a simple malloc/free test with the exact same results. Bad Solaris. > By the way, look at that code carefully: the default Queue > implementation > wasn't meant to handle memory-busting amounts of data! That "del > self.queue[0]" line makes a physical copy of the entire data remaining > every > time. I do need the thread-safety of the Queue class. The large size requirement is only an extreme situation, which is why it is important that it backs down afterward. Perhaps I need to take some pressure off Queue and move more quickly to my other lines of defense. Is there no way to remove an element from a list without making a copy? append() doesn't need a copy. I was under the impression that lists were internally represented by a more dynamic form. Thanks for the information. I will reevaluate my plan of attack. ---------------------------------- Nathan Clegg nathan at islanddata.com From etsang at my-deja.com Tue Sep 28 14:29:28 1999 From: etsang at my-deja.com (etsang at my-deja.com) Date: Tue, 28 Sep 1999 18:29:28 GMT Subject: ExpectPy Installation problem --- problem restated. Message-ID: <7sr1dn$iou$1@nnrp1.deja.com> I used this during installation of ExpectPy: ./configure --with-python=/s1/sqa/edwardt/Python/Python-1.5.2--with- expect=/tools/2.5.1/local/lib But it says cannot compile with the python library..... Any heads up? Is there something I need to download before this?? I have got the python from www.python.org. The final release one... But for some reason, the installation program is still trying to look for the network installed Python!!!! Attached below is the config.log: Please help experts!!! This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. configure:568: checking host system type configure:659: checking for gcc configure:736: checking whether the C compiler (gcc ) works configure:750: gcc -o conftest conftest.c 1>&5 configure:770: checking whether the C compiler (gcc ) is a cross- compiler configure:775: checking whether we are using GNU C configure:784: gcc -E conftest.c configure:799: checking whether gcc accepts -g configure:828: checking whether gcc and cc understand -c and -o together configure:843: gcc -c conftest.c -o conftest.o 1>&5 configure:844: gcc -c conftest.c -o conftest.o 1>&5 configure:849: cc -c conftest.c 1>&5 configure:851: cc -c conftest.c -o conftest.o 1>&5 configure:852: cc -c conftest.c -o conftest.o 1>&5 configure:879: checking how to run the C preprocessor configure:900: gcc -E conftest.c >/dev/null 2>conftest.out configure:940: checking for AIX configure:974: checking for a BSD compatible install configure:1026: checking for ranlib configure:1053: checking whether ln -s works configure:1076: checking for rm configure:1116: checking for python configure:1155: checking for expect configure:1202: checking SO configure:1224: checking LDSHARED configure:1256: checking LDEXE configure:1279: checking CCSHARED configure:1341: checking Python version configure:1370: checking Expect version configure:1390: checking Expect library location configure:1435: checking Tcl version (for testing) configure:1473: checking use of Python Setup configure:1548: checking for openpty configure:1576: gcc -o conftest -g -O2 -I/s1/sqa/edwardt/Python/Python-1.5.2/Include -I/tools/2.5.1/local/lib -L/s1/sqa/edwardt/Python/Python-1.5.2 -L/tools/2.5.1/local/lib conftest.c 1>&5 /var/tmp/ccafaaHJ1.o: In function `main': /s1/sqa/edwardt/Python/ExpectPy-1.8/configure:1570: undefined reference to `openpty' configure: failed program was: #line 1553 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char openpty(); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char openpty(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_openpty) || defined (__stub___openpty) choke me #else openpty(); #endif ; return 0; } configure:1598: checking for openpty in -lutil configure:1617: gcc -o conftest -g -O2 -I/s1/sqa/edwardt/Python/Python-1.5.2/Include -I/tools/2.5.1/local/lib -L/s1/sqa/edwardt/Python/Python-1.5.2 -L/tools/2.5.1/local/lib conftest.c -lutil 1>&5 /tools/2.5.1/local/sparc-sun-solaris2.5.1/bin/ld: cannot open -lutil: No such file or directory configure: failed program was: #line 1606 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char openpty(); int main() { openpty() ; return 0; } configure:1646: checking for cos in -lm configure:1665: gcc -o conftest -g -O2 -I/s1/sqa/edwardt/Python/Python-1.5.2/Include -I/tools/2.5.1/local/lib -L/s1/sqa/edwardt/Python/Python-1.5.2 -L/tools/2.5.1/local/lib conftest.c -lm 1>&5 configure:1658: warning: conflicting types for built-in function `cos' configure:1693: checking for dlopen in -ldl configure:1712: gcc -o conftest -g -O2 -I/s1/sqa/edwardt/Python/Python-1.5.2/Include -I/tools/2.5.1/local/lib -L/s1/sqa/edwardt/Python/Python-1.5.2 -L/tools/2.5.1/local/lib conftest.c -ldl -lm 1>&5 configure:1741: checking for pthread_create in -lpthread configure:1760: gcc -o conftest -g -O2 -I/s1/sqa/edwardt/Python/Python-1.5.2/Include -I/tools/2.5.1/local/lib -L/s1/sqa/edwardt/Python/Python-1.5.2 -L/tools/2.5.1/local/lib conftest.c -lpthread -ldl -lm 1>&5 configure:1877: checking for exp_expectv in -lexpect5.26 configure:1896: gcc -o conftest -g -O2 -I/s1/sqa/edwardt/Python/Python-1.5.2/Include -I/tools/2.5.1/local/lib -L/s1/sqa/edwardt/Python/Python-1.5.2 -L/tools/2.5.1/local/lib conftest.c -lexpect5.26 -ldl -lm 1>&5 /tools/2.5.1/local/lib/libexpect5.26.a(exp_clib.o): In function `exp_spawnv': /net/wrk/expect-5.26/exp_clib.c:282: undefined reference to `Tcl_ErrnoMsg' /net/wrk/expect-5.26/exp_clib.c:296: undefined reference to `Tcl_ErrnoMsg' /net/wrk/expect-5.26/exp_clib.c:369: undefined reference to `Tcl_ErrnoMsg' /net/wrk/expect-5.26/exp_clib.c:497: undefined reference to `Tcl_ErrnoMsg' /net/wrk/expect-5.26/exp_clib.c:509: undefined reference to `Tcl_ErrnoMsg' /tools/2.5.1/local/lib/libexpect5.26.a(exp_clib.o):/net/wrk/expect- 5.26/exp_clib .c:532: more undefined references to `Tcl_ErrnoMsg' follow /tools/2.5.1/local/lib/libexpect5.26.a(exp_clib.o): In function `expectv': /net/wrk/expect-5.26/exp_clib.c:771: undefined reference to `TclRegError' /net/wrk/expect-5.26/exp_clib.c:772: undefined reference to `TclRegComp' /net/wrk/expect-5.26/exp_clib.c:773: undefined reference to `TclGetRegError' /net/wrk/expect-5.26/exp_clib.c:947: undefined reference to `TclRegError' /net/wrk/expect-5.26/exp_clib.c:948: undefined reference to `TclRegExec' /net/wrk/expect-5.26/exp_clib.c:952: undefined reference to `TclGetRegError' /net/wrk/expect-5.26/exp_clib.c:953: undefined reference to `TclGetRegError' /tools/2.5.1/local/lib/libexpect5.26.a(pty_termios.o): In function `exp_getptyslave': /net/wrk/expect-5.26/pty_termios.c:623: undefined reference to `Tcl_ErrnoMsg' /net/wrk/expect-5.26/pty_termios.c:626: undefined reference to `Tcl_ErrnoMsg' /net/wrk/expect-5.26/pty_termios.c:629: undefined reference to `Tcl_ErrnoMsg' configure: failed program was: #line 1885 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char exp_expectv(); int main() { exp_expectv() ; return 0; } configure:1920: checking for exp_expectv in -lexpect5.26 configure:1939: gcc -o conftest -g -O2 -I/s1/sqa/edwardt/Python/Python-1.5.2/Include -I/tools/2.5.1/local/lib -L/s1/sqa/edwardt/Python/Python-1.5.2 -L/tools/2.5.1/local/lib conftest.c -lexpect5.26 -ltcl -ldl -lm 1>&5 configure:2024: checking for PyObject_GetAttr in -lpython1.5 configure:2043: gcc -o conftest -g -O2 -I/s1/sqa/edwardt/Python/Python-1.5.2/Include -I/tools/2.5.1/local/lib -L/s1/sqa/edwardt/Python/Python-1.5.2 -L/tools/2.5.1/local/lib conftest.c -lpython1.5 -ldl -lm 1>&5 /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `setipaddr': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:404: undefined reference to `gethostbyname' /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `PySocketSock_accept': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:612: undefined reference to `accept' /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `PySocketSock_setsockopt': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:719: undefined reference to `setsockopt' /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `PySocketSock_getsockopt': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:759: undefined reference to `getsockopt' /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:773: undefined reference to `getsockopt' /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `PySocketSock_bind': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:803: undefined reference to `bind' /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `PySocketSock_connect': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:854: undefined reference to `connect' /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `PySocketSock_connect_ex': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:880: undefined reference to `connect' /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `PySocketSock_getsockname': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:953: undefined reference to `getsockname' /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `PySocketSock_getpeername': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:980: undefined reference to `getpeername' /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `PySocketSock_listen': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:1008: undefined reference to `listen' /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `PySocketSock_recv': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:1083: undefined reference to `recv' /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `PySocketSock_recvfrom': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:1122: undefined reference to `recvfrom' /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `PySocketSock_send': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:1167: undefined reference to `send' /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `PySocketSock_sendto': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:1199: undefined reference to `sendto' /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `PySocketSock_shutdown': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:1223: undefined reference to `shutdown' /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `PySocket_gethostbyname_ex': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:1483: undefined reference to `gethostbyname' /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `PySocket_gethostbyaddr': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:1551: undefined reference to `gethostbyaddr' /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `PySocket_getservbyname': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:1583: undefined reference to `getservbyname' /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `PySocket_getprotobyname': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:1617: undefined reference to `getprotobyname' /s1/sqa/edwardt/Python/Python-1.5.2/libpython1.5.a(socketmodule.o): In function `PySocket_socket': /s1/sqa/poonam/python/Python-1.5.2/Modules/./socketmodule.c:1651: undefined reference to `socket' configure: failed program was: #line 2032 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char PyObject_GetAttr(); int main() { PyObject_GetAttr() ; return 0; } configure:2066: checking for PyObject_GetAttr in -lpython1.5 Sent via Deja.com http://www.deja.com/ Before you buy. From pinard at iro.umontreal.ca Sat Sep 18 09:04:30 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 18 Sep 1999 09:04:30 -0400 Subject: Reaching subtrees In-Reply-To: "Darrell"'s message of "Fri, 17 Sep 1999 22:13:40 -0400" References: <012e01bf017b$6ce64a20$0100a8c0@rochester.rr.com> Message-ID: "Darrell" ?crit: > Not understanding why you like this [recursive tuple unpacking] so much. > But happy that you do. Thanks. I like it because I have code that explore subtrees according to literally hundreds of structural patterns (if not thousands when you put all the programs together), and I even wrote a language to help me at this. So, it is a common problem for me, and I like expressing constraints fluently. If Python allows me to easily name subtrees while picturing the skeleton model, it means that I could use unadorned Python to write unusually legible code for such things without having to recourse to special languages. A Python application would have to be small, as implementing my language revealed me how necessary it is to precondition how huge rule sets are handled -- an important part of my effort was devoted to optimisation. However, having contemplated Python in some more detail, there is still a few important cases of structural patterns that my language implements, and that do not seem to be easily representable with mere recursive tuple unpacking. But I would guess that for many simple cases, Python would just suffice. By the way, and quite unrelated to my own tool language, if recursive tuple unpacking was accepting an immutable (instead of a variable) in the skeleton as forcing an exact match instead of an assignment, and if the same variable could be repeated in the skeleton and then, force an identity check instead of an assignment, maybe that would make Python not very far from Prolog unification :-). Just a random thought, of course. > Yes, this looks like standard python stuff. I'll try to find a precise statement of this in Guido's reference manual. > As you know if the tuples don't unpack correctly they throw an exception. > Exceptions are slow so doing this on a large scale might be a problem. I guess they might be slow because they have to somewhat scan the stack back to find an exception catcher, but otherwise, if exceptions are caught quite early on the stack, do they still have to be slow? That would be a little unfortunate, at least for my case. I thought that `try:' could become an important part of Python writing style. It should rather not? -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From pinard at iro.umontreal.ca Mon Sep 13 23:01:35 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 13 Sep 1999 23:01:35 -0400 Subject: French pun on Python! :-) Message-ID: Hi, people. While introducing Python to a few friends, I noticed they tend to naturally use `je Pythonne', `nous Pythonnons', etc. as an easy pun on the word Python. I think that English people pronounce `pie-ton', while French people say `pea-to[n]' (said faster, with the `n' silent). This has the same sounds as for the word `piton'. A `piton' is a familiar word to design any mechanical device on which someone pushes, like an electrical button, or often, one of the keys of a computer keyboard. So, `je pitonne', `nous pitonnons', etc. already became a familiar way to express any soft computer hacking. I thought this might amuse some of you. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From Doug at news.vex.net Mon Sep 13 01:19:05 1999 From: Doug at news.vex.net (Lewis) Date: 13 Sep 1999 05:19:05 GMT Subject: ANN: Tk Slashdot Headline Viewer References: <7rgmd0$2htg$1@hub.org> <7rgv38$8m8$1@nnrp1.deja.com> Message-ID: <7ri1g9$2k5p$1@hub.org> On Sun, 12 Sep 1999 19:31:52 GMT, srenner at lycosmail.com wrote: >It works! Although I'm not sure what it's for -- why not just read >Slashdot directly? Admittedly it's probably of little practical value. It was really a project for me to play with while learning Tkinter. Although on the other hand, it can be nice to have a little window open (which is not a browser window) which monitors the slashdot headlines and regularly checks for updates... just in case soemthing interesting comes along. Also my little monitor is much more concise in its listing than the web page which you have to actually scroll down (gasp!) to see all the stories. Heh. >Would you consider modifying IDLE's class browser into a folding >code editor? Don't ask me! I still can't figure out how the heck to even change the normal text background in IDLE! Hehe. Which is why i never use it... it blinds me with its black and whiteness... alas. I have heard newer versions have a config file now, which may or may not have such settings... however it's only available on the CSV... a trick i haven't learned to access yet. I'm just a small time hobby hacker who doesn't really have any sort of clue what he's doing most of the time after all. (-: From akuchlin at mems-exchange.org Wed Sep 8 15:00:24 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 08 Sep 1999 15:00:24 -0400 Subject: Programmers Editor References: <37D5916B.606E@zeusedit.com> <00da01bef9e0$6e1b5c70$f29b12c2@secret.pythonware.com> Message-ID: <3dg10p1b5j.fsf@amarok.cnri.reston.va.us> "Fredrik Lundh" writes: > but to help them, it's probably better to put up > a site somewhere comparing different tools (or > just pointing to them), than to follow up on every > announcement with a plug for your own favourite > tool. with dozens of development tools out there, > it doesn't really scale if everyone would do that ;-) Andres Corrada-Emmanuel has written an editor HOWTO that hasn't been put on the Web yet; currently it covers configuring Emacs, Alpha and CodeWright for convenient editing of Python code. (Hmm... I vaguely recall sections on jed and vi; maybe my copy at work is out of date -- I'll have to look on my home machine.) Anyway, if someone wanted to contribute info on editing Python with Zeus, KDevelop, or whatever, it would be very helpful. Just follow up to this posting with notes on configuring your editor of choice. -- A.M. Kuchling http://starship.python.net/crew/amk/ His first victim was a priest. Roger's senses were blessed with furtive longings and sweet altar wine. -- The Head's backstory, in ENIGMA #1: "The Lizard, The Head, The Enigma" From fredrik at pythonware.com Thu Sep 9 09:04:29 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 9 Sep 1999 13:04:29 GMT Subject: Inspecting long running programs References: <19990909111034.12856@nms.otc.telstra.com.au> <7r7356$3b4@dfw-ixnews8.ix.netcom.com> <5lr9k84777.fsf@eric.cnri.reston.va.us> Message-ID: <00c101befac3$dac08790$f29b12c2@secret.pythonware.com> Guido van Rossum wrote: > > asyncore (which Medusa is built on) includes this functionality. It can > > be kind of trippy to just telnet to a blind socket and get a Python > > interpreter session. > > Really? I don't see a trace of this in the version of asyncore I have > in the standard Python library! I'd love to have this feature! it's a medusa thingie. look for monitor.py and monitor_client.py. From g.gruber at xsoft.co.at Thu Sep 2 05:40:54 1999 From: g.gruber at xsoft.co.at (Gerhard W. Gruber) Date: Thu, 02 Sep 1999 11:40:54 +0200 Subject: adding to dictionaries Message-ID: <37CE4626.8FCEA15B@xsoft.co.at> Is it possible to add an entry to an already existing dictioniary? -- bye, Gerhard email: sparhawk at eunet.at g.gruber at xsoft.co.at From tre17 at student.canterbury.ac.nz Tue Sep 21 20:46:35 1999 From: tre17 at student.canterbury.ac.nz (tre17 at student.canterbury.ac.nz) Date: 22 Sep 1999 12:46:35 +1200 Subject: Print/Input statements References: <000601befe4c$3e585ae0$54a2143f@tim> <87u2oxeass.fsf@pc-hrvoje.srce.hr> <87n1ug5t0y.fsf_-_@compsoc.dur.ac.uk> <000b01bf043b$39f2fab0$f29b12c2@secret.pythonware.com> <19990921151648.B5974@compsoc.dur.ac.uk> Message-ID: Andrew Stribblehill writes: [slightly misunderstood version snipped] > > OK, a more obvious example (sorry!): > > #!/usr/bin/python > import sys > print "I didn't expect a Spanish Inquisition\n>", > x=sys.stdin.readline() > print "Nobody expects a Spanish Inquisition!" > > The "Nobody" has a space in front of it. > > When I replace the print statement with: > sys.stdout.write("doodah\n>") > the Nobody loses its annoying space. > > Cheerio, > > Andrew. Well, you could always use raw_input to print your prompt, instead of print: #!/usr/bin/python import sys print "I didn't expect a Spanish Inquisition" x = raw_input(">") print "Nobody expects a Spanish Inquisition!" If you also add `import readline' to the script (if readline is available) then you get command editing and history. -- Tim Evans From ivanlan at callware.com Wed Sep 8 11:20:20 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Wed, 8 Sep 1999 15:20:20 GMT Subject: Feast or famine! - Anyone read or dealt with Wrox Press? References: <37d60e03.1299428@news.iol.ie> <9VtB3.14$114.1985@news.clarkson.edu> Message-ID: <37D67EB4.22612A9E@callware.com> Hi All-- Brad Clements wrote: > > Not quite related but the Wrox folks seem interested in a Python book. Has > anyone actually read a Wrox press book? Whats your opinion? Has anyone dealt > with them as a publisher? > Their books present a nice appearance; usually, they cover their areas in exhaustive detail. However, I do suspect them of rushing their authors, as I've found many errors in example code. I've got several Wrox books, and the code in none of them is perfect. I hesitate to say that the code is not tested, as it may just be version creep. -ly y'rs, Ivan;-) ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From laheadle at boguscs.uchicago.edu Tue Sep 14 04:20:43 1999 From: laheadle at boguscs.uchicago.edu (Lyn A Headley) Date: Tue, 14 Sep 1999 08:20:43 GMT Subject: embedded Python server - desperate for help References: <37DD589D.5B0347E6@ncsa.uiuc.edu> Message-ID: Randy> Py_Initialize(); // import some libs // wait for incoming Randy> strings to execute... Randy> then client #1 might do: server-> execute("s1 = Square(4)"); Randy> what if client #2 also creates an object 's1': server-> execute("s1 = Square(6)"); Randy> Aren't the object names in some global namespace and Randy> therefore problematic? Well yes, that would be problematic if you want each client to have its own namespace. Are you sure you want clients to run arbitrary code on the server side? I'd suggest you define a client/server protocol, based on something like xml-rpc or corba with fnorb. -- Lyn Headley remove the word "bogus" from my address for the real one. From aahz at netcom.com Wed Sep 1 17:35:43 1999 From: aahz at netcom.com (Aahz Maruch) Date: 1 Sep 1999 21:35:43 GMT Subject: Returning none References: <000001bef265$fe64f340$192d153f@tim> <37CC79C5.1BFDC710@compaq.com> <7qidi6$nbb$1@towncrier.cc.monash.edu.au> Message-ID: <7qk67f$9oc@dfw-ixnews15.ix.netcom.com> In article <7qidi6$nbb$1 at towncrier.cc.monash.edu.au>, Jonathan Giddy wrote: > >This requires that we always use the result of a call to a real function, >even if we just assign it to a dummy variable. And that means someone >will one day spend time trying to find where the dummy variable is used, >instead of instantly being aware that the function is only called for its >side effects. > >For example, FileObject.close needs to be a function to return the exit >status of a popen process. Hence, every file close will need to be >assigned (or used in some way). Your example does not illustrate your point IMO, because there *is* a potentially useful value returned. If a function returns a value that is truly never used, there is Something Wrong. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From daniels at mindspring.com Sun Sep 12 22:55:02 1999 From: daniels at mindspring.com (Alan Daniels) Date: 13 Sep 1999 02:55:02 GMT Subject: Programmers Editor References: <37D5916B.606E@zeusedit.com> <00da01bef9e0$6e1b5c70$f29b12c2@secret.pythonware.com> <3dg10p1b5j.fsf@amarok.cnri.reston.va.us> Message-ID: On 9 Sep 1999 18:42:51 GMT, the infinitely wise Bernhard Reiter (bernhard at alpha1.csd.uwm.edu) spoke forth to us, saying... >Someone should elaborate on the tab use in vim a bit. I set up the following in my .vimrc file: set list set listchars=tab:#^ set noexpandtab "list" says to show otherwise non-viewable characters, such as tabs, newlines, or trailing spaces. "listchars" sets what those should show up as -- in my case, I'm just interested in seeing all tabs as something like "#^^^^^". The "noexpandtab" tells VIM to insert spaces rather than an actual tab character. The overall effect is that tab characters never make it into my source code. Tabs are bad, bad, bad. And, with "list" turned on, I can immediately see if any snuck in there, or (horrors), I have the source code of others that has tabs in them. A simple... :%s/\t/ /gc ...turns all of your tabs into spaces. Of course, this means I usually trip up when handling Makefiles (which, if you'll remember, really DO need actual tab chars), but the benefit is worth the occasional headache. :=) Also, if you're brave enough, you can compile VIM with a --python-enabled option under "./configure", which will let you run python code without leaving the editor (Hey! Almost like Emacs!). This may sound complicated, but if you're using VIM to begin with you obviously have a pathological lack of any fear of complexity to begin with. :=) The interface will let you type stuff like... :py print "Hello world!" ...and Python is fired up for you. The downside is, it's only good for one-liners, so you can't do anything too complicated. I can only surmise that this feature was added in the same spirit as VIM's ":pl" command for Perl. :=) -- ======================= Alan Daniels daniels at mindspring.com daniels at cc.gatech.edu From englim at pc.jaring.my Wed Sep 8 12:20:03 1999 From: englim at pc.jaring.my (lec) Date: Thu, 09 Sep 1999 00:20:03 +0800 Subject: Bug in time module? References: <1275332084-98066501@hypernet.com> Message-ID: <37D68CB2.BB5F9CC9@pc.jaring.my> Gordon McMillan wrote: > > The only editing Python's time module does is to ensure that you've > passed the right number and kind of args. Everything else is the > result of your platform's implementation of strptime. If you want > something _good_, you should probably use MA Lemburg's mxDateTime. > > - Gordon Consider the following exception raised: Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 (egcs-1.1.1 on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import time >>> time.strptime('31/13/1999', "%d/%m/%Y") Traceback (innermost last): File "", line 1, in ? ValueError: format mismatch Shouldn't the same exception be raised for time.strptime('31/02/1999', "%d/%m/%Y") ? From mlh at idt.ntnu.no Tue Sep 21 19:02:38 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 22 Sep 1999 01:02:38 +0200 Subject: cgi authentication References: Message-ID: "Dan Grassi" writes: > I need to do authentication from Python, for various reasons using Apache > and .htaccess is not a workable solution. I can get the request to show up > with the following code but I can not figure out how to access the returned > name/password pair. Yes, I have looked hard for the info on the web and in > the books. "-) Well - I have had the same problem, and AFAIK, Apache refuses to give you the password (ostensibly for security reasons...) There is a patched version available somewhere... > > Can anyone help? > -- Magnus Lie Please forward all spam to Hetland uce at ftc.org From victor at idaccr.org Wed Sep 22 16:51:24 1999 From: victor at idaccr.org (Victor S. Miller) Date: 22 Sep 1999 16:51:24 -0400 Subject: PIL: decode jpeg not available Message-ID: I have Python 1.5.2 build on Solaris 2.6 with gcc 2.7.2.2. I also have tcl8.1 and tk8.1, IJG jpeg-6b and zlib-1.1.3. I built PIL 1.0 with all these, and uncommented and built Python with the WITH_PIL stuff for tkinter. However, when I try to use the viewer.py script that came with PIL with a jpeg file, I get the following error: Traceback (innermost last): File "viewer.py", line 45, in ? UI(root, im).pack() File "viewer.py", line 24, in __init__ self.image = ImageTk.PhotoImage(im) File "/usr/local/coop/lib/python1.5/site-packages/PIL/ImageTk.py", line 85, in __init__ self.paste(image) File "/usr/local/coop/lib/python1.5/site-packages/PIL/ImageTk.py", line 107, in paste im.load() File "/usr/local/coop/lib/python1.5/site-packages/PIL/ImageFile.py", line 133, in load d = Image._getdecoder(self.mode, d, a, self.decoderconfig) File "/usr/local/coop/lib/python1.5/site-packages/PIL/Image.py", line 229, in _getdecoder raise IOError, "decoder %s not available" % decoder_name IOError: decoder jpeg not available Is there something that I've forgotten? Any suggestions as to how to track down the problem? -- Victor S. Miller | " ... Meanwhile, those of us who can compute can hardly victor at idaccr.org | be expected to keep writing papers saying 'I can do the CCR, Princeton, NJ | following useless calculation in 2 seconds', and indeed 08540 USA | what editor would publish them?" -- Oliver Atkin From dnlbfx at aol.com Thu Sep 23 22:28:04 1999 From: dnlbfx at aol.com (dnlbfx at aol.com) Date: Fri, 24 Sep 1999 02:28:04 GMT Subject: This Is The Best The Internet Has To Offer 9098 Message-ID: Hi, My name is Ellie and I just stumbled across what has to be the BEST source on the internet! Its totally free and easy to have the most fun ever! http://www.amylinks.com/ Visit Amys Links, its totally worth it! oibrpmeqtxifgghnvbkfcwmgdffikymfbsjhwcxvodrbykyktus From os at webinspace.de Thu Sep 30 02:05:17 1999 From: os at webinspace.de (Oliver Scheel) Date: Thu, 30 Sep 1999 08:05:17 +0200 Subject: More Python books coming... References: <5lpuz483p4.fsf@eric.cnri.reston.va.us> <37F0855B.461C6DC3@webinspace.de> <5lk8pb8ex5.fsf@eric.cnri.reston.va.us> Message-ID: <37F2FD9D.EF7D475C@webinspace.de> Guido van Rossum wrote: > > If you don't mind the different cover art, David Beazley's "Python; > Essential Reference" is pretty much what you'd expect from a nutshell > book; packed with no-nonse reference information about language and > library. There's even an appending with C API info. Visited Amazon to get a description. Sounds very interesting! It seems that it is the book that I was looking for ;-) Thanks for that hint. Oliver From dave at see.sig.for.address Sun Sep 5 17:03:29 1999 From: dave at see.sig.for.address (Dave) Date: Sun, 05 Sep 1999 21:03:29 GMT Subject: jpython and java apps References: <7qsh7i$5nu$1@msunews.cl.msu.edu> Message-ID: <37d4c8a5.17734643@read.news.global.net.uk> On Sat, 4 Sep 1999 21:35:36 -0400, "Richard Hensh" wrote: >Can one "compile" a Python script into a Java class (?) using JPython (a la >NetRexx)? > >thanks >ricky > Yes, though it is not very well documented. Essentially you have to do the following: 1) write a python class and have it inherit from a Java class or interface. The python class must have the same name as the file it is in, just like Java classes. 2) add a doc string to each python method that specifies the Java signature, starting with "@sig". This bit is not documented, but is done in the example that comes with jpython. 3) compile the python class using jpythonc. This will create the .class files that can be used just like any other Java class. There are numerous options to jpythonc for things like creating jar files and packages, which are documented to some extent. Make sure you have the latest version of jpython (1.1a2), especially if you want to use Java packages. I would also suggest joining the jpython mailing list, which is where all the real experts hang out. Dave K -------------------------------------------------- All great ideas start as heresy and end as dogma. dkirby@ <-figure this out, spambots! bigfoot. My opinions are my own, com but I'm willing to share. From nathan at islanddata.com Tue Sep 28 12:07:20 1999 From: nathan at islanddata.com (Nathan Clegg) Date: Tue, 28 Sep 1999 09:07:20 -0700 (PDT) Subject: keys and values lining up In-Reply-To: <000601bf094d$43e55ce0$18a0143f@tim> Message-ID: d.items() is my backup plan, of course, but I'd rather not. My purpose is to insert into a database based on the contents of a dictionary. SQL requires a list of keys and a separate list of values: INSERT INTO table (key1, key2, key3) VALUES (val1, val2, val3) If I were to use d.items(), I would them have to go back and use the list of two-tuples to generate a two-tuple of lists :) No point in going through the back door if you can work it right. If I'm guaranteed to get keys and values in the same order from the two function calls, that's far easier for my purposes. On 28-Sep-99 Tim Peters wrote: > [Nathan Clegg] >> If d is a dict, am I guaranteed that d.keys() and d.values() will >> line up, in proper order, if called successively with no modification >> in between? That is, is the following safe? >> >> k,v = d.keys(), d.values() > > Yes, under the mild assumption that you don't have another thread > running > that manages to sneak in and mutate d between the calls. If that's a > potential problem, do > > kv = d.items() # list of (key, value) tuples > > If you want both keys and values, it's clearer to use the method > designed > for that purpose anyway. > > something-fishy-about-keys-that-don't-unlock-anything-ly y'rs - tim > > > > -- > http://www.python.org/mailman/listinfo/python-list ---------------------------------- Nathan Clegg nathan at islanddata.com From holger at phoenix-edv.netzservice.de Wed Sep 15 09:29:42 1999 From: holger at phoenix-edv.netzservice.de (Holger Jannsen) Date: Wed, 15 Sep 1999 13:29:42 GMT Subject: timesync with python? References: <37D66AF3.6A3E96F7@phoenix-edv.netzservice.de> <002701befabb$1a884880$f29b12c2@secret.pythonware.com> Message-ID: <37DF9F46.85E7A332@phoenix-edv.netzservice.de> Thank you all for answers, I'll try it this week... greetings, Holger (a little bit in a hurry) From gerrit.holl at pobox.com Wed Sep 8 15:01:14 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Wed, 8 Sep 1999 21:01:14 +0200 Subject: string.zfill() Message-ID: <19990908210113.A3754@optiplex.palga.uucp> Hello, Why doesn't zfill takes as third argument the character (or string) to fill up the string with, instead of '0's? Has it a reason, or is it a bug/mistake? regards, Gerrit. -- Unix is easy: type 'man man' and the rest comes of itself. From wware-nospam at world.std.com Wed Sep 15 12:45:10 1999 From: wware-nospam at world.std.com (Will Ware) Date: Wed, 15 Sep 1999 16:45:10 GMT Subject: high school programming & python References: <37DF9080.21A8D285@calibre-dd.com> Message-ID: Stephen J King (king at calibre-dd.com) wrote: : Luxury! When we was kids all we 'ad was old wires which we 'ad to strip : with our teeth and wrap around dirty binding posts with our bare : fingers. Least your school could afford electrons. All we had was neutrons. They were slow and heavy, and you couldn't just impose an ambient electric field and expect them to move. Back then, computing took more skill and finesse. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From paul at prescod.net Sat Sep 4 18:40:32 1999 From: paul at prescod.net (Paul Prescod) Date: Sat, 4 Sep 1999 22:40:32 GMT Subject: language interpreters/ interpreted languages weaknesses? References: <1275835455-67788915@hypernet.com> <37CE9F55.88DFC9FC@megsinet.net> <37CEC4A9.C2CE2A91@prescod.net> Message-ID: <37D19FE0.C87DA906@prescod.net> Blake Winton wrote: > > Which points out, IMHO, Java's biggest problem. > There is no distinction between Java *the language*, Java *the VM*, Java > *the OS*, etc... This is a problem from a purist point of view but from a political point of view it is brilliant. Sun owns all of those things and it is much harder for anyone else to take control as long as they are bound together. What if Microsoft "bought" JPython and started promoting it? "That isn't Java" says Scott McNealy. What about when Microsoft makes a really great native compiler for Java. "That isn't Java either." Paul Prescod From watterss at pilot.msu.edu Sun Sep 12 23:51:02 1999 From: watterss at pilot.msu.edu (Shannon Watters) Date: Sun, 12 Sep 1999 23:51:02 -0400 Subject: [NEWBIE]: Tk icon Message-ID: <7rhsk2$gbi$1@msunews.cl.msu.edu> How can I get rid of the Tk logo in the top left corner of a Tk(inter) window? It's 'tacky'. I don't use that word much but it's the best one that came to mind when I was staring at it up there. It's making my highly complex "Hello world" button look unprofessional (<-spelled?). Shannon From Cobra__77 at hotmail.com Fri Sep 17 20:29:50 1999 From: Cobra__77 at hotmail.com (coby) Date: Sat, 18 Sep 1999 10:29:50 +1000 Subject: ftp files based on start and finish byte Message-ID: <37E2DCFE.6FE5BE87@hotmail.com> Here is a little problem... I want to transfer a 15MB file from one ftp sever to another using the passive mode...but I can't transfer 15MB at once...I can only transfer 5MB at a time...so I need a little script or ftp client (???) that will allow me to transfer files based on start and finish bytes..ie. I want to specify when to start and finish transfer...so basically I will get 3 five mega byte files..which I can merge together with a merge utility and end up with the 15MB file... any suggestions on how to do this....if you know any scripting or know any ftp client that does the above then please let me know... thanks From aahz at netcom.com Wed Sep 8 19:24:49 1999 From: aahz at netcom.com (Aahz Maruch) Date: 8 Sep 1999 23:24:49 GMT Subject: Looking for someone to program Python with References: <37D6EAF4.E3EEC55A@hotmail.com> Message-ID: <7r6r81$87p@dfw-ixnews5.ix.netcom.com> In article <37D6EAF4.E3EEC55A at hotmail.com>, Matt Lauer wrote: > >I am new in programming python and i am just looking for someone that >could help me with programming and write a prog. if possible. Try the Tutor mailing list, http://www.python.org/mailman/listinfo/tutor -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From skip at mojam.com Mon Sep 27 14:12:24 1999 From: skip at mojam.com (Skip Montanaro) Date: Mon, 27 Sep 1999 13:12:24 -0500 (CDT) Subject: Circular refs In-Reply-To: <000701bf0909$46bcb0b0$3acbd9c2@peridot.optichrome.com> References: <000701bf0909$46bcb0b0$3acbd9c2@peridot.optichrome.com> Message-ID: <14319.45960.133595.441653@dolphin.mojam.com> Adrian> I can dream up a million ways to kludge around this bug, but I Adrian> was referring to a 'fix' to the Python source code. How hard can Adrian> it be? You can take a look at Neil Schemenauer's recent garbage collection patch. It's only used to reclaim circular garbage. http://www.acs.ucalgary.ca/~nascheme/python/gc.html There are other GC patches for Python floating around. This just happens to be the most recent one I've seen posted. Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From pinard at iro.umontreal.ca Thu Sep 2 10:23:07 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: Thu, 2 Sep 1999 14:23:07 GMT Subject: Python speed and `pcre' In-Reply-To: "Fredrik Lundh"'s message of "Thu, 2 Sep 1999 15:54:00 +0200" References: <00af01bef543$0affe8f0$f29b12c2@secret.pythonware.com> <002101bef54a$9c7682b0$f29b12c2@secret.pythonware.com> Message-ID: "Fredrik Lundh" ?crit: > Fran?ois Pinard wrote: > > Yes, of course. Given strings are immutable, an implementation could have: > > > > ref=str > > str=str+str1 > > > > and have `ref' points to a substring of `str', without copy most of > > the time, when `str1' is small. > what do you do when you have to reallocate str? Then, you have copies. The substring is still referenced. How to implement that? I do not know and would have to study the matter to find possible answers, but it really is an implementation issue, that should not bother users. The key point of the whole argument is that people should program in Python in the spirit of its simplicity, while the implementor should worry about how to make the implementation speedy. It is not healthy that users need to know how things are implemented, then alter their programming style. It does not fit well in what I understand from Python, as a language. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From wware-nospam at world.std.com Fri Sep 24 12:23:46 1999 From: wware-nospam at world.std.com (Will Ware) Date: Fri, 24 Sep 1999 16:23:46 GMT Subject: Read stdout from shell command, was: Becoming root References: <19990924165114.A753@krikkit.vollmert.home> Message-ID: Robert Vollmert (rvollmert at gmx.net) wrote> > On Fri, Sep 24, 1999 at 04:14:15AM +0000, Will Ware wrote: > > if os.popen('whoami').readline()[:-1] == 'root': > > Dumb question for those wiser than myself: > > The os.popen().readline()[:-1] construction is pretty ugly. > > Is there a better way to do it? > How about 'if os.getuid() == 0:' ? Thanks, a few others have mentioned this and slight variations. The thing I'd really like to know is how to do the Python equivalent of a shell command of this form: variable = `some shell command` where "some shell command" prints to standard output. I find I do this quite frequently, usually using something like os.popen('some shell command').readline()[:-1] and sure, it works, but it's really ugly, and I'm always left with the nagging suspicion that since I didn't explicitly close the os.popen(), it might still be floating around. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From aahz at netcom.com Wed Sep 1 12:10:54 1999 From: aahz at netcom.com (Aahz Maruch) Date: 1 Sep 1999 16:10:54 GMT Subject: SyntaxError exception 1.5.1 vs 1.5.2 References: <7q7822$ba6$1@nnrp1.deja.com> Message-ID: <7qjj6e$4eu@dfw-ixnews21.ix.netcom.com> In article <7q7822$ba6$1 at nnrp1.deja.com>, wrote: > >i've noticed differences between 1.5.1 and 1.5.2 wrt: handling a >SyntaxError exception. Which behavior is correct? > >Here is the scenario: > >bad_syntax.py: >hello" > >build_py.py: >import sys > >try: > py_compile.compile('bad_syntax.py') > print "after compile" >except: > print "compile error" > >now the output: > >python1.5.1: >compile error > >python1.5.2: >File "bad_syntax.py", line 1 > hello" > ^ >SyntaxError: invalid token >after compile I dunno. Tim? Fred? Fredrik? Yoo-hoo! -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From fredrik at pythonware.com Mon Sep 6 03:25:51 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 6 Sep 1999 07:25:51 GMT Subject: Localizing strings? References: <7qv8c8$qtm$1@nnrp1.deja.com> Message-ID: <004701bef839$0e303fe0$f29b12c2@secret.pythonware.com> Preston Landers wrote: > Is there an easy way to use translatable strings in your Python program > a la GNU gettext? The os.localize module doesn't seem to do what I need > to do. can anyone point me to some documentation or examples? how about: # Translate.py messages = {} # ... check environment variable to figure out what file # to load, and load it using marshal, fp.readlines, pickle, ... # do it by hand, for now... message["hello, world"] = "tjaba" def T(message): return table.get(messages, messages) and: # main from Translate import T print T("hello, world") From donn at oz.net Mon Sep 6 12:43:45 1999 From: donn at oz.net (Donn Cave) Date: 6 Sep 1999 16:43:45 GMT Subject: ANN: BeOS system API modules Message-ID: <7r0r01$qqg$0@216.39.151.169> First release of some stuff I've been fiddling with for a long time. BeOS is, of course, the new computer operating system that has Microsoft quaking in their boots, as we learned during recent judicial proceedings. It has a C++ API, which has been some fun to integrate with Python. The result is a more or less idiomatic native BeOS Python interface. One module per C++ class, modules import each other liberally. Only a fairly minimal complement of modules at this point, but they're generated from templates and fairly easy to write. I have included a USENET news reader as a sample application. Lots of stuff remains to be done, haven't even thought up a name for it. http://www.oz.net/~donn/ Donn Cave, donn at oz.net, donn at u.washington.edu From gmcm at hypernet.com Thu Sep 9 17:19:33 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 9 Sep 1999 16:19:33 -0500 Subject: Turing Compliant? In-Reply-To: <7r935e$u0f$1@nnrp1.deja.com> Message-ID: <1275214276-477894@hypernet.com> Jim Hefferon wrote: [snip] > Somebody else in this thread mentioned quantum computation. I've > tried to read up on it, but I'm afraid I didn't get it. Is it the > case that anything quantum computable is Turing computable, that is, > quantum computability may go faster but doesn't add anything > actually new? Well there's biological computation, in which each fork() grows it's own "CPU", thus making some formerly non-computable problems computable. No, I didn't make that up, and yes, I probably got something subtly wrong, thus ensuring the non-boundedness of this thread... - Gordon From gmcm at hypernet.com Thu Sep 9 08:26:32 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 9 Sep 1999 07:26:32 -0500 Subject: Reading plain text file database tables In-Reply-To: <37D781B8.FE238AC8@inet.polyu.edu.hk> Message-ID: <1275246255-103229193@hypernet.com> I think you'll find a regex that does this on Hans Nowaks snippets page, whereever that is at the moment (he just posted a notice that it had moved in the last few days). Just found it at http://www.hvision.nl/~ivnowa/snippets/source/67.py Li Dongfeng wrote: > Thanks for the direction. I'm also > trying to solve this with RE. But in order > to extract "ab \" cd" like structure, > your [^"\\] seems puzzling, because anything > inside [] represent only one character, not > the '\"' two character sequence. Any real > worked out result? > > Stephan Houben wrote: > > > > On Thu, 09 Sep 1999 14:15:38 +0800, Li Dongfeng > > wrote: > > > > > > > >Do we have a module to read plain text file > > >database tables? > > > > > >All the data management software, e.g. excel, > > >dBase, SAS, etc., support input/output a table > > >from/to a plain text file, fields can be separated > > >by their column position, by spaces, by tabs, > > >by commas, etc. > > > > > >How can we read this kind of file into a matrix like > > >structure(list of lists)? I have written one reading > > >files with fixed-width fields. For delimited files, > > >simply using string.split work most of the time, but > > >fails reading lines like > > > > > > "Peter Thomson" 25 36 > > > > > >or even > > > > > > "Peter\" Thomson" 25 36 > > > > > >I think this is a common task, so maybe someone has > > >already given a very good solution. > > > > Use regular expressions. > > A regular expression that matches strings within "..", > > while escaping " with \, is: > > > > r = re.compile(r'"([^"\\]|(\\.))*"') > > > > Extend this to get what you want. > > If you're very worried about speed, create > > a lexer using (f)lex, and then call the generated > > C code from python. > > > > Greetings, > > > > Stephan > > -- > http://www.python.org/mailman/listinfo/python-list - Gordon From guido at cnri.reston.va.us Wed Sep 29 08:36:11 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 29 Sep 1999 08:36:11 -0400 Subject: Freezing script gives error message: References: <7sdlht$e0f$1@nnrp1.deja.com> <37f103a0.70349727@freenews.remarq.com> Message-ID: <5l3dvx99ok.fsf@eric.cnri.reston.va.us> jiwils at stopspam.acxiom.com (Jimmy Wilson) writes: > On Thu, 23 Sep 1999 16:46:58 GMT, swgeorge at my-deja.com wrote: > > > Does anybody know why I am getting the following error message: > > Error: needed directory D:\Program Files\Python\lib\python1.5\config > > not found. > > I have received the same error message, and I am puzzled as well. I > also install the binary distribution of Python as well as downloading > the source. I suspect that some registry entries are part of the > problem as I removed the binary installation of Python and I the > freeze.py script still knew where that old installation was. The freeze script is confused -- it seems to be thinking it is running on a Unix system. How did you invoke it? What Python version are you using? You *could* try running freeze.py -w... --Guido van Rossum (home page: http://www.python.org/~guido/) From m.faassen at vet.uu.nl Sun Sep 5 14:12:34 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 5 Sep 1999 18:12:34 GMT Subject: Spanish Inquisition?! References: <37CFC38C.20A9C267@megsinet.net> Message-ID: <7qubqi$q02$3@newshost.accu.uu.nl> David Oppenheimer wrote: > In a previous thread (about languages interpreted versus languages > compiled) there was talk of the Spanish Inquisition. I am guessing that > this is 1) a joke or 2) the code name for a "secret" project to create > compiled code from python code and thereby permanently blur the line for > Python. Anyone know anything about this? > I know no one ever expects the Spanish Inquisition, but if its coming > I'd like to know about it. Yes, this is currently vaporware starting to lose its vapor. It's been called 'Swallow' by me (don't know if it's African or European). More recently, John Skaller has been working on Viper (which apparently actually has some source code, so even less vapor). Before my time, there have been other attempts I don't know the name of. :) The Spanish Inquisition is definitely a cool name for such a project, though. :) Regards, Martijn From geek+ at cmu.edu Mon Sep 13 09:30:42 1999 From: geek+ at cmu.edu (Brian E Gallew) Date: 13 Sep 1999 09:30:42 -0400 Subject: ANN: Tk Slashdot Headline Viewer References: <7rgmd0$2htg$1@hub.org> Message-ID: From: Doug at news.vex.net (Lewis) > Inspired by the Slashdot headline viewer demo in the wxPython > package, i decided to implement my own in Tkinter. > > My implementation, while simpler, is much cuter. (-: > > Should anyone care to try it out, you can snag it from.... > > http://www.vex.net/~x/python_stuff.html#slashdot Dude, if you want this to run under unix, change the spawnBrowser function to do the following: os.system(browser % url) And browser should look like: browser = "/usr/local/bin/netscape -remote 'openURL(%s)'" -- ===================================================================== | JAVA must have been developed in the wilds of West Virginia. | | After all, why else would it support only single inheritance?? | ===================================================================== | Finger geek at cmu.edu for my public key. | ===================================================================== -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 266 bytes Desc: not available URL: From jrush at summit-research.com Tue Sep 21 22:52:01 1999 From: jrush at summit-research.com (Jeff Rush) Date: 21 Sep 1999 21:52:01 -0500 Subject: Module to open URLs that set cookies? References: <15d84bec.887c3642@usw-ex0107-051.remarq.com> Message-ID: On Thu, 9 Sep 1999 22:26:15, Marshall T. wrote: > I would like to know how to write an http client that will > accept cookies when opening webpages. I'm attempting to > write a module that open a page and note the latency in > doing so. I've been successful in doing this with the > sockets and urllib library modules, but have been foiled by > pages that set cookies. Is there a canned library for > doing this in Python? I do exactly that in my webbot module at: http://starship.python.net/crew/jrush/Webbot/ -Jeff Rush From news at dorb.com Thu Sep 2 22:14:17 1999 From: news at dorb.com (Darrell) Date: Thu, 2 Sep 1999 22:14:17 -0400 Subject: Bring Out Yer Dead References: <37CE2648.D4254FCC@megsinet.net> <37ceeef4.5698550@news.erols.com> Message-ID: As a check. Down loaded PIL_win32.tar.gz from this link and extracted it with WinZip 7.0 -- --Darrell Robert Kern wrote in message news:37ceeef4.5698550 at news.erols.com... > On Thu, 02 Sep 1999 03:24:59 -0400, David Oppenheimer > wrote: > > >I am going to give up on trying to get the PIL to work with Pythonwin > >1.5.2 unless someone who has it working with their setup can give me > >explicit instructions on how to do this. I am unable to implement > >Robert Kern's instructions due to the fact that I cannot get my Win Zip > >program to unzip the tar.gz file format. > > This is probably a browser problem. Clear your cache first. Be sure > that the .gz and .tar extensions are associated with Winzip in your > browser. Their MIME types should be "application/x-gzip" and > "application/x-tar", respectively. At least, that's how I have them. > > Then try downloading again (use a shift-click from > http://starship.python.net:9673/crew/da/Code/PIL rather than a > straight left-click). > > >So ... time for me to put PIL for Pythonwin 1.5.2 on the pile of > >software corpses and set it ablaze. Can you feel the heat?! Anyone > >have any marshmallows? > > You'll be fine. BTW, _Pythonwin_ is the name of Mark Hammond's IDE > for Python on Windows, not the general name for Python on Windows. > > >David O. > > Robert Kern | > ----------------------|"In the fields of Hell where the grass grows high > This space | Are the graves of dreams allowed to die." > intentionally | - Richard Harter > left blank. | From wtanksle at dolphin.openprojects.net Thu Sep 2 02:15:30 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Thu, 02 Sep 1999 06:15:30 GMT Subject: language interpreters/ interpreted languages weaknesses? References: <7qi3q3$n1d$1@nnrp1.deja.com><37CCE10D.D07D023B@strs.co.uk><7qjgq8$k1i$1@newshost.accu.uu.nl> <14285.38262.884171.416195@dolphin.mojam.com> Message-ID: On Wed, 1 Sep 1999 15:51:00 -0700, Emile van Sebille wrote: >Skip Montanaro wrote in message >> So, aside from the differences in how you get from source to running >> program, depending on your definitions, they can all be called >> compiled or interpreted languages. >From my perspective, <25+years business basic> it's interpretive if it >politely stops when it hits a bug, and waits for you to fix the program >and continue. You see, that's what I call an "interactive" language. I don't have much use for the word "interpreted". It used to mean a lot, back when only a few mmethods of compilation and interpretation were commonly used. Its meaning and use are now completely gone. >If-you-can't-change-a-running-program-then-it's-compiled-ly yrs >Emile van Sebille -- -William "Billy" Tanksley From rvollmert at gmx.net Wed Sep 8 17:00:36 1999 From: rvollmert at gmx.net (Robert Vollmert) Date: Wed, 8 Sep 1999 23:00:36 +0200 Subject: Python example: possible speedup? In-Reply-To: <87puztv2gt.fsf@pc-hrvoje.srce.hr>; from Hrvoje Niksic on Wed, Sep 08, 1999 at 05:37:38PM +0200 References: <87puztv2gt.fsf@pc-hrvoje.srce.hr> Message-ID: <19990908230036.A3530@krikkit.vollmert.home> On Wed, Sep 08, 1999 at 05:37:38PM +0200, Hrvoje Niksic wrote: > As a Python exercise, I wrote a simple program to "scratch an itch", > i.e. do something useful. However, I found that Python's lack of > speed really bytes me here, so I'd like to hear suggestions for > speedup. People who don't like that kind of topic, please skip to the > following article. Others, read on. ... > The program was quite easy to write, and easy to read afterwards. The > problem is that it is also quite slow. On my system, it takes about > 27 CPU seconds (as reported by `time' shell builtin) to do the work, > which can extend to more than a minute of real time, depending on the > system load. > > As a comparison, the equivalent Perl program does the same thing in 9 > CPU seconds. I tried everything I knew to make the Python version > fast. I tried to use `re' to avoid returning headers other than the > ones we're interested in. I tried changing self.__current to just > current to avoid a dictionary lookup. I tried to make self.__current > a list, to avoid the expensive `current = current + line' operation. > All of these things made the program measure slower. > > I would really appreciate some suggestions. The code is not large, > and is (I hope) rather elegant. I am a Python beginner, so I'd also > appreciate tips on Python style and OO technique. I'll post/mail the > Perl equivalent on demand. Hi, the following code is about five times faster here. That means it's faster than perl, I suppose :-). It is of course not quite as general as your's, but it seems to fit the job nicely. For this kind of problem, I usually don't bother with OO. The main speed advantage seems to be that the files aren't processed line by line, which is of course very memory consuming. HTH, Robert #! /usr/bin/env python import string def get_installed(): fstatus = open('/var/lib/dpkg/status', 'r') status = fstatus.read() fstatus.close() status = string.split(status, '\n\n') installed = [] for package in status: fields = string.split(package, '\n') name = fields[0][9:] for line in fields: if line[:7] == 'Status:': if string.split(line[8:])[-1] == 'installed': installed.append(name) break return installed def get_sizes(packages): favailable = open('/var/lib/dpkg/available', 'r') available = favailable.read() favailable.close() available = string.split(available, '\n\n') results = [] for package in available: fields = string.split(package, '\n') name = fields[0][9:] if name in packages: for line in fields: if line[:15] == 'Installed-Size:': results.append(name, int(line[16:])) break return results def main(): results = get_sizes(get_installed()) results.sort(lambda a, b: cmp(b[1], a[1])) for r in results: print '%s: %d' % r if __name__ == '__main__': main() -- Robert Vollmert rvollmert at gmx.net From pinard at iro.umontreal.ca Thu Sep 2 08:30:45 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 02 Sep 1999 08:30:45 -0400 Subject: Python speed and `pcre' In-Reply-To: "Darrell"'s message of "Tue, 31 Aug 1999 13:25:09 -0400" References: Message-ID: "Darrell" ?crit: > I've found a common mistake is splitting and combining strings. Use > string.join(), don't do this str=str+str1 in a loop. Strings are immutable > so you end up allocating memory and coping every time. Very expensive. Hi, Darrell, and gang. I do not fully understand the cost of splitting. If strings are immutable, there is really no need to copy a slice contents. The only reason I really see to copy would be to simplify the garbage collector, which is more related to a particular implementation than the language design itself. Somewhere, it is said that some extra-space is allocated at end of sequences, to allow for some peaceful growth. Does `str=str+str1' at least attempt to use of this extra-space? It should, in my opinion. Of course, you might tell me that the implementation does not notice the form `str=str+X' as really meaning `str+=X', but then, again, the inefficiency might be related to the implementation. The trend, for a lot of years now, is to improve the implementation for speed, rather than adapt the programming style of all users to a given implementation. If Python is meant to be a clean, clear language, one should not have to resort to convolutions to give it reasonable speed. Or else, things look a bit artificial, and the gain in clarity is a bit lost. Oh, I'm sure we get used to idioms after a while, then simplicity is lost. I'm not saying that `str+=X' should make it into the language, I quite guess this has been debated to death already, and I agree that the writing `str=str+X' has the virtue of clarity. But making the language more clear should not necessarily be accompanied by making it slower. Avoiding a syntactic construct does not free the implementation from recognising the intent behind most usual alternate writings for it (in our case, here, extending a given string) and acting best, accordingly. Once again, I'm fairly new to Python, and ask for your kind forgiveness if I err too much. Maybe that `str=str+X' is already recognised and acted upon as it should, usually without copy when X is small, and maybe that slicing a string just knows, already, how to not copy the slice contents. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From jh at cddk.dk Thu Sep 9 10:44:02 1999 From: jh at cddk.dk (Jesper Hertel) Date: Thu, 9 Sep 1999 16:44:02 +0200 Subject: Query system date References: <7r8fjh$dno$1@nnrp1.deja.com> Message-ID: <7r8h3k$pqo$1@news1.tele.dk> Hello Mark, Try this: def getCurrentTimeString(): from time import * return strftime ("%d-%m-%Y", localtime(time())) print getCurrentTimeString() Jesper Hertel wrote in message news:7r8fjh$dno$1 at nnrp1.deja.com... > I am new to python and I am trying to figure out how to return the > computers system date and time and then format it as MM-DD-YYYY. I have > searched the documentation up and down and have not found anything about > how to accomplish this. Any help would be greatly appeciated. > > Thanks, > > Mark. > > > Sent via Deja.com http://www.deja.com/ > Share what you know. Learn what you don't. From davidopp at megsinet.net Wed Sep 22 16:57:10 1999 From: davidopp at megsinet.net (David Oppenheimer) Date: Wed, 22 Sep 1999 16:57:10 -0400 Subject: PTUI Message-ID: <37E942A6.969CB5C4@megsinet.net> Does anyone know if PTUI (python tkinter user interface) is still being actively maintained? I tried to send an e-mail to Zachary Roadhouse and it was returned undeliverable. Thanks, David O. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hniksic at srce.hr Wed Sep 8 11:37:38 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 08 Sep 1999 17:37:38 +0200 Subject: Python example: possible speedup? Message-ID: <87puztv2gt.fsf@pc-hrvoje.srce.hr> As a Python exercise, I wrote a simple program to "scratch an itch", i.e. do something useful. However, I found that Python's lack of speed really bytes me here, so I'd like to hear suggestions for speedup. People who don't like that kind of topic, please skip to the following article. Others, read on. When browsing my Debian packages, I found I often wanted to know the size of the installed packages. To achieve this, I wrote a simple program that prints the installed packages and their sizes, all sorted by size. Output looks like this: tetex-base: 27652 tetex-extra: 27118 cmucl-safe: 22174 mozilla: 13007 timidity-patches: 11662 locales: 11489 quake2: 10800 [...] To achieve this, the program needs to parse two files: /var/lib/dpkg/status, to find which packages are installed, and /var/lib/dpkg/available, to find the size of the installed packages. Both files are textual, in the form of headers. Like this: Package: telnet Status: install ok installed Priority: standard Section: net Installed-Size: 130 Maintainer: Herbert Xu Source: netkit-telnet Version: 0.14-4 Replaces: netstd Depends: libc6 (>= 2.1), libncurses4 (>= 4.2-3.1) Description: The telnet client. The telnet command is used for interactive communication with another host using the TELNET protocol. Package: packaging-manual Status: purge ok not-installed Priority: optional Section: doc [...] The program was quite easy to write, and easy to read afterwards. The problem is that it is also quite slow. On my system, it takes about 27 CPU seconds (as reported by `time' shell builtin) to do the work, which can extend to more than a minute of real time, depending on the system load. As a comparison, the equivalent Perl program does the same thing in 9 CPU seconds. I tried everything I knew to make the Python version fast. I tried to use `re' to avoid returning headers other than the ones we're interested in. I tried changing self.__current to just current to avoid a dictionary lookup. I tried to make self.__current a list, to avoid the expensive `current = current + line' operation. All of these things made the program measure slower. I would really appreciate some suggestions. The code is not large, and is (I hope) rather elegant. I am a Python beginner, so I'd also appreciate tips on Python style and OO technique. I'll post/mail the Perl equivalent on demand. The code follows: #!/usr/bin/python import string class Dpkg_Reader: def __init__(self, file): self.__current = '' self.__fp = open(file) def next_header(self): while 1: line = self.__fp.readline() if line == '': return (None, None) # EOF if self.__current: if line == "\n" or (line[0] != ' ' and line[0] != "\t"): #print "{%s}" % (self.__current) try: name, value = string.split(self.__current, ': ', 1) except: name, value = string.split(self.__current, ':', 1) value = value[:-1] if line == "\n": self.__current = '' else: self.__current = line return (name, value) self.__current = self.__current + line def close(self): self.__fp.close() def process_status(file): reader = Dpkg_Reader(file) package = None installed = {} while 1: name, value = reader.next_header() if name is None: break if name == 'Package': package = value elif name == 'Status': status = string.split(value, ' ') if status[2] == 'installed': installed[package] = 1 reader.close() return installed def process_available(file, installed): reader = Dpkg_Reader(file) sizes = {} while 1: name, value = reader.next_header() if name is None: break elif name == 'Package': package = value elif name == 'Installed-Size': if installed.has_key(package): sizes[package] = string.atoi(value) reader.close() return sizes def main(): installed = process_status('/var/lib/dpkg/status') sizes = process_available('/var/lib/dpkg/available', installed) lst = sizes.keys() lst.sort(lambda a, b, sizes=sizes: cmp(sizes[b], sizes[a])) for pack in lst: print "%s: %d" % (pack, sizes[pack]) if __name__ == '__main__': main() From greg.ewing at compaq.com Mon Sep 6 17:17:15 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Tue, 07 Sep 1999 09:17:15 +1200 Subject: language interpreters/ interpreted languages weaknesses? References: <7qi3q3$n1d$1@nnrp1.deja.com> <37CCE10D.D07D023B@strs.co.uk> <7qjgq8$k1i$1@newshost.accu.uu.nl> <7qlj3b$p7u$1@newshost.accu.uu.nl> <7qrce6$dgh$1@news.bayarea.net> Message-ID: <37D42F5B.F8D00F97@compaq.com> Jean Jordaan wrote: > > Z-code! That's the bytecode of the Infocom text adventure engine. Infocom > wrote Z-code engines for all their target machines, and released one version > of the bytecode of the games for all of them. It's been implemented as Inform > by Graham Nelson, and ported all over the place. Does this qualify :? It doesn't qualify for the "published" part. Infocom never publicised the specification of the Z-machine; it was reverse-engineered later by I.F. enthusiasts. The Amsterdam Compiler Kit uses an abstract machine code called EM with a published specification, although it's intended more as an intermediate form between the front and back ends of a compiler than as a medium for distributing programs. Greg From Bill at nospam.com Fri Sep 24 12:10:18 1999 From: Bill at nospam.com (Bill Rodgers) Date: Fri, 24 Sep 1999 10:10:18 -0600 Subject: NT Services In Python? Message-ID: Has anyone done this? I don't see any mention of it in the latest release. Any info greatly appreciated. Thanks, -- Bill Rodgers Enterprise Management Consultant Specialty: BMC/Patrol brodg1 at ix.netcom.com From jean at lnx2.sun.ac.za Sun Sep 5 08:50:20 1999 From: jean at lnx2.sun.ac.za (Jean Jordaan ) Date: 5 Sep 1999 12:50:20 GMT Subject: language interpreters/ interpreted languages weaknesses? References: <7qi3q3$n1d$1@nnrp1.deja.com> <37CCE10D.D07D023B@strs.co.uk> <7qjgq8$k1i$1@newshost.accu.uu.nl> <7qlj3b$p7u$1@newshost.accu.uu.nl> <7qrce6$dgh$1@news.bayarea.net> Message-ID: On Sat, 4 Sep 1999 08:09:29 -0700, Frank Mitchell wrote: >Stephan Houben wrote in message ... >>m.faassen at vet.uu.nl (Martijn Faassen) writes: >>Of course, Sun marketed the fact that Java used bytecode as if it was >>something revolutionary. "No, it is not interpreted, it is compiled to >>Byte Code!" Of course, all those other languages which had been called >>"interpreted" where actually compiled to byte code since the >>beginning of time. Byte-code compilation is really as old as the Sun. ;-) > >Right, but as the guy who hired me into Sun pointed out, it's the first time >(AFAIK) that a byte code format has been fully specified and published, with >the intent of transferring bytecode among different implementations. > >If someone could point me to a previous bytecode format that worked in more >implementations than the one that issued it, and stayed stable from revision >to revision, I will stand corrected. Z-code! That's the bytecode of the Infocom text adventure engine. Infocom wrote Z-code engines for all their target machines, and released one version of the bytecode of the games for all of them. It's been implemented as Inform by Graham Nelson, and ported all over the place. Does this qualify :? --jean From gambino at news.mondenet.com Tue Sep 7 19:13:42 1999 From: gambino at news.mondenet.com (Jack) Date: Tue, 07 Sep 1999 23:13:42 GMT Subject: Formatting numbers Message-ID: I'm learning Python and the documentation is great, but I haven't found an easy way to do the following. Given an array (2-D) of numbers, I'd like to print them out nicely formatted. The numbers can differ greatly in magnitude, so I'd like to use fewer decimal places for big numbers than for large ones. The output should look something like this (or better): 123456.78 -0.000123 -54231.321 -4321567.1 9876.543 etc. Someone somewhere must have written a module to do this. Any pointers? P.S. I want to use the Python interpreter only at this time -- no tk or gtk. Thanks. From philh at vision25.demon.co.uk Tue Sep 28 17:22:07 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Tue, 28 Sep 99 21:22:07 GMT Subject: Please Help Convert This Code References: <37E96EE5.95270EA9@megsinet.net> Message-ID: <938553727snz@vision25.demon.co.uk> In article <37E96EE5.95270EA9 at megsinet.net> davidopp at megsinet.net "David Oppenheimer" writes: > Dear Group, > > I would really appreciate it if someone could help convert this Tkinter > code into equivalent wxPython code. Need this to be done to create a > drag and drop GUI maker that will have Tkinter AND wxPython as output > choices. Thanks in advance. > > David O. > > [Tkinter code deleted] Unfortunately, I don't know wxPython, so I can't help you with your query. But I couldn't help feeling that what you're doing is very similar to what I'm doing with Parrot. (Parrot is a text-based GUI builder; it converts a text file into GUI code -- currently it produces Python/Tkinter code, but it is designed to be able to output to other formats too (different python GUI libraries, and different languages. For details, see http://www.vision25.demon.co.uk/prog.parrot.html ). If you are going to be writing a wxPython code generator, and so am I, perhaps we could work together on this one? -- Phil Hunt - - - - - - - - - philh at vision25.demon.co.uk - Linux was 8 years old on 17th September! See: - http://www.vision25.demon.co.uk/prog/linuxbirthday.html From emile at fenx.com Sat Sep 4 11:20:32 1999 From: emile at fenx.com (Emile van Sebille) Date: Sat, 4 Sep 1999 08:20:32 -0700 Subject: "if" syntax error References: <37D138C1.3EABC811@dialnet.net> Message-ID: Hi Andrew, It may not be the if... statement. When I get these *obviously correct* syntax errors, it's typically that I've left an incomplete statement unterminated. HTH -- Emile van Sebille emile at fenx.com ------------------- Andrew Kesterson wrote in message news:37D138C1.3EABC811 at dialnet.net... > I've got a CGI script (python) set to check the value of form element > "Listing_Type", and it does it as thus: > > CGIHeaders = cgi.FieldStorage() > if CGIHeaders["Listing_Type"].value == "Residential": > > when I compile it, I get this error: > > File "C:\Program Files\Python\Source\Skydev\addlisting.py", line 82 > if CGIHeaders["Listing_Type"].value == "Residential": > ^ > SyntaxError: invalid syntax > > There is NO WAY that this is invalid syntax! I've used if comparisons > like that one hundreds of times and compiled fine! > What's going on? Or is it just that my CGI *really* doesn't want to run > from command line? > > -- > "I never came across anyone in whom the moral sense > was dominant who was not heartless, cruel, vindictive, > log-stupid and entirely lacking in the smallest sense > of humanity. Moral people, as they are termed, are > simply beasts. I would sooner have fifty unnatural > vices than one unnatural virtue." > --Oscar Wilde From davidopp at megsinet.net Wed Sep 8 01:27:10 1999 From: davidopp at megsinet.net (David Oppenheimer) Date: Wed, 08 Sep 1999 01:27:10 -0400 Subject: Stackless Python Message-ID: <37D5F3AE.D187DB3C@megsinet.net> Found this link to a paper by Christian Tismer called Stackless Python. I still don't understand everything he's talking about but I found it very interesting. David O. -------------- next part -------------- An HTML attachment was scrubbed... URL: From wtbridgman at radix.net Sat Sep 18 09:39:47 1999 From: wtbridgman at radix.net (T. Bridgman) Date: Sat, 18 Sep 1999 9:39:47 -0400 Subject: [Mac] Python mode for Alpha editor References: Message-ID: <01HW.B4090E63001D90290D2F1590@news1.radix.net> Thanks Howard. There is in fact a Python mode for Alpha but it doesn't seem to work in release 7.0 or later. Does this version work with 7.+? Tom On Fri, 17 Sep 1999 15:05:07 -0400, Howard Oakley wrote (in message ): > > Gentlepersons, > > I looked in vain for a Python mode for the wonderful (if Tcl-based!) text > editor, Alpha. I could not find any. Here, below, is an Alpha mode file for > Python, which makes the Alpha text editor much more usable for editing > Python code. Please feel free to post it anywhere that you feel appropriate. > The code works fine here, but is kludgy and largely borrowed from other Tcl > mode files - I could hardly claim any sort of copyright anyway! > > I am also sending it to Pete Keleher, the author of Alpha, and Jack Jansen. > > Howard. From fredrik at pythonware.com Wed Sep 22 06:13:44 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 22 Sep 1999 10:13:44 GMT Subject: lists and append, and loop iteration References: <37E8860B.C024C4F8@radiata.com> <14312.40896.797841.421283@gargle.gargle.HOWL> <87ln9ztgml.fsf@ifm.uni-kiel.de> Message-ID: <001501bf04e3$27634e10$f29b12c2@secret.pythonware.com> Janko Hauser wrote: > I could not write > >>> dict={} > >>> dict['new_key'] = dict.get('new_key',[]).append(['new_value']) > >>> dict > {'new_key': None} > > To this refered my last note about the reference of a. Although I do > not understand this. If I get not an empty list, why can I do an > append? "get" returns an empty list, "append" returns None. From mal at lemburg.com Thu Sep 9 18:56:27 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 10 Sep 1999 00:56:27 +0200 Subject: mxODBC: File DSNs? References: <37D5E859.78BB8DF0@compaq.com> <37D6B32E.40846F82@lemburg.com> <37D82A0A.F7F84305@compaq.com> Message-ID: <37D83B1B.1B0F4388@lemburg.com> Greg Ewing wrote: > > "M.-A. Lemburg" wrote: > > > > Just add the File DSN to your ODBC Manager setup and then point > > mxODBC at it using ODBC.Windows.DriverConnect(). > > This doesn't work. > > Under the "File DSN" tab in the ODBC Data Source Administrator > I have an entry called "Py2kTest2.dsn" which refers to a > Microsoft Access database. But "Py2kTest2" or "Py2kTest2.dsn" > does not seem to be a valid data source name: > > >>> db = ODBC.Windows.DriverConnect("DSN=Py2kTest2") > Traceback (innermost last): > File "", line 1, in ? > db = OW.DriverConnect("DSN=Py2kTest2") > OperationalError: ('IM002', 0, '[Microsoft][ODBC Driver Manager] Data > source name not found and no default driver specified', 4316) > > >>> db2 = ODBC.Windows.DriverConnect("DSN=Py2kTest2.dsn") > Traceback (innermost last): > File "", line 1, in ? > db2 = ODBC.Windows.DriverConnect("DSN=Py2kTest2.dsn") > OperationalError: ('IM002', 0, '[Microsoft][ODBC Driver Manager] Data > source name not found and no > default driver specified', 4316) > > If I create a User DSN with the same parameters, everything > is fine. > > What magic string do I need to give to DriverConnect to > specify a File DSN? Try "FILEDSN=" as parameter. The ODBC docs for SQLDriverConnect have more details on the dsn string to be used. -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 113 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From skip at mojam.com Fri Sep 3 14:56:09 1999 From: skip at mojam.com (Skip Montanaro) Date: Fri, 3 Sep 1999 13:56:09 -0500 (CDT) Subject: smtplib: subject? to? In-Reply-To: <19990903202313.A23408@optiplex.palga.uucp> References: <19990903142456.A2124@optiplex.palga.uucp> <19990903202313.A23408@optiplex.palga.uucp> Message-ID: <14288.6544.705239.464758@dolphin.mojam.com> Gerrit> Ah. But if I have to put a To: in the message, why do I have to Gerrit> give recipients? SMTP has "mail from" and "rcpt to" commands. Those are what the to and from args are for I believe. Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/~skip/ 847-971-7098 | Python: Programming the way Guido indented... From wware-nospam at world.std.com Wed Sep 8 11:56:03 1999 From: wware-nospam at world.std.com (Will Ware) Date: Wed, 8 Sep 1999 15:56:03 GMT Subject: Stackless Python References: <37D5F3AE.D187DB3C@megsinet.net> Message-ID: David Oppenheimer (davidopp at megsinet.net) wrote: : Found this link to a paper by Christian Tismer called Stackless Python. : I still don't understand everything he's talking about but I found it : very interesting. Python normally uses the C stack for some of its house-keeping when it's running code. Functions, and I believe also blocks within functions, require data structures called frames to keep track of variable scope and some other things. These are usually maintained as local variables of eval_code2, a function in Python/ceval.c. eval_code2 calls itself recursively whenever one Python function calls another (except for functions which are coded directly in C), so the eval_code2 call representing the outer function is still on the C stack, including any frames for the outer function. What Christian is doing is to set up frame stacks as independent Python objects, distinct from the C stack. This means that you could interrupt a Python process and store or study the frozen snapshot. You could continue the process some time later. You could step many threads, each a few opcodes at a time, to implement a system of multiple threads. There are probably other applications that I'm not aware of. The reason I know this is because I implemented my own multiple-thread package a few weeks back, having paid insufficient attention when Stackless Python was first mentioned on the newsgroup. People then pointed out to me that almost all of what I was doing was already done in Stackless Python. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From MHammond at skippinet.com.au Mon Sep 6 19:04:08 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Tue, 7 Sep 1999 09:04:08 +1000 Subject: case for open lang on win32 - fill in the table References: <7r0049$bfh$1@nnrp1.deja.com> <7r0d3t$chk$1@newshost.accu.uu.nl> Message-ID: <7r1hab$9bd$1@m2.c2.telstra-mm.net.au> Martijn Faassen wrote in message <7r0d3t$chk$1 at newshost.accu.uu.nl>... >[followups set to comp.lang.python only] Good move :-) I recently cross-posted a Python question to the Perl groups 'cos I didnt look hard enough - was then honoured with an autoresponder message from an tchrist. (:-) >> multi thread none recent-ok ? > >Python can do multithreading, though there's a global interpreter lock. >Ask someone who knows more about multithreading than I do what this means. Python is fully multi-threaded. It wont perform as well as you may expect on an SMP machine, but otherwise is fully thread safe. >> file system access no yes yes >> basic locking no (obviously) flock flock? > >Python has the fcntl module -- again, ask others for details as I'm >not familiar with this. Seems limited to Unix. Indeed it is. There are no portable locking semantics, but there is full support for locking (via the "msvcrt" module, or the win32file module. >> idispatch only yes ? ? IDispatch plus about 100 extra interfaces. We can not use raw interfaces if there is no C++ support, but many useful interfaces already have that support (and it is trivial to add new ones). From a marketting POV, this should definately read "yes" :-) >> COM threading STA only STA only? STA only? No - full support for all COM threading models. STA is the default. >> project size small to medium big big >> (lines of code) > >What does that mean, lines of code? for COM, or in general? Agreed = I would have to argue "small", especially compared to VB. For _anything_ other than GUI code (which VBScript doesnt do anyway) the LOC for a Python solution will always be smaller than for VB. Hope this helps... Let us know if you complete this and post it to the web. Mark. From skip at mojam.com Wed Sep 15 15:46:15 1999 From: skip at mojam.com (Skip Montanaro) Date: Wed, 15 Sep 1999 14:46:15 -0500 (CDT) Subject: ANN: Biopython.org (Call for Participation) In-Reply-To: <7rorsc$tf1$1@nnrp1.deja.com> References: <7rorsc$tf1$1@nnrp1.deja.com> Message-ID: <14303.63367.306074.152475@dolphin.mojam.com> Peter> I am very interested in becoming a part of the biopython project Peter> but I am new to these types of forums. Could someone please let Peter> me know how I can get involved with writing code(how do you get a Peter> topic for code developement) and the scientific discussions. Peter, Best bet would be to trot on over the the biopython web site and sign up for the mailing list. If you ask there, I'm sure someone will be able to direct you to some meaningful information. You might also want to browse the archives of the biopython lists (they just got started so this should only take a few minutes). Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/~skip/ 847-971-7098 | Python: Programming the way Guido indented... From kuncej at mail.conservation.state.mo.us Tue Sep 7 11:13:49 1999 From: kuncej at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Tue, 07 Sep 1999 10:13:49 -0500 Subject: Snippets site temporarily (?) down Message-ID: >OK, the title says it all... Well, in fact it's not just my snippets >... >I have been thinking about moving the site elsewhere, since this >... Why not on starship.python.net ? Free accounts for PSA members. --Jeff From henk_p at my-deja.com Wed Sep 15 08:45:32 1999 From: henk_p at my-deja.com (henk_p at my-deja.com) Date: Wed, 15 Sep 1999 12:45:32 GMT Subject: Python, FastCGI and FreeBSD Message-ID: <7ro4d9$apg$1@nnrp1.deja.com> Hi, I am experiencing this strange problem with a Python script running as a fastCGI application under FreeBSD 3.2. For some reason when the fastcgi process manager in Apache starts the script, it (or the Python interpreter) immediately crashes. It does not matter what the script contains, it always crashes upon initialization. ('Uncaught signal 11, Segmentation Fault' as it says in the apache error log) The strange thing is that the same script runs perfectly OK on a Redhat linux box (5.2). Are there any known bugs that could cause Python interpreter to crash on initialization?, maybe due to the user privilege level it is running, or the layout of the python libs on the platform (FreeBSD3.2). The script runs perfectly fine when invoked from a shell. It just seems like the python interpreter does not like to be forked by the FastCGI process manager... Well anyway, thanx in advance, Henk. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From jblaine at shell2.shore.net Sat Sep 4 10:49:04 1999 From: jblaine at shell2.shore.net (Jeff Blaine) Date: Sat, 04 Sep 1999 14:49:04 GMT Subject: raw_input() and readline References: Message-ID: Did you 'import readline' ? >...but if I use > >python t.py > >I don't have any readline functionality. >I would appreciate any help. From etsang at my-deja.com Fri Sep 17 16:01:52 1999 From: etsang at my-deja.com (etsang at my-deja.com) Date: Fri, 17 Sep 1999 20:01:52 GMT Subject: NEWBIE: Try to intialise a big C structure easily from Python...HELP!!!! Message-ID: <7ru6n9$pf1$1@nnrp1.deja.com> Hey, I am trying to initialise a C structure from Python. My Aim is to init a C structure without passing each indivual elements through the interface, but rather package the whole thing and pass that it one time. Then the C may do somethign about it, initialise its won struct and pass back a struct with the same kind of elements but with different parameters. I am stuck with the intialising the C struct part, and have not clue how to convert the C struct back to a PyObject appropriate to pass back to the Python script. Please help . Below is the code. Error: segmentation fault occurres at PyArg_ParseTuple (args,"s:mymath",string_from_Python)) PyString_Size(string_from_Python)calls inside function pyfunc_mystruct Here is what I tried: >From the python script I have: import struct import mymath_wrapper fmt = "120sf" a=255 b='knights who say ni' c=3.14159011841 data = struct.pack(fmt,a,b,c) mymath_wrapper.mystruct(data) in my mymath_wrapper.c file I have: #include #include "mymath.h" PyObject* pyfunc_mystruct(self, args) PyObject *self, *args; { PyObject* string_from_Python; if(!PyArg_ParseTuple (args,"s:mymath",string_from_Python)) return NULL; if(PyString_Size(string_from_Python)!= sizeof (struct diffstruct)) { PyErr_SetString(PyExc_AssertionError, "Given strgin not a good size"); return NULL; } globaldiffstruct = (diffstruct *) PyString_AsString(string_from_Python); printf("globaldiffstruct calling within C:%d %s %f\n",globaldiffstruct->a, globaldiffstruct- >b,globaldiffstruct->c); /* python side will print the last res value*/ return string_from_Python; /* not correct, deal with this later */ } static PyMethodDef mymathMethods[] = { {"mystruct", pyfunc_mystruct, 1}, {NULL,NULL} }; void initmymath_wrapper() { (void) Py_InitModule("mymath_wrapper", mymathMethods); } Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From wtanksle at dolphin.openprojects.net Sat Sep 11 01:16:19 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Sat, 11 Sep 1999 05:16:19 GMT Subject: Text UI References: <65118AEEFF5AD3118E8300508B124877073BEE@webmail.altiris.com> Message-ID: On Fri, 10 Sep 1999 21:10:16 -0700, Robin Dunn wrote: >Mike Steed wrote in message >> One possibility worth investigating is wxWindows, which includes a curses >> port. I have not used the curses port, nor I do not know whether the >> Python interface will work with it.... >> wxWindows: http://www.wxwindows.org/ >> wxPython: http://alldunn.com/wxPython/ >It doesn't. The curses port was only for wxWindows 1.x, and if I remember >correctly it was never quite finished. The current wxPython is just for >wxWindows 2.x. The COOL thing is that according to the "supported platforms" page, Curses is being ported back into 2.0. Who knows what that means, but there's some hope... >In the Python sources, in the Modules directory there is a module for >ncurses that can be built. That's cool. It would be nice to have a standard Python text mode interface (wxPython would be the best imaginable ;-). >Robin Dunn -- -William "Billy" Tanksley From kuncej at mail.conservation.state.mo.us Wed Sep 8 12:02:50 1999 From: kuncej at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Wed, 08 Sep 1999 11:02:50 -0500 Subject: Python interface to Groupwise mailoxes? Message-ID: >Is there an existing python interface to Novell'sGroupwise mailboxes? >Failing an existing python module, are there ANY open-source programs that >interface with Groupwise that I can use as a starting point... Yep. Groupwise is wide open to python on windows using COM. In fact, my "project of the week" has been to read the groupwise calendars of a group of employees, and to generate html pages that display everyone's appointments on a particular day. You need to get the "Groupwise 5.x Object API" from Novell. (Go to developer.novell.com, sign up for a free online membership to the Novell Developer Network, find the file and download it.) To make it work, you need these things installed: -Python -Python Win32 Extensions -GroupWise client I've attached some simple/rough demo code to get you started. --Jeff -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: gwcomdemo.py URL: From skip at mojam.com Wed Sep 15 09:43:29 1999 From: skip at mojam.com (Skip Montanaro) Date: Wed, 15 Sep 1999 08:43:29 -0500 (CDT) Subject: Boiler plate method for Module In-Reply-To: <7rn9am$87t$1@news.is.co.za> References: <7rn9am$87t$1@news.is.co.za> Message-ID: <14303.41601.531563.688130@dolphin.mojam.com> Jacques> Hi am looking for a good but simple example of how to write my Jacques> own Python Object in C Jacques> 1) Must show me how to write the constructor/destructor Jacques> 2) Sow me how to do getattr/setattr pair Jacques> PLEASE DO NOT TELL ME TO LOOK AT TO SOURCE OF PYTHON, I HAVE Jacques> DONE THAT I JUST WANT TO SEE SIMPLE LAYOUT. What source did you look at? There are hardly any better examples of what you are looking for than the actual, functioning source code. Here are the places I recommend you look: 1. The Extending and Embedding Manual - find a pointer at http://www.python.org/doc/. 2. Modules/xxmodule.c in the source distribution - a skeleton module that outlines all the necessary bits and pieces. There's even a stub xxmodule line in Modules/Setup. 3. Any of a number of actual modules in the Modules directory: * dbmmodule.c is a pretty simple example of a module that creates an object and has to have allocation/deallocation methods, and to define both module methods and object methods. * soundex.c is a very simple example of a module that doesn't need to create any objects. It just wraps a simple algorithm. If you can't fathom the contents of the documentation or the source code to simple modules, you're probably better off looking for a consultant to hire. Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/~skip/ 847-971-7098 | Python: Programming the way Guido indented... From wware-nospam at world.std.com Thu Sep 2 10:02:40 1999 From: wware-nospam at world.std.com (Will Ware) Date: Thu, 2 Sep 1999 14:02:40 GMT Subject: Turing Compliant? References: <37CD7CBC.54AD295F@megsinet.net> Message-ID: David Oppenheimer (davidopp at megsinet.net) wrote: : What the heck does Turing Compliant mean? I've heard discussion that : Python is not Turing Compliant. Is this true and why would this be an : important consideration for someone who is programming in Python? Many people have already discussed "Turing Complete". The meaning of "Turing Compliant" is that Python will remain Turing Complete after January 1st, 2000. "Turing Delectable" means that Python will also remain Turing Complete after September 9th, 9999. The Posix module should break by then, but otherwise, I believe Python is Turing Delectable. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From emile at fenx.com Sat Sep 4 10:40:50 1999 From: emile at fenx.com (Emile van Sebille) Date: Sat, 4 Sep 1999 07:40:50 -0700 Subject: Spread/Worksheet References: <37CA8EAB.5DD1314@uniserve.com> <7qeks8$pd5$1@news4.isdnet.net> <37CEC2AB.B72137AB@uniserve.com> Message-ID: http://alldunn.com/wxPython/ -- Emile van Sebille emile at fenx.com ------------------- From nielsenjf at my-deja.com Tue Sep 7 12:46:41 1999 From: nielsenjf at my-deja.com (nielsenjf at my-deja.com) Date: Tue, 07 Sep 1999 16:46:41 GMT Subject: case for open lang on win32 - fill in the table References: <7r0049$bfh$1@nnrp1.deja.com> <7r0d3t$chk$1@newshost.accu.uu.nl> <7r1hab$9bd$1@m2.c2.telstra-mm.net.au> Message-ID: <7r3fhd$oqb$1@nnrp1.deja.com> I've decided to expand the table with comments and code examples including compiled languages. (though I'll probably need help with the vb examples :-) I hope to show that you can use open languages rather than vbscript or visual basic and have just as easy or easier time doing it that using proprietary stuff with the benefits of more power and cross-platform (Where I work we're going 100% microsoft and 100% visual basic). The main argument being visual basic/vbscript is so easy to use and the only other viable option is C++ which is too hard (in their opinion). IMHO, python has a feel similar vb/vbscript except it doesn't have the vb world's limitations. Now of course, reality may not match my ideas that (maybe you really have to use vbscript and visual basic to function the best in their closed world). However, on first inspection it doesn't look that way. There is actually very little supporting vbscript. For example, you can do everything COMwise in C++. Choose any other language and you start to make compromises. What is there that you can do in C++ that you can't do in python? In what cases is visual basic(a probably weaker language) better than python to use? > IDispatch plus about 100 extra interfaces. We can not use raw interfaces if > there is no C++ support, but many useful interfaces already have that > support (and it is trivial to add new ones). From a marketting POV, this > should definately read "yes" :-) When you say C++ support, I assume you mean there is code written than allows vtable access for python for some interfaces? Is there c++ support for ADSI or MTS or OLEDB (which look to be the big things for windows 2000)? Or can we only access it via Idispatch(I know perl can do some stuff w/ADSI via Idispatch). OLDEDB access would be cool since ADO is so slow. Perl has dbi to fix that problem. > >> COM threading STA only STA only? STA only? > > No - full support for all COM threading models. STA is the default. Great. I think even visual basic is stuck in the STA. > >> project size small to medium big big > >> (lines of code) > > > >What does that mean, lines of code? for COM, or in general? > > Agreed = I would have to argue "small", especially compared to VB. For > _anything_ other than GUI code (which VBScript doesnt do anyway) the LOC for > a Python solution will always be smaller than for VB. I guess that was ambigous. It should be broken up into 2 things. Maximum size of project you can use it with: It looks like python projects can get huge. Amount of code needed to solve a problem: (for example in the recent Practice of Programming book, perl, java,C, c++ and others were compared, with perl being the fastest except for raw C code, but it only needed a fraction of the code. Java was slowest and needed a lot of code). > Hope this helps... Let us know if you complete this and post it to the web. Will do, thanks a lot for your help. john Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From kernr at mail.ncifcrf.gov Thu Sep 9 14:16:53 1999 From: kernr at mail.ncifcrf.gov (Robert Kern) Date: Thu, 09 Sep 1999 18:16:53 GMT Subject: [Newbie:]Importing modules from different files References: <7r8dl0$cao$1@nnrp1.deja.com> Message-ID: <37d7f6b7.1849692@news.erols.com> On Thu, 09 Sep 1999 13:45:08 GMT, gtnorton at my-deja.com wrote: > Hello folks, > Up until now, I've been putting >all of my modules in my main Python folder.But now it grows too large to >find quickly.When I create a folder(still in the main Python file) for >the scripts and try to import them with: >>>import spam I get back >"no module named spam".Please clue me in. > Thanks in advance > gtnorton >(P.S.)Running Windows98 I the long standing tradition of this newgroup to post as many possible, different solutions to a problem (who says there's "only one way"?), here is what I have done: Say I have a subdirectory 'Stuff' that has most of my non-package scripts (like 'compile.py', 'ipp.py', 'codeplot.py', etc.). I place a text file in the main Python folder ('C:\Python' for me) called 'Stuff.pth'. The name is irrelevant, but the '.pth' extension is necessary. The content of this file is the single word 'Stuff'. When the interpreter searches the PYTHONPATH and it comes across such a file, it will add the directory specified in the file to the search path. In general, the content of a '.pth' file can be any directory specification either relative or absolute. Therefore, if you have scripts in a place like 'C:\Even\More\Python\Scripts', the '.pth' file would contain '/Even/More/Python/Scripts' (following the UNIX path separator convention because it's easier. It works on Windows fine). I know this is documented somewhere, but I don't know where. Robert Kern | ----------------------|"In the fields of Hell where the grass grows high This space | Are the graves of dreams allowed to die." intentionally | - Richard Harter left blank. | From gmcm at hypernet.com Wed Sep 8 14:06:08 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 8 Sep 1999 13:06:08 -0500 Subject: Bug in time module? In-Reply-To: <37D68CB2.BB5F9CC9@pc.jaring.my> Message-ID: <1275312392-99250951@hypernet.com> lec wrote: > Gordon McMillan wrote: > > > > > The only editing Python's time module does is to ensure that you've > > passed the right number and kind of args. Everything else is the > > result of your platform's implementation of strptime. If you want > > something _good_, you should probably use MA Lemburg's mxDateTime. > > > > - Gordon > > Consider the following exception raised: > > Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 > (egcs-1.1.1 on linux2 Copyright 1991-1995 Stichting Mathematisch > Centrum, Amsterdam > >>> import time > >>> time.strptime('31/13/1999', "%d/%m/%Y") > Traceback (innermost last): > File "", line 1, in ? > ValueError: format mismatch > > Shouldn't the same exception be raised for > time.strptime('31/02/1999', "%d/%m/%Y") ? "Should / shouldn't" is a very different question from "why". Consider the following: static PyObject * time_strptime(self, args) PyObject *self; PyObject *args; { struct tm tm; char *fmt = "%a %b %d %H:%M:%S %Y"; char *buf; char *s; if (!PyArg_ParseTuple(args, "s|s", &buf, &fmt)) { PyErr_SetString(PyExc_ValueError, "invalid argument"); return NULL; } memset((ANY *) &tm, '\0', sizeof(tm)); s = strptime(buf, fmt, &tm); if (s == NULL) { PyErr_SetString(PyExc_ValueError, "format mismatch"); return NULL; } while (*s && isspace(*s)) s++; if (*s) { PyErr_Format(PyExc_ValueError, "unconverted data remains: '%.400s'", s); return NULL; } return tmtotuple(&tm); Do you see any Python edits of values there? Consider the following: Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import time >>> time.strptime('31/13/1999', '%d/%m/%Y') Traceback (innermost last): File "", line 1, in ? AttributeError: strptime No strptime in Windows c runtime. I leave the "should" question untouched. - Gordon From evan at tokenexchange.com Tue Sep 21 16:30:34 1999 From: evan at tokenexchange.com (Evan Simpson) Date: Tue, 21 Sep 1999 15:30:34 -0500 Subject: global in nested functions (viper) References: <37E7AF7B.8DEC7CC8@maxtal.com.au> <5l67149gwc.fsf@eric.cnri.reston.va.us> Message-ID: <9XRF3.2$Ae3.15469@news-dal.corridex.com> This sounds relevent to one of my many proposals to make work for other folks . Perhaps instead of causing a reference to the (grand-)*parent's locals, this could simply copy the object into a local variable at definition time? Example: >>> def f1(x): ... y = x + 2 ... def f2(x): ... global y ... print x+y ... y = 0 ... return f2 ... >>> f = f1(3) >>> del f1 >>> f(5) # the behavior below would print 5, and force f1's entire locals() to stay alive. 10 Guido van Rossum wrote in message news:5l67149gwc.fsf at eric.cnri.reston.va.us... > skaller writes: > > > The following file and viperi run demonstrate the current handling > > of the globals statement in viper. What happens is: global causes > > a variable to refer to the containing context, often a module, > > but in this demo, there is also a nested function, global then refers > > to the locals() of the containing function, unless the variable > > is _also_ declared 'global' in that function. > > Hm, this looks elegant, although I also see the elegance of > disallowing assignments into the parent function altogether (i.e., you > can *read* your parent's locals, but you can't *write* them). So I'm > undecided. > > --Guido van Rossum (home page: http://www.python.org/~guido/) From fredrik at pythonware.com Tue Sep 28 08:23:06 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 28 Sep 1999 12:23:06 GMT Subject: File recursion, info extraction References: <37F0AD76.911900AE@bibsyst.no> Message-ID: <007801bf09ac$496dc9e0$f29b12c2@secret.pythonware.com> Thomas Weholt wrote: > I need a way of handling ( get size, possibly type, modification time, > path, filename, possible extension ) all files in a directory and all > sub-folders. > > Furtermore, I want to extract info on images, like size, resolution, and > id-tag-info from mp3 files. I`ve seen a module for that could at least > set id-tag info on mp3-files. Can it read them too? The > PIL-module/project, can that take care of the "getting the info from the > images"-thing? the following script implements everything except the MP3 ID tag stuff. it requires PIL and PST, available from: http://www.pythonware.com/products/pil/ http://www.pythonware.com/products/pst/ it's probably fairly easy to add ID support to PST's MpegSoundPlugin module, but I haven't gotten around to do that yet (please send me the patches if you implement that). see the library docs for more info on what exactly os.stat returns. ... import os import time import Image # PIL import Sound # PST def check(userdata, directory, files): for file in files: filename = os.path.join(directory, file) # check if image try: im = Image.open(filename) except IOError: pass else: print filename, im.format, im.size, im.mode, return # check if sound try: sn = Sound.open(filename) except IOError: pass else: print filename, sn.format, sn.mode, sn.rate, sn.channels return return # ordinary file try: st = os.stat(filename) except os.error: pass else: print filename, st # see docs for details return print "cannot process", filename os.path.walk("/", check, None) ... From uche.ogbuji at fourthought.com Sun Sep 26 09:51:52 1999 From: uche.ogbuji at fourthought.com (Uche Ogbuji) Date: Sun, 26 Sep 1999 09:51:52 -0400 Subject: Turing Compliant? References: <1275048323-10459679@hypernet.com> Message-ID: <37EE24F8.245CE626@fourthought.com> Gordon McMillan wrote: > > Bryan VanDeVen wrote: > > > Gordon McMillan wrote: > ... > > > Well there's biological computation, in which each fork() grows it's > > > own "CPU", thus making some formerly non-computable problems > > > computable. > > > > I have heard of some experiments with biological computing - most > > taking advantange of the much higher information density that can be > > achieved using DNA, for instance, but I am very skeptical of the claim > > that this adds something fundamentally new. Any pointers to a proof? > > No experiments, just theory. Grow a new "cell" for each > decomposition of the problem. With a bit of overhead, you're getting > close to solving problems of exponential complexity in linear time. I'm pretty sure I read about some actual experiments in bio-computing in The Economist. True, this is not exactly Nature, but they are pretty reliable for combing the major peer-reviewed journals and exctracting interesting and accurate material. I don't keep back-issues of The Economist, but I do remember that there was some twist to the sorts of DNA with which they'd had success, Mitochondrial, or perhaps messenger-RNA? But then again, I have only had a sip of the Pierian, so I'm dangerous. -- Uche Ogbuji FourThought LLC, IT Consultants uche.ogbuji at fourthought.com (970)481-0805 Software engineering, project management, Intranets and Extranets http://FourThought.com http://OpenTechnology.org From hoel at GermanLloyd.org Thu Sep 16 08:40:15 1999 From: hoel at GermanLloyd.org (Berthold Hoellmann) Date: Thu, 16 Sep 1999 14:40:15 +0200 Subject: pyfort2 question References: <7rqnf5$kot$1@bignews.shef.ac.uk> Message-ID: <37E0E52F.88CBB29A@GermanLloyd.org> Jose L Gomez Dans wrote: > > Hi! > I've just downloaded pyfort2, and I'm trying to convert a > subroutine. Everything seems to work fine, and I get my module.so in > the end. When I try "from import *", python complains that there is > an udefined symbol G77_rand_0. I suppose it is related to some random > routines I use in my fortran code. > > What can I do to get over this problem? I'm running linux, with g77 > and ld, and python 1.5.2, if that's of any help. In your Setup file just add -lg2c to your compile flags. In general the documentation should mention, that you have to link the Fortran runtime library with any compiler. Cheers Berthold -- email: hoel at GermanLloyd.org ) ( C[_] These opinions might be mine, but never those of my employer. From dragondm at polar.integral.org Wed Sep 29 08:17:08 1999 From: dragondm at polar.integral.org (The Dragon De Monsyne) Date: 29 Sep 1999 12:17:08 GMT Subject: Intelligent datastructure? References: Message-ID: <7st004$r9s$1@utah.laird.net> In article , mlh at idt.ntnu.no (Magnus L. Hetland) writes: > > Hi! > > I'm making a stripped-down language for teaching algorithms (and > datastructures) without requiring much knowledge of a specific > language - (it might end up being a stripped-down version of > Python...) > > I only have two datatypes - integers and sequences. The thing I have > been thinking about lately is the implementation of the sequences. I > want them to be usable both as simple lists or arrays, and as general > hash-tables (with numeric keys) without the user having to care about > the difference... Thus, you could make yourself a sequence like this: > > s = [1,2,3] > > and then do something like > > s[100] = 4 > > without getting any complaints. (I think I will only allow positive > integers as indices, but I'm not sure...) [ --- 8< --- ] Basically what you are looking for is a 'sparse array' (basically an array (list) that allows unfilled 'holes' in it, so you can add list[x] = 42 without needing to actually store x elements. My suggestion is this, if you implement this in Python, just use a dictionary. Python dictionaries are hashtables, which are pretty fast and efficient. I timed adding 10k integers to a list, and to an integer-keyed dictionary. The list took 2.25 sec, the dict took 0.5 sec. (caveat benchmark, YMMV) -- ############# # I # Really, # Really, # Really, # Really, # Really, # Really, # Really, # Really, # __Really__ hate newservers that have bogus limits on quoted text. :P ############# -- -The Dragon De Monsyne From balance_is_healthy at my-deja.com Tue Sep 28 06:03:35 1999 From: balance_is_healthy at my-deja.com (balance_is_healthy at my-deja.com) Date: Tue, 28 Sep 1999 10:03:35 GMT Subject: where did www.python.org go? Message-ID: <7sq3pk$sbg$1@nnrp1.deja.com> Hi I?m a real newcommer (haven?t posted before) But I?m really insterested in programming. Can anyone please tell me where www.python.org went? Have they moved ? All advices on pythonresources are appreciated. Though please don?t send any files. If I posted on the wrong place please have mercey. Thanks wizzes! Henrik Sent via Deja.com http://www.deja.com/ Before you buy. From Denys.Duchier at ps.uni-sb.de Fri Sep 10 17:39:08 1999 From: Denys.Duchier at ps.uni-sb.de (Denys Duchier) Date: 10 Sep 1999 23:39:08 +0200 Subject: Using indentation for blocking References: <7raqm7$5ag$1@nnrp1.deja.com> <002f01befb88$5b930b80$f29b12c2@secret.pythonware.com> Message-ID: "Fredrik Lundh" writes: > "We will perhaps eventually be writing only small > modules which are identified by name as they are > used to build larger ones, so that devices like > indentation, rather than delimiters, might become > feasible for expressing local structure in the source > language." > > -- Donald E. Knuth, "Structured Programming with goto > Statements", Computing Surveys, Vol 6 No 4, Dec. 1974 If memory serves, this (the offside-rule) was one of the many visionary things proposed by Landin in his 1966 CACM paper "The next 700 programming languages". While that idea is quite convenient for authoring programs manually, it is a nuisance for automated processing, e.g. for macros (i.e. the combination of textual program fragments). In Haskell, you can use indifferently a mix of indentation or braces and semicolons to convey layout structure. This is, in my opinion, a more reasonable compromise. -- Dr. Denys Duchier Denys.Duchier at ps.uni-sb.de Forschungsbereich Programmiersysteme (Programming Systems Lab) Universitaet des Saarlandes, Geb. 45 http://www.ps.uni-sb.de/~duchier Postfach 15 11 50 Phone: +49 681 302 5618 66041 Saarbruecken, Germany Fax: +49 681 302 5615 From jacques at integra.co.za Wed Sep 15 01:05:10 1999 From: jacques at integra.co.za (Jacques Oosthuizen) Date: Wed, 15 Sep 1999 07:05:10 +0200 Subject: Boiler plate method for Module Message-ID: <7rn9am$87t$1@news.is.co.za> Hi am looking for a good but simple example of how to write my own Python Object in C 1) Must show me how to write the constructor/destructor 2) Sow me how to do getattr/setattr pair PLEASE DO NOT TELL ME TO LOOK AT TO SOURCE OF PYTHON, I HAVE DONE THAT I JUST WANT TO SEE SIMPLE LAYOUT. From bobklin at idt.net Wed Sep 8 19:54:30 1999 From: bobklin at idt.net (Bob Kline) Date: Wed, 8 Sep 1999 19:54:30 -0400 Subject: Choosing a MySQL interface References: Message-ID: <7r6t12$b3t@nnrp3.farm.idt.net> jims wrote in message news:rtcnbgef1iv21 at corp.supernews.com... > I'm a bit of a Python newbie, and am building an app > that uses a MySQL database (the latest version) as the back > end. > I wonder if anyone can tell me whuich is the currently "correct" > way to connect to a MySQL database using Python. There > appear to be several methods available (like here and here) > but I can't tell which one is the right one to use at this time. The advantage of the first package to which you refer (MySQLmodule) is that it appears to build properly on the two platforms I've tried it on. The advantage of the second package (MySQLdb) is that it conforms to the new standard API for database access using Python. Unfortunately, although I've succeded in getting the second package working on Linux, the build fails on NT. I posted a message last week reporting the error messages I got and asking what components are missing from the win32 Python distribution that are needed to make the error messages go away, but no one seems to know the answer. I hope you have better luck finding knowledgable folks on this list. Of course, if your db client is on UNIX or Linux, you may not have any problems. Bob From jetman3 at netzero.net Thu Sep 23 05:34:32 1999 From: jetman3 at netzero.net (The Jetman) Date: Thu, 23 Sep 1999 05:34:32 -0400 Subject: [PyWin] Does Win32RAS Work ? References: Message-ID: Neglected to mention that the problem is happening under Win95....Jet -- ================================================================ In Paris, they simply stared when I spoke to them in French; I never did succeed in making those idiots understand their own language. - Mark Twain, The Innocent Abroad,1869 ======================================= jetman3 at netzero.net == The Jetman wrote in message ... > > Have spent a couple of hours trying to narrow down a >prob w/ Win32RAS and I'm at the point where I suspect it simply >doesn't work. Have trimmed down the rastest script to simply >call win32ras.Dial(). It starts dialing, then hangs the >PyWin process (starts beeping incessantly, until I do a >three-finger salute.) Any ideas ? > >-- > >================================================================ > In Paris, they simply stared when I spoke to them in French; > I never did succeed in making those idiots understand their > own language. - Mark Twain, The Innocent Abroad,1869 >======================================= jetman3 at netzero.net == > > > > From warren at nightwares.com Thu Sep 9 12:46:14 1999 From: warren at nightwares.com (Warren 'The Howdy Man' Ockrassa) Date: Thu, 09 Sep 1999 11:46:14 -0500 Subject: And now for something completely boneheaded... References: <37D623A2.DC09F0CC@nightwares.com> Message-ID: <37D7E456.728C0BC1@nightwares.com> OK, first a big thank you to those who answered my question in a patient manner, and a big razzberry to those who did not. :) So it seems clear to me now that what I need, more than anything else, is a good language ref. I don't think I've seen one online, and the _Programming Python_ book by Mark Lutz, while it contains some teriffic content, is not, as Mark Lutz himself points out, a reference manual. :\ So. Anyone have suggestions? A language ref is pretty much precisely what I need, I think; and while I am aware of other O'Reilly books on the subject, I don't know for sure which would be more along the lines of what I'm looking for. Thanks once more, all! --WthmO From JACarson at addcoinc.com Wed Sep 29 11:10:00 1999 From: JACarson at addcoinc.com (Carson, Jon A.) Date: Wed, 29 Sep 1999 10:10:00 -0500 Subject: Newbie Stuff Message-ID: <290CDF914950D3118D79006008BD51AF0B4F8E@rc.addcoinc.com> Hi, I have a "newbie" question for the list. I would like to write a small aplication with python/tkinter that deals with information to and from the serial port. this application would potentially run on serveral different platforms...WinDoze, Mac, *nix...etc. Question: How do I deal with ports in Python, and is the same across platforms. Thanks in Advance, Jon c. ----------------------------------------------- jacarson at addcoinc.com ___..---'~~~`---..___ .-=========================- _______________/ :.::..-~--..___..---~~~' (___________(_||_)____/ /____/___:..::.:::. / NCC-1701 D \_________/ "Engage" ----------------------------------------------- From evb0 at gte.com Fri Sep 24 11:12:13 1999 From: evb0 at gte.com (Evgeni V. Belin) Date: Fri, 24 Sep 1999 11:12:13 -0400 Subject: color JPEGs Message-ID: <199909241512.LAA01413@kuai.gte.com> Hi Paul, => IOError: cannot write mode P as JPEG I'd suggest to look at pilconvert.py that comes in the Scripts subdir. Basically, you can use *drafts* to to convert images before saving in different format: >>> import Image >>> im = Image.open('foo.gif') >>> im.save('foo.jpg') ... IOError: cannot write mode P as JPEG >>> im.draft("RGB", im.size) >>> im = im.convert("RGB") >>> im.save('foo.jpg') >>> Hope that helps, -Evgeni ------- Forwarded Message Return-Path: python-list-admin at python.org Delivery-Date: Fri Sep 24 10:47:55 1999 Received: from newman.gte.com (newman.gte.com [132.197.8.26]) by kuai.gte.com (8.8.8/8.8.8) with ESMTP id KAA01363 for ; Fri, 24 Sep 1999 10:47:51 -0400 (EDT) Received: from cliff2.gte.com (cliff2.gte.com [132.197.8.43]) by newman.gte.com (8.9.1/8.9.1) with ESMTP id KAA11552 for ; Fri, 24 Sep 1999 10:47:50 -0400 (EDT) Received: from relay.gte.com (relay.gte.com [132.197.248.10]) by cliff2.gte.com (8.9.1/8.9.1) with ESMTP id KAA25962 for ; Fri, 24 Sep 1999 10:47:50 -0400 (EDT) Received: from python.org ([132.151.1.90]) by relay.gte.com (8.9.1/8.9.1) with ESMTP id KAA09793 for ; Fri, 24 Sep 1999 10:47:49 -0400 (EDT) Received: from python.org (localhost [127.0.0.1]) by python.org (8.9.1a/8.9.1) with ESMTP id KAA13674; Fri, 24 Sep 1999 10:45:53 -0400 (EDT) From: Paul Barrett Newsgroups: comp.lang.python Subject: color JPEGs Date: Fri, 24 Sep 1999 10:17:23 -0400 Organization: Space Telescope Science Institute Lines: 20 Message-ID: <37EB87F2.87A9A19D at STScI.Edu> NNTP-Posting-Host: dhcp-042.stsci.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.6 [en] (X11; I; Linux 2.2.12 i586) X-Accept-Language: en Path: news!uunet!ffx.uu.net!pulsar.dimensional.com!dimensional.com!coop.net!ncar!noao!stsci.edu!not-for-mail Xref: news comp.lang.python:72687 To: python-list at python.org Sender: python-list-admin at python.org Errors-To: python-list-admin at python.org X-Mailman-Version: 1.0.2 Precedence: bulk List-Id: General discussion list for the Python programming language X-BeenThere: python-list at python.org I'm trying to create a color JPEG from Numeric data. I used Rob Hooft's message from earlier this year to get me started. All of his code appears to work fine. The problem appears when I try to save the image, i.e. img.save('filename.jpg'). I get the following error message: IOError: cannot write mode P as JPEG Can a PIL guru tell me what I'm doing wrong and how to proceed? I've attached the relevant python code to help. img = Image.Palette('P', (data.shape[1], data.shape[0]), data.tostring(), 'raw', 'P') img.palette = ImagePalette.raw('RGB', string.join(palette, '')) img.save('filename') - -- Paul - -- http://www.python.org/mailman/listinfo/python-list ------- End of Forwarded Message From jam at quark.emich.edu Thu Sep 30 00:15:47 1999 From: jam at quark.emich.edu (Jeff) Date: Thu, 30 Sep 1999 00:15:47 -0400 Subject: Python TimeServer (RFC 868) In-Reply-To: References: <19990929000705.A21607@quark.emich.edu> Message-ID: <19990930001547.B22550@quark.emich.edu> On Thu, Sep 30, 1999 at 01:57:13AM +0000, Benjamin Schollnick wrote: > Jeff, > [..snipped..] > > - Benjamin greetings. I poked around a little, and came up with some code, which I have attached. please let me know if it works for you-- I haven't tested it other than to telnet to the port, and it seems to work.. I've got no idea if it will work under NT or not (though I can't think of any particular reason why it wouldn't), but use it for what it's worth. -- begin code -- #!/usr/bin/env python import socket import struct def timeserver_calculation(): import time return time.time() def server(host="", port=3737, backlog=5): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.bind(host, port) sock.listen(backlog) print "listening on port %s (%s, %d)" % (port, host, backlog) while 1: conn, addr = sock.accept() print "connected by %s at %s" % (conn, addr) ft = timeserver_calculation() conn.send(struct.pack("!i", ft)) conn.close() if __name__ == "__main__": server("localhost", 3737) -- end code -- -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From bartek69 at kki.net.pl Sun Sep 26 03:49:46 1999 From: bartek69 at kki.net.pl (Bartek Nicka) Date: Sun, 26 Sep 1999 09:49:46 +0200 Subject: wxPython problems Message-ID: <7sjl5n$4gc$1@sunsite.icm.edu.pl> I got strange problem with wxPython on RH6.0. I've written the small application and each time I run it the some texts ( eg. buttons' captions and labels ) look in other way. I mean that the font's size and,style changes each time and I have no idea why it happens. Thanks in advance for help and sorry for my bad English. bartekn at jota.ps.pl From madq968 at djeksta.comNOSPAM Sun Sep 26 14:01:40 1999 From: madq968 at djeksta.comNOSPAM (madQ) Date: 26 Sep 1999 18:01:40 GMT Subject: Download Ia.n.i.!!! It's free! Message-ID: <7sln24$7l9$501@nslave1.tin.it> Download Ia.n.i. RemoteControlSystem 1.2 beta. It's free!!! New site: http://jump.to/IaniProject From aahz at netcom.com Wed Sep 15 16:20:43 1999 From: aahz at netcom.com (Aahz Maruch) Date: 15 Sep 1999 20:20:43 GMT Subject: Checking for 'new' POP3 mail References: Message-ID: <7rov2r$h6r@dfw-ixnews16.ix.netcom.com> In article , Python Addict wrote: > >Messages come and go so just purely checking on the number of messages in >the spool isn't going to work. Our POP server supports the optional UIDL >command which returns the message number, a space, and then a unique >identifier for each message. Bingo. >Am I making things complex for no reason or is there some built in >functionality I'm missing from the POP spec? Is there a Python-ish way of >comparing two lists that I might not be aware of? I was going to start at >the beginning of the second list, waddle through it, and search for each >element in the first list. Use a dict instead of a list. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From mjackson at wc.eso.mc.xerox.com Tue Sep 7 13:21:15 1999 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 7 Sep 1999 17:21:15 GMT Subject: 1.5.2 NT install question(s) Message-ID: <7r3hib$24f$1@news.wrc.xerox.com> I've done this twice recently and encountered problems both times. On a fresh system (never had Python or Tcl/Tk) things (for example, PySol) seem to work, but whenever I use Tkinter (specifically, when _tkinter is imported) I get a warning box about not being able to find tcl80.dll in the specified path. (tcl80.dll is present, in Program Files\Tcl\bin.) What's wrong, and how do I put it right? On a system where 1.5.1 (with Tcl/Tk) had previously been installed, I carefully uninstalled both before installing 1.5.2. Here both "import _tkinter" and "inport Tkinter" are OK, but Tkinter._test() yields: TclError: Can't find a usable init.tcl in the following directories: {} ./lib/tcl8.0 D:/tc18.0/library {D:/Program Files/library} This probably means that Tcl wasn't installed properly. (init.tcl is present, in Program Files\Tcl\lib\tcl8.0.) What's wrong, and how do I put it right? Thanks in advance. Sorry to be asking such trivial-seeming questions, but I found nothing helpful through python.org. And I haven't dealt with the innards of NT enough for its design coherence to become manifest (yeah, right). -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson Spend the optimal amount of time on each decision and pretty soon you run out of life. - Steven Waldman From laheadle at boguscs.uchicago.edu Thu Sep 30 04:18:35 1999 From: laheadle at boguscs.uchicago.edu (Lyn A Headley) Date: 30 Sep 1999 03:18:35 -0500 Subject: Nolan's question of the day: distributed servers? References: <87btal3td5.fsf@ethereal.dhis.org> Message-ID: >>>>> "Nolan" == Nolan Darilek writes: Nolan> I've kept up a good tradition (Maybe not, depending on your Nolan> point of view :) of asking one question per day. Here's Nolan> today's. :) whew! this one's a doozy. Nolan> So, a network of namespaces will exist, each accessing Nolan> either a database or a server. My current concern, though, So do I get this right? A main architectural goal for your mud server framework will be to allow servers access to objects on other servers, along with a protocol for discovering and invoking services offered by those objects. The hairy part (as you've mentioned below) is where do the _effects_ of those services take place? If you are hoping to invoke an object on one server and have it change the state of another server, good luck. That sounds pretty tough to me. They will need to share knowledge about the state of each other in a very intimate way, which would be especially hard if the servers have different coders. I do believe corba will do what you want (not that I've DONE it or anything ;-) They call it dynamic method invocation or something equally obvious (also look at interface repositories). However, if you're serious about this I'd advise you to look at Erlang. www.erlang.org -- Lyn Headley remove the word "bogus" from my address for the real one. From mnot at mnot.net Wed Sep 8 19:07:57 1999 From: mnot at mnot.net (Mark Nottingham) Date: Thu, 9 Sep 1999 09:07:57 +1000 Subject: Python example: possible speedup? References: <87puztv2gt.fsf@pc-hrvoje.srce.hr> Message-ID: <00a801befa4e$fd89c450$0301a8c0@mnot.net> Have you tried profiling it? I.e., [...] if __name__ == '__main__': import profile profile.run('main()') From robin at jessikat.demon.co.uk Wed Sep 15 05:00:44 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Wed, 15 Sep 1999 09:00:44 GMT Subject: high school programming & python In-Reply-To: References: <937300939snz@vision25.demon.co.uk> <$JL+lCAFvt33Ewr8@jessikat.demon.co.uk> Message-ID: In message , Bill Janssen writes >Excerpts from ext.python: 14-Sep-99 Re: high school programming.. Robin >Becker at jessikat.de (951) > >> You were lucky to have plugboards. We had to key things in with a bunch >> of switches. > >Hard little metal toggle switches, too -- none of these posh molded >plastic rocker switches! > >Bill > yes indeed -- Robin Becker From phil at geog.ubc.ca Mon Sep 27 14:54:56 1999 From: phil at geog.ubc.ca (Phil Austin) Date: 27 Sep 1999 11:54:56 -0700 Subject: Moving from Perl to Python References: Message-ID: jonathon writes: > On 25 Sep 1999, Harry George wrote: > > Other interesting/useful language translations might be > > _Numerical Fortran_/_Numerical C_/_Numerical Pascal_ > << Or has this been done? >> Thanks to Paul Dubois and collaborators, my guess is that the difficulty threshold for wrapping Fortran code using either CXX or pyfort (http://xfiles.llnl.gov/python.htm) has become so low that reimplementation probably isn't worth it (expecially since netlib usually contains a free Fortran/C/C++ free alternative that could be substituted). For those who haven't seen the new technology, here's a small example: the complete Python/CXX wrapper for the NR routines fasper.f (Section 13.8 of the 2nd edition) and gasdev.f: #include "Python.h" #include "CXX_Objects.h" #include "CXX_Extensions.h" #include "CXX_Array.h" #include #include #include using namespace std; extern "C" { void fasper_(float* x,float* y,int& n,float& ofac,float& hifac,float* wk1, float* wk2,int& nwk,int& nout,int& jmax,float& prob); float gasdev_(int& idum); } static PyObject * ex_fasper(PyObject* self, PyObject* args) { Py_Initialize(); import_array(); PyImport_ImportModule("Numeric"); Py::Tuple inargs(args); Py::Array x(inargs[0]); assert(x.species()==PyArray_FLOAT); Py::Array y(inargs[1]); assert(y.species()==PyArray_FLOAT); int jint = Py::Int(inargs[2]); float ofacfloat = Py::Float(inargs[3]); float hifacfloat = Py::Float(inargs[4]); int MPint = Py::Int(inargs[5]); Py::Array wk1(MPint,PyArray_FLOAT); Py::Array wk2(MPint,PyArray_FLOAT); int nout; int jmax; float prob; fasper_( (float*) x.to_C(), (float*) y.to_C(), jint, ofacfloat, hifacfloat ,(float*) wk1.to_C(), (float*) wk2.to_C(), MPint ,nout,jmax,prob); Py::Dict output; output["wk1"]=wk1; output["wk2"]=wk2; output["nout"]=Py::Int(nout); output["jmax"]=Py::Int(jmax); output["prob"]=Py::Float(prob); return Py::new_reference_to(output); } static PyObject * ex_gasdev(PyObject* self, PyObject* args) { Py_Initialize(); import_array(); PyImport_ImportModule("Numeric"); Py::Tuple inargs(args); int idumint = Py::Int(inargs[0]); float ranNum=gasdev_(idumint); Py::Tuple output(2); output[0]=Py::Int(idumint); output[1]=Py::Float(ranNum); return Py::new_reference_to(output); } static Py::ExtensionModule* lombper; extern "C" void initlombper(); void initlombper() { // experimental initialization stuff lombper = new Py::ExtensionModule("lombper"); lombper->add("fasper", ex_fasper, "calculate the Lomb periodogram"); lombper->add("gasdev", ex_gasdev, "return a gaussian deviate"); Py::Dict d = lombper->initialize(); } From fredrik at pythonware.com Thu Sep 23 04:55:38 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 23 Sep 1999 08:55:38 GMT Subject: Postscript printing in Python References: <37E98032.FA3B77F5@ans.com.au> Message-ID: <014c01bf05a1$6b6507c0$f29b12c2@secret.pythonware.com> Clement wrote: > I checked the libraries and other Python documentation and failed to > find any help on printing to a postscript printer! a few options: there's PIDDLE: http://www.strout.net/python/piddle/intro.html if you have PIL installed, there's a very basic PostScript driver in there: http://www.pythonware.com/library/pil/handbook/psdraw.htm and yes, Tkinter can print the contents of a canvas to a PostScript printer, and Grail (http://grail.cnri.reston.va.us/grail/) comes with an HTML to PostScript converter... From davidopp at megsinet.net Sat Sep 11 14:42:52 1999 From: davidopp at megsinet.net (David Oppenheimer) Date: Sat, 11 Sep 1999 14:42:52 -0400 Subject: Python or Java or "X" from me and my little job References: <1275048881-10426114@hypernet.com> Message-ID: <37DAA2AB.1ABFA8E9@megsinet.net> Gordon McMillan wrote: > > > > 2)Should I go with JAVA instead? > > Not unless you shave with a belt sander and use a gasoline-based > aftershave. > Q: Are trying to point out that Java isn't the right tool for the job or are you implying that Java is for insane people or both? David O. "Any Sufficiently Advanced Technology Is Indistinguishable From Magic" -Arthur C. Clarke From gerrit.holl at pobox.com Sat Sep 25 07:04:31 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Sat, 25 Sep 1999 13:04:31 +0200 Subject: Source line number for log purpose (newbie) In-Reply-To: <7shiqh$d96$1@ssauraaa-i-1.production.compuserve.com> References: <7shiqh$d96$1@ssauraaa-i-1.production.compuserve.com> Message-ID: <19990925130431.B11328@optiplex.palga.uucp> T. C. Mits: > In c there was a way to get the current source line number via a macro, > __LINE__. > > I need to be able to do the same thing. I created a logger class that uses > a level setting. At high levels I want to > log the source line number where the inline log.prtl( level, msg) method > call appears. > > I'm sure this is easy but am getting lost digging through the Python source > and docs. > That's possible via the 'Exception' module. regards, Gerrit. -- RTFM: Read That FreshMeat From amiramir at my-deja.com Mon Sep 27 02:31:10 1999 From: amiramir at my-deja.com (amiramir at my-deja.com) Date: Mon, 27 Sep 1999 06:31:10 GMT Subject: smtp and pop servers? Message-ID: <7sn2vf$p8m$1@nnrp1.deja.com> I can't seem to find any code for smtp and pop servers. Plenty of client stuff, but no server. Any pointers? Thanks, -A- Sent via Deja.com http://www.deja.com/ Before you buy. From nikolai at micon.no Sun Sep 5 17:50:32 1999 From: nikolai at micon.no (Nikolai Kirsebom) Date: Sun, 5 Sep 1999 23:50:32 +0200 Subject: Using Python in ASP scripts References: Message-ID: I had a look at it (Aaron's description), but it appears to be information intended for CGI-scripts. I'm running (trying to) ASP scripts with Python as the scripting language. As I state in my first message - the pages runs ok on one of my machines (actually only a backup server). I have checked (manually) the registries (for Python issues) and they are identical. I'm running Python 1.5.2b2 and PythonWin build 125. Even the simplest python-code does not work. As I wrote in my previous message, I suspect there must be something wrong with a 'reference' to the scripting language. When I select the ASP page in the browser - it waits endlessly (even if I in the server has configured a 90 second for ASP script timeout). I cannot see anything peculiar in the task-manager (processes heavily using the cpu). Does anyone know how I could 'trace' what happends when IIS receives the URL referencing a ASP file. The last resort will probably be to re-install everything on the machine and upgrade to SP5. Hope someone can help. Nikolai Bill Wilkinson wrote in message ... >Have you read this bit? >http://starship.python.net/crew/aaron_watters/pws.html > >It might help. > From da at ski.org Fri Sep 24 16:51:54 1999 From: da at ski.org (David Ascher) Date: Fri, 24 Sep 1999 13:51:54 -0700 (Pacific Daylight Time) Subject: replacing the class of an instance In-Reply-To: <99Sep24.123307pdt."3473"@watson.parc.xerox.com> Message-ID: On Fri, 24 Sep 1999, Bill Janssen wrote: > I'd like to be able to replace the class of previously created > instances when I create a new version of the class. Is it sufficient > to keep track of all the instances, then go through and change the > __class__ member of each instance when I change the class definition? > > Or is there an even easier way? Depending on your needs, you may be able to rip out the guts (aka the methods and class attributes) of the class that the instances all share and squeeze in the new class as a base class of the original class. That would avoid having to deal with circular references. Something like (untested): orig_class.__dict__.clear() orig_class.__bases__ = (new_class, ) --david ascher From bob at horvath.com Wed Sep 22 15:55:20 1999 From: bob at horvath.com (Bob Horvath) Date: Wed, 22 Sep 1999 19:55:20 +0000 Subject: wxPython on Debian Linux References: <37E8C20A.F4051E56@horvath.com> <87u2omg1yc.fsf@baal.winnegan.fake> Message-ID: <37E93428.F1AAEC8C@horvath.com> Siggy Brentrup wrote: > Bob Horvath writes: > > [...] > > > I haven't tried it myself, but itsn't it at > > > > http://www.debian.org/Packages/unstable/interpreters/python-wxwin.html > > This won't help if the original poster is running stable aka slink aka > Debian 2.1 as I am doing. But you can always get the source package > and build you own local .deb. > True, but if you aren't living on the edge, you're taking up way too much space! From m.faassen at vet.uu.nl Sun Sep 5 13:40:27 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 5 Sep 1999 17:40:27 GMT Subject: language interpreters/ interpreted languages weaknesses? References: <7qi3q3$n1d$1@nnrp1.deja.com> <37CCE10D.D07D023B@strs.co.uk> <7qjgq8$k1i$1@newshost.accu.uu.nl> <7qlj3b$p7u$1@newshost.accu.uu.nl> <7qrce6$dgh$1@news.bayarea.net> Message-ID: <7qu9ub$q02$1@newshost.accu.uu.nl> Frank Mitchell wrote: > Stephan Houben wrote in message ... >>m.faassen at vet.uu.nl (Martijn Faassen) writes: Hm, confusing misattribution, I didn't write what's coming. You should've snipped this. :) Stephan wrote it. >>Of course, Sun marketed the fact that Java used bytecode as if it was >>something revolutionary. "No, it is not interpreted, it is compiled to >>Byte Code!" Of course, all those other languages which had been called >>"interpreted" where actually compiled to byte code since the >>beginning of time. Byte-code compilation is really as old as the Sun. ;-) Regards, Martijn From ngps at madcap.dyn.ml.org Tue Sep 14 09:07:53 1999 From: ngps at madcap.dyn.ml.org (Ng Pheng Siong) Date: 14 Sep 99 13:07:53 GMT Subject: [ANNOUNCE] M2Crypto 0.02 - now does SSL Message-ID: <37de48a9.0@news.cyberway.com.sg> (Apologies if you've seen this. I didn't see the posting appear. Apparently Usenet is not my ISP's long suit.) I am pleased to announce the release of M2Crypto 0.02. The package is available at http://www.post1.com/home/ngps This release incorporates support for SSL, specifically, For building servers, blocking i/o: - An SSLServer modeled after SocketServer. - A ForkingSSLServer that seems to work well. - A ThreadingSSLServer that runs one thread at a time. (!) ;-) For building servers, nonblocking i/o: - An ssl_dispatcher modeled after asyncore.dispatcher. A HTTPS server based on Medusa. For client-side web programming: - httpslib - urllib2 Your feedback is appreciated. Cheers. -- Ng Pheng Siong -- Ng Pheng Siong From jpersson1 at yahoo.com Tue Sep 7 09:48:18 1999 From: jpersson1 at yahoo.com (jpersson1 at yahoo.com) Date: Tue, 07 Sep 1999 13:48:18 GMT Subject: JPython and serialization Message-ID: <7r352v$ggh$1@nnrp1.deja.com> Hello Is there anyone out there who has experience with using JPython together with the Java serialization API. I want to subclass a native Java class in JPython and then serialize an instance of this class to a file, but when I try to do it I get the following error: Traceback (innermost last): File "ser/test.py", line 11, in ? java.io.NotSerializableException: org.python.core.PyFile$TextWrapper at java.io.ObjectOutputStream.outputObject (ObjectOutputStream.java) at java.io.ObjectOutputStream.writeObject (ObjectOutputStream.java) at java.io.ObjectOutputStream.defaultWriteObject (ObjectOutputStream.java) at java.io.ObjectOutputStream.outputObject (ObjectOutputStream.java) at java.io.ObjectOutputStream.writeObject (ObjectOutputStream.java) at java.io.ObjectOutputStream.defaultWriteObject (ObjectOutputStream.java) at java.io.ObjectOutputStream.outputObject (ObjectOutputStream.java) at java.io.ObjectOutputStream.writeObject (ObjectOutputStream.java) at java.io.ObjectOutputStream.defaultWriteObject (ObjectOutputStream.java) at java.io.ObjectOutputStream.outputObject (ObjectOutputStream.java) at java.io.ObjectOutputStream.writeObject (ObjectOutputStream.java) at org.python.core.PyReflectedFunction.__call__ (PyReflectedFunction.java:156) at org.python.core.PyMethod.__call__(PyMethod.java:40) at org.python.core.PyObject.__call__(PyObject.java:268) at org.python.core.PyInstance.invoke(PyInstance.java:272) at org.python.pycode._pyx0.f$0(test.py) at org.python.pycode._pyx0.call_function(test.py) at org.python.core.PyTableCode.call(PyTableCode.java:75) at org.python.core.Py.runCode(Py.java:935) at org.python.core.__builtin__.execfile(__builtin__.java:244) at org.python.core.__builtin__.execfile(__builtin__.java:248) at org.python.util.PythonInterpreter.execfile (PythonInterpreter.java:132) at org.python.util.jpython.main(jpython.java:123) java.io.NotSerializableException: java.io.NotSerializableException: org.python.core.PyFile$TextWrapper It seems that the JPython proxy class, that are created on the fly when I am subclassing, contains references to non serializable objects. Can it be done or must I rethink my design? -- Regards //Jan Persson (Syren Software, Sweden) Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From battery841 at usa.net Wed Sep 15 22:50:46 1999 From: battery841 at usa.net (battery841 at usa.net) Date: Thu, 16 Sep 1999 02:50:46 GMT Subject: Python Programmer needed Message-ID: <7rplu3$gag$1@nnrp1.deja.com> Hey, I am part of a new Linux site called Linuxfeed. You can check us out at www.linuxfeed.com. Anyways, someone is programming a language which is based off of corba called BLADE. BLADE will be used eventually in Linuxfeed. We need someone to work help make bindings for BLADE. If you can help, please contact bob at thestuff.net . Thanks Kevin PS. check us out at www.linuxfeed.com Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From mhuster_AT at hotmail_DOT.com Thu Sep 30 20:49:19 1999 From: mhuster_AT at hotmail_DOT.com (Michel Huster) Date: Fri, 01 Oct 1999 00:49:19 GMT Subject: How Can I do vi-like substitutions? Message-ID: <7t10nc$97k$1@thoth.cts.com> I want to do some complex replace inside python. I am used to vi power like: s/\([0-9]*\) at \([0-9]*\)/\2 AT \1/ which will change 1234 at 5678 into 5678 AT 1234 I can only find re.sub(expr, repl, count) but this does not 'remember' the saves matches between arguments. Help! ?Ayudame! Michael Huster mhuster_AT at hotmail_DOT.com (remove _AT and _DOT to reply) From hniksic at srce.hr Tue Sep 14 18:11:18 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 15 Sep 1999 00:11:18 +0200 Subject: Python and MySQL Message-ID: <87d7vlcfeh.fsf@pc-hrvoje.srce.hr> Do people use Python connected to MySQL? If so, what client do you use? I've seen two, the MySQLdb, and the generic mxODBC. The latter seems better, but I was unable to compile the required infrastructure, i.e. the myodbc libraries. What are the experiences of others? I ask this because I will soon start working for a company that connects Perl with Microsoft SQL server extensively. (They connect through, I think, Sybase ODBC drivers. I could be wrong.) I would like to gradually convert their infrastructure to more maintainable Python, so I'm using MySQL for practice. If there are useful experiences or cautionary tales regarding mxODBC and MSSQL/Sybase, I'd like to hear them too. From randall_burns_hp at my-deja.com Thu Sep 2 20:53:31 1999 From: randall_burns_hp at my-deja.com (randall_burns_hp at my-deja.com) Date: Fri, 03 Sep 1999 00:53:31 GMT Subject: How to sell Python to your boss? References: Message-ID: <7qn667$e30$1@nnrp1.deja.com> In article , Petri Mikael Kuittinen wrote: > I have lots of programming experience in C, and >much less in Python. Despite this I am confident >that I would be able to implement > the prototype using Python many times faster >than using C. Well, I agree that you are representative of a big constituency out there. We've been making substantial use of Python at HP/Cupertino and our experience so far indicates that Python can be used to develop programs rapidly that can be maintained easily. So far, one of our biggest issues has been finding developers enthusiastic about developing in Python. I've seen lots of folks who are rather pessimistic about Python's future(my current boss is not among them). If anyone would like to talk to me about Python opportunities at HP/Cupertino, I'd be happy to speak with them(we are doing some substantial e-commerce applications in Python). > I can understand my bosses opinion. He wants to protect the interest > of this firm. If I would leave the firm, then someone else would have > tp spend time learning Python in order to modify my program code. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> There is a lot to be said for sticking with widely used languages. The problem is that the mostly widely used languages may not be suited for all areas. > > For several months I have tried to get my >colleagues excited to learn Python, but so far >nobody has been interested to learn new >languages, except for some mild interest towards >Java (which is IMHO an overly-hyped language). > Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From bsb at baal.infodrom.north.de Thu Sep 23 20:28:01 1999 From: bsb at baal.infodrom.north.de (Siggy Brentrup) Date: 24 Sep 1999 02:28:01 +0200 Subject: Becoming root within a Python script In-Reply-To: =?ISO-8859-1?Q?Fran=E7ois?= Pinard's message of "23 Sep 1999 18:31:53 -0400" References: Message-ID: <87zoydrw4u.fsf@baal.winnegan.fake> Fran?ois Pinard writes: > Hi, people. I have a small problem, for which I see no elegant solution yet. > Is there a common idiom I could use? > > I would like, within a executing Python started as non-root, ask for the root > password, and then, continue executing part of the script while being root, > becoming the previous again after some sub-job is done. > > Of course, I can kludge something in, but I would prefer something nice. :-) What you are asking for requires suid root scripts, a really bad thing modern Unices don't allow any more. You have to hack up a wrapper written a compiled language, which starts the interpreter with root priveledge. A while ago I did some work on such a beast using an md5 registry for trusted scripts, but after rethinking I threw it away - just to big a security risk. CU Siggy -- noch nichts Aufregendes: Siggy Brentrup - bsb at baal.infodrom.north.de - voice: +49-441-6990134 From stephan at pcrm.win.tue.nl Fri Sep 10 03:55:16 1999 From: stephan at pcrm.win.tue.nl (Stephan Houben) Date: 10 Sep 1999 07:55:16 GMT Subject: Programmers Editor References: <37D5916B.606E@zeusedit.com> <00da01bef9e0$6e1b5c70$f29b12c2@secret.pythonware.com> <3dg10p1b5j.fsf@amarok.cnri.reston.va.us> Message-ID: On 08 Sep 1999 15:00:24 -0400, Andrew M. Kuchling wrote: >Anyway, if someone wanted to >contribute info on editing Python with Zeus, KDevelop, or whatever, it >would be very helpful. Just follow up to this posting with notes on >configuring your editor of choice. JED is a very nice editor. It comes with Python support right out of the box. I actually didn't need anything to configure to work comfortably with it. (OK I chose another colour scheme in the menu.) But make sure you get the latest version (0.98). 0.97 comes with some older Linux distributions (in my case, RH 6.0), but is much less nice. It is also much more light-weight then Emacs. But then again, there's no kitchen-sink built-in. Greetings, Stephan From JohnH at PHM.GOV.AU Sun Sep 19 07:44:42 1999 From: JohnH at PHM.GOV.AU (Hirsch, John) Date: Sun, 19 Sep 1999 21:44:42 +1000 Subject: CygWin version Message-ID: Sorry to appear so stupid, But if I open an MS-DOS window then install Doskey it installs OK and works. But if I then start Python in the same DOS window, Doskey does not seem to work within Python what is my problem.? > > If your on 95 running doskey will give you command history. > NT has the equivalent of doskey always on. > > Bill > > > > > Hi all > > In the Python tutorial it says "The interactive editing and history > > described here are optionally available in the Unix and > > CygWin versions of > > the interpreter." > > Is there a CygWin version of the interpreter and if so where > > can I get it. > > If not is there another way to get interactive editing and > > history in the > > command line interpreter. > > Thanks in advance > > > > Jonathan Hirsch > > johnh at phm.gov.au > > > > > > > From mkrisch at radiata.com Wed Sep 22 03:32:27 1999 From: mkrisch at radiata.com (Mark Krischer) Date: Wed, 22 Sep 1999 17:32:27 +1000 Subject: lists and append, and loop iteration Message-ID: <37E8860B.C024C4F8@radiata.com> this might be a newbie a question, but is there a reason why append doesn't create a list if the list doesn't exist? it seems to add a bit of complexity to have to do something like: dict = {} if 'new_key' not in dict.keys(): dict['new_key'] = [new_value] else: dict['new_key'].append(new_value) it seems like i should just be able to say "list.append(new_value)" and if list doesn't exist, i get "list[0] = [new_value] am i missing something fundamental that this would completely break? and while i'm bending your ear, let me ask a second question. if i do: for element in list: do something with element is there any to find out what my current index is? i've basically been doing something like: list.index(element) this happens to work fine for what i'm doing now, but only because i don't care about doubles in the list, but should that ever be a problem, how will i know which element i'm dealing with. i figure i can always do: for i in range(len(list)): do something with list[i] but it just feels like i should be able to things the other way as well. thoughts? thanks in advance. --mk From culliton at clark.net Wed Sep 1 09:51:40 1999 From: culliton at clark.net (Tom Culliton) Date: Wed, 01 Sep 1999 13:51:40 GMT Subject: Pythom in embedded system? References: <37ccfed3.3577714@news.omnilink.de> Message-ID: In article <37ccfed3.3577714 at news.omnilink.de>, Stefan Franke wrote: >On 1 Sep 1999 07:09:28 GMT, vnesek at maja.zesoi.fer.hr (Vjekoslav NESEK) wrote: > >>Anyway if not python, can you point me to some other free >>interpeter suitable for embedding in such a limited system? Forth is a common choice in embedded environments which require a small footprint and good speed, but while the concepts are elegant the reality is icky IMO. TCL also has a very small footprint but is much slower and thinks everything is string. You may also want to look at slang which has a forth like core and a more procedural syntax above that, any of several tiny lisp/scheme interepters if you can handle the parenthesis, an LPC derivative called Pike which looks promising but doesn't say much about embedding, ... >Have a look at Lua: > http://www.tecgraf.puc-rio.br/lua/ > >Stefan Lua seems to be small enough and designed to be embedded... From jnc at ecs.soton.ac.uk Wed Sep 29 06:00:11 1999 From: jnc at ecs.soton.ac.uk (John Carter) Date: Wed, 29 Sep 1999 10:00:11 GMT Subject: ImageTk.PhotoImage vs. Tkinter.PhotoImage References: Message-ID: <37f1e251.6515442@news.ecs.soton.ac.uk> On Mon, 27 Sep 1999 21:42:15 GMT, Les Schaffer wrote: >i need to zoom in on a user specified subset of an image. > >but i am confussed about ImageTk.PhotoImage and >Tkinter.PhotoImage. the former creates an instance of the latter in >its self.__photo, used for pasting. but i need access to >Tkinter.Photoimage's copy and zoom commands. i dont understand why >ImageTk.PhotoImage doesnt just extend Tkinter.PhotoImage so the copy >and zoom methods are available, or delegate those calls to __photo >methods. > >also, i notice that in Tkinter.PhotoImage the -from and -to keywords >for the image copy methods are not explicitly defined. wonder why.... > >this is my first real foray into using tkinter/PIL for some astro >work, so please excuse if my questions are stupid. > > >so, with code like this: > > ... > self.photo = ImageTk.PhotoImage(image) > self.canvas.create_image(0, 0, image=self.photo, anchor=NW) > ... > >i want to create a new PhotoImage consisting of a zoom in on a subset >of self.photo (i have the x,y coords of the desired zoom area in >self.photo). I've simply used the crop method, so I would do something like image1 = image,crop((x1,y1,x2,y2)) self.photo = ImageTk.PhotoImage(image1) self.canvas.create_image(0, 0, image=self.photo, anchor=NW) Do all the image manipulation before I create an instance of Image.TK. This worked well, except when I called a C extension, there was clearly something I dodnt usnder stand about PIL's internal data structures, as my C code accted on the whole origional image. This was easily solved by using a copy after the crop. John Carter jnc at ecs.soton.ac.uk > >-- >____ Les Schaffer ___| --->> Engineering R&D <<--- >Theoretical & Applied Mechanics | Designspring, Inc. >Center for Radiophysics & Space Research | http://www.designspring.com/ >Cornell Univ. schaffer at tam.cornell.edu | les at designspring.com From paul at prescod.net Sat Sep 4 19:11:03 1999 From: paul at prescod.net (Paul Prescod) Date: Sat, 4 Sep 1999 23:11:03 GMT Subject: Turing Compliant? References: <37CD7CBC.54AD295F@megsinet.net> Message-ID: <37D1A707.6CFD5159@prescod.net> C.Laurence Gonsalves wrote: > > Actually, there are programming languages that are not Turing complete. I claim that Turing completeness is the only useful (or at least quasi-useful) definition of programming language that we have. If we accept that a programming language could be non-complete then how do we fend off the Barbarians that call HTML a programming language? Paul Prescod From gduzan at gte.com Fri Sep 3 15:20:54 1999 From: gduzan at gte.com (Gary Duzan) Date: Fri, 03 Sep 1999 15:20:54 -0400 Subject: Problems with threads References: <936212879.1129421157@news.nikoma.de> <7qkh06$r2$1@towncrier.cc.monash.edu.au> Message-ID: <37D01F96.DB020567@gte.com> Jonathan Giddy wrote: > > Dominic Hillenbrand writes: > >This code produces this type of error message: > > >currentThread(): no current thread for 1025 > >currentThread(): no current thread for 2050 > >(.....) > > >The program still seems to run correct!!! > >But what is the reason for the error message? > > It is an interaction between the builtin thread module and the threading > module. If you start your threads using the threading.Thread class, the > message will not appear. > > Essentially, this is a warning from threading.py that there is no Thread > instance representing this thread. However, depending on your code, this may be a perfectly valid state, and threading handles it reasonably well, but there is no way to turn off the message short of editing threading.py, which we did here. This should really be fixed in a future release. Gary Duzan GTE Laboratories From tim_one at email.msn.com Mon Sep 13 20:55:15 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 13 Sep 1999 20:55:15 -0400 Subject: error in module re? In-Reply-To: <937225378.3989@mhs0096x.mchh.siemens.de> Message-ID: <000501befe4b$cef02700$54a2143f@tim> [Chris...] > Is this an implementation or documentation error? Neither. > >>> import re > >>> re.sub('(a+)\s(b+)', '\2-\1', 'aaa bbb') > '\002-\001' > instead of > 'bbb-aaa' > The documentation says, that you can use backreferences in replacement > string, but only \g works. Read the cautions about using regular strings with regexps, then get in the habit of using r-strings. This does what you want: >>> re.sub(r'(a+)\s(b+)', r'\2-\1', 'aaa bbb') 'bbb-aaa' >>> assuming-anybody-could-want-that-ly y'rs - tim From pinard at iro.umontreal.ca Thu Sep 2 09:49:30 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 02 Sep 1999 09:49:30 -0400 Subject: Turing Compliant? In-Reply-To: Stephan Houben's message of "02 Sep 1999 10:05:38 +0200" References: <37CD7CBC.54AD295F@megsinet.net> Message-ID: Stephan Houben writes: > [...] it was a lame joke, and it confused people. I might have missed the original message, maybe sent before I came in. OK, I'll try to read any more article on this topic as extensions of the original joke, which begins to be a real, heavy good one :-). > # Lambda calculus interpreter in Python. Thanks. Who knows, I'll play with it one of these days! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From tre17 at student.canterbury.ac.nz Thu Sep 9 02:47:24 1999 From: tre17 at student.canterbury.ac.nz (tre17 at student.canterbury.ac.nz) Date: 09 Sep 1999 18:47:24 +1200 Subject: tkinter: identifying callback button? References: <7r7anm$21a7$1@hub.org> Message-ID: Doug at news.vex.net (Lewis) writes: > I have a bunch of (named) buttons which call the same callback. > I've been trying to figure out how (or if) I can get the callback > function to be able to identify which one. > > For example.... > > for x in range(0,5): > b = Button(frame,text='#%s' % x,command=self.xxx, name='b%s' % x) > b.pack() > > So one of the five buttons gets pressed and calls App.xxx(self) ... > but can App.xxx figure out which button triggered the command? > > I could save the button references in a list, but don't know if that > would help. The easiest way of doing this is the create a new class that inherits from `Button'. ============================== class MyButton(Button): def __init__(self, name, *args, **kw): self.name = name apply(Button.__init__, (self,)+args, kw) self.configure(command=self.clicked) def clicked(self): some_command(self.name) ============================== -- Tim Evans From hannah at schlund.de Mon Sep 13 09:32:47 1999 From: hannah at schlund.de (Hannah Schroeter) Date: 13 Sep 1999 13:32:47 GMT Subject: List Comprehensions Enhancement References: <37D9E932.66F2B0D3@cosc.canterbury.ac.nz> Message-ID: <7riudv$24g$1@c3po.schlund.de> Hello! In article <37D9E932.66F2B0D3 at cosc.canterbury.ac.nz>, Greg Ewing wrote: >[...] >print [3 * x for x in nums] >print [x for x in nums if x > 2] >print [(i, s) for i in nums for s in strs] >print [(i, s) for i in nums for s in [f for f in strs if "n" in f]] The syntax looks a bit verbose, compared to e.g. Haskell's list comprehension syntax which looks quite similar to the mathematical set comprehensions: print [3 * x | x <- nums] print [x | x <- nums, x > 2] print [(i,s) | i <- nums, s <- strs] print [(i,s) | i <- nums, s <- [f | f <- strs, 'n' `elem` f]] Also, I think there should be a clear separator between the generators/predicates in your syntax too: print [(i,s) for i in nums, for s in strs] or similar. Nice thing, though :-) Regards, Hannah. From donn at u.washington.edu Thu Sep 23 14:11:03 1999 From: donn at u.washington.edu (Donn Cave) Date: 23 Sep 1999 18:11:03 GMT Subject: SIGCHLD, fork, listen References: <7sd6q4$gqq$1@salome.rfa.org> Message-ID: <7sdqfn$m0o$1@nntp6.u.washington.edu> Quoth bill : | I'm trying to set up a fairly "simple" | server that listens for a socket connection, | forks off a process and goes back to listening. | This works fine for multiple clients, except | I get zombies. I try redefining SIGCHLD as | SIG_IGN, but this doesn't work (as apparently | is what's expected under POSIX). I then | try redefining it with my own function that | includes a WAIT. Fine, except "listen" | doesn't get signalled when the child process | dies, only when the next socket connection | occurs. (which could be hours later, not | good). This sounds like your platform "restarts" the accept() system call after an interrupt. That's kind of a feature for C programmers, because otherwise they have to check for EINTR after this kind of system call and restart it themselves. Python programmers do too, for that matter, but your Python signal handlers don't execute in a kind of parallel Python thread, they wait for the next chance at the interpreter. That chance is going to come when the EINTR hit - unless the system call restarts on its own. I don't like SIGCHLD in C programs, and it's even less useful in Python. In your shoes, I would probably just run waitpid() when the opportunity arises in the accept/fork loop, and live with the occasional zombie processes. If you can't stand them, you can get rid of them with a double fork(). The forked child immediately forks again while its parent calls waitpid(). The first forked process exits, and the parent's waitpid() returns, right away. That leaves an orphaned process whose parent reverts to 1 ("init"). In C, on at least some UNIX platforms that support X/Open standard signal operations, you can use sigaction(2) with SIGCHLD and a SA_NOCLDWAIT flag to just dispense with the zombie system. Haven't actually used this myself, and I don't know how widely it's supported. It's not an option in the standard Python signal module. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From cjc26 at nospam.cornell.edu Sat Sep 11 12:50:04 1999 From: cjc26 at nospam.cornell.edu (Cliff, or a close facsimile) Date: 11 Sep 1999 16:50:04 GMT Subject: Python-based IRC bots..and a #python channel References: <37D879A1.EE4D10DE@op.net> Message-ID: Pada Fri, 10 Sep 1999 03:24:05 GMT, Eron bilang: | Hello. I'm looking to really get into python hacking, and I want to | write a IRC bot in it. Does anyone know of any already existing IRC | libraries and bots (well-documented ones, with LOTS of in-line comments | to help me understand), that I can use and extend, and then eventually | use it as a model to build one from scratch. Also, is there an | "official" #python channel somewhere? If there isn't, we should | establish one. Any info would be greatly appreciated. Hmm, I was going to wait to announce this, but... I'm also working on a Python IRC framework, called "Perk"; see for details. I haven't actually written any bots in it yet, but it should be especially suited for doing so; the core of the program is a file containing a list of regular expressions, each with an associated block of Python code. Each line of input from the server is compared to each regex, and when a match is found, the corresponding code is executed. So to make a bot all you would need to do is modify/extend this file to watch for kick messages, commands in privmsg's, etc. The only caveats are, this version is PRE-alpha :), and there's not too much documentation yet. -- cliff crawford http://www.people.cornell.edu/pages/cjc26/ There are more stars in the sky than there are -><- grains of sand on all the beaches of the world. From bthomas at trey-industries.com Sat Sep 11 19:32:20 1999 From: bthomas at trey-industries.com (Ben Thomas) Date: Sat, 11 Sep 1999 19:32:20 -0400 Subject: Python or Java or "X" from me and my little job References: <37DA8D01.3D6616A@trey-industries.com> Message-ID: <37DAE684.FE7A05F7@trey-industries.com> Thanks to you all. Python it is. Using command call to other programs is major coll idea. I did not know python could do that. I wll go forth and "PYTHON" my jobs. Is there a great place to get the availible functions list? I think I need another Python book. I just read Learning Python, Lutz and Ascher, I would like another book or download I could print that would list all the functions I can call. Anyone know one? expect me back soon for tech support :) Ben Ben wrote: > > I am new to Linux. I have Python 1.5.2 up and working. I want to have > Python grab some files, ZIP them, and FTP them offsite. I will let CRON > start the job every night. Since I am just getting to look at Python, I > wanted to ask to make sure I don't pick the wrong tool for the job. > > 1)Am I selelcting a good tool to get light weight sys admin jobs done? > > 2)Should I go with JAVA instead? > > 3)Can Python ZIP files easily? > > thankful for any comments; > Ben From ivnowa at hvision.nl Fri Sep 3 02:37:23 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Fri, 3 Sep 1999 06:37:23 GMT Subject: OH, I'm A Lumberjack And I'm OK... In-Reply-To: <37CF55DC.816F38F5@megsinet.net> References: <37CF55DC.816F38F5@megsinet.net> Message-ID: <199909030637.IAA23513@axil.hvision.nl> On 3 Sep 99, David Oppenheimer wrote: > ... I play with Python all night and I sleep all day... lol > > I received an e-mail message which told me that WIN ZIP sometimes deletes part > of the extension and to try adding ".tar" to the file or placing a "." before > the tar extension if it was missing. This allowed me to extract the files > Robert Kern was recommending, but still the PIL doesn't work. > > Again I will relate some hopefully relevant info in the hope (getting less > hopeful about this all the time) that someone will know what the $%@# is going > on and how to fix it so I can run files from the PIL. > > Computer: Packard Hell P-75 > OS: Windows 98 > Python Version: Python for Windows 1.5.2 with all of the win32all - 125 > extensions > > PATHS (yes, I took the suggestion to place my Python & related files in > pathways that have no spaces) > > Path to Python executable: C:\Python > Path to Tcl executable: C:\Tcl\bin > Path to PIL: C:\Python\PIL > Path to Tkinter: C:\Python\Lib\lib-tk > Path to Painter (a program that I am more than curious to see work, I am almost > obsessed now): C:\Python\scripts\painter.py > > My Traceback (error message): > > >>> Traceback (innermost last): > File "C:\Python\Pythonwin\pywin\framework\scriptutils.py", line 237, in > RunScript > exec codeObject in __main__.__dict__ > File "C:\Python\scripts\painter.py", line 12, in ? > import Image, ImageTk > ImportError: No module named Image > > My Autoexec.bat settings: > > PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\WINDOWS; > set PATH=%PATH%C:\mingw32\bin; > set PATH=%PATH%C:\PYTHON;C:\PYTHON\PIL;C:\TCL\BIN;C:\PYTHON\LIB\LIB-TK; Did you set the PYTHONPATH environment variable? If so, what are its contents? Hans Nowak (ivnowa at hvision.nl) Homepage: http://fly.to/zephyrfalcon "A smile, a song, and a compiler" From rainer2207 at my-deja.com Wed Sep 22 07:53:53 1999 From: rainer2207 at my-deja.com (rainer2207 at my-deja.com) Date: Wed, 22 Sep 1999 11:53:53 GMT Subject: Toplevel window size Message-ID: <7sag0b$3io$1@nnrp1.deja.com> How can I define a maximum toplevel window size? Thanks. Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From davidopp at megsinet.net Thu Sep 9 20:37:44 1999 From: davidopp at megsinet.net (David Oppenheimer) Date: Thu, 09 Sep 1999 20:37:44 -0400 Subject: Newbie needs help References: <37D851C2.DEB53659@hotmail.com> Message-ID: <37D852D7.772D981E@megsinet.net> http://www.python.org/doc/current/ Matt Lauer wrote: > I am very new at this program stuff and i don't have a clue so if there > is someone that can help me email me, (wpvnetx at hotmail.com) From jam at quark.emich.edu Wed Sep 29 18:17:16 1999 From: jam at quark.emich.edu (Jeff) Date: Wed, 29 Sep 1999 18:17:16 -0400 Subject: Article on IBM developerWorks In-Reply-To: References: Message-ID: <19990929181716.B22321@quark.emich.edu> On Wed, Sep 29, 1999 at 05:38:28PM +0200, Henning Schroeder wrote: > Hi! > > Even IBM knows about Python :-) Check out > http://www-4.ibm.com/software/developer/library/python101.html > on their "developerWorks Linux Library". > > Henning I read this article, and it is an even toned comparison between not only the 'other language that starts with "p"', but tcl and java as well. it should be recommended reading for every phb. it is fairly short, and all around is a good article. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From nathan at islanddata.com Wed Sep 29 14:12:04 1999 From: nathan at islanddata.com (Nathan Clegg) Date: Wed, 29 Sep 1999 11:12:04 -0700 (PDT) Subject: keys and values lining up In-Reply-To: <5l905p9a4c.fsf@eric.cnri.reston.va.us> Message-ID: Hmmmm...not sure this worked quite the way you thought it would :) Output below. >>> d = {'key1' : 'val1', 'key2' : 'val2', 'key3' : 'val3'} >>> keys, values = transpose(d.items()) Traceback (innermost last): File "", line 1, in ? ValueError: unpack sequence of wrong size >>> transpose(d.items()) array([[[k, k, k], [v, v, v]], [[e, e, e], [a, a, a]], [[y, y, y], [l, l, l]], [[1, 2, 3], [1, 2, 3]]],'c') >>> It does work when all of the keys and values are numbers, and actually raises an exception with string keys and numeric values. Eek! On 29-Sep-99 Guido van Rossum wrote: >> >>> d = {'key1' : 'val1', 'key2' : 'val2', 'key3' : 'val3'} > Of course, if you have NumPy, there's always > > keys, values = transpose(d.items()) > > which probably beats everything else. > > --Guido van Rossum (home page: http://www.python.org/~guido/) ---------------------------------- Nathan Clegg nathan at islanddata.com From M.Oti at warande.uu.nl Sat Sep 4 15:57:12 1999 From: M.Oti at warande.uu.nl (Martin Oti) Date: Sat, 04 Sep 1999 21:57:12 +0200 Subject: Pirate -> RAD References: <7qno38$6uk$1@news.is.co.za> Message-ID: <37D17998.5CF4@warande.uu.nl> Jacques Oosthuizen wrote: > > Hi All > > I am busy working on a tool I named Pirate ("Python RAD") it has a component > library similar to Delphi and shall in the future work with win32,gtk,qt. It > will have a IDE. > > Before I do to much and work to hard on it, will anyone be interested in > using a > tool like this. Absolutely! I'm new to Python and the more I find out about it, the more I like it. :) One major aspect which I miss is a good RAD GUI-building tool. I use Visual Basic at work, mainly for within-company scripting and automation tasks, and I often need to whip stuff up pretty fast. I've already started to use Python as much as possible and with a RAD GUI-building tool I will be able to ditch VB for good. :) There are some lovely Python GUI toolkits out there, but I'm no expert programmer and I need to whip GUIs up pretty fast. Considering the masses of Visual basic programmers out there, I think a visual RAD GUI-builder/IDE for Python will have a large audience. It would be particularly handy for those (like me ;) who would also like VB-like functionality on Linux. Indeed, considering that KOffice will use Python as it's extension language, Python could then become the scripting-language-for-the-masses on Linux the way VB is on MS Windows. Martin PS: A zillion thanks to Mark Hammond for the PyWin IDE, Robin Dunn for wxPython (which I only just discovered yesterday), and the entire Python community for a great programming/scripting language/tool. :) PS2: I don't know what this would involve, but it would be handy if the GUI-Builder could also interface with (soon to be) existing Python GUI toolkits (like TkInter, wxPython and Parrot). I have no clue how difficult it would be to separate the front-end from the back-end. PS3: Pirate and Parrot. How ironic. ;) Is this a coincidence? ------------ Trying is the first step towards failure. -- Homer Simpson From skip at mojam.com Sun Sep 26 14:44:53 1999 From: skip at mojam.com (Skip Montanaro) Date: Sun, 26 Sep 1999 13:44:53 -0500 (CDT) Subject: re vs. sgmllib (was Re: Moving from Perl to Python) In-Reply-To: <7skbhk$b06@dfw-ixnews16.ix.netcom.com> References: <000601bf07cb$5e1ede20$602d153f@tim> <7skbhk$b06@dfw-ixnews16.ix.netcom.com> Message-ID: <14318.27045.968552.30026@dolphin.mojam.com> Aahz> Tim Peters wrote: >> Regexps are not Python's forte, and all of speed, clarity and >> maintainability will increase in proportion to your zeal in purging >> them. Aahz> That sounds like a Call To Action for rewriting sgmllib to use Aahz> something other than re. Has anyone started any work in this Aahz> area? I think a more profitable direction is to look at the mad scientist's sgmlop extension module: http://www.pythonware.com/madscientist/ It comes with suitably modified versions of the xmllib and sgmllib modules. I'd like to see them incorporated into the Python distribution if possible, depending upon what the XML sig is doing. (They have their own distribution. I'm not sure what's included in it.) Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From fleck at informatik.uni-bonn.de Thu Sep 16 17:38:00 1999 From: fleck at informatik.uni-bonn.de (Markus Fleck) Date: 16 Sep 1999 21:38:00 GMT Subject: Splitting c.l.py References: <7rr088$74b@dfw-ixnews8.ix.netcom.com> Message-ID: <7rrnvo$p26@news.rhrz.uni-bonn.de> Aahz Maruch wrote: > c.l.py.announce could be better used than it currently is (for example, > the Weekly Python URL doesn't go to c.l.py.announce). I'm currently starting to process a backlog of about 50-60 postings for c.l.py.a; this includes three issues of "Python-URL". So the current lack of "Python-URL" there appears to be entirely my fault... splitting-comp.lang.python.announce-ly, Markus. -- //////////////////////////////////////////////////////////////////////////// Markus B Fleck - University of Bonn - CS Department IV - WHOIS MF5079 UNIX Administrator - comp.lang.python.announce Moderator \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ From gherman at darwin.in-berlin.de Thu Sep 30 11:41:56 1999 From: gherman at darwin.in-berlin.de (Dinu C. Gherman) Date: Thu, 30 Sep 1999 17:41:56 +0200 Subject: lzw.py Message-ID: <37F384C4.9486B017@darwin.in-berlin.de> Hi, I had some fun writing Python functions to encode and decode data using a variant of the Lempel-Ziv coding algorithm family, namely LZW, Lempel-Ziv-Welch. This is something like a "taboo algorithm" if I understand the weird logic of companies and their mind-boggling interpretation of intellectual property rights. To me this sounds like saying some of Newton's algorithms were illegal to use without paying for it. In any case I don't want to mess with Unisys and let them im- pose their view of the world on me, but I also don't want to end, somewhat early, in "what-happens-to-be-just-a-regular" car accident... So, is there a way to make my rather limited brain understand, what I and you can do with such a code without going to all patent offices and legal departments of companies? Am I, my- self, allowed to use it? Is there a difference between using the coding and decoding part? Can I pass anything of this to somebody else? Is it illegal to send it, receive it, read it, download it, use it? -- All of it? Of course, there is zlib, but who says there won't be another deep-pocket company popping up tomorrow just to say they have invented this "before" already? Regards, Dinu -- Dinu C. Gherman ................................................................ "An average of more than 15 % of adults in 12 industrialized countries are functionally illiterate; in Ireland, the United Kingdom and the United States, the rates are over 20 %." (The State of the World's Children 1999, UNICEF, http://www.unicef.org/sowc99) From boud at rempt.xs4all.nl Thu Sep 30 09:25:14 1999 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 30 Sep 1999 13:25:14 GMT Subject: DP-Api 2 and autoincrement Message-ID: <7svobq$ef$1@essle.valdyas.org> I'm trying to build a sort of object framework for a database application, using the db-api II specification. It's a bit like: db-api | thin connection object (dbObj) | SQL abstraction layer (dbSQL) | record object (dbRecord) | table object (dbTable) I also have a set of objects that define the tables, records and relations, like a repository, so in theory the sql layer could generate all necessary sql for inserting, updating, selecting, deleting and working with child tables and so on. Now, most databases have some sort of sequence generator or autoincrement datatypes, especially for surrogate keys. When my SQL layer inserts a record, one field is left blank, and the database fills the number in. I'd like to have the SQL layer return that number, so it can be entered in the dbRecord object. Is there a way to get that number back from the database using db-api II? I'd really hate to build a sequence generator myself, or to try and find the number using selects before or after inserts. -- Boudewijn Rempt | http://ww From mal at lemburg.com Fri Sep 3 07:56:40 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 03 Sep 1999 13:56:40 +0200 Subject: How to pass options to an extension References: <37CE7CB0.979ADF87@onera.fr> Message-ID: <37CFB778.4EC31926@lemburg.com> Marc POINOT wrote: > > Our extension module has a getopt()-like class (C++). > It is used to drive some of the toolkit options. How can > I pass my option through the python interpreter without > making it stop on my -- ? Could you be a bit more verbose about what exactly you want ? Perhaps you are looking for PySys_SetArgv (int argc, char **argv) ? -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 123 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From fredrik at pythonware.com Mon Sep 6 10:40:00 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 6 Sep 1999 14:40:00 GMT Subject: Python speed and `pcre' References: <000301bef83b$9d7fa620$da2d153f@tim> <7r0ivu$95j@dfw-ixnews21.ix.netcom.com> Message-ID: <002301bef875$b3b18410$f29b12c2@secret.pythonware.com> Aahz Maruch wrote: > >The design issues are more complicated than that, alas. Here's one you > >weren't thinking of : for easy chatting with C, under the covers a > >Python string is always terminated with a null byte. You can't see that > >from Python code (it's not counted in the string length, and you can't index > >to it), but your C code can rely on it. > > Hmmm.... From what I've seen, Python strings work perfectly well with > null bytes in the middle. Are there any circumstances under which that > does not hold true? from Include/stringobject.h: Type PyStringObject represents a character string. An extra zero byte is reserved at the end to ensure it is zero-terminated, but a size is present so strings with null bytes in them can be represented. in other words, any Python string can be passed directly to any C function that expects a null terminated string, without having to copy it to a separate buffer. From damien_morton at my-deja.com Wed Sep 15 19:20:28 1999 From: damien_morton at my-deja.com (damien_morton at my-deja.com) Date: Wed, 15 Sep 1999 23:20:28 GMT Subject: mxODBC and NT services Message-ID: <7rp9jg$7sh$1@nnrp1.deja.com> hi people, Im about to embark on something on an adventure in Python programming - the creation of an SMTP server that uses a database to store incoming and outgoing emails. All of the SMTP severs I have examined store incoming and outgoing emails as files in spool directories. For extremely large numbers of emails (50k+), this will bring an OS to its knees. A database, on the other hand, will cope just fine (at least, thats my theory). Before I embarked on this project, I thought Id post a note to see if anyone had any comments, suggestions, or warnings about the use of the mxODBC drivers, and about my project in general. I intend using the mxODBC drivers in a fairly heavily multithreaded environment under Windows NT - i.e. in an NT service. Most of the outgoing emails will be generated on demand as lists are processed, so, in truth, there wont be massive volumes of data being transferred over ODBC. This thing will have to be pretty damned reliable though. I have read that ODBC has certain limitations when running as an NT service of with threads. Do anyone think this will be a problem at all? Does anyone have any experince with this that they might share? Ive listed the relevant MS KB artiles below. Ive read them and think that the problems is probably much more minor than I imagine. Limitations of DAO, DAO SDK in NT Service or with Threads http://support.microsoft.com/support/kb/articles/Q156/1/38.asp Running ODBC Applications as Windows NT Services http://support.microsoft.com/support/kb/articles/Q136/4/81.ASP Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From bill at hk.rfa.org Thu Sep 30 07:08:39 1999 From: bill at hk.rfa.org (Bill Eldridge) Date: Thu, 30 Sep 1999 19:08:39 +0800 Subject: Help - Timezone conversion problem Message-ID: <37F344B7.3663458F@hk.rfa.org> I had a Python script running on a Washington machine to convert Eastern time to Hong Kong time. No problem - convert local Eastern time to UTC and add 8 hours (no Daylight Savings Time in Asia). Now I'm trying to do something similar in Hong Kong to convert Eastern time to Hong Kong, but I can't seem to find an easy way to do this, since the machines have TZ=CST (Hong Kong time) and there's no obvious (to me) way to temporarily make the script pretend it's in Eastern time to figure out if it's EDT or EST. (even if I set time.altzone time.timezone and time.tz, the time module looks to use the system values for these - i.e. the variables reflect the system but aren't used for calculations). So, basically, I have a timestamp 1999-10-01-1030 Eastern time and need to figure out if it's daylight (+1) or standard (+0) and then add the offset of +13. I could hardcode this to work for a few years, but that's not very elegant. Ideas? Thanks, Bill -- Bill Eldridge Radio Free Asia bill at hk.rfa.org From aaron_watters at my-deja.com Mon Sep 13 09:25:51 1999 From: aaron_watters at my-deja.com (aaron_watters at my-deja.com) Date: Mon, 13 Sep 1999 13:25:51 GMT Subject: Announcing: A Python Curses-Based Telnet Client References: <37DCDC05.8E25CCBE@sdm.de> Message-ID: <7riu0h$jdf$1@nnrp1.deja.com> In article <37DCDC05.8E25CCBE at sdm.de>, Peter Stoehr wrote: > Hi Moshe, > > it would be great if you can send me a copy of your "Python Cursed- Based > Telnet Client".... Yes, sounds interesting. Also, fwiw, there are many free sites where you can put files, I think. I think geocities is one of them, also yahoo, lycos, egroups... --Aaron Watters === Call the Dr. I think I'm gonna crash The doctor says he's coming but you gotta pay him cash Life in the fast lane Everything. All the time. Life in the fast lane Uh huh Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From emile at fenx.com Wed Sep 8 10:21:39 1999 From: emile at fenx.com (Emile van Sebille) Date: Wed, 8 Sep 1999 07:21:39 -0700 Subject: Python interface to Groupwise mailoxes? References: <37D5B211.E9C7C9F3@nightwares.com> Message-ID: <37d64753@news-server.direcpc.com> When I checked into delivering content through to a GroupWise mailbox, I found out the easiest way was to bounce it off the net through the user at company.com internet mail address. -- Emile van Sebille emile at fenx.com ------------------- Warren 'The Howdy Man' Ockrassa wrote in message news:37D5B211.E9C7C9F3 at nightwares.com... > "S. Blakey" wrote: > > > Even some good documentation of Novell's proprietary crap would > > appreciated. > > That's the problem. Novell's way of doing things is, well, Novell's. > I've tried to hack into my GroupWise box at work using non-Novell tools, > in non-MS IDEs, and had nothing but grief. > > However note that Novell *does* market a POP server which *in theory* > makes their G'Wise mailboxen available to any POP3 client. It's spendy > -- about US$1300 for a 50-seat license as I recall -- but it opens the > gateway, so to speak, and in large companies or companies with many > users on many OSen or many users travelling amortizes well. > > I am still pushing hard at work for that implementation, as the current > scheme is intolerable (G'Wise client hoses NT4's networking, surprise.) > > Don't know if they have a gateway for SMTP for sending stuff. Sigh. > Their site used to have lots of info like that available, but recently > they seem to have buried the relevant docs under a lot of noise, so it's > darn near impossible to find even the POP server, which in fact they > released under the aegis of being something like "Netscape mail server > for Novell", when you search their site. I found the POP server before > AOL sucked up Mozilla though, and that might be a factor too. > > Short answer: If anyone has figured out Novell's server scheme for mail > I'd sure love to know about it, but I fear it has not been done yet. (Or > did I see a Red Hat install go by a while back which included a G'Wise > client?) > > -- > warren ockrassa | nightwares | mailto:warren at nightwares.com > http://www.nightwares.com/ From wtanksle at dolphin.openprojects.net Thu Sep 2 22:38:49 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Fri, 03 Sep 1999 02:38:49 GMT Subject: language interpreters/ interpreted languages weaknesses? References: <7qi3q3$n1d$1@nnrp1.deja.com> Message-ID: On Wed, 01 Sep 1999 02:42:13 GMT, Mr Kelvin Lee wrote: >Hi, >The main weakness I hear about language interpreters/ interpreted >languages (btw.. is that the same thing?) is that they are slow(?).. You'll need to define your criterion for 'slow'. That sounds Clintonian, but it's true -- different projects have different needs. For heavy numeric work, Python might wind up being the fastest language available to you because of NumPy (although I can't imagine the circumstances). The usual meaning of "slow" is that they do common tasks, such as function calls, much more slowly than the machine could do them. Python certainly has that particular weakness. For the rest of your post, I'm going to assume that when you say "interpreted" you mean "dynamic". >is this because of the way they handle (data) variables? No, there are many reasons -- the main one is that they have so much more to do at runtime. This makes things you do naturally in a static language slow -- but it makes many more things _possible_, where before they would have taken a LONG time to develop and be very buggy. >Are there any other major weaknesses of interpreted languages over >conventional languages such as C, C++, Ada etc.? Yes, and vice versa. Dynamic languages are capable of much less compiler optimization, so they're slower. They're also capable of doing much more useful work per word of code, so they wind up doing the job faster. >What are the most popular interpreted languages around? Perl, Python, Common Lisp, CAML, Forth... >Thanks, > >-- >Regards, > >KL. > > >Sent via Deja.com http://www.deja.com/ >Share what you know. Learn what you don't. -- -William "Billy" Tanksley From 101.139915 at germanynet.de Tue Sep 7 11:43:16 1999 From: 101.139915 at germanynet.de (Stefan Knappmann) Date: 7 Sep 1999 15:43:16 GMT Subject: How to get the python sourcecode line, when debuging the Python C sources? Message-ID: <7r3bqk$hbv$1@newshost.germany.net> Hi, I extended Python with a self written C Module. Unluckily my program crashes with a segmentation fault. I recompiled Python with debugger information and reprodced the error. In the C debugger I can see that the program is in an initialisation function of a datastructure in my C module. So far so good, but this initialisation function is only called at the start of the python script and the crash commes aproximately after two hours of running. I would like to know in which line of python code is the program, when it calls my function. Does anybody know in which C variable I can find the Python Stack? Or how to get the activ Python source code line from within the C debugger? Thanks in advance Stefan From I.Clarke at strs.co.uk Wed Sep 22 10:44:31 1999 From: I.Clarke at strs.co.uk (Ian Clarke) Date: Wed, 22 Sep 1999 15:44:31 +0100 Subject: Matching templates against a tree - any ideas? References: <37E7A272.51E5C4E1@strs.co.uk> <37E7F8C0.AC421C83@maxtal.com.au> Message-ID: <37E8EB4F.BC42825E@strs.co.uk> > you have a template and you want to match them against EVERY subtree > of a given tree, efficiently. Correct, but there will be multiple trees and multiple templates (I mention this just in case some preprocessing or building of lookup tables might be useful). > Question: what happens if there is more than one overlapping match? One of the possibilities is selected and returned as a match - it doesn't matter [at this stage] which one [although that may change in the future]. [...snip interesting parser idea...] I would rather implement a solution from scratch instead of attempting to reformulate the problem into that of parsing something. Do you think that you could provide an explanation of what one of the parsers you describe would do - but in terms of the problem I described, rather than in terms of parsing. Cheers, Ian. -- "Don't throw your PC out the window, throw Windows out of your PC, and install Linux" Ian Clarke http://www.gnu.demon.co.uk/ From hnowak at cuci.nl Sat Sep 4 04:09:10 1999 From: hnowak at cuci.nl (Hans Nowak) Date: Sat, 4 Sep 1999 08:09:10 GMT Subject: termios disappears during object deletion In-Reply-To: References: Message-ID: <199909040810.KAA18642@dionysus.fw.cuci.nl> On 3 Sep 99, at 22:58, Brien Barton wrote: > Can anyone explain this behavior?? For some reason, the termios and > TERMIOS modules get wiped out when python is running the __del__ method > during program termination. I've tried this with Python 1.5.1 on Linux > and with Python 1.5.2 on SGI IRIX. If you explicitly delete the object, > you don't have this problem. > > ~> cat test.py > import math, termios, TERMIOS > > print 'math=', math > print 'termios=', termios > print 'TERMIOS=', TERMIOS > > class Test: > def __del__(self): > print 'deleting Test object ...' > print 'math=', math > print 'termios=', termios > print 'TERMIOS=', TERMIOS > > t = Test() I'm not sure, but I have a vague idea why this happens... an instance of Test is created, then the program is finished. Python starts cleaning up some stuff, freeing memory, etc. *Maybe* (as said, I don't know this fer shure) it first gets rid of termios and TERMIOS, then it takes on the Test instance t, calling its __del__ method. This method then correctly sees that termios and TERMIOS are already deleted. Just an idea... I don't know much about Python's internals, but it would make sense to me... --Hans Nowak (zephyrfalcon at hvision.nl) Homepage: http://fly.to/zephyrfalcon Python Snippets: http://www.hvision.nl/~ivnowa/snippets/ The Purple Kookaburra Forum: http://www.delphi.com/kookaburra/ From nathan at islanddata.com Wed Sep 1 16:23:50 1999 From: nathan at islanddata.com (Nathan Clegg) Date: Wed, 01 Sep 1999 13:23:50 -0700 (PDT) Subject: Queue class deadlocking application In-Reply-To: <1275908198-63413490@hypernet.com> Message-ID: On 01-Sep-99 Gordon McMillan wrote: > How do you know the queue size if you only ever use put_nowait and > get_nowait ? Okay, okay...I do a qsize() now and then, but the code is not dependent on it, nor do I ever use a blocking get or put. I've also found that the problem is totally non-existent if I remove the consumer or decrease the number of producers to one. I should try two to see if that's safe or not... Thanks for putting some time into it, though. It's quite important that this application run robustly enough to be left unmonitored. The worst part of this is that I can't even check for it, as it seems to freeze up all the threads...I'm going to also enter a new thread that does nothing with the queue but check its size and see if it survives. ---------------------------------- Nathan Clegg nathan at islanddata.com From nathan at islanddata.com Sat Sep 11 23:26:23 1999 From: nathan at islanddata.com (nathan at islanddata.com) Date: Sat, 11 Sep 1999 20:26:23 -0700 (PDT) Subject: Queue not releasing memory Message-ID: <19990912032623.13533.qmail@islanddata.com> After filling a Queue class instance with large amounts of data, the memory footprint of python grows dramatically. I would expect, then, that this footprint would decrease in size when the queue is emptied, but it does not. The memory use drops instantly when the empty queue is delete, however. I've examined the Queue.py code and cannot see where this data may be cached, etc. Executing: sys.getrefcount(q.queue[0]) for example, yields 2: the temporary reference and a single one for the queue entry. It stands to reason that after get'ing an item from the queue that it should be lost forever. Test program: q = Queue.Queue(20000) for x in string.uppercase: for y in string.uppercase: for z in string.uppercase: m = (x + y + z) * 1024 q.put(m) for x in string.uppercase: for y in string.uppercase: for z in string.uppercase: q.get() The memory taken up by this program does not decrease until q is deleted. Can anyone tell me why this happens and how I can fix it *without* deleting the queue and creating a new one? Thanks... From jussij at zeusedit.com Tue Sep 7 18:27:55 1999 From: jussij at zeusedit.com (Jussi Jumppanen) Date: Wed, 08 Sep 1999 08:27:55 +1000 Subject: Programmers Editor Message-ID: <37D5916B.606E@zeusedit.com> Zeus for Windows Version 3.00 Now Released ------------------------------------------ The Zeus for Windows programmer's editor has been totally re-developed and the results of this full re-write are now ready for use. The Programmer's is designed to run on the Windows 95, Windows 98 or NT platforms. So what is new: 1) New syntax highlighting engine should now support almost any language. 2) Comes with pre-configured syntax highlighting for: C/C++, Java, Perl, HTML, Python, Pascal and is easily to almost any other language. 3) New plugable scripting modules allows you to write Zeus macro scripts using the Python, LUA or Small C macro languages. 4) New configuration model now makes it even easier for you to configure Zeus to do just what you want. 5) Enhanced compiler, project and tool support. 6) Improved keyboard mapping. You can download the shareware version from: http://www.zeusedit.com/z300/download.htm For some screen shots of Zeus in action goto: http://www.zeusedit.com/z300/look.htm For more details visit the Zeus web page: http://www.zeusedit.com Jussi Jumppanen Author of: Zeus for Windows, Win32 (Brief, WordStar, Emacs) Text Editor "The C/C++, Java, HTML, Pascal, Cobol, Fortran programmers text editor" http://www.zeusedit.com From valb at vtek.com Thu Sep 23 20:04:56 1999 From: valb at vtek.com (Val Bykoski) Date: Thu, 23 Sep 1999 20:04:56 -0400 Subject: PST - Python Sound Tool Message-ID: <7sefdn$8au$1@winter.news.rcn.net> Hello,dear Pythoneers: I was playing with PST-0.1, trying to play any wav file. No luck. And for now there is no sample,or usage doc. Any help would be great. Thanx. val Val Bykoski valb at vtek.com From mlh at idt.ntnu.no Sun Sep 5 13:15:45 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 05 Sep 1999 19:15:45 +0200 Subject: cgi post References: <37D179CC.2DDFD7A7@netscape.com> Message-ID: vijay Mallela writes: > how do i do something like this in a python cgi script: > > form = cgi.fieldstorage() > if form['foo'] == 'bar': > loadhttp('spam.com') > please let me know if there is a way to do this.. > > Right now, I am opening the file and spam.com and then printing it.. > what if the file is some where else and I would like to direct the user > to that site.. Just print a header like this: Content-type: text/html Location: spam.com The user will then be redirected to spam.com without any problems. (Remember the empty line after spam.com, though... Even if you aren't printing anything else) > > Thanks > v > -- Magnus Making no sound / Yet smouldering with passion Lie The firefly is still sadder / Than the moaning insect Hetland : Minamoto Shigeyuki From gerrit.holl at pobox.com Fri Sep 10 16:59:17 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Fri, 10 Sep 1999 22:59:17 +0200 Subject: [Python-checkins] CVS: python/dist/src/Lib pdb.py In-Reply-To: <199909091632.MAA24868@anthem.cnri.reston.va.us>; from Barry A. Warsaw on Thu, Sep 09, 1999 at 12:32:42PM -0400 References: <199909091632.MAA24868@anthem.cnri.reston.va.us> Message-ID: <19990910225917.A3356@optiplex.palga.uucp> Hello, I have a question because of this email on the python-checkins mailinglist. On Thu, Sep 09, 1999 at 12:32:42PM -0400, Barry A. Warsaw wrote: > Update of /projects/cvsroot/python/dist/src/Lib > In directory anthem:/projects/python/develop/bwarsaw/python/dist/src/Lib > > Modified Files: > pdb.py > Log Message: > Pdb.lineinfo(): Don't use os.popen('egrep ...') to find the line in > the file that a function is defined on. Non-portable to Windows and > JPython. I understand that it isn't portable to Windows, but why isn't it portable to JPython? Doesn't the os.popen function exist in JPython? If so, why not? [cut] regards, Gerrit. -- Unix is easy: type 'man man' and the rest comes of itself. From Elie.Naulleau at westgroup.com Mon Sep 13 16:16:11 1999 From: Elie.Naulleau at westgroup.com (Elie Naulleau) Date: Mon, 13 Sep 1999 15:16:11 -0500 Subject: Perf. Python/Tcl comparison ? Message-ID: <37DD5B8B.9402908F@westgroup.com> I wondering if some specs have been done about comparing Tcl and Python performances, on strings integers and floats for instance. Thks, Elie.Naulleau at westgroup.com From bthomas at trey-industries.com Tue Sep 14 11:48:20 1999 From: bthomas at trey-industries.com (Ben Thomas) Date: Tue, 14 Sep 1999 15:48:20 GMT Subject: python call external program (WHAT THE?!) References: <37DE6156.FD4384C6@trey-industries.com> <37DE68B7.49D0C5A5@mach.uni-karlsruhe.de> <37DE6980.2FC85A6F@trey-industries.com> Message-ID: <37DE6D8B.FD6AC6E0@trey-industries.com> Hey guys the below is true with the addition of system('d:\\data\\vacman\\mybat.bat') = ok Have I found a bug? Do I get a t-shirt? :) Could a py-xpert explain to me my results? Ben Ben Thomas wrote: > I just tried but putting the batch file in three places on a drive. The I tried > them all. > > system('d:\mybat.bat') = ok > system('d:\data\mybat.bat') = ok > system('d:\data\vacman\mybat.bat') = fails, it works fine from DOS prompt! > > what gives? > Ben > > Andreas Cardeneo wrote: > > > Ben Thomas wrote: > > > > > > very simple question: > > > > > > What would I do to have Python execute something from the DOS command > > > line. I am very new to python but I bet it is in a moudule but don't > > > know the command or the modules to look in. I want to > > > > > > dir >%myvar.txt > > > > > > #this code would run dir from the command line and pass the var "myvar" > > > , dir would dump a listing of the files into a text file called xxxx.txt > > > > > > pointers? > > > > > > Ben > > > > Hi Ben, > > > > you should use the system() function from the "os" module. > > > > os.system("dir *.txt") shows all files in the current directory matchin > > *.txt. > > The function returns the exit code. > > > > Bye, > > Andreas > > > > -- > > Andreas Cardeneo Universit?t Karlsruhe (TH) > > Tel: +49 721 608-4576 Institut f?r F?rdertechnik und Logistiksysteme > > Fax: +49 721 75 83 78 Hertzstra?e 16 - 76187 Karlsruhe > > eMail: Andreas.Cardeneo at mach.uni-karlsruhe.de From news at dorb.com Thu Sep 30 22:31:02 1999 From: news at dorb.com (Darrell) Date: Thu, 30 Sep 1999 22:31:02 -0400 Subject: Last question of the day (This one's easy!) References: <877ll88031.fsf@ethereal.dhis.org> Message-ID: Tried your example in C, Java and Python. "C" ~2sec, Java was 1.5min and Python was 4.5 min. This isn't as significant as it sounds though. The algorithm is often the largest impact on performance. Making significant algorithm changes to gain performance is vastly easier in Python. Drop into Java or "C" for that inner loop. Builtins like string.split and string.join are examples of some stuff better done in "C". Notice how much faster "C" is than Java. -- --Darrell From fredrik at pythonware.com Thu Sep 30 07:43:31 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 30 Sep 1999 11:43:31 GMT Subject: !! Non blocking IO !! References: <7st1ra$6vb$1@oceanite.cybercable.fr> <7svfn1$ce2$1@oceanite.cybercable.fr> Message-ID: <001e01bf0b39$06733c40$f29b12c2@secret.pythonware.com> Pierre Saloni wrote: > In fact what I want is an autoflush when I print, i do not want print to > bufferize at all. the easiest way to do this is to use the -u option to the interpreter. this also enables binary stdio where necessary: $ python -? Unknown option: -? usage: python [option] ... [-c cmd | file | -] [arg] ... Options and arguments (and corresponding environment variables): /.../ -u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x) /.../ ... an alternative solution is to use an autoflushing wrapper: class AutoFlush: def __init__(self, stream): self.stream = stream def write(self, text): self.stream.write(text) self.stream.flush() import sys sys.stdout = AutoFlush(sys.stdout) sys.stderr = AutoFlush(sys.stderr) print "hello" ... (maybe the CGI module should contain a helper function that does exactly this?) From amitp at Xenon.Stanford.EDU Tue Sep 28 16:32:29 1999 From: amitp at Xenon.Stanford.EDU (Amit Patel) Date: 28 Sep 1999 20:32:29 GMT Subject: Matching templates against a tree - any idea? References: <000901bf089c$911731c0$032292cb@akha> Message-ID: <7sr8kt$3c8$1@nntp.Stanford.EDU> Jon Fernquest wrote: | Fernando Pereira wrote: | | Thanks for making the posting on term rewriting systems. | | 1. Do you think it's possible to make a rewriting system extension | to an existing language like Python or Perl? | | Everything seems to be in ML and ML extensions such as | Isabelle right now. It's so easy to cook up (or integrate | components into) whole systems in Python | (or Perl) and since so many people use them in their | day to day work modules have a greater chance of being used. ML already has some pattern-matching constructs that can be used to match subtrees. For example, this tree: Mul / \ Add B / \ A 0 can be matched like this: case(tree) of Mul(Add(A,Num(0)), B) => ... do something with A and B ... My guess is that complicated tree matching becomes easier when you have these simpler tree matching constructs built into the language. ObPython: Pattern matching is the one ML thing I miss when I'm in Python.. - Amit From skip at mojam.com Thu Sep 30 10:42:03 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 30 Sep 1999 09:42:03 -0500 (CDT) Subject: When Good Regular Expressions Go Bad In-Reply-To: <000101bf0a47$98084da0$ce2d153f@tim> References: <000101bf0a47$98084da0$ce2d153f@tim> Message-ID: <14323.30395.394477.753318@dolphin.mojam.com> Tim> [Douglas Alan] >> It seems to me that even when a regular expression fails to match a >> string, you might want to know just how far it was able to get before >> getting stuck. Tim> I believe this would be easy to add to any regexp engine I've ever Tim> seen, and also believe I've never seen one that keeps track of it. Tim> I confess I'm at a loss to think of a compelling use for it, Tim> though. Take a look at http://www.musi-cal.com/fast-itineraries.shtml I want to let people set up schedule submissions and give them some help when they format their schedules incorrectly. Currently I use three regular rexpressions per selected format, the one that will match a correctly formatted line and two shorter ones. When the real thing fails I use the shorter ones to try and give the user some idea of where they might have gone astray. Of course, users aren't told that regular expressions underly the pattern matcher. compellingness-is-in-the-eyes-of-the-programmer-ly y'rs, Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From paul at prescod.net Thu Sep 2 14:40:41 1999 From: paul at prescod.net (Paul Prescod) Date: Thu, 2 Sep 1999 18:40:41 GMT Subject: language interpreters/ interpreted languages weaknesses? References: <1275835455-67788915@hypernet.com> <37CE9F55.88DFC9FC@megsinet.net> Message-ID: <37CEC4A9.C2CE2A91@prescod.net> David Oppenheimer wrote: > > I am sure that many of you can > relate to having run into a page where a Java applet is loading and been quite > irritated that while this Java code is loading (being interpreted or the JVM > is firing up or whatever) that your browser (and your cursor too) will lock-up > until the applet is ready to run. There are by now dozens of impementations of Java and your complaint is with a single one (or maybe two, if you have had the same problem with Internet Explorer and Netscape). Seriously this has nothing to do with Java *the language*. A bad implementation of Python could do the same thing. Paul Prescod From brianr at dnr.state.ak.us Thu Sep 9 17:16:41 1999 From: brianr at dnr.state.ak.us (Brian Raynes) Date: Thu, 09 Sep 1999 13:16:41 -0800 Subject: question about the safety of os.popen() Message-ID: <37D823B9.9D4337EE@dnr.state.ak.us> I'm writing a simple module that, in part, sends an email. >From various examples, I use the following line to start sendmail, then I use the write method of the resulting mail object to send the header and body text, then mail.close(). mail = os.popen("/usr/sbin/sendmail -t", "w") I believe that this method of using os.popen() is relatively safe since it does not pass any user input directly to the shell. All the examples I can find concerning security are written in perl, but this statement seems to differ from the dangerous examples because it does not include any user input on the command line. If I understand what os.popen() is doing, this is opening a pipe directly to sendmail, so that stuff sent via the .write() method does not go to the shell, but to sendmail. It is my understanding that this is safer - most warnings about CGI security warn against allowing user input to be sent to the shell. Am I doing the safe thing in regards to not sending input to the shell? Is there a better way to accomplish this? I realize there are also security concerns with stuff sent to sendmail, but the information on what to look for there is more available and more appropriate in a sendmail discussion than a Python one. I'm still pretty new, but I've gone through the vast majority of "Learning Python" and have read about popen() in the Library Reference. I don't know C, or else I would look and understand exactly what's happening from the source code. Brian Raynes From watterss at pilot.msu.edu Wed Sep 8 22:33:27 1999 From: watterss at pilot.msu.edu (Shannon Watters) Date: Wed, 8 Sep 1999 22:33:27 -0400 Subject: NEWBIE: M. Lutz's Programming Python Message-ID: <7r76hh$cqv$1@msunews.cl.msu.edu> I'm reading Programming Python and I've come across a problem with running one of the examples. In Chapter 9 there is a module to generalize list and dictionary menus using functions. When I test the functions I get an unexpected result (my module looks just like Mr. Lutz's, or I'm just bleary eyed). Here is the module (menu0.py): from string import upper, lower def interactDict(menu): while 1: for name in menu.keys(): print '\t' + name tool = raw_input('?') try: menu[tool]() except KeyError: print 'what? - try again' def interactList(menu): while 1: for name, func in menu: print '\t' + upper(name[0]) + ')' + name[1:] tool = lower(raw_input('?')) for name, func in menu: if tool == name[0] or tool == name: exitflag = func() break else: print 'what? - try again' continue if exitflag: break def interact(menu): try: if type(menu) == type([]): interactList(menu) elif type(menu) == type({}): interactDict(menu) else: print "bad menu: must be a list or dictionary" except EOFError: pass ------------------------------------------------------------- We (me and Mr. Lutz :-) use another module of simple menus to test the above module(testmenu.py): from sys import stdout, exit dmenu = {'spam' : lambda:stdout.write('SPAM\n'), 'stop' : exit } lmenu = [('eggs', lambda:stdout.write('EGGS\n')), ('stop', lambda:1)] ----------------------------------------------------------------------- When I go to test menu0 in the interaction window I get this: >>> from testmenu import * >>> from menu0 import interact >>> interact(lmenu) E)ggs S)top ?E EGGS E)ggs S)top ?S what? - try again >>> interact(dmenu) spam stop ?spam SPAM spam stop ?stop Traceback (innermost last): File "", line 1, in ? interact(dmenu) File "menu0.py", line 34, in interact interactDict(menu) File "menu0.py", line 11, in interactDict menu[tool]() SystemExit: >>> What I don't understand is why it prints 'what? - try again' since my raw-input was a valid choice. I'm not exactly sure why I get the traceback when I stop using dmenu either. I would appreciate any reply and I hope that the answer isn't one that makes me say 'damn, I should have seen that!'. Thanks, Shannon From skip at mojam.com Thu Sep 16 13:03:18 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 16 Sep 1999 12:03:18 -0500 (CDT) Subject: Marking translatable strings In-Reply-To: <14305.3887.816696.344596@dolphin.mojam.com> References: <14305.3887.816696.344596@dolphin.mojam.com> Message-ID: <14305.8918.763630.110275@dolphin.mojam.com> Skip> 2. Could a loadable module be defined that would put Python into Skip> "translate" mode, thus forcing all raw strings in the code to Skip> be mapped into translatable strings at runtime (whose semantics Skip> would then be definable as appropriate). Ack! Should have been "... thus forcing all string literals in the code..." S From gmcm at hypernet.com Sat Sep 11 14:25:24 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 11 Sep 1999 14:25:24 -0400 Subject: yacc/lex for Python In-Reply-To: <37DA861F.57212BC3@atl.mediaone.net> Message-ID: <1275048324-10459585@hypernet.com> Kristopher Johnson asks: > Are there any lex- or yacc-like tools available for Python? See: http://starship.python.net/crew/amk/python/string.html (towards the bottom of the page) for a (probably out of date) list of various parsing packages. - Gordon From mal at lemburg.com Mon Sep 27 17:24:52 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Mon, 27 Sep 1999 23:24:52 +0200 Subject: Bug report : fcntlmodule.so (fonction ioctl) python 1.5.2 References: <37EB7EAE.E2D5A7A@lirmm.fr> Message-ID: <37EFE0A4.639A3218@lemburg.com> David Berthelot wrote: > > Hi, > > i think, i found a bug (and a fix). > > In the "fcntlmodule.so", the "ioctl" function does not work with > an optional int parameter but currently it works only with an > optional string parameter. > > So i think that the line number 76 of fcntlmodule.c : > 76: ret = ioctl(fd, code, arg); > > should be replaced by: > 76: ret = ioctl(fd, code, &arg); > > I think it does it, doesn't it ? > Yes, unlike fcntl, ioctl uses a pointer for its 3rd arg. Not always... it depends on the fd and code. Note that Python 1.5.2 (well at least the CVS version) has code for handling strings *and* integers. The struct module will help you build pointers to integers if needed. If you need a read/write memory area, you can use the new buffer objects for this task. -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 98 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From holger at phoenix-edv.netzservice.de Thu Sep 16 03:43:19 1999 From: holger at phoenix-edv.netzservice.de (Holger Jannsen) Date: Thu, 16 Sep 1999 07:43:19 GMT Subject: timesync with python? References: <37D66AF3.6A3E96F7@phoenix-edv.netzservice.de> <002701befabb$1a884880$f29b12c2@secret.pythonware.com> Message-ID: <37E09F97.F546A143@phoenix-edv.netzservice.de> ...works great, thanx!!!;-))) Ciao, Holger From tim_one at email.msn.com Sat Sep 11 16:29:51 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 11 Sep 1999 16:29:51 -0400 Subject: whrandom.randint(): no LONGs? In-Reply-To: <19990911163530.A11476@optiplex.palga.uucp> Message-ID: <000601befc94$6692ab00$6aa2143f@tim> [Gerrit Holl] > whrandom.randint() always try to convert the given arguments to a > integer. Why? > I'm not able to use Longs now. I don't require it directly, but > it might be a useful thing to know the "why". I can learn from it... It's a good question! The "deep" reason is that the method used by whrandom to create the illusion of randomness has limited precision. Using this method to ask for a random choice from among 2**15 things works pretty well for most purposes; but using it to ask for a random choice from among 2L**150 things would work terribly for many purposes. Creating the illusion of random longs requires a different approach altogether, so rather than give you garbage results Python raises an error. If you get to the point where you need pseudo-random longs, I posted a LongRan.py module about a year ago that can do it. whrandom-knows-its-limitations-so-it's-smarter-than-us-ly y'rs - tim From robert.yodlowski at intel.com Mon Sep 27 16:19:29 1999 From: robert.yodlowski at intel.com (Robert Yodlowski) Date: Mon, 27 Sep 1999 16:19:29 -0400 Subject: Python interface to Spice or other circuit simulator? Message-ID: <37EFD151.39411C5C@intel.com> An HTML attachment was scrubbed... URL: From actgal8 at aol.com Thu Sep 2 18:24:26 1999 From: actgal8 at aol.com (actgal8 at aol.com) Date: Thu, 02 Sep 1999 16:24:26 -0600 Subject: 18 AND OVER 65769 Message-ID: <020999162426@aol.com> free xxx pics: http://207.240.225.250 :Q$$RawN From fredrik at pythonware.com Thu Sep 2 09:54:00 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 2 Sep 1999 13:54:00 GMT Subject: Python speed and `pcre' References: <00af01bef543$0affe8f0$f29b12c2@secret.pythonware.com> Message-ID: <002101bef54a$9c7682b0$f29b12c2@secret.pythonware.com> Fran?ois Pinard wrote: > Yes, of course. Given strings are immutable, an implementation could have: > > ref=str > str=str+str1 > > and have `ref' points to a substring of `str', without copy most of > the time, when `str1' is small. what do you do when you have to reallocate str? From arne at leithe.no Sun Sep 12 16:50:43 1999 From: arne at leithe.no (Arne Leithe) Date: Sun, 12 Sep 1999 20:50:43 GMT Subject: ASP with Python question References: <37d87ed7@news.interq.or.jp> <7rf5ke$3c1$1@m2.c2.telstra-mm.net.au> <37dbdf82.1605161@news.online.no> Message-ID: <37dc0fa6.13931092@news.online.no> On Sun, 12 Sep 1999 17:17:10 GMT, arne at leithe.no (Arne Leithe) wrote: >It does :-) However, this syntax doesn't seem to work with COM-objects; for example: <%@language = Python%> <% fso = Server.CreateObject("Scripting.FileSystemObject") Session.SetValue('Key', fso) %> yields: Python ActiveX Scripting Engine error '80020009' Traceback (innermost last): File "