From bryan at eevolved.com Sat Mar 3 01:31:14 2001 From: bryan at eevolved.com (Bryan Mongeau) Date: Sat, 03 Mar 2001 06:31:14 GMT Subject: Adding a method to an instance References: <6621ato2vknc667m3iuqvmm8vcj0h99qqk@4ax.com> Message-ID: Kirby Urner wrote: Thanks Kirby, > In saying f.__class__, you point back to the superclass foo. > If you want to poke newMethod into object f alone, then you > should just go: > > f = newMethod This I do not want. Maybe I should have been more clear. I would like to add "newMethod" to the instance of class foo so that later I can call: f.newMethod() > > Here's a transcript that addresses your question: > > >>> class foo: > def duh(self): > print "Duh!" Is my question really that bad? :) > > >>> o = foo() > >>> o > <__main__.foo instance at 00B9719C> > >>> k = lambda x: x+2 > >>> k(2) > 4 > >>> o.othermethod = k k is a lambda function. I would need the new method to be able to access internal class attributes, thus require the "self" parameter of class methods. > >>> o.othermethod(3) > 5 > >>> dir(o) > ['othermethod'] > >>> dir(foo) > ['__doc__', '__module__', 'duh'] > >>> o.__class__ > > >>> foo > > >>> o > <__main__.foo instance at 00B9719C> > > Note re the last three commands: o.__class__ is a pointer to > the class foo in memory, so you would be adding to the superclass > to put a method in there. You want to insert your method into > the instance/object, so don't involve its __class__. Okay, based on these statements and referring to my previous example, I should be able to do this: def newMethod(self): print self.bar f.newMethod = newMethod Problem is: f.newMethod() TypeError: not enough arguments; expected 1, got 0 Understandably though, this works in this case: f.newMethod(f) > I bet you get it now. Sorry, I must be really dense or something... :) I don't see how your method can assist me. -- <=====================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. Website: http://www.eevolved.com Public key: http://eevolved.com/bcm.pk <=====================================> "The eternal mystery of the world is its comprehensibility."-- Einstein From ngps at post1.com Wed Mar 14 10:58:42 2001 From: ngps at post1.com (Ng Pheng Siong) Date: Wed, 14 Mar 2001 23:58:42 +0800 Subject: Packages, modules and exceptions In-Reply-To: <20010312163907.A23991@freedom.puma-ag.com>; from stephen_purcell@yahoo.com on Mon, Mar 12, 2001 at 04:39:07PM +0100 References: <98ip5c$397$1@clematis.singnet.com.sg> <20010312163907.A23991@freedom.puma-ag.com> Message-ID: <20010314235842.B2335@madcap.dyndns.org> On Mon, Mar 12, 2001 at 04:39:07PM +0100, Steve Purcell wrote: > I assume you also have a file 'M2Crypto/__init__.py'... Um, yes; missed that out. > > For M2Crypto/SSL/Connection.py to get access to SSLError which is defined > > in M2Crypto/SSL/__init__.py, it (Connection.py) contains the following: > > > > SSLError = > > __import__('M2Crypto.SSL', globals(), locals(), 'SSLError').SSLError > > from M2Crypto.SSL import SSLError > raise SSLError, "there's a problem" Ahh, I wasn't clear enough. Within M2Crypto/SSL/Connection.py, I have "class Connection:..." Then, within M2Crypto/SSL/__init__.py, I have "from Connection import Connection". This is so that clients can say "s = M2Crypto.SSL.Connection()" instead of "s = M2Crypto.SSL.Connection.Connection()". Because of this, I can't just do "from M2Crypto.SSL import SSLError" within Connection.py. __init__.py's "from Connection import Connection" creates a circular reference. What's a nice way to fix this fine mess? ;-) Thanks. Cheers. -- Ng Pheng Siong * http://www.post1.com/home/ngps From mal at lemburg.com Fri Mar 30 18:27:25 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Sat, 31 Mar 2001 01:27:25 +0200 Subject: ANN: eGenix.com mxODBC Database Interface Version 2.0.1 References: <3AC5158B.D34E8F27@lemburg.com> Message-ID: <3AC5165D.B129822A@lemburg.com> ________________________________________________________________________ ANNOUNCING: eGenix.com mxODBC Database Package for Python Version 2.0.1 Full Source Python extensions providing important and useful services for Python programmers. ________________________________________________________________________ WHAT IS IT ?: The eGenix.com mxODBC Database Package for Python is part of the eGenix.com mx Extension Series for Python, a collection of professional quality software tools which enhance Python's usability in many important areas such as ODBC database connectivity, fast text processing, date/time processing and web site programming. ________________________________________________________________________ WHAT'S NEW ? This patch release fixes a few problems which were found by users on Windows platforms: * Execution of SQL commands lead to a hanging Python processes for some users. * Handling of date/time values resulted in exceptions on some Windows configurations. Due to popular demand, I am now also providing precompiled Windows binaries for the older Python 1.5.2 version. Binaries for Python 2.1 will be announced after its final release. ________________________________________________________________________ SPECIAL OFFER theKompany.com has licensed the eGenix.com mx Commercial Package (which includes mxODBC) for inclusion in their brand new Qt-based Python IDE BlackAdder. It allows developing portable GUI-based database applications which run on Windows and Linux platforms without any change to the source code. BlackAdder includes a 1 CPU license for this package at no extra cost, so you may want to check out their great new product. See http://www.lemburg.com/files/python/eGenix-mx-Extensions.html#BlackAdder for details. ________________________________________________________________________ EGENIX.COM MX COMMERCIAL PACKAGE OVERVIEW: mxODBC - Generic ODBC 2.0-3.5 interface for Python mxODBC is an extension package that provides a Python Database API compliant interface to ODBC capable database drivers and managers. In addition to the capabilities provided through the standard DB API it also gives access to a rich set of catalog methods which allow you to scan the database for tables, procedures, etc. Furthermore, it uses the mxDateTime package for date/time value interfacing eliminating most of the problems these types normally introduce (other in/output formats are available too). mxODBC allows you to interface to more than one database from one process, making inter-database interfacing very flexible and reliable. The source version includes a varity of preconfigured setups for many commonly used databases such as MySQL, Oracle, Informix, Solid, SAP DB, Sybase ASA and ASE, DBMaker and many more. The precompiled versions for Windows and Linux include the interfaces to the standard ODBC manager on these platforms to allow for a more easily configurable setup. More details are available at: http://www.lemburg.com/files/python/mxODBC.html ________________________________________________________________________ WHERE CAN I GET IT ? The download archives and instructions for installing the packages can be found at: http://www.lemburg.com/files/python/ Note that in order to use mxODBC you will also need to install the eGenix.com mx BASE package which can be downloaded from the same location. ________________________________________________________________________ WHAT DOES IT COST ? mxODBC comes with a licenses which allows non-commercial use at no charge, but costs a moderate fee for commercial use. Please see http://www.lemburg.com/files/python/eGenix-mx-Extensions.html#mxCOMMERCIAL for details. The package comes with full source code. ________________________________________________________________________ WHERE CAN I GET SUPPORT ? Commercial quality support for these packages is available from eGenix.com Software GmbH. Please see http://www.lemburg.com/files/python/eGenix-mx-Extensions.html#Support for details about the eGenix support offerings. ________________________________________________________________________ REFERENCE:

eGenix.com mxODBC Package - eGenix.com mxODBC Database Interface 2.0.1 with distutils support and precompiled binaries for Windows and Linux. (31-Mar-2001) ________________________________________________________________________ Enjoy, -- Marc-Andre Lemburg ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Pages: http://www.lemburg.com/python/ From alexander.stirzel at daimlerchrysler.com Tue Mar 13 06:47:58 2001 From: alexander.stirzel at daimlerchrysler.com (Alexander Stirzel) Date: Tue, 13 Mar 2001 12:47:58 +0100 Subject: What's wrong with me/Python ? References: <3AAE0652.D68F253E@daimlerchrysler.com> <98l16c$29cvf$1@fu-berlin.de> Message-ID: <3AAE08EE.7B6925C6@daimlerchrysler.com> Matthias Huening wrote: > > >What did I do wrong? And why does Python want a "variable > >named 'string'" here? > > Because you didn't import the string-module... > > Matthias *ganzrotesGesicht* (peinlich) Vielen Dank. (*sichinGrundundBodensch?m*) -- Alexander Stirzel E-Mail: alexander.stirzel at informatik.uni-ulm.de From roy at panix.com Sat Mar 17 12:02:06 2001 From: roy at panix.com (Roy Smith) Date: Sat, 17 Mar 2001 12:02:06 -0500 Subject: Looking for web indexer in python Message-ID: The software development group I work in has a small internal web site (a few hundred documents) which we don't currently have any way of searching. I'd like to put an automated indexer/search system in place. If possible, I'd like to use python, since I think it would be a nifty way to introduce the group to the language. There's no funding for this, so it has to be free software. A cursory look around didn't turn up anything that would fit the bill, but I have to assume somebody's already done a free python web indexer. Any suggestions? From aleaxit at yahoo.com Fri Mar 30 07:57:46 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 30 Mar 2001 14:57:46 +0200 Subject: how query function args References: <3AC374BC.F90A2894@abaqus-sn.com> <99vvn1$bmh$1@news.mathworks.com> Message-ID: <9a1vsj0cg@news1.newsguy.com> "Joshua Marshall" wrote in message news:99vvn1$bmh$1 at news.mathworks.com... > david winkler wrote: > > I need to query the names and values of a function's keyword arguments. > > I > > suspect that there is an easy way to do this but cannot find it. Would > > someone care to make a suggestion? > > func.func_defaults will return a tuple of the default values, but not > the names of the formals. func.func_code, the code-object for the function, has most of the info you want: its co_argcount attribute is the number of arguments (the ones with defaults are the last len(func.func_defaults) of them), its co_varnames attribute has the names of local variables starting with the argument names. So, the names of arguments which have default values are: func.func_code.co_varnames[ func.func_code.co_argcount - len(func.func_defaults) : func.func_code.co_argcount ] in the same order as the func.func_defaults. E.g., if you want name/value tuples (pairs): def dw(func): return zip( func.func_code.co_varnames[ func.func_code.co_argcount - len(func.func_defaults) : func.func_code.co_argcount ], func.func_defaults) It's of course easy to make this into a dictionary or whatever. Alex From tuttledon at hotmail.com Sat Mar 3 22:02:35 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Sun, 04 Mar 2001 03:02:35 GMT Subject: Beginer References: <3aa18bf8$0$65279$38c90ffe@news1.twtelecom.net> Message-ID: "mark" > can anyone tell me where i can find a real beginer tutorial for python? The > one that comes with the program is still to complicated.thanks> http://www.crosswinds.net/~agauld/ From loriendNOSPAM at bigpond.com Sat Mar 17 01:38:22 2001 From: loriendNOSPAM at bigpond.com (Lorien Dunn) Date: Sat, 17 Mar 2001 17:38:22 +1100 Subject: Meta-class inheritance problem (Python2.0 bug?) References: <6Kzs6.35062$v5.73895@newsfeeds.bigpond.com> Message-ID: <5nDs6.35198$v5.74638@newsfeeds.bigpond.com> I've located the point in the python 2.0 code where this occurs, so my question is now: What needs to be changed to make this wotk with meta-classes as well?: ceval.c, line 1816 (reformatted for clarity): /* BEGIN CODE SAMPLE */ else { /* Unbound methods must be called with an instance of the class (or a derived class) as first argument */ if (na > 0 && (self = stack_pointer[-n]) != NULL && PyInstance_Check(self) && PyClass_IsSubclass((PyObject *) (((PyInstanceObject*) self)->in_class), class)) /* Handy-dandy */ ; else { PyErr_SetString(PyExc_TypeError, "unbound method must be called with class instance 1st argument"); x = NULL; break; } } /* END CODE SAMPLE */ Lorien From flognat at flognat.myip.org Thu Mar 15 18:35:47 2001 From: flognat at flognat.myip.org (Andrew Markebo) Date: 16 Mar 2001 00:35:47 +0100 Subject: Should I close after popen?? References: Message-ID: / "Ken Seehof" wrote: | [...] | In other words, you are better off closing files explicitly. | | In the case of popen, it seems to me like it wouldn't matter if you | leave a few open streams lying around, but it just seems sloppy, | like not washing your dishes after dinner. I agree, but I tried with close, but I got the following problems: Traceback (innermost last): File "", line 1, in ? File "/usr/tmp/python-18803PG", line 314, in ? mymain() File "/usr/tmp/python-18803PG", line 304, in mymain keepALive() File "/usr/tmp/python-18803PG", line 259, in keepALive if PingAway(): File "/usr/tmp/python-18803PG", line 230, in PingAway fd1.close() IOError: [Errno 10] No child processes The code is: fd1=os.popen("ping -q -c 3 %s 2> /dev/null" % name1) fd2=os.popen("ping -q -c 3 %s 2> /dev/null" % name2) pid1, res1=os.wait(fd1) out1=fd1.read() pid2, res2=os.wait(fd2) out2=fd2.read() fd1.close() fd2.close() /Andy From kens at sightreader.com Wed Mar 14 17:24:19 2001 From: kens at sightreader.com (Ken Seehof) Date: Wed, 14 Mar 2001 16:24:19 -0600 Subject: compile / exec Message-ID: <003d01c0acd5$83b2ab70$04090a0a@upcast.com> The first line in the string is indented, which is a syntax error. The first line of the string has to be non-indented. "eric wilson" wrote: > hi - > i am new to python and i'm trying to use the compile / exec feature for > speeding up a loop. i'm using python v2.0 with pythonwin. i don't > understand why this doesn't work.... > thanks in advance for the help. > file://eric > > the code snippet looks like this: > exec_code = compile(""" > for eachLine in map(strip, allLines): > mySequence = split('\s\s+|\t', eachLine) > foundFields = str(gm2local(DateTimeFromString(mySequence[0])))[:-3] > + '\t' + mySequence[1]+ '\t' + mySequence[4]+ '\t' + mySequence[5]+ '\t' + > mySequence[9]+ '\t' + mySequence[16] + '\n' > fw.write(foundFields) > count = count + 1 > """, '', 'exec') > exec exec_code > > the error message that i get when this piece of code runs is: > Traceback (most recent call last): > File "C:\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in > RunScript > exec codeObject in __main__.__dict__ > File "E:\W2\pytest\logman.py", line 114, in ? > checkArgs() > File "E:\W2\pytest\logman.py", line 110, in checkArgs > parmFind(sys.argv[1], sys.argv[2]) > File "E:\W2\pytest\logman.py", line 55, in parmFindRAM > exec_code = compile(""" > File "", line 2 > for eachLine in map(strip, allLines): > ^ > SyntaxError: invalid syntax -------------- next part -------------- An HTML attachment was scrubbed... URL: From erwin at andreasen.com Wed Mar 28 16:01:48 2001 From: erwin at andreasen.com (Erwin S. Andreasen) Date: Wed, 28 Mar 2001 21:01:48 +0000 (UTC) Subject: Changing every other instance of in a file References: Message-ID: <99tjfr$16et$1@news.cybercity.dk> On 27 Mar 2001 21:44:56 GMT, Marcin 'Qrczak' Kowalczyk wrote: >Here is an obfuscated version: > >import List; main = interact $ concat . snd . mapAccumL f 1 . tails >f x ('<':'B':'>':_) = (3-x, take x "`$^X++%2?q{}:$&`gei;' datafile I managed to use only ^`'{}$%&<>?/;+:*\ -- still lot of punctuation left :) INTERCAL, anyone? -- ======================================================================= Herlev, Denmark Software Designer <*> LASAT^WEicon Networks ======================================================================= From aahz at panix.com Sat Mar 17 11:41:58 2001 From: aahz at panix.com (Aahz Maruch) Date: 17 Mar 2001 08:41:58 -0800 Subject: This math scares me References: <20010312170356.B3513@better.net> <98qnq0$qc2$1@panix3.panix.com> <98umb1$f2i$1@panix3.panix.com> Message-ID: <99044m$cfi$1@panix2.panix.com> In article , Grant Edwards wrote: > >It looks like I had them mixed up with the Babylonians. I >swear, the denizens of c.l.p have the widest base of knowege of >any newsgroup I've read. You obviously haven't read rec.arts.sf.fandom ;-) -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Three sins: BJ, B&J, B&J From ryan at NOSPAMda-men.comNOSPAM Tue Mar 6 09:42:06 2001 From: ryan at NOSPAMda-men.comNOSPAM (Tonnage) Date: Tue, 06 Mar 2001 14:42:06 GMT Subject: iis and python References: Message-ID: <2H6p6.372$oz.53556@newsread1.prod.itd.earthlink.net> LOL...this is not a flame, I am just chuckling at the same thing. I have played that game, and then walked down the hall and beat the newbie with config scripts and libs. USE 'EM LIVE 'EM LOVE 'EM Its far better to have 30 scripts, with only a few operations or commands per script, than to have one huge one with all of them. The only people that dont go with with, in the PHP/Perl case, are those that have never had to either optimize, or debug someone elses huge script. Ryan "Wayne Izatt" wrote in message news:Rs0p6.183447$df5.5139760 at news1.crdva1.bc.home.com... > > In order to use python it would have to entail cgi or ASP. Is this > correct. > > Or is there an alternative. I dont know if Zope is the right thing. I hate > > DTML. > > Zope is very powerful, and if you want to you can write almost all your code > in Python. DTML is there for presentation, not for logic, and should only be > used for simple processing. > > > Is using python in ASP a pain in the but? Am I going to have to learn a > > whole technology just to implelment python well into it? > > No, its fairly straighforward. However, before you go the ASP route, take > the time to examine Webware. Webware gives you ASP with Python, as well as > Python Server Pages and servlets - very powerful, easy to use, and pure > Python. > > > I hear troubleshooting ASP pages is not fun. > > Correct. > > > The only time I have used iis is with php and it was a total snap. > Painless. > > PHP is fine, but I've had the pleasure of debugging someone else's massive > 'one-script-wonder', and I remembered what my misgivings about Perl-based > languages were. Don't flame me, PHPer's, I still like the language! > > cheers > > > > From larskl at klassekampen.no Tue Mar 27 11:03:45 2001 From: larskl at klassekampen.no (Lars Klęboe) Date: Tue, 27 Mar 2001 18:03:45 +0200 Subject: Changing every other instance of in a file References: <8e41ctkk4l38jmj34070j15iotgv4is2cg@4ax.com> <99qb39$2m0$1@animus.fel.iae.nl> Message-ID: On 27 Mar 2001 17:20:09 +0200, Carel Fellinger wrote: >Lars Kl?boe wrote: >... >> Blablabla talktalk blabla blabla balbalblabla > >> The resulting file.html (html) > >> Blablabla talktalk blabla blabla balbalblabla > >> As you can tell, every other instance of is to be changed into . > >Let's hope those B-tags aren't nested, then the following might work: No they aren't nested. Why haven't I thought of dictionaries before ? Ever ? In any programming context ? At all ? ;) Thanks ! -- Lars Kl?boe From bedge at troikanetworks.com Wed Mar 21 10:32:18 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Wed, 21 Mar 2001 07:32:18 -0800 Subject: Saving history in interactive Python References: Message-ID: <3AB8C982.50901FE5@troikanetworks.com> set /home//.python, then here's what I stuck in my ~/.python file histfile="/home//.python import rlcompleter import readline readline.parse_and_bind("M-?: complete") readline.parse_and_bind("tab: menu-complete") import os import sys readline.read_history_file( histfile ) def savehist(): global histfile readline.write_history_file( histfile ) import atexit atexit.register( savehist ) This gets you command history saving, and readline command line editing. -Bruce. Timothy Grant wrote: > > Is there a way to save the history list in the Python > interpreter. > > -- > Stand Fast, > tjg. > > Timothy Grant tjg at exceptionalminds.com > Red Hat Certified Engineer www.exceptionalminds.com > Avalon Technology Group, Inc. <>< (503) 246-3630 > >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< > >>>>This machine was last rebooted: 62 days 22:52 hours ago<< From bencr at bigpond.com Tue Mar 27 06:13:28 2001 From: bencr at bigpond.com (Ben) Date: Tue, 27 Mar 2001 21:13:28 +1000 Subject: Executing external programs Message-ID: Hi, this appears to be a simple problem ... but i can not find any documentation on this ... could anyone point me to a rescource that would have an answer to this solution ... All I want to do is run program1.exe -args ... when program1.exe is finished run program2.exe -args ... run program3.exe -args etc etc ie the next process waits for the preceding processes exit code before starting ... if I can avoid the overhead of having the command shell open everytime I run an exe that would be good. Thanks From tim.one at home.com Sat Mar 3 14:02:24 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Mar 2001 14:02:24 -0500 Subject: the demise of 'from foo import * and its implications? In-Reply-To: Message-ID: [Robin Becker] > my preference would be that statements legal in one context should be > legal in another where they make sense. I cannot see how using import * > or eval etc in nested scopes is somehow obviously bad or different from > the same usage in non-nested scopes. The fact that the prohibition comes > from making things easier for the compiler adds to my confusion. The prohibition (against import* except at module scope) is there for "make sense" reasons. Here's a simple function, where nested scopes don't even come into play: def f(): from mystery import * g() def g(): print "hmm" f() What does that do? Forget the compiler! What makes *sense*? There simply isn't an answer that isn't surprising (although there *could* have been!). The Ref Man has always said: Whether a name is local or global in a code block is determined by static inspection of the source text for the code block: in the absence of global statements, a name that is bound anywhere in the code block is local in the entire code block; all other names are considered global. By that lovely rule, "g" is a global name within "f" (because static inspection shows that g is not bound within the body of f). However, because of the way Python was first implemented, it just so happens that *if* the mystery module contains its own global g, *that's* what "g" inside "f" refers to instead. The import* magically creates a local "g" inside "f", shadowing the global g anyone reading the quoted part of the Ref Man expects (and assuming they ignored the part of the Ref Man saying import* has undefined behavior here). And that's very surprising if you think-- as Guido intended, and as the Ref Man says --that Python is statically scoped. OTOH, since the first implementation did just happen to have this other behavior, Guido clung to it over the years for backward compatibility, despite that it's documented as being undefined, and despite that the compiler internals have gotten considerably warped *trying* to preserve this accidental behavior. So taking it away now is surprising if you think-- as some protest ever so loudly --that accidents should be preserved in loving detail forever more. It's not "a feature" of Python that it exhibits a bizarre form of dynamic scoping in some cases. It wasn't intended. Whenever that pops up, it's a flaw in the language design, or (in the case of import* at other than module scope) a (IMO, with hindsight) misguided attempt to preserve accidents of the initial implementation. > I have no particular objection to being able to access variables in > intermediate scopes. > > If we really want to improve visibility we could try to make > > >>> def bingo(a): > ... if a<=1: return 0 > ... return bingo(a-1)*a > ... > > work naively, but I'm fairly sure this will be rejected as unpythonic or > somesuch. Sorry, I can't make out what you're trying to say there. It's a vanilla recursive function, and it works exactly the way I expect it to work (which hasn't changed since the first release, and almost certainly never will). What about it doesn't work the way *you* expect? Note that if there's a "from mystery import *" at *module* scope, and mystery happens to define a global of its own named "bingo", then that latter is the bingo called inside the body. That's an example of "flaw in the language design" I mentionoed above, and I don't give a rat's ass about preserving *that* accident of the implementation either. language-behaviors-are-clarified-by-relating-them-to-animal-body- parts-ly y'rs - tim From f8dy at yahoo.com Wed Mar 28 13:18:00 2001 From: f8dy at yahoo.com (Mark Pilgrim) Date: Wed, 28 Mar 2001 13:18:00 -0500 Subject: list vs tuple References: <99stcb$483$1@panix6.panix.com> Message-ID: <99t9om$2o2q3$1@ID-77331.news.dfncis.de> "Aahz Maruch" wrote in message news:99stcb$483$1 at panix6.panix.com... > In article , > deadmeat wrote: > > > >Whats the practical difference between a list[] and a tuple() ? > > As someone said, tuples are immutable. This leads to useful > functionality, such as being able to easily use tuples as keys in > dictionaries (ditto strings). It was my understanding that only tuples containing immutable objects could be used as dictionary keys. For instance, (1,2,3) can be, and ("a","b","c") can be, but ([1,2,3], ["a","b","c"]) can not, because the underlying objects could mutate and cause problems. (Wow, that sounds like a bad sci-fi movie.) Is this true? -M You're smart; why haven't you learned Python yet? http://diveintopython.org/ From tjg at exceptionalminds.com Tue Mar 6 17:30:10 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Tue, 6 Mar 2001 14:30:10 -0800 Subject: Processing XML In-Reply-To: ; from martin.skott@propylon.com on Tue, Mar 06, 2001 at 04:58:49PM +0000 References: Message-ID: <20010306143010.L3579@trufflehunter.avalongroup.net> Thanks for the helpful post. String2xTree was just what I needed. The good word for Pyxie was also a big help! On Tue, Mar 06, 2001 at 04:58:49PM +0000, Martin Skott wrote: > Timothy Grant writes: > > > If Pyxie is a good choice, how do I add nodes to a document > > stored as an xTree? > > Use the String2xTree function to create a mini tree of your sting and > then use the paste functions to insert it into your main tree. -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Red Hat Certified Engineer www.exceptionalminds.com Avalon Technology Group, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 49 days 2:43 hours ago<< From scarblac at pino.selwerd.nl Tue Mar 27 03:02:17 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 27 Mar 2001 08:02:17 GMT Subject: fixing map(None, [1,2,3]) ? References: <873dc040ny.fsf@mathdogs.com> Message-ID: Mike Coleman wrote in comp.lang.python: > Shouldn't "map(None, [1,2,3])" return "[(1,), (2,), (3,)]"? > > Is there any hope that this could be fixed? No, since zip() already does that in 2.0 and higher, changing map would break lots of code, and it's not better anyway... -- Remco Gerlich From gerhard.nospam at bigfoot.de Wed Mar 7 10:51:19 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Wed, 07 Mar 2001 16:51:19 +0100 Subject: Python script for deMSWordification? References: <985h02$1pbm$1@swen.emba.uvm.edu> Message-ID: <3AA658F7.9127B12E@bigfoot.de> kelvin.chu at uvm.edu wrote: > > Dear fellow Pythoneers; > > Numerous colleagues and administration types send memos, colloqium > announcements and other things around in Micro$oft word format. Has anyone > written a filter in Python that can convert these things into normal text? > > If not, is there a basic set of rules for decoding .doc format files > anywhere that I can look at? Hmm, not Python, but wv (http://www.wvWare.com/) does that job. It converts M$ Word (6, 95, 97, 2000) to various formats. It's a (C, C++?) library, so you should be able to write a Python binding, if you need to access the internals of a Word document. For conversion only, calling the command line program will suffice, of course. Gerhard -- Sorry for the fake email, please use the real one below to reply. contact: g e r h a r d @ b i g f o o t . d e web: http://highqualdev.com From loewis at informatik.hu-berlin.de Sat Mar 24 07:19:20 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 24 Mar 2001 13:19:20 +0100 Subject: [Python-Dev] Anyone using weakrefs? References: <15035.46175.599654.851399@localhost.localdomain> Message-ID: "Fredrik Lundh" writes: > am I the only one who gets a bit nervous when the guy who > designed and implemented a feature has a hard time finding a > non-contrived use case? ;-) Seriously (and not knowing the exact meaning of contrived), a good application is the parent link in a DOM tree. The problem is that this is a) probably a too complex example for the documentation, as just making parent weak is not enough - ownerDoc also needs to be weak, and, b) nobody has changed any DOM implementation to make use weak references; Fred was asking for a real application. Regards, Martin P.S. I've considered using weakrefs in minidom, but put that plan aside since that would break portability with 1.5. From jkraska1 at san.rr.com Sat Mar 24 23:57:41 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 25 Mar 2001 04:57:41 GMT Subject: time to invest ??? References: <3abd3a17.7103358@news.vif.com> Message-ID: >I would think most people familiar with a couple other >languages could master the commonly used language features in a >day or two. Err, yeah. I tought someone the other day, and they had all they needed to get going on their whiteboard. It all fit. :) C// From ewilson at nospam.jamdat.com Wed Mar 14 20:28:42 2001 From: ewilson at nospam.jamdat.com (eric wilson) Date: Thu, 15 Mar 2001 01:28:42 GMT Subject: compile / exec References: Message-ID: thanks ken - that's got it! :-) "Ken Seehof" wrote in message news:mailman.984615559.29257.python-list at python.org... The first line in the string is indented, which is a syntax error. The first line of the string has to be non-indented. "eric wilson" wrote: > hi - > i am new to python and i'm trying to use the compile / exec feature for > speeding up a loop. i'm using python v2.0 with pythonwin. i don't > understand why this doesn't work.... > thanks in advance for the help. > //eric > > the code snippet looks like this: > exec_code = compile(""" > for eachLine in map(strip, allLines): > mySequence = split('\s\s+|\t', eachLine) > foundFields = str(gm2local(DateTimeFromString(mySequence[0])))[:-3] > + '\t' + mySequence[1]+ '\t' + mySequence[4]+ '\t' + mySequence[5]+ '\t' + > mySequence[9]+ '\t' + mySequence[16] + '\n' > fw.write(foundFields) > count = count + 1 > """, '', 'exec') > exec exec_code > > the error message that i get when this piece of code runs is: > Traceback (most recent call last): > File "C:\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in > RunScript > exec codeObject in __main__.__dict__ > File "E:\W2\pytest\logman.py", line 114, in ? > checkArgs() > File "E:\W2\pytest\logman.py", line 110, in checkArgs > parmFind(sys.argv[1], sys.argv[2]) > File "E:\W2\pytest\logman.py", line 55, in parmFindRAM > exec_code = compile(""" > File "", line 2 > for eachLine in map(strip, allLines): > ^ > SyntaxError: invalid syntax From sholden at holdenweb.com Thu Mar 15 00:27:58 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 15 Mar 2001 00:27:58 -0500 Subject: PythonWorks: opinions sought Message-ID: Before I part with almost $400 of hard-earned cash, I would be interested to hear user experiences of PythonWorks. If you don't want /F to see what you have to say an email would be fine (;-), but otherwise the newsgroup as a whole might be interested: I haven't seen much discussion here of what seems to be quite a worthwhile product. Presumably due to Fredrik's keen sense of public service, he never mentions it in his fine postings. regards Steve PS: "XXX is better" responses will *not* be welcome: I have other IDE products already, and am currently solely interested in PythonWorks rather than in IDE comparisons. From stevewilliams at wwc.com Sun Mar 25 23:36:47 2001 From: stevewilliams at wwc.com (Steve Williams) Date: Mon, 26 Mar 2001 04:36:47 GMT Subject: Python classes on east coast? References: Message-ID: <3ABEC78A.99C63F07@wwc.com> Robert Hicks wrote: > Is there or are there any plans for Python classes on the east coast [snip] As far as I know Python classes have no geographical attributes. Perhaps we need a PEP for 'import from __longitude__' to distinguish the GMT Python from the PST Python. From dale at out-think.NOSPAMco.uk Thu Mar 22 14:02:22 2001 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Thu, 22 Mar 2001 19:02:22 +0000 Subject: Automatic install of ActivePython Message-ID: I've had a pretty good hunt around for an answer to this and I'm somewhat surprised to have drawn a blank. How do I do an automated or quiet install of ActivePython 2.0? It would be nice to be able to set the target directory but I can live without that. Thanks. -- Dale Strickland-Clark Out-Think Ltd Business Technology Consultants From tchur at optushome.com.au Sat Mar 10 16:24:11 2001 From: tchur at optushome.com.au (Tim Churches) Date: Sun, 11 Mar 2001 08:24:11 +1100 Subject: Urgent Question about Python licensing References: <98cpfe$5oj$0@216.39.170.247> <20010310110228.L404@xs4all.nl> Message-ID: <3AAA9B7B.34AE0336@optushome.com.au> Thomas Wouters wrote: > > On Sat, Mar 10, 2001 at 08:43:26AM +0000, Dave LeBlanc wrote: > > Hi; > > > While reading up on the recent Python conference on O'Reilly's site > > (http://python.oreilly.com/news/pythonday1_0301.html - actually on the > > 'day 2' page), I cam across the following: > > [ The python licence hassles.] > > > My questions are these: > > 1. What prevents Python and GPL code from being distributed together? > > If I write some Python code that drives a GPL'd app (but which does > > not depend on that app), what prevents me from offering both my python > > code and the GPL'd app on the same medium (disk/CD/web)? > > 'derives' is a bit of a general and weird term. If your code does not depend > on a GPL library or binary, you can just distribute it. You can also > distribute both a GPL application and a Python-licenced application on the > same medium -- there is no restriction to that, as long as you make clear > what licence applies to what part. What you cannot do is link a > Python-licenced piece of software to a GPL-licenced part, *and* distribute > that resulting binary. Not even using dynamic linking, for some reason. > (Don't ask me, I'm not a lawyer.) I am not sure if you can attempt to import > a module, which might be a C module that is covered, possibly indirectly, by > the GPL. My gut says that that should be just fine, but my gut usually tries > to empty itself when it comes to lawyerese. You had me worried there about the implications of all of the above for the (really exciting, from my point of view) work being done by Duncan Temple Lang under the aegis of the OmegaHat project (see http://www.omegahat.org) to make the R statistical environment (see http://www.r-project.org), which can be built as a shared library, callable from within Python, and v-v (see http://www.omegahat.org/RSPython/index.html)? R is GPLed and only GPLed. However, the eleventh section (i.e. section number 10 - clearly the GPL and Python are fellow-travellers) of the GPL (see http://www.gnu.org/copyleft/gpl.html) states that if you want to incorporate GPLed software in non-GPLed software (and presumably v-v), one merely has to ask permission in writing from the authors (or should that be copyright holders?) of the GPLed software. So there would not appear to be any absolute impediment to linking Python (as currently licensed) with GPLed software - you just have to ask permission first. Tim Churches From nospam at collinet.freeserve.co.uk Sat Mar 24 20:04:06 2001 From: nospam at collinet.freeserve.co.uk (Tony Collins) Date: Sun, 25 Mar 2001 02:04:06 +0100 Subject: Python script to create HTML gallery, thumbnails References: <3ABCAC94.B095CB9A@ozemail.com.au> Message-ID: <99jfsd$l5u$1@news6.svr.pol.co.uk> You could try albumatic - creates full web pages complete with thumbnails - link on my site. -- Tony Collins Please change nospam in address to 'tony' nospam at collinet.freeserve.co.uk Digital Photo website : http://www.digifotoinfo.co.uk "ccang" wrote in message news:3ABCAC94.B095CB9A at ozemail.com.au... > Hi there all, > I recently got a digital camera (Kodak DC4800) and wanted to > put all the crappy photos I shoot on the web. > > I looked for software to create thumbnails and corresponding > HTML files but couldnt find any so I wrote my own using Python > and the PIL. > > It creates a consolidated thumbnail and the corresponding HTML files. > > No GUI yet so u'll have to edit the script to customize > your settings eg page headers, comments. > > # Does only JPGs for now. > # Usage : python mkgallery.py [ filenames ] > # Will produce 1 HTML file for the thumbnail index. > # 1 HTML file per JPG image. > # 1 consolidated thumbnail JPG. > # > # There will be GUI for this pretty soon. > # > # The HTML file for the thumbnail is generated in the same > # directory as where the script is run from. > # However, it assumes that it will reside > # in a subdirectory above where the other files (HTML, JPGS) reside. > # ie u'll have to move it. > # > # eg > # myGallery/ > # myGallery/topic.html > # myGallery/topic/topic_index.jpg > # myGallery/topic/zpic1.jpg > # myGallery/topic/zpic1.html > # ... > # ... > # myGallery/topic/zpicN.jpg > # myGallery/topic/zpicN.html > # > > http://www.ozemail.com.au/~calcium/scripts.html > > Sample output > http://www.ozemail.com.au/~calcium/rogaine.html > > Feedback welcome, > Chai > -- > | mailto:calcium at ozemail.com.au | +61 401 688 408 > | http://www.ozemail.com.au/~calcium > | I dont use the voice of Bart when I'm making love > | to my husband, but Marge's voice turns him on a > | little - Nancy Cartwright. > From gmcm at hypernet.com Sat Mar 10 14:19:00 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 10 Mar 2001 14:19:00 -0500 Subject: ANN: Linux version of Installer for Python 2 Message-ID: The Linux version of Installer for Python 2 is here: http://www.mcmillan-inc.com/installer_dnld.html Background: The Installer is a sort of compilerless Freeze - a way of distributing Python apps with all the required support built in. The Linux version collects all dependencies and packages the pure Python into an archive attached to the executable. Just tar, gzip and ship. Old-Python-style license. Contact: gmcm at hypernet.com

Linux Installer release 3j A compiler-less way of distributing Python 2.0 apps on Windows. (10-Mar-01) - Gordon From johann at physics.berkeley.edu Tue Mar 27 16:43:30 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 27 Mar 2001 13:43:30 -0800 Subject: python, OS X, and fcntl References: Message-ID: Robert Hicks writes: > http://www.zope.org/Members/jshell/ZopeOnOSX > This goes into exactly what you are asking about... Aha. Thanks. I saw that page, but I think the last time I looked at it, it hadn't been updated to OS X Final yet. --Johann -- Johann Hibschman johann at physics.berkeley.edu From chrisw at nipltd.com Wed Mar 14 06:12:24 2001 From: chrisw at nipltd.com (Chris Withers) Date: Wed, 14 Mar 2001 11:12:24 +0000 Subject: zipfile: how to find out if a zipinfo object is a directory or file References: <3AAF3BCF.580F3ECC@t-online.de> Message-ID: <3AAF5218.9EC5DA79@nipltd.com> Stephane wrote: > > Hi, > > does somebody know how to find out in a zipinfo object represents a file > or directory. I think zipinfo objects _always_ represent files. The name in the zipinfo object includes that path where that file should be expanded to. cheers, Chris From porter at et.byu.edu Wed Mar 21 13:34:19 2001 From: porter at et.byu.edu (C. Porter Bassett) Date: Wed, 21 Mar 2001 11:34:19 -0700 (MST) Subject: IDE with vi key bindings In-Reply-To: References: <98amlj01sp6@news2.newsguy.com> Message-ID: Is there any python IDE (windows) that either can integrate with vim or has vi key bindings? I know that there are some (Dave) who can't understand why I would want this, but I just can't seem to break my vi addiction. I currently do all my python coding in vim, but I would like to try an IDE without leaving behind my precious vi. -------------------------------------------------------------------------- "Pretend like this is a really witty saying." - Anonymous -------------------------------------------------------------------------- From loewis at informatik.hu-berlin.de Wed Mar 14 06:12:27 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 14 Mar 2001 12:12:27 +0100 Subject: Process details References: Message-ID: Timothy Grant writes: > I need to create a list of processes and process information. I > have created a class that contains much of the information in > /proc/'pid'/status. > > It works quite well, however, it takes about four seconds to > populate a list of 90 procs. This seems a bit long. Is there a > faster way to get ahold of the information than reading /proc? It depends on you exactly you read them, and what information exactly you need. os.listdir("/proc") never took more than 10ms on my system. Regards, Martin From tim.one at home.com Sat Mar 3 15:21:19 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Mar 2001 15:21:19 -0500 Subject: the demise of 'from foo import * and its implications? In-Reply-To: Message-ID: [Robin Becker] >>> If we really want to improve visibility we could try to make >>> >>> >>> def bingo(a): >>> ... if a<=1: return 0 >>> ... return bingo(a-1)*a >>> ... >>> >>> work naively, but I'm fairly sure this will be rejected as unpythonic or >>> somesuch. [Tim Hochberg] >>????? >> >> In what sense doesn't this work now? >> ... >> >>What doesn't work is the following: >> >>def spam(n): >> def fact(a): >> if a <= 1: return 1 >> else: return fact(a-1)*a >> return fact(n) + 42 [Robin Becker] > you're right of course, this is what I meant. I haven't played with the > new statically scoped stuff, but I probably wrongly assumed that bingo > would remain invisible inside bingo. Ah! Yes, that assumption is wrong. Making nested recursive functions "work" as expected was one of the (few) strong *practical* arguments in favor of adding nested_scopes. > ... > I hadn't really appreciated before now that python wishes to enforce a > fixed scope for references (for optimisation purposes) See other reply: "optimization" is incidental here. Python wants static scoping *primarily* for sanity. Dynamic scoping is more error-prone because more surprise-prone. From glhzxo at aol.com Thu Mar 8 10:40:25 2001 From: glhzxo at aol.com (glhzxo at aol.com) Date: Thu, 08 Mar 2001 15:40:25 GMT Subject: Napster Zapstered - Downloads Mastered! Get them HERE! FREE! Message-ID: If Napster won't help - WE WILL! Everything you want is available RIGHT NOW at #MP3_DEPOT on IRC; the server is irc.action-irc.net. Need speed? Well, most of our databases are cable or T-1. The servers are all megaspeed - all are on a fiber channel. You won't be disappointed. And we have servers in the U.S., Canada, Europe, even Australia. Wherever you are, there is a server close enough to give you top speed! Everything you need and want, in one convenient place and, as a bonus, REAL NICE PPL! Friendly chat, and OPS who are actually users, not pricks. You have a real opportunity to pitch in and help your fellow internet junkies, and maybe earn OP or even IRCOP status. Action_IRC is a small network, owned and operated By the users. We are a friendly bunch - but we unquestionably have the largest music library on the Internet. We have 10 servers worldwide and 300 channels. Our selection is absolutely incredible. Of course we have all the modern pop, rock, and rap. But then we also have jazz, blues, bluegrass, country, classical, 50's, and anything else you are looking for. If you are new to IRC, you are in for a real treat. There are none of the hassles you have with Napster. You don't get half a file then never see the user again. And, unlike Napster, we don't have a million users, each with the same 3 files! Just download a database list, select your file and download. You can choose from over 50 MP3 databases. Our MP3 databases range from 100 gigabytes to a terabyte - that's right, a Terrabyte of MP3's in ONE PLACE! Looking for Celtic Mouth Music? No? Well, how about Hilary Hahn, BEETHOVEN Violin Concerto BERNSTEIN Serenade - Aristophanes? Or a rare Jimmi Hendrix boot? Frank Zappa Compositions by the Kronos Quartet? All of the works of Robert Johnson or Howlin' Wolf? Carter Family, anyone? Or the Library of Congress collection of great American folk? Or Hank Williams demos? That oldie from your Senior Prom - or the newbie, as the case may be... we have it all. Did you know that the Chordettes did a female barbarshop album? Yeah, we got that. But music is not all we have. Action_IRC also has the largest binary library on the net. Want movies? Then visit #Movietime or #Movieland for them. Is videos your thing? Then you will want to check out #Musicvideos. And don't forget to stop by #Warez4u, #Hotwarez, #Crackhouse, or #Gametime. So stop by and see us. We will be waiting for you! IF YOU HAVE NEVER USED IRC BEFORE --------------------------------- If you have never used IRC before, IRC is really easy to use. Any of the following links will directly download MIRC, the program you need: http://www.kissland.com/mirc/mirc582t.exe http://www.carbosoft.com/mirc/mirc582t.exe ftp://mirc.entic.net/pub/mIRC/mirc582t.exe http://mirc.mcclimans.com/downloads/mirc582t.exe NOTE TO TECHIES: ONLY use MIRC, 5.71 or above. That's because you will need to load SpR, a MIRC script to access the databases. It works only on MIRC 5.71 or higher. Install MIRC, then look for this server: Action-IRC If you can't find it, or are using an earlier version of MIRC (or another client) then either add this server: irc.action-irc.net or just type /join irc.action-irc.net When you connect to irc.action-irc.net, a window will pop up with lots of channels. Select them all and delete them. Then add this channel #MP3_Depot You need the #. Join that channel. If you can't figure out how to add a channel, once you have logged into a server and get the welcome message, close the menu box and at the bottom of the page just type this: /join #MP3_Depot No space or other character before the / That will bring you to our channel From there just ask any question you have and someone will answer it. jkxoqyguphuuvhfvhnxlebitveqdgukvfwgglbofiptlhqrpltedcjztwzcyfhqxlp From root at rainerdeyke.com Thu Mar 8 22:58:37 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 09 Mar 2001 03:58:37 GMT Subject: from Tkinter import * References: <989dot$t6t$1@panix3.panix.com> Message-ID: "Aahz Maruch" wrote in message news:989dot$t6t$1 at panix3.panix.com... > Actually, I disagree with the effbot. I used to think it was okay to > special-case "from Tkinter import *", but I've come to the conclusion > that "import *" is _always_ a Bad Idea in any sort of production code. > Sure it takes more work to write > > from Tkinter import Tk, Frame, Button, Entry, Canvas, Text > > but I think the payoff in clarity is worth it. I have used 'from ... import *' to group several imports: includes.py: import a, b, c, d, e, f, g # This line is the entire content of includes.py somethingelse.py: from includes import * # Imports a, b, c, d, e, f, g ... -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From evertonreid at netscapeonline.co.uk Sun Mar 11 23:38:55 2001 From: evertonreid at netscapeonline.co.uk (Everton reid) Date: Mon, 12 Mar 2001 04:38:55 +0000 Subject: programming h----ng Message-ID: <3AAC52DF.420FB510@netscapeonline.co.uk> You might not want to answer this but I have read and I am just blocked I know the basic of c/C++ but I am hungryfor more reverse engineer canyou help please please please please please please -------------- next part -------------- An HTML attachment was scrubbed... URL: From akuchlin at mems-exchange.org Thu Mar 22 17:41:59 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 22 Mar 2001 17:41:59 -0500 Subject: Curses under python 2.0 References: <99darm$o3o$00$1@news.t-online.com> Message-ID: <3dsnk5zars.fsf@ute.cnri.reston.va.us> "Christian Theune" writes: > >>> import curses > Traceback (most recent call last): > File "", line 1, in ? > File "/usr/local/lib/python2.0/curses/__init__.py", line 15, in ? > from _curses import * > ImportError: No module named _curses You *did* enable the _curses module in Modules/Setup, right? --amk From kalle at gnupung.net Thu Mar 8 14:11:12 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Thu, 8 Mar 2001 20:11:12 +0100 Subject: "Wrap" a python-cgi In-Reply-To: <3aa7c5f9$0$21482@SSP1NO25.highway.telekom.at>; from dusty@strike.wu-wien.ac.at on Thu, Mar 08, 2001 at 06:48:31PM +0100 References: <3aa7c5f9$0$21482@SSP1NO25.highway.telekom.at> Message-ID: <20010308201112.A6106@father> Sez Hermann Himmelbauer: > Hi, > I am currently using python for several cgi programs. One problem is that > if my cgi-script has a bug it exits with an exception and the user gets an > ugly error message done by the webserver. > > I would like to put some really simple "bugfree" (if something like this > can exist :-) "wrapper" around my cgi-scripts, let it trap Exceptions, log > the error and let it output a nice error page to the user. > > My first approach would perhaps be to wrap the whole script into a "try: > except" clause but at first I don't know if nested try/except clauses are > allowed and moreover the whole script looks somehow ugly as every line is > indented. This is basically a good idea, but you should use functions too. Something like this might work (untested): def main(): # whatever goes here... if __name__ == "__main__": print "Content-Type: text/html\n" try: main() except: import traceback, sys print "

Error!

\n
"
	traceback.print_exc(file=sys.stdout)
	print "
" And yes, try: ... except: blocks can be nested. Peace, Kalle -- Email: kalle at gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [Not signed due to braindamage. Blame Microsoft Outlook Express.] From chris.gonnerman at usa.net Mon Mar 5 00:24:10 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sun, 4 Mar 2001 23:24:10 -0600 Subject: Newbie question about nested lists and constructor functions... References: Message-ID: <01a901c0a534$8701d2e0$a100000a@local> ----- Original Message ----- From: "Norm Lyons" Sent: Sunday, March 04, 2001 10:18 PM Subject: Re: Newbie question about nested lists and constructor functions... > Sorry about that Chris. S'awright. > I am trying to create instantiated objects with the following properties: > > list_var = [(key, value), left, right] > > where the "key, value" pair are a tuple, and the variables "left" and > "right" are empty lists [ ] which will be manipulated to hold values later > in the program after they have already been initialized to empty lists. The > purpose of this object is to hold the necessary data for nodes in a binary > search tree. I know how to implement this type of data structure in C++ but > I seem to be getting hung up on the syntax differences in the Python class > and member variable declarations. > > An example of one of my attempts would be: > > class Node: > def __init__(self, key = ''): > left = [] > right = [] > data = (key, 'value') > newnode = [data, left, right] > def info(self): > return self.data OKAY. Now we are getting somewhere. This seems to be a common mistake for users of other languages. Your code likely should be like this: class Node: def __init__(self, key = ''): left = [] right = [] data = (key, 'value') self.data = [data, left, right] def info(self): return self.data[0] SPECIFICALLY, you need to assign your list to a data attribute of self. I would write your code more like this: class Node: def __init__(self, key = ''): self.left = [] self.right = [] self.data = (key, 'value') def info(self): # not really needed with this version IMHO return self.data or perhaps: class Node: def __init__(self, key = '', value = ''): self.left = None # these get object references (later) self.right = None # so I don't think they need to be lists. self.key = key self.value = value # is this a default? def info(self): # not really needed with this version IMHO return (self.key, self.value) but that is a personal thing. > The "info" function is only intended to return the values of the variables > "key and value". The other values are used as pointers to child nodes in > the tree. As I mentioned earlier, I have been through the online tutorial a > few times and have not found any information that clears this issue up for > me. Obviously, the code above is incomplete as it should also contain the > appropriate "if" and "elif" statements to properly branch according to the > information passed to the constructor function. Unfortunately, I do not > know what I am doing wrong. Any suggestions? I think I have this all right, but I haven't test run it yet. Good luck :-) From sholden at holdenweb.com Thu Mar 22 00:41:50 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 22 Mar 2001 00:41:50 -0500 Subject: comp.lang.python.travel, anyone? Message-ID: Just wondered how many on this news group travel regularly, and if so where? I was in Albuquerque two weeks ago, New York last week and Boston this (tip o' the hat to Tim Peters, who formerly lived here). Sweden in April. Any Pythoneers out there? regards Steve From jmg at ecs.soton.ac.uk Tue Mar 13 14:36:35 2001 From: jmg at ecs.soton.ac.uk (Jacek Generowicz) Date: 13 Mar 2001 19:36:35 +0000 Subject: Extending Python: rewriting a single method in C References: <98l1i901k4u@news1.newsguy.com> Message-ID: "Alex Martelli" writes: > > How do I get at the members of a class in C if that class was defined > > in python ? > > By passing the reference to the instance to the function, and > receiving it on the C side as a PyObject* -- you can then call > methods and access attributes on it from C, just as you could > from Python. See the "O" format code in the documentation of > PyArg_ParseTuple (1.7 in the "Extending and Embedding" manual). This is exactly what I have been trying to do, using exactly that reference as a guide, but I haven't managed to get a working piece of code yet. > > JE> In fast_a and fast_b, you can get arguments by using the ParseTuple > string > > JE> "(Oii)" and then use PyObject_SetAttrString and PyObject_GetAttrString > > JE> to store or retrieve attributes (including, if necessary, instance > > JE> methods) from the instance by their name. > > > > Is there an organized reference where I can find the specifications of > > all these functions ? All I have come across shows example code, but > > no full descriptions of what can/must be done. > > It's somewhat disorganized. I think Beazley's "Python Essential > Reference" (New Riders) is your best bet among current books (but > it only covers Python 1.5.2). Even now that the local copy of the above has retured from walkabout, I am not all that much wiser. I've not seriously used gettattr before, so maybe I'm missing something. As I understand it, I have to provide a __getattr__ method in my python class which will get called when I use PyObject_GetAttr. (If this is so then I don't see why the function isn't automatically provided; any creative definition---ie differing from the blatantly obvious (and hence tedious)---surely only opens the door to horrors. Still, mine is not to reason why.) In Beazley I see that the signature of the PyObject_GetAttr is PyObject * PyObject_GetAttr( PyObject *o, PyObject *attr_name ) Nowhere can I find an explanation of the variables, so I'm guessing that o should be a pointer to the object whose attribute I want to get (which I will have obtained by something like PyObject *o; if (! PyArg_ParseTuple( args, "O", o ) ) return NULL; ). But what on earth is attr_name ? Is it a PyObject* pointing to a python string containing the name of the attribute I want ? How about PyObject_GetAttrString ? Is it the same as PyObject_GetAttr except that I can use a C string to give the name of the attribute ? Assuming that is so, and that these funcitons return a pointer to the attribute in question, how do I do anything with it ? For example, assume that I know that PyObject * O points to a python integer, how do I convert it to a C integer? or is this The Wrong Thing To Do ? (Would it be fair to say that the documentaion is, on the whole, less that satisfactory ?) > > Maybe some kind soul could show me what the correct code for a minimal > > extension type is ? > > > > For example, I tried to write an extension type equivalent to > > > > > > class foo: > > def __init__ ( self, a ): > > self.a = a > > def show ( self ): > > print a > > > > My various attempts, almost work, but there is always something not > > quite right. > > Getting equivalence to this is not going to be easy -- the > type/class separation hits hard, Could you elabore a bit on this, please ? (the bit after --). Jacek From tim at vegeta.ath.cx Thu Mar 8 03:39:35 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Thu, 08 Mar 2001 08:39:35 GMT Subject: "!=" is bad form. Re: sorry....never mind References: <3AA6E308.5B63ECC6@cosc.canterbury.ac.nz> <3AA72253.FB021815@Lugoj.Com> Message-ID: James Logajan wrote: > Greg Ewing wrote: > > Victor Louie wrote: > > > <> is obsolescent. > > > > Really? I hope it's not taken away, because that will > > break ALL of my code! I hate != (looks too much like > > C), so I always use <>. Nobody ever told me I was doing > > anything wrong! I hate '<>' because it's too much like VB (and so many other BASIC variants). > Actually, for Python, "!=" IS totally bogus and should be considered the > unusual variant. The only confusing thing I've noticed about this is that it comes close to violating Python's guideline: There should be one, and only one, reasonable way to do something. But I, unlike Mr. Logajan, decline to challenge Guido's better judgement. (Hell, _he_ wrote it, not you!) [ snip ] > Shucks, if one is going to borrow "!=" from "C", why stop there? Why not > borrow the keywords and concepts such as "register", "auto", "extern", > pointers, malloc, free, etc. Heck, why not throw out print(), the '==' operator, the printf()-style "%f" notation, and the whole dot (.) access operator just because they were based on something C (or C++ for access op) had? Or, just maybe, we can get past this? -- -Tim Hammerquist Programmers are achievement oriented; give them an impossible task, and they'll do their best to give you what they think you would have asked for if you had a clue as to what was possible. -- Peter Coffee, PC Week From dav-nospam-id at westco-nospam-ntrol.com Thu Mar 22 09:23:48 2001 From: dav-nospam-id at westco-nospam-ntrol.com (David Brown) Date: Thu, 22 Mar 2001 15:23:48 +0100 Subject: Python 2.1 and MySQL 3.23.33 on Windows Message-ID: <99d1te$ogo$1@news.netpower.no> I have MySQL 3.23.33 and Python 2.1 installed on my Windows machine. Both work fine (I use MySQL along with PHP and Apache), and I have used Python for a few short scripts. But I cannot get Python to work with MySQL. The mySQLdb windows installation is built for Python 2.0, not 2.1, and I do not have MSVC to recompile it myself. Does anyone have any hints or pointers to get me started? Thanks. David Brown Norway From ping at lfw.org Mon Mar 12 00:18:06 2001 From: ping at lfw.org (Ka-Ping Yee) Date: Sun, 11 Mar 2001 21:18:06 -0800 (PST) Subject: [Python-Dev] Revive the types sig? In-Reply-To: Message-ID: On Sun, 11 Mar 2001, Michel Pelletier wrote: > As I see it, interfaces satify your first point, remove the need for your > second and third point, satify your fourth point, and meet the goals of > your fifth. For the record, here is a little idea i came up with on the last day of the conference: Suppose there is a built-in class called "Interface" with the special property that whenever any immediate descendant of Interface is sub-classed, we check to make sure all of its methods are overridden. If any methods are not overridden, something like InterfaceException is raised. This would be sufficient to provide very simple interfaces, at least in terms of what methods are part of an interface (it wouldn't do any type checking, but it could go a step further and check the number of arguments on each method). Example: >>> class Spam(Interface): ... def islovely(self): pass ... >>> Spam() TypeError: interfaces cannot be instantiated >>> class Eggs(Spam): ... def scramble(self): pass ... InterfaceError: class Eggs does not implement interface Spam >>> class LovelySpam(Spam): ... def islovely(self): return 1 ... >>> LovelySpam() Essentially this would replace the convention of writing a whole bunch of methods that raise NotImplementedError as a way of describing an abstract interface, making it a bit easier to write and causing interfaces to be checked earlier (upon subclassing, rather than upon method call). It should be possible to implement this in Python using metaclasses. -- ?!ng "Computers are useless. They can only give you answers." -- Pablo Picasso From bh at abbenay.cs.berkeley.edu Sun Mar 11 19:43:00 2001 From: bh at abbenay.cs.berkeley.edu (Brian Harvey) Date: 11 Mar 2001 16:43:00 -0800 Subject: Einstein's Riddle References: <98glrd$1si1a$1@ID-75892.news.dfncis.de> Message-ID: <98h62k$knn$1@abbenay.CS.Berkeley.EDU> "Boris Popov" writes: >house 1 2 3 4 5 >color yellow blue red green white >nationality norweigian dane brit german swede >drink water tea milk coffee beer >smoke dunhill blend pall mall prince bluemaster >pet cats horse birds fish dogs > >P.S. Did I have to write software to solve it ? :) I can't resist being (apparently) first to post a computer program. But it doesn't really belong in any of these newsgroups, because it's written in Logo. First get Berkeley Logo from ftp://ftp.cs.berkeley.edu/ucblogo/ (pick the one that matches your platform) Then get the logic-puzzle-solver from http://www.cs.berkeley.edu/~bh/logic-code/hybrid.lg Then here's the part specific to this puzzle: ? po [einstein neighbor neighbor1] to einstein cleanup category "position [1 2 3 4 5] category "color [red green white yellow blue] category "nationality [British Swedish Danish Norwegian German] category "beverage [tea coffee milk beer water] category "cigar [pallmall dunhill blend bluemaster prince] category "pet [dog bird cat horse fish] verify "British "red verify "Swedish "dog verify "Danish "tea justbefore "green "white :position verify "green "coffee verify "pallmall "bird verify "yellow "dunhill verify 3 "milk verify 1 "Norwegian neighbor "blend "cat :position neighbor "horse "dunhill :position verify "bluemaster "beer verify "German "prince neighbor "Norwegian "blue :position neighbor "blend "water :position print [] solution end to neighbor :a :b :lineup falsify :a :b neighbor1 :lineup count :lineup end to neighbor1 :lineup :count if :count=0 [stop] foreach bl bf bf :lineup [implies :a first :lineup "true :b ? "false] neighbor1 (lput first :lineup bf :lineup) :count-1 end ? solve [einstein] category position [1 2 3 4 5] category color [red green white yellow blue] category nationality [British Swedish Danish Norwegian German] category beverage [tea coffee milk beer water] category cigar [pallmall dunhill blend bluemaster prince] category pet [dog bird cat horse fish] British red -> true Swedish red -> false Danish red -> false Norwegian red -> false German red -> false green British -> false white British -> false yellow British -> false blue British -> false Swedish dog -> true British dog -> false red dog -> false Danish dog -> false Norwegian dog -> false German dog -> false bird Swedish -> false cat Swedish -> false horse Swedish -> false fish Swedish -> false Danish tea -> true British tea -> false red tea -> false Swedish tea -> false dog tea -> false Norwegian tea -> false German tea -> false coffee Danish -> false milk Danish -> false beer Danish -> false water Danish -> false green 5 -> false white 1 -> false green coffee -> true red coffee -> false British coffee -> false white coffee -> false yellow coffee -> false blue coffee -> false 5 coffee -> false tea green -> false Danish green -> false milk green -> false beer green -> false water green -> false pallmall bird -> true dunhill bird -> false blend bird -> false bluemaster bird -> false prince bird -> false dog pallmall -> false Swedish pallmall -> false cat pallmall -> false horse pallmall -> false fish pallmall -> false yellow dunhill -> true red dunhill -> false British dunhill -> false green dunhill -> false coffee dunhill -> false white dunhill -> false blue dunhill -> false pallmall yellow -> false bird yellow -> false blend yellow -> false bluemaster yellow -> false prince yellow -> false 3 milk -> true 1 milk -> false 2 milk -> false 4 milk -> false 5 milk -> false tea 3 -> false Danish 3 -> false coffee 3 -> false green 3 -> false white 4 -> false beer 3 -> false water 3 -> false 1 Norwegian -> true 2 Norwegian -> false 3 Norwegian -> false milk Norwegian -> false 4 Norwegian -> false 5 Norwegian -> false white Norwegian -> false British 1 -> false red 1 -> false Swedish 1 -> false dog 1 -> false Danish 1 -> false tea 1 -> false German 1 -> false blend cat -> false horse dunhill -> false yellow horse -> false bluemaster beer -> true pallmall beer -> false bird beer -> false dunhill beer -> false yellow beer -> false blend beer -> false prince beer -> false tea bluemaster -> false Danish bluemaster -> false coffee bluemaster -> false green bluemaster -> false milk bluemaster -> false 3 bluemaster -> false water bluemaster -> false German prince -> true British prince -> false red prince -> false Swedish prince -> false dog prince -> false Danish prince -> false tea prince -> false Norwegian prince -> false 1 prince -> false pallmall German -> false bird German -> false dunhill German -> false yellow German -> false blend German -> false bluemaster German -> false beer German -> false Norwegian blue -> false 1 blue -> false blue 3 -> false milk blue -> false blue 4 -> false blend water -> false Assuming 1 yellow 1 yellow -> true 2 yellow -> false dunhill 2 -> false 3 yellow -> false milk yellow -> false dunhill milk -> false 3 dunhill -> false 4 yellow -> false dunhill 4 -> false 5 yellow -> false dunhill 5 -> false 1 dunhill -> true Norwegian dunhill -> true Swedish dunhill -> false dog dunhill -> false yellow dog -> false Swedish yellow -> false Danish dunhill -> false tea dunhill -> false water dunhill -> true pallmall water -> false bird water -> false prince water -> false German water -> false yellow water -> true red water -> false British water -> false white water -> false blue water -> false Swedish water -> false Norwegian water -> true 1 water -> true 2 water -> false 4 water -> false 5 water -> false dog water -> false coffee 1 -> false green 1 -> false Norwegian green -> false yellow Norwegian -> true beer Norwegian -> false bluemaster Norwegian -> false 1 bluemaster -> false beer 1 -> false horse Norwegian -> false 1 horse -> false water horse -> false blend Norwegian -> false 1 blend -> false pallmall Norwegian -> false bird Norwegian -> false 1 bird -> false pallmall 1 -> false coffee Norwegian -> false Danish yellow -> false tea yellow -> false white 2 -> false blend 4 -> false blend 3 -> false milk blend -> false horse 4 -> false horse 3 -> false milk horse -> false Assuming 5 beer 5 beer -> true 2 beer -> false bluemaster 2 -> false 4 beer -> false bluemaster 4 -> false 5 bluemaster -> true pallmall 5 -> false bird 5 -> false blend 5 -> false 2 blend -> true white blend -> false pallmall 2 -> false bird 2 -> false prince 2 -> false German 2 -> false cat 2 -> false cat 5 -> false bluemaster cat -> false beer cat -> false cat 4 -> false prince 5 -> false German 5 -> false tea 5 -> false Danish 5 -> false Assuming 5 Swedish 5 Swedish -> true 2 Swedish -> false blend Swedish -> false bluemaster Swedish -> true beer Swedish -> true coffee Swedish -> false green Swedish -> false German green -> true prince green -> true pallmall green -> false bird green -> false coffee bird -> false pallmall coffee -> false blend green -> false 2 green -> false 4 green -> true cat green -> false coffee cat -> false horse green -> false coffee horse -> false red 4 -> false British 4 -> false coffee 4 -> true tea 4 -> false Danish 4 -> false 2 Danish -> true blend Danish -> true pallmall Danish -> false bird Danish -> false British bird -> true red bird -> true white bird -> false pallmall white -> false blue bird -> false pallmall blue -> false red pallmall -> true British pallmall -> true 4 pallmall -> false 3 pallmall -> true milk pallmall -> true tea pallmall -> false blend tea -> true 2 tea -> true cat tea -> false Danish cat -> false bird tea -> false milk bird -> true 3 bird -> true 4 bird -> false dog 3 -> false Swedish 3 -> false milk Swedish -> false dog milk -> false cat 3 -> false 1 cat -> true yellow cat -> true red cat -> false British cat -> false white cat -> false blue cat -> false water cat -> true milk cat -> false Norwegian cat -> true German cat -> false prince cat -> false dunhill cat -> true fish dunhill -> false 1 fish -> false yellow fish -> false water fish -> false Norwegian fish -> false fish 3 -> false milk fish -> false white 3 -> false red 3 -> true British 3 -> true German 3 -> false prince 3 -> false 4 prince -> true horse prince -> false fish prince -> true milk prince -> false coffee prince -> true blue prince -> false German blue -> false white prince -> false bluemaster white -> true 5 white -> true beer white -> true tea white -> false Danish white -> false blue Danish -> true Swedish blue -> false dog blue -> false white Swedish -> true 4 Swedish -> false German 4 -> true dog 4 -> false fish 4 -> true 2 fish -> false blend fish -> false 5 fish -> false beer fish -> false bluemaster fish -> false green fish -> true red fish -> false British fish -> false white fish -> false blue fish -> false Danish fish -> false German fish -> true tea fish -> false coffee fish -> true dog coffee -> false beer dog -> true 5 dog -> true 2 dog -> false blend dog -> false bluemaster dog -> true green dog -> false white dog -> true horse white -> false milk white -> false red milk -> true British milk -> true German milk -> false coffee German -> true horse German -> false white German -> false 2 coffee -> false blend coffee -> false beer British -> false 5 British -> false bluemaster British -> false red bluemaster -> false 5 red -> false beer red -> false horse British -> false Danish horse -> true tea horse -> true beer horse -> false 5 horse -> false 2 horse -> true blend horse -> true bluemaster horse -> false British blend -> false red blend -> false blue blend -> true bluemaster blue -> false 5 blue -> false 2 blue -> true beer blue -> false tea blue -> true red 2 -> false British 2 -> false horse blue -> true red horse -> false 1 yellow Norwegian water dunhill cat 2 blue Danish tea blend horse 3 red British milk pallmall bird 4 green German coffee prince fish 5 white Swedish beer bluemaster dog From fredrik at pythonware.com Thu Mar 1 16:35:07 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 01 Mar 2001 21:35:07 GMT Subject: [Q] Inspect variables during execution? References: Message-ID: Daehyok Shin wrote: > Is there any function helping me to inspect variables for debugging during > execution? something like this, perhaps? # # code-example-3.py def keyboard(banner=None): import code, sys # use exception trick to pick up the current frame try: raise None except: frame = sys.exc_info()[2].tb_frame.f_back # evaluate commands in current namespace namespace = frame.f_globals.copy() namespace.update(frame.f_locals) code.interact(banner=banner, local=namespace) # # usage example def func(): print "START" a = 10 keyboard() print "END" func() # START # Python 1.5.2 # Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam # (InteractiveConsole) # >>> print a # 10 # >>> print keyboard # # ^Z # END Cheers /F From stephen_purcell at yahoo.com Tue Mar 27 11:14:23 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 27 Mar 2001 18:14:23 +0200 Subject: Eat this one In-Reply-To: <3AC0B349.EE0AA9B2@hack.org>; from bos@hack.org on Tue, Mar 27, 2001 at 05:35:37PM +0200 References: <3AC0B349.EE0AA9B2@hack.org> Message-ID: <20010327181423.A1260@freedom.puma-ag.com> Rikard Bosnjakovic wrote: > I feel ashamed to show the code, but I didn't find any other solution :) > > What way would be better and _faster_ to wipe out the five chars from > the list? Here is a nice readable way: >>> import string >>> s = 'here is < some > text with& nasty characters' >>> for badchar in "<>&\n": ... s = string.replace(s,badchar,'') ... >>> s 'here is some text with nasty characters' And using regular expressions: >>> import re >>> s2 = re.sub('[<>&\n]', '', s) >>> s2 'here is some text with nasty characters' -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From root at [127.0.0.1] Sat Mar 31 02:22:43 2001 From: root at [127.0.0.1] (deadmeat) Date: Sat, 31 Mar 2001 07:22:43 GMT Subject: list vs tuple References: <3AC20CD3.265A2D94@alcyone.com> <71q9ct4le63anefmiajj5cbh3mg04qu1ga@4ax.com> Message-ID: <7Bfx6.989$p5.3791@news1.rivrw1.nsw.optushome.com.au> > Have you used other languages before coming to Python? I would > think it would be confusing to people who were used to languages > that have a reference/value inconsistency. Python is totally > consistent (everything is a object, all names refer to objects). No it's not. I come from a Pascal background, the behaviour noted in the parent is what would happen if two pointers were made equal. To copy the contents from one variable to another, a ^ is used to refer to the structure at the pointer, not the pointer itself. Python does not do that >>> a = 1 >>> b = a >>> a = 5 >>> b 1 >>> a = [1,2,3] >>> b = a >>> b[1] = 999 >>> b [1, 999, 3] It's dependant on datatype, which most people would think as inconsistant. Example 2 is the same for function arguments, pass all lists to functions with a [:] on the end to ensure your function doesn't modify your list without the parent code knowing about it. From cjw at sympatico.ca Sun Mar 11 12:28:04 2001 From: cjw at sympatico.ca (Colin J. Williams) Date: Sun, 11 Mar 2001 17:28:04 GMT Subject: Python In A Nutshell References: Message-ID: <3AABB165.959ABD5@sympatico.ca> Laura, Two suggestions: * Produce the book with a binding so that it will lie flat on a desk when open * Document the classes in wxPython Colin W. LLewin at oreilly.com wrote: > Hi, > Yep--Python Nutshell is "forthcoming"...we're just in the planning stages at this point--very early on in the process. Any suggestions are welcome! > Laura > LLewin at oreilly.com > > > Hey Alex, congrats on landing "Python In A Nutshell" book deal. One > > problem. I went down to the book store and it's not there. What gives? > > > > > > Don > > > > > > ================================== > Posted via http://nodevice.com > Linux Programmer's Site -------------- next part -------------- An HTML attachment was scrubbed... URL: From piet at cs.uu.nl Thu Mar 29 08:11:20 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 29 Mar 2001 15:11:20 +0200 Subject: Getting all the *files* from a directory -- A better way?? References: <99r6v7$4hef2$1@fido.engr.sgi.com> Message-ID: >>>>> scarblac at pino.selwerd.nl (Remco Gerlich) (RG) writes: RG> Or even RG> dir="a/b/c" RG> files = [os.path.join(dir, f) for f in os.listdir(dir) RG> if os.path.isfile(f)] RG> If you do the map() with a list comprehension, why not the filter() as RG> well. Perhaps because it would have to be: if os.path.isfile(os.path.join(dir, f)) -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From aahz at panix.com Mon Mar 19 09:57:37 2001 From: aahz at panix.com (Aahz Maruch) Date: 19 Mar 2001 06:57:37 -0800 Subject: Problems with 2.0 cgi scripts References: Message-ID: <9956p1$8g0$1@panix3.panix.com> In article , Sheila King wrote: > >So, basically, it cannot find the modules when I run it as a cgi-script. I >have all the paths set correctly, and the permissions set correctly. Grr, I'm >frustrated with this one by now... You can't set the path because you don't own the web server. Simplest solution is to set sys.path yourself as the first line of the script. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 There's a difference between a person who gets shit zie doesn't deserve and a person who gets more shit than zie deserves. --Aahz From NoSpam at NoSpam.com Fri Mar 2 15:27:09 2001 From: NoSpam at NoSpam.com (Tom) Date: Fri, 02 Mar 2001 20:27:09 GMT Subject: Unresolved symbols in MSVCRT.DLL when running a py2exe packaged program. References: Message-ID: "Tim Peters" wrote in message news:mailman.983556668.16192.python-list at python.org... > [Tom] > > I disagree. > > > > You can distribute system dll's. You are expected to, and sometimes you > > have to. You must insure that the version you load is at least > > equal to the version that you linked against. > > > > I have done this (distribute system DLL's) on all windows except WinME and > > the 16bit ones. Unfortunately I can't say how I did it precisely, because > > I just used InstallShield. > > And Python just uses the Wise installer. They aren't that fancy under the > covers, though -- they just "follow the rules", checking version numbers, > bumping refcounts on refcounted DLLs, and arranging for a reboot if they need > to replace something. But that stuff is ineffective on the newer systems > with SFP. > > > But I believe that, where SFP exists, you must use specific and new > > API's to replace DLL's, otherwise the system will back out your changes. > > My understanding is that SFP isn't so easily fooled; e.g., > > http://support.microsoft.com/support/kb/articles/Q253/5/71.ASP > > http://www.microsoft.com/hwdev/sfp/wfp.htm > > SFP won't allow replacement of protected files via just using API tricks; it > also sucks in a digital signature scheme, and only MS can supply signatures > that work. I didn't mean to suggest 'fooling' it - I agree that safeguards like SFP are needed - I meant that one had to do it according to the rules. As for not being able to update the DLL's, this would be a problem. If a service pack for VC6 updates the MFC or CRT DLL's (which SP's usually do), and you ship an app build with it, then you must update these DLL's on your target system. Perhaps this is where the new ability to run 'personal' instances of DLL's comes in: ie. you can't update the system32 version the DLL, but you can install your own personal copy. Tom. > > One solution is to specify the changes in an .INF file and let the system > > worry about these details (but this has its limitations). > > > > I assume that Python itself updates the MSVCRT.dll. > > The PythonLabs Windows installer tries to, yes. > > > Might look at how it does it on Win2K. > > My understanding is that it can't (but Win2K ships with a "good enough" set > of DLLs, so the version check shouldn't trigger there -- yet). > > BTW, I'm *glad* MS is doing SFP! Whatever Windows Life may be in theory, > DLLs in practice cannot be mixed and matched -- you need a self-consistent > set else Very Strange Things Happen. And with about 1,000 DLLs under a > typical Windows system directory, that's just impossible for app developers > to keep straight. May well be impossible for MS to keep straight too, but at > least it's no longer impossible for them to *try* to keep 'em straight now. > > something-to-ponder-each-time-your-win9x-crashes-ly y'rs - tim > > From stephen_purcell at yahoo.com Wed Mar 14 12:20:27 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Wed, 14 Mar 2001 18:20:27 +0100 Subject: Packages, modules and exceptions In-Reply-To: <20010314235842.B2335@madcap.dyndns.org>; from ngps@post1.com on Wed, Mar 14, 2001 at 11:58:42PM +0800 References: <98ip5c$397$1@clematis.singnet.com.sg> <20010312163907.A23991@freedom.puma-ag.com> <20010314235842.B2335@madcap.dyndns.org> Message-ID: <20010314182027.A30729@freedom.puma-ag.com> Ng Pheng Siong wrote: > Within M2Crypto/SSL/Connection.py, I have "class Connection:..." Then, > within M2Crypto/SSL/__init__.py, I have "from Connection import > Connection". This is so that clients can say "s = M2Crypto.SSL.Connection()" > instead of "s = M2Crypto.SSL.Connection.Connection()". > > Because of this, I can't just do "from M2Crypto.SSL import SSLError" > within Connection.py. __init__.py's "from Connection import Connection" > creates a circular reference. You can. There is no problem with such a circular reference. Just try it out. Consider the following files and their contents: ./M2Crypto/SSL/Connection.py #--------- from M2Crypto.SSL import SSLError class Connection: pass #--------- ./M2Crypto/SSL/__init__.py #--------- class SSLError(Exception): pass from Connection import Connection #--------- ./M2Crypto/__init__.py #--------- #--------- I can start Python, and everything works as intended: >>> from M2Crypto.SSL import Connection >>> Connection Magic! -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From bk at xk7.com Thu Mar 1 08:34:51 2001 From: bk at xk7.com (Burkhard Kloss) Date: Thu, 1 Mar 2001 13:34:51 -0000 Subject: python performance References: Message-ID: <983453691.827499@master.nyc.kbcfp.com> Speed is always a tricky issue - in my experience it's fast enough, but YMMV. I would recommend that you write as much as possible in Python to get it working, then profile it and either improve the algorithms or rewrite low level routines in C. Lots of people seem to use this approach for numerical stuff, and if that combination is fast enough for numerics it ought to be fast enough for anything else as well. HTH - Burkhard > Can anyone comment on the speed of Python programs under Windows? > > I am interested in using Python as a embedded game scripting language. > Amongst other things, I want to doing AI, but not the low level routines > like path finding. From tim at vegeta.ath.cx Wed Mar 7 02:16:29 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Wed, 07 Mar 2001 07:16:29 GMT Subject: How to use <>? References: Message-ID: Victor Louie wrote: > I was just wondering if any knew what <> does....I've got some sample code > and can't figure out what's happening > > eg. > x =10 > if x <> 10: > .... It's an alternate operator which is identical in meaning to != (inequality). The following are equivalent: if x != 10: # do stuff if x <> 10: # do stuff HTH -- -Tim Hammerquist Computers are useless. They can only give you answers. -- Pablo Picasso From benjamin.altman at noaa.gov Wed Mar 28 11:41:55 2001 From: benjamin.altman at noaa.gov (Benjamin.Altman) Date: Wed, 28 Mar 2001 11:41:55 -0500 Subject: learning python... References: <3AB8F4E1.184DD9C@noaa.gov> Message-ID: <3AC21453.3A6F8524@noaa.gov> What about the aspect of it covering a version less than 2.0 when Programming Python would be more up to date? Thanks, Ben chris wrote: > "Core Python Programming "from PH is easily the better book for easing into > Python. I am an O'Reilly fan and generally buy their books blind if it is > on a subject I am interested in (since they very rarely disappoint). > However on this occassion the PH book is a genuinely good book and worth > buying, considerably more than the Learning Python book and the 2e version > of Programming Python. > > My opinion! > > Chris From alf at leo.logilab.fr Mon Mar 5 05:46:28 2001 From: alf at leo.logilab.fr (Alexandre Fayolle) Date: Mon, 5 Mar 2001 10:46:28 +0000 (UTC) Subject: Editing Python source as XML? References: Message-ID: <97vqq4$2ap7$1@norfair.nerim.net> Martin von Loewis wrote: > Steven Haryanto writes: >> A recent experience of having to modify a long C source file has >> led me to wonder whether there are any tool/effort towards editing >> Python source code as XML or other form of structured document. > Not sure *why* you'd want to do that, but it is certainly possible to > convert any script automatically to an XML document with the help of > the parser module. I'm releasing today a utility we use at Logilab for documenting the code of Narval. We call it pypasax. It uses the parser module to extract information about classes and methods and generates an XML tree from this. We are working on XSLT to generate XMI files so that we can import the data in some UML tool such as ArgoUML. Alexandre Fayolle -- http://www.logilab.com Narval is the first software agent available as free software (GPL). LOGILAB, Paris (France). From skidrow at nownuri.net Sun Mar 11 05:16:48 2001 From: skidrow at nownuri.net (Seo ji won) Date: Sun, 11 Mar 2001 19:16:48 +0900 Subject: mod_python or MoinMoin problem. Message-ID: <98fioq$qud$1@news2-2.kornet.net> I'm now using FreeBSD 4.2 release, apache 1.3.14, mod_python 2.6.3 and trying to use MoinMoin(one of wiki clones, written in python, and is kind of CGI program I guess) but it doesn't work out. the apache log says, ---------------------------------------------------------------------------- ------------------------- Mod_python error: "PythonHandler mod_python.cgihandler" Traceback (most recent call last): File "/usr/local/lib/python2.0/site-packages/mod_python/apache.py", line 185, in Dispatch result = object(self.req) File "/usr/local/lib/python2.0/site-packages/mod_python/cgihandler.py", line 76, in handler imp.load_module(module_name, fd, path, desc) File "/usr/local/www/cgi-bin/MoinMoin/wiki-moinmoin/moin.py", line 15, in ? cgimain.run() File "/usr/local/www/cgi-bin/MoinMoin/cgimain.py", line 161, in run cgi.print_exception() File "/usr/local/lib/python2.0/cgi.py", line 870, in print_exception print File "/usr/local/lib/python2.0/site-packages/mod_python/apache.py", line 484, in write h, v = string.split(line, ":", 1) ValueError: unpack list of wrong size ---------------------------------------------------------------------------- ----------------------------- What seems to be the problem?.. Thanks in advance. :) p.s) If this news group is not proper to post this message, plz let me know. -- with suitable news group. :) From kens at sightreader.com Thu Mar 15 16:02:05 2001 From: kens at sightreader.com (Ken Seehof) Date: Thu, 15 Mar 2001 15:02:05 -0600 Subject: Should I close after popen?? References: Message-ID: <003201c0ad93$30f982f0$04090a0a@upcast.com> ----- Original Message ----- From: "Sean 'Shaleh' Perry" To: "Andrew Markebo" Cc: Sent: Thursday, March 15, 2001 4:27 PM Subject: RE: Should I close after popen?? > > On 15-Mar-2001 Andrew Markebo wrote: > > I am hacking away a small background program, using popen to call > > commands, should I close the file in some way when done or it is taken > > care of automagically?? > > > > I do something like this once every 10 mins.. > > > > fd1=os.popen("command") > > fd2=os.popen("command") > > os.wait(fd1) > > os.wait(fd2) > > values=fd1.read()+fd2.read() > > > > And.. anything to worry about, nesting popen/wait like this?? > > (Linux/Solaris) > > > > if that is in a loop, it should be fine: > > while 1: > f = open(file) # every time the loop repeats, f gets closed and opened > # again > # do things to f > I don't think that's reliable in general. I'm pretty sure the file gets closed when the file object gets finalized, but you aren't supposed to count on garbage collection to do its job at any particular time. The while loop above could in theory be equivalent to the folowing: f0 = open(file) f0.close() f1 = open(file) f2 = open(file) f3 = open(file) f1.close f4 = open(file) f3.close() f2.close() f4.close() ...because the objects can be deleted whenever the interpreter feels like it. In practice, you'll probably get by with it, but you are setting yourself up for nasty bugs later. In other words, you are better off closing files explicitly. In the case of popen, it seems to me like it wouldn't matter if you leave a few open streams lying around, but it just seems sloppy, like not washing your dishes after dinner. Your usage of wait is fine, (assuming that the fd1 process is never dependent on the fd2 process). > -- > http://mail.python.org/mailman/listinfo/python-list > From gregj at pobox.com Sun Mar 11 16:36:52 2001 From: gregj at pobox.com (Gregory Jorgensen) Date: Sun, 11 Mar 2001 21:36:52 GMT Subject: Einstein's Riddle References: Message-ID: The 2% that can solve it must be psychic or deranged. The riddle as posed is not solvable. We are told of five houses anf five people. The hints mention five colors (red, green, white, yellow, blue), five drinks (tea, coffee, milk, beer, water), five smokes (Pall Mall, Dunhill, Blends, Bluemaster, Prince), and five nationalities (Brit, Swede, Dane, Norwegian, German). But only four types of pet are mentioned: dogs, birds, cats, horse. We have no evidence that any of the five owns fish. More telling: how many people can't quickly determine that this puzzle is unsolvable? In article , Steve Graham says... > >Who would be interested in using his/her brain (and his computer) to solve >the following? > > >Steve Graham > >=== > >Einstein's Riddle > >Albert Einstein wrote this riddle this century [ed. 20th century]. He said >98% of the world could not solve it. > >There are 5 houses in 5 different colors. In each house lives a person with >a different nationality. The 5 owners drink a certain type of beverage, >smoke a certain brand of cigar, and keep a certain pet. No owners >have the same pet, smoke the same brand of cigar or drink the same beverage. > >The question is: "Who owns the fish?" > >Hints: > >The Brit lives in the red house. > >The Sweed keeps dogs as pets. > >The Dane drinks tea. > >The green house is on the left of the white house. > >The green house's owner drinks coffee. > >The person who smokes Pall Mall rears birds. > >The owner of the yellow house smokes Dunhill. > >The man living in the center house drinks milk. > >The Norwegian lives in the first house. > >The man who smokes Blends lives next to the one who keeps cats. > >The man who keeps the horse lives next to the man who smokes Dunhill. > >The owner who smokes Bluemasters drinks beer. > >The German smokes Prince. > >The Norwegian lives next to the blue house. > >The man who smokes Blends has a neighbor who drinks water. Greg Jorgensen Deschooling Society Portland, Oregon, USA gregj at pobox.com From kuncej at mail.conservation.state.mo.us Tue Mar 20 16:12:33 2001 From: kuncej at mail.conservation.state.mo.us (Jeff Kunce) Date: Tue, 20 Mar 2001 15:12:33 -0600 Subject: (no subject) References: Message-ID: > I want to execute an executable binary as thought through the Command-Line. in addition to os.system(), take a look at win32api.ShellExecute() --Jeff From hgg9140 at seanet.com Sat Mar 17 22:47:14 2001 From: hgg9140 at seanet.com (Harry George) Date: 17 Mar 2001 19:47:14 -0800 Subject: installing 2.x over the top of 1.5.2 References: Message-ID: Don't know if this qualifies as clean. I have the rpm'd 1.5.2 under /usr. Then I installed py 2.x under /usr/local. During our (extended) transition period, we use shell scripts which set PYTHONHOME and PYTHONPATH before calling python1.5 or python2.0. Once all is well in 2.x, we'll remove the rpm'd 1.5.2, and (conceivably) install 2.x into /usr. Timothy Grant writes: > This problem has been bothering me for a while. > > Python v1.5.2 is installed by default on RH6.2 boxes. > > My problem is that upgrading an RH6.2 box by using the 2.x rpms > now means that there are two versions of Python installed on my > box, and any extra modules I have installed have to be copied > to the new location for v2.x. I then need to uninstall the > v1.5.2 rpms. > > I'm sure someone somewhere has come up with a clean way of > upgrading Python. As with all thing Pythonic, there must be an > easier way. > > -- > Stand Fast, > tjg. > > Timothy Grant tjg at exceptionalminds.com > Red Hat Certified Engineer www.exceptionalminds.com > Avalon Technology Group, Inc. <>< (503) 246-3630 > >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< > >>>>This machine was last rebooted: 60 days 4 hours ago<< From bwalker at earth1.net Mon Mar 26 15:14:05 2001 From: bwalker at earth1.net (Bill Walker) Date: Mon, 26 Mar 2001 15:14:05 -0500 Subject: Some Basic Questions about Python Message-ID: I am fairly new to OOP, but I have done quite a bit of programming in Dos Basic a few years back. I've tried Java -- forget that. Perl too. I bought the book "Core Python Programming" by Wesley Chun. It had Python 1.5 on the CD-ROM that came with the book as well as TK graphics. I have successfully written a Python program to display the graph of a sine wave in a Tk window. I like the syntax. Now for the questions: 1) If I write an application and want to pass it on to others who may not have Python installed, how do I do this? I understand there is no compiler for Python and Tk yet that generates .exe files. 2) Can I distribute the Python install file along with my app without violating a copyright or license? 3) Better yet, can I include only the base files needed to run my application with the source code? Say Pythonw.exe and only the appropriate DLLs, libs, etc. I tried to do #3 above and ran into trouble. It is hard to determine just what dlls, libs and the like are actually needed, even for a simple program that uses only the Tk and math modules. 4) Is there docs somewhere that tells one what files are needed for what modules? From mcherm_python at yahoo.com Tue Mar 20 11:12:52 2001 From: mcherm_python at yahoo.com (Michael Chermside) Date: Tue, 20 Mar 2001 10:12:52 -0600 Subject: New PEP: The directive statement Message-ID: <3AB78184.5060409@yahoo.com> > Please have a look at the PEP below. Martin: After all the heated discussion going on here, I'm glad SOMEONE finally responded to Tim's request to write it up as a PEP. Now, as Tim points out, you'll probably hear lots of complaints about why "directive" is a poor idea. But thanks for writing it up... we can't have "from __future__ import" being the only target, now can we? Seriously, it looks well-written, TRIES (I think) to incorporate the vast majority of what people have said on the subject so far, and as Tim pointed out, it was high time it got written. -- Michael Chermside _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From tim.hochberg at ieee.org Tue Mar 20 16:12:58 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Tue, 20 Mar 2001 21:12:58 GMT Subject: Insertin **keywords into a class References: <9960i1$tp0$1@nntp6.u.washington.edu> <99661m$scc$1@panix6.panix.com> <99877b$uss$1@nntp6.u.washington.edu> Message-ID: "C. Porter Bassett" wrote : > cCan you please tell me why the following code snippet doesn't update the > value of radius? Because you are updating self.kw instead. Try: setattr(self, kw, keywords[kw]) instead of "self.kw = keywords" I'll make a bit of attempt to expain this, but no gaurantees that it'll be helpful. "self.kw = keywords[kw]" in this case is translated into "setattr(self, 'kw', keywords[kw])". Note the quotes around the first kw. You don't want that. The way you do it now, sets self.kw is set sucessively to each value in keywords. You might want to throw a "print self.kw" into your code after the "self.kw =..." line just to see what I mean. Incidentally, I think you can accomplish the same things with: class myClass: def __init__(self, *arguments, **keywords): self.radius = 0.0 self.__dict__.update(keywords) print "self.radius =", self.radius But I haven't tried it. -tim > class myClass: > def __init__(self, *arguments, **keywords): > self.radius = 0.0 > for kw in keywords.keys(): > print kw, ":", keywords[kw] > self.kw = keywords[kw] > print "self.radius =", self.radius > > > b = myClass(radius = 1.0) > > > -------------------------------------------------------------------------- > "Pretend like this is a really witty saying." - Anonymous > -------------------------------------------------------------------------- > > > From j_wesselink at chello.nl Wed Mar 21 19:24:47 2001 From: j_wesselink at chello.nl (Wieger Wesselink) Date: Thu, 22 Mar 2001 00:24:47 GMT Subject: starting Java VM using JNI? Message-ID: <3AB9487C.F528E426@chello.nl> I'm trying to start a Java VM in Python using JNI, with the following C++ code: void start() { JNIEnv *env; JavaVM *jvm; JavaVMInitArgs vm_args; JavaVMOption options[2]; options[0].optionString = "-Djava.class.path=D:\\java"; vm_args.version = 0x00010002; vm_args.options = options; vm_args.nOptions = 1; vm_args.ignoreUnrecognized = JNI_TRUE; jint res = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args); if (res < 0) { exit(1); } } That appears to work, but there is a problem. After invoking the function start() in Python, the interepreter generates syntax errors after each subsequent input (see below). Can someone tell me how to fix this, or is there a better way to start the JVM? Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> import mymodule >>> mymodule.start() >>> File "", line 1 ^ SyntaxError: invalid syntax >>> Best regards, Wieger From nospam at mega-nerd.com Thu Mar 15 14:38:12 2001 From: nospam at mega-nerd.com (Erik de Castro Lopo) Date: Thu, 15 Mar 2001 19:38:12 GMT Subject: Tkinter : resizing Text widget with main window Message-ID: <3AB11827.469F6C0C@mega-nerd.com> Hi all, How does one force a Tkinter.Text widget to be resized whenever the main window is resized? TIA, Erik -- ----------------------------------------------------------------- Erik de Castro Lopo nospam at mega-nerd.com (Yes its valid) ----------------------------------------------------------------- IDIOT, n. A member of a large and powerful tribe whose influence in human affairs has always been dominant and controlling. The Idiot's activity is not confined to any special field of thought or action, but "pervades and regulates the whole." He has the last word in everything; his decision is unappealable. He sets the fashions and opinion of taste, dictates the limitations of speech and circumscribes conduct with a dead-line. Ambrose Bierce From tim.one at home.com Sat Mar 10 18:03:45 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 10 Mar 2001 18:03:45 -0500 Subject: Memory leaks in VC6 2 line Python 2.1b1 apps? In-Reply-To: <98b0a0$2g8i$1@shadow.skypoint.net> Message-ID: [Craig Holman] > I'm afraid that both versions 2.0 and 2.1b1 leak memory for a single > Py_Initialize, Py_Finalize sequence in a Visual C++ MFC application. The bad news is that there are legit bugs in 2.0 here. The good/bad news is that it's got nothing to do w/ MFC (it's much the same on all platforms). The bad/good news is that 2.1b1 appears to be "leaking" exactly as much as it's designed to "leak". > ... > Python 2.1b1 had 21 memory leaks that resulted in a leakage of a > total of 6,899 bytes for a single pair of Py_Initialize, Py_Finalize > calls. Additional Py_Intitialize, Py_Finalize pairs did not result > in any additional leakage (10,000 pairs were tested). Then it's functioning as designed. Python has no protocol to let modules know that Python is shutting down, so any number of file statics "leak" at shutdown. However, modules are also written so as to reuse those guys at the next Py_Initialize, so they're "leaks" in a mostly academic sense; i.e., the cost of hunting all of them down is thought higher than the benefits of killing them. Besides, we could well end up with more than 7Kb of runtime code to track down and nuke that 7Kb of data you're seeing! So long as additional (beyond the first) Init/Fini pairs don't systematically leak additional memory, we're happy enough. > ,,, > I'm hoping that some of these leaks can be addressed before the 2.1 > release is issued. It's unlikely unless somebody submits "obviously safe" patches. Most leaks now appear due to interned strings, and I'll push a bit to get those cleaned up (they already are in 2.1b1, but only when Barry is running *his* leak tests under Insure++). the-question-is-how-python-knows-when-barry-is-running-it-ly y'rs - tim From aahz at panix.com Mon Mar 19 18:48:55 2001 From: aahz at panix.com (Aahz Maruch) Date: 19 Mar 2001 15:48:55 -0800 Subject: Why "from __future__" stinks; a counter-offer References: Message-ID: <9965t7$s57$1@panix6.panix.com> In article , Tim Rowe wrote: > >But there's part of the problem; egoless PEP writing is as hard as >egoless programming, and having come up with a solution the author >of that solution is bound to have some emotional involvement in that >solution. There have been (rightly IMHO) howls of protest about >__future__, but Tim has said it's ok for him, routinely dismisses all >protests, presumably because he genuinely doesn't understand what our >problem is, and he tells us it's going in anyway. Can you see why we're >not all convinced that the PEP process is any help to us? I think that of the various people to accuse of having an ego tied up in something, the Timbot is one of the last that I would choose. No, it's more that Uncle Timmy is *lazy*. Thus, to get his interest, you have to appeal to his laziness. So far, no other person has actually come up with a scheme that addreses the problem at hand, as opposed to simply whining, suggesting minor and worthless variations, or putting forth even *more* complicated solutions. One of the nice things about this solution is that if it is decided to be an ugly wart, it can be easily dropped for Python 2.2. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 There's a difference between a person who gets shit zie doesn't deserve and a person who gets more shit than zie deserves. --Aahz From rburnham at cri-inc.com Fri Mar 2 19:38:12 2001 From: rburnham at cri-inc.com (Roger Burnham) Date: Sat, 03 Mar 2001 00:38:12 GMT Subject: Communicating with serial port References: Message-ID: <3aa039a6.210669196@news-server.socal.rr.com> On Fri, 2 Mar 2001 14:16:58 +0100, "Peter Blom" wrote: >I shall write a python program for downloading data from a memory card in a >measuring instrument, via a serial port. >For this purpose, I have downloaded SioModule.zip - a serial comm extension >for windows 95, upgraded to Python 1.5.1. >This does not seem to work - when importing the module 'serial.py', my >system hangs (Windows 98, Activestate Python 2.0). >Could anybody give a hint? > >Peter (a newbie) > > Hi, I'm the SioModule author. While I deal with getting my starship account back active (where this installer will soon be), I've sent you via email the installer that will work with 2.0. Cheers, http://starship.python.net/crew/roger/ Roger Burnham rburnham at cri-inc.com From claird at starbase.neosoft.com Wed Mar 14 11:28:26 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 14 Mar 2001 10:28:26 -0600 Subject: Who's minister of propaganda this week? References: <98nu1m$12e@dispatch.concentric.net> Message-ID: <660ACCA1E4816F7E.C359CDF4168EF3FB.3B6B05538D619770@lp.airnews.net> In article <98nu1m$12e at dispatch.concentric.net>, Phlip wrote: . . . >Robert C. Martin meant two things. A> If you write wall-to-wall unit tests >when you code, if you use a typeless language you will add bullet-proof >features faster than if you use a statically typed language, even though >the former has less built-in error checking at type conversion time. The >latter supports refactoring easier. . . . Along with this, there's an important *empirical* aspect that I regard as inadequately appreciated. Uche recently expressed it this way: Type errors are not even close to the majority of those I make while programming in Python, and I'm quite certain that the code I've written in Python is much less buggy than code I've written in strongly-typed languages. Expressiveness, IMO, is a far better aid to correctness than artificial restrictions (see Java for the example of school- marm programming gone amok). It's OK to think, "gosh, with strict typing we save errors, and with Hungarian notation we save errors, and ..." We've done enough experiments by now, though, to convince at least me that it is exactly true that Expressiveness ... is a far better aid to correctness ... I leave to another time fine points about how there are more advanced systems of strict typing (Dylan, for example), and about other dimensions in which managerially-accepted languages differ from Smalltalk, Python, and Ruby; I just want to empha- size for now that, among the few reasonably certain results Software Engineering has given us, the dominance of expressive- ness is one of the most important. Myself, I prefer to "write wall-to-wall unit tests" *before* I code. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From mwh21 at cam.ac.uk Mon Mar 5 15:13:20 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 05 Mar 2001 20:13:20 +0000 Subject: Static class methods References: Message-ID: "Alex Shindich" writes: > Just out of my curiosity, have any of you ladies and gentlemen > experienced a need for an equivalent of C++/Java static method? Here's a particularly nasty way to do what you want. class C: class _Temp: def __call__(self, arg): print arg static = _Temp() del _Temp def call_static(self): self.static("from meth") Then: >>> C.static("from cli") from cli >>> C().static("from cli 2") from cli 2 >>> C().call_static() from meth Cheers, M. -- There are two kinds of large software systems: those that evolved from small systems and those that don't work. -- Seen on slashdot.org, then quoted by amk From sekter at matavnet.hu Fri Mar 9 05:31:51 2001 From: sekter at matavnet.hu (Arpad Kiss) Date: Fri, 09 Mar 2001 11:31:51 +0100 Subject: OODB question References: Message-ID: <3AA8B117.1050107@matavnet.hu> No, you did't dream. Zope has an OODB named ZODB. Look for it on www.zope.org or on www.amk.ca/zodb/ there are some good docs and a separate distribution (without Zope). Arpad chris lamb wrote: > I am sure that I read somewhere of an OODB implementation developed > > specifically with Python or having a Python interface. > > > > I am beginning to wonder if I dreamt it up since I cannot remember where I > > read about it! > > > > Can anyone help me ? (I doubt it!) > > > > Best wishes > > > > Chris -- "Don't try to teach a pig to sing; it wastes your time and it irritates the pig." Awareness by Anthony de Mello From rickylee at americasm01.nt.com Wed Mar 7 12:55:17 2001 From: rickylee at americasm01.nt.com (Lee, Rick) Date: Wed, 07 Mar 2001 12:55:17 -0500 Subject: Setting interactive flag inside a script? Message-ID: <3AA67605.B04B1135@americasm01.nt.com> Is there a way to set the python interactive flag, ie. the '-i' flag in the command line, inside a script itself? (Motivation: Sometimes you give someone else a .py script, s/he doubleclicks on it, something may have gone wrong, and the command line window just disappears. If the script can turn the interactive flag on, then the window won't just disappear by default. When the script finishes properly, it can turn the flag off just at the very end.) - Rick Lee From pearu at cens.ioc.ee Thu Mar 22 16:44:31 2001 From: pearu at cens.ioc.ee (Pearu Peterson) Date: Thu, 22 Mar 2001 23:44:31 +0200 Subject: PEP 240 scares me Message-ID: Hi! I very much agree what is in PEP 240 Rationale, but its Proposal scares me a lot, its like a nightmare (and I actually don't see any logical connection between the Rationale and the Proposal). Let me explain why. It is true that 1/2 == 0 surprise new (Python) programmers (but I quickly learned to write 1./2 or 1/2. or 1/float(n) etc). But making 1.2 to be a rational 1 --- 2 will most definitely surprise new (Python) programmers even more *because* in ever programming language I know of (C, Fortran, Maple, Mathematica, Matlab to name few), use 1.2 to denote a float that is equal to 6 --- 5 (up to a computers ability to represent such a number in float). I apologize if my message is too emotional but after reading the PEP 240 Proposal, I felt very uncomfortable. I think that any of the following representation of rational numbers are much more appropriate, though none of them is perfect: 1//2 1r/2 (like 1j+2 is a complex number) 1/2r (like 1+2j) 1_2 1:2 (that's probably tricky in Python) Note that they all raise SyntaxError in current Python, so, just pick one and there will be no backwards compatibility problems. Using 1.2 for a `half' will probably break any Python code that does (scientific) numerical calculations. In conclusion, I will look forward for Python to support rational numbers. Though floats are always imperfect in computers representation, somebody in c.l.py even said hating floats. I don't love them either but I *do* need them. Let's not make things worse than they already are. Regards, Pearu From ccraig at ccraig.org Wed Mar 28 11:08:25 2001 From: ccraig at ccraig.org (Christopher A. Craig) Date: 28 Mar 2001 11:08:25 -0500 Subject: Speed problems with Python vs. Perl References: <99sv33$8hk$1@news.cineca.it> <1znw6.1969$sk3.665386@newsb.telia.net> Message-ID: <87y9tplvuu.fsf@elbereth.ccraig.org> "Fredrik Lundh" writes: > assuming you're using Python 2.1, the following version is > about 16 times faster on my box: > > import sys > > def main(): > > icount = 0 > for line in sys.stdin.xreadlines(): > icount += 1 > f = line.split() > print "Total lines read", icount > > if __name__ == '__main__': > main() > You can't necessarily blame this on the line I/O performance because you used line.split() where he used the split method on a regular expression object. Testing just the differences in those two I show a 10 fold improvement on line.split(). In this case that is valid since you are splitting on whitespace in both Perl and Python, but it would be interesting to see if Python still holds up under more complex regular expressions. I went ahead and used --- Python Script --- import re import sys r = re.compile(":+") def main(): icount = 0 while 1: lines = sys.stdin.readlines(50000) if not lines: break for line in lines: icount += 1 f = r.split(line) if __name__=="__main__": main() --- End Python Script --- vs. --- Perl Script --- $icount = 0; while(<>) { $icount++; @f = split(/:+/); } --- End Perl Script --- with Python 2.0 and Perl 5.6.0 on a Celeron 300A using a 242000 line input file and I got the following results: python: 61.10s user 0.42s system 87% cpu 1:10.37 total perl: 11.31s user 0.10s system 76% cpu 14.960 total admittedly Python is being hurt by the slower 2.0 line I/O, but I would guess that regular expressions are still hurting performance. -- Christopher A. Craig "Parity is for farmers." Seymour Cray on his machines lack of parity "I guess farmers buy a lot of computers." Seymour Cray on including parity From phd at phd.pp.ru Mon Mar 5 09:31:26 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Mon, 5 Mar 2001 17:31:26 +0300 (MSK) Subject: Open Source In-Reply-To: <9806i4$2e97$1@news3.infoave.net> Message-ID: On Mon, 5 Mar 2001, Alton Luder III wrote: > Is there any place on the web that offers open source python programs. It > might be helpful for me to learn if I see other people's program's source > code. Welcome! There are a lot. Run through Parnasus (vex.net/parnasus) and downlaod what you may find interesting. Parnasus is not downloading site, just a catalog of links, but pretty good catalog. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From paulp at ActiveState.com Wed Mar 14 09:49:34 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 14 Mar 2001 06:49:34 -0800 Subject: Who's minister of propaganda this week? References: <98nu1m$12e@dispatch.concentric.net> Message-ID: <3AAF84FE.F28A2C30@ActiveState.com> Phlip wrote: > > ... > > B> The full depth of behaviors we should expect from a typeless language > have yet to be fathomed. Ruby trumps Python in the simple matter of > closures (imagine my shock when I discovered Python didn't have them). But > a language "like" those might win the decade. I don't know if you are serious (I mean closures are NOT that important!) but anyhow, Python 2.1 has nested scopes and I think that functions defined in those scopes are closures just like in any other language. -- Python: Programming the way Guido indented it. - (originated with Skip Montanaro?) From wunschname at kapet.de Fri Mar 23 12:25:23 2001 From: wunschname at kapet.de (Karsten Petersen) Date: Fri, 23 Mar 2001 18:25:23 +0100 Subject: Python MPI References: Message-ID: <3u0g99.vn3.ln@dollerup.csn.tu-chemnitz.de> Eugene Leitl wrote: > I've just came back from a 3 day MPI course, and promptly noticed that > I can use Python with MPI (yay!): > http://www.fysik.dtu.dk/~schiotz/comp/PythonAndSwig/pythonMPI.html Well, that only describes how to use Python with C-modules using MPI. I found it even more interesting to call MPI functions directly from Python - thats possible with e.g. the MPI-module contained in ScientificPython 2.1. http://starship.python.net/crew/hinsen/scientific.html The above link also describes, that you have to patch your Python executable. But my tests with lam-mpi and mpich had shown that it is not really needed - they finish themself cleanly even if MPI_Finalize is not called. > Any MPI Python users here? I'll be interested in hearing your experiences. I used Python with the MPI-Module from Scientific-Python 2.1 during the last months to do my MPI-coding homework. Currently I am trying to write a parallizing fractal-generator in Python using MPI, NumPy and PyGTK... Greets, Karsten -- ,-, Student of Computer Science at Chemnitz University of Technology ,-, | | EMail: Karsten at kapet.de WWW: http://www.kapet.de/ | | '-' Home: kapet at dollerup.csn V72 / 230 Phone: +49-177-82 35 136 '-' From cce at clarkevans.com Tue Mar 20 00:39:34 2001 From: cce at clarkevans.com (Clark C. Evans) Date: Tue, 20 Mar 2001 00:39:34 -0500 (EST) Subject: Functionalism, aesthetics Was:(RE: I come to praise .join, not In-Reply-To: <5.0.2.1.0.20010319224910.021134d0@mail.inet.com.br> Message-ID: > I'm lost for words... This summarizes a lot of concerns that sometimes I > find so hard to explain. Anyone who has actually *read* Christopher > Alexander's books on design should know that the best solutions are the > ones that take into account the inner sense of satisfaction of their end > users. As Alexander puts it itself, it is a rewarding experience born out > of the "completeness" of the solution. The best solutions also share > another common trait: they look *and feel* good to the untrained eye. > Beware of works that can only be appreciated by experts - they are way too > trained to see the obvious. CA has a nice talk at OOPSLA a few years back, '97 I believe, where he really got into these kind of items. The speech challenged programmers to take an ethical/humane approach to software construction. As a programmer I really didn't clue in to what he was talking with. Recent work at a local museum has made me see better, the software they use is deeply disturbing -- the antithesis of aestetic concern. Such a sharp contrast with the beautyful objects on the table less than a meter away. Mike C. Fletcher wrote: > The reason I felt it necessary to jump in here again is the implicit > creation of a "inner circle" of the "initiated" who are considered > "worthy" to contribute to a discussion about the evolution of the > language. In my experience, Inner circles tend to be self serving and I avoid them at all costs. Meritocracy works much better. > The users of a system, whether it is a building, a language, a piece of > software, or a chair, need to be heard. A user complaining that something > is "ugly", "bad" or "wrong" needs the nature of their discomfort > ascertained, and that knowledge integrated into further design decisions. Now, a user community is a horse of a different color. And, indeed, I would hope that a strong user community emerges with a voice equal to the implementers. However, this maturity has yet to come to the software world -- I think it will take many many years. > Designers who ignore their users, assuming that their own > understanding of the system is correct, and that anyone who > is unable to speaking the dialect of designers cannot possibly > contribute to a design, will create monstrosities which are next to > impossible to inhabit. Hear Hear! If only you would broadcast your post on the xml-dev mailing list... XML Schema is an abomination. > Its unfortunate that in many cases the non-expert user keeps quiet, > assuming that whatever opinion the "master" haves, its going to be better > than theirs - after all they are the so-called experts. Well, this is a problem with open source in general. Most coders have the attitude: "If you can't code, get out of the kitchen". Sad, but true. Clark From jmarshal at mathworks.com Thu Mar 1 13:01:09 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 1 Mar 2001 18:01:09 GMT Subject: A counter-proposal to __future__ in PEP 236 References: Message-ID: <97m2p5$3au$2@news.mathworks.com> Martin von Loewis wrote: ... > In this implementation, directive is only considered as a keyword if > it appears at the beginning of the module. Therefore, code that > happens to use directive as an identifier will not break (unless it > assigns to directive as the first thing in the module). Note that it doesn't need to be implemented this way. Currently, directive foo is a syntax error. Meaning can be assigned to this syntax without breaking any existing code--it is unambiguous. From tjreedy at udel.edu Mon Mar 12 17:00:09 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 12 Mar 2001 17:00:09 -0500 Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> Message-ID: <98jgij$si1$1@news.udel.edu> wrote in message news:3aad4062.1290021 at News.CIS.DFN.DE... > Ok, I can see maybe division having problems. But why does addition of the two numbers below: > > 5.01+5.54 > > give me this? > > 10.550000000000001 Neither 5.01, 5.54, nor 10.55 have exact binary representations. Floating point arithmetic is always slightly approximate unless you only use 'binary' fractions like .5, .25, .125, .0625, etc and multiples. Understanding and controlling such inexactness is a large part of the discipline of numerical analysis. > I hope its some setting that can take care of this. I am using Python under Windows 98. You can hide the inexactness by displaying results with % formats. Terry J. Reedy From erno-news at erno.iki.fi Tue Mar 27 03:24:03 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 27 Mar 2001 11:24:03 +0300 Subject: HTTP redirect via Python? References: Message-ID: In article , "John E. Barham" writes: | Apologies if this is too basic a question, but I'm wondering how I can send | a redirect/URL rewrite command to a browser via Python. | The context: we're developing a fairly substantial Web-based application | and using Python for the CGI coding (which is working beautifully, BTW). In | order to partially protect ourselves (and the users ;) against | back/forward/refresh with forms, we'd like to send them to a "safe" URL | after a form has been submitted. How can we do this? There doesn't appear | to be anything to do this in module cgi... | If it's a server dependent thing, we're using Apache. def print_redirect(url): print 'Status: 302 Moved Temporarily' print 'Location:', url print 'Pragma: no-cache' print 'Content-Type: text/html' print print '' print 'Redirect (302)' print '

302 Moved Temporarily

' print '

The answer to your request is located at' hurl = cgi.escape(url, 1) print '%s.' % (hurl, hurl) note that the url must be absolute. -- erno From syver at NOSPAMcyberwatcher.com Wed Mar 14 17:05:39 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Wed, 14 Mar 2001 23:05:39 +0100 Subject: windows script host and python References: <%tKr6.2570$pX.26174@news1.onlynews.com> Message-ID: <98oq3r$1e0$1@troll.powertech.no> "Mike Carifio" wrote > I'm looking for some resources on using python with wsh generally. Just curious but what do plan to acheive by using python with wsh that you couldn't do using normal .py files? From ransen_spam_me_not at nemo.it Wed Mar 7 13:02:54 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Wed, 07 Mar 2001 18:02:54 GMT Subject: tokenizer.c crashes in 2.1b1 References: <3aa34d5c.1284101@news.newsguy.com> <3aa5d493.5922346@news.newsguy.com> <984q1m0skr@news1.newsguy.com> Message-ID: <3aa76191.1071940@news.newsguy.com> On Wed, 7 Mar 2001 09:03:58 +0100, "Alex Martelli" wrote: >"Owen F. Ransen" wrote in message >news:3aa5d493.5922346 at news.newsguy.com... >> On 06 Mar 2001 12:54:06 -0800, Ben Hutchings >> wrote: >> >> >> The debugger points to the guilty party: >> >> tokenizer.c, the fgets call at line 247 fails. >> >> My VC project uses Multithreaded Debug compiler settings, >> >> as does the Pythoncore project. > [snip] >> Debug Multithreaded in my MFC app make settings >> Debug Multithreaded DLL in the Pythoncore DLL make settings >> >> Is this wrong? > >Yes: Oops! Thanks for the pointer... -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From costas at meezon.com Sat Mar 10 23:53:01 2001 From: costas at meezon.com (Costas Menico) Date: Sun, 11 Mar 2001 04:53:01 GMT Subject: import headaches/gripes References: <3aaa3f94.15940553@News.CIS.DFN.DE> Message-ID: <3aaafcdd.344477@News.CIS.DFN.DE> Paul Prescod wrote: >> Why can't the import statement be smart enough to check if a file was >> changed to import it anyway? All it has to do is compare .py to the >> last import date/time. > >I think there are two reasons: > > 1. Even checking file dates has a performance cost. It involves going >to the hard disk after all. Code like this isn't rare in Python > >def foo(): > import bar > .... > > 2. What would happen if you built a big, long-running application and >then changed a file while it was running. Would you really want one >import statement in the file to load the new version? Then you would >have objects floating around from the old version alongside objects from >the new version. When it crashed due to the inconsistency, it would be >very confusing. > >Pythonwin is one big long-running Python app. In that particular >situation you might prefer it to act differently but Python doesn't >really have a feature that allows what you want...and even if it did, >you'd have to be careful because you could get into the same situation >where you had old objects hanging around with the old behavior. That >happens even with a reload today. > >> if module_exists(utils): >> reload(utils) >> else: >> import utils > >You can make it simpler than that: > >import utils >reload(utils) > >The first operation will continue silently and quickly if the module is >loaded. Then it will be reloaded. The only "cost" is that the very first >time you would load the module twice in a row... Well, I didnt expect anyone to change the way the import works. But your idea of the two in a row is good. Now if I could write a function that I can call to do this, then I can enable and disable the reload() at will. Maybe a solution: import aModule1 alias aName1; assert reload(aName1) import aModule2 alias aName2; assert reload(aName2) Then turn off debugging when done. Thanks Costas From guido at digicool.com Mon Mar 26 04:46:48 2001 From: guido at digicool.com (Guido van Rossum) Date: Mon, 26 Mar 2001 04:46:48 -0500 Subject: WANTED: chairs for next Python conference Message-ID: <200103260946.EAA02170@cj20424-a.reston1.va.home.com> I'm looking for chairs for the next Python conference. At least the following positions are still open: BOF chair (new!), Application track chair, Tools track chair. (The Apps and Tools tracks are roughly what the Zope and Apps tracks were this year.) David Ascher is program chair, I am conference chair (again). We're in the early stages of conference organization; Foretec is looking at having it in a Southern city in the US, towards the end of February 2002. --Guido van Rossum (home page: http://www.python.org/~guido/) From bernie at pacific.net.hk Mon Mar 12 13:45:18 2001 From: bernie at pacific.net.hk (bernie) Date: Tue, 13 Mar 2001 02:45:18 +0800 Subject: (no subject) References: Message-ID: <3AAD193D.EAC30597@pacific.net.hk> Try www.modpython.org Bernie ?i???q wrote: > Hi All, Can I find Apache module for Python ?? > -- > Best Regards, Winson Chang 3F, 2, 150 Lane, Sec. 5, Hsin I Rd., > Taipei, Taiwan, R.O.C. Tel: +886-2-27225333 ext 376 > Fax: +886-2-27222330 Email: winson at mdsserv.mds.com.tw -------------- next part -------------- An HTML attachment was scrubbed... URL: From igorr at ifi.uio.no Thu Mar 1 10:55:07 2001 From: igorr at ifi.uio.no (Igor V. Rafienko) Date: 01 Mar 2001 16:55:07 +0100 Subject: str behaviour Message-ID: Hi, I was playing around with printing tuples, when I noticed how str behaves with "compound" types (such as tuples): >>> class A: ... def __str__( self ): ... return "I'm A" ... >>> a = A() >>> t = ( A, a ) >>> str( t ) '(, <__main__.A instance at 810f090>)' >>> str( a ) "I'm A" >>> I expected str to be called recursively for the constituent types. But, alas, that did not happen. Am I misunderstanding something or is it the intended behaviour? If the latter is the case, could someone elaborate on why this behaviour was chosen? TIA, ivr -- Besides, meat tends to run away when possible, or fights. Either response presents behavioral challenges too complex for any existing robot. -- Stuart Wilkinson, inventor of the "gastrobot" From grante at visi.com Wed Mar 7 12:22:11 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 07 Mar 2001 17:22:11 GMT Subject: Can anyone recomend a good intoduction to C... References: <3AA5EF59.507F1D91@olsen.ch> <983958878.976344@newsmaster-04.atnet.at> Message-ID: <77up6.1289$y6.235541@ruti.visi.com> In article <983958878.976344 at newsmaster-04.atnet.at>, Werner Schiendl wrote: > >> I don't think C deserves all the superlatives you apply to it, >> but I agree that it's instructive to study C++ as an example of >> a language that gets it wrong. Take a good language, C; add >> some good ideas; and end up with a baroque mess. Fascinating. > >To be completely honest, I can not see the obvius reason why >C++ should be such a bad programming language. It's complicated and unsafe. Either one is tolerable without the other. When you combine the two, you're dead. >It is widely available (on almost any platform, I would guess). If 1 billion people do a stupid thing, it's still a stupid thing. >It supports for a real large number of different design approaches. That isn't always a good thing. ;) -- Grant Edwards grante Yow! It was a JOKE!! Get at it?? I was receiving visi.com messages from DAVID LETTERMAN!! YOW!! From whisper at oz.net Tue Mar 27 14:48:19 2001 From: whisper at oz.net (Dave LeBlanc) Date: 27 Mar 2001 19:48:19 GMT Subject: Python scripts as Drop targets in Windows Explorer References: <99qogo$o6g$1@troll.powertech.no> Message-ID: <99qqq3$qt7$0@216.39.170.247> I can't speak for others, but i'd be reluctant to even attempt to import the following into my registry without knowing exactly what it does. How about using the export option in regedit for a human readable version of this please? Interesting idea though :-) Dave LeBlanc On Tue, 27 Mar 2001 20:53:21 +0200, "Syver Enstad" wrote: >Run the attached .reg file (or enter the contained information manually) to >make python scripts behave like .exe in the way that you can drop files on >them and the files will appear in the sys.argv list as command line >arguments. > What contained information? >Something to consider for the installer of the win32 port of python maybe? > From nospam at wanted.com Tue Mar 6 10:25:51 2001 From: nospam at wanted.com (huber) Date: Tue, 6 Mar 2001 16:25:51 +0100 Subject: Tkinter eventmask ? Message-ID: how can i get the modifiers ( Control, Shift ..... ) from a KeyPress event ? From costas at meezon.com Thu Mar 1 21:17:02 2001 From: costas at meezon.com (Costas Menico) Date: Fri, 02 Mar 2001 02:17:02 GMT Subject: compile() source code from a string References: <3a9ee600.391990@News.CIS.DFN.DE> Message-ID: <3a9f01f5.7549826@News.CIS.DFN.DE> If you look at my post this is exactly what I am doing. I cannot get this to work with multiline code (as in my example). Can you give me an example how to make it work? costas Alex wrote: > >>>> print compile.__doc__ >compile(source, filename, mode) -> code object > >Compile the source string (a Python module, statement or expression) >into a code object that can be executed by the exec statement or eval(). >The filename will be used for run-time error messages. >The mode must be 'exec' to compile a module, 'single' to compile a >single (interactive) statement, or 'eval' to compile an expression. >>>> > >So, you want the 'exec' option. > >Alex. > From aleaxit at yahoo.com Fri Mar 16 15:46:33 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 16 Mar 2001 21:46:33 +0100 Subject: Yet another C++ binding (using Extension Classes) References: Message-ID: <98tu4i06kq@news2.newsguy.com> "Lee, Jaeho" wrote in message news:mailman.984760603.29541.python-list at python.org... > > About a year ago, I had to bind a C++ template class into objects that > > could be used from within python. I made a wrapper for Extension > > Classes that extended the basic structure into a C++ class. Any objects > > that subclassed this class would automagically become valid python > > objects and could be extended in much the same way as Extension Classes. > > I am researching on how to expose "complex" C++ class in python. I found > that SWIG does not support well my specific purpose. If you can open your > source code (even with document - how great !!), it will be very helpfu. Have a look at www.boost.org, specifically the Boost Python Library -- it's likely to include most or all of the tools you need. Alex From emile at fenx.com Sun Mar 18 21:24:24 2001 From: emile at fenx.com (Emile van Sebille) Date: Sun, 18 Mar 2001 18:24:24 -0800 Subject: Subsetting a dictionary References: <993dkm$ttr$1@news6.svr.pol.co.uk> Message-ID: <993qq3$4bajg$1@ID-11957.news.dfncis.de> Rather than copying and then deleting from the copy, try building a new dictionary while adding only those that qualify. Something like: (untested) def subset(self, attr, value): # Copy semantics td = {} td.data = self.data.copy() for ky, val in TrainingData.items(): if ky[attr] == value: td[ky] = val return td "Will Newton" wrote in message news:993dkm$ttr$1 at news6.svr.pol.co.uk... > > I need to get a subset of a dictionary: > > D = Dictionary of objects (in this case, training examples for a decision > tree) > > D2 = {D | d in D, d under some constraint} > > I need to be able to do this, but as it is temporary I do not want to > destructively remove examples, so: > > D.subset(c) > will return a new dictionary object that is equivalent to D under > constraint c. > > I have code that does this, but it's very slow, consuming typically 75% of > program runtime - it is called many times, which seems to be unavoidable > without modifying the algorithm (ID3) too far. > > I currently have: > > class TrainingData: > data = {} > def subset(self, attr, value): > # Copy semantics > > td = TrainingData() > > td.data = self.data.copy() > > for item in td.data.keys(): > if item[attr] != value: > del td.data[item] > > return td > > Can anyone see how I can speed this up? > > I could conceivably do this with a list and use filter, I'll see how that > works. From sheila at spamcop.net Sun Mar 18 15:13:17 2001 From: sheila at spamcop.net (Sheila King) Date: Sun, 18 Mar 2001 20:13:17 GMT Subject: Help with 500 error on cgi script References: <5739bt04e50ku01rn3dptgqch3l07p2cnf@4ax.com> Message-ID: On Sun, 18 Mar 2001 12:35:11 +0100, Steve Purcell wrote in comp.lang.python in article : :Closing quote is missing. : :Try running the scripts from the command line first to weed out such syntax :errors. : :-Steve Thanks. I finally got my script working this morning. I used your advice, and ran it from the command line. That was much more efficient than testing it through the web server, for syntax errors anyhow. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From kens at sightreader.com Thu Mar 22 13:53:36 2001 From: kens at sightreader.com (Ken Seehof) Date: Thu, 22 Mar 2001 10:53:36 -0800 Subject: Good Editor? References: <3ab9a32b$1_1@news2.one.net> <3AB9FAC9.97EA420E@student.liu.se> <99d780$l2g$1@laurel.tc.umn.edu> <3ABA20F7.AB71D3B4@student.liu.se> <98qu6.166420$Z8.35271037@typhoon.southeast.rr.com> Message-ID: <002501c0b301$672d11c0$04090a0a@upcast.com> Yeah, but I want to know: does it actually work? > "Rikard Bosnjakovic" > > Anyone sending unwanted advertising e-mail to my address will be > > charged $250 for network traffic and computing time. By extracting my > > address from this message or its header, you agree to these terms. > > love it...Love It...LOVE IT! > > Don ---------------------------------------------------- Copyright (c) 2001 by Ken Seehof This document may not be distributed, copied, duplicated, or replicated in any form without express written permission by Ken Seehof. Express permission is hereby granted. kens at neuralintegrator.com ---------------------------------------------------- From moshez at zadka.site.co.il Fri Mar 23 12:13:24 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Fri, 23 Mar 2001 19:13:24 +0200 Subject: newbie question In-Reply-To: <575F0D65CC45F12D.7D165177C452F6D5.01903532892CC93D@lp.airnews.net> References: <575F0D65CC45F12D.7D165177C452F6D5.01903532892CC93D@lp.airnews.net>, <99fll8$996$1@rex.ip-plus.net> Message-ID: On 23 Mar 2001, claird at starbase.neosoft.com (Cameron Laird) wrote: > There are few languages that canNOT be used with > Apache. I might be talking out of my ass here, in which case Cameron will surely correct me. Haskell, Ruby, Icon, Scheme, ML and Smalltalk are all languages which are highly useful, and which no interfaces to Apache exists as far as I know. I'd simply go the opposite direction and say "there are few things Python cannot talk to. Apache is not one of those" (I like to phrase it: Python plays nice with the other kids. And there are *always* other kids) waiting-for-someone-to-prove-me-wrong-(hurd,plan9)-ly y'rs, Z. -- "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than Python? looking for someplace else to grab power."|YODA: No...no... no. Quicker, -- Wichert Akkerman (on debian-private)| easier, more seductive. For public key, finger moshez at debian.org |http://www.{python,debian,gnu}.org From donn at oz.net Fri Mar 16 20:37:12 2001 From: donn at oz.net (Donn Cave) Date: 17 Mar 2001 01:37:12 GMT Subject: Should I close after popen?? References: <98satl$1t8$0@216.39.151.169> Message-ID: <98uf48$552$1@216.39.151.169> Quoth Andrew Markebo : | Ahh hmm yep.. the scripts are running in 1.5.2, so what I do is to | remove the waits, (hmm are ther any possibility of doing something | similar??? am I supposed to use select/poll?) Depends on what you want to do. For sure, select has the potential to solve some programming problems with pipes. One thing that you should bear in mind, though, is that the file object returned by popen() buffers input, and select() can't see the buffered data, so you may have "no data" yet have more to read from the file object. You can ignore the file object, use the fileno() method to obtain the pipe file descriptor and use os.read() on it, for example. Anyway, it would be easier to say what you ought to use, if it were clear what problem you're trying to solve. It's probably simpler than you think. If you just read the pipes until they return an empty string, like any file, there's no reason to expect problems. | Uhm how do I get the exit-code of stuff from popen? Looking at popen2 | it forks and does waitpid.. Did I mention that you could find some relevant documentation in the pclose man page? fp = popen('echo OK; exit 9') data = fp.read() status = fp.close() You might have to shift the result down 8, on UNIX, I forget. One unrelated advantage of popen2 is that if you supply a list of arguments, it will use them directly instead of a shell command line. That is much safer. A command line constructed at run time can have much more surprising effects if it's wrong, because the shell is a much more powerful and general purpose program. Donn Cave, donn at oz.net From alan.gauld at bt.com Mon Mar 12 09:50:21 2001 From: alan.gauld at bt.com (Alan Gauld) Date: Mon, 12 Mar 2001 14:50:21 +0000 Subject: learning C References: <983975751.18833@newsmaster-04.atnet.at> <984047775.592522@newsmaster-04.atnet.at> <9896hk$ig8$1@verence.demon.co.uk> <984134612.781779@newsmaster-04.atnet.at> Message-ID: <3AACE22D.3A9EEB12@bt.com> Werner Schiendl wrote: > Unsafe is somewhat the same topic I think: It's a question > of disciplined use. I think one problem with C++ is the number of temporary objects it creates. Calling a seemingly innocuous function with some object references as paramrters may or may not involve the creation of many temporary objects. Since these objects may be subclasses the programmer may not be able to determine how much memory will be alloocated by the function call mechanism and in a minimalist memory system it can cause a crash which appears inermittent and non deterministic. In C, by virtue of its fixed primitive types, is much easier to gurantee what will happen by way of memory allocation etc. > > There's the feeling that you never quite know what it's > > going to do. Temporary objects being one such case. Others include the use of operator overloading, function overloading vv default parameters etc etc. C++ is a maintenance nightmare compared to C - I speak from 18 months painful experience maintaining a large C++ system! > You can have the same in C++ (using one or more static objects, > or construct the objects just once when booting) Even here the compiler will cause tempoiray object copies to occur when passing object references around. Static objects are not as 'static' as we might like to think! > This is nothing more difficult than in C. Sorry but it is. There's just so much less lurking under the hood in C. > > One of the particular unsafe things in C is error handling, > C++ exceptions at least make sure the error _is_ handled This bit I tend to agree with. I'm not sure what the original poster had in mind here... Alan g From dnew at san.rr.com Fri Mar 16 12:14:34 2001 From: dnew at san.rr.com (Darren New) Date: Fri, 16 Mar 2001 17:14:34 GMT Subject: list.sort(cmpfunc) question References: <98t9dq$qvu$1@panix6.panix.com> <98tf9d$g3v$1@news.mathworks.com> Message-ID: <3AB249FB.131080CD@san.rr.com> Joshua Marshall wrote: > Seems the word "should" should never appear in documentation. Not quite true. RFC's use "should" all the time, but there's a very strict definition for what it means. I think "usually" is the other problematic word. :-) -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. From dan at eevolved.com Fri Mar 2 11:35:48 2001 From: dan at eevolved.com (Dan Parisien) Date: Fri, 02 Mar 2001 16:35:48 GMT Subject: feature wish Message-ID: it seems all the special purpose overloadable methods are to provide type emulation through classes e.g. __nonzero__ __contains__ __setitem__ etc. it would be cool if there was another method provided that allowed a programmer to overload the value returned by an instance as well. e.g. class example: def __init__(self, name, data): self.name = name self.data = data def __value__(self): return self.data eg = example("my name", (1,2,3)) >>>print eg (1,2,3) You could get to the instance behind the value by using a function like instance(eg) What do you guys think? Dan From sverker.is at home.se Thu Mar 1 13:55:32 2001 From: sverker.is at home.se (Sverker Nilsson) Date: Thu, 01 Mar 2001 19:55:32 +0100 Subject: A counter-proposal to __future__ in PEP 236 Message-ID: <3A9E9B23.23FFCEDF@home.se> I think the directive directive is better too. When I read about the future import I was worried over what the new semantics of import would be, for example what would happen to the identifier that would be imported: would it be visible, probably not but that's a new semantics to understand & learn. Seems to me it is better starting afresh with a new directive directive. So I'd give my vote of agreement with you. Also it's reasurring as Joshua Marshall noted that directive wouldn't need to break code even if it was used in an assignment, because directive would have a unique meaning anyway. Sverker From uche.ogbuji at fourthought.com Mon Mar 12 02:11:27 2001 From: uche.ogbuji at fourthought.com (Uche Ogbuji) Date: Mon, 12 Mar 2001 00:11:27 -0700 Subject: [Python-Dev] Revive the types sig? In-Reply-To: Message from Jeremy Hylton of "Sun, 11 Mar 2001 20:22:04 EST." <15020.9404.557943.164934@w221.z064000254.bwi-md.dsl.cnc.net> Message-ID: <200103120711.AAA09711@localhost.localdomain> Jeremy Hylton: > If documentation is really the problem you want to solve, I imagine > we'd make much more progress if we could agree on a javadoc-style > format for documentation. The ability to add return-type declarations > to functions and methods doesn't seem like much of a win. I know this isn't the types SIG and all, but since it has come up here, I'd like to (once again) express my violent disagreement with the efforts to add static typing to Python. After this, I won't pursue the thread further here. I used to agree with John Max Skaller that if any such beast were needed, it should be a more general system for asserting correctness, but I now realize that even that avenue might lead to madness. Python provides more than enough power for any programmer to impose their own correctness tests, including those for type-safety. Paul has pointed out to me that the goal of the types SIG is some mechanism that would not affect those of us who want nothing to do with static typing; but my fear is that once the decision is made to come up with something, such considerations might be the first out the window. Indeed, the last round of talks produced some very outre proposals. Type errors are not even close to the majority of those I make while programming in Python, and I'm quite certain that the code I've written in Python is much less buggy than code I've written in strongly-typed languages. Expressiveness, IMO, is a far better aid to correctness than artificial restrictions (see Java for the example of school-marm programming gone amok). If I understand Jeremy correctly, I am in strong agreement that it is at least worth trying the structured documentation approach to signalling pre- and post-conditions before turning Python into a rather different language. -- Uche Ogbuji Principal Consultant uche.ogbuji at fourthought.com +1 303 583 9900 x 101 Fourthought, Inc. http://Fourthought.com 4735 East Walnut St, Ste. C, Boulder, CO 80301-2537, USA Software-engineering, knowledge-management, XML, CORBA, Linux, Python From aleaxit at yahoo.com Fri Mar 16 08:44:29 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 16 Mar 2001 14:44:29 +0100 Subject: gah! I hate the new string syntax References: <97sudi01i26@news1.newsguy.com> <98elrk$li8$1@nntp.Stanford.EDU> <98fc070thh@news1.newsguy.com> <98iqo2$56o$1@nntp.Stanford.EDU> Message-ID: <98t5bv0l8b@news1.newsguy.com> "Pieter Nagel" wrote in message news:Pine.LNX.4.21.0103161339210.2809-100000 at bast.jhb.equinox.co.za... [snip] > Of course you can. The technique is to modify the String class itself It's not a class. It's a non-class type, and does not support modification. Alex From grante at visi.com Fri Mar 30 10:51:16 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 30 Mar 2001 15:51:16 GMT Subject: Creation d'un NG francophone sur Python References: <1eqzyk6.gxd4jr1tkjykzN%francois.granger@free.fr> <9a1e6f011es@enews3.newsguy.com> Message-ID: In article , Fran?ois Pinard wrote: >> >Pardon, mais pourquoi un NG pour Python en fran?ais? > >> C'est un choix, une opportunit?. > >I directly know some people that do not read English easily, >and that would be Python users if there were more French >resources for Python. I'm sure the same applies for people >speaking many other languages. English should not be necessary >to use computers, and if Python is meant to be a CP4E, it >should have wide views about non-English people. Post away in whatever languge you want. I see no need to separate people by linguistic lines. I suppose if you don't read English it would be nice not to have to sift through the newsgroup looking for postings you can read. Though as a mono-lingual American, I also feel the urge to P O S T S L O W L Y A N D L O U D L Y I F I T W I L L H E L P P E O P L E W H O D O N ' T R E A D E N G L I S H. ;) -- Grant Edwards grante Yow! Is this "BIKINI at BEACH"? visi.com From nde at comp.leeds.ac.uk Thu Mar 22 07:36:42 2001 From: nde at comp.leeds.ac.uk (Nick Efford) Date: Thu, 22 Mar 2001 12:36:42 GMT Subject: Good Editor? References: <3ab9a32b$1_1@news2.one.net> Message-ID: On 22 Mar 2001 08:22:26 GMT, Fred Pacquier wrote: > >Can someone recomend a good editor to write python in? Im just getting > >started learning python and dont know which ones support python. > > You don't mention the platform. Under Unix/Linux there are a number of > options (including Vim, Emacs, etc.). Under Windows, I found WScite > (http://www.scintilla.org) the easiest to get started with... vim and emacs run on Windows, too! So you can use one editor across platforms as well as one programming language :) N. From stephen_purcell at yahoo.com Mon Mar 5 11:18:13 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Mon, 5 Mar 2001 17:18:13 +0100 Subject: Name of the Script In-Reply-To: ; from paul.moore@uk.origin-it.com on Mon, Mar 05, 2001 at 04:40:08PM +0100 References: <20010304.185354.2114937732.8277@localhost.localdomain> Message-ID: <20010305171813.A9043@freedom.puma-ag.com> Paul Moore wrote: > On Mon, 5 Mar 2001 16:17:38 +0100 , Pearu Peterson > wrote: > >--- a.py --- > >import os,sys > >print os.path.abspath(sys.argv[0]) > >--- > >might be what you want. > > Close, but not quite... >>> def current_module_path(): ... import os, sys ... try: ... path = sys.modules[__name__].__file__ ... except AttributeError: ... path = sys.argv[0] ... return path and os.path.join(os.getcwd(), path) or None ... >>> Then, in an interactive session: >>> `current_module_path()` 'None' And in 'a.py': '/home/steve/a.py' -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Get servlets at http://pyserv.sourceforge.net/ "Even snakes are afraid of snakes." -- Steven Wright From sholden at holdenweb.com Wed Mar 7 14:24:38 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 7 Mar 2001 14:24:38 -0500 Subject: I come to praise .join, not to bury it... References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> <3AA2F4B3.A7496E76@cosc.canterbury.ac.nz> <97vmoh061p@news2.newsguy.com> <3AA46134.D385208B@cosc.canterbury.ac.nz> <98292h0s0g@news1.newsguy.com> <3AA58BD0.3324C709@cosc.canterbury.ac.nz> <9850ge013ns@news1.newsguy.com> Message-ID: "Rainer Deyke" wrote in message news:gRup6.364652$ge4.128679630 at news2.rdc2.tx.home.com... > "Alex Martelli" wrote in message > news:9850ge013ns at news1.newsguy.com... > > in fact, just about any test for 'IS object X of exact type > > Y' you can find in the Python sources, unless they are > > shortcut-like 'accelerators' for a special case _before_ > > the more-general request 'please o mr X try to behave like > > an Y, are you able to?', can be seen as implementation > > defects, in my personal opinion. > > I'm curious: how do you feel about the automagic conversions of functions > (and only true function, not function-like objects) into unbound methods, > and from unbound methods into bound methods? I'm thinking that the former > could be eliminated entirely, and the latter replaced by a __bind__ magic > method that allows the mechanism to apply to function-like objects. > > Surely no type conversion is involved: the interpreter just converts instance.method(*args) into class.method(instance, *args) regards Steve From vecernik at aon.at Tue Mar 27 03:19:23 2001 From: vecernik at aon.at (Oliver Vecernik) Date: Tue, 27 Mar 2001 10:19:23 +0200 Subject: sitemap and ftp Message-ID: <3AC04D0B.5A44A4D5@aon.at> Hi, I'm relatively new to Python, but I felt immediately in love because of it's clear structure and ease to read the code. Unfortenately I still lack a lot of knowledge. Maybe some can help me or point me to the right spot in the docs. I'd like to parse through my website tree and generate an automated sitemap from the tags. Is there a module that helps me achieving this task? Furthermore I'd like to copy all *.html files and all *.jpg and *.gif files to my ISP preserving the directory structure. Before copying the *.html files have to be filtered (adding a header and a footer). Has anybody written such routines already? Regards, Oliver From stephen_purcell at yahoo.com Fri Mar 30 02:09:36 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Fri, 30 Mar 2001 09:09:36 +0200 Subject: max filename size In-Reply-To: <3ac416a6$0$4017$6e49188b@news.goldengate.net>; from volucris@hotmail.com on Thu, Mar 29, 2001 at 11:16:41PM -0600 References: <3ac416a6$0$4017$6e49188b@news.goldengate.net> Message-ID: <20010330090936.C4187@freedom.puma-ag.com> Voluciris wrote: > Is there away to find the maximum filename length of the current os? On > Windows it's 215 characters, but I don't want to hard code that in. It would > be much more pythonic if it was portable. I don't think there's a standard function for this. On some platforms, the maximum filename length varies according to the location on the disk. If you run UNIX with different filesystems mounted in various locations on your directory tree, you might see the following values for the maximum filename length in those locations: >>> import statvfs, os >>> os.statvfs('/')[statvfs.F_NAMEMAX] 4032 >>> os.statvfs('/boot')[statvfs.F_NAMEMAX] 255 -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From shredwheat at mediaone.net Mon Mar 19 10:22:45 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Mon, 19 Mar 2001 15:22:45 GMT Subject: Python In A Nutshell - Numpy essential References: <3AAE7E0D@MailAndNews.com> <slrn9aolph.ccf.jimhill@meldrick.swcp.com> <3AACE20C.AC8D2EA2@northwestern.edu> <Ikkr6.68807$ML1.3285992@e420r-atl2.usenetserver.com> <3AAE5DA3.B736C2D0@northwestern.edu> <Pine.HPX.4.33.0103182208511.10898-100000@sesame.ee.byu.edu> Message-ID: <9vpt6.71944$Ch.9136379@typhoon.we.rr.com> > I used to be one who really wanted Numeric in the Python core. At this > point it is not critical to me. Maybe someday, the multidimensional array > aspect of Numeric will be distributed with Python. For now, though what > is needed instead is an easy to install package (which includes Numeric) > and provides a competitive numerical enviroment (something like SciPy > which is coming this summer...) > > I'm happy to keep Numeric out of the core as it gives the math-heads more > control over it's optimization. well, i would still like to see at least the multidimensional array part of Numeric included with the python release. the most notable changes to the package since python2.0 came out has been support for python2.0 and python2.1 features. the package seems to be settling down nicely, and is a great value to me (and i'm not even using it for any scientific purposes, owell) i just created a fun tutorial on Numeric Python and using it to do imaging effects here. http://pygame.seul.org/docs/tut/SurfarrayIntro.html From gregj at pobox.com Fri Mar 16 23:39:34 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Sat, 17 Mar 2001 04:39:34 GMT Subject: Cookies References: <mailman.984707839.22839.python-list@python.org> <lmq6m07j.fsf@propylon.com> <mailman.984773062.25819.python-list@python.org> Message-ID: <aUBs6.581328$U46.17323742@news1.sttls1.wa.home.com> "Ken Seehof" <kens at sightreader.com> wrote in message news:mailman.984773062.25819.python-list at python.org... > Here's a restatement of the problem. It's really about crossing the sandbox > barrier. > > Does anyone know of another mailing list more specific to http questions? > > 1. Client downloads an execuatable (frozen python application). > 2. Client downloads a web page. > 3. Web page javascript generates a statistically unique random identifier. > 4. Web page sends identifier to the server, which uses it as database key. > 5. User runs python application > 6. *** Python application somehow gets the identifier from somewhere *** > 7. Now the python application and the server both have the same identifier. Can you do it like this? 1. Client downloads and runs Python executable 2. Python app sends HTTP request to remote server 3. Server creates unique ID, sends it back to the Python app via HTTP 4. Python app saves the unique ID somewhere (text file, registry) where it or other Python app can find it later 5. Python app launches web browser, passing server URL + unique ID 6. Web browser opens up remote web page, sending unique ID in the URL 7. Remote server gets unique ID, sends it back to client embedded in the web page (hidden INPUT field) 8. User fills out form, submits it (along with the unique ID embedded in the web page) 9. Server saves user's inputs in database record keyed on unique ID At this point the server could send back a page containing a cookie that has the unique ID (or whatever) in it. Or you could use JavaScript to create a bookmark in the user's browser that has your URL + unique ID embedded in it. Maybe you need two Python apps: one to "prime the pump," i.e. get a unique ID from the server and save it, and another that does whatever your current application is supposed to do. Variations on this could involve writing an HTML page from your Python app on the user's system, and embedding the unique ID in that page. When the page is loaded into the browser it sends a URL + unique ID to your server. For clients using Windows or MacOS you can save a URL as a shortcut on the desktop; again that URL can be your web page plus the unique ID generated earlier (e.g. http://www.somesite.com/page.html?id=12345). Again I advise you to generate the unique IDs on your server, not on the client side. I've often used a simple scheme that combines a record sequence number (called an IDENTITY column in SQL Server) and a random number generated on the server and stored in the database row. The database layout looks like this: id: identity column or default value set to a sequence generator (a la Oracle) check: default value is a function that generates a random number user-stuff: name, address, etc. ... You can send this back as id.check, and pass it in the URL like id=1234.67132. The server uses the first part to fetch the row, and then checks to make sure the second bit matches (this can all be done in the SQL SELECT). Good luck. -- Greg Jorgensen / programmer, pedant, raconteur / Portland, Oregon, USA From jcc.ugm at ix.netcom.com Wed Mar 28 15:18:20 2001 From: jcc.ugm at ix.netcom.com (Jonathan Claggett) Date: Wed, 28 Mar 2001 15:18:20 -0500 Subject: Is inheritance broken? In-Reply-To: <15042.17325.125458.471763@beluga.mojam.com> Message-ID: <NDBBLAKACLGJJBDNGGCMIEJDCCAA.jcc.ugm@ix.netcom.com> >How about creating mixins, then composing a set of classes from them: Interesting. Are there conventions for mixin classes which distinguish them from normal classes? For example, are mixins not suppposed to use inheritance (or at least not use mulitple inheritance)? Thanks for the help, Jonathan From jdgorman at att.net Sat Mar 24 22:59:39 2001 From: jdgorman at att.net (John D. Gorman) Date: Sun, 25 Mar 2001 03:59:39 GMT Subject: New Tkinter and PIL documentation (free) References: <99en42$2vl6$1@newshost.nmt.edu> <Y_Vu6.179074$Z8.37733056@typhoon.southeast.rr.com> <99ikps$1qmo$1@newshost.nmt.edu> Message-ID: <3ABD6D24.260DE481@att.net> Was this document generated using Adobe Distiller? I've had similar problems with fonts and Distiller. I've had better luck with pdftex. This produces pdfs that don't have the font blockiness. There's a Win32 version at miktex.org. --John Gorman John Shipman wrote: > First I wrote: > > +-- > | At this site you will find my newly written reference document > | for Tkinter: > | > | http://www.nmt.edu/tcc/help/pubs/lang.html > +-- > > Then Don Tuttle <tuttledon at hotmail.com> replied: > > +-- > | I downloaded the Tkinter PDF, but apparently I don't have the same > | font you used. (The text is very fuzzy) Assuming this is the > | problem, would you consided remaking the PDFs with a more standard > | font? Thanks. > +-- > > The document was designed for print, not for screen use. It > should print cleanly. If you're reading it with Acrobat, > try increasing the magnification. > > -- > John Shipman (john at nmt.edu), Applications Specialist, NM Tech Computer Center, > Speare 128, Socorro, NM 87801, (505) 835-5950, http://www.nmt.edu/~john > ``Let's go outside and commiserate with nature.'' --Dave Farber -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-list/attachments/20010325/24b73203/attachment.html> From emile at fenx.com Fri Mar 23 10:10:06 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 23 Mar 2001 07:10:06 -0800 Subject: New PEP: The directive statement References: <mailman.985085006.24236.python-list@python.org> <slrn9bk7fk.fnm.scarblac@pino.selwerd.nl> <j4k85gkiye.fsf@informatik.hu-berlin.de> <99fnif$gsq$1@news.mathworks.com> Message-ID: <99fp6h$15i5v$1@ID-11957.news.dfncis.de> I don't think the interpreter switch works. Modules will either depend on the current or future behavior, so the option needs to be there. -- Emile van Sebille emile at fenx.com --------- "Joshua Marshall" <jmarshal at mathworks.com> wrote in message news:99fnif$gsq$1 at news.mathworks.com... > Martin von Loewis <loewis at informatik.hu-berlin.de> wrote: > > scarblac at pino.selwerd.nl (Remco Gerlich) writes: > > >> First the inconsistency: the syntax definition in (C) claims that some > >> restrictions on the placement of directive may be in place, depending on > >> the directive. However, (D) notes that directives must appear as the first > >> non-string token in a file, for backwards compatibility. So in practice, > >> directive can't be used anywhere in a file. > > > That's not inconsistent. There is only one directive defined so far, > > to activate nested scopes, and it must appear at the top of the file. > > In some later release of Python, directive will become a proper > > keyword, at which time introducing directives with less strict > > placement rules is possible. > > Please, no more keywords. It's unnecessary in this case. > How about an interpreter switch: > > python -directive nested_scopes fu.py From aleaxit at yahoo.com Fri Mar 9 10:09:23 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 9 Mar 2001 16:09:23 +0100 Subject: win32com:MakePy -- Early Binding without the size jitters? References: <mailman.984043211.10915.python-list@python.org> <98ae5r01hn0@news2.newsguy.com> <guKoOvyz2tkgZ9zg6THcL9zanB2o@4ax.com> Message-ID: <98armv0233m@news2.newsguy.com> "Paul Moore" <paul.moore at uk.origin-it.com> wrote in message news:guKoOvyz2tkgZ9zg6THcL9zanB2o at 4ax.com... [snip] > >Yes: study the sources and look at the bForDemand > >flag (introduced reasonably recently). That flag > >ensures that only the wrappers you're actually using > >are generated (it uses packages rather than modules > >to house the wrappers). > > More specifically, run makepy -d to generate "on demand" support. Support for > the basic object is generated, but then sub-object support is built as > necessary. > > This is quite nice, and I didn't know it was available. Thanks for the > pointer, Alex! Thank *YOU* for mentioning the -d switch, which I had completely omitted...!!! Alex From greg at cosc.canterbury.ac.nz Mon Mar 19 20:57:51 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 20 Mar 2001 13:57:51 +1200 Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> <20010312170356.B3513@better.net> <mailman.984480856.18097.python-list@python.org> <984486395.407379@newsmaster-04.atnet.at> <slrn9asf1d.ja3.qrczak@qrnik.zagroda> <984518199.127140@newsmaster-04.atnet.at> <jwbnews-09D75F.13313313032001@corp.supernews.com> <98ohuc$du9$1@news.udel.edu> <7bQr6.644$lz1.17686@ruti.visi.com> <98oku1$f6a$1@news.udel.edu> <erRr6.659$lz1.20662@ruti.visi.com> <98qv55$f5d$1@news.udel.edu> Message-ID: <3AB6B91F.F201AA7C@cosc.canterbury.ac.nz> Terry Reedy wrote: > > BCD does not eliminate the problems of finite precision arithmetic. No, but it lets you see exactly what's going on in terms that most people are familiar with. It eliminates any *extra* surprises due to conversion between bases. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From Patrick.Bussi at space.alcatel.fr Thu Mar 29 05:06:52 2001 From: Patrick.Bussi at space.alcatel.fr (Patrick.Bussi at space.alcatel.fr) Date: Thu, 29 Mar 2001 12:06:52 +0200 Subject: =?iso-8859-1?Q?R=E9f._:_Re:_Why_not_Tcl/Tk=3F?= Message-ID: <C1256A1E.00384E80.00@vzmta01.netfr.alcatel.fr> Hello, I've had the same issues as Alexander's and finally choose Python after reading some studies about languages comparisons. A list of links is available at http://www.python.org/doc/Comparisons.html Hope this helps. --- Patrick Bussi patrick.bussi at space.alcatel.fr Any opinions expressed are my own and not necessarily those of my Company. grante at visi.com (Grant Edwards) on 27/03/2001 17:54:44 Pour : python-list at python.org cc : (ccc : Patrick Bussi/ALCATEL-SPACE) Objet : Re: Why not Tcl/Tk? -------------- next part -------------- In article <4211ctgvusgcma0c6ok1cpmjou98lv9714 at 4ax.com>, Alexander Kluge wrote: >Here are some very general newbie questions and a plea for your opinion. > >Having some outdated hobby hacking experience (Turbopascal, Modula2, >DBase) on AtariST and PC, and some recent experience with a 70k perl cgi >script consecutivly changed by different persons (@!?$@*!!!), I think >that I actually don't want to use neither C, C++ or Java (overkill) nor >perl (see above). I confess having used the try and error method of >learning, therefore my autodidactic abilities stopped every time dynamic >arrays were needed :). >I don't want neither spend much time in learning the language nor >writing professional strength applications but I rather look for a >replacement of very easy languages as e.g. pascal/basic. > >I'm interested in your opinions concerning the following points: > >-How would you describe the major strengths and flaws of Tcl vs. Python? Tcl Flaws: Only one data type: string Incomprehensible quoting semantics Roll-your-own control flow No OO support Strengths: Tk integration Lots of code out there Roll-your-own control flow Python: Flaws: No roll-your-own control flow Lots of GUI options Strengths: No roll-your-own control flow Good OO support Lots of GUI options Simple syntax and semantics Library modules >-Why do you prefer the one you use over the other? I gave up on Tcl after one program and switch to Scheme. Now I use Python a lot more than Scheme. [I don't know much about eithr on Win32, so I'll let others answer those questions.] -- Grant Edwards grante Yow! As President I at have to go vacuum my coin visi.com collection! -- http://mail.python.org/mailman/listinfo/python-list From ctavares at develop.com Sun Mar 4 21:51:40 2001 From: ctavares at develop.com (Chris Tavares) Date: Mon, 05 Mar 2001 02:51:40 GMT Subject: Static class methods References: <rdzo6.154$gc4.80445@news.pacbell.net> Message-ID: <0bDo6.16804$7Y1.1656672@newsread2.prod.itd.earthlink.net> Try this: >>> class Foo: ... class FooMethods: ... def foo1(self): ... print "FooMethods.foo1" ... class_methods = FooMethods() ... >>> foo = Foo() >>> foo.class_methods.foo1() FooMethods.foo1 >>> Foo.class_methods.foo1() FooMethods.foo1 >>> -Chris "Alex Shindich" <alex at shindich.com> wrote in message news:rdzo6.154$gc4.80445 at news.pacbell.net... > Just out of my curiosity, have any of you ladies and gentlemen experienced a > need for an equivalent of C++/Java static method? > Because I have, but it is impossible add them to Python classes -- all class > methods are treated as instance methods. > This is especially unfortunate given that local functions now work properly > thanks to PEP 227. > I was thinking that a new keyword "unbound" could be used to identify > functions that belong to a class but do not expect "self" as their first > attribute. > From outside the class "unbound" methods would be invoked by specifying the > class name -- Foo.my_static_method (). From within the class they would work > similar to local functions that are defined at the class level. The __ trick > should work for the "unbound" methods as well to allow for creation of > private static methods. > > Examples: > >>>class Foo: > """This is a sample class...""" > > __myPrivateStaticVariable = None > > unbound getMyPrivateStaticVariable (): > """getMyPrivateStaticVariable (obj) -> obj > > This method returns the value stored in private static variable... > """ > return Foo.__myPrivateStaticVariable > > > unbound modifyMyPrivateStaticVariable (obj): > """modifyMyPrivateStaticVariable (obj) -> void > > This method assigns obj to the private static variable... > """ > Foo.__myPrivateStaticVariable = obj > > >>> type (Foo.modifyMyPrivateStaticVariable) > <type 'unbound method'> > >>> type (Foo.getMyPrivateStaticVariable ()) > <type 'None'> > >>> Foo.modifyMyPrivateStaticVariable ("abc") > >>> Foo.getMyPrivateStaticVariable () > "abc" > >>> > > > > From volucris at hotmail.com Fri Mar 30 00:16:41 2001 From: volucris at hotmail.com (Voluciris) Date: Thu, 29 Mar 2001 23:16:41 -0600 Subject: max filename size Message-ID: <3ac416a6$0$4017$6e49188b@news.goldengate.net> Is there away to find the maximum filename length of the current os? On Windows it's 215 characters, but I don't want to hard code that in. It would be much more pythonic if it was portable. thanks greg From tim.one at home.com Thu Mar 1 14:30:26 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 1 Mar 2001 14:30:26 -0500 Subject: A counter-counter-proposal for PEP 236: #pragma( nested_scopes) In-Reply-To: <0Swn6.3324$TW.17061@tor-nn1.netcom.ca> Message-ID: <LNBBLJKPBEHFEDALKOLCOEBKJDAA.tim.one@home.com> [Warren Postma] > Has anyone considered borrowing a C notation: > > #pragma( nested_scopes ) > > Benefits: > - It's a comment therefore it doesn't break anything else. But that's dead-wrong behavior for future_statements. If your module needs nested_scopes semantics, it will do unpredictable wrong things at runtime if it doesn't get them. That's why PEP 236 is emphatically *not* a "pragma" proposal. That doesn't mean a pragma facility isn't *also* desirable, but does mean it's unsuitable for what PEP 236 is doing. future_statements can have profound effects on both syntax and semantics (indeed, that's what they're *addressing*); they're not about pragmatics (from whence "pragma"). > - It compiles fine and is ignored on pre-2.x systems. Again dead-wrong behavior for future_statements. > - More pragmas can be added later, for warnings, code generation, > etcetera. Yes, pragmas can be useful for lots of things. But not for cross-release incompatible changes in semantics or syntax. From Randy.L.Kemp at motorola.com Thu Mar 22 09:03:23 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Thu, 22 Mar 2001 08:03:23 -0600 Subject: Good Editor? Message-ID: <E566B020833BD311B6610008C791A397050ECEAD@il93exm04.css.mot.com> There are many good free, cheap editors. You can look at emacs on Unix, Ultradev in Windows (www.ultradev.com (load down the python extension), or jedit. I'm sure there are others. -----Original Message----- From: Courageous [mailto:jkraska1 at san.rr.com] Sent: Thursday, March 22, 2001 1:38 AM To: python-list at python.org Subject: Re: Good Editor? On Wed, 21 Mar 2001 23:00:58 -0800, "fjs" <fjs6 at usa.net> wrote: >Can someone recomend a good editor to write python in? Im just getting >started learning python and dont know which ones support python. Vim has a language highliting for python and has friendly tab control. I have mine set, for example, so that "every tab fills in enough spaces to take you to the next tab stop." On all my python projects, actual tab characters are completely forbidden. C// From jbauer at rubic.com Fri Mar 16 20:21:24 2001 From: jbauer at rubic.com (Jeff Bauer) Date: Fri, 16 Mar 2001 19:21:24 -0600 Subject: Guido on SlashDot Message-ID: <3AB2BC14.73FA5F26@rubic.com> Guido discussed on SlashDot: http://slashdot.org/articles/01/03/16/0349216.shtml ministry-of-propaganda-dept-ly y'rs, -Jeff From chris.gonnerman at usa.net Wed Mar 7 23:11:42 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Wed, 7 Mar 2001 22:11:42 -0600 Subject: News from Python9!!! References: <NUCp6.65206$Z8.11697516@typhoon.southeast.rr.com> Message-ID: <00ac01c0a785$efa17a00$a100000a@local> I've just got one problem... When I go to the links given, I get this: <html><head><title>Site Not Found No web site is configured at this address. Huh. What happened? ----- Original Message ----- From: "Don Tuttle" Newsgroups: comp.lang.python To: Sent: Wednesday, March 07, 2001 9:21 PM Subject: News from Python9!!! > For those of you, like myself, who are NOT at the Python bash in Long Beach, > some very good news from there has been posted at ActiveState. > > 1) The "Python Software Foundation" has been created > http://www.activestate.com/Corporate/Communications/Releases/Press983863928. > html > > 2)The Programmers' Choice for Python award winner is Christian Tismer > http://www.activestate.com/Corporate/Communications/Releases/Press983917761. > html > > 3) A "Python Cookbook" project has started. > http://www.activestate.com/Corporate/Communications/Releases/Press983583358. > html > > 4)And a bugfix release of Python 2.0 has been released. It includes PPM > (Programmer's Package Manager ) to make finding and installing Python > modules simple. > http://www.activestate.com/Corporate/Communications/Releases/Press983916629. > html > > Don From JohnH at PHM.GOV.AU Sun Mar 18 20:22:54 2001 From: JohnH at PHM.GOV.AU (Hirsch, John) Date: Mon, 19 Mar 2001 12:22:54 +1100 Subject: Using ActiveX Control from Python Message-ID: Hi All I am trying to use an ActiveX Control from Python 2.0 with little success. The Interactive session goes a little like this. First I ran AwusbIO ActiveX Control module through makepy.py -i. >>> AwusbIO ActiveX Control module {95438942-F98A-11D2-AC25-00104B306BEE}, lcid=0, major=1, minor=0 >>> # Use these commands in Python code to auto generate .py support >>> from win32com.client import gencache >>> gencache.EnsureModule('{95438942-F98A-11D2-AC25-00104B306BEE}', 0, 1, 0) >>> from win32com.client import gencache >>> gencache.EnsureModule('{95438942-F98A-11D2-AC25-00104B306BEE}', 0, 1, 0) >>> aw = win32com.client.Dispatch("AWUSBIO.AwusbIOCtrl.1") >>> aw >>> aw.AboutBox >>> aw.AboutBox() Traceback (innermost last): File "", line 1, in ? File "c:\python20\win32com\gen_py\95438942-F98A-11D2-AC25-00104B306BEEx0x1x0.py", line 29, in AboutBox return self._oleobj_.InvokeTypes(0xfffffdd8, LCID, 1, (24, 0), (),) com_error: (-2147418113, 'Unexpected failure', None, None) >>> I am running ActiveState ActivePython2.0 on Win98. The Control works fine with the supplied demo software from ActiveWire (not to be confused with ActiveState). They provide a demo that runs the control in a web browser using Java script. Any suggestions? From mmealman at loki.thebisgroup.com Fri Mar 23 12:29:21 2001 From: mmealman at loki.thebisgroup.com (Mark) Date: 23 Mar 2001 11:29:21 -0600 Subject: Commercial Products in Python? References: <3abb86ee.142862695@localhost> Message-ID: In article <3abb86ee.142862695 at localhost>, Victor Muslin wrote: >A friend of mine is considering developing a shrink-wrapped commercial >product. Python seems like a possible choice, but it is not clear >whether there are any precedents (though probably similar concerns >apply to a Perl-based product). > >I would very much appreciate an advice in this area and possibly >answers to some of the following questions: > >1. Are there any existing shirnk-wrap commercial products written in >Python? Hard to say. Most shrink wrap developers don't advertise what language they code in. But there's zero reason against using Python for commercial apps. I'd personally feel more comfortable using Python than say, Java, in a commercial app. IMHO Python would have fewer deployment issues. >3. What is the best way to go about it? Is it better to have customers >install Python and give them bytecode files or use one of the programs >that creates an executable? I'd try to compile Python down to an executable. It'd probably make it easier to deploy. That's assuming you're targetting Windows. >4. There is an easy shrink-wrap install for Python (at least on >Windows NT). Are there such on Unix/Linux platforms? (Typically >customers don't like having to compile software from source). Compile Python down to an exe for 'doze and install using Install Shield or something similar. That way it looks nice and professional. For Linux I'd probably pop my program into a .rpm and just list the dependencies. I'd also create a .deb because I'm a Debian user and shipping in multiple package dists shows some taste. >6. Are there any licensing issues to be aware of? Just pop in a seperate copyright notice somewhere for Python and you should be covered. >Anything else that comes to mind in this direction would be very >helpful. Yeah, who's your target audience? If you're expecting John Q Public running Windows 95 to use this, then it needs to be easy enough for a monkey to install and the install has to look pretty. But if you're targeting developers you can get a little more flexible, we appreciate multiple methods of installing software. -Mark -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From winkler at abaqus-sn.com Thu Mar 29 13:19:07 2001 From: winkler at abaqus-sn.com (david winkler) Date: Thu, 29 Mar 2001 18:19:07 GMT Subject: how query function args Message-ID: <3AC37CAB.50937BD6@abaqus-sn.com> I need to query the names and values of a function's keyword arguments. I suspect that there is an easy way to do this but cannot find it. Would someone care to make a suggestion? From phrxy at csv.warwick.ac.uk Thu Mar 29 13:31:41 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Thu, 29 Mar 2001 19:31:41 +0100 Subject: Linux GPS program In-Reply-To: <99sud0$m7a$1@newsserver.rrzn.uni-hannover.de> References: <3AC01637.4EF3A6F2@crynwr.com> <99q3ob$ehr$1@newsserver.rrzn.uni-hannover.de> <3AC0D79E.ADED2832@crynwr.com> <99sud0$m7a$1@newsserver.rrzn.uni-hannover.de> Message-ID: On 28 Mar 2001, Bernhard Reiter wrote: > In article <3AC0D79E.ADED2832 at crynwr.com>, > Russell Nelson writes: > > Bernhard Reiter wrote: [...] > If you want it to be Free Software, > attach a license (maybe MIT style or LGPL). [...] > > It's free software now -- I just don't want rogue versions that would be > > hard for me to integrate back into the mainline branch. Feel free > > to suggest changes. [...] Erm, are you two sure you're not talking at cross-purposes? Does Russell know the usual meaning of 'Free Software' is free as in freedom rather than beer? try http://www.gnu.org/philosophy/free-sw.html and http://www.opensource.org/ John From lbates at syscon-computers.com Thu Mar 1 12:11:49 2001 From: lbates at syscon-computers.com (Larry Bates) Date: Thu, 1 Mar 2001 11:11:49 -0600 Subject: Newbie createing .PYC for import Message-ID: <3a9e83fa$1@news1.dbtech.net> I have spent the last couple of hours (unsuccessfully) attempting to figure out how to generate a .PYC file for a module that I've defined. Everything appears to imply that it's "automatic", but I'm not getting anywhere. I have a module and I wish to generate a .PYC file so that I can import it into future projects. Can anyone shed any light on how to accomplish this? -Larry From qrczak at knm.org.pl Thu Mar 8 15:19:59 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 8 Mar 2001 20:19:59 GMT Subject: I come to praise .join, not to bury it... References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> <3AA2F4B3.A7496E76@cosc.canterbury.ac.nz> <97vmoh061p@news2.newsguy.com> <3AA46134.D385208B@cosc.canterbury.ac.nz> <98292h0s0g@news1.newsguy.com> <3AA58BD0.3324C709@cosc.canterbury.ac.nz> <9850ge013ns@news1.newsguy.com> Message-ID: Wed, 7 Mar 2001 14:24:38 -0500, Steve Holden pisze: > Surely no type conversion is involved: the interpreter just converts > > instance.method(*args) > > into > > class.method(instance, *args) No. This is what I would like it to do, and proposed a few weeks ago. A conversion happens during extraction from a class, and only if it's a function (not function-like object). If C is a class, then after foo = whatever C.foo = foo foo = C.foo foo is the same as whatever *unless* it was a function, in which case it got converted to an unbound method (and can only accept C instances as the first argument). If you try to implement a method using a function-like object instead of a function, it won't work. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From jmarshal at mathworks.com Fri Mar 16 12:19:06 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 16 Mar 2001 17:19:06 GMT Subject: list.sort(cmpfunc) question References: <98t9dq$qvu$1@panix6.panix.com> <98tf9d$g3v$1@news.mathworks.com> <3AB249FB.131080CD@san.rr.com> Message-ID: <98thua$i40$1@news.mathworks.com> Darren New wrote: > Joshua Marshall wrote: >> Seems the word "should" should never appear in documentation. > Not quite true. RFC's use "should" all the time, but there's a very strict > definition for what it means. I think "usually" is the other problematic > word. :-) What does "should" mean, in the context of RFCs? Although an RFC is different than documentation. From aahz at panix.com Sat Mar 24 10:51:53 2001 From: aahz at panix.com (Aahz Maruch) Date: 24 Mar 2001 07:51:53 -0800 Subject: New PEP: The directive statement References: Message-ID: <99ifqp$jni$1@panix3.panix.com> In article , Tim Peters wrote: >[James_Althoff] >> ok, how about: >> >> from __readyOrNot__ import nested_scopes >> >> or perhaps, >> >> from __likeItOrNot__ import nested_scopes > >[Aahz Maruch] >> This is in some respects excessively flippant, but that very flippancy >> calls attention to it. I'm not going to push this idea, but I do think >> it's worth considering. > >Aahz, "__future__" was intended to be flippant enough to get peoples' >attention, and for some people that works (e.g., /F originally said "it >makes me smile", which was half the point). But the people offended by >an ounce of irreverence aren't going to be happier with a full pound. Yes, I understand. But "__future__" isn't excessively flippant, so I thought it might be worth considering pushing the flippancy factor even higher. Or not. But this *is* Python, after all. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "I won't accept a model of the universe in which free will, omniscient gods, and atheism are simultaneously true." -- M From sinisa_pavlovic at yahoo.com Thu Mar 29 06:55:08 2001 From: sinisa_pavlovic at yahoo.com (Simpa) Date: Thu, 29 Mar 2001 11:55:08 GMT Subject: Newbie Tkinter problem Message-ID: <3ac32211.18968775@news.iskon.hr> Hi. When I start the following script twice, without leaving Python I got TclError message (first time everything is OK). What am I doing wrong? I am using Python 1.5.2 for Win32 with Mark Hammond's PyWin, but same things happend on IDLE too. Thanks in advance. Simpa. from Tkinter import * class Wind: def __init__(self): self.root = Tk() self.root.title('Show image') self.c = Canvas(self.root,background = 'green') self.photo = PhotoImage(name = 'wedda',file="wedda.gif") self.c.create_image(0,0,image=self.photo,anchor=NW) self.c.pack(fill=BOTH,expand=1) self.root.mainloop() MyWind = Wind() >>> Traceback (innermost last): File "D:\PythonW32\Pythonwin\pywin\framework\scriptutils.py", line 237, in RunScript exec codeObject in __main__.__dict__ File "D:\Private\PythonProba\Tkinter\Image.py", line 17, in ? MyWind = Wind() File "D:\Private\PythonProba\Tkinter\Image.py", line 11, in __init__ self.photo = PhotoImage(name = 'wedda',file="wedda.gif") File "D:\Python\Lib\lib-tk\Tkinter.py", line 1874, in __init__ apply(Image.__init__, (self, 'photo', name, cnf, master), kw) File "D:\Python\Lib\lib-tk\Tkinter.py", line 1839, in __init__ self.tk.call(('image', 'create', imgtype, name,) + options) TclError: can't invoke "image" command: application has been destroyed From jkraska1 at san.rr.com Wed Mar 21 19:05:12 2001 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 22 Mar 2001 00:05:12 GMT Subject: New PEP: The directive statement References: Message-ID: >from __experimental__ import stackless While I understand what you're trying to say, stackless requires alterations to the base runtime environment in which python lives. This is not really amenable to an import. C// From n8gray at caltech.edu.is.my.e-mail.address Tue Mar 20 22:31:04 2001 From: n8gray at caltech.edu.is.my.e-mail.address (Nathan Gray) Date: Tue, 20 Mar 2001 19:31:04 -0800 Subject: New PEP: The directive statement References: Message-ID: <3AB82078.8060005@caltech.edu.is.my.e-mail.address> Martin von Loewis wrote: > Please have a look at the PEP below. It is intended to replace the > __future__ import suggested in PEP 236. Excellent work, Martin. As it stands, I would prefer this to __future__ on grounds of clarity alone. Last time I checked, though, my name wasn't Guido, so you can take that for what it's worth. Thanks for putting your money where your mouth was. Or putting your additional keystrokes where your original keystrokes were. Usenet stretches the boundaries of our cliches... I've got a couple of comments about the design, though. > > Syntax > > A directive_statement is a statement of the form > > directive_statement: 'directive' NAME [atom] [';'] NEWLINE > > The name in the directive indicates the kind of the directive; it > defines whether the optional atom can be present, and whether > there are further syntactical or semantical restrictions to the > atom. In addition, depending on the name of the directive, certain > additional syntactical or semantical restrictions may be placed on > the directive (e.g. placement of the directive in the module may be > restricted to the top of the module). This syntax works but leaves little room for the future (no pun intended). Only one directive can be placed on a line, and using whitespace to link NAME with its possible atom seems inconsistent with the way similar constructs in Python work. (e.g. import general.lessgeneral.specific) Would you consider using this sort of syntax instead? directive_statement: "directive" directive_ID ("," directive_ID)* [";"] NEWLINE directive_ID: identifier ("." identifier)* I understand that there are those who want to keep things as dead-simple as possible, and there are good reasons for *not* wanting people to put multiple directives on one line, but at the very least consider changing the syntax to NAME ["." atom] to allow for more elegant extension in the future if we decide that this functionality is desirable. My second comment is that you may want to consider adopting a form of the __future__ proposal's runtime semantics for directive statements. Perhaps directive transitional.nested_scopes could create a "_Feature object" called nested_scopes identical to the one proposed in "back to the __future__". print nested_scopes.getOptionalRelease() # prints "(2, 1, 0, 'beta', 1)" Note that not all directive statements would need to have runtime semantics. In the case of "transitional", though, it seems like a useful idea. Well, that's all for now. Lest it sound like I'm blasting Martin's PEP, I should reiterate that I think it's the way to go. I've just got a quibble and a suggestion here and there. Thanks again, Martin, -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From fredrik at pythonware.com Wed Mar 21 12:18:56 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Mar 2001 17:18:56 GMT Subject: Stupid String Question References: <3AB8327C.493C70A5@direct.ca> Message-ID: <4o5u6.907$sk3.295107@newsb.telia.net> "Brian & Colleen" wrote: > What is the pretty way to generate a string of 30 asterisks. how about: a = "*" * 30 Cheers /F From mcalla at home.com Wed Mar 7 21:54:38 2001 From: mcalla at home.com (Mike Callahan) Date: Thu, 08 Mar 2001 02:54:38 GMT Subject: Simple Tkinter question References: <3AA482C0.D92E3CC4@theworld.com> Message-ID: Oh, so if I use root.quit() and then follow it up with root.mainloop() it would start the GUI again? Where if I use root.destroy(), it destroys the widgets and also quits the loop with no chance of starting it again unless I create another root. Is that correct? "David Lees" wrote in message news:3AA482C0.D92E3CC4 at theworld.com... > As I understand it, .quit simply exits the main loop, but leaves all > widgets and everything else you have created, while .destroy removes the > widgets you have created from the namespace. > > david lees > > Mike Callahan wrote: > > > > I know this is probably a stupid question but after reading the Tkinter > > documentation I am still confused between root.quit() and root.destroy(). > > What are the differences between these two methods? Thanks. > > > > Mike Callahan From dsavitsk at e-coli.net Fri Mar 9 01:29:30 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Fri, 9 Mar 2001 00:29:30 -0600 Subject: Another Tkinter question References: Message-ID: Wow ... Amazing ... Thanks. I think I just needed some confidence to try what VB would never do for me. ds "Matthew Dixon Cowles" wrote in message news:slrn9afn9a.ps.matt at happy-hour.mondoinfo.com... > On Thu, 8 Mar 2001 12:08:47 -0600, dsavitsk > wrote: > > >I have a small tkinter app that contains a (PMW) ScrolledFrame which > >in turn has a grid of entry widgets (it sort of emulates a small > >spread sheet). What I would like to do is add a new row of entry > >widgets while the thing is running, and I'm not sure how to go about > >this as I've already .packed them in. > > Tkinter is very dynamic: that your entry widgets have already been > packed shouldn't make a difference. Try just adding more. If that > doesn't work, I'd need to see your code to figure out what's up. > > >(Also, if anyone knows a better way to do this than tons of entry > >widgets that would be great.) > > If the easy way works, I'd do it the easy way. Naturally, it's also > possible to move the data around in a bunch of static widgets. That a > bit annoying since you have to do your own scrolling. If you'd like to > see some code of mine that does that, I'd be glad to point you at it. > I've seen combinations of the two approaches done as well, but that > was ugly. > > Regards, > Matt From emile at fenx.com Wed Mar 14 12:04:06 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 14 Mar 2001 09:04:06 -0800 Subject: Who am I: can a class instance determine its own name? References: Message-ID: <98o8fu$2s4dj$1@ID-11957.news.dfncis.de> Has locals changed so that it may be written to reliably? My documentation still warns: locals () Return a dictionary representing the current local symbol table. Warning: The contents of this dictionary should not be modified; changes may not affect the values of local variables used by the interpreter. Emile van Sebille emile at fenx.com "Harry George" wrote in message news:xqxzoeol3ju.fsf at cola.ca.boeing.com... > class MyName: > #-------------------------- > def init(self,name): > self.name=name > try: > raise None > except: > c=sys.exc_info()[2].tb_frame.f_back.f_back > c.f_locals[name]=self > ... > > MyName("me") > print me.name > > "Kevin Cazabon" writes: > > > The reason I say it's not elegant is that there is the possibility (read > > "probability") that the assigned name and the actual name can differ. > > > > We're assuming that the programmer assigns exactly the same name to both, > > which doesn't seem like a hard task, but it introduces the possibility of > > problems, and probably hard ones to debug too. > > > > If there were an automatic method, it would be MUCH more reliable. > > > > Just MHO. > > > > Kevin. > > > > > > > > "Paul Prescod" wrote in message > > news:mailman.984324974.25480.python-list at python.org... > > | Kevin Cazabon wrote: > > | > > > | > ... > > | > You could also > > | > make it an initialization parameter. > > | > > > | > FooBar = Foo(name="FooBar") > > | > > > | > Just trying to help... not elegantly though. > > | > > | I disagree Kevin. This is not only the canonical way to give an instance > > | a name, it is also the elegant way. It gives you a lot more flexibility > > | because the name it has at runtime is unrelated to the variable name you > > | happened to have given it in your code. If you need to change one or the > > | other for any reason, you can do so safely. > > | > > | Paul Prescod > > | > > > > > > -- > Harry George E-mail: harry.g.george at boeing.com > The Boeing Company Renton: (425) 237-6915 > P. O. Box 3707 02-CA Everett: (425) 266-3868 > Seattle, WA 98124-2207 Page: (425) 631-8803 From quickdry at users.sourceforge.net Sun Mar 11 01:36:47 2001 From: quickdry at users.sourceforge.net (Steven Adams) Date: Sun, 11 Mar 2001 06:36:47 GMT Subject: Python & Wireless Apps References: <98b4ra$107$1@bashir.peak.org> Message-ID: <32Fq6.10772$pG5.38040@news1.rdc1.nsw.optushome.com.au> "prince.kattare.com" wrote in message news:98b4ra$107$1 at bashir.peak.org... > Hello! I just got back from the Python Conference and glad to see that > there is a lot of motivation for the language. I am just starting out with > python and was wondering how it's being used in the wireless space, meaning > mostly palm devices. Has anyone ported an app to a palm pilot? What kind > of restrictions should I be considering when thinking about this? > > Thanks for any insight you might have! > > Louis > louis at decipherinc.com Python has been around on the WindowsCE platform for quite some time, and is really handy - http://starship.python.net/crew/skippy/ce/ while I haven't done much serious work on it, my advice would be to really pay attention to what data structures you're going to use. Efficiency in terms of execution speed and size is very important, where convenience is fine on the PC, on a 20MHz Palm you'll feel the hit that the convenience brings. IIRC pippy (python's palm port) doesn't support floating point ops, and there are a few other limitations. Happy hacking, Steven From ^NOSPAM^ifi at ifi.it Wed Mar 7 09:54:50 2001 From: ^NOSPAM^ifi at ifi.it (accattatevillo) Date: Wed, 07 Mar 2001 15:54:50 +0100 Subject: Using a jar with jython References: <3AA6115E.7B2ACDEE@ifi.it> <3aa62b59_1@nnrp1.news.uk.psi.net> Message-ID: <3AA64BBA.DCECD14F@ifi.it> > What are the problems that you are having? Error messages? > > BTW, I'm cross-posting this the Jython on AS/400 mailing list. If > you are using Jython to access an AS/400, you might want to join - > see . I found the problem: I was sleeping when I wrote JT400.JAR instead of jt400.jar!!! Thanks a lot. Regards Stefano P.S.: I'll join the group you told me about From jdries at mail.com Thu Mar 8 20:23:02 2001 From: jdries at mail.com (Jan Dries) Date: Fri, 09 Mar 2001 02:23:02 +0100 Subject: Can anyone recomend a good intoduction to C... References: <3AA5EF59.507F1D91@olsen.ch> <983958878.976344@newsmaster-04.atnet.at> <77up6.1289$y6.235541@ruti.visi.com> <985vqs01ipr@drn.newsguy.com> Message-ID: <3AA83076.B968CCED@mail.com> Courageous wrote: > > >All this bloat added to C++ was not necessary for making an OO language. > > Echo that. What's "object oriented" about templates? > > A: NOTHING. > If Stroustrup's goal had been to come up with an object oriented language, and nothing more, he might just as well have produced SmallTalk. Templates may not be OO per se, but that does not mean they're of no use. OO is just one of around 40 commonly used architectural styles to develop software. OO is a means of achieving some goal, not a goal in itself, and templates are simply another technique, complementary to OO, to assist programmers in achieving the goal of developing robust, reusable, entensible software. Quoting from "The ANSI/ISO C++ Professional Programmer's Handbook": "Generic programming proceeds one step beyond object oriented programming in pursuing reusability. Two important features of C++, templates and operator overloading, are the basis of generic programming." Regards, Jan From dog at ERC.MsState.Edu Tue Mar 13 22:11:05 2001 From: dog at ERC.MsState.Edu (David OGwynn) Date: Tue, 13 Mar 2001 21:11:05 -0600 (CST) Subject: Problems with Irix (stack overload) Message-ID: <200103140311.f2E3B5i05941@ERC.MsState.Edu> I'm building a visualization tool for debugging polygonal mapping trees using python and the python/c API. In the extension module, I have both togl and glut interfaces. On SUN, everything works swimmingly. On SGI/irix, I'm having problems. To preface, the module takes a binary file, parses it and builds an "Octree" object. The parser then inserts facets and octants (both singly linked lists of c structs). Then the preparedraw Octree object function builds a set of OpenGL Display lists by marching down the facet and octant lists. I say all this to give exposition to my delema. Like I said, solaris works like a dream for both glut and togl. SGI, though, throws up on the togl preparedraw function. When I run preparedraw function, it segfaults and tells me that the program has exceeded its stack allotment. I tried increasing the stack allotment to 500M, but that still didn't work. Here's another twist: I tried rloging into the same machine and everything worked fine. So, I can run the code if I am rloging but not when I'm on the machine. Can anyone give me a clue? _____________ David O'Gwynn dog at erc.msstate.edu "Life begins where math breaks down." --B.D.O. From no-spam-popov at bigserver.com Sun Mar 11 15:05:39 2001 From: no-spam-popov at bigserver.com (Boris Popov) Date: Sun, 11 Mar 2001 12:05:39 -0800 Subject: Einstein's Riddle References: Message-ID: <98glrd$1si1a$1@ID-75892.news.dfncis.de> "Steve Graham" wrote in message news:oNPq6.396644$ge4.138479566 at news2.rdc2.tx.home.com... > Who would be interested in using his/her brain (and his computer) to solve > the following? > > > Steve Graham > > === > > Einstein's Riddle > > Albert Einstein wrote this riddle this century [ed. 20th century]. He said > 98% of the world could not solve it. > > There are 5 houses in 5 different colors. In each house lives a person with > a different nationality. The 5 owners drink a certain type of beverage, > smoke a certain brand of cigar, and keep a certain pet. No owners > have the same pet, smoke the same brand of cigar or drink the same beverage. > > The question is: "Who owns the fish?" > > Hints: > > The Brit lives in the red house. > > The Sweed keeps dogs as pets. > > The Dane drinks tea. > > The green house is on the left of the white house. > > The green house's owner drinks coffee. > > The person who smokes Pall Mall rears birds. > > The owner of the yellow house smokes Dunhill. > > The man living in the center house drinks milk. > > The Norwegian lives in the first house. > > The man who smokes Blends lives next to the one who keeps cats. > > The man who keeps the horse lives next to the man who smokes Dunhill. > > The owner who smokes Bluemasters drinks beer. > > The German smokes Prince. > > The Norwegian lives next to the blue house. > > The man who smokes Blends has a neighbor who drinks water. > I don't beleive he said that only 2% of the world could solve it. It's not hard, you just need to pay attention to the details. The German owns the fish. It was supposed to be a table that I used to layout all the details, but I prefer to post plain-text: house 1 2 3 4 5 color yellow blue red green white nationality norweigian dane brit german swede drink water tea milk coffee beer smoke dunhill blend pall mall prince bluemaster pet cats horse birds fish dogs -Boris P.S. Did I have to write software to solve it ? :) From chris at home.com Fri Mar 30 19:52:03 2001 From: chris at home.com (Chris) Date: Sat, 31 Mar 2001 00:52:03 GMT Subject: Know of Substantial Apps Written in Python? References: <3ac4e4a8_1@news4.newsfeeds.com> Message-ID: <3AC529CD.70406@home.com> Have a look at the Gadfly database engine. Not all that "large", but complex, as demonstrates the power of python. Moshe Zadka wrote: > On Fri, 30 Mar 2001 12:02:14 -0800, "Dry Ice" wrote: > > >> Know of substantial apps written in Python? > > > Two big ones come to mind: Mailman (www.list.org) and Zope (www.zope.org) > Oh, and Sketch (sketch.sourceforge.net) From greg at cosc.canterbury.ac.nz Sun Mar 4 21:06:43 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Mon, 05 Mar 2001 15:06:43 +1300 Subject: I come to praise .join, not to bury it... References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> Message-ID: <3AA2F4B3.A7496E76@cosc.canterbury.ac.nz> Alex Martelli wrote: > > I have not heard ANY _technical_ arguments opposed to > this last time the discussion went around -- nothing but > vague aesthetic, "it should be the other way", "I find it > ugly" kind of complaints. While your arguments are _technically_ sound, we are yet to be convinced that the benefits outweigh the drawbacks of being forced to use what many find to be an obscure and hard-to-follow syntax for all string joining. The vast majority of string-joining operations in Python code that I've seen and written haven't had any need for polymorphism at all. On the rare occasions when I want a polymorphic joiner[1], I'm quite willing to build the necessary machinery and use whatever syntax is necessary. But I don't want to pay the price of having to use that syntax *every* time I join strings! Footnotes: [1] So rare, in fact, that so far I've *never* wanted one. (Although I *have* written functions to do the join-the- last-pair-with-something-different thing, I've never had to choose between the two polymorphically.) -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From petasis at iit.demokritos.gr Mon Mar 12 01:54:23 2001 From: petasis at iit.demokritos.gr (Petasis George) Date: Mon, 12 Mar 2001 08:54:23 +0200 Subject: Einstein's Riddle References: Message-ID: <3AAC729F.77068663@iit.demokritos.gr> Well, I saw the same in Greek a month ago and it was somewhat unclear in its formation. Now that I see the English version, the ambiguity remains. If we assume that the fifth owner owns the fish, then: There is only one solution if you *asume* that "The green house is on the left of the white house." means that the green house in next to the white house, on the left side. On the other hand, if you assume that the green house is on the left of the white house, but other houses can be in between, then the are more than one solutions. In a simple C++ program that a friend wrote to find all solutions, it find at least 8. Supposing the first case (green house next to white, on the left), everyone that tried to solve it succeded. Ok, some people simply need more time. Even my 16-year little brother manage to solve it. So, where is this 98% not able to solve it? But unfortunately, I have to agree with Greg Jorgensen: the way it is stated is not solvable:-) You have to make assumptions for solving it... George Steve Graham wrote: > > Who would be interested in using his/her brain (and his computer) to solve > the following? > > Steve Graham > > === > > Einstein's Riddle > > Albert Einstein wrote this riddle this century [ed. 20th century]. He said > 98% of the world could not solve it. > > There are 5 houses in 5 different colors. In each house lives a person with > a different nationality. The 5 owners drink a certain type of beverage, > smoke a certain brand of cigar, and keep a certain pet. No owners > have the same pet, smoke the same brand of cigar or drink the same beverage. > > The question is: "Who owns the fish?" > > Hints: > > The Brit lives in the red house. > > The Sweed keeps dogs as pets. > > The Dane drinks tea. > > The green house is on the left of the white house. > > The green house's owner drinks coffee. > > The person who smokes Pall Mall rears birds. > > The owner of the yellow house smokes Dunhill. > > The man living in the center house drinks milk. > > The Norwegian lives in the first house. > > The man who smokes Blends lives next to the one who keeps cats. > > The man who keeps the horse lives next to the man who smokes Dunhill. > > The owner who smokes Bluemasters drinks beer. > > The German smokes Prince. > > The Norwegian lives next to the blue house. > > The man who smokes Blends has a neighbor who drinks water. From xeger at usa.net Wed Mar 7 00:15:10 2001 From: xeger at usa.net (Regular Expression) Date: Wed, 07 Mar 2001 05:15:10 GMT Subject: C/C++ extension: subclassing an extension type with Python code? Message-ID: I'd like to create an extension type which can be further extended by end users of the type. Ideally, I'd like to define certain properties that are read-only, and others that cannot be occluded in "subclasses" of the type. I'd also like to define certain methods that cannot be overridden. Does anybody have an idea how to do this? From aleaxit at yahoo.com Fri Mar 23 18:47:01 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 24 Mar 2001 00:47:01 +0100 Subject: PEP 245: Python interfaces References: Message-ID: <99gnb306gu@news2.newsguy.com> "Michel Pelletier" wrote in message news:mailman.985377931.22542.python-list at python.org... [snip] > > d) What is also missing from Python is > > an "auto-delegation". An analysis > > of how this fits in or doesn't fit > > in would be helpful. > > What is that? I've neve heard of auto-delegation. More properly "automatic delegation" -- in Python, you code it up in __getattr__; in my dream-version of Java (not existing afaik) you could just declaratively state "and all methods of interfaces X and Y which I have not implemented just delegate to the following expression based on my attributes", with at least interface granularity (if not method by method). Alex From careye at spamcop.net Thu Mar 22 05:06:38 2001 From: careye at spamcop.net (Carey Evans) Date: 22 Mar 2001 22:06:38 +1200 Subject: Evaluating the contents of a string References: Message-ID: <87lmpy6rtd.fsf@psyche.dnsalias.org> "Matt Barnett" writes: > In article , Aaron Ginn > wrote: > > Is there a simple way to evaluate the contents of a string assuming > > that string contains only nunbers and mathematical operators? [...] > eval("1.1 * 1.15") You can do that more safely, by passing in a globals() argument: >>> eval('1.1 * 1.15', {'__builtins__': {}}) 1.2649999999999999 Without this (or checking the string's syntax), something like this is possible (don't try this at home): >>> eval(r'__import__("os").system(r"echo I\'m so worried | mail root")') 0 >>> eval(r'__import__("os").system(r"echo I\'m so worried | mail root")', ... {'__builtins__': {}}) Traceback (innermost last): File "", line 2, in ? File "", line 0, in ? NameError: __import__ You could allow just mathematical operations, too: >>> import math >>> gl = {'__builtins__': {}} >>> for k in dir(math): ... if k[0] != '_': ... gl[k] = getattr(math, k) ... >>> eval('cos(2 * pi)', gl) 1.0 More advanced forms of this are handled by the rexec and Bastion modules. If this goes beyond what Aaron wants, I'm sure there's someone out there that found it interesting. -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "Quiet, you'll miss the humorous conclusion." From cribeiro at mail.inet.com.br Wed Mar 28 13:31:55 2001 From: cribeiro at mail.inet.com.br (Carlos Alberto Reis Ribeiro) Date: Wed, 28 Mar 2001 15:31:55 -0300 Subject: What *instance* called me & proxy methods In-Reply-To: <003701c0b7b2$039b1250$04090a0a@upcast.com> References: <3AC1BE92.ACE82741@ua.ac.be> <5.0.2.1.0.20010328104602.021cfc40@mail.inet.com.br> Message-ID: <5.0.2.1.0.20010328152624.021a45e0@mail.inet.com.br> At 10:07 28/03/01 -0800, Ken Seehof wrote: >You want 'im_self'. Ken, I checked this *before* posting my first message. In fact I cited this in my original message... First, in this paragraph, where I'm stating that I'm not looking for self: > > Can I know what *instance* called a method? I'm not talking about "self" > > here, because we *can* call a method using other techniques, such as > > copying the instance method pointer directly: And then here, when I said that I know about the im_self attribute (and about its companions as well). > > In both cases, hello() received the same value as the self parameter. This > > is exactly what I need; in fact, the im_self attribute of the instance > > method stores the pointer to self, which explains this behavior. Please check my examples. My question is not about how to know about "self" or "im_self". When I attach a instance method to my proxy, the value of im_self is kept the same(see the first example). I would like to have some way to know if the call was redirected through my proxy. My second example shows how I did manage to achieve it, but I'm not satisfied with the solution. Carlos Ribeiro From jeremy at alum.mit.edu Wed Mar 14 17:37:18 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Wed, 14 Mar 2001 17:37:18 -0500 (EST) Subject: Thoughts about extensions to the Python language In-Reply-To: <5.0.2.1.0.20010314181331.0213eac0@mail.inet.com.br> References: <5.0.2.1.0.20010314181331.0213eac0@mail.inet.com.br> Message-ID: <15023.62110.155494.764345@w221.z064000254.bwi-md.dsl.cnc.net> Guido did a poll at developers day last week. The question was: "Is Python development moving too fast or at just the right speed?" (He was being dictatorial and didn't even consider votes from the more-faster crowd.) I believe the results were 42 too fast and 50 just right. I noted that two of the more vocal proponents of the too fast camp proceeded to suggest new features. So at least some of the "too fast" people probably meant "too fast unless it's a feature I want" :-). Several people also suggested that Python 2.0 was a fine release, but there were too many new things in Python 2.1. Other than nested scopes, which aren't slated for standard arrival until 2.2, there aren't very many new features in 2.1 -- rich comparisons, a warnings framework, support for weak references. Rich comparisons, to pick an example, have been on the table for ages. The numeric people seem happy, because NumPy has already added support for them. You seem to have a very abstract concern about the speed of develpoment and the fact that we write design documents that describe changes to the language. I voted for "just right" in the poll, so we probably don't agree on the former. As for the latter, what alternative is there? Make changes to the language without describing the changes in advance? I don't expect Guido's good judgement is impaired by having written proposals to consider. He's been known to reject PEPs. Jeremy From enrico.spinielli at marconi.com Thu Mar 8 03:46:37 2001 From: enrico.spinielli at marconi.com (Enrico Spinielli) Date: 08 Mar 2001 09:46:37 +0100 Subject: LONG_BIT error when compiling python2.0 Message-ID: Hi all, I am trying to install python2.0 on RedHat 7.0 Linux. I got the sources and successfully run ./configure but after a little while down in the compilation I got the following error message: [...] gcc -g -O2 -Wall -Wstrict-prototypes -I./../Include -I.. -DHAVE_CONFIG_H -c -o node.o node.c In file included from ../Include/Python.h:54, from node.c:3: ../Include/pyport.h:390:2: #error "LONG_BIT definition appears wrong for platform (bad gcc config?)." make[1]: *** [node.o] Error 1 make[1]: Leaving directory `/mysrc/Python-2.0/Parser' make: *** [Parser] Error 2 I am using gcc2.96-54 Any idea about a possible solution? In the meanwhile I'll install gcc2.96-69 and retry... Thanks a million bye From sheila at spamcop.net Wed Mar 28 20:17:51 2001 From: sheila at spamcop.net (Sheila King) Date: Thu, 29 Mar 2001 01:17:51 GMT Subject: list vs tuple References: <3AC1EB93.7BC87292@hack.org> <3AC1F93A.BAC9E34B@hack.org> <99teuu02p5f@news1.newsguy.com> Message-ID: On Wed, 28 Mar 2001 16:50:58 -0500, "Steve Holden" wrote in comp.lang.python in article : :"Alex Martelli" wrote in message :news:99teuu02p5f at news1.newsguy.com... :> Actually, tuples have NO methods -- including those that would :> require no mutability at all: ...... :> Note the lack of 'count' and 'index', which do not mutate a list :> when applied to it, but are still missing from tuples. :> :So, tuples are not only immutable, they are also uncooperative. Tuples can be used as keys in dictionaries. Lists cannot. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From sholden at holdenweb.com Mon Mar 5 20:55:59 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 5 Mar 2001 20:55:59 -0500 Subject: Little problem with the "+" operator References: <983802310.155838463@news.t-online.de> <980i6q$crs$1@news.mathworks.com> Message-ID: "Joshua Marshall" wrote in message news:980i6q$crs$1 at news.mathworks.com... [ ... ] > Comparing Python to Perl here doesn't seem very fair. They're very > different languages. In general, I'm surprised by the urgency with > which people often jump to compare them. A very fair point, although of course the original enquiry was about an exception that Perl (nor VBScript, for that matter), would have raised. Methinks we Pythonistas should not protest too much. regards Steve From fredrik at pythonware.com Mon Mar 12 17:25:09 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 12 Mar 2001 22:25:09 GMT Subject: binary comparison of file object References: Message-ID: <91cr6.17919$Qb7.3117741@newsb.telia.net> Jaeho Lee wrote: > I am trying to compare the contents of binary file. Checking if the files > are same or not is enough. use the filecmp module: result = filecmp.cmp(file1, file2, shallow=0) for more info, see: http://www.python.org/doc/current/lib/module-filecmp.html Cheers /F From phlip_cpp at my-deja.com Wed Mar 28 15:26:04 2001 From: phlip_cpp at my-deja.com (Phlip) Date: Wed, 28 Mar 2001 12:26:04 -0800 Subject: Python and SWIG - passing object pointer param to an embedded script. References: <3ac1a999@pron.i-way.net.uk> Message-ID: Andrew Bonello wrote: > PyDict_SetItemString( globals, "myobjptr", myobj); > > PyObject* obj = PyRun_File( fp, (char*)fn, 0, globals, locals ); > > This just causes an access violation. (I am using Microsoft Visual C++ > V6.0 with Python V2.0, Debug build). We ran with SWIG for a spell, and then I auditioned the Boost Python Library (www.boost.org) and never looked back. For a way-cool example of reflection in native C++ without any extra parsers or mucking Boost rocks. -- Phlip phlip_cpp at my-deja.com ============== http://phlip.webjump.com ============== -- It's a small Web, after all... -- From scarblac at pino.selwerd.nl Thu Mar 22 11:01:16 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 22 Mar 2001 16:01:16 GMT Subject: learning python... References: <3AB8F4E1.184DD9C@noaa.gov> <3ABA1148.ABBC50C0@sewardweb.com> Message-ID: Lloyd Sommerer wrote in comp.lang.python: > One final bit of advice: When you're wondering how to use a specific > module, the best documentation is very often within the module itself. I > didn't actually come across that advice anywhere, and it would have helped > me to have known it sooner. And all of that info is now available on http://www.pydoc.org under "Module Documentation by PyDoc". All the docstrings extracted from the code. Pretty cool. -- Remco Gerlich From dg at pearl.tao.co.uk Tue Mar 13 06:59:08 2001 From: dg at pearl.tao.co.uk (David Given) Date: Tue, 13 Mar 2001 11:59:08 +0000 Subject: Atomic Event.{wait,clear} Message-ID: I'm using the threading module, with the Event class to handle synchronisation. It's all working nicely and is very easy to use. However, I can't seem to find a way of atomically waiting for an Event, and then clearing the flag, which is very strange. Currently I do Event.wait() and then Event.clear(). If another thread does a Event.set() in between the two, the event will be lost. For my current application, this isn't a problem, but what shold I do in the future? -- +- David Given ---------------McQ-+ | Work: dg at tao-group.com | Ugl?k u bagronk sha pushdug Internet-glob | Play: dgiven at iname.com | b?bhosh skai. +- http://wired.st-and.ac.uk/~dg -+ From cfelling at iae.nl Fri Mar 2 19:12:50 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 3 Mar 2001 01:12:50 +0100 Subject: Thinking Pythonically (was Re: gah! I hate the new string syntax) References: <97ohh2$polt0$1@ID-77331.news.dfncis.de> <97opsb$nhu$1@nntp6.u.washington.edu> <97oupq$qijrh$1@ID-77331.news.dfncis.de> Message-ID: <97pcu2$n6n$1@animus.fel.iae.nl> Mark Pilgrim wrote: ... >>>> output = os.popen("cleartool lsvob -l").readlines() ... >>>> [line for line in output if line[:4]=='Tag:'] ... >>>> vobs = [line.replace('Tag:', '').strip() for line in output if > line[:4]=='Tag:'] ... >>>> "cleartool lock %s" % " ".join(vobs) > 'cleartool lock /vobs/intranet /vobs/project' > And that's what I call thinking Pythonically. YMMV. nai, that's unix thinking, like with $ cleartool lock `cleartool lsvob -l | grep ^Tag: data | cut -c 6-` -- groetjes, carel From gerhard.nospam at bigfoot.de Fri Mar 23 21:10:47 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sat, 24 Mar 2001 03:10:47 +0100 Subject: Install Python on Apache References: <99fph5$a2n$1@rex.ip-plus.net> Message-ID: <3ABC0227.BC35664@bigfoot.de> No need for weird and ugly hacks like the ones mentioned before 8-) Just add this *one* line at the end of your httpd.conf: ScriptInterpreterSource Registry Assuming .py, .pyc, .pyw and .pyo are registered to be handled by python{w}.exe, like any installer from ActiveState or python.org does, you are ready to go. Just give your cgi-scripts an extension registered to Python. My scripts look like this: #!/usr/bin/env python print 'Content-type: text/plain\n\nPython cgi works!' They then run unchanged on win32 and Unix. Gerhard PS: The ScriptInterpreterSource is mentioned in the Apache docs. It just makes Apache use the Windows assosiations of the various extensions to invoke the right interpreter for cgi, such as .pl for P*rl, .py for Python, .bat and .cmd for batch files, etc. -- Sorry for the fake email, please use the real one below to reply. contact: g e r h a r d @ b i g f o o t . d e web: http://highqualdev.com From kknbk2 at bellsouth.net Sat Mar 3 22:17:24 2001 From: kknbk2 at bellsouth.net (Kyle Wayne Kelly) Date: Sat, 3 Mar 2001 21:17:24 -0600 Subject: Java guy interested in Python Message-ID: <003801c0a459$a29c97f0$63da1542@wisdom> Can anyone tell me some of the things that Python offers which are not available in Java? I like Python's syntax, but what can Python do that Java can not do? Any comments are helpful. Kyle Wayne Kelly Computer Science Student University of New Orleans http://www.cs.uno.edu/~kkelly -------------- next part -------------- An HTML attachment was scrubbed... URL: From shaleh at valinux.com Wed Mar 7 14:37:32 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Wed, 07 Mar 2001 11:37:32 -0800 (PST) Subject: Can Python 1.5.2 code run on Python 2.x? In-Reply-To: <985c9m$3gg$1@hobbes2.crc.com> Message-ID: On 07-Mar-2001 Glen Mettler wrote: > Can code written in Python 1.5.2 run without modification on Python 2.x? > If not, what modification in code is required? > The what's new docs show places where old code could fail. From grante at visi.com Tue Mar 6 11:47:57 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 06 Mar 2001 16:47:57 GMT Subject: Can anyone recomend a good intoduction to C... References: <3aa366c6_2@nnrp1.news.uk.psi.net> <8gNo6.440$y6.128357@ruti.visi.com> <3aa79a8a.466828531@nntp.interaccess.com> Message-ID: <1x8p6.1046$y6.188683@ruti.visi.com> In article <3aa79a8a.466828531 at nntp.interaccess.com>, Thaddeus L. Olczyk wrote: >>>I'm going to have to bite the bullet and learn a bit of C. I'd at >>>least like to learn the *right* way to do it. >> >>The "right" way to do it is with a PDP-11, a Lear-Siegler ADM3a >>and the v7 source code. ;) Some would argue in favor of an >>ASR-33, but they tend to annoy the downstairs neighbors. >Recently the original UNIX was released( isn't the v7 source a bit >old? I would think you get something a bit earlier). Yes, v7 is farily "modern". It happens to be the first one I used, so that's what came to mind. -- Grant Edwards grante Yow! Where does it go when at you flush? visi.com From aleaxit at yahoo.com Fri Mar 9 08:52:53 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 9 Mar 2001 14:52:53 +0100 Subject: gah! I hate the new string syntax References: Message-ID: <98an7i01tgp@news2.newsguy.com> "D-Man" wrote in message news:mailman.984063199.18779.python-list at python.org... > On Thu, Mar 08, 2001 at 06:51:07PM +1300, Paul Foley wrote: > | On Wed, 7 Mar 2001 15:33:30 -0500, D-Man wrote: > | > | > What about one who is both English and Scots, yet never set foot on > | > that island ;-)? > | > | AFAIK, nobody outside the US would admit the existence of such a > | thing. The American habit of calling themselves "Irish" or "Italian" > | or whatever when they're not is *very* strange. I've never heard > | anything like it anywhere else. > > Heh. Maybe Americans are very odd. Wouldn't surprise me at all. ;-) Maybe. OTOH, Italians born abroad (from parents who consider themselves temporary immigrants, and fully intend to return "home" when they've put enough savings aside) have traditionally called themselves "Italians" whether that "abroad" was Northern America, Argentina, Germany, Libia, or any of the several other countries where Italian emigrants used to go. (Of course, intentions to return are not always carried out -- few are aware, for example, that such an icon of French popular culture as Yves Montand was Italian -- real name Ivo Livi, born of just-as-Italian parents in a village near Florence; his father, a socialist, had to flee [and ended up in France] when the Fascists took power, and Ivo, as well as the rest of the family, followed him a while later; I'm not sure when he changed his citizenship over to France). > that I am not really American since none of my ancestors came from > America. "Real" Americans would be the so-called "Indians", or more Why? *THEIR* ancestors came from Asia over the Bering Straits, after all (and following the line a while longer, one gets back to Africa). Alex From tim.one at home.com Sat Mar 24 17:26:10 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 24 Mar 2001 17:26:10 -0500 Subject: New PEP: The directive statement In-Reply-To: Message-ID: [Martin von Loewis] > That was rather meant as a comment to PEP 236: Instead of giving a > mandatory release, it appears that all you can specify is a > is_mandatory (isMandatory, or mandatory_p) flag; this is also all you > said an application might need. I don't think I followed that. Since the future isn't certain until it happens (and half the time not even then <0.9 wink>), I don't see that it's possible "even in theory" to do better than give a best guess, and one that gets updated if the once-predicted future arrives in a form other than hoped for. > ... > it is also a fact that I do like to see the possibility to specify > source encodings. Me too. > It's just that I cannot hope to get that now - but I had the hope that > the future statement would be removed before the 2.1 release. Now that > the final beta still has it, that hope is vanishing... Note that Guido didn't reject your patch, he postponed it. He even said he *liked* the idea of directives! The "transitional" form of the patch didn't show up until Tuesday (three tiny days before the 2.1b2 scheduled release: the worst possible time to try to get mindshare), and it didn't come with (for example) doc changes, or patches to IDLE or python-mode.el to colorize stuff the way people will expect. We couldn't possibly make time to take up that slack, and 2.1b2 is supposed to be the last chance for *anything* new to get in. The PEP was also too late, and now that you've written it it's clear enough that it hasn't been met with universal delight either. So I agree w/ Guido's patch comment in all respects: I'm postponing this now. I like the idea of directives, but I don't think we should disrupt the 2.1 release for this. So let's look at this again after 2.1. You have to work pretty hard to get depressed by that . From mwh21 at cam.ac.uk Fri Mar 9 06:52:04 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 09 Mar 2001 11:52:04 +0000 Subject: Static typing (was Re: Java guy interested in Python) References: Message-ID: =?iso-8859-1?q?Hamish=20Lawson?= writes: > Michael Hudson wrote: > > > If you type-annotate this, you might write (using entirely made up > > syntax): > > > > def write16(file : , int : ): > > file.write(struct.pack("h",int)) > > > > but then what about passing in a StringIO object, or some user > > wrapper of a file object? What makes a ""? At the moment, > > it's just a loose collection of methods, some of which are optional > > in some circumstances. > > Wouldn't there be a hierarchy of interface types for file-like > objects, with some interfaces specifying more methods than others? > You'd then choose the interface type that specified the collection > of methods that you require of your passed object. Well, that might be possible, but (a) there isn't one, presently (b) you'd certainly have fun trying to make the heirachy a DAG. I suspect that you'd basically end up listing the methods required, eg: def func(file : , ...): pass I'm not sure that makes a "type system". Hmm. More thinking required. Cheers, M. -- The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offence. -- Edsger W. Dijkstra, SIGPLAN Notices, Volume 17, Number 5 From fredrik at pythonware.com Tue Mar 13 14:57:00 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 13 Mar 2001 19:57:00 GMT Subject: Extending Python: rewriting a single method in C References: <98l1i901k4u@news1.newsguy.com> Message-ID: Jacek Generowicz wrote: > (Would it be fair to say that the documentaion is, on the whole, less > that satisfactory ?) are you sure you read the C API docs before posting? http://www.python.org/doc/current/api/objects.html explains how PyObject's work. http://www.python.org/doc/current/api/concrete.html explains how to deal with objects of a known type. http://www.python.org/doc/current/api/object.html explains the abstract object interface, including the functions you mention: PyObject* PyObject_GetAttrString (PyObject *o, char *attr_name) Return value: New reference. Retrieve an attribute named attr_name from object o. Returns the attribute value on success, or NULL on failure. This is the equivalent of the Python expression "o.attr_name". etc. Cheers /F From grante at visi.com Mon Mar 12 16:50:31 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 12 Mar 2001 21:50:31 GMT Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> Message-ID: In article <3aad4062.1290021 at News.CIS.DFN.DE>, costas at springmail.com wrote: >Ok, I can see maybe division having problems. But why does addition of >the two numbers below: > >5.01+5.54 > >give me this? > >10.550000000000001 Sorry. That's how floating point numbers on computers work. Many numbers (including 10.01) can't be represented exactly in the binary representation used by your computer. Therefore floating-point results are never going to be exact. >I hope its some setting that can take care of this. I am using Python >under Windows 98. Use integer or fixed-point BCD math if you need exact results. -- Grant Edwards grante Yow! MMM-MM!! So THIS is at BIO-NEBULATION! visi.com From fredrik at pythonware.com Wed Mar 14 17:15:57 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 14 Mar 2001 22:15:57 GMT Subject: gah! I hate the new string syntax References: <97sudi01i26@news1.newsguy.com> <98elrk$li8$1@nntp.Stanford.EDU> <98fc070thh@news1.newsguy.com> <98iqo2$56o$1@nntp.Stanford.EDU> <98iv3s01sc2@news2.newsguy.com> Message-ID: Quinn Dunkan wrote: > Note that in ruby, any time you write > > class Foo > ... > end > > you are adding to, not overriding, 'Foo'. Thus, > > class String > def cap > s = (if self[0].betwwen?(97, 122) then > self[0] - 32 > else > self[0] > end).chr > s + self[1 .. self.length] > end > end > > is perfectly valid ruby that does what he wanted does all classes live in the same namespace? Cheers /F From jziniti at speakeasy.org Tue Mar 6 08:21:05 2001 From: jziniti at speakeasy.org (mapMonkey) Date: Tue, 06 Mar 2001 18:21:05 +0500 Subject: Open Source Organic Chemistry software project Message-ID: Pythonistas, I am encouraging my current employer to GPL at least some of our code and I would like to see what kind of interest I can generate from the Python community ( everyone's favorite language ;). The amount of interest is very likely to swing the vote ... The current code-base is geared to Organic Chemistry molecules and the IUPAC nomenclature system and it works quite well. It was written entirely in Python, and entirely by me. My goals are to re-engineer this code for added flexibility, and to increase the scope of the model to include all (or most) of organic chemistry (reactions, submolecular thingies, etc.). Anyone? Anyone? Thanks for your time, John Ziniti From patrick at swdev.com Fri Mar 23 02:58:45 2001 From: patrick at swdev.com (Patrick Curtain) Date: Fri, 23 Mar 2001 07:58:45 GMT Subject: learning python... References: <3AB8F4E1.184DD9C@noaa.gov> Message-ID: Count me in. I'd LOVE a better integrated environment for development, but retain the vi keybindings. :) Yes, we're strange. --p In article <3AB8F4E1.184DD9C at noaa.gov>, "Benjamin.Altman" wrote: > Hello. From the perspective of someone who already has programming > experience, would anyone know if O'reillys "Learning Python" book would > be better than say Prentice Hall's "Core Python Programming"? Or would > it be better to go straight into something like "Programming Python"? > > Thanks, > Ben -- Patrick Curtain, Husband & Father ( i also write software ) http://www.swdev.com/ From aleaxit at yahoo.com Tue Mar 20 01:39:03 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 20 Mar 2001 07:39:03 +0100 Subject: [Very Long (11K)] Numeric PEPs, first public posts References: <1DBt6.120680$ML1.5626083@e420r-atl2.usenetserver.com> Message-ID: <996u310128n@news2.newsguy.com> "Steve Holden" wrote in message news:1DBt6.120680$ML1.5626083 at e420r-atl2.usenetserver.com... [snip] > > > Should the // operator be renamed to "div"? > > > > If % is % and not "mod", I would probably spell it //. But I would > > call % "mod", except that it's too late. > > > No it isn't. It's never too late to _suggest_ a change :-) I seem to I think div and mod might be built-in functions; sure, infix operator syntax is nice, but, two new keywords... [BTW, this discussion is supposed to move to the Python Numerics list...]. > > I guess that sin(1.5) converts the argument to float? > > > Well, it shouldn't need to, unless the default numeric literal is a > rational: 1.5 already _is_ floating point, isn't it? It is now, but not in Moshe's PEP (it would be rational; 1.5e0 would be the float literal). Alex From db3l at fitlinxx.com Fri Mar 30 16:57:35 2001 From: db3l at fitlinxx.com (David Bolen) Date: 30 Mar 2001 16:57:35 -0500 Subject: Should I close after popen?? References: Message-ID: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) writes: > As it was pointed on this list quite a while ago, Python has no language > definition per itself. It is rather defined by the documentation of its > main implementation. It is true that the documentation of (C)Python does > not commit it on the particular issue above, and this is why I checked > with this list before starting to firmly rely on this feature, in real code. Except that Python (the language) does have a Language Reference, which does a reasonably good job of defining the language, sans implementation, along with some implementation notes. In particular, section 3.1 talks about finalization and garbage collection as implementation specific, and even "strongly" recommends using methods such as close() on objects that involved external resources. Clearly CPython has some deterministic behavior in this respect, which has a low probability of changing at this point, and taking advantage of that is just fine, as long as there's clarity on what the dependence is, which is important in forum discussions such as this. > In the meantime, I think we might continue to safely define Python as per > (C)Python, rather than by the intersection of Jython and Python. I do know > that if I ever move from Python to Jython, I'll have to revise many things > in my code, but until then, I prefer to be as clean and legible as possible. I think "Python" should be defined as Python, and in discussions about implementation issues, it's perfectly valid to base decisions on an implementation such as CPython or JPython/Jython if one is willing to have implementation-dependent code. I guess perhaps my point was somewhat pedantic, but in a discussion about implementation dependent items, I think it's best to be clear on naming the implementations. > The close *is* properly done. This is guaranteed by the fact I do not > keep any reference to the file. On the first example, the close is done > before proceeding with the next Python instruction. On the second example, > the close is done even before the first "process(line)" is executed. In current CPython yes, but not guaranteed by Python the language (per the reference which is very clear on that fact). > About errors, shouldn't we just rely on the fact that they raise exceptions, > automatically? One of the beauties of Python, compared to C or Perl, is that > errors are always trapped and handled by the system, when not by the user. Except that if the finalization was postponed, that exception might crop up in the strangest place (assuming it was propagated up at all). But aren't exceptions that occur as part of finalization suppressed? Assuming that the internal file type works similarly to Python code objects, where exceptions are definitely suppressed in __del__ processing (see language reference section 3.3.1, under the Warning: note for __del__). > So, we have all guarantees that the data got written to the logfile, given > the script does not fail with an I/O error. Errors on implicit close will > also be properly detected. So, there is no need to feel uncomfortable! :-) Just as an FYI, but that's not true in CPython. The close that is done during object deallocation ignores any error codes, unlike that done in response to a close() method call. This is true in at least 1.5.2 and 2.x which I had source around for. So errors on implicit closes will be silently ignored. Note that I'm definitely not trying to force a certain comfort level on yourself - you have the right to feel as comfortable or uncomfortable depending on implementation-specific behavior as you like :-) But at the same time, I think it's worth pointing out the risks in such dependence (note your assumption about exceptions), since it's up to each developer to make that risk/ease tradeoff. For me, while I may make the trade-off with read-only operations, I don't think I'd do it if I were writing. And even for reading, for best use of resources in the most portable way, explicit close() is better. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From dsh8290 at rit.edu Thu Mar 8 18:34:31 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 8 Mar 2001 18:34:31 -0500 Subject: Can Python replace Visual Basic? Should it? In-Reply-To: ; from bbollenbach@homenospam.com on Thu, Mar 08, 2001 at 02:10:22AM +0000 References: <5DZo6.11126$hn5.1578410@news1.rdc1.mb.home.com> Message-ID: <20010308183431.D3723@harmony.cs.rit.edu> On Thu, Mar 08, 2001 at 02:10:22AM +0000, Brad Bollenbach wrote: [snip] | | Maybe the fact that only one person who saw my original post has | actually migrated from VB to Python is an answer in itself. Maybe there are other reasons entirely. For example, I am not a VB programmer, nor have I ever used VB. Maybe there just aren't many people on this list who have used VB, or more specifically used VB before using Python. And again, maybe not. I come from an Eiffel, C++, Java, C background (pretty much in that order) mostly on *nix systems. -D From gerhard.nospam at bigfoot.de Tue Mar 13 14:14:20 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Tue, 13 Mar 2001 20:14:20 +0100 Subject: Subject with SMTPLIB? References: <3AADE48A.5D8AA43@daimlerchrysler.com> Message-ID: <3AAE718C.DA8B99B9@bigfoot.de> Gregory Jorgensen wrote: > > You need to add a subject header to your message. Email message format is > simple: headers, blank line, message body. > > import smtplib > > msg = "subject: hello, world!\n\nmessage body" > > s = smtplib.SMTP(host) > s.sendmail(fromaddr, toaddrs, msg) > > You'll find a good SMTP quick reference on Dan Bernstein's site (he's the author > of qmail). See http://cr.yp.to/immhf.html. > > In article <3AADE48A.5D8AA43 at daimlerchrysler.com>, root says... > [...] And, btw. you don't need to be root on a mission critical mailserver to use it ;-) Gerhard -- Sorry for the fake email, please use the real one below to reply. contact: g e r h a r d @ b i g f o o t . d e web: http://highqualdev.com From cce at clarkevans.com Tue Mar 20 22:57:12 2001 From: cce at clarkevans.com (Clark C. Evans) Date: Tue, 20 Mar 2001 22:57:12 -0500 (EST) Subject: Yet Another PEP: Query Protocol Interface or __query__ In-Reply-To: Message-ID: On Wed, 21 Mar 2001, Delaney, Timothy wrote: > So far as I can see, this PEP does not solve one basic > problem - interfaces which the class writer doesn't know about. I think that this is a problem it does not set out to solve, Alex Martelli's last post gave some insightful ways this can be done. Something like this can go into another PEP. As this PEP doesn't prevent such a mechanism. > I think it would be better if an interface was actually a class instance > which specified exactly what it required. This could not only be methods (or > other attributes), but also the (minimum) parameters required (and possibly > their types) and even any pre- or post- conditions required by the > interface. It could also mark "optional" features which if available > will be used. Right. This is a complicated issue, and this PEP doesn't attempt to solve this. It only attempts to introduce a simple mechanism to allow "declarations" in such a way so that "discovery" can be added later. > This instance then gets passed to the __query__() method. The __query__() > method then inspects the requirements, and returns either a class instance > or None. The class instance could either be self or a proxy to self or > something completely separate. A None of course means that it cannot meet > the requirements for the interface. I like returning None! You are I think the third person to suggest this, so I'll update the PEP with this suggestion. > If no __query__() method is defined on the class, the query() function would > then inspect the methods and other attributes of the class to determine if > it meets the requirements of the interface. Naturally, interfaces with > post-conditions would have to fail immediately in this case, and any > pre-conditions which could not be readily determined would also have to fail > the interface test immediately. A "readily-determined" pre-condition would > be something like "attribute x == 3" (not a good example, but a simple one). > > This seems to me a much more general and useful way of specifying > interfaces, whilst covering all the things an interface may need. It allows > the __query__() method to return different things on different invocations > for the same interface, depending on the state of the class. For example, a > file-like object may be unable to meet the "file-like" interface until it > has all its data in memory. Until this is the case, it would return None > from its __query__() method for an interface which required the read() > method. Right. All this is good, and I'm specifically not trying to prevent this kind of stuff. I just wanted a simple way to get at interfaces that are declared _without_ diving into this type of stuff... > I may well just try implementing this some time ... most of it shouldn't be > too hard. Unfortunately, I've got a nasty deadline coming up ... :( Kewl. Thank you so much for the feedback! Clark From stephen_purcell at yahoo.com Mon Mar 5 03:03:35 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Mon, 5 Mar 2001 09:03:35 +0100 Subject: Missing the functional mind set In-Reply-To: <2j35at4v2u75l507v4djdqjv6if8rsq10u@4ax.com>; from urner@alumni.princeton.edu on Sun, Mar 04, 2001 at 10:53:13AM -0800 References: <2j35at4v2u75l507v4djdqjv6if8rsq10u@4ax.com> Message-ID: <20010305090335.A4486@freedom.puma-ag.com> Kirby Urner wrote: > >The problem is that sorting a list can't be done in a functional way. > > Maybe you didn't see the first responder's solution: > > >>> d = {3: 'd', 2: 'b', 1: 'a', 0: 'z'} > >>> templist = [d[n] for n in range(len(d))] > >>> templist > ['z', 'a', 'b', 'd'] > > That's a good 2.0 and up solution. Except that he wanted the keys sorted, and didn't claim that they would always be consecutive integers in range(len(d)). (in which case I'd go for 'map(d.get, range(len(d)))' anyway) -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Get servlets at http://pyserv.sourceforge.net/ "Even snakes are afraid of snakes." -- Steven Wright From sarnold at earthling.net Mon Mar 12 01:08:56 2001 From: sarnold at earthling.net (Stephen L Arnold) Date: Sun, 11 Mar 2001 22:08:56 -0800 Subject: font problem Message-ID: <20010312060857.494931F661@shiva.arnolds.bogus> Howdy: I'm trying to get started with ActivePython, but the windoze html help thingie uses the wrong font for identifiers (it's trying to use the line drawing font). I have the latest IE5 and the html help update (running on win95 OSR2 with all the updates). I tried the old windoze un-install/re-install ting, with no luck. Anybody know the fix, or which font to install (if one is missing). I've got a ton new ones after installing IE and Python... Thanks in advance, Steve From kevin_cazabon at hotmail.nospamplease!.com Sun Mar 11 02:33:41 2001 From: kevin_cazabon at hotmail.nospamplease!.com (Kevin Cazabon) Date: Sun, 11 Mar 2001 00:33:41 -0700 Subject: Who am I: can a class instance determine its own name? References: Message-ID: You could "assign" it a name when you create the instance: FooBar = Foo() FooBar.name = "FooBar" This would let you trace it later... not elegant though. You could also make it an initialization parameter. FooBar = Foo(name="FooBar") Just trying to help... not elegantly though. Kevin "Tim CHURCHES" wrote in message news:mailman.984034150.9635.python-list at python.org... This is probably an elementary question and the answer is probably writ large in multiple places in the Python documentation, but... ...can an instance of a class determine the name of the variable to which it is assigned? For example: ########################### class Foo: def whoami(self): return "You are a Foo() but I do not know your name" FooBar = Foo() print FooBar.whoami() ########################### How does one define the method whoami() so that it returns "FooBar"? This sort of navel gazing is formally called introspection, I think (therefore I am)? Tim Churches Sydney, Australia (where, due to the Coriolis effect, the Python prompt does indeed look like this: <<< - or maybe its because we are upside-down) From charlie at gabrielinteractive.com Thu Mar 15 14:37:06 2001 From: charlie at gabrielinteractive.com (Charlie Barrows) Date: Thu, 15 Mar 2001 14:37:06 -0500 Subject: PyImport_ImportModuleEx() ? Message-ID: <98r5lv$1mbi$1@allnight.news.cais.net> I'm just starting to tinker with embedding Python in a C app and I'm having trouble getting PyImport_ImportModuleEx() to import [*] of a module into __main__. More specifically: I can get it to import the module fine as a separate namespace, but, just for the sake of thinking I know what I'm doing, I wanted to import all the module's functions into __main__'s namespace. I guess you could also say I'm looking for the PyImport_ version of this line: PyRun_SimpleString("from TestScript import *\n"); I was thinking some combination of PyImport_ImportModuleEx would do the trick but haven't been able to figure it out. Am I missing one or more points here? Thanks. Charlie Barrows Gabriel Interactive From claird at starbase.neosoft.com Wed Mar 14 17:06:41 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 14 Mar 2001 16:06:41 -0600 Subject: BCD applications (was: This math scares me) References: <3aad4062.1290021@News.CIS.DFN.DE> <7bQr6.644$lz1.17686@ruti.visi.com> <98oku1$f6a$1@news.udel.edu> Message-ID: <96182B7D15FEECF4.22799D8BFE69044A.17D2E54CAD32E9D6@lp.airnews.net> In article , Grant Edwards wrote: . . . >I believe that there are plans (on some exchanges) to switch >pricing from base-2 fractions to decimal fractions. . . . Various exchanges have made that switch at various times during the last few centuries. Most famous was 29 January of this year, when the NYSE made the change for most common equities. Most of NASDAQ, though, remains in eighths, I believe. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From bezilla at hotmail.com Tue Mar 27 00:45:22 2001 From: bezilla at hotmail.com (John E. Barham) Date: Tue, 27 Mar 2001 05:45:22 GMT Subject: HTTP redirect via Python? Message-ID: Apologies if this is too basic a question, but I'm wondering how I can send a redirect/URL rewrite command to a browser via Python. The context: we're developing a fairly substantial Web-based application and using Python for the CGI coding (which is working beautifully, BTW). In order to partially protect ourselves (and the users ;) against back/forward/refresh with forms, we'd like to send them to a "safe" URL after a form has been submitted. How can we do this? There doesn't appear to be anything to do this in module cgi... If it's a server dependent thing, we're using Apache. From warren-postma at home.com Tue Mar 27 17:31:57 2001 From: warren-postma at home.com (Warren Postma) Date: Tue, 27 Mar 2001 22:31:57 GMT Subject: WANTED: chairs for next Python conference References: Message-ID: "Guido van Rossum" wrote in message: > I'm looking for chairs for the next Python conference. OfficeMax has some nice ones, with good lumbar support. [sorry!] Warren From aleaxit at yahoo.com Fri Mar 9 10:27:54 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 9 Mar 2001 16:27:54 +0100 Subject: I come to praise .join, not to bury it... References: Message-ID: <98aspo024jg@news2.newsguy.com> "Andrew MacIntyre" wrote in message news:mailman.984074812.27842.python-list at python.org... > On Wed, 7 Mar 2001, Alex Martelli wrote: > > > Suppose I'm building a line of a CSV file, a popular > > textual format where fields are separated (aka joined) > > with commas -- the acronym stands for 'comma-separated > > values'. So, what I want to do is > > 'comma-separate these values' > > and, since 'separate' equates to join, this equates to: > > 'comma-join these values' > > so, I code: > > comma.join(these_values) > > *WHAT'S BACKWARDS ABOUT IT*?! > > Well thats fine from your point of view, but to me you've just argued > against your point of basing programming around natural language > (although I may have misconstrued your argument). I'm definitely not arguing that design should be based on natural language; rather, I'm taking exception to people who claim some programming-language expression is 'backwards' *when it even happens to be basically homomorphic to some expressions in THEIR OWN native natural language*! > From my POV, a method is something that logically "sends a message" to its > object. ...requesting the object to perform some action (execute some method). Fine with me. > In this context, having the joiner be the object is backwards, No it isn't. We send to the joiner the request to execute its method, thus performing the joining-action. > because it makes more sense to me to think in terms of: > "send message to > a sequence" But that's exactly what I'm arguing against! That's *NOT* optimal. We do NOT want a sequence to have code for the purpose of 'joining its items' -- it's not a special task that every sequence should somehow perform or delegate; rather, the sequence's task is just to *ENUMERATE* its items, for whatever purpose that enumeration happens to be needed this time. Further, we want the enumeration to happen *identically*, whether it's for the purpose of joining items one after the other inside some joiner object's join-method, or for the purpose of joining items one after the other inside a file-object's writelines method, or for any of a zillion other purposes yet. Consider .writelines again, for example. I have never heard objections to it being a method of the file object, taking the sequence as its argument and accessing it via the sequence's standard interface (i.e. just asking the sequence to enumerate its items one after the other). And, indeed, it's an excellent architecture -- some file like objects may implement .writelines as just a loop over their own .write method, others may take advantage of performance shortcuts (e.g., if they hold their data internally as a list of pieces, they'll be able to directly implement .writelines by delegating to .extend). But the .join/.writelines parallel is VERY close, so why would the SAME architectural choice (to have the sequence object as an argument, accessing it through its ability to enumerate its items, only) cause problems in one case and not the other?! I think it's a misperception due to thinking of strings as somehow 'passive', 'data', while a file-object is thought of as 'active', 'a truly object-y object', or something. I further opine that this misperception is susceptible of being corrected _in individuals who are more interested in furthering the effectiveness of their perceptive mechanisms than in trying to win a point in a Usenet discussion_ -- which, I hope, describes a vast majority of Pythonistas:-). Alex From tim.hochberg at ieee.org Wed Mar 28 10:51:53 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Wed, 28 Mar 2001 15:51:53 GMT Subject: Speed problems with Python vs. Perl References: <99sv33$8hk$1@news.cineca.it> Message-ID: > Last week I wrote a simple Python program and found out that it was > terribly slow. Therefore I retried with Perl and found a much better > performance. The programs simple read a file and split the lines on white > space, something I have to do very often for data elaboration [SNIP] > As you can see, without the splitting (only reading and counting the lines) > Perl is twice as fast, but once I split on whitespace, Python gets more > than 5 times slower than Perl. > > These results have been achieved on a AMD with 650 MHerz. On my home > machine, a 266 Celeron, the performance gap is worse. Without line > splitting the programs > are about the same speed, but with splitting enabled, the Python version > becomes 10 times slower than the Perl version (5 secs against 0.5 secs) Why the Perl's REs are faster, I'll leave for someone else to explain. Perhaps they special case common REs more than Python does. However, you are suffering from Overuse of Regular Expressions (ORE [tm]). Specifically, you can use string.split or in Python 2.0 you can use the split method on strings: def main152(): # Should work on python 1.5.2 import string icount = 0 for line in sys.stdin.readlines(): icount = icount + 1 f = string.split(line) print "Total lines read: " + `icount` or def main20(): # Should work on python >= 2.0 icount = 0 for line in sys.stdin.readlines(): icount += 1 f = line.split() print "Total lines read: " + `icount` or def main21(): # Should? work on Python >= 2.1 icount = 0 for line in sys.stdin.xreadlines(): # Might speed things up a bit.... icount += 1 f = line.split() print "Total lines read: " + `icount` I haven't actually benchmarked (or even tried) any of these, but I'd be curious to see how the last one in particular stacks up against it's Perl equivalent. I don't have Perl installed at the moment, though so I leave that as an excercise for the reader.... -lazy tim From gregj at pobox.com Tue Mar 20 19:07:09 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Wed, 21 Mar 2001 00:07:09 GMT Subject: deleting files from a script References: Message-ID: You can get the name of an open file from the file object's name attribute: >>> f = open('foo') >>> f.name 'foo' If you always open your files with full absolute paths (rather than relative to the current working directory) you can then retrieve that path from the f.name attribute. With a full path, deleting the file is simple: >>> f.close() >>> os.remove(f.name) The os.path module has functions for converting relative paths to absolute paths. "Gary" wrote in message news:RSRt6.2154$nd.2670928 at typhoon.ne.mediaone.net... > Is the best way to do this to just issue a shell command using getstatus or > something similar? I have a file descriptor created with open. I'd rather > not deal with constructing the entire path string if I can avoid it. -- Greg Jorgensen / programmer, pedant, raconteur / Portland, Oregon, USA From thomas at xs4all.net Thu Mar 1 17:21:07 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 1 Mar 2001 23:21:07 +0100 Subject: [Python-Dev] Re: d = {}; d[0:1] = 1; d[0:1] = 2; print d[:] In-Reply-To: <200103012101.QAA18516@cj20424-a.reston1.va.home.com>; from guido@digicool.com on Thu, Mar 01, 2001 at 04:01:52PM -0500 References: <15006.46879.607192.367739@w221.z064000254.bwi-md.dsl.cnc.net> <200103012101.QAA18516@cj20424-a.reston1.va.home.com> Message-ID: <20010301232107.O9678@xs4all.nl> On Thu, Mar 01, 2001 at 04:01:52PM -0500, Guido van Rossum wrote: > > Quoth Robin Thomas : [ Dicts accept slice objects as keys in assignment, but not in retrieval ] > > | 1) Is this behavior considered a bug by the BDFL or the community at large? > I can't speak for the community, but it smells like a bug to me. Speaking for the person who implemented the slice-fallback to sliceobjects: yes, it's a bug, because it's an unintended consequence of the change :) The intention was to eradicate the silly discrepancy between indexing, normal slices and extended slices: normal indexing works through __getitem__, sq_item and mp_subscript. Normal (two argument) slices work through __getslice__ and sq_slice. Extended slices work through __getitem__, sq_item and mp_subscript again. Note, however, that though *this* particular bug is new in Python 2.0, it wasn't actually absent in 1.5.2 either! Python 1.5.2 (#0, Feb 20 2001, 23:57:58) [GCC 2.95.3 20010125 (prerelease)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> d = {} >>> d[0:1] = "spam" Traceback (innermost last): File "", line 1, in ? TypeError: object doesn't support slice assignment >>> d[0:1:1] = "spam" >>> d[0:1:] = "spam" >>> d {slice(0, 1, None): 'spam', slice(0, 1, 1): 'spam'} The bug is just extended to cover normal slices as well, because the absense of sq_slice now causes Python to fall back to normal item setting/retrieval. I think making slices hashable objects makes the most sense. They can just be treated as a three-tuple of the values in the slice, or some such. Falling back to just sq_item/__getitem__ and not mp_subscript might make some sense, but it seems a bit of an artificial split, since classes that pretend to be mappings would be treated differently than types that pretend to be mappings. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From clee at gnwy100.wuh.wustl.edu Wed Mar 7 08:00:18 2001 From: clee at gnwy100.wuh.wustl.edu (Christopher Lee) Date: 07 Mar 2001 07:00:18 -0600 Subject: How to installing NumPy? References: <3AA57C0D.BBC5E956@itu.edu.tr> <7u3dcqqq2z.fsf@gnwy100.wuh.wustl.edu> <3AA60D2D.4E31AA50@imkt.uni-hannover.de> Message-ID: <7usnkpentp.fsf@gnwy100.wuh.wustl.edu> >>>>> "Harald" == Harald Rosemann writes: Harald> Christopher Lee wrote: >> >>>>> "Nuzhet" == Nuzhet Dalfes writes: Harald> Got the error message: .... gcc -O2 -m486 -fpic -IInclude Harald> -I/usr/include/python2.0 -c Src/_numpymodule.c -o ^^^^^^^^^^^^^^^^^^^^^^^ Harald> build/temp.linux-i686-2.0/Src/_numpymodu Src/_numpymodule.c:1: Harald> Python.h: No such file or directory error: command 'gcc' failed Harald> with exit status 1 .... Harald> In Python-2.0 I found: Python-2.0/Include/Python.h but that Harald> doesn't seem to work. It sounds like Suse may not install the headers where python expects, or if you installed from source, perhaps you didn't do a "make install" ? I can't tell based upon your description but either way... I would: - check to see if the directory /usr/include/python2.0 exists and create it if it doesn't exist yet - copy all the files that you found in Python-2.0/Include to /usr/include/python2.0. This should allow the compiler to find Python.h using the -I/usr/include/python2.0 flag. - try "python setup.py install" again good luck From bowman at montana.com Mon Mar 26 23:44:30 2001 From: bowman at montana.com (bowman) Date: Mon, 26 Mar 2001 21:44:30 -0700 Subject: warrior geeks References: Message-ID: Delaney, Timothy wrote in message news:mailman.985653937.22321.python-list at python.org... > That's easy. With Python you can be sure that you have shot yourself in the > foot. With Perl, you think you've *probably* shot yourself in the foot, but > due to a difficult-to-find typo you have also shot several other people in > the foot. Or, as Stroustrup says about C++, it is much more difficult to shoot yourself in the foot than when using C -- but when you do, you blow your whole leg off. From jarober at mail.com Sat Mar 24 20:24:49 2001 From: jarober at mail.com (James A. Robertson) Date: Sun, 25 Mar 2001 01:24:49 GMT Subject: Collection interfaces References: <3a90fa97.0@news1.mweb.co.za> <3A9A86B1.9A8C69A2@ix.netcom.com> <97fjla128ir@news2.newsguy.com> <97h5s40vhc@news2.newsguy.com> <97ibmc0k47@news1.newsguy.com> <97m0c7080c@news2.newsguy.com> <3AA2A898.450B659E@mail.com> <3AB755F8.67E84126@mail.com> <%a%t6.17245$227.1601569@newsread2.prod.itd.earthlink.net> <3AB8A730.4BE13D22@mail.com> <61bv6.8693$P4.676800@newsread1.prod.itd.earthlink.net> Message-ID: <3ABE9A43.90576C8A@mail.com> topmind wrote: > > "James A. Robertson" wrote in message > news:3AB8A730.4BE13D22 at mail.com... > > topmind wrote: > > > > > > > > > http://www.cincom.com/smalltalk > > > > > > > > > > I only see a front page, not a parsing example. > > > > > > > Follow the tutorial link - it's right there on that page. > > > > I cannot find any "tutorial" link. Well, it was there, but the site was redesigned. Follow this link: http://www.cincom.com:80/scripts/smalltalk.exe/gettingstarted/index.asp?content=trysmalltalknc > > Perhaps you are afraid that if you give me the full tutorial link, you > will have to expose to the world the FACT that the site runs on > Microsoft ASP VSscript instead of Smalltalk? > > Do Chevy salesmen drive Fords? > > -tmind- -- James A. Robertson Product Manager (Smalltalk), Cincom jarober at mail.com From loewis at informatik.hu-berlin.de Fri Mar 2 11:01:01 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Mar 2001 17:01:01 +0100 Subject: A counter-counter-proposal for PEP 236: #pragma( nested_scopes) References: Message-ID: "Tim Peters" writes: > Hmm. Maybe that's why I so dislike Martin's attempt to hijack PEP 236: his > current formulation of an alternative leaves only the raw names, without the > __future__ or __possible_world__ qualifiers. If *that* is the complaint, then the patch can be easily changed into reading directive future nested_scopes (future would be the directive name, and nested_scopes the atom argument). In that case, I'd prefer /F's interpretation of the state of things, i.e. directive experimental nested_scopes since this does not talk about the future, but about the present (just as the future import does not talk about the future, but about directives that are presently needed). Regards, Martin From sholden at holdenweb.com Thu Mar 1 09:41:14 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 1 Mar 2001 09:41:14 -0500 Subject: To the point of defeat.....IDLE References: <3A9AE62B.5070402@yahoo.com> Message-ID: <%ftn6.12742$zL.491362@e420r-atl1.usenetserver.com> "Deon Garrett" wrote in message news:slrn99s6tu.8rl.garrett at falcon.cs.colostate.edu... > The best way to go is to completely wipe any traces > of python rpms from your system before installing > Python 2.0 from source. > > rpm -e python > > will fail because a bunch of stuff needs python. But > it will list all the packages that need it. You should > be able to look through the dependencies and find all > the stuff you want to remove. > > rpm -e --nodeps python python-tools tkinter....... > > I assume that the python executable is installed in > /usr/bin on RedHat 7. If so, then run configure in > the python 2.0 root directory with the --prefix=/usr > option and all your scripts should still work. > > cd your/python2.0/root/dir > ./configure --prefix=/usr (and any other options you want) > make > make install > > Then build any add-ons you want (Tkinter, NumPy, PIL, etc). > Has anyone actually verified that the myriad pieces of RedHat Python aren't incompatible with 2.x? RedHat makes heavy use of Python for various system configuration tasks, and I've always been cautious about replacing the RPM-installed Python (so I installed newer versions with --prefix=/usr/local). regards Steve From dwmurphy at home.com Mon Mar 12 22:43:12 2001 From: dwmurphy at home.com (David Murphy) Date: Tue, 13 Mar 2001 03:43:12 GMT Subject: Einstein's Riddle References: <984380185.768920@news.aei.ca> <4w6r6.193645$df5.5192565@news1.crdva1.bc.home.com> Message-ID: "{R} Richard Ashton" <{R}@news.semolina.org> wrote in message news:r62qats4341i3hcn7h6cum5mlfrtso60gi at 4ax.com... > On Mon, 12 Mar 2001 16:08:32 GMT, "David Murphy" > wrote: > > }*IF* Einstein was just talking about people's ability to deal with just the > }facts, and not to make assumptions, I think 2% +/- 5% is probably a good > }estimate. Take a look at the first draft of the next project specification > }you get *grin* > > He was. There are many variants of these, and they have been around along > time. A lot of psychological papers have been written about "mindsets" and > jumping to conclusions, reading more into the information than the data > warrants. I could go on ... > > {R} Interesting. Although I haven't read any of those papers, i have to wonder what types of people are inclined to make such assumptions. i mean, for varies activities, it might be essential. For example, anything creative may require the ability to lead 'beyond the facts' to come up with something new. (so long as the individual is able to work back and fill in the facts) dave From tjreedy at udel.edu Sat Mar 17 01:56:54 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 17 Mar 2001 01:56:54 -0500 Subject: Python style questions References: <98tb91$9t9$1@saltmine.radix.net> <98tdu1$cfk$1@panix2.panix.com> <1eqdo5u.1xxmzfi2kjk0qN%francois.granger@free.fr> Message-ID: <98v1vi$gre$1@news.udel.edu> "Fran?ois Granger" wrote in message news:1eqdo5u.1xxmzfi2kjk0qN%francois.granger at free.fr... > Aahz Maruch wrote: > > > In article <98tb91$9t9$1 at saltmine.radix.net>, > > Cary O'Brien wrote: > > > >3. I really miss not having a "switch" or "case" statement. Sniff. > > > Use a dictionary. > > Some code snippet as exemple ? > At this point, I can't imagine a good way, and I don't remember seeing > something on this. I posted an example about a month ago ... and about a year ago. Don't know what archive search facilities we currently have. Terry J. Reedy From tuttledon at hotmail.com Thu Mar 15 18:04:34 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Thu, 15 Mar 2001 23:04:34 GMT Subject: Python and ADO References: <98r9qn$tbi$1@troll.powertech.no> Message-ID: <6Ubs6.118581$Z8.23975952@typhoon.southeast.rr.com> "Syver Enstad" wrote in message news:98r9qn$tbi$1 at troll.powertech.no... > Has anyone considered making a DB API compliant wrapper around MS ADO? Or > isn't this considered worthwhile? > > As ADO is the database api that I use, I could have a look at making a > wrapper for it if there was any interest in it and if making such a thing is > not too involved. Sounds like a good idea to me too! I'm not currently doing an database work but I will be. Don From grante at visi.com Wed Mar 7 15:05:30 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 07 Mar 2001 20:05:30 GMT Subject: Can anyone recomend a good intoduction to C... References: <3AA5EF59.507F1D91@olsen.ch> <983958878.976344@newsmaster-04.atnet.at> <77up6.1289$y6.235541@ruti.visi.com> <985vqs01ipr@drn.newsguy.com> Message-ID: In article <985vqs01ipr at drn.newsguy.com>, Grant Griffin wrote: >>>To be completely honest, I can not see the obvius reason why >>>C++ should be such a bad programming language. >> >>It's complicated and unsafe. Either one is tolerable without >>the other. When you combine the two, you're dead. > >I dunno...I think you've hit on exactly its _strength_: it's complicated and >unsafe. > >As a virtually 100.0% backwards-compatible superset of C, it >has little choice but to be complicated and unsafe. By >"unsafe", maybe you are referring to its >backwards-compatibility with C's pointers: C++ is unsafe >because C is unsafe. Exactly. >By "complicated", maybe you are refererring to the fact that it >supports both procedural programming (from C) and OO >programming (which is its whole reason to exist). Well, I'm referring to templates, overloading, and all of the other features that confuse people. >But those of us who like C++ don't regret its complication or >its unsafety; we lthink of that more as being "powerful" and >"flexible". I think that being too flexible is a bad thing when it comes to large projects with many developers. >I would agree that C++ is somewhat _unnecessarily_ compilicated >(primarily in terms of its silly protection features), but then >again, nothing's perfect. (Heck, even Python has "warts". >) > >Still, in terms of its design goal (of grafting OO onto C while >being 100.0% backwards-compatible),I personally think C++ is a >real Work of Art. Right! As in most software project failures, the problem lay in the requirements. If you ask for something with both the unsafe features required for backwards compatibility with C _plus_ all the bells and whistles they thought they needed for OO programming, there's no way you can end up with something that isn't an unholy mess. I think asking for a language that did both low-level stuff like C and OO stuff was a mistake. >(In contrast, I find Perl's approach to grafting on OO to be >distinctly hokey.) I never liked Perl, and doubt that duct-taping stuff to the side of it would make me like it any better. >I think that C++'s choice of design goal, in combination with >its success in meeting that goal, adequately explains why large >numbers of lemmings use it. > >>>It is widely available (on almost any platform, I would guess). >> >>If 1 billion people do a stupid thing, it's still a stupid thing. > >(And you gotta admire the chutzpah of that one guy who thinks >that the 1 billion people who disagree with him must, ipso >facto, be wrong. ) Hey, if I thought I was wrong, I'd change my mind. :) I think most of the projects using C++ would be far better off using Modula-3, Ada, Smalltalk, or Python. The rest should probably be using C. Despite Ada's bad rap as a DoD project, it's a pretty decent language (esp for embedded systems), and I think Modula-3 got OO-in-a-procedureal-language pretty close to right right. >isn't-it-nice-to-know-that-we-grants-don't-always > -agree?--ly y'rs Even when we're both from Iowa. -- Grant Edwards grante Yow! Look DEEP into the at OPENINGS!! Do you see any visi.com ELVES or EDSELS... or a HIGHBALL??... From root at rainerdeyke.com Wed Mar 21 11:42:34 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 21 Mar 2001 16:42:34 GMT Subject: Yet Another PEP: Interface Adapter Mechanism __adapt__ References: Message-ID: <_R4u6.466172$ge4.162590641@news2.rdc2.tx.home.com> "Clark C. Evans" wrote in message news:Pine.LNX.4.21.0103210418490.21377-100000 at clarkevans.com... > def adapt(obj,ident, options = None): > global check_base > def check_base(bas,cmp): > if bas == cmp: return 1 > for base in bas.__bases__: > if check_base(base,cmp): return 1 > return 0 > if hasattr(obj, '__adapt__'): > retval = obj.__adapt__(ident) > if retval == None: > if check_base(obj.__class__,ident): > retval = obj > # options flag used to enable: > # - reverse lookup via ident (future PEP) goes here? > # - signature based lookup (future PEP) goes here? > # - automatic signature checking (future PEP) goes here? > return retval This 'check_base' stuff is a mess. "A is an instance of a superclass of B" does not imply "B implements interface A". I also don't see why 'ident' should be a class instance instead of just a class or a new built-in type. What functionality does 'ident' provide? How are extension types supported? -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From jmg at ecs.soton.ac.uk Mon Mar 12 06:13:51 2001 From: jmg at ecs.soton.ac.uk (Jacek Generowicz) Date: 12 Mar 2001 11:13:51 +0000 Subject: Extending Python: rewriting a single method in C Message-ID: I have an object-oriented numerical code written in Python. It has come to the stage where the speed of the code is seriously impeding progress. Profiling reveals (surprise, surprise) that most of the time is spent in only 2 methods. Is there any way of re-writing just these methods in C ? I would imagine that this sort of thing has been done/attempted many times by the Scientific Python community, but I haven't managed to find mcuh. Thanks, Jacek From sholden at holdenweb.com Fri Mar 9 18:55:26 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 9 Mar 2001 18:55:26 -0500 Subject: gah! I hate the new string syntax References: <98an7i01tgp@news2.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:98an7i01tgp at news2.newsguy.com... > "D-Man" wrote in message > news:mailman.984063199.18779.python-list at python.org... > > On Thu, Mar 08, 2001 at 06:51:07PM +1300, Paul Foley wrote: > > | On Wed, 7 Mar 2001 15:33:30 -0500, D-Man wrote: > > | > > | > What about one who is both English and Scots, yet never set foot on > > | > that island ;-)? > > | > > | AFAIK, nobody outside the US would admit the existence of such a > > | thing. The American habit of calling themselves "Irish" or "Italian" > > | or whatever when they're not is *very* strange. I've never heard > > | anything like it anywhere else. > > > > Heh. Maybe Americans are very odd. Wouldn't surprise me at all. ;-) > > Maybe. OTOH, Italians born abroad (from parents who consider > themselves temporary immigrants, and fully intend to return "home" > when they've put enough savings aside) have traditionally called > themselves "Italians" whether that "abroad" was Northern America, > Argentina, Germany, Libia, or any of the several other countries > where Italian emigrants used to go. (Of course, intentions to > return are not always carried out -- few are aware, for example, > that such an icon of French popular culture as Yves Montand was > Italian -- real name Ivo Livi, born of just-as-Italian parents > in a village near Florence; his father, a socialist, had to flee > [and ended up in France] when the Fascists took power, and Ivo, > as well as the rest of the family, followed him a while later; > I'm not sure when he changed his citizenship over to France). > > > > that I am not really American since none of my ancestors came from > > America. "Real" Americans would be the so-called "Indians", or more > > Why? *THEIR* ancestors came from Asia over the Bering Straits, > after all (and following the line a while longer, one gets back > to Africa). > > > > Alex > The topic drift on this thread could only be explained by the Gondwanaland theory! property-is-theft-ly y'rs - steve From diverdown at parsmail.com Thu Mar 1 12:02:53 2001 From: diverdown at parsmail.com (diverdown at parsmail.com) Date: 1 Mar 2001 17:02:53 GMT Subject: *CD SALE* Message-ID: <97lvbt$4j0$15652@iac5.navix.net> --_NextPart_00009057-000011FA-0093ADA1-52FD Content-Type: text/plain Content-Transfer-Encoding: 7bit SUPER CD SALE!!! Jam Packed with information. Reports, How-to's, screensavers, game cheats, recipes, freebies, Internet business opportunities, and much, much more. This CD is packed full of valuable information. No, this CD is not intended to make you rich. However, it can save you money and possibly make you a buck or two. Order now, supplies are limited. This CD sells on Ebay for $21.95. As part of our special promotion, you can order today for only $4.00 and $1.00 S/H. That's only $5.00 total. Order today. We accept cash, checks and money orders. Checks will delay shipping until the check clears. All other forms of payment gets the CD shipped out same day. Please, print out this order form and send it along with your payment. If you do not have a printer, just include the included information on a separate sheet of paper with your order. Send all orders to the following address. Software 510 Alma Avenue Mulberry, AR 72947 Print Clearly Name: _______________________________________________________ Address: _____________________________________________________ City: _________________________________________________________ State/Province: __________________ Zip/Postal code: _______________ Country if other than U.S.: _______________________________________ E-mail address:________________________________________________ Quantity:______ X 5.00 ______ Total:________ --_NextPart_00009057-000011FA-0093ADA1-52FD-- From aleaxit at yahoo.com Mon Mar 26 02:55:34 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 26 Mar 2001 09:55:34 +0200 Subject: Yet Another PEP: Interface Adapter Mechanism __adapt__ References: Message-ID: <99msll02o92@news2.newsguy.com> "Alex Shindich" wrote in message news:mailman.985588473.13759.python-list at python.org... [snip] > Let's see... The abstract section of the PEP says: "This proposal allows > a standard and extensible method to ask two types of questions: Is a > particular object compliant with a given protocol?" The following > describes the strategy pattern: "The Strategy pattern provides a means of > parameterizing a component to accept an algorithm. This keeps the > component simpler, and lets clients pick and choose an algorithm > specifically tailored to their needs." See any similarities? Some vague ones, maybe. Protocols need not be algorithms, nor do components need to 'accept' protocols (it can well be the other way round, for example). > > > Another way of looking at your PEP is to say that you are > > > asking for Python Java-like interfaces. > > > > No, actually there are other PEPs that do that. > > > That is true, there is PEP-245. But in some sense, an ability to determine > "is-a" relationship is no different from asking "do you support > protocol Blah?" Clark's PEP Without A Number most often ends up asking a more general question than 'are-you'/'do-you-support', namely: "Are you now, *or do you know how to wrap yourself to provide*, a supporter of protocol X"? (when this is asked of the object); or: "Does object Y support you, *or do you know how to wrap it to obtain such a supporter*"? (when this is asked of the protocol). The duality is important, because protocols can be developed after objects are, OR vice-versa, and this PEP lets either case be supported 'non-invasively' wrt the pre-existing component[s]. The question[s] don't receive a simple yes/no answer, which would be of little use by itself; rather, in the 'yes' case, the return is the required object-supporting-protocol-X, be that the input object Y or some wrapper around it (this can be ignored, and used as a simple boolean yes/no, in the rare cases where the client only DOES care about a yes/no check, of course; commonly, it will be saved and used for calls to the relevant protocol methods). > Other comments: > 1. You are making an assumption that each class will provide adaptors to > some set of protocols, thus entangling the class and available set of > protocol conversions. Why can't protocol conversion live outside of the > class? If I have a pre-existing protocol, say "FileObject", and I design a new class which I intend to support this pre-existing protocol, then the most natural residence for the code providing that support, and the knowledge that the support is provided, seems to be in the new class itself. If I have a pre-existing type of objects, say builtin file-objects, and I design a new protocol that is meant to encompass (maybe with wrapping) said pre-existing objects, then the natural residence seems to be in the protocol. The case for residence in a third place yet seems more remote (both objects and protocols pre-exist, I just want to add an adaptation) and might be left as a future enhancement IMHO. > 2. Is adaption symmetric? If class A provides an adaptor for class B, > mustn't class B provide an adaptor for class A? ***NO***!!! That would be absurd even if all classes were protocols. E.g., a ReadableAndWriteableFileObject can surely be adapted (trivially, by not wrapping) to satisfy a protocol ReadableFileObject, but that in no way implies adaptation makes any sense the other way 'round -- read-only files may perfectly well exist (even physically, on a RO media), why deny the fact in quest of nonexistent adaptation symmetry? Further, *MANDATING* mutual (circular) dependency is about as far from best software development practices as one can get. If A depends on (needs to know about) B, it's BY FAR better if we can avoid any dependency of B on A. Please read all that R. Martin has to say on his www.objectmentor.com site (publications page) then move on to Lakos' book (it's written for C++, but it's really about dependency management as THE key issue with large scale SW). > 3. Versioning is not mentioned anywhere in your PEP. Once a class defines > an adaptor for a protocol, the protocol better not change. Otherwise every > adaptor needs to change to match the new definition of the > protocol. Looking at protocols as contracts between suppliers and consumers, they had better never change unless ALL existing suppliers AND consumers can be refactored appropriately -- whether one provides a formally recognized idiom to adapt a few more suppliers to the protocol, or not. Alex From gmunsey at adobe.com Tue Mar 27 20:15:48 2001 From: gmunsey at adobe.com (Grant Munsey) Date: Tue, 27 Mar 2001 17:15:48 -0800 Subject: wavlets? References: Message-ID: What platform are you using. For Windows there is a pretty nice tuned library called IPP that does wavelet stuff and a lot more. I have a pretty complete set of cover routines for the Windows 1.0b2 version. Intel is about to release version 1.0 and when they do I was going to put the Python module source up on the Adobe Open Source site. http://developer.intel.com/software/products/ipp/index.htm "Taz" wrote in message news:tc27anovquqm79 at corp.supernews.co.uk... > i'm about to write a wavelets module for python - does one already exist... > couldn't find one? > > taz > > > From aleaxit at yahoo.com Mon Mar 19 18:15:21 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 20 Mar 2001 00:15:21 +0100 Subject: windows script host and python References: <%tKr6.2570$pX.26174@news1.onlynews.com><98oq3r$1e0$1@troll.powertech.no> <8Aps6.104$pl.1515@newsfeed.slurp.net><98tc4d0rmk@news1.newsguy.com> Message-ID: <9963te04s9@news2.newsguy.com> "Don Dwiggins" wrote in message news:mailman.985028069.29930.python-list at python.org... [snip] > >> processes = GetObject("winmgmts:{impersonationLevel=impersonate}").\ > >> InstancesOf("Win32_process") [snip] > > Cool! Is this supposed to be NT-only? It doesn't fly on my Win98 box. > > Actually, it fails on my NT workstation also: [snip] > File "e:\python20\win32com\client\__init__.py", line 87, in Moniker > moniker, i, bindCtx = pythoncom.MkParseDisplayName(Pathname) > pywintypes.com_error: (-2147221020, 'Invalid syntax', None, None) ...but do you have WMI installed? AFAIK, it doesn't come as default with either 98 or NT (perhaps 2000 and/or ME -- not sure) -- it has to be downloaded from the MS site and installed. Alex From ecastro at cicei.ulpgc.es Fri Mar 30 09:48:12 2001 From: ecastro at cicei.ulpgc.es (Enrique) Date: 30 Mar 2001 13:48:12 -0100 Subject: Printing mixtures in integers and strings References: <3ac38cf6$0$12246$ed9e5944@reading.news.pipex.net> Message-ID: <3AC47F42.B545A084@cicei.ulpgc.es> Hi Neil, Neil Benn wrote: > > Hello, > > I'm trying to use something like this:- > > def move(row): #Moves the dispenser to the row on the plate > print "Moved to Row - " + row You are trying to add (operator "+") a number and a string > > Where row is expected to be a number. However when I import this into > teh interpreter I get an error message - stating that __add__ and __radd__ > have not been defined:- > > Traceback (innermost last): > File "", line 1, in ? > File "c:\projects\scripting\TrialScripting\AcmeBRD.py", li > TypeError: __add__ nor __radd__ defined for these operands > Which is the expected result since built-in strings and ints do not add together You can modify __add__ or __radd__ methods in these object so they know how to add a number a string or the opposite. It's easier to convert number to string : print "Moved to Row - " + str(row), or let's 'print' to do this conversion : print "Moved to Row - ", row (prints string "Moved to Row - " and then prints printable form of var "row" which happens to be str(row)) Enrique From hinsen at cnrs-orleans.fr Thu Mar 22 10:03:54 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 22 Mar 2001 16:03:54 +0100 Subject: PEP 242 Released References: Message-ID: "Paul F. Dubois" writes: > PEP: 242 > Title: Numeric Kinds Looks good overall. I am just wondering how much of a problem this is in real life - I have used Python on several platforms, and on all of them a float was an IEEE double. > Coercion > > In an expression, coercion between different kinds is to the > greater kind. For this purpose, all complex kinds are "greater > than" all floating-point kinds, and all floating-point kinds are > "greater than" all integer kinds. This might lead to a loss of precision when combining a high-precision float with a low-precision complex number. It would be better to use a complex type whose precision is determined by coercion between the real part of the complex number and the other float. > Open Issues > > The assertion that a decimal literal means a binary floating-point > value of the largest available kind is in conflict with other > proposals about Python's numeric model. This PEP asserts that > these other proposals are wrong and that part of them should not > be implemented. Do you mean Moshe Zadka's proposal for rational numbers and corresponding literals? One could reconcile both proposals by deciding that Moshe's rationals are equivalent to infinite-precision floats. Then literals would always be rationals and the kind objects would convert to the desired float type. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From fdrake at acm.org Sat Mar 3 14:54:31 2001 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Sat, 3 Mar 2001 14:54:31 -0500 (EST) Subject: Bug fix releases In-Reply-To: <200103031944.OAA21835@cj20424-a.reston1.va.home.com> References: <200103031821.NAA24060@panix3.panix.com> <200103031910.OAA21663@cj20424-a.reston1.va.home.com> <15009.17989.88203.844343@cj42289-a.reston1.va.home.com> <200103031944.OAA21835@cj20424-a.reston1.va.home.com> Message-ID: <15009.19447.154958.449303@cj42289-a.reston1.va.home.com> Guido van Rossum writes: > But of course the library repackaging in itself would cause enormous > outcries, because in a very real sense it *does* break code. That's why it has to be a feature release. ;-) -Fred -- Fred L. Drake, Jr. PythonLabs at Digital Creations From scarblac at pino.selwerd.nl Tue Mar 13 03:12:31 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 13 Mar 2001 08:12:31 GMT Subject: Very Cool References: Message-ID: Brendhan Horne wrote in comp.lang.python: > Everybody thank you for your help you may have broken the one barrier that > was causing me not to understand this. Now let explain what happened and > maybe you can clarify something even futher for me. > I went in to my Python 20 command line interpreter the DOS based one ( am I > saying that right ) And wrote in what you guys sent me. > Items in parenthsis () are notes about what I did or what happen nothing in > those parenthesis was ever typed in. > > >>>while 1: ( I wrote this in )(press enter key > .... print "Hello World" ( the dots would appear as soon as I entered in > while 1:) > File "", line 2 > print "Hello World" > (there is a control symbol under the t in print) > Indentation Error: expected an indented block You didn't indent the line with print on it. You have to put some whitespace (say, a space) before the print otherwise it won't be a block belonging to the while:. In the editor, you probably did write the spaces. When you put the spaces and hit enter after the print line, it will give another line with dots, where you can continue the block. Just hit enter and it will run. -- Remco Gerlich From calcium at ozemail.com.au Fri Mar 30 07:05:55 2001 From: calcium at ozemail.com.au (ccang) Date: Fri, 30 Mar 2001 22:05:55 +1000 Subject: General CGI advice... References: Message-ID: <3AC476A3.7739E221@ozemail.com.au> http://www.ozemail.com.au/~calcium/publications.html "Vincent A. Primavera" wrote: > Hello, > Looking for some general guidance... I am relatively new to Python and > pretty much totally green to CGI programming. However, I would like to start > learning more about CGI using Python as my means. Do I need to focus on > generic CGI concepts first or are there any really good resources available > to integrate the two immediately? > > Thank You, > Vincent A. Primavera -- | mailto:calcium at ozemail.com.au | +61 401 688 408 | http://www.ozemail.com.au/~calcium | To me, boxing is like a ballet except there's no music, no | choreography, and the dancers hit each other - Jack Handy From ssartor at bellatlantic.net Thu Mar 29 07:19:53 2001 From: ssartor at bellatlantic.net (Steven Sartorius) Date: Thu, 29 Mar 2001 12:19:53 GMT Subject: How to update status bar in wxPython? References: <5Tpw6.2172$K%.667185@typhoon1.ba-dsg.net> Message-ID: In article , "Robin Dunn" wrote: > "Steven Sartorius" wrote in message > news:5Tpw6.2172$K%.667185 at typhoon1.ba-dsg.net... >> I'm a newbie to GUI programming in general so apologies if this is a > FAQ.... >> >> I've got a Python script that does some heavy duty number crunching and > file >> I/O. To track the progress of the script I print a series of messages >> to > the >> console/x-term ("Working on file #....", etc,etc). As a project, I > decided to >> guify the script with wxPython and Boa-constructor. I've successfully > built a >> window with a single button, a couple of text input fields and a status > bar; >> clicking the button fires off the script. What I'm trying to do (so >> far unsuccessfully) is redirect the progress messages from the console >> to the status bar on the window. Because I'm retrofitting an existing >> script, > I've >> just replaced the original 'print' statements with >> 'statusBar.SetStatusText("Working on file....") and (for good measure) >> 'statusBar.Refresh()'. This approach kind of works....the status bar > shows >> the final progress message ("All data processed") but only after I >> force > the >> window to redraw (moving it or covering and then uncovering it). I'm >> sure > I'm >> missing something basic here so any help would be much appreciated. >> > > When you click the button and "fire off the script" you are effectivly > blocking the GUI until the script is complete. You need to allow the > GUI's main loop to run in order for new events to be dispatched and > other housework types of things to happen. When you call > statusBar.Refresh() you are simply requesting that a paint event be sent > ot the statusBar, but as you've seen if the event is never dispatched to > the window then it is never actually refreshed. > > One way to allow the main loop to run from within the middle of some > long running task is to call wxYield, which will return when there are > no more events waiting to be proccessed. Unfortunatly there are > potential reentrancy issues you need to deal with when using wxYield, > for example what if the user clicks on your launcher button while a > script is already running, and then the code calls wxYield? > > A better way is to refactor your long running task so that it can be > executed a chunk (or iteration) at a time from an EVT_IDLE event > handler. Each time the handler is called do the next chunk of the task > and if there is more to be done call event.RequestMore() before > returning. This lets the code return to the main loop frequently so the > GUI continues receiving events and can be updated, but all extra time is > spent running your task. > > If the task is not easily broken into chunks then you can run it in a > background thread, but then there are a few things you need to do > specially to allow your thread to communicate back to the GUI thread. > See the demo and also the wxpython-users archives for details. > > -- > Robin Dunn Software Craftsman robin at AllDunn.com Java give you > jitters? http://wxPython.org Relax with wxPython! Thanks for the response. I kind to thought I might have to restructure my code. Good thing I'm not doing anything this weekend.... Steve From cg at schlund.de Mon Mar 5 10:29:20 2001 From: cg at schlund.de (Carsten Gaebler) Date: Mon, 05 Mar 2001 16:29:20 +0100 Subject: Access to sybase API References: Message-ID: <3AA3B0D0.90876BA7@schlund.de> Neotaku wrote: > I search a code source for python to access Sybase thru API connexion the > Sybase DB-Library API or Sybase CT-Library (aka the Client Library) API Have a look at Dave Cole's Sybase module: http://www.object-craft.com.au/projects/sybase/ cg. From tim.one at home.com Sat Mar 17 01:38:17 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 17 Mar 2001 01:38:17 -0500 Subject: Pep 238 Why new // operator (Non-integer Division) In-Reply-To: <3AB2ED5E.A9B44B1E@seebelow.org> Message-ID: [Grant Griffin] > BTW, I guess I'm not the first one to notice that this new operator > looks an awful lot like a C/C++ comment. No, you're the first! 329 people did note that // looks an awful lot like Fortran's string concatenation operator. I expect these were the same 329 who complained to the C++ committee about abusing *their* prior art. > So maybe some other symbol should be used. Why bother? Python's # looks an awful lot like C++'s preprocessor directive flag too. Guido would probably prefer infix "div" (a la Pascal), but a new keyword is a very hard sell. > Hey, isn't "$" still open? Barry has first dibs on that one, to make print $ fileobject, 2, "+ 5% tax =", 2*1.05 print $2.00 + $0.10 = $2.10 Curiously, he will ignore the fileobject in this case, unless it's spelled print $ >> fileobject, 2, "+ 5% tax =", 2*1.05 I forget what print >> $fileobject, 2, "+ 5% tax =", 2*1.05 is going to mean. I *think* it reads the next line from fileobject, strips the newline, then uses that as the name of the file to print to (after opening for append). > just-tryin'-to-make-a-buck-ly y'rs, sell-documentation-for-barry's-proposals!-ly y'rs - tim From n8gray at caltech.edu.is.my.e-mail.address Thu Mar 22 22:32:56 2001 From: n8gray at caltech.edu.is.my.e-mail.address (Nathaniel Gray) Date: Thu, 22 Mar 2001 19:32:56 -0800 Subject: Good Editor? References: <3ab9a32b$1_1@news2.one.net> Message-ID: <99eggq$mvk@gap.cco.caltech.edu> Sorry if this goes through twice, you never know with news server errors whether your post got posted. fjs wrote: > Can someone recomend a good editor to write python in? Im just getting > started learning python and dont know which ones support python. > > thanks On *NIX check out NEdit (http://www.nedit.org). It's got syntax highlighting support for a ton of languages, a simple and powerful scripting language, rock-solid stability, and it's light on resources. Plus, you don't have to time-warp backwards 30 years to understand the keyboard accellerators (unless you already think C-x C-f for "open file" is intuitive. I'd bash the vi command too if I'd ever bothered to learn what it was...). -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From LLewin at oreilly.com Fri Mar 9 16:51:48 2001 From: LLewin at oreilly.com (LLewin at oreilly.com) Date: Fri, 09 Mar 2001 21:51:48 GMT Subject: Python In A Nutshell References: Message-ID: Hi, Yep--Python Nutshell is "forthcoming"...we're just in the planning stages at this point--very early on in the process. Any suggestions are welcome! Laura LLewin at oreilly.com > Hey Alex, congrats on landing "Python In A Nutshell" book deal. One > problem. I went down to the book store and it's not there. What gives? > > > Don > > ================================== Posted via http://nodevice.com Linux Programmer's Site From vsbabu at erols.com Mon Mar 5 18:56:38 2001 From: vsbabu at erols.com (Satheesh Babu) Date: Mon, 5 Mar 2001 18:56:38 -0500 Subject: iis and python References: Message-ID: <98191m$88j$1@bob.news.rcn.net> Hi, ASP with Python works really well. Additionally, Python's vast collection of modules make a short work of many tasks ASP/VBScript pundits would need a compiled COM object for. We've some ASP/VB code. To extend it to connect to some network services I started using Python, mixed with VB and it rocks. When we get time, I'm certainly going to convert all VB stuff to Python. I use ActiveState Python.. -- v.s.babu vsbabu at erols.com http://vsbabu.csoft.net "tech" wrote in message news:F5622749FED6DA5D.AF4594816A4865C9.16CD98F1C1FAC3F6 at lp.airnews.net... > I am going to do a project building a web front end while my friend is > going to build the back end. > > The backend will be MS SQL. The front end will be a web interface, IIS 5.0 > or whatever comes with win2k . > > I have a choice of doing php or python. > > In order to use python it would have to entail cgi or ASP. Is this correct. > Or is there an alternative. I dont know if Zope is the right thing. I hate > DTML. > > Is using python in ASP a pain in the but? Am I going to have to learn a > whole technology just to implelment python well into it? > > I hear troubleshooting ASP pages is not fun. > > The only time I have used iis is with php and it was a total snap. Painless. > > From shaleh at valinux.com Mon Mar 26 18:12:03 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Mon, 26 Mar 2001 15:12:03 -0800 (PST) Subject: fixing map(None, [1,2,3]) ? In-Reply-To: <873dc040ny.fsf@mathdogs.com> Message-ID: On 26-Mar-2001 Mike Coleman wrote: > Shouldn't "map(None, [1,2,3])" return "[(1,), (2,), (3,)]"? > > Is there any hope that this could be fixed? > map runs the function on each element of the list it is passed and returns an element of a new list. Why should it magically return a list of one-tuples? From sourin at alumnux.com Thu Mar 29 09:36:38 2001 From: sourin at alumnux.com (Sourin Sarkar) Date: Thu, 29 Mar 2001 20:06:38 +0530 Subject: (no subject) Message-ID: Can anyone explain the usage of: win32api.Apply() (in detail please.) function of the win32 extension add on to the python library. From mcfletch at home.com Mon Mar 19 03:42:39 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Mon, 19 Mar 2001 03:42:39 -0500 Subject: Help Rewriting/Refactoring/Rethinking Parsing Algorythm In-Reply-To: Message-ID: <000701c0b050$8f566510$a9807018@cr706570a> Thanks Tim. I'd actually downloaded it when it was first announced and played with it back with Dragon 3 (I uninstalled it 'cause I was crashing too often). Re-downloaded and played with it this evening. Don't have time to do it up myself, but looks like it'd be quite simple to make a PythonWin (or IDLE or Boa)-specific grammar with all sorts of neat macros (for x indexing y, for instance). Biggest need I can see in the project is a template using wxPython (or Tkinter) and a styled text control (aka Scintilla) to do "proper" update-the-dictation-object-with-minimal-diffs-and-current-context work (as described in the source files). From there it should be possible to start building voice-aware editors with neato features. Quicky script to load up the "py-commands" seems to crude by comparison :) . Mike -----Original Message----- From: Tim Peters [mailto:tim.one at home.com] Sent: Sunday, March 18, 2001 11:51 PM To: python-list at python.org Subject: RE: Help Rewriting/Refactoring/Rethinking Parsing Algorythm ... Note that Joel Gould (Dragon NatSpeak's chief architect) developed a system that lets you script NatSpeak from Python: http://www.synapseadaptive.com/joel/ ... From paul at pfdubois.com Tue Mar 20 18:56:06 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Tue, 20 Mar 2001 15:56:06 -0800 Subject: PEP 242 Released Message-ID: PEP: 242 Title: Numeric Kinds Version: $Revision: 1.1 $ Author: paul at pfdubois.com (Paul F. Dubois) Status: Draft Type: Standards Track Created: 17-Mar-2001 Python-Version: 2.2 Post-History: Abstract This proposal gives the user optional control over the precision and range of numeric computations so that a computation can be written once and run anywhere with at least the desired precision and range. It is backward compatible with existing code. The meaning of decimal literals is clarified. Rationale Currently it is impossible in every language except Fortran 90 to write a program in a portable way that uses floating point and gets roughly the same answer regardless of platform -- or refuses to compile if that is not possible. Python currently has only one floating point type, equal to a C double in the C implementation. No type exists corresponding to single or quad floats. It would complicate the language to try to introduce such types directly and their subsequent use would not be portable. This proposal is similar to the Fortran 90 "kind" solution, adapted to the Python environment. With this facility an entire calculation can be switched from one level of precision to another by changing a single line. If the desired precision does not exist on a particular machine, the program will fail rather than get the wrong answer. Since coding in this style would involve an early call to the routine that will fail, this is the next best thing to not compiling. Supported Kinds Each Python compiler may define as many "kinds" of integer and floating point numbers as it likes, except that it must support at least two kinds of integer corresponding to the existing int and long, and must support at least one kind of floating point number, equivalent to the present float. The range and precision of the these kinds are processor dependent, as at present, except for the "long integer" kind, which can hold an arbitrary integer. The built-in functions int(), float(), long() and complex() convert inputs to these default kinds as they do at present. (Note that a Unicode string is actually a different "kind" of string and that a sufficiently knowledgeable person might be able to expand this PEP to cover that case.) Within each type (integer, floating, and complex) the compiler supports a linearly-ordered set of kinds, with the ordering determined by the ability to hold numbers of an increased range and/or precision. Kind Objects Three new standard functions are defined in a module named "kinds". They return callable objects called kind objects. Each int or floating kind object f has the signature result = f(x), and each complex kind object has the signature result = f(x, y=0.). int_kind(n) For n >= 1, return a callable object whose result is an integer kind that will hold an integer number in the open interval (-10**n,10**n). This function always succeeds, since it can return the 'long' kind if it has to. The kind object accepts arguments that are integers including longs. If n == 0, returns the kind object corresponding to long. float_kind(nd, n) For nd >= 0 and n >= 1, return a callable object whose result is a floating point kind that will hold a floating-point number with at least nd digits of precision and a base-10 exponent in the open interval (-n, n). The kind object accepts arguments that are integer or real. complex_kind(nd, n) Return a callable object whose result is a complex kind that will will hold a complex number each of whose components (.real, .imag) is of kind float_kind(nd, n). The kind object will accept one argument that is integer, real, or complex, or two arguments, each integer or real. The compiler will return a kind object corresponding to the least of its available set of kinds for that type that has the desired properties. If no kind with the desired qualities exists in a given implementation an OverflowError exception is thrown. A kind function converts its argument to the target kind, but if the result does not fit in the target kind's range, an OverflowError exception is thrown. Kind objects also accept a string argument for conversion of literal notation to their kind. Besides their callable behavior, kind objects have attributes giving the traits of the kind in question. The list of traits needs to be completed. The Meaning of Literal Values Literal integer values without a trailing L are of the least integer kind required to represent them. An integer literal with a trailing L is a long. Literal decimal values are of the greatest available binary floating-point kind. Concerning Infinite Floating Precision This section makes no proposals and can be omitted from consideration. It is for illuminating an intentionally unimplemented 'corner' of the design. This PEP does not propose the creation of an infinite precision floating point type, just leaves room for it. Just as int_kind(0) returns the long kind object, if in the future an infinitely precise decimal kind is available, float_kind(0,0) could return a function that converts to that type. Since such a kind function accepts string arguments, programs could then be written that are completely precise. Perhaps in analogy to r'a raw string', 1.3r might be available as syntactic sugar for calling the infinite floating kind object with argument '1.3'. r could be thought of as meaning 'rational'. Complex numbers and kinds Complex numbers are always pairs of floating-point numbers with the same kind. A Python compiler must support a complex analog of each floating point kind it supports, if it supports complex numbers at all. Coercion In an expression, coercion between different kinds is to the greater kind. For this purpose, all complex kinds are "greater than" all floating-point kinds, and all floating-point kinds are "greater than" all integer kinds. Examples In module myprecision.py: import kinds tinyint = kinds.int_kind(1) single = kinds.float_kind(6, 90) double = kinds.float_kind(15, 300) csingle = kinds.complex_kind(6, 90) In the rest of my code: from myprecision import tinyint, single, double, csingle n = tinyint(3) x = double(1.e20) z = 1.2 # builtin float gets you the default float kind, properties unknown w = x * float(x) w = x * double(z) u = csingle(x + z * 1.0j) u2 = csingle(x+z, 1.0) Note how that entire code can then be changed to a higher precision by changing the arguments in myprecision.py. Comment: note that you aren't promised that single != double; but you are promised that double(1.e20) will hold a number with 15 decimal digits of precision and a range up to 10**300 or that the float_kind call will fail. Open Issues The assertion that a decimal literal means a binary floating-point value of the largest available kind is in conflict with other proposals about Python's numeric model. This PEP asserts that these other proposals are wrong and that part of them should not be implemented. Determine the exact list of traits for integer and floating point numbers. There are some standard Fortran routines that do this but I have to track them down. Also there should be information sufficient to create a Numeric array of an equal or greater kind. Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil End: From ws-news at gmx.at Tue Mar 6 16:27:50 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Tue, 6 Mar 2001 22:27:50 +0100 Subject: Can anyone recomend a good intoduction to C... References: <983896344.701456@newsmaster-04.atnet.at> <983911749.217622@newsmaster-04.atnet.at> Message-ID: <983914348.247943@newsmaster-04.atnet.at> This is exactly my opinion. I think right now, given the instruction sets and really hard to predict design of CPUs (parallel execution, which instruction support that, which sequence is better...) makes it a really hard task to do hand optimization. There, for sure, are some experts that still can. But they, I guess, do that all the time over... Personally I try to avoid asm whereever possible :-) regards werner Roy Smith wrote in message news:roy-32CDC5.15461906032001 at news.panix.com... > "Werner Schiendl" wrote: > > Years ago I had a lot of discussions why use C instead of Assembler. > > The arguments were mainly for performance. > > I wouldn't be surprised if a good optimizing C compiler can actually > produce faster code than hand-coded assembler in many cases. From jhauser at ifm.uni-kiel.de Fri Mar 23 10:24:48 2001 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 23 Mar 2001 16:24:48 +0100 Subject: newbe how to read in a string? References: <3ABB4E70.54885C9F@noos.fr> <99fo39$gsq$2@news.mathworks.com> Message-ID: <87ofush5j3.fsf@lisboa.ifm.uni-kiel.de> As posted numerous times, there is ftp://ftp.python.org/pub/python/contrib-09-Dec-1999/All/sscanfmodule.c HTH, __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 jmarshal at mathworks.com Thu Mar 1 12:44:26 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 1 Mar 2001 17:44:26 GMT Subject: PEP 227 (was Re: Nested scopes resolution -- you can breathe again!) References: <200102230259.VAA19238@cj20424-a.reston1.va.home.com> <97lqsr0311d@news2.newsguy.com> Message-ID: <97m1pq$3au$1@news.mathworks.com> Alex Martelli wrote: > "Jeremy Hylton" wrote in message > news:mailman.983384008.21434.python-list at python.org... > [snip] >> Rebinding names in enclosing scopes > [snip] >> opposed to it. It is difficult to support, because it would >> require a new mechanism that would allow the programmer to specify >> that an assignment in a block is supposed to rebind the name in an >> enclosing block; presumably a keyword or special syntax (x := 3) >> would make this possible. > If this were to be allowed (and I'm not saying it should be!), the > most natural way to allow it would appear to be to be a new clause > on the global statement -- most natural, because "allow rebinding > in an outer scope" is exactly global's job (of course, up to Python > 2, the only 'outer scope' was the module-one:-). > Maybe something like...: > def spam(): > def inner(): > global in spam, x > x += 1 > x = 23 > inner() Or how about just using "global" as is? If you declare a variable reference global, then search the enclosing scopes until you find the right name. It will break a little code, but on the same order as this incompatible change will already break. From paulp at ActiveState.com Mon Mar 12 07:35:46 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 12 Mar 2001 04:35:46 -0800 Subject: Extending Python: rewriting a single method in C References: Message-ID: <3AACC2A2.B7EC96D4@ActiveState.com> Jacek Generowicz wrote: > > .. > > Is there any way of re-writing just these methods in C ? Sure! In fact, it is down-right easy if you are a C programmer. You just put the two functions in an extension module and call them from C. http://www.python.org/doc/current/ext/ext.html Also, look at this example module: (you'll have to paste together the URL) http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/python/dist/src/Modules/xxmodule.c?rev=2.22&content-type=text/x-cvsweb-markup&cvsroot=python -- Python: Programming the way Guido indented it. - (originated with Skip Montanaro?) From aleaxit at yahoo.com Sun Mar 25 11:56:19 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 25 Mar 2001 18:56:19 +0200 Subject: Referencing a container object's attributes References: Message-ID: <99l80s11enf@news1.newsguy.com> "Tim Churches" wrote in message news:mailman.985486832.26248.python-list at python.org... > Is there any way for a method of a class instance which is embedded in a > container class instance to look up attributes of that container class > instance (i.e. the one which contains it)? At the moment I am putting Zope uses metaclasses for something like that == "inheritance" (sort of) from a container. Not sure how applicable that is to your needs... Alex From qrczak at knm.org.pl Mon Mar 5 11:49:57 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 5 Mar 2001 16:49:57 GMT Subject: Java guy interested in Python References: <003801c0a459$a29c97f0$63da1542@wisdom> Message-ID: Sat, 3 Mar 2001 22:54:16 -0800, Ken Seehof pisze: > Many programmers are confused in that they think the purpose of type > declarations is to protect the programmer from errors by providing > enforcement of "programming by contract". I use static typing to protect myself from errors, and to define interfaces, and to dispatch polymorphic code (on types rather than values), and to think about a piece of code before I write it. So it definitely is a purpose. > IMHO, type declarations are a sacrifice necessary to give compilers > enough information to produce efficient code. This is not true. It's simply not the only purpose. > Type declarations make sense in C and C++, but they are (IMHO) > a design flaw in high level languages. Please don't attribute flaws of C, C++ and Java to static typing itself. Haskell, ML, Mercury are at least as high level as Python and have rich type systems, which IMHO makes these languages convenient and powerful. Neither static typing nor dynamic typing is better suited than the other for all purposes. Both approaches have very strong good reasons. >From this it follows that static vs. dynamic typing flamewars will never end :-) -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From philmi at pliocene.cenozoic Mon Mar 26 22:27:59 2001 From: philmi at pliocene.cenozoic (Phil Mitchell) Date: 26 Mar 2001 22:27:59 -0500 Subject: python or smalltalk for persistence-based app? Message-ID: I need an interactive, OOP language with good support for persistence. I'm looking at python plus ZODB versus smalltalk and gemstone. I don't know either language at this point (I know C, Java, Perl). The intended use is to develop some ideas for a desktop productivity tools framework; there'll be some gui stuff and a lot of generic info management stuff (eg., managing text data organized in trees). Right now I'm leaning towards python, b/c ZODB is open-source and gemstone isn't (although there's some talk over at squeak of working on such a thing). I don't have a good sense of the relative depth/quality of libraries (and this is not a funded project that will be able to buy commercial ones). I know that's not a lot to go on, but I'd welcome any thoughts... -- sentinel %at pobox $dot com From embed at geocities.com Wed Mar 14 13:40:59 2001 From: embed at geocities.com (Warren Postma) Date: Wed, 14 Mar 2001 13:40:59 -0500 Subject: Dynamic construction of a print format string References: <3AAFB663.57FCCE7@troikanetworks.com> Message-ID: whoops... how about... fmtstr = " %"+`namelen`+"s - %s" From qrczak at knm.org.pl Mon Mar 19 11:05:44 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 19 Mar 2001 16:05:44 GMT Subject: Who's minister of propaganda this week? References: <98nu1m$12e@dispatch.concentric.net> <660ACCA1E4816F7E.C359CDF4168EF3FB.3B6B05538D619770@lp.airnews.net> <3AAFA13D.76E32C3F@divalsim.it> <98oa4o01i4v@news2.newsguy.com> <98q9h60122v@news2.newsguy.com> <9937en0bge@news2.newsguy.com> <994ab801h5o@news2.newsguy.com> <994tg9026qa@news1.newsguy.com> Message-ID: Mon, 19 Mar 2001 13:19:22 +0100, Alex Martelli pisze: > > OTOH Haskell and OCaml don't work by implicit coercion of elements > > to a common supertype. > > Isn't that what the "O" in O'Caml adds to plain good old Caml? Well, coercion upwards is explicit, but it's not as often as in C++ or Java because functions generally accept "object of any type providing these methods of these types" instead of "object coerced to the class which declares these methods". There is no coercion downwards (except unsafe Obj.magic) nor typecase. The class system is rarely used. The module system, higher order functions or algebraic types are often more appropriate and better fit the rest of the language. There is "O" in the language, but in practice it often doesn't matter. > > Note that in these languages it's meaningless to mix all types of > > objects together in a container. If they are unrelated, you can't > > apply any operation to an unspecified member of them. > > Not sure if by "these" you mean, here, "the former" (C++, Java, ...) > or "the latter" (ML, Haskell, ...). ML, Haskell. > Assuming now that by 'these' you mean 'Haskell' (or ML or Caml > without the 'O'), it's not true that I don't _want_ to built > heterogeneous, structured containers -- it's that I _can't_ do > it conveniently, It's both. > because of the language limitations imposed by the desire to allow > static type-checking. I don't call this a limitation. You could embed a complete Python-like object model in Haskell or ML. Python's classes won't correspond to types in Haskell or ML, but to values, with explicit method dictionaries etc. Syntax might be a bit awkward, and the library would have to be adapted, but in can be done. High level functional languages are especially convenient in building a sublanguage with its own rules inside them. Although I don't think that anybody would make a totally isolated object model, because of necessary glue with the rest of libraries. Viewed from that point, it's not a limitation wrt. Python's model, but an extension. > Objects are rarely mutable _in functional programming_ -- they > are commonly mutable _in object oriented programming_, and this > makes a very substantial difference. What about object oriented functional programming? I guess they are often immutable, as opposed to functional object oriented programming :-) -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From loewis at informatik.hu-berlin.de Fri Mar 2 11:06:24 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Mar 2001 17:06:24 +0100 Subject: A counter-proposal to __future__ in PEP 236 References: <97ll2u02qmp@news2.newsguy.com> <3A9FBE5C.95615241@sewardweb.com> Message-ID: Lloyd Sommerer writes: > This is obviously very distinct from its use with slices. But it seems > reasonable to me that new python programmers would wonder if this: > > directive: nested_scopes > > might be equivalent to: > > directive: > nested_scope Indeed, that is also what I would expect, and there is nothing wrong with that expectation. The confusing part would be that you'd expect to put statements into the directive block, when you really only put individual names there. Regards, Martin From dvdeug at x8b4e53cd.dhcp.okstate.edu Thu Mar 1 12:58:45 2001 From: dvdeug at x8b4e53cd.dhcp.okstate.edu (David Starner) Date: 1 Mar 2001 17:58:45 GMT Subject: [ANNOUNCE] pyAda, first public release References: <3A9DB9E1.8DD0E36D@bigfoot.de> <3A9E5AD7.FAB962F5@bton.ac.uk> Message-ID: <97m2kl$7hu1@news.cis.okstate.edu> On Thu, 01 Mar 2001 14:21:11 +0000, John English wrote: >Brad Clements wrote: >> >> Plugging in a "non-verifiable" script plug-in kinda defeats this purpose.. >> doesn't it? > >You're asking for a pure Ada implementation of Python, then. What's the point of being theoritically verifiable if you can't actually do it? If I'm not mistaken, Python is large enough to make verification of even an Ada or SPARK version unfeasible. In any case, I can't think of where you would have a verified system that you would want to give the users the ability to execute arbitrary code on. A Python script plug-in is nice for things like the Gimp, or a spreadsheet, or a word-processor; stuff where the worst case scenario is annoyance, not anything that would get verified. -- David Starner - dstarner98 at aasaa.ofe.org Pointless website: http://dvdeug.dhis.org "I don't care if Bill personally has my name and reads my email and laughs at me. In fact, I'd be rather honored." - Joseph_Greg From sholden at holdenweb.com Mon Mar 19 18:05:02 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 19 Mar 2001 18:05:02 -0500 Subject: list.sort(cmpfunc) question References: <98t9dq$qvu$1@panix6.panix.com> <98tf9d$g3v$1@news.mathworks.com> Message-ID: "Joshua Marshall" wrote in message news:98tf9d$g3v$1 at news.mathworks.com... [ ... ] > Seems the word "should" should never appear in documentation. ... and '"should" should' should _definitely_ never appear in documentation! regards Steve From winson at mdsserv.mds.com.tw Fri Mar 30 03:23:19 2001 From: winson at mdsserv.mds.com.tw (=?big5?B?sWm4zq9x?=) Date: Fri, 30 Mar 2001 16:23:19 +0800 Subject: Jython and Win2000 Message-ID: <004201c0b8f2$b04ce640$340210ac@winson> Hi all, Maybe post to wrong place. But help me... My win2000 cannot work with Jython. When I type jython under c>, sometimes there nothing happened and response me a c>. Why ?? I installed Sun's Java 1.3 SDK already. -- Best Regards, Winson Chang 3F, 2, 150 Lane, Sec. 5, Hsin I Rd., Taipei, Taiwan, R.O.C. Tel: +886-2-27225333 ext 376 Fax: +886-2-27222330 Email: winson at mdsserv.mds.com.tw -------------- next part -------------- An HTML attachment was scrubbed... URL: From sholden at holdenweb.com Fri Mar 9 09:39:57 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 9 Mar 2001 09:39:57 -0500 Subject: gah! I hate the new string syntax References: <98amlj01sp6@news2.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:98amlj01sp6 at news2.newsguy.com... > "Steve Holden" wrote in message > news:BcCp6.37817$1D5.1582482 at e420r-atl1.usenetserver.com... > [snip] > > > | > What about one who is both English and Scots, yet never set foot on > > > | > that island ;-)? > [snip] > > Either you were born in England, or you were born in Scotland, or you are > > neither English nor a Scot. Part-either-or-both, maybe, but not fully > > Wrong! You're talking about people whose seafaring skills and > traditions are (deservedly) legendary. It's perfectly acceptable > for either an English or a Scot to be born aboard a ship...!!! > OK, you got me! regards Steve From ws-news at gmx.at Tue Mar 6 16:04:16 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Tue, 6 Mar 2001 22:04:16 +0100 Subject: Can anyone recomend a good intoduction to C... References: Message-ID: <983912934.638039@newsmaster-04.atnet.at> Hello Laura, >Hello Werner > >you write: > > >I further think it is easier to move 'back' from C++ to C, when the need > >arises, than vice versa. This is simply because you are forced to use a > >different technique if the one you are used to does not work on that > >platform. > >Personally I started with procedural programming and moved to the object > >oriented technique afterwards. This is why I think it is hard to get used to > >objects when you are used to malloc, free, memcpy and friends. > > > >Did I miss an important point? > >2 points. First of all, while you may be correct that your first exposure >to procedural programming has made it hard for you to get used to >object oriented programming, it is also possible that your problem was that >C++ is a widely-avialable-but-not-particularily-good programming language. This is the point to cut in. 1) I think a language is not particularly good or bad at all. Not Python, not C, not Eiffel or whatever language. Each has advantages and disadvantages. Using the right language is an art that needs a lot of experience and knowing a lot of languages is an important issue to get there. 2) The original post asks for C, probably to add functionality not available otherwise to Python. Therefore I did not bring up any other language, but C++ because you have full access to C libraries but it's still more powerful and from my point of view a better start. Personally I wish the procedural C stuff had never even existed. 3) I have a heavy background in C because I am working in an industrial environment and lots of these small devices have nothing else than a C compiler or they only perform well if C is used. If such a thing comes with a C++ compiler I consider that a large improvement (and I'm lucky in that point - this is becoming more common). >People whose first OO programming language is Smalltalk have, in my experience >a far easier time learning OO programming. I do not know anybody whose >first OO language was Eiffel, but I suspect they have an easier time as well. >I think that the Smalltalk courses which I took at university, which >were optional, and I only took because I *like* learning languages ended >up being the most valuable courses I ever took. > Never had something to do with Smalltalk or Eiffel. I think those languages are not very well supported on to many platforms. And this is of course a point, you need some sort of library or framework to get a GUI application up and running in a reasonable amount of time. But because of your emphasis on it and some other sources maybe I will once take a look at it. But to come back to your point. Yes, I agree with you that C++ is probably not the best way to dive into objects. If I had the choice to start with either Java or C++ I would take the former, even knowing that is not es widely supported and not always (or often, sadly) not fast enough. And, just to mention it, I like to learn languages too. This is the exact reason why I am just working with Python. I cannot use it much for my business right now (appart from some build tools and such stuff), but who knows - hope never dies :-) >So the question becomes, why is it that the original poster decided to >learn C or C++? If he has an application which he thinks is suited to >one or the other, more power to him, though it is hard to make such >decisions until you have more experience with a host of computer languages. I agree with that. At least that it is difficult to learn use the right tool. But C++ is almost always an considerable alternative to plain C. And if you use it for nothing more than to hold the functions as part of the data (make them methods). >Maybe he just has a compiler and wants to play with it. Maybe he >has a linux or unix system and wants to find out exactly what it is >that his system is doing. But finally, it may be that it is more >experience with computer languages in general which is what he wants, >in which case I would say, yes, by all means learn C. Then go out and >learn Smalltalk, or Lisp or Haskell. And make sure you learn an assembler I would agree with the completeness, but not with the order. I would take the most advanced technique first. Simply because it is closest to the human mind. I know a lot of newcomers to programming that can cope with objects much easier than with C's way of doing things, pointers, memory allocation, etc. >as well on the way, because that too will make your brain go off and work >in amazing new directions. This is a keen source of personal pleasure. >They say that you cannot feel new neural connections being made in your >brain, but I am not so sure about that. > >Laura Creighton > Regards Werner From vlouie at telusplanet.net Wed Mar 7 01:57:39 2001 From: vlouie at telusplanet.net (Victor Louie) Date: Wed, 07 Mar 2001 06:57:39 GMT Subject: How to use <>? Message-ID: Hi, I was just wondering if any knew what <> does....I've got some sample code and can't figure out what's happening eg. x =10 if x <> 10: .... thanks Victor From bsass at freenet.edmonton.ab.ca Fri Mar 23 17:08:18 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Fri, 23 Mar 2001 15:08:18 -0700 (MST) Subject: New PEP: The directive statement In-Reply-To: References: Message-ID: On 23 Mar 2001, Martin von Loewis wrote: > Bruce Sass writes: > > > For example, I'd rather do... > > > > use: > > new_math.// > > result = new_math_based_function() > > except NewMathError: > > result = old_math_based_function() > > > > ...and have the compiler use the appropriate source depending on what > > the interpreter can handle, rather than do a check of the > > "sys.version"[1] or try to catch a run-time exception. > > And you would supply both new_math_based_function and > old_math_based_function in the same module, outside of the use: block? > That is probably difficult to implement, as the compiler *when > processing new_math_based_function* needs to know what / means. I'd have figured too costly (timewise), rather than too difficult... but since it is a compile-time operation (done once, or infrequently, for most users), maybe the hit would be worth the expense. In general, have the compiler scan the source to find out what the program is trying to use, then compile according to that information. With this specific example, presumably there will be broken, unused, old_math_based_function-(s) kicking around in the .pyc (removing them for the .pyo would probably be difficult). However, it may be necessary to have two pieces in place, e.g., #!/usr/bin/env python use: new_feature . . . use: new_feature # new code except: # old code ...but that would really depend on new_feature and the programmer, with some it may only make sense to do... #!/usr/bin/env python use: new_feature except: print "Sorry, you need new_feature to run this program!" sys.exit(1) ...and if always having declarative use: blocks at the top of the file would help with compiling, then it should be required. - Bruce From MarkH at ActiveState.com Wed Mar 21 19:22:00 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 22 Mar 2001 00:22:00 GMT Subject: Little red lines in PythonWin! References: <9OQt6.13652$992.84056@news-server.bigpond.net.au> Message-ID: <3AB946F0.3050106@ActiveState.com> David Bolen wrote: > Interestingly enough when I looked at this in response to the first > post > (I don't normally use Pythonwin), I noticed that the default setup > seems to have a tab size of 4 rather than 8. So Pythonwin was > expanding > literal tabs visually to a 4-position stop rather than 8, which > is different from the language definition. Yes, because I prefer them this way, and it helps keep people honest. Anyone who codes assuming that every editor on the planet uses 8 character tab stops needs a dose of reality. Every other editor I use has 4 character tab stops (if they didn't out of the box they do now). > default (with or without the red indicators) would at least present > a visual indication of what the Python parser was going to "see". I tend to be more concerned with what other editors will see. At least Python will give an immediate error if it is wrong. If you mix tabs and spaces in a way that Python likes, but still looks bad in many editors, finding out earlier is better than later IMO. If you don't like it, simply turn it off. However, my recomendation is to leave it turned on and heed its warnings regardless of the legality of the source to Python. Editors that still insist tabs characters can be 8 characters now have about 2 decades worth of catching up to do. However, I realize this may spawn its own "tabs are 8 chars the way God intended" religous thread, that I refuse to participate in - mine (and others with a dissenting opinion) minds simply can not be changed on this. Mark. From phrxy at csv.warwick.ac.uk Thu Mar 1 07:14:33 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Thu, 1 Mar 2001 12:14:33 +0000 (GMT) Subject: [Distutils] Re: CPAN functionality for python - requirements In-Reply-To: <20010228170725.B1781@tummy.com> Message-ID: On Wed, 28 Feb 2001, Sean Reifschneider wrote: > On Wed, Feb 28, 2001 at 09:59:38AM -0000, Moore, Paul wrote: [...] > >The h2xs program > >---------------- > > That seems like a distutils tool to me. > > >A social structure > >------------------ > > Based on my experimenting with Distutils last night, I don't know that this > will be a problem. Distutils is totally cool -- I can't imagine going back. > > >Interestingly, developers probably don't "expect" to have to include > >dependency information, and hence many don't - resulting in the problems you > > I think we can deal with that in an iterative manner. First get them to build > distutils packages, then when it fails to install on some user's machine > because they don't have foo.py we can educate them on the joys of listing > third-party module requirements. I think an iterative approach is a recipe for an archive full of packages that only very patchily take advantage of all the facilities on offer. The perl approach of making 'stubs' generation very easy for tests, docs, etc. is a very good idea -- it encourages you to actually put something more useful in the stubs (if not immediately, then later on). It's self perpetuating: they're always generated and the standard instructions for uploading stuff say you should include them (presumably), so it becomes widespread in the archive; people making new packages then see that everyone makes packages that way, so they'll do the same thing. I'm not suggesting everyone's about to start writing huge comprehensive manuals and test suites for everything, but a little encouragement and standardisation can go a long way, with a relatively small effort on the part of the developer. Same for dependencies, even more so probably. > >still (relatively) new, and so there are LOTS of packages which don't come > >with a setup.py yet. Often, adding one isn't hard, but it is still to > > The biggest win of using distutils is that it makes it easier for the > developer to run their software on multiple machines. That selfish > reason is enough for me. And, as selfish users of other people's software, you can use that as a hook to get people to start making documentation and tests at the same time. Getting started is often the 'rate limiting step'. > >Things are looking better with Python 2.1, though. Included with 2.1, it > >looks like there will be a standard unit testing module, and a new "pydoc" > >package, which will extract documentation from module docstrings. So the > > Should be sweet... [...] Especially if this and PyUnit, and whatever else, can all be tied together in Distutils. But *only* if there are actually some proper docs and good howto examples for Distutils itself!! What happened to the effort a while back on that? What remains to be done -- a todo list would be useful to spread the load, wouldn't it? John From djc at object-craft.com.au Thu Mar 8 20:06:18 2001 From: djc at object-craft.com.au (Dave Cole) Date: 09 Mar 2001 12:06:18 +1100 Subject: class fields vs __getattr__ References: <9898al$j3j$1@news.mathworks.com> Message-ID: >>>>> "Joshua" == Joshua Marshall writes: Joshua> If you try to get a field of an object, it seems __getattr__ Joshua> is called only if no such field exists on the class. For Joshua> exmaple: Joshua> >>> class T: Joshua> ... x = 1 Joshua> ... def __getattr__(self, name): Joshua> ... return 2 Joshua> ... Joshua> >>> ob = T() Joshua> >>> ob.foo Joshua> 2 Joshua> >>> ob.x Joshua> 1 Joshua> I would have expected ob.x to return 2. Can anyone explain Joshua> the rationale behind this behavior? __getattr__ is only used when Python cannot find the named attribute. - Dave -- http://www.object-craft.com.au From SEND at YOUR.SPAM Mon Mar 12 19:12:48 2001 From: SEND at YOUR.SPAM (Dave Simons) Date: Tue, 13 Mar 2001 01:12:48 +0100 Subject: Einstein's Riddle References: <984380185.768920@news.aei.ca> <4w6r6.193645$df5.5192565@news1.crdva1.bc.home.com> Message-ID: <98jofp$2jdr$1@norfair.nerim.net> David Murphy wrote: I'm certain that if Albert had wanted to lead people up the garden path, he could have devised a much more subtle way than "na na na na na - I never said there was any fish!" Presupposing, of course, that it realy does come from Einstein. I used to buy a monthly French magazine called Logica that had nothing but this exact type of puzzle from cover to cover. I can tell you they start to get boring after doing about two hundred of them. I remember learning of the magazine's existence from a poetry-writing tramp who wandered into a caf? where I was one day. You meet all sorts... Dave -- I think, therefore I am ... or at least there are some people who think I am. From kbk at shore.net Wed Mar 7 12:22:31 2001 From: kbk at shore.net (Kurt B. Kaiser) Date: Wed, 07 Mar 2001 17:22:31 GMT Subject: Can anyone recomend a good intoduction to C... References: <3aa366c6_2@nnrp1.news.uk.psi.net> Message-ID: <3AA66D6A.7021E451@shore.net> And once you've read K&R, try Kernighan and Pike, "The Practice of Programming", which has good advice on C style, design, and test. Harbison and Steele, "C: A Reference Manual", when you need a language lawyer. Learning a language is more than absorbing the syntax, you need to internalize quality examples to gain fluency. Look at at P. J. Plauger, "The Standard C Library" for many short codes written in the C idiom. A most remarkable book: Don Knuth's "Stanford Graphbase", which is an *extended* example of C programming in the literate programming style. You can actually sit down and read the code like literature, there's a gem on almost every page. In a hurry? K&R followed by browsing Plauger. Kurt B. Kaiser From urner at alumni.princeton.edu Sat Mar 3 12:16:14 2001 From: urner at alumni.princeton.edu (Kirby Urner) Date: Sat, 03 Mar 2001 09:16:14 -0800 Subject: Hitting two targets: OO + group theory (pedagogy) References: <3aa1077a.1110803@nntp.sprynet.com> <0932atgt9v8d8aboq90evoi5ipj5c0sk8s@4ax.com> <3aa11a91.5998558@nntp.sprynet.com> Message-ID: ullrich at math.okstate.edu (David C. Ullrich) wrote: >Some people would say that the reference to Genesis >is out of place here... probably you know that some >people would say that. Might be regarded as just >generally inappropriate - some other people might >think that the bit about Abel is misleading, since >"Abelian" _does_ refer to a man named Abel, but >not the one in Genesis. True, but it's a useful mnemonic connected to a well-known story. Making allusions to Biblical characters need be no more or less churchy than alluding to Greek mythology or to cartoon characters like Bugs Bunny (or Coyote in Native American lore) -- just taking advantage of some shared cultural heritage. Anyway, I learned this mnemonic from a very strait- laced group theory book (which I've since returned to the library), plus saw it mentioned on another list frequented by math heads -- sort of assumed this clever CAIN/Abel thing was cited routinely by those more familiar with the literature. Agreed though: we should make clear who the Abel in Abelian was. >But why not start with a class Group instead >of special cases? (Would be a class with a >__mul__ method that does nothing but raise >an exception "must implement __mul__ in >a subclass", an Id attribute, etc. I can't think >of anything offhand that Group would actually >_do_, but if we're bent on this OO-math thing >it seems like groups _should_ be descendants >of a class Group...) > In my example, it's the elements of a group which get instantiated as separate objects, with each element inheriting the same meaning for *, whatever that might be. The modulus and order of the group (= totient in this example) are also saved at the class level, where all members have access to the same bytes in memory. What's unique to each member is its integer value. For example: >>> a = G(3,20) # modulus 20, 3 is relatively prime >>> b = G(7,20) # modulus 20, 7 is relatively prime >>> a*b # product 1 >>> pow(a,2) # a^2 9 >>> G.totient # order of group (a & b share access) 8 >>> G.n # modulus of group (ditto) 20 >>> a.val # unique to a 3 >>> b.val # unique to b 7 This approach parallels my implementation of a Vector class and Quaternion class in other curriculum segments. Every v "looks within" to find a shared definition of cross product, dot product or whatever, such that we write v1.dot(v2). But for people who prefer to write dot(v1,v2), we can define a function: def dot(v1,v2): return v1.dot(v2) Some might argue that Vector and Quaternion should be integrated in some higher level superclass. Whereas I do, in fact, subclass Vector into Svector (spherical coordinates) and Qvector (quadray coordinates), I don't generalize in the other direction. I will think more about your suggestion as I continue to develop OO + math curriculum segments. It could be that the abstractions re inform the thinking of students such that they imagine special case groups as subclasses of the generic group class, without needing to literally code it this way. In other words, seeing a class hierarchy from a given starting point on down, helps them think upwards to higher levels of abstraction, even though the computer language by itself doesn't really go there (that's where we stay with a math notation -- looking for when it starts to make sense to implement more concretely as we descend to the applications level). Kirby From leo at iems.nwu.edu Tue Mar 27 15:42:01 2001 From: leo at iems.nwu.edu (Leonardo B Lopes) Date: Tue, 27 Mar 2001 14:42:01 -0600 Subject: order by instead of two queries Message-ID: <3AC0FB19.7291F7DF@iems.nwu.edu> I have some data in a table that I would like to obtain order by a specific instance of the data. ex: Name: Age: Joe 50 Jill 60 Jack 65 What I would like to do is have a query that returns Jack first, then the regular name order. Something like: SELECT Name FROM clients ORDER BY Name='Jack',Name Can this be done with one query? Thanks! Leo. -- ======================================================================= Leonardo B. Lopes leo at iems.nwu.edu Ph.D. Student (847)491-8470 IEMS - Northwestern University http://www.iems.nwu.edu/~leo From stephen_purcell at yahoo.com Wed Mar 21 09:40:57 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Wed, 21 Mar 2001 15:40:57 +0100 Subject: [Newbie] line separators in file-output In-Reply-To: <3AB8AEDA.2D2BD105@bg-sys.de>; from daniel.orlowski@bg-sys.de on Wed, Mar 21, 2001 at 02:38:34PM +0100 References: <3AB8AEDA.2D2BD105@bg-sys.de> Message-ID: <20010321154057.B26814@freedom.puma-ag.com> Daniel Orlowski wrote: > If I in Python uder Windows do smth like this: > > >>> File=open("test","w") > >>> File.write("a line"+"\n") > >>> File.close() > > I have data in file test: > 'a line\015\012' > > How can I prevent output of '\015'? Open the file in binary mode: File = open('test','wb') Windows automatically changes line endings for files opened in text mode. -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From aleaxit at yahoo.com Mon Mar 5 04:57:03 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 5 Mar 2001 10:57:03 +0100 Subject: I come to praise .join, not to bury it... References: Message-ID: <97vnu3076q@news2.newsguy.com> "Delaney, Timothy" wrote in message news:mailman.983756766.27347.python-list at python.org... [snip] > I truly have no complaints with the technical merits of ''.join(). Good. > However, I have *severe* complaints with the aesthetics and consistency. > Quite simply, the way we look at things tends to be > > "result" = "thing to be acted on to get the result" modified by "thing which > does the action" This is bass-ackwards. The 'thing which does the action', i.e. the object which will house the method code, is the one that NEEDS to come first, because of how dispatching is coded in the Python language! > This is consistently followed in the standard python libraries in almost all We seem to be using two VERY different languages/libraries - funny that they're both named 'Python', innit. For example, in the Python _I_ use, the re module defines objects (compiled regular expressions) which are the 'things which do the action', and, sure enough, they have methods which are passed the 'thing to be acted upon' as their argument -- result = thing_doing_the_action.method(thing_acted_on). Similarly, the pickle module defines objects (pickler objects) whose methods are passed 'things to be acted upon' (e.g., a list to be pickled can be passed to method dumps of the pickler, which returns the result, a string). And again, the urllib module defines object (URLopener objects) whose methods are passed 'things to be acted upon' (e.g., open is given a fullurl and optionally data) to return a result (here, a file-like object). And so on, and so forth. It's really very consistent -- it HAS to be, because it's mostly dictated by technical considerations of 'which object do we need full polymorphism on, which one is best handled through a standard interface instead'. > cases ... but ''.join() is a glaring inconsistency. As a result, it seems > unintuitive and ugly. What inconsistency?! It's exactly like the other cases -- the object which does the action (here, a string-like object, who works as a joiner) defines a method which is passed as argument the object to be acted upon. Alex From ixokai-nf at myNOSPAM.org Thu Mar 29 15:45:26 2001 From: ixokai-nf at myNOSPAM.org (Ixokai) Date: Thu, 29 Mar 2001 12:45:26 -0800 Subject: Looking for Python equivalent to a Perl'ism References: <3AC375A7.A4BA87F1@spammraqia.com> Message-ID: <3ac3a14a$1_2@goliath.newsfeeds.com> While this is not exactly what you want, were you aware of the following syntax: dict = {"foo":"yechfoo", "mumble":"yukkomumble"} print "This is %(foo)s this is junk %(mumble)s and more stuff" % dict --Stephen (replace 'NOSPAM' with 'seraph' to respond) David Lees wrote in message <3AC375A7.A4BA87F1 at spammraqia.com>... > >I am trying to figure out how to do the Python equivalent of the >following perl code, which finds all the groups tagged by 'xx' and >replaces them with text looked up in a dictionary: >---------- >my %dict; >my $string="this is xxfooxx this is junk xxmumblexx and more stuff"; >%dict=(foo=>"yechfoo",mumble=>"yukkomumble"); > >$string =~ s/xx(\S+)xx/$dict{$1}/g; > >print $string; >--------------------- > >My Python equivalent without the backreference dictionary lookup is: > >dict ={'xxx':'foo', > 'yyy':'barf', > } >p=re.compile(r'zz(\w+)zz') >s='this is and so is zzxxxzz abc that an zzyyyzz abc zzxxxzz or else' >print re.sub(p,'junk',s) > >-------------- > >But I do not understand how to include backreferences into the regex >substitution as is conveniently done in perl. Can someone tell me if >there is an easy Python solution to this? > >Thanks in advance. > >David Lees -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From mwh21 at cam.ac.uk Thu Mar 29 17:22:05 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 29 Mar 2001 23:22:05 +0100 Subject: KeyBoardInterrupt error References: Message-ID: Headers indicate evolution, so Linux, right? Jason "Straw." writes: > What can trigger a Keyboard Interrupt? Receiving a SIGINT. The terminal driver will send one of those if you hit Ctrl-C (by default). > I need Ctrl-C to be ignored and Ctrl-D to map to a function. Two options for ignoring Ctrl-C: use termios to tuen off the ISIG flag, along the lines of import termios import TERMIOS n = termios.tcgetattr(0) n[3] &=~ TERMIOS.ISIG termios.tcsetattr(0, TERMIOS.TCSANOW, n) but with some kind of error checking & stuff or use signal to ignore SIGINTs: signal.signal(signal.SIGINT,signal.SIG_IGN) Note that when you're playing around at the console that readline tends to reset both of these, which is nice, and that both of these will leave ^C in the input stream (it seems). Ctrl-D just causes reads to abort early. If you're using raw_input() (a) don't, if you want this level of control (b) just catch EOFErrors and restart your loop. > gettting a single char at a time is a bad idea for my project Eh? How does this relate to the above? If you're interested in line input, you *might* want to look at my python line reader, which was tentatively dubbed "pyrl", but needs a new name ("pyrl" is taken). It's not really finished; find it at: http://www-jcsu.jesus.cam.ac.uk/~mwh21/hacks/pyrl-0.2.0.tar.gz To test drive, unpack & go: $ python python_reader.py (requires Python 2). I've almost got incremental history searching done on my hard drive, but a few bugs and some additional commitments have stalled me... Anybody interested in seeing more, or have a better name than pyttyinput? Cheers, M. -- I'll write on my monitor fifty times 'I must not post self-indulgent wibble nobody is interested in to ucam.chat just because I'm bored and I can't find the bug I'm supposed to fix'. -- Steve Kitson, ucam.chat From guido at digicool.com Mon Mar 12 18:41:01 2001 From: guido at digicool.com (Guido van Rossum) Date: Mon, 12 Mar 2001 18:41:01 -0500 Subject: [Python-Dev] Revive the types sig? In-Reply-To: Your message of "Mon, 12 Mar 2001 18:15:15 EST." <15021.22659.616556.298360@anthem.wooz.org> References: <15020.9404.557943.164934@w221.z064000254.bwi-md.dsl.cnc.net> <200103120711.AAA09711@localhost.localdomain> <15021.22659.616556.298360@anthem.wooz.org> Message-ID: <200103122341.SAA23054@cj20424-a.reston1.va.home.com> > >>>>> "UO" == Uche Ogbuji writes: > > UO> I know this isn't the types SIG and all, but since it has come > UO> up here, I'd like to (once again) express my violent > UO> disagreement with the efforts to add static typing to Python. > UO> After this, I won't pursue the thread further here. > > Thank you Uche! I couldn't agree more, and will also try to follow > your example, at least until we see much more concrete proposals from > the types-sig. I just want to make a few comments for the record. Barry, you were supposed to throw a brick at me with this content at the meeting, on Eric's behalf. Why didn't you? I was waiting for someone to explain why this was a big idea, but everybody kept their face shut! :-( > First, it seemed to me that the greatest push for static type > annotations at IPC9 was from the folks implementing Python on top of > frameworks other than C. I know from my own experiences that there is > the allure of improved performance, e.g. JPython, given type hints > available to the compiler. While perhaps a laudable goal, this > doesn't seem to be a stated top priority of Paul's. > > Second, if type annotations are to be seriously considered for > inclusion in Python, I think we as a community need considerable > experience with a working implementation. Yes, we need PEPs and specs > and such, but we need something real and complete that we can play > with, /without/ having to commit to its acceptance in mainstream > Python. Therefore, I think it'll be very important for type > annotation proponents to figure out a way to allow people to see and > play with an implementation in an experimental way. +1 > This might mean an extensive set of patches, a la Stackless. After > seeing and talking to Neil and Andrew about PTL and Quixote, I think > there might be another way. It seems that their approach might serve > as a framework for experimental Python syntaxes with minimal overhead. > If I understand their work correctly, they have their own compiler > which is built on Jeremy's tools, and which accepts a modified Python > grammar, generating different but compatible bytecode sequences. > E.g., their syntax has a "template" keyword approximately equivalent > to "def" and they do something different with bare strings left on the > stack. I'm not sure this is viable. I believe Jeremy's compiler package actually doesn't have its own parser -- it uses the parser module (which invokes Python's standard parse) and then transmogrifies the parse tree into something more usable, but it doesn't change the syntax! Quixote can get away with this because their only change is giving a different meaning to stand-alone string literals. But for type annotations this doesn't give enough freedom, I expect. > The key trick is that it all hooks together with an import hook so > normal Python code doesn't need to know anything about the mechanics > of PTL compilation. Given a homepage.ptl file, they just do an > "import homepage" and this gets magically transformed into a .ptlc > file and normal Python objects. That would be nice, indeed. > If I've got this correct, it seems like it would be a powerful tool > for playing with alternative Python syntaxes. Ideally, the same > technique would allow the types-sig folks to create a working > implementation that would require only the installation of an import > hook. This would let them build their systems with type annotation > and prove to the skeptical among us of their overwhelming benefit. +1 --Guido van Rossum (home page: http://www.python.org/~guido/) From sholden at holdenweb.com Mon Mar 5 03:06:28 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 5 Mar 2001 03:06:28 -0500 Subject: ftp a list to a remote server References: Message-ID: "Austin Wilson" wrote in message news:tCHo6.8449$v5.32212 at newsfeeds.bigpond.com... > Hi > > I would like to save a list as a text file on a remote server using ftp. > > Is this possible? If so, could you please provide some sample code. > > Or do I have to save the file locally first then ftp that file to the remote > server? > > Thanks > Austin > > Take a look at ftpStream in http://www.holdenweb.com/Python/index.html This allows you to read from and write to files on remote FTP servers. regards Steve From dnew at san.rr.com Tue Mar 13 18:21:52 2001 From: dnew at san.rr.com (Darren New) Date: Tue, 13 Mar 2001 23:21:52 GMT Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> <20010312170356.B3513@better.net> <984486395.407379@newsmaster-04.atnet.at> <984518199.127140@newsmaster-04.atnet.at> Message-ID: <3AAEAB92.DC8E984A@san.rr.com> Grant Edwards wrote: > Of course we'd never imagined we'd ever see hardware FP and BCD > libraries were only marginally slower than binary ones. Now > that FP is usually in hardware, BCD FP (or fixed point) will be > pretty slow by comparison. One mainframe I worked on (Xerox 560, AKA Sigma 9) had the "scientific module" which was hardware floating point, and the "business module" which was the hardware BCD. The latter added instructions like "Edit byte string" that would copy packed BCD into a string according to COBOL display-edit formatting. (Or whatever COBOL called the "print using" formatting. Too many years. Not enough COBOL. Or something like that.) -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. From ben.hutchings at roundpoint.com Tue Mar 6 19:31:53 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 06 Mar 2001 16:31:53 -0800 Subject: Remote script execution with Python ... References: <7Ybp6.7729$r4.7336@news.indigo.ie> Message-ID: "Robert Gahan" writes: > Hi there, > > I have installed python on a Windows PC and I am looking to > remotely execute a script on a UNIX box from a python program. > I need to be able to pipe a "y" to stdin also. Is there a windows > equivalent of the unix "rexec" that could help me ?. What is the > most appropriate way of doing this ?. You might be able to do this with something like: script_in, script_out = os.popen2("rsh otherhost -c myscript") print >>script_in 'y' result = script_out.readlines() Windows 2000 includes an rsh client but I'm not sure about other versions of Windows. You might want to use ssh instead for greater security. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From dnew at san.rr.com Wed Mar 14 13:37:16 2001 From: dnew at san.rr.com (Darren New) Date: Wed, 14 Mar 2001 18:37:16 GMT Subject: Who's minister of propaganda this week? References: <98nu1m$12e@dispatch.concentric.net> <660ACCA1E4816F7E.C359CDF4168EF3FB.3B6B05538D619770@lp.airnews.net> <3AAFA13D.76E32C3F@divalsim.it> <98oa4o01i4v@news2.newsguy.com> Message-ID: <3AAFBA5D.63AAF897@san.rr.com> Alex Martelli wrote: > So, all the compile-time checking is buying is catching (a small > subset of) the errors that would be caught in testing anyway, a > little bit earlier (thus, a little bit cheaper) Actually, if you do the XP thing, you write the tests before the code, so you're actually catching the type error before you even have something that compiles. ;-) -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. From grante at visi.com Sun Mar 11 23:50:12 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 12 Mar 2001 04:50:12 GMT Subject: Poll'able Queue objects. References: Message-ID: In article , Dan Maas wrote: >> As this didn't seem to exist i have coded a selectable Queue object based >> on pipes (which should thus work under unix and win32). I have included >> the code below. If you go to the following URL : > >I hate to say it, but this code won't work on Win32 since you can't select() >or WaitForMultipleObjects() on anonymous pipes (thanks, MS!). The mind wobbles. One of the things that Unix got right is that you can select() (or poll()) on pipes, sockets, serial ports (any properly written character device that's properly written), or, in degenerate-case sort of way, "regular" files. The fact that MS could take such a giant step backwards demonstrates either a monumental lack of knowledge about OS's or a monumental amount of conceit. Probably a combination of both. It's really sad and shocking. -- Grant Edwards grante Yow! Do you think the at "Monkees" should get gas on visi.com odd or even days? From hzhu at mars.localdomain Tue Mar 20 19:16:56 2001 From: hzhu at mars.localdomain (Huaiyu Zhu) Date: Wed, 21 Mar 2001 00:16:56 GMT Subject: comp.lang.python.numeric? (was Re: Numeric PEPs, first public posts) References: <99669h$so4$1@panix6.panix.com>, Message-ID: On Tue, 20 Mar 2001 11:24:49 +0200, Moshe Zadka wrote: >On 19 Mar 2001 15:55:29 -0800, aahz at panix.com (Aahz Maruch) wrote: > >> Because a lot of people don't have time to subscribe to every mailing >> list that comes along. > >I respectfully disagree. The numerics sig has managed to get many people >that probably don't read c.l.py subscribed to it. Different peopel have different preferences. Some like mail clients, some like news clients, some even prefer web access. Any one choice will make others unhappy. Since there have been several numerical discussions popping up here and there, does anybody else think it's a good idea to create a news group comp.lang.python.numeric? It could be gatewayed such that posting to any of the numerical mailing lists would be submitted to the news group as well. I do not have the expertise to manage a call for vote and other necessary things about creating a news group. Here is a list several advantages that might be included in a CfV if someone does it. 1. There exists a substantial need for dicussion of numerical computing in Python. This is evident from the existence of several specialized discussion forums. 2. A news group offers a unique type of venue that is unmatched by news groups in many ways. Many potential discussants would use news group if if they do not use other forums. Furthermore, it can be used in conjunction with others. 3. Numerical related discussions pop up in c.l.p quite often. But the content is often quite specialized that it is not of general interest to majority of readers here at any given moment. The discussions are also often very long as well. On second thought, maybe we could broaden the scope a bit, say comp.lang.python.math or even comp.lang.python.sci. This would allow discussions about symbolic algebra as well. Anybody having the energy and know-how to do this? Huaiyu From gervaserules at yahoo.com Tue Mar 13 21:00:45 2001 From: gervaserules at yahoo.com (Nathan Heagy) Date: Wed, 14 Mar 2001 02:00:45 GMT Subject: Console column Width Message-ID: I can't figure out how to learn the (linux) console's column width from within a script? That is, without using curses. I thought it would be so simple that an included module would already be able to do it. I can't find one. I resorted to looking in the ls source and found that a call to ioctl is how ls does it. However trying to use python's fnctl.ioctl() on sys.stdout gives me an error. Even if it did work, I'm not sure how to parse the results! Any help here is greatly appreciated, especially replies be email : ) Thanks, nathan From barry at digicool.com Wed Mar 21 12:40:21 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Wed, 21 Mar 2001 12:40:21 -0500 Subject: PEP 1, PEP Purpose and Guidelines Message-ID: <15032.59269.4520.961715@anthem.wooz.org> With everyone feeling so PEPpy lately (yay!) I thought it was time to do an updating pass through PEP 1. Attached below is the latest copy, also available (as soon as uploading is complete) via http://python.sourceforge.net/peps/pep-0001.html Note the addition of the Replaces: and Replaced-By: headers for formalizing the PEP replacement policy (thanks to Andrew Kuchling for the idea and patch). Enjoy, -Barry -------------------- snip snip -------------------- PEP: 1 Title: PEP Purpose and Guidelines Version: $Revision: 1.16 $ Author: barry at digicool.com (Barry A. Warsaw), jeremy at digicool.com (Jeremy Hylton) Status: Draft Type: Informational Created: 13-Jun-2000 Post-History: 21-Mar-2001 What is a PEP? PEP stands for Python Enhancement Proposal. A PEP is a design document providing information to the Python community, or describing a new feature for Python. The PEP should provide a concise technical specification of the feature and a rationale for the feature. We intend PEPs to be the primary mechanisms for proposing new features, for collecting community input on an issue, and for documenting the design decisions that have gone into Python. The PEP author is responsible for building consensus within the community and documenting dissenting opinions. Because the PEPs are maintained as plain text files under CVS control, their revision history is the historical record of the feature proposal[1]. Kinds of PEPs There are two kinds of PEPs. A standards track PEP describes a new feature or implementation for Python. An informational PEP describes a Python design issue, or provides general guidelines or information to the Python community, but does not propose a new feature. PEP Work Flow The PEP editor, Barry Warsaw , assigns numbers for each PEP and changes its status. The PEP process begins with a new idea for Python. Each PEP must have a champion -- someone who writes the PEP using the style and format described below, shepherds the discussions in the appropriate forums, and attempts to build community consensus around the idea. The PEP champion (a.k.a. Author) should first attempt to ascertain whether the idea is PEP-able. Small enhancements or patches often don't need a PEP and can be injected into the Python development work flow with a patch submission to the SourceForge patch manager[2] or feature request tracker[3]. The PEP champion then emails the PEP editor with a proposed title and a rough, but fleshed out, draft of the PEP. This draft must be written in PEP style as described below. If the PEP editor approves, he will assign the PEP a number, label it as standards track or informational, give it status 'draft', and create and check-in the initial draft of the PEP. The PEP editor will not unreasonably deny a PEP. Reasons for denying PEP status include duplication of effort, being technically unsound, or not in keeping with the Python philosophy. The BDFL (Benevolent Dictator for Life, Guido van Rossum ) can be consulted during the approval phase, and is the final arbitrator of the draft's PEP-ability. The author of the PEP is then responsible for posting the PEP to the community forums, and marshaling community support for it. As updates are necessary, the PEP author can check in new versions if they have CVS commit permissions, or can email new PEP versions to the PEP editor for committing. Standards track PEPs consists of two parts, a design document and a reference implementation. The PEP should be reviewed and accepted before a reference implementation is begun, unless a reference implementation will aid people in studying the PEP. Standards Track PEPs must include an implementation - in the form of code, patch, or URL to same - before it can be considered Final. PEP authors are responsible for collecting community feedback on a PEP before submitting it for review. A PEP that has not been discussed on python-list at python.org and/or python-dev at python.org will not be accepted. However, wherever possible, long open-ended discussions on public mailing lists should be avoided. A better strategy is to encourage public feedback directly to the PEP author, who collects and integrates the comments back into the PEP. Once the authors have completed a PEP, they must inform the PEP editor that it is ready for review. PEPs are reviewed by the BDFL and his chosen consultants, who may accept or reject a PEP or send it back to the author(s) for revision. Once a PEP has been accepted, the reference implementation must be completed. When the reference implementation is complete and accepted by the BDFL, the status will be changed to `Final.' A PEP can also be assigned status `Deferred.' The PEP author or editor can assign the PEP this status when no progress is being made on the PEP. Once a PEP is deferred, the PEP editor can re-assign it to draft status. A PEP can also be `Rejected'. Perhaps after all is said and done it was not a good idea. It is still important to have a record of this fact. PEPs can also be replaced by a different PEP, rendering the original obsolete. This is intended for Informational PEPs, where version 2 of an API can replace version 1. PEP work flow is as follows: Draft -> Accepted -> Final -> Replaced ^ +----> Rejected v Deferred Some informational PEPs may also have a status of `Active' if they are never meant to be completed. E.g. PEP 1. What belongs in a successful PEP? Each PEP should have the following parts: 1. Preamble -- RFC822 style headers containing meta-data about the PEP, including the PEP number, a short descriptive title, the names contact info for each author, etc. 2. Abstract -- a short (~200 word) description of the technical issue being addressed. 3. Copyright/public domain -- Each PEP must either be explicitly labelled in the public domain or the Open Publication License[4]. 4. Specification -- The technical specification should describe the syntax and semantics of any new language feature. The specification should be detailed enough to allow competing, interoperable implementations for any of the current Python platforms (CPython, JPython, Python .NET). 5. Rationale -- The rationale fleshes out the specification by describing what motivated the design and why particular design decisions were made. It should describe alternate designs that were considered and related work, e.g. how the feature is supported in other languages. The rationale should provide evidence of consensus within the community and discuss important objections or concerns raised during discussion. 6. Reference Implementation -- The reference implementation must be completed before any PEP is given status 'Final,' but it need not be completed before the PEP is accepted. It is better to finish the specification and rationale first and reach consensus on it before writing code. The final implementation must include test code and documentation appropriate for either the Python language reference or the standard library reference. PEP Style PEPs are written in plain ASCII text, and should adhere to a rigid style. There is a Python script that parses this style and converts the plain text PEP to HTML for viewing on the web[5]. Each PEP must begin with an RFC822 style header preamble. The headers must appear in the following order. Headers marked with `*' are optional and are described below. All other headers are required. PEP: Title: Version: Author: * Discussions-To: Status: Type: Created: * Python-Version: Post-History: * Replaces: * Replaced-By: Standards track PEPs must have a Python-Version: header which indicates the version of Python that the feature will be released with. Informational PEPs do not need a Python-Version: header. While a PEP is in private discussions (usually during the initial Draft phase), a Discussions-To: header will indicate the mailing list or URL where the PEP is being discussed. No Discussions-To: header is necessary if the PEP is being discussed privately with the author, or on the python-list or python-dev email mailing lists. PEPs may also have a Replaced-By: header indicating that a PEP has been rendered obsolete by a later document; the value is the number of the PEP that replaces the current document. The newer PEP must have a Replaces: header containing the number of the PEP that it rendered obsolete. PEP headings must begin in column zero and the initial letter of each word must be capitalized as in book titles. Acronyms should be in all capitals. The body of each section must be indented 4 spaces. Code samples inside body sections should be indented a further 4 spaces, and other indentation can be used as required to make the text readable. You must use two blank lines between the last line of a section's body and the next section heading. Tab characters must never appear in the document at all. A PEP should include the Emacs stanza included by example in this PEP. A PEP must contain a Copyright section, and it is strongly recommended to put the PEP in the public domain. You should footnote any URLs in the body of the PEP, and a PEP should include a References section with those URLs expanded. References and Footnotes [1] This historical record is available by the normal CVS commands for retrieving older revisions. For those without direct access to the CVS tree, you can browse the current and past PEP revisions via the SourceForge web site at http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/python/nondist/peps/?cvsroot=python [2] http://sourceforge.net/tracker/?group_id=5470&atid=305470 [3] http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse [4] http://www.opencontent.org/openpub/ [5] The script referred to here is pep2html.py, which lives in the same directory in the CVS tree as the PEPs themselves. Try "pep2html.py --help" for details. The URL for viewing PEPs on the web is http://python.sourceforge.net/peps/ Copyright This document has been placed in the public domain. Local Variables: mode: indented-text indent-tabs-mode: nil End: From skip at pobox.com Wed Mar 28 15:03:57 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 28 Mar 2001 14:03:57 -0600 (CST) Subject: Is inheritance broken? In-Reply-To: References: <15042.11167.848530.564353@beluga.mojam.com> Message-ID: <15042.17325.125458.471763@beluga.mojam.com> Jonathan> Ugly and error prone, no? Well, perhaps there is a better way... ;-) How about creating mixins, then composing a set of classes from them: class VaryingAnglesMixin: def angle(self): return "variable" class SameAnglesMixin: def angle(self): return "same" class NinetyDegreesMixin: def angle(self): return "90 degree" class VaryingSidesMixin: def side(self): return "variable" class SameSidesMixin: def side(self): return "same" class parallelogram(VaryingAnglesMixin, VaryingSidesMixin): pass class rhombus(VaryingAnglesMixin, SameSidesMixin): pass class rectangle(NinetyDegreesMixin, VaryingSidesMixin): pass class square(NinetyDegreesMixin, SameSidesMixin): pass s = square() print "squares have", s.angle(), "angles" print "squares have", s.side(), "sides" r = rhombus() print "rhombuses have", r.angle(), "angles" print "rhombuses have", r.side(), "sides" Skip From wware at world.std.com Tue Mar 6 19:27:04 2001 From: wware at world.std.com (Will Ware) Date: Wed, 7 Mar 2001 00:27:04 GMT Subject: Open Source Organic Chemistry software project References: <983tj3$fio$1@nntp9.atl.mindspring.net> Message-ID: "mapMonkey" wrote: > The current code-base is geared to Organic Chemistry molecules > and the IUPAC nomenclature system and it works quite well. It > was written entirely in Python, and entirely by me... Greg Landrum (gReGlAnDrUm at earthlink.net) wrote: > I'll express provisional interest... Likewise. There is in fact a long and venerable history of computational chemistry in the Python world, most notably the MMTK molecular modeling package: http://starship.python.net/crew/hinsen/MMTK/ Also of some interest, but currently inactive to the best of my knowledge, is the OpenChem project: http://www.openchem.org/ Here's some stuff by Konrad Hinsen: ftp://www.ccl.net:/pub/chemistry/software/SOURCES/PYTHON/HINSEN/ Konrad was IIRC the original author of MMTK, and an early contributor to the development of NumPy. There's also something interesting on SourceForge called PyMOL: http://pymol.sourceforge.net/ It's a graphics system for making images and animations. I don't know if any of this stuff will be of any use to your project, but at least it should give you a comfortable feeling about mixing Python and computational chemistry. -- -----------------------------------+--------------------- 22nd century: Esperanto, geodesic | Will Ware domes, hovercrafts, metric system | wware at world.std.com From aleaxit at yahoo.com Sat Mar 17 03:30:07 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 17 Mar 2001 09:30:07 +0100 Subject: Who's minister of propaganda this week? References: <98otuq0nnf@news1.newsguy.com> <98q6ro2uoa@news2.newsguy.com> <98t8830nlb@news1.newsguy.com> Message-ID: <98v77v11qcg@news2.newsguy.com> "Neelakantan Krishnaswami" wrote in message news:slrn9b5sbv.lu3.neelk at alum.mit.edu... [snip] > >> I actually have a function that walks the class tree checking it > >> against the dictionary, which solves this problem. You don't need to > >> add a special attribute in Python since __class__ gives you what you > >> need for free. > > > > ...except it doesn't, because it's _not_ inherited -- you have > > to 'manually' walk the directed acyclic graph (tree? what tree? > > we have _multiple_ inheritance:-) or iterate through the dictionary's > > keys (assumed to be types) using isinstance for each on your > > object. > > Okay, I don't understand what you're saying at all. > > If I call __class__ on an object, I get its class. Now, I can ask > each class what its superclasses are using the __bases__ attribute on > each class. This is okay to leave as a function, because Python > promises to walk the class heterarchy (happy? :) in a depth-first > left-to-right order. So far, so good. > So I have a dictionary like this > > >>> d > {: 2, > : 3, > : 1} > > and when I call lookup(d, Baz()) where Baz is a direct subclass of > Foo, it will return 1. (C types are easy to handle, because they don't > admit any subtyping.) That depends on how you have coded your lookup function, of course; basically, it needs to duplicate the logic of Python's bases-lookup (left-first, depth-first) unless you want to risk some big surprise. Consider, for example: class Baz(Bar, Foo): pass Now, Baz IS a direct subclass of Foo -- but I would expect the lookup to yield 2, not 1, because Bar 'dominates' Foo in Baz's ancestors-DAG -- and directness is less important than other issues, e.g: class Baz2(Baz,Foo): pass this inherits from Foo twice, _and_ directly too -- but Bar STILL dominates Foo, as left-first comes before depth-first. Nothing wrong in duplicating this logic in your lookup function, except that I'd much rather have things done ONCE whenever feasible. Affixing classes with an attribute, and using that attribute's value as a key, lets us take advantage of Python's inheritance mechanism *directly* -- because our getattr for that attribute uses just that mechanism. So we KNOW we have no semantic variation in any subtle aspect, etc. (It's also likely to be faster, but that's a secondary issue). Alex From pearu at cens.ioc.ee Sat Mar 10 15:17:14 2001 From: pearu at cens.ioc.ee (Pearu Peterson) Date: Sat, 10 Mar 2001 22:17:14 +0200 Subject: Can anyone recomend a good intoduction to C... In-Reply-To: <98dpoe12ckn@news1.newsguy.com> References: <989mbk$24nuv$1@fido.engr.sgi.com> <98auhn0270j@news2.newsguy.com> <98dpoe12ckn@news1.newsguy.com> Message-ID: On Sat, 10 Mar 2001, Alex Martelli wrote: > "Expected" is correct; it's a social issue, NOT a technical one -- > technically, C++ is a better choice for most Python extensions &c > on a Linux platform. But, if one wants acceptance, one writes in > C (e.g., that's what I did for GMPY, because I'd like people to use > it -- but it would be already out of alpha if had dared use C++, and > it would be just as fast &c). > > Your opinion is widespread, and self-perpetuating, but it has no > current technical basis for such tasks as Python extensions on Linux. I must say that earlier I had also an opinion that no matter what I would not use C++ for extending Python --- the reasons of my opinion are now irrelevant after I learned about Boost. Though I had a gap about 2 years of programming in C++, interfacing a C++ library to Python using Boost was so easy that I caught up with C++ and started to use it on Linux. Boost is an excellent tool, so is gcc. Thanks to the authors of these tools! But I must say that there is also a dark side in using C++. The C++ compiler (gcc 2.95.2, in particular) takes more memory (>100MB) than in my computer when compiling a (still incomplete) Python interface to the GiNaC C++ library. And this interface has only approx. 300 lines of code that uses mostly Boost constructs. I don't yet know if I am able to compile this extension module on my laptop when it will be complete... In conclusion, extending Python with C++ libraries in connection with Boost works very fine on Linux **if** you have plenty of memory available in your computer for compilation. At least, that's my experience. Pearu From whisper at oz.net Thu Mar 29 15:15:40 2001 From: whisper at oz.net (Dave LeBlanc) Date: 29 Mar 2001 20:15:40 GMT Subject: Python scripts as Drop targets in Windows Explorer References: <99qogo$o6g$1@troll.powertech.no> <99qqq3$qt7$0@216.39.170.247> <99r043$qqr$1@troll.powertech.no> <8kAw6.780$R6.22057@news1.oke.nextra.no> Message-ID: <9a055c$n2q$1@216.39.170.247> Yes, i'm using NT 4.0 currently. The second posting where you said you where putting an ascii version was also in "gooberish" Regards, Dave LeBlanc On Thu, 29 Mar 2001 08:10:08 +0200, "Syver Enstad" wrote: > >"Michael Linnemann" wrote > >> Yeah, looks cool. What is it, perl? Czech? EBCDIC? >As it said in the posting: >>>default on Win2k is to save as unicode. >> Come on, tune your W2k a little and make it talk plain :-) >I don't know what you mean, isn't Unicode one of the most plain ways to talk >nowadays? And I have also posted it as plain text so it shouldn't be too >difficult for you. > > > From jmcmonagle at velseis.com.au Wed Mar 21 23:37:13 2001 From: jmcmonagle at velseis.com.au (John McMonagle) Date: Thu, 22 Mar 2001 14:37:13 +1000 Subject: Is there python code highlighting in emacs ? References: <3AB978A9.353A0E4B@yahoo.com> <3AB97F1F.70FF97DD@velseis.com.au> Message-ID: <3AB98179.679DC4A@velseis.com.au> > > > > > > > The hilit19 package in emacs provides keyword highlighting when editing > > > code. For example, if you are writing in C, comments are italicised in > > > red, strings are in grey, import statements are in lavender, functions > > > are in bold-blue, etc. > > > > > > Does anyone know if there is python support in the hilit19 emacs lisp > > > package ? > > > > I don't know about hilit19, but I use python-mode which highlights > > using font-lock-mode. Comes with GNU Emacs 20.whatever. Try M-x > > python-mode and see if anything happens. > > > > python-mode does many other useful things, too. I can't imagine > > working without it at this point. > > > > I already use python-mode which works fine for indenting, etc. How do I > configure this font-lock-mode for python ? What do I add to my .emacs > file ? > Worked it out. Add the following to your .emacs file: (add-hook 'python-mode-hook '(lambda() (font-lock-mode 1))) From dsavitsk at e-coli.net Sat Mar 10 15:39:57 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Sat, 10 Mar 2001 14:39:57 -0600 Subject: Tkinter focus_get() Message-ID: I have a grid (actually a dictionary of dictionaries) of entry widgets that are dynamically created. Each has bound to it. I am trying to determine which one has focus, so i used self.root.focus_get() which returns something that looks like .8854796.8898804.18282492.18282532.18283228.18248316.17887444.17854708 is there a way to interpret this? or a better way to get focus? how the entries are created is shown below (this creates a row of entries in a ScrolledCanvis) ----------------------------------------------------- def AddRow(self): y = {} self.itemnumber = self.itemnumber + 1 y['lbl'] = str(self.itemnumber) + '.' self.data_dict[self.itemnumber] = y y['frm'] = Frame(self.ft2.interior(), bg='#AAAAFF') # frame for entry and label Label(y['frm'], width=11, bg='#eeeeee', justify='right', wraplength=172, text=y['lbl']).pack(side=LEFT, fill=X, expand=YES) for i in ['a', 'b', 'c', 'd', 'e']: y[i + 'd'] = StringVar() # entry's data y[i + 'e'] = Entry(y['frm'], relief='solid', borderwidth=0, textvariable=y[i + 'd']) y[i + 'e'].bind('', self.reportUp) y[i + 'e'].bind('', self.reportDown) y[i + 'e'].bind('', self.reportLeft) y[i + 'e'].bind('', self.reportRight) y[i + 'e'].pack(side=LEFT, expand=YES, fill=X, padx=1, pady=1) y['frm'].pack(side=TOP, expand=YES, fill=X, padx=0, pady=0) self.grid[self.itemnumber] = y ------------------------------------------------------ thanks again, doug From shaleh at valinux.com Fri Mar 2 16:06:56 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Fri, 02 Mar 2001 13:06:56 -0800 (PST) Subject: the demise of 'from foo import * and its implications? Message-ID: I understand that the 'from foo import *' syntax will be deprecated some day soon. How will this affect things like thr gtk python binding which has many many functions, defines, etc? Will I have code where every other word is 'gtk.Foo'? From Markus_Reitz at yahoo.com Wed Mar 21 06:44:09 2001 From: Markus_Reitz at yahoo.com (Markus Reitz) Date: Wed, 21 Mar 2001 12:44:09 +0100 Subject: Bug or feature? Message-ID: <99a433$b8b$1@sun.rhrk.uni-kl.de> Hi, I'm using Python 2.0 and have found a, according to my opinion, strange behaviour. a=[] a.extend('Test') Printing a results in: a=['T','e','s','t'] I expected a TypeError message, because a String is not a list and so it can't be used to extend an existing list. On the other hand, a string can be seen as a kind of "list of characters" ... Is this behaviour a bug or a feature? Markus From dsh8290 at rit.edu Tue Mar 27 16:44:29 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 27 Mar 2001 16:44:29 -0500 Subject: Good Editor? (What's the big deal with syntax colouring?) In-Reply-To: <99erbn$3e@gap.cco.caltech.edu>; from n8gray@caltech.edu.is.my.e-mail.address on Thu, Mar 22, 2001 at 10:38:00PM -0800 References: <008F0A63472BD311AF9800104BCD102561CD3E@minirex.vmlabs.com> <99erbn$3e@gap.cco.caltech.edu> Message-ID: <20010327164429.B3707@harmony.cs.rit.edu> On Thu, Mar 22, 2001 at 10:38:00PM -0800, Nathaniel Gray wrote: | Timothy Grant wrote: | > Now if only else didn't highlight but else: did $ vim $VIM/syntax/python.vim ;-) you can adjust the regexes to your preferences | Ah, but that's what auto-indent is for! When NEdit doesn't indent the | first line of a block I know I forgot the colon at the end of the last line. | | One of these days I'll send in my ultra-improved auto-indent Python macros | for NEdit. I'm still working on the auto-dedent macros... I can't wait for auto-dedent in vim, it has most of the auto-indent correct. Anyone want to work on making it? Vim is python-scriptable as well. -D From joelg at alum.mit.edu Mon Mar 12 07:42:37 2001 From: joelg at alum.mit.edu (Joel Gould) Date: Mon, 12 Mar 2001 12:42:37 GMT Subject: Tkinter with PIL crashing on large images - help Message-ID: <3aacc208.1842603@news.ne.mediaone.net> Is this expected behavior? If I load a 3.3 megapixel JPG file into a PIL (Python Image Library) PhotoImage object and then draw that on a Tkinter.Canvas object, Python crashes with an access violation (under WIndows 98). I have attached the code that fails. You can ge a suitable image from this link: http://www.gouldhome.com/Travel/StThomas00/images/001229_1106_charlotteAmalie3.jpg I have tried this using the latest py20 distribution (Python 2.0, PIL 1.1.1, etc.) from Secret Labs. I also tried it using the PythonWorks Testdrive 1.1 (which uses Python 1.5.2) also from Secret Labs. I am using Windows 98 SE on a Pentium III with 256MB of RAM. Can anyone tell me why this is failing? P.S. I know the image is very big and I can make it smaller before displaying it. I just do not think it should GPF in this case. Joel Gould joelg at alum.mit.edu ----- snip ---- import Tkinter import Image import ImageTk class MainDialog: def __init__(self, parent): self.canvas = Tkinter.Canvas(parent,width=700,height=500) self.canvas.pack() self.image = Image.open("001229_1106_charlotteAmalie3.jpg") self.tkim = ImageTk.PhotoImage(self.image) self.item = self.canvas.create_image( 0,0,image=self.tkim,anchor='nw') if __name__ == '__main__': root = Tkinter.Tk() dialog = MainDialog(root) root.mainloop() From kammie at commie.com Sun Mar 11 13:38:05 2001 From: kammie at commie.com (kammie) Date: Sun, 11 Mar 2001 18:38:05 GMT Subject: Python and ObjectSpace Voyager Message-ID: <4chnatkpmpvo29v515orlcjcfuoii5gcte@4ax.com> Hello -- Has anyone heard of writing Python CORBA apps for use with the Voyager orb? It would be neat if that orb had its own Python mappings (I don't think so), otherwise IIOP would be nice. From ws-news at gmx.at Wed Mar 14 17:46:02 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Wed, 14 Mar 2001 23:46:02 +0100 Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> <20010312170356.B3513@better.net> <984486395.407379@newsmaster-04.atnet.at> <984518199.127140@newsmaster-04.atnet.at> <98ohuc$du9$1@news.udel.edu> <7bQr6.644$lz1.17686@ruti.visi.com> Message-ID: <984610248.564504@newsmaster-04.atnet.at> > In fiancial calculations you also need to represent numbers > that aren't amounts of money. Interest rates for example. > How about 1/100 of a percent? So you can stay with integer arithmetics, especially if you consider pythons 'unlimited' long If 0.01 % does not suffice in precision, you can store it as 0.0001 % units (say, store 1.0625% as 10625, no comma whatsoever) regards werner From gerhard.nospam at bigfoot.de Thu Mar 22 11:59:36 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Thu, 22 Mar 2001 17:59:36 +0100 Subject: Python 2.1 and MySQL 3.23.33 on Windows References: <99d1te$ogo$1@news.netpower.no> Message-ID: <3ABA2F78.87E037CA@bigfoot.de> David Brown wrote: > > I have MySQL 3.23.33 and Python 2.1 installed on my Windows machine. Both > work fine (I use MySQL along with PHP and Apache), and I have used Python > for a few short scripts. But I cannot get Python to work with MySQL. The > mySQLdb windows installation is built for Python 2.0, not 2.1, and I do not > have MSVC to recompile it myself. Does anyone have any hints or pointers to > get me started? Thanks. A new version of the MySQLdb Windows binary distribution is available at my homepage. This one contains binaries for Python 1.5.2, 2.0 and 2.1 Beta 1. Gerhard -- Sorry for the fake email, please use the real one below to reply. contact: g e r h a r d @ b i g f o o t . d e web: http://highqualdev.com From shaleh at valinux.com Thu Mar 22 13:56:15 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Thu, 22 Mar 2001 10:56:15 -0800 (PST) Subject: Python and emacs In-Reply-To: Message-ID: On 22-Mar-2001 Don Dwiggins wrote: > A semi-idle question: has anyone looked into embedding Python as an > extension language in Emacs, alongside Elisp? I'm toying with the idea of > doing some Emacs enhancements/modifications, and given the choice, I'd much > rather do them in Python. (One such enhancement would be to add > Pythonwin-style "intellisense" popups to python-mode.) > An editor that spoke python would not be a bad thing. However, trying to get emacs to speak python strikes me as an amazingly good way to waste whatever brain cells you have left. From hzhu at mars.localdomain Fri Mar 9 03:36:37 2001 From: hzhu at mars.localdomain (Huaiyu Zhu) Date: Fri, 09 Mar 2001 08:36:37 GMT Subject: polymorphjsm &c (was Re: I come to praise .join, not to bury it...) References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> <9811a8$k5k$1@nntp6.u.washington.edu> <982cja0v5c@news1.newsguy.com> <983u1l$6mk$1@animus.fel.iae.nl> <9851gf014vq@news1.newsguy.com> Message-ID: On Wed, 7 Mar 2001 11:11:17 +0100, Alex Martelli wrote: > >but neither do you get what you want, because a.split(b) works >irregularly...: > > -- if a is a re object, or if it's module-object os.path, > then string b is split using splitter-object a > -- if a is a string object (including a Unicode string), > then string a is split using splitter-object b (which > must also be a string) [...] > >It's no doubt too late to remedy the discrepancy between >the semantics of a.split(b) depending on a's type (string >versus re) and the resulting irregularity (which we no >doubt will have to live with anyway) is unpleasant, to say >the least. Maybe not too late? sep.splits(thing) => list sep.joins(list) => thing list.joinswith(sep) => thing thing.splitswith(sep) => list This would allow sep to be either string, re or os.path, etc. The words joinswith and splitswith are comparable to startswith, endswith. In any case, we have to live with two orders of split whichever way the original design goes. How else would one reconcile the following? re.compile.split # sep.split(string) file.read.splitline # string.split(sep) But honestly, after seeing all these arguments and switching opinion twice I come to believe only multimethod would be the true solution. Wait for Py3k? Just-realize-I-was-promoting-TMTOWTDI-ly yr's Huaiyu From max at alcyone.com Wed Mar 28 11:09:55 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 28 Mar 2001 08:09:55 -0800 Subject: list vs tuple References: Message-ID: <3AC20CD3.265A2D94@alcyone.com> deadmeat wrote: > Whats the practical difference between a list[] and a tuple() ? > > A tuple seems to be a very basic list, so unless it's faster, what's > the > point of it? A list is mutable, whereas a tuple is immutable. That means that tuples, for instance, cannot be changed behind your back through other references, and that tuples can be used as dictionary keys where lists can't. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ 'Tis man's to fight, but Heaven's to give success. \__/ Homer REALpolitik / http://www.realpolitik.com/ Get your own customized newsfeed online in realtime ... for free! From richard at loudcloud.com Tue Mar 27 15:24:12 2001 From: richard at loudcloud.com (Richard Weth) Date: Tue, 27 Mar 2001 12:24:12 -0800 Subject: How does one set a value via win32com Message-ID: <3AC0F6EC.314B103D@loudcloud.com> All I have been banging away on an assignment that requires me to alter com plus settings (something one should never do normally). Here is the pertinent code fragment: import win32com.client import regex wcc = win32com.client adm = wcc.Dispatch( "COMAdmin.COMAdminCatalog" ) app = adm.GetCollection("Applications") app.Populate() for thingy in app: if regex.match("^Hello World.*",thingy.Name)!= -1: print "what we have here is ...",thingy.Name thingy.Value("Name") = thingy.Name + "t0" # <================ THE PROBLEM break else: print thingy.Name app.SaveChanges() Now the code in VBS thingy.Value("Name") = thingy.Name & "t0" works just fine but in python I get: >>> thingy.Value("Name") = "joemama" SyntaxError: can't assign to function call Is there a way to set that (and other) properties in Python via win32com. I really would like to learn as little VB as humanly possible and not write this in it's own VBScript. Any and all suggestions welcome! -- Sincerely Richard A. Weth Sr. Software Engineer LoudCloud, Inc richard at loudcloud.com From sheila at spamcop.net Sun Mar 18 15:12:26 2001 From: sheila at spamcop.net (Sheila King) Date: Sun, 18 Mar 2001 20:12:26 GMT Subject: Help with 500 error on cgi script References: <5739bt04e50ku01rn3dptgqch3l07p2cnf@4ax.com> <3AB492FE.4D963C32@stroeder.com> Message-ID: <7k5abt0vkd55rbbnrb818fprrc1nslu02g@4ax.com> On Sun, 18 Mar 2001 11:50:38 +0100, Michael Str?der wrote in comp.lang.python in article <3AB492FE.4D963C32 at stroeder.com>: :What keeps you away from correcting the syntax error mentiond in the :error traceback? I guess I was too tired to notice the missing " I went to bed shortly after I posted this. Thanks for your help. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From jafo at tummy.com Mon Mar 26 03:35:58 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Mon, 26 Mar 2001 01:35:58 -0700 Subject: ANNOUNCE: Distutils upload patch (PEP243) Message-ID: <20010326013558.A9281@tummy.com> I've got the server and client side of my PEP243 implementation (for uploading distributions made by distutils to the repository server) built. I've also created the code for distutils (2.1b2) to do the upload. For example: guin:python-netstring$ ./setup.py sdist --submit [...] gzip -f9 dist/python-netstring-1.14.tar removing 'python-netstring-1.14' (and everything under it) Submitting to repository server... sending dist/python-netstring-1.14.tar.gz... Succeeded. done. Currently, I have the repository server set up on our "public service" server "community.tummy.com". The files you will need are: ftp://ftp.tummy.com/pub/tummy/swalow/swalow-1.13/distutils-swalow.patch ftp://ftp.tummy.com/pub/tummy/swalow/swalow-1.13/swalowsupp.py See the README below for information on how to apply it. The server for handling the requests is also available at the above site, you'll need a few support modules as well (like the tar module for extraction of the PKG-INFO file). I need to update the repository server and client for PEP241, but that should be pretty straight-forward. Also, if anyone else wants to get copies of the data sent to my repository, I can certainly arrange that... Any comments? Sean ========================= swalow + Distutils README Sean Reifschneider ========================================== The file "distutils-swalow.patch" contains a patch against the 2.1b2 distutils which allows "setup.py sdist --submit" to upload the completed distribution file to the repository server. This will allow automatic or semi-automatic submissions of modules. To gain this functionality, apply the above patch, and copy "swalowsupp.py" into the main distutils package directory. If the environment variable "PYTHON_MODULE_SERVER" is set, that value overrides the default host for uploading the distribution to. -- That weapon will replace your tongue. You will learn to speak through it. And your poetry will now be written with blood. -- _Dead_Man_ Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From ben.hutchings at roundpoint.com Tue Mar 27 18:59:32 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: Tue, 27 Mar 2001 16:59:32 -0700 Subject: daemon app in win32 References: <99nk49$a2q$02$1@news.t-online.com> <99nsn3$q39$06$1@news.t-online.com> <99o2ge$9on$0@216.39.170.247> Message-ID: whisper at oz.net (Dave LeBlanc) writes: > On Mon, 26 Mar 2001 19:02:27 +0200, Michael Bauer > wrote: > > >Steve Purcell wrote: > > > >> Michael Bauer wrote: > >>> i am writing a daemon application that runs both under windows and unix. > >>> Since i am not very experienced in win32 - programming, i really would > >>> appreciate some hints how to register my app in win32 that i can do some > >>> cleanup-functions when windows is shut down. > >>> > >>> At the moment it is just a standard console application that simply gets > >>> killed when windows shuts down. The app does not have/need a GUI, it > >>> should just run in the background. > >> > >> > >> If you're using NT, take a look at the win32service API. I think it > >> provides hooks like SvcStop that Windows will call for you (if you ask it > >> nicely). > > > >Hmm, seems like this is only available under NT. Is there a more general > >way to accomplish this task independently of the underlying Windows-version? > > > >But maybe i should just get a life and write different wrappers for Win95, > >Win98, WinME, Win200, WinNT... :-( You should only need two. The Apache web server code for Windows might be instructive. > >still hoping... Mike > AFAIK, Every Windows app gets sent a WM message when it's about to be > terminated. If it has a GUI, then its top-level window will be sent WM_CLOSE. Console applications can register to receive such notifications in the same way they receive control-C notifications under *some* versions of Windows. > Most apps just let this fall through to the default > message processor (which you have to do anyway) without doiing > anything to clean up. You can add a message handler for this such that > the app can gracefully (make out it's will?) prepare to end it all. The DefWindowProc (default message handler) responds to WM_CLOSE by calling DestroyWindow() (which runs synchronously). The message handler for a top-level window should respond to this by calling PostQuitMessage(), which posts a WM_QUIT message to the calling thread's message queue. (The message handler for a dialog should do something else again.) Application frameworks like MFC should do this stuff for you. > Just make sure that in the end, it passes the message on to the > default message handler so that windows can do it's own cleanup of > your app. Actually, what's supposed to happen is that your main message loop calls GetMessage(), which finds a WM_QUIT message and returns 0; the loop then exits and your cleanup code runs on the way out. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From glennj at pcard31e.ca.nortel.com Thu Mar 8 11:24:49 2001 From: glennj at pcard31e.ca.nortel.com (Glenn W Jackman) Date: 8 Mar 2001 16:24:49 GMT Subject: grabbing return codes from os.system() call References: <%wFp6.9481$dL4.126404@vixen.cso.uiuc.edu> Message-ID: <988boh$kl5$1@bcarh8ab.ca.nortel.com> Pat Knight wrote: >Look at the process management section of the os module documentation in >Python. This contains functions to decode exit codes. > >Also, check the UNIX man pages for system, and the exec, exit and waitpid >system calls. You'll find details of the encoding, and probably find that you >can't have the large exit status values you want. > >If you're wanting to return strings or large numbers, start investigating >os.popen. Also have a look at the 'commands' module. -- Glenn From dnew at san.rr.com Thu Mar 15 13:15:41 2001 From: dnew at san.rr.com (Darren New) Date: Thu, 15 Mar 2001 18:15:41 GMT Subject: I come to praise .join, not to bury it... References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> <3AAF7E47.294617E1@sage.att.com> <98qeco02hn7@news1.newsguy.com> Message-ID: <3AB106CD.7D259EBC@san.rr.com> Alex Martelli wrote: > And then again, the _appearance_ that too much emphasis > was being placed on syntax-sugary issues kept me *AWAY* > from Python for longer than it should have Actually, what I found quite cool about Python is that the procedural syntax maps to OO semantics. I.e., in Smalltalk, everything looks like a method call, including "if". In Eiffel, everything that isn't a method call doesn't look like a method call, and vica versa. But in Python, the convenient and familiar "x = y[5:10]" maps to a real live method call you can override. Well, *I* thought it was neat. It lets you be OO where you want, and keeps it out of your face otherwise. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. From steinar.eriksen at fikse.net Tue Mar 20 11:28:45 2001 From: steinar.eriksen at fikse.net (Steinar Eriksen) Date: Tue, 20 Mar 2001 17:28:45 +0100 Subject: Jython and IDE/debugger Message-ID: <9980fp$sm0$1@news.ost.eltele.no> I would like to prototype my Java application in Jython, byt calling up Jython scripts from my Java classes. Whilst developing my Jython scripts; I am looking for some IDE or debugging tool to help me test my code. Anyone seen that available for Jython ? I know the Python IDE's are excellent, but since the libraries differ I suppose they are not applicable, Regards Steinar Eriksen From harisri at bigpond.com Thu Mar 29 06:47:05 2001 From: harisri at bigpond.com (Srihari Vijayaraghavan) Date: Thu, 29 Mar 2001 21:47:05 +1000 Subject: A newbie question on ftplib. Message-ID: <87Ew6.5454$45.29758@newsfeeds.bigpond.com> Hello, When I execute the following statement under Linux it uploads the binary file properly, but under Windows NT it creates only 512 bytes file at the ftp server. ftp.storbinary('STOR ' + xyz, open(xyz), 1024) I tried various values (1, 128, 256, 515) for the "number of blocks" parameter. I am using Python 2.0 on both Windows NT (Windows NT 4.0 / SP6a), and on Linux. (Linux 2.2.x and 2.4.x) Can I someone help me correcting if I am doing something wrong? Advance thanks, -- Hari. From mal at lemburg.com Wed Mar 14 13:46:20 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Wed, 14 Mar 2001 19:46:20 +0100 Subject: cursor.execute fails under mxODBC References: <3AABF77F.7B77D51@northwestern.edu> <3AAE59AE.630C148C@lemburg.com> <3AAEF113.E928A434@northwestern.edu> Message-ID: <3AAFBC7C.2A1CD536@lemburg.com> Louis Luangkesorn wrote: > > > Thank you for forwarding the messages. I have had numerous questions > > about this problem and will look into it later this week (just came > > back from the Python conference and am still fighting the jet lag). > > > > One thing I've noted about the problem reports is that all seem > > to use ActiveState Python 2.0. There may be an issue here, since > > the mxODBC (alas the egenix-commercial) package was compiled against > > the BeOpen Python 2.0 version which is available from python.org. > > > > Could you perhaps check whether you experience the same problems > > using BeOpen Python 2.0 ? > > > > Thanks, > > Marc. > > Marc > > No, that did not work. Here it is under the BeOpen-Python-2.0 After the > cursor.execute(...) the Python shell hangs. I've uploaded a new version of the Windows installer to: http://www.lemburg.com/files/python/egenix-mx-commercial-2.0.0.win32-py2.0.exe There seems to have been some build error during the release session which was introduced after the final tests. Please check whether you still get the indicated problems with the new build. One thing this teaches is that distutils should probably clear the build directory before rebuilding a package... I'll add that to my batch file. Thank you for looking into this and sorry for the trouble this has caused you. I hope the new build works for you as well (it does for me on Windows 9x -- don't have a W2k to test on). -- Marc > Louis > ---begin output--- > Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license" for more information. > IDLE 0.6 -- press F1 for help > >>> import mx.ODBC.Windows > >>> channel = mx.ODBC.Windows.Connect('sqltutor') > > >>> cursor = channel.cursor() > >>> cursor.execute('select FirstName, LastName, Address, City, State FROM > EmployeeAddressTable') > > ---end output--- > -- > K Louis Luangkesorn > lluang at northwestern.edu http://pubweb.nwu.edu/~kll560 PGP:0xF3E2D362 > > Whatsoever things are true, ... honest, ... just, ... pure, ... lovely, ... of > good report; if there be any virtue, and if there be any praise, think on > these things. > - motto - Northwestern University (Phil 4:8) -- Marc-Andre Lemburg ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Pages: http://www.lemburg.com/python/ From pae at dim.com Thu Mar 29 00:43:53 2001 From: pae at dim.com (Phil Earnhardt) Date: Wed, 28 Mar 2001 22:43:53 -0700 Subject: Collection interfaces References: <3a90fa97.0@news1.mweb.co.za> <99l6s8$gpu$1@nyheter.chalmers.se> Message-ID: On 28 Mar 2001 11:26:12 -0500, Lex Spoon wrote: >> >> Yea, use a Java applet instead. Guaranted not to fiddle with your >> >> DLL's :-) >> > >> >Oh great, so we get to fiddle with JAR's instead of DLL's! At least >> >JAR is easier to pronounce. :) >> >> Can you explain your comment, Lex? How is downloading and running >> applets from a jarfile have anything to do with fiddling with DLLs? > >Java programs tend to require you to have various extensions installed >as JAR files, just the same way that Windows EXE's tend to require >that you have various extensions installed as DLL's. Not really. A single Jar can be used to deploy your entire application. > I'd hazard that >JAR's are *worse* than DLL's -- DLL's at least *pretend* to do >something about versions. What you're talking about does not apply in the case where a single application is deployed as a single Jar. In that case, you don't really need version numbers -- you just overwrite the old jarfile with the new one. What you're talking about is the case where an API shared between multiple applications is implemented in a Jar. In that case, you're correct. As a practical matter, there is often less need for such APIs in Java because the core class libraries provide rich functionality. >Admittedly, I missed the "applet" part. Applets run with a standard >set of classes available, so they don't have that problem. (Instead, >they have the problem that *no* extensions are available. What exactly does that mean? >-Lex --phil From digitig at cix.co.uk Wed Mar 21 17:02:00 2001 From: digitig at cix.co.uk (Tim Rowe) Date: Wed, 21 Mar 2001 22:02 +0000 (GMT Standard Time) Subject: I'm sure there's a good reason! Message-ID: Can any of the assembled experts explain to me why: print r"\hello" is fine, but print r"hello\" isn't? In other words, why does the backslash escape quotes in a raw string? At one level I'm going to guess (without reading the spec) that it's because "that's what the spec says", but why? I thought the idea of raw strings was that they /didn't/ handle escapes! TIA, Tim From jwbnews at scandaroon.com Mon Mar 12 22:09:27 2001 From: jwbnews at scandaroon.com (John W. Baxter) Date: Mon, 12 Mar 2001 19:09:27 -0800 Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> Message-ID: In article , scarblac at pino.selwerd.nl (Remco Gerlich) wrote: > If you can avoid them, don't use floats. If you're working with money, count > cents instead (and use longs if you have numbers over a few hundred million > cents). Or perhaps mils, for a little extra room for tax computations. --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From tan at pobox.com Fri Mar 2 17:12:07 2001 From: tan at pobox.com (tan at pobox.com) Date: Fri, 2 Mar 2001 15:12:07 -0700 Subject: ImportError with extensions in python2.1 installed in home dir Message-ID: <20010302151207.A4418@tan.powerandlove.com> folks, I've installed python 2.1 in my home directory on the web hosting service I use (because they have no plans to move from python 1.5.2 to 2.x anytime soon, and I don't have access to /usr.) Installation succeeds, and modules that don't import extension modules work fine, but when I try to import an extension module, I get ImportError: No module named [name of extension module] If I uncomment the module in Modules/Setup, the module gets compiled into libpython2.1.a correctly, I don't get the error, and the module seems to work as it should. sys.path is correct (my python2.1 binary is looking for python2.1, plat-linux2, lib-tk, lib-dynload and site-packages in the right place.) The system is: Linux 2.0.36 i686 unknown Before I installed python 2.1, I installed a package (4Suite) that contains a few extension modules and tried using them with the python1.5 binary in /usr/bin. Same problem. The python1.5 binary can find and run extension modules in /usr/lib/python1.5/lib-dynload. But neither it nor the python2.1 binary I compiled can find extension modules in my home directory tree. I suppose whenever I add a package I could compile any extension modules it contains into libpython2.1.a, but I'd rather not. What am I missing? Please cc any replies to tan at pobox.com. thanks, Tom -- Tom Newman tan at pobox.com From dsh8290 at rit.edu Wed Mar 7 13:41:36 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 7 Mar 2001 13:41:36 -0500 Subject: I come to praise .join, not to bury it... In-Reply-To: <97rka002k9@news1.newsguy.com>; from aleaxit@yahoo.com on Sat, Mar 03, 2001 at 09:29:55PM +0100 References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> Message-ID: <20010307134135.A29445@harmony.cs.rit.edu> On Sat, Mar 03, 2001 at 09:29:55PM +0100, Alex Martelli wrote: | "Russell E. Owen" wrote in message | news:97p7iq$kk2$1 at nntp6.u.washington.edu... | [snip] | > However, I do agree that join is not intuitive. I believe the problem | > (at least for the way I look at it) is that join should be a list | > method, not a string method. I.e.: | > | > joined_string = ['a', 'b'].join(', ') | > | > makes a lot of sense to me. The current join string method does not. This was my opinion as well. | | This seems to be a widespread opinion, and I've already tried | to explain why my take on it differs, but that was a few months | ago, and apparently the current crop of discussants hasn't read | those discussions, so, let's give it one more spin. | | Python does not have multi-methods: it's a single-dispatch Where can I learn about multi-methods and their usefulness/applicability? | [snip] | | So, since we want general polymorphism on the joiner | object, but are quite content with polymorphism through | the standard sequence interface on the sequence object, | it is _just right_ that .join be a method on the joiner | object (e.g., a string) and that it take the sequence of | string to be joined as its argument. Ok, so instead of calling "join" a "string method" how about using the following Java-Python hybrid snippet to describe it : interface Joiner : abstract Object join( Sequence s ) class String implements Joiner : String join( Sequence s ) : """ oh, cool. I can mix and match the signatures sensibly without casting ;-) """ ... This does make sense to me. It looks logical and reasonable. You have convinced me Alex. Your English (and writing) classes have paid off ;-). You must have been a writer before computers took over ;-). -D PS. BTW I haven't finished reading this thread yet From rikbo716 at student.liu.se Sat Mar 24 01:31:53 2001 From: rikbo716 at student.liu.se (Rikard Bosnjakovic) Date: Sat, 24 Mar 2001 07:31:53 +0100 Subject: Install Python on Apache References: <99fph5$a2n$1@rex.ip-plus.net> Message-ID: <3ABC3F59.336D3296@student.liu.se> Sharp wrote: > (cgi.bin is set to the right place because php and perl do work) ... > [Fri Mar 23 15:54:50 2001] [error] [client xxx.xxx.xxx.xxx] Premature end of > script headers: c:/web/cgi-bin/python/python.exe What you need to do with CGI-scripts is to send headers before the actual CGI is run. The headers tell what kind of data the script will send. To send a header, you just need a "Content-type: \n" before the rest of the output. In your case, you are sending html-tags. Thus add a print "Content-type: text/html\n" as first CGI-statement. -- Rikard Bosnjakovic - http://a214.ryd.student.liu.se/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From wayne.izatt at _nospam_myself.com Tue Mar 6 02:37:21 2001 From: wayne.izatt at _nospam_myself.com (Wayne Izatt) Date: Tue, 06 Mar 2001 07:37:21 GMT Subject: iis and python References: Message-ID: > In order to use python it would have to entail cgi or ASP. Is this correct. > Or is there an alternative. I dont know if Zope is the right thing. I hate > DTML. Zope is very powerful, and if you want to you can write almost all your code in Python. DTML is there for presentation, not for logic, and should only be used for simple processing. > Is using python in ASP a pain in the but? Am I going to have to learn a > whole technology just to implelment python well into it? No, its fairly straighforward. However, before you go the ASP route, take the time to examine Webware. Webware gives you ASP with Python, as well as Python Server Pages and servlets - very powerful, easy to use, and pure Python. > I hear troubleshooting ASP pages is not fun. Correct. > The only time I have used iis is with php and it was a total snap. Painless. PHP is fine, but I've had the pleasure of debugging someone else's massive 'one-script-wonder', and I remembered what my misgivings about Perl-based languages were. Don't flame me, PHPer's, I still like the language! cheers From wcanopy at covad.net Mon Mar 12 18:17:49 2001 From: wcanopy at covad.net (Wiwih Gunadi) Date: Mon, 12 Mar 2001 17:17:49 -0600 Subject: wxPython UI refresh Message-ID: <98jku0$ifi$1@newstest.laserlink.net> Hi, I used the ActiveXWrapper_IE.py to load an Excel spreadsheet. The problem is whenever the spreadsheet is loaded, the screen doesn't update and I have to minimize the window and restore it again (or do other things such as switching the active notebook page and back again) Strangely, this doesn't happen when I'm loading ordinary html file, so I suppose this is IE's quirk, does anybody know how to fix this? I've tried Refresh(), Validate, wxYield() on the OnSize event handler to no avail. Appreciate any help! BTW, Excel is not an ActiveX control is it? i.e. it's impossible to "wrap" Excel like IE with the activexwrapper, right? -Will-- From Michael.Husmann at teleatlas.com Thu Mar 15 08:28:47 2001 From: Michael.Husmann at teleatlas.com (Michael Husmann) Date: Thu, 15 Mar 2001 14:28:47 +0100 Subject: Umlaut and Tkinter Message-ID: <3AB0C38F.34218EEB@teleatlas.com> typing in idle.py using Python 2.1b1: >>> print "??" results in an: UnicodeError: ASCII encoding error: ordinal not in range(128) Is there someone who can help me. Michael From syver at NOSPAMcyberwatcher.com Tue Mar 27 17:12:03 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Wed, 28 Mar 2001 00:12:03 +0200 Subject: Newbie question : string processing with RE References: Message-ID: <99r3br$s06$1@troll.powertech.no> wrote in message news:mailman.985707278.14550.python-list at python.org... >But when I try to read it again, it acts as if the index of > a file had to be "rewinded" (e.g. as would do a "seek" on a "true" file). Yes, that is correct, it is a file object (not a disk file in this case) and it behaves like a file. >I > thought that f3.read was to be considered as a string. Yes, and no, f3.read() returns a string that is the whole file from the point in the file where you are to the end. But this means that the next time you call read on the file it will be at the end and return the empty string. If you want to search the string twice you'll have to keep the string returned by read, like this: content = f3.read() Then you can use content as many times as you like. From sholden at holdenweb.com Thu Mar 22 22:24:55 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 22 Mar 2001 22:24:55 -0500 Subject: Good Editor? References: <3ab9a32b$1_1@news2.one.net> <3AB9FAC9.97EA420E@student.liu.se> <99d780$l2g$1@laurel.tc.umn.edu> <3ABA20F7.AB71D3B4@student.liu.se> <98qu6.166420$Z8.35271037@typhoon.southeast.rr.com> Message-ID: "Ken Seehof" wrote in message news:mailman.985286969.17591.python-list at python.org... > Yeah, but I want to know: does it actually work? > > "Rikard Bosnjakovic" > > > Anyone sending unwanted advertising e-mail to my address will be > > > charged $250 for network traffic and computing time. By extracting my > > > address from this message or its header, you agree to these terms. > > > > love it...Love It...LOVE IT! > > > > Don > ---------------------------------------------------- > Copyright (c) 2001 by Ken Seehof > This document may not be distributed, copied, > duplicated, or replicated in any form without > express written permission by Ken Seehof. > Express permission is hereby granted. > kens at neuralintegrator.com > ---------------------------------------------------- > Now that's what I call an open source legal threat. regards Steve > > From tjreedy at udel.edu Wed Mar 28 00:51:36 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 28 Mar 2001 00:51:36 -0500 Subject: Newbie question : string processing with RE References: Message-ID: <99rue5$brh$1@news.udel.edu> I believe the indicated changes will work. > f3 = urllib.urlopen ("www.such-a-nice-webpage.com/index.html", encoded_data) f3 = urllib.urlopen ("www.such-a-nice-webpage.com/index.html", encoded_data).read() > p=re.compile("window.open") > q=re.compile("document.location =" ) > print p,'\n',q > t1=p.search(f3.read()) > t2=q.search(f3.read()) t1=p.search(f3) t2=q.search(f3) From cobrien at Radix.Net Fri Mar 16 10:25:21 2001 From: cobrien at Radix.Net (Cary O'Brien) Date: 16 Mar 2001 10:25:21 -0500 Subject: Python style questions Message-ID: <98tb91$9t9$1@saltmine.radix.net> I have a couple of style questons regarding larger Python programs. I'd be interested in comments. 1. I have a class that handles communications with a remote service. It is fairly complex, having to deal with timeouts and retransmits and the like. The class definition is getting bigger than I'd like. Should I a. Live with it b. Factor into mix-in classes c. Define some methods outside of the class definition. d. ??? 2. One thing I've done is to define classes used only by another class inside that class. For example, if a class A needs to keep track of a bunch of "things", then the class definition for the "things" is inside of the class definition of A. This is a. SOP b. Brilliant c. Idiotic 3. I really miss not having a "switch" or "case" statement. Sniff. 4. I need to change things like "88aa99bb" (hex string) into integers. Should I a. use expr("0x"+s) b. not use such things c. ??? That's it for now. I'm sure I'll have more questions as time goes on. I guess what I'm really interested is how to create readable, maintainable, code for complex classes. -- cary From tm at kernelconsult.com Wed Mar 28 22:01:48 2001 From: tm at kernelconsult.com (TM) Date: Thu, 29 Mar 2001 03:01:48 GMT Subject: Which Python version is better on Win32 Message-ID: <20010329.3014838@mis.configured.host> Hi, I've seen recently that yhere were several releases of Python for the MS Windows platform: ActivePython is one of them there's also PythonWin which is not branded, beOpenPython and maybe others. Which one would you advise me to use and why? Thanks in advance TM From jmg at ecs.soton.ac.uk Wed Mar 28 13:12:34 2001 From: jmg at ecs.soton.ac.uk (Jacek Generowicz) Date: 28 Mar 2001 19:12:34 +0100 Subject: Boost documentation. References: Message-ID: Jacek Generowicz writes: > Well, I've managed to get an attempt past the compiler now, so I'll > post it here for a critique. > > It provides one function called `hmm', which takes a tuple (of > integers), and should print out those integers. Unfortunately it > thinks all the integers are zero (though it does get the correct > number of them). OK, i was not initialized to zero here: > for ( int i; i When I try to do something similar with lists rather than tuples, the > get() method appears to be unavailable. I'd still be interested in knowing how to do it with lists. Jacek From tim.one at home.com Sat Mar 24 16:25:10 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 24 Mar 2001 16:25:10 -0500 Subject: [Python-Dev] Anyone using weakrefs? In-Reply-To: <018e01c0b456$6710b830$e46940d5@hagrid> Message-ID: [Fred Drake] > Is anyone out there playing with the weak references support yet? > I'd *really* appreciate receiving a short snippet of non-contrived > code that makes use of weak references to use in the documentation. Alas, it's kinda like asking for a "short snippet" illustrating coroutines: the need isn't apparent in tiny examples. Still, I've been happily playing w/ this little module: import weakref id2obj_dict = weakref.mapping() def remember(obj): id2obj_dict[id(obj)] = obj def id2obj(id): return id2obj_dict.get(id, None) In various introspective tools (like Cyclops.py), there's a need to keep track of "other peoples'" class instances. Before weakrefs, it was impossible to do this without keeping the instances artificially alive. Now I can pass arbitrary instances to remember() above, then just use their ids internally. This doesn't keep the objects alive, but id2obj() above can still get the objects back so long as they're still alive. I suppose I could work with weakrefs directly instead of indirecting through id()s, but most code of this nature I have is already mucking w/ ids anyway (ints are small, fast, cheap and make great dict keys themselves). From ws-news at gmx.at Wed Mar 7 12:59:55 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Wed, 7 Mar 2001 18:59:55 +0100 Subject: Can anyone recomend a good intoduction to C... References: <983896344.701456@newsmaster-04.atnet.at> <983911749.217622@newsmaster-04.atnet.at> <983916572.286918@newsmaster-04.atnet.at> <9852b8015jm@news1.newsguy.com> <983967284.246700@newsmaster-04.atnet.at> <985oev0216v@news1.newsguy.com> Message-ID: <983988272.976222@newsmaster-04.atnet.at> Thank you for your really thorough reply I would agree that inspecting a C++ compiler to every extent is impossible. But I think so are most other languages, apart from extremely simply ones like assembler. Do you think one can inspect a Python interpreter and make sure there is no, not a single, error or security problem in it? I would never expect that possible... nor for C... and of course not for C++ I do not think that a review (this is basically what human expecting source code means) can prove code to be error free. Not for any language, otherwise there would not be errors in production software. The one way I could imagine to test an application for safety is to test all possible data on the smallest part in software. But of course this is not practically manageable for normal size application. How can you be sure the CPU is doing correct calculation? Think about that Pentium FDIV bug years ago... You can use a parallel executing different platform and compare each and every result. This does however not support recovery because you do not know which one is correct. That is not a way, because it would not be safe either. So you can use three different architectures (and make sure that one is not somehow copied/related from an other) and do a majority decision. The alternative is to inspect the CPU (and other hardware) the same. What I think is that there is no absolute safety. You can test as much as you like and review as much as you like. Never can you be completely sure that there can not be a problem. Maybe that sounds pessimistic, but this is what I think. Safety inspection just greatly reduces the number of problems that could arise by doing much more thorough tests but in the end is limited as well. >From the educational standpoint it does not matter if the standard library uses templates or not. the average user can use it in a cookbook fashion and does not need to know how the machanics work. If you need to inspect that as well, yes this is hard. But if you need the full flexibility you'll end up with code the same complex than the original. If the application only needs more trivial containers and I cannot afford using the template based standard ones, I can still resort to writing an simpler one myself. So in the end I think it is an issue, but probably not for the question the original poster had. There are other reasons as well, like customers that insist on plain C because they do not have people experienced in C++. Again, I really enjoyed your thorough reply regards werner From chris.gonnerman at usa.net Thu Mar 1 23:26:46 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Thu, 1 Mar 2001 22:26:46 -0600 Subject: compile() source code from a string References: <3a9ee600.391990@News.CIS.DFN.DE> Message-ID: <008a01c0a2d1$05507f40$a100000a@local> There IS a syntax error in your code. To wit: ----- Original Message ----- From: "Costas Menico" Subject: compile() source code from a string [ vicious hack ] > However I would like to execute the following example from string > variable: > > if x == 1: > print "1" > print "2" > print "3" > elif x = 2: ERROR ^^^ Should be: elif x == 2: > print 'A' > print 'B' > print 'C' > > print 1+2 > [ brutal hack ] Whenever you do something fancy like this and it doesn't work, you should build a stripped example and test that. Your code doesn't work in a string, but hey, it doesn't work as a normal module file either. I don't intend to be mean about it; I've been there too. Attached is an example using your sample, corrected, which works for me. -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: testcompile.py URL: From syver at NOSPAMcyberwatcher.com Wed Mar 21 08:56:49 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Wed, 21 Mar 2001 14:56:49 +0100 Subject: Html entities Message-ID: Is there an easy way to convert ISO Latin-1 characters that are above 127 ascii to their HTML, XML entity form? From ransen_spam_me_not at nemo.it Mon Mar 5 06:47:28 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Mon, 05 Mar 2001 11:47:28 GMT Subject: tokenizer.c crashes in 2.1b1 References: <3aa34d5c.1284101@news.newsguy.com> Message-ID: <3aa37c7e.74688@news.newsguy.com> If anyone more expert than I am wants to look at the program which crashes I have a VC6 workspace, mostly empty except for calls to the Python API...email me removing the spam breaker part... -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From claird at starbase.neosoft.com Fri Mar 23 09:59:33 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 23 Mar 2001 08:59:33 -0600 Subject: email address verification References: <99d5qi$95l$1@solaria.cc.gatech.edu> <99fjv8$bhf$1@solaria.cc.gatech.edu> Message-ID: In article <99fjv8$bhf$1 at solaria.cc.gatech.edu>, Holland King wrote: . . . >despite the way it sounds i am not trying to set up a mass mailer program >or trying to spam people. i am trying to set my departments system so >that when an account expires it will parse the .forward file and use >addresses in there to make an alias. however, we don't like the idea of >sending mail to a list or to a non-existant address for obvious reason >(especially consider how large we are). . . . I don't understand your description. In general, comp.mail.misc might be a more productive place to ask these questions than c.l.p. Are you asking about verifying e-mail addresses *on hosts you control*? That's entirely different! Well, it's significantly different, at least. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From sheila at spamcop.net Sun Mar 18 21:09:01 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 19 Mar 2001 02:09:01 GMT Subject: Get Python2 Win32 working with Apache References: Message-ID: On Sun, 18 Mar 2001 17:33:15 -0500, "Ryan" wrote in comp.lang.python in article : :Any hints? http://www.aota.net/ubb/Forum14/HTML/000218-1.html -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From sholden at holdenweb.com Sun Mar 4 12:41:55 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 4 Mar 2001 12:41:55 -0500 Subject: Subclassing builtin types References: Message-ID: "Daniel Klein" wrote in message news:i6u4atslg4euv732pvaujk6u036kemcidf at 4ax.com... > One of the classes I have to write is merely a wrapper around a 'list' object. > A very abreviated example, > > class MyParams: > def __init__(self): > self.parameters = [] > def append(self, object): > self.parameters.append(object) > def insert(self, i, object): > self.parameters.insert(i, object) > def del(self, i): > del self.parameters[i] > etc, etc... > > This would allow me to do things like > > p = MyParams() > p.append('foo') > > Since I know you are going to ask :-), there are two main reasons I need to do > this: > > 1) I need to ensure that a certain 'capacity' is not exceeded. I will probably > have class variable which is checked in all methods which add objects to > 'parameters' and then raise an exception if 'capacity' is exceeded. > > 2) I can only allow certain types of objects to be added to the list, so these > too will be checked where necessary and appropriate exceptions raised. > > What I would _REALLY_ like to do is subclass list something like > > class MyParams(List): > > so that I can inherit all of the list methods and only override the ones I need > to. In Smalltalk this would be accomplished simply with > > OrderedCollection subclass: #MyParams > > I had actually thought of creating a generic List class that could be reused in > cases like this. > > So two questions: > > 1) Are wrapper classes for the builtin types a feasible (and pythonic) thing to > do? > Yes and yes: so feasible the library includes a UserList class which provides esxactly what you seem to want: it wraps a list inside a class so you can inherit from it! > 2) Are there another ways to accomplish what I'm trying to do here without > creating my own class hierarchy? > > Thanks for any and all help, you people have been a wonderful lot to deal with > during this new-language learning period. > > Daniel Klein > Portland OR USA > Delegation is also a useful trick. I've just published an ftpStream class which delegates most of its actions to an ftplib.FTP object by providing its own __getattr__() method. Follow the public-domain Python link from http://www.holdenweb.com/ regards Steve From parkw at better.net Thu Mar 1 15:05:58 2001 From: parkw at better.net (William Park) Date: Thu, 1 Mar 2001 15:05:58 -0500 Subject: [Q] Question from Python tutorial In-Reply-To: ; from ylee12@uiuc.edu on Thu, Mar 01, 2001 at 01:38:02PM -0600 References: <3A9EA472.F15AF847@cybermesa.com> Message-ID: <20010301150558.A1284@better.net> On Thu, Mar 01, 2001 at 01:38:02PM -0600, Young-Jin Lee wrote: > > > class MyClass: > > > "A simple example class" > > > i = 12345 > > > def f( x ): > > > return 'hello world' > > > > > > x = MyClass() > > > > > > x.counter = 1 > > > while x.counter < 10: > > > x.counter = x.counter * 2 > > > print x.counter > > > ^ > > > SyntaxError: invalid syntax > > > > > > There is no typo, I have no idea of where this SyntaxError came from. > > > > > > Thanks in advance. Any comment would be greatly appreciated. On my computer, it goes something like this: >>> x.counter = 1 >>> while x.counter < 10: ... x.counter = x.counter * 2 ... >>> print x.counter 16 ---William Park, Open Geometry Consulting, Linux/Python, 8 CPUs. From scarblac at pino.selwerd.nl Mon Mar 19 19:43:11 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 20 Mar 2001 00:43:11 GMT Subject: (no subject) References: Message-ID: Brad Jennings wrote in comp.lang.python: > I want to execute an executable binary as thought through the Command-Line. > Python provides some powerful methods in the os package that use very quirky > syntax. The two methods I've used are "startfile()" and "execv()". Neither > have performed the action I need. > > I'm just trying to execute "ss.exe" and pass it some args but the method > syntax is laborious and prone to mistakes. Do anyone know of a better way > to call an executable from a python script without using a function to do > it? Without using a function it's not possible. But what's the problem with using os.system ?! import os os.system("ss.exe some args") -- Remco Gerlich From aleaxit at yahoo.com Mon Mar 12 11:56:33 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 12 Mar 2001 17:56:33 +0100 Subject: gah! I hate the new string syntax References: <97sudi01i26@news1.newsguy.com> <98elrk$li8$1@nntp.Stanford.EDU> <98fc070thh@news1.newsguy.com> <98iqo2$56o$1@nntp.Stanford.EDU> Message-ID: <98iv3s01sc2@news2.newsguy.com> "Amit Patel" wrote in message news:98iqo2$56o$1 at nntp.Stanford.EDU... > Alex Martelli wrote: > | "Amit Patel" wrote in message > | news:98elrk$li8$1 at nntp.Stanford.EDU... > | [snip] > | > What I mean to say is that I cannot write new methods on strings. So > | > | Perfectly true, just as you cannot on dictionaries, lists, tuples, > | file objects, and so on. Only classes and extension-classes > | are extensible (by inheritance and overriding), not types. > > Even if strings were a class, and I could extend it, it is NOT the > thing to do to add new functionality like capitalize(). Suppose If you wanted to MODIFY the functionality of the hypothetical string class, so the new functionality applied to all objects of the class, then you would indeed have to alter the class-object -- just as you would have to alter the module-object to alter the functionality of that module, in an exact parallel. > The advantage of method functions like string.capitalize is that they > do not require me to change something I can't change (the string > type). A class-object is just as alterable as a module-object -- neither more, nor less. (Whether it's _wise_ to do so, of course, is a different issue -- but the ability is there in either case). Type-objects are different, but there's no inherent reasons why it should be any harder to perform someobj.capitalize = mycapfun for someobj being a type-object, than for its being a module -- it can be seen as an accident of current implementation if only one case out of the two possibilities is allowed. > I can write capitalize(x) when x is a string. I can't write > x.capitalize() when x is a string. But you would probably be writing string.capitalize in the former case anyway -- unless you're advocating a "from string import *"? So, to add (e.g.) a capitalize function to the string module, you'd have to set string.capitalize rather than inject the 'capitalize' name into your global (or local) namespace in other (dirtier?) ways. > Defining methods is like running things as root. Yes, you sometimes > need to do it, but it's best to limit yourself to only those things > that need superuser access. Run as much as you can as non-root. And > IMO that goes for methods and functions too -- string type methods are > "root" (where "root" = "Guido & pals") and have access to the > internals of a string, whereas functions on strings are user-level and > go through the abstractions. Focusing on the polymorphism needs, I see the issue in the mirror way from you: it's a _weakness_ (of Python and most other languages) that I can't add methods 'post-facto, from the outside' to existing objects -- it impedes the most natural, elegant, typeswitch-free way to add functionality. If you pursued your "capitalize as a function" idea, you'd be unable to properly capitalize Unicode (e.g.) without a typeswitch -- a very unadvisable construct. Something like Haskell's typeclasses, on the other hand, would provide the best of both worlds (multimethods would be an even more powerful alternative) -- let the compiler/interpreter/runtime do the dispatching, and just code in the most natural, polymorphic way. If you have to work with both existing and new objects, some of which provide a method while others don't, then a wrapper function (or class, &c) is indeed best -- and inside it you can do the weakest (safest, least-unadvisable) form of typeswitching, e.g.: def capitalize(self): try: return self.capitalize() except AttributeError: pass # proceed implementing the default way of # capitalization If you can perform your capitalization-default more effectively in a mixin class (this is often true, since keeping state can be quite helpful), then extend this to: def capitalize(self): try: return self.capitalize() except AttributeError: pass # if it's a class we can add our mixin once & for all: try: self.__class__.__bases__.append(MixinCapitalizer) except AttributeError: pass else: # good, we were able to add it, so init & use it: MixinCapitalizer.__init__(self) return self.capitalize() # proceed implementing the default way of # capitalization as a function, sigh The ability to perform such shehanigans does argue for using functions _from client-code that needs to be very robust in dealing with all sorts of weird objects including legacy ones_, but it does NOT argue against adding suitable methods on the implementation side -- anything BUT, in fact... where the method is right on the object we get the fastest path through the wrapper-function, even in client-code that needs to go through such wrappers for legacy-support reasons. Alex From Sibylle.Koczian at Bibliothek.Uni-Augsburg.de Fri Mar 23 05:02:59 2001 From: Sibylle.Koczian at Bibliothek.Uni-Augsburg.de (Sibylle Koczian) Date: Fri, 23 Mar 2001 11:02:59 +0100 Subject: win32net, documentation References: <3AB8CD29.C69CC1E2@Bibliothek.Uni-Augsburg.de> <3AB949C4.1040501@ActiveState.com> Message-ID: <3ABB1F53.EEEEB8C1@Bibliothek.Uni-Augsburg.de> Thank you - I've got that to work after some trial and error. Mark Hammond wrote: > > > I want to do the Python equivalent of > > net use k: \\server\share > > > I suggest you use win32wnet - that will work on Win9x too. > That's not an issue for me - are there other advantages? It seems a little simpler, though - and I _did_ get it to work, which should be enough, but I'm curious (and there isn't anything in your book about it, as far as I remember?). > Look in win32\demos\win32wnet for some examples... > Only one - which got me started, anyway. Thank you again, Sibylle -- ---- Dr. Sibylle Koczian Universitaetsbibliothek , Abt. Naturwiss. D-86135 Augsburg Tel.: (0821) 598-2400, Fax : (0821) 598-2410 e-mail : Sibylle.Koczian at Bibliothek.Uni-Augsburg.DE From kens at sightreader.com Tue Mar 13 05:54:45 2001 From: kens at sightreader.com (Ken Seehof) Date: Tue, 13 Mar 2001 02:54:45 -0800 Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> <20010312170356.B3513@better.net> Message-ID: <009301c0abac$05352ef0$a325fea9@his> You're not alone, but there is a good explanation for what you see, and it is not generally considered a bug in python, though some would like to change python to give more visually correct results. This is also true of many other programming languages, such as C and C++. The reason is that the computer stores your number in binary. Turns out that 10.55 (or 0.55) does not have an exact representation in binary, therefore you get a "rounding error". To give you an idea of what I am talking about, consider that in decimal, you can't represent 1/3 exactly (you get 0.33333333...). Let's take a simpler example: >>> 0.2 0.20000000000000001 What happened here? Well 0.2 = 1/5, which works fine in decimal. When you convert that to binary, it looks like this: 0.2 (decimal) = 0.0011001100110011001100110011001100110011001100110011... (binary). The reason your desk calculator gets the right result is that it represents numbers in decimal internally. If python did the same, it would run significantly slower than it does because most computers prefer to do math in binary. However, switching to decimal floating point is a proposed change for a future version of python, along with making 1/2 = 0.5 (or some other equivalent answer (right now, 1 / 2 = 0 (try it) ) ) and other stuff. Keep in mind that any floating point system will have rounding errors. Doing math in decimal merely hides the wierd unexpected ones like the one you found (at the cost of slowing things down). Some people propose that python keeps fractional numbers in rational form (i.e. A/B). This would completely solve the rounding error problem (for division and multiplication, that is), but would make python really really really slow. There are various other compromises but there is unfortunately no good solution to this dilemma at all. These numerical issues cause endless debates among python people. As you will see, there will probably be a stream of endless innane babble in response to this message. I think there's a SIG or a PEP or something (couldn't find it) where this debate is supposed to be instead of here. ----- Original Message ----- From: "William Park" To: Cc: Sent: Monday, March 12, 2001 2:03 PM Subject: Re: This math scares me > On Mon, Mar 12, 2001 at 09:34:58PM +0000, costas at springmail.com wrote: > > Ok, I can see maybe division having problems. But why does addition of > > the two numbers below: > > > > 5.01+5.54 > > > > give me this? > > > > 10.550000000000001 > > It's called 'Round-off error'. > > ---William Park, Open Geometry Consulting, Linux/Python, 8 CPUs. > > -- > http://mail.python.org/mailman/listinfo/python-list > From francois_forest at yahoo.fr Fri Mar 16 09:00:03 2001 From: francois_forest at yahoo.fr (Francois Forest) Date: Fri, 16 Mar 2001 14:00:03 GMT Subject: Python with the VBA recording capabilities Message-ID: <3AB21C3E.95DAB3D2@yahoo.fr> I compared Python to VBA (not for their syntax): VBA gives the programming capability to Applications Python gives the programming capability at the OS level (as shell scripts traditionally did ) VBA has the RECORD capability that transform any sequence of mouse clics into a program that can be edited and then adapted. This recording capability is amazingly efficient. Can we imagine to add this feature to any current GUI (kde and others) ? From fredrik at pythonware.com Thu Mar 29 08:29:20 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 29 Mar 2001 13:29:20 GMT Subject: Defining class files References: <3ac33343$0$12248$ed9e5944@reading.news.pipex.net> Message-ID: Neil Benn wrote: > However, I then tried to write the class as an external text file, > using:- > > class YourClass: > "A simple example class" > i = 12345 > def f(x): > return 'hello world' that's a module containing a class, not a "class file" as you noticed, "import YourClass" gives you the module. to get at the class itself, refer to it as "YourClass.YourClass" (the YourClass object in the YourClass module). you can also write "from YourClass import YourClass". > The text file is saved as YourClass.py - is this the problem, should > class files have different terminaters in their filename?? there are no such thing as a "class file" in Python. just modules... for more info, see chapter 6 in the tutorial: http://www.python.org/doc/current/tut/node8.html Cheers /F From phrxy at csv.warwick.ac.uk Thu Mar 15 19:05:02 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Fri, 16 Mar 2001 00:05:02 +0000 Subject: tiny extension crashes In-Reply-To: References: Message-ID: On Thu, 15 Mar 2001, Greg Jorgensen wrote: > You have an uninitialized pointer, intp, in your iround() function. Do this: [...] Oops, thanks. What I still don't get, though, is why it was crashing even when only the hcf() function was being imported and called by my (pure) Python code. Surely if it doesn't get called, the uninitialised pointer can't scribble over anything? > Since you posted your source code, let me suggest an alternative > implementation of array_max: > > static long array_max(PyArrayObject *array, int absolute) > { > long *a = array->data; > long stride = array->strides[0]; > long max = 0; > > if (absolute) { > for (i = 0; i < array->dimensions[0]; i++) { > if (labs(*a) > max) > max = labs(*a); > a += stride; > } > } > else { > for (i = 0; i < array->dimensions[0]; i++) { > if (*a > max) > max = *a; > a += stride; > } > } > return max; > } > > The test on absolute only happens once, not at every loop iteration. (I > would make this two functions, one that works on the actual values and one > that works on the absolute values.) Yeah, so would I, but my C is so rusty that I couldn't be bothered with the effort (not that my knowledge of C was ever clean and shiny). :) That's what these interpreted languages do to you -- I'm spoilt. > The array->data[] index calculation is > changed to pointer addition. And I used the labs() function rather than the > unnecessary floating-point fabs() version. And I changed max to a long, and > made the function return a long. All good tips, thanks. (Although as it happens, in this particular case, I had intended to replace that function with the built-in Numeric max(), when I had got round to looking up how to call Python functions from C. In fact I'll probably scrap all of these functions eventually -- they're only there because they were the simplest functions I had lying around, and I knew I'd certainly get tangled up in C if I picked something more complicated for my first extension.) John From thomas.heller at ion-tof.com Fri Mar 30 14:31:47 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Fri, 30 Mar 2001 21:31:47 +0200 Subject: Application distribution with python References: Message-ID: <9a2mv5$3995a$1@ID-59885.news.dfncis.de> > > > > Can any one knows what are files to ship to client machine or > > list of distribution files. > > http://starship.python.net/crew/gmcm/distribute.html > > and http://starship.python.net/crew/theller/py2exe/ From loewis at informatik.hu-berlin.de Sun Mar 11 15:55:33 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 11 Mar 2001 21:55:33 +0100 Subject: Python 2.0 and Tcl/Tk 8.3.2? References: <3A997A0A.67CA82E1@UTS.Itron.com> <3AAAFFE5.15A7A878@python.net> Message-ID: "Thomas A. Bryan" writes: > If Python works as well with Tcl/Tk 8.3 as it does with Tcl/Tk 8.0, > I wonder why the default Python-2.0 still defaults to the older > version. Does this line get updated to the latest version of Tcl/Tk > that was known to work at the time of release, or is it frozen at > 8.0 for the time being? > > From Modules/Setup.in: > # *** Uncomment and edit to reflect your Tcl/Tk versions: > # -ltk8.0 -ltcl8.0 \ Well, there is a comment in the beginning of the line - if you remove the comment, you have to adjust the line; this is what you do with all other lines as well, don't you? The Linux RPM of Python 2.0 required Tcl 8.0 since that is what was available on Redhat 6; most likely, this is also the reason that the Setup refers to 8.0 'by default' (if you look carefully, you'll see that 'by default', tkinter is not built at all). In any case, Python 2.1 will use distutils for building _tkinter; it will search for Tcl 8.4, 8.3, 8.2, 8.1, 8.0 in that order. Regards, Martn From MarkH at ActiveState.com Wed Mar 14 17:52:01 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 14 Mar 2001 22:52:01 GMT Subject: [Q]: How can I get the logged in users username on Win32? References: <3aaf7ab4.3152221@news.is.co.za> Message-ID: <3AAFF55A.9090107@ActiveState.com> nomad wrote: > Howzit, > > After searching through the Python Docs, I found that on Un*x I could > use getpass.getuser(), but there is no equivalent for the Win32 > platform. > > In other words, how can I get the username in Windows? > > As a side note, how can I enable Windows Scripting Host support for > python - there is mention of python in the original WSH docs - and if > I can use python scripts in WSH how would I call the built-in > Wscript. > > TIA > > nomad win32api.GetUserName() For WSH examples, check out the win32com\test directory. Mark. From shaleh at valinux.com Thu Mar 15 15:19:11 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Thu, 15 Mar 2001 12:19:11 -0800 (PST) Subject: Dynamic append in a dictionnary object ... In-Reply-To: <3ab11de3$0$389$446d705c@news.skynet.be> Message-ID: On 15-Mar-2001 Furax wrote: > Hi, > I'm pretty new to Python. > I cannot figure out, reading the documentation, how I can dynamicaly add a > new pair in a dictionnary ? > if not foo.has_key(key): foo[key] = value From mwh21 at cam.ac.uk Fri Mar 2 08:00:18 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: Fri, 2 Mar 2001 13:00:18 +0000 (GMT) Subject: python-dev summary 2001-02-15 - 2001-03-01 Message-ID: Thanks for all the positive feedback for the last summary! This is a summary of traffic on the python-dev mailing list between Feb 15 and Feb 28 (inclusive) 2001. It is intended to inform the wider Python community of ongoing developments. To comment, just post to python-list at python.org or comp.lang.python in the usual way. Give your posting a meaningful subject line, and if it's about a PEP, include the PEP number (e.g. Subject: PEP 201 - Lockstep iteration) All python-dev members are interested in seeing ideas discussed by the community, so don't hesitate to take a stance on a PEP if you have an opinion. This is the second python-dev summary written by Michael Hudson. Previous summaries were written by Andrew Kuchling and can be found at: New summaries will appear at: and will continue to be archived at Andrew's site. Posting distribution (with apologies to mbm) Number of articles in summary: 400 | ]|[ | ]|[ 60 | ]|[ | ]|[ | ]|[ | ]|[ ]|[ | ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ 40 | ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ 20 | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ 0 +-033-037-002-008-006-021-071-037-051-012-002-021-054-045 Thu 15| Sat 17| Mon 19| Wed 21| Fri 23| Sun 25| Tue 27| Fri 16 Sun 18 Tue 20 Thu 22 Sat 24 Mon 26 Wed 28 A slightly quieter week on python-dev. As you can see, most Python developers are too well-adjusted to post much on weekends. Or Mondays. There was a lot of traffic on the bugs, patches and checkins lists in preparation for the upcoming 2.1b1 release. * backwards incompatibility * Most of the posts in the large spike in the middle of the posting distribution were on the subject of backward compatibility. On of the unexpected (by those of us that hadn't thought too hard about it) consequences of nested scopes was that some code using the dreaded "from-module-import-*" code inside functions became ambiguous, and the plan was to ban such code in Python 2.1. This provoked a storm of protest from many quarters, including python-dev and comp.lang.python. If you really want to read all of this, start here: However, as you will know if you read comp.lang.python, PythonLabs took note, and in: Guido announced that the new nested scopes behaviour would be opt-in in 2.1, but code that will break in python 2.2 when nested scopes become the default will produce a warning in 2.1. To get the new behaviour in a module, one will need to put from __future__ import nested_scopes at the top of the module. It is possible this gimmick will be used to introduce further backwards compatible features in the future. * obmalloc * After some more discussion, including Neil Schemenauer pointing out that obmalloc might enable him to make the cycle GC faster, obmalloc was finally checked in. There's a second patch from Vladimir Marangoz implementing a memory profiler. (sorry for the long line) Opinion was muted about this; as Neil summed up in: noone cares enough to put the time into it and review this patch. Sufficiently violently wielded opnions may swing the day... * pydoc * Ka-Ping Yee checked in his amazing pydoc. pydoc was described in It gives command line and web browser access to Python's documentation, and will be installed as a separate script in 2.1. * other stuff * It is believed that the case-sensitive import issues mentioned in the last summary have been sorted out, although it will be hard to be sure until the beta. The unit-test discussion petered out. Nothing has been checked in yet. The iteraators discussion seems to have disappeared. At least, your author can't find it! Cheers, M. From qrczak at knm.org.pl Sat Mar 31 16:29:17 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 31 Mar 2001 21:29:17 GMT Subject: list vs tuple References: <3AC20CD3.265A2D94@alcyone.com><71q9ct4le63anefmiajj5cbh3mg04qu1ga@4ax.com><7Bfx6.989$p5.3791@news1.rivrw1.nsw.optushome.com.au> Message-ID: Sat, 31 Mar 2001 21:16:54 GMT, deadmeat pisze: > > thus it is consistent. > > The syntax is not. It's not different than Pascal. It is self-consistent. Please show an example which proves that a = b ever does something different than making the name 'a' refer to object to which 'b' refers. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From tonetheman at hotmail.com Thu Mar 22 00:22:17 2001 From: tonetheman at hotmail.com (Tonetheman) Date: Thu, 22 Mar 2001 05:22:17 GMT Subject: Dynamically reloading extension modules References: <007f01c0b252$852bb370$04090a0a@upcast.com> <20010321145901.M24341@trufflehunter.avalongroup.net> <00e201c0b25f$b95d4a70$04090a0a@upcast.com> <20010321154600.Q24341@trufflehunter.avalongroup.net> Message-ID: Ok, I am an idiot. Sorry about the last post. I see that the beos module is only using this to cleanup on exit. I will have to poke around some more to see how you could get at a del module; Sorry for the bad advice. "Ken Seehof" wrote in message news:mailman.985218751.8244.python-list at python.org... > > > On Wed, Mar 21, 2001 at 03:36:15PM -0800, Ken Seehof wrote: > > > Not exactly. I didn't state the problem very clearly. The > > > problem is that while an extension module is loaded, the > > > module file (pyd on windows) is read-only. > > > > > > At least this is true on windows. On unix, I think maybe you > > > can rename the module file, rebuild it, and do a reload(module). > > > Is this true? Windows doesn't allow you to rename or rewrite > > > a dll while it is in use, so something like FreeLibrary would be > > > necessary. > > > > Sorry, I can't answer Windows questions. I haven't had to run > > Windows in years. > > > > But I would still think that reload() should work as long as > > you are using python modules, *not* c/c++ modules. > > I -am- talking about c/c++ modules (which I have been referring > to as "extension" modules). Hence there's a bit more to it than > reload(). > > I want to recompile and reload a c/c++ extension module from > within a continuously running python program. > > > Beazley has no disclaimers about reload working only on > > specific platforms. > > > > There is a caveat, objects created with the old module won't be > > updated. > > > From nperkins7 at home.com Fri Mar 23 22:41:25 2001 From: nperkins7 at home.com (Nick Perkins) Date: Sat, 24 Mar 2001 03:41:25 GMT Subject: newbie IDLE, Tkinter Message-ID: I have been playing around with Python and Tkinter, using the IDLE prompt and edit windows. I am a little confused about what happens when I run my tkinter programs, then close them (by closing their window). Sometimes I come back to the prompt, sometimes the interactive window just seems to hang, and sometimes the whole IDLE program just quits. Can someone explain the best way to interactively edit and test a tkinter program with IDLE? Do these window-closing behaviours depend on how I actually run my program? From korpo at 01019freenet.de Thu Mar 22 17:24:09 2001 From: korpo at 01019freenet.de (Oliver Korpilla) Date: Thu, 22 Mar 2001 23:24:09 +0100 Subject: python, perl, lisp, tcl / got a decision to make, can you give me a view point please ? and a joke for python users :) References: <3aba3076.14395287@news.vif.com> Message-ID: <3ABA7B89.3A542D1C@01019freenet.de> You really got the point by publishing the joke... Ciao, Korpo From tchur at optushome.com.au Thu Mar 22 13:10:03 2001 From: tchur at optushome.com.au (Tim Churches) Date: Fri, 23 Mar 2001 05:10:03 +1100 Subject: python, perl, lisp, tcl / got a decision to make, can you give me a view point please ? and a joke for python users :) References: <3aba3076.14395287@news.vif.com> Message-ID: <3ABA3FFB.50CF5714@optushome.com.au> Yvon Boulianne wrote: > > Hello, i'm a bit confused with so many language ;-) > theres the story, i like to learn a programming language for 2 reasons ... > 2- i want to learn to keep my mind trained, i'm a mystic and i want to > make this mental grow in ability ;-) ... Well, assuming your mysticism extends to clairvoyance, Python is definitely the language for you. After many seances and much work with the ouija board, GvR and his gang have decided to include support for the following syntax: from __future__ import * Crystal-ball-gazingly yours, Tim C From info at pythonware.com Mon Mar 26 07:52:32 2001 From: info at pythonware.com (PythonWare) Date: Mon, 26 Mar 2001 14:52:32 +0200 Subject: ANN: PythonWorks Pro 1.2 Message-ID: <021001c0b5f4$367a3440$0900a8c0@SPIFF> a pythonware newsflash: Secret Labs AB has released a new, much improved version of their integrated development environment for Python. PythonWorks is a rapid application development tool, designed for efficient development in Python. PythonWorks includes editors, a debugger, a user-interface design tool, project browser, deployment tools, integrated on-line help, and a scriptable environment. PythonWorks is well suited for many tasks, including: + Cross-platform system administration (system automation) + Prototyping of user interfaces and full applications + Building test frameworks + Rapid development and deployment of complete applications New features in 1.2 include improved support for Python 2.0, support for multiple pads and views, directory workspaces, lots of editor improvements, basic class browser, and improved EXE deployment support. Beginning with version 1.2, Secret Labs is also offering OEM versions of PythonWorks, for customers who want to provide a powerful IDE environment as part of their own Python-powered applications, or want a customized version of PythonWorks for use in their organization. To learn more, visit the PythonWorks product site: http://www.pythonworks.com You can also mail us at info at pythonware.com regards, the pythonworks team From sholden at holdenweb.com Wed Mar 7 21:20:35 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 7 Mar 2001 21:20:35 -0500 Subject: Can Python replace Visual Basic? Should it? References: <5DZo6.11126$hn5.1578410@news1.rdc1.mb.home.com> Message-ID: "Don Dwiggins" wrote in message news:mailman.984010931.26257.python-list at python.org... [ ... ] > I'd say go for it -- get the Python on Windows book and convert one of your > VB, Powerbuilder, or Delphi projects to Python and see what you think (or if > you're adventurous, just use the documentation included in the > distribution). I converted one of our ASP pages to Python from VBScript to > see if it would be faster (it wasn't), and was pleasantly surprised at how > easy it was. > The main problem here is the overhead of starting the Python interpreter (and recompiling the top-level script) each time a page is called. I've done some work with Xitami to develop long-running web processes to server HTML from realational data, and the speedup was, to say the least, startling. My results may not translate to IIS, though, since I did this on the road using Win98 and PWS. YMMV. Of course, structuring your scripts so they just call a function in an imported module will win you some performance, since then most everything is pre-compiled into a .pyc. > I should say, though, that we haven't used any of the GUI toolkits -- maybe > someone else can recommend the best one to use when migrating from VB Forms. > I haven't yet seen anything that stirs me, but it's early days yet. BlackAdder looks promising, though they could certainly use an interface design consultant on their own product... regards Steve From jurgen.defurne at philips.com Fri Mar 16 02:12:50 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Fri, 16 Mar 2001 08:12:50 +0100 Subject: This math scares me Message-ID: <0056900016651646000002L062*@MHS> grante at visi.com@SMTP at python.org on 15/03/2001 19:20:46 Sent by: python-list-admin at python.org To: python-list at python.org@SMTP cc: Subject: Re: This math scares me Classification: In article <98qv55$f5d$1 at news.udel.edu>, Terry Reedy wrote: >So, .1% gets represented as the binary equivalent of, perhaps, >.0010000000000000001. >So the interest on 2,000,000,000 pennies is calculated as >2000000.0000000002 instead of >2000000 pennies. When rounded off, they are the same. To me, this is, as >I claimed. 'well enough' (for many purposes, at least), even though not >'exact'. If that's good enough for you, then go ahead and use FP. But, the people who actually write financial SW for a living seem to think it's not good enough. You would have to talk to one of them to find out the exact situations where FP proved insufficient. Try summing all financial operations of one day together, or better, all operations involving percentages and then adding them together : cumulative errors. Jurgen From kalle at gnupung.net Sat Mar 3 16:55:45 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Sat, 3 Mar 2001 22:55:45 +0100 Subject: Opposite of PyLong_FromString In-Reply-To: ; from qrczak@knm.org.pl on Sat, Mar 03, 2001 at 07:16:15PM +0000 References: Message-ID: <20010303225545.A2165@apone.network.loc> Sez Marcin 'Qrczak' Kowalczyk: > What is the best way to convert a Python's Long to a C string > (matching "-?[0-9]+")? Perhaps something like char *s = PyString_AsString(longobj->ob_type->tp_str(longobj)); or maybe use PyString_Format ? I don't know what's idiomatically correct, though. Peace, Kalle -- Email: kalle at gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From someone at microsoft.com Tue Mar 20 12:24:43 2001 From: someone at microsoft.com (Miki) Date: Tue, 20 Mar 2001 12:24:43 -0500 Subject: Python2.0 rpm's don't have IDLE? References: Message-ID: I had the same problem. What I did was get Python 2.0 as a tarball and install it that way. Even though IDLE doesn't install, it is still in the "Tools" subdirectory. I just copied the entire Tools folder to /user/local/lib/python and changed the shell script "idle" in /usr/bin to the new path of "idle.py". This worked for me on Redhat 6.1 Miki "Martin Brown" wrote in message news:OaEt6.2328$Up.121023 at sea-read.news.verio.net... > I've downloaded and installed the 3 Python2.0 rpm's retrieved: > > BeOpen-Python-2.0-1.i386.rpm > Tkinter-2.0-8.0-3.i386.rpm > expat-1.1-1.i386.rpm > > I've checked the installation directories, but there doesn't seem to be a > copy of IDLE. The web site says IDLE 0.6 is included in Python2.0. Also, > as a separate package, apparently, only version 0.5 is available. > > Suggestions on how to get version 0.6 of IDLE into my Python2.0 > installation greatly appreciated. > > -- > - Martin J. Brown, Jr. - > - mjbjr at beaudesign.com - > > PGP Public Key ID: 0xCED9BD8A Key Server: http://www.keyserver.net/en/ From root at [127.0.0.1] Sat Mar 31 16:24:33 2001 From: root at [127.0.0.1] (deadmeat) Date: Sat, 31 Mar 2001 21:24:33 GMT Subject: list vs tuple References: Message-ID: > THERE IS NO DIFFERENCE. What happens to the objects is not the point, what happens to what I put into a and b is the point. >>> a = 1 >>> b = a >>> a = 2 >>> b 1 >>> a = [1,2,3] >>> b = a >>> a[0] = 0 >>> b [0, 2, 3] Are you saying there is no difference (IN THE *RESULT*) between these? Are you able to read? What goes on in the background is NOT THE POINT. I only care about the values I put into them, and what happens after b = a. From sdm7g at virginia.edu Wed Mar 14 12:45:27 2001 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Wed, 14 Mar 2001 12:45:27 -0500 (EST) Subject: Who's minister of propaganda this week? In-Reply-To: <3AAFA861.C773D977@san.rr.com> Message-ID: On Wed, 14 Mar 2001, Darren New wrote: > Phlip wrote: > > Ruby trumps Python in the simple matter of > > closures (imagine my shock when I discovered Python didn't have them). > > Can someone summarize the important difference between closures and object > instances? Other than convenience, I mean, it would seem that something like > [ ... ] An object is a piece of data with procedures attached to it. A closure is a procedure with a piece of data attached to it. Obviously, they are complete opposites! Well -- maybe "mirror images" is a better term. If you read the HOPL articles on Lisp and Smalltalk, it's clear that both groups were in communication with each other and were aware of this -- they called it "orthigonality" -- both a different syntax, and a different way of looking at the same thing. -- Steve Majewski From embed at geocities.com Thu Mar 1 13:49:00 2001 From: embed at geocities.com (Warren Postma) Date: Thu, 1 Mar 2001 13:49:00 -0500 Subject: A counter-counter-proposal for PEP 236: #pragma( nested_scopes) References: Message-ID: <0Swn6.3324$TW.17061@tor-nn1.netcom.ca> Has anyone considered borrowing a C notation: #pragma( nested_scopes ) Benefits: - It's a comment therefore it doesn't break anything else. - It compiles fine and is ignored on pre-2.x systems. - More pragmas can be added later, for warnings, code generation, etcetera. Drawbacks: - It means a comment can be made to Do Something. The express intent of pragma is that it was the least evil means to accomplish the given purpose though. The comment nature might make it less egregious. I can imagine other #pragma stuff if bytecode compilers for the Microsoft Net CLR and Jython compiler had code generation options that needed to be taken into account. I'm willing to attempt a patch if anybody else likes this idea. The pragma thing can be useful for other things as well. As python grows, this mechanism can be used instead of lots of other little cumulatively uglier hacks. Warren Postma From aahz at panix.com Sat Mar 3 16:58:40 2001 From: aahz at panix.com (Aahz Maruch) Date: 3 Mar 2001 13:58:40 -0800 Subject: Bug fix releases References: <200103031910.OAA21663@cj20424-a.reston1.va.home.com> <15009.17989.88203.844343@cj42289-a.reston1.va.home.com> Message-ID: <97rpeg$54p$1@panix3.panix.com> In article , Guido van Rossum wrote: > >That's how all of us here at PythonLabs are feeling... I feel a >community task coming. I'll bless a 2.0.1 release and the general >idea of bugfix releases, but doing the grunt work won't be a >PythonLabs task. Someone else inside or outside Python-dev will have >to do some work. Aahz? I'm certainly committing to be the cheerleader/explainer (meaning that every time someone complains about the lack of a bugfix release, I tell them how to get one -- not just flippantly like Uncle Timmy, but in the sense that there's a real process available for making it happen). Not sure how much of the actual code I can do, but we'll see what happens. -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Nostalgia just ain't what it used to be From dougfort at downright.com Thu Mar 22 04:14:40 2001 From: dougfort at downright.com (Doug Fort) Date: Thu, 22 Mar 2001 04:14:40 -0500 Subject: automatic cookie handling with urllib? References: <3AB9BFA9.56301B22@ugcs.caltech.edu> Message-ID: <3AB9C280.391E5025@downright.com> This is our cookie module. I've been meaning to rewrite it as a Python library Cookie object. -- Doug Fort (dougfort at downright.com) Senior Meat Manager Downright Software LLC http://www.dougfort.net -------------- next part -------------- #!/usr/bin/env python """ CookieContainer This object stores and retrieves cookies IAW RFC 2109 & RFC 2068 $Id: cookiecontainer.py,v 1.7 2001/02/16 00:27:46 dougfort Exp $ """ __author__=""" Downright Software LLC http://www.downright.com """ __copyright__=""" Copyright (c) 2000 Downright Software LLC. All Rights Reserved. Distributed and Licensed under the provisions of the WebNudge Open Source License (Version 1.0) which is included by reference. The WebNudge Open Source License can be found in the file WOSLV10.TXT in the source distribution kit. """ __version__="$Revision: 1.7 $"[11:-2] import re import time import urlparse import string import webnudge.util.misc def CookieContainerException(Exception): def __init__(self, message): self._message = message def __str__(self): return self._message ########################################################### class CookieContainer: ########################################################### """ This object stores and retrieves cookies IAW RFC 2109 & RFC 2068 """ #---------------------------------------------------------- def __init__(self, listelement=None): #---------------------------------------------------------- """ Constructor """ self._cookiedict = {} # Match dates of this form: # Monday, 05-Feb-2001 08:00:00 GMT self._DatePattern = re.compile(r""" (?P # Start of group 'weekday' [A-za-z]+ # Any word of at least one letter ) # End of group 'weekday' \s*\,\s* # a literal comma after weekday (?P # Start of group 'day' \d\d # two digits ) # End of group 'day' - # literal hyphen (?P # Start of group 'month' [A-za-z]+ # three letters ) # End of group 'month' - # literal hyphen (?P # Start of group 'year' \d+ # some digits ) # End of group 'year' \s+ # a space or more (?P # Start of group 'hour' \d\d # two digits ) # End of group 'hour' : # a colon (?P # Start of group 'minute' \d\d # two digits ) # End of group 'minute' : # a colon (?P # Start of group 'second' \d\d # two digits ) # End of group 'second' \s+ # some whitespace GMT # literal 'GMT """, re.VERBOSE | re.IGNORECASE) self._DateFormat = "%4d-%2s-%2s %2s:%2s:%2s" # yyyy-mm-dd hh:mm:ss self._MonthDict = { "jan" : "01", "feb" : "02", "mar" : "03", "apr" : "04", "may" : "05", "jun" : "06", "jul" : "07", "aug" : "08", "sep" : "09", "oct" : "10", "nov" : "11", "dec" : "12" } #---------------------------------------------------------- def __str__(self): #---------------------------------------------------------- """ Report ourself as a string """ return str(self._cookiedict) #---------------------------------------------------------- def isempty(self): #---------------------------------------------------------- """ Report presence of cookies """ return not self._cookiedict #---------------------------------------------------------- def clear(self): #---------------------------------------------------------- """ Empty out the cookies """ self._cookiedict.clear() #---------------------------------------------------------- def loadFromHeaders(self, defaultdomain, headers): #---------------------------------------------------------- """ Extract 'set-cookie' from headers from RawHTMLPage Return a count of the new cookies added """ count = 0 cookieheaderlist = headers.getallmatchingheaders("set-cookie") for cookieheader in cookieheaderlist: cookie = { "domain" : defaultdomain, "path" : "/", "secure" : "no" } # split on ';' after dropping 'set-cookie:' tokenlist = string.split(cookieheader[12:],";") # assume name is the first token token = string.strip(tokenlist[0]) index = string.find(token, "=") if index <= 0: continue cookie["name"] = token[:index] cookie["value"] = token[index+1:] for token in tokenlist[1:]: # split on the first '=', except for secure token = string.strip(token) if token == "secure": cookie["secure"] = "yes" continue index = string.find(token, "=") if index <= 0: continue key = string.lower(token[:index]) value = token[index+1:] if key == "expires": cookie[key] = self._convertExpirationDate(value) else: cookie[key] = value self._cookiedict[cookie["name"]] = cookie count = count + 1 return count #---------------------------------------------------------- def returnCookieList(self, url): #---------------------------------------------------------- """ Return a list of name:value tuples for cookies that fit the url """ scheme,netloc,path,parameters,query,fragment = urlparse.urlparse( url ) returnlist = [] for cookie in self._cookiedict.values(): if len(netloc) < len(cookie["domain"]): continue # The url must be in the domain the cookie specifies if netloc[len(netloc)-len(cookie["domain"]):] != cookie["domain"]: continue # the path must include the path the domain specifies if path and string.find(path, cookie["path"]) != 0: continue # if we have an expiration date, check for it expirationdate = cookie.get("expires", None) if expirationdate and expirationdate <= time.time(): continue returnlist.append((cookie["name"],cookie["value"])) return returnlist #---------------------------------------------------------- def _convertExpirationDate(self, value): #---------------------------------------------------------- """ convert a date string of the form 'Dayofweek, dd-mmm-yyyy hh:mm:ss GMT' into a python date. """ # look for a date we can understand match = self._DatePattern.search(value) if not match: return None # allow for a two digit year # redhat is one of the offenders if len(match.group("year")) == 4: year = int(match.group("year")) else: year = 2000 + int(match.group("year")) # kludge alert! I can't find a slick way to convert # this date, so I'm going to convert it to our database # format and use code that I know works datestr = self._DateFormat % ( year, self._MonthDict[string.lower(match.group("month"))], match.group("day"), match.group("hour"), match.group("minute"), match.group("second"), ) return webnudge.util.misc.strtime(datestr) #---------------------------------------------------------- if __name__ == "__main__": #---------------------------------------------------------- """ Code for commandline testing """ import sys if len(sys.argv) != 2: print "Usage: cookiecontainer.py " sys.exit(-1) cookiecontainer = CookieContainer() import webnudge.util.rawhtmlpage page = webnudge.util.rawhtmlpage.RawHTMLPage() page.load(sys.argv[1], "GET", [], cookiecontainer, debuglevel=1) if not page: print "*** Error *** %s" % (page._message) sys.exit(-1) print "*" * 30 print page._data print "*" * 30 print "cookie dict" for key, value in cookiecontainer._cookiedict.items(): sys.stdout.write("%s = %s\n" % (key, value)) print "cookies returned" for item in page._cookiesreturned: print item From News at Titanic.co.uk Sat Mar 10 10:14:46 2001 From: News at Titanic.co.uk (Simon Faulkner) Date: Sat, 10 Mar 2001 15:14:46 +0000 Subject: Sucking in a text file Message-ID: <53hkats5d5noic51fskjv0dm72f1rgc29g@4ax.com> I have a .py cgi script that writes a page to the web and it works! To allow the users to customise the out put I would like the script to suck in the first part of the page from a text file and then to spit this out to the web server. Is this easy or do I need to open the file and read each byte in turn? Simon Simon Faulkner From aahz at panix.com Fri Mar 23 10:46:54 2001 From: aahz at panix.com (Aahz Maruch) Date: 23 Mar 2001 07:46:54 -0800 Subject: Python T-shirts References: Message-ID: <99fr5e$sp4$1@panix6.panix.com> [posted to c.l.py with cc to python-dev] In article , Guido van Rossum wrote: > >At the conference we handed out T-shirts with the slogan on the back >"Python: programming the way Guido indented it". We've been asked if >there are any left. Well, we gave them all away, but we're ordering >more. You can get them for $10 + S+H. Write to Melissa Light >. Be nice to her! If you're in the USA, S&H is $3.50, for a total cost of $13.50. Also, at the conference, all t-shirts were size L, but Melissa says that she'll take size requests (since they haven't actually ordered the t-shirts yet). -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "I won't accept a model of the universe in which free will, omniscient gods, and atheism are simultaneously true." -- M From ben.hutchings at roundpoint.com Tue Mar 20 15:31:52 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 20 Mar 2001 12:31:52 -0800 Subject: Insertin **keywords into a class References: <9960i1$tp0$1@nntp6.u.washington.edu> <99661m$scc$1@panix6.panix.com> <99877b$uss$1@nntp6.u.washington.edu> Message-ID: "C. Porter Bassett" writes: > cCan you please tell me why the following code snippet doesn't update the > value of radius? Yes... > class myClass: > def __init__(self, *arguments, **keywords): > self.radius = 0.0 > for kw in keywords.keys(): > print kw, ":", keywords[kw] > self.kw = keywords[kw] This binds/re-binds self.kw, not the attribute of self named by kw. I think you can accomplish what you want by putting self.__dict__[kw] on the left hand side of the assignment. > print "self.radius =", self.radius > > > b = myClass(radius = 1.0) -- Any opinions expressed are my own and not necessarily those of Roundpoint. From tim.one at home.com Thu Mar 1 17:59:17 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 1 Mar 2001 17:59:17 -0500 Subject: A counter-proposal to __future__ in PEP 236 In-Reply-To: <97meh4$c0g$1@news.mathworks.com> Message-ID: [Joshua Marshall] > ... > Note that it doesn't need to be implemented this way. Currently, > > directive foo > > is a syntax error. Meaning can be assigned to this syntax without > breaking any existing code--it is unambiguous. [Tim] > You should study Python's parser before getting too optimistic about that > . [back to Joshua] > So anybody care to post an example of how this can be ambiguous (in > context) so I don't need to go study Python's parser...? It's not a question of ambiguity. You really need to study the parser! Some changes are easy, others are hard, due to the way the parser is implemented. Make "directive" a keyword and it's trivial, because then it can be captured directly by a grammar production. It's not possible-- in Python's parser --to make the identifier "directive" a keyword in some contexts but not others; if it's not a keyword, it would have to be expressed in terms of a generic sequence-of-NAME production followed by post-processing. You also have to consider the parsers in tools, from the Emacs python-mode thru whatever the heck PythonWorks uses. Then also the tools building on the parser module's form of parse trees, which won't even have a case now for *considering* that "sequence of NAME" is a possible construct. Unless "directive" is a keyword, it's a pain in the ass for all of them. Doesn't mean it can't be hacked, but it's ugly, and you have to get a lot of different people to sign up to do all that hacking. "possible"-is-necessary-not-sufficient-ly y'rs - tim From robin at jessikat.fsnet.co.uk Wed Mar 28 03:47:22 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 28 Mar 2001 09:47:22 +0100 Subject: mailman location spoofing Message-ID: I have setup mailman at x.co.uk for accessibility/control reasons and it all works fine. Our principal web address is not x.co.uk, but x.com and it's possible to divert mail to the lists at x.com to lists at x.co.uk. I would like to know if there's an easy way to spoof the return address information in mailman or if that makes sense? I know that the web side cannot in general be moved unless we run mailman on the x.com server. -- Robin Becker From carribeiro at yahoo.com Wed Mar 14 17:13:54 2001 From: carribeiro at yahoo.com (Carlos Ribeiro) Date: Wed, 14 Mar 2001 19:13:54 -0300 Subject: Thoughts about extensions to the Python language Message-ID: <5.0.2.1.0.20010314181331.0213eac0@mail.inet.com.br> (flames off please ...) First of all, some background information... I'm watching this list for the past few days. Thats my first contribution to the list. I work on computer related jobs for some time (since 1984), and I have saw a lot of things in the past decade or so. I'm learning Python since mid-2000, mainly for use as a tool to gather network management information. What attracted me to Python was the simplicity and cleanliness of the language. Code written in Python is as clean as code can be. I have written systems using several other languages, including C, C++ and Perl, and none of these languages can even come close of Python in terms of readability. I think that most people on this list will agree with me that making code readable is one of the most important (and relegated) steps to improve programming skills. I'm not saying that Python is perfect - as a "work in progress" we can surely think about a lot of things that can be improved. However, I'm seeing a lot of effort these days toward language extensions. Call it "featuritis" or anything like it, but I dont like it, and something inside tells me that this is the wrong approach for Python's evolution. I can number several ways this approach is failed: 1) Python is not an application, is a programming language. However it seems that the PEP process is making Python development look just like any other generic application. Someone else on the list has already posted on this (he was asking for a maturation time for extensions to the language definition). Maybe a lot of this is related to the crescent confusion between Python (the language) and CPython - the C implementation that most of us know and use. 2) Python has reached a stated where it's useful for a large number of people and a wide range of applications. It is absolutely expected that people come up with lots of imaginative extensions that fit theirs particular needs. 3) Another reason is that some people come from other languages and environments. They try to translate their mental models in Python and fail, not because something is missing in Python, but because they have a hard time learning the "Python Way". 4) There is a lot of pressure from the "my-language-is-better-than-yours" department. Some of this people are particularly loud on making their requests heard, and this gives an unproportional weight to some proposals that are silly at best. The vast majority of the Python users don't listen to the list. They are going to have quite a surprise with the next releases... 5) Written proposals are dangerous ;-) Ok, this is an exageration. This is another way to state some of the points above. Dumb ideas have somehow developed an ability to make themselves look much better when written in a formal proposal (Alan Sokal, please?). That's a problem that plagues a lot of mailing lists. You have to be alert to avoid it. 6) Most important of all, it's clear that Guido had used a 'common sense' approach to design the original language. At that time there were much less exposition than today. It seems that some of this "practical" approach is being lost in the transition to the open source world. I think that all the reasons above apply, mainly because the pressure is much higher. We could elaborate a lot on this, and I think that some of the older "Pythoneers" are doing exactly this. However, for the extensions proposed for the language itself, I saw a lot of discussions for particular issues *without* the amplitude needed for a generic solution. I fear that this may lead to a distorted perception of reality. Is everyone sure that Python needs as much extensions to the language as proposed now? Maybe I'm way too much conservative, but for me the answer is no. Let's see what everyone else thinks. Carlos Ribeiro carribeiro at yahoo.com cribeiro at mail.inet.com.br _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From tuttledon at hotmail.com Tue Mar 13 10:24:19 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Tue, 13 Mar 2001 15:24:19 GMT Subject: win32all buld 137 win32gui fails References: <98l8qk$oeo$1@troll.powertech.no> Message-ID: "Syver Enstad" wrote in message news:98l8qk$oeo$1 at troll.powertech.no... > I've just installed the win32all build 137 that contains the support for > Vtable interfaces in win32com. I've suddenly found that import win32gui > fails with the message: > > ImportError: DLL load failed: The specified module could not be found. > > This is mighty strange as the pyd file is lying there among the other .pyd > files like win32help and so on. Maybe there are some other modules that > win32gui depends on that it didn't depend on before? > > Anybody have a suggestion to fix this? > > For the record I am running Win2000 Pro with no service packs, VC++ 6 to > service pack 3, IE 5. Don't know. It imports fine for me. Perhaps unistall 137, then reinstall. Don From claird at starbase.neosoft.com Fri Mar 23 13:54:16 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 23 Mar 2001 12:54:16 -0600 Subject: newbie question References: <575F0D65CC45F12D.7D165177C452F6D5.01903532892CC93D@lp.airnews.net> <99fll8$996$1@rex.ip-plus.net> Message-ID: <73125560B5E4EF16.CC3FC0DB3FD693E3.4AF0ACCBD2EFF29B@lp.airnews.net> In article , Moshe Zadka wrote: >On 23 Mar 2001, claird at starbase.neosoft.com (Cameron Laird) wrote: > >> There are few languages that canNOT be used with >> Apache. > >I might be talking out of my ass here, in which case Cameron will surely >correct me. Haskell, Ruby, Icon, Scheme, ML and Smalltalk are all languages >which are highly useful, and which no interfaces to Apache exists as far as I >know. I'd simply go the opposite direction and say > >"there are few things Python cannot talk to. Apache is not one of those" >(I like to phrase it: Python plays nice with the other kids. And there >are *always* other kids) > >waiting-for-someone-to-prove-me-wrong-(hurd,plan9)-ly y'rs, Z. . . . I was elliptic. And also intuitive--I speculated that CGI would fit what the original poster had in mind for "an interface to Apache". Subsequent correspondence turned out to confirm that. So: out-of-the-box, Apache installs with CGI capabilities, and Icon, Scheme, Ruby, ... are all languages I've seen used in CGI (with Apache). I make the point not as a mere legalism. Many of the questioners who come here are thrilled to learn, "Ah, you already have a standard Linux distribution Apache and Python installed; all you need is to write ..., and you'll see your existing configuration already supports Python-savvy Web service." That's a lot more exciting for them than hearing that, with a mere week or two of study, they can install Zope on their own. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From padiolea at merlin.irisa.fr Wed Mar 14 07:26:10 2001 From: padiolea at merlin.irisa.fr (Yoann Padioleau) Date: 14 Mar 2001 13:26:10 +0100 Subject: Einstein's Riddle References: <984380185.768920@news.aei.ca> <4w6r6.193645$df5.5192565@news1.crdva1.bc.home.com> <3aae4114.63604234@nntp.interaccess.com> <3AAE4BFD.9A7B0D9C@cs.man.ac.uk> <3AAF1240.C446D19@iit.demokritos.gr> Message-ID: Petasis George writes: > "Donal K. Fellows" wrote: > > > > Thaddeus L Olczyk wrote: > > > I also figure the fish thing was simply a typo, and that this guy ( > > > who hasn't resdponded ) was probably given this as a homework > > > assignement, and is simply looking for a cheap way to get it done. > > > > That'd be a very lame homework assignment. Not unless you had to write > > a program in $FAVOURITE_LANGUAGE to compute the answer automatically > > (which is much more interesting, especially if you make the program > > start from the natural language expression of the problem! :^) > > > Well, try this:-) > Written by a friend of mine. Its amazing how small can programs be if you > know STL. To bad I don't know stl :-) > Of course it will need some time, as it randomly checks all combinations... But your program dont really do the job cos it is too slow. You first generate the permutations and then test, the pb is that there is too many permutations : p[nation][english] can be either 0 1 2 3 4 or 5, same for the other variables you have 5*(5!) possibililty = 24 883 200 000 if you are able to do 1 000 000 ValidConstraints per second (cos you have perhaps a very very fast computer) you will need 24 883 seconds =~ 6hours to compute (in the worst case i admit) the prolog program i propose take 0.1 second to find the solution :) who say that prolog is slower than c++ :)) > > George > > //A simple randomiser to find the solution to the riddle, by J. Y. Goulermas > > #include > #include > #include > #include > #include > #include > > using namespace std; > > enum element_type { nation, colour, pet, drink, cigs }; > enum nation_type { english, swedish, danish, german, norwegian }; > enum colour_type { red, blue, yellow, green, white }; > enum pet_type { cat, bird, horse, dog, fish }; > enum drink_type { tea, water, milk, beer, coffee }; > enum cigs_type { palmal, dunhill, bluemasters, prince, blends }; > > char* codes[][5] = { { "english", "swedish", "danish", "german", > "norwegian" }, > { "red", "blue", "yellow", "green", > "white" }, > { "cat", "bird", "horse", "dog", "fish" > }, > { "tea", "water", "milk", "beer", > "coffee" }, > { "palmal", "dunhill", "bluemasters", "prince", > "blends" } > }; > > inline bool ValidConstraints(const vector< vector >& p) > { > return p[nation][norwegian] == 0 //Rule 9 > && > p[colour][blue] == 1 //Rule 14 > && > p[drink][milk] == 2 //Rule 8 > && > p[nation][english] == p[colour][red] //Rule 1 > && > p[nation][swedish] == p[pet][dog] //Rule 2 > && > p[nation][danish] == p[drink][tea] //Rule 3 > && > p[colour][yellow] == p[cigs][dunhill] //Rule 7 > && > p[pet][bird] == p[cigs][palmal] //Rule 6 > && > p[drink][beer] == p[cigs][bluemasters] //Rule 12 > && > p[nation][german] == p[cigs][prince] //Rule 13 > && > p[colour][green] == p[drink][coffee] //Rule 5 > && > abs(p[cigs][blends] - p[pet][cat]) == 1 //Rule 10 > && > abs(p[cigs][blends] - p[drink][water]) == 1 //Rule 15 > && > abs(p[pet][horse] - p[cigs][dunhill]) == 1 //Rule 11 > && > p[colour][green] < p[colour][white]; //Rule 4 > } > > void Output(const vector< vector >& p, > unsigned c > ) > { > ofstream text("solution.txt"); > > for (int i = nation; i <= cigs; ++i) > { > for (int j = 0; j < p[i].size(); ++j) > text < < //get inverse permutation > text < } > text <<"\n\nTotal attempts: " < > text.close(); > } > > void main(void) > { > //srand( (unsigned) time(NULL) ); //optional RNG seeding > > int ramp[] = { 0, 1, 2, 3, 4 }; > vector< vector > permutations; > unsigned counter(0); > for (int i = nation; i <= cigs; i++ ) > permutations.push_back( vector(ramp, ramp + 5) ); > > do > { > for (int i = nation; i <= cigs; i++) > random_shuffle( permutations[i].begin(), permutations[i].end() ); > if ( ! (++counter % 100000) ) > cout <<"\rRe-Randomisations: " < } > while ( ! ValidConstraints(permutations) ); > > Output(permutations, counter); > } -- Yoann Padioleau, INSA de Rennes, France, http://www.irisa.fr/prive/padiolea Opinions expressed here are only mine. Je n'?cris qu'? titre personnel. **____ Get Free. Be Smart. Simply use Linux and Free Software. ____** From cg at schlund.de Sat Mar 10 13:36:48 2001 From: cg at schlund.de (Carsten Gaebler) Date: Sat, 10 Mar 2001 19:36:48 +0100 Subject: How to efficently build a nested dictionary References: <3AAA2042.E69A53FC@gmx.de> <98dgjb$iee$1@panix3.panix.com> <3AAA71F1.7FC7597A@schlund.de> Message-ID: <3AAA7440.E0DBACAF@schlund.de> Carsten Gaebler wrote: > > Aahz Maruch wrote: > > > > > >traffic = {dir: {year: {month: {day: 42}}}} > > > > I think Emile's suggestion to use a single compound key is a good one. > > If that's not sufficient *and* you can use Python 2.0, take a look at > > the dict.setdefault() method. > > How could the setdefault() method help me out? By just saying traffic[dir][year][month][day] = traffic.setdefault(dir,{}).setdefault(year,{}).setdefault(month,{}).setdefault(day, 0) + bytes Yes, I know, sometimes I'm a bit slow ... :-) cg. From fredrik at pythonware.com Mon Mar 12 17:21:23 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 12 Mar 2001 22:21:23 GMT Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> <3aad4485.2348499@News.CIS.DFN.DE> Message-ID: costas at springmail.com wrote: > I will also tell my customers that this is the new math. if you don't understand how floating point numbers work, you probably shouldn't use them in customer projects. (unless you like to get sued for incompetence, of course...) Cheers /F From wolfson at midway.uchicago.edu Tue Mar 13 03:14:31 2001 From: wolfson at midway.uchicago.edu (Ben Wolfson) Date: Tue, 13 Mar 2001 08:14:31 GMT Subject: Stupid Python trick Message-ID: I'm sure this can be put to creatively bad use. Python 2.1b1 (#3, Mar 2 2001, 20:37:19) [GCC 2.96 20000731 (Red Hat Linux 7.0)] on linux2 Type "copyright", "credits" or "license" for more information. IDLE 0.6 -- press F1 for help >>> class D: def __init__(self, otherself, v): self.val = v try: otherself.val = v except: pass >>> import new >>> d = D(None, 5) >>> d.val 5 >>> m = new.instancemethod(D, d, D) >>> m(6) <__main__.D instance at 0x82df1dc> >>> d.val 6 -- Barnabas T. Rumjuggler Fried Something with Noodle: Very good for ugly, sad, lonely, sick people with the blood and the grasses all over the floor... -- Joe Frank, _A Call in the Night_ From johnw at gnu.org Sun Mar 11 23:49:10 2001 From: johnw at gnu.org (John Wiegley) Date: 11 Mar 2001 21:49:10 -0700 Subject: Going ZODB References: Message-ID: >>>>> On Sun Mar 11, A writes: > Current versions of the ZODB *do* support __getattr__ and > __setattr__, so you may want to take another look at the ZODB. Now THAT sounds cool. Checking now... From vsbabu at erols.com Sat Mar 31 06:33:08 2001 From: vsbabu at erols.com (Satheesh Babu) Date: Sat, 31 Mar 2001 06:33:08 -0500 Subject: HTML Tidy and Python wrapper References: <985945106.28359.0.nnrp-02.c1c3e154@news.demon.co.uk> Message-ID: <9a4f6t$qn1$1@bob.news.rcn.net> I was searching for some thing like this. I had to use it with ASP. I've a small article about this at http://vsbabu.csoft.net/techbits/tidywithasp.html Also has a snippet on using Tidy with Python. This probably might be useless -- v.s.babu vsbabu at erols.com http://vsbabu.csoft.net "Paul Brian" wrote in message news:985945106.28359.0.nnrp-02.c1c3e154 at news.demon.co.uk... > Dear all, > > I was sure that I recently read that there was a python wrapper around the > HTML Tidy (http://www.w3.org/People/Raggett/tidy/). Unfortunately I cannot > find the reference. Does any one know if such a thing exists, as simple > searches through deja have come up nought. > > thank you > > From phrxy at csv.warwick.ac.uk Sun Mar 25 17:05:59 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Sun, 25 Mar 2001 23:05:59 +0100 Subject: boolean values in COM / VB / Python Message-ID: ie.Document.execCommand("SaveAs", false, pathname) where ie is an Internet Explorer object, pops up a dialogue box, no matter what value for false I try, from (1==0, 0, "0", None). According to the MS docs at http://msdn.microsoft.com/workshop/author/dhtml/reference/constants/saveas.asp and http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/execCommand.asp this isn't supposed to happen, because when the second argument to execCommand is 'false', the command 'Does not display a user interface'. According to Mark Hammond just last month, 0 should do fine as a way of representing 'false': http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=1cd0ed3943dead44&thn=Setting+boolean+COM+properties&seekd=926499672 Any clues as to what is happening? Tips on the differences between C++ / VB and Python in general would also be appreciated -- presumably there must be some reliable and mechanical way of doing this? John From not.this at seebelow.org Thu Mar 1 09:17:36 2001 From: not.this at seebelow.org (Grant Griffin) Date: Thu, 01 Mar 2001 08:17:36 -0600 Subject: is and == (is not other_thread) References: Message-ID: <3A9E5A00.E276C54A@seebelow.org> Robin Thomas wrote: > > At 10:33 PM 2/28/01 -0600, Grant Griffin wrote: > >Hi Gang, > > > >I've had a few of my own little questions about "is" and "==", vis-a-vis > >strings: > Use the source, Luke. Yup, I'd like to one day. But for now, I don't have time to figure out how 100k lines of C code works: I only have enough time to ask people other folks who _do_ have enough time to figure out how 100k lines of C code. > All multipart questions are thus answered. This reply > was your freebie. You're so kind...may I ask just one more favor? My car needs an oil change... give-in-to-the-dark-side-of-automotive-lubrication,-Luke- -ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From dsavitsk at e-coli.net Mon Mar 5 17:51:21 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Mon, 5 Mar 2001 16:51:21 -0600 Subject: Python COM server to VB interface References: Message-ID: for anyone interested, this turns out to be a corrupted registry i think. it works fine on other computers. ds "dsavitsk" wrote in message news:keyo6.156158$Ch.31627133 at newsrump.sjc.telocity.net... > I am attempting to learn to use python as a com server to a VB interface. > When i run my little example i get the following error. > > Run-time error'-2147467259 (800004005)': > Unexpected Python Error: AttributeError: CreateInstance > > Here is the Python end of things... > > class pyserv_test: > _public_methods_ = [ 'AddString' ] > _reg_progid_ = 'PyServ.Test' > _reg_clsid_ = '{EA08AFC9-E0AA-4C9B-8E42-1170A21D59AC}' > > def AddString(self, val): > return 'the string was: ' + str(val) > > def Register(): > import win32com.server.register > return win32com.server.register.UseCommandLine(pyserv_test) > > if __name__=='__main__': > print "Registering COM server..." > Register() > > > and here is the relevant VB code... > > Private Sub Command1_Click() > Dim x > Dim y > Set x = CreateObject("PyServ.Test") > y = x.AddString(Text2.Text) > Text1.Text = y > End Sub > > The error occurs on the "CreateObject" line. Does anyone know what this > might be? > > Thanks, > doug > > From neilh at scintilla.org Tue Mar 20 17:26:13 2001 From: neilh at scintilla.org (Neil Hodgson) Date: Tue, 20 Mar 2001 22:26:13 GMT Subject: Little red lines in PythonWin! References: Message-ID: <9OQt6.13652$992.84056@news-server.bigpond.net.au> Bill Bell: > When I view the whois client using PythonWin I see that lots of the > Python indenting is lost and that numerous red lines have been > introduced which are (presumably) meant to inform me that > something is wrong. Even though Bill has found his problem, I'd like to point out the meaning of the little red lines. They are there to show that there is potentially ambiguous indentation in the file and that the indentation should be fixed, preferrably to all tabs or all spaces. This feature is turned on by default in PythonWin and can be controlled through View | Options... | Tabs and Whitespace | Tab-Timmy. IMO all Python IDEs should have a similar feature. For those IDEs that use Scintilla, the feature is already implemented for you so it is almost free to add. Neil From aleaxit at yahoo.com Mon Mar 12 04:14:52 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 12 Mar 2001 10:14:52 +0100 Subject: Static typing (was Re: Java guy interested in Python) References: <98glhc02sga@news2.newsguy.com> <98gt3f064l@news2.newsguy.com> Message-ID: <98i42a0oas@news2.newsguy.com> "Michael Hudson" wrote in message news:m3elw39a7m.fsf at atrus.jesus.cam.ac.uk... [snip] > > to spot this. But on re-reading it falls pretty flat -- sorry! > > Actually, I thought > > #define int foo > > was pedantically illegal C++ that was almost certain to work, but on > checking I see that it's probably legal. I also hadn't taken this > possibility into account when replying above; catching people out with > the preprocessor isn't really fair... Yes it's legal, and yes it IS 'unfair' -- to the point of making my original post on this a waste of time (I repeat my apologies). Alex From loewis at informatik.hu-berlin.de Thu Mar 29 02:13:43 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 29 Mar 2001 09:13:43 +0200 Subject: Building "non-standard" standard extensions References: <719vbt8tlkb05h4n1mcvh65l0f0i62tgsj@4ax.com> Message-ID: Paul Moore writes: > However, I do have a binary version of the readline library > available. Can I build the readline module for Windows usingh this? > Ideally, I'd like to do this *without* having to rebuild the whole > of Python for Windows (I'm happy with just using the normal build > for everything else). I've never built Python for myself, so > apologies if the answer to this is "obvious"... Building the readline module alone should be possible. I'm not sure whether the interactive interpreter will use it - it only tries if stdin isatty. > (BTW, this doesn't just apply to readline - I have various other libraries > such as a curses port, which I wouldn't mind trying to integrate as well...) That should work as well. Regards, Martin From flognat at flognat.myip.org Thu Mar 15 18:45:20 2001 From: flognat at flognat.myip.org (Andrew Markebo) Date: 16 Mar 2001 00:45:20 +0100 Subject: inverse of asctime References: <98rfn6016rf@drn.newsguy.com> Message-ID: / Grant Griffin wrote: | Hi Gang, | | I'm in the market for the inverse of asctime(). I looked in the time module but | couldn't find it. (Nope, strptime isn't available on my Windows installation.) | Seems like there oughtta be sucha thing somewhere. Ehm.. I actually have a strptime.py, used by RogueWave ;-) *stretches his back* You can locate it at my mismaintained code-page, will have to make it come back to life some day. http://www.fukt.hk-r.se/~flognat/hacks/ http://www.fukt.hk-r.se/~flognat/hacks/strptime.py *stretching-his-backly-yours* /Andy BTW Have you actually tried searching the python site :-) Number-crunching NumPy Extensions ... strptime.py - Produce time-module style time tuples (Andy Eskilsson) The inverse of strftime, convert a string to a tuple that the time module can handle. ... www.python.org/topics/scicomp/numbercrunching.html - 14k - Cached - From lluang at northwestern.edu Tue Mar 13 12:49:23 2001 From: lluang at northwestern.edu (Louis Luangkesorn) Date: Tue, 13 Mar 2001 11:49:23 -0600 Subject: Python In A Nutshell - Numpy essential References: <3AAE7E0D@MailAndNews.com> <3AACE20C.AC8D2EA2@northwestern.edu> Message-ID: <3AAE5DA3.B736C2D0@northwestern.edu> Steve Holden wrote: > "Louis Luangkesorn" wrote in message > news:3AACE20C.AC8D2EA2 at northwestern.edu... > > I have to second that Numeric Python belongs in the ESSENTIAL column. For > me, the fact that Python can replace Matlab was the reason I started using > Python. > > Well, just for balance, I still haven't downloaded NumPy, and don't ever > expect to. > > one-man's-essential-is-another-man's-redundant-ly y'rs - steve Oh, oh, I hope this does not mean that we have to have an election. From joconnor at cybermesa.com Thu Mar 1 14:35:14 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Thu, 01 Mar 2001 12:35:14 -0700 Subject: [Q] Question from Python tutorial References: Message-ID: <3A9EA472.F15AF847@cybermesa.com> Young-Jin Lee wrote: > Hi, I have a question from Python tutorial. > The code segment in the page 60 (chapter 9. classes) is not executed. > I don't know what I did wrong. Here is the code and the error I got. > > class MyClass: > "A simple example class" > i = 12345 > def f( x ): > return 'hello world' > > x = MyClass() > > x.counter = 1 > while x.counter < 10: > x.counter = x.counter * 2 > print x.counter > ^ > SyntaxError: invalid syntax > > There is no typo, I have no idea of where this SyntaxError came from. > > Thanks in advance. Any comment would be greatly appreciated. You probably cut and pasted the code from the tutorial. When I cut and pasted your code into IDLE, I got the same error. When I manyually typed the code, it works fine. My guess is that the cut and paste didn't paste properly and the interactive interpreter didn't make the right break between the 2 and the word print -- Jay O'Connor joconnor at cybermesa.com http://www.cybermesa.com/~joconnor Python Language Forum - http://pub1.ezboard.com/fobjectorienteddevelopmentpython From Pieter_Claerhout at CreoScitex.com Wed Mar 7 04:37:05 2001 From: Pieter_Claerhout at CreoScitex.com (Pieter Claerhout) Date: Wed, 7 Mar 2001 10:37:05 +0100 Subject: GadFly and gfplus.py working with Python 2.0? Message-ID: <2B1262E83448D211AE4B00A0C9D61B0301DDDB81@msgeuro1.177.115.149.IN-ADDR.ARPA> I tried it and it seems to work fine... Pieter -----Original Message----- From: Eugene Leitl [mailto:Eugene.Leitl at lrz.uni-muenchen.de] Sent: Wednesday, March 07, 2001 10:42 AM To: python-list at python.org Subject: GadFly and gfplus.py working with Python 2.0? See subject. Aye, nay, maybe? TIA, -- Eugene ______________________________________________________________ ICBMTO : N48 10'07'' E011 33'53'' http://www.lrz.de/~ui22204 57F9CFD3: ED90 0433 EB74 E4A9 537F CFF5 86E7 629B 57F9 CFD3 -- http://mail.python.org/mailman/listinfo/python-list From sholden at holdenweb.com Fri Mar 9 09:33:00 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 9 Mar 2001 09:33:00 -0500 Subject: COM support (was Re: Can Python replace Visual Basic? Should it?) References: <5DZo6.11126$hn5.1578410@news1.rdc1.mb.home.com> <984133550.452523@newsmaster-04.atnet.at> <98ai2j01o8j@news2.newsguy.com> <984145785.263773@newsmaster-04.atnet.at> Message-ID: "Werner Schiendl" wrote in message news:984145785.263773 at newsmaster-04.atnet.at... > There are definitely areas in COM - a lot of such, to be precise - where > Visual Basic is _not_ suited (at all). Well, "three thousand six hundred seventeen" would be precise. "A lot" just sounds like you've got(ten) tired of stubbing your toe on an inadequate platform. > Thing is, there are a lot of things that do not need to care on how the > marshaling is done in detail (because the default is good enough for a lot > of applications, IF you have well designed interfaces - if not, writing your > own marshaling code is the wrong answer to the problem) or how the security > is handled in detail (becuase, e. g. it is not intended to use even by a > local client - only inproc like active x controls or utility classes to > provide functions Visual Basic is missing by default). > COM is quite good at hiding (often-irrelevant) implementation detail from the inexperienced user. The major problems with it seem to be its underlying complexity and Microsoft's insistence on inventing things for themselves which solve problems for whiuch there are already perfectly adequate solutions, quite often in open source. > As I mentioned, I do not have much experience with Python and COM and I > _thought_, based on that very small insight, Visual Basic would be the more > convenient environment. I read a lot of rather headache stuff on generating > interface classes and things like that and this is one point Visual Basic > handles nicely. ActiveX control containment is also one thing I would have > no idea on how to start. > COM is much more fun in Python than in VB, until you stub your toe against somethig that really does require an understanding of the underlying implementation. My usual solution (and that of many others) at this point is to scream for help on c.l.py, and Mark Hammond amazingly often comes up with an answer. I somethimes don't LIKE the answer, of course, but that's *my* problem. > BTW: I intend to get a copy of O'Reillys book "Python Programming on Win32" > to deepen my insight on that topic. If you know > other links or books worth reading (apart from the docs that come with > python, of course) I would appreciate to hear about them. > Run, don't walk. It's an amazingly broad and useful book. > regards > werner > > P.S.: Of course one should (or must, to bring it to the point) understand > the technology in use. This applies heavily to COM, and I know quite a lot > about that stuff. This is one of the reasons I think that well designed > interfaces are more important for remoting than the actual programming > language. And you can use IDL defined Interfaces with VB, otherwise it would > be a headache some time... > [martellibot wisdom snipped] From dnew at san.rr.com Mon Mar 5 11:37:26 2001 From: dnew at san.rr.com (Darren New) Date: Mon, 05 Mar 2001 16:37:26 GMT Subject: Missing the functional mind set References: <97rqgb$lt2$1@tyfon.itea.ntnu.no> <3AA298F5.7742810E@wwc.com> Message-ID: <3AA3C0C8.2F33233C@san.rr.com> Steve Williams wrote: > To be consistent with the "index == offset" mindset, counting should > start at zero. Most humans don't start counting until after they've already found one. Since computers only do one thing at a time (either count, or find one), computers make explicit that you're starting at zero. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. From ws-news at gmx.at Tue Mar 6 11:59:26 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Tue, 6 Mar 2001 17:59:26 +0100 Subject: absolute namespace for callbacks? References: <3AA50AFB.83C7459F@troikanetworks.com> <983895797.296667@newsmaster-04.atnet.at> <3AA51144.3DD3FC3F@troikanetworks.com> Message-ID: <983898242.925306@newsmaster-04.atnet.at> Con you specify how you intend to register your callback? somewhat like this? >>> def test_func(msg): ... print "Hello in Testfunc, message is:", msg ... return len(msg) ... >>> def use_callback(func): ... print "Function provided as callback is %s", func ... testdata = "Hello, World!" ... result = func(testdata) ... print "Invoked function with %s, result is %d" % (testdata, result) ... return result ... >>> use_callback(test_func) Function provided as callback is %s Hello in Testfunc, message is: Hello, World! Invoked function with Hello, World!, result is 13 13 (make sure for proper identation) So it in fact does not matter, where test_func or use_callback is declared... Did I miss something? hth werner Bruce Edge wrote in message news:3AA51144.3DD3FC3F at troikanetworks.com... > My callback func is defined in one module, and the callback is executed > from another module which does not know in advance what module the > callback func resides in. So, by default, the caller cannot find the > callback func in it's own namespace. > The callback registration procedure needs to specify the namespace where > the callback func exists. > > OTOH, maybe I'm missing something here :-) > > -Bruce. > > Werner Schiendl wrote: > > > > What's the matter? > > > > You do not pass the name, but a reference to the function > > (the function is an object for python like anything else) > > It does not matter where the function is defined... > > > > or did I miss anything in your post? > > > > hth > > werner > > > > Bruce Edge wrote in message > > news:3AA50AFB.83C7459F at troikanetworks.com... > > > Tcl has a func to get a fully qualified namespace from a context. This > > > is essential for registering callback functions. > > > How does one register a callback in Python, when the callback func > > > exists in a different namespace? > > > > > > Is there any method to get the current absolute namespace? > > > > > > Thanks, Bruce. > > > From aleaxit at yahoo.com Thu Mar 29 09:25:23 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 29 Mar 2001 16:25:23 +0200 Subject: setvbuf() ?? References: <3AC29961.9937EC59@ucdavis.edu> Message-ID: <99vglp02gdd@news2.newsguy.com> "Bruce Wolk" wrote in message news:3AC29961.9937EC59 at ucdavis.edu... > Putting a trailing comma after the print statement eliminates the newline, but > adds a trailing space. Would periods separated by spaces work? > > I would be curious if anyone knows how to eliminate the trailing space. The simplest way is probably import sys sys.stdout.write('.') Alex From lluang at northwestern.edu Sat Mar 17 00:47:58 2001 From: lluang at northwestern.edu (Louis Luangkesorn) Date: Fri, 16 Mar 2001 23:47:58 -0600 Subject: MS Access query fails on Date/Time field Message-ID: <3AB2FA8E.F00ED88E@northwestern.edu> This has got to be a FAQ, but I can't find it anywhere I am trying to use the mx.ODBC.Windows module to query an Access database (for some data laundering it into a database application we are using at my church). But when I try a query that returns a Date/Time field, it returns an error >>> import mx.ODBC.Windows >>> connect = mx.ODBC.Windows.connect('ptcdonors',user='',password='christ') >>> c1 = connect.cursor() >>> c1.execute('select [Receipt #], City, State from Person') >>> a = c1.fetchone() >>> a (3268, None, None) Works fine, but >>> c1.execute('select Date, [Receipt #], City, State from Person') >>> a = c1.fetchone() Traceback (innermost last): File "", line 1, in ? InternalError: ('S1003', 0, '[Microsoft][ODBC Driver Manager] Program type out of range', 3013) >>> I've narrowed it down to the date field. When I try to use ADO (following Hammond's chapter 13) I can get the date object, but then I have to figure out how to get each of the returned data fields out from their tuples. So, 1) Is it possible to get the information out of an MS Access date field using ODBC? -or- 2) How do you unpack all those tuples that ADO queries return? I figured out the date one, using int(aDate), then aDate.Format(), but not the others. Thank you. Louis -- K Louis Luangkesorn lluang at northwestern.edu http://pubweb.nwu.edu/~kll560 PGP:0xF3E2D362 Whatsoever things are true, ... honest, ... just, ... pure, ... lovely, ... of good report; if there be any virtue, and if there be any praise, think on these things. - motto - Northwestern University (Phil 4:8) From fgeiger at datec.at Mon Mar 12 02:25:27 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Mon, 12 Mar 2001 08:25:27 +0100 Subject: question , Does pytyon excist on a pda, like psion? References: Message-ID: <98htoa$a87$1@newsreaderm1.core.theplanet.net> I tried to install Jython on my Psion but yet did not succeed. There are some special considerations installing Java programs on EPOC. But I'm not a Java programmer... Regards Franz "SonoBull" wrote in message news:xDJq6.28348$KE1.1127955 at zwoll1.home.nl... > Hello all, > > Is Python already ported to the psion or other pda, s? > > greetings. > > Sono. > > > > From qrczak at knm.org.pl Sat Mar 31 16:00:20 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 31 Mar 2001 21:00:20 GMT Subject: list vs tuple References: <3AC20CD3.265A2D94@alcyone.com><71q9ct4le63anefmiajj5cbh3mg04qu1ga@4ax.com><7Bfx6.989$p5.3791@news1.rivrw1.nsw.optushome.com.au> Message-ID: Sat, 31 Mar 2001 19:59:22 GMT, deadmeat pisze: > but thats not the point - which when the statement a = b copies > the data across for one type it's expected to do it for others. > It doesn't, so it's inconsistant, contrary to the original claim. It *never* copies the data across, thus it is consistent. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From aaldv97 at student.removethispart.vxu.se Mon Mar 26 09:23:24 2001 From: aaldv97 at student.removethispart.vxu.se (David Andreas Alderud) Date: Mon, 26 Mar 2001 16:23:24 +0200 Subject: Lists and Files Message-ID: <99njdo$oa3$1@news.lth.se> I'm new to Python, started yesterday, is there a good way to handle lists and files? For example: stooges = ['val1', 'val2', 1, [['val2_1', 'val2_2', 0], ['val2_1', 'val2_2', 0]]] fds = open("stooges", "w") # fds.write(stooges) doesn't work, maybe I can encapsulate and pack it to some other format, other than str that is, one that works? fds.write(str(stooges)) fds.close() fds = open("stooges", "r") no_longer_stooges = list(fds.read()) print no_longer_stooges => ['[', "'", 'v', 'a', 'l', '1', "'", ',', ' ', "'", 'v', 'a', 'l', '2', "'", ',', ' ', '1', ',', ' ', '[', '[', "'", 'v', 'a', 'l', '2', '_', '1', "'", ',', ' ', "'", 'v', 'a', 'l', '2', '_', '2', "'", ',', ' ', '0', ']', ',', ' ', '[', "'", 'v', 'a', 'l', '2', '_', '1', "'", ',', ' ', "'", 'v', 'a', 'l', '2', '_', '2', "'", ',', ' ', '0', ']', ']', ']'] and that's not what I want, I could write a parser for the dynamic data but I rather not if there is a good way to handle it. Someone _must_ have stumbled across this problem before me, as it seams like a common thing to do, and solved it, so I rather not duplicate the effort, any hits and pointers or full solutions? /Kind regards, David A. Alderud From loewis at informatik.hu-berlin.de Sat Mar 24 06:26:53 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 24 Mar 2001 12:26:53 +0100 Subject: Is setup.py a "good thing"? (long) References: <3aba76e2.167083508@24.0.228.33> <3dvgp1zasw.fsf@ute.cnri.reston.va.us> <99fsdu$p2u$1@hop.gmd.de> <3dpuf8zb4t.fsf@ute.cnri.reston.va.us> Message-ID: Andrew Kuchling writes: > woetzel at gmd.de (Gerd Woetzel) writes: > > Modules/Setup has buit zlibmodule.so and socketmodule.so which worked > > fine during the test phase, but setup.py has (secretly?) created > > zlib.so (socket.so) too! Finally "make install" has installed all of them. > > That certainly shouldn't have happened. Can you reproduce the problem? It could happen if you use *shared* in Modules/Setup and if setup.py is older than 1.30; before, it would use on builtin_module_names to exclude modules. So that was a problem once and should be fixed since 2.1b1. Regards, Martin From qrczak at knm.org.pl Sun Mar 18 18:15:02 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 18 Mar 2001 23:15:02 GMT Subject: Who's minister of propaganda this week? References: <98nu1m$12e@dispatch.concentric.net> <660ACCA1E4816F7E.C359CDF4168EF3FB.3B6B05538D619770@lp.airnews.net> <3AAFA13D.76E32C3F@divalsim.it> <98oa4o01i4v@news2.newsguy.com> <98q9h60122v@news2.newsguy.com> <9937en0bge@news2.newsguy.com> Message-ID: Sun, 18 Mar 2001 21:55:59 +0100, Alex Martelli pisze: > For example, say that you want to organize certain objects in a > container/contained hierarchy, with no nesting limits. > > All existing objects will be leaves in the resulting tree. Why does > this imply that such existing objects need to inherit from a certain > interface asserting "I may or may not be a container" (perhaps with > a default implementation stating "I am _not_ a container after all")? It doesn't imply that. > In a dynamically typed language, you will define an interface > (and perhaps a default implementation thereof) *only for container > objects*, i.e., the "new" organizing superstructure. Each container > will hold a set (e.g. a list, or dict) of (suitably tagged) > references to other objects; for recursive walks on the tree, one > will dynamically test whether a given object is-a container (else, > it's a leaf). In a statically typed language I would just recognize leafs on the container side, without relying on any properties of objects in leafs themselves. You solved a problem which did not exist. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From robin.thomas at starmedia.net Fri Mar 30 11:58:15 2001 From: robin.thomas at starmedia.net (Robin Thomas) Date: Fri, 30 Mar 2001 11:58:15 -0500 Subject: best practice? null/None vs 'None' vs '' (in web/sql) In-Reply-To: <9a2b9v+lrgp@eGroups.com> Message-ID: <4.3.1.2.20010330113737.00e39ab0@exchange.starmedia.net> At 04:12 PM 3/30/01 +0000, fluxent at yahoo.com wrote: >(Python 2.x, Win2K, IIS5) > >I've got some simple pages for viewing and editing SQL records via >Python in ASP. > >I would really like to distinguish between fields with null values >and fields that might actually include the text string 'None'. Right >now both cases come out from a SELECT as showing up as 'None', and >then when I submit and edit they definitely get changed to 'None', so >I end up with no nulls. > >I can see that the ODBC result set distinguishes them. But of course >when things get rendered out to HTML you don't want to see single >quotes around every string value, so 'None' and None become the same >thing. This about the limitations of "query arguments" to HTTP requests, not about any limitations of ODBC, Python, or ODBC/Python interfaces. HTTP query arguments are of one type: STRING. There is no concept of a "null" value; the closest thing you have is an "empty" string like "". In most database engines, there is a clear difference between NULL and "" in any textual or character data column. If your HTTP-based application wishes to consider some special string value as meaning "null", then you must choose which special string value will be considered "null". Then you must have your application transform data in two ways: transforming the special string to the null value (when processing HTTP request input), and transforming the null value to the special string value (on output of HTTP response). >So, I guess this isn't a platform bug, it's a nasty area calling for >some sort of interface standard. Is there a best practice I should >adopt? The best practice is consistency in your application. Pick a special value and go with it. The "lack of standard" is instead a lack of (or lack of need for) as built-in string-to-null-value conversion function. Python has int() and float() and others to convert strings to numeric objects. But a null() function is overkill. You can write it yourself: if a == "": a = None If you instead wish for a magical standard "convert a string into the neatest possible object" function, the magical standard may not do what you ask. Consider: magic_function("") magic_function("None") magic_function('"is this string quoted?"') magic_function("[]") magic_function("{'a': 5}") magic_function("6L") # form submitter's apartment number, not a long integer magic_function("11201") # zip code for ZIP_CODE VARCHAR column magic_function("6K5 B1E") # Canadian zip code for ZIP_CODE VARCHAR column Would these do the conversions you want in your application? In the case of "6L" as apartment number in an address form in HTML, definitely not. Because the policies of string-to-object conversion are so application-dependent, Python does not impose a magical standard that may cuase you headaches. Instead, it gives you specific type-conversion function like int() and float(), and lets you do the rest. >Maybe (a) transform the outputs of each SELECT to a different >representation of None (either '' or 'null'?), then (b) transform all >UPDATE query strings before executing them to change any ='' (or >='null') to =NULL? Yes. You've stated above that you do *not* wish to have "None" be the special string in your application. So you can pick something else. Many people choose the empty string "", which means that no input argument via HTTP can really be an empty string; it will always get converted to null/None by your application. def output(object): if object is None: return "" else: return str(object) def input(string): if not string: return None else: # maybe do other conversions to int() or float() return string # or use string unchanged -- Robin Thomas Engineering StarMedia Network, Inc. robin.thomas at starmedia.net From ct at gocept.com Fri Mar 23 15:48:51 2001 From: ct at gocept.com (Christian Theune) Date: Fri, 23 Mar 2001 21:48:51 +0100 Subject: Curses under python 2.0 References: <99darm$o3o$00$1@news.t-online.com> <3dsnk5zars.fsf@ute.cnri.reston.va.us> Message-ID: <99gcrj$b43$03$1@news.t-online.com> Ok. I did. Now. Tnx & best regards Christian Theune PS: why didn't i check this out before .... stupid baby myself ... In article <3dsnk5zars.fsf at ute.cnri.reston.va.us>, "Andrew Kuchling" wrote: > "Christian Theune" writes: >> >>> import curses >> Traceback (most recent call last): >> File "", line 1, in ? File >> "/usr/local/lib/python2.0/curses/__init__.py", line 15, in ? >> from _curses import * >> ImportError: No module named _curses > > You *did* enable the _curses module in Modules/Setup, right? > > --amk From dbrueck at edgix.com Wed Mar 21 13:17:36 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Wed, 21 Mar 2001 11:17:36 -0700 Subject: re.match Message-ID: <066601c0b233$3db4f700$450514ac@PRODUT2KDAVE> "Bob Cannard" wrote in message news:3AB8E6DF.A2C32AD8 at mentor.com... > - Is this string a Thing? (re.match - er, no, that doesn't work, > it only asks if this string begins with a Thing.) > Hi Bob, '$' matches 'end of string', so you _can_ use re.match to test "Is this string a Thing". -Dave -------------- next part -------------- An HTML attachment was scrubbed... URL: From ransen_spam_me_not at nemo.it Fri Mar 2 11:04:54 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Fri, 02 Mar 2001 16:04:54 GMT Subject: PyRun_SimpleFile - impossible to call it under Windows? Message-ID: <3aa07704.2672581@news.newsguy.com> I've seen that there is an odd bug in PyRun_SimpleFile probably because of version incompatibilities in the FILE structure and using DEBUG modes in VC6 I'd like to call PyRun_SimpleFile in the debug version of my VC6 program, is it impossible currently with Python 2? TIA Owen -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From andreas at andreas-jung.com Wed Mar 28 07:30:38 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Wed, 28 Mar 2001 07:30:38 -0500 Subject: dynamic web pages? References: <99q701$jlr10@news-1.bank.dresdner.net> <3AC0B262.6F0E30DE@gmx.net> Message-ID: <99tvno$d0k$1@slb7.atl.mindspring.net> And we have the small gun: PMZ (Poor Men's Zope): http://pmz.sourceforge.net Andreas "Robert Kiendl" schrieb im Newsbeitrag news:3AC0B262.6F0E30DE at gmx.net... > we have the BIG GUN here: Zope (www.zope.org) dynamic app.server in > native python logic including an OODBMS! > > or use cgi programming with apache From tjg at exceptionalminds.com Tue Mar 20 13:37:54 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Tue, 20 Mar 2001 10:37:54 -0800 Subject: Saving history in interactive Python Message-ID: <20010320103754.V3109@trufflehunter.avalongroup.net> Is there a way to save the history list in the Python interpreter. -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Red Hat Certified Engineer www.exceptionalminds.com Avalon Technology Group, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 62 days 22:52 hours ago<< From stephen_purcell at yahoo.com Mon Mar 26 03:56:55 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Mon, 26 Mar 2001 10:56:55 +0200 Subject: file locking In-Reply-To: <5zCv6.583$p5.2667@news1.rivrw1.nsw.optushome.com.au>; from root@excalibur.iks-jena.de on Mon, Mar 26, 2001 at 07:52:33AM +0000 References: <5zCv6.583$p5.2667@news1.rivrw1.nsw.optushome.com.au> Message-ID: <20010326105655.A4191@freedom.puma-ag.com> deadmeat wrote: > How do I lock a file on opening it? the bultin open() only allows me to set > the read/write mode, not any deny modes. On Unix, look at the 'flock' function in the module 'fcntl'. You can also try the 'posixfile' module -- posixfile objects support locking. -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From sholden at holdenweb.com Wed Mar 7 19:15:48 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 7 Mar 2001 19:15:48 -0500 Subject: gah! I hate the new string syntax References: Message-ID: "D-Man" wrote in message news:mailman.983997252.5628.python-list at python.org... > On Sat, Mar 03, 2001 at 03:19:05PM -0500, Steve Holden wrote: [ ... ] > > What about one who is both English and Scots, yet never set foot on > that island ;-)? > No such animal! regards Steve From matt at mondoinfo.com Wed Mar 21 14:52:45 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Wed, 21 Mar 2001 19:52:45 GMT Subject: Substitute for join() References: Message-ID: On Wed, 21 Mar 2001 11:35:53 -0800, Daniel Klein wrote: >I've got to make a script (written in version 2.0) to work on a machine >running 1.5.2. The only incompatible line is one that uses the >"".join(mylist) method. >>> import string >>> string.join(mylist,"") Will do what you want. Regards, Matt From tim.one at home.com Fri Mar 16 19:12:15 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 16 Mar 2001 19:12:15 -0500 Subject: list.sort(cmpfunc) question In-Reply-To: <3ab2a132@si-nic.hrz.uni-siegen.de> Message-ID: [Simon Budig] > ... > Is the sort-function guaranteed to be stable? Does it keep the order, > when cmpfunc returns 0 for a pair of items? No, Python's list.sort() is not stable. Stability can be "faked", though, by sorting a derived list y, where each element y[i] == (x[i], i). Then no two list elements are equal. Because tuples are compared lexicographically, cmp((x, i), (x, j)) has the same sense as cmp(i, j), thus preserving the original order of equal elements in x. Caution: if a list is "short enough", list.sort() falls back to a binary insertion sort, and IIRC that *is* stable. So trying out small examples may fool you. forewarned-is-forearmed-ly y'rs - tim From belrick at home.com Sun Mar 11 15:58:59 2001 From: belrick at home.com (Bruce Elrick) Date: Sun, 11 Mar 2001 20:58:59 GMT Subject: Einstein's Riddle References: <98glrd$1si1a$1@ID-75892.news.dfncis.de> Message-ID: <3AABE712.499CCF4C@home.com> I swear there is no evidence that any of them own a fish. The German owns an emu. Bruce Boris Popov wrote: > > "Steve Graham" wrote in message > news:oNPq6.396644$ge4.138479566 at news2.rdc2.tx.home.com... > > Who would be interested in using his/her brain (and his computer) to solve > > the following? > > > > > > Steve Graham > > > > === > > > > Einstein's Riddle > > > > Albert Einstein wrote this riddle this century [ed. 20th century]. He > said > > 98% of the world could not solve it. > > > > There are 5 houses in 5 different colors. In each house lives a person > with > > a different nationality. The 5 owners drink a certain type of beverage, > > smoke a certain brand of cigar, and keep a certain pet. No owners > > have the same pet, smoke the same brand of cigar or drink the same > beverage. > > > > The question is: "Who owns the fish?" > > > > Hints: > > > > The Brit lives in the red house. > > > > The Sweed keeps dogs as pets. > > > > The Dane drinks tea. > > > > The green house is on the left of the white house. > > > > The green house's owner drinks coffee. > > > > The person who smokes Pall Mall rears birds. > > > > The owner of the yellow house smokes Dunhill. > > > > The man living in the center house drinks milk. > > > > The Norwegian lives in the first house. > > > > The man who smokes Blends lives next to the one who keeps cats. > > > > The man who keeps the horse lives next to the man who smokes Dunhill. > > > > The owner who smokes Bluemasters drinks beer. > > > > The German smokes Prince. > > > > The Norwegian lives next to the blue house. > > > > The man who smokes Blends has a neighbor who drinks water. > > > > I don't beleive he said that only 2% of the world could solve it. It's not > hard, you just need to pay attention to the details. The German owns the > fish. It was supposed to be a table that I used to layout all the details, > but I prefer to post plain-text: > > house 1 2 3 4 5 > color yellow blue red green white > nationality norweigian dane brit german swede > drink water tea milk coffee beer > smoke dunhill blend pall mall prince bluemaster > pet cats horse birds fish dogs > > -Boris > P.S. Did I have to write software to solve it ? :) From aahz at panix.com Mon Mar 26 18:41:48 2001 From: aahz at panix.com (Aahz Maruch) Date: 26 Mar 2001 15:41:48 -0800 Subject: Namespaces question References: Message-ID: <99ok3s$mkg$1@panix3.panix.com> In article , Chris Withers wrote: > >def create(self): > > for name in ['x','y','z']: > value = session.get(name,None) > if value is None: > errors.append('No %s supplied.' % name) > else: > locals()[name]=value > > if errors: > return errors > > print x > >...now I know it's not right, 'cos I get a NameError on x at the print >statement. > >What should I be using instead of locals()? Just use a dictionary: "print dict['x']" works fine -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Boost the stock market -- fire someone" From nadavh at envision.co.il Wed Mar 7 02:27:23 2001 From: nadavh at envision.co.il (Nadav Horesh) Date: Wed, 07 Mar 2001 09:27:23 +0200 Subject: NumPy's undocumented type code Message-ID: <3AA5E2DB.45BFD417@envision.co.il> An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: nadavh.vcf Type: text/x-vcard Size: 360 bytes Desc: Card for Nadav Horesh URL: From peter at schneider-kamp.de Fri Mar 9 14:02:20 2001 From: peter at schneider-kamp.de (Peter Schneider-Kamp) Date: Fri, 09 Mar 2001 20:02:20 +0100 Subject: "!=" is bad form. Re: sorry....never mind References: Message-ID: <3AA928BC.1DAB4284@schneider-kamp.de> Dave Brueck wrote: > > I don't really care if Python keeps <>, but the reason I don't like it is > because of the example listed above: to me seeing "<>" implies something > about the ordering of a and b, namely (a < b) or (a > b), even when such an Well, Python *does* define an ordering of a and b, no matter what a and b may be. E.g.: >>> 1 > (1,2) 0 >>> 1 < (1,2) 1 >>> {"a":1} < u"hello world" 1 >>> {"a":1} > u"hello world" 0 So, yes, interpreting "a <> b" as "(a < b) or (a > b)" makes perfect sense in Python. not-sure-comparing-strings-and-dictionaries-is-a-sane-thing-to-do-ly y'rs Peter From Denys.Duchier at ps.uni-sb.de Sat Mar 24 18:13:20 2001 From: Denys.Duchier at ps.uni-sb.de (Denys Duchier) Date: 25 Mar 2001 00:13:20 +0100 Subject: [Python-Dev] Anyone using weakrefs? References: Message-ID: "Tim Peters" writes: > Still, I've been happily playing w/ this little module: > > import weakref > id2obj_dict = weakref.mapping() > > def remember(obj): > id2obj_dict[id(obj)] = obj > > def id2obj(id): > return id2obj_dict.get(id, None) If memory serves, in T3 (Yale Scheme) the printed representation of an object included an integer id which you could use as a key to look up the object in a weak table. Quite convenient for interactive use. Cheers, -- 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 phd at phd.pp.ru Tue Mar 13 12:18:39 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 13 Mar 2001 20:18:39 +0300 (MSK) Subject: Sortin dictionaries in python In-Reply-To: <3aae4757.68617130@News.CIS.DFN.DE> Message-ID: On Tue, 13 Mar 2001 costas at springmail.com wrote: > Is there a simple way to sort a dictionary? It seems the only way to > do this is by indirectly creating a sorted list. There is no. > And while on the topic of sorting lists. I tried sorting a list and > wanted to to pass a compare function to the list.sort() method. The > documentaion gives no example. > > import string > > x=['a','c','B'] > > def ignoreCase(left, right): > if string.upper(left) < string.upper(right): > return -1 > else: > return 1 > > x.sort(ignoreCase(left, right)) You are close: x.sort(ignoreCase) Pass the function, not call it :) BTW, ignoreCase (like any other comparison function) should return 0 if left == right! Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From stevewilliams at wwc.com Tue Mar 13 11:11:13 2001 From: stevewilliams at wwc.com (Steve Williams) Date: Tue, 13 Mar 2001 16:11:13 GMT Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> <3aad4485.2348499@News.CIS.DFN.DE> Message-ID: <3AAE46B5.963FC3CE@wwc.com> Grant Edwards wrote: > In article , Fredrik Lundh wrote: > >costas at springmail.com wrote: > >> I will also tell my customers that this is the new math. > > > >if you don't understand how floating point numbers work, you > >probably shouldn't use them in customer projects. > > Fredrik is right. Using floating point numbers requires that > you know what you're doing. They are _not_ exact. If your > customers are expecting exact results and you're using floating > point numbers, then you did a bad thing. > > People should have to pass a test before they're allowed to use > floating point numbers. 1/2 ;) > [snip] Languages supporting serious commercial numeric processing have the dreaded static typing. Viz: Picture 99v99 in COBOL or Decimal(4,2) in DDL That way you 'do the right thing' in your *intermediate* calculations without having to sit the exam for floating point or remembering to 'adjust the scale and precision' for fixed point. And using print formatting to solve the problem is [wait for it] missing the point. From MarkH at ActiveState.com Fri Mar 23 18:15:44 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Fri, 23 Mar 2001 23:15:44 GMT Subject: Python Script to dial a VPN connection, automate VPN routing table updates. References: Message-ID: <3ABBDA6D.2000305@ActiveState.com> Warren Postma wrote: > Sorry for the nearly-off-topic nature of this post, but .... > > I work from home now, and there's something in Windows 2000 that's > annoyingly manual: > > I have a permanent internet connection via @home cable modem, and I "dial" > through that to create a VPN connection to the office. The problems are > two: > > (1) Windows won't accept or save my userid, password and the domain name, so > I have to enter it manually. > > (2) After connecting, I have two default gateways in my routing tables > (ROUTE PRINT) and I need to update it so only the traffic that is destined > to the office goes through that interface. The IP addresses I get given are > different each time, making a batch file insufficient, so voila, a perfect > use for python. I have very similar problems. Here is a script I wrote for the purpose. It doesnt handle authentication sa Windows does remember the password etc for me. When run with a command-line option being the VPN connection name, it establishes a connection to the named site. Once connected, or if an argument is not given it attempts to find the IP of the VPN connection and manually add a route for the VPN. Thus, I generally use it with no options after manually connecting - not for any good reason actually, just that is the way I do it :) import os import sys import win32ras def Connect(rasEntryName, numRetries = 5): # See if already connected for info in win32ras.EnumConnections(): if info[1] == rasEntryName: print "Already connected to '%s'" % (rasEntryName,) return 1 dial, have_pw = win32ras.GetEntryDialParams(None, rasEntryName) if not have_pw: print "Error: The password is not saved for this connection" print "Please connect manually selecting the 'save password' option and try again" sys.exit(1) retryCount = numRetries bValid = 0 print "Connecting to:", rasEntryName while retryCount > 0: rasHandle, errCode = win32ras.Dial(None, None, dial, None) if win32ras.IsHandleValid(rasHandle): bValid = 1 break print "Retrying..." win32api.Sleep(5000) retryCount = retryCount - 1 return bValid def FixRoute(): data = os.popen("ipconfig", "r").readlines() have_ppp = 0 ip_str = None for line in data: if line.startswith("PPP"): have_ppp = 1 if have_ppp and line.strip().startswith("IP Address"): ip_str = line.split(":")[1].strip() if ip_str is None: print "ERROR: could not find the PPP ip address" else: print "Your PPP IP address is", ip_str cmd = "route add 192.168.2.0 mask 255.255.255.0 %s" % (ip_str,) print cmd os.system(cmd) print "Route updated." if len(sys.argv) == 2: if not Connect(sys.argv[1]): print "Could not connect to '%s'" % (sys.argv[1],) sys.exit(1) else: print "No connection name specified - just adding route..." FixRoute() From dnew at san.rr.com Sun Mar 18 17:15:34 2001 From: dnew at san.rr.com (Darren New) Date: Sun, 18 Mar 2001 22:15:34 GMT Subject: Who's minister of propaganda this week? References: <98nu1m$12e@dispatch.concentric.net> <3AAFA861.C773D977@san.rr.com> <992qbh$et7$1@nntp.Stanford.EDU> Message-ID: <3AB53387.9AEF272D@san.rr.com> > Don't underestimate convenience. :-) If you had to declare each > string value in your program as a class like the above, it would make > strings less useful in a practical sense although they'd still be > equivalent in a theoretical sense. True. On the other hand, there are things like co-routines which, to get the same effect, you have to basically implement co-routines rather than just use an inconvenient syntax. I think there's actually a rather big difference between "inconvenience" and "impossible". :-) -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. A million monkeys in a room with a million typewriters will only yield half a million pregnant monkeys. From phlip_cpp at my-deja.com Wed Mar 14 09:08:54 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 14 Mar 2001 14:08:54 GMT Subject: Who's minister of propaganda this week? References: Message-ID: <98nu1m$12e@dispatch.concentric.net> Proclaimed Cameron Laird from the mountaintops: > Sure; Bruce "Mr. Java" Eckel says Python's his favorite language. > That was last week's news. What would you think if the former > editor of the *C++ report* gave his > prediction for this decade: Keep an > eye on languages like Python, Ruby, > and Smalltalk. They are likely to > become extremely important. Robert C. Martin meant two things. A> If you write wall-to-wall unit tests when you code, if you use a typeless language you will add bullet-proof features faster than if you use a statically typed language, even though the former has less built-in error checking at type conversion time. The latter supports refactoring easier. B> The full depth of behaviors we should expect from a typeless language have yet to be fathomed. Ruby trumps Python in the simple matter of closures (imagine my shock when I discovered Python didn't have them). But a language "like" those might win the decade. > I heard you wiseacres in the back there, with the, "But Python > and Smalltalk *already* are extremely important" comment. Many pointy-haired bosses are unaware of the former, and think the latter is some academic curiosity. That's why selling Java (a statically typed language) to these bosses was so easy. -- Phlip phlip_cpp at my-deja.com ============== http://phlip.webjump.com ============== -- Please state the nature of the programming emergency -- From adaminthedomaindevtty.net Sat Mar 3 01:15:45 2001 From: adaminthedomaindevtty.net (Adam Logghe) Date: Fri, 2 Mar 2001 22:15:45 -0800 Subject: Editing Python source as XML? References: Message-ID: <3a9fe475_1@news.nwlink.com> It sounds like the feature you are really looking for is frequently called "code folding". I also find it to be very useful. You have many options in editors unfortunately IDLE does not yet support code folding. www.activestate.com has a project called "Komodo" which is written with a combination of the Mozilla codebase and Python (my understanding is that originally this was also to have a substantial portion written in Perl but the developers could code so much faster in Python that Perl ended up as a minor part). Despite some primitive features I have begun to use this full-time, I find it the easiest to use for editing multiple files. I'm hoping they start supporting XML folding as well. www.activestate.com also supports "PythonWin" which is basically a Windows specific enhanced version of IDLE. http://archaeopteryx.com/ is selling an Editor for Linux which also supports code folding and looks very capable. It is available for free if you are using it to develop free software. I know I am missing one more fairly significant editor, I am sure someone else will point that out (extra points for not mentioning vi or emacs). By the way, there are several shareware editors available that support Python and code folding. Search on hotfiles.com Adam in the domain devtty.net "Steven Haryanto" wrote in message news:mailman.983546704.10789.python-list at python.org... > A recent experience of having to modify a long C source file has > led me to wonder whether there are any tool/effort towards editing > Python source code as XML or other form of structured document. > > What I would like is an editor that presents the source file as a > tree outline, where I can collapse selected class or function > definition body, certain long if's/for's, some section of code, > view/hide the asserts, etc. So then I only have to deal with the > section I am concentrating with and don't have look at other > distracting parts (especially in C with all those #ifdef/#endif's, > argh...). > > I visited conglomerate.org some months ago, and it seems the > project has been abandoned. > > Thanks, > Steve > > From fig at monitor.net Wed Mar 21 19:17:32 2001 From: fig at monitor.net (Stephen R. Figgins) Date: Wed, 21 Mar 2001 16:17:32 -0800 Subject: Puzzling input problem Message-ID: <3AB9449C.A1D14738@monitor.net> I ran into a puzzling problem combining print with raw_input(). Normally I would pass the prompt string to raw_input, but instead I tried something like this: print "prompt string: ", answer = raw_input() print answer When it prints answer, it is indented one space. Why is raw_input() putting a space in there? Is it a bug, a feature, an unintended side effect? input() does this too. I am currently using Active Python 2.0 build 202. When I tried it with Jython 2.0, I didn't get the extra space. Stephen From dwig at advancedmp.net Mon Mar 19 13:53:45 2001 From: dwig at advancedmp.net (Don Dwiggins) Date: 19 Mar 2001 10:53:45 -0800 Subject: windows script host and python In-Reply-To: Tim Roberts's message of "Sat, 17 Mar 2001 20:57:12 -0800" References: <%tKr6.2570$pX.26174@news1.onlynews.com> <98oq3r$1e0$1@troll.powertech.no> <8Aps6.104$pl.1515@newsfeed.slurp.net> <98tc4d0rmk@news1.newsguy.com> Message-ID: Tim Roberts writes: > "Alex Martelli" wrote: >> >> Here, for example, is the "list all running processes" WMI scripting >> example translated into Python: >> >> from win32com.client import GetObject >> >> processes = GetObject("winmgmts:{impersonationLevel=impersonate}").\ >> InstancesOf("Win32_process") >> >> for process in processes: >> print process.Name > Cool! Is this supposed to be NT-only? It doesn't fly on my Win98 box. Actually, it fails on my NT workstation also: Traceback (most recent call last): File "", line 3, in ? File "e:\python20\win32com\client\__init__.py", line 72, in GetObject return Moniker(Pathname, clsctx) File "e:\python20\win32com\client\__init__.py", line 87, in Moniker moniker, i, bindCtx = pythoncom.MkParseDisplayName(Pathname) pywintypes.com_error: (-2147221020, 'Invalid syntax', None, None) Just FYI, I haven't tried to debug it. -- Don Dwiggins "Solvitur Ambulando" Advanced MP Technology dwig at advancedmp.net From alex at server01.shindich.com Sun Mar 25 19:01:54 2001 From: alex at server01.shindich.com (Alex Shindich) Date: Mon, 26 Mar 2001 00:01:54 +0000 (UTC) Subject: Yet Another PEP: Interface Adapter Mechanism __adapt__ Message-ID: It sounds like your PEP suggests adding Strategy pattern behavior to all Python objects. My question is WHY? Implementing strategy pattern, i.e. asking object if it supports a particular interface, is trivial. In fact, you can do it easily by using introspection, i.e. hasattr (obj, 'blah'). There are other ways of implementing strategies -- flyweights, query interface, etc. Another way of looking at your PEP is to say that you are asking for Python Java-like interfaces. In my humble opinion, interface driven programming is not as needed in Python because of introspection. Instead of asking if the object supports a set of methods, you can ask if object supports individual methods. -- Alex Shindich mailto:alex at shindich.com Visit http://www.shindich.com/ -- Posted from adsl-63-194-17-248.dsl.lsan03.pacbell.net [63.194.17.248] via Mailgate.ORG Server - http://www.Mailgate.ORG From austinw at bhpvillage.com Mon Mar 5 03:07:10 2001 From: austinw at bhpvillage.com (Austin Wilson) Date: Mon, 5 Mar 2001 19:07:10 +1100 Subject: ftp a list to a remote server Message-ID: Hi I would like to save a list as a text file on a remote server using ftp. Is this possible? If so, could you please provide some sample code. Or do I have to save the file locally first then ftp that file to the remote server? Thanks Austin From gerhard.nospam at bigfoot.de Wed Mar 14 08:57:09 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Wed, 14 Mar 2001 14:57:09 +0100 Subject: Python interacting with Java Script webpage? References: Message-ID: On Tue, 13 Mar 2001 19:37:14 GMT, William Dandreta wrote: >I would like to write a Python program that will be able to connect to a >webpage that runs a Java Script, post data to the form displayed, and save >the data retrieved to a file. Hmm. As I see it, the JavaScript is irrelevant here. What you probably want is to have a CGI script output a HTML page with a form included. And the form fields should be already filled with default values or values that were stored earlier, like user preferences. Am I right? I have attached a quick and dirty CGI script that should show the basics of how this can be done. >I have been looking for a book, tutorial, or any docs that will take me from >not having a clue as to how to do it to being able to write the program. For an example, you can look at the source code of the CGI module, there is a test function in there that uses most of the modules functionality and is also useful for debugging. Gerhard ##################################################################### #!/usr/bin/env python # FillForm demo script import string, cgi def printRetrievedData(): # could write data to file instead print cgi.FieldStorage(), '
' * 3 def printForm( fields, submiturl ): print '

' % ( submiturl ) for ( key, value ) in fields.items(): print '%s:
'\ % ( key, key, value ) print '
' print '
' # Mapping of name of form fields to values form_fields = { 'Name' : 'Gerhard', 'favlanguage' : 'Python' } # URL of the CGI-Script, probably to be adjusted cgi_url = '/cgi-bin/ff.py' print 'Content-type: text/html\n' print '

' printRetrievedData() printForm( form_fields, cgi_url ) print '

' -- mail: gerhard bigfoot de web: http://highqualdev.com From jmarshal at mathworks.com Thu Mar 29 13:42:41 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 29 Mar 2001 18:42:41 GMT Subject: how query function args References: <3AC374BC.F90A2894@abaqus-sn.com> Message-ID: <99vvn1$bmh$1@news.mathworks.com> david winkler wrote: > I need to query the names and values of a function's keyword arguments. > I > suspect that there is an easy way to do this but cannot find it. Would > someone care to make a suggestion? func.func_defaults will return a tuple of the default values, but not the names of the formals. From just at letterror.com Thu Mar 15 03:40:46 2001 From: just at letterror.com (Just van Rossum) Date: Thu, 15 Mar 2001 09:40:46 +0100 Subject: Cameron Laird Quote on www.unixinsider.com -- Probably old news to y'all, but new to me. References: <3AB00593.D1C4BBBF@fxtech.com> Message-ID: <3AB08001.9532A3F0@letterror.com> "Paul T. Miller" wrote: > > > I apologize for trotting it out again, if I am repeating something earlier > > discussed, but I couldn't find any direct reference to it (my nntp server > > sucks, only goes back 7 days). > > > > All I'll add is: Well said, Cameron! > > I love Python. I especially love it as an embedded scripting language. > But it is not going to replace graphics applications where speed is > paramount. Many of these articles fail to take that into account. But > then again, many problem domains do not have the interaction constraints > that 3D or compositing applications have. Yeah, I was going to say: there's an awfully large application area _between_ scripting and interactive 3d graphics apps! Python already does quite well with interactive 2d graphics, though: see eg. Sketch. Just From pinard at iro.umontreal.ca Thu Mar 29 21:11:23 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 29 Mar 2001 21:11:23 -0500 Subject: I come to praise .join, not to bury it... In-Reply-To: <98tacr0q5s@news1.newsguy.com> References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> <3AAF7E47.294617E1@sage.att.com> <98qeco02hn7@news1.newsguy.com> <98rmod$c8p$1@animus.fel.iae.nl> <98tacr0q5s@news1.newsguy.com> Message-ID: [Alex Martelli] > Somebody who's unable to do anything but talk of aesthetics when > discussing a choice in the architecture of a software component is simply > not contributing to the discussion. It looks good to you, it looks > bad to him, it looks indifferent to her, yawn, great debate, now let's > get beyond this to the REAL meat of the issue, please -- the technical > implications of this, that, or the other choice in a specific matter. I just want to emphasize, as others replied already, that aesthetics (or better said in this precise context, legibility and understandability) *is* real meat. Consider that Python is art turned into technique :-). By being technical for the only sake of it, we are escaping something important. > If you _can't_ get down to concrete specifics, then either you're not > investing enough time & energy to contribute (in which case, staying > out of a debate WOULD be a nice matter of courtesy) Sorry if I'm looking impolite to you, then (:-). I still think that minor contributions, and even opinions, should not be merely or wholly dismissed because their author is not available enough to write and sustain a PEP! > IF the huge investment of time and energy doesn't faze you [...] striving > to help others articulate their objections, in great detail, by first > laying out in just as much details my reason for NOT objecting at all > to the architecture Guido has chosen for .join; it won't of course have > any direct repercussion on how Python behaves in the matter, but it MAY > have positive implications on technical growth of the people involved, > and thus, very indirectly, on future efforts on their part). I'm not trying to systematically argue, here, but yet, I would like to counter-weight a tiny bit the attitude which is depicted above. Investing a lot of energy into a project undoubtedly helps someone to develop more complex and structured opinions, and is often a good step towards acquiring more competence. However, the amount of work invested does not necessarily guarantee competence, and someone may mislead himself into dubious tracks for quite a long while. I presume we all know people that did such mistakes. Huge investment of work is never a complete guarantee of being right, and simple remarks from casual users are not necessarily wrong, even if they do not show commitment to spoil all their sweat and blood arguing with you. > it _still_ boils down to aesthetics being AT BEST a mental and verbal > shorthand to avoid the considerable investment required to articulate > the concrete underlying realities in detail. The scheme is usual, to me at least. It takes a tremendous amount of energy for me to argue with people which are already set on an idea, and even after having exhausted myself, I have no guarantee at all that any progress will result of all that expense. After many years, I learned how to spare myself a bit better. Yet, I still do not accept, for one, to hear that my opinion is not worth being listened, just because I'm not ready to fight hard for it. > AT WORST (and, I suspect, more often, particularly in Usenet debates) > a way for somebody to keep spewing words on a subject on which they > actually have nothing concrete, constructive, and useful to say. Note that I understand that you, too, need some protection against abuse. We all lived it. Best, however, is to not become over-protective! :-) In the case under discussion, here, I suspect that the community has shown enough reluctance to consider that there was at least something to ponder. Details may well have been articulated, but if they are not even listened at, there is no point in repeating them endlessly: this is a lost cause. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From jepler at inetnebr.com Mon Mar 26 20:19:01 2001 From: jepler at inetnebr.com (Jeff Epler) Date: Tue, 27 Mar 2001 01:19:01 GMT Subject: Newbie needs help to find bug in his first Perl program References: <3ABCC757.6C6F17CA@earthlink.net> <3ABE73B2.CAFCA177@student.liu.se> <3ABD67C6.7B714D7A@earthlink.net> Message-ID: On Mon, 26 Mar 2001 04:24:14 GMT, Ron Stephens wrote: >This is a multi-part message in MIME format. >--------------FD2A49219370BD01A077FCD5 >Content-Type: text/plain; charset=us-ascii >Content-Transfer-Encoding: 7bit > >Thanks, Richard, you solved my problem, despite my fuzzy question ;-))) and >to the rest of you, yes, I will try to be much more careful and precise from >now on when asking for help! Point acknowledged. Ron, To help introduce you to the power of Python, I have written a program with a similar intent to yours. It lets a user enter any number of options and criteria, but it uses some of Python's versatile data types (mostly the "dictionary", but a few lists), functions, and loops to reduce the amount of code which must be repeated by the programmer (imagine when your client asks you to make your program support 99 options and 100 criteria! Without loops, that's well over 10,000 lines the programmer has to write). I've tried to add comments that will explain what is going on. I think that almost all of the ideas in this program are present in the Tutorial document. The "sort" at the end is probably the hardest to understand. Good luck with Python! ------------------------------------------------------------------------ # This code is placed in the public domain def get_list(heading, prompt): """ get_list(heading, prompt) -> list This function prompts for a list of things. The heading is printed on a line by itself, and the prompt must have a %d substitution for the number of the item within the list. """ print heading print print "(enter a blank line to end the list)" ret = [] i = 1 while 1: line = raw_input(prompt % i) if not line: break ret.append(line) i=i+1 print return ret def get_number(prompt): """ get_number(prompt) -> float This function prompts for a number. If the user enters bad input, such as "cat" or "3l", it will prompt again. """ res = None while res is None: try: res = float(raw_input(prompt)) except ValueError: pass return res # First, ask the user to enter the lists options = get_list("Enter your options", "Option %d: ") criteria = get_list("Enter your criteria ...", "Criterion %d: ") # Next, get the user to rank his criteria. I use a system where higher # is better, so that an undesirable characteristic can be given a negative # weight. # # {} is a dictionary, it can be indexed by (nearly) any expression, # and we will index it with the names of the criteria. # (For a more traditional program, we could use a list and index by the # number of the criterion) rankings = {} print print "Enter relative importance of criteria (higher is more important)" print for c in criteria: rankings[c] = get_number("Criterion %s: " % c) # Next, get the user to score each option on all the criteria. # Here, we index the dictionary on the pair (option, criterion). # This is similar to a two-dimensional array in other languages score = {} print print "Enter score for each option on each criterion" print for o in options: print print "Scores for option %s" % o print for c in criteria: score[o, c] = get_number("Criterion %s: " % c) # Calculate the resulting score for each option. This equation # is different from Rod Stephen's original program, because I # make more important criteria have higher rankings, and even let # bad criteria have negative rankings. # The "result" dictionary is indexed with the names of the options. result = {} for o in options: value = 0 for c in criteria: print o, c, rankings[c], score[o, c] value = value + rankings[c] * score[o, c] result[o] = value # Now, I want to take the dictionary result, and turn it into a ranked list. results = result.items() # A list of tuples (key, value) results.sort(lambda x, y: -cmp(x[1], y[1])) # Sort the list using the reverse of the # "value" of the entry, so that higher # values come first print print "Results, in order from highest to lowest score" print print "%5s %s" % ("Score", "Option") # Take the pairs out of results in order, and print them out for option, result in results: print "%5s %s" % (result, option) ------------------------------------------------------------------------ From aleaxit at yahoo.com Sat Mar 10 17:47:41 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 10 Mar 2001 23:47:41 +0100 Subject: Can anyone recomend a good intoduction to C... References: <989mbk$24nuv$1@fido.engr.sgi.com> <98auhn0270j@news2.newsguy.com> <98dpoe12ckn@news1.newsguy.com> <3AAA85C1.81FB90AA@shore.net> Message-ID: <98eb1f02uqq@news1.newsguy.com> "Kurt B. Kaiser" wrote in message news:3AAA85C1.81FB90AA at shore.net... > Alex Martelli wrote: > > > Your opinion is widespread, and self-perpetuating, but it has no > > current technical basis for such tasks as Python extensions on Linux. > > > My understanding is that the C++ compiler for Linux is still > considered to be unstable and that that is a significant technical > factor for sticking with C? Interesting; we developed and deployed C++ applications for years on gcc on various Unix boxes around the mid-90's, and we had no problems with "unstable compilers" (then, the market forced our hand so we switched to Win/NT and VC++ -- now THAT was another ball of wax at the time, though it HAS gotten better since). It's no doubt possible that gcc has significantly worsened in the last 5 or 6 years, but I'll confess that would really surprise me. Alex From cerutti at together.net Thu Mar 1 10:12:58 2001 From: cerutti at together.net (Neil Cerutti) Date: 1 Mar 2001 15:12:58 GMT Subject: Allow anything in identifiers? References: <3A9DC13A.1647EE51@home.se> Message-ID: Sverker Nilsson posted: >This would be a new kind of identifiers, I suppose one >can make them by writing for example id like in: > >id 'a>b' = a > b >id 'x.b' = x.b >alu.id'+' = lambda x, y... > >I think it could make programs easier to read by allowing >more evident identifiers in many cases. The extended identifier >syntax should not break anything, and it seems it might be easy to >implement... I have to admit I love being able to use function names like number? and list->word in scheme. is_number and list_to_word are just harder to type and to read. -- Neil Cerutti "The Analytical Engine weaves algebraic patterns just as the Jacquard loom weaves flowers and leaves." -- Lady Lovelace From stephen_purcell at yahoo.com Thu Mar 29 09:23:28 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Thu, 29 Mar 2001 16:23:28 +0200 Subject: Whats in your $PYTHONSTARTUP$ ? In-Reply-To: <20010329083827.B4611551@vislab.epa.gov>; from aa8vb@yahoo.com on Thu, Mar 29, 2001 at 08:38:27AM -0500 References: <20010329083827.B4611551@vislab.epa.gov> Message-ID: <20010329162328.A631@freedom.puma-ag.com> Randall Hopper wrote: > Just a little fragment to colorize my python prompts. Nowadays, I'm always > on a VT100 color capable terminal (recent xterm, aterm, FreeBSD/Linux > console, etc.). > > import sys,os > if os.environ.get( 'TERM' ) in [ 'xterm', 'vt100' ]: > sys.ps1 = '\001\033[0:1;32m\002>>> \001\033[0m\002' > sys.ps2 = '\001\033[0:31m\002... \001\033[0m\002' > That's nice. And you can set the xterm title string using: if os.environ['TERM'] in ('rxvt', 'xterm'): sys.stdout.write('\033]0;python in %s\007' % os.getcwd()) You could add in all kinds of nice stuff like the Python version number and the hostname (sys.version, socket.gethostname)... -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From chris.gonnerman at usa.net Fri Mar 9 09:03:51 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Fri, 9 Mar 2001 08:03:51 -0600 Subject: learning C References: <983975751.18833@newsmaster-04.atnet.at> <3AA82422.53026D3D@cosc.canterbury.ac.nz> <20010308221519.A4367@harmony.cs.rit.edu> <984135226.858948@newsmaster-04.atnet.at> Message-ID: <006301c0a8a1$c856b2e0$a100000a@local> ----- Original Message ----- From: "Werner Schiendl" Subject: Re: learning C > The compiler vendors already did it on a lot of platforms. > C++ will swallow C, because C is nearly a subset of C++. The COMPILER swallows C, C++, and (in the case of the newer GCC) a bunch of other languages. Fortran is in there, but you won't catch me using it. > If you have a full cupboard of tools installed, what sense does it make to > ignore 90% of it?? I forget who first quoted the famous bear, but I too am of "little brain". This doesn't mean I'm not a competent programmer, but only that the cost of learning the "new tools" of C++ is just too high for the benefits I perceive. I also agree with the assertion that C is more predictable than C++; yeah, I know I could learn all the rules for performance etc. but that is exactly what I am complaining about. For OOP I choose Python. For raw power and control I choose C. If I need both, I extend Python with C. My Python extensions tend to be quite small; in fact, the Windows Conio (WConio) package that I wrote got smaller with each version, as I removed code from the C extension and put it in the Python wrapper layer. > Why not have a look at all of it and use what's suited for the application > best? Like I said, been there, done that, couldn't afford the T-shirt. Rewiring my brain for C++ is just too hard. I'm glad that it works for you, and many others, but there are also many like me that can't see why you are pushing so hard. I guess you just can't see our point of view, though I think I see yours just fine. From kens at sightreader.com Wed Mar 28 13:07:35 2001 From: kens at sightreader.com (Ken Seehof) Date: Wed, 28 Mar 2001 10:07:35 -0800 Subject: What *instance* called me & proxy methods References: <3AC1BE92.ACE82741@ua.ac.be> <5.0.2.1.0.20010328104602.021cfc40@mail.inet.com.br> Message-ID: <003701c0b7b2$039b1250$04090a0a@upcast.com> You want 'im_self'. Also, you might find 'im_func' handy as well. It returns the function, so you can unbind a bound method. >>> class X: ... def a(self): ... return 1 ... >>> x = X() >>> x.a >>> x.a.im_self <__main__.X instance at 01390DFC> >>> x.a.im_func - Ken Seehof ----- Original Message ----- From: "Carlos Alberto Reis Ribeiro" To: Sent: Wednesday, March 28, 2001 8:57 AM Subject: What *instance* called me & proxy methods > I've seen some talk on how to get the name of the caller. I got a related > problem to solve, only slightly more complicated. > > Can I know what *instance* called a method? I'm not talking about "self" > here, because we *can* call a method using other techniques, such as > copying the instance method pointer directly: > > >>> class myclass: > ... def hello(self): > ... print "hi! I'm ", self > >>> class myproxy: > ... pass > >>> a = myclass() > >>> a.hello() > hi! I'm <__main__.myclass instance at 015093EC> > >>> m = a.hello > >>> p = myproxy() > >>> p.m = m > >>> p.m() > hi! I'm <__main__.myclass instance at 015093EC> > > In both cases, hello() received the same value as the self parameter. This > is exactly what I need; in fact, the im_self attribute of the instance > method stores the pointer to self, which explains this behavior. However, I > would also like to have some information to differentiate between these two > calls. My goal is to implement some security checking as part of my > proxy/adapter module [1]. I have already tried some simple minded > approaches (too many to list here), so far with no success. > > The best solution the I have thought so far can be implemented as a Python > extension - if I manage to put my Linux box up and running (I'm gcc-less > right now :-). > > 1) Implement a new object called 'ProxyMethod', derived of 'instance > method', with the following differences: > > * It does not make the im_* attributes visible to the outside > world; > > * It stores a read-only attribute to the proxy that 'owns' the > ProxyMethod. > > 2) The 'ProxyMethod' constructor would take a instance method and > build the proxy method from it. > > 3) The information about the proxy would need to be stored somewhere > in the call stack. I dont know if it is possible without changing > some of the Python internals. > > 4) The runtime semantics of the 'ProxyMethod' would be about the > same as the ones of the instance method - just a direct call, > without any extra intermediation. > > I would like to know what the community thinks about turning this into a > PEP. Maybe we can find a simpler solution, or it's better to keep this as a > module outside the distribution. > > For now I have a very simple Python implementation. It's far from perfect, > and it has some undesirable side effects because it is not completely > transparent, and it needs some intermediate processing. The only way that I > found to signal to the proxied object about the existence of the proxy was > to create a temporary "proxy" attribute (see point (3) above). However, it > serves it purpose as a proof-of-concept: > > ---------------------------------------------------------------------- > TEST RESULT > > >>> n = NuclearArsenal() > >>> n.NuclearAttack("NY") > Only the proxy can order the attack > >>> p = Proxy() > >>> p.attack = ProxyMethod(n.NuclearAttack, p) > >>> p.attack("NY") > Boooom! NY destroyed > > ---------------------------------------------------------------------- > CODE > > """ ProxyMethod proof-of-concept > (c) 2001 Carlos Ribeiro - cribeiro at mail.inet.com.br > Released in public domain for use "as-is" > """ > > from types import * > > class Proxy: > pass > > class ProxyMethod: > > def __init__(self, im, p): > if type(im) != MethodType: > raise "A proxy needs a method" > if p.__class__ != Proxy: > raise "A proxy method is bounded to a proxy" > self.im = im > self.p = p > > def __call__(self, *a): > # set a flag inside the target instance > setattr(self.im.im_self, 'proxy', self.p) > # do the call > self.im(*a) > # clear the flag > delattr(self.im.im_self, 'proxy') > > class NuclearArsenal: > def NuclearAttack(self, city): > if getattr(self, 'proxy', None): > # called through the proxy > print "Boooom! %s destroyed" % (city) > else: > print "Only the proxy can order the attack" > > ---------------------------------------------------------------------- > > Carlos Ribeiro > > > > -- > http://mail.python.org/mailman/listinfo/python-list From stowasser.h at idowa.de Wed Mar 14 08:44:42 2001 From: stowasser.h at idowa.de (Stowasser Harald) Date: Wed, 14 Mar 2001 14:44:42 +0100 Subject: Better string.translate? Message-ID: <3aaf758f$1_2@news.zet.net> Hello, i am very new in Python. I don't know how i can do this better: _deltable=string.maketrans('.,:;-_?!.=()?[]{}\'\"\r\n\f\t\v',' ') ret = string.translate(s,_deltable) This works fine, but i need a 'anti-maketrans'. I want to define what characters NOT to change in a space-character. How can i do this in Python? From db3l at fitlinxx.com Thu Mar 1 13:57:28 2001 From: db3l at fitlinxx.com (David Bolen) Date: 01 Mar 2001 13:57:28 -0500 Subject: Newbie createing .PYC for import References: <3a9e83fa$1@news1.dbtech.net> Message-ID: "Larry Bates" writes: > I have spent the last couple of hours (unsuccessfully) attempting to figure > out how to generate a .PYC file for a module that I've defined. Everything > appears to imply that it's "automatic", but I'm not getting anywhere. I > have a module and I wish to generate a .PYC file so that I can import it > into future projects. Can anyone shed any light on how to accomplish this? It's "automatic" if you are importing the module and Python has the ability (permissions, free space, etc...) to write the compiled module back to the directory. Note that running Python on a top level script is not considered an import and thus no pyc will be created by default. You can manually compile any module using the py_compile module, and, for example, the compile() function in that module, so interactively: >>> import py_compile >>> py_compile.compile('filename') and this will write the pyc to the same location as filename (or you can override that with the optional parameter cfile). You can also automatically compile all files in a directory or directories using the compileall module, which can also be run straight from the command line. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From robin at jessikat.fsnet.co.uk Thu Mar 1 13:41:37 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 1 Mar 2001 18:41:37 +0000 Subject: PEP 227 (was Re: Nested scopes resolution -- you can breathe again!) References: <200102230259.VAA19238@cj20424-a.reston1.va.home.com> <97lqsr0311d@news2.newsguy.com> Message-ID: In article , Jeremy Hylton writes >Or: global NAME in FUNCTION > >def eggs(): > z = 2 > def spam(): > def inner(): > global x in spam, z in eggs > x += 1 > z += x > x = 23 > inner() > >Jeremy > I like that a lot better than having it default possibly wrongly, but how would this be doable/spelled in the lambda case? -- Robin Becker From kens at sightreader.com Fri Mar 16 18:08:38 2001 From: kens at sightreader.com (Ken Seehof) Date: Fri, 16 Mar 2001 17:08:38 -0600 Subject: Pep 238 Why new // operator (Non-integer Division) References: Message-ID: <003501c0ae6e$27e4de40$04090a0a@upcast.com> Also, integer division is fairly common and a direct implementation is significantly faster than floor(a/b). Hey, I know: maybe "a//b" should be "a log b". That way // is the inverse operator of **. :-) Dang, if only I had time to write PEPs. :-) ----- Original Message ----- From: "Tim Peters" To: Sent: Friday, March 16, 2001 6:14 PM Subject: RE: Pep 238 Why new // operator (Non-integer Division) > [Gordon Williams] > > Why do we need a new // operator to do the divide operation. If > > we want to do an integer divide with two reals why wont people just > > use int(a/b). For > > 1. int() truncates. Current i/j returns the floor. > > 2. There is no bound on the sizes of i and j; it's very easy to > get Python long ints that don't fit in a Python float. > > > -- > http://mail.python.org/mailman/listinfo/python-list > From scarblac at pino.selwerd.nl Thu Mar 29 15:15:41 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 29 Mar 2001 20:15:41 GMT Subject: Quoted identifiers in Python? References: <3ac3387f$0$12248$cc9e4d1f@news.dial.pipex.com> Message-ID: Eddie and Babs wrote in comp.lang.python: > While reading an article about the Dylan language a few years ago, I was > surprised to find that you could have quoted identifiers (ie, variable and > function names, etc). So you could have a function named "turn around" (with > quotes) and then call it using something like: > > "turn around"(xxx) > > The idea is that you can put any characters within the quotes. So when I do x = "turn around" How does Python know whether I mean the string or the identifier? -- Remco Gerlich From lac at cd.chalmers.se Wed Mar 28 08:54:09 2001 From: lac at cd.chalmers.se (Laura Creighton) Date: Wed, 28 Mar 2001 15:54:09 +0200 (MET DST) Subject: __init__.py files in PMW Message-ID: <200103281354.PAA13594@boris.cd.chalmers.se> PMW comes in several directories, and each one has as file named __init__.py which contains this line: # File to allow this directory to be treated as a python 1.5 package. I don't understand. Who needs this file and for what? Thanks very much, Laura Creighton lac at cd.chalmers.se From pmj769 at concentric.net Fri Mar 30 22:28:02 2001 From: pmj769 at concentric.net (pmj769 at concentric.net) Date: 31 Mar 2001 03:28:02 GMT Subject: mxODBC chokes on dates! Any Help? References: Message-ID: <3ac54daa.33659169@news.xo.com> The older version 1.1.1 version of mxODBC works fine on dates. I just ran into the same problem that you did and sent a report to Marc. He has been excellent at getting back to me in the past. For now you can revert back to the older (and free) version. However, you may run into an issue with the older version in the way it (doesn't) handles UNICODE data coming from MS-SQL 7.0 Marshall On Fri, 30 Mar 2001 12:58:02 -0800, Owen Ap Owen wrote: >Thanks for the info. It is SQL Server that I am connecting to. But I got >the same error with date fields when I set up a test connection to >Access. > >It's nice that a fix is in the works. But this seems like something of a >show stopper (at least for the win32 side of things). > >Considering that the creator of mxODBC is trying to charge a laughably >exorbitant license fee for commercial use he really needs to fix this >kind of stuff very quickly. He also needs to add a lot more functionality >and even then his licensing concept is pretty extreme. > > >In article , db3l at fitlinxx.com >says... > >> I ran into the same problem with some date fields in an MS SQL Server >> database, and Marc-Andre was able to revert back to an earlier way of >> handling date fields (he preferred a different C data type if defined >> in 2.0.0 than in earlier versions) to resolve it. I was traveling and >> was a little tardy getting back to verify that the fix worked, but I >> expect it will show up in the next release of mxODBC. From trentm at ActiveState.com Sat Mar 31 02:32:19 2001 From: trentm at ActiveState.com (Trent Mick) Date: Fri, 30 Mar 2001 23:32:19 -0800 Subject: very basic, how do you find square roots? In-Reply-To: <9a408a$1mpp$1@raewyn.paradise.net.nz>; from gordonj@paradise.net.nz on Sat, Mar 31, 2001 at 07:05:43PM +1200 References: <9a408a$1mpp$1@raewyn.paradise.net.nz> Message-ID: <20010330233219.A27969@ActiveState.com> On Sat, Mar 31, 2001 at 07:05:43PM +1200, johnston112 wrote: > Yes, that is my question :) > I am trying to make a program that dose the quadratic equation. > > johnston112 import math print math.sqrt(4) Trent -- Trent Mick TrentM at ActiveState.com From fredrik at pythonware.com Thu Mar 29 05:41:51 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 29 Mar 2001 10:41:51 GMT Subject: Getting all the *files* from a directory -- A better way?? References: <99uu6401u9c@news2.newsguy.com> Message-ID: Alex Martelli wrote: > So wrap it up...: > > def joined_listdir(dir): > return [os.path.join(dir,f) for f in os.listdir(dir)] or: glob.glob(os.path.join(dir, "*")) > then use your wrapper: > > files1 = [f for f in joined_listdir(dir) if os.path.isfile(f)] or: files1 = filter(os.path.isfile, joined_listdir(dir)) (shorter, faster -- and works for all versions of Python) Cheers /F From SCook at pobox.com Tue Mar 13 06:40:32 2001 From: SCook at pobox.com (Steve) Date: Tue, 13 Mar 2001 11:40:32 GMT Subject: Compiling python under Windows Message-ID: Hi, Is it possible to build python on win32 with either mingw (the win32 port of gcc) or the borland free compiler? As I don't want to have to buy MS VC++ just to try a changes that I plan to the core. From costas at meezon.com Fri Mar 2 08:03:15 2001 From: costas at meezon.com (Costas Menico) Date: Fri, 02 Mar 2001 13:03:15 GMT Subject: compile() source code from a string References: <3a9ee600.391990@News.CIS.DFN.DE> Message-ID: <3a9f98b0.2420376@News.CIS.DFN.DE> "Chris Gonnerman" wrote: >This is a multi-part message in MIME format. > >------=_NextPart_000_0085_01C0A29E.B3939520 >Content-Type: text/plain; > charset="Windows-1252" >Content-Transfer-Encoding: 7bit > >There IS a syntax error in your code. To wit: > Sorry, I should test my examples before posting (duh). The problem I have been having is with this code below.This code will not work unless the """ are on their own line. It seems Python needs an extra CR at the end of the code. I guess it kind of makes sense. Thanks for your help, costas #!/usr/bin/env python # This code does not work unless you put # the """ on their own line codestr = """ if x == 1: print "1" print "2" print "3" elif x == 2: print 'A' print 'B' print 'C'""" codeobj = compile(codestr, "codestr", "exec") x = 2 exec(codeobj) #!/usr/bin/env python # This code works codestr = """ if x == 1: print "1" print "2" print "3" elif x == 2: print 'A' print 'B' print 'C' """ codeobj = compile(codestr, "codestr", "exec") x = 2 exec(codeobj) From info at black-karma.de Fri Mar 23 08:50:44 2001 From: info at black-karma.de (Harvest T. Moon) Date: Fri, 23 Mar 2001 14:50:44 +0100 Subject: Slightly Off-Topic: Python featured in Severance: Blade of Darkness References: Message-ID: <99fk8p$13h82$1@ID-22517.news.dfncis.de> | Writing mods/extensions in Python would be cool in any game. :-> | Wouldn't Python fit just perfectly for this purpose? i remember someone said a Quake1 MOD was written in Python, some BOTs too ... dunno if anyone knows something more specific about it. Harvest T. Moon -- a life less ordinary!! From cfelling at iae.nl Thu Mar 29 18:06:00 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 30 Mar 2001 01:06:00 +0200 Subject: Accessing variables in __main__ from modules.... References: <9a0ett$eqb$1@animus.fel.iae.nl> Message-ID: <9a0f4o$eu6$1@animus.fel.iae.nl> Carel Fellinger wrote: > The most straightforwarth way to achieve this would be to import Debug > from main, or better to have a seperate options module and import from > there. like: ... > other module: Oh, and importing something in many modules is relative cheap. Only the first import compiles and executes that module, subsequent imports only bind the module object to a name in the current scope. -- groetjes, carel From tim.one at home.com Sun Mar 11 01:01:08 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 11 Mar 2001 01:01:08 -0500 Subject: Urgent Question about Python licensing In-Reply-To: <98ejhr$38q$0@216.39.170.247> Message-ID: [Dave LeBlanc] > When UCITA first came out, there was a lot of press about it's evils. There still is! There was also a lot of discussion about it on comp.lang.python, specifically in relation to the 1.6 CNRI license at the time. You need to read the license and the actual text of UCITA to get anywhere with this -- or ask a lawyer. Whether UCITA is good or bad, the 1.6 license grants you very strong rights, and UCITA can't magically negate those. > ... > However, after reviewing information at http://www.ucitaonline.com/ > and at http://www.2bguide.com, I came to the conclusion that i'd been > mislead. Imagine! being mislead by the press! . (I should have > known better - i'm a firm believer in the "believe none of what you > hear and only half of what you read" school of thought.) Both of those are UCITA advocacy sites, and set up by the same lawyer (Carol Kunze, who "attended the UCITA drafting committee meetings from 1996 - 1999"). So on *those* sites, believe the negative halves (if you can find any <0.5 wink>). > ... > As it turns out, after the fact license changes are NOT binding, > "shrink wrap" or "click wrap" licenses ARE binding and have been > upheld by the courts, can't make a bogus venue choice, and that a > licensor CAN unilaterally disable software but only after a 2 week > warning in many cases. Note that what UCITA says is irrelevant unless read *in conjunction* with what the 1.6 license says. For example, section 308(2)(B) of UCITA holds that the license is *perpetual* if "the license expressly grants the right to incorporate or use the licensed information or informational rights with information or informational rights from other sources in a combined work for public distribution or public performance.". The CNRI 1.6 license does so expressly grant both rights. I am not a lawyer, but I can read -- so can you. UCITA simply doesn't kick in except where the 1.6 license leaves holes, and CNRI didn't intend to leave any holes. IMO (and IANAL), the GPL does leave holes, and that's the fundamental source of the conflict (when CNRI plugs a hole that the GPL doesn't, that's "a restriction" not in the GPL, hence automatically leaves the CNRI license "incompatible" with the latter, which forbids additional restrictions of *any* kind). > ... > Moving along, I find it ironic that the Open Software Foundation calls > the GPL an open source license since it violates the rules given for > such. GPL software has source available, but it's use is constrained > and contaminating (unlike the GLL library license). I see that they've added a footnote to point 9 at http://www.opensource.org/docs/definition.html It reads: Yes, the GPL is conformant with this requirement. GPLed libraries "contaminate" only software to which they will actively be linked at runtime, not software with which they are merely distributed. I'm unsure whether they added that before or after your post, though . > P.S Guido is welcome to my first born if I ever have one - but he has > to do his own cooking. guido-does-not-eat-children-neither-cooked-nor-raw-ly y'rs - tim From robin at jessikat.fsnet.co.uk Fri Mar 2 10:51:41 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 2 Mar 2001 15:51:41 +0000 Subject: gah! I hate the new string syntax References: <0vpn79.331.ln@127.0.0.1> Message-ID: In article <0vpn79.331.ln at 127.0.0.1>, Carl Banks writes >Sean 'Shaleh' Perry wrote: >> return ";".join(["%s=%s" % (k, params[k]) for k in params.keys()]) >> >> every day python seems to be moving closer to the line noise aspect of >> coding. > >I find it ok for methodlike functions such as split. > >For unmethodlike functions such as join, I would use the old >string.join syntax (for regular strings, anyways). > >"".join is just creepy. > > it looks plain wrong, but would ['a','b','c'].join(';') look any better? In fact there may be some benefit in being able to say pathJoiner = (sys.platform=='win32' and ';' or ':').join ..... path1 = pathJoiner([d1,d2,.....]) path2 = pathJoiner([e1,e2,.....]) -- Robin Becker From DSHIN at nc.rr.com Thu Mar 15 01:15:53 2001 From: DSHIN at nc.rr.com (Daehyok Shin) Date: Thu, 15 Mar 2001 06:15:53 GMT Subject: [Q] Bug in Python? Message-ID: Recently, I met a strange behavior of Python 6.1. When I tried the following module, I got an error message in "print var": UnboundLocalError: var But, when I changed "var=None" to "pass", the error message was gone and I got an expected result:--printing None and None. What happens here? Is this a bug in Python or I missed something? ############# test.py ############### var = None def a(): print var #UnboundLocalError if var != None: var = None # >> pass def b(): print var a() b() ################################# -- Daehyok Shin (Peter) Terrestrial Hydrological Ecosystem Modelers Geography Department UNC-CH From tim at vegeta.ath.cx Wed Mar 7 20:21:24 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Thu, 08 Mar 2001 01:21:24 GMT Subject: gah! I hate the new string syntax References: Message-ID: Steve Holden wrote: > "D-Man" wrote in message > news:mailman.983997252.5628.python-list at python.org... > > On Sat, Mar 03, 2001 at 03:19:05PM -0500, Steve Holden wrote: > [ ... ] > > > > What about one who is both English and Scots, yet never set foot on > > that island ;-)? > > > No such animal! If you refer to being "English" and "Scots" as a native only, then that may be true. Otherwise, you've just negated my existence!! ;) -- -Tim Hammerquist American society is a sort of flat, fresh-water pond which absorbs silently, without reaction, anything which is thrown into it. -- Henry Brooks Adams From tjg at exceptionalminds.com Thu Mar 22 13:26:39 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Thu, 22 Mar 2001 10:26:39 -0800 Subject: Good Editor? In-Reply-To: <99cb42013df@news2.newsguy.com>; from aleaxit@yahoo.com on Thu, Mar 22, 2001 at 08:54:42AM +0100 References: <3ab9a32b$1_1@news2.one.net> <99cb42013df@news2.newsguy.com> Message-ID: <20010322102639.S24341@trufflehunter.avalongroup.net> On Thu, Mar 22, 2001 at 08:54:42AM +0100, Alex Martelli wrote: > "fjs" wrote in message news:3ab9a32b$1_1 at news2.one.net... > > Can someone recomend a good editor to write python in? Im just getting > > started learning python and dont know which ones support python. > > I mostly use VIM (www.vim.org), which among other things > supports the use of Python as a macro-language. However, > VIM is a development of vi -- some of us love its modal > basic operations (it minimizes fingermovement wrt any > alternative -- highly ergonomic), some other detest it > (I think it's because they try to grasp it with their > brains rather than just let their _fingers_ learn it). As a vim newbie, I can vouch for this brains/fingers thing. Once my fingers got things mostly figured out, I find myself using vim keystrokes everywhere by force of habit. I even ended up changing from bash to zsh because zsh has such amazingly good vim emulation. I'm faster, more productive, and use *far* fewer system resources with vim than I did with emacs. I'd like to give a plug to Glimmer as an editor. It's still quite young, but it's native tongue is Python. It is quite light and has some nice interface things. It's what I used between emacs and vim. -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Red Hat Certified Engineer www.exceptionalminds.com Avalon Technology Group, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 64 days 22:39 hours ago<< From thomas at cintra.no Thu Mar 8 06:18:23 2001 From: thomas at cintra.no (Thomas Weholt) Date: Thu, 8 Mar 2001 12:18:23 +0100 Subject: Added namespaces; now nothing works! Message-ID: <3UJp6.10068$t21.271693@news3.oke.nextra.no> Hi, I have a xml-document I've decided to add namespaces to. Tried to convert my old stylesheet to reflect the changes and parse it to HTML with XT, but now nothing but the stylesheet ends up in the resulting document. What am I doing wrong? The xml-document : TestValue 1 alice.txt The stylesheet, just a simple thing to get something into the browser or result document : I only get the entire stylesheet as result. No formatting done whatsoever. If somebody could provide a dead-simple stylesheet that just enters the value of the jcd:test-tag in the result document I'd be happy. Just started using namespaces so I just need a kick to get going. Thanks!! Best regards, Thomas Weholt From support at internetdiscovery.com Tue Mar 27 07:36:58 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Tue, 27 Mar 2001 12:36:58 GMT Subject: Python wrapper for TkHTML? Message-ID: <3ac08765.3126948@24.0.228.33> Does anyone have a Python wrapper for TkHTML, the c-coded HTML widget for Tk ? Many thanks in advance, Mike From tjg at exceptionalminds.com Mon Mar 19 14:11:08 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Mon, 19 Mar 2001 11:11:08 -0800 Subject: Evaluating the contents of a string In-Reply-To: ; from aaron.ginn@motorola.com on Mon, Mar 19, 2001 at 10:48:13AM -0700 References: Message-ID: <20010319111108.C3109@trufflehunter.avalongroup.net> On Mon, Mar 19, 2001 at 10:48:13AM -0700, Aaron Ginn wrote: > > Is there a simple way to evaluate the contents of a string assuming > that string contains only nunbers and mathematical operators? > > For example, I'm parsing a file that contains expressions contained in > parantheses such the following: > > 12 net64 a vss vss n w=1.1u l=0.5u ad=(1.1 * 1.15) as=(1.1 * 1.15) > ^^^^^^^^^^^^ ^^^^^^^^^^^^ > > I'm using a stack to determine when an expression can be evaluated > (i.e., when a closing paranthesis is found), and I'm storing the > contents of the parantheses in a string. When the first closing > parenthesis is found in the example above, the string to be evaluated > will be '1.1 * 1.15'. Is there a module that will mathematically > evaluate this string? Using your example string above, the following appears to work: >>> import re >>> x = re.findall(r'[a-z][a-z]=\(.*?\)', x) >>> for y in x: ... exec y ... >>> dir() ['__builtins__', '__doc__', '__name__', 'a', 'ad', 'as', 're', 'x', 'y', 'z'] >>> >>> print ad 1.265 >>> print as 1.265 >>> -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Red Hat Certified Engineer www.exceptionalminds.com Avalon Technology Group, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 61 days 23:25 hours ago<< From djc at object-craft.com.au Sat Mar 24 22:50:51 2001 From: djc at object-craft.com.au (Dave Cole) Date: 25 Mar 2001 13:50:51 +1000 Subject: Referencing a container object's attributes References: <200103250239.SAA10240@mail.novus-tele.net> Message-ID: >>>>> "Tim" == Tim Churches writes: >> Is so, there there is no language feature that would allow you to >> do this without passing an instance of 'b' to 'a'. Standard >> practice would be to do something like this: >> >> class a: >> def __init__(self, parent): >> self.parent = parent >> >> def doSomething(self): >> self.parent.blah( ) >> >> class b: >> __init__(self): >> self.a = a( self ) >> Tim> OK, many thanks. Tim> One question: does the circularity inherent in the above (in Tim> which a reference to the container object is placed in an Tim> attribute of each containee) have any potential for causing Tim> problems - particularly since I want to pickle the container Tim> objects? You should be able to pickle the container, but you will have to manually remove all of the circular references yourself when you want to free the object(s). In Python 2.x I understand that the garbage collector can detect and handle circular references. - Dave -- http://www.object-craft.com.au From emile at fenx.com Mon Mar 12 07:23:48 2001 From: emile at fenx.com (Emile van Sebille) Date: Mon, 12 Mar 2001 04:23:48 -0800 Subject: I have no idea References: Message-ID: <98ifa7$26rae$1@ID-11957.news.dfncis.de> while 1: print "Hello World" >"Brendhan Horne" wrote in message news:g13r6.201$qt5.10920 at news3.mia... > In basic you use to be able to do this: > 10 print "Hello World" > 20 goto 10 > Run > > If you did that it would run up the screen in an endless loop until you hit > the ESC key. If you added ; it would cover the whole screen. How do you > write the equivalent in python? > > -- > Thanks, > Brendhan > > From erno-news at erno.iki.fi Sun Mar 4 19:29:10 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 05 Mar 2001 02:29:10 +0200 Subject: Concurrency and shelve References: <3AA26D5E.2FD28B40@stroeder.com> <3AA2C1F0.980A23F7@stroeder.com> Message-ID: In article , Erno Kuusela writes: | In article <3AA2C1F0.980A23F7 at stroeder.com>, Michael Str?der | writes: || BTW: I'm trying to use shelve to store web session data. How does || others solve this problem with the the standard lib without being to || DB-specific? Unpossible? | don't keep it open all the time. erm, i seem to have missed the "not db-specific" part. i guess the answer is to do the locking yourself. there are some functions in the fcntl module to do it. it's probably best to use a separate empty file (like dbfilename + '.lock') that you do the locking on, so that it does not interfere with gdbm's locking. -- erno From tim.one at home.com Mon Mar 12 00:55:06 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 12 Mar 2001 00:55:06 -0500 Subject: From SETL to Python translation In-Reply-To: Message-ID: [cyberian bear] > Hi guys I have 2 programs below that I must have in Python but I have > them in SETL(whatever the hell that is) and I don't know anything about > it. I tried finding stuff about it on the web but all I found was two > small, irrelevant pages and no tutorials. You must have missed: http://birch.eecs.lehigh.edu/~bacon/doc.html You can download Robert Dewar's introductory "The SETL Programming Language" paper via a link on that page. > The thing is, if at least I knew what the 'Euler path construction', or > 'Prime factors' are, I could just program them on my own without looking > at the SETL code, but i don't. prime_factors(n) takes an integer as input and returns a list of its prime factors, via repeated trial division by 2, then by the odd numbers from 3 up to the ceiling of the square root of n. Euler_path(G) takes an undirected graph represented as a set of 2-element lists (representing edges via the nodes they connect), and returns an Euler path as a list of the nodes of G in an Euler-path order; it returns OM (SETL's spelling for "there's no meanigful result") if no Euler path exists. An Euler path is a traversal of the graph such that each edge is taken exactly once. These are standard algorithms in their fields, and as such can be found all over the web. > Basically I just want to ask some good soul if he could translate these > two programs for me from SETL to Python. I know chances of finding anyone > who knows SETL are negligibe but i guess it's worth a try. > ... Finding someone who knows SETL is easier than finding someone who's keen to solve what appears to be a homework problem <0.5 wink>. Study the algorithms and reimplement them from scratch; line-by-line translation of SETL is going to be very frustrating. For example, the closest simple and readable translation of the SETL: > if #(odds := {x in nodes | odd(#G{x})}) > 2 then is the Python: odds = [] for x in nodes: successors = [y for (z, y) in G if z == x] if len(successors) % 2: odds.append(x) if len(odds) > 2: but even then lots of representation changes have been made (the SETL set G is taken to be a list of 2-tuples in Python instead; and the SETL set odds is constructed instead as a Python list, exploiting that I happen to know no element appears more than once in the SETL-set / Python-list "nodes"). The SETL is a more direct translation of an English algorithm, reading "Let 'odds' be the set of nodes with an odd number of successors. If there are more than two of those, then ...". prime_factors is (by far) the easier of the two, so start with that. setl-is-to-ltes-as-python-is-to-nohtyp-ly y'rs - tim From tim.one at home.com Thu Mar 1 22:41:57 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 1 Mar 2001 22:41:57 -0500 Subject: define a new func on the fly? In-Reply-To: <3a9f0ce3.10347756@News.CIS.DFN.DE> Message-ID: [Costas Menico] > Here is the exact error I get when running it > > >>>> exec("def f():\n\treturn 'hello'\t") > Traceback (innermost last): > File "", line 1, in ? > File "", line 2 > return 'hello' > ^ > SyntaxError: invalid syntax > > I've trying all day to get this to work. No luck... >>> exec "def f():\n\treturn 'hello'\n" >>> f() 'hello' >>> 1. exec is a statement, not a function, so you don't need the parens (although they shouldn't hurt). 2. You *intended* to end your string with a newline, not a tab. The tab is what yields the SyntaxError. A good clue about that is the caret pointing after the final ' in 'hello' in the error message. From fredrik at pythonware.com Thu Mar 15 12:45:22 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 15 Mar 2001 17:45:22 GMT Subject: Random Access Files References: <9e4s6.42245$p66.13534448@news3.rdc1.on.home.com> Message-ID: Colin Meeks wrote: > I would like to be able to do something like > > 1. Seek the potion to write f.seek(offset) > 2. Write f.write(data) > 3. Close file f.close() > I don't mean writing code that hides the methods of the first example. If I > remember correctly you can do random access files in GWBasic. > > Anyone have any pointer?? http://www.python.org/doc/current/lib/bltin-file-objects.html Cheers /F From tuttledon at hotmail.com Sat Mar 31 23:09:45 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Sun, 01 Apr 2001 04:09:45 GMT Subject: PythonLabs Team Moves to ActiveState References: Message-ID: "Guido van Rossum" > PythonLabs Team Moves to ActiveState To paraphrase a popular saying in my neck of the woods... "Guido said it. I believe it. That settles it!" (or was that just one of the reasons I deconverted? ;-) Don From mbarnett at ualberta.ca Mon Mar 19 13:49:14 2001 From: mbarnett at ualberta.ca (Matt Barnett) Date: Mon, 19 Mar 2001 11:49:14 -0700 Subject: Evaluating the contents of a string References: Message-ID: ---------- In article , Aaron Ginn wrote: > > Is there a simple way to evaluate the contents of a string assuming > that string contains only nunbers and mathematical operators? > > For example, I'm parsing a file that contains expressions contained in > parantheses such the following: > > 12 net64 a vss vss n w=1.1u l=0.5u ad=(1.1 * 1.15) as=(1.1 * 1.15) > ^^^^^^^^^^^^ ^^^^^^^^^^^^ eval("1.1 * 1.15") >When the first closing >parenthesis is found in the example above, the string to be evaluated >will be '1.1 * 1.15'. Is there a module that will mathematically >evaluate this string? Yup From f8dy at yahoo.com Fri Mar 9 13:26:48 2001 From: f8dy at yahoo.com (Mark Pilgrim) Date: Fri, 9 Mar 2001 13:26:48 -0500 Subject: I come to praise .join, not to bury it... References: <98aspo024jg@news2.newsguy.com> Message-ID: <98b75u$15les$1@ID-77331.news.dfncis.de> "Alex Martelli" wrote in message news:98aspo024jg at news2.newsguy.com... > But the .join/.writelines parallel is VERY close, so why > would the SAME architectural choice (to have the sequence > object as an argument, accessing it through its ability > to enumerate its items, only) cause problems in one case > and not the other?! > > I think it's a misperception due to thinking of strings > as somehow 'passive', 'data', while a file-object is > thought of as 'active', 'a truly object-y object', or > something. Exactly! I have taught Python to half a dozen people in the last few months, and every one of them had trouble with this concept, because they all came from a C background where they only thought of "string" as "packed array of char", or some other language (like Powerbuilder) where "string" is just a native datatype and isn't an object in any sense of the word. Nobody minded file objects, even if they were only used to using integer file handles in their previous language. I think that's because they could build a mental model of a file object as a kind of secretary who has a copy of a document on their desk and can read you various parts of it, or all of it, or tell you its title, or whatever. But everybody had trouble with string objects, because the mental model is different. IIRC, the post that started the thread that spawned this thread quoted a code sample from my book, something like this: return ";".join([...]) There are obviously lots of ways to do this (assign ";" to a variable first, or use the old string.join function, or don't use join at all), but I did it this way on purpose. Call it shock value, for lack of a better term -- to force the point that the literal string ";" is an object, not just string variables. I have gotten multiple e-mails from readers telling me that this was their "a-ha!" moment when they realized that everything in Python really *is* an object. After that moment, they don't mind seeing modules that have attributes, or functions passed around as parameters, or anything other weird/cool/wicked-ness. "Sure, you can do that, you can do anything, because everything is an object; just look at what you can do with string literals..." -M You're smart; why haven't you learned Python yet? http://diveintopython.org/ From db3l at fitlinxx.com Tue Mar 20 18:48:11 2001 From: db3l at fitlinxx.com (David Bolen) Date: 20 Mar 2001 18:48:11 -0500 Subject: Little red lines in PythonWin! References: <9OQt6.13652$992.84056@news-server.bigpond.net.au> Message-ID: "Neil Hodgson" writes: > This feature is turned on by default in PythonWin and can be controlled > through View | Options... | Tabs and Whitespace | Tab-Timmy. IMO all Python > IDEs should have a similar feature. For those IDEs that use Scintilla, the > feature is already implemented for you so it is almost free to add. Interestingly enough when I looked at this in response to the first post (I don't normally use Pythonwin), I noticed that the default setup seems to have a tab size of 4 rather than 8. So Pythonwin was expanding literal tabs visually to a 4-position stop rather than 8, which is different from the language definition. Expanding to 8 by default (with or without the red indicators) would at least present a visual indication of what the Python parser was going to "see". -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From lluang at northwestern.edu Mon Mar 12 17:13:07 2001 From: lluang at northwestern.edu (Louis Luangkesorn) Date: Mon, 12 Mar 2001 16:13:07 -0600 Subject: sent a note to Lemburg References: <3AA7FF0E.50E6D70F@northwestern.edu> Message-ID: <3AAD49F3.B9FF9480@northwestern.edu> An HTML attachment was scrubbed... URL: From chris.gonnerman at usa.net Tue Mar 6 21:31:40 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Tue, 6 Mar 2001 20:31:40 -0600 Subject: Overriding UserList methods References: Message-ID: <009201c0a6ae$d59c8960$a100000a@local> ----- Original Message ----- From: "Daniel Klein" Subject: Re: Overriding UserList methods > On Mon, 5 Mar 2001 00:52:40 -0500, "Steve Holden" > wrote: > > >"Daniel Klein" wrote in message > >news:b566atck0ruu4tae8n1srrkntbmme26gor at 4ax.com... > >> I must be missing something, cos I can't figure out how to override a > >method > >> using the UserList module. Here is some code: > >> > >> import UserList > >> class MyList(UserList.UserList): > >> __def __init__(self): > >> UserList.UserList.__init__(self) > >> > >While this would work, I don't see it's strictly necessary. Why not just > >inherit the __init__ method from UserList? > > One of the reasons for subclassing UserList is to provide additional instance > variables. So I need my own __init__ method to initialize this, don't I? Nope. Only if you *actually* initialize them in the __init__ method, which you aren't doing. I wrote a module a while back that subclasses UserDict... not exactly the same problem but close enough to help. If you are interested, visit http://newcenturycomputers.net/projects/python and download the Chunk.py module. Remember that when you call a method of an instance variable, i.e.: from UserList import UserList lst = UserList() lst.append(1) what is (effectively) called is: UserList.append(lst, 1) So: class MyList(UserList): def append(self, item): UserList.append(self, item) is the "right" way to do it. Of course, you can also just use the .append() method of the underlying .data element, but I prefer to use the "proper" encapsulation. From tim.one at home.com Mon Mar 12 14:45:43 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 12 Mar 2001 14:45:43 -0500 Subject: PyEval_CallObject and threads In-Reply-To: Message-ID: [Phlip] > My colleague came over and asked me to write this: > > "We got multiple C++ pthreads calling PyEval_CallObject. How threadsafe > is the Python API? A C++ module using Boost BPL creates multiple threads, > which then call back into Python. When two threads simultaneously call > PyEval_CallObject we go boom." > > I will now go examine his serialization primitives. But if anyone has any > better ideas... With very few exceptions, all calls to Python C API functions must be made while holding the global interpreter lock. The exceptions have mostly to do with a handful of functions related to initialization and shutdown. See the section "Thread State and the Global Interpreter Lock" in the Python/C API Reference Manual for details. From gregj at pobox.com Fri Mar 9 02:05:52 2001 From: gregj at pobox.com (Gregory Jorgensen) Date: Fri, 09 Mar 2001 07:05:52 GMT Subject: learning C References: <983975751.18833@newsmaster-04.atnet.at> <3AA82422.53026D3D@cosc.canterbury.ac.nz> Message-ID: Stroustrup himself said it best: "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off." http://www.research.att.com/~bs/bs_faq.html#really-say-that In article , D-Man says... > >On Fri, Mar 09, 2001 at 01:30:26PM +1300, Greg Ewing wrote: >| Werner Schiendl wrote: >| > >| > The fine thing is: C++ still HAS the scalpel, so what? >| >| C++ is a Swiss army knife with both scissors and scalpel, >| and a nasty tendency for the scalpel to shoot out and >| stick you in the palm when all you were trying to do >| was use the scissors... >| > >Nice. I like this description. > >yet-not-joining-the-war-ly y'rs -D > > Greg Jorgensen Deschooling Society Portland, Oregon, USA gregj at pobox.com From kens at sightreader.com Wed Mar 21 20:05:47 2001 From: kens at sightreader.com (Ken Seehof) Date: Wed, 21 Mar 2001 17:05:47 -0800 Subject: What is being compared? References: Message-ID: <014101c0b26c$3af6f890$04090a0a@upcast.com> Documentation says: """ The operators <, >, ==, >=, <=, and != compare the values of two objects. The objects need not have the same type. If both are numbers, they are coverted to a common type. Otherwise, objects of different types always compare unequal, and are ordered consistently but arbitrarily. """ I'm pretty sure that the default rules for mixed types are something like this: 1. numbers are less than non-numbers 2. otherwise compare id(type(a)) with id(type(b)) Note that, rather weirdly, types are compared by their ids. That's right. In other words, the address where the type object happened to get allocated. Hence the behavior will be only be guaranteed to be consistent within an execution of the python shell. On some operating systems it will also usually to be mostly consistent from one execution to the next because the objects tend to be allocated in the same order. Actually, the documentation is slightly wrong. Any type can overload __cmp__ or the new rich comparisons. Hence it is possible for instances and objects to define any inter-type behaviour you want. In fact the only reason numbers are special is that they happen overload __cmp__ to do appropriate conversions. >>> class God: ... def __cmp__(self, x): ... return 0 ... >>> c = God() >>> c>42 0 >>> c<3 0 >>> c==3 1 >>> c=="spam" 1 ----- Original Message ----- From: "Daniel Klein" Newsgroups: comp.lang.python To: Sent: Wednesday, March 21, 2001 3:59 PM Subject: What is being compared? > Comparing a string to an integer... > > >>> 'a' < 1 > 0 > > ..what is it actually comparing? Is it 'casting' anything? > > Just curious, > > Dan > > > -- > http://mail.python.org/mailman/listinfo/python-list > From dalfes at itu.edu.tr Tue Mar 6 19:08:45 2001 From: dalfes at itu.edu.tr (Nuzhet Dalfes) Date: Wed, 07 Mar 2001 02:08:45 +0200 Subject: How to installing NumPy? Message-ID: <3AA57C0D.BBC5E956@itu.edu.tr> Hi, I am trying to install NumPy on a RedHat 7.0 running python2.0. Everything is in the standard places (I think!) and I picked up and unzipped http://download.sourceforge.net/numpy/NumPy1711_20.zip into /usr/local/lib/python2.0/site-packages. And set PYTHONPATH to /usr/local/lib/python2.0/site-packages. But don't seem to be able to get 'import Numeric' going. Help Nuzhet -------------- next part -------------- A non-text attachment was scrubbed... Name: dalfes.vcf Type: text/x-vcard Size: 389 bytes Desc: Card for Nuzhet Dalfes URL: From nospam at mega-nerd.com Tue Mar 20 02:52:40 2001 From: nospam at mega-nerd.com (Erik de Castro Lopo) Date: Tue, 20 Mar 2001 07:52:40 GMT Subject: Tkinter : resizing Text widget with main window References: <3AB11827.469F6C0C@mega-nerd.com> Message-ID: <3AB70C35.1B02410E@mega-nerd.com> Rick Pasotto wrote: > > On Thu, 15 Mar 2001 19:38:12 GMT in comp.lang.python, Erik de Castro Lopo wrote: > > Hi all, > > > > How does one force a Tkinter.Text widget to be resized whenever > > the main window is resized? > > t=Text(width=30,height=12) # sets the initial size > t.pack(expand=1,fill='both') That may work for widgets which are pack()ed, but what about widgets which are place in the parent window using grid ()? This does work for grid (). Erik -- ----------------------------------------------------------------- Erik de Castro Lopo nospam at mega-nerd.com (Yes its valid) ----------------------------------------------------------------- "I've got an idea! Sun, Oracle, and IBM hold down MS while Linux gets to kick them!" -- Lou Grinzo on LinuxToday.com From kens at sightreader.com Mon Mar 26 19:15:05 2001 From: kens at sightreader.com (Ken Seehof) Date: Mon, 26 Mar 2001 16:15:05 -0800 Subject: Oatmeal (was warrior geeks) References: <3ABF72F1.98CB78F@sage.att.com> <3ABFA209.CF27BC20@optushome.com.au> Message-ID: <003101c0b652$fa514ee0$04090a0a@upcast.com> I like oatmeal (porridge) too. ----- Original Message ----- From: "Tim Churches" To: "Garry Hodgson" Cc: Sent: Monday, March 26, 2001 12:09 PM Subject: Re: warrior geeks > Garry Hodgson wrote: > > > > a funny thing happened at IPC9. a bunch of were sitting in the > > lounge (bar) talking, and one person mentioned that he was going > > to study kendo while in japan this year. i asked if he had previous > > martial arts experience, and he said yes, he'd studied judo. > > it then turned out that in this group of maybe 6-7 people, we had > > this judo/kendo student, another who's done karate and now kickboxing, > > another who did karate, myself (okinawan karate, aikijutsu and others), > > and a pa qua practitioner. at the next table sat another tae kwon > > do/aikido > > student. > > > > it seemed like an odd coincidence, but it made me wonder: is there an > > unusually high percentage of MA practitioners among the python > > community? > > or the open source community? or software in general? > > I'll use our time zone advantage to jump in early on this thread and > opine that it is way off-topic. Not that I am opposed to > marital...whoops...martial arts (although they are not my cup of tea), > but I am concerned that if this threads continues, sooner or later > someone will mention the whole "Geeks with Guns" thing that Eric S. > Raymond promotes (see http://www.tuxedo.org/~esr/geeks-with-guns/ or for > even worse IMHO see http://www.tuxedo.org/~esr/guns/ ), especially given > ESR's apparent fondness for Python. That sort of thing gives me a fit of > the shudders (playing with guns, not ESR's fondness for Python). I would > have thought that if male hackers were looking for a hobby which > involves phallic-shaped objects and chemically-propelled projectiles, > then model rocketry would be just the ticket. > > There, that should put an immediate end to this very off-topic thread... > > Tim C > Sydney, Australia > PS Damn! I was cooking porridge (oatmeal) for breakfast and became so > carried away composing this message that I completely forgot to stir the > pot... > > -- > http://mail.python.org/mailman/listinfo/python-list > From fredrik at pythonware.com Wed Mar 14 10:55:12 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 14 Mar 2001 15:55:12 GMT Subject: String comparison References: <3AAF9290.42BDAAD3@mailhost.stg.rt.daimlerchrysler.com> Message-ID: Alexander Stirzel wrote: > I printed processname just before this comparison and I got "netscape" > on screen. (With no spaces there, that's not the problem) But when I > >>>> print (processname=="netscape") > I get a "0" on screen. And when I > >>>> print (processname) > I get "netscape" on screen. maybe you have control characters (e.g. a carriage return) left in the string? try >>> print repr(processname) or just >>> processname (nit: print is a statement, not a function call. don't use parentheses around its argument) Cheers /F From m.linnemann at addcom.de Thu Mar 29 06:50:40 2001 From: m.linnemann at addcom.de (Michael Linnemann) Date: Thu, 29 Mar 2001 13:50:40 +0200 Subject: Python scripts as Drop targets in Windows Explorer References: <99qogo$o6g$1@troll.powertech.no> <99qqq3$qt7$0@216.39.170.247> <99r043$qqr$1@troll.powertech.no> <8kAw6.780$R6.22057@news1.oke.nextra.no> Message-ID: Am Thu, 29 Mar 2001 08:10:08 +0200 schrieb Syver Enstad: >> Yeah, looks cool. What is it, perl? Czech? EBCDIC? >>>default on Win2k is to save as unicode. >> Come on, tune your W2k a little and make it talk plain :-) >I don't know what you mean, isn't Unicode one of the most plain ways to talk >nowadays? And I have also posted it as plain text so it shouldn't be too >difficult for you. It is not really difficult, especially for me in particular. I don ot care about registries because I have none :-) But you posted the code that I cited, and my newsreader (slrn) did _not_ trigger any mime decoding or something, that is, it showed your unicode as plain ascii. And that looks like plain garbage. So, either your newsreader told you it was ascii, but it wasn't; or it knew it was _not_ ascii but did not declare it. Regards Michael From freier at xtramind.com Thu Mar 22 05:48:48 2001 From: freier at xtramind.com (Andreas Freier) Date: Thu, 22 Mar 2001 11:48:48 +0100 Subject: Why Python/Jython? Message-ID: <99cl9e$b2b$1@Merlin.et.bocholt.fh-gelsenkirchen.de> In several articles I read that Python/Jython imporoves the programmers performance many times. Why? I am considering to use Jython for my job as Java programmer. How should I use it to achieve this performance? Thanks a lot. Andreas Freier From bsass at freenet.edmonton.ab.ca Thu Mar 1 04:49:46 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 1 Mar 2001 02:49:46 -0700 (MST) Subject: CPAN functionality for python - requirements In-Reply-To: <01022721090603.20069@branagan> Message-ID: On Tue, 27 Feb 2001, Doug Hellmann wrote: > On Tue, 27 Feb 2001, Bruce Sass wrote: > > I'm a little concerned about the privacy aspect of this... > > > > > That decision is up to the client. If the client has the smarts to turn > > > a distutils package into an RPM, then the client would list it's preferred > > > format as a distutils package and it would handle the rest. If it can't, > > > you can either select an RPM, or fall back to a distutils package. > > > > Why should the client need to "list" anything. > > > > client: what do you have? > > server: this(deb,rh-5.rpm,rh-6.2.rpm,rh-7.rpm) that() other(hqx) <...> > I'm not sure why the "what do you have" question is needed. The "send me > that(mandrake.rpm)" interaction is what we want. Automated tools need to query what is available so they can decide where to satisfy a dependency from. Packages will be available from a variety of outlets, not just the python archive. > The client requests packages in the formats prefered. A standard source format > should be available for all packages so that everybody can get every package in > some form. If the standard source format contains distutil-enabled scripts, > platform specific distribution files could be generated from the source. Yup. What do you think of having the server look like a platform specific distribution archive? So, when the server sees requests for (lets say) Debian style Packages and Release files (used to create the available packages DB), it assembles them from the list of python packages. Requests for URLs that look like those of packages in RHs archive whould result in a RH-rpm being served up. This would allow for complete integration with any client's native package archive system the server knows about, and give the CPyAn archive full control over package names, release numbers, etc. - the little bits that can cause simple to fix, but annoying, dependency problems. just a thought > > This could work... > > client: only show me (deb) and () > > client: what do you have? > > Right, that would be a bit more efficient than specifying a format for every > package for every request. There could also be an (all) format, why limit the possibilities. > > The server should NOT be usable as a tool to track Python users and > > their habits, and making it do so should require a conscious effort on > > the operators part (so there is no opportunity for the operator to > > say, "I don't track you, that's just how the software works"). > > The server is likely to be a cgi, which by its nature means requests may be > written to a log file. Should that be disallowed? Obviuosly there is nothing that can be done about normal system logging, but the cgi/factory-object/whatever should not keep any persistent user/connection information around (i.e., no log from the CPyAN software which lists who got what in which format when). - Bruce From michael at stroeder.com Sun Mar 18 05:50:38 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Sun, 18 Mar 2001 11:50:38 +0100 Subject: Help with 500 error on cgi script References: <5739bt04e50ku01rn3dptgqch3l07p2cnf@4ax.com> Message-ID: <3AB492FE.4D963C32@stroeder.com> Sheila King wrote: > > [Sun Mar 18 02:18:42 2001] [error] [client 4.3.200.226] print "

Good > Result!

> > [Sun Mar 18 02:18:42 2001] [error] [client 4.3.200.226] > ^ > > [Sun Mar 18 02:18:42 2001] [error] [client 4.3.200.226] SyntaxError: invalid > token > > But I'm at a loss to figure out what is wrong. :-( What keeps you away from correcting the syntax error mentiond in the error traceback? Ciao, Michael. From aahz at panix.com Thu Mar 22 11:31:28 2001 From: aahz at panix.com (Aahz Maruch) Date: 22 Mar 2001 08:31:28 -0800 Subject: Jython is cool? References: <20010322103954.A18539@sync.nyct.net> Message-ID: <99d9d0$n2a$1@panix6.panix.com> In article , Neil Schemenauer wrote: > >I'm hoping that the Mozilla guys catch the Python bug based on >what Active State has been doing with Komoto and adds " > > > If I do a Response.BinaryWrite(bstrIn) I get the image in the browser but if > I do Response.BinaryWrite(bstrOut.getvalue()) I get spaces between every > character (I've seen this with unicode problems). It's not just an > incompatibility with Response.BinaryWrite because I've written the results > back to the database with the same results. It seems like it's a problem > with how python deals with strings. > > Anyone have any ideas? > > Thanks in advance > > Shonn > > From fredrik at pythonware.com Wed Mar 21 02:40:49 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Mar 2001 07:40:49 GMT Subject: Base 2 to long integers and back References: Message-ID: <5WYt6.846$sk3.282417@newsb.telia.net> Tim Churches wrote: > but there is no built-in or library function which does the > reverse, it would seem. However your code does the trick > nicely and quite quickly for larger numbers, something like this is 8-10 times faster: binmap = [] for i in range(256): binmap.append( "%d%d%d%d%d%d%d%d" % ( (i&0x80)!=0, (i&0x40)!=0, (i&0x20)!=0, (i&0x10)!=0, (i&0x08)!=0, (i&0x04)!=0, (i&0x02)!=0, (i&0x01)!=0 ) ) def f2(val, joiner="".join, binmap=binmap): out = [] append = out.append while 1: append(binmap[val & 255]) val >>= 8 if not val: break out.reverse() return joiner(out) Cheers /F From root at [127.0.0.1] Wed Mar 28 08:28:45 2001 From: root at [127.0.0.1] (deadmeat) Date: Wed, 28 Mar 2001 13:28:45 GMT Subject: list vs tuple Message-ID: Whats the practical difference between a list[] and a tuple() ? A tuple seems to be a very basic list, so unless it's faster, what's the point of it? From xyzmats at laplaza.org Sat Mar 10 12:54:58 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Sat, 10 Mar 2001 17:54:58 GMT Subject: Urgent Question about Python licensing References: <98cpfe$5oj$0@216.39.170.247> Message-ID: <3aaa6973.5847127@news.laplaza.org> On 10 Mar 2001 16:20:57 +0200, Erno Kuusela wrote: >In article <98cpfe$5oj$0 at 216.39.170.247>, whisper at oz.net (Dave >LeBlanc) writes: > >| Hi; >| While reading up on the recent Python conference on O'Reilly's site >| (http://python.oreilly.com/news/pythonday1_0301.html - actually on the >| 'day 2' page), I cam across the following: >| ---------------------------------------------------- >[...] >| This difficulty means that Python >| can't be distributed with software licensed under the GPL. > >that is false. the issue is not distributiong python with gpl software, >it is mixing the python interpreter code with gpl'd code. (ie where >the other code and the python interpreter would combine to produce >what the gpl refers to as a "derivate work"). That's right. This all /ought/ to be straightforward: a GPL'd piece of code is 'free' and through being combined with some other code, it may not lose (any of) that freedom. Putting GPL'd code into the Python interpeter would cause it to come under the terms of the Python license, thus changing the terms under which that piece of GPL'd code was available, and that's not allowed unless the licenses are considered "compatible", which has been one of the hopes for Python. The issue seems to be more complicated than this though, because there are people still worried about including new Python versions on Linux distributions because of the CNRI license, and I don't fully get why this is yet (not sure I want to, either). Like other folks have said, the subtleties will make your brain explode (always pick up a new one at Curry's, though). From gzeljko at sezampro.yu Tue Mar 20 15:04:48 2001 From: gzeljko at sezampro.yu (gzeljko) Date: Tue, 20 Mar 2001 21:04:48 +0100 Subject: Sequence-spreading References: <3AB7167F.2816AA21@student.liu.se> <99790u01c73@news2.newsguy.com> <99851p$ba6$2@neptun.beotel.net> <998ba7$5j7$1@news.mathworks.com> Message-ID: <998d5u$cqj$1@neptun.beotel.net> Joshua Marshall wrote in message news:998ba7$5j7$1 at news.mathworks.com... > gzeljko wrote: > > > Alex Martelli wrote in message > >> offsets = [ [] for i in range(pm) ] > >> for i in range(len(arg)): > >> offsets[i%pm].append(i) > >> > >> > >> Alex > >> > > > Old syntax yet works: > > > offsets = [[]]*pm > > Careful here: > > >>> x = [[]]*2 > >>> y = [[] for i in range(2)] > >>> x > [[], []] > >>> y > [[], []] > >>> x[0] is x[1] > 1 > >>> y[0] is y[1] > 0 > > The first way gives you the same value at each element ("[]" is > evaluated once), while the second way gives you distinct values ("[]" > is evaluated for each element). > -- [Careful]*3 Thanx. ly-y'rs-gzeljko From michel at digicool.com Mon Mar 26 17:50:29 2001 From: michel at digicool.com (Michel Pelletier) Date: Mon, 26 Mar 2001 14:50:29 -0800 Subject: PEP 245: Python interfaces In-Reply-To: <99o9g4$nh3$0@216.39.170.247> References: <99o9g4$nh3$0@216.39.170.247> Message-ID: On 26 Mar 2001, Dave LeBlanc wrote: > Having read the PEP briefly, I have one question: > > Is there a good reason to add the "implements" keyword? > > Current syntax is (from Language Reference 7.6): > classdef: "class" classname [inheritance] ":" suite > inheritance: "(" [expression_list] ")" > classname: identifier > (i'm adding this based on the text of 7.6:) > expression_list: Expression(s) which evaluate to a class object. > > Any reason why expression_list couldn't include an interface? Because that expression list defines inheritance, and interfaces are not inherited. They do not define any of the same behaviors, like shared implementation, as inheritance. Readers of your code would (wrongly) assume that you were mixing in implementation into your class instead of asserting the implementation of a certain interface. > Seems to > me it's easier to just extend the semantics of expression_list to > include interface_name(s) instead of adding a variation like '"class" > classname [inheritance] ["implements" interfaces] ":" suite'. > (Besides, two optional elements in a row makes for messy parsing :-).) You mean human visual parsing or the actual Python parser? I don't know about the former, but the syntax is no problem for the latter. > The end of a class definition might be slightly more complex to check > that all "pure" methods have implementations, but (almost certianly) > not hopelessly so... and you get to detect the "not implemented" error > early with a "missing definition" error rather then later with a > "can't instantiate" error. You need to re-read PEP 245; no such compile time checking or error conditions are proposed, and I think that requireing that checking is a bad idea (in addition to being impossible for anything but the most naive cases, since you can change a class at run time). These are not like Java interfaces. Interface enforcement can certainly be done optionally, but it is not a requirment and it never should be because a) it is expensive, b) the object should be implicitly trusted unless you feel otherwise (and then you use optional enforcement) and c) the problem is unbounded: at first you want to check just attributes, and then parameters, and then assertions, and then types, whoa! Everybody's requirement is different (go read the types-sig and you'll see what I mean), by making all of these enforcements optional, everybody gets to be happy with their own. Java and other static languages get away with this because all interfaces do is assert compile time enforcement, this would not work for Python which is much more dynamic. > Surely a python interpreter could be smart enough to realize that some > name in the list of inherited objects is actually an interface? The interpreter? Surely. The guy reading your code? No way. Thanks for you comments, if you'd like, I can add your suggestion to the PEP under the different opinions section. -Michel From db3l at fitlinxx.com Wed Mar 28 13:29:34 2001 From: db3l at fitlinxx.com (David Bolen) Date: 28 Mar 2001 13:29:34 -0500 Subject: list vs tuple References: Message-ID: "Sean 'Shaleh' Perry" writes: > dir_list is declared as a tuple, which is as close to a const one can find in > python. I'm not sure I'd agree - I'd say that dir_list is defined to reference a tuple, but not that dir_list itself is defined as a tuple. Python doesn't associate types with the reference labels but with the objects themselves. I don't think that I'd read into that definition anything more than that dir_list was being initialized to point to an immutable object - not that dir_list itself might never point to any other object. It may be as close to a const definition as you can get (at least textually - an object that was used to retrieve the directory list and thus could exert control over any ability to change that list would be symantically closer), but if that was the intent, I think some comments along with the code would be advisable, albeit only informational. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From mix77 at usa.net Tue Mar 6 06:02:52 2001 From: mix77 at usa.net (Mix) Date: Tue, 06 Mar 2001 13:02:52 +0200 Subject: Python and Printing Message-ID: <3AA4C3DC.95EF7249@usa.net> I have pictures (JPEG) which I get from a database and dump in an arbitrary directory. To print a picture I do the following: import os os.system("lpr lena.jpg") My problem is that page orientation is always"landscape" instead "portatrait". What switch is there to specify orientation for "lpr" if any? P.S. I'm working under linux (redhat 7.0 distribution ). From cce at clarkevans.com Tue Mar 27 09:40:27 2001 From: cce at clarkevans.com (Clark C. Evans) Date: Tue, 27 Mar 2001 09:40:27 -0500 (EST) Subject: Yet Another PEP: Query Protocol Interface or __query__ In-Reply-To: Message-ID: I've started to write an example usage of this PEP. It is far from perfect, however it should give you an idea of the usage. I could use some help with examples and tightening this up... Thanks! Clark ... Example Usage (written but not checked) Suppose a user has a function that requires a file-like object. Here is how adapt can be used to ensure that an argument does indeed follow the file protocol: import types from adapt import adapt def first_line(file): file = adapt(file,types.FileType) print file.readline() >>> first_line(open("c:/autoexec.bat")) SET WXWIN=F:\PROGRA~1\wx2 >>> first_line('bad') ... TypeError: test cannot be adapted to Let us assume that the code above becomes the norm, and now the user needs to re-use this code with a BLOB stored in a database. Here is how that would be done. class PseudoFile: def readline(self): # read line from BLOB return "This is a new line" # real code goes here # (other file functions go here) def __conform__(self,protocol): if protocol is types.FileType: return self >>> first_line(PseudoFile()) This is a new line Let us say that this works for a while, but sooner or later the concept of a forward-access read-only file is needed. So, perhaps the following "standard interface" emerges: class ForwardFile: def readline(self): pass def read(self,size=-1): pass class AdaptRead(ForwardFile): def readline(self): # implement using read class AdaptReadline(ForwardFile): def read(self,size=-1): # implement using readline class Adapt: def __call__(self, obj): # objects adaptable to FileType is are compliant retval = adapt(obj,types.FileType) if retval: return retval # objects that have both readline and read are ok if getattr(obj,'readline',None) and \ getattr(obj,'read',None): return obj # wrap objects exposing a readline if getattr(obj,'readline',None): retval = AdaptReadline() retval.readline = obj.readline return retval # wrap objects exposing a read if getattr(obj,'read',None): retval = AdaptRead() retval.read = obj.read return retval __adapt__= Adapt() This would allow our first-line program to be re-written to use the new interface: def first_line(file): file = adapt(file,ForwardFile) print file.readline() Note that anything which inherits from ForwardFile is a adaptable as well as anything which considers itself a FileType More so, do to the __adapt__ class method above, anything that has read or readline can be adapted to work! Let's say that time passes on, and a record-set class is created. And after the above interface is well in use (and now immutable due to wide distribution), the creator of the record-set class wishes to make this new class substitutable for any ForwardFile. class RecordSet: def readline(): pass # some intelligent impl def read(): pass # more intelligent impl # other record set specific stuff There are a few choices. First, the RecordSet class could inherit from ForwardFile. Or, the following __adapt__ method could be added! def __conform__(self,protocol): if protocol is ForwardFile: return self This has a slight problem in that a dependency is now created (ForwardFile must be on the user's system). This can be mitigated with something like the following: def __conform__(self,protocol): if protocol.__name__ = 'ForwardFile': return self Note that readline and read could be put in a wrapper class instead (so that they don't clutter the RecordSet class! Regardless, in every case where a ForwardFile is accepted, the adapter mechanism will also pass off for objects of this class. Questions: 1. Is there a way to get a fully-qualified name (including the package?) 2. What kind of "wrapper helpers" could be made? (I like Carlos's examples!) 3. Perhaps a __conform__ function would also like to know who the caller is... I wonder if this would be useful. Can this be obtained automatically? 3. Would a __protocol__ item also help? class ForwardFile: ... __protocol__ = "com.zoober.protocols.ForwardFile" This would allow the __conform__ above to be re-written: def __conform__(self,protocol): if protocol.__protocol__ = 'com.zoober.protcols.ForwardFile': return self In this way, support for multiple protocols could be put in place without requiring said classes/interface declarations on the user's box. 4. Is a protcol registry needed, or does the above suffice? (I think it's good enough) A proposal would be like: register_adapter(relevant_protocol, the_handler) And then, after exhausting the object and the protcol, it could check in the registry... Thank you all for your help! Clark From stephen_purcell at yahoo.com Tue Mar 27 12:25:20 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 27 Mar 2001 19:25:20 +0200 Subject: large arbitrary binary data in python In-Reply-To: ; from wcuddy@lserv.ja10629.home on Tue, Mar 27, 2001 at 04:46:19PM +0000 References: Message-ID: <20010327192520.F1260@freedom.puma-ag.com> Wayne Cuddy wrote: > 1) simply read the data into a python binary string Yes, see http://www.python.org/doc/lib/module-StringIO.html http://www.python.org/doc/lib/module-cStringIO.html > 2) pipe the string to md5sum to verify integrity Yes, but don't pipe it to md5sum if you can avoid it. Instead, use the 'md5' standard module: http://www.python.org/doc/lib/module-md5.html > 3) pipe the data to a shell command like this "gunzip -dc | dd of=device" Yep, see os.popen() and the popen2 module: http://www.python.org/doc/lib/os-newstreams.html http://www.python.org/doc/lib/module-popen2.html > Is there a limit to the size of a binary string in python? Yes. The limit is the amount of available virtual memory. -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From tim.one at home.com Sat Mar 3 16:59:01 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Mar 2001 16:59:01 -0500 Subject: A counter-counter-proposal for PEP 236: #pragma( nested_scopes) In-Reply-To: Message-ID: [Tim continues nagging Martin to write a PEP; Martin continues resisting] [Martin von Loewis] > I'm surprised that you evaluate the present based on what I think > about the future. I hope everyone who evaluates any proposed language feature does their best to consider its likely implications as far into the future as they can. For example, apart from explicitly identified unresolved issues in PEP 236, I did my best to ensure that no addition, change, or deletion would *ever* be needed to the rest of the PEP. I may not have succeeded (only time will tell), but I did my best toward that end. I want to see the same done for "directive" too -- along with every other language feature that ever gets proposed. Besides, no new language feature gets in without a PEP -- that's the rule we all play by now. Why should "directive" be exempt? > I think I've given a specification of the feature as implemented. If true, it should be trivial to copy the text of your spec into a PEP. I haven't seen the spec that I know of (I have seen a blossoming collection of now hard-to-find-again postings that suggest different variants of "directive"), and I'm not going to try reverse-engineering it from the patch. Neither are the Jython developers, who don't normally look at CPython patches at all. Etc. It needs a PEP. > I'd happily add a specificiation of the directive statement (including > plans that I have how it should look in Python 2.5.2 :) into PEP 236, > as a section "Alternative Proposal" - if you allow me to do that. No, because it doesn't make sense: if "directive nested_scopes" is accepted, then PEP 236 moves into the Rejected section, along with all the text you put into it. Then you'll need a separate PEP anyway. Play the game as if you expect to succeed . > I'd rather not author a new PEP, as the directive statement addresses > the same problem as does PEP 236. I don't know what the directive statement *is* in the absence of a PEP. How many "atoms" does it support in your mind today? Is "atom" slang or a deliberate reference to the Ref Man's grammar production of that name? If the latter, what sense is there in allowing constructs like directive [x+1 for x, y in module.foo() if x > 3] ? That is, don't you think the syntax is overly permissive? Etc: if you refuse to spell out your intent in a PEP, nobody has a basis for discussing it beyond wishful thinking (or reverse-engineering the patch du jour, which is unacceptable). What *would* make sense in PEP 236 is to say that PEP 240 (whatever -- the "directive statement" PEP) subsumes this-and-that parts of a future_statement's functionality. The "directive statement" PEP needs to be a separate entity not only for all the reasons given above, but because you *don't* intend for it to stop here. You need a separate PEP so that there's one clear place to specify the additional bells and whistles that go beyond the parts of future_statements it subsumes. last-msg-from-me-on-this-until-there's-a-pep-ly y'rs - tim From NOstarfighterSPAM at freeuk.com Sat Mar 17 11:37:01 2001 From: NOstarfighterSPAM at freeuk.com (Richard Townsend) Date: Sat, 17 Mar 2001 16:37:01 -0000 Subject: Catching exceptions in Tkinter's mainloop References: <%dws6.9947$Q47.2723350@news1.rdc1.tn.home.com> Message-ID: "Mike Callahan" wrote in message news:%dws6.9947$Q47.2723350 at news1.rdc1.tn.home.com... > I want to make sure that if any exception pops up inside a mainloop, that > exception is printed to a log file and the mainloop quits. I tried to > simulate this with the following code but failed: > > from Tkinter import * > > class Gui: > def __init__(self, master): > self.master = master > self.button = Button(master, text='Crash', command=self.crash) > self.button.pack() > > def crash(self): > z = zz # trigger exception > > root = Tk() > app = Gui(root) > try: > root.mainloop() > except: > print 'caught' > root.quit() > > It doesn't work. The exception is printed out by standard traceback and the > mainloop continues. What am I doing wrong? > > Mike Callahan > Tkinter catches exceptions raised in callbacks and Tk by using the class 'CallWrapper' (defined in Tkinter.py). I copied the technique used by Pmw, and created my own CallWrapper class (based on Tkinter.CallWrapper) and then after initialising Tk, I use the following statement: Tkinter.CallWrapper = MyCallWrapper MyCallWrapper's __call__ method invokes my error logging function in the final except clause, you could get yours to print info to your log file and quit. Note, you must always have an except clause for SystemExit (like Tkinter.CallWrapper does) otherwise calling sys.exit() in a callback won't work! e.g. class MyCallWrapper: """Internal class. Stores function to call when some user defined Tcl function is called e.g. after an event occurred.""" def __init__(self, func, subst, widget): """Store FUNC, SUBST and WIDGET as members.""" self.func = func self.subst = subst self.widget = widget def __call__(self, *args): """Apply first function SUBST to arguments, than FUNC.""" try: if self.subst: args = apply(self.subst, args) return apply(self.func, args) except SystemExit, msg: raise SystemExit, msg except: # substitute your functionality here... Richard From sholden at holdenweb.com Tue Mar 6 19:35:53 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 6 Mar 2001 19:35:53 -0500 Subject: I come to praise .join, not to bury it... References: Message-ID: "Mike C. Fletcher" wrote in message news:mailman.983890030.6303.python-list at python.org... > Here's a professional aesthetic's take: > A professional would call themself an aesthete :-) > mystring.join( ) > > This is a perfectly normal and good-looking construct. It seems pythonic > and beautiful, object orientation is part of Python, and this works nicely. > Agreed. > "'".join( ) > ";".join( ) > ".".join( ) > "!".join( ) > ",".join( ) > > All look like executable line noise. That is, the literal string's syntax > makes the use of dotted attributes on such a string look jarring and > off-putting. You almost expect some weird function to jump out of this > syntax. It looks very Ruby/Perl-esque. > Just the same, a beginner can read the code as "some string's method is applied to whatever argument is passed" just by knowing the syntax. > Note particularly the amount of space between the " character and the . > character. Typographically, " characters serve to set the enclosing data > off from the outer context, and that's the opposite of what you're trying to > do with dot notation. Dot notation normally looks natural because almost > every character that gets used right before the . comes fairly close to the > . (even characters such as r ). Also note: in the common cases of > single-character joins, there's no significant visual weight difference > between what's inside and outside the quotes). Consider what happens when > you alter the proportions of space and the size of the connector... > Well, if you like white space Python should be the perfect language for you! > "."__join( ) > "."-->join( ) > "."..join( ) > " "__join( ) > > You should find those slightly easier on the eyes (except possibly the " " > one) because the entire "." entity can be understood as a single graphic > with a connector to "join". > What about the currently syntactically-acceptable >>> ", " . join(["big", "fat", "joint"]) 'big, fat, joint' >>> Remember that technically the dot is an operator. Personally I find the extra whitespace intrusive, but that is a matter of style and taste. Any better for you? > That said, I don't think we'll get this particular wart out of the language, > so we'll have to deal with the flaw in the way artists have through the > ages, enhance it and accent it so people start to think it's a beauty mark. > Not a wart, but a consistent application of object-oriented principles. Sorry. I too wish the world looked more beautiful (to you). but-if-wishes-were-horses-then-bill-gates-would-have-hoofmarks-in-his-ass-ly y'rs - steve From bowman at montana.com Fri Mar 30 10:06:20 2001 From: bowman at montana.com (bowman) Date: Fri, 30 Mar 2001 08:06:20 -0700 Subject: Updated edition of Programming Python out References: Message-ID: Alan Miller wrote in message news:MPG.152d8de631a0ecbf98977b at news-enteract... > > Is there such a thing as a second edition of a computer (or other > technical) book that is _thinner_ than the original? I don't think it is thinner than the first edition, but K&R hasn't gained much weight in 20, 25 years, whatever the timespan is. The mark of a successful language, imho. True, it doesn't document libraries and modules, which seems to be where unchecked growth occurs. From mcalla at home.com Mon Mar 5 21:14:59 2001 From: mcalla at home.com (Mike Callahan) Date: Tue, 06 Mar 2001 02:14:59 GMT Subject: Simple Tkinter question Message-ID: I know this is probably a stupid question but after reading the Tkinter documentation I am still confused between root.quit() and root.destroy(). What are the differences between these two methods? Thanks. Mike Callahan From cce at clarkevans.com Fri Mar 9 06:50:41 2001 From: cce at clarkevans.com (Clark C. Evans) Date: Fri, 9 Mar 2001 06:50:41 -0500 (EST) Subject: Static typing (was Re: Java guy interested in Python) In-Reply-To: Message-ID: > So, are there any efforts in the Python community to provide something in > this area? I'm thinking of things like type inference, and of something > like "permissive typing" (compiler/interpreter to programmer: "you don't have > to tell me the type of a variable or argument, but if you do, I'll use that > information to help you wherever I can"). I'd be interesting to know to what level of type infrencing can be done with Python. In particular, I wonder what the ambiguous cases are... ML also does dynamic type infrencing, dynamically. When you type a variable or define a function on the interactive interpreter, ML returns with the type of the object. I'm sure something like this could be done in a Python interpreter, perhaps as an option. Of course, in ML, if a type is ambiguous, it must be declared -- unlike python. Clark From aleaxit at yahoo.com Tue Mar 13 04:05:22 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 13 Mar 2001 10:05:22 +0100 Subject: Einstein's Riddle References: <98glrd$1si1a$1@ID-75892.news.dfncis.de> <3AABE712.499CCF4C@home.com> <98gp5b$1u0oi$1@ID-75892.news.dfncis.de> <98i5880pl2@news2.newsguy.com> <98kfrl$pug$1@sshuraaa-i-1.production.compuserve.com> Message-ID: <98kntc0o5l@news2.newsguy.com> "Mark Yudkin" wrote in message news:98kfrl$pug$1 at sshuraaa-i-1.production.compuserve.com... > Rather than looking at America sites for information about emu's, consider > that it's an AUSTRALIAN flightless bird, and there's more to it than eating > it. It's an animal of Australian _origin_, just as, say, cows are of old-world origin; that doesn't imply it's wrong to look for emu information on American sites, any more than the species-origin of cows impedes Australian or American sites offering interesting bovine information. And, yes, of course there's more than gastronomy about _any_ animal or plant. However, _most_ people's main interests in cows, tomatos, lettuce, or emus, are quite likely to include culinary aspects (no matter how fascinating it IS to study a tomato flower's sepals, petals, stamens, carpels, anther, stigma, &c, for example, it is a biological as well as a cultural fact that most people would be more interested in ascertaining the amount of, say, sodium, vitamins, energy, minerals, dietary fiber, etc, in a 100-gram serving of tomato juice...). Alex From me at nospam.net Sat Mar 31 20:09:54 2001 From: me at nospam.net (Scottie) Date: Sat, 31 Mar 2001 17:09:54 -0800 Subject: PEP 240 scares me References: <15040.53203.949420.930912@beluga.mojam.com>, <99e2h61aao@news2.newsguy.com> Message-ID: def Farey(v, lim): '''Named after James Farey, an English surveyor. No error checking on args -- v >= 0, lim = max denominator, results are (numerator, denominator) in lowest terms. (1,0) is "infinity". ''' lower, upper = (0L,1L), (1L,0L) while 1: mediant = (lower[0] + upper[0]), (lower[1]+upper[1]) if v * mediant[1] > mediant[0]: if lim < mediant[1]: return upper lower = mediant else: if lim < mediant[1]: return lower upper = mediant "Moshe Zadka" wrote in message news:mailman.985731647.721.python-list at python.org... > On Tue, 27 Mar 2001 11:37:23 -0600 (CST), Skip Montanaro wrote: > > > Okay, dumb question time. Suppose the compiler sees the string "1.2" in the > > input stream. How does it translate that into a rational number (6/5 or > > 12/10 or 24/20 or ...)? Does it simply move the decimal point over > > sufficiently and create the corresponding rational number that contains the > > appropriate power-of-ten denominator? > > That's what Rational.py (in CVS nondist/sandbox/rational/) does. > > > What about rationals that can't be > > represented correctly using decimal notation (e.g. how does one get from > > 0.3333 to 1/3, or is it simply approximated by 3333/10000?) > > The later. If you want 1/3, you need to ask for it: > > third = rational(1)/3 > > I guess I could be bribed to have > > rational("0.(3)") == rational(1)/3 > > I just need to recall the formula for the sum of a geometric series and > apply it. There is no rational which cannot be written as > > \d*.\d*(\d*) > > Where () means "repeat ad infinitum". > -- > "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than Python? > looking for someplace else to grab power."|YODA: No...no... no. Quicker, > -- Wichert Akkerman (on debian-private)| easier, more seductive. > For public key, finger moshez at debian.org |http://www.{python,debian,gnu}.org > From admin at mulga.com.au Sat Mar 17 20:41:00 2001 From: admin at mulga.com.au (Michael Hall) Date: Sun, 18 Mar 2001 11:11:00 +0930 (CST) Subject: reading stdinput Message-ID: Please excuse this ultra newbie question ... How do I read standard input into a Python script? I'm trying to do the same as 'read' in a shell script to create a variable. I've played about with various combinations of 'sys.stdin.read()' and such but no go. If there is a better list for newbie questions like this, please let me know. *********************************************** Michael Hall - mick at mulga.com.au - mulga.com.au *********************************************** From francois.granger at free.fr Sat Mar 17 07:47:33 2001 From: francois.granger at free.fr (=?ISO-8859-1?Q?Fran=E7ois_Granger?=) Date: Sat, 17 Mar 2001 12:47:33 GMT Subject: Python style questions References: <98tb91$9t9$1@saltmine.radix.net> <98tdu1$cfk$1@panix2.panix.com> <1eqdo5u.1xxmzfi2kjk0qN%francois.granger@free.fr> <98v1vi$gre$1@news.udel.edu> Message-ID: <1eqevwc.ydlvbi3ybxaoN%francois.granger@free.fr> Terry Reedy wrote: > I posted an example about a month ago ... and about a year ago. > Don't know what archive search facilities we currently have. Sorry, found your post of Jan 24 throught groups.google.com. Thanks -- un jardin peut-il ?tre non naturel ? ce qui n'est pas naturel peut-il ?tre un jardin ? qu'est-ce qu'une mauvaise herbe ? part une herbe naturelle ? un jardin sans herbe est-il un jardin ? - Richard From gabriel_ambuehl-py at buz.ch Fri Mar 30 13:55:23 2001 From: gabriel_ambuehl-py at buz.ch (Gabriel Ambuehl) Date: Fri, 30 Mar 2001 20:55:23 +0200 Subject: Working with soaplib... Message-ID: <86550378262.20010330205523@buz.ch> -----BEGIN PGP SIGNED MESSAGE----- Hello, I've been trying to work with either soaplib or XMLRPC (I don't care too much about which one gets used as long as my RPC works. As SOAP looks to be a much broader standard, it would probably the one to prefer, but this is largely theoretical as this is an inhouse project and I plan to write a small wrapper function which should take care of the underlying transport anyway)and while writing clients is simple, I run into serious problems when it comes to writing servers (soapserver got modified to not use any try/except constructions so it will dump everything to the screen which is to be preferred as error handling seems to be broken, i.e. the client will just get some list containing other, empty lists): - ---------- import SocketServer import soapserver class TestRequestHandler(soapserver.RequestHandler): #Override method: def call(self, method, params): print "Dispatching: ", method, params try: server_method = getattr(self, method) except: raise AttributeError, "Server does not contain SOAP procedure %s" % method return server_method(method, params) def equal_five(self, method, params): print "inside equal_five()" return 5 def test(self, method, params): return params def add(self, method, params): c=params[0]+params[1] print "c: " + c return c if __name__ == '__main__': server = SocketServer.TCPServer(('', 8000), TestRequestHandler) server.serve_forever() - ----------- And the client >>> import soaplib >>> server = soaplib.ServerProxy("http://local:8000") >>> print server.test('test') this works without any problems and yields test on the screen (as one would expect) Now >>> print server.equal_five() won't work, the server dumps the following error: Dispatching: equal_five () inside equal_five() - ---------------------------------------- Exception happened during processing of request from ('10.2.2.100', 3574) Traceback (most recent call last): File "/usr/local/lib/python2.0/SocketServer.py", line 221, in handle_request self.process_request(request, client_address) File "/usr/local/lib/python2.0/SocketServer.py", line 247, in process_request self.finish_request(request, client_address) File "/usr/local/lib/python2.0/SocketServer.py", line 251, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/local/lib/python2.0/SocketServer.py", line 385, in __init__ self.handle() File "/usr/local/lib/python2.0/BaseHTTPServer.py", line 266, in handle method() File "\\local\admin_net\soaplib-0.8-20000621\soapserver.py", line 37, in do_POST File "\\local\admin_net\soaplib-0.8-20000621\soaplib.py", line 654, in dumps AssertionError: argument must be tuple, method call/response, or fault instance - ---------------------------------------- (the script lives on a FreeBSD machine and the client gets loaded over samba from it, that's why the strange UNCs are there) I think there's something wrong with my return statements of the not working functions but can't seem to figure out what to do about it. What data type do I need to return so soaplib.dumps (xmlrpclib.dumps appears to be having exactly the same problem, for that matter) can handle it? A tuple like return (value,) doesn't appear to be working, neither does return ([value,]) Any help would be greatly appreciated. Thanks in advance and best regards, Gabriel -----BEGIN PGP SIGNATURE----- Version: PGP 6.0.2i iQEVAwUBOsTIj8Za2WpymlDxAQGO+Af+Ms+cs0fY6Nu0njzyqUttJvs/Cb7o9QXi 6VL/7h3dxJ1eBxY+NNDgZeGlf1V0YgkjTjSYknksxARcW8wdILLK5WJPlbqBsZWb TiUCWbNzCXVVLVF5DzEUmtlL5QMSR4cceRbufD/Kpfi/87xgcPTRzVoMC2vGMIKh PXLn9f0L4MjvUWYcdXOWrZDRAQVfcT3ivaK4bQLeiRkI+lTWTcHSdjdKAKyHMvKh owpUbzzwL7p4l1wYxjpgfZStNEulMzGIpw6FebdGRj8lwyCO1wiOyV+bBm40o6b1 RZ6ihz2Pvgl9Q+Q2Z40woOO/dTq9r1tFbQPT16WwL77xlXj+7PRcvg== =NX/H -----END PGP SIGNATURE----- From ocaner at gmx.de Sun Mar 11 06:55:45 2001 From: ocaner at gmx.de (Özgür Caner) Date: Sun, 11 Mar 2001 12:55:45 +0100 Subject: RPM Module? Message-ID: <3aab687b$1@news.teuto.net> Does anybody know where to find a Documentation about the RPM Module for Python? From phrxy at csv.warwick.ac.uk Thu Mar 29 12:44:19 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Thu, 29 Mar 2001 18:44:19 +0100 Subject: Defining class files In-Reply-To: <3ac33343$0$12248$ed9e5944@reading.news.pipex.net> References: <3ac33343$0$12248$ed9e5944@reading.news.pipex.net> Message-ID: On Wed, 28 Mar 2001, Neil Benn wrote: [...] > >>> YourClass > > > The text file is saved as YourClass.py - is this the problem, should > class files have different terminaters in their filename?? [...] The module name comes from the name of the file it is saved in. YourClass.py gives you a module called YourClass. This is fine -- using the same name for both class and module is common practice (although not when the module name includes the word 'class'!) -- but you'll have to use: import YourClass foo = YourClass.YourClass() or this: from YourClass import YourClass foo = YourClass() to get at the class inside the module. John From Hawley_Randall_R at Lilly.com Tue Mar 27 12:12:51 2001 From: Hawley_Randall_R at Lilly.com (Randy Hawley) Date: Tue, 27 Mar 2001 17:12:51 GMT Subject: newbie IDLE, Tkinter References: Message-ID: <01c0b6e2$3d426740$4ecb0c28@PC0AB085S5A8> Howdy Python Gurus. I too am a newbie trying out Python on Win32 platforms. I have the same problems as Nick describes below. Also, somethimes when I hit a button that has "command=root.quit" defined as its action, not only does my program's window quit, but so does IDLE. What gives with this? Anybody else ever run into this? Is it a result of poor coding in my script (saw it when I just ran the examples from the Tkinter tutorial, too) ? Thanks, Randy Hawley Nick Perkins wrote in article ... > I have been playing around with Python and Tkinter, using the IDLE prompt > and edit windows. > > I am a little confused about what happens when I run my tkinter programs, > then close them (by closing their window). Sometimes I come back to the > prompt, sometimes the interactive window just seems to hang, and sometimes > the whole IDLE program just quits. > > Can someone explain the best way to interactively edit and test a tkinter > program with IDLE? Do these window-closing behaviours depend on how I > actually run my program? > > > > From guido at digicool.com Sat Mar 3 14:44:19 2001 From: guido at digicool.com (Guido van Rossum) Date: Sat, 03 Mar 2001 14:44:19 -0500 Subject: Bug fix releases In-Reply-To: Your message of "Sat, 03 Mar 2001 14:30:13 EST." <15009.17989.88203.844343@cj42289-a.reston1.va.home.com> References: <200103031821.NAA24060@panix3.panix.com> <200103031910.OAA21663@cj20424-a.reston1.va.home.com> <15009.17989.88203.844343@cj42289-a.reston1.va.home.com> Message-ID: <200103031944.OAA21835@cj20424-a.reston1.va.home.com> > Guido van Rossum writes: > > I wonder, does that extend to new library modules? Is there also > > resistance against the growth there? I don't think so -- if anything, > > people are clamoring for more stuff to become standard (while at the > > There is still the issue of name clashes; introducing a new module > in the top-level namespace introduces a potential conflict with > someone's application-specific modules. This is a good reason for us > to get the standard library packagized sooner rather than later > (although this would have to be part of a "feature" release;). But of course the library repackaging in itself would cause enormous outcries, because in a very real sense it *does* break code. > > Wait a minute! Now you're making it too complicated. Betas of bugfix > > releases? That seems to defeat the purpose. What kind of > > Betas of the bugfix releases are important -- portability testing is > fairly difficult to do when all we have are Windows and Linux/x86 > boxes. There's definately a need for at least one beta. We probably > don't need to lengthy, multi-phase alpha/alpha/beta/beta/candidate > cycle we're using for feature releases now. OK, you can have *one* beta. That's it. > > It's not too late, as I mentioned. We'll also do this for 2.1. > > Managing the bugfix releases would also be an excellent task for > someone who's expecting to use the bugfix releases more than the > feature releases -- the mentality has to be right for the task. I > know I'm much more of a "features" person, and would have a hard time > not crossing the line if it were up to me what went into a bugfix > release. That's how all of us here at PythonLabs are feeling... I feel a community task coming. I'll bless a 2.0.1 release and the general idea of bugfix releases, but doing the grunt work won't be a PythonLabs task. Someone else inside or outside Python-dev will have to do some work. Aahz? > > BTW, See you at the conference! > > If we don't get snowed in! Good point. East coasters flying to LA on Monday, watch your weather forecast! --Guido van Rossum (home page: http://www.python.org/~guido/) From erno-news at erno.iki.fi Mon Mar 5 19:15:16 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 06 Mar 2001 02:15:16 +0200 Subject: I come to praise .join, not to bury it... References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> Message-ID: In article <97rka002k9 at news1.newsguy.com>, "Alex Martelli" writes: | I have not heard ANY _technical_ arguments opposed to | this last time the discussion went around -- nothing but | vague aesthetic, "it should be the other way", "I find it | ugly" kind of complaints. what's wrong with vague aesthetic?-) if lots of people share it, it's not to be dismissed so lightly. -- erno From francois.granger at free.fr Fri Mar 30 18:18:56 2001 From: francois.granger at free.fr (=?ISO-8859-1?Q?Fran=E7ois_Granger?=) Date: Fri, 30 Mar 2001 23:18:56 GMT Subject: Creation d'un NG francophone sur Python References: <1eqzyk6.gxd4jr1tkjykzN%francois.granger@free.fr> <9a1e6f011es@enews3.newsguy.com> Message-ID: <1er40bo.b8vjsq6avf3gN%francois.granger@free.fr> Grant Edwards wrote: > I certainly would never vote against a French Python newsgroup. > But, I want to let you know that French language postings are > quite welcome in this group -- as are threads in any other > language. > > You've even got a fair chance of getting replies to questions > posted in Esperanto. Thanks for this message and other nice messages. And sorry to have started a political thread about linguistic, this was not my aim. [fr] Merci pour ton messages et les autres messages accueillants. D?sol? d'avoir d?marr? une enfilade politique ? propos de pr?f?rences linguistiques, ce n'?tait pas le but. -- "On jouit moins de ce qu'on obtient que de ce qu'on esp?re." - Jean-Jacques Rousseau - Cit? par Anne-Marie From jmarshal at mathworks.com Mon Mar 5 12:20:01 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 5 Mar 2001 17:20:01 GMT Subject: Q: Operator precedence References: <3AA3BCB1.13CC1479@javanet.com> Message-ID: <980hs1$c8t$1@news.mathworks.com> Raymond Hettinger wrote: > Pearu Peterson wrote: >> Section 5.12 in Python reference manual summarizes operator precedence. >> >> I would like to have the following function: >> >> def getprec(s): >> return > Here is an approach to rank ordering of precedence at run-itme: > def higherOrEqual( op1, op2 ): > return eval('51 %s 83 %s 97 == ( 51 %s 83 ) %s 97' % (op1,op2,op1,op2)) > order = ['Lower', 'HigherOrEqual'] > binops = ['+', '-', '&', '^', '/'] > for x in binops: > for y in binops: > print x, order[higherOrEqual(x,y)], y This will fail for '**', since it's right-associative. (Ignoring integer overflow and computation time.) From m.wilson at bibliocraft.com Tue Mar 6 21:02:34 2001 From: m.wilson at bibliocraft.com (Mark Wilson) Date: Wed, 7 Mar 2001 02:02:34 -0000 Subject: Windows98+Idle0.6+ 32 bit color HW or SW problem? Message-ID: <010901c0a6aa$cbe04e60$7e824ac3@mwdell1> Gerrit: This may be a bit lower level than you want, but... >When switching >between 16 bit and 32 bit color mode the Tkinter windows are apparantly not >updated, the contents of these windows becomes garbage. > >Microsoft applications, such as IE and outlook express do not suffer from >these effects. Is there any known SW problem in Tkinter or related SW, which >may cause these problems. The alternative is suspect HW (AMD Thunderbird 900 >MHz, ELSA Gladiac MX). Windows sends a message with the id WM_DISPLAYCHANGE whenever the user applies changes to screen resolution/depth. (In fact, with typical MS "panache", they send the message twice - same params each time - and don't talk to me about WM_ACTIVATE!). I have no experience with either Tkinter or Idle, but you could check the Win sources and see if this message is at least handled by the Windows message handling code. That might indicate a possible solution. I don't actually know where this message is derived from, but I'd be surprised if it was the graphics card driver. >I now get horizontal disturbances in the idle and other >TKinter windows, when using 32 bit color mode and 1280*1024. Sounds like a different problem - perhaps that is the HW/driver. Perhaps you could elaborate. Have fun wishing-he-was-at-ipc9-with-the-guys-who-could-give-you-better-answers-ly y'rs - Mark From chrisw at nipltd.com Thu Mar 8 09:25:08 2001 From: chrisw at nipltd.com (Chris Withers) Date: Thu, 08 Mar 2001 14:25:08 +0000 Subject: virtual hosting in Zope References: <987lbo$119t$1@infocom.km.ua> Message-ID: <3AA79644.58A556A8@nipltd.com> "Anton A. Zotov" wrote: > > Urgent: I'd appreciate a person who would tell me how to implement virtual > hosting under Zope/Medusa environment zope at zope.org is the mailing list to ask on. SiteAccess is the key, it can be downloaded from www.zope.org and comes included with Zope versions 2.3.0 and above. cheers, Chris From bob_cannard at mentor.com Fri Mar 23 17:09:14 2001 From: bob_cannard at mentor.com (Bob Cannard) Date: Fri, 23 Mar 2001 14:09:14 -0800 Subject: re.match References: Message-ID: <3ABBC98A.EE24DE24@mentor.com> > Dave Brueck wrote: > Hi Bob, > > '$' matches 'end of string', so you _can_ use re.match to test "Is this string a Thing". Heh. I already knew that, Dave; apparently my original message wasn't clear enough. My point was that there's no way to do it without constructing a second regular expression, which is inefficient and clumsy. What is wanted is something like: def fullmatch(r, s): return re.match(r + '$', s) but which, by analogy with re.match, does not have the overhead of constructing and compiling a new regular expression; which works equally well whether r is a string or a compiled re; which works regardless of whether or not r already has a $ at the end. I'm just surprised that Python has a separate function for matching at the start of a string but seems to lack one for matching an entire string. The issue is efficient re-use of a compiled regular expression in different situations, not "how to do this". Cheers, Bob. From MarkH at ActiveState.com Sat Mar 10 21:35:37 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 11 Mar 2001 02:35:37 GMT Subject: win32com:MakePy -- Early Binding without the size jitters? References: Message-ID: <3AAAE3BB.5090506@ActiveState.com> Clark C. Evans wrote: > Hello. I'd like to use early-binding with about three COM > libraries, each one of the stub.pyc files over 100KB (with > one in particular over 300KB). However, I'm only using > about a dozen methods (including constructors, etc) from > each library. I was wondering... is it safe to delete > methods/interfaces which I'm not using? I've deleted > a few, and it still works for my purposes, so I was > wondering if I'm shooting myself in the foot -- or if > there is a methodological approach to this pruning? > It'd be cool to get the .pyc alot smaller; no use > toossing away 1MB of memory when I only need a few K... > If you are using the gencache functions to create makepy files, try passing "bForDemand=1" to the functions. This will only generate what is actually used by the program, as it is used. Mark. From fredp at mygale.org.nospam Wed Mar 21 10:57:19 2001 From: fredp at mygale.org.nospam (Fred Pacquier) Date: 21 Mar 2001 15:57:19 GMT Subject: Accessing Oracle from Python remotely ? References: Message-ID: "gkiffney" said : >There's http://www.zope.org/Products/DCOracle which should get you >started. There was an article by Uche Ogbuji in Linuxworld that helped >me get going with this, but it's apparently fallen off the Internet map >into the bit bucket. Using the dcoracle module (which is a bit of a >pain to get going, look at the Zope docs carefully, and if you can find >the prebuilt dll's, use those), you can do things like this: Thanks for confirming this. DCOracle definitely sounds like the right candidate. Some will probably smile at this, but my first problem actually will be to get the Oracle client onto the Unix box. We have servers on NT and Unix, but unfortunately the "client = Windows" law applies here, too... :-) -- YAFAP : http://www.multimania.com/fredp/ From greg at cosc.canterbury.ac.nz Thu Mar 1 19:48:24 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 02 Mar 2001 13:48:24 +1300 Subject: Collection interfaces References: <3a90fa97.0@news1.mweb.co.za> <3A933830.7F98D118@ix.netcom.com> <220220010813598042%cmh@bDistributed.com> <8Gem6.473353$U46.14105062@news1.sttls1.wa.home.com> <3A9A86B1.9A8C69A2@ix.netcom.com> <97fjla128ir@news2.newsguy.com> <97h5s40vhc@news2.newsguy.com> <97ifd60sen@news1.newsguy.com> Message-ID: <3A9EEDD8.9102C3A@cosc.canterbury.ac.nz> Alex Martelli wrote: > > the indisputable success > of Smalltalk does show that single-inheritance is *practically > workable* for many tasks Smalltalk is like Python in that its inheritance hierarchy is more about implementation inheritance than subtype relationships. So I don't think you can conclude much from Smalltalk about whether single inheritance is adequate for classification purposes. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From akuchlin at mems-exchange.org Fri Mar 23 14:29:04 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 23 Mar 2001 14:29:04 -0500 Subject: pyncurses documentation?? References: <3abb8a08$0$16654@SSP1NO25.highway.telekom.at> Message-ID: <3dn1acz3lr.fsf@ute.cnri.reston.va.us> Alex Berger writes: > Does anybody know where I can get an introduction/documentation to > pyncurses?? The LibRef documentation is at http://www.python.org/doc/lib/module-curses.html, and the HOWTO is at http://py-howto.sourceforge.net/curses/ . --amk From woetzel at gmd.de Mon Mar 26 05:19:26 2001 From: woetzel at gmd.de (Gerd Woetzel) Date: 26 Mar 2001 10:19:26 GMT Subject: Is setup.py a "good thing"? (long) References: <3aba76e2.167083508@24.0.228.33> <3dvgp1zasw.fsf@ute.cnri.reston.va.us> <99fsdu$p2u$1@hop.gmd.de> <3dpuf8zb4t.fsf@ute.cnri.reston.va.us> Message-ID: <99n53e$5s3$1@hop.gmd.de> >Andrew Kuchling writes: >> woetzel at gmd.de (Gerd Woetzel) writes: >> > Modules/Setup has buit zlibmodule.so and socketmodule.so which worked >> > fine during the test phase, but setup.py has (secretly?) created >> > zlib.so (socket.so) too! Finally "make install" has installed all of them. >> >> That certainly shouldn't have happened. Can you reproduce the problem? Martin von Loewis writes: >It could happen if you use *shared* in Modules/Setup and if setup.py >is older than 1.30; before, it would use on builtin_module_names to >exclude modules. So that was a problem once and should be fixed since >2.1b1. I have tried 2.1b1 and the newest 2.1b2a this morning. It still installs both both _socket.so (wrong!) and _socketmodule.so (the working module). Same with zlib.so and zlibmodule.so. Note: After removing the installation directory /opt/python/lib/python2.1/ I have done the Installation from scratch, starting with the extraction of Python-2.1b2a.tar.gz. Here is my Setup.local which I have copied to Python-2.1b2a/Modules after extraction of the sources (yes, I used *shared*) : readline readline.c -I/opt/gnu/include -L/opt/gnu/lib -lreadline -ltermcap *shared* WZLIB=/home/woetzel/lib WZINCL=/home/woetzel/include _socket socketmodule.c \ -DUSE_SSL -I$(WZINCL)/ssl -I$(WZINCL)/ssl/openssl \ -L$(WZLIB)/ssl -R$(WZLIB)/ssl -lssl -lcrypto zlib zlibmodule.c -I$(WZINCL) -L$(WZLIB) -R$(WZLIB) -lz Here is the output of "grep _socket make.out": Python-2.1b2a/Lib/test/output/test_socket Python-2.1b2a/Lib/test/test_socket.py Python-2.1b2a/PCbuild/_socket.dsp gcc -shared Modules/socketmodule.o -L/home/woetzel/lib/ssl -R/home/woetzel/lib/ssl -lssl -lcrypto -o Modules/_socketmodule.so building '_socket' extension gcc -shared build/temp.solaris-2.8-sun4u-2.1/socketmodule.o -L/usr/local/ssl/lib -L/usr/local/lib -lssl -lcrypto -o build/lib.solaris-2.8-sun4u-2.1/_socket.so skipping '_socket' extension (up-to-date) from _socket import * test_socket from _socket import * test_socket /opt/gnu/gnubin/install -c -m 644 ./Lib/test/test_socket.py /opt/python/lib/python2.1/test /opt/gnu/gnubin/install -c -m 644 ./Lib/test/output/test_socket /opt/python/lib/python2.1/test/output Compiling /opt/python/lib/python2.1/test/test_socket.py ... Compiling /opt/python/lib/python2.1/test/test_socket.py ... skipping '_socket' extension (up-to-date) skipping '_socket' extension (up-to-date) copying build/lib.solaris-2.8-sun4u-2.1/_socket.so -> /opt/python/lib/python2.1/lib-dynload /opt/gnu/gnubin/install -c -m 555 Modules/_socketmodule.so /opt/python/lib/python2.1/lib-dynload/_socketmodule.so ls -l /opt/python/lib/python2.1/lib-dynload/_socket*: -rwxrwxr-x 1 woetzel woetzel 60704 Mar 26 11:24 /opt/python/lib/python2.1/lib-dynload/_socket.so -r-xr-xr-x 1 woetzel woetzel 60668 Mar 26 11:35 /opt/python/lib/python2.1/lib-dynload/_socketmodule.so Not a big Problem. "rm lib-dynload/_socket.so" will fix it. Just for information ... Regards, Gerd -- Gerd Woetzel | email: gerd.woetzel at gmd.de GMD FIT.CSCW | phone: ++49 2241 142648 (fax: 142084) D-53754 Sankt Augustin | www: http://orgwis.gmd.de/~woetzel/ From aleb at gmx.net Sat Mar 24 09:40:58 2001 From: aleb at gmx.net (Alex Berger) Date: Sat, 24 Mar 2001 15:40:58 +0100 Subject: reading single bits? Message-ID: <3abcb2da$0$20400@SSP1NO25.highway.telekom.at> How can I read/write single bits of some binary data when I know the position?? alex. From ws-news at gmx.at Thu Mar 1 18:43:28 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Fri, 2 Mar 2001 00:43:28 +0100 Subject: catching a del References: Message-ID: <983490479.833644@newsmaster-04.atnet.at> not sure how to implement such thing in python, but you could use an object that has the reference to your object and allows the client software to access the object's functionality so you have references to the object in that 'reference' object and in the dictionary but only the client software has references to the 'reference' object (hate that term, maybe someone more trained in english language can provide me with a better one...) so when all references to that new object are gone it will then be destroyed and can remove the object from the dict hth werner Dan Parisien wrote in message news:j%zn6.322252$f36.11513719 at news20.bellglobal.com... > class obj: > def __init__(self, name, parent): > parent.children[name] = self > self.parent = parent > self.name = name > > def onDelete(self): #?! > del self.parent[self.name] > > I want to be able to catch a del of an instance of the above class so I can > remove it from its parent dictionary. Is there a way? (note it cannot be in > a destructor because there will always be a reference inside the parent > dict) > > Thanks, > Dan From pieter at equinox.co.za Fri Mar 16 06:52:01 2001 From: pieter at equinox.co.za (Pieter Nagel) Date: Fri, 16 Mar 2001 13:52:01 +0200 Subject: gah! I hate the new string syntax In-Reply-To: References: <97sudi01i26@news1.newsguy.com> <98elrk$li8$1@nntp.Stanford.EDU> <98fc070thh@news1.newsguy.com> <98iqo2$56o$1@nntp.Stanford.EDU> <98iv3s01sc2@news2.newsguy.com> Message-ID: On Mon, 12 Mar 2001 17:56:33 +0100, Alex Martelli wrote: > Focusing on the polymorphism needs, I see the issue in the mirror > way from you: it's a _weakness_ (of Python and most other languages) > that I can't add methods 'post-facto, from the outside' to existing > objects -- it impedes the most natural, elegant, typeswitch-free way > to add functionality. Not true. See my other message in this post for how to extend Python classes with new methods at runtime. -- ,_ /_) /| / / i e t e r / |/ a g e l From bill-bell at bill-bell.hamilton.on.ca Tue Mar 20 11:49:36 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Tue, 20 Mar 2001 11:49:36 -0500 Subject: Little red lines in PythonWin! Message-ID: <3AB743D0.30906.DCA4AF@localhost> OK, I withdraw my earlier stupid question. Let me ask another one! What, in general, do you guys do about distributing sourcecodes in a language like Python that depends on indenting and where tabs can cause chaos. (And, no, you can't possibly shoot all of those of us who get caught this way, so that's not a solution.) Please point me towards the accepted approach. Thanks. From topmind at technologist.com Fri Mar 23 00:26:08 2001 From: topmind at technologist.com (topmind) Date: Fri, 23 Mar 2001 05:26:08 GMT Subject: Collection interfaces References: <3a90fa97.0@news1.mweb.co.za> <3A9A86B1.9A8C69A2@ix.netcom.com> <97ibmc0k47@news1.newsguy.com> <97m0c7080c@news2.newsguy.com> s.earthlink.net> <3AA2A898.450B659E@mail.com> <3AB755F8.67E84126@mail.com> <%a%t6.17245$227.1601569@newsread2.prod.itd.earthlink.net> <3AB8A730.4BE13D22@mail.com> Message-ID: "Troy Brumley" wrote in message news:B6DF5D0D.D7AE%t*b*r*u*m*l*e*y at f*u*s*e.n*e*t... > in article anhu6.18497$Im6.1938203 at newsread1.prod.itd.earthlink.net, topmind > at topmind at technologist.com wrote on 3/22/01 1:57 AM: > > > > > "Troy Brumley" wrote in message > > news:B6DE17D2.D6B0%t*b*r*u*m*l*e*y at f*u*s*e.n*e*t... > >> in article 3AB8A730.4BE13D22 at mail.com, James A. Robertson at > >> jarober at mail.com wrote on 3/21/01 8:06 AM: > >> > >>> topmind wrote: > >>>> > >>> > >>>>> http://www.cincom.com/smalltalk > >>>>> > >>>> > >>>> I only see a front page, not a parsing example. > >>>> > >>> > >>> Follow the tutorial link - it's right there on that page. > >>> > >>> > >>>> Besides, what are you comparing it to so say > >>>> it is better than a procedural/relational approach? > >>> > >>> It's vastly easier than similar code done in C or basic, for example > >> > >> User testimonial here ... last week I had to rip thorugh a pile of IIS > > logs > >> to get some statistics for some people, and I used the original (non-gui) > >> tutorial code as a starting point. I was once again impressed with how > > much > >> easier it was to do several common data processing tasks in Smalltalk than > >> it was in Assembly language or C or Pascal. > >> > > > > Give me specific requirements and I bet I can match it on code size. > > > > C, Pascal, and Assembly are hardly what I would use for code-size > > contests. > > > > Of course, there is more to comparing than code size, but those often > > get very subjective or fuzzy. > > I rarely worry about code size except how it relates to code clarity. Even > back in my assembly oriented youth I tried to keep functions under one page > on a listing for the sake of clarity. > Can you quantify "clarity" or is it a personal thing (subjective)? What makes people confortable with code seems to vary greatly per individual. Do you have specific examples. > I mention C, Pascal, and Assembly because they are my usual tool set, or > were until I discovered Smalltalk. I used similar stuff at first, but was glad to leave them in the dust when I discovered the concepts of Table Oriented Programming. I never wanted to see another fricken array again (accept as hashes/dictionaries to pass single records or parameter lists or attributes. That is their best use, and not data collection holding.) > I've done a lot of business programming > over the years in procedural environments and used more languages than those > (even COBOL and RPG) but for the heavy lifting I would always stick with > them. > > Again, until I discovered Smalltalk :) > > I've seen Perl and run away screaming. Perl is a strong divisor. You either swear by it, or swear at it. There are few in-betweeners. > Python and Eiffel are on the to learn > list, but Smalltalk seems to have the power I need for the tasks I want to > do these days. Objects are becoming more and more natural as I use them, and > my code improves contantly. > > > > >> I'm a long time procedural type, learning to really think in and use > >> Smalltalk has been an interesting experience. > >> > >> I've also done a lot of database "fixing" and Smalltalk has usually beat > > out > >> raw SQL for anything but the most trivial tasks. > >> > > > > Fixing what? SQL is not good at string parsing. > > Usually sweeping changes, or dangling referential integrity problems. Huh? Referential integrity is an option, not a forced feature. If the lamp keeps you awake at night, then turn it off! > > >> All that said, I think it's the environment (interactive) that improves > > the > >> experience as much as the language itself. If I had a reasonable > >> interpretive BASIC environment available, I could probably do many of the > >> things I did in Smalltalk almost as easily ... certainly more easily than > >> with C. > >> > > > > I find interpretive environments potentially more compact code-wise than > > static ones. > > No argument here. > > > > >> > >>> > >>>> > >>>>>> > >>>>>>> [snip] From scarblac at pino.selwerd.nl Thu Mar 22 10:47:53 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 22 Mar 2001 15:47:53 GMT Subject: New PEP: The directive statement References: Message-ID: I'm not that happy with this PEP. I'll try to explain why. First I have to point out an inconsistency in the PEP, then I'll explain my broader concerns. For problem a) I think 'from __future__' is better, for b) I think directives are too general, allow things we want to keep away from the language, this problem is better solved with, say, a sys.options dict. Martin von Loewis wrote in comp.lang.python: (I'll leave some bits that I want to comment on) (A) > In discussion of this PEP, readers commented that there are two > kinds of "settable" language features: > > a) those that are designed to eventually become the only option, > at which time specifying use of them is not necessary anymore. > The features for which the syntax of the "Back to the > __future__" PEP [3] was proposed fall into this category. This > PEP supports declaring such features, and supports phasing out > the "old" meaning of constructs whose semantics has changed > under the new feature. However, it defines no policy as to what > features must be phased out eventually. > > b) those which are designed to stay optional forever, e.g. if they > change some default setting in the interpreter. An example for > such settings might be the request to always emit line-number > instructions for a certain module; no specific flags of that > kind are proposed in this specification. > > Since a primary goal of this PEP is to support new language > constructs without immediately breaking old libraries, special > care was taken not to break old libraries by introducing the new > syntax. (B) > Syntax > > A directive_statement is a statement of the form > > directive_statement: 'directive' NAME [atom] [';'] NEWLINE > > The name in the directive indicates the kind of the directive; it > defines whether the optional atom can be present, and whether > there are further syntactical or semantical restrictions to the > atom. In addition, depending on the name of the directive, certain > additional syntactical or semantical restrictions may be placed on > the directive (e.g. placement of the directive in the module may be > restricted to the top of the module). (C) > Backwards Compatibility > > Introducing 'directive' as a new keyword might cause > incompatibilities with existing code. Following the guideline in > [1], in the initial implementation of this specification, > directive is a new keyword only if it was used in a valid > directive_statement (i.e. if it appeared as the first non-string > token in a module). First the inconsistency: the syntax definition in (C) claims that some restrictions on the placement of directive may be in place, depending on the directive. However, (D) notes that directives must appear as the first non-string token in a file, for backwards compatibility. So in practice, directive can't be used anywhere in a file. Then the two kinds of language features, from (A). The transitional features are your a), the features that will have a short transitional period before they become just another part of the language. This is the part that the __future__ PEP addresses. Your problem b) is for truly optional features, I imagine that would be things like optimization, warnings, debugging output (like your line numbers). These things are currently addressed by command line options. I don't think these two problems are solved best by a single solution. What I miss most in the 'directive' approach is the introspection. Can a program see which directives are on? List the current directives and their docstrings? Also, if I can turn on a directive further down a file, how can I turn it *off*? Transitional features are transitional for a hopefully short time. They are provided for people who need to test their existing software against an upcoming incompatible feature, and for early adopters who want the new feature now so they can tinker with it. The version in which the feature will become part of the language proper is already decided (2.2, in the case of nested scopes). The 'from __future__ import' idea shows that a feature is being used from a future version. It's also a realy module with real information, so that a running program can see what is in there, and can see information like the version when this will become mandatory and, not least, the feature's docstring. What is ugly about that is the magical side effect of an import statement at the first line of a file that has compile time side effects. But since this is for testing code against upcoming changes and for early adopters who are usually testers anyway, I don't see that as a big problem. Besides, using __underscores__ always implies at least a little magic, as should time machines. The 'directive' idea still has the magical first line of the file bit, but it doesn't provide information to the running program about what is turned on. It's not possible to make a single tool once that removes unneeded 'directive' statements from files, or even prints a list of available statements. Also, 'transitional' is odd. The feature is *in a transitional period*, but neither the file nor the feature is transitional (it's either on or off, not in some transitional state). So I don't even agree on the clarity point. And then the other half of the problem, use of the directive statement for other things. Is this vapor? I can't think of any useful applications at the moment; for systemwide features we have command line options (not that that's perfect, but that's not the point here), and directives can only be used on a file-wide level. I can imagine there would be options you want to toggle on a smaller level, say, for only part of a file. But you can't toggle directives, you can't even see what their current setting is, inside the program. So I feel the application domain for the second form of directive is very small, basically compile time options that make sense for single files. I haven't seen a pressing demand for those. Besides, a dictionary 'sys.options' could control a lot of options. In a much nicer and more Pythonic way. In the case of compile time options, they'd have to be set before the file is compiled, say, before an 'import' statement. Want to warn for mixed tabs and spaces for a single file, not using the compile time option? set sys.options["mixedtabs"] to 1, then import it. What this means is that you can't have real (non-transitional) options that change the semantics of the file and distribute the files, because you can't rely on the option being turned on. This is a good thing! It keeps Python a single language. Option directives basically mean "This file is in Python, with directives 2, 4 and 6c turned on." We don't want that. Transitional features have a use, but only because they'll be mandatory soon. For problem a) I think 'from __future__' is better, for b) I think directives are too general, allow things we want to keep away from the language, this problem is better solved with, say, a sys.options dict. I could go on, but noone reads this far anyway, I'll wait for the reactions :-). -- Remco Gerlich From db3l at fitlinxx.com Fri Mar 9 20:55:52 2001 From: db3l at fitlinxx.com (David Bolen) Date: 09 Mar 2001 20:55:52 -0500 Subject: getting the field names from a resultset on Windows with mxODBC References: Message-ID: "Scott Hathaway" writes: > I am using mxODBC for Windows. When I do a query, how can I get the names > of the fields that the resultset returns (without parsing the SQL myself or > having the user supply them)? Use .description - it's a list of tuples corresponding to your fields that map to each element of the result set you are getting back. It includes name and type information and some other stuff. This is part of the standard Python DB-API, and is covered in both the DB-API and mxODBC-specific documentation included with mxODBC. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From ransen_spam_me_not at nemo.it Sun Mar 4 11:15:45 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Sun, 04 Mar 2001 16:15:45 GMT Subject: PyRun_SimpleFile - impossible to call it under Windows? References: <3aa07704.2672581@news.newsguy.com> Message-ID: <3aa40bea.3717542@news.newsguy.com> On Fri, 02 Mar 2001 16:04:54 GMT, ransen_spam_me_not at nemo.it (Owen F. Ransen) wrote: >I've seen that there is an odd bug in PyRun_SimpleFile >probably because of version incompatibilities in the >FILE structure and using DEBUG modes in VC6 This bug or feature is still there in 2.1b1.... -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From cce at clarkevans.com Fri Mar 23 03:02:54 2001 From: cce at clarkevans.com (Clark C. Evans) Date: Fri, 23 Mar 2001 03:02:54 -0500 (EST) Subject: PEP 245: Python interfaces Message-ID: > http://python.sourceforge.net/peps/pep-0245.html This is very good work Michel. Here are my comments which I've been mulling over for the last few days. a) First, I'm not sure a new type is needed, perhaps classes work just fine (see the PyXML library for current interface declaration practices...) In general, your PEP didn't convince me why the class construct couldn't be extended in a reasonable way to satisify the goals you enumerated without introducing a new type. Assuming that the "class" type can be augmented: b) If the class syntax was extended, perhaps it may be useful to add a new statement like pass, but could be used to mark "pure" methods (like = 0 in C++), perhaps: class X: def func(self,z): pure Then, if any method in a class was marked "pure", the class could not be instantiated. c) If the class syntax was extended, perhaps there might be a way to signify "inherit" from "implements", perhaps: class X (Y,#Z): The above class X "inherits" from the class Y, and "implements" the public attributes found in class Z, but without sharing the implementation. d) What is also missing from Python is an "auto-delegation". An analysis of how this fits in or doesn't fit in would be helpful. Assuming that a new "interface" type were to be added. e) I personally feel that the syntax should be much different from the syntax of a class to reduce confusion. Note that maps and lists have different syntaxes. The different syntaxes give better context for programmers... f) If a new type is added, why not go further? Although I don't like the idea of argument types in classes... they could very well make sence for interfaces. This could help to differentiate the syntax, perhaps: interface Y: decl func( number as types.IntType, string as types.StringType, any as any, cls as IAnotherInterface ): "This function does such and such" g) I like the pre/post condition stuff, however, this shoudl be put in a seperate PEP as it is seperable and could be added later, no? h) I don't like the string for pre/post conditions. They should have special syntax, perhaps as these could be implemented as "local methods?" interface Y: decl func(...) def pre(self): if ... then raise PreConditionFailure def post(self): pass def test(self): pass Summary: I like what you have done, but given your requirements, I think we should extend class with a "pure" construct instead. If we are going to have a new type, then a new, more appropriate syntax should be created. Wheu! I hope this helps! Kind Regards, Clark From robin at stop.spam.alldunn.com Fri Mar 16 21:49:31 2001 From: robin at stop.spam.alldunn.com (Robin Dunn) Date: Fri, 16 Mar 2001 18:49:31 -0800 Subject: socket.ssl for win32 References: <2_ys6.108066$__6.20130421@typhoon.southeast.rr.com> Message-ID: "Don Tuttle" wrote in message news:2_ys6.108066$__6.20130421 at typhoon.southeast.rr.com... > "Robin Dunn" > > I got impatient and just did it myself. (Okay, I only waited about 5 > > minutes...) I've put the binaries at http://alldunn.com/python/ in case > > anyone else wants them. > > Thanks Robin! Would you check the integrity of your zip file? I'm getting > the following error when I try to extract socket.py : > Error in file #1: bad Zip file offset (Error local header signature not > found): disk #1 offset: 51766 > It unzipped okay here, so I uploaded it again just in case. > Do you know if any one has written a telnet server/client in Python that run > on Windows? I've been experimenting with SSH & SSHD for CYGWIN But Python > would be nicer! Not that I know of. -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From grante at visi.com Fri Mar 9 22:52:56 2001 From: grante at visi.com (Grant Edwards) Date: Sat, 10 Mar 2001 03:52:56 GMT Subject: Python In A Nutshell References: <98c4ok$fhd$1@panix2.panix.com> Message-ID: In article <98c4ok$fhd$1 at panix2.panix.com>, Aahz Maruch wrote: > >>Planning stages? We've all seen his posts (a.k.a. treatises) here. I'd say >>he should have the final draft to you in 3 weeks tops. ;-) > >ITYM "first draft". It will take another three-to-six months for Alex >to edit it down. ;-) "Sorry it's so long, I didn't have time to write it short." No idea where that quote is from, but I noticed in grad school that assignments stated maximum lengths allowed for papers while in undergrad courses they specified minimum lengths for papers. It sort of gives you an idea about which types of people go on to grad school. ;) -- Grant Edwards grante Yow! We have DIFFERENT at amounts of HAIR -- visi.com From samschul at pacbell.net Sat Mar 31 15:38:46 2001 From: samschul at pacbell.net (samschul at pacbell.net) Date: 31 Mar 2001 20:38:46 GMT Subject: I want to learn PYTHON! References: <1iqx6.3744$aD4.234302@news2.atl> Message-ID: <9a5f8m$7km$1@news.netmar.com> In article <1iqx6.3744$aD4.234302 at news2.atl>, KEVIN writes: >Where do I start. > >I am not a programmer but have an intermediate level of computer knowledge >in Windows only. > >-- >KEVIN > >"Si hoc legere scis, nimis eruditionis habes." >----------------------------------------------------------------- >Please repond in the newsgroup. >My email address is altered for anti-spam >Just change .nOt to .net > > Try amazon.com and search on Python Sam Schulenburg ----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web ----- http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups NewsOne.Net prohibits users from posting spam. If this or other posts made through NewsOne.Net violate posting guidelines, email abuse at newsone.net From louis at decipherinc.com Fri Mar 9 12:46:36 2001 From: louis at decipherinc.com (prince.kattare.com) Date: Fri, 9 Mar 2001 09:46:36 -0800 Subject: Python & Wireless Apps Message-ID: <98b4ra$107$1@bashir.peak.org> Hello! I just got back from the Python Conference and glad to see that there is a lot of motivation for the language. I am just starting out with python and was wondering how it's being used in the wireless space, meaning mostly palm devices. Has anyone ported an app to a palm pilot? What kind of restrictions should I be considering when thinking about this? Thanks for any insight you might have! Louis louis at decipherinc.com From aahz at panix.com Thu Mar 8 20:33:51 2001 From: aahz at panix.com (Aahz Maruch) Date: 8 Mar 2001 17:33:51 -0800 Subject: I come to praise .join, not to bury it... References: <000001c0a64c$497df250$a9807018@cr706570a> Message-ID: <989btv$rd4$1@panix3.panix.com> In article , Grant Edwards wrote: >In article , D-Man wrote: >> >>Even with my newfound understanding, provided by the Martellibot, I >>agree with this. Calling a method on an object is fine. Calling it >>on a literal looks weird. > >What makes you think a "literal" is not an object? It is, but not at the aesthetic level. >> Take for example something like this >> >>three = 1.__add__( 2 ) > >Looks just fine to a ex-Smalltalker: everything is an object. Python isn't Smalltalk. -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "..., and some of you may regard all women as evil traps that exist only to tease, torture, and suck out your very soul." --DrMax From jwbnews at scandaroon.com Fri Mar 16 10:21:25 2001 From: jwbnews at scandaroon.com (John W. Baxter) Date: Fri, 16 Mar 2001 07:21:25 -0800 Subject: This math scares me References: <984486395.407379@newsmaster-04.atnet.at> <984518199.127140@newsmaster-04.atnet.at> <98ohuc$du9$1@news.udel.edu> <7bQr6.644$lz1.17686@ruti.visi.com> <98oku1$f6a$1@news.udel.edu> Message-ID: In article , "Steve Holden" wrote: > "Fabio Olive Leite" wrote in message > news:mailman.984689603.19242.python-list at python.org... > > On Thu, Mar 15, 2001 at 03:04:07PM +0000, Grant Edwards wrote: > > ) > > ) One step further is base-60, which is still used for many > > ) things. Time and angular measurement for example is partially > > ) a base-60 system. I believe that one or more of the ancient > > ) Aztecs/Incans/Mayans used a base-60 number system. > > > > Indeed, they used it. And some other people too, as is seen even today in > > the most common languages of the word. French, for example, has no "real > > words" for seventy, eighty and ninety, and uses "sixty ten", "four twenty" > > and "four twenty ten". > > > > Base 12 was used a lot for commerce, as it has more integer fractions than > > 10. :) > > > What can you expect from a race who insist on calling seventeen, eighteen > and nineteen "ten-seven", "ten-eight" and "ten-nine" respectively? And let's > not get into punds, shillings and pence. > > old-enough-to-remember-them-ly y'rs - steve And stone, furlong, and fortnight: a valued employee at JPL in the early 1960s was tired of all the different measurement systems in which data arrived at the Lab from various field locations. [At least four methods of expressing Azimuth, alone.] He converted everything for one (formal) report into the stone/furlong/fortnight system. ;-) And let's not forget the 32-point circle used in [English-descended] sailing (STILL used in sailing, including iron jib sailing): "two points off the starboard bow" is somehow easier to understand than "22.5 degrees off the starboard bow". This floating point thread has become more fun than any of the scores of others I've seen here and elsewhere. --John (probably bearing roughly WNW 1/4N from *someone* reading this) -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From bsb at winnegan.de Fri Mar 30 05:56:47 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 30 Mar 2001 12:56:47 +0200 Subject: HELP urllib POST can't get it to work In-Reply-To: <9a1m91$fdg$1@pheidippides.axion.bt.co.uk> References: <9a1m91$fdg$1@pheidippides.axion.bt.co.uk> Message-ID: <87snjvtths.fsf@winnegan.de> "mike mcleod" writes: > My code: > > import urllib > params = urllib.urlencode({'address': '07', 'identity': 'me', > 'resultpg':'html/sendresult.html', 'message': > 'test', > 'fPage':'true', > }) > f = urllib.urlopen("http://www.samemachine.uk/bin/afunc.pl?", params) > print f.read() > > It looks like the order of the params come out different in the urlopen. > But because the server will only accept in the order shown it fails. > I have tried to do this using basic sockets but don't know how to get that > work without lots of reading. >From looking at 2.1b1 lib/urllib.py: use a list of pairs instead of a dictionary (untested) params = urllib.urlencode( [('address','07'), ('identity','me'), ... HTH Siggy -- Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/ ****** ceterum censeo javascriptum esse restrictam ******* From gtalvola at nameconnector.com Fri Mar 2 09:55:48 2001 From: gtalvola at nameconnector.com (Geoff Talvola) Date: Fri, 02 Mar 2001 09:55:48 -0500 Subject: [ANNOUNCE] Webware for Python 0.5 References: <5.0.2.1.0.20010301205419.047bfd90@mail.mindspring.com> Message-ID: <3A9FB474.A57363A4@NameConnector.com> Chuck Esterbrook wrote: > "Don Tuttle" wrote in message > news:... > >"Chuck Esterbrook" > > > * Python Server Pages (PSP, similar to ASP, PHP and JSP) > >I 'm trying to get a handle on why I would want to use PSP on WinNt with > >IIS. What's the difference/advantage to using PSP compared to using ASP > >with embedded Python script? > >Don > > [1] Webware's PSP offers more syntax options than ASP. If I remember > correctly, using Python in ASP involves some funkiness because of the clash > between Pythonic indentation and HTML. I don't remember the details, but > I'm positive they are chronicled in the archives of c.l.p. > > PSP also allows you to inherit one or more base classes which can be good > for reusing code. I don't know if ASP lets you do that or not. This is a great feature of PSP that I make use of a lot, and I am pretty sure ASP offers nothing similar. > In any case, if you check the docs for PSP, you can see what various > options you have compared to ASP: > > http://webware.sourceforge.net/Webware/PSP/Docs/ > > [2] Webware's PSP sits on top of WebKit, which means that when you use it, > you can also create plain old Python servlets. You can also make your own > "servlet factories". For example, you can write a handler that serves up > *.sql, *.mytemplate, etc. There are also other components you can use with > WebKit such as UserKit, MiddleKit, etc. Of course, that doesn't matter if > you're not interested in these options, although using Webware puts you in > a position to use them any time later. > > [3] A colleague of mine has had "caching" problems in ASP regarding out of > date code residing in memory despite file modifications and reload()s. I > can't say I know the details, and I won't say that you are guaranteed to > suffer this if you use ASP+Python. > > Hope that helps. More details might be available from people who have > extensively used both. > > -Chuck I recall that ASP with Python places limitations on what you can store in session variables. For example, if you try to place a dictionary into a session variable you'll get an error like "TypeError: Objects of type 'dictionary' can not be converted to a COM VARIANT". Generally, only "simple" types like integers, floats, strings, and lists of them can be placed into a session variable. WebKit/PSP has no such restrictions. One more feature of WebKit/PSP that I _think_ doesn't exist in ASP, but I might be wrong: The ability to forward a request to another Servlet or PSP purely within the app server (as opposed to redirecting the browser). This allows you to do things like write a "controller" servlet that examines the request and then forwards to the appropriate servlet or PSP. It's a nice model for certain types of problems that is really simple to implement in WebKit/PSP, and I think it would be difficult or maybe even impossible in ASP. On the flip side, one possible advantage of ASP with Python is that you might be able to take advantage of 3rd-party extensions that are designed to only work with ASP. I don't know if such things exist. I happen to be using a 3rd-party COM component in my web pages to draw dynamic graphs. The component was designed for use with Visual Basic and Active Server Pages, but it works great with WebKit too. ASP/Python also has the dubious advantage of being an easier sell within a corporation than WebKit/PSP, which may or may not be important to you... Overall, I think WebKit/PSP is significantly more productive and powerful than ASP, and I was able to convince my coworkers of that, so it's working out great for me :-) -- - Geoff Talvola Parlance Corporation gtalvola at NameConnector.com From scarblac at pino.selwerd.nl Tue Mar 20 04:00:58 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 20 Mar 2001 09:00:58 GMT Subject: Sequence-spreading References: <3AB7167F.2816AA21@student.liu.se> Message-ID: Rikard Bosnjakovic wrote in comp.lang.python: > I made a small spreading-sequence with the following code: > > ------ > arg = "some string" > pm = 3 > offsets = [] > for i in xrange(pm): > everyX = filter(lambda y: not divmod(y, pm)[1], range(len(arg))) > added = map(lambda x: x+i, everyX) > offsets.append(filter(lambda x: x > print offsets > ------ > > which gives the correct result: > > >>> ## working on region in file /usr/tmp/python-3115DCp... > [[0, 3, 6, 9], [1, 4, 7, 10], [2, 5, 8]] > > "pm" is the number of sequences, and then the sequences are increasing. > 0 in first, 1 in second, 2 in third, 3 in first and so on, until the > length of the string 'arg' is reached. However, the loop-code is pretty > unreadable and awkward. > > Anyone got a better solution for it? arg = "some string" pm = 3 offsets = [ [] for i in range(pm) ] for i in range(len(arg)): offsets[i % pm].append(i) -- Remco Gerlich From cce at clarkevans.com Tue Mar 27 04:15:34 2001 From: cce at clarkevans.com (Clark C. Evans) Date: Tue, 27 Mar 2001 04:15:34 -0500 (EST) Subject: Yet Another PEP: Query Protocol Interface or __query__ In-Reply-To: <5.0.2.1.0.20010325210220.00a2cc00@mail.inet.com.br> Message-ID: On Mon, 26 Mar 2001, Carlos Ribeiro wrote: > 6) We can solve (5) using a 'proxy', or 'adapter'. Ahh, it finally got though my dence skull what you are proposing -- more of a proxy mechanism, which has a further constraint, not only must the expected methods be mapped, but *only* the expected methos are to be mapped. > EXAMPLE > > Assume that we have these protocols: > > a) protocol 'IntegerDivision' > supports the __div__() method for integer division > b) protocol 'FloatDivision' > supports the __div__() method for floating point division > > #---------------------------------------------------------------------- > > class Protocol: > """ empty class that can be used for all protocol adaptation """ > pass > > def MakeProtocolDefault(protocol_methods, adaptee): > """ Returns the default protocol adapter for an object > The default uses the same name for all methods in the protocol > and in the object instance that is being adapted > """ > p = Protocol() > for pm in protocol_methods: > om = getattr(adaptee, pm) > setattr(p, pm, om) > return p > > def MakeProtocol(protocol_methods, object_methods): > """ Returns the a protocol adapter for an object, mapping > each protocol_method to a object_method > """ > p = Protocol() > for pm, om in zip(protocol_methods, object_methods): > setattr(p, pm, om) > return p > > class Number: > """ supports both protocols: 'IntegerDivision' & 'FloatDivision' """ > def __init__(self, p_value): > self.value = p_value > > def div_int(self, b): > # integer division > return int(self.value)/int(b) > > def div_float(self, b): > # floating point division > return float(self.value)/float(b) > > def __adapt__(self, protocol): > if protocol == 'IntegerDivision': > return MakeProtocol(['__div__'], [self.div_int]) > elif protocol == 'FloatDivision': > return MakeProtocol(['__div__'], [self.div_float]) > else: > return None > > #---------------------------------------------------------------------- > > >>> n = Number(2) > >>> in = n.__adapt__('IntegerDivision') > >>> fn = n.__adapt__('FloatDivision') > >>> in/3 > 0 > >>> fn/3 > 0.66666666666666663 > >>> n.value = 5 > >>> fn/3 > 1.6666666666666667 > >>> > > #---------------------------------------------------------------------- Very Neat. ;) Clark From fdrake at acm.org Sat Mar 24 12:35:27 2001 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Sat, 24 Mar 2001 12:35:27 -0500 (EST) Subject: [Python-Dev] Anyone using weakrefs? In-Reply-To: <018e01c0b456$6710b830$e46940d5@hagrid> References: <15035.46175.599654.851399@localhost.localdomain> <018e01c0b456$6710b830$e46940d5@hagrid> Message-ID: <15036.56031.221142.247490@cj42289-a.reston1.va.home.com> Fredrik Lundh writes: > am I the only one who gets a bit nervous when the guy who > designed and implemented a feature has a hard time finding a > non-contrived use case? ;-) I had a non-contrived need for them 5 1/2 years ago! But I worked around it in C code back then, since I was building a C extension anyway; the result was not generally applicable since it was tightly tied to the particular C extension I needed. And I'm sure we could have used this in Grail as well. ;-) -Fred -- Fred L. Drake, Jr. PythonLabs at Digital Creations From loewis at informatik.hu-berlin.de Sat Mar 24 05:32:16 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 24 Mar 2001 11:32:16 +0100 Subject: New PEP: The directive statement References: Message-ID: "Tim Peters" writes: > The entire point of the PEP is to give incompatible language changes > a trial run of at least one full release cycle before saying "that's > it". In what respect does that come off as absolute certainty to > you? And in what respect does your PEP differ in relation to this > point? If you have a better idea, change your PEP to spell it out. That was rather meant as a comment to PEP 236: Instead of giving a mandatory release, it appears that all you can specify is a is_mandatory (isMandatory, or mandatory_p) flag; this is also all you said an application might need. > > Tim claims that I invented the statement to declare file encodings, > > e.g. > > > > directive encoding "koi8-r" > > Gimme a break Ok, I should have put a smiley in there, I guess :-) It is a fact that you were claiming it, it is also a fact that I do like to see the possibility to specify source encodings. It's just that I cannot hope to get that now - but I had the hope that the future statement would be removed before the 2.1 release. Now that the final beta still has it, that hope is vanishing... Regards, Martin From C.Brewster at dcs.shef.ac.uk Thu Mar 15 05:02:40 2001 From: C.Brewster at dcs.shef.ac.uk (Christopher Brewster) Date: Thu, 15 Mar 2001 10:02:40 -0000 Subject: reversing a dictionary (newbie) Message-ID: <007201c0ad37$12571f80$6809a78f@dcs.shef.ac.uk> I have written a program to extract pairs of words from a corpus (the BNC). It is my first Python program Once it has processed the files I "reverse" the dictionary so that the keys are frequencies and the values lists of word pairs of that frequency. The processing of the files is quite quick (700 odd files (@ 100k mean size) of directory 'A' in about 20 minutes) but the reversing of the dictionary took hours and hours. I have run the program successfully on a PC (500 MHz, 256 RAM, running Windows NT) and I am still waiting for results from a Sun (1 Giga RAM) since yesterday. Here is the code - what have I done wrong? def revdict(diction): revdict = {} for wordpair in diction.keys(): #print wordpair list = [] freq = diction[wordpair] if revdict.has_key(freq): list.extend(revdict[freq]) list.append(wordpair) revdict[freq] = list else: list.append(wordpair) revdict[freq] = list return revdict The total number of 'wordpair's (i.e. keys in the original dictionary) were 567000. I need to be able to handle ten times that many. Thank you, Christopher Brewster Department of Computer Science, University of Sheffield Tel: +44(0)114-22.21872 Fax: +44 (0)114-22.21810 Regent Court, 211 Portobello Street Sheffield S1 4DP UNITED KINGDOM From danielk at aracnet.com Tue Mar 13 21:49:44 2001 From: danielk at aracnet.com (Daniel Klein) Date: Tue, 13 Mar 2001 18:49:44 -0800 Subject: Where can I find Docs on how to use the debugger please? References: <3lltat8tgd86rknhgnqkij6bk9rkbqk824@4ax.com> Message-ID: On Wed, 14 Mar 2001 13:35:45 +1100, cmfinlay at SPAMmagnet.com.au wrote: >Where can I find Docs on how to use the debugger please? Look up the 'pdb' module in the Library Reference. Daniel Klein From root at rainerdeyke.com Sat Mar 17 12:25:04 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sat, 17 Mar 2001 17:25:04 GMT Subject: [Very Long (11K)] Numeric PEPs, first public posts References: Message-ID: "Moshe Zadka" wrote in message news:mailman.984748941.31248.python-list at python.org... > PEP: 237 > Title: Unifying Long Integers and Integers > Rationale > > Having the machine word size exposed to the language hinders > portability. For examples Python source files and .pyc's are not > portable because of this. Many programs find a need to deal with > larger numbers after the fact, and changing the algorithms later > is not only bothersome, but hinders performance in the normal > case. A simpler way to solve this problem would be to standardize Python ints as 32 bit. > Implementation > > The PyInt type's slot for a C long will be turned into a > > union { > long i; > struct { > unsigned long length; > digit digits[1]; > } bignum; > }; > > Only the n-1 lower bits of the long have any meaning; the top bit > is always set. This distinguishes the union. All PyInt functions > will check this bit before deciding which types of operations to > use. >From a performance point-of-view, it might be better to keep integers and longs as separate types. Not sure if this makes any real difference. > PEP: 238 > Title: Non-integer Division > (a/b) * b = a (more or less) > > The type of a/b will be either a float or a rational, depending on > other PEPs[2, 3]. Please, no floats. This newsgroup is evidence that floating point numbers are much more confusing than integer truncation. Rationals I can live with, but I think the operator '/' should keep its semantics and the new operator should produce the rationals. This would be consistent with the current system where 'a / b' has the same type as 'a' and 'b' if 'a' and 'b' have the same type. > PEP: 239 > Title: Adding a Rational Type to Python > RationalType > > There will be a new numeric type added called RationalType. Its > unary operators will do the obvious thing. Binary operators will > coerce integers and long integers to rationals, and rationals to > floats and complexes. > > The following attributes will be supported: .numerator and > .denominator. The language definition will not define these other > then that: > > r.denominator * r == r.numerator > > In particular, no guarantees are made regarding the GCD or the > sign of the denominator, even though in the proposed > implementation, the GCD is always 1 and the denominator is always > positive. I don't see the point in not guaranteeing this. Undefined behavior is bad. > PEP: 240 > Title: Adding a Rational Literal to Python > Abstract > > A different PEP[1] suggests adding a builtin rational type to > Python. This PEP suggests changing the ddd.ddd float literal to a > rational in Python, and modifying non-integer division to return > it. I very much like this idea (because I hate floats), but I suspect this will break too much code. A suffix similar to the 'L' after long literals might work better. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From fritz.heinrichmeyer at fernuni-hagen.de Mon Mar 26 02:02:59 2001 From: fritz.heinrichmeyer at fernuni-hagen.de (Fritz Heinrichmeyer) Date: 26 Mar 2001 09:02:59 +0200 Subject: Python ready to replace perl (was Re: Install Python on Apache) References: <99fph5$a2n$1@rex.ip-plus.net> Message-ID: <86snk1qafw.fsf_-_@jfh00.fernuni-hagen.de> A student who could help me with web support is more fluent with python than with perl (that is no a feat :-). So i consider using python in the future. For this python has to have 1. sql-interface like dbi, at least for postgres (i think this exists). 2. interface to openldap 3. mod_perl beeing able to program authentification procedures using 1. and 2. for apache and beeing able to program arbitrary URL-redirect procedures. 4. a template system beeing able to manage multiple language versions (to replace the perlish WML-System)?. Are there solutions apart from using zope? -- Fritz Heinrichmeyer mailto:fritz.heinrichmeyer at fernuni-hagen.de FernUniversitaet Hagen, LG ES, 58084 Hagen (Germany) tel:+49 2331/987-1166 fax:987-355 http://www-es.fernuni-hagen.de/~jfh From inconnu at nul.net Sat Mar 31 15:15:05 2001 From: inconnu at nul.net (Rémi yyyy) Date: Sat, 31 Mar 2001 22:15:05 +0200 Subject: C++ and Python References: <99q99l$g21$1@news.clinet.fi> Message-ID: <9a5dr3$9fj$1@front7m.grolier.fr> See in http://www.swig.org/ for C++ Wrapper Ahto a ?crit dans le message : 99q99l$g21$1 at news.clinet.fi... > I'm very new to Python and haven't quite figured out how to use c++ and > python together on windows...if someone could send me an example program of > tutorial webpage where this is explained?!? > > Thanks > > From tim.hochberg at ieee.org Sat Mar 3 11:24:30 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Sat, 03 Mar 2001 16:24:30 GMT Subject: the demise of 'from foo import * and its implications? References: <3kVBAfATrDo6EwEM@jessikat.fsnet.co.uk> Message-ID: <2V8o6.1383$8q3.219969@news1.rdc1.az.home.com> "Robin Becker" wrote in message [SNIP] > If we really want to improve visibility we could try to make > > >>> def bingo(a): > ... if a<=1: return 0 > ... return bingo(a-1)*a > ... > > work naively, but I'm fairly sure this will be rejected as unpythonic or > somesuch. ????? In what sense doesn't this work now? Under 2.0 or 1.5.2 or even, I think, under 0.9 this 'works' in the sense that it iterates for a while then returns 0. If one replaces "return 0" with "return 1" it even returns the factorial as I assume it should. What doesn't work is the following: def spam(n): def fact(a): if a <= 1: return 1 else: return fact(a-1)*a return fact(n) + 42 With the current three level scope rule this fails, so a function that works fine when defined at the top level fails miserably when defined at an intermediate level. Given your earlier statement that: >my preference would be that statements legal in one context should be >legal in another where they make sense. This seems like it would be of concern to you as well. My understanding is we can have two of the following three options: 1. Decent performance (~current performance) 2. "Real" lexical scoping 3. Unrestricted use of "from X import *" at other than module scope. Given those choices I'd choose 1 and 2. Which is fortunate for me, since that's what were going to get anyway. ---------------------------------------------------- Going off on a tangent: In listening to the various debates here, and when I was spying on PythonDev, I've come to the conclusion that "from X import *" was a mistake to begin with. It has it's uses, but there are other ways to satisfy them without the downsides of "import *". "import *" is used, in essence, to extend the list of __builtins__ that one sees in a module or in interactive mode. This is commonly used with some windowing toolkits for example, where importing the contents an item at a time is too painful (using from X import a,b,c,d....) and where the names of the toolkit's contents have been constructed not to stomp on the local namespace. The problems with "import *" include: * May inadvertenly stomp on local namespace * Can't easily reload module contents (OK, so it's not that hard, but it's hard to explain sometimes). * Gives the compiler a headache in inner scope. Let's consider another approach that I believe satisfies the current uses for "import *" without its drawbacks. __module_builtins__ is a list of modules, each of which is searched in turn when lookup fails at the global (aka module) scope. Initally, __module_builtins__ equals [__builtins__], so the behaviour is the same as in the real world, except for going through an additional layer. But if additional modules are appended to __module_builtins__, they are each searched in turn to resolve a name lookup. import spam as * # I don't defend this syntax, it's only for illustration Is shorthand for: import spam __module_builtins__.append(spam) del spam So, to make all of the wxPython stuff available one types: import wxPython.wx as * class MyApp(wxApp): # .... This looks first in the module dictionary, then in __builtins__ (since it's the first entry in __module_builtins__) then in wxPython.wx, where it would find wxApp. It involves extra lookups over "import *", but if anyone needs speed in a particular place, they can import directly into the local scope, as they do now. The nice things about this approach include: * It can't stomp on local variables * Reload just works. * You can use it wherever you want without giving the compiler fits since is only affects __module_builtins__, not the local scope. * You can cleanly remove imported modules by deleting them from _builtin_modules__, something that's difficult to do with import * * Others to numerous to mention. However, at this point I imaging it's many years to late, and "from spam import *" is here to stay. If you've put up with my rambling to this point I congratulate you. Ramblin on, -tim . From me at home.nl Sun Mar 11 06:49:49 2001 From: me at home.nl (SonoBull) Date: Sun, 11 Mar 2001 11:49:49 GMT Subject: question , Does pytyon excist on a pda, like psion? Message-ID: Hello all, Is Python already ported to the psion or other pda, s? greetings. Sono. From jepler at inetnebr.com Sun Mar 11 21:12:54 2001 From: jepler at inetnebr.com (Jeff Epler) Date: Mon, 12 Mar 2001 02:12:54 GMT Subject: Subclass factories? References: Message-ID: On Mon, 12 Mar 2001 11:23:24 +1100, Tim CHURCHES wrote: >If the subclass factory approach is reasonable, what is the best way >to do it? So far I been assembling the necessary statements for the >new class definition into a string then exec'ing that string, but that >seems rather inelegant. I'm sure there must be a better way. Use the "new" module to create a class with a particular list of superclasses and a particular dictionary of functions or attributes. Example: >>>import new >>> class A: ... pass >>> class B: ... pass >>>def f(self): ... print "it's f", self >>> D = new.classobj("from new.classobj", (A, B), {"f": f}) >>> print D.__bases__ (, ) >>> print dir(D) ['__doc__', '__module__', 'f'] >>> d = D() >>> print d.f() it's f <__main__.from new.classobj instance at 80c5b00> Jeff From jmarshal at mathworks.com Fri Mar 16 11:40:10 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 16 Mar 2001 16:40:10 GMT Subject: Python style questions References: <98tb91$9t9$1@saltmine.radix.net> Message-ID: <98tfla$gck$1@news.mathworks.com> Cary O'Brien wrote: ... > 3. I really miss not having a "switch" or "case" statement. Sniff. Me too. > 4. I need to change things like "88aa99bb" (hex string) into integers. Should I > a. use expr("0x"+s) > b. not use such things > c. ??? c. int(s, 16) This works in Python 2.x. If you're using an older version, use string.atoi. From NoSpam at NoSpam.com Sun Mar 11 11:16:10 2001 From: NoSpam at NoSpam.com (Tom) Date: Sun, 11 Mar 2001 16:16:10 GMT Subject: Memory leaks in VC6 2 line Python 2.1b1 apps? References: <3aa88f52.5419185@news.newsguy.com> <98b0a0$2g8i$1@shadow.skypoint.net> <3aa91ea5.645940@news.newsguy.com> <98dngs$2cmm$1@shadow.skypoint.net> Message-ID: Craig, The debug CRT can give you this info. Add the following to your program to enable this feature. I put it in my precompiled header. // For memory debugging (VC++ specific) // Must come after some STL includes (or conflicts with 'new') #ifdef _DEBUG //#include // seen this recom., but I don't see why #define _CRTDBG_MAP_ALLOC // Causes CrtDbg to #define all the crt alloc routines to versions with more debug info, // to replace operator new with one that adds debug info. // (but in a stupid way that doesn't work - so we #define new ourselves after CrtDbg.h.) #include #define new new(_NORMAL_BLOCK, __FILE__, __LINE__) For more info, see the crt docs in MSDN. There are a number of options. Let me know if you are using wxWindows - this requires more changes. Tom. "Craig Holman" wrote in message news:98dngs$2cmm$1 at shadow.skypoint.net... > I wish that Visual Studio's memory-leak reporter were smart enough to > display where the leaked blocks of memory were allocated. It only puts out > pairs of lines like the following : > > {1037} normal block at 0x0079CE80, 39 bytes long. > Data: < y > 20 EE 79 00 88 85 1F 1E 03 00 00 00 B8 17 20 1E > > The other lines in the annotated dump were added by me. They contain the > results of my efforts to figure out where the leaked blocks were allocated. > After each of the pair of lines produced by the memory-leak reporter, I've > listed my best guess as to what kind of a block was leaked and why, the line > in the Python 2.1b1 source file that I placed a breakpoint at that allocates > the leaked memory block, and a snapshot of the relevant part of the runtime > stack at the point that the breakpoint was hit and execution was paused. I > haven't identified where all of the leaked blocks are being allocated yet. > > Hope this helps, > Craig > > "Owen F. Ransen" wrote in message > news:3aa91ea5.645940 at news.newsguy.com... > > On Fri, 9 Mar 2001 10:28:33 -0600, "Craig Holman" > > wrote: > > > > >Greetings, > > > > > >I'm afraid that both versions 2.0 and 2.1b1 leak memory for a single > > >Py_Initialize, Py_Finalize sequence in a > > >Visual C++ MFC application. > > > > Phew! I thought it was just me! ;) > > > > I hope someone understands the rest of your post, I'm too new > > to Python embedding to help. Also, for some reason, though I > > did rebuild from source, VC gives me the leak "number" but not > > the line in the library which caused it. > > > > > > -- > > Owen F. Ransen > > http://www.ransen.com/ > > Home of Gliftic & Repligator Image Generators > > From scarblac at pino.selwerd.nl Wed Mar 21 07:25:23 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 21 Mar 2001 12:25:23 GMT Subject: Checking the type References: <99a493$bhl$1@sun.rhrk.uni-kl.de> Message-ID: Markus Reitz wrote in comp.lang.python: > Hi, > > is there a possibilty to check if a variable refers to an object of type x? > Does a typeof-command exist in Python: > > if a typeof list: > #Commands only useable with list > > I read the Python Tutorial, but have not found a hint to this topic. There is a the type() function, and the list of types in the types module. You can also use isinstance(), it's slightly more general. >>> isinstance(3, types.IntType) 1 >>> class Spam: ... pass ... >>> isinstance(Spam(), Spam) 1 In many cases, the Python way is to just assume that your input is a list, and use it as if it were one. If it's not, an exception will be raised as appropriate. This make it possible to make classes that are not lists but behave like one (like UserList does). Same for files. -- Remco Gerlich From bob_cannard at mentor.com Wed Mar 28 13:10:21 2001 From: bob_cannard at mentor.com (Bob Cannard) Date: Wed, 28 Mar 2001 10:10:21 -0800 Subject: R: unique items in lists References: <_nZv6.2878$yU4.468236@news.infostrada.it> <3AC0E010.3CDC94FC@mentor.com> Message-ID: <3AC2290D.F79F1B70@mentor.com> Remco Gerlich wrote: > Dictionaries are hashes, I'm assuming a dictionary setattr is about constant > time. The "dict.keys()" at the end must be linear, since its result is > linear... Looking back over the messages, it seems that I misread Remco's earlier message - for some reason I read it as meaning the dictionary lookups were linear, which would certainly be bad news! Oh well. At least my analysis of the original algorithm appears to be correct. Moral: never post while suffering from caffeine deficiency. Cheers, Bob. From ransen_spam_me_not at nemo.it Wed Mar 7 13:02:58 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Wed, 07 Mar 2001 18:02:58 GMT Subject: ANNOUNCE: 2.1b1 SRPM References: Message-ID: <3aa861c3.1122387@news.newsguy.com> On Tue, 6 Mar 2001 22:48:35 -0700, Sean Reifschneider wrote: >The SRPM is available at: What is an SRPM? -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From jurgen.defurne at philips.com Fri Mar 16 02:05:58 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Fri, 16 Mar 2001 08:05:58 +0100 Subject: This math scares me Message-ID: <0056900016651515000002L052*@MHS> It was the Babylonians who gave us the base-60 numbered division of circular events. Jurgen grante at visi.com@SMTP at python.org on 15/03/2001 16:17:21 Sent by: python-list-admin at python.org To: python-list at python.org@SMTP cc: Subject: Re: This math scares me Classification: In article , Fabio Olive Leite wrote: >Hi there, > >On Wed, Mar 14, 2001 at 09:31:54PM +0000, Grant Edwards wrote: >) No. The binary floating point representation of many decimal >) fraction values is not exact. That's what started this whole >) thread. You can't represent 0.1 exactly in binary FP. You can >) in BCD. > >Just to make matters worse in this discussion, let me add some more noise. > >Since base 10 contains base 2 and base 5 (`factor 10`), every >number coming from any of those bases is exactly represented in >base 10. Conversely, base 2 contains only itself, and thus it >cannot represent correctly some numbers that are exactly >representable in other bases, like 0.1 in base 10. > >The usual 1/3 example is a problem for base 10, but not so for >base 12, for example, since 12 contains 3 2 2. Thus: > >1_{12} / 3_{12} == 0.4_{12} > >And then base 30 would let us count exactly fractions of base >2, 3, 5, 6, 10, 12, 15, 16 and all the others you can think of >that have only 2, 3 and 5 as factors of the base. But since no >one (usualy) has 30 fingers, that base is not terribly popular. >:) One step further is base-60, which is still used for many things. Time and angular measurement for example is partially a base-60 system. I believe that one or more of the ancient Aztecs/Incans/Mayans used a base-60 number system. -- Grant Edwards grante Yow! It's hard being at an ARTIST!! visi.com -- http://mail.python.org/mailman/listinfo/python-list From lac at cd.chalmers.se Tue Mar 6 13:11:22 2001 From: lac at cd.chalmers.se (Laura Creighton) Date: Tue, 6 Mar 2001 19:11:22 +0100 (MET) Subject: Can anyone recomend a good intoduction to C... Message-ID: <200103061811.TAA27998@boris.cd.chalmers.se> Hello Werner you write: >I further think it is easier to move 'back' from C++ to C, when the need >arises, than vice versa. This is simply because you are forced to use a >different technique if the one you are used to does not work on that >platform. >Personally I started with procedural programming and moved to the object >oriented technique afterwards. This is why I think it is hard to get used to >objects when you are used to malloc, free, memcpy and friends. > >Did I miss an important point? 2 points. First of all, while you may be correct that your first exposure to procedural programming has made it hard for you to get used to object oriented programming, it is also possible that your problem was that C++ is a widely-avialable-but-not-particularily-good programming language. People whose first OO programming language is Smalltalk have, in my experience a far easier time learning OO programming. I do not know anybody whose first OO language was Eiffel, but I suspect they have an easier time as well. I think that the Smalltalk courses which I took at university, which were optional, and I only took because I *like* learning languages ended up being the most valuable courses I ever took. So the question becomes, why is it that the original poster decided to learn C or C++? If he has an application which he thinks is suited to one or the other, more power to him, though it is hard to make such decisions until you have more experience with a host of computer languages. Maybe he just has a compiler and wants to play with it. Maybe he has a linux or unix system and wants to find out exactly what it is that his system is doing. But finally, it may be that it is more experience with computer languages in general which is what he wants, in which case I would say, yes, by all means learn C. Then go out and learn Smalltalk, or Lisp or Haskell. And make sure you learn an assembler as well on the way, because that too will make your brain go off and work in amazing new directions. This is a keen source of personal pleasure. They say that you cannot feel new neural connections being made in your brain, but I am not so sure about that. Laura Creighton From jmarshal at mathworks.com Fri Mar 16 14:44:35 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 16 Mar 2001 19:44:35 GMT Subject: list.sort(cmpfunc) question References: <98t9dq$qvu$1@panix6.panix.com> <98tf9d$g3v$1@news.mathworks.com> <3AB249FB.131080CD@san.rr.com> <98thua$i40$1@news.mathworks.com> <3AB25C59.284E58E3@san.rr.com> Message-ID: <98tqf3$o4r$1@news.mathworks.com> Darren New wrote: > Fredrik Lundh wrote: >> in other words, "recommended but not required" > Even more strongly than "recommended", but rather "you better have a darn > good reason and know every result of your change before you consider doing > this." :-) It's like "Unix root accounts SHOULD have a hard-to-guess > password." It's possible to run UNIX with no root password, but you ought > to have a good reason. > And yes, there's an RFC defining what "SHOULD" and "MUST" and such mean. :-) Of course, documentation is a very different thing than an RFC. From jra at dorothy.msas.net Thu Mar 29 17:43:01 2001 From: jra at dorothy.msas.net (Jay R. Ashworth) Date: Thu, 29 Mar 2001 22:43:01 GMT Subject: Linux GPS program References: <3AC01637.4EF3A6F2@crynwr.com> <3AC0D915.83C2C0C3@crynwr.com> <99suho$m7a$2@newsserver.rrzn.uni-hannover.de> Message-ID: This one time, in band camp, Bernhard Reiter wrote: > In article , > jra at dorothy.msas.net (Jay R. Ashworth) writes: > > This one time, in band camp, > > Russell Nelson wrote: > >> "Jay R. Ashworth" wrote: > > >> > Any plans to do vector map data as well? > >> > >> I'm pretty ignorant here. What sources of vector information are there, > >> how big is the dataset, and how do I render it so I can use lat/lon or > >> easting/northing to get my location? > > > > There are *stunning* amounts of vector data, all in different formats. > > I agree, though most proprietory. No, actually, I'd bet some cash that the largest collection by size is the combined efforts of the US Govenment. That's (almost) all free. > > I'm trying to (get time cleared up to) sort some of that all out even > > as I type. > > The shapefile format is used for a couple of things. > Check www.freegis.org for several libraries dealing with it > (and other gps packages, btw). > There is a python wrapper for the shapereading library. Yeah, I saw that. Cheers, -- jra -- Jay R. Ashworth jra at baylink.com Member of the Technical Staff Baylink The Suncoast Freenet The Things I Think Tampa Bay, Florida http://baylink.pitas.com +1 727 804 5015 From emile at fenx.com Sat Mar 31 21:13:08 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 31 Mar 2001 18:13:08 -0800 Subject: Conditional operator in Python? References: <3AC68CB8.22AAF7B8@alcyone.com> Message-ID: <9a631k$3s8qb$1@ID-11957.news.dfncis.de> Yes, it comes up. Generally, except for short-circuiting, the solutions follow: >>> 1 and 2 or 3 2 >>> 0 and 2 or 3 3 HTH, -- Emile van Sebille emile at fenx.com --------- "Erik Max Francis" wrote in message news:3AC68CB8.22AAF7B8 at alcyone.com... > Okay, okay, but I still have to ask. > > Why isn't there a conditional operator (a ? b : c) in Python? 2.0 now > has augmented assignments, and the FAQ even acknowledges that the > conditional operator is sometimes quite convenient and gives some (very > awkward) Python alternatives. > > I've been reading comp.lang.python for a while (since just before 2.0 > shipped) and I can't really remember much discussion about it. Is it a > perennial request and I'm just missing it? > > -- > Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ > __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE > / \ I sidestep the either > \__/ or choices of logic and choose both. | Ken Feit > Product's Quake III Arena Tips / http://www.bosskey.net/ > Tips and tricks from the absolute beginner to the Arena Master. From jmarshal at mathworks.com Mon Mar 19 15:19:48 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 19 Mar 2001 20:19:48 GMT Subject: Why "from __future__" stinks; a counter-offer References: <4Aft6.2171$pP2.372173@paloalto-snr1.gtei.net> Message-ID: <995pl4$jta$1@news.mathworks.com> Jeremy Hylton wrote: >>>>>> "VC" == Vadim Chugunov writes: > >> might be OK -- alas, without a PEP, it's a non-starter). > VC> But, surely, the PEP can be updated! This "from __future__" > VC> syntax is ugly, ugly, ugly!!! > Vadim, > If someone else wants to write a PEP and implement it this week, it > would be considered. Tim wrote the PEP. I implemented it. We're > both going to be spending most of our waking hours this week getting > ready for the beta release on Friday. We have no time and less > interest in implementing something other than the __future__ > mechanism. We think it is a good solution to the problem it addresses. > But neither of us is the BDFL. If someone writes a PEP and implements > it in the next day or two, he or she may be able to convince Guido > that it is better than __future__. In the absence of someone writing > a new PEP, nothing is going to change. > Jeremy As responses to suggestions, there's a lot of "write up a PEP or it won't get implemented" going around. I can understand this, but it's also important that good ideas don't go to waste just because the proposer _didn't_ write a PEP. I guess I just hope that the PEP-mechanism doesn't make it so that good proposals get overlooked in favor of proposals with enthusiastic proponents. From parker at gol.com Thu Mar 1 17:46:03 2001 From: parker at gol.com (Ian Parker) Date: Thu, 01 Mar 2001 22:46:03 GMT Subject: docs for mysqldb References: <3A9D63BC.C3EB9246@iems.nwu.edu> Message-ID: In article <3A9D63BC.C3EB9246 at iems.nwu.edu>, Leonardo B Lopes writes >Sorry for the crossposting, but this actually interests both lists... > >Does anyone use the python module mysqldb? Does anyone have any decent >docs for it? In particular, how do you do cursor.execute() with >different parameters? The MySQLdb-0.2.2.tar.gz kit that I downloaded includes both documentation and examples. IIRC correctly, I got it from http://home.t-online.de/home/err666/ Checking again, it looks like there are later version available. Regards Ian -- Ian Parker From xyzmats at laplaza.org Sun Mar 4 08:18:03 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Sun, 04 Mar 2001 13:18:03 GMT Subject: jython question: accessing protected superclass methods References: Message-ID: <3aa23eb1.166345652@news.laplaza.org> On 03 Mar 2001 22:03:06 -0800, Michael Vanier wrote: >So, I've been playing with jython for a few hours, and I'm *really* >impressed. This is a kick-ass system for doing portable graphics >programming. > >However, the online docs are a bit sparse Indeed. Feel free to contribute to the docs, by the way, once you get this worked out. Jython is just like Python...except when it isn't, and things work just like you'd expect, except when they can't because of the way the JVM works... and those conditions are not always easy to find out about. I'm sure any contributions would be welcome... >Also, I was surprised to find that MyJPanel, just by subclassing JPanel, gets >its own public version of the protected JPanel methods! So if I don't >override the method, I can call it directly. I assume this is intentional, >but maybe the jython developers can comment. You'll get a quicker response, in general, on the jython-users (or for appropriate topics, jython-developers) mailing list, if the question is Jython-specific. The core developers are very helpful, but don't seem to be very active on this newsgroup. You can signup for the lists through the Jython project site, jython.sourceforge.net. Mats (a lurker on the jython lists, not a developer) From bedge at troikanetworks.com Thu Mar 15 11:52:58 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Thu, 15 Mar 2001 08:52:58 -0800 Subject: building python for multiple targets References: <3AB0F009.E27D9AD7@troikanetworks.com> Message-ID: <3AB0F36A.F6B30A7F@troikanetworks.com> Just a followup, Is it possible to build python to be relacatable? So the same runtime tree can be placed in /usr/local/python, or in /home/anyone/target/usr/local/python? Bruce Edge wrote: > > I need to build Python for multiple targets from one host. > > One target is the host, the other is for embedded Linux, with it's own > compiler, libs, include, etc, all of which are installed in say > /usr/local/rtlinux/... > > The host build is simple, ./configure, make, make install. > > The target one is ugly, currently I'd doing: > ./configure --include= --bindir=/usr/local/rtlinux/bin > --sbindir= option there is> > > Is there a better way? From seth.shikora at intel.com Fri Mar 23 14:35:14 2001 From: seth.shikora at intel.com (Seth Shikora) Date: Fri, 23 Mar 2001 11:35:14 -0800 Subject: Good GUI for Python References: Message-ID: <99g8hj$mk4@news.or.intel.com> I must agree. wxPython is a nice GUI toolkit. Much easier in my opinion than working with native widows objects. I'll also agree that wxPython will not work with PythonWin. I tried and it crashes way too often. I've been using Boa Constructor for a week now and I really like it. Seth. __________________________ "Rolander, Dan" wrote in message news:mailman.985355222.6126.python-list at python.org... I think wxPython is *very* easy to use, if you can maneuver your way through the C++ documentation. Dan -----Original Message----- From: winson at mdsserv.mds.com.tw [mailto:winson at mdsserv.mds.com.tw] Sent: Thursday, March 22, 2001 9:19 PM To: Python List Subject: Good GUI for Python Hi, All I surveyed 3 GUI framework for Python including wxPython, PythonWin's included win32ui and Tkinter. My development environment is Mark Hammond's PythonWin downloaded from ActiveStates. These're my issues: First, ActiveStates' Python tool cannot support Tkinter and I confirmed with their stuff. So Tkinter maybe good, but not compatible with PythonWin. Second, Mark's masterpiece win32ui and total MFC solution is excellent, but I'd wanna bind on Windows platform. Third, wxPython sounds great but not so easy as win32ui. Is there any suggestions ? Change my develop environment or is there another good gui for me ?? -- Best Regards, Winson Chang 3F, 2, 150 Lane, Sec. 5, Hsin I Rd., Taipei, Taiwan, R.O.C. Tel: +886-2-27225333 ext 376 Fax: +886-2-27222330 Email: winson at mdsserv.mds.com.tw From thygrrr at gmx.net Fri Mar 9 12:30:37 2001 From: thygrrr at gmx.net (Moritz Voss) Date: Fri, 9 Mar 2001 18:30:37 +0100 Subject: I don't get it (Extending C/C++) Message-ID: <98b3cf$apu$02$1@news.t-online.com> I'm somewhat stumped by all the weird function names in the Tutorial of the 2.0 Manual... Is something like this possible: I call a Python function from my C/C++ program. I pass it two pointers, one to an array with data, and one to an empty space where it can put its results.... I don't even remotely see a way how to do this in the Tutorial, it's just full of (to me) irrelevant stuff about callbacks etc...I feel stupid here, folks ;-) Also, is it advisable to invoke the interpreter (do I even do that? what DO I do when I execute a python function?) several hundred times? (running about 500 instances of several, sometimes identical python scripts times would be likely for medium load of my application). I'm sorry, I just don't /understand/ the Python concept...yet. It looks all so cool, but I don't have a clue about how to use it. (I plan to use it as a scripting language to customize application component behaviour) -- -- Moritz "Thygrrr" Voss http://www.thygrrr.com From Patrick.Bothe at ePost.de Sun Mar 25 10:17:01 2001 From: Patrick.Bothe at ePost.de (Patrick Bothe) Date: 25 Mar 2001 17:17:01 +0200 Subject: Commercial Products in Python? References: <3abb86ee.142862695@localhost> <3ABBD84B.9020404@ActiveState.com> Message-ID: <87bsqp515e.fsf@gabriel.heim6.tu-clausthal.de> Hi, I think some pieces of code of "Severance - Blade of Darkness" (PC-GAME) are coded in Python 1.5.2. bye, Patrick -- Der Kopf ist rund, (_ ) damit das Denken die Richtung ?ndern kann. \\\@@ ) ^ \/, \( [Francis Picabia] cXc_/_) From lsommerer at sewardweb.com Tue Mar 13 15:49:44 2001 From: lsommerer at sewardweb.com (Lloyd Sommerer) Date: Tue, 13 Mar 2001 14:49:44 -0600 Subject: Newbie: Is there a more pythonic approach? Message-ID: <3AAE87E8.FE11B4F9@sewardweb.com> I'm trying to reduce 404 errors (at least one that visitors see) on my website by correcting problems with case and extensions on the fly. This is one of my first python programs, and I was wondering if it: a) made use of python language features in a way that seems natural to "real" python programmers. b) missed any language construction that makes the program "better" (faster, easier to read...) Thanks, the program follows below. Lloyd Sommerer ========================================= error_page = '/404.html' base_url = 'http://churchsite.gatheringspot.com' base_directory = '/home/gatheri/public_html/churchsite/' extension_list = ['.html','.shtml','.htm','.txt','.php','.asp'] import string import os lowercase_url = string.lower(os.environ['REDIRECT_URL']) url_path,url_extension = os.path.splitext(lowercase_url) new_url = base_url+error_page # # Check to see if simply converting the URL to lowercase corrects the problem. # If it doesn't, check to see if the extension is incorrect and fix it if it is. # if os.path.exists(base_directory+lowercase_url): new_url = base_url+lowercase_url else: for extension in extension_list: if os.path.exists(base_directory+url_path+extension): new_url = base_url+url_path+extension # # Send HTTP header information to the browser so that it can request the "correct" document. # print "Status: 301 Permanently moved" print "Location: " + new_url print From bhk at dsl.co.uk Wed Mar 14 11:30:17 2001 From: bhk at dsl.co.uk (Brian {Hamilton Kelly}) Date: Wed, 14 Mar 2001 16:30:17 GMT Subject: Einstein's Riddle References: <7z9r6.2576$54.2837@www.newsranger.com> Message-ID: <984587417snz@dsl.co.uk> In article <7z9r6.2576$54.2837 at www.newsranger.com> gregj at pobox.com "Gregory Jorgense" writes: > Clearly my statement that the puzzle can't be solved puts me in a minority. If > you assume that SOMEONE keeps fish the puzzle can be solved with a little bit of> logic. Perhaps the intent of the riddle is to show how few people can devise a > useful and logical methodology. There is (or was) a British monthly (possibly bi-monthly) magazine published under the title Logic Problems. This had about fifty of this genre of puzzle in every issue. It is bought by a wide range of people, not many of whom are likely to belong in the upper two-percentile of intelligence, but all of whom (presumably, otherwise the magazine wouldn't sell) have the right mindset to solve the problems. Incidentally, I first saw a puzzle of this nature in McCall's Magazine in the 1950s, when I was still at primary school. That particular one was *entitled* "Who owns the zebra", which was the only mention of that particular species in the whole exposition of the puzzle. It IS "information" that is required for the puzzle to be soluble, however. Isn't it about time this stupid thread came to a halt? It was needlessly cross-posted (perhaps also multiply to other groups than appear in the headers of this post?) and has excited "interest" beyond all rationality. IOW, YHBT. -- Brian {Hamilton Kelly} bhk at dsl.co.uk "We have gone from a world of concentrated knowledge and wisdom to one of distributed ignorance. And we know and understand less while being incr- easingly capable." Prof. Peter Cochrane, BT Labs From jmarshal at mathworks.com Wed Mar 21 14:46:46 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 21 Mar 2001 19:46:46 GMT Subject: learning python... References: <3AB8F4E1.184DD9C@noaa.gov> <3ab90559_6@goliath.newsfeeds.com> Message-ID: <99b0f6$ns1$1@news.mathworks.com> Bubba Brains wrote: > Forget Learning Python? I think it's the best reference/tutorial around. I > use python once every couple months, and sometimes forget the simple python > syntax. The Learning Python book is great for getting up to speed fast, and > to look up common stuff. The other OReilly book (Programming Python) is > absolutely annoying to use. It's not even a good reference book (good luck > finding the info you want quickly). Don't know about the Prentice book. I agree about Programming Python. It _is_ a great book for programmers to use to learn Python, but it can be tedious to try look up something specific. From fredrik at pythonware.com Fri Mar 23 11:28:12 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 23 Mar 2001 16:28:12 GMT Subject: Tkinter - Widget Colours References: Message-ID: Clodagh O'Rourke wrote: > I was wondering does anyone know how the bag/fag > colours can be changed after the widget is packed. as others have pointed out, you can use "config" (aka "configure") to change options at any time. a bit more info here: http://www.pythonware.com/library/tkinter/introduction/widget-configuration.htm Cheers /F From andy at reportlab.com Fri Mar 23 19:44:04 2001 From: andy at reportlab.com (Andy Robinson) Date: Sat, 24 Mar 2001 00:44:04 +0000 Subject: Commercial Products in Python? References: <3abb86ee.142862695@localhost> Message-ID: On 23 Mar 2001 11:29:21 -0600, mmealman at loki.thebisgroup.com (Mark) wrote: >>3. What is the best way to go about it? Is it better to have customers >>install Python and give them bytecode files or use one of the programs >>that creates an executable? > >I'd try to compile Python down to an executable. It'd probably make it >easier to deploy. ReportLab have just put out two commercial demos for download built around Gordon McMillan's Windows Installer, with some mods of our own. Once you get it set up, it works beautifully. Have a quick look at http://www.reportlab.com/pageCatcher/pagecatch.zip I'm told it works just fine with GUI apps as well. We will end up advising the 'power users' to get Python, but the executable is perfect for many users and for demonstrations. - Andy Robinson CEO/Chief Architect, ReportLab Inc. From greg at cosc.canterbury.ac.nz Mon Mar 5 23:01:56 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 06 Mar 2001 17:01:56 +1300 Subject: I come to praise .join, not to bury it... References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> <3AA2F4B3.A7496E76@cosc.canterbury.ac.nz> <97vmoh061p@news2.newsguy.com> Message-ID: <3AA46134.D385208B@cosc.canterbury.ac.nz> Alex Martelli wrote: > > indeed, the string module supplies ready-made versions > of such calls For the time being, yes, but the intention has been hinted at on python-dev to deprecate and eventually remove the string module. That worries me. > if the string.join function had to typeswitch on the > joiner-object to distinguish Unicode from single-byte -- I don't get this business about avoiding type switches by dispatching on the joiner, because you still have to typeswitch on all the OTHER strings that you're joining. So you save one (very fast C-level) typeswitch out of quite a lot. Nowhere near a big enough gain to justify anything, to my mind. (And if ordinary strings and Unicode strings are ever unified, this argument will go away completely.) -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From nanotech at europa.com Thu Mar 29 13:38:51 2001 From: nanotech at europa.com (nanotech at europa.com) Date: Thu, 29 Mar 2001 18:38:51 -0000 Subject: Accessing variables in __main__ from modules.... Message-ID: <99vvfr+8hq6@eGroups.com> All: When writing programs, I like to add print statements that are only displayed when the user provides a command line switch such as '-- debug'. Ex: %myprog spam.txt ham Found the word 'ham' in 'spam.txt' 45 times %myprog --debug spam.txt ham -I-: Reading 'spam.txt'....has 213 lines.... Found the word 'ham' in 'spam.txt' 45 times Now, say most of the work is done in a module 'spam.py'. If I wrote code in this module like: lines=open(filename).readlines() if (DEBUG): print "-I-: Reading '%s'....has %s lines...."%(filename,len (lines)) DEBUG would be searched for at the module scope. But I want it to look for DEBUG back in __main__, like: if (sys.modules["__main__"].DEBUG): print "-I-: Reading '%s'....has %s lines...."%len(filename,lines) Is this the "best" way to access variable in the "__main__" scope? How else might I solve this (in the python way)?? Quentin Crain Note: I might load many modules all wanting to know if DEBUG is turned on. I do not want to pass DEBUG to functions or classes and I do not want to set a module variable DEBUG to the same value (module1.DEBUG=DEBUG, module2.DEBUG=DEBUG, etc. in __main__). Unless these are "better" solutions! :) From dfan at harmonixmusic.com Mon Mar 26 10:45:24 2001 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 26 Mar 2001 10:45:24 -0500 Subject: Good Editor? (What's the big deal with syntax colouring?) References: <99dqqo$gpi$1@news.mathworks.com> <99e9sv$usmp$1@ID-11957.news.dfncis.de> <99emg2$qif@gap.cco.caltech.edu> Message-ID: grey at despair.rpglink.com (Steve Lamb) writes: | Don't do much coding in the dark, do you? | | I never understood why people insist on it "looking like paper" | when there is one major difference. Paper is reflective, a monitor | is projective. I've never been blinded by a 19" piece of paper 3' | from my face but I sure have been blinded by a 19" monitor 3' from | my face because of this "looking like paper" bit. :/ The last time I saw this debate, someone made the observation that, in general, people who use computers in lit rooms prefer black on white and people who use computers in dark rooms prefer something light on black, and both of them have good ergonomic reasons for their preference. -- http://www.dfan.org From sholden at holdenweb.com Fri Mar 30 13:56:10 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 30 Mar 2001 13:56:10 -0500 Subject: email address verification References: <99d5qi$95l$1@solaria.cc.gatech.edu> <99fjv8$bhf$1@solaria.cc.gatech.edu> <99fo48$d9h$1@solaria.cc.gatech.edu> <6491BB8AD25B69BC.0BFC7C13FCE3713E.F0B7BA5A511B6DBC@lp.airnews.net> Message-ID: "Cameron Laird" wrote in message news:6491BB8AD25B69BC.0BFC7C13FCE3713E.F0B7BA5A511B6DBC at lp.airnews.net... > In article <99fo48$d9h$1 at solaria.cc.gatech.edu>, > Holland King wrote: > >Cameron Laird wrote: > >: I don't understand your description. In general, > > > >ok, we run a server that holds a lot of accounts, once an account expires > >then we run a script that parses the .forward file found in the home > >dir. the script then takes the addresses found and makes them into aliases > >so that hopefully the user will not lose any mail. we need to make sure > >that the aliases are real addresses so that at worst mail is not bounced > >and at best it doesn't go to a mailing list (i know i am being an optimist) > It's a good question to ask--but one which > turns out to be quixotic. Not only can one > make no guarantees by a "static" examination > of a purported e-mail address, my own exper- > ience is that there are few heuristics which > are worth implementing. So much can and > does happen at the recipient end of an e-mail > transaction that it's nearly fruitless to > try to automate. > > > >: comp.mail.misc might be a more productive place to > >: ask these questions than c.l.p. > > > >ok thank you i will try there to, the reason i asked here is that i tried > >comp.linux.misc and they didn't help and i am writing it in python (i > >think my orignal post mention that i had found the smtp library and i > >was wondering if there was something similar that would work) > I understand. It's a reasonable presumption. You also need to remember that some domains (such as bellatlantic.net) won't even raise a bounce message on an expired account, so it might appear mail is getting through even when nobody will ever see it. regards Steve From sholden at holdenweb.com Thu Mar 22 22:21:44 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 22 Mar 2001 22:21:44 -0500 Subject: Good Editor? References: <3ab9a32b$1_1@news2.one.net> Message-ID: Nope. That's two languages. No emacser worth their salt would leave elisp out of their vocabulary. (((elisp) anyone) for?)-ly y'rs - steve "Nick Efford" wrote in message news:GALn19.C1z at leeds.ac.uk... > On 22 Mar 2001 08:22:26 GMT, Fred Pacquier wrote: > > > >Can someone recomend a good editor to write python in? Im just getting > > >started learning python and dont know which ones support python. > > > > You don't mention the platform. Under Unix/Linux there are a number of > > options (including Vim, Emacs, etc.). Under Windows, I found WScite > > (http://www.scintilla.org) the easiest to get started with... > > vim and emacs run on Windows, too! So you can use one editor across > platforms as well as one programming language :) > > > N. > From cfelling at iae.nl Tue Mar 27 09:10:26 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 27 Mar 2001 16:10:26 +0200 Subject: Is it possible to sort a dictionary? References: <3ABE771B.7B9E1631@student.liu.se> <99o33k$aq4$0@216.39.170.247> <99o51301qgb@news1.newsguy.com> Message-ID: <99q70i$1le$1@animus.fel.iae.nl> Carlos Alberto Reis Ribeiro wrote: > At 03:09 27/03/01 +0200, you wrote: ... >>similar and was surprised when I found the dict.items function to be >>soo slow that going through the whole dict indexing each entry >>one by one was faster. > I was thinking about something similar today. It would be useful to have a > "xitems()" method, behaving exactly like items(), but *without* the need to > build the tuple in advance. I see two advantages: I don't know. One can only sort after the whole list exists, so a non-sorting xitems() won't suffice. In this case we wanted it to be sorted on keys, in other cases one would like it sorted on values. Are you proposing all kind of flavours for the xitem() method? I just wonder why the items() method is slooow; values() and keys() are both much faster, going over the whole dict indexing from keys() is even faster. Is tuple making/unpacking so expensive? Or is a dict optimized for key/value access on the expense of items()? I know I should dive into the python-code, but maybe someone can save me a few minutes:) -- groetjes, carel From claird at starbase.neosoft.com Tue Mar 27 10:45:34 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 27 Mar 2001 09:45:34 -0600 Subject: dynamic web pages? References: <99q701$jlr10@news-1.bank.dresdner.net> Message-ID: In article <99q701$jlr10 at news-1.bank.dresdner.net>, Dr. Peter Dintelmann wrote: >Hi, > >is there any module to create dynamic web pages >using Python? . . . There is an abundance of such schemes: -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From oddxcb at e.elim.com Sat Mar 24 05:04:16 2001 From: oddxcb at e.elim.com (oddxcb at e.elim.com) Date: Sat, 24 Mar 2001 10:04:16 GMT Subject: Evidence on................YOUR COMPUTER................Get rid............. . 1926 Message-ID: I was shocked at what I found. Files I shredded months earlier were clearly visible using this software. It's a fact Did you know......... For example that every click you make on Windows 98 Start Menu is logged and stored for ever on a hidden encrypted database within your own computer? your PC is keeping frightening records of both your online and off-line activity. Evidence Eliminator. http://www.evidence-eliminator.com/go.shtml?A653615 nyzktchuvgvmffcoudmgizrcnr From mcherm_python at yahoo.com Sun Mar 18 12:56:45 2001 From: mcherm_python at yahoo.com (Michael Chermside) Date: Sun, 18 Mar 2001 11:56:45 -0600 Subject: Who's minister of propaganda this week? References: <98nu1m$12e@dispatch.concentric.net> <660ACCA1E4816F7E.C359CDF4168EF3FB.3B6B05538D619770@lp.airnews.net> <3AAFA13D.76E32C3F@divalsim.it> <98oa4o01i4v@news2.newsguy.com> <3AB0176D.8070903@yahoo.com> <3AB0C70A.C6A55DF5@ActiveState.com> <3AB40BE3.3080001@yahoo.com> <3AB417FD.1905AC3D@ActiveState.com> Message-ID: <3AB4F6DD.10901@yahoo.com> Paul Prescod wrote: > ...[snip]... > >> (But see Alex's response, where he argues that perhaps it DOES hurt, >> for other reasons.) > > > I think it takes a lot of work with both kinds of languages to recognize > that you lose something significant in exchange for the earlier error > messages. And I think that slowly over the next few years, programmers > are going to to come to that realization. Well, most of my experience has been in staticly typed languages. I suspect that even in dynamically typed languages I tend to program in a "static typed fashion". Do you have any suggestions of examples of good code to read (or good books to read!) which would help me to realize what kinds of advantages I can get from dynamic typing? > It is highly akin to the GC situation. A few years back, garbage > collection of any sort was considered unaffordable for real apps (even > in the face of evidence to the contrary) merely because most programmers > did not have real-world experience with it. Now, nobody designs a new > language without GC. Of course it wasn't all just education. Moore's law > helped too. The situation is the same with dynamic typing. Moore's law > and education will bring programmers over. Hmm... the first time I ever heard of GC I immediately said to myself, "Aha! That's the way to go!". But I'm still working at figuring out the advantages of dynamic typing. -- Michael Chermside > _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From stephen_purcell at yahoo.com Tue Mar 27 12:43:43 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 27 Mar 2001 19:43:43 +0200 Subject: large arbitrary binary data in python In-Reply-To: <20010327192520.F1260@freedom.puma-ag.com>; from stephen_purcell@yahoo.com on Tue, Mar 27, 2001 at 07:25:20PM +0200 References: <20010327192520.F1260@freedom.puma-ag.com> Message-ID: <20010327194343.A7081@freedom.puma-ag.com> Steve Purcell wrote: > Yes, see > --- snip --- > Yes, but don't pipe it to md5sum if you can avoid it. Instead, use the > 'md5' standard module: > --- snip --- > Yep, see os.popen() and the popen2 module: > --- snip --- > Yes. The limit is the amount of available virtual memory. Python is a 'yes' language. (Unlike Java, which is a YeSDK language) -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From lac at cd.chalmers.se Thu Mar 8 11:30:41 2001 From: lac at cd.chalmers.se (Laura Creighton) Date: Thu, 8 Mar 2001 17:30:41 +0100 (MET) Subject: Can Python 1.5.2 code run on Python 2.x? Message-ID: <200103081630.RAA18168@boris.cd.chalmers.se> Guess what I am finding out today. Big change ... string conversion of long int no longer tacks an L on the end. Since I just ripped off the last digit wholesale all over this code, I have many lines to change. Laura Creighton From costas at springmail.com Mon Mar 12 15:38:42 2001 From: costas at springmail.com (costas at springmail.com) Date: Mon, 12 Mar 2001 20:38:42 GMT Subject: Crashed PythonWin. How can I fix it? References: <3aa04cf5.34464140@News.CIS.DFN.DE> <3AAACCDE.80703@ActiveState.com> Message-ID: <3aad3370.2161792618@News.CIS.DFN.DE> On Sun, 11 Mar 2001 00:58:04 GMT, Mark Hammond wrote: >Costas Menico wrote: > >> import glob >> File "glob.py", line 11, in ? >> glob2.what2() >> File "glob2.py", line 3, in what2 >> print x >> exceptions.NameError: There is no variable named 'x' > >It looks alot like a "glob.py" is being found that isnt the glob.py in >the standard library. Mark, I tried searching all of Python and could not find anywhere glob2 or what2. I had to erase everything and reinstall Python not just PythonWin. Hope I will never see this again :) Costas From aleaxit at yahoo.com Tue Mar 13 08:45:16 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 13 Mar 2001 14:45:16 +0100 Subject: module importing and variable syntax References: <3AADF3DC.1030003@dynworks.com> Message-ID: <98l89901v7f@news1.newsguy.com> "Jeff Davis" wrote in message news:3AADF3DC.1030003 at dynworks.com... > I was previously a perl user, but now I am taking an interest in python. > I am used to common perl methods such as using "variable variables" > where the accessed variable depends on the situation (perl: "print > ${$x};"). Isn't this style of ``soft'' referencing deprecated as dangerous and unadvisable in Perl itself? > Module importing doesn't take a string argument, but just a "bare word" > (in perl terms). This means I have to know the name of the file in > advance, and it needs to be in the right directory, or I need to use eval(). Or, as other have suggested, __import__. Also note that if the module HAS already been imported, the module-object can also be found at sys.modules[name] where name is a string that names the module. > What I am trying to do is have an arbitrary string with an arbitrary > type (type with respect to my program, not python) access the function > associated with the string in the module associated with the type. > > For example: someone writes an extension to my program creating a new > object of name "O". Then some other part of the program (i.e. another > extended module) tries to square an instance of that object, like: > o = O() > o.square() > > However, my program is completely unaware of either "O" or "square" > until someone writes the module(s) and registers them with the program > (not writing to the main program's source). > > It seems like I could get away with it if I used a lot of eval() > statements, but talk about unreadable code (especially since you have to > concatenate the variables in python to form a string)! The "other extended module" can perfectly well import module O, access its O attribute (a class, calling which creates an instance thereof), and access (and call) the instance attribute called 'square', all on its own, without bothering "your program" -- if I understand what you're saying. If the call must happen in your main program, it need not be the case that your main code has to be aware of anything -- it may be passed the appropriate *objects*, rather than strings it's supposed to use to fetch the objects. Module-object, instance object, bound-method object o.square -- whatever. As I don't exactly understand what you're doing, I can't tell whether this is the appropriate route, but it often is -- people coming from other programming languages often think in terms of passing strings around, where in Python they might be better off passing appropriate objects instead. > I think I am having problems understanding the way python works in this > regrard, which is why this question was probably way more complex than > it needed to be. Everything's object-centered; strings (names, variables, etc) are basically 'tags' for the objects -- names (keys) whose corresponding value is a reference to the object in some appropriate dictionary ('hash' for a Perlist). Handy for human consumption, but programs may have an easier time handly the objects directly. > I would really appreciate some clarification. I like a lot about the way > python is made and I think it has a lot of potential. Right now the > concatenation of strings can be annoying compared to just (perl) > '$string = "a $anotherstring be";', but for a lot of programs it is well > worth the tradeoff. Concatenation would be: Perl: $string = "a " . $anotherstring . " be"; Python: astring = "a " + anotherstring + " be" essentially equivalent. What you're doing is variable-interpolation: Perl: $string = "a $anotherstring be"; Python: astring = "a %(anotherstring)s be" % vars() but note that in Python you can contextually pass another dictionary to the %-operator (which does the formatting, aka interpolation), AND use a different format-specifier than %...s (which just lets the object supply a string in whatever way it wishes) much like in C's printf, if you wish. Another equivalent approach: astring = "a %s be" % anotherstring some find this preferable to having the names mixed in with the format-string (mostly, ones coming from C, I think:-). Alex From tim_one at email.msn.com Tue Mar 6 21:22:21 2001 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 6 Mar 2001 18:22:21 -0800 Subject: IEEE 754 conformance in Python In-Reply-To: Message-ID: [CY Jair] > Python's floating-point numbers representations are done by C > library, with 17 significant decimal digits preserved by the "%.17g" > format in floatobject.c file. All of Python's floating-point behavior is inherited from the platform C compiler and libraries. > It is advertised to be conformant to IEEE 754 double precision standard. Unclear what "it" means here. CPython does not promise anything wrt 754. > Java is advertised as fully conformant to IEEE 754 by Sun. However, when I > compare the two, I'm getting a little bit doubtful. Note that string<->double behavior isn't fully specified by the 754 standard (I/O conversions are unique among the operations covered by 754 in this way: a conforming implementation need not round them properly). > ... > One more thing that makes me wonder is the way Python does rounding on > floating-point numbers. In the IEEE standard, when rounding a "halfway" > result to the nearest floating-point number, it picks the one > that is even. By default, yes, although it also depends on the rounding mode in effect. > But Python's way of "%.17g" doesn't seem to work that way. CPython's %.17g behavior is inherited from the platform C sprintf %.17g behavior. It can and does vary across platforms; e.g., "add a half and chop" is normal under Windows: C:\Code\python\dist\src\PCbuild>python Python 2.1b1 (#11, Mar 3 2001, 05:56:55) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> "%.0g" % 2.5 '3' >>> Most (but not all) flavors of Unix produce '2' there. Same thing if you write the test in C. From bedge at troikanetworks.com Fri Mar 2 16:10:28 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Fri, 02 Mar 2001 13:10:28 -0800 Subject: create new statement? References: <3A9FE7C2.1F5525D2@troikanetworks.com> Message-ID: <3AA00C44.FB588EAE@troikanetworks.com> Steve Purcell wrote: > > Bruce Edge wrote: > > I want to add my own command to the interp, but not have to use object > > calling syntax > > eg: > > create obj opt > > not > > create(obj, opt) > > > > How do I define new statements, or, a way of calling functions using the > > former syntax? > > You can get the effect you want by subclassing 'Cmd' in the 'cmd' > standard library module and using your subclass in place of the usual > interactive command interpreter. I played around with that for a bit. I think it is useable. I would need to register an alternate completer for readline, as the default picks up the python global namespace. Thanks. > > -Steve > > -- > Steve Purcell, Pythangelist > Get testing at http://pyunit.sourceforge.net/ > Get servlets at http://pyserv.sourceforge.net/ > "Even snakes are afraid of snakes." -- Steven Wright From ransen_spam_me_not at nemo.it Sat Mar 3 05:02:28 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Sat, 03 Mar 2001 10:02:28 GMT Subject: PyRun_SimpleFile - impossible to call it under Windows? References: <3aa07704.2672581@news.newsguy.com> <3AA08A11.95BC7745@bigfoot.de> Message-ID: <3aa0bd3f.708696@news.newsguy.com> On Sat, 03 Mar 2001 07:07:13 +0100, Gerhard H?ring wrote: >> I'd like to call PyRun_SimpleFile in the debug version >> of my VC6 program, is it impossible currently with Python 2? >I suggest that you use the debug version of the Python libraries, >available at >http://www.activestate.com/Products/ActivePython/Download.html >Gerhard Hi Gerhard, I am already linking to Python20_d.lib, is that not the correct version? -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From jwbnews at scandaroon.com Thu Mar 15 18:43:24 2001 From: jwbnews at scandaroon.com (John W. Baxter) Date: Thu, 15 Mar 2001 15:43:24 -0800 Subject: Off-python-topic: Cron jobs on linux...help References: Message-ID: In article , "Chris Richard Adams" wrote: > I'd like to ask two things about the cron tool that comes with Linux - > have RedHat 6.2. > > 1.) I have a script that runs fine when I am logged in a the user who > owns it. I have env variables that are needed and these are loaded in > the .bash profile as that user logs in. As that user, I set a cron job > putting the pathname of the script. It runs, but fails because it > appears the environment vars are not set. I can work around it by > putting all the vars in the script of course, but what might be the > problem? Cron deliberately sets up a VERY limited set of environment variables when it starts a process. [For example, the PATH is likely not to contain what one needs, so full path names are generally given.] See man env > > 2.) I want the script to run each 20 minutes. With only the 5 time > parameters to set, I can't do this? This snippet from /etc/crontab runs the elided stuff every 5 minutes much of the day and every 15 minutes overnight. 0-55/5 7-23 * * * root nice /... 5-50/15 0-6 * * * root nice /... You don't have to abbreviate that much...the minute can be shown as 0,5,10,15, and so on. See man -S 5 crontab (-s rather than -S on many Unix systems) --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From ego at macondo.visconti.home Thu Mar 22 09:00:29 2001 From: ego at macondo.visconti.home (Gabriele Favalessa) Date: 22 Mar 2001 14:00:29 GMT Subject: Text printing under Windows Message-ID: Hi, how do I print using a dot matrix printer in text mode under Windows 98? I have both a local and a remote printer. I use python 2.0 and wxPython 2.2.5. The latter seems to support printing only in bitmap mode. My knowledge of win32 APIs is poor, I'm looking for a simple open/write/close API. Something similar to: printer = os.popen ("lpr -Pprinter1") printer.write ("Hello world!\n") printer.close () that works fine under unix. Thanks in advance. Gabriele From pj at sgi.com Sun Mar 18 03:26:45 2001 From: pj at sgi.com (Paul Jackson) Date: 18 Mar 2001 08:26:45 GMT Subject: How do I avoid the Tkinter 30 msec polling loop. References: <98s781$7a8o$1@fido.engr.sgi.com> <3ab3d191.6695740@24.0.228.33> Message-ID: <991rg5$14pol$1@fido.engr.sgi.com> Thanks for the short answer. I don't know tcl (well, did a little once, but developed an allergy to it). Whether your long answer provokes me into useful investigations remains to be seen. Guess it depends on how much I am trying to avoid 'real' work sometime. Anyhow - thanks for the prompt and most helpful reply. -- I won't rest till it's the best ... Manager, Linux System Software Paul Jackson 1.650.933.1373 From abg at saturnsys.com Wed Mar 28 13:10:13 2001 From: abg at saturnsys.com (Adam Gurno) Date: Wed, 28 Mar 2001 18:10:13 GMT Subject: Python and Dock Apps... Message-ID: <1103_985803013@stella> Hi All, While browsing for new Dock Apps to use with Blackbox, I came across this: http://www.kryogenix.org/tech/wm8ball.py.txt However, I can't find *any* other information on wmdock.py. Anyone know of any locations or can find anything else? Adam (mapson means no spam, if you knowhaddimean) From jmarshal at mathworks.com Mon Mar 19 22:12:20 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 20 Mar 2001 03:12:20 GMT Subject: list.sort(cmpfunc) question References: <98t9dq$qvu$1@panix6.panix.com> <98tf9d$g3v$1@news.mathworks.com> Message-ID: <996hqk$4p2$1@news.mathworks.com> Steve Holden wrote: > "Joshua Marshall" wrote in message > news:98tf9d$g3v$1 at news.mathworks.com... > [ ... ] >> Seems the word "should" should never appear in documentation. > ... and '"should" should' should _definitely_ never appear in documentation! I was hoping someone would bite :) From jfontain at free.fr Sun Mar 11 14:39:43 2001 From: jfontain at free.fr (Jean-Luc Fontaine) Date: Sun, 11 Mar 2001 19:39:43 GMT Subject: ANNOUNCE: tclpython-2.0 Message-ID: <3AABD472.EE38F075@free.fr> ### CHANGES ### --- version 2.0 --- allow multiple Python interpreters no longer requires the Python print command to pass data to the Tcl interpreter embedded Python interpreters can now send data to standard output or error (useful for debuging, using the print function, for example) successfully tested against the Python thread library added tclpython2 rpm for Redhat python2 compatibility includes 1 line addition patch to the Python sources ### README ### tclpython version 2.0: a Python package for Tcl This package allows the execution of Python code from a Tcl interpreter, as in: package require tclpython # or: package require tclpython2 set interpreter [python::interp new] $interpreter eval {print("Hello World")} python::interp delete $interpreter You can actually create several Python interpreters this way, if the tclpython package was linked against a Python library compiled with threads support, otherwise only 1 Python interpreter can exist at a time. Use the tclpython2 if you are using Python 2.0 or above. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ### you may find it now at my homepage: http://jfontain.free.fr/tclpython-2.0.tar.gz http://jfontain.free.fr/tclpython-2.0-1.i386.rpm http://jfontain.free.fr/tclpython-2.0-1.spec http://jfontain.free.fr/tclpython2-2.0-1.i386.rpm http://jfontain.free.fr/tclpython2-2.0-1.spec http://jfontain.free.fr/tclpython.htm Enjoy and please let me know what you think. -- Jean-Luc Fontaine mailto:jfontain at free.fr http://jfontain.free.fr/ From ben.hutchings at roundpoint.com Tue Mar 6 15:54:06 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 06 Mar 2001 12:54:06 -0800 Subject: tokenizer.c crashes in 2.1b1 References: <3aa34d5c.1284101@news.newsguy.com> Message-ID: ransen_spam_me_not at nemo.it (Owen F. Ransen) writes: > Embedding Python 2.1b1 I recreated the DLL and LIB from > the sources, VC6 , and any call to PyRun_SimpleFile still > crashes. > > The debugger points to the guilty party: > > tokenizer.c, the fgets call at line 247 fails. > > My VC project uses Multithreaded Debug compiler settings, > as does the Pythoncore project. Multithreaded Debug, or Multithreaded Debug *DLL*? It sounds like you picked the former, when you want the latter. Linking with a static run-time library tends to (but doesn't always) lead to disaster under Windows. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From francois.granger at free.fr Wed Mar 28 15:15:14 2001 From: francois.granger at free.fr (=?ISO-8859-1?Q?Fran=E7ois_Granger?=) Date: Wed, 28 Mar 2001 20:15:14 GMT Subject: warrior geeks References: <3ABF72F1.98CB78F@sage.att.com> <99okcr$mt1$1@panix3.panix.com> Message-ID: <1er02ll.srnkf9j87ztzN%francois.granger@free.fr> Aahz Maruch wrote: > What are you? Some kind of Commie? Guns form the very foundation of > the Pax Americana that gives you the freedom to use Python. Is this a good location for such a phrase ? Remember that the 'Rest Of The World' read this NG ! -- "La vie est une ?cole o? les le?ons co?tent cher, mais c'est la seule o? les insens?s puissent s'instruire." - Kipling cit? par Bernard Hall? From brian at sweetapp.com Wed Mar 21 01:19:11 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Tue, 20 Mar 2001 22:19:11 -0800 Subject: Base 2 to long integers and back In-Reply-To: Message-ID: I can't think of a library function that does this, but it should be pretty easy to do it yourself. String to int: >>> test = '10110' >>> val = 0L >>> for i in test: ... val <<= 1 ... if i == '1': ... val += 1 >>> val 22 OR, for the anal and efficiency oriented: >>> test = '10110' >>> val = 0L >>> for i in test: ... val = ( val << 1 ) + ( ord( i ) & 1 ) >>> val 22 Int to string: >>> out = '' >>> val = 100 >>> while val: ... out = str( val & 1 ) + out ... val >>=1 >>> out '1100100' -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Tim CHURCHES Sent: Tuesday, March 20, 2001 7:23 PM To: python-list at python.org Subject: Base 2 to long integers and back Can anyone suggest a fast method of converting base2 strings (e.g. '0000101110') to Python long integers, and back? I couldn't locate any functions in the standard library to do this, but no doubt I am overlooking something obvious. Cheers, Tim Churches Sydney, Australia -- http://mail.python.org/mailman/listinfo/python-list From jim.vickroy at noaa.gov Fri Mar 9 17:11:43 2001 From: jim.vickroy at noaa.gov (j vickroy) Date: Fri, 09 Mar 2001 15:11:43 -0700 Subject: Dictionary attributes and functions References: Message-ID: <3AA9551F.62F5F0F9@noaa.gov> Hello David, See if the following code fragment meets you needs. mapping = {} # create an empty dictionary for item in keys_list: # some list of keys you provide -- duplicates ok if not mapping.has_key (item): mapping [item] = [] # create empty list mapped to key item mapping [item] .append (some_value) iddwb wrote: > > I'm looking to read a list of items where their may be duplicates. I'd > like to use a dictionary to do this but am way to new to python to know > fully how to do it. I'm hoping there is some set of fuctions or > attributes that can be reference regarding dictionaries... specifically if > key(a) is already in dictionsary x I'd like to know prior to > adding. rather than change the value of key(a) I'd like to add the value > of key(`a) to the value of key(a) so I end up with > > {keya: [123]} > on insert of keya againg have something like > {keya: [123, 234]} > > Any pointers on what to look for in the docs? > > btw, I've been going through Mark Lutz's book on "programming python" but > I'd like something with a little more langugage reference in it. > > David Bear > College of Public Programs/ASU From loewis at informatik.hu-berlin.de Sun Mar 11 15:50:15 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 11 Mar 2001 21:50:15 +0100 Subject: Setting Exception data. References: <3AAAEA46.5922B1BD@eso.org> Message-ID: Ivan Munoz writes: > When raising a foo.error exception In my C code I set the error object > to some data (an object defined on my extension module, an integer and a > string) as follows: > > v=Py_BuildValue("Ois", e, errorNumber, errStr); > if (v != NULL) { > PyErr_SetObject(ErrorObject, v); > Py_DECREF(v); > } That may not exactly do what you expect. It first builds a tuple, and then sets it as the exception. Python normalizes the exception, essentially by doing exc = ErrorObject(e,errorNumber,errStr) i.e. it creates an instance by calling the class with the tuple as arguments. > so far so good, in Python then I catch this exception as: > > except foo.error, (object, errnum, errstr): Here, you have an implicit instance-unpacking: object,errnum,errstr = exc Now, since exc is a class instance, this accesses exc[0],exc[1],exc[2] subsequently, which then invokes __getitem__ three times. > Now what is the right way to acomplish the same from Python?, this does > not seem to work .... > > raise foo.error MyObject, errnum, 'You are toasted' Please have a look at the raise syntax. It allows raise Class raise Class, Value raise Value raise Class, Value, Traceback Value can be an instance of Class, a single value, or a tuple; in the latter cases, an instance is constructed by calling the class. So you can write either raise foo.error(MyObject, errnum, 'You are toasted') or raise foo.error,(MyObject, errnum, 'You are toasted') Hope this helps, Martin From delza at antarcti.ca Mon Mar 5 13:54:57 2001 From: delza at antarcti.ca (Dethe Elza) Date: Mon, 05 Mar 2001 18:54:57 GMT Subject: Suffering For Your Art References: Message-ID: <5iRo6.44561$o%6.860997@news1.rdc1.bc.home.com> But just think, if computer science was taught with python, the 4-year curriculum would only take one semester, then all the students would drop out to start writing code and making money. C++ was designed to make things hard to learn to keep comp sci instructors gainfully employed and off the streets. --Dethe "Ben" wrote in message news:n2rl6.1686$v5.5388 at newsfeeds.bigpond.com... > # Just A Quick Observation > > Is it just me or is there a lot of animosity towards Python as a serious > programming language ... it seems to be an old school attitude that if you > do not have to struggle and suffer with an idiosyncratic, unintuitive > programming syntax then it cannot possibly be a powerful language. All these > ascetics who would like to see everyone go back to the 'halcyon days' of > assembly ... IMHO I think Python is a marvellously eloquant and beautiful > language because it does not get in the road of programming. It pisses me > off if I have to consult a tome of a help file/manual to find some obscure > reference to do something that should have been quite simple ... > > # Would Anyone Like To Comment? > > From f8dy at diveintopython.org Sat Mar 3 02:06:52 2001 From: f8dy at diveintopython.org (Mark Pilgrim) Date: Sat, 03 Mar 2001 02:06:52 -0500 Subject: Thinking Pythonically (was Re: gah! I hate the new string syntax) In-Reply-To: <97q14l$jbi$0@216.39.151.169> References: <97ohh2$polt0$1@ID-77331.news.dfncis.de> <97opsb$nhu$1@nntp6.u.washington.edu> <97oupq$qijrh$1@ID-77331.news.dfncis.de> <97p3mh$bkm$1@tyfon.itea.ntnu.no> <97q14l$jbi$0@216.39.151.169> Message-ID: in article 97q14l$jbi$0 at 216.39.151.169, Donn Cave at donn at oz.net wrote on 3/3/01 12:57 AM: > I have no idea what it's like to use Visual Basic, I have never > even heard of Powerbuilder. Heh heh, I'd love to go back to my previous employer and quote you on that. They thought Powerbuilder was the right tool for every job. > verbose by comparison. Many people love Perl. You may find that > you do, too, there's no reason to expect otherwise. But it's I have had just enough experience with Perl to know that I don't want any more. ;) > important to recognize that there is a huge crowd of people who > swim upstream to use Python instead, and it's not just because > we have to be different, it's not because we want to use Zope > or our boss twisted our arm to write in Python. It's certainly > not because Python is more powerful, in the sense you have been > talking about. Oddly enough, my current boss did twist my arm to learn Python, but I realize that that's the exception. But I do now understand better why people have called my coding style "dense" (meaning "too tightly packed"), "line noise", etc. Coming from Perl, I guess Python would be a breath of fresh air precisely because it's more verbose, less dense, more readable. But I came at Python from a different angle, after years of being forced to use inferior, less powerful, less expressive languages which we were pushing beyond their limits. (We had to write code from scratch to parse the command line, because there was nothing like sys.argv. We had to write Windows API calls to get a directory listing because we had no os.listdir and the only built-in function to do it would only put the results into a graphical listbox. We had no regular expression parsing whatsoever. Etc.) I love that, in Python, I can write in three lines of code what would take an entire page in Powerbuilder. If you want to quibble and say that it would be more Pythonic to write it in four lines of code, that's fine, we can both happily co-exist. > know, I guess it's not for everyone, but for myself, I want to > challenge your notion of what it is to think Pythonically. Actually, to me, rich data structures are a minor part of thinking Pythonically; they're just what the original example was about in this thread. A much more important part is introspection, which I cover in depth in chapter 2 of my book (http://diveintopython.org/apihelper_divein.html). Looking back on it now, I can't believe I ever put up with a language where you had to choose between dynamically constructing a method name and getting a return value (*); where you couldn't find out what methods a class had; where you couldn't get access to the stack trace when something went wrong. (*) Fellow Powerbuilder survivors will remember that TriggerEvent, which allows you to call an event by name, doesn't return the event's return value, and all other ways of calling a method require you to know the method name at design time. If you were wondering why I poke fun at Powerbuilder in my book, that's why. That, and the directory-listing-into-a-graphical-listbox function; that was classic. -M You're smart; why haven't you learned Python yet? http://diveintopython.org/ From thomas at xs4all.net Sun Mar 4 19:16:55 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 5 Mar 2001 01:16:55 +0100 Subject: [Python-Dev] Re: Bug fix releases In-Reply-To: <200103031910.OAA21663@cj20424-a.reston1.va.home.com>; from guido@digicool.com on Sat, Mar 03, 2001 at 02:10:35PM -0500 References: <200103031821.NAA24060@panix3.panix.com> <200103031910.OAA21663@cj20424-a.reston1.va.home.com> Message-ID: <20010305011655.V9678@xs4all.nl> On Sat, Mar 03, 2001 at 02:10:35PM -0500, Guido van Rossum wrote: > But I understand that you're saying that the community has grown so > conservative that it can't stand new features even if they *are* fully > backwards compatible. There is an added dimension, especially with Python. Bugs in the new features. If it entails changes in the compiler or VM (like import-as, which changed the meaning of FROM_IMPORT and added a IMPORT_STAR opcode) or if modules get augmented to use the new features, these changes can introduce bugs into existing code that doesn't even use the new features itself. > I wonder, does that extend to new library modules? Is there also > resistance against the growth there? I don't think so -- if anything, > people are clamoring for more stuff to become standard (while at the > same time I feel some pressure to cut dead wood, like the old SGI > multimedia modules). No (yes), bugfix releases should fix bugs, not add features (nor remove them). Modules in the std lib are just features. > So that relegates us at PythonLabs to a number of things: coding new > modules (boring), or trying to improve performance of the virtual > machine (equally boring, and difficult to boot), or fixing bugs (did I > mention boring? :-). How can you say this ? Okay, so *fixing* bugs isn't terribly exciting, but hunting them down is one of the best sports around. Same for optimizations: rewriting the code might be boring (though if you are a fast typist, it usually doesn't take long enough to get boring :) but thinking them up is the fun part. But who said PythonLabs had to do all the work ? You guys didn't do all the work in 2.0->2.1, did you ? Okay, so most of the major features are written by PythonLabs, and most of the decisions are made there, but there's no real reason for it. Consider the Linux kernel: Linus Torvalds releases the kernels in the devel 'tree' and usually the first few kernels in the 'stable' tree, and then Alan Cox takes over the stable tree and continues it. (Note that this analogy isn't quite correct: the stable tree often introduces new features, new drivers, etc, but avoids real incompatibilites and usually doesn't require extra upgrades of tools and such.) I hope you don't think any less of me if I volunteer *again* :-) but I'm perfectly willing to maintain the bugfix release(s). I also don't think we should necessarily stay at a single bugfix release. Whether or not a 'beta' for the bugfix release is necessary, I'm not sure. I don't think so, at least not if you release multiple bugfix releases. Holiday-Greetings-from-Long-Beach-ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From cfelling at iae.nl Tue Mar 27 10:20:09 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 27 Mar 2001 17:20:09 +0200 Subject: Changing every other instance of in a file References: <8e41ctkk4l38jmj34070j15iotgv4is2cg@4ax.com> Message-ID: <99qb39$2m0$1@animus.fel.iae.nl> Lars Kl?boe wrote: ... > Blablabla talktalk blabla blabla balbalblabla > The resulting file.html (html) > Blablabla talktalk blabla blabla balbalblabla > As you can tell, every other instance of is to be changed into . Let's hope those B-tags aren't nested, then the following might work: ###define an input file = """ talktalk talktalk talktalk blabla blabla balbalblabla talktalk blabla blabla balbalblabla talktalk blabla blabla balbalblabla """ ###define the appropriate html equivalent result = """ talktalk<\BB> talktalk talktalk blabla blabla balbalblabla talktalk <\B> blabla blabla balbalblabla <\CC> talktalk <\BB> blabla blabla balbalblabla """ import re ### re.sub can deal with functions instead of simple strings to substitute ### but we need a function with state, so let's use a callable class instead class Change: def __init__(self): self.dict = {} def __call__(self, matchobj): key = matchobj.group() val = self.dict.get(key, key) if key == val: self.dict[key] = val[:1] + '\\' + val[1:] else: self.dict[key] = key return val assert result == re.sub(r'(<[^>]+>)', Change(), file) -- groetjes, carel From ssthapa at classes.cs.uchicago.edu Fri Mar 23 13:09:09 2001 From: ssthapa at classes.cs.uchicago.edu (ssthapa at classes.cs.uchicago.edu) Date: Fri, 23 Mar 2001 18:09:09 GMT Subject: python suitability for large critical run forever apps References: <3AB77CE4.78378862@troikanetworks.com> Message-ID: Tim Rowe wrote: >It depends on what you mean by "large critical run forever apps". I >routinely deal with systems that can kill a few hundred people if they go >wrong, and that's what /I/ mean by "critical". But then I baulk at the >suggestion that such a system might be "large", never mind the suggestion >that it might be multithreaded! If you need something like IEC61508 SIL4 >or the military equivalents then forget Python (and C/C++, and Perl, and >Ruby...). That doesn't make /any/ of those a "toy" language, just not >right for that application. I've said before -- here, I think -- that I >don't believe in general purpose languages; to misquote Michael Jackson, >if a language offers to helps you with /every/ problem, it won't help you >/much/ with /any/ problem. FWIW, Erlang which is used by Ericsson and Bluetail to control and operate their telecom equipment has a fairly nice multithreaded model. Basically, if an error causes a process to crash, a supervisor process just restarts the process. This may not be the best solution when you don't want any data to be missed or lost but it gives fairly good performance on telecom switches. -- ---------------------------------------------------------------------------- | Suchandra Thapa | "There are only two kinds of math . s-thapa-11 at NOSPAMalumni.uchicago.edu | books. Those you cannot read beyond | the first sentence, and those you | can not read beyond the first page." | -C.N. Yang ---------------------------------------------------------------------------- From fredrik at pythonware.com Fri Mar 30 02:14:30 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 30 Mar 2001 07:14:30 GMT Subject: issues with mixing and matching python packages References: Message-ID: John Schmitt wrote: > Does this mean that I can't simply change the installation I'm using by > simply changing some environment variables? What's up? > > What happens when I upgrade to 2.1? Is that going to be a problem? 2.0 and 2.1 can coexist. registry-dependent 2.0 or 2.1 versions cannot coexist with each other. non-registry-dependent versions (like the PythonWare distribution) can coexist with others. Cheers /F From colinmeeks at home.com Fri Mar 2 08:35:17 2001 From: colinmeeks at home.com (Colin Meeks) Date: Fri, 02 Mar 2001 13:35:17 GMT Subject: CGI & Python (error) References: <3A9F5FF5.34E01148@usa.net> Message-ID: > When accessing the script I get the error: > > File "getdate2.py", line 12, in ? > day=form["day"].value > File "/usr/lib/python1.5/cgi.py", line 907, in __getitem__ > raise KeyError, key > KeyError: day > > The script works from the command line. > > My problems is: the script I am trying to run is based on another one. > This other script works. I can't figure out the what is causing the problem > as the 2 scripts are identical in every aspect execpt for 1 variable. Both > scripts are run in a page which has all the required parameters passed to it. > Help. Please... If this is what I think it is (sorry it's not immediately clear), but when I try to parse anything from CGI, if nothing is entered in one of the boxes, this seems to be especially for radio buttons, then the variable isn't initialised. The thing I always do is something like try: day=form["day"].value except: day=1 #or what ever you want the day variable initialised as I hope this is of some help. Regards Colin From fritz.heinrichmeyer at fernuni-hagen.de Wed Mar 28 01:27:10 2001 From: fritz.heinrichmeyer at fernuni-hagen.de (Fritz Heinrichmeyer) Date: 28 Mar 2001 08:27:10 +0200 Subject: Python ready to replace perl (was Re: Install Python on Apache) References: <86snk1qafw.fsf_-_@jfh00.fernuni-hagen.de> <99fph5$a2n$1@rex.ip-plus.net> Message-ID: <86lmpq5ry9.fsf@jfh00.fernuni-hagen.de> Moshe Zadka writes: > > > 3. mod_perl beeing able to program authentification procedures using a stupid typo, i meant mod_python, mod_snake .. Btw. all reactions i got indicate that the answer is "yes" (surprise surprise) and where helpful and friendly. -- Fritz Heinrichmeyer mailto:fritz.heinrichmeyer at fernuni-hagen.de FernUniversitaet Hagen, LG ES, 58084 Hagen (Germany) tel:+49 2331/987-1166 fax:987-355 http://www-es.fernuni-hagen.de/~jfh From joelg at alum.mit.edu Mon Mar 12 07:56:57 2001 From: joelg at alum.mit.edu (Joel Gould) Date: Mon, 12 Mar 2001 12:56:57 GMT Subject: Tkinter with PIL, Image Corruption - please help Message-ID: <3aacc682.2989486@news.ne.mediaone.net> I have noticed corruption of displayed imaged when using the PhotoImage object from PIL (Python Image Library) under Tkinter. I am using Windows 98 SE with 256 MB or RAM. I see the effect under Python 2.0 (using the latest Py20 Windows binaries). I have attached a sample program which fails for me. The failure symptom is that the lower 10% of some of the images is corrupted with noise as you cycle through the images (pressing the button). Not every image is corrupted and the corruption pattern changes even when you get back to the same image. You can get the images from: http://www.gouldhome.com/Travel/StThomas00/images/001229_1106_charlotteAmalie1.jpg http://www.gouldhome.com/Travel/StThomas00/images/001229_1106_charlotteAmalie2.jpg http://www.gouldhome.com/Travel/StThomas00/images/001229_1106_charlotteAmalie3.jpg http://www.gouldhome.com/Travel/StThomas00/images/001229_1106_charlotteAmalie4.jpg Attached is the code sample. I would appreciate it if anyone could tell me what is wrong. ----- snip ----- import Tkinter import Image import ImageTk imageList = [ "001229_1106_charlotteAmalie1.jpg", "001229_1106_charlotteAmalie2.jpg", "001229_1106_charlotteAmalie3.jpg", "001229_1106_charlotteAmalie4.jpg", ] class MainDialog: def __init__(self, parent): self.canvas = Tkinter.Canvas(parent,width=800,height=600) self.canvas.pack() self.images = [] for name in imageList: image = Image.open(name) image.thumbnail( (800,600) ) self.images.append(image) self.currentImage = 0 self.tkim = ImageTk.PhotoImage(self.images[self.currentImage]) self.item = self.canvas.create_image( 0,0,image=self.tkim,anchor='nw') button = Tkinter.Button(parent, text='Next Image', command=self.onNewImage) button.pack() def onNewImage(self): self.currentImage = self.currentImage + 1 if self.currentImage >= len(self.images): self.currentImage = 0 self.tkim = ImageTk.PhotoImage(self.images[self.currentImage]) self.item = self.canvas.create_image( 0,0,image=self.tkim,anchor='nw') if __name__ == '__main__': root = Tkinter.Tk() dialog = MainDialog(root) root.mainloop() From jkraska1 at san.rr.com Sat Mar 17 14:51:24 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 17 Mar 2001 19:51:24 GMT Subject: Pep 238 Why new // operator (Non-integer Division) References: <98tc2s$qir$1@news2.ottawa.cyberus.ca> Message-ID: >>All these changes make my head spin. There is more to life than learning >>all the fine details in a computer language. The fewer number of ways to do >>something the better. > >Just because the changes are being made doesn't mean you have to USE them. This isn't true; the moment you encounter code written by someone else, you DO have to use them. This simple principle is the magic of Python minimalism, and the primary driving reason why new Python programmers can become so effective so fast (IMO). C// From aahz at panix.com Mon Mar 26 20:08:32 2001 From: aahz at panix.com (Aahz Maruch) Date: 26 Mar 2001 17:08:32 -0800 Subject: PEP 1, PEP Purpose and Guidelines References: <99ifgu$jei$1@panix3.panix.com> Message-ID: <99op6g$dr7$1@panix2.panix.com> In article , Andrew Kuchling wrote: >aahz at panix.com (Aahz Maruch) writes: >> >> After taking a closer look at Moshe's numeric proposals, I suggest adding >> a Depends-On: header. (E.g. PEP 240 depends on PEP 239.) > >What would Depends-On mean? Does it mean "To understand PEP 240, go >read PEP 239 first"? Or "To implement PEP 240, PEP 239 would first >have to be implemented or accepted"? Or something else? More that second one (dependency in the makefile sense, kinda). -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Boost the stock market -- fire someone" From fpm at u.washington.edu Thu Mar 1 00:27:25 2001 From: fpm at u.washington.edu (Frank Miles) Date: 1 Mar 2001 05:27:25 GMT Subject: PyQt file locations References: <3A9AE155.FF8C3A08@ucdavis.edu> <3A9C6E6B.3B727A37@ucdavis.edu> <97j7vk$l2c$1@nntp6.u.washington.edu> <3A9DCE00.CD9BD4AD@ucdavis.edu> Message-ID: <97kmjt$tom$1@nntp6.u.washington.edu> Dear Arzhang: Thanks for the suggestion. Unfortunately, it was already on the path, as running ldconfig -v shows. But wait... now it works!!! But I didn't changed ld.so.conf! Hmmn. I haven't checked, but perhaps the 'make install' doesn't run ldconfig? The one thing that was done was to run ldconfig. I'd assumed that the 'make install' did that. Now I can finally explore PyQt! Great! -frank In article <3A9DCE00.CD9BD4AD at ucdavis.edu>, Bruce Wolk wrote: >Frank, > >Here is the solution that solved my problem: >------------- >I had the same trouble with PyQt and RH6.2. The problem is that libsip >installs itself in /usr/local/lib which is not in your library path by >default. The best solution is to add the following line to the end of >/etc/ld.so.conf > >/usr/local/lib > >and then run /sbin/ldconfig -v as root. You should have no problems after >that. > >Good luck, >Arzhang >------------------- >Frank Miles wrote: > >> In article <3A9C6E6B.3B727A37 at ucdavis.edu>, >> Bruce Wolk wrote: >> >> >I have the same files in my site-packages directory, except for qt.pyc. >> > >> >make-install gave me some errors: >> >> [snip] >> >> >Traceback (most recent call last): >> > File "", line 1, in ? >> > File "/usr/local/lib/python2.0/site-packages/qt.py", line 43, in ? >> > import libqtc >> >ImportError: libsip.so.4: cannot open shared object file: No such file or >> >directory >> >make[3]: *** [install-data-hook] Error 1 >> >make[3]: Leaving directory `/home/bruce/down/PyQt-2.3/qt' >> >make[2]: *** [install-data-am] Error 2 >> >make[2]: Leaving directory `/home/bruce/down/PyQt-2.3/qt' >> >make[1]: *** [install-am] Error 2 >> >make[1]: Leaving directory `/home/bruce/down/PyQt-2.3/qt' >> >make: *** [install-recursive] Error 1 >> >________________________ >> > >> >When I try to run the examples, I get the same ImportError. >> > >> >Any ideas? >> >> I can only say that I am getting a nearly identical set of error messages. >> I'm running Debian 'potato', with Python 1.5.2. Sip seemed to install ok. >> Anyone have a clue? >> >> -frank >> -- > -- From xyzmats at laplaza.org Wed Mar 7 10:37:35 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Wed, 07 Mar 2001 15:37:35 GMT Subject: Can anyone recomend a good intoduction to C... References: <3aa366c6_2@nnrp1.news.uk.psi.net> <8gNo6.440$y6.128357@ruti.visi.com> Message-ID: <3aa6551e.212870101@news.laplaza.org> On Mon, 05 Mar 2001 14:19:48 GMT, grante at visi.com (Grant Edwards) wrote: >In article <3aa366c6_2 at nnrp1.news.uk.psi.net>, Simon Brunning wrote: >>... for a Python programmer? >> >>I'm going to have to bite the bullet and learn a bit of C. I'd at >>least like to learn the *right* way to do it. > >The "right" way to do it is with a PDP-11, a Lear-Siegler ADM3a >and the v7 source code. ;) Some would argue in favor of an >ASR-33, but they tend to annoy the downstairs neighbors. Sheesh, an ADM3a. What luxury. On that you can run vi. The ADM3, on the other hand, only allowed "open" mode - a little better than a line editor but not much. (a totally pointless historical tidbit: it was the 3a that allowed the vi mode of ex to creep out to a wider population at UC Berkeley and thence to become inflicted on the rest of the world. Closely followed by the much-less reliable HP 2621.) (oops, I smell a flood of "I can top that" comments such as "you had a terminal? I learned on a Teletype", "you had a Teletype? I had to toggle code in using switches", "you had switches? I had to use Forth!". Consider that joke already played out, eh). Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From chris.gonnerman at usa.net Mon Mar 5 00:35:31 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sun, 4 Mar 2001 23:35:31 -0600 Subject: Overriding UserList methods References: Message-ID: <01b101c0a536$1908d480$a100000a@local> ----- Original Message ----- From: "Daniel Klein" Subject: Overriding UserList methods > I must be missing something, cos I can't figure out how to override a method > using the UserList module. Here is some code: > > import UserList > class MyList(UserList.UserList): > __def __init__(self): > UserList.UserList.__init__(self) > > def append(self, object): > self.append(object) > > Understandably, this goes into a recursive frenzy until it hits the stack > limit. :-( Like this: import UserList class MyList(UserList.UserList): def __init__(self): UserList.UserList.__init__(self) def append(self, object): UserList.UserList.append(self, object) I think, anyway. Good luck :-) From MarkH at ActiveState.com Tue Mar 13 08:31:50 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 13 Mar 2001 13:31:50 GMT Subject: Want to catch pywintypes.api_error References: <98kftn$jf9$1@newsreaderm1.core.theplanet.net> Message-ID: <3AAE208D.4010103@ActiveState.com> Franz GEIGER wrote: > When I start win32api.FindFiles(filespec) with a non-existing filespec it > throws an exception of class pywintypes.api_error. But a "except > pywintypes.api_error, e:" does not work. Using "except Exception, e:" does > the job, because Exception is the base class. But how can I catch api_error? > What do I miss? > win32api.error Mark. From James_Althoff at i2.com Mon Mar 19 19:58:42 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Mon, 19 Mar 2001 16:58:42 -0800 Subject: Why "from __future__" stinks; a counter-offer Message-ID: If folks are getting worked up about the name __future__ (seems fine to me), perhaps __roadmap__ would be another possibility? Jim "Tim Peters" .com> cc: Sent by: Subject: RE: Why "from __future__" stinks; a counter-offer python-list-admin@ python.org 03/18/01 01:04 PM [Jason Orendorff] > Okay, nested scopes are a good idea. Having the feature > "disabled by default" in 2.1 is a good idea. But this > "from __future__" stuff isn't so hot. > > First, it's ugly. Good -- then it will stick out <0.5 wink>. Double double-underscore names are intended to "stick out", btw, and future_statements are intended to be temporary. In that sense, the uglier they are, the more incentive to get rid of them ASAP. > Second, owing mostly to its ugliness, it will be > *really* embarrassing to try and explain this to my > (non-Python-bitten) friends. If they don't use Python, I don't know why you'd bother to mention this to them regardless of spelling. > Third, it's extremely silly to have a module named > "__future__" that describes only the present and the past. At the moment, __future__.py contains only one entry, which refers to 2.2 final. Sounds like the future to me. > Fourth, Python 2.0 and earlier report an > ImportError: No module named __future__ > when they encounter a future_statement. Surely a > compiler error, even a SyntaxError, would be more > appropriate and less confusing. I agree that would be better. Over time, though, it becomes less interesting, as people move to more recent releases (which will raise exceptions at compile-time for future_statements they can't satisfy). > Lastly and most importantly, it's not too late to do > something saner. Unclear, although in the absence of a competing PEP it's certain to remain as it is, and the last 2.1 beta release is scheduled for this coming Friday (as noted in PEP 226). > I agree it's desirable to have the code itself advertise that it > uses a certain nascent feature. Since syntax and/or semantics change in the presence of a future_statement, it's *mandatory* that modules desiring the new behavior explicitly say so -- "desirable" has nothing to do with it. > So, what if we do something like this: > > 1. Pick a name. Suggestions follow: > require > using > pragma > this_code_uses > feature > ... Did you read Martin's messages on this? He picked "directive", and submitted a patch to implement it (or some part of it). But he didn't write a PEP, so you'll have to search c.l.py and SourceForge for the relevant bits. He had in mind a more general facility, and in particular wants to specify source-file character encodings someday; I actively want not to conflate future_statements with "general directives" (although "directive future xxx" might be OK -- alas, without a PEP, it's a non-starter). BTW, from the names you suggested, I have to guess that you think a future_statement is for an "optional feature". It is not: it's for an incompatible language change that will become *mandatory* in a future release (and there's no going back then). future_statements are a temporary aid for use during a transition period. "require", "using", "this_code_uses" and "feature" all send a wrong message in that respect. "pragma" is inappropriate because future_statements are about syntax and semantics, not pragmatics. patiently-awaiting-the-end-of-the-world-ly y'rs - tim -- http://mail.python.org/mailman/listinfo/python-list From paulp at ActiveState.com Thu Mar 22 16:39:09 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Thu, 22 Mar 2001 13:39:09 -0800 Subject: Automatic install of ActivePython References: Message-ID: <3ABA70FD.67DA9BE3@ActiveState.com> Dale Strickland-Clark wrote: > > I've had a pretty good hunt around for an answer to this and I'm somewhat surprised to have drawn a > blank. > > How do I do an automated or quiet install of ActivePython 2.0? > > It would be nice to be able to set the target directory but I can live without that. ActivePython has a pretty sophisticated ability to do command-line installs. This is documented in the release notes which should be in your "start menu". Yes, you can control the target directory. Remember: the install can download things off of the web. You should turn those features off if you are going to be doing batch installs in places without net connectivity. -- Take a recipe. Leave a recipe. Python Cookbook! http://www.activestate.com/pythoncookbook From dima at localhost.localdomain Wed Mar 7 21:20:48 2001 From: dima at localhost.localdomain (Dmitri A. Sergatskov) Date: 8 Mar 2001 02:20:48 GMT Subject: National Intruments GPIB References: <3AA46593.753BAE1@newfocus.com> Message-ID: On Wed, 7 Mar 2001 22:55:56 +0100, Dietmar Schwertberger wrote: >Hi Ken! > >> GPIB API. Was hoping someone else had done it :) > >Instead of using C you could just call the DLL using windll/calldll. > I do not think it would work on Linux/x86 or Sparc/Solaris though... You may want to look at ftp://ftp.llp.fu-berlin.de/pub/linux/LINUX-LAB/IEEE488/contrib/ file pythoninterface.tar.gz as a starting point also. Dmitri. From rdsteph at earthlink.net Tue Mar 27 21:35:30 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Wed, 28 Mar 2001 02:35:30 GMT Subject: Jython and JPython Questions...How similar to Python, Tkinter? Message-ID: <3ABFF14A.30D0096D@earthlink.net> Does Jython support Tkinter? OK, maybe that question as worded is nonsense, let me re-phrase it: If I code a program in Python and put a GUI front end on it with Tkinter, how hard would it be to do the same program in Jython? Or is there a better solution for Jython GUI's? By the way, as I am new to Python and learning it, but I am interested in Jython for embedding (relatively simple) applets into webpages, how different is Jython from Python? How steep will the learning curve be for Jython, after learning a reasonable amount of Python? How hard is it to translate Python programs into Jython? How good is Jython? Can I write Jython programs, and then turn them into Java applets that easily embed into web pages? (I have a small but working knowledge of embedding Java applets in web pages, despite my overwhelming newbie status in all things coding related ;-))) Please forgive my newbieness and all replies will be deeply appreciated!!! Ron Stephens From petar at metamarkets.com Fri Mar 9 13:20:43 2001 From: petar at metamarkets.com (Petar Karafezov) Date: Fri, 9 Mar 2001 10:20:43 -0800 Subject: help needed with forms' parameters handling Message-ID: <86FC34EA3C4F074AA6BBFFE52ED83FED27BE3E@METAEXCH.sfo.metamarkets.com> Hello all - I am running Apache/1.3.14 (Unix) mod_python/2.7.2 Python/2.0. At this point I am not even sure that this is a mod_python issue, as I have seen this same behavior before I ported my cgi to mod_python. I am not sure what to do at this point.. Here's the issue: When you do a POST to a python script you obtain the parameters using the util.FieldStorage, when using cgi it's cgi.FieldStorage. The returned result is a dictionary { key, value }. Everything is OK if you just what to work with this dictionary. However, if you try to pass this dictionary object to urllib.urlencode, we raise an exception: Mod_python error: "PythonHandler parse2" Traceback (most recent call last): File "/usr/local/lib/python2.0/site-packages/mod_python/apache.py", line 189, in Dispatch result = object(self.req) File "/usr/local/apache/htdocs/test/parse2.py", line 147, in handler params=urllib.urlencode(form) File "/usr/local/lib/python2.0/urllib.py", line 1086, in urlencode for k, v in dict.items(): AttributeError: 'FieldStorage' instance has no attribute 'items' Now, the funny part is that if I get this object 'form' - which was defined as form=util.FieldStorage(req) and just get the keys and values and form a new dictionary, I can pass that new one to urllib.urlencode with no problems. ... newparams={} for key in form.keys(): newparams[key]=form[key] params=urllib.urlencode(newparams) ... Again, I run into the same issue with both util.FieldStorage when working with mod_python and with cgi.FieldStorage when using my cgi version. I am quite happy with this workaround until I bumped into a different issue, which I am not exactly sure if it's related or not. When there're multiple checkboxes on a form: and we have selected more than 1, then the form parameter value gets passed to the server as an array. For example, if I'd select DEM and DAY from the checkboxed above, my params would be: 'frequences' : ['DEM','DAY'] This is all great, but when I pass the parameters to the server - my python script is playing the role of a proxy, then I am passing as value for 'frequences' the STRING "['DEM','DAY']" and not the ARRAY ['DEM','DAY']. So, somewhere in what I do/use the array gets converted to a string. The way I see it is: 1) It could be the python's FieldStorage when I originally get the keys and values 2) It could be that funky dictionary rewriting that I am doing before I pass the form parameters to urllib.urlencode. 3) I could be something in what urlencode does. I am not sure where to look at this point. Any ideas, anyone ?? Any help would be greatly appreciated! Thanks for your help! regards, Petar Karafezov MetaMarkets.com 415-575-3015 ------------------------------------------- Investing Out Loud at http://www.metamarkets.com ------------------------------------------- From fredrik at pythonware.com Sat Mar 17 10:33:18 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 17 Mar 2001 15:33:18 GMT Subject: image handling References: Message-ID: <2tLs6.1193$4N4.107379@newsc.telia.net> Michael Hall wrote: > I'm brand new on this list and am looking for resources about image > processing in a web environment in Python. I'm wondering if there exists a > module that does things like the PHP image handling functions > (creating, copying, resizing, etc). here's one: http://www.pythonware.com/products/pil Cheers /F From danielk at aracnet.com Sun Mar 4 13:13:10 2001 From: danielk at aracnet.com (Daniel Klein) Date: Sun, 04 Mar 2001 10:13:10 -0800 Subject: Subclassing builtin types References: Message-ID: On Sun, 4 Mar 2001 12:41:55 -0500, "Steve Holden" wrote: >> 1) Are wrapper classes for the builtin types a feasible (and pythonic) >thing to >> do? >> >Yes and yes: so feasible the library includes a UserList class which >provides esxactly what you seem to want: it wraps a list inside a class so >you can inherit from it! Thanks Steve, you have just saved me a ton of work, something Python has a habit of doing consistently. :-) > Delegation is also a useful trick. I'm not sure what you mean by this. Are there any simple examples I can look at? Dan From phrxy at csv.warwick.ac.uk Sat Mar 31 09:04:51 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Sat, 31 Mar 2001 15:04:51 +0100 Subject: Gaussian line profile using numeric python In-Reply-To: References: <3ac31698@zfree.co.nz> Message-ID: On 30 Mar 2001, Konrad Hinsen wrote: > "John J. Lee" writes: [...] > > but you probably don't need to know in detail, it boils down to > > > > inv_FFT(FFT(data)*FFT(kernel)) > > Except for zero-padding in case of non-periodic signals. That's why > I always recommend to look at a detailed description before doing > this; some of my colleagues keep telling me that FFT techniques "don't > work", and I suspect this is the reason. :) Yes. And that's (IIRC) what Numeric's convolve() doesn't do quite as generally as it might -- but there is (IIRC again) an XXX in the manual somewhere that admits it. Good old 'Numerical Recipes' has a reasonable description of the accountancy for the various kinds of convolutions, as long as you've grasped that you do inevitably lose some of your function to end effects for non-periodic functions (as I didn't, to start with!). John From michael at stroeder.com Wed Mar 14 02:56:05 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Wed, 14 Mar 2001 08:56:05 +0100 Subject: Unpickling from strings References: Message-ID: <3AAF2415.5789AC4E@stroeder.com> Doug Fort wrote: > > Perhaps it is getting garbled in transmission. We quote ours: > > urllib.quote_plus(cPickle.dumps(self._statsdict)) I would pickle it as binary and base64-encode that. The pickled string might be shorter. Ciao, Michael. From jmg at ecs.soton.ac.uk Wed Mar 28 12:38:32 2001 From: jmg at ecs.soton.ac.uk (Jacek Generowicz) Date: 28 Mar 2001 18:38:32 +0100 Subject: Boost documentation. References: Message-ID: Jacek Generowicz writes: > Are there any sources of documentation for the Boost Python Library > besides the source examples, getting_started<1-5>.cpp ? > > How would I write a C++ function which receives a python list and > converts it into a std::vector for its own use ? > > Thanks, > > Jacek Well, I've managed to get an attempt past the compiler now, so I'll post it here for a critique. It provides one function called `hmm', which takes a tuple (of integers), and should print out those integers. Unfortunately it thinks all the integers are zero (though it does get the correct number of them). When I try to do something similar with lists rather than tuples, the get() method appears to be unavailable. BTW, I'm using gcc version 2.95.2 on linux. -------------------------------------------------------------- #include #include #include #include namespace python = boost::python; namespace { void hmm( std::vector v ) { std::copy( v.begin(), v.end(), std::ostream_iterator( std::cout, " " ) ); std::cout << std::endl; } } BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE std::vector from_python( PyObject * p, python::type< std::vector > ) { python::tuple tup = python::tuple(python::ref(p, python::ref::increment_count)); std::vector v( tup.size() ); for ( int i; i() ); std::cout << j << std::endl; v[i] = j; } return v; } BOOST_PYTHON_END_CONVERSION_NAMESPACE BOOST_PYTHON_MODULE_INIT(converting) { try { python::module_builder this_module("converting"); this_module.def( hmm, "hmm" ); } catch(...) { python::handle_exception(); } } From qrczak at knm.org.pl Sun Mar 18 18:01:36 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 18 Mar 2001 23:01:36 GMT Subject: Who's minister of propaganda this week? References: <98nu1m$12e@dispatch.concentric.net> <660ACCA1E4816F7E.C359CDF4168EF3FB.3B6B05538D619770@lp.airnews.net> <3AAFA13D.76E32C3F@divalsim.it> <98oa4o01i4v@news2.newsguy.com> <98q9h60122v@news2.newsguy.com> Message-ID: Sun, 18 Mar 2001 14:24:54 -0800, Daniel Klein pisze: > Having dealt with both Java and Python, I can confirm that once > you are use to a dynamically typed language, variable declarations > become like training wheels; once you learn how to 'ride the bike' > they just get in the way. Let me repeat that an important cause of complaints about static typing are poor languages like C++ and Java. In Haskell, OCaml, SML, Clean you don't have to write explicit type declarations on variables or functions. They are usually written on public functions for the purpose of documentation and for checking that the body really has the type that the programmer has in mind, but types can be inferred by the compiler and don't clutter the code. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From jwbnews at scandaroon.com Sun Mar 4 13:30:28 2001 From: jwbnews at scandaroon.com (John W. Baxter) Date: Sun, 04 Mar 2001 10:30:28 -0800 Subject: Bug fix releases References: <200103031821.NAA24060@panix3.panix.com> <200103031910.OAA21663@cj20424-a.reston1.va.home.com> <15009.17989.88203.844343@cj42289-a.reston1.va.home.com> Message-ID: In article , Guido van Rossum wrote: [Quoting Aasz, I think ] > > Betas of the bugfix releases are important -- portability testing is > > fairly difficult to do when all we have are Windows and Linux/x86 > > boxes. There's definately a need for at least one beta. We probably > > don't need to lengthy, multi-phase alpha/alpha/beta/beta/candidate > > cycle we're using for feature releases now. > [Guido:] > OK, you can have *one* beta. That's it. That covers the hoped for case, in which no disasters appear during that beta. If one does, it implies that the bug-fix release is dead, since even backing out the failed fix requires fresh testing of the remainder, just as fixing the fix would require fresh testing. This could actually be a useful discipline: it might improve the quality of the submitted fixes. --John (who comes from a time of slower release cycles than the world sees now) -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From db3l at fitlinxx.com Fri Mar 16 18:48:19 2001 From: db3l at fitlinxx.com (David Bolen) Date: 16 Mar 2001 18:48:19 -0500 Subject: Cookies References: Message-ID: "Ken Seehof" writes: > Does anyone know of another mailing list more specific to http questions? > > 1. Client downloads an execuatable (frozen python application). > 2. Client downloads a web page. > 3. Web page javascript generates a statistically unique random identifier. > 4. Web page sends identifier to the server, which uses it as database key. > 5. User runs python application > 6. *** Python application somehow gets the identifier from somewhere *** > 7. Now the python application and the server both have the same identifier. Because of the restrictive client Javascript environment you'll probably be faced with, crossing the boundary between inside the browser and outside is not trivial. Is there a reason that the identifier has to only be generated by 3? It's not clear if your Python application is going to connect to the server anyway, but if so couldn't it just do the same processing you're putting into the javascript and generate a unique identifier (that it thus knows about) at that point? Or, if it isn't going to connect to the server, how about just letting the Python application open up it's own web page internally to run appropriate code on your web server to generate the identifier (which could run as a server script), and then Python could parse it right from the resulting HTML information. > The only question I am asking is how to do step 6. > > Alternative: > > 1. Client downloads an execuatable (frozen python application). > 2. Client downloads a web page. > 3. *** Web page javascript makes a unique identifier for the client. *** > 4. Web page sends identifier to the server, which uses it as database key. > 5. User runs python application > 6. *** Python application somehow generates the same identifier *** > 7. Now the python application and the server both have the same identifier. > > Again the only question I am asking is how to do steps 3 and 6 to get the > same number. This would probably prove even harder. Algorithmic generation of a truly unique identifier will almost always include some time based deviation, so I'm not sure about an algorithm that will both be globally unique and re-computable at different times - at least not without still passing some information between the two compute engines which puts you back at your same problem. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From lcortes at aodinc.com Mon Mar 19 12:28:13 2001 From: lcortes at aodinc.com (Luis Cortes) Date: Mon, 19 Mar 2001 10:28:13 -0700 Subject: What IDE are you'all using for Python 2.1 for Windows? Message-ID: <995gai$2bv$1@news.chatlink.com> Hi, Just wanted to know what "good" ide's are out there for python. Please let me know which ones you prefer. Thanks, Luis. From aaldv97 at student.removethispart.vxu.se Mon Mar 26 10:36:05 2001 From: aaldv97 at student.removethispart.vxu.se (David Andreas Alderud) Date: Mon, 26 Mar 2001 17:36:05 +0200 Subject: Lists and Files References: <99njdo$oa3$1@news.lth.se> Message-ID: <99nnm1$pak$1@news.lth.se> Thank you very much Duncan Booth and Steve Purcell. I really like Pythons fast prototyping capabilites, nothing short of amazing, I'll never use LISP again :) /Kind, regards David A. Alderud From jwbnews at scandaroon.com Tue Mar 13 20:09:04 2001 From: jwbnews at scandaroon.com (John W. Baxter) Date: Tue, 13 Mar 2001 17:09:04 -0800 Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> <20010312170356.B3513@better.net> <984486395.407379@newsmaster-04.atnet.at> <984518199.127140@newsmaster-04.atnet.at> <3AAEAB92.DC8E984A@san.rr.com> Message-ID: In article <3AAEAB92.DC8E984A at san.rr.com>, Darren New wrote: > Grant Edwards wrote: > > Of course we'd never imagined we'd ever see hardware FP and BCD > > libraries were only marginally slower than binary ones. Now > > that FP is usually in hardware, BCD FP (or fixed point) will be > > pretty slow by comparison. > > One mainframe I worked on (Xerox 560, AKA Sigma 9) had the "scientific > module" which was hardware floating point, and the "business module" which > was the hardware BCD. The latter added instructions like "Edit byte string" > that would copy packed BCD into a string according to COBOL display-edit > formatting. (Or whatever COBOL called the "print using" formatting. Too many > years. Not enough COBOL. Or something like that.) Sigmas were quite nice. And the NCR C-315 line had a company-supplied Fortran with (obviously!) floating point routines, and a user group supplied set of floating point libraries which actually worked, which most sites used. The 315 was a decimal machine (BCD)...a word was 12 bits...either 2 characters or 3 digits. The accumulator was as long as it needed to be (up to 12 slabs) to contain the current value...there was a T@ register (Tally of Accumulator) which held its current length. Words were called syllables (ergo slabs) because someone in engineering had thought 12 bits too short to be dignified as a word. --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From fredrik at pythonware.com Thu Mar 29 10:04:36 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 29 Mar 2001 15:04:36 GMT Subject: Basic Question: 2.0 --> 2.1 do extensions need to be recompiled? References: Message-ID: <8aIw6.4172$4N4.850578@newsc.telia.net> Mike C. Fletcher wrote: > I'm short on time this week, so I'd rather not have to get Python, Numeric, > etceteras just to compile PyOpenGL if it isn't necessary. So, is > recompilation required for extension modules compiled for 2.0 to work with > 2.1? in theory, yes. in practice, it may work on some platforms (but under protest). windows is not such a platform. unix might be. Cheers /F From bsass at freenet.edmonton.ab.ca Fri Mar 2 01:49:48 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 1 Mar 2001 23:49:48 -0700 (MST) Subject: Lower bounds of lists In-Reply-To: <00cb01c0a2b2$d1063fe0$a100000a@local> Message-ID: > > It seems an odd choice, as humans count from one, and Python in > > other respects seems quite logical and well thought out. > > Humans count from 1. Hackers count from 0. Not really - it's an index (the offset from the start), not a count. If you are at the start of something, the offset is 0. <...> > C does it that way. So, in general, does assembler, and the internal > representation of unsigned integer numbers runs from 0 to (2^bits)-1, > where bits is the number of bits of data storable. > > Counting from 0 is counter-intuitive to humans, but so is much of > computer science. Ultimately, it's because Guido wanted it that way. Consider this... maybe you are not really counting, you are actually building a list then referring to the items in it. Once you get your head in the right space it all becomes clear. HTH - Bruce From bsb at winnegan.de Tue Mar 6 13:05:35 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 06 Mar 2001 19:05:35 +0100 Subject: urllib.urlopen and proxies In-Reply-To: References: <008301c0a57d$1331cde0$a100000a@local> Message-ID: <87g0gq6ads.fsf@winnegan.de> Paul Moore writes: > On Mon, 5 Mar 2001 16:07:42 +0100 , Siggy Brentrup > wrote: > [...] > >I suggest using urllib2, changing the proxy setup described in the > >module's docstring to > > > > proxy_support = urllib2.ProxyHandler({"http" : > > "http://user:pw at proxy:port"}) > > > >Untested too, since my proxy doesn't require authorization. > > I had a look at urllib2. The module docstring even includes an > example! > [...] > > The only problem is that I don't know what the 'realm' and 'host' > parameters to authinfo.add_password should be. I need to supply a > username and password for everything... The authinfo stuff is for remote sites requiring authentication, as long as you visit unprotected sites only you can ignore it. Modify the docstring example as follows: -------- import urllib2 proxy_info = { 'user' : 'your userid', 'pass' : 'your password', 'host' : "proxy.doma.in', 'port' : 3128 # or 8080 or whatever } # build a new opener that uses a proxy requiring authorization proxy_support = urllib2.ProxyHandler({"http" : "http://%(user)s:%(pass)s@%(host)s:%(port)d" % proxy_info}) opener = urllib2.build_opener(proxy_support) # install it urllib2.install_opener(opener) f = urllib2.urlopen('http://www.python.org/') -------- Proxy authorization still untested, please report if it works. Siggy From cwebster at nevada.edu Tue Mar 13 13:16:55 2001 From: cwebster at nevada.edu (Corran Webster) Date: Tue, 13 Mar 2001 10:16:55 -0800 Subject: Sortin dictionaries in python References: <3aae4757.68617130@News.CIS.DFN.DE> Message-ID: In article <3aae4757.68617130 at News.CIS.DFN.DE>, costas at springmail.com wrote: > Is there a simple way to sort a dictionary? It seems the only way to > do this is by indirectly creating a sorted list. Dictionaries have no inherent order, but if you need to get at the items in a sorted order, you'd do something like: keys = mydict.keys() keys.sort() for key in keys: # do stuff with mydict[key] If the data that you are dealing with is something that is strongly ordered, you may be better off using someting like a list of tuples instead of a dictionary. > And while on the topic of sorting lists. I tried sorting a list and > wanted to to pass a compare function to the list.sort() method. The > documentaion gives no example. Have a look at the Sorting Mini-HOWTO from the main python site. http://www.python.org/doc/howto/sorting/sorting.html This has a solution to the problem below, as well. > import string > > x=['a','c','B'] > > def ignoreCase(left, right): > if string.upper(left) < string.upper(right): > return -1 > else: > return 1 I think that this will work, but a comparison function should return 0 if the two strings are equivalent, just in case the sort method changes in a future version of Python. The following is a better way of doing this: def ignorecase(left, right): return cmp(string.upper(left), string.upper(right)) In fact, if you are using a Python which has string methods, you could write this as: def ignorecase(left, right): return cmp(left.upper(), right.upper()) which will be slightly more efficient. > x.sort(ignoreCase(left, right)) When passing a function you only need to pass the name of the function, not the function parameters: x.sort(ignorecase) tells sort to use the comparison function "ignorecase". Sort expects this function to have the right number of arguments, do the right kind of things to the arguments, and return the right kinds of results. Finally, if you don't want to have to define a separate function and just want to do a one-off sort, you could do the following one-liner: x.sort(lambda left, right: cmp(left.upper(), right.upper())) This is quick if you only sort once, but slow if you need to sort many lists in this way. Regards, Corran From ws-news at gmx.at Wed Mar 7 04:06:22 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Wed, 7 Mar 2001 10:06:22 +0100 Subject: class object access in class definition? References: Message-ID: <983956262.417565@newsmaster-04.atnet.at> Depends on what you really need this for But you can of course access the class object in the __init__ method like this >>> class Foo: ... def __init__(self): ... print Foo ... hth werner Lars Damerow wrote in message news:Pine.LNX.4.21.0103061556510.2015-100000 at zero... > Hi folks! > > Is it possible to reference a class from within its own definition? Something > along the lines of: > > class Foo: > print Foo > > This works for functions--that is, > > >>> def foo(): > ... print foo > ... > >>> foo() > > > works as expected, but the class definition above raises a NameError: > > >>> class Foo: > ... print Foo > ... > Traceback (most recent call last): > File "", line 1, in ? > File "", line 2, in Foo > NameError: There is no variable named 'Foo' > > Thanks for any pointers! > -lars > > ___________________________________________________________ > lars damerow > senior unix administrator > pixar animation studios > lars at pixar.com > > "Nauseous. Nauseated. The first means 'sickening to contemplate'; the second > means 'sick at the stomach.' Do not, therefore, say, "I feel nauseous," unless > you are sure you have that effect on others." > > - William Strunk Jr., "The Elements of Style" > From Laura_01 at MailAndNews.com Sun Mar 11 23:20:41 2001 From: Laura_01 at MailAndNews.com (Laura Lewin) Date: Sun, 11 Mar 2001 23:20:41 -0500 Subject: Python In A Nutshell - suggestions Message-ID: <3AAE7366@MailAndNews.com> Hi! Thanks for your suggestions. We'll definitely take these into account. Laura LLewin at oreilly.om >===== Original Message From Louis Luangkesorn ===== >Laura, > >Well, since your asking for suggestions . . . > >One thing I would like the Nutshell book to include are sections on some of the commonly used modules that may not be included in the base >distribution. I say this because for the language itself and standard modules, there is already printed documentation in the form of the Python >Essential Reference by David M. Beazley and presumably the The Standard Python Library by Fredrik Lundh that is coming out. But in no place I've seen >is there documentation on the third party modules. > >Of course this begs the question of "what are commonly used modules?" There are a couple of lists out there. One is the list of modules that is on the >ActiveState page, http://www.activeState.com/Products/ActivePython/Extensions.html, >These include: tkinter, wxPython, expat, Numeric Python, and ODBC (they have mxODCB, but using DBI 2.0 compliant modules in general would make for a >useful section) Another useful list are the modules that are mentioned in Python Programing for Windows32 by Hammond and Robinson in Chapter 3. They >only have space for a paragraph each as a teaser, but it would be good to have a few pages in a Nutshell book. (and if you really want to know, the >modules I use are Numeric Python and ODBC, and I'm going to be choosing between tkinter and wxPython soon) > >And while I'm at it, one useful book to have would be on wxWindows/wxPython. I see references to it in several places, and a few intros on the web, but >nothing that looks like good documentation (besides help files), even on the internet. (and this book would be useful to C, C++ as well as Python >programmers.) > >Thank you. (as I look at my shelf with several binders of printed documentation) > >Louis >LLewin at oreilly.com wrote: > >> Hi, >> Yep--Python Nutshell is "forthcoming"...we're just in the planning stages at this point--very early on in the process. Any suggestions are welcome! >> Laura >> LLewin at oreilly.com > >-- >K Louis Luangkesorn >lluang at northwestern.edu http://pubweb.nwu.edu/~kll560 PGP:0xF3E2D362 >Whatsoever things are true, ... honest, ... just, ... pure, ... lovely, ... of good report; if there be any virtue, and if there be any praise, think on >these things.- motto - Northwestern University > From whisper at oz.net Sat Mar 31 20:12:12 2001 From: whisper at oz.net (Dave LeBlanc) Date: 1 Apr 2001 01:12:12 GMT Subject: HTML Tidy and Python wrapper References: <985945106.28359.0.nnrp-02.c1c3e154@news.demon.co.uk> Message-ID: <9a5v9c$fc7$1@216.39.170.247> Dunno about a python wrapper, but a wrapper for Tcl has been done and some mods to tidy are done that allows it to be repeatedly called instead of "once through" batching as it comes from the "factory" ;-) Check out Tcl on SourceForge and look around for TclXML etc. Regards, Dave LeBlanc On Fri, 30 Mar 2001 10:37:41 +0100, "Paul Brian" wrote: >Dear all, > >I was sure that I recently read that there was a python wrapper around the >HTML Tidy (http://www.w3.org/People/Raggett/tidy/). Unfortunately I cannot >find the reference. Does any one know if such a thing exists, as simple >searches through deja have come up nought. > >thank you > > From loewis at informatik.hu-berlin.de Fri Mar 2 10:56:42 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Mar 2001 16:56:42 +0100 Subject: A counter-counter-proposal for PEP 236: #pragma( nested_scopes) References: <0Swn6.3324$TW.17061@tor-nn1.netcom.ca> Message-ID: "Warren Postma" writes: > Has anyone considered borrowing a C notation: > > #pragma( nested_scopes ) > > Benefits: > - It's a comment therefore it doesn't break anything else. > - It compiles fine and is ignored on pre-2.x systems. > - More pragmas can be added later, for warnings, code generation, > etcetera. I have considered it, but I dislike the idea of putting semantics into comments. Comments are there for human readers, and not to be interpreted by the language. If it has any formal meaning to the language, it should have formal, outside-of-comments syntax as well. Regards, Martin From wesc at deirdre.org Tue Mar 20 15:19:39 2001 From: wesc at deirdre.org (Wesley J. Chun) Date: Tue, 20 Mar 2001 12:19:39 -0800 Subject: Thread join example Message-ID: <200103202019.MAA22128@emperor.deirdre.org> From: seung-won hwang > Subject: Thread join example > Date: Tue, 20 Mar 2001 13:59:08 -0600 > > I am looking for a code example which contains thread join. I would > appreciate your help very much! i put a small chapter on multithreaded programming in Core Python Programming, including several simple code examples using the join() method of Thread objects which come from the threading module. click on the book URL below and hunt down the Chapter 17 code samples. hope this helps! -wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Silicon Valley-SF Bay Area Python users group: http://baypiggies.org "Core Python Programming", Prentice Hall PTR, December 2000 http://starship.python.net/crew/wesc/cpp/ wesley.j.chun :: wesc at baypiggies.org cyberweb.consulting :: silicon.valley, ca http://www.roadkill.com/~wesc/cyberweb/ From phd at phd.pp.ru Thu Mar 1 12:41:41 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 1 Mar 2001 20:41:41 +0300 (MSK) Subject: sre bug with \b in locale mode Message-ID: Hi! The following program works fine under python 1.5.2 and has a problem under python 2.0. It seems like a bug in sre in hadling \b in locale mode. Is it a known bug? Can anyone test it with latest python/sre (adapt last line to your locale, please)? import re, locale locale.setlocale(locale.LC_ALL, "") def test(s): pattern = re.compile(r"\b%s\b" % s, re.LOCALE) match = pattern.search(s) if match: print s, "- found!" else: print s, "- not found..." test("home") # english text test("???") # russian cyrillic, encoding koi8-r, locale is koi8-r Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From phrxy at csv.warwick.ac.uk Wed Mar 28 10:17:44 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Wed, 28 Mar 2001 16:17:44 +0100 Subject: wavlets? In-Reply-To: References: Message-ID: On Wed, 28 Mar 2001, Taz wrote: > i'm about to write a wavelets module for python - does one already exist... > couldn't find one? Try asking on the Numerical Python mailing list. John From kcocaine at GamesandTheory.com Sun Mar 4 19:51:23 2001 From: kcocaine at GamesandTheory.com (Kevin Douglas) Date: Sun, 4 Mar 2001 19:51:23 -0500 (EST) Subject: Need a free lancer python programmer - to do bots In-Reply-To: <006e01c0a4fa$3c4e0820$52d0fea9@mario> Message-ID: On Sun, 4 Mar 2001, [iso-8859-1] M?rio Gilberto Eichler Junior wrote: > I need a free lancer programmer to do a bots to search information in 35 sites based in a word dictionary and write the results in a mysql database > > I will pay per a job. > > I leave in Brazil. > > All sites are locate in Brazil. > > Will pay in American Dollars. > hola! i used to work for StarMedia Network - we rolled out a python product in spanish and portugeuse - i'm sure i'd be perfect for this job i really really really need the money too - u.s. corporate scene is all whacky right now and i live in NYC - one of the most effected places how much are you looking to spend and when do you need it done by? i'm not busy at the moment i'm sure i can knock it out rather quick dont really care how much the $$$ is either, as long as its a fair deal been working with agent based technologies in python for 3 years now :) multi-million transaction level type stuff anyway - let me know - send me some details on the project - what kind of server its on and if theres a development environment - etc -kev From aahz at panix.com Wed Mar 14 00:06:47 2001 From: aahz at panix.com (Aahz Maruch) Date: 13 Mar 2001 21:06:47 -0800 Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> <984518199.127140@newsmaster-04.atnet.at> Message-ID: <98mu97$fd1$1@panix3.panix.com> In article , Grant Edwards wrote: > >Of course we'd never imagined we'd ever see hardware FP and BCD >libraries were only marginally slower than binary ones. Now >that FP is usually in hardware, BCD FP (or fixed point) will be >pretty slow by comparison. If anyone cares, it ought to be fairly easy to create an unbounded BCD module using Python's longs. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Python: Programming the way Guido indented it From mertz at gnosis.cx Sun Mar 11 22:46:30 2001 From: mertz at gnosis.cx (Dr. David Mertz) Date: Sun, 11 Mar 2001 22:46:30 -0500 Subject: sql query results to xml (fwd) Message-ID: Scott Hathaway wrote: > I want to create a tool that will take a valid SQL query and return the > results as valid xml. Before I reinvent the wheel, is there a python class > or code snippet that someone has that does this already? Uche Ogbuji responded: |Not that I know of. Are you planning to use the syntax from Oracle's |XSQL, or DB2's XML Extender, or any of the other hundreds of formats |available (see |http://www.linuxworld.com/lw-2001-02/lw-02-xml3databases.html |But all that is just to point out that you probably don't have to |reinvent a resultant XML format. Before anyone *does* decide to roll-their-own version of this, I wanted to mention that Scott Hathaway and I are working on a pair of tools in answer to Scott's original inquiry. Consider this preliminary, but my little bit can be seen at: http://gnosis.cx/download/sql2dtd.py A *likely* output file (partially hand done) can be found at: http://gnosis.cx/download/sql2xml_sample.xml I've looked at a version of Scott's sql2xml.py portion of things, but am not sure if he wants to make that available quite yet. Anyway, it will be a matter of just a few days before we'll have a fairly reasonable Python solution to the (small) problem above. Hopefully, it will be useful to some developers. However, contrary to Uche's no-doubt-sound advice, our stuff is a brand new format, not any of those referenced by Uche's article. The choices are straightforward and obvious, but presumably not *identical* to other systems. Yours, David... From sheila at spamcop.net Tue Mar 27 08:46:05 2001 From: sheila at spamcop.net (Sheila King) Date: Tue, 27 Mar 2001 13:46:05 GMT Subject: Reading e-mail body (newbie) References: Message-ID: On Tue, 27 Mar 2001 14:51:08 +0200, Jacobus van der Merwe wrote in comp.lang.python in article : :I have a script to which e-mail to a certain address is relayed. :I need to write the body of the e-mail to a file. :I use : :rfc822.Message(sys.stdin) : :to read the e-mail, but I can't figure out how to access the body. :It seems that rfc822 only have methods to access the headers. ???? :Any help will be appreciated. #! /usr/bin/env python import rfc822, sys, os inheaders=rfc822.Message(sys.stdin, 0) for h in inheaders.headers: print h, print for line in sys.stdin.readlines(): print line, print print print "This message was passed through a Python script" print "passmailthrough.py" -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From andrew.bonello at metrics.co.uk Wed Mar 28 04:22:17 2001 From: andrew.bonello at metrics.co.uk (Andrew Bonello) Date: Wed, 28 Mar 2001 10:22:17 +0100 Subject: Python and SWIG - passing object pointer param to an embedded script. Message-ID: <3ac1a999@pron.i-way.net.uk> Good Day I have a query as regards embedded Python scripts and the Python/C API. I am invoking evaluation of a Python script from within my C++ code using the PyRun_File(...) function. I want to be able to pass a pointer to one of my PyObject-derived C++ objects into this script as a parameter. Then, within the Python script, I want to be able to pass this parameter to function calls in an imported module defined using a SWIG interface, which invokes C++ code in a DLL that I have written. What I am trying to do here is to be able to work in my wrapping C++ code, creating and modifying the state of some (PyObject-based) C++ objects, then invoke an embedded Python script, which in turn calls some C++ functions defined in my SWIG module. Those functions may themselves modify the state of my outer C++ objects, so clearly I need some way of linking the objects into my script environment when the Python interpreter is run. I have tried to do this as follows: // intialise python interpreter Py_Initialize(); std::string m_FileName = "./test.py"; FILE* fp = fopen( m_FileName.c_str(), "r" ); const char* fn = m_FileName.c_str(); PyObject *globals = PyDict_New(); PyObject *locals = PyDict_New(); // this is my outer C++ object which I want Python and any SWIF functions called to have access to PyObject* myobj = new MyPyObj(); PyDict_SetItemString( globals, "myobjptr", myobj); PyObject* obj = PyRun_File( fp, (char*)fn, 0, globals, locals ); This just causes an access violation. (I am using Microsoft Visual C++ V6.0 with Python V2.0, Debug build). It seems to me that what I really ought to be doing is getting a reference to the *exisiting* global dictionary and adding my object pointer to that, rather than constructing a new dict using PyDict_New() - can anyone offer any help on this? Furthermore, my "MyPyObject" derived class may not yet be a valid PyObject. I have been unable to find examples of how to write code for and correctly initialise a simple C++ object which inherits from the PyObject class and can thus be accessed from within embedded Python scripts. If anyone is able to offer any examples of doing this, I would be most grateful. Thanks very much! Andy Bonello From matthias.oberlaender at daimlerchrysler.com Thu Mar 8 05:11:11 2001 From: matthias.oberlaender at daimlerchrysler.com (matthias.oberlaender at daimlerchrysler.com) Date: 8 Mar 2001 10:11:11 GMT Subject: Who am I: can a class instance determine its own name? References: Message-ID: <987lrv$7v5$1@news.sns-felb.debis.de> > "Tim CHURCHES" wrote in message > news:mailman.984034150.9635.python-list at python.org... > This is probably an elementary question and the answer is probably writ > large in multiple places in the Python documentation, but... > > ...can an instance of a class determine the name of the variable to which it > is assigned? For example: > > ########################### > class Foo: > def whoami(self): > return "You are a Foo() but I do not know your name" > > FooBar = Foo() > > print FooBar.whoami() > ########################### > > How does one define the method whoami() so that it returns "FooBar"? This > sort of navel gazing is formally called introspection, I think (therefore I > am)? > > Tim Churches > Sydney, Australia > (where, due to the Coriolis effect, the Python prompt does indeed look like > this: <<< - or maybe its because we are upside-down) In "Steve Holden" wrote: > This question recurs so frequently I would appreciate knowing of any > omprovement which could be made to FAQ entry 4.97: How can my code discover > the name of an object? > http://www.python.org/doc/FAQ.html seems to be out of data. I could not find 4.97 on that page. However, the wizard finds it: http://www.python.org/cgi-bin/faqw.py?query=4.97&querytype=simple&casefold=y es&req=search > This tries to address the question in a helpful manner. > Yes, but here is something more constructive: >>> def howDoYouCall(me, here): .. # return a list of names whose value is identical to 'me' in namespace 'here' .. result = [] ... for (name, value) in here.items(): ... if value is me: result.append(name) ... return result ... ... >>> x = 5 >>> y = 3 >>> z = None >>> >>> howDoYouCall(3, globals()) ['y'] >>> howDoYouCall(5, globals()) ['x'] >>> howDoYouCall(None, globals()) ['__doc__', 'z'] >>> Does this help a bit? -- ____ __ _/_/ . ( / / ( / / / / ===================================================================== Matthias Oberlaender, DaimlerChrysler AG, Research Center Ulm FT3/AB (Information Technology / Image Understanding) Wilhelm-Runge-Str. 11, P.O. Box 2360, 89013 Ulm, Germany Phone: +49 731 505 2354 Fax: +49 731 505 4113 Email: matthias.oberlaender at daimlerchrysler.com ===================================================================== From Padraig at Antefacto.com Thu Mar 15 14:14:22 2001 From: Padraig at Antefacto.com (Padraig Brady) Date: Thu, 15 Mar 2001 19:14:22 GMT Subject: wxPython/Tkinter/pyGTK Message-ID: <3AB11488.3010006@Antefacto.com> Hi, I'm just starting to use python, and my first app will have the following widgets: Tabbed interface, with tabs in horizontal position. toolbar. treeview. listview (with embedded checkboxes) the odd button. like: +--------------------------+ | MyApp | +--------------------------+ | toolbar | |--------------------------| | tab1 +-----------------+ | | tab2 | treeview &/or | | | .. | listview | | | tabn +-----------------+ | +--------------------------+ So 1. I'm wondering what to use? wxPython, Tkinter, PMW+Tkinter or pyGTK 2. Is there any documents comparing these options. 3. Are there other options I haven't considered. 4. What option do people consider as having the least dependencies (easiest to install), as this app is GPL'd and must be easy to install. Thanks, Padraig. From thys at klaribel.netsys.co.za Fri Mar 23 12:42:59 2001 From: thys at klaribel.netsys.co.za (Thys) Date: Fri, 23 Mar 2001 19:42:59 +0200 Subject: wxImageList use in wxPanel Message-ID: <01032319432603.09619@klaribel.feetjieland> Hi All, I need to display a few images on several places in a wxPanel, the obvious soluttion would be to use a wxImageList, especially as the panel changes over time (a status screen of sorts). I cant seem to get it to work though, no compilation problems but the graphics refuse to be displayed. The documentation seems to concentrate on wxListCtrl and wxtreeCtrl none of which is applicable in this case. appreciated as always -- Regards Thys -------------------- Thys Meintjes thys at netsys.co.za Netsys International(Pty) Ltd http://www.netsys.co.za +27 12 348-4246 From fredrik at pythonware.com Tue Mar 20 16:10:54 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 20 Mar 2001 21:10:54 GMT Subject: New PEP: The directive statement References: Message-ID: Martin von Loewis wrote: > That is also why the PEP 236 proposal (__future__ imports) finds that > much resistance it uses an action statement to declare things. except that "import" already is a declaration statement, of course. > P.S. If "directive transitional nested_scopes" is approved well, adding new, ugly, and utterly non-pythonic syntax for a one- shot workaround strikes me as a really bad thing. if I want Tcl (random interpretation of barewords) or applescript (lame attemts to make things look like english), I know where to find it. Cheers /F From fredrik at pythonware.com Wed Mar 14 11:33:23 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 14 Mar 2001 16:33:23 GMT Subject: [Python-Dev] Revive the types sig? References: <15020.9404.557943.164934@w221.z064000254.bwi-md.dsl.cnc.net> <200103120711.AAA09711@localhost.localdomain> <1pWvOlsMJ9Zxk0d4s9BhFmMCSusy@4ax.com> Message-ID: Paul Moore wrote: > Type annotations, as described so far, sound like a sanitised and formalised > version of this: > > def f(n): > assert type(n) == type(1) > > I can imagine *very* few places where an assert like this is of genuine > practical use. > > Of course, if type annotations will *actually* formalise and support > interfaces in some form, that's entirely different - I'm mostly neutral, about > something like this. > > def f(n): > assert footnote: the correct way to spell this is: assert isinstance(n, type(1)) # or types.IntType as you say, assert type(n) is type(1) is mostly evil. Cheers /F From sheila at spamcop.net Mon Mar 19 20:08:39 2001 From: sheila at spamcop.net (Sheila King) Date: Tue, 20 Mar 2001 01:08:39 GMT Subject: Problems with 2.0 cgi scripts References: <9956p1$8g0$1@panix3.panix.com> Message-ID: On 19 Mar 2001 06:57:37 -0800, aahz at panix.com (Aahz Maruch) wrote in comp.lang.python in article <9956p1$8g0$1 at panix3.panix.com>: :In article , :Sheila King wrote: :> :>So, basically, it cannot find the modules when I run it as a cgi-script. I :>have all the paths set correctly, and the permissions set correctly. Grr, I'm :>frustrated with this one by now... : :You can't set the path because you don't own the web server. Simplest :solution is to set sys.path yourself as the first line of the script. Thanks, that was one solution. However, the other solution was for me to re-install Python with the correct exec_prefix option. (I had not done that correctly.) Now I've fixed everything, and it's running smoothly. Thanks to D-Man, Michael Reilly, and other regulars on the Python Tutor list! More details here: http://www.aota.net/ubb/Forum3/HTML/001564-1.html -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From jra at dorothy.msas.net Tue Mar 27 09:27:04 2001 From: jra at dorothy.msas.net (Jay R. Ashworth) Date: Tue, 27 Mar 2001 14:27:04 GMT Subject: Linux GPS program References: <3AC01637.4EF3A6F2@crynwr.com> Message-ID: This one time, in band camp, Russell Nelson wrote: > Hi. I have written a GPS program in Python for Linux. I'm sure that > someone could port it to run under Windows, but I have no interest in > doing so. I haven't done a real release of the software yet, since > it's still under heavy development. But you're welcome to download a > copy from handhelds.org's CVS. The location is "apps/pygps". For info > on handhelds.org's CVS: http://www.handhelds.org/sources.html > > Right now, it does moving maps (UTM bitmaps), track recording, and > playback. Will select the "best" of multiple maps. No *schidt*. Cool, Russ; thanks. Any plans to do vector map data as well? (Yeah, I know, I know; "it's never enough". :-) Did you use wxPython? Cheers, - jra -- Jay R. Ashworth jra at baylink.com Member of the Technical Staff Baylink The Suncoast Freenet The Things I Think Tampa Bay, Florida http://baylink.pitas.com +1 727 804 5015 From marcin.chady at ntlworld.com Tue Mar 13 18:03:46 2001 From: marcin.chady at ntlworld.com (Marcin Chady) Date: Tue, 13 Mar 2001 23:03:46 -0000 Subject: Unpickling from strings Message-ID: I have pickled an object into a string and saved it in an hidden HTML form field, so that I can recover the state when the form is resubmitted. However, when the form comes back and I try to unpickle my object I get an error saying that the module in which the object's class was originally defined is unknown, even though the CGI script which does the unpickling has already imported the module! Has anyone got an idea why it is? Marcin From topmind at technologist.com Sun Mar 25 04:39:32 2001 From: topmind at technologist.com (topmind) Date: Sun, 25 Mar 2001 09:39:32 GMT Subject: Collection interfaces References: <3a90fa97.0@news1.mweb.co.za> <3A9A86B1.9A8C69A2@ix.netcom.com> <97fjla128ir@news2.newsguy.com> <97h5s40vhc@news2.newsguy.com> <97ibmc0k47@news1.newsguy.com> <97m0c7080c@news2.newsguy.com> <3AA2A898.450B659E@mail.com> <3AB755F8.67E84126@mail.com> <%a%t6.17245$227.1601569@newsread2.prod.itd.earthlink.net> <3AB8A730.4BE13D22@mail.com> <61bv6.8693$P4.676800@newsread1.prod.itd.earthlink.net> Message-ID: > > http://www.cincom.com:80/scripts/smalltalk.exe/gettingstarted/index.asp?cont > ent=trysmalltalknc > It seems to be wacked out right now. > Pardon the word wrapping my news client does. There's no spaces in the > above. > > That should get you to a place where you can download the lesson browser > (thanks again to Mark Windholtz, great job!) and the tutorial (thanks to Jim > F. as well). > Lesson browser download? The last thing I need is yet more foriegn software on my PC making it crash more and confusing other DLL's. Please, HTML. >...site runs on > Microsoft ASP VSscript instead of Smalltalk? > > Naw. Jim isn't afraid of anything. At least, nothing on Usenet! > > Me either :) > > The rest of the Cincom site, and the old Smalltalk portion of the site, does > indeed not run on Smalltalk. We'll get it all moved over eventually :) > > Heck, my own business unit, which is very into VisualWave, understands that > we have to use JavaScript on our pages to drive the browsers. There's > nothing wrong with being multi-lingual. > > > > > Do Chevy salesmen drive Fords? > > Some do. I work for Cincom and use both our Smalltalk products, I actually > prefer ObjectStudio when I'm doing Windows specific work, but I also have > Squeak and Dolphin around and have experimented with both. > > > -tmind- > > From fredp at mygale.org.nospam Thu Mar 22 08:04:09 2001 From: fredp at mygale.org.nospam (Fred Pacquier) Date: 22 Mar 2001 13:04:09 GMT Subject: Good Editor? References: <3ab9a32b$1_1@news2.one.net> Message-ID: nde at comp.leeds.ac.uk (Nick Efford) said : >> You don't mention the platform. Under Unix/Linux there are a number of >> options (including Vim, Emacs, etc.). Under Windows, I found WScite >> (http://www.scintilla.org) the easiest to get started with... > >vim and emacs run on Windows, too! So you can use one editor across >platforms as well as one programming language :) This is totally true, I should have been more precise. I didn't mean to say that these solutions weren't cross-platform, just that for a Windows-only beginner the Scite editor seemed easier to set up and offers good functionality. BTW, Scite also works with Linux/GTK... -- YAFAP : http://www.multimania.com/fredp/ From f8dy at diveintopython.org Sat Mar 10 16:04:14 2001 From: f8dy at diveintopython.org (Mark Pilgrim) Date: Sat, 10 Mar 2001 16:04:14 -0500 Subject: Private class and instance methods? In-Reply-To: <3AAA73BF.9CDCF3B2@alcyone.com> References: <3AAA73BF.9CDCF3B2@alcyone.com> Message-ID: in article 3AAA73BF.9CDCF3B2 at alcyone.com, Erik Max Francis at max at alcyone.com wrote on 3/10/01 1:34 PM: > How often do people use methods beginning with __ in order to get some > amount of privacy with the automatic name mangling that occurs, to get > some kind of weak protection, with, say, accessor methods: > > class C: > def __init__(self, x): > self.__x = x > > def getX(self): return self.__x > def setX(self, x): self.__x = x > > [which would of course allow C.getX and C.setX to do something different > in the future]? There is a better way to do this in Python, using the __getattr__ and __setattr__ special methods. class foo: privatekeys = ('x',) def __init__(self, x): self.x = x def __getattr__(self, key): print "getting private value %s" % key return self.__dict__['__%s' % key] def __setattr__(self, key, value): if key in self.__class__.privatekeys: print "setting private value %(key)s to %(value)s" % locals() self.__dict__['__%s' % key] = value else: self.__dict__[key] = value if __name__=='__main__': f = foo('abc') print "f.x = %s" % f.x f.y = [] print "f.y = %s" % f.y f.x = 10 print "f.x = %s" % f.x Running the example script produces this output (minus the comments): setting private value x to abc # from __init__ method getting private value x # from getting f.x in first print in main block f.x = abc # output of 1st print f.y = [] # output of 2nd print setting private value x to 10 # from setting f.x getting private value x # from getting f.x in 3rd print f.x = 10 # output of 3rd print There is no f.x (insert gratuitous reference to "The Matrix" here), because whenever you try to set it, Python calls __setattr__ and you end up setting f.__x instead, and whenever you try to get it, Python calls __getattr__ and you end up getting f.__x instead. f.y does exist, just like a normal public attribute. You can control which attributes are redirected by adding their names to the class attribute "privatekeys". More on special methods: http://diveintopython.org/fileinfo_specialmethods.html http://www.python.org/doc/current/ref/specialnames.html More on class attributes: http://diveintopython.org/fileinfo_classattributes.html Hope this helps. -M You're smart; why haven't you learned Python yet? http://diveintopython.org/ From spahievi at vega.bg Mon Mar 12 17:22:25 2001 From: spahievi at vega.bg (Niki Spahiev) Date: Tue, 13 Mar 2001 00:22:25 +0200 Subject: Packages, modules and exceptions In-Reply-To: <98ip5c$397$1@clematis.singnet.com.sg> References: <98ip5c$397$1@clematis.singnet.com.sg> Message-ID: <1514001711.20010313002225@vega.bg> 12.3.2001, 17:14:52, Ng Pheng Siong wrote: NPS> Hi, NPS> In M2Crypto, I have the following (abridged) directory structure: NPS> M2Crypto/ NPS> SSL/ NPS> __init__.py NPS> Connection.py NPS> Within M2Crypto/SSL/__init__.py, I have the following: NPS> class SSLError(Exception): pass Why not "class SSLError(StandardError)" so we can leave SystemExit alone. -- Best regards, Niki Spahiev From urner at alumni.princeton.edu Fri Mar 16 18:39:14 2001 From: urner at alumni.princeton.edu (Kirby Urner) Date: Fri, 16 Mar 2001 15:39:14 -0800 Subject: revamping K-12 math curriculum Message-ID: Exploring Integrated Math Topics + a Programming Language with an Eye towards Developing the Content of a Standard Pre-College Mathematics Curriculum by Kirby Urner March 15, 2001 [slightly revised from first draft on math-teach at the Swarthmore Math Forum ] I. CURRICULUM AS CONNECTED NETWORK OF "FABRICS" I've used this forum (math-teach) as a scratch pad for evolving some curriculum segments. A curriculum segment is a patch of related topics and activities that might be revisited at different levels of difficulty and sophistication. Another, perhaps better, word for a segment is a "fabric" or a "weave". There's an emphasis on achieving a kind of seamless blend of themes and patterns, which assists students wanting a sense of the big picture (overview is what seems to be lacking in a lot of current math teaching).[1] One example of a fabric is the whole patch of topics surrounding sequences and series, figurate numbers, polyhedra and Pascal's Triangle. Conway & Guy develop this weave in 'The Book of Numbers' (Springer-Verlag, 1996), whereas I'd independently hit on a similar approach in my 'Numeracy and Computer Literacy' series. I add the Buckminster Fuller element, with mention of the jitterbug transformation, geodesic spheres, viral protein sheaths and buckyballs.[2] Another example of a fabric blends topics from cryptology, probability and group theory. Here we develop the idea of a simple 'clubhouse code' based on letter substitution, and use this as a segue to the group theory concept of permutations, and multiplication as the composition of permutations. This framework allows us to discuss the properties of a group, in contrast to those of semi-groups, rings and fields. The next step is to use the new concepts to develop more sophisticated enciphering strategies, wherein the substitution dictionary continues to change throughout the encryption process. This provides a useful segue to historical threads, such as the storylines involving German U-boats, the Enigma code, Alan Turing and Bletchy Park ala Neal Stephenson's bestseller 'Cryptonomicon'.[3] Both of these fabrics contain material we could be phasing in as early as first or second grade... Fabric #1: Number and Geometry Sphere packing and polyhedra (built with tooth picks and little marshmellows, for example) are a popular topic with smaller kids (I know from experience -- and not just because of the marshmellows -- modeling clay works too). Euler's Law (V+F=E+2) makes sense to slightly older kids, as does Descartes' Deficit (720 degrees). The idea of triangular and square numbers, which may be modeled by packing spheres (as in 'Pool Hall Math' -- see math-teach archives), makes sense early too, with 'flat shaped numbers' becoming 'spatial' (my 'beyond flatland' theme) rather early in the game (ala 'The Book of Numbers'). Fuller's 10 F^2 +2, for the number of spheres in a cuboctahedral shell, identical to the number in an icosahedral shell, fits into this context. That the number of spheres is the same for both shapes is shown by the jitterbug transformation, which hyperlinks to phi (the cuboctahedron's square cross-sections transform into the icosahedron's golden rectangles) and provides a segue to virology, buckyball chemistry, crystalography and architecture.[4] Fabric #2: Permutations and Cryptology The idea of a 'clubhouse code' starts to make sense as soon as children have some mastery of the alphabet, and an understanding of why you might want to keep a message secret and therefore indecipherable by anyone but the intended recipient. Games of chance, ideas about probability, enter the picture here, explorable with polyhedral dice (not just hexahedra) -- note the hyperlink to Fabric #1 here. Using permutations to discuss the composition of functions makes sense at the middle school level, where we also should be developing the idea of modular arithmetic e.g. 240 mod 13. II. BEYOND CALCULATORS: PYTHON AS 'FIRST COMPUTER LANGUAGE' Aside from 'beyond flatland', another major theme promulgated by my Oregon Curriculum Network (a kind of Oriental Rug Factory for curriculum fabrics -- math-related especially), is 'beyond calculators'. Since the 1980s, programming languages have matured considerably, and since the 1990s we've had the option of teaching Python as a first language. The synergetic blend of procedural, functional, and object-oriented programming styles available through Python provides a good nucleus of concepts which will serve a student well when branching out to other languages later, whether in the direction of C/C++/Java, LISP/Scheme, or any of several other well-traveled pathways. Having some knowledge of a generic programming language, developing familiarity with it by coding around interwoven math topics, is going to yield many benefits later on in life. Early exposure (but not too early) lowers the chances of developing debilitating phobias later on, and gives students a vehicle for turning math topics into opportunities for exploration and portfolio-building (programs may be saved, revisited and improved over time). Using programs written in earlier classes to tackle topics in later classes helps provide a sense of continuity and relatedness -- something students need, but don't always get, in the current hodge-podge. In 'Numeracy + Computer Literacy', I use Fabric #1 to develop some graphical output capability, by synergizing Python with a ray tracer (I use POV-Ray and VRML plug-ins, but many other graphics applications would be suitable, plus there's the VPython option, permitting an even more interactive approach based on OpenGL). This link to computer graphics is likewise a segue to what I'll call Fabric #3, the weave on concepts relating coordinate systems, vectors, and geometric transformations as implemented by matrices or quaternions or some other apparatus (e.g. Clifford Algebra). Fabric #3 is where we use object-oriented programming to explore the Gibbs-Heaviside vector operations, bringing in trigonometric functions, rotation matrices and so on -- all of which makes more sense and is a lot more fun when one is rewarded with colorful, shadowed, perspective renderings, such as POV-Ray (or other software) provides (such colorful renderings might be transferred to T-shirts for those so inclined). III. TRAVERSING THE NET: FROM CRYPTOGRAPHY TO CALCULUS With Fabric #2, students will be able to encipher and decipher text files, using their newfound/maturing computer language skills. Given the opportunity is to encipher random passages, we have more opportunities to jump outside the math domain and capture topical paragraphs from other points in the curriculum. For example, we might choose to encipher Lincoln's Gettysberg Address, or a speech by Martin Luther King. If students are on a network, they can practice passing ciphertext and secret keys back and forth. Some educators may object to this focus on cryptography at an early age, suggesting that students will misuse this knowledge. However, my experience is that many in 8th grade and above develop this interest on their own, picking up memes from popular culture, and, since this material is "avoided" in school, they develop the impression that cryptography is something the "establishment" is against, i.e. this knowledge takes on a "subversive" spin. This is unfortunate, and it would be better if the schools worked in a more empowering mode, to help students develop skills and knowledge which is part of the mainstream commercial environment and net-based ecosphere. Cryptography is not inherently "subversive" -- unless we craft an environment which makes it seem that way (which, perhaps inadvertently, is where we are today, in many school districts).[5] The group theory aspect of permutations (as applied to cryptography) segues nicely to other kinds of group, such as sets of postivie integers less than and relatively prime to some modulus (this is why modulo arithmetic was important). We can talk about CAIN (closure, associative, inverse, neutral element) and Abel(ian) groups. The notion of coprimes segues to Euler's totient function, and Euler's Theorem, of which Fermat's Little Theorem is a special case -- more topics typically covered in group theory with applications to cryptography, in that huge primes are hard to "crack" into factors (what makes RSA and some other public key systems effective). Thanks to Python, we have access to big numbers (long integers) and don't have to suffer the trade-offs that plagued earlier "math through programming" forays into this realm (i.e. we don't trade away access to big numbers just because we choose to use a generic programming language, and not a strictly math-focussed or number theoretic package).[6] We can loop back to Fabric #1 and talk about symmetry groups and polyhedra, or the group properties of quaternions under multiplication. All of these concepts will have been developed concretely, in a hands-on, interactive context, using a computer language (I prefer Python) by the end of high school. The result will be a more sophistacted and non-math-phobic mindset among students, who have a well-connected set of math- related concepts and a feel for the bigger picture. I haven't forgotten the calculus, and will simply point out that we have a good basis for exploring limits starting with Fabric #1, with phi and Fibonacci numbers in particular (with a link between phi and the fractal-like, recursive nature of phi-based five-fold symmetric geometries). Fabric #1 was a lot about Sigma and Pi (summations and products of a sequences respectively), and about differences between successive terms in a sequence, the discrete math analog of the differential. With Fabric #3 (graphics/vectors), we have the standard graphing calculator topics of (x,f(x)) and might explore the calculus of the catenary for example (suspension bridges and electrical wires have this shape), which will include mention of hyperbolic trig functions. I can talk more about Fabric #4 in another post.[7] Kirby [1] these 'fabric' terminology is borrowed from memetics as embodied in Fluidiom, which is also an elastic interval geometry application (http://www.fluidiom.com/) [2] http://www.inetarena.com/~pdx4d/ocn/numeracy0.html [3] http://www.inetarena.com/~pdx4d/ocn/clubhouse.html http://mail.python.org/pipermail/edu-sig/2001-March/001077.html [4] Jay Kappraff's, Connections, the geometric bridge between art and science (McGraw-Hill, 1996) is also good on the root(2)-based vs. phi-based aesthetics. For an animated GIF of the jitterbug, see "Getting Inventive with Vectors" http://www.inetarena.com/~pdx4d/ocn/numeracy1.html [5] Teachers might want to use the relevance/importance of a cryptographic "fabric" as an argument for bringing more powerful computing platforms into math classrooms, vs. "making do" with less suitable calculators for this purpose. For more along these lines, see my post to k12.math.teach: http://www.mathforum.com/epigone/k12.ed.math/glaterdphum/ [6] here's a post to math-learn quoting an earlier curriculum writer who had to contend with this trade-off: http://groups.yahoo.com/group/math-learn/message/217 [7] or see http://www.inetarena.com/~pdx4d/ocn/catenary.html From greg at cosc.canterbury.ac.nz Thu Mar 1 19:40:38 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 02 Mar 2001 13:40:38 +1300 Subject: Best way to string compare a python object in a getattrofunc? References: Message-ID: <3A9EEC06.2180834D@cosc.canterbury.ac.nz> Cayce Ullman wrote: > I am > thinking about interning the string "spam" on module initialization, then > saving that pointer somewhere, and then just comparing the pointers on every > fetch. Interning your string on initialisation is a good idea, BUT you should use PyObject_Compare() to compare it with other strings. If the string you're comparing it with also happens to be interned, PyObject_Compare() will do a pointer comparison, otherwise it will use strcmp(). So you'll get the benefits of interning where possible, while still doing the right thing in other cases. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From fredrik at pythonware.com Tue Mar 20 02:26:38 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 20 Mar 2001 07:26:38 GMT Subject: What IDE are you'all using for Python 2.1 for Windows? References: <995gai$2bv$1@news.chatlink.com> <995in5$22s$1@panix2.panix.com> Message-ID: Luis Cortes wrote: > Just wanted to know what "good" ide's are out there for python. Please > let me know which ones you prefer. pythonworks 1.2 (but I supposed I'm biased ;-) http://www.pythonware.com/products/works Cheers /F From zalivin at krona.obninsk.ru Mon Mar 12 18:16:26 2001 From: zalivin at krona.obninsk.ru (Alexei Zalivine) Date: Tue, 13 Mar 2001 02:16:26 +0300 Subject: IPC module Message-ID: <984438966.381139@basic.maxnet.ru> Hello, Please help me to compile shm module for linux. I'm not a C programmer, and I can't understand errors from compiler. You can get the source from http://sirac.inrialpes.fr/~marangoz/python/shm/ Are there other IPC modules for Python? Thank you, Alexei. From kalle at gnupung.net Wed Mar 21 17:52:41 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Wed, 21 Mar 2001 23:52:41 +0100 Subject: Simple regex that has me banging my head against a wall In-Reply-To: <20010321143144.K24341@trufflehunter.avalongroup.net>; from tjg@exceptionalminds.com on Wed, Mar 21, 2001 at 02:31:44PM -0800 References: <20010321143144.K24341@trufflehunter.avalongroup.net> Message-ID: <20010321235241.D807@apone.network.loc> Sez Timothy Grant: > Hi again. > > I actually thought I had this regex thing down pretty well, but > I'm getting beat up by what I thought should be a simple one. > > >>> x = '$1$asdfjke$lkjasdkjfsdasdfj' > >>> re.sub(r'\$', r'\\\$', x) One \ too many, it seems. The second argument to re.sub is not a regex, so you don't have to escape the $. > '\\\\$1\\\\$asdfjke\\\\$lkjasdkjfsdasdfj' > > All I want to do is substitute \$ for $. Peace, Kalle -- Email: kalle at gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From fredrik at pythonware.com Fri Mar 16 11:59:14 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 16 Mar 2001 16:59:14 GMT Subject: redefining stdout References: <3AB240E4.1EB6E144@dvinc.com> Message-ID: Mark Limber wrote: > However, when I try: > > >>> import sys > >>> import t # short file names = less typing! > >>> sys.stdout = t.myPrint >>> sys.stdout = t.myPrint() > >>> print "hey" > Traceback (most recent call last): > File "", line 1, in ? > TypeError: unbound method must be called with class instance > 1st argument Cheers /F From loewis at informatik.hu-berlin.de Wed Mar 14 06:05:54 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 14 Mar 2001 12:05:54 +0100 Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> <3aad4485.2348499@News.CIS.DFN.DE> Message-ID: Andrew Koenig writes: > I'm curious -- Does Python now follow either the IEEE or the more > restrictive Scheme rules for floating-point conversion? Somebody explained already that this is deferred to the underlying C system. To be more specific, Python 2.0 - uses C double to represent floating point numbers - when representing them as strings, uses the %.17g sprintf format, the commentary in the code says The repr() precision (17 significant decimal digits) is the minimal number that is guaranteed to have enough precision so that if the number is read back in the exact same binary value is recreated. This is true for IEEE floating point by design, and also happens to work for all other modern hardware. - uses strtod when converting a string to a double. So, I think if you have a C99 compiler that defines __STDC_IEC_559__, then the answer to your question is yes. In all other cases, the answer is 'probably yes'. Regards, Martin From cfelling at iae.nl Sun Mar 11 10:37:13 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 11 Mar 2001 16:37:13 +0100 Subject: map - lambda - problem References: <3AAB6078.EE50AE8D@aon.at> Message-ID: <98g639$32f$1@animus.fel.iae.nl> Gregor Lingl wrote: ... > In direct mode I got: >>>> r = [] >>>> for i in range(len(n[0])-1,-1,-1): > r.append(map(lambda x: x[i],n)) ... > If i put this into a function: > def rotate(piece): > r = [] > for i in range(len(piece[0])-1,-1,-1): > r.append(map(lambda x: x[i], piece)) > return r ... > Why, exactly, this behaviour. Is i now taken from some other namespace? Bingo, you got it! Python used to know only three scopes: local, global and builtin. And lambda starts a new local scope, hiding rotate's local scope. Newer versions of Python have nested function-scope, that is within functions/lambdas scopes nest. The work around used to be to pass the needed local vars explicitly to the function/lambda like: def rotate(piece): r = [] for i in range(len(piece[0])-1,-1,-1): r.append(map(lambda x, i=i: x[i], piece)) return r You can do the same with named functions, like: def rotate(piece): r = [] for i in range(len(piece[0])-1,-1,-1): def sub(x, i=i): return x[i] r.append(map(sub, piece)) return r Or you could forgo that local i alltogether, like: def rotate(piece): r = apply(map, (None,) + list(piece)) r.reverse() return r -- groetjes, carel From donotreply at interbulletin.bogus Thu Mar 8 13:46:12 2001 From: donotreply at interbulletin.bogus (Rob Earl) Date: Thu, 08 Mar 2001 18:46:12 +0000 Subject: cursor.execute fails under mxODBC References: Message-ID: <3AA7D374.7C72D4B2@interbulletin.com> "Steve Holden" wrote in article : > wrote in message >news:mailman.983993842.26448.python-list at python.org... >> I just upgraded to the latest version of mxODBC. Calling execute on a >> cursor object is hosing python. This code worked perfectly under 1.5.1 >> and version 1.1.1 of mxODBC. >> >> Having trouble on both Win98 and Win2000. >> >> I can stay on windows, so I'm gonna give ADO a try, but I'd still like >> to know what's going on. >> >> Thanks, >> >> Bill >> >So would we! What error messages are you seeing, form what code? > >regadrs > Steve > > > I have experienced something very similiar. On my system running Windows 2000 the execute on a cursor object never completes. Instead python takes 100% of the CPU and just sits there. I haven't been able to find any logs that might help, but maybe I'm not looking in the right place. Could you tell me where I should look? Also, just so you are aware I'm using ActivePython not just the regular Python. Thanks, Rob _______________________________________________ Submitted via WebNewsReader of http://www.interbulletin.com From scarblac at pino.selwerd.nl Thu Mar 29 15:24:59 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 29 Mar 2001 20:24:59 GMT Subject: setvbuf() ?? References: <3AC29961.9937EC59@ucdavis.edu> Message-ID: Bruce Wolk wrote in comp.lang.python: > Putting a trailing comma after the print statement eliminates the newline, but > adds a trailing space. Would periods separated by spaces work? > > I would be curious if anyone knows how to eliminate the trailing space. Either use sys.stdout.write() instead of print, or set sys.stdout.softspace to 0 after the print command. -- Remco Gerlich From vlindberg at verio.net Mon Mar 26 20:36:25 2001 From: vlindberg at verio.net (VanL) Date: Mon, 26 Mar 2001 18:36:25 -0700 Subject: ftplib and zipfile question Message-ID: <3ABFEE99.F5301392@verio.net> Hello, I am writing a program to download something from an ftp site. I have checked the ftplib documentation and I know that I need the retrbinary command. However, the docs say: retrbinary (command, callback[, maxblocksize[, rest]]) Retrieve a file in binary transfer mode. command should be an appropriate "RETR" command, i.e. 'RETR filename'. The callback function is called for each block of data received, with a single string argument giving the data block .... What is the callback command? Could anyone give an example of the use of this command to download a file and save it locally? Further, does python have anything like the Unix pipe? The file in question is a zip file. If possible, I would rather just pipe it through to the zipfile module. In short, is this possible? ++++++++++++++++++++++++++++++++++++++ import zlib, zipfile from ftplib import FTP ftp = FTP('mysite.com', 'anonymous', 'me at myaddress.com') ftp.cwd('newdir') myzip = Zipfile((ftp.retrbinary('binaryfile.zip', OTHER_ARGS_HERE), 'r') for filename in myzip.namelist: file = open(filename, 'w') file.write(myzip.read(filename)) ftp.close() +++++++++++++++++++++++++++++++++++++++++ If possible, I would like to process the file as it goes through, without either incurring huge memory usage or having to save the file to disk. If I have to choose one or the other, tho, I would store the file to disk. From shaleh at valinux.com Fri Mar 2 17:34:29 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Fri, 02 Mar 2001 14:34:29 -0800 (PST) Subject: gah! I hate the new string syntax In-Reply-To: <97p3sa$bpq$1@tyfon.itea.ntnu.no> Message-ID: On 02-Mar-2001 Magnus Lie Hetland wrote: > "Sean 'Shaleh' Perry" wrote in message > news:mailman.983551204.27573.python-list at python.org... > [...] >> The point of all of this was 'join' especially, >> but a few of the others (it >> brother split) make for really ugly code. >> >> " ".split(list) is another I have seen recently. >> > > What does *this* mean, then? (AFAIK it isn't valid > Python unless list is a character...) > it was a snippet of code I saw somewhere. It turns out the person has it backwards (thankfully). The actual code would be: s = 'This is a string' s.split(" ") which makes some amount of sense, although I still like the string module version better. From sholden at holdenweb.com Mon Mar 5 22:52:20 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 5 Mar 2001 22:52:20 -0500 Subject: PIL and Windows file formats? References: <3AA45311.150DB844@alcyone.com> Message-ID: "Erik Max Francis" wrote in message news:3AA45311.150DB844 at alcyone.com... > I installed Python 2.0 and PIL for Python 2.0 on my machine and am > trying to manipulate images. I try to open a (valid) PNG image (with a > standard .png file extension) with PIL.Image.open and get a "cannot > identify image type" error. I then debug through PIL.Image.py only to > discover, much to my surprise, the only formats it seems to know about > (in PIL.Image.ID) are GIF, JPEG, and TIFF. > > Any idea what in the world is going on here? > Nope. My PIL directory has a pngImagePlugin.py file. Does yours? Would this make any difference? regards Steve From aahz at panix.com Fri Mar 9 10:28:58 2001 From: aahz at panix.com (Aahz Maruch) Date: 9 Mar 2001 07:28:58 -0800 Subject: gah! I hate the new string syntax References: <98amlj01sp6@news2.newsguy.com> Message-ID: <98asrq$645$1@panix6.panix.com> In article <98amlj01sp6 at news2.newsguy.com>, Alex Martelli wrote: >"Steve Holden" wrote in message >news:BcCp6.37817$1D5.1582482 at e420r-atl1.usenetserver.com... > [snip] >> > | > What about one who is both English and Scots, yet never set foot on >> > | > that island ;-)? > [snip] >> Either you were born in England, or you were born in Scotland, or you are >> neither English nor a Scot. Part-either-or-both, maybe, but not fully > >Wrong! You're talking about people whose seafaring skills and >traditions are (deservedly) legendary. It's perfectly acceptable >for either an English or a Scot to be born aboard a ship...!!! Since when are *women* allowed aboard ships? -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "..., and some of you may regard all women as evil traps that exist only to tease, torture, and suck out your very soul." --DrMax From jwbnews at scandaroon.com Thu Mar 15 10:39:05 2001 From: jwbnews at scandaroon.com (John W. Baxter) Date: Thu, 15 Mar 2001 07:39:05 -0800 Subject: This math scares me References: <20010312170356.B3513@better.net> <984486395.407379@newsmaster-04.atnet.at> <984518199.127140@newsmaster-04.atnet.at> <98ohuc$du9$1@news.udel.edu> <7bQr6.644$lz1.17686@ruti.visi.com> <98oku1$f6a$1@news.udel.edu> Message-ID: Had our Noble Ancestors believed their thumbs to be Sacred, and not to be used for counting or other Profane Purposes, we wouldn't be having these Problems. [Surely, another set of problems would have arisen to take their place.] --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From aleaxit at yahoo.com Fri Mar 16 08:46:13 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 16 Mar 2001 14:46:13 +0100 Subject: Cookies References: Message-ID: <98t5f60lb7@news1.newsguy.com> "Martin Skott" wrote in message news:lmq6m07j.fsf at propylon.com... [snip] > You should first of all be aware that there is no common unique > identifier for a computer available from the net today[1]. IP [snip] > [1]Why would somebody use cookies if there was? Because cookies are more powerful -- they let you associate state with, e.g., several different _users_ on a single computer, rather than 'that computer as a whole'. (That was a trick question, right?-) Alex From dbrueck at edgix.com Wed Mar 14 09:49:37 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Wed, 14 Mar 2001 07:49:37 -0700 Subject: "Scary Math" Solver Message-ID: Sorry if somebody already point this out but... If it shakes your faith to know that many floating point numbers can't be stored without slight rounding errors, in Python 2.1 you can always do this to change how things work in interactive mode: >>> 5.3 5.2999999999999998 # HELP! SAVE ME!!! >>> def printstr(s): >>> print str(s) >>> import sys >>> sys.displayhook = printstr >>> 5.3 5.3 # I BELIEVE!!! And you could modify printstr so that other data types still use repr. -Dave From ixokai-nf at myNOSPAM.org Thu Mar 29 05:34:24 2001 From: ixokai-nf at myNOSPAM.org (Ixokai) Date: Thu, 29 Mar 2001 02:34:24 -0800 Subject: types.AnyType - describing interfaces with sequences of types References: Message-ID: <3ac31215$1_6@goliath.newsfeeds.com> The reason there is no UserType is because Types are the exclusive domain of the C side of Python. Under normal circumstances, extentions/additions of this nature in C end up making "types", while extentions/additions in Python end up making Classes, which are not, under normal circumstances, able to be made in C. This is my understanding, at least. The missing behavior that you wish is a result of the fact that Classes and Types really don't have that much in common yet... Sure, some types have wrappers around them, but there is no ultimate ancestor that is available... The problem is, I think, is that there really is no functionality to wrap in a 'TypeType'. And until classes and types get all combined into the same thing, where you'd then have an ultimate ancestor to inherit from and compare to, I don't think you'll get a way to do what you want exactly like you want. Then again, I may be talking out of my ass. I'm a semi newbie who just lurks forever. :) --Ix (Replace 'NOSPAM' with 'seraph' to respond in email) Carlos Alberto Reis Ribeiro wrote in message ... >At 02:56 28/03/01 -0800, you wrote: >>You get the idea. AnyType above will be eternally happy to be equivelent to >>anything you compare it to. Note that you can't do 'IntType is AnyType', >>that tells you actual object identity. Now, if you wanted it to only show up >>as 'equivelent' to TypeTypes, and not say, strings, (e.g. "string" == >>AnyType) you could do a check to make sure what its being compared to is a >>TypeType..... > >My first instinct it was to do something like this. However, it did not >work, but because of a dumb mistake of mine :-) I tried again now, and this >is the resulting code: > >class CAnyType: > def __cmp__(self, other): > return (type(other) != TypeType) > def __rcmp__(self, other): > return (type(other) != TypeType) > >AnyType = CAnyType() > >That was my fault - I was trying to compare the class to IntType, but I >need an instance for the code to work. > >Anyway, I felt that should be a better way to make it, maybe be inheriting >from some "UserType" object. However no such object exists. I don't know if >"UserType" does not exist because it not make sense, or if it does not >exist simply because no one else required it before. The way it is, it's >inconsistent, because: > > >>> type(AnyType) # should return "TypeType" > > > > >Carlos Ribeiro > > > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From shwang5 at students.uiuc.edu Tue Mar 20 14:59:08 2001 From: shwang5 at students.uiuc.edu (seung-won hwang) Date: Tue, 20 Mar 2001 13:59:08 -0600 Subject: Thread join example Message-ID: Hello, I am looking for a code example which contains thread join. I would appreciate your help very much! Thanks! From whisper at oz.net Thu Mar 29 15:24:17 2001 From: whisper at oz.net (Dave LeBlanc) Date: 29 Mar 2001 20:24:17 GMT Subject: Which Python version is better on Win32 References: <20010329.3014838@mis.configured.host> Message-ID: <9a05lh$ovk$0@216.39.170.247> As far as I know, PythonWin isn't a full Python distribution, it's a (large) add-on which, the last time I looked, is still available in source from Mark Harrison's CVS. I think you can find it via either The Vaults of Parnassus or ActiveState's site. The only real varient I know of with respect to Python is Stackless Python (which is supposedly about 10% faster, at least on Windows). Dave LeBlanc On Wed, 28 Mar 2001 22:40:27 -0500, "Steve Holden" wrote: >"TM" wrote in message >news:20010329.3014838 at mis.configured.host... > >> I've seen recently that yhere were several releases of Python for the MS >> Windows platform: >> ActivePython is one of them there's also PythonWin which is not branded, >> beOpenPython and maybe others. >> >> Which one would you advise me to use and why? > >BeOpen Python is the standard 2.0 release, as built by the development team >while they were working at BeOpen (which looks, by the way, as though it >might now BeClosed). > >PythonWin is actually just one component of ActiveState's ActivePython >distribution. Unless anyone can tell you any better, it bundles BeOpen >Python with a huge set of add-on goodies devised and produced mostly by Mark >Hammond. > >IMHO you would be best advised to go for ActivePython unless you >specifically want a small installation with just the Python language core on >it. > >regards > Steve > > > From p.herth at uni-koeln.de Wed Mar 7 16:53:02 2001 From: p.herth at uni-koeln.de (Peter Herth) Date: 07 Mar 2001 22:53:02 +0100 Subject: National Intruments GPIB References: <3AA46593.753BAE1@newfocus.com> Message-ID: "Tim Hochberg" writes: > I have a simple interface to NI44.2 GPIB that I wrote. I'll send you a copy > via private email to avoid cluttering C.L.P. And if anyone else needs a > copy, let me know. You're welcome to use it as a starting point. > I would be very interested in it too, since I considered doing something likewise too, getting fed up with using C for GPIB work... Peter From no at thank.you Fri Mar 30 10:55:45 2001 From: no at thank.you (Owen Ap Owen) Date: Fri, 30 Mar 2001 07:55:45 -0800 Subject: mxODBC chokes on dates! Any Help? Message-ID: I'm using mxODBC from Python 2.0 under Win32. I have a functional ODBC connection but when I try to select data that includes date fields mxODBC chokes. Here's what I'm doing. >>> import mx.ODBC.Windows >>> import mx.DateTime >>> conn = mx.ODBC.Windows.connect('JTech',user='tech',password='tech') >>> cur = conn.cursor() >>> cur.execute('SELECT jci_num, test_date, weight, standard_25 FROM zwick_data') >>> from pprint import pprint >>> pprint(cur.description) (('jci_num', 12, None, None, 30, 0, 0), ('test_date', 11, None, None, 23, 3, 1), ('weight', 5, None, None, 5, 0, 1), ('standard_25', 6, None, None, 15, 0, 1)) >>> data = cur.fetchall() Traceback (innermost last): File "", line 1, in ? InternalError: ('S1003', 0, '[Microsoft][ODBC Driver Manager] Program type out of range', 3013) I've tried this using three seperate ODBC dsn connections. In every case I get a "Program type out of range" error whenever I try to select any data that includes a date field. If I connect to the ODBC connection using any other method besides mxODBC I can fetch the date fields without a problem. Am I missing something obvious? Any suggestions? From dsh8290 at rit.edu Wed Mar 7 20:18:03 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 7 Mar 2001 20:18:03 -0500 Subject: gah! I hate the new string syntax In-Reply-To: ; from sholden@holdenweb.com on Wed, Mar 07, 2001 at 07:15:48PM -0500 References: Message-ID: <20010307201803.A277@harmony.cs.rit.edu> On Wed, Mar 07, 2001 at 07:15:48PM -0500, Steve Holden wrote: | "D-Man" wrote in message | news:mailman.983997252.5628.python-list at python.org... | > On Sat, Mar 03, 2001 at 03:19:05PM -0500, Steve Holden wrote: | [ ... ] | > | > What about one who is both English and Scots, yet never set foot on | > that island ;-)? | > | No such animal! Oh. Am I a bot too? If so I must find a new maintainer so I can match the intelligence of the other bots on the list. ;-) -D From sheila at spamcop.net Mon Mar 26 08:56:45 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 26 Mar 2001 13:56:45 GMT Subject: How to set PYTHONHOME ??? References: <3ABF2743.ED5904F2@bevoux.grenoble.hp.com> Message-ID: On Mon, 26 Mar 2001 12:25:55 +0100, Philippe Rodriguez wrote in comp.lang.python in article <3ABF2743.ED5904F2 at bevoux.grenoble.hp.com>: :I'm running Python 1.6 on hpux 10.20. I got the standard depot binary :release. : :Each time I'm trying to run Python, I have the following message : :--- :Could not find platform dependent libraries :Consider setting $PYTHONHOME to [:] :--- :I have set this to every conceivable option I can think of, but it still :complains. :The program seems to be OK, but my tool which use python runs a cron :every minutes : ans so I'm receiving a message every minute ... boring ! Yes, I have seen this error. It seems that the install is looking for files in a place where you do not have them. While the best solution is a reinstall, if you cannot do that, there is also a way to set the Python Path. This link http://www.aota.net/ubb/Forum3/HTML/001564-1.html leads to a discussion board where I was seeking help, and also has links to other places where I went for help. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From fredrik at pythonware.com Tue Mar 20 12:29:23 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 20 Mar 2001 17:29:23 GMT Subject: re.match References: <997skf$qoc$1@bmerhc5e.ca.nortel.com> Message-ID: Michael P. Soulier wrote: > Hey people. Could someone explain the purpose of the match function in the > re module? If it's only difference from search is to match at the beginning of > the line, why does it exist? That's what the ^ in the regexp is for. no, it's not. read the documentation again. Cheers /F From mda at idatar.com Sat Mar 31 17:04:30 2001 From: mda at idatar.com (David Allen) Date: Sat, 31 Mar 2001 22:04:30 GMT Subject: Newbie Dictionary Question References: Message-ID: In article , "Gary Walker" wrote: > Actually, they don't have to be ordered, so I suppose (thinking aloud here) > that I could use a dictionary of dictionaries, but again - it seems to me > that I'd need to dynamically create a dictionary whose name isn't known > until runtime... A dictionary of dictionaries doesn't sound like too bad of an idea. Each "key" in the toplevel dictionary would be the name of another dictionary. In that way, since keys are just strings, you can have a bunch of dictionaries with variable names. Like: metadict = {} # Empty top level dictionary user_input = get_user_input() metadict[user_input] = {} Now you can populate metadict[user_input] with a bunch of keys and values. User_input might be something from the user or more broadly just anything that isn't know until runtime. (Like the value of a config varaible or whatever) -- David Allen http://opop.nols.com/ ---------------------------------------- It's that time of year again, Defcon has descended upon us. Time to venture to SYN City to see the lights, meet strange new people, and create new blurs we later dub memories. -- Attrition.org From rdsteph at earthlink.net Tue Mar 27 21:13:16 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Wed, 28 Mar 2001 02:13:16 GMT Subject: Completing the thread with latest program versions References: <3ABCC757.6C6F17CA@earthlink.net> <3ABE73B2.CAFCA177@student.liu.se> Message-ID: <3ABFEC14.BD3B0709@earthlink.net> In the interest of completeness of the this thread, here is my latest corrections and updates of my first Python program (DecisionAnalysisBeta143.py) and a proposed GUI front end coded for me today by another email correspondent (decisionaaron.py) in Tkinter. I have not interfaced them yet. (Need to learn how to do that too ;-))) Thanks to all form my newbieness. Also don't forget to see Mr. Jeff Elper'ss version of my idea below (he did in about 65 lines plus comments what I took almost 400 lines to do so far ;-))))) From jmarshal at mathworks.com Mon Mar 19 14:51:58 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 19 Mar 2001 19:51:58 GMT Subject: Python style questions References: <98tb91$9t9$1@saltmine.radix.net> Message-ID: <995o0u$itc$1@news.mathworks.com> Michael Hudson wrote: > cobrien at Radix.Net (Cary O'Brien) writes: ... > The scoping can get a bit counter-intuitive >> 3. I really miss not having a "switch" or "case" statement. Sniff. > -- > 3. Syntactic sugar causes cancer of the semicolon. > -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html A switch statement may just be syntactic sugar, but not necessarily in a simple way. A good compiler will compile switch statements into jump-tables or, at worst, binary searches. Cluttery to code by hand. Sure this is "just" an efficiency thing, but switches can get quite big. From cce at clarkevans.com Thu Mar 22 05:14:25 2001 From: cce at clarkevans.com (Clark C. Evans) Date: Thu, 22 Mar 2001 05:14:25 -0500 (EST) Subject: PEP 1, PEP Purpose and Guidelines In-Reply-To: <15032.59269.4520.961715@anthem.wooz.org> Message-ID: Barry, If you don't mind, I'd like to apply for one of them there PEP numbers. Sorry for not following the guidelines, it won't happen again. Also, I believe that this isn't just my work, but rather a first pass at concensus on this issue via the vocal and silent feeback from those on the main and type special interest group. I hope that I have done their ideas and feedback justice (if not, I'm sure I'll hear about it). Thank you so much, Clark ... PEP: XXX Title: Protocol Checking and Adaptation Version: $Revision$ Author: Clark Evans Python-Version: 2.2 Status: Draft Type: Standards Track Created: 21-Mar-2001 Updated: 23-Mar-2001 Abstract This proposal puts forth a built-in, explicit method for the adaptation (including verification) of an object to a context where a specific type, class, interface, or other protocol is expected. This proposal can leverage existing protocols such as the type system and class hierarchy and is orthogonal, if not complementary to the pending interface mechanism [1] and signature based type-checking system [2] This proposal allows an object to answer two questions. First, are you a such and such? Meaning, does this object have a particular required behavior? And second, if not, can you give me a handle which is? Meaning, can the object construct an appropriate wrapper object which can provide compliance with the protocol expected. This proposal does not limit what such and such (the protocol) is or what compliance to that protocol means, and it allows other query/adapter techniques to be added later and utilized through the same interface and infrastructure introduced here. Motivation Currently there is no standardized mechanism in Python for asking if an object supports a particular protocol. Typically, existence of particular methods, particularly those that are built-in such as __getitem__, is used as an indicator of support for a particular protocol. This technique works for protocols blessed by GvR, such as the new enumerator proposal identified by a new built-in __iter__. However, this technique does not admit an infallible way to identify interfaces lacking a unique, built-in signature method. More so, there is no standardized way to obtain an adapter for an object. Typically, with objects passed to a context expecting a particular protocol, either the object knows about the context and provides its own wrapper or the context knows about the object and automatically wraps it appropriately. The problem with this approach is that such adaptations are one-offs, are not centralized in a single place of the users code, and are not executed with a common technique, etc. This lack of standardization increases code duplication with the same adapter occurring in more than one place or it encourages classes to be re-written instead of adapted. In both cases, maintainability suffers. In the recent type special interest group discussion [3], there were two complementary quotes which motivated this proposal: "The deep(er) part is whether the object passed in thinks of itself as implementing the Foo interface. This means that its author has (presumably) spent at least a little time about the invariants that a Foo should obey." GvR [4] and "There is no concept of asking an object which interface it implements. There is no "the" interface it implements. It's not even a set of interfaces, because the object doesn't know them in advance. Interfaces can be defined after objects conforming to them are created." -- Marcin Kowalczyk [5] The first quote focuses on the intent of a class, including not only the existence of particular methods, but more importantly the call sequence, behavior, and other invariants. Where the second quote focuses on the type signature of the class. These quotes highlight a distinction between interface as a "declarative, I am a such-and-such" construct, as opposed to a "descriptive, It looks like a such-and-such" mechanism. Four positive cases for code-reuse include: a) It is obvious object has the same protocol that the context expects. This occurs when the type or class expected happens to be the type of the object or class. This is the simple and easiest case. b) When the object knows about the protocol that the context requires and knows how to adapt itself appropriately. Perhaps it already has the methods required, or it can make an appropriate wrapper c) When the protocol knows about the object and can adapt it on behalf of the context. This is often the case with backwards-compatibility cases. d) When the context knows about the object and the protocol and knows how to adapt the object so that the required protocol is satisfied. This proposal should allow each of these cases to be handled, however, the proposal only concentrates on the first two cases; leaving the latter two cases where the protocol adapts the object and where the context adapts the object to other proposals. Furthermore, this proposal attempts to enable these four cases in a manner completely neutral to type checking or interface declaration and enforcement proposals. Specification For the purposes of this specification, let the word protocol signify any current or future method of stating requirements of an object be it through type checking, class membership, interface examination, explicit types, etc. Also let the word compliance be dependent and defined by each specific protocol. This proposal initially supports one initial protocol, the type/class membership as defined by isinstance(object,protocol) Other types of protocols, such as interfaces can be added through another proposal without loss of generality of this proposal. This proposal attempts to keep the first set of protocols small and relatively unobjectionable. This proposal would introduce a new binary operator "isa". The left hand side of this operator is the object to be checked ("self"), and the right hand side is the protocol to check this object against ("protocol"). The return value of the operator will be either the left hand side if the object complies with the protocol or None. Given an object and a protocol, the adaptation of the object is: a) self, if the object is already compliant with the protocol, b) a secondary object ("wrapper"), which provides a view of the object compliant with the protocol. This is explicitly vague, and wrappers are allowed to maintain their own state as necessary. c) None, if the protocol is not understood, or if object cannot be verified compliant with the protocol and/or if an appropriate wrapper cannot be constructed. Further, a new built-in function, adapt, is introduced. This function takes two arguments, the object being adapted ("obj") and the protocol requested of the object ("protocol"). This function returns the adaptation of the object for the protocol, either self, a wrapper, or None depending upon the circumstances. None may be returned if adapt does not understand the protocol, or if adapt cannot verify compliance or create a wrapper. For this machinery to work, two other components are required. First is a private, shared implementation of the adapt function and isa operator. This private routine will have three arguments: the object being adapted ("self"), the protocol requested ("protocol"), and a flag ("can_wrap"). The flag specifies if the adaptation may be a wrapper, if the flag is not set, then the adaptation may only be self or None. This flag is required to support the isa operator. The obvious case mentioned in the motivation, where the object easily complies with the protocol, is implemented in this private routine. To enable the second case mentioned in the motivation, when the object knows about the protocol, a new method slot, __adapt__ on each object is required. This optional slot takes three arguments, the object being adapted ("self"), the protocol requested ("protocol"), and a flag ("can_wrap"). And, like the other functions, must return an adaptation, be it self, a wrapper if allowed, or None. This method slot allows a class to declare which protocols it supports in addition to those which are part of the obvious case. This slot is called first before the obvious cases are examined, if None is returned then the default processing proceeds. If the default processing is wrong, then the AdaptForceNoneException can be thrown. The private routine will catch this specific exception and return None in this case. This technique allows an class to subclass another class, but yet catch the cases where it is considered as a substitutable for the base class. Since this is the exception, rather than the normal case, an exception is warranted and is used to pass this information along. The caller of adapt or isa will be unaware of this particular exception as the private routine will return None in this particular case. Please note two important things. First, this proposal does not preclude the addition of other protocols. Second, this proposal does not preclude other possible cases where adapter pattern may hold, such as the protocol knowing the object or the context knowing the object and the protocol (cases c and d in the motivation). In fact, this proposal opens the gate for these other mechanisms to be added; while keeping the change in manageable chunks. Reference Implementation and Example Usage ----------------------------------------------------------------- adapter.py ----------------------------------------------------------------- import types AdaptForceNoneException = "(private error for adapt and isa)" def interal_adapt(obj,protocol,can_wrap): # the obj may have the answer, so ask it about the ident adapt = getattr(obj, '__adapt__',None) if adapt: try: retval = adapt(protocol,can_wrap) # todo: if not can_wrap check retval for None or obj except AdaptForceNoneException: return None if retval: return retval # the protocol may have the answer, so ask it about the obj pass # the context may have the answer, so ask it about the pass # check to see if the current object is ok as is if type(protocol) is types.TypeType or \ type(protocol) is types.ClassType: if isinstance(obj,protocol): return obj # ok... nothing matched, so return None return None def adapt(obj,protocol): return interal_adapt(obj,protocol,1) # imagine binary operator syntax def isa(obj,protocol): return interal_adapt(obj,protocol,0) ----------------------------------------------------------------- test.py ----------------------------------------------------------------- from adapter import adapt from adapter import isa from adapter import AdaptForceNoneException class KnightsWhoSayNi: pass # shrubbry troubles class EggsOnly: # an unrelated class/interface def eggs(self,str): print "eggs!" + str class HamOnly: # used as an interface, no inhertance def ham(self,str): pass def _bugger(self): pass # irritating a private member class SpamOnly: # a base class, inheritance used def spam(self,str): print "spam!" + str class EggsSpamAndHam (SpamOnly,KnightsWhoSayNi): def ham(self,str): print "ham!" + str def __adapt__(self,protocol,can_wrap): if protocol is HamOnly: # implements HamOnly implicitly, no _bugger return self if protocol is KnightsWhoSayNi: # we are no longer the Knights who say Ni! raise AdaptForceNoneException if protocol is EggsOnly and can_wrap: # Knows how to create the eggs! return EggsOnly() def test(): x = EggsSpamAndHam() adapt(x,SpamOnly).spam("Ni!") adapt(x,EggsOnly).eggs("Ni!") adapt(x,HamOnly).ham("Ni!") adapt(x,EggsSpamAndHam).ham("Ni!") if None is adapt(x,KnightsWhoSayNi): print "IckIcky...!" if isa(x,SpamOnly): print "SpamOnly" if isa(x,EggsOnly): print "EggsOnly" if isa(x,HamOnly): print "HamOnly" if isa(x,EggsSpamAndHam): print "EggsAndSpam" if isa(x,KnightsWhoSayNi): print "NightsWhoSayNi" ----------------------------------------------------------------- Example Run ----------------------------------------------------------------- >>> import test >>> test.test() spam!Ni! eggs!Ni! ham!Ni! ham!Ni! IckIcky...! SpamOnly HamOnly EggsAndSpam Relationship To Paul Prescod and Tim Hochbergs Type Assertion method The example syntax Paul put forth recently [2] was: interface Interface def __check__(self,obj) Pauls proposal adds the checking part to the third (3) case described in motiviation, when the protocol knows about the object. As stated, this could be easily added as a step in the interal_adapt function: # the protocol may have the answer, so ask it about the obj if typ is types.Interface: if typ__check__(obj): return obj Further, and quite excitingly, if the syntax for this type based assertion added an extra argument, "can_wrap", then this mechanism could be overloaded to also provide adapters to objects that the interface knows about. In short, the work put forth by Paul and company is great, and I dont see any problems why these two proposals couldnt work together in harmony, if not be completely complementary. Relationship to Python Interfaces [1] by Michel Pelletier The relationship to this proposal is a bit less clear to me, although an implements(obj,anInterface) built-in function was mentioned. Thus, this could be added naively as a step in the interal_adapt function: if typ is types.Interface: if implements(obj,protocol): return obj However, there is a clear concern here. Due to the tight semantics being described in this specification, it is clear the isa operator proposed would have to have a 1-1 correspondence with implements function, when the type of protocol is an Interface. Thus, when can_wrap is true, __adapt__ may be called, however, it is clear that the return value would have to be double-checked. Thus, a more realistic change would be more like: def internal_interface_adapt(obj,interface) if implements(obj,interface): return obj else return None def interal_adapt(obj,protocol,can_wrap): # the obj may have the answer, so ask it about the ident adapt = getattr(obj, '__adapt__',None) if adapt: try: retval = adapt(protocol,can_wrap) except AdaptForceNoneException: if type(protocol) is types.Interface: return internal_interface_adapt(obj,protocol) else: return None if retval: if type(protocol) is types.Interface: if can_wrap and implements(retval,protocol): return retval return internal_interface_adapt(obj,protocol) else: return retval if type(protocol) is types.Interface: return internal_interface_adapt(obj,protocol) # remainder of function... It is significantly more complicated, but doable. Relationship To Iterator Proposal: The iterator special interest group is proposing a new built-in called "__iter__", which could be replaced with __adapt__ if an an Interator class is introduced. Following is an example. class Iterator: def next(self): raise IndexError class IteratorTest: def __init__(self,max): self.max = max def __adapt__(self,protocol,can_wrap): if protocol is Iterator and can_wrap: class IteratorTestIterator(Iterator): def __init__(self,max): self.max = max self.count = 0 def next(self): self.count = self.count + 1 if self.count < self.max: return self.count return Iterator.next(self) return IteratorTestIterator(self.max) Relationships To Microsofts Query Interface: Although this proposal may sounds similar to Microsofts QueryInterface, it differs by a number of aspects. First, there is not a special "IUnknown" interface which can be used for object identity, although this could be proposed as one of those "special" blessed interface protocol identifiers. Second, with QueryInterface, once an object supports a particular interface it must always there after support this interface; this proposal makes no such guarantee, although this may be added at a later time. Third, implementations of Microsofts QueryInterface must support a kind of equivalence relation. By reflexive they mean the querying an interface for itself must always succeed. By symmetrical they mean that if one can successfully query an interface IA for a second interface IB, then one must also be able to successfully query the interface IB for IA. And finally, by transitive they mean if one can successfully query IA for IB and one can successfully query IB for IC, then one must be able to successfully query IA for IC. Ability to support this type of equivalence relation should be encouraged, but may not be possible. Further research on this topic (by someone familiar with Microsoft COM) would be helpful in further determining how compatible this proposal is. Backwards Compatibility There should be no problem with backwards compatibility. Indeed this proposal, save an built-in adapt() function, could be tested without changes to the interpreter. Questions and Answers Q: Why was the name changed from __query__ to __adapt__ ? A: It was clear that significant QueryInterface assumptions were being laid upon the proposal, when the intent was more of an adapter. Of course, if an object does not need to be adapted then it can be used directly and this is the basic premise. Q: Why is the checking mechansim mixed with the adapter mechanism. A: Good question. They could be seperated, however, there is significant overlap, if you consider the checking protocol as returning a compliant object (self) or not a compliant object (None). In this way, adapting becomes a special case of checking, via the can_wrap. Really, this could be seperated out, but the two concepts are very related so much duplicate work would be done, and the overall mechanism would feel quite a bit less unified. Q: This is just a type-coercion proposal. A: No. Certainly it could be used for type-coercion, such coercion would be explicit via __adapt__ or adapt function. Of course, if this was used for iterator interface, then the for construct may do an implicit __adapt__(Iterator) but this would be an exception rather than the rule. Q: Why did the author write this PEP? A: He wanted a simple proposal that covered the "deep part" of interfaces without getting tied up in signature woes. Also, it was clear that __iter__ proposal put forth is just an example of this type of interface. Further, the author is doing XML based client server work, and wants to write generic tree based algorithms that work on particular interfaces and would like these algorithms to be used by anyone willing to make an "adapter" having the interface required by the algorithm. Q: Is this in opposition to the type special interest group? A: No. It is meant as a simple, need based solution that could easily complement the efforts by that group. Q: Why was the identifier changed from a string to a class? A: This was done on Michel Pelletiers suggestion. This mechanism appears to be much cleaner than the DNS string proposal, which caused a few eyebrows to rise. Q: Why not handle the case where instances are used to identify protocols? In other words, 6 isa 6 (where the 6 on the right is promoted to an types.Int A: Sounds like someone might object, lets keep this in a separate proposal. Q: Why not let obj isa obj be true? or class isa baseclass? A: Sounds like someone might object, lets keep this in a separate proposal. Q: It seems that a reverse lookup could be used, why not add this? A: There are many other lookup and/or checking mechanisms that could be used here. However, the goal of this PEP is to be small and sweet ... having any more functionality would make it more objectionable to some people. However, this proposal was designed in large part to be completely orthogonal to other methods, so these mechanisms can be added later if needed Credits This proposal was created in large part by the feedback of the talented individuals on both the main mailing list and also the type signature list. Specific contributors include (sorry if I missed someone). Robin Thomas, Paul Prescod, Michel Pelletier, Alex Martelli, Jeremy Hylton, Carlos Ribeiro, Aahz Maruch, Fredrik Lundh, Rainer Deyke, Timothy Delaney, and Huaiyu Zhu Copyright This document has been placed in the public domain. References and Footnotes [1] http://python.sourceforge.net/peps/pep-0245.html [2] http://mail.python.org/pipermail/types-sig/2001-March/001223.html [3] http://www.zope.org/Members/michel/types-sig/TreasureTrove [4] http://mail.python.org/pipermail/types-sig/2001-March/001105.html [5] http://mail.python.org/pipermail/types-sig/2001-March/001206.html [6] http://mail.python.org/pipermail/types-sig/2001-March/001223.html From greg at cosc.canterbury.ac.nz Sun Mar 4 21:15:44 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Mon, 05 Mar 2001 15:15:44 +1300 Subject: gah! I hate the new string syntax References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97soak$qh9$1@nntp.Stanford.EDU> Message-ID: <3AA2F6D0.5BF0268@cosc.canterbury.ac.nz> Amit Patel wrote: > > But certainly not capitalize or center. > They feel like a user definable function that are in the string module > for convenience. At least in my mind, capitalize is NOT part of the > basic functionality of a string class. I second that. Capitalising, splitting, joining, etc. are things that you do *to* strings, not things that strings themselves do. Another thing I'd like to mention is that, by keeping as many things as possible *not* being methods, the modularity of the core Python system is improved. Suppose one day I wanted to make a cut-down version of the Python interpreter for some specialised application in which string processing wasn't going to be of much importance. I might decide that I wanted to remove most of the standard string-processing functions to keep the size down. If the string functions live in a separate module, I can just recompile Python with that module disabled or replace it with my own cut-down version. But if they're methods of the string object, I have to do surgery on one of the most basic built-in types, which is a much hairier proposition. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From mitchchapman at earthlink.net Sat Mar 17 11:13:14 2001 From: mitchchapman at earthlink.net (Mitch Chapman) Date: Sat, 17 Mar 2001 16:13:14 GMT Subject: Thoughts about extensions to the Python language References: <3AB2FA0F.E61862B0@seebelow.org> Message-ID: <3AB38DE8.788C86D6@earthlink.net> Pearu Peterson wrote: > On Fri, 16 Mar 2001, Grant Griffin wrote: > > Still, one can write FORTRAN in any language. (But it takes so much > > work to write FORTRAN in Python that lazy folks don't bother.) > > What do you mean in the parenthesis? Wrapping Fortran programs to Python > is now even easier than wrapping C programs. I think he meant "write Python code with the mindset of a Fortran programmer." This would entail lots of global variables, humongous function bodies and modules, etc. (Dunno if this still holds; I'm basing it on the 20-30 year old code I used to maintain.) -- Mitch From aleaxit at yahoo.com Thu Mar 22 03:24:52 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 22 Mar 2001 09:24:52 +0100 Subject: How to increase PythonWin v2.0: COM browser limits? References: <994psh$so5$1@news1.xs4all.nl> <3AB9444E.5040403@ActiveState.com> Message-ID: <99ccsk015b7@news2.newsguy.com> "Mark Hammond" wrote in message news:3AB9444E.5040403 at ActiveState.com... [snip] > Ahh - excellent. Thats for tracking that down - it has always worked for me. Me too -- the categories part. The one that breaks down is the registered-libraries part (of combrowse.py). The fix is in HLIHeadingRegisterdTypeLibs -- as the error is an UnboundLocalError on 'name' at the line: ret.append(HLIRegisteredTypeLibrary((keyName, versionStr), name)) I just set name to None right before the try/finally, and guarded this specific line with an 'if name is not None:'; it now works fine (so I haven't looked deeper at WHAT was causing the wrong behavior -- no doubt some craziness in my registry, since other tools trying to systematically parse it are also prone to funky breakdowns). Alex From bckfnn at worldonline.dk Wed Mar 14 10:33:12 2001 From: bckfnn at worldonline.dk (Finn Bock) Date: Wed, 14 Mar 2001 15:33:12 GMT Subject: ANN: First alpha release of Jython-2.1 Message-ID: <3aaf8b98.20888005@smtp.worldonline.dk> I am happy to announce the first alpha release of Jython 2.1. Jython is a Java implementation of the Python programming language. It allows users to compile Python source code to Java byte codes, and run the resulting bytecodes on any Java Virtual Machine. It is a very seamless and smooth integration with Java: from Python you have complete access to all Java libraries, can build applets, can integrate with Java beans, and can subclass Java classes in Python and vice versa. Like Python, and unlike Java, Jython can also be used interactively: just type some Jython code at the prompt and see the results immediately. A java installer is available for download at the Jython website: http://www.jython.org/ Installation of version 2.1a1 is similar to version 2.0. Further information and tips on installation is available at: http://www.jython.org/install.html Jython 2.1 aims to be feature compatible with Python 2.1 and among the new feature are: - Nested scopes - The warning framework - Rich comparison - The numeric coercion model have changed. - Function attributes. The changes from Jython-2.0 include: New features. - Improve speed when indexing a string and iterating over a string in a for loop. - Reworked coercing model (pep-0208) - Added {}.popitem(). - Improved speed for python files by buffering the RandomAccessFile. - Added function attributes (pep-0232) - Rich comparison (pep-0207) - Updated cPickle to handle CPython compatible unicode strings. - Updated sre to CPython-2.1a1 - Added the "new" module - Added a PyServlet class to the util package. - Warning framework (pep-0230). - Added sys.add_classdir and sys.add_extdir. - Added nested scope to the interpreter (pep-0227). Bug fixes. - Allow self referencing adapters to be collected when using weak tables. - Added workaround for a reader bug in MRJ22Jitc.01. - Fixes #127340 where serializable parameter received a PyObject instead of the wrapped java object. - Include a LineNumberTable in the compiled class files. - Fixed a java version test bug in the installer. A complete list of changes and differences are available here: http://www.jython.org/NEWS.html Bugs can be reported to the bug manager on SourceForge: http://sourceforge.net/bugs/?group_id=12867 Cheers, the jython-developers From sheila at spamcop.net Sun Mar 18 04:33:57 2001 From: sheila at spamcop.net (Sheila King) Date: Sun, 18 Mar 2001 09:33:57 GMT Subject: Help with 500 error on cgi script Message-ID: OK, I'm at my wits end. I have Apache running on my local Win98 machine, and I have one simple python cgi script, equivalent to "Hello, World!", that I have been able to run. Today I thought I would start to play with the cgi module and start doing some forms and so forth. Well, I was getting 500 internal server errors. I've checked everything. The path, etc... So, finally, I tried just running cgi.test(), as recommended in the Python tutorial. It worked splendidly. I also have the Python Core Programming book, from Wesley Chun, that comes with a CD-ROM and I put up his friends.htm and friends1.py files from the CD onto my local site, and it ran just fine, also. I've compared my file to the other two files and just can't see what I'm doing wrong. So, here is my script. I'm sure someone here will see it right off? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ #!/usr/bin/env python import cgi form = cgi.FieldStorage() form_ok = 0 if form.has_key("subscriberEmail") and form.has_key("command"): form_ok = 1 if not form_ok: output = '''Content-type: text/html\n\n Error in Form \n \n

Error

You have not filled out all necessary information to complete this request You MUST fill in your subscriber e-mail in the From: box and you MUST select some action to modify your delivery options. Please use the back button on your browser to return to the form and fill in the required information \n ''' print output else: for k in form.keys(): print k, " : ", form[k] print "All done!" From aahz at panix.com Tue Mar 20 10:44:18 2001 From: aahz at panix.com (Aahz Maruch) Date: 20 Mar 2001 07:44:18 -0800 Subject: The most important modules References: Message-ID: <997tsi$q91$1@panix3.panix.com> In article , Martyn Quick wrote: > >I've seen a few comments along the lines of "When you are a newbie it will >take a while to realize which the important modules are." As someone who >is in the middle of wading through Chapter 3 of the Library Reference, it >would be very helpful to know which ones are particularly worth >noting. (Presumably sys, (c)Pickle and shelve, from the ones I've so far >in the chapter - but what other treats are out there for me?) Here's my list: sys string re os os.path shutil zlib/gzip/zipfile urllib md5 -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 There's a difference between a person who gets shit zie doesn't deserve and a person who gets more shit than zie deserves. --Aahz From bkline at rksystems.com Tue Mar 27 15:57:04 2001 From: bkline at rksystems.com (Bob Kline) Date: Tue, 27 Mar 2001 15:57:04 -0500 (EST) Subject: Changing every other instance of in a file In-Reply-To: <3e71cto4blbb71qdpp7v3h1kn9lousaq78@4ax.com> Message-ID: On Tue, 27 Mar 2001, Lars Kl?boe wrote: > On Tue, 27 Mar 2001 05:56:26 -0800, "Emile van Sebille" > wrote: > >Here's one way (although I'm interested to see how re might do this): > > [--- interresting code ---] > > This is another (fancier ;)) implementation of the solution I've > been working on, but I still refuse to believe that the script has > to be this elaborate/big. *twisting my tired gray matter* In the spirit of using the best tool for each job, why not use lex for this? %s GOT_B %% \ { printf(""); BEGIN(0); } \ { printf(""); BEGIN(GOT_B); } %% main() { yylex(); } yywrap() { return 1; } -- Bob Kline mailto:bkline at rksystems.com http://www.rksystems.com From guido at digicool.com Fri Mar 2 17:46:09 2001 From: guido at digicool.com (Guido van Rossum) Date: Fri, 02 Mar 2001 17:46:09 -0500 Subject: Python 2.1b1 released Message-ID: <200103022246.RAA18529@cj20424-a.reston1.va.home.com> With great pleasure I announce the release of Python 2.1b1. This is a big step towards the release of Python 2.1; the final release is expected to take place in mid April. Find out all about 2.1b1, including docs and downloads (Windows installer and source tarball), at the 2.1 release page: http://www.python.org/2.1/ WHAT'S NEW? ----------- For the big picture, see Andrew Kuchling's What New in Python 2.1: http://www.amk.ca/python/2.1/ For more detailed release notes, see SourceForge: http://sourceforge.net/project/shownotes.php?release_id=25924 The big news since 2.1a2 was released a month ago: - Nested Scopes (PEP 227)[*] are now optional. They must be enabled by including the statement "from __future__ import nested_scopes" at the beginning of a module (PEP 236). Nested scopes will be a standard feature in Python 2.2. - Compile-time warnings are now generated for a number of conditions that will break or change in meaning when nested scopes are enabled. - The new tool *pydoc* displays module documentation, extracted from doc strings. It works in a text environment as well as in a GUI environment (where it cooperates with a web browser). On Windows, this is in the Start menu as "Module Docs". - Case-sensitive import. On systems with case-insensitive but case-preserving file systems, such as Windows (including Cygwin) and MacOS, import now continues to search the next directory on sys.path when a case mismatch is detected. See PEP 235 for the full scoop. - New platforms. Python 2.1 now fully supports MacOS X, Cygwin, and RISCOS. [*] For PEPs (Python Enhancement Proposals), see the PEP index: http://python.sourceforge.net/peps/ I hope to see you all next week at the Python9 conference in Long Beach, CA: http://www.python9.org --Guido van Rossum (home page: http://www.python.org/~guido/) From mix77 at usa.net Thu Mar 29 10:58:46 2001 From: mix77 at usa.net (Mix) Date: Thu, 29 Mar 2001 17:58:46 +0200 Subject: Printing "%" Message-ID: <99vm4k$22l$1@ctb-nnrp2.saix.net> How do you print a percenrage (%)sign in Python? I tried : return "select * from fax where id LIKE '%s\%'" %ident I get the following error File "/home/mixo/faxserv/cgi-bin/OutputStr.py", line 136, in GetFaxPages return "select * from fax where id LIKE '%s\%'" %ident TypeError: not enough arguments for format string Please help! From thomas.heller at ion-tof.com Thu Mar 8 10:43:30 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 8 Mar 2001 16:43:30 +0100 Subject: Finding the TCL directory Message-ID: <9889bb$mtr9$1@ID-59885.news.dfncis.de> Hi, I would like to update py2exe to fully support Tkinter programs. Fortunately, it's nearly done, the only thing remaining to do is to copy the TCL installation into the dist directory. But how to find it? Looking into lib-tk\FixTk.py, I have some impression how to do it. But, isn't there an easier way than just to copy all the code? It should work for python 1.5.2, 2.0, ... Thomas From danielk at aracnet.com Mon Mar 19 09:50:15 2001 From: danielk at aracnet.com (Daniel Klein) Date: Mon, 19 Mar 2001 06:50:15 -0800 Subject: The order of classes References: <9r3cbt04tg3c3li151416n9b2a0gg3eccb@4ax.com> Message-ID: On 19 Mar 2001 14:06:31 GMT, scarblac at pino.selwerd.nl (Remco Gerlich) wrote: >Don't use default arguments like this. You do realize, that even if you put >the definition of foo before bar, that every instance of bar will have >*the same foo instance* as its default argument? The 'f = foo()' happens >only once, namely when the class is defined. > >Try something like this: > >class bar: > def __init__(self, f = None): > if f == None: > f = foo() > >class foo: > pass > > >Now the 'f = foo()' happens when a bar instance is created, and at that >time, foo already exists. Excellent answer Remco and it makes a heap of sense! I am already recoding this as you advise. Thanks, Dan From grante at visi.com Wed Mar 14 16:31:54 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 14 Mar 2001 21:31:54 GMT Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> <20010312170356.B3513@better.net> <984486395.407379@newsmaster-04.atnet.at> <984518199.127140@newsmaster-04.atnet.at> <98ohuc$du9$1@news.udel.edu> <7bQr6.644$lz1.17686@ruti.visi.com> <98oku1$f6a$1@news.udel.edu> Message-ID: In article <98oku1$f6a$1 at news.udel.edu>, Terry Reedy wrote: > >"Grant Edwards" wrote in message >news:7bQr6.644$lz1.17686 at ruti.visi.com... >> In article <98ohuc$du9$1 at news.udel.edu>, Terry Reedy wrote: >> >> >> Bill Gates got this right in the early days, delivering two >> >> Basic interpreters: binary floating point for speed, and >> >> decimal floating point for money and such >> > >> >If one counts pennies instead of dollars, then 32 bit ints (+- >> >$20 million) will serve for many purposes. Exact, faster, and >> >more widely available than BCD >> >> In fiancial calculations you also need to represent numbers >> that aren't amounts of money. Interest rates for example. > >So? So 32 bit integers with a weighting of one penny per count won't work for that. >Floats (double precision) work well enough for this, I believe. No. The binary floating point representation of many decimal fraction values is not exact. That's what started this whole thread. You can't represent 0.1 exactly in binary FP. You can in BCD. >Note that binary fraction stock prices are exact with floats >and not with BCD. Wrong. 1/16 is exactly represented in BCD as 0.0625. 1/32 is 0.03125, and so on. Some other fractions (e.g. 1/3) are not exactly representable by BCD, but all the fractions used on exchanges are all powers of 1/2 and can be represented exactly in BCD. I believe that there are plans (on some exchanges) to switch pricing from base-2 fractions to decimal fractions. -- Grant Edwards grante Yow! Now I can join WEIGHT at WATCHERS! visi.com From stephen_purcell at yahoo.com Thu Mar 29 11:31:28 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Thu, 29 Mar 2001 18:31:28 +0200 Subject: Printing "%" In-Reply-To: <99vm4k$22l$1@ctb-nnrp2.saix.net>; from mix77@usa.net on Thu, Mar 29, 2001 at 05:58:46PM +0200 References: <99vm4k$22l$1@ctb-nnrp2.saix.net> Message-ID: <20010329183128.B989@freedom.puma-ag.com> Mix wrote: > How do you print a percenrage (%)sign in Python? > I tried : > return "select * from fax where id LIKE '%s\%'" %ident Do the following: >>> "%i%%" % 85 '85%' Or, in your case, return "select * from fax where id LIKE '%s%%'" %ident -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From dav-nospam-id at westco-nospam-ntrol.com Thu Mar 22 10:59:00 2001 From: dav-nospam-id at westco-nospam-ntrol.com (David Brown) Date: Thu, 22 Mar 2001 16:59:00 +0100 Subject: Cross-platform serial port access References: <99d274$ogv$1@news.netpower.no> Message-ID: <99d7g3$qed$1@news.netpower.no> Grant Edwards wrote in message ... >In article <99d274$ogv$1 at news.netpower.no>, David Brown wrote: > >>I am relatively new to Python, but am planning to use it for a >>number of small programs that should be able to run both on >>Windows (for initial development and testing) and Linux (once >>we get a server running properly). Some of these programs will >>need to communicate with external devices using a serial port - >>is this going to work in a portable fashion using Python? > >Currently, serial port stuff in Python is not portable between >Mac/MS/Unix. I suppose it should be easy enough to make a small wrapper around the different platforms' code. > >>Does anyone know if Linux supports RTS toggle handshaking >>(i.e., the RTS line is high while transmitting, for convenient >>connection to RS-485 convertors), > >Not with the standard PC serial port driver. I hacked the >16x50 driver to do RTS toggle several years ago, but it never >worked reliably. It's very difficult to do it reliably in >software at high baud rates. > >Your best bet is to buy a board that supports RTS toggle in >hardware or use a 232-485 converter that handles it >automatically by detecting the presence of data. The only >board I've used under Linux that supported hardware RTS toggle >was Cyclades Y series 8-port board. I believe that RTS toggle >support doesn't work in their newer boards, so you might have >to look around. > This is definitely a shame. The RTS toggle works well under NT (no idea about Win9x) - I have written a Delphi program that uses it to run a RS-485 convertor at 57600. I don't know for sure how fast RTS is turned off after the last byte - the other nodes on the bus wait 10 ms before answering anyway. I guess under Linux I would have to toggle RTS manually. Turning it on before sending is easy enough, it is turning it off at the right time that is more of a hassle. I suppose I would have to calculate how long the sending would take, sleep for that time, then turn it off. If the process or thread in question was fairly high priority, this should work with reasonable accuracy. So-called "intelligent" RS-485 convertors that read the incomming data and change direction appropriately have their own problems. We have delivered systems that communicated at 300 baud, and "intelligent" convertors frequently do not work at such slow rates. Additionally, they generally need configured with DIP-switches and the like, which is an extra hassle if you need to change the baud rate. Simple RTS-controlled convertors are much easier in that respect. Although it is not really Python-specific, do you know if there are serial drivers for Linux that simulate 9-bit UARTs (i.e., swapping the parity bit from space to mark as appropriate)? Thanks for your help. From stevewilliams at wwc.com Sat Mar 17 22:16:03 2001 From: stevewilliams at wwc.com (Steve Williams) Date: Sun, 18 Mar 2001 03:16:03 GMT Subject: Pep 238 Why new // operator (Non-integer Division) References: <98tc2s$qir$1@news2.ottawa.cyberus.ca> Message-ID: <3AB42890.AD9E9FF0@wwc.com> Courageous wrote: > >>All these changes make my head spin. There is more to life than learning > >>all the fine details in a computer language. The fewer number of ways to do > >>something the better. > > > >Just because the changes are being made doesn't mean you have to USE them. > > This isn't true; the moment you encounter code written by someone else, > you DO have to use them. This simple principle is the magic of Python > minimalism, and the primary driving reason why new Python programmers > can become so effective so fast (IMO). > > C// [ simulated persona = "Kurt G?del", node #157, max search depth 49%, neural variance 12.180 ] For simplicity's sake I do all my computations in the base-pi number system. In this system pi=10. From ajtodd at mpower.com.au Fri Mar 30 21:23:42 2001 From: ajtodd at mpower.com.au (Andy Todd) Date: Sat, 31 Mar 2001 12:23:42 +1000 Subject: best practice? null/None (correction) References: <9a2b9v+lrgp@eGroups.com> <9a2rnd011au@news1.newsguy.com> Message-ID: <3AC53FAE.8E94D410@mpower.com.au> Having used Oracle for far too many years I can confirm that "" and NULL are not the same, sorry Robin. The Oracle RDBMS implements the standard ANSI SQL function 'is'/'is not' for testing for null. eg. SELECT 'x' FROM my_table WHERE my_column IS NULL is NOT the same as SELECT 'x' FROM my_table WHERE my_column='' and will not be guaranteed to return the same results as specified in "Oracle SQL Language Reference Manual". What you *may* have observed is that some implementations of SQL (for intance SQL*Plus) allow lazy programming and will converted NULL VARCHAR2 column values into the empty string after selecting them from the database. Andy Todd -- "Today I'm a part time Oracle DBA and full time head scratcher" Alex Martelli wrote: > > "Robin Thomas" wrote in message > news:mailman.985976988.3926.python-list at python.org... > > At 11:58 AM 3/30/01 -0500, Robin Thomas wrote: > > >HTTP query arguments are of one type: STRING. There is no concept of a > > >"null" value; the closest thing you have is an "empty" string like "". In > > >most database engines, there is a clear difference between NULL and "" in > > >any textual or character data column. > > > > I'm sorry to be outright WRONG here, fluxent. > > > > Many databases consider "" to be NULL for textual columns. Oracle 7 and up > > certainly does. > > Wok?! I _thought_ Oracle was an RDBMS -- fun to hear that it isn't > (proper treatment of NULL as distinguished from any data value being > one crucial requisite for being called an RDBMS). Guess I'll stick with > SQL Server/MSDE then... > > Alex From aleaxit at yahoo.com Fri Mar 16 10:30:13 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 16 Mar 2001 16:30:13 +0100 Subject: Python with the VBA recording capabilities References: <3AB21C3E.95DAB3D2@yahoo.fr> Message-ID: <98tbi80r4l@news1.newsguy.com> "Francois Forest" wrote in message news:3AB21C3E.95DAB3D2 at yahoo.fr... > I compared Python to VBA (not for their syntax): > > VBA gives the programming capability to Applications > > Python gives the programming capability at the OS level > (as shell scripts traditionally did ) Python (with win32com) is basically on a par with VBA in terms of its ability to script COM object models (the pluses and minuses of each for this task are very subtle technical issues, and we HAVE gone into them in the past on this forum). Whether the 'programming' goes to an Application, to 'OS level', or wherever, has zero to do with the language involved and everything to do with the object-model involved. For example, with the 'Windows Scripting Host' object model, 'Scripting Runtime', etc, VBA can just as well be used to automate OS level tasks (though most users appear to prefer scripting languages, such as VB Scripting Edition, for such tasks, still VBA is quite able to perform them too). Python has other, additional capabilities that do not rely on scripting a COM/Automation object model (which VBA also does to a very limited extent, for legacy-compatibility purposes, but _almost_ all it does is scripting various object models -- that's how it interacts with its forms and the controls on them, for example, although direct access to the Win32 API's _is_ also feasible). > VBA has the RECORD capability that transform any sequence of mouse clics > into a program that can be edited and then adapted. This recording > capability is amazingly efficient. Actually (as you'd know if you had ever tried integrating full VBA support into an application), it is the application that has to do most of the work for this purpose; the support actually provided by the VBA framework for this purpose is helpful, but quite minimal. > Can we imagine to add this feature to any current GUI (kde and others) ? No, I can't imagine that; I don't see where the GUI gets into the macro-recording process -- it's the _application_ (in VBA's case, but I don't see much of an alternative?) that needs to have a mode where keystroke, mouseclicks etc get 'recorded' (by suitable calls that the application will make to the recording utility) in terms that are semantically meaningful on the application's object-model. We do have (laying around somewhere) a generic COM recorder we had developed to allow the 'capture and playback' mode of our own applications to also produce editable scripts (at first in our proprietary scripting language, with some idea on how to generalize that), but we never invested the huge amount of work to turn the proof-of-concept prototype into production-level infrastructure -- our existing 'capture and playback' having been deemed perfectly adequate for its needed uses (basically, allowing some sequence of user actions that reveals an application defect in some pre-release version to be saved, then repeatedly replayed as a test to prove the defect has indeed been fixed and does not come up again in later pre-releases and releases). The actual recording infrastructure is the least of it -- the really hard stuff is peppering the _application_ with suitable calls to the recorder, to register relevant events at a semantically appropriate level... Alex From paulp at ActiveState.com Sat Mar 10 00:06:58 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 09 Mar 2001 21:06:58 -0800 Subject: class func & var name overlap References: <3AA9AEC2.12BA1E95@nd.edu> Message-ID: <3AA9B672.BB06B2C@ActiveState.com> Changsen Xu wrote: > > hi all, > > I just now tried function name and variable name overlaping > in Python's script (1) and (2): > > (1) > class x: > x = 3 > def x(self): return 5 > y=x() > print y.x > > ... > > I'm here curious why Python doesn't even report an error > for this obvious mistake ? The code in a class is executed just as if it were at the top level. You can have if statements, loops etc. in there. If Python disallowed binding the same name twice in that particular context, it would not be as consistent as it is today. The class context would be special whereas today it is not. -- Python: Programming the way Guido indented it. From costas at meezon.com Thu Mar 1 22:03:03 2001 From: costas at meezon.com (Costas Menico) Date: Fri, 02 Mar 2001 03:03:03 GMT Subject: define a new func on the fly? References: <3A9EE927.8744154E@troikanetworks.com> Message-ID: <3a9f0ce3.10347756@News.CIS.DFN.DE> Gregory Jorgensen wrote: >eval() evaluates an expression. exec() executes a statement. Try this: > Here is the exact error I get when running it >>>> exec("def f():\n\treturn 'hello'\t") Traceback (innermost last): File "", line 1, in ? File "", line 2 return 'hello' ^ SyntaxError: invalid syntax I've trying all day to get this to work. No luck... costas From fredrik at pythonware.com Thu Mar 22 18:39:40 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 22 Mar 2001 23:39:40 GMT Subject: Checking the type References: <99a493$bhl$1@sun.rhrk.uni-kl.de> <99daj70aeu@enews4.newsguy.com> Message-ID: <03wu6.3116$4N4.451246@newsc.telia.net> Ken Seehof wrote: > The compare is a tiny bit slower, but looks nicer (I think). > > >>> a = [2,3,4] > >>> b = "3,4,5" > >>> def foo(x): > ... if type(x) == type([]): # just use type() with a literal for extra guru points, use "if type(x) is type([])" (there's only one type object for each type), or better: if isinstance(x, type([])): .... Cheers /F From f8dy at diveintopython.org Sat Mar 3 02:55:54 2001 From: f8dy at diveintopython.org (Mark Pilgrim) Date: Sat, 03 Mar 2001 02:55:54 -0500 Subject: Thinking Pythonically (was Re: gah! I hate the new string syntax) References: <97ohh2$polt0$1@ID-77331.news.dfncis.de> <97opsb$nhu$1@nntp6.u.washington.edu> <97oupq$qijrh$1@ID-77331.news.dfncis.de> <97p3mh$bkm$1@tyfon.itea.ntnu.no> <97q14l$jbi$0@216.39.151.169> <7k31at0hbkuqgjtnsfts9nieskove1nli4@4ax.com> Message-ID: in article 7k31at0hbkuqgjtnsfts9nieskove1nli4 at 4ax.com, Kirby Urner at urner at alumni.princeton.edu wrote on 3/3/01 1:41 AM: > Pilgrim's use of list comprehensions wherever suitable doesn't > seem a dive into an arcane or cryptic style. The 'map' thing > was cumbersome, because if your function had two or more > parameters, but you wanted to hold one or more of them constant, Heh heh, he said "Dive Into". :) I agree completely with Kirby. I mentioned this in passing earlier in this thread, but it bears repeating: the map/lambda solution is awkward no matter how you cut it. Consider the example of getting a list of fully qualified pathnames of the contents of a directory, something I do all the time. You could certainly do this with map: >>> map(lambda f, dirname=dirname: os.path.join(dirname, f), os.listdir(dirname)) That's awkward because of the "dirname=dirname" hack required by the lack of nested scopes. (Yes, yes, I know this will be solved in Python 2.1^H^H^H2.2^H^H^H2.3.) Or you could break it up into two steps, like this: >>> fileList = os.listdir(dirname) >>> map(os.path.join, [dirname]*len(fileList), fileList) That's awkward because of the list multiplication, and it has to be done in two steps because you don't know how long the list will be ahead of time. Or you could just use a list comprehension, like this: >>> [os.path.join(dirname, f) for f in os.listdir(dirname)] To me, that says "for each of the files in this directory, make a full pathname out of it, and give me a list of all of those." I don't know what the map examples say, other than "I'm trying to do something simple and this language is making it hard." If I wanted to feel like that, I'd go back to Powerbuilder. -M You're smart; why haven't you learned Python yet? http://diveintopython.org/ From loewis at informatik.hu-berlin.de Fri Mar 2 09:12:06 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Mar 2001 15:12:06 +0100 Subject: A counter-counter-proposal for PEP 236: #pragma( nested_scopes) References: <0Swn6.3324$TW.17061@tor-nn1.netcom.ca> Message-ID: "Fredrik Lundh" writes: > We're talking about two kinds of "directives" here: > > -- Source code encoding, which needs to be specified at the at > the top of the source file, since it affects the tokenizer/parser > (cf. XML encodings). As specified, "directive" doesn't cut it. Why is that? A directive must appear at the beginning of the source file. > -- Experimental compiler features, which if successful will become > standard in the next release. Again, "directive" doesn't work, since > it makes "experimental" stuff look "optional". There are certainly other categories. For example, Tim Peters suggested that users may want to declare "optimize for size, not speed", on a per-module basis; that would not change the language at all, and it won't become standard in the next release, either. As another item, where would "all strings are Unicode" fit? It's not a source encoding, and it won't become standard in the next release, either. The -U option does not work for it, either, since it should be a per-module setting. Regards, Martin From aahz at panix.com Fri Mar 23 23:38:06 2001 From: aahz at panix.com (Aahz Maruch) Date: 23 Mar 2001 20:38:06 -0800 Subject: static methods References: Message-ID: <99h8be$om7$1@panix3.panix.com> In article , Clark C. Evans wrote: > >I was wondering if there is any rationale as to why >Python classes do not have static methods? Without debating the rationale, the standard answer is to stick the class into a module with the same name and use module global functions to simulate static methods. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "I won't accept a model of the universe in which free will, omniscient gods, and atheism are simultaneously true." -- M From a2619725 at smail.uni-koeln.de Wed Mar 7 15:33:28 2001 From: a2619725 at smail.uni-koeln.de (Oliver Hofmann) Date: Wed, 7 Mar 2001 21:33:28 +0100 Subject: UserDict and items() Message-ID: <98656v$cud$1@news.rrz.Uni-Koeln.DE> Hello everyone! Been toying around with UserDict lately and stumbled into a problem. Here's the relevant code: --- from UserDict import UserDict class ClText(UserDict): def __init__(self): UserDict.__init__(self) # Set initial value self.data['test'] = '' def __getitem__(self, key): if key == 'test': return 'found' return UserDict.__getitem__(self, key) --- In short, whenever a few reserved keys are queried I'd like to return default values or fetch needed values from a database. This works quite nicely: >>> a = class.ClText() >>> a['test'] 'found' Unfortunately: >>> a.items() [('test', '')] Is there a more elegant way to handle items(), values() etc than overwriting each function? One way would be to set data[key] to the required value during init(); however I'd like to postpone fetching data from the database until the time it is actually requested. Any help would be appreciated, Oliver -- Oliver Hofmann - University of Cologne - Department of Biochemistry o.hofmann at smail.uni-koeln.de - setar at gmx.de - connla at thewell.com You can present the material, but you can't make me care. -- Calvin From emile at fenx.com Thu Mar 22 08:57:50 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 22 Mar 2001 05:57:50 -0800 Subject: tempfile problem on win98 References: <99d0dg$os92$1@ID-11957.news.dfncis.de> Message-ID: <99d0is$qcv3$1@ID-11957.news.dfncis.de> I just notice as well that the routine doesn't in fact create the file, so that a delay in using the name, or accessing mktemp from another process could also result in duplicates. Emile "Emile van Sebille" wrote in message news:99d0dg$os92$1 at ID-11957.news.dfncis.de... > The mktemp routine guarantees to return a name unique in the target > directory. Are you sure you're using fully qualified path names throughout > when subsequently discovering duplicate files? > > Emile van Sebille > emile at fenx.com > > From mariogilberto at eichlerjunior.inf.br Sun Mar 4 17:27:01 2001 From: mariogilberto at eichlerjunior.inf.br (=?iso-8859-1?Q?M=E1rio_Gilberto_Eichler_Junior?=) Date: Sun, 4 Mar 2001 19:27:01 -0300 Subject: Need a free lancer python programmer - to do bots Message-ID: <006e01c0a4fa$3c4e0820$52d0fea9@mario> I need a free lancer programmer to do a bots to search information in 35 sites based in a word dictionary and write the results in a mysql database I will pay per a job. I leave in Brazil. All sites are locate in Brazil. Will pay in American Dollars. -------------- next part -------------- An HTML attachment was scrubbed... URL: From duncan at rcp.co.uk Mon Mar 26 06:02:12 2001 From: duncan at rcp.co.uk (Duncan Booth) Date: Mon, 26 Mar 2001 11:02:12 +0000 (UTC) Subject: Python T-shirts References: <99g4ik$lb6$1@tyfon.itea.ntnu.no> Message-ID: "Magnus Lie Hetland" wrote in <99g4ik$lb6$1 @tyfon.itea.ntnu.no>: >> At the conference we handed out T-shirts with the slogan on the back >> "Python: programming the way Guido indented it". > >Just thought I'd mention... > > http://www.cafepress.com/ > >(I'm in no way affiliated with them.) > While I'm sure they provide a good service, I find their international shipping charges look a bit high to really justify. For example, shipping to the UK is charged at $20 for the first t-shirt. From chrisa at ASPATECH.COM.BR Wed Mar 7 07:08:40 2001 From: chrisa at ASPATECH.COM.BR (Chris Richard Adams) Date: Wed, 7 Mar 2001 09:08:40 -0300 Subject: finding and listing the differences between two files Message-ID: Right now I am finding the differences using Bsh...like diff file1 file2 > filediff if [ $? = 0 ] then echo same else echo different read filediff... fi Anyone know the equivalent in Python or am I better off sticking to shell. Thanks, Chris From sandipan at vsnl.com Sat Mar 31 04:06:56 2001 From: sandipan at vsnl.com (Sandipan Gangopadhyay) Date: Sat, 31 Mar 2001 14:36:56 +0530 Subject: very basic, how do you find square roots? References: <9a408a$1mpp$1@raewyn.paradise.net.nz> Message-ID: <004201c0b9c1$f0b38f20$020000c3@node02> >>> import math >>> math.pow(2,4) 16.0 >>> math.pow(2, .5) 1.41421356237 Regards, Sandipan ----- Original Message ----- From: "johnston112" Newsgroups: comp.lang.python To: Sent: Saturday, March 31, 2001 12:35 PM Subject: very basic, how do you find square roots? > Yes, that is my question :) > I am trying to make a program that dose the quadratic equation. > > johnston112 > > > -- > http://mail.python.org/mailman/listinfo/python-list > From nanotech at europa.com Tue Mar 27 17:36:24 2001 From: nanotech at europa.com (nanotech at europa.com) Date: Tue, 27 Mar 2001 22:36:24 -0000 Subject: Getting all the *files* from a directory -- A better way?? Message-ID: <99r4l8+kd3u@eGroups.com> All: Here is how I get all the files from a directory: dir="a/b/c" files=filter(os.path.isfile,["%s/%s"%(dir,f) for f in os.listdir (dir)]) Is this *REALLY* the Pythonic way to do this? (OR, why does os.listdir return only file names, and not the path given prepended?) Quentin Crain From aleaxit at yahoo.com Tue Mar 20 02:11:21 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 20 Mar 2001 08:11:21 +0100 Subject: Functionalism, aesthetics Was:(RE: I come to praise .join, not References: Message-ID: <996vss013mp@news2.newsguy.com> "Carlos Ribeiro" wrote in message news:mailman.985052844.17993.python-list at python.org... > > I'm lost for words... This summarizes a lot of concerns that sometimes I > find so hard to explain. Anyone who has actually *read* Christopher > Alexander's books on design should know that the best solutions are the > ones that take into account the inner sense of satisfaction of their end > users. As Alexander puts it itself, it is a rewarding experience born out > of the "completeness" of the solution. The best solutions also share > another common trait: they look *and feel* good to the untrained eye. > Beware of works that can only be appreciated by experts - they are way too > trained to see the obvious. Unfortunately, this does not generalize to fields in which the non-experts lack a few thousand years of collective cultural adaptation. In that case, the superficial apperception of 'beauty' does need understanding of the underlying technology to be grounded -- shared cultural background and biology don't suffice. Back when "Concorde" and "Jumbo" first appeared on the scene, for example, non-experts found the former quite beautiful, the latter quite plain. Sure the sleek, fast-looking lines of Concorde were superior to the goofy-looking fatness of Jumbo? Unfortunately, this superficial perception had zero relevance for the actual technical soundness of the designs. A few decades later, we can see with hindsight that Concorde was one of the costliest big failures in airliner design, Jumbo the unqualified greatest success ever in the same field. The actual need was to carry huge masses of humanity from A to B cheaply, NOT to wiz around a few upper class poshies in half the time. So why did the elitist design look better? Perhaps because it's a common subconscious mechanism to prefer the luxury good, even when in actual fact one won't be able to take advantage of it, as a wishful-thinking byproduct. Remember that human beings are quite prone to a few well-known systematic perception errors -- and it takes LOTS of training to teach one of us to stop making them. Thus, a design which happens to hit squarely on the button one of those common perception errors may well be quite pleasing, superficially, to the untrained masses -- only highly experienced professionals really stand a chance to smell something fishy with it. Computers and peripherals without an on/off button ('software will do it all' -- yeah, right, but what happens when due to a bug you need to recycle power...? unplug/replug the mains...?!) are another example, closer to our field. Buildings as such (and more generally dwelling-places) are old enough that it's quite possible that we all share some basic biological basis for sound judgment -- I'm not pronouncing on that, but that's what Alexander is mostly writing about. Other technologies don't share that characteristics, or may even display nothing actually relevant to the end-user; I am reminded of a huge brouhaha about a drug that happened a few years ago here. The color of the pills was changed from vivid red to pale red (actually to reduce the amount of artificial coloring after doubts were raised about it being intrinsically harmful). People were furious that the medicine had been 'weakened' -- even though the actually active chemicals in each pill were exactly the same as before! We can endlessly discuss where computers and software fit on this scale, but surely the example of pharmaceutics does suffice to show conclusively that, with far too many modern technologies, it's quite likely that what appears to the untrained eye has *zero* relevance -- that, no matter how ideologically unpleasant this may feel, we DO have to rely on _expertise and training_ to be able to judge certain issues. Vox populi is NOT necessarily vox Dei -- not when the underlying technology is too new (a few centuries) and/or not reflected in immediately apperceivable traits. > To summarize it: a *technically* optimal solution for a problem is not > always the *best* solution. If it does not look intuitively good for most > users, its probably a bad solution. So, you're arguing that the amount of artificial coloring should have been kept high (who cares about giving users cancer, right?), since that bright color was definitely what "looked intuitively good for most users" as proved by the endless carping...? > Its unfortunate that in many cases the non-expert user keeps quiet, > assuming that whatever opinion the "master" haves, its going to be better > than theirs - after all they are the so-called experts. Ask the experts in any field whether untrained users keep too quiet, or not enough, in their field, and you'll get a different opinion (of course, self-serving conscious or unconscious biases are at work as well!). Alex From Eugene.Leitl at lrz.uni-muenchen.de Fri Mar 16 05:36:23 2001 From: Eugene.Leitl at lrz.uni-muenchen.de (Eugene Leitl) Date: Fri, 16 Mar 2001 11:36:23 +0100 (MET) Subject: OO-Browser Message-ID: I'm setting up a Python/C development environment, so I decided to go with XEmacs/gdb/ddd/pdb and OO-Browser. However, I'm only running into dead links when attempting to access BeOpen. What's up with them? From jsoons at juilliard.edu Thu Mar 22 16:05:13 2001 From: jsoons at juilliard.edu (Jonathan Soons) Date: Thu, 22 Mar 2001 16:05:13 -0500 Subject: expanding a variable Message-ID: I am trying to give my cv group (who all have logins like cv???.) all the same .profile. The variable in the last line of the script doesn't seem to be expanding, even though this is very similar to an example in "Core Python Progr..." d = commands.getoutput('ls /u') dirs = string.split(d, '\n') for dir in dirs: if re.search('^cv', dir): os.system('cp /u/test/.profile /u/dir/') ^^^ Should I stick to bash for this kind of thing? Thanks for any advice. From gregj at pobox.com Fri Mar 9 01:58:25 2001 From: gregj at pobox.com (Gregory Jorgensen) Date: Fri, 09 Mar 2001 06:58:25 GMT Subject: Who am I: can a class instance determine its own name? References: Message-ID: Emile van Sebille's very cool hack aside, I don't understand why you would do this. I'm not criticizing; you've got me curious. I've never needed this in years and years of programming. I don't think of a variable name as an attribute of the object it refers to, because (as one poster pointed out) objects may have no name, one name, or several names at any time, and the names referring to an object may change during the object's lifetime through assignment, parameter passing, etc. Even Emile's hack has limited usefulness: it captures the name at the time the Bar object is added to a Foo container, but consider these obvious problems: def addbar(f, b): f.addBar(b) foo = Foo() bar_a = Bar() addbar(foo, bar_a) bar_b = Bar() foo.addBar(bar_b) zzz = bar_b del bar_b foo.listBars() will yield ['b','bar_b'], not ['bar_a','zzz']. You mention the "problem of composition" and give a container class example, implying that this is a problem associated with those object-oriented designs. Why? Python has the "is" operator to test if two objects refer to the same thing; that's safer than using names. >>> b = Bar() >>> z = b >>> z is bar 1 I'm sure I'm not the only inquiring mind who wants to know. Greg Jorgensen Deschooling Society Portland, Oregon, USA gregj at pobox.com From william.famy at noos.fr Fri Mar 23 10:17:21 2001 From: william.famy at noos.fr (William Famy) Date: Fri, 23 Mar 2001 16:17:21 +0100 Subject: newbe how to read in a string? the solution References: <3ABB4E70.54885C9F@noos.fr> Message-ID: <3ABB6901.F714006A@noos.fr> Thanks for you answer. This a sumary of the answer i receive. _________________________________________________ import string d,n1,n2,n3 = string.split(a, ",") n1 = float(n1) n2 = float(n2) n3 = float(n3) If the list of numbers is of variable length, this might be cool: import string seq = string.split(a, ",") for i in range(1, len(seq)): # this skips the 0 index, seq[i] = float(seq) # which needs to stay a string. _______________________________________________ One possibility: import string a='2000/12/28,24.3,87.1,65.4' b = string.split(a, ',') Then b[2] is 87.1,written as string: str(b[2]) _________________________________________________ strFields = a.split(",") thirdField = strFields[2] _________________________________________________ -- \\\|/// \\ - - // ( @ @ ) +-------------------------oOOo-(_)-oOOo-------------------------+ | Famy William 36 avenue des barattes 74000 Annecy France | | email:william.famy at noos.fr william.famy at mail-enseignant.com | +---------------------------------Oooo--------------------------+ oooO ( ) ( ) ) / \ ( (_/ \_) From grante at visi.com Fri Mar 30 16:57:29 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 30 Mar 2001 21:57:29 GMT Subject: Know of Substantial Apps Written in Python? References: <3ac4e4a8_1@news4.newsfeeds.com> Message-ID: In article , David Allen wrote: >What's the definition of "substantial"? > >There's Grail, a web browser >http://grail.sourceforge.net Anybody get Grail to work lately? Last time I tried it wouldn't run. >There's ZOPE, an internet publishing thingy >(thingy is a technical term :) Sketch is one of my favorites: http://sketch.sourceforge.net/ And there's teh PySol solitare game http://wildsau.idv.uni-linz.ac.at/mfx/pysol.html -- Grant Edwards grante Yow! Yes, Private at DOBERMAN!! visi.com From aahz at panix.com Sat Mar 31 17:08:11 2001 From: aahz at panix.com (Aahz Maruch) Date: 31 Mar 2001 14:08:11 -0800 Subject: Threading legality/morality References: <99qogp$o6g$2@troll.powertech.no> <9a2r6n$mlq$1@troll.powertech.no> Message-ID: <9a5kgb$3kk$1@panix3.panix.com> In article <9a2r6n$mlq$1 at troll.powertech.no>, Syver Enstad wrote: > >I have a confession to make here. It seems that this behaviour is a feature >rather than a bug and has to do with the os rather than the app or python >itself for that matter. (Inserts foot in mouth). > >If you click the mouse in the client area of a console window, the os >freezes the application running there until you press a key. I guess it's >for the convenience of copying text off of the console but it sure tripped >me up. Oh, that one. Forgot about it. Change your CMD preferences to not allow one-click select. (I'd be more precise, but I don't have access to NT anymore.) -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "I put people on my humor list as a form of revenge, you realize." --SJM From bsb at winnegan.de Mon Mar 5 10:14:37 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 05 Mar 2001 16:14:37 +0100 Subject: Little problem with the "+" operator In-Reply-To: <983802310.155838463@news.t-online.de> References: <983802310.155838463@news.t-online.de> Message-ID: <87vgpo6yea.fsf@winnegan.de> Zamurai writes: > I want to make the following: > > variableOne = 500 > myVariable = variableOne + "cool" > > But I get the following error: "unsupported operand types for +" > > Does someone know how to solve the problem? That depends on what your problem is :-) You're trying to add a string to an integer, which isn't supported. If you expect '500cool' as a result, try myVariable = str(variableOne) + 'cool' Siggy From lex at cc.gatech.edu Wed Mar 28 11:26:12 2001 From: lex at cc.gatech.edu (Lex Spoon) Date: 28 Mar 2001 11:26:12 -0500 Subject: Collection interfaces References: <3a90fa97.0@news1.mweb.co.za> <99l6s8$gpu$1@nyheter.chalmers.se> Message-ID: Phil Earnhardt writes: > On 27 Mar 2001 18:42:49 -0500, Lex Spoon wrote: > > >matso at dtek.chalmers.se (Mats Olsson) writes: > > > >> Yea, use a Java applet instead. Guaranted not to fiddle with your > >> DLL's :-) > > > >Oh great, so we get to fiddle with JAR's instead of DLL's! At least > >JAR is easier to pronounce. :) > > Can you explain your comment, Lex? How is downloading and running > applets from a jarfile have anything to do with fiddling with DLLs? Java programs tend to require you to have various extensions installed as JAR files, just the same way that Windows EXE's tend to require that you have various extensions installed as DLL's. I'd hazard that JAR's are *worse* than DLL's -- DLL's at least *pretend* to do something about versions. Admittedly, I missed the "applet" part. Applets run with a standard set of classes available, so they don't have that problem. (Instead, they have the problem that *no* extensions are available. Easy to set up, but not as powerful! :)) -Lex From robin at jessikat.fsnet.co.uk Mon Mar 12 19:05:06 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 13 Mar 2001 00:05:06 +0000 Subject: ANNOUNCE Mailman 2.0.3 References: Message-ID: In article , Barry A. Warsaw writes > >[I think I forgot to announce the Mailman 2.0.2 release on these >mailing lists. Apologies. -Barry] > >I've just announced the 2.0.3 release of Mailman, the GNU Mailing List >Manager. Mailman is released under the GNU General Public License >(GPL). > >I highly recommend that all sites running earlier versions of Mailman >upgrade to 2.0.3. This release includes the important privacy patch >from Mailman 2.0.2. Sadly, Mailman 2.0.2 contained a small but nasty >typo requiring this new version. Mailman 2.0.3 is being released as >both a gzip'd source tarball and as a patchfile. .... >Enjoy, >-Barry > thanks, I've just installed 2.0.2 and set up my first list. It's not a problem for me now, but is it easy to install over an existing installation? -- Robin Becker From michael at lindrum.de Thu Mar 15 17:01:58 2001 From: michael at lindrum.de (Michael Lindrum) Date: Thu, 15 Mar 2001 23:01:58 +0100 Subject: Python2C References: <3AAE98EA.2754A358@lindrum.de> <4gyr6.160$4d3.34825@newsb.telia.net> Message-ID: <3AB13BD5.5831BD4A@lindrum.de> Thanks, in the meantime I got the lib, but it needs libpython.a from Python 2.0 Fredrik Lundh schrieb: > Michael Lindrum wrote: > > I'm searching for the lib that is necessary to compile C-Code generated > > by Python2C. > > OS: SunOS > > Who knows where I can find it? > > assuming you mean libpython, all you have to do is to > download and build python itself: > > http://www.python.org > > (if that's not it, consider telling us what library you think > you're missing) > > Cheers /F From bedge at troikanetworks.com Fri Mar 2 10:37:34 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Fri, 02 Mar 2001 07:37:34 -0800 Subject: define a new func on the fly? References: Message-ID: <3A9FBE3E.5CD3BB69@troikanetworks.com> Christopher Li wrote: > > On Thu, 1 Mar 2001, Bruce Edge wrote: > > > >>> class xx: > > ... def __init__(self): > > ... exec( "def yyy(): print \"yyyyyyyyy\"" ) > > ... > > >>> x=xx() > > >>> > > >>> x.__dict__ > > {} > > > > Where is yyy defined? > In local namespace of __init__. Ahhh. I'm coming from Tcl, it's a wee bit different. > > > > Ideally, I'd like to be able to create it in the global namespace. > Do yon mean in class xx? > How about > > >>> class xx: > ... def __init__(self): > ... exec( "def tmp(self): print 'yyyyyy'") > ... self.yyy = tmp > ... > >>> x = xx() > >>> x.__dict__ > {'yyy': } OK, so that kicks it up to the class namespace. Now, just for completeness, I wanted it in the global namespace, so: >>> class xx: ... def __init__(self): ... global g ... exec( "def tmp(): print 'yyyyyy'") ... self.yyy = tmp ... g = tmp ... >>> g=dir >>> g >>> t=xx() >>> t.__dict__ {'yyy': } >>> type(g) >>> g() yyyyyy Thanks to all for the help. Guess I won't be going back to Tcl after all :-) > Chris From DavidlNo at spammyraqia.com Wed Mar 28 13:28:01 2001 From: DavidlNo at spammyraqia.com (David Lees) Date: Wed, 28 Mar 2001 13:28:01 -0500 Subject: Setting sleep interval less than 10 mS on a Linux PC? Message-ID: <3AC22D31.FD4644B1@spammyraqia.com> I suspect this is a system question, but I will ask anyway. I am using the Python sleep method (time.sleep) and on a PC running RedHat 7.0 Linux, it has a 10 millisecond lower limit. Below that it still wakes up every 10 milliseconds, regardless of the argument. I gather from a little reading, that 10 mS is the default miniumumlinux sleep interval. Is there a way from Python to set this to a shorter interval (1 mS would be nice), without recompiling the linux kernel? david lees From fdrake at localhost.localdomain Fri Mar 23 14:11:52 2001 From: fdrake at localhost.localdomain (Fred Drake) Date: Fri, 23 Mar 2001 14:11:52 -0500 (EST) Subject: [development doc updates] Message-ID: <20010323191152.3019628995@localhost.localdomain> The development version of the documentation has been updated: http://python.sourceforge.net/devel-docs/ Documentation for the second beta release of Python 2.1. This includes information on future statements and lexical scoping, and weak references. Much of the module documentation has been improved as well. From jeremy at alum.mit.edu Mon Mar 19 14:19:09 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Mon, 19 Mar 2001 14:19:09 -0500 (EST) Subject: Why "from __future__" stinks; a counter-offer In-Reply-To: <4Aft6.2171$pP2.372173@paloalto-snr1.gtei.net> References: <4Aft6.2171$pP2.372173@paloalto-snr1.gtei.net> Message-ID: <15030.23469.813235.630703@w221.z064000254.bwi-md.dsl.cnc.net> >>>>> "VC" == Vadim Chugunov writes: >> might be OK -- alas, without a PEP, it's a non-starter). VC> But, surely, the PEP can be updated! This "from __future__" VC> syntax is ugly, ugly, ugly!!! Vadim, If someone else wants to write a PEP and implement it this week, it would be considered. Tim wrote the PEP. I implemented it. We're both going to be spending most of our waking hours this week getting ready for the beta release on Friday. We have no time and less interest in implementing something other than the __future__ mechanism. We think it is a good solution to the problem it addresses. But neither of us is the BDFL. If someone writes a PEP and implements it in the next day or two, he or she may be able to convince Guido that it is better than __future__. In the absence of someone writing a new PEP, nothing is going to change. Jeremy From embed at geocities.com Thu Mar 8 12:43:56 2001 From: embed at geocities.com (Warren Postma) Date: Thu, 8 Mar 2001 12:43:56 -0500 Subject: Ldap / Python help References: Message-ID: "Pablo Pernot" wrote in message news:mailman.984067391.2391.python-list at python.org... > Hello all, > > I'm new in python > > I found an ldap module. > > Where can I find documentation about ldap/python > > my modify instruction won't work => modify_s is waiting for a string (dn) > and a list (mylist) formed by tuple (mytuple) and this tuple is formed for 3 strings. > > So I can't understand the error message about integer. > > mytuple=("MOD_REPLACE","sn","test") > mylist=[mytuple] > > >>> l.modify_s(dn,mylist) > Traceback (most recent call last): > File "", line 1, in ? > TypeError: an integer is required > > To convert a tuple to a list, try: mylist = list(mytuple) To see what mylist=[mytuple] does, try this: print repr( [mytuple] ) You see the difference now? Warren From qrczak at knm.org.pl Mon Mar 19 14:50:13 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 19 Mar 2001 19:50:13 GMT Subject: [Very Long (11K)] Numeric PEPs, first public posts References: Message-ID: Fri, 16 Mar 2001 15:18:43 +0200, Moshe Zadka pisze: > PEP: 237 > Title: Unifying Long Integers and Integers I like it! > Overflows > > When an arithmetic operation on two numbers whose internal > representation is as machine-level integers returns something > whose internal representation is a bignum, a warning which is > turned off by default will be issued. This is only a debugging > aid, and has no guaranteed semantics. I would not bother with this warning. > Implementation > > The PyInt type's slot for a C long will be turned into a > > union { > long i; > struct { > unsigned long length; > digit digits[1]; > } bignum; > }; > > Only the n-1 lower bits of the long have any meaning; the top bit > is always set. This distinguishes the union. The i is unified with length, not with digits[]. Isn't it simpler to have Int as Long as separate types? If they behave in the same way, arithmetic on Ints yields longs when needed etc., it should be OK and nice. They can even return the same type(x) and have a unified PyInt_Check, but operations are more naturally dispatched as currently. It's probably unnecessary to normalize the large form into the small form if the value gets smaller. That way there are fewer places which have to dispatch on the representation. Wouldn't using gmp be an advantage? > Open Issues Let me add: I would like to have PyInt_AsString. I know I can convert to a Python string object and get the C string from it, but it looks like an unnecessary indirection. I wanted PyLong_AsString to convert them for another bignum library. There might be faster ways to do this, but every library will understand decimal strings. Unfortunately it's unclear how to obtain and free the storage, as usual in C. Well, maybe it's not that important. > What to do about sys.maxint? Deprecate like the long function etc., unless some important libraries would still be limited to that. > What to do about PyInt_AS_LONG failures? A good question. > What do do about %u, %o, %x formatting operators? If portability here is not that important, let them output negative numbers as negative. One can use "%x" % (x % 2**32) to get the old behavior. If it is, I don't know. > How to warn about << not cutting integers? If there is a portability switch like from __future__ import foo, use that; it's bad that it doesn't happen at compile time, but maybe it's all that we can get. If not, I don't know. > Should the overflow warning be on a portable maximum size? I would drop it. > Will unification of types and classes help with a more > straightforward implementations? I don't know. > PEP: 238 > Title: Non-integer Division I like it! > Open Issues > > Should the // operator be renamed to "div"? If % is % and not "mod", I would probably spell it //. But I would call % "mod", except that it's too late. > PEP: 239 > Title: Adding a Rational Type to Python I like it! I guess that sin(1.5) converts the argument to float? How many digits does str(1/3) return, assuming it prints the number in decimal? Should str(5.0) return '5.0' or '5'? Note that it finally doesn't hurt if you have an integer instead of a rational, so there is more sense to let it return '5' than currently: integers can be treated as a special case of rationals (implemented as a separate type). But maybe accepting 4.0 as list indices etc. is too much. What does repr(1/3) return? '1/3'? > PEP: 240 > Title: Adding a Rational Literal to Python I like it! All PEPs together make arithmetic on literals exact, independent of the platform's integer size and float representation. Moreover one can always write 42 instead of 42.0 and get the same result (numerically). BTW. A nice thing about static typing is that it allowed Haskell's numeric literals and functions to have types deduced from the context of usage. 5+1/3 can be computed on either Rational or Double or Complex Float or any other (perhaps user defined) fractional type. Literals are internally converted from Integer (infinite precision) or Rational (= Ratio Integer). In Python it can't be done that way, but the conversion can be delayed such that the results are the same (modulo the *lack* of *loss* of precision if numbers are converted to float too late). -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From weiqigao at networkusa.net Wed Mar 7 20:53:03 2001 From: weiqigao at networkusa.net (Weiqi Gao) Date: Wed, 07 Mar 2001 19:53:03 -0600 Subject: Article on Rhino and Jython Message-ID: <3AA6E5FF.FDAA74C@networkusa.net> Hi, I just though some of the Jython fans on this list might find the following article useful in trying to convince your Java-knowledgable but Jython-ignorant colleagues to start using Jython (or Rhino): http://www.ociweb.com/jnb/archive/jnbMar2001.html Feel free to send comments to me (weiqigao at networkusa.net), link to it, show it to your friend. My goal is to make the average Java programmer curious about Jython and Rhino (or any of the other languages mentioned) enough to actually try them. -- Weiqi Gao networkusa.net From syver at NOSPAMcyberwatcher.com Tue Mar 20 19:38:46 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Wed, 21 Mar 2001 01:38:46 +0100 Subject: urllib.urlopen doesn't accept Unicode strings. Message-ID: <998tau$q6i$1@troll.powertech.no> The offending line is at 241 in urllib.py (python 2.0) def open_http(self, url, data=None): """Use HTTP protocol.""" import httplib user_passwd = None # next line patched, original line was: if type(url) is type(""): if type(url) is type("") or type(url) is type(u""): host, selector = splithost(url) if host: Or maybe this has been fixed in Python 2.1? From not.this at seebelow.org Mon Mar 19 16:23:04 2001 From: not.this at seebelow.org (Grant Griffin) Date: 19 Mar 2001 13:23:04 -0800 Subject: Pep 238 Why new // operator (Non-integer Division) References: Message-ID: <995tbo0oce@drn.newsguy.com> In article , "Tim says... > >[Grant Griffin] >> BTW, I guess I'm not the first one to notice that this new operator >> looks an awful lot like a C/C++ comment. > >No, you're the first! 329 people did note that // looks an awful lot like >Fortran's string concatenation operator. I expect these were the same 329 >who complained to the C++ committee about abusing *their* prior art. Eureka!--I get it now. It's designed to make it easier to write Fortran in Python (er, I mean "Fortran _as_ Python") >> So maybe some other symbol should be used. Now that you mention it, did the previous line inspire "print >>"? > >Why bother? Python's # looks an awful lot like C++'s preprocessor directive >flag too. Now don't get me start on that: to me, it had looked more like _Perl's_ #! (That has too many sharp edges!) anything-that-python-and-perl-agree-on-can't-be -*all*-good--ly y'rs, =g2 _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From root at [127.0.0.1] Wed Mar 28 09:35:08 2001 From: root at [127.0.0.1] (deadmeat) Date: Wed, 28 Mar 2001 14:35:08 GMT Subject: list vs tuple References: <3AC1EB93.7BC87292@hack.org> Message-ID: > Tuples are immutable, lists are not. As are strings which I find a tad irritating (I come from a Pascal background)... it just means more work for me to split & rejoin. so is that the only difference? From brangdon at cix.co.uk Thu Mar 1 05:16:00 2001 From: brangdon at cix.co.uk (Dave Harris) Date: Thu, 1 Mar 2001 10:16 +0000 (GMT Standard Time) Subject: Stream interfaces References: <3A9BC3F9.1929EB9A@ix.netcom.com> Message-ID: tgagne at ix.netcom.com (Thomas Gagne) wrote (abridged): > ExternalStream > BufferedExternalStream > ExternalReadStream > ExternalReadWriteStream > ExternalWriteStream > InternalStream > WriteStream > ReadWriteStream Do you agree this hierarchy is a bit duff? Notice how "Write" appears in 3 leaf classes: ExternalReadWriteStream, ExternalWriteStream, ReadWriteStream. These apparently share no implementation or interface. Notice also that in one place we get a trio of classes: > ExternalReadStream > ExternalReadWriteStream > ExternalWriteStream and in another we get a pair: > WriteStream > ReadWriteStream yet they would seem to be doing the same kind of thing. How do I get an internal stream which is readable but not writable? If ReadWriteStream inherits from WriteStream, why doesn't ExternalReadWriteStream inherit from ExternalWriteStream? Something has gone wrong here. Dave Harris, Nottingham, UK | "Weave a circle round him thrice, brangdon at cix.co.uk | And close your eyes with holy dread, | For he on honey dew hath fed http://www.bhresearch.co.uk/ | And drunk the milk of Paradise." From syver at NOSPAMcyberwatcher.com Tue Mar 27 06:43:02 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Tue, 27 Mar 2001 13:43:02 +0200 Subject: Threading legality/morality References: <99nnbv$phs$1@panix6.panix.com> Message-ID: "Aahz Maruch" wrote: > Syver Enstad wrote: > > > >How is calling print from more than one thread looked upon? > > Depends what you're trying to do. If it's debugging output and if you > concatenate strings before trying to do a print (don't use multiple > prints in succession), you're safe. Anything other than that is > probably risky -- but unlikely to do actual damage (you'll just get > messed up output). Yes, that is to be expected. Are you aware of any material on which Python modules that are threadsafe, and the definition of threadsafety I am talking about is using functions and objects from the same class in different threads, but not one object from more than one thread. To those familiar with COM, threadsafe like apartment threaded objects. I have seen some strange behaviour in some multi threaded programs I have made in python, where they seem to lockup, but a push on the the return key (or another key, I don't know) keeps them going. These are console programs, running under Win2000 server and professional, Python 2.0. As I was writing this I checked out my program that has been running for about 24 hours, downloading files from the internet via urllib, and using ADO via pythoncom. It has been running ever so happily until about 10 clock this morning when I inspected some output it had given. Then it froze for about three hours, when I pushed a key on the keyboard it continued again. Strange. From bernhard at abnoba.intevation.de Tue Mar 27 08:14:51 2001 From: bernhard at abnoba.intevation.de (Bernhard Reiter) Date: 27 Mar 2001 13:14:51 GMT Subject: Linux GPS program References: <3AC01637.4EF3A6F2@crynwr.com> Message-ID: <99q3ob$ehr$1@newsserver.rrzn.uni-hannover.de> [Posted and mailed] Hi Russell, will pygps be Free Software? I could not find anything about a license in the cvs. If it was I will be happy to add it to the www.freegis.org link collection. Bernhard In article <3AC01637.4EF3A6F2 at crynwr.com>, Russell Nelson writes: > Hi. I have written a GPS program in Python for Linux. I'm sure that > someone > could port it to run under Windows, but I have no interest in doing so. > I haven't > done a real release of the software yet, since it's still under heavy > development. > But you're welcome to download a copy from handhelds.org's CVS. The > location is "apps/pygps". For info on handhelds.org's CVS: > http://www.handhelds.org/sources.html > > Right now, it does moving maps (UTM bitmaps), track recording, and > playback. > Will select the "best" of multiple maps. > -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From greg at cosc.canterbury.ac.nz Tue Mar 20 21:22:30 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 21 Mar 2001 14:22:30 +1200 Subject: relational/boolean operator overloading -> PEP 207 References: <98tjq6$qre$1@news.flashnet.it> <994h71$ohq$1@news.flashnet.it> <996r1u$67f$1@panix6.panix.com> <9977ap$l05$1@news.flashnet.it> <997t73$p7i$1@panix3.panix.com> Message-ID: <3AB81066.38E5DFE9@cosc.canterbury.ac.nz> Aahz Maruch wrote: > > 5 In the current proposal, when A elementwise comparisons ... its interpretation as Boolean by > the shortcut operators raises an exception. That's a special case, though. In general, obj1 and obj2 will do the same as it does now on arbitrary objects -- i.e. evaluate to obj2 if obj1 is considered "true", otherwise obj1. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From greg at cosc.canterbury.ac.nz Thu Mar 1 19:55:47 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 02 Mar 2001 13:55:47 +1300 Subject: Collection interfaces References: <3a90fa97.0@news1.mweb.co.za> <3A933830.7F98D118@ix.netcom.com> <220220010813598042%cmh@bDistributed.com> <8Gem6.473353$U46.14105062@news1.sttls1.wa.home.com> <3A9A86B1.9A8C69A2@ix.netcom.com> <97fjla128ir@news2.newsguy.com> <97h5s40vhc@news2.newsguy.com> <97ifd60sen@news1.newsguy.com> Message-ID: <3A9EEF93.4B18FCA@cosc.canterbury.ac.nz> Topmind wrote: > > There is no polymorphism if there is > only one "type" with a bunch of independant attributes - > HAS-A reigns and sub-IS-A is rare. Polymorphism is not inherently dependent on any kind of inheritance or classification system. In Python, for instance, most functions are quite promiscuous and will happily operate on any objects which have the right methods, without there having to be any inheritance relationship between them. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From chris.gonnerman at usa.net Wed Mar 21 22:51:28 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Wed, 21 Mar 2001 21:51:28 -0600 Subject: CGIPython on BSD/OS (BSDI) ? Message-ID: <005801c0b283$69e8d3a0$a100000a@local> I have recently set up a personal web space account on Prohosting.com. They permit CGI but only support /bin/sh and perl. According to the FAQ they are running BSDI systems (meaning the "commercial" BSD/OS kernel). Has anyone on this list ported mxCGIPython to BSD/OS? Lemberg's site (http://www.lemburg.com/files/python/mxCGIPython.html) doesn't mention BSDI so obviously no one has sent it to him. Alternately, is there anyone who can build for this target? I'd do it myself but I've never before seen a BSDI system. From ws-news at gmx.at Mon Mar 12 05:51:14 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Mon, 12 Mar 2001 11:51:14 +0100 Subject: Can anyone recomend a good intoduction to C... References: Message-ID: <984394558.795085@newsmaster-04.atnet.at> The string module and methods are a perfect example that it is somewhat hard to have _only_ one passibility of doing things. What is perfectly fine and state-of-the-art today will probably look poor and old fashioned in some years. But I agree that there should be at least one _obvius_and_easy_ way to perform every task. regards werner Tim Peters wrote in message news:mailman.984256456.30652.python-list at python.org... > [Werner Schiendl] > > What's TMTOWTDI, please? > > [Fran?ois Granger] > > There is More Than One Way To Do It > > > > which is a Perl motto as far as I know. > > Right! My automobile license plate reads > > TOOWTDI > > Honest. I will know that my work on Python is finally complete when the > average American looks at my license plate and nods in silent agreement. I'm > not there yet. So far, approximately 100 out of 100 look at it, ponder, then > start making noises like some demented 170-pound bird with a broken beak. > > perhaps-i'd-have-better-luck-if-i-moved-to-california-ly y'rs - tim > > From dsh8290 at rit.edu Thu Mar 8 09:52:38 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 8 Mar 2001 09:52:38 -0500 Subject: gah! I hate the new string syntax In-Reply-To: ; from mycroft@actrix.gen.nz on Thu, Mar 08, 2001 at 06:51:07PM +1300 References: Message-ID: <20010308095238.A2645@harmony.cs.rit.edu> On Thu, Mar 08, 2001 at 06:51:07PM +1300, Paul Foley wrote: | On Wed, 7 Mar 2001 15:33:30 -0500, D-Man wrote: | | > What about one who is both English and Scots, yet never set foot on | > that island ;-)? | | AFAIK, nobody outside the US would admit the existence of such a | thing. The American habit of calling themselves "Irish" or "Italian" | or whatever when they're not is *very* strange. I've never heard | anything like it anywhere else. Heh. Maybe Americans are very odd. Wouldn't surprise me at all. ;-) I was born in America and have lived in America all my life. I do have English, Scots, Irish and Welsh ancestry though. One could argue that I am not really American since none of my ancestors came from America. "Real" Americans would be the so-called "Indians", or more appropriately "Native Americans". (Also Aztecs, Inca, etc., and their descendants such as the Quiche) -D From tuttledon at hotmail.com Thu Mar 22 20:50:23 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Fri, 23 Mar 2001 01:50:23 GMT Subject: PyUnit in Python 2.1 standard library References: <3ABA8A23.85EA76CE@downright.com> Message-ID: "Doug Fort" > Just recieved word that Steve Purcell has checked PyUnit into the > standard library. Aside from being a useful tool to me PyUnit typifies > the kind of development that ESR advocates in 'The Cathedral and the > Bazaar'. A project started to 'scratch an itch', then shared with the > communityto evolve and grow. None of the stuff I work on seems to come > out so clean. Congratulations Steve! PyUnit is an example to us all. So what kind of itch does PyUnit scratch? Don From cce at clarkevans.com Tue Mar 6 14:20:40 2001 From: cce at clarkevans.com (Clark C. Evans) Date: Tue, 6 Mar 2001 14:20:40 -0500 (EST) Subject: Can Python replace Visual Basic? Should it? In-Reply-To: Message-ID: > > Face it, most VB users aren't exactly star programmers. If I were > > That's a sweeping generalization, that I'd be very careful about > making, to say the least. There is one thing that I would point out. In the corporate environment actually 'laying-in-code is really a minor part of an individuals job. Getting the requirements, talking to the users, managing expectations, building test plans, drawing up a design, working out impacts on other applications, getting buy-in for the extra field you need on a common table, getting your data model approved, supporting the previous version of the program, etc., all take up considerable time. When it comes down to it, when I was in a corporate setting, I only got to 'code about 10 hours a week. What GUIs do is let you 'jump into the process and continue to work. In other words, they are good at helping to remind you where your context is... you just press play and see what breaks! > I'll certainly admit that I've only got about 7 months worth of experience > in "the industry", but of all the programmers I know of that had more than a > passing interest in VB (in other words, they liked and used it enough that > one might refer to them as "A VB Programmer(TM)"), at LEAST three (of the > six that I'm thinking of) were extremely bright and creative hackers. From > my perspective, I would be proud to be as good as they are! In general, VB is a good "put-the-components-together" tool. Quite a few, although not the majority of VB programmers that I know are very good at many other languages. And ones like me use VB to prototype a feature, and then I re-write it as an MSVC OCX so that it can be shared across the enterprise. > That said though, the stereotype of VB programmers all being idiots is > extremely common among Linux and Unix users, who, in many cases have almost > no knowledge of the tool, and would look silly themselves if throw into a > large project that used it ("silly" as in far from the creative geniuses > they would seem to indicate they are). Hear Hear! But, alas, no Holy Wars. I see Python as my new "put-the-components-together" tool. And possibly even a "make-the-components-tool", but I that remains to be proven to me. Kind Regards, Clark From scarblac at pino.selwerd.nl Mon Mar 19 09:06:31 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 19 Mar 2001 14:06:31 GMT Subject: The order of classes References: <9r3cbt04tg3c3li151416n9b2a0gg3eccb@4ax.com> Message-ID: Daniel Klein wrote in comp.lang.python: > Is it a requirement to place classes in a particular order if one class uses > another in its __init__ method? *In* its method, no. But below, you use it as a default argument for the method, and those are evaluated when the 'def' is executed - and at that moment, foo isn't defined yet, so you get an error. > To illustrate this in its simplest form... > > class bar: > def __init__(self, f = foo()): > pass > > class foo: > def __init__(self): > pass > > ...then at the interactive prompt... > > >>> import foobar > Traceback (innermost last): > File "", line 1, in ? > import foobar > File "C:\DanielK\python\foobar.py", line 1, in ? > class bar: > File "C:\DanielK\python\foobar.py", line 2, in bar > def __init__(self, x = foo()): > NameError: There is no variable named 'foo' > > ...however, it works if I reverse the order of the classes and put 'foo' before > 'bar'. > > I would like to keep my classes in a particular order but it does not appear > that I can do this in all cases. Don't use default arguments like this. You do realize, that even if you put the definition of foo before bar, that every instance of bar will have *the same foo instance* as its default argument? The 'f = foo()' happens only once, namely when the class is defined. Try something like this: class bar: def __init__(self, f = None): if f == None: f = foo() class foo: pass Now the 'f = foo()' happens when a bar instance is created, and at that time, foo already exists. -- Remco Gerlich From mcfletch at home.com Thu Mar 29 09:11:18 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Thu, 29 Mar 2001 09:11:18 -0500 Subject: Basic Question: 2.0 --> 2.1 do extensions need to be recompiled? Message-ID: <000001c0b85a$1fec6f50$a9807018@cr706570a> I'm short on time this week, so I'd rather not have to get Python, Numeric, etceteras just to compile PyOpenGL if it isn't necessary. So, is recompilation required for extension modules compiled for 2.0 to work with 2.1? Thanks all, Mike __________________________________ Mike C. Fletcher Designer, VR Plumber http://members.home.com/mcfletch From loredo at spacenet.tn.cornell.edu Mon Mar 12 18:34:24 2001 From: loredo at spacenet.tn.cornell.edu (Tom Loredo) Date: Mon, 12 Mar 2001 18:34:24 -0500 Subject: ZODB and OSX References: Message-ID: <3AAD5D00.C91265FB@spacenet.tn.cornell.edu> Howdy- Robert L Hicks wrote: > > The current beta says that it will compile on OSX. ZODB would be a great > thing to have as well! I compiled the ZODB parts of Zope for Python1.5.2 under OS9 last summer, and I have a similar port for Python2.0. However, I'm only just learning ZODB myself and haven't exercised either of these ports (which is why I haven't put them on the web yet). If there are Mac users interested in these, feel free to drop me a line. -Tom Loredo From akuchlin at mems-exchange.org Thu Mar 22 17:41:19 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 22 Mar 2001 17:41:19 -0500 Subject: Is setup.py a "good thing"? (long) References: <3aba76e2.167083508@24.0.228.33> Message-ID: <3dvgp1zasw.fsf@ute.cnri.reston.va.us> support @ internetdiscovery.com (Mike Clarkson) writes: > #1) Someone documented what setup.py is supposed to do, and how it is > supposed to interact with configure and make. I've written most of setup.py, so I'll comment. It arose from the observation that most people don't edit the Module/Setup file and turn on all the modules they could possibly run. This is annoying because there are bunches of modules there that are useful, but you can't really count on them being very widespread -- how many people uncomment, say, the syslog module when they compile from source. There was some work done for 2.0, and during the 2.0->2.1 development process, on making configure check for the BSDDB library, several DBM variants, and curses, but this didn't approach the number of modules available in Setup, and the process of supporting a module -- hack configure.in, which in turn built a Setup.config file -- was messy and complicated. (This was before the Makefiles were rewritten to be non-recursive and the build process tidied up in various ways. It's quite possible that perhaps this will make adding modules to configure and setup.py is no longer such a burning need.) > #3) Python configure had the configure options --with-tcl-config and > --with-tk-config so I could say explicitly where what I want is. This If a module is enabled in Modules/Setup, then setup.py won't try to build it, so you could just enable Tkinter there with whatever options are required. --amk From rodrigc at mediaone.net Sun Mar 25 01:47:55 2001 From: rodrigc at mediaone.net (rodrigc at mediaone.net) Date: Sun, 25 Mar 2001 06:47:55 GMT Subject: Python Mega Widgets rpm spec file? Message-ID: Hi, I am using John Grayson's book "Python and Tkinter Programming" to learn how to develop GUI's under Python. I developing under Redhat Linux 7.0 which comes with Python 1.52 and Tkinter. Grayson's book refers to Python Mega Widgets (Pmw) quite a bit, but this does not come standard with Redhat distributions. Has anyone made an rpm spec file for Pmw, so that it can be installed as an rpm package? I like to work on Redhat systems, and would like to deploy my GUI to other Redhat systems, without having to package up 3rd party libraries which are not included as part of the base distribution. Thanks for any help. -- Craig Rodrigues http://www.gis.net/~craigr rodrigc at mediaone.net From aleaxit at yahoo.com Fri Mar 30 09:21:49 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 30 Mar 2001 16:21:49 +0200 Subject: Is inheritance broken? References: Message-ID: <9a24q50684@news1.newsguy.com> "Jonathan Claggett" wrote in message news:mailman.985883539.13017.python-list at python.org... [snip] > styles (OOP Fu :-). I just checked* and it appears Scott Meyers has a book > on effective programming which I now intend to purchase. Obviously, there is Be warned, though -- Scott's excellent book is specifically on _C++_. If that's what you want, fine (just be sure to get the CD version, it's MUCH richer & better value for money) -- but it's NOT a general book on programming, nor, alas, is it about Python. Alex From hungjunglu at yahoo.com Sun Mar 11 17:59:37 2001 From: hungjunglu at yahoo.com (hungjunglu at yahoo.com) Date: Sun, 11 Mar 2001 22:59:37 -0000 Subject: Chinese text GIF file generation Message-ID: <98h00p+bqc2@eGroups.com> --- In python-list at y..., William Park wrote: > Because there is so many variables (ie. font, style, size, ...), I don't > think there is package that does what you want. However, you can use > LaTeX to produce Postscript format, and then convert it into GIF. There surely are existing packages. Just visit any of the Chinese news portals (e.g: www.sinanet.com) and you'll see what I mean. Unlike Korean or Japanese, or even Vietnamese, for Chinese websites, it is usually a better idea to present text in GIF than in multi-byte encoding schemes. The thing is, there is a big need out there for real-time or quasi-real-time on-the-fly GIF generation of Chinese text in GIF format. Anything that involves an intermediate manual process is unacceptable. (Besides, it's easy to do it manually on any PC: screen capture + format conversion and you are done. It's just time-consuming.) For websites containing multiple foreign languages in the USA, text-to-gif converters is a real necessity: you don't want to show jibberish to your visitors. Writing these packages in Java is a bit involved, but not that hard. I am pretty sure that the C library has been written, since someone else has mentioned it to me a long time ago. Imagine the number of Chinese computer geeks out there: it is unthinkable that this thing has not been done. (Of course there might be legal issues with GIF, but PNG will be fine.) Hung Jung From paulp at ActiveState.com Tue Mar 13 22:22:51 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Tue, 13 Mar 2001 19:22:51 -0800 Subject: Where can I find Docs on how to use the debugger please? References: <3lltat8tgd86rknhgnqkij6bk9rkbqk824@4ax.com> Message-ID: <3AAEE40B.4ACD89D7@ActiveState.com> cmfinlay at SPAMmagnet.com.au wrote: > > Where can I find Docs on how to use the debugger please? > > I am using the Win32 version of Python 2.1 > > I would like to set a breakpoint > and then later step down the source code line by line. > and view the source code as it is executed. There are actually several Python debuggers and it is hard to know which one you are asking about. How did you get into the debugger? What is on the menu bar? Or are you talking about the command line debugger? -- Python: Programming the way Guido indented it. - (originated with Skip Montanaro?) From bernhard at abnoba.intevation.de Wed Mar 28 10:01:52 2001 From: bernhard at abnoba.intevation.de (Bernhard Reiter) Date: 28 Mar 2001 15:01:52 GMT Subject: Linux GPS program References: <3AC01637.4EF3A6F2@crynwr.com> <99q3ob$ehr$1@newsserver.rrzn.uni-hannover.de> <3AC0D79E.ADED2832@crynwr.com> Message-ID: <99sud0$m7a$1@newsserver.rrzn.uni-hannover.de> In article <3AC0D79E.ADED2832 at crynwr.com>, Russell Nelson writes: > Bernhard Reiter wrote: >> will pygps be Free Software? I could not find anything about a >> license in the cvs. > > Yes, it will. Right now, I want people to fetch it from the CVS so > they have the latest-n-greatest. Well right now there is no usage term blurb attached, so the default would be that the user does not have the necessary freedoms to make it Free Software. If you want it to be Free Software, attach a license (maybe MIT style or LGPL). Just put it into CVS. People will still have no tarball. If you ask them for not distribution their changes on their own I do not see why somebody would want to do this. If they don't care for your copyright, they can still produce "rogue" versions now... >> If it was I will be happy to add it to the www.freegis.org >> link collection. > > It's free software now -- I just don't want rogue versions that would be > hard for me to integrate back into the mainline branch. Feel free > to suggest changes. Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From corour01 at motorola.com Wed Mar 21 06:57:15 2001 From: corour01 at motorola.com (O'Rourke Clodagh-corour01) Date: Wed, 21 Mar 2001 11:57:15 -0000 Subject: Tkinter Problem - NameError Message-ID: <13EE655665F4D311AB4D0008C789498A01EE2C91@zei02exm02.cork.cig.mot.com> From: Fredrik Lundh [mailto:fredrik at pythonware.com] >Looks like recursive from-import problems Ahh yes thanks a million. I was using import-* instead of import. However now my functions which close the current window and open a new one don't work it was for example def newCellWindow self.destroy() Cell.(self.parent) How do I call the constructor of the Cell class from another class to which Cell is imported? Thanks again, Clodagh. From smnordby at yahoo.com Sat Mar 31 19:07:43 2001 From: smnordby at yahoo.com (Steve) Date: Sat, 31 Mar 2001 16:07:43 -0800 Subject: I want to learn PYTHON! References: <1iqx6.3744$aD4.234302@news2.atl> Message-ID: <3AC6714F.F3EAC690@yahoo.com> Step one: Go to http://www.python.org and download Python version 2.0 for Windows. Step two: Run it to install Python. Step three: Go to http://www.crosswinds.net/~agauld and follow his programming tutorial. Step four: Join the Python Tutor mailing list (you'll find info on the python.org website). Step five: Read this newsgroup regularly. HTH -SteveN- KEVIN wrote: > > Where do I start. > > I am not a programmer but have an intermediate level of computer knowledge > in Windows only. > > -- > KEVIN > > "Si hoc legere scis, nimis eruditionis habes." > ----------------------------------------------------------------- > Please repond in the newsgroup. > My email address is altered for anti-spam > Just change .nOt to .net From vecernik at aon.at Wed Mar 28 09:32:35 2001 From: vecernik at aon.at (Oliver Vecernik) Date: Wed, 28 Mar 2001 16:32:35 +0200 Subject: diff lists References: Message-ID: <3AC1F603.A1074A7B@aon.at> "Mike C. Fletcher" wrote: > >>> [ element for element in a if element not in b ] # python 2.0+ Works great! Thank you. Regards, Oliver From max at alcyone.com Wed Mar 7 23:53:15 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 07 Mar 2001 20:53:15 -0800 Subject: is it possible to use Tkinter on linux References: <98714n$3p8$1@news2-2.kornet.net> Message-ID: <3AA7103B.CE819252@alcyone.com> rambo wrote: > someone knows that it is possible to use Tkinter on linux? Yes. > if it is, what program I should need to use Tkinter on linux, > how to install , which environment variable should I set. An RPM is downloadable from http://www.python.org/2.0/ -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ My life was better before I knew you. \__/ Edith Wharton (to Morton Fullerton) Polly Wanna Cracka? / http://www.pollywannacracka.com/ The Internet resource for interracial relationships. From edcjones at erols.com Sat Mar 17 12:29:46 2001 From: edcjones at erols.com (Edward C. Jones) Date: Sat, 17 Mar 2001 12:29:46 -0500 Subject: Debugging Python extensions (was Re: image handling) References: <2tLs6.1193$4N4.107379@newsc.telia.net> Message-ID: <3AB39F0A.6EB4E1C5@erols.com> Fredrik Lundh wrote: Can this product or something like it be used to debug both the Python and the C of a Python extesnion module? From erno-news at erno.iki.fi Tue Mar 27 05:45:43 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 27 Mar 2001 13:45:43 +0300 Subject: Namespaces question References: Message-ID: In article , Chris Withers writes: | What should I be using instead of locals()? you aren't supposed to alter the dictionary returned by locals. try using exec if you really want to do this, although it would probably be better to just put the values in a regular dictionary. -- erno From tjg at exceptionalminds.com Sat Mar 17 15:24:53 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Sat, 17 Mar 2001 12:24:53 -0800 Subject: md5 passwords In-Reply-To: <87elvwvq59.fsf@psyche.dnsalias.org>; from c.evans@clear.net.nz on Sat, Mar 17, 2001 at 07:57:38PM +1300 References: <87elvwvq59.fsf@psyche.dnsalias.org> Message-ID: <20010317122453.B24992@trufflehunter.avalongroup.net> I will do. Thanks. Thanks to all who have been kind enought to respond to this question. On Sat, Mar 17, 2001 at 07:57:38PM +1300, Carey Evans wrote: > Timothy Grant writes: > > I would like to be able to be able to os.system('useradd -p > > md5/crypt username') > > Have a look at Michal Wallace's `md5crypt.py' module, which should do > this for you: > > http://www.sabren.net/code/python/crypt/ -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Red Hat Certified Engineer www.exceptionalminds.com Avalon Technology Group, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 60 days 3 hours ago<< From danielk at aracnet.com Tue Mar 27 09:02:43 2001 From: danielk at aracnet.com (Daniel Klein) Date: Tue, 27 Mar 2001 06:02:43 -0800 Subject: Executing external programs References: Message-ID: <3971ct8tq60d44mc65b1758fkfho9jbfac@4ax.com> On Tue, 27 Mar 2001 21:13:28 +1000, "Ben" wrote: >Hi, > >this appears to be a simple problem ... but i can not find any documentation >on this ... could anyone point me to a rescource that would have an answer >to this solution ... > >All I want to do is > > run program1.exe -args > > ... when program1.exe is finished > >run program2.exe -args ... > >run program3.exe -args > >etc etc > > ie the next process waits for the preceding processes exit code before >starting ... if I can avoid the overhead of having the command shell open >everytime I run an exe that would be good. Methinks you should look at os.system(). Daniel Klein From guido at digicool.com Sat Mar 3 15:07:09 2001 From: guido at digicool.com (Guido van Rossum) Date: Sat, 03 Mar 2001 15:07:09 -0500 Subject: [Python-Dev] Re: Bug fix releases In-Reply-To: Your message of "Sat, 03 Mar 2001 14:55:09 EST." References: Message-ID: <200103032007.PAA21925@cj20424-a.reston1.va.home.com> > [Fred L. Drake, Jr.] > > ... > > Managing the bugfix releases would also be an excellent task for > > someone who's expecting to use the bugfix releases more than the > > feature releases -- the mentality has to be right for the task. I > > know I'm much more of a "features" person, and would have a hard time > > not crossing the line if it were up to me what went into a bugfix > > release. [Uncle Timmy] > Note there was never a bugfix release for 1.5.2, despite that 1.5.2 had some > serious bugs, and that 1.5.2 was current for an unprecedentedly long time. > Guido put out a call for volunteers to produce a 1.5.2 bugfix release, but > nobody responded. Past is prelude ... > > everyone-is-generous-with-everyone-else's-time-ly y'rs - tim I understand the warning. How about the following (and then I really have to go write my keynote speech :-). PythonLabs will make sure that it will happen. But how much stuff goes into the bugfix release is up to the community. We'll give SourceForge commit privileges to individuals who want to do serious work on the bugfix branch -- but before you get commit privileges, you must first show that you know what you are doing by submitting useful patches through the SourceForge patch mananger. Since a lot of the 2.0.1 effort will be deciding which code from 2.1 to merge back into 2.0.1, it may not make sense to upload context diffs to SourceForge. Instead, we'll accept reasoned instructions for specific patches to be merged back. Instructions like "cvs update -j -j " are very helpful; please also explain why! --Guido van Rossum (home page: http://www.python.org/~guido/) From aahz at panix.com Mon Mar 26 18:46:35 2001 From: aahz at panix.com (Aahz Maruch) Date: 26 Mar 2001 15:46:35 -0800 Subject: warrior geeks References: <3ABF72F1.98CB78F@sage.att.com> Message-ID: <99okcr$mt1$1@panix3.panix.com> In article , Tim Churches wrote: > >I'll use our time zone advantage to jump in early on this thread and >opine that it is way off-topic. Not that I am opposed to >marital...whoops...martial arts (although they are not my cup of tea), >but I am concerned that if this threads continues, sooner or later >someone will mention the whole "Geeks with Guns" thing that Eric S. >Raymond promotes (see http://www.tuxedo.org/~esr/geeks-with-guns/ or for >even worse IMHO see http://www.tuxedo.org/~esr/guns/ ), especially given >ESR's apparent fondness for Python. That sort of thing gives me a fit of >the shudders (playing with guns, not ESR's fondness for Python). What are you? Some kind of Commie? Guns form the very foundation of the Pax Americana that gives you the freedom to use Python. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Boost the stock market -- fire someone" From mda at idatar.com Sat Mar 17 13:36:13 2001 From: mda at idatar.com (David Allen) Date: Sat, 17 Mar 2001 18:36:13 GMT Subject: image handling References: Message-ID: In article , "Michael Hall" wrote: > G'day people: > > I'm brand new on this list and am looking for resources about image > processing in a web environment in Python. I'm wondering if there exists a > module that does things like the PHP image handling functions > (creating, copying, resizing, etc). > > I've had a look at the Python Functions Library but there doesn't appear to > be much in there. I've started to use Python a bit in a web environment and > like what I've seen so far, and from what I've heard I'm sure there must be > some pretty flash image handling capabilities hanging around somewhere. Sounds like you're looking for the Python Imaging Library (PIL) http://www.pythonware.com/library/the-pythonware-image-library.htm -- David Allen http://opop.nols.com/ ---------------------------------------- Be wary of strong drink. It can make you shoot at tax collectors and miss - Lazarus Long, "Time Enough for Love" From aleaxit at yahoo.com Thu Mar 15 07:11:39 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 15 Mar 2001 13:11:39 +0100 Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> <20010312170356.B3513@better.net> <984486395.407379@newsmaster-04.atnet.at> <984518199.127140@newsmaster-04.atnet.at> <98ohuc$du9$1@news.udel.edu> <7bQr6.644$lz1.17686@ruti.visi.com> <984610248.564504@newsmaster-04.atnet.at> Message-ID: <98qbhk02dck@news1.newsguy.com> "Werner Schiendl" wrote in message news:984610248.564504 at newsmaster-04.atnet.at... > > In fiancial calculations you also need to represent numbers > > that aren't amounts of money. Interest rates for example. > > How about 1/100 of a percent? (Normally called a "basis point", btw -- at least when one is discussing _changes_ in a security's yield). Alex From winkler at abaqus-sn.com Thu Mar 29 12:49:09 2001 From: winkler at abaqus-sn.com (david winkler) Date: Thu, 29 Mar 2001 17:49:09 GMT Subject: how query function args Message-ID: <3AC375A5.507C4D73@abaqus-sn.com> I need to query the names and values of a function's keyword arguments. I suspect that there is an easy way to do this but cannot find it. Would someone care to make a suggestion? From aleaxit at yahoo.com Fri Mar 30 15:46:44 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 30 Mar 2001 22:46:44 +0200 Subject: best practice? null/None (correction) References: <9a2b9v+lrgp@eGroups.com> Message-ID: <9a2rnd011au@news1.newsguy.com> "Robin Thomas" wrote in message news:mailman.985976988.3926.python-list at python.org... > At 11:58 AM 3/30/01 -0500, Robin Thomas wrote: > >HTTP query arguments are of one type: STRING. There is no concept of a > >"null" value; the closest thing you have is an "empty" string like "". In > >most database engines, there is a clear difference between NULL and "" in > >any textual or character data column. > > I'm sorry to be outright WRONG here, fluxent. > > Many databases consider "" to be NULL for textual columns. Oracle 7 and up > certainly does. Wok?! I _thought_ Oracle was an RDBMS -- fun to hear that it isn't (proper treatment of NULL as distinguished from any data value being one crucial requisite for being called an RDBMS). Guess I'll stick with SQL Server/MSDE then... Alex From neotaku at free.fr Mon Mar 5 10:23:00 2001 From: neotaku at free.fr (Neotaku) Date: Mon, 05 Mar 2001 15:23:00 GMT Subject: Access to sybase API Message-ID: Hello everybody I search a code source for python to access Sybase thru API connexion the Sybase DB-Library API or Sybase CT-Library (aka the Client Library) API Thanks a lot see ya From jmarshal at mathworks.com Wed Mar 14 12:49:08 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 14 Mar 2001 17:49:08 GMT Subject: Who's minister of propaganda this week? References: <98nu1m$12e@dispatch.concentric.net> <3AAFA861.C773D977@san.rr.com> Message-ID: <98oauk$j8j$1@news.mathworks.com> Darren New wrote: > Phlip wrote: >> Ruby trumps Python in the simple matter of >> closures (imagine my shock when I discovered Python didn't have them). > Can someone summarize the important difference between closures and object > instances? Other than convenience, I mean, it would seem that something like > class yadda: > def __init__(self, a, b): > self.a = a ; self.b = b > def __call__(self, x, y): > return (self.a + x * self.b * y) > would seem to be quite a lot like a closure with a and b bound and x and y > free? Yup. Object instances and closures are very similar. Scoping issues aside, you can think of closures as classless instances with only one method. From whisper at oz.net Sat Mar 10 20:14:35 2001 From: whisper at oz.net (Dave LeBlanc) Date: 11 Mar 2001 01:14:35 GMT Subject: Urgent Question about Python licensing References: Message-ID: <98ejhr$38q$0@216.39.170.247> Dear Tim; When UCITA first came out, there was a lot of press about it's evils. Statements where made that a licensor could impose new license clauses after the fact and unilaterally, that "shrink wrap" licenses became automagically binding, that a licensor could make a choice of venue for resolution of legal issues anywhere in the world, and that a licensor could create software that the licensor could remotely disable (presumably via the internet) the software you've licensed. After your statement that that was a "most concentrated pile of absurdist FUD", I went back and did some further research intent on proving you incorrect. After all, this was reported by some regular news organizations (InfoWord, CNET etc.) so how could they be wrong?! However, after reviewing information at http://www.ucitaonline.com/ and at http://www.2bguide.com, I came to the conclusion that i'd been mislead. Imagine! being mislead by the press! . (I should have known better - i'm a firm believer in the "believe none of what you hear and only half of what you read" school of thought.) As it turns out, after the fact license changes are NOT binding, "shrink wrap" or "click wrap" licenses ARE binding and have been upheld by the courts, can't make a bogus venue choice, and that a licensor CAN unilaterally disable software but only after a 2 week warning in many cases. http://www.2bguide.com/newsart.html does have a lot of links to the news articles I recall about the evils of the UCITA, but http://www.ucitaonline.com has a good FAQ which addresses and rebuts the claims of it's evilness. FWIW, this FAQ is worth reading, particularly if you're a small software business entrepeneur. UCITA adds some implicit waranties worth checking into. It also turns out that Virginia's law adopting UCTIA doesn't take effect until July 2001, so whatever laws Virginia currently has would apply to Python 1.6+ and not the UCTIA. So, I was incorrect wrt to my statement about unilateraly chages etc. My apologies to any who where mislead and alarmed by my post. Moving along, I find it ironic that the Open Software Foundation calls the GPL an open source license since it violates the rules given for such. GPL software has source available, but it's use is constrained and contaminating (unlike the GLL library license). Regards, Dave LeBlanc P.S Guido is welcome to my first born if I ever have one - but he has to do his own cooking. On Sat, 10 Mar 2001 14:59:21 -0500, "Tim Peters" wrote: >> 3. Is Python 2.0 covered by that evil CNRI 1.6 license? > >2.0 is covered by CNRI's 1.6 license, as well as by BeOpen.com's minor >variation on that. I disagree that it's evil, although the way it was >imposed on the community was exceedingly ham-handed, and it has created >problems due to its purported incompatibility with the GPL. > >> I avoided 1.6 mostly because of the license, and thought that 2.0 had >> "skipped" 1.6 and used a far more equitable license then the 1.6 one. > >I suggest you read the licenses in question (you clearly have not yet). > >> 1.6's license permits the copyright holder to suddenly decide that >> anyone using the covered software must pay a fee (or any other thing they >> so desire - this is only an example), and by virtue of your even so much >> as having read the license are implicitly bound to their unilateral >> declaration - lovely Virginia laws). > >No offense intended, Dave, but this is the most concentrated pile of >absurdist FUD I've seen in a solid year of ill-informed license rants. Even >by the FSF's standards, the CNRI 1.6 license is a "free software" license >(see "The License of Python 1.6b1 and later versions", at: > > http://www.fsf.org/philosophy/license-list.html > >). > >the-2.1-license-will-require-giving-your-firstborn-to-guido-ly y'rs - tim > > From porter at et.byu.edu Tue Mar 20 13:53:00 2001 From: porter at et.byu.edu (C. Porter Bassett) Date: Tue, 20 Mar 2001 11:53:00 -0700 (MST) Subject: Insertin **keywords into a class In-Reply-To: <99877b$uss$1@nntp6.u.washington.edu> References: <9960i1$tp0$1@nntp6.u.washington.edu> <99661m$scc$1@panix6.panix.com> <99877b$uss$1@nntp6.u.washington.edu> Message-ID: cCan you please tell me why the following code snippet doesn't update the value of radius? class myClass: def __init__(self, *arguments, **keywords): self.radius = 0.0 for kw in keywords.keys(): print kw, ":", keywords[kw] self.kw = keywords[kw] print "self.radius =", self.radius b = myClass(radius = 1.0) -------------------------------------------------------------------------- "Pretend like this is a really witty saying." - Anonymous -------------------------------------------------------------------------- From rtexier at elikya.com Fri Mar 30 03:11:12 2001 From: rtexier at elikya.com (Romuald Texier) Date: Fri, 30 Mar 2001 10:11:12 +0200 Subject: htmllib samples References: <3AC2F48E.4EF77C71@aon.at> <3AC3296D.E24DBA02@downright.com> Message-ID: <9a1f2i$72v$1@news.irisa.fr> Doug Fort wrote: > I've attached a simple parser we use. It may help. > > Note that Frederick Lundh modestly failed to mention his upcoming book on > 'The Python Library'. There's an ebook version of his 'eff-bot' Guide, > which is the first place I look for code examples. > It looks very interesting but what is this webnudge module you are using? I can't find it anywhere... Thank you, -- Romuald Texier From gkiffney at my-deja.com Thu Mar 22 11:45:13 2001 From: gkiffney at my-deja.com (gkiffney) Date: Thu, 22 Mar 2001 11:45:13 -0500 Subject: os.system output References: Message-ID: <9%pu6.792$9%.208326@newsr1.maine.rr.com> If you're on Unix, you can use 'commands'. import commands res = commands.getoutput('ls') and res will be a long string with the output of 'ls'. To make a list out of res, you'd just do import string dirlist = string.split(res, '\n') "Jonathan Soons" wrote in message news:mailman.985192771.32528.python-list at python.org... > I am trying to save the output of > > >>>dirs = os.system('ls') > > into a variable but I do not need any output to > the screen (altho it doesn't hurt). How do I > go about this? > My fat book only explains how to get output to the screen. > > I could do > > >>>os.system('ls > file') > >>>f = open('file') > >>>dirs = f.readlines() > > but it looks crude. Is there a better way? > From fredrik at pythonware.com Fri Mar 16 12:41:56 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 16 Mar 2001 17:41:56 GMT Subject: Python style questions References: <98tb91$9t9$1@saltmine.radix.net> <98tclh$ap6$2@lahti.tasking.nl> <98th1k$ka2$1@saltmine.radix.net> Message-ID: Cary O'Brien wrote: > Dick Streefland: wrote: > >c. use string.atoi(s, 16), or for Python >= 2.0, the builtin int(s, 16). > > Hmm... > > >>> int('abcd',16) > Traceback (innermost last): > File "", line 1, in ? > TypeError: int requires exactly 1 argument; 2 given > >>> > > Is this a 2.0 feature? that's probably what Dick meant with "Python >= 2.0", don't you think? Cheers /F From db3l at fitlinxx.com Tue Mar 13 18:08:24 2001 From: db3l at fitlinxx.com (David Bolen) Date: 13 Mar 2001 18:08:24 -0500 Subject: Divorcing Command Line and GUI References: <98dpoi32ckn@news1.newsguy.com> Message-ID: "Alex Martelli" writes: > Piece of cake -- just make sure your CL tools take a switch > (-u or --unbuffered) to work without any input buffers on > stdin/stdout, and similarly-unbuffered Python GUI front-ends > will be easily able to drive them (after an os.popen2). Or just pass the "-u" to python itself when running the command line script - no changes to scripts required. (Something I find extremely helpful to work with pre-existing scripts, unlike Perl where you have to modify the script itself to enable autoflushing.) -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From chrislamb at btinternet.com Sat Mar 24 05:48:42 2001 From: chrislamb at btinternet.com (chris) Date: Sat, 24 Mar 2001 10:48:42 +0000 Subject: learning python... References: <3AB8F4E1.184DD9C@noaa.gov> Message-ID: Benjamin.Altman wrote: > Hello. From the perspective of someone who already has programming > experience, would anyone know if O'reillys "Learning Python" book would > be better than say Prentice Hall's "Core Python Programming"? Or would > it be better to go straight into something like "Programming Python"? > > Thanks, > Ben "Core Python Programming "from PH is easily the better book for easing into Python. I am an O'Reilly fan and generally buy their books blind if it is on a subject I am interested in (since they very rarely disappoint). However on this occassion the PH book is a genuinely good book and worth buying, considerably more than the Learning Python book and the 2e version of Programming Python. My opinion! Chris From emile at fenx.com Tue Mar 27 10:22:15 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 27 Mar 2001 07:22:15 -0800 Subject: who is my caller? References: <99q8nv$2aibn$1@ID-11957.news.dfncis.de> Message-ID: <99qbdu$2a0et$1@ID-11957.news.dfncis.de> Well yes, but traceback gets its info by raising an exception anyway. -- Emile van Sebille emile at fenx.com --------- "Emile van Sebille" wrote in message news:99q8nv$2aibn$1 at ID-11957.news.dfncis.de... > > "Remco Gerlich" wrote in message > news:slrn9c18o0.ojm.scarblac at pino.selwerd.nl... > > > > > Anyways, yes, it's more like black magic in Python. There is a call stack > > you can inspect, but only if you just caught an exception. > > > > If I'm not mistaken, with 2.0 you can directly import traceback without > needing to generate an exception first. > > > -- > > Emile van Sebille > emile at fenx.com > > From shredwheat at mediaone.net Mon Mar 19 10:40:51 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Mon, 19 Mar 2001 15:40:51 GMT Subject: newbie - infinite loop References: <985012513.18971.0.nnrp-12.c1c3e154@news.demon.co.uk> Message-ID: <7Mpt6.72006$Ch.9139356@typhoon.we.rr.com> "Paul Brian" wrote > Surely this should not happen. Surely the line 3 condition "for every > element in this list", should not constantly expand but should be set solid > till the next pass? > > What have I done wrong - is it the mutable list v the immutable tuple > problem (but it should work..surely?) Or is this just the way things are - > "live with it and do not try anything like this again?" > > thanks in advance > ============== > uniqueList = ['q'] > line = 'q' > > for listElement in uniqueList: #infinite loop > if listElement == line: > uniqueList.append(line) > > print len(uniqueList) hello paul. this code should indeed loop forever. let's look and see why... it sounded like in your message, you only wanted to add items to the list if they weren't already in it. this section of code is doing something different. this is going through the list, and everytime it finds a match for a word, it is adding that word again. the way this loop is setup, the word will be added to the end of the list, and it will loop over the appended elements in the list. because of this, the code will keep finding the same word on the list and keep appending the same word to the end... infinitely. obviously this is not the best solution. there are several other ways you could do this. the way i would probably do it (not the best, likely) would replace the loop with this; if line not in uniqueList: uniqueList.append(line) it ends up being somewhat trickier to loop through a list and make sure an element isn't found. since it sounded like you wanted to see your loop fixed, i'll take a stab at it. remember, an 'else' statement in a for loop is executed when the loop is not 'break'ed for listElement in uniqueList: if listElement == list: break else: uniqueList.append(list) good luck, hopefully this was able to teach you a little something about python. btw, the looping method will definitely be slower than the "in" version. From stephen_purcell at yahoo.com Mon Mar 19 03:51:56 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Mon, 19 Mar 2001 09:51:56 +0100 Subject: How to find out about free space on a given drive? In-Reply-To: <3AB5C19E.FA40DDA9@darwin.in-berlin.de>; from gherman@darwin.in-berlin.de on Mon, Mar 19, 2001 at 09:21:50AM +0100 References: <3AB5C19E.FA40DDA9@darwin.in-berlin.de> Message-ID: <20010319095156.A12242@freedom.puma-ag.com> Dinu Gherman wrote: > is there a simple way (or any way at all) to find out for > any given hard disk how much free space is left on that > device? I looked into the os module, but either not hard > enough or there is no such function. Of course, the ideal > solution would be platform-independant, too... :) os.statvfs() seems to be what you want for UNIX. I don't think you'll find a cross-platform solution. -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From aleaxit at yahoo.com Mon Mar 26 14:22:13 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 26 Mar 2001 21:22:13 +0200 Subject: Is it possible to sort a dictionary? References: <3ABE771B.7B9E1631@student.liu.se> <99o33k$aq4$0@216.39.170.247> Message-ID: <99o51301qgb@news1.newsguy.com> "Dave LeBlanc" wrote in message news:99o33k$aq4$0 at 216.39.170.247... > How about: > > # prints the elements of myDictionary in sort order > # error handling needed (myKeys != none for example) > myKeys = myDictionary.keys() > myKeys.sort() > for key in myKeys: > print myDictionary[key] Fine! Even faster & simpler: myItems = myDictionary.Items() myItems.sort() for key, value in myItems: print value Alex From dan at eevolved.com Thu Mar 1 18:07:36 2001 From: dan at eevolved.com (Dan Parisien) Date: Thu, 01 Mar 2001 23:07:36 GMT Subject: Lower bounds of lists References: <2mjt9tcfa0o55ap99p452trjj3u7h3qst6@4ax.com> Message-ID: Michael Prager wrote: > As a newcomer to Python, I'm curious about the choice to number > list elements starting at zero, rather than one. My impression > is that there is no user option to change that in a specific > program. Correct? correct. > It seems an odd choice, as humans count from one, and Python in > other respects seems quite logical and well thought out. The reason this is so is historical. Writing a program involved having data contained in addresses in memory. Data's addresses were always offsets from a set address (say 5 bytes from the begining). Because of that it starts at zero (0 bytes from the beginning _is_ the beginning) It's the case in a lot of programming languages as well. Hope this helps, Dan From aleaxit at yahoo.com Wed Mar 7 05:25:46 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 7 Mar 2001 11:25:46 +0100 Subject: Can anyone recomend a good intoduction to C... References: <983896344.701456@newsmaster-04.atnet.at> <983911749.217622@newsmaster-04.atnet.at> <983916572.286918@newsmaster-04.atnet.at> Message-ID: <9852b8015jm@news1.newsguy.com> "Werner Schiendl" wrote in message news:983916572.286918 at newsmaster-04.atnet.at... > > C++ is far more complex that C without being much safer. Since > > the safety has to be "inspected" into the program, you want > > to make things as easy to inspect as possible: a nice simple > > language. > > That is of course a point, if you need to let the program inspect you will > try to keep it as simple as possible. > But given the same functionality, I think a C++ program will not be more > complex. The program will not be, the language is. It's a hard-to-judge tradeoff. > ...as long as it is well designed of course, nobody forces you to use any > number of features at all possible > > don't you think so? I do not: C++ *forces* "any number of features" on you -- you can't easily subset it and ENSURE features outside of the subset are not intruding. > Think about string operations: I think about 50 % of all security issues I > read about are somehow related with a (string) buffer overflow. The string > family of classes does not have that kind of problem. No, but it does have other issues -- e.g., std::string oneletter('A', 1); does NOT do what one might expect, nor does it give any warning in the implementations I have at hand (oneletter becomes a string of 65 characters all equal to '\001', not one of 1 character equal to 'A' -- oops, arguments the wrong way around...!-). The trade-off is no doubt a win for std::string here -- it removes many more issues than it introduces. But it's not so clear overall -- considering that you can't subset, not really. I think that C++ (used properly, particularly with STRONG reliance on GOOD libraries) is a definite net win over C, but I can well see somebody might disagree, most particularly when security-crucial applications are being targeted. (If I _could_ throw a switch to subset C++, _ensuring_ at least warnings for a zillion potential errors and complexities, the picture would of course change). Alex From aleaxit at yahoo.com Mon Mar 5 14:54:08 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 5 Mar 2001 20:54:08 +0100 Subject: Name of the Script References: <20010304.185354.2114937732.8277@localhost.localdomain> Message-ID: <980qsk02m1g@news1.newsguy.com> "David Given" wrote in message news:u0i089.7it.ln at 127.0.0.1... [snip] > in argv[0]. (This is the same as a the generic Unix question: `How do I > find out where my executable lives?' It's basically not solveable.) I > don't know about Windows, though. In Windows, location of the executable and/or dll IS solvable (there's a system-call, or API if you will, expressly for that), but you still would not learn 'exactly how' it was invoked (through ShellExecute, or through CreateProcess [which underlies it], through a shortcut, etc) -- and it does not help for an interpreter (you'd only learn about Python.Exe or thereabouts, not which script it started out executing!). Alex From s713221 at student.gu.edu.au Mon Mar 19 19:04:05 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Tue, 20 Mar 2001 10:04:05 +1000 Subject: Organizing Python References: <995ogm$1u6$0@216.39.170.247> Message-ID: <3AB69E75.CEDBC8AE@student.gu.edu.au> > from the module foo. A module is usually represented by a file, but it > is also possible to have it be a directory which I once read something > about on python.org, but I can't find it now. If you place a file called __init__ into a directory on your path, python imports that as the name of the directory. /python/path/FFT | ----->__init__.py #contains python instructions to load code from other | files | ----->other/files/and/directories which make up FFT >>>import FFT #Imports FFT/__init__.py >>>print "Handy, ain't it?" Another method is to put a file called module_name.pth into your python path, containing the name of a directory that the module is in. (What I've used to get Numeric working without fiddling with my /etc/profile or ~/.bashrc files.). less /usr/lib/python2.0/site-packages/Numeric.pth Numeric In this case, python loads the file with the name of the module /usr/lib/python2.0/site-packages/Numeric | ----> Numeric.py | ----> other numeric files >>>import Numeric # Imports Numeric/Numeric.py >>>print "A little bit messier, but maybe what the original poster was looking for?" Joal Heagney/AncientHart Joal Heagney/AncientHart From fredrik at pythonware.com Tue Mar 20 17:45:10 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 20 Mar 2001 22:45:10 GMT Subject: ASCII encoding error: ordinal not in range(128) References: <91o5ih$2kv$1@news.wrc.xerox.com> <20001219172933.B29727@ActiveState.com> Message-ID: Jose Isaias Cabrera wrote: > UnicodeError: ASCII encoding error: ordinal not in range(128) translated to english, this overly cute error message attempts to say something like "cannot convert this Unicode string to ASCII as it contains non-ASCII characters" > I've search on python sites for this, and though there is > something about Unicode, there is no python example code > to use. > > Does anyone have any idea how to fix this? summary: someone's handing you unicode strings (probably the COM interface), and you're trying to use them as 8-bit strings (probably by passing them to a method that expects 8-bit data) without specifying an encoding. (if you want me to be more precise, you have to show us more code). to solve this, you have to add an explicit conversion to the right place. e.g: s = u.encode("latin-1") where "u" is a unicode string and "s" an 8-bit ISO Latin string. (if you don't do this, Python will convert the string anyway when you pass it to an 8-bit function. the default conversion assumes ASCII, which is why you get that exception) Hope this helps! Cheers /F From thomas at xs4all.net Mon Mar 5 10:33:44 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 5 Mar 2001 16:33:44 +0100 Subject: Overriding UserList methods In-Reply-To: <2oc6atgkn0ror77rj3b6j8d8d2s0gaa5k7@4ax.com>; from danielk@aracnet.com on Sun, Mar 04, 2001 at 10:35:27PM -0800 References: <2oc6atgkn0ror77rj3b6j8d8d2s0gaa5k7@4ax.com> Message-ID: <20010305163344.A9678@xs4all.nl> On Sun, Mar 04, 2001 at 10:35:27PM -0800, Daniel Klein wrote: > I found the answer in the Beazley book. It's > def append(self, object): > self.data.append(object) > using the 'data' instance variable automatically set up in the UserList > class. But I'll try the other suggestions anyway just to get a better > understanding. Note that though this method is 'allowed' with UserList instances (because 'data' is not a private variable) it does break the encapsulation. If you were to change your class to derive from OtherModule.ExtendedUserList, which did some extra funky stuff before/after really appending to the data, you wouldn't get the new functionality. If you just used 'UserList.UserList.append(self, data)', you would, though you would have to remember to change all references from 'UserList.UserList' to 'OtherModule.ExtendedUserList'. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From grante at visi.com Sat Mar 31 01:22:40 2001 From: grante at visi.com (Grant Edwards) Date: Sat, 31 Mar 2001 06:22:40 GMT Subject: Know of Substantial Apps Written in Python? References: <3ac4e4a8_1@news4.newsfeeds.com> <3AC5529D.8D7BCC63@seebelow.org> Message-ID: On Fri, 30 Mar 2001 21:44:29 -0600, Grant Griffin wrote: Hi Grant, >Hey, I looked at that, and it looks cool. But I was somewhat >puzzled by the following statement: > > Sketch is an interactive vector drawing program for Linux > and other UNIX compatible systems. > > A somewhat unique(for a drawing program) feature of Sketch > is that it is implemented almost completely in a very > high-level, interpreted language, Python. > >If it's implemented almost completely in Python, why does it >only run on "UNIX-compatible" systems? (BTW, does it delete >hyphens? ) Is there something about its "almost" part >that can't be done in Windows. I believe it uses standard Tcl/Tk, PIL, and one module with support functions written in C. I would guess that the C stuff has never been ported to non-Unix platforms. It looks like some of the low-level drawing and rendering stuff is written in C (I presume for performance reasons), as well as some file-parsing and font manipulation routines. Hr. Herzog (Sketch's author) has been known to read c.l.p, and knows more about it that I do (I'm just a happy user -- since before I even knew what Python was.) -- Grant Edwards grante Yow! I smell a RANCID at CORN DOG! visi.com From syver at NOSPAMcyberwatcher.com Fri Mar 30 15:41:55 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Fri, 30 Mar 2001 22:41:55 +0200 Subject: Threading legality/morality References: <99nnbv$phs$1@panix6.panix.com> <99qa3v$6e0$1@panix6.panix.com> <99qogp$o6g$2@troll.powertech.no> Message-ID: <9a2r6n$mlq$1@troll.powertech.no> I have a confession to make here. It seems that this behaviour is a feature rather than a bug and has to do with the os rather than the app or python itself for that matter. (Inserts foot in mouth). If you click the mouse in the client area of a console window, the os freezes the application running there until you press a key. I guess it's for the convenience of copying text off of the console but it sure tripped me up. "Syver Enstad" wrote in message news:99qogp$o6g$2 at troll.powertech.no... > > "John J. Lee" wrote in message > Perhaps you're > right, but I've seen the same behaiviour on win95, without > > multi-threading. When you run command-line (do we mean the same thing by > > console and command-line?) apps it freezes until a key gets pressed. Not > > using urllib either. > > > > It is possible (likely, even) that I was using cygwin, so maybe that's > > where the blame lies. I'll see if I can reproduce it with the standard > > DOS shell. > > I am using console program/command line whatever you like, and I am not > using Cygwin. I've experienced this both on the BeOpen and ActiveState > distros. > > From mwh21 at cam.ac.uk Mon Mar 5 14:53:23 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 05 Mar 2001 19:53:23 +0000 Subject: ANNOUNCE: Python - The RPG References: <97he34$jhc$1@newshost.accu.uu.nl> Message-ID: m.faassen at vet.uu.nl (Martijn Faassen) writes: > Jim Fulton [snip] > Disadvantages: > > * Can inadvertantly make people's heads explode when attempting > to explain how something works, rendering them unable to think > very well for a while. This is a disadvantage *how*? Cheers, M. -- Hmmm... its Sunday afternoon: I could do my work, or I could do a Fourier analysis of my computer's fan noise. -- Amit Muthu, ucam.chat (from Owen Dunn's summary of the year) From bobhicks at nospam.adelphia.net Sun Mar 25 16:22:16 2001 From: bobhicks at nospam.adelphia.net (Robert Hicks) Date: Sun, 25 Mar 2001 21:22:16 GMT Subject: Python classes on east coast? Message-ID: Is there or are there any plans for Python classes on the east coast (preferrably around DC)? - Bob -- Bob Remove: the nospam. in my address if you want to email me From akuchlin at mems-exchange.org Thu Mar 29 15:43:42 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 29 Mar 2001 15:43:42 -0500 Subject: Looking for Python equivalent to a Perl'ism References: <3AC375A7.A4BA87F1@spammraqia.com> Message-ID: <3d3dbwwbk1.fsf@ute.cnri.reston.va.us> David Lees writes: > ---------- > my %dict; > my $string="this is xxfooxx this is junk xxmumblexx and more stuff"; > %dict=(foo=>"yechfoo",mumble=>"yukkomumble"); > > $string =~ s/xx(\S+)xx/$dict{$1}/g; > > print $string; > ------------ To simply substitute the contents of a single group, you can include \N, or \g: p=re.compile(r'zz(\w+)zz') s='this is and so is zzxxxzz abc that an zzyyyzz abc zzxxxzz or else' print p.sub('\g<1>', s) This produces "this is and so is xxx abc that an yyy abc xxx or else" You want to do a dictionary lookup, though; instead of passing a replacement string, you can pass a function which will be handed the match object, and can return whatever string it likes: def sub_func(match): return dict[ match.group(1) ] print p.sub(sub_func, s) This will output "this is and so is foo abc that an barf abc foo or else". Note that this raises an exception if the contents of group 1 aren't found in the dictionary, so 'zzrandomzz' will trigger a KeyError. Perl would probably just assume undef or the empty string or something like that, so sub_func() would have to be changed accordingly -- to dict.get(match.group[1], ""), perhaps. --amk From aleaxit at yahoo.com Mon Mar 5 12:25:20 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 5 Mar 2001 18:25:20 +0100 Subject: the demise of 'from foo import * and its implications? References: <3kVBAfATrDo6EwEM@jessikat.fsnet.co.uk> Message-ID: <980i6t017ag@news2.newsguy.com> "Steve Holden" wrote in message news:suPo6.16824$ML1.841861 at e420r-atl2.usenetserver.com... [snip] > I did begin to wonder whether it might be possible to specify a name prefix, > along the lines of > > from modulewithaverylongname import * prefix sh_ > > to allow > > sh_i But why not just import modulewithaverylongname as sh and then use sh.i ...? You can do that today, and the detailed semantics seem likelier to be what is desired (e.g., should attribute i of the module ever be re-bound, it's probably better to automatically pick up the new reference, as happens by using sh.i, than keep using the old one, as any 'from/import' approach would do -- marginal stuff, sure). Alex From qrczak at knm.org.pl Sun Mar 25 16:21:24 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 25 Mar 2001 21:21:24 GMT Subject: static methods References: Message-ID: Sun, 25 Mar 2001 12:37:43 -0800, Paul Prescod pisze: > Doh! Okay, it will work if you add it to the instances in the __init__: > > class Class: > def __init__(self): > self.staticmethod = _static What is static in this method? (You can't get it from the class for example, but need an instance.) -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From quickdry at users.sourceforge.net Thu Mar 22 08:25:32 2001 From: quickdry at users.sourceforge.net (Steven Adams) Date: Thu, 22 Mar 2001 13:25:32 GMT Subject: tempfile problem on win98 Message-ID: Hi, I'm using the tempfile module in Python 1.5.2 and it keeps giving me duplicate filenames. It's being called only once each time the script runs, (small cgi messageboard) with this is the code related to the tempfile: import tempfile tempfile.tempdir=SOME_DIRECTORY tempfile.template=None id=tempfile.mktemp() shouldn't this give me a unique value for id every time? I initially had it running without the tempfile.template being assigned None, but when I noticed the duplicate filenames, so I thought I'd try that. Currently I'm making it recompute tempfile names until it has one that does not already exist, but why does this happen?once I get a lot of messages in the system I don't want to be possibly iterating through the whole lot checking their names (unfortunately I don't have permissions or the space to use a proper database) thanks for any help, Steven From shonn at shonn.com Fri Mar 2 18:17:35 2001 From: shonn at shonn.com (Shonn Gilson) Date: Fri, 2 Mar 2001 15:17:35 -0800 Subject: Python, ASP, ADO, and Image string/binary problems Message-ID: Okay, here it goes. I have a site in ASP where I need to upload an image (already working) and then make a thumbnail of it. The image is stored in a MS SQL Server database, I'm using IIS5 (Win2k), and the python is Active State's with all the COM functionallity added. Here's what I'm trying to do: If I do a Response.BinaryWrite(bstrIn) I get the image in the browser but if I do Response.BinaryWrite(bstrOut.getvalue()) I get spaces between every character (I've seen this with unicode problems). It's not just an incompatibility with Response.BinaryWrite because I've written the results back to the database with the same results. It seems like it's a problem with how python deals with strings. Anyone have any ideas? Thanks in advance Shonn From aahz at panix.com Fri Mar 9 10:01:43 2001 From: aahz at panix.com (Aahz Maruch) Date: 9 Mar 2001 07:01:43 -0800 Subject: Can anyone recomend a good intoduction to C... References: <989cvj$sba$1@panix3.panix.com> <984132875.222868@newsmaster-04.atnet.at> Message-ID: <98ar8n$1rt$1@panix6.panix.com> In article , Steve Holden wrote: >"Werner Schiendl" wrote in message >news:984132875.222868 at newsmaster-04.atnet.at... >> >> What's TMTOWTDI, please? > >There's another programming language whose name begins with P, whose primary >philosophy is demonstrated in the well-known phrase" > > "There's More Than One Way to Do It" > >This means that it's more difficult to establish recognisable programming >idioms, because for every task there are between three and seventeen ways to >accomplish it, and the choice is usually made on efficiency grounds rather >than those of program readability. More often than that, the idiom chosen is simply the one the programmer happens to know, because zie succeeded in learning that idiom from another person's program and therefore sticks to it like a leech because zie *knows* the idiom will work. -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "..., and some of you may regard all women as evil traps that exist only to tease, torture, and suck out your very soul." --DrMax From piet at cs.uu.nl Wed Mar 28 04:47:51 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 28 Mar 2001 11:47:51 +0200 Subject: I'm sure there's a good reason! References: <99cl87$3nq$1@inputplus.demon.co.uk> Message-ID: >>>>> ralph at inputplus.demon.co.uk (Ralph Corderoy) (RC) writes: >> if-one-string-gimmick-were-enough-for-all-purposes-there-wouldn't- >> be-two-ly y'rs - tim RC> A PEP for Hollerith constants anyone? LOL! -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From ckrill at qvlinc.com Fri Mar 23 18:47:42 2001 From: ckrill at qvlinc.com (Coy Krill) Date: Fri, 23 Mar 2001 15:47:42 -0800 Subject: Daemonizing a python programme. References: Message-ID: <3ABBE09E.3287DEC5@qvlinc.com> Timothy Grant wrote: > Hi all, > > I have been investigating daemonizing a python programme, and > have discovered to bits of code that assist in this endeavour: > daemonize.py and Daemon.py. > > I think that I like Daemon.py's method of doing things, but I > can't get it to work as it imports a module named delay that I > can't find anywhere. > > Does anyone have any success stories with either of these > tools? > > Thanks > > -- > Stand Fast, > tjg. > > Timothy Grant tjg at exceptionalminds.com > Red Hat Certified Engineer www.exceptionalminds.com > Avalon Technology Group, Inc. <>< (503) 246-3630 > >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< > >>>>This machine was last rebooted: 65 days 23:52 hours ago<< I combined ideas from both and rolled this one, that works for me. # Daemon Module - basic facilities for becoming a daemon process # # Combines ideas from Steinar Knutsens daemonize.py and # Jeff Kunces demonize.py """Facilities for Creating Python Daemons""" import os import time import sys class NullDevice: def write(self, s): pass def daemonize(): if (not os.fork()): # get our own session and fixup std[in,out,err] os.setsid() sys.stdin.close() sys.stdout = NullDevice() sys.stderr = NullDevice() if (not os.fork()): # hang around till adopted by init ppid = os.getppid() while (ppid != 1): time.sleep(0.5) ppid = os.getppid() else: # time for child to die os._exit(0) else: # wait for child to die and then bail os.wait() sys.exit() From fredrik at pythonware.com Wed Mar 28 11:34:28 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 28 Mar 2001 16:34:28 GMT Subject: help with passing arguments to published objects a la Zope References: Message-ID: Eugene Leitl wrote: > However, is there a simple mechanism, allowing me to pass arguments > via the URI, as well as use the CGI module (i.e. to parse arguments into a > dictionary)? how about XML-RPC? http://mail.python.org/pipermail/python-announce-list/2001-March/000698.html http://www.pythonware.com/products/xmlrpc/index.htm http://www.xmlrpc.com Cheers /F From aleaxit at yahoo.com Fri Mar 9 06:56:29 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 9 Mar 2001 12:56:29 +0100 Subject: Who am I: can a class instance determine its own name? References: Message-ID: <98agdc01mi6@news2.newsguy.com> "Tim CHURCHES" wrote in message news:mailman.984034150.9635.python-list at python.org... > This is probably an elementary question and the answer is probably writ large in > multiple places in the Python documentation, but... > ...can an instance of a class determine the name of the variable to which it is > assigned? For example: As many respondents have already stated, the answer has to be No; any object, at any given moment, may be referred-to by any number N of references [[an aside: in the current version of CPython, it must be the case that N>0, or the object would be destroyed; in Jython, in Python .NET, and possibly in future versions of CPython, this guarantee does not hold]], including maybe both ones that are named, and other ones that are not named (but, rather, indexed). For example, adict = {} adict['!}@}!'] = [] adict['!}@}!'].append(MyClass()) now, what is "the name of the variable" you would wish to determine for this instance, which can at this time be referred to only as adict['!}@}!'][0] but 'at a drop of a hat' might also be seen through other references, not be seen through this one any more, etc, etc...? Asking an object "under what names [and/or unnamed refs] are you known" is akin to asking an individual "on what web sites (URLs) are you mentioned". The individual most likely has no idea: he or she is typically not informed each and every time a reference to him/her is added to some URL or removed from it, nor does the existence of such reference have any effect directly observable on/by him/her. If you wanted to find all such URLs, you would have to grep through ALL URLs of the web, and, for each one, determine if it refers to the individual of interest -- this is basically what search engines such as Google do. Similarly, if you want to find all references to some Python object, you will have to grep through all the objects currently existing, recursively determining all the references held, and see which of these references are the ones of your interest (use the 'is' operator for this purpose). It makes no real sense to delegate this job to each individual/object you might be looking for -- do it in a global function (or utility class) so you can reuse it for any object, regardless of type. Supposing you're not interested in unnamed (indexed) references, local variables, or attributes of instance objects, but only in attributes of modules (module-level 'global variables'), for example, here's a start...: def namesOf(anobject): result = [] import sys for modname,modobj in sys.modules.items(): for varname,varobj in modobj.__dict__.items(): if varobj is anobject: result.append("%s.%s" % ( modname, varname)) return result import sys, re, string sys.blab = re.blob = string.blub = "fakaoplod" names = namesOf(sys.blab) for name in names: print name Alex From grante at visi.com Sat Mar 24 11:38:12 2001 From: grante at visi.com (Grant Edwards) Date: Sat, 24 Mar 2001 16:38:12 GMT Subject: static methods References: Message-ID: On Fri, 23 Mar 2001 16:51:10 -0500 (EST), Clark C. Evans wrote: >I was wondering if there is any rationale as to why >Python classes do not have static methods? What's a "static method?" I assume it's some C++ contrivance? After using Modula-3 and Smalltalk, I tried to learn C++ once. It was mind boggling. When I got to "virtual" methods, I just shook my head and gave up. Apparently in C++ you have to know ahead of time what methods somebody might want to override at some point in the future. Bizarre. -- Grant Edwards grante Yow! I hope I at bought the right visi.com relish... zzzzzzzzz... From gmcm at hypernet.com Sat Mar 10 19:53:33 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 11 Mar 2001 00:53:33 GMT Subject: import headaches/gripes References: <3aaa3f94.15940553@News.CIS.DFN.DE> Message-ID: <9060CBC10gmcmhypernetcom@199.171.54.155> pearu at cens.ioc.ee (Pearu Peterson) wrote: > >On Sat, 10 Mar 2001, Paul Prescod wrote: > >> I think there are two reasons: >> >> 1. Even checking file dates has a performance cost. It involves going >> to the hard disk after all. Code like this isn't rare in Python > >I think this is not true in Linux where recently read files stay in >memory buffer so that later access to the files does not involve >(physical) actions on the hard disk. Don't know if Windows has such a >feature.. Windows caches that stuff too. But Linux doesn't cache everything you need to do this: for dir in sys.path: for ext in ('.py', '.pyc') + c_extensions: testnm = os.path.join(dir, modulename) + ext if os.path.exists(testnm): ..... so Paul's point stands. - Gordon From steven at haryan.to Fri Mar 2 10:27:58 2001 From: steven at haryan.to (Steven Haryanto) Date: Fri, 02 Mar 2001 22:27:58 +0700 Subject: Editing Python source as XML? Message-ID: <4.3.2.7.2.20010302222446.00c84360@202.53.255.51> A recent experience of having to modify a long C source file has led me to wonder whether there are any tool/effort towards editing Python source code as XML or other form of structured document. What I would like is an editor that presents the source file as a tree outline, where I can collapse selected class or function definition body, certain long if's/for's, some section of code, view/hide the asserts, etc. So then I only have to deal with the section I am concentrating with and don't have look at other distracting parts (especially in C with all those #ifdef/#endif's, argh...). I visited conglomerate.org some months ago, and it seems the project has been abandoned. Thanks, Steve From db3l at fitlinxx.com Mon Mar 26 18:08:59 2001 From: db3l at fitlinxx.com (David Bolen) Date: 26 Mar 2001 18:08:59 -0500 Subject: win32net, documentation References: <3AB8CD29.C69CC1E2@Bibliothek.Uni-Augsburg.de> Message-ID: Sibylle Koczian writes: > Hello, all, > > I want to do the Python equivalent of > > net use k: \\server\share > > so I suppose I must call > > win32net.NetUseAdd("\\server", level, data). NetUseAdd is the right function, yes, but not called quite this way. Also, it will only work under NT 3.1 or later or 2000, but not Windows 9x. > Level = 1 should be right, I think, but I can't get the syntax right. > I'm trying to translate the api_error messages (they seem to come > directly from my german Windows version): > > - "server" without the "\\": api_error 50, the network request isn't > supported > > - "\\server": api_error 123, the syntax for the file name, path name or > the drive name is wrong. I've tried: The NetUseAdd function is documented (in MSDN) as reserving this parameter and it should be NULL (None in Python). > data['local'] = 'k:', 'k:\\' or 'k' > data['remote'] = 'share', '\\server\share', '\\\\server\\share', > '\\share' > data['password'] = my normal domain password > data['asg_type'] = STYPE_DISKTREE > > It's a network ressource I'm using constantly, so I'm quite sure it > exists, I've got the name right and I can connect to it. In your data block, just use the drive letter for local (with ":"), the full UNC to the sharename for the remote. The appropriate asg_type value would be USE_DISKDEV (assuming a shared file resource). I don't see USE_DISKDEV actually included in win32con (it's off in an LMUSE header file rather than the WIN header files which may be why), but it's value is 0. > So what's the right syntax? The help file for the Win32 extensions > hasn't got anything about the USE_INFO_* dictionaries, and the MSDN > library doesn't help either. The MSDN reference for NetUseAdd should have everything you need, including detailed documentation on the USE_INFO structures for each supported level. Check out http://msdn.microsoft.com/library/psdk/network/ntlmapi2_1cdg.htm, and follow the link to the documentation on the USE_INFO_1 structure (or just look for NetUseAdd if you have a local MSDN CD). The following should work to map your local K: drive to a resource \\server\share: import win32net data = {} data['local'] ='k:' data['remote'] = r'\\server\share' data['asg_type'] = 0 win32net.NetUseAdd(None,1,data) It actually works also even if you leave out the asg_type, but it's probably safer to include it. You only need to supply a password if it's going to be different than your current authentication Note also the use of the raw (r'') string syntax for the share name. That way you can use the backslashes normally - if you don't do that then you'd have to double each backslash for the Python parser. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From sholden at holdenweb.com Thu Mar 22 22:19:54 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 22 Mar 2001 22:19:54 -0500 Subject: Please rate these Python books References: <20010322.1445209@mis.configured.host> <_Meu6.8736$8O6.1818817@typhoon.austin.rr.com> Message-ID: "Steve Lamb" wrote in message news:slrn9bjuha.4qv.grey at teleute.dmiyu.org... > On Thu, 22 Mar 2001 03:59:54 GMT, alan runyan wrote: > >how are you approaching python? what is your level of experience w/ python? > >what kinda books do you like? reference, explanatory, or 'by example' ? My > >favorite is Essential Reference, David Beazley did a incredible job. > > No disrespect towards Beazley, he's a large reason why I work in Python as > much as I can now but his book semmed to be pretty much a dump of the > postscript of the website to a printer. Not that that is a bad thing as it is > the /only/ Python book I own and one I recommend to anyone who has passing > familiarity with other scripting languages (Perl comes to mind). You're > correct in stating it is sparse on the examples but it is a rare case where > I've really needed the examples. Python being as interactive as it is I tend > to learn by firing up Python in a separate window and then playing with the > syntax until it works out in that session before plopping it into my script. > I would disagree with that (just so no-one can say this is a "me too" post :-). Beazley travels with me so I don't need to look up the ActiveState help files as often as I otherwise would. If I can find it quicker offline, I'll spend the money on the dead trees. Prime collection is currently "Learning Python" (despite its age), "Win32 Programming in Python" and "Python Essential Reference". The rest have their place, but it's in the bookshelf, not the briefcase. regards Steve From olczyk at interaccess.com Tue Mar 13 10:57:19 2001 From: olczyk at interaccess.com (Thaddeus L Olczyk) Date: Tue, 13 Mar 2001 15:57:19 GMT Subject: Einstein's Riddle References: <984380185.768920@news.aei.ca> <4w6r6.193645$df5.5192565@news1.crdva1.bc.home.com> Message-ID: <3aae4114.63604234@nntp.interaccess.com> On Mon, 12 Mar 2001 16:08:32 GMT, "David Murphy" wrote: >This reminds me of a test my class was given WAY back in grade 6. It was >two sheets of paper long, and at the very top, it was clearly stated that >the student should 'Read the entire test carefully before beginning'. > >The point was, at the bottom of the second page, the student was told >something to the effect of: 'After reading through the test, place your >pencil on you desk and wait for further instructions'. > >Well, 90%+ of the class immediately went to work on this test. There were a >couple of questions where students had to get up and do things, and it was >rather amusing to watch them run around. About 30 minutes later, they >started to get to the end, and they realized that they had been running >around and scribbling down answers for nothing. It was a rather profound >lesson, at least for me. > The version I saw the last question was sign your name and turn it in. There were ( AFAIK ) no questions about getting up and running around. We were given an hour told it was very important. I gave up after reading the test halfway in the first thirty minutes and started answering questions. It didn't help that we had a strange test two weeks. For the first time the HS I was in had set up a special schedual for midterms/finals. In this particular class we would meet for two seperate hours. THe teacher gave us an exam that should have lasted one hour ( by her estimation ). She was going to use the second hour for a class. It turned out that most fiished about 3/4 of the test in the two hours. So she had a reputation for giving long tests. >*IF* Einstein was just talking about people's ability to deal with just the >facts, and not to make assumptions, I think 2% +/- 5% is probably a good >estimate. Take a look at the first draft of the next project specification >you get *grin* > The problem is typical of problems published in many magazines ( here in Dell Crosswords ). I suspect that 2%-5% will have the motivation to sit through solving the puzzle unless there were some other reward, but I figure half the population could actually solve it given the proper motivation. I also figure the fish thing was simply a typo, and that this guy ( who hasn't resdponded ) was probably given this as a homework assignement, and is simply looking for a cheap way to get it done. From carribeiro at yahoo.com Sun Mar 18 22:19:18 2001 From: carribeiro at yahoo.com (Carlos Ribeiro) Date: Mon, 19 Mar 2001 00:19:18 -0300 Subject: Wrong reasons to enhancing the language Message-ID: <5.0.2.1.0.20010318232654.02243ba0@mail.inet.com.br> Le me try to summarize what I've seen on the past ten days or so on this list, regarding the awful lot of "enhancements" proposed to the Python language. 1) Proposing "syntactic sugar" changes to make some particular code constructions look better; 2) Proposing new operators because of speed concerns; 3) Fixing the semantic of the language to fix incompatibilities with other languages/modules/theoretical model; 4) Including new constructions because some other language support them; 5) Avoiding the inclusion of some constructions because some other language support them (yes, that also happens sometimes). In my opinion, none of the above reasons is good enough to justify alone changes to the language. There are other criteria that need to be met. Are the extensions useful to many people? Are they generic and extensible? Do they cause any compatibility issue? I dont think that we'll ever see a perfect language. Every one will have some issues or limitations, and thats part of the design decisions. Trying to make too much inside of the constraints of a single language is overkill. Small incompatibilities are impossible to avoid, partly because there are so many different things around. Some problems are just not worth the time to "fix" them. Maybe a different language is the answer for them. I think that is better to focus the effort where Python is already good, to make it stronger. There is no sense in trying to make Python the best tool for all jobs - it is an unattainable goal. Synctatic sugar may make things clear for some, but makes it also a little bit harder for the others. If some code is speed critical, let's do it in C, C++, whatever compiled language you want. Python makes it extremely simple both ways, either to have embedded Python in a compiled language application, or to call compiled modules from Python code. Alternatively, I'm sure there is a lot of enhancements that could be done to the compiler to shave off precious CPU cycles. Why not spend more energy on this? Sometimes Python cant do what you want - maybe it's better to use another tool. Note that I'm not against all change. I found the list comprehensions to be extremely effective. Also for the nested scopes - we all know that it didn't make it before for practical reasons. But some PEPs... sound silly at best. _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From tjg at exceptionalminds.com Fri Mar 23 14:38:33 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Fri, 23 Mar 2001 11:38:33 -0800 Subject: Daemonizing a python programme. Message-ID: <20010323113833.F7911@trufflehunter.avalongroup.net> Hi all, I have been investigating daemonizing a python programme, and have discovered to bits of code that assist in this endeavour: daemonize.py and Daemon.py. I think that I like Daemon.py's method of doing things, but I can't get it to work as it imports a module named delay that I can't find anywhere. Does anyone have any success stories with either of these tools? Thanks -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Red Hat Certified Engineer www.exceptionalminds.com Avalon Technology Group, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 65 days 23:52 hours ago<< From brendhanhorne at bellsouth.net Mon Mar 12 07:10:44 2001 From: brendhanhorne at bellsouth.net (Brendhan Horne) Date: Mon, 12 Mar 2001 07:10:44 -0500 Subject: I have no idea Message-ID: In basic you use to be able to do this: 10 print "Hello World" 20 goto 10 Run If you did that it would run up the screen in an endless loop until you hit the ESC key. If you added ; it would cover the whole screen. How do you write the equivalent in python? -- Thanks, Brendhan From grey at despair.rpglink.com Thu Mar 8 14:14:02 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Thu, 08 Mar 2001 19:14:02 -0000 Subject: Get terminal size in perl and python References: Message-ID: On Thu, 8 Mar 2001 19:40:29 +0100, Egbert Bouwman wrote: >My perl correspondent uses: > use Term::ReadKey; > ($cols,$lines)=GetTerminalSize() >What is the python equivalent ? >If I don't come up with one, python looses ten points. If I do in under 5 minutes (having never needing it before) does that mean you lose 10 instead? -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From stephen_purcell at yahoo.com Mon Mar 12 10:39:07 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Mon, 12 Mar 2001 16:39:07 +0100 Subject: Packages, modules and exceptions In-Reply-To: <98ip5c$397$1@clematis.singnet.com.sg>; from ngps@madcap.dyndns.org on Mon, Mar 12, 2001 at 03:14:52PM +0000 References: <98ip5c$397$1@clematis.singnet.com.sg> Message-ID: <20010312163907.A23991@freedom.puma-ag.com> Ng Pheng Siong wrote: > > In M2Crypto, I have the following (abridged) directory structure: > > M2Crypto/ > SSL/ > __init__.py > Connection.py > I assume you also have a file 'M2Crypto/__init__.py'... > Now, various parts of M2Crypto/SSL/Connection.py wish to raise SSLError > when it is appropriate to do so. > > For M2Crypto/SSL/Connection.py to get access to SSLError which is defined > in M2Crypto/SSL/__init__.py, it (Connection.py) contains the following: > > SSLError = > __import__('M2Crypto.SSL', globals(), locals(), 'SSLError').SSLError > > This works, but looks kinda funny. > > What's the best way to do this? from M2Crypto.SSL import SSLError raise SSLError, "there's a problem" -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From sholden at holdenweb.com Wed Mar 7 21:30:10 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 7 Mar 2001 21:30:10 -0500 Subject: gah! I hate the new string syntax References: Message-ID: "D-Man" wrote in message news:mailman.984014353.5058.python-list at python.org... > On Wed, Mar 07, 2001 at 07:15:48PM -0500, Steve Holden wrote: > | "D-Man" wrote in message > | news:mailman.983997252.5628.python-list at python.org... > | > On Sat, Mar 03, 2001 at 03:19:05PM -0500, Steve Holden wrote: > | [ ... ] > | > > | > What about one who is both English and Scots, yet never set foot on > | > that island ;-)? > | > > | No such animal! > > Oh. Am I a bot too? If so I must find a new maintainer so I can > match the intelligence of the other bots on the list. > Well, that would be nice, but I digress. ;-) By "that island" I presume you refer to Great Britain? Either you were born in England, or you were born in Scotland, or you are neither English nor a Scot. Part-either-or-both, maybe, but not fully either. Or perhaps you were born on the border, and carried away before you could walk? Or maybe you just have no feet?!? regards Steve From piet at cs.uu.nl Wed Mar 21 06:18:24 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 21 Mar 2001 12:18:24 +0100 Subject: New PEP: The directive statement References: <200103201042.LAA20248@pandora.informatik.hu-berlin.de> <9988ie02k7u@drn.newsguy.com> Message-ID: >>>>> Grant Griffin (GG) writes: GG> No kidding, Gang, when I first ran across posts about the __future__ GG> directive, I thought it was another one of Tim's beloved witicisms. GG> (That's a polite way of saying I thought it was a joke. ) It took GG> me awhile to figure out it was serious, because it _reads_ like a GG> joke!: "from __future__ import..." It would be much less of a joke when __future__ would be replaced by __features__, I think. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From mwh21 at cam.ac.uk Sun Mar 11 14:44:13 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 11 Mar 2001 19:44:13 +0000 Subject: Questions about no more nested imports References: <98gi4l$n9n$0@216.39.170.247> Message-ID: whisper at oz.net (Dave LeBlanc) writes: > I'm a bit confused by this. | <- the right end the wrond end -> | +----------------------------------------------------------+ | the stick | *----------------------------------------------------------+ ^ you're about here > It appears that if this is enforced, one can no longer dynamically > load extensions/whatever dynamically and all imports must be done at > the top of a module prior to anticipated use - whether used or > not. If this is true, then load times for python apps could go up > drastically. The only thing that's getting banned is "from blah import *" and "exec" without "in" in a set of fairly restricted circumstances. Read the PEP: http://python.sourceforge.net/peps/pep-0227.html (specifically the section "Backwards compatibility"). Cheers, M. -- please realize that the Common Lisp community is more than 40 years old. collectively, the community has already been where every clueless newbie will be going for the next three years. so relax, please. -- Erik Naggum, comp.lang.lisp From brendhanhorne at bellsouth.net Tue Mar 13 07:27:25 2001 From: brendhanhorne at bellsouth.net (Brendhan Horne) Date: Tue, 13 Mar 2001 07:27:25 -0500 Subject: Very Cool References: Message-ID: That did it . I must have tried every other space combinationin the world except that one. -- Thanks, Brendhan From micampe at f2s.com Tue Mar 27 05:39:21 2001 From: micampe at f2s.com (comp.lang.python) Date: Tue, 27 Mar 2001 10:39:21 GMT Subject: R: unique items in lists References: <_nZv6.2878$yU4.468236@news.infostrada.it> Message-ID: Here is what I'm doing now: for w in words: while words.count(w) > 1: words.remove(w) comments? Remco Gerlich wrote in message slrn9c0ph1.o5h.scarblac at pino.selwerd.nl... > comp.lang.python wrote in comp.lang.python: > > Which is the best (read: fastest) way to remove duplicated items from a list > > of strings? > > The standard idiom is to put the items in a dictionary, then get the > dictionary keys: > > def unique_strings(l): > dict = {} > for s in l: > dict[s] = 1 > return dict.keys() > > I think this is also very fast, at least lots faster than comparing all the > strings in a double for loop or something. > > -- > Remco Gerlich From tim at vegeta.ath.cx Fri Mar 9 18:37:11 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Fri, 09 Mar 2001 23:37:11 GMT Subject: "!=" is bad form. Re: sorry....never mind References: <3AA6E308.5B63ECC6@cosc.canterbury.ac.nz> <3AA72253.FB021815@Lugoj.Com> <984047188.296438@newsmaster-04.atnet.at> <3AA86D0F.E36B0BDC@Lugoj.Com> Message-ID: James Logajan wrote: > Tim Hammerquist wrote: > > I realize I seem to be in the minority in this group when I say I like > > C/C++. NB: I like them as _languages_, but would prefer NOT to do > > everyday programming in them, as they're just a pain in the ass most of > > the time. > > Ironically, I like C and have been coding in C on and off for it seems just > about forever (well, 18 some years I think). And I find programming in C a > mostly pleasurable experience. Yet as I stated earlier, for Python "<>" > feels "righter" to me than "!=". I suspect it is a triviality for both > programmers to understand, and the language to support, both forms. While > deprecating "<>" in Python would not mean the end of civilization as we know > it, it would be a damn shame anyway. Likewise, I would be disappointed if '!=' were deprecated, but, as you said, not the end of civilisation. ;) > (a > b) or (a == b) ---> (a >= b) > (a < b) or (a == b) ---> (a <= b) > (a < b) or (a > b) ---> (a <> b) Thank you, BTW for this explanation. I just don't think of it like that, but it makes a little more sense to me now. Thx. -- -Tim Hammerquist A university is what a college becomes when the faculty loses interest in students. -- John Ciardi From loriendNOSPAM at bigpond.com Sat Mar 17 21:04:03 2001 From: loriendNOSPAM at bigpond.com (Lorien Dunn) Date: Sun, 18 Mar 2001 13:04:03 +1100 Subject: Meta-class inheritance problem (Python2.0 bug?) References: <6Kzs6.35062$v5.73895@newsfeeds.bigpond.com> <5nDs6.35198$v5.74638@newsfeeds.bigpond.com> <90678B1B1gmcmhypernetcom@199.171.54.194> Message-ID: Gordon McMillan wrote: > > That's the same code as Python 1.5. Did this work before? I don't know. I don't have python 1.5 anymore, and its a new extension I'm writing. David Abrahams (the major author of the boost::python lib) said that isinstance() and issubclass() have been fixed to deal with metaclasses in Python 2.0, but it seems this check of self hasn't. > > From your previous post, it does not appear to be using the Don Beaudry > hook, but then again, I don't know what type(MyBoostClass) is. A boost class is a class that uses the boost::python library to reflect a C++ class in python. It does use the Don Beaudry hook. IMHO Boost seems to be the only reasonable way to wrap C++ (and I've tried SWIG, Siloon, SIP, CXX, and Boost), in that it supports exceptions, overidable virtual functions, derivation from C++ classes without shadow classes, automatic type conversion, function overloading, etc. It is also MUCH easier to use than Zope. However it puts a lot of stress on the compiler in terms of adherance to the ansi standard. And a lot of stress on the system. The wrapping code of my extension takes about 10 minutes 160 megs of ram to compile (and its not that large). Boost as a whole is a C++ library that seems to be almost a draft for the next ansi standard. If you use C++ it will make your life more pleasant. Have a look at http://www.boost.org. Thanks, Lorien Dunn From loewis at informatik.hu-berlin.de Sat Mar 24 06:44:43 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 24 Mar 2001 12:44:43 +0100 Subject: XML/XSLT for newbies References: <3abbbb0f.69122775@nnrp.wiznet.ca> Message-ID: lance.hill at removespamfilter.olsinc.net writes: > All the documentation I have been able to find on how to do xsl > transformation assumes you have ASP,VB,JAVA or such. Does anyone know > of learning resources for xml/xsl in python? For XML, I recommend the Python/XML tutorial: http://py-howto.sourceforge.net/xml-howto/xml-howto.html and the API documentation: http://python.sourceforge.net/devel-docs/lib/markup.html For XSLT, I recommend the 4Suite API documentation: http://services.4Suite.org/topics/rdf/Top/Documentation/APIs Regards, Martin From arkanea at yahoo.com Fri Mar 30 08:25:05 2001 From: arkanea at yahoo.com (Olivier Laurent) Date: Fri, 30 Mar 2001 15:25:05 +0200 Subject: converting python to latex Message-ID: <9a21er$pa4$1@news.brutele.be> I'd like to convert some little Python scripts into Latex. This Latex source will be converted into html and pdf with colored syntax highligting (something like py2html but outputing in Latex instead of html) I've tried an old program called py2tex but it doesn't convert into Latex (it converts int o a file that can be imported by Latex). Does someone know of a module or program that can do it. If not : what's the best an d simple way to do it. Thank you. Olivier Laurent. -- P3B.org : Association des programmeurs Python de Belgique francophone. From bsass at freenet.edmonton.ab.ca Thu Mar 22 00:21:50 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Wed, 21 Mar 2001 22:21:50 -0700 (MST) Subject: New PEP: The directive statement In-Reply-To: References: Message-ID: On Wed, 21 Mar 2001, Huaiyu Zhu wrote: > With the __future__ PEP, I envision there could also be things like > > from __future__ import nested_scope > from __experimentatal__ import stackless > from __optional__ import static_type > from __mandatory__ import string_methods <...> [an alternative] > directive transitional nested_scope > directive experimentatal stackless > directive optional static_type > directive mandatory string_methods [or whatever] <...> Why was (something along the lines of)... use: __future__.nested_scopes __experimental__.stackless __optional__.static_type __mandatory__.string_methods except FutureError: # compensate for lack of nested scopes except ExperimentalError: . . ...and allowing... use: __future__.nested_scopes # code that relies on nested scopes except FutureError: # code that does not use nested scopes ...rejected? [It looks like a natural to me ... <...> > IMHO, reusing existing syntax is closer to Python than Perl, which > introduces new syntax for many things that are only slightly different. ...and seems the most "Pythonic" of all.] - Bruce From prairiesasquatch at crosswinds.net Thu Mar 15 22:13:34 2001 From: prairiesasquatch at crosswinds.net (Kevin Russell) Date: Thu, 15 Mar 2001 19:13:34 -0800 Subject: Umlaut and Tkinter References: <3AB0C38F.34218EEB@teleatlas.com> Message-ID: <3AB184DE.8CF1682E@crosswinds.net> Michael Husmann wrote: > typing in idle.py using Python 2.1b1: > > >>> print "??" > > results in an: > > UnicodeError: ASCII encoding error: ordinal not in > range(128) > > Is there someone who can help me. > > Michael This looks like a messy incompatibility between Python 2's not-quite-fully-integrated-yet Unicode support and Tcl's even-less-quite-fully-integrated-yet Unicode support, and the desire of one or both of the parties to communicate in the lowest common denominator (ASCII) unless beaten over the head with a stick and forced not to. Until the Tkinter and Unicode gurus can sort the mess out, in their abundant free time, you'll probably have to use one of the other Python interfaces if you want to be able to use upper-128 Latin-1 characters at an interactive prompt. I just tried your '''print "??"''' line in both PythonWin and the Python mode of Emacs (with Python 2.0) and it does what you'd expect. It also works fine under in a Windows MS-DOS box (abstracting away from the whole different passel of character set problems there), so I suspect it should also work OK at a Unix command line. Good luck. -- Kevin From chrisw at nipltd.com Fri Mar 23 10:46:08 2001 From: chrisw at nipltd.com (Chris Withers) Date: Fri, 23 Mar 2001 15:46:08 +0000 Subject: Slightly Off-Topic: Python featured in Severance: Blade of Darkness References: Message-ID: <3ABB6FC0.97A8E10B@nipltd.com> Thomas Weholt wrote: > > A friend of mine just informed me that while starting up his copy of the > game Blade of Darkness he saw a reference to Python 1.5.2 during the loading > process. Anybody know anything about that? What has Python been used for? > Writing mods/extensions in Python would be cool in any game. :-> IIRC, Severance looks like it's 90% written in python :-) (the bladex engine looks like it's been wrapped up as a DLL, I wonder if they used SWIG? ;-) Anyway, take a look in the scripts and lib folders of the games install and you'll find lots of python you can play with. I believe there's even one called cheats.py... happy hunting, Chris From tuttledon at hotmail.com Thu Mar 22 11:55:33 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Thu, 22 Mar 2001 16:55:33 GMT Subject: Good Editor? References: <3ab9a32b$1_1@news2.one.net> <3AB9FAC9.97EA420E@student.liu.se> <99d780$l2g$1@laurel.tc.umn.edu> <3ABA20F7.AB71D3B4@student.liu.se> Message-ID: <98qu6.166420$Z8.35271037@typhoon.southeast.rr.com> "Rikard Bosnjakovic" > Anyone sending unwanted advertising e-mail to my address will be > charged $250 for network traffic and computing time. By extracting my > address from this message or its header, you agree to these terms. love it...Love It...LOVE IT! Don From chris.gonnerman at usa.net Sun Mar 4 09:46:51 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sun, 4 Mar 2001 08:46:51 -0600 Subject: How to broadcast socket References: Message-ID: <003b01c0a4b9$fa467380$a100000a@local> So, *exactly* what *does* it do? Throw an exception? Appear to work but not send a packet? How do you know if it sent or not (i.e. are you testing with another application or did you actually use a packet sniffer?) If you are testing with an application and the application shows no sign of receiving the packet, get a packet sniffer and see if anything is actually being sent. I use Ethereal (don't remember the URL but look on freshmeat.net) but I believe there are many others. ----- Original Message ----- From: "J?rgen Tapani" Subject: How to broadcast socket > I'm new to Python, and I have achived this > def test(): > s = socket(AF_INET, SOCK_DGRAM) > s.setsockopt(SOL_SOCKET,SO_BROADCAST,1) > s.sendto('Broadcast test',INADDR_BROADCAST) > s.close() > > And it do not run! > Help! > Jorgen Tapani From fredrik at pythonware.com Wed Mar 21 10:29:38 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Mar 2001 15:29:38 GMT Subject: Access Issues References: Message-ID: Clodagh O'Rourke wrote: > I wonder if anyone can help. > > I am trying call the constructor of the EnvVar class from the > newEnvWin function of the Cell class. But I am getting the > following error > > Exception in Tkinter callback > Traceback (innermost last): > File "/usr/vob/omc_reference/ThirdParty/scriptSources/lib/python1.5/lib-tk/Tkinter.py", line 764, in __call__ > return apply(self.func, args) > File "Cell.py", line 63, in newCellMgt > self.newEnvWin('cellmgt') > File "Cell.py", line 60, in newEnvWin > instance = EnvVar.__init__(g, self.parent) > AttributeError: __init__ > > I have include some extracts of the code. __init__ is not a constructor; it's the function called by the constructor to initialize an instance. (and in your case, EnvVar appears to be a module, not a class) try replacing instance = EnvVar.__init__(g, self.parent) with instance = EnvVar.EnvVar(g, self.parent) Cheers /F From barry at digicool.com Sat Mar 10 13:50:31 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Sat, 10 Mar 2001 13:50:31 -0500 Subject: "!=" is bad form. Re: sorry....never mind References: <3AA6E308.5B63ECC6@cosc.canterbury.ac.nz> <3AA72253.FB021815@Lugoj.Com> Message-ID: <15018.30583.852611.836468@anthem.wooz.org> Personally, I agree. I hate "!="; to me <> looks much better and I use it all the time. Guido has been known to disagree with me so violently that he'll make a patch to my code just to change that. :) http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/python/dist/src/Lib/smtpd.py?rev=1.4&content-type=text/x-cvsweb-markup&cvsroot=python -Barry From gregj at pobox.com Sun Mar 11 00:47:01 2001 From: gregj at pobox.com (Gregory Jorgensen) Date: Sun, 11 Mar 2001 05:47:01 GMT Subject: grabbing return codes from os.system() call References: <%wFp6.9481$dL4.126404@vixen.cso.uiuc.edu> Message-ID: In article , Gregory Jorgensen says... > >os.system returns the exit status. The low-order byte of the exit status is the >signal number that killed the process, and the high-order byte is the exit >status (if the signal number is 0). This only works under Unix; on Windows the >exit status is always 0. Actually the current docs at python.org say that Windows 95 and 98 always return 0. Apparently Windows NT and 2000 do return something. I don't know about Win ME. The Beazley book "Python Essential Reference" (which I used) says "On Windows, the exit code is always 0" in the description of os.system. Greg Jorgensen Deschooling Society Portland, Oregon, USA gregj at pobox.com From tuttledon at hotmail.com Fri Mar 16 22:23:23 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Sat, 17 Mar 2001 03:23:23 GMT Subject: socket.ssl for win32 References: <2_ys6.108066$__6.20130421@typhoon.southeast.rr.com> Message-ID: Got it. Thanks. Don From tjg at exceptionalminds.com Mon Mar 12 18:22:16 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Mon, 12 Mar 2001 15:22:16 -0800 Subject: Process details Message-ID: <20010312152216.N6836@trufflehunter.avalongroup.net> Hi all, I hope everyone is enjoying there first week back after the events of P9. I need to create a list of processes and process information. I have created a class that contains much of the information in /proc/'pid'/status. It works quite well, however, it takes about four seconds to populate a list of 90 procs. This seems a bit long. Is there a faster way to get ahold of the information than reading /proc? -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Red Hat Certified Engineer www.exceptionalminds.com Avalon Technology Group, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 55 days 3:34 hours ago<< From spam at spam.com Sat Mar 31 01:02:38 2001 From: spam at spam.com (Penfold) Date: Sat, 31 Mar 2001 07:02:38 +0100 Subject: mxODBC chokes on dates! Any Help? References: Message-ID: "Owen Ap Owen" wrote in message news:MPG.152e9338351a7e1b9896a7 at news.pacbell.net... > Thanks for the info. It is SQL Server that I am connecting to. But I got > the same error with date fields when I set up a test connection to > Access. > > It's nice that a fix is in the works. But this seems like something of a > show stopper (at least for the win32 side of things). > > Considering that the creator of mxODBC is trying to charge a laughably > exorbitant license fee for commercial use he really needs to fix this > kind of stuff very quickly. He also needs to add a lot more functionality > and even then his licensing concept is pretty extreme. Considering lots of developers in commercial settings such as finance and banking currently free ride off what is in general a fantastic package, its not that laughable. Questions: (i) Did you try to contact him directly ? He has always been very prompt in replying to me when I have, and I do *not* pay him a licence fee (ii) Have you actually paid any money for mxODBC. If not, why do you expect that it should be perfect and that he should fix it for you quick smart if it aint ? I imagine you probably think that mxODBC and mxDateTime, a fantastically useful package as well, should be free for you to use and abuse simply because you expect to be paid to do development work for a commercial company, but you think that others should provide for free the tools you need in such work. If its a problem, why not write your own DB interface and datetime support, I'm sure you could manage it in a jiffy ;-) > > In article , db3l at fitlinxx.com > says... > > > I ran into the same problem with some date fields in an MS SQL Server > > database, and Marc-Andre was able to revert back to an earlier way of > > handling date fields (he preferred a different C data type if defined > > in 2.0.0 than in earlier versions) to resolve it. I was traveling and > > was a little tardy getting back to verify that the fix worked, but I > > expect it will show up in the next release of mxODBC. From fredrik at pythonware.com Tue Mar 20 15:37:22 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 20 Mar 2001 20:37:22 GMT Subject: re.match References: <997skf$qoc$1@bmerhc5e.ca.nortel.com> <998bke$88i$1@bmerhc5e.ca.nortel.com> Message-ID: <6cPt6.2545$4N4.332824@newsc.telia.net> Michael P. Soulier wrote: > If you do not include anchors, then by the definition of the regexp syntax, > the entire line should be searched. by your definition, perhaps. obviously not by Python's definition. > No biggy, but surprising if you find it surprising that "match" matches and "search" searches, I'm sure Python has more surprises in store for you... Cheers /F From gmcm at hypernet.com Sat Mar 10 14:19:00 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 10 Mar 2001 14:19:00 -0500 Subject: ANN: Linux version of Installer for Python 2 Message-ID: <3AAA37D4.21892.6BB45937@localhost> The Linux version of Installer for Python 2 is here: http://www.mcmillan-inc.com/installer_dnld.html Background: The Installer is a sort of compilerless Freeze - a way of distributing Python apps with all the required support built in. The Linux version collects all dependencies and packages the pure Python into an archive attached to the executable. Just tar, gzip and ship. Old-Python-style license. Contact: gmcm at hypernet.com

Linux Installer release 3j A compiler-less way of distributing Python 2.0 apps on Windows. (10-Mar-01) - Gordon From joconnor at cybermesa.com Fri Mar 9 15:23:25 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Fri, 09 Mar 2001 20:23:25 GMT Subject: "!=" is bad form. Re: sorry....never mind References: <3AA6E308.5B63ECC6@cosc.canterbury.ac.nz> <3AA72253.FB021815@Lugoj.Com> Message-ID: <3aa93b8e.775214008@news.uswest.net> On 8 Mar 2001 16:20:53 GMT, qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) wrote: >Wed, 07 Mar 2001 22:10:27 -0800, James Logajan pisze: > >> The operations "<", ">", "<=", ">=", "==", "<>" form a nice >> consistent and predictable set. > >Except "==". Using "=" instead would be consistent. > >PS. Lisp, Ada, Eiffel and Haskell use "/=" for inequality. Icon uses >"~=" for numbers and "~==" for strings. Simula uses NE for value >inequality and "=/=" for identity inequality. OCaml uses "=" and "<>" >for value (in)equality, and "==" and "!=" for identity (in)equality. > I prefer if not x == y: myself Take care, Jay From python at commandprompt.com Thu Mar 15 18:35:00 2001 From: python at commandprompt.com (python at commandprompt.com) Date: Thu, 15 Mar 2001 15:35:00 -0800 (PST) Subject: Announcement: Python Programming: Taming the Snake. Message-ID: Open Docs, LLC has announced today "Python Programming: Taming the Snake". The book, their fifth title is a comprehensive programmer's guide to the Python Programming Language. With this release, Open Docs has managed to keep pace with the open source's cutting edge development. The title is ensured to be one of the most comprehensive resource books available today. About Python: The first beta version of Python 2.1, a rapid application development language, was released on March 2, 2001. As developers have grown to use Python on a number of different platforms (Unix, Linux, Windows, Mac ) many companies have embraced Python and are now using it for their products. The final release of Python 2.1 is due in April 2001; with the added platforms and technical advances it will bring a new level of functionality to the Python community. Python is being found just about anywhere you look, from animation for the big screen (Disney animation) to advising users through Linux installations. You'll find it managing internet discussion forums, dishing up directories and maps on the internet. They have even gone as far as scripting wireless products, and online games. Python is striking every where you look and striking fast. About the Book: Open Docs is set to release "Python Programming: Taming the Snake" at the end of June. It will cover 2.0 including features found in 2.1. It will also cover the new Python tools and applications, including Jython (a version of Python that compiles as Java byte code); support; the CGI and Internet protocol modules; and database support, for databases such as PostgreSQL . Open Docs will also be including 2 CD-ROM's loaded with examples from the book and Python-related packages. These include the full Python 2.1 source code distribution, the Zope web framework, and the Vaults of Parnassus. We are sure this book will prove to be invaluable to any serious Python programmer. About Open Docs Publishing: Open Docs is a publishing company specializing in technical books. They are a full service publisher that offers authoring, editing, along with special programs that allow companies to maintain their focus on development. Open Docs strives in maintaining tight quality control to ensure that they put out only the best books possible. They take pride in the work that others find numbing; documentation. Open Docs currently has three books in print. The third book, "Securing and Optimizing Linux; Red Hat Edition" is the number one selling book on LinuxCentral.com, a premiere online Linux retailer, and has been for six months. They are currently preparing there fourth title "Getting Stated with Yellow Dog Linux". Additionally Open Docs is striving to help support the Open Source Documentation Community by donating 10% of all net profits from the sales of "Python Programming; Taming the Snake" to the Python Software Foundation. As part of their Open Source Documentation Fund they are setting a new standard. If you would like to read more on Open Docs Publishing or their Open Source Documentation Fund please visit there web site at www.opendocspublishing.com. Contact Info: WWW: http://www.opendocspublishing.com/ Voice: 503-963-8316 Email: Christine Parmer. Postal: OpenDocs, LLC. 2746 Front St. NE Salem, OR 97303 From tjreedy at udel.edu Sun Mar 18 21:46:51 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 18 Mar 2001 21:46:51 -0500 Subject: Help Rewriting/Refactoring/Rethinking Parsing Algorythm References: <3AB5675A.8363C9F2@mindspring.com> Message-ID: <993s09$8p7$1@news.udel.edu> ... > print "what's wrong with %s?" % first name -> print "what's > wrong with %s?" % firstName ... > I've gotten all but the last case to work. But once I started trying to ... You need to add 'quote' or sum such to your list of special words. You will need a variable 'inquote' to keep track of when you are in quotes (and should therefor turn off all other special processing). To do this without making code spaghetti, you might jump to another within-quote function. There have been versions of WordPerfect bundled with Dragon N. S. This might give you more ideas on how to direct text editing with DNS. From menscher+python at uiuc.edu Thu Mar 8 18:07:57 2001 From: menscher+python at uiuc.edu (Damian Menscher) Date: Thu, 08 Mar 2001 23:07:57 GMT Subject: grabbing return codes from os.system() call References: <%wFp6.9481$dL4.126404@vixen.cso.uiuc.edu> <98795o$kq8$0@216.39.151.169> <45BCEEDEDA54E206.15154B99753B2A0C.82A8F3BAA10D6E91@lp.airnews.net> Message-ID: Cameron Laird wrote: > In article <98795o$kq8$0 at 216.39.151.169>, Donn Cave wrote: >>Quoth Damian Menscher : >>| I'm new to Python (as in, my experience is essentially the tutorial), >>| but I've already come up with an interesting question: >>| >>| How do I get the return code from an os.system call? I would have >>| expected I could do something like >>| >>| ---returncode--- >>| #/bin/csh >>| echo do stuff >>| exit 3 >>| >>| and then in my python program I could do >>| >>| print os.system('./returncode') >>| >>| But it prints out 768. Not particularly useful, even after I recognize >>| the trick of dividing by 256 (byte-swapping going on? No, because a >>| return code of 768 reports as 0). Given that my real return codes >>| will be (possibly large) integers, this limitation will likely cause >>| some serious problems down the line. >>| >>| Even better would be a way of returning a string (the script I run >>| can be something other than csh, but it has to be a separate script). >>| >>| Ideas? I'm trying to avoid writing the string out to a file and then >>| read the file back in to the python program.... > Guys, guys; you are making it too hard on Mr. Menscher. My guess > is that he'd appreciate being told that, if he creates /tmp/other > with contents > #!/bin/sh > echo "This is a string from an external process." > he can then have fun with > import os > print os.popen("/tmp/other").read() Thank you much -- this solves my problem. I'm sure I'll have more questions in the near future, though.... Damian Menscher -- --==## Grad. student & Sys. Admin. @ U. Illinois at Urbana-Champaign ##==-- --==## www.uiuc.edu/~menscher/ Ofc:(217)333-0038 ##==-- --==## Physics Dept, 1110 W Green, Urbana IL 61801 Fax:(217)333-9819 ##==-- From moshez at zadka.site.co.il Sat Mar 31 05:42:09 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sat, 31 Mar 2001 12:42:09 +0200 Subject: list vs tuple In-Reply-To: References: , <3AC20CD3.265A2D94@alcyone.com> <71q9ct4le63anefmiajj5cbh3mg04qu1ga@4ax.com> <7Bfx6.989$p5.3791@news1.rivrw1.nsw.optushome.com.au> Message-ID: On Sat, 31 Mar 2001 10:01:16 GMT, "deadmeat" wrote: > Ooh, poor diddums got proven wrong. I blew the lid on your little baby. > You're proving yourself less knowledgable with every post. > What python DOES is irrelevant Of course. Completely irrelevant. > The same > statement (a = b) behaves entirely differently in each case. The same statement behaves *exactly the same*. It's the next statements (b[5] = 9, b = 9) that behave entirely differently. There are valid arguments for not making = do such wildly different things (the Scheme world occasionally get into these flamewars, only they spell = as set!) b = 9 binds the variable b[5] = 9 is equivalent to b.__setitem__(5, 9) Fredrik's explanation makes sure to explain that *this* is the gotcha. -- "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than Python? looking for someplace else to grab power."|YODA: No...no... no. Quicker, -- Wichert Akkerman (on debian-private)| easier, more seductive. For public key, finger moshez at debian.org |http://www.{python,debian,gnu}.org From ljohnson at resgen.com Thu Mar 15 18:37:16 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Thu, 15 Mar 2001 17:37:16 -0600 Subject: wxPython/Tkinter/pyGTK References: <3AB11488.3010006@Antefacto.com> Message-ID: > 3. Are there other options I haven't considered. FXPy (the Python bindings for FOX) should be able to handle everything you've described here. Here's a link: http://fxpy.sourceforge.net Hope this helps, Lyle From scarblac at pino.selwerd.nl Tue Mar 20 10:22:31 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 20 Mar 2001 15:22:31 GMT Subject: The most important modules References: Message-ID: Lyle Johnson wrote in comp.lang.python: > > I've seen a few comments along the lines of "When you are a newbie it will > > take a while to realize which the important modules are." As someone who > > is in the middle of wading through Chapter 3 of the Library Reference, it > > would be very helpful to know which ones are particularly worth > > noting. (Presumably sys, (c)Pickle and shelve, from the ones I've so far > > in the chapter - but what other treats are out there for me?) > > For writing scripts that deal with files (whether for system administration > or other tasks), you should get familiar with the "fileinput", "glob" and > "os" modules. And "shutil" if you have to copy or remove files. People forget about that one. > All of Python's support for regular expressions comes in > through the "re" module, so that will be one you'll want for some > text-processing needs. And I've been meaning to teach myself how to use the > source-level Python debugger module, "pdb", but haven't gotten around to > that yet; > > A lot of the other modules get into more application-specific needs, whether > it's for network support ("ftplib", "httplib", ...), XML processing > ("xml.*") or others. "urllib" is always so easy to use :) > But it's all good stuff. And of course the standard > Python library doesn't even scratch the surface of what's available; you'll > also want to check some of the other sources for contributed software, like > the Vaults of Parnassus: > > http://www.vex.net/parnassus/ Especially win32all for Windows, PIL for images, NumPy for numerical things, and the mx* modules like mxDateTime (that should be in the standard library). It doesn't hurt to just read through the library reference now and then, try some things out, etc. I've never read it back to back, I would forget most of it anyway... -- Remco Gerlich From sholden at holdenweb.com Thu Mar 22 22:41:55 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 22 Mar 2001 22:41:55 -0500 Subject: email address verification References: <99d5qi$95l$1@solaria.cc.gatech.edu> Message-ID: "Holland King" wrote in message news:99d5qi$95l$1 at solaria.cc.gatech.edu... > does python provide quick/simple way to verify that an email address exist? > i looked at the smtp library and the verify method but that does not seem > to be very standard anymore. is there anything else that is simalar? > thank you. > The classic way would be to send it mail containing a link, which begins: "To remove yourself from this mailing list, all you have to do is click here". Naturally the URL clicked on adds the relevant email address to at least several hundred salable lists, including "gullible individuals who believe what they read in their inbox". do-i-seem-a-bit-cynical-today-or-what?-ly y'rs - steve From shaleh at valinux.com Fri Mar 2 11:42:09 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Fri, 02 Mar 2001 08:42:09 -0800 (PST) Subject: gah! I hate the new string syntax In-Reply-To: Message-ID: On 02-Mar-2001 Robin Becker wrote: > In article <0vpn79.331.ln at 127.0.0.1>, Carl Banks writes >>Sean 'Shaleh' Perry wrote: >>> return ";".join(["%s=%s" % (k, params[k]) for k in params.keys()]) >>> >>> every day python seems to be moving closer to the line noise aspect of >>> coding. >> >>I find it ok for methodlike functions such as split. >> >>For unmethodlike functions such as join, I would use the old >>string.join syntax (for regular strings, anyways). >> >>"".join is just creepy. >> >> > it looks plain wrong, but would ['a','b','c'].join(';') look any better? > > In fact there may be some benefit in being able to say > > pathJoiner = (sys.platform=='win32' and ';' or ':').join > ..... > path1 = pathJoiner([d1,d2,.....]) > path2 = pathJoiner([e1,e2,.....]) > good ole: from string import join l = join(';', ['a','b','c']) # thanks, this is clear and obvious Please o' gods of python, do not deprecate the clean and obvious syntax that is found in the string module. From mvanier at endor.bbb.caltech.edu Sun Mar 4 00:49:58 2001 From: mvanier at endor.bbb.caltech.edu (Michael Vanier) Date: 03 Mar 2001 21:49:58 -0800 Subject: writing a C function to manipulate python lists References: Message-ID: I should have RTFM before I posted. I worked my way through the embedded/extending parts of the online docs and got the function I needed working in no time. I think SWIG had conditioned me into thinking that extending python at the C level was really hard (my fault, not SWIG's), but it's actually quite easy, especially with the newer releases. Thanks to all who replied! Mike -------------------------------------------------------------- Mike Vanier mvanier at bbb.caltech.edu Department of Computation and Neural Systems, Caltech 216-76 GNU/Linux: We can't lose; we're on a mission from God. From will at nospam.misconception.org.uk Mon Mar 19 13:10:45 2001 From: will at nospam.misconception.org.uk (Will Newton) Date: Mon, 19 Mar 2001 18:10:45 +0000 Subject: Subsetting a dictionary References: <993dkm$ttr$1@news6.svr.pol.co.uk> <993sif$92d$1@news.udel.edu> Message-ID: <995hu4$ea7$1@newsg3.svr.pol.co.uk> Terry Reedy wrote: > Hmmm. What you need is a currently imaginary feature that we might call a > dict comprehension, > with syntax paralleling that for list comprehensions: > D2 = {key:val for (key,val) in D if constraint(key,val)} That would indeed be cool. The worry I have with this syntax is the constraint will often be on only the value or the key (as in my case) and accessing the dict as a list of key-value tuples may be very slow and not much faster than the current way of doing things. (And why not use a list of tuples in this case?) I'm not sure exactly how it would be best do this, but I think it could be a useful feature. From xeno at bigger.aa.net Sat Mar 10 01:01:28 2001 From: xeno at bigger.aa.net (Xeno Campanoli) Date: 9 Mar 2001 22:01:28 -0800 Subject: LWP session problems Message-ID: <3aa9c338$1_3@huge.aa.net> I'm trying to make some Perlscripts work that need to make web client requests. LWP, it turns out, is really hard (possibly impossible) to make work over multiple requests for an SSL session because you can't seem to make it maintain the SessionId... or at least, I haven't been able to make it do that, and nobody on the mailing lists seems to have a clear answer. So, there must be a good (probably superior) web robot that does everything without problems or obscurity or breakage in Python...Is there a class in Python I can use effectively to program multiple requests in an SSL session? If so, I'll try to use it soon. I keep hearing that Python and Python People do it better..so? Sincerely, Xeno -- Xeno Campanoli (erstwhile Xeno Whitenack, and Rick Burgess) Email: xeno at aa.net (Web pages: http://www.aa.net/~xeno) From stephen_purcell at yahoo.com Wed Mar 14 09:19:41 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Wed, 14 Mar 2001 15:19:41 +0100 Subject: Better string.translate? In-Reply-To: <3aaf758f$1_2@news.zet.net>; from stowasser.h@idowa.de on Wed, Mar 14, 2001 at 02:44:42PM +0100 References: <3aaf758f$1_2@news.zet.net> Message-ID: <20010314151941.B30007@freedom.puma-ag.com> Stowasser Harald wrote: > Hello, > i am very new in Python. I don't know how i can do this better: > > _deltable=string.maketrans('.,:;-_?!.=()?[]{}\'\"\r\n\f\t\v',' > ') > ret = string.translate(s,_deltable) > > This works fine, but i need a 'anti-maketrans'. > I want to define what characters NOT to change in a space-character. Use the 'sub' function in the 're' module: >> import re >> re.sub('[^abcd]','', "string from which to remove all but a, b, c or d") 'cababcd' -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From romberg at smaug.fsl.noaa.gov Thu Mar 22 17:47:00 2001 From: romberg at smaug.fsl.noaa.gov (Mike Romberg) Date: 22 Mar 2001 15:47:00 -0700 Subject: Is setup.py a "good thing"? (long) References: <3aba76e2.167083508@24.0.228.33> Message-ID: >>>>> " " == Mike Clarkson writes: > setup.py was introduced in 2.1, presumably to help configure > and compile Python, so presumably it's a "good thing". But I > have an uneasy feeling which I will try to explain. [snip] I too have these same concerns about setup.py. To me it seems that distutils (which is what I think setup.py uses) does not yet work very well with C extension modules. So, why not use configure to deal with these and let distutils do the pure python stuff. I suppose distutils could even call configure. A setup like this would allow users to specify Tcl/Tk and other libraries using one of the methods supported by configure. As of now I'm not real comfortable with having to hack setup.py to get _tkinter to build. I can do this but describing what needs to be done to others is difficult. It is more complicated that a makefile or a simple command line argument to configure. Mike Romberg (romberg at fsl.noaa.gov) From grante at visi.com Sat Mar 24 20:09:15 2001 From: grante at visi.com (Grant Edwards) Date: Sun, 25 Mar 2001 01:09:15 GMT Subject: static methods References: <7h1qbt8h8aos1parc090s8tqu2ooc04t4d@4ax.com> <4lgqbto46c4c6i307lnq0e614uujd2fsss@4ax.com> Message-ID: On Sun, 25 Mar 2001 00:52:06 GMT, Courageous wrote: >>>Hrm. I'd forgotten that. In languages where there are no namespaces, >>>it's useful to be able to make certain that symbols don't go out and >>>pollute the global namespace in which ALL symbols reside. This is >>>what that's for. >> >>I'm confused -- are you saying that C doesn't have namespaces? > >Erm, well, unless C99 defined them, no. There's a global namespace, a "file" namespace, and each set of {} defines a namespace (they're all nested). Somehow I don't think that's what you're talking about... -- Grant Edwards grante Yow! World War III? No at thanks! visi.com From JohnH at PHM.GOV.AU Thu Mar 1 23:13:20 2001 From: JohnH at PHM.GOV.AU (Hirsch, John) Date: Fri, 2 Mar 2001 15:13:20 +1100 Subject: Cannot find win32gui.IsIconic() Message-ID: Hi All I am trying to use win32gui.IsIconic() to check if a window has been minimized. But Python gives me an AttributeError when I try to call it. According to the win32gui documentation it should be there. Am I doing something wrong. Thanks Jon From jra at dorothy.msas.net Thu Mar 29 17:44:39 2001 From: jra at dorothy.msas.net (Jay R. Ashworth) Date: Thu, 29 Mar 2001 22:44:39 GMT Subject: Linux GPS program References: <3AC01637.4EF3A6F2@crynwr.com> <3AC0D915.83C2C0C3@crynwr.com> Message-ID: This one time, in band camp, John J. Lee wrote: > On Tue, 27 Mar 2001, Jay R. Ashworth wrote: > > This one time, in band camp, > > Russell Nelson wrote: > [...] > > > No. I used pygtk, which is a set of Python bindings to the gtk > [...] > > Okay, he does know what it (free software) means, I was wrong. You may have missed that this is *Russ Nelson*, who's been doing commercial support for the *free* Clarkson/Crynwyr packet drivers for about 300 years... Yeah, he knows what "free" means. Cheers, -- jra -- Jay R. Ashworth jra at baylink.com Member of the Technical Staff Baylink The Suncoast Freenet The Things I Think Tampa Bay, Florida http://baylink.pitas.com +1 727 804 5015 From claird at starbase.neosoft.com Mon Mar 12 12:40:31 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 12 Mar 2001 11:40:31 -0600 Subject: Magnitude of the wx* market (was: Python In A Nutshell - suggestions) References: <3AAA4FE3.B471B689@northwestern.edu> Message-ID: In article <3AAA4FE3.B471B689 at northwestern.edu>, Louis Luangkesorn wrote: . . . >And while I'm at it, one useful book to have would be on wxWindows/wxPython. I see references to it in several places, and a few intros on the web, but . . . This is an interesting point. It's typical in computer book publishing that publishers want more than authors can produce; roughly, someone like ORA would happily print many more titles than they can find authors willing and able to write. I happen to know, though, that several publishers have rejected wxWindows proposals. I doubt, though, that there'd be much trouble making the case that the subject deserves a chapter in a larger work. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From whisper at oz.net Thu Mar 29 15:29:19 2001 From: whisper at oz.net (Dave LeBlanc) Date: 29 Mar 2001 20:29:19 GMT Subject: htmllib samples References: <3AC2F48E.4EF77C71@aon.at> Message-ID: <9a05uv$png$0@216.39.170.247> Ok, i'll bite - why would you want to use the significantly greater complexity of SGML if you think you want to do HTML? Regards, Dave LeBlanc P.S Looked at the book niblet on O'Reilly - looks good. Can't wait to see it in print! On Thu, 29 Mar 2001 08:53:32 GMT, "Fredrik Lundh" wrote: >note that when you think you need the htmllib module, you >usually want the sgmllib module: >Cheers /F From sholden at holdenweb.com Tue Mar 13 02:33:10 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 13 Mar 2001 02:33:10 -0500 Subject: learning C References: <983975751.18833@newsmaster-04.atnet.at> <984047775.592522@newsmaster-04.atnet.at> <9896hk$ig8$1@verence.demon.co.uk> <984134612.781779@newsmaster-04.atnet.at> <3AACE22D.3A9EEB12@bt.com> Message-ID: "Alan Gauld" wrote in message news:3AACE22D.3A9EEB12 at bt.com... > Werner Schiendl wrote: > > Unsafe is somewhat the same topic I think: It's a question > > of disciplined use. > > I think one problem with C++ is the number of temporary objects > it creates. [ ... ] > > In C, by virtue of its fixed primitive types, is much easier > to gurantee what will happen by way of memory allocation etc. > > > > There's the feeling that you never quite know what it's > > > going to do. > > Temporary objects being one such case. Others include the use of > operator overloading, function overloading vv default parameters > etc etc. C++ is a maintenance nightmare compared to C - I speak > from 18 months painful experience maintaining a large C++ system! > > > You can have the same in C++ (using one or more static objects, > > or construct the objects just once when booting) > > Even here the compiler will cause tempoiray object copies to > occur when passing object references around. Static objects are > not as 'static' as we might like to think! > > > > This is nothing more difficult than in C. > > Sorry but it is. There's just so much less lurking under > the hood in C. > But by this argument, assembly code is even better! It's always a question of selecting language features because they are appropriate to your problem domain. or-doing-what-the-pointy-haired-managers-tell-you-ly y'rs - steve From robin.thomas at starmedia.net Thu Mar 1 01:58:49 2001 From: robin.thomas at starmedia.net (Robin Thomas) Date: Thu, 01 Mar 2001 01:58:49 -0500 Subject: d = {}; d[0:1] = 1; d[0:1] = 2; print d[0:1] In-Reply-To: <97kotr$su9$0@216.39.151.169> References: Message-ID: <4.3.1.2.20010301014119.00cf3490@exchange.starmedia.net> At 06:06 AM 3/1/01 +0000, Donn Cave wrote: >If it helps, you ruined my day. Now I'm not alone! >I think we might be able to do better. I hacked in a quick fix >in ceval.c that looks to me like it has the desired effect without >closing the door to intentional slice keys (however unlikely.) Cool. I think that the abstract object layer saves us, though: - slice assignment is handled by PySequence_SetSlice - *intentional* assignment of slice object is handled by PyObject_SetItem PySequence_SetSlice, strangely, has a big chunk of code expressly written to support slice assignment to mapping objects. From Objects/abstract.c below. If we remove that code, we get the same effect. int PySequence_SetSlice(PyObject *s, int i1, int i2, PyObject *o) { PySequenceMethods *m; PyMappingMethods *mp; if (s == NULL) { null_error(); return -1; } m = s->ob_type->tp_as_sequence; if (m && m->sq_ass_slice) { if (i1 < 0 || i2 < 0) { if (m->sq_length) { int l = (*m->sq_length)(s); if (l < 0) return -1; if (i1 < 0) i1 += l; if (i2 < 0) i2 += l; } } return m->sq_ass_slice(s, i1, i2, o); /* the evil begins */ } else if ((mp = s->ob_type->tp_as_mapping) && mp->mp_ass_subscript) { int res; PyObject *slice = sliceobj_from_intint(i1, i2); if (!slice) return -1; res = mp->mp_ass_subscript(s, slice, o); Py_DECREF(slice); return res; } type_error("object doesn't support slice assignment"); return -1; } Anybody have an explanation why this behavior was desired? >I don't know if this is the answer, but it at least demonstrates >that [:] and slice() can be separate issues at some level. They're separate issues even for lists: >>> l = [] >>> l[0:1] = [1] >>> f = slice(0,1) >>> l[f] = [1] Traceback (innermost last): File "", line 1, in ? l[f]= [1] TypeError: sequence index must be integer The question remains: should slice objects be hashable/comparable so that >>> slice(0,1) == slice(0,1) 1 I say YES YES YES. What do you say? -- Robin Thomas Engineering StarMedia Network, Inc. robin.thomas at starmedia.net From pfortin at pfortin.com Tue Mar 13 19:35:22 2001 From: pfortin at pfortin.com (Pierre Fortin) Date: Tue, 13 Mar 2001 19:35:22 -0500 Subject: PyQT-2.3 compile fails... Message-ID: <3AAEBCCA.4E53671@pfortin.com> Hi, Anyone have a clue as to why others can compile PyQT-2.3; but I get errors...? I've also tried the CVS files... I'd hate to think this is a symlink related problem: /usr/local/src --> /hd/b6/src Thanks, Pierre # make make all-recursive make[1]: Entering directory `/hd/b6/src/Python/PyQt-2.3' Making all in qt make[2]: Entering directory `/hd/b6/src/Python/PyQt-2.3/qt' /bin/sh ../libtool --mode=compile c++ -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include/python2.0 -I/usr/local/include/sip -I/usr/local/qt/include -I/usr/X11R6/include -fno-exceptions -O2 -c sipqtQString.cpp c++ -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include/python2.0 -I/usr/local/include/sip -I/usr/local/qt/include -I/usr/X11R6/include -fno-exceptions -O2 -Wp,-MD,.deps/sipqtQString.pp -c -fPIC -DPIC sipqtQString.cpp -o sipqtQString.lo sip/qstring.sip: In function `int sipConvertTo_QString(PyObject *, QString **, int, int *)': sip/qstring.sip:456: no matching function for call to `QString::setUnicodeCodes (short unsigned int *&, int &)' make[2]: *** [sipqtQString.lo] Error 1 make[2]: Leaving directory `/hd/b6/src/Python/PyQt-2.3/qt' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/hd/b6/src/Python/PyQt-2.3' make: *** [all-recursive-am] Error 2 From thomas.heller at ion-tof.com Thu Mar 22 04:01:48 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 22 Mar 2001 10:01:48 +0100 Subject: Standalone executables References: <998igr$4al$1@niagara.nonet> <99aldn$7dh$1@niagara.nonet> Message-ID: <99cf1s$hrsb$1@ID-59885.news.dfncis.de> > I wonder, for Linux, what if I wrote in Jython, compiled with jythonc, > then used a Java native-code compiler? Would that be too insane? (-: > With virtually every Linux coming with python, why is this needed at all? Thomas From dmaas at dcine.com Mon Mar 12 00:55:04 2001 From: dmaas at dcine.com (Dan Maas) Date: Mon, 12 Mar 2001 05:55:04 GMT Subject: Poll'able Queue objects. References: Message-ID: > The mind wobbles. One of the things that Unix got right is that you can > select() (or poll()) on pipes, sockets, serial ports (any properly written > character device that's properly written), or, in degenerate-case sort of > way, "regular" files. As much of a Unix fan as I am, we've got it worse... Pthreads condition variables. SysV semaphores and message queues. Asynchronous disk I/O (POSIX AIO). UNIX signals. None of these "waitable objects" can be multiplexed together with file descriptors*... Also the "stateless" paradigm of select() and poll() is not always preferable to "stateful" Windows message loops - consider the problems involved with using two unrelated Unix libraries that each want control of the main loop... AFAIK MsgWaitForMultipleObjects() handles Win32 message queues, semaphores, mutexes, async disk I/O, network I/O, etc. The API is not as clean but the functionality is there =) Dan * well FreeBSD has kqueue, those lucky bastards =) From dwig at advancedmp.net Mon Mar 19 12:39:47 2001 From: dwig at advancedmp.net (Don Dwiggins) Date: 19 Mar 2001 09:39:47 -0800 Subject: Pep 238 Why new // operator (Non-integer Division) In-Reply-To: "Tim Peters"'s message of "Sat, 17 Mar 2001 04:50:30 -0500" References: Message-ID: Tim Peters writes: > [Alex Martelli] >> So what's so terrible about non-infix notation, a builtin div(a,b) [and >> mod(a,b) too since we're at it...?]. Sure, infix can be handy -- > Infix is also a speed issue in Python, since syntax is fixed but builtin > names are not reserved; so the speed freaks will surely argue for syntax. >> but then this might be the occasion to steal a leaf from Haskell's >> book... let any 2-operand function be used as an infix operator >> (possibly with some stropping if that is needed to disambiguate >> syntax). Many Prologs also have this capability, with a way to define prefix, infix, and postfix operators, along with precedence values to determine grouping. -- Don Dwiggins "Solvitur Ambulando" Advanced MP Technology dwig at advancedmp.net From annis at biostat.wisc.edu Mon Mar 26 09:24:28 2001 From: annis at biostat.wisc.edu (William Annis) Date: 26 Mar 2001 08:24:28 -0600 Subject: Daemonizing a python programme. References: <3ABBE09E.3287DEC5@qvlinc.com> Message-ID: Coy Krill writes: > class NullDevice: > def write(self, s): > pass > > def daemonize(): > if (not os.fork()): > # get our own session and fixup std[in,out,err] > os.setsid() I include these here: os.chdir(some_sensible_root_dir_for_core_files) os.umask(000) # or whatever seems sensible See chapter 13, "Daemon Processes," pp.415-425 of "Advanced Programming in the Unix Environment" by W. Richard Stevens for a full treatment. > sys.stdin.close() > sys.stdout = NullDevice() > sys.stderr = NullDevice() This is curious. Why not just close down STDOUT and STDERR, too? -- William Annis - System Administrator - Biomedical Computing Group annis at biostat.wisc.edu PGP ID:1024/FBF64031 Mi parolas Esperanton - La Internacian Lingvon www.esperanto.org From jmarshal at mathworks.com Mon Mar 5 12:25:46 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 5 Mar 2001 17:25:46 GMT Subject: Little problem with the "+" operator References: <983802310.155838463@news.t-online.de> Message-ID: <980i6q$crs$1@news.mathworks.com> Steve Purcell wrote: > Zamurai wrote: >> variableOne = 500 >> myVariable = variableOne + "cool" >> >> But I get the following error: "unsupported operand types for +" >> >> Does someone know how to solve the problem? > You can't add variables of different types together in Python and expect them > to magically agree on a sensible result. > So, you have to explicitly say: >>>> variableOne = 500 >>>> myVariable = str(variableOne) + "cool" >>>> myVariable > '500cool' >>>> > Or, >>>> variableOne = 500 >>>> myVariable = variableOne + int("cool") > Traceback (innermost last): > File "", line 1, in ? > ValueError: invalid literal for int(): cool >>>> > This is infinitely more sane than: > % perl -e 'print 500 + "cool"' > 500 Comparing Python to Perl here doesn't seem very fair. They're very different languages. In general, I'm surprised by the urgency with which people often jump to compare them. From sholden at holdenweb.com Tue Mar 27 23:39:02 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 27 Mar 2001 23:39:02 -0500 Subject: newbie IDLE, Tkinter References: <01c0b6e2$3d426740$4ecb0c28@PC0AB085S5A8> Message-ID: "Randy Hawley" wrote in message news:01c0b6e2$3d426740$4ecb0c28 at PC0AB085S5A8... > Howdy Python Gurus. > > I too am a newbie trying out Python on Win32 platforms. > > I have the same problems as Nick describes below. Also, somethimes when > I hit a button that has "command=root.quit" defined as its action, not only > does my program's window quit, but so does IDLE. > > What gives with this? Anybody else ever run into this? Is it a result of > poor coding in my script (saw it when I just ran the examples from the > Tkinter tutorial, too) ? > > Thanks, > Randy Hawley > > Nick Perkins wrote in article > ... [ ... similar problems ... ] The difficulty you are experiencing is to do with IDLE being a Tkinter application itself, I suspect. I normally run Tkinter-based programs from a command window to avoid the unpredictable interactions you describe. I guess one day IDLE may be able to run programs as a separate process. regards Steve From bbollenbach at homenospam.com Tue Mar 6 15:41:34 2001 From: bbollenbach at homenospam.com (Brad Bollenbach) Date: Tue, 06 Mar 2001 20:41:34 GMT Subject: Can Python replace Visual Basic? Should it?...and generalities : ) References: Message-ID: <2Ybp6.12845$hn5.1818206@news1.rdc1.mb.home.com> This reply is interesting, but still contains a lot of the "I've started invistigating Python and these are the things I like about it" comments, which I was hoping to avoid. [snip] > A Python "OCX" control needs to be written. This control > would simply encapsulate Python for us Visual Basic idiots. > This way we could 'pop in the control in our VB project and > start using Python for parts of the program. That's a neat idea. I hope someone smarter than me decides to do it. :) > At first, this control could be non-visual. The OCX would > have to expose through IDispatch the objects managed within > the embedded python system. Then, it would be cool if it > became a wxWindows frame, so that small client areas could > be re-written in Python, etc. For extra bonus points, > the visual control would allow OCX components to be dropped. > > Eventually the VB programmer could 'drop the VB shell after > their entire program is re-written. In the corporate world, > it will be damn near impossible to get funding for re-writing > a program in Python. However, it is very possible to have > this conversion be INCREMENTAL, one sub-routine at a time! > In short, a complete re-write is just too high of risk for > most corporate progammers to do... "Damn near impossible", but not "impossible". I know, because where I work, we ARE almost done a complete rewrite of an app that was written in Powerbuilder 4.x (the exact version, I'm not sure), now being completely rewritten (with a totally new database) in Powerbuilder 6.5.1. To give you an idea of the size of the app, there are 200+ stored procs behind it, and about 30,000-40,000 lines of Powerscript code (but that's totally ballpark, I'm just guessing). And with the dime-a-dozen comments that keep saying how ridiculously simple Python is, you'd think that maybe we should have chosen Python instead of a newer version of Powerbuilder?! Hmm...the more I think about it, the more I think we chose the right tool for the job. But then, as seems to be often the case, people seem to blur the differentiation between "easy programming languages" and "easy programming tasks". How many people have written 30,000 lines out of _any_ programming language and still refer to it as being simple to work with? As, you mentioned in a reply to the other thread of this thread (heh), coding really is the most insignificant part of a large programming project in a coporate environment. In theory at least, you should have a clear idea of what you're going to do before you do it, in which case the coding (almost irregardless of the language) is often times just grunt work. From topmind at technologist.com Wed Mar 21 05:07:26 2001 From: topmind at technologist.com (topmind) Date: Wed, 21 Mar 2001 10:07:26 GMT Subject: Collection interfaces References: <3a90fa97.0@news1.mweb.co.za> <3A9A86B1.9A8C69A2@ix.netcom.com> <97fjla128ir@news2.newsguy.com> <97h5s40vhc@news2.newsguy.com> <97ibmc0k47@news1.newsguy.com> <97m0c7080c@news2.newsguy.com> Message-ID: ----- Original Message ----- From: "Randy A. Ynchausti" Newsgroups: comp.object,comp.lang.smalltalk,comp.lang.python,comp.lang.java.advocacy Sent: Tuesday, March 20, 2001 1:01 AM Subject: Re: Collection interfaces > topmind, > > > Okay. > > > > For the sake of argument, let's say that OO shines if the app is very > mathy. > > > > But, what about the rest? > > What the rest any different from the very mathy? The classes and objects > don't care what their behaviors are. > They do if their behavior is mathy. > It use to be that people said you should never implement a compiler using OO > because for all of the "obvious" reasons. Then someone did it and found out > that their solution was essentially as fast, easier to maintain, and > produced a smaller code base. As far as I am concerned the same experience > was had by the "data-visualization" industry. > > Now -- where is that procedural code -- I have the OO code in hand? > > Regards, > > Randy > > I don't consider that a "typical custom biz app" because it requires a certain math *specialty* and I don't know enough about that narrow specialty to comment. Most apps I work with use very little math beyond adding and multiplying and dividing. Thus, my math skills have greatly rusted over the years, as have many other biz app programmer's. This is NOT saying that biz apps are simple, but just not complexity in the math sense. -tmind- From daniel at dittmar.net Wed Mar 14 15:04:26 2001 From: daniel at dittmar.net (Daniel Dittmar) Date: Wed, 14 Mar 2001 21:04:26 +0100 Subject: Dynamic construction of a print format string References: <3AAFB663.57FCCE7@troikanetworks.com> Message-ID: <3AAFCECA.18663E5D@dittmar.net> If you want to set some format size dynamically, you can use the * option. "%*s" % (namelen, data) Not quite the asnwer to your question, but maybe the solution to your problem. Daniel Bruce Edge wrote: > > I'm using: > > fmtstr = "%s%s%s" % ( " %", namelen, "s - %s" ) > > to get: > > " %19s - %s" > > Is there a better way? > > TIA, Bruce. From tchur at optushome.com.au Tue Mar 13 13:39:06 2001 From: tchur at optushome.com.au (Tim Churches) Date: Wed, 14 Mar 2001 05:39:06 +1100 Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> <3aad6ffe.3692710@News.CIS.DFN.DE> Message-ID: <3AAE694A.765076D3@optushome.com.au> Costas Menico wrote: > >> Ok, I can see maybe division having problems. But why does addition of > >> the two numbers below: > >> > >> 5.01+5.54 > >> > >> give me this? > >> > >> 10.550000000000001 > >> > >> I hope its some setting that can take care of this. I am using Python > >> under Windows 98. > > > >It's worse than that. Try: > > > >>>> 5.01 > >5.0099999999999998 > > I don't think anyone has mentioned Jurjen Bos' real-accurate module (see ftp://ftp.python.org/pub/www.python.org/ftp/python/contrib-09-Dec-1999/DataStructures/). Alas it doesn't fix the finite precision limitation which these newfangled electric digital computer gizmos have when it comes to floating point numbers, but it does make the limitation explicit, viz: >>> import real >>> a = real.r(5.01) >>> b = real.r(5.54) >>> a 5.010000000000000+-1 >>> b 5.540000000000000+-1 >>> a + b 10.549999999999997+-4 give-or-take-a-bit-ly y'rs - Tim C From brian_zhou at agilentNOSPAM.com Sun Mar 18 18:22:35 2001 From: brian_zhou at agilentNOSPAM.com (Brian Zhou) Date: Sun, 18 Mar 2001 15:22:35 -0800 Subject: [Announce] jywiki Message-ID: <984957750.523849@emperor.labs.agilent.com> This is a wiki clone ported from Martin Pool's PikiPiki to Jython Servlet. The project is hosted here: http://sourceforge.net/projects/jywiki And there is a wiki (using phpwiki for now): http://jywiki.sourceforge.net with information about Jython Servlet in general and jywiki in specific. It's still work in progress since I don't have a lot of time to spare. Cheers, -Brian Zhou From aleaxit at yahoo.com Mon Mar 12 04:28:07 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 12 Mar 2001 10:28:07 +0100 Subject: any interest in type-scoped static constants? References: <3AAB9578.4C8754E4@fxtech.com> <98gs2i$2vtp$1@news1.simtel.ru> Message-ID: <98i4r70p4r@news2.newsguy.com> "Alexander Semenov" wrote in message news:98gs2i$2vtp$1 at news1.simtel.ru... [snip] > > If I create an extension type for Point, I can't do this: > > > > p = Point.ZERO > > In Python: > > class Point: > def __init(self, x, y): pass > > Point.ZERO = Point(0,0) > > Then you can write p = Point.ZERO. > It's even simpler and clearer then C++ Yes, but it doesn't apply to *extension types* (which you write in C or C++, then *use* from Python), only to classes you write in Python itself. One solution is, indeed, to split the extension into two parts: one, written in C or C++, is in some _foo.pyd (the leading _ suggests it's internal-use-only), and it's wrapped by a foo.py which adds the niceties -- a rather popular solution (you only use C or C++ for truly speed-critical parts). Another is to use the Boost Python Library (www.boost.org) to write your extension (in C++, only -- C is not supported). BPL uses the Beaudry Hook so the 'types' it exports are actually 'extension classes', so you can do a lot with them that would not be feasible with 'just-types', including using attributes. Alex From bfleming at bserv.com Thu Mar 1 15:03:56 2001 From: bfleming at bserv.com (Bruce Fleming) Date: Thu, 01 Mar 2001 20:03:56 GMT Subject: Can SAX parser return ??? Message-ID: How can I expose comments in the content handler ? It does not return comments by default, and I cannot find where to hook into the class..? From ben.hutchings at roundpoint.com Tue Mar 6 16:42:31 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 06 Mar 2001 13:42:31 -0800 Subject: Little problem with the "+" operator References: <983802310.155838463@news.t-online.de> <980i6q$crs$1@news.mathworks.com> <3aa3d3a7.420988249@news.uswest.net> Message-ID: joconnor at cybermesa.com (Jay O'Connor) writes: > Actually, JavaScript will allow you to add numbers to strings, with > weird results > > '100' + 200 = '100200' > 100 + '200' = 300 > > I *think* that's how it works, I just know it's not very safe So my mathematics teachers were lying when they said addition was commutative! Seriously, that's just awful behaviour. I now have this vision of what someone at Netscape must have written when hacking JavaScript (ne? LiveScript) together: class LiveScriptObject { virtual LiveScriptObject * add(LiveScriptObject const * other) = 0; }; class LiveScriptInteger { virtual LiveScriptObject * add(LiveScriptObject const * other) { return new LiveScriptInteger(integer_ + other->toInteger()); } }; class LiveScriptString { virtual LiveScriptObject * add(LiveScriptObject const * other) { return new LiveScriptString(string_ + other->toString()); } }; Yes, addition is *obviously* just a function that's dynamically dispatched on its left argument. Any web page author should know *that*. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From niessink at serc.nl Mon Mar 19 07:56:53 2001 From: niessink at serc.nl (Frank Niessink) Date: 19 Mar 2001 12:56:53 GMT Subject: Tkinter Canvas inheritance References: <3AB5EC65.DF767FDC@ira.uka.de> Message-ID: <994vml$c20$1@newshost.accu.uu.nl> Markus von Ehr wrote: > > When I change the Code and create the image in the main function, > there's no problem, it works well. How can I do it in the constructor > and why doesn't it work???? You need to keep a reference to the image else it gets garbage collected. Change: > slider = PhotoImage(file="button.gif") into: > self.slider = slider = PhotoImage(file="button.gif") Cheers, Frank -- See first, think later, then test. But always see first. Otherwise you will only see what you were expecting. Most scientists forget that. -- Douglas Adams, 'So long, and thanks for all the fish' From parkw at better.net Sat Mar 17 19:49:29 2001 From: parkw at better.net (William Park) Date: Sat, 17 Mar 2001 19:49:29 -0500 Subject: Interactive startup file In-Reply-To: <3dTs6.2144$ge.55105@news3.mia>; from brendhanhorne@bellsouth.net on Sat, Mar 17, 2001 at 07:22:15PM -0500 References: <3dTs6.2144$ge.55105@news3.mia> Message-ID: <20010317194929.A9033@better.net> On Sat, Mar 17, 2001 at 07:22:15PM -0500, Brendhan Horne wrote: > In the tutorial it says in section 2.2.3 ... > import os > filename = os.environ.get('PYTHONSTARTUP') > if filename and os.path.isfile(filename): > execfile(filename) ... > Can some one please explain this to me in novice english and for a guy > who is using windows98 with his python. Well, it's exactly what it says. If you set environment variable PYTHONSTARTUP='.pythonrc' then commands in file '.pythonrc' will be executed everytime you run python in interactive mode (ie. when you get '>>>' prompt). For example, mine contains import rlcompleter rlcompleter.readline.parse_and_bind('tab: complete') If you want to run those commands from a script, then you have to call the file explicitly, using execfile('.pythonrc') :wq --William Park, Open Geometry Consulting, Linux/Python, 8 CPUs. From t*b*r*u*m*l*e*y at f*u*s*e.n*e*t Fri Mar 23 08:04:34 2001 From: t*b*r*u*m*l*e*y at f*u*s*e.n*e*t (Troy Brumley) Date: Fri, 23 Mar 2001 08:04:34 -0500 Subject: Collection interfaces References: <3a90fa97.0@news1.mweb.co.za> <3A9A86B1.9A8C69A2@ix.netcom.com> <97ibmc0k47@news1.newsguy.com> <97m0c7080c@news2.newsguy.com> s.earthlink.net> <3AA2A898.450B659E@mail.com> <3AB755F8.67E84126@mail.com> <%a%t6.17245$227.1601569@newsread2.prod.itd.earthlink.net> <3AB8A730.4BE13D22@mail.com> Message-ID: in article Q7Bu6.2721$P4.207644 at newsread1.prod.itd.earthlink.net, topmind at topmind at technologist.com wrote on 3/23/01 12:26 AM: > > "Troy Brumley" wrote in message > news:B6DF5D0D.D7AE%t*b*r*u*m*l*e*y at f*u*s*e.n*e*t... >> in article anhu6.18497$Im6.1938203 at newsread1.prod.itd.earthlink.net, > topmind >> at topmind at technologist.com wrote on 3/22/01 1:57 AM: >> >>> >>> "Troy Brumley" wrote in message >>> news:B6DE17D2.D6B0%t*b*r*u*m*l*e*y at f*u*s*e.n*e*t... >>>> in article 3AB8A730.4BE13D22 at mail.com, James A. Robertson at >>>> jarober at mail.com wrote on 3/21/01 8:06 AM: >>>> >>>>> topmind wrote: >>>>>> >>>>> >>>>>>> http://www.cincom.com/smalltalk >>>>>>> >>>>>> >>>>>> I only see a front page, not a parsing example. >>>>>> >>>>> >>>>> Follow the tutorial link - it's right there on that page. >>>>> >>>>> >>>>>> Besides, what are you comparing it to so say >>>>>> it is better than a procedural/relational approach? >>>>> >>>>> It's vastly easier than similar code done in C or basic, for example >>>> >>>> User testimonial here ... last week I had to rip thorugh a pile of IIS >>> logs >>>> to get some statistics for some people, and I used the original > (non-gui) >>>> tutorial code as a starting point. I was once again impressed with how >>> much >>>> easier it was to do several common data processing tasks in Smalltalk > than >>>> it was in Assembly language or C or Pascal. >>>> >>> >>> Give me specific requirements and I bet I can match it on code size. >>> >>> C, Pascal, and Assembly are hardly what I would use for code-size >>> contests. >>> >>> Of course, there is more to comparing than code size, but those often >>> get very subjective or fuzzy. >> >> I rarely worry about code size except how it relates to code clarity. Even >> back in my assembly oriented youth I tried to keep functions under one > page >> on a listing for the sake of clarity. >> > > Can you quantify "clarity" or is it a personal thing (subjective)? My rule of thumb definition back in assembly days was not having to have a separate note pad to keep track of what was going on. When I saw many coworkers running out of fingers to mark pages in fanfold listings as they flipped back and forth, I realized there was an easier solution -- move code around and rewrite it. Yet another reason why refactoring comes natural to me, I've never been afraid to rewrite code. > What makes people confortable with code seems to vary > greatly per individual. True. > Do you have specific examples. Not anymore. That system is retired. I still use those principles when I am forced into a procedural environment because I know they work and people have repeatedly said "thanks for cleaning that code up so I could understand it" back in those old days. Unlike some, my personal software process has not developed to include record keeping. > >> I mention C, Pascal, and Assembly because they are my usual tool set, or >> were until I discovered Smalltalk. > > I used similar stuff at first, but was glad to leave them in the dust when I > discovered the concepts of Table Oriented Programming. > > I never wanted to see another fricken array again (accept as > hashes/dictionaries to pass single records or parameter > lists or attributes. That is their best use, and not data collection > holding.) While I'm not familiar with table oriented programming, a long time ago I did read a book on decision tables in software engineering. I wonder if your advocacy of TOP is because it's the paradigm that works best with how your mind works? I know people who can do wonderful things in RPG that I could never do in the language, and indeed I found that working in it gave me headaches. These same people, bright and capable, couldn't work in my prefered environment of assembly language. Some assembly language programmers I worked with could not transition to 4GLs like Cincom's MANTIS. We all have different thinking styles, and I think language/environment preference relates directly to this. I'm a non-linear non-verbal intuitive thinker and I like Smalltalk. I know one verbal linear type who I couldn't imagine working in Smalltalk, but she's a very sharp gal. > >> I've done a lot of business programming >> over the years in procedural environments and used more languages than > those >> (even COBOL and RPG) but for the heavy lifting I would always stick with >> them. >> >> Again, until I discovered Smalltalk :) >> >> I've seen Perl and run away screaming. > > Perl is a strong divisor. You either swear by it, or swear at it. There > are few in-betweeners. Scripting tools are wonderful, but why write one with an ugly looking C type of code? Yuck! :) > >> Python and Eiffel are on the to learn >> list, but Smalltalk seems to have the power I need for the tasks I want to >> do these days. Objects are becoming more and more natural as I use them, > and >> my code improves contantly. >> >>> >>>> I'm a long time procedural type, learning to really think in and use >>>> Smalltalk has been an interesting experience. >>>> >>>> I've also done a lot of database "fixing" and Smalltalk has usually > beat >>> out >>>> raw SQL for anything but the most trivial tasks. >>>> >>> >>> Fixing what? SQL is not good at string parsing. >> >> Usually sweeping changes, or dangling referential integrity problems. > > Huh? Referential integrity is an option, not a forced feature. Peculiar to our stage in development. We have both database enforced and some program enforced integrity to manage. I prefer to have the integrity turned on and would like more of it managed in the database, but in a couple of cases there's a chicken and egg cycle between tables. Some of our deletes needed to cascade and did not. I botched some things on a migration and had to go in and fix them up as well. Data does not refactor as well as code :) > If the lamp keeps you awake at night, then turn it off! > >> >>>> All that said, I think it's the environment (interactive) that improves >>> the >>>> experience as much as the language itself. If I had a reasonable >>>> interpretive BASIC environment available, I could probably do many of > the >>>> things I did in Smalltalk almost as easily ... certainly more easily > than >>>> with C. >>>> >>> >>> I find interpretive environments potentially more compact code-wise than >>> static ones. >> >> No argument here. >> >>> >>>> >>>>> >>>>>> >>>>>>>> >>>>>>>>> [snip] > > > From aleaxit at yahoo.com Thu Mar 22 03:10:11 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 22 Mar 2001 09:10:11 +0100 Subject: urllib.urlopen doesn't accept Unicode strings. References: <998tau$q6i$1@troll.powertech.no> <99bk6c$hh7$1@panix6.panix.com> Message-ID: <99cc13014ic@news2.newsguy.com> "Aahz Maruch" wrote in message news:99bk6c$hh7$1 at panix6.panix.com... > In article , > Martin von Loewis wrote: > > > >using types.UnicodeType is much better than type(u"") > > Really? I haven't seen any strong consensus on this issue. Me neither. Personally, I generally find type(aconstant) more directly usable than types.WhateverType, though I do not think it's that big a deal either way. Alex From michael at stroeder.com Thu Mar 8 14:34:20 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Thu, 08 Mar 2001 20:34:20 +0100 Subject: Ldap / Python help References: Message-ID: <3AA7DEBC.555BA9A5@stroeder.com> Pablo Pernot wrote: > > Where can I find documentation about ldap/python Hmm, David sent a new PDF to the mailing list, 28 Jan 2001. Hmm, it does not seem to be on the web page... > my modify instruction won't work => modify_s is waiting for a string (dn) > and a list (mylist) formed by tuple (mytuple) and this tuple is formed for 3 strings. > > So I can't understand the error message about integer. > > mytuple=("MOD_REPLACE","sn","test") Should be mytuple=(ldap.MOD_REPLACE,"sn",["test"]). ldap.MOD_REPLACE is an integer constant hence the... > >>> l.modify_s(dn,mylist) > Traceback (most recent call last): > File "", line 1, in ? > TypeError: an integer is required Ciao, Michael. From bill-bell at bill-bell.hamilton.on.ca Thu Mar 22 21:08:27 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Thu, 22 Mar 2001 21:08:27 -0500 Subject: Digest Number 1946 In-Reply-To: <985302234.525.51095.l7@yahoogroups.com> Message-ID: <3ABA69CB.10176.7159B28@localhost> I'm new to Python, have been playing with someone's whois client, which contains the following lines: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setblocking(1) s.connect((self.whoisserver, 43)) The code works fine (as long as the requested whois server is available) if the argument to 'setblocking' is 1. However, if I change this to 0 I receive the diagnostic, "The socket operation could not complete without blocking." I cannot find the code that contains this literal. Would someone please suggest what might be going wrong. Thanks for any help! Bill Bell, MSc, Software Developer From parkw at better.net Mon Mar 12 15:45:06 2001 From: parkw at better.net (William Park) Date: Mon, 12 Mar 2001 15:45:06 -0500 Subject: continue/else functionality In-Reply-To: ; from chrisa@ASPATECH.COM.BR on Mon, Mar 12, 2001 at 05:27:39PM -0300 References: Message-ID: <20010312154506.A2934@better.net> On Mon, Mar 12, 2001 at 05:27:39PM -0300, Chris Richard Adams wrote: > I have a script that reads lines out of a text file. The first line in > the file serves as a "flag-line" stating whether or not the file should > be read: 1 yes, 0 no. The rest of the file contains data lines to be > read. How can I get my script to read on the first line and upon getting > a 1 go back to the for, get the next line and read the rest from there? > For example, I tried: > > > for line in f.readlines(): > > datalist = string.split(line) > if datalist[0][0] == 1: > continue > elif datalist[0][0] == 0: > break > > ## Do a bunch of string manipulation here... As it is written, you're checking first non-whitespace character on every line. If it's 1, you read next line; if it's 0, you exit the loop; only if it's neither 1 or 0, do you go down further. Solution: Check the first line. Then, do the loop for 2nd, 3rd, ... lines. You may want to check for '1' or '0' (ie. entire string) instead of '1...' or '0...' (ie. first character of string). ---William Park, Open Geometry Consulting, Linux/Python, 8 CPUs. From hungjunglu at yahoo.com Sun Mar 11 19:24:33 2001 From: hungjunglu at yahoo.com (hungjunglu at yahoo.com) Date: Mon, 12 Mar 2001 00:24:33 -0000 Subject: Chinese text GIF file generation Message-ID: <98h501+8kmu@eGroups.com> --- In python-list at y..., William Park wrote: > They are using blocks of image in > ... . > So, what is your question? Do you simply want to duplicate it using > Python? Or, do you want to display each character as separate image? Character-by-charater would not be efficient, since this implies downloading thousands of files to view just one single webpage. Usually people do it by chunks. A chunk is typically a few paragraphs. A small article can fit into one single chunk. > Once these images are stored in /icons/chinese/, you would have to write > stand-alone script to match your input characters to corresponding > images. It would spit out for each chinese character. Usually people would use an application server like Zope to serve this kind of requests. LaTeX is good for printed documents, but not for webpages utilities. By the way, I just found that that they revived the IFCSS website: http://www.ifcss.org/ (There were some internal political problems for sometime, and the website was dead for a long time.) They have text-to-bmp, text-to-PostScript converters, but they are kind of old. I bet their fonts are missing quite a few Chinese characters, too. It's just sad how politics has so deeply ruined this website. I'll search around a bit more. If I don't find anything good, then I'll use Java, or if I have time, I'll write one myself. :) Might have to play with font format and with PIL a bit. regards, Hung Jung From thomas at xs4all.net Tue Mar 13 09:05:42 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 13 Mar 2001 15:05:42 +0100 Subject: Einstein's Riddle In-Reply-To: <98kpaj0p6m@news2.newsguy.com>; from aleaxit@yahoo.com on Tue, Mar 13, 2001 at 10:29:54AM +0100 References: <98kpaj0p6m@news2.newsguy.com> Message-ID: <20010313150542.B404@xs4all.nl> On Tue, Mar 13, 2001 at 10:29:54AM +0100, Alex Martelli wrote: > "Gregory Jorgensen" wrote in message > news:NI9r6.2583$54.2812 at www.newsranger.com... > > So I'm stupid, is that it? I've taken lots of IQ tests and none of them > > had this question on them; that's probably why I don't score so well! > > Actually I did figure out that the German owned the fish. Furthermore I > > was able to determine that the fish is named Eric. > Actually, I'm pretty sure she was called Wanda. Only if the german didn't have a fish licence for it. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From glenfant.nospam at bigfoot.com Fri Mar 30 11:38:58 2001 From: glenfant.nospam at bigfoot.com (Gilles Lenfant) Date: Fri, 30 Mar 2001 18:38:58 +0200 Subject: HELP urllib POST can't get it to work References: <9a1m91$fdg$1@pheidippides.axion.bt.co.uk> <9a1puq$gnf$1@pheidippides.axion.bt.co.uk> Message-ID: <9a2civ$1jr3$1@news4.isdnet.net> Remove the "?" at the end of the URL (useless with POST) "mike mcleod" a ?crit dans le message news: 9a1puq$gnf$1 at pheidippides.axion.bt.co.uk... > Also if I try to add the params as as a string: > > params = 'address==07&message=test&... > f = urllib.urlopen("http://www.samemachine.uk/bin/afunc.pl?", params) > > I get: >

Error occured on server. Couldnt open result file, > > Mike McLeod. > > From neilh at scintilla.org Fri Mar 2 16:09:27 2001 From: neilh at scintilla.org (Neil Hodgson) Date: Fri, 02 Mar 2001 21:09:27 GMT Subject: Editing Python source as XML? References: <3a9fe475_1@news.nwlink.com> Message-ID: Adam Logghe: > www.activestate.com has a project called "Komodo" which is written with a > combination of the Mozilla codebase and Python (my understanding is that > originally this was also to have a substantial portion written in Perl but > the developers could code so much faster in Python that Perl ended up as a > minor part). It'd be excellent to hear from ActiveState about their use of Python versus Perl here. Just a company statement that "Perl sucks" would do fine. ;) Neil From bedge at troikanetworks.com Thu Mar 1 20:10:51 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Thu, 01 Mar 2001 17:10:51 -0800 Subject: define a new func on the fly? References: <3A9EE927.8744154E@troikanetworks.com> Message-ID: <3A9EF31B.4105F05C@troikanetworks.com> Gregory Jorgensen wrote: > > eval() evaluates an expression. exec() executes a statement. Try this: Yup, that was it! thanks! Now, how can I get it to create this function in the global namespace? I'm doing this inside of a class method, so I have no access to the new func after I leave the class method. >>> exec( "def xxx(): print \"xxxxxxxx\"" ) >>> xxx() xxxxxxxx Woo Hoo! works! now: >>> class xx: ... def __init__(self): ... exec( "def yyy(): print \"yyyyyyyyy\"" ) ... >>> x=xx() >>> >>> x.__dict__ {} Where is yyy defined? Ideally, I'd like to be able to create it in the global namespace. -Bruce. > > >>> exec("def f():\n\treturn 'hello'\t") > >>> f() > 'hello' > > >>> eval("f()") > 'hello' > > In article <3A9EE927.8744154E at troikanetworks.com>, Bruce Edge says... > > > >I'm trying to define a new function on the at runtime, > > > >this fails: > > > >>>> eval( "def global_func_name():\n\tpass" ) > >Traceback (most recent call last): > > File "", line 1, in ? > > File "", line 1 > > def global_func_name(): > > ^ > >SyntaxError: invalid syntax > > > >any idea how I can do this? > > > > > > > >Thanks, Bruce. > > Greg Jorgensen > Deschooling Society > Portland, Oregon, USA > gregj at pobox.com From TCHUR at doh.health.nsw.gov.au Tue Mar 27 03:15:29 2001 From: TCHUR at doh.health.nsw.gov.au (Tim CHURCHES) Date: Tue, 27 Mar 2001 18:15:29 +1000 Subject: Pickling functions Message-ID: How does one go about pickling and unpickling a function object? All my attempts so far result in a reference to the function object being pickled but not the function itself. For example: ################################################ def maketransform(name,code=None,path="/somewhere/"): import zlib, cPickle, new filename = path + name + "_transform.gsz" f = open(filename, 'w+') func = new.function(compile(code,'blah','exec'),{},name,(v,)) print func(1) f.write(zlib.compress(cPickle.dumps(func, 1))) f.close() maketransform("sexlabel",code="""def sexlabel(v): ldict = {1:"Male",2:"Female"} try: return ldict[v] except: return v""")######################################### and then in a separate Python session ######################################### def loadtransform(name,path="/somewhere/"): import zlib, cPickle filename = path + name + "_transform.gsz" f = open(filename, 'r+') func = cPickle.loads(zlib.decompress(f.read())) f.close() return func sexlabel = loadtransform("sexlabel")print sexlabel(1)########################################## does not work - Python reports a NameError because function sexlabel can't be found in __main__ What am I doing wrong? Is there a simpler way of doing this? Tim C From tim.one at home.com Sun Mar 11 12:35:42 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 11 Mar 2001 12:35:42 -0500 Subject: "!=" is bad form. Re: sorry....never mind In-Reply-To: <11032001.1@wanderer.local.jae.ddns.org> Message-ID: [J?rgen A. Erhard, reacting to the deprecation of <> in favor of !=] > > So when can we expect `||' and `&&' to replace `or' and `and'? > Shouldn't we `Beware of the slippery slope'? > The deprecation of <> occurred about a decade ago, before Python's first public release. It surprises people today only because (a) contrary to some opinion, Guido is very keen on preserving backward compatibility so never took <> away; and, (b) people generally don't read the language Reference Manual, where this has been documented all along. How slippery is this slope? Well, one other class of syntax change did tumble down the same path: the shift (<< >>) and bitwise logical (& | ^ ~) operators were added after <> was deprecated. wondering-whether-micro-changes-per-decade-is-a-useful-measure-of- slipperiness-ly y'rs - tim From runyaga at thisbox.com Thu Mar 29 23:57:37 2001 From: runyaga at thisbox.com (alan runyan) Date: Fri, 30 Mar 2001 04:57:37 GMT Subject: dtml-with and dtml-sqltest References: <9a0b2s$16to$1@node17.cwnet.frontiernet.net> Message-ID: <5nUw6.8000$wx.1368177@typhoon.austin.rr.com> Lee, the zope mailing list is more appropriate for ZOPE inquiries. there is a larger community focused solely on that domain. please direct email to zope at zope.org. I dont really know what sqltest does, I have never used it. you can try this: sqlMethod - arguement - aaa=1 SELECT * FROM table WHERE id= dtmlMethod: the dtmlMethod should probably be in a PythonMethod that looks like: aaalist=[1,2,3] stuff = [] for aaa in aaalist: for sql in container.getPhById({'aaa': aaa}): # _TRICKY_ ZSQLMethods *DO NOT* use DTML namespace stuff.append(sql[0]) # position in sql row returned return stuff Lessons learned: PythonMethods are cleaner (on a whole), ZSQL doesnt get a DTML namespace, Dieter Maurer has most of the answers on the ZOPE mailing list, just search through it @ egroups. ~runyaga From shaleh at valinux.com Fri Mar 2 11:54:06 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Fri, 02 Mar 2001 08:54:06 -0800 (PST) Subject: gah! I hate the new string syntax In-Reply-To: <97ohh2$polt0$1@ID-77331.news.dfncis.de> Message-ID: > 3. I *like* string methods, even .join(). I am aware that this puts me in a > very small minority on comp.lang.python. But I would maintain that > ";".join(...) only seems odd to you because you see it as the result of a > strained migration from string.join(..., ";"), instead of seeing it with > fresh eyes. However, I may add a footnote explaining the old style > string.join, if only because new programmers will eventually come across old > code that uses it. > if I were learning python today, I would still hate code like the above. Turning a string literal (";") suddenly into a string object and then using its methods is not an easy read. While trying to scan that line, my eye wants to read the list comprehension (which is a nice feature, if compact). Then I see the join function and it takes a moment to realize it belongs to the semicolon. The other problem I have with this is I know too many languages. I am forced to deal with quite a bit of perl and I actually read your book immediately after a week's worth of working on some really evil perl code that was dumped in my lap. SO what do I see? ";" . join() # in perl, this means concat ";" with the result of join() Yes, I know this is an issue you learn to deal with. However, the nice, pretty string module at least makes python look like python. Mark, I like a lot of what I read in your book. The apihelper is a nifty idea (if only it worked on the re module )-:). However, the coding style and decisions seem counter to the python way. But maybe that is just me and my hyper sensitivity to hard to read code after way too many lines of perl. From gahanr at gofree.indigo.ie Tue Mar 6 15:25:23 2001 From: gahanr at gofree.indigo.ie (Robert Gahan) Date: Tue, 6 Mar 2001 20:25:23 -0000 Subject: Remote script execution with Python ... Message-ID: <7Ybp6.7729$r4.7336@news.indigo.ie> Hi there, I have installed python on a Windows PC and I am looking to remotely execute a script on a UNIX box from a python program. I need to be able to pipe a "y" to stdin also. Is there a windows equivalent of the unix "rexec" that could help me ?. What is the most appropriate way of doing this ?. Thanks again, Rob. From fuess at att.net Mon Mar 26 08:01:29 2001 From: fuess at att.net (David Fuess) Date: Mon, 26 Mar 2001 13:01:29 GMT Subject: Help how do I read `word' variables from a binary file? References: <3abf3b0b.1487830@news.is.co.za> Message-ID: Read the data in recordsize groups like you're doing now, then use struct.py do decompose the records into Python variables. Dave On Mon, 26 Mar 2001 12:57:31 GMT, nomad***@***freemail.absa.co.za (nomad) wrote: >Howzit, > >I'm having trouble with reading a binary file properly in Python 2.0 >on win32. I'm stating explicitly that I'm using Win32 as I know that >you have to state when opening the file that it is for `br' as in >binary reading (I'm think this is due to intels little-endian >approach, but I could be wrong). > >I can open the file without problems, and I can read from the file >without a hitch, _BUT_ the trouble comes in that some of the data >records in the file have fields that would be a double word or even a >normal word in C++, so in effect the data may be 0x80002310, but >python reads the data directly from the file, and as such is reading >hex bytes as (in this example) `10 23 00 80' etc. I'm sure that there >must be a simple way to read in data like this, but I can't figure it >out. > >Any help would be greatfully recieved. > >TIA. From chris.arndt at gmx.net Wed Mar 7 12:14:43 2001 From: chris.arndt at gmx.net (Christopher Arndt) Date: Wed, 07 Mar 2001 18:14:43 +0100 Subject: Easy way to get the X selection (as text)? Message-ID: <3AA66C83.29412EE0@gmx.net> I skimmed the docs of most X GUI modules for python on how to retrieve the X selection, but this seems to be a non-trivial task. Is there an easy way to do this, without having to use tkinter (don't want a useless window) or is there a ready-to-use module for this? I want to write a little utility for openening urls I have selected in some window. Thanx in advance. Please email me. I'm no list member, nor do I read the news regulary Cheers, Chris From grante at visi.com Tue Mar 13 12:40:51 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 13 Mar 2001 17:40:51 GMT Subject: learning C References: <983975751.18833@newsmaster-04.atnet.at> <984047775.592522@newsmaster-04.atnet.at> <9896hk$ig8$1@verence.demon.co.uk> <984134612.781779@newsmaster-04.atnet.at> <3AACE22D.3A9EEB12@bt.com> Message-ID: In article , Steve Holden wrote: >> > This is nothing more difficult than in C. >> >> Sorry but it is. There's just so much less lurking under >> the hood in C. >> >But by this argument, assembly code is even better! Yes, but not much. C is little more than a portable assembly language. If we're talking about embedded systems, a competent programmer pretty much knows what assembly language the C compiler is going to generate for each line of code he writes. Example: for a particular processor/compiler combination he should know whether it's faster to increment a pointer through an array or to increment an index through an array. >It's always a question of selecting language features because >they are appropriate to your problem domain. If there were some way to disable C++ features, then yes, that might be feasible. -- Grant Edwards grante Yow! Thank god!!... It's at HENNY YOUNGMAN!! visi.com From jeremy at alum.mit.edu Thu Mar 1 11:37:53 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Thu, 1 Mar 2001 11:37:53 -0500 (EST) Subject: d = {}; d[0:1] = 1; d[0:1] = 2; print d[:] In-Reply-To: <4.3.1.2.20010228223714.00d29430@exchange.starmedia.net> References: <4.3.1.2.20010228223714.00d29430@exchange.starmedia.net> Message-ID: <15006.31457.377477.65547@w221.z064000254.bwi-md.dsl.cnc.net> >>>>> "RT" == Robin Thomas writes: RT> Using Python 2.0 on Win32. Am I the only person to be depressed RT> by the following behavior now that __getitem__ does the work of RT> __getslice__? You may the only person to have tried it :-). RT> Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 >>> d = {} >>> d[0:1] = 1 >>> d {slice(0, 1, None): 1} I think this should raise a TypeError (as you suggested later). >>> del d[0:1] Traceback (most recent call last): File "", line 1, in ? TypeError: object doesn't support slice deletion Jeremy From fredrik at pythonware.com Tue Mar 20 17:26:28 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 20 Mar 2001 22:26:28 GMT Subject: New PEP: The directive statement References: <998hv2$5ub$1@panix3.panix.com> Message-ID: Aahz Maruch wrote: > >except that "import" already is a declaration statement, of course. > > Depends how you define "already". There is no current released version > of Python (alphas and betas do not count as "released versions") in > which "import" is a declaration. import declares things, in all existing Python versions (hint: it's an assignment statement) the future hack overloads the meaning of a specific declaration, inspired by similar solutions in other languages. (fwiw, the original proposal was "import __nested_scopes__", and the BDFL didn't seem to find that very unpythonic, given that it's only there to allow people to do prerelease testing. pre-2.2, that is) > So you're saying that "from __future__" is only to be used for this one > issue of nested scopes? I don't think so.... well, I do -- with the possible exception of cleaning up the numerics model (also an age-old issue). Cheers /F From urner at alumni.princeton.edu Fri Mar 2 21:07:16 2001 From: urner at alumni.princeton.edu (Kirby Urner) Date: Fri, 02 Mar 2001 18:07:16 -0800 Subject: Hitting two targets: OO + group theory (pedagogy) Message-ID: ============== OREGON CURRICULUM NETWORK ===================== RE: HITTING TWO TARGETS: OO + MATH TOPIC OO + POLYHEDRA In earlier writings, I've discussed how object-oriented (OO) syntax might be melded with math notations with regard to polyhedra.[see links] A Polyhedron superclass, subclassed as Tetrahedron, Octahedron etc., would demonstrate the concepts of class hierarchy and instantiated selves, or objects. Many intro-to-OO books use already flatlander shapes (superclass: shape; subclasses: triangle, circle, square...). However the Polyhedron case is mathematically more interesting and takes better advantage of the computer's graphical display capabilities. Rotation, translation and scaling may be implemented using matrices, or we might swap in quaternions to accomplish rotation, or we might develop use some other Clifford Algebra ala Hestenes et al. OO + GROUP THEORY More recently, I've been looking to group theory as another paradigm case for hitting two targets with one stone: OO concepts and number-theoretic math concepts. Each set of concepts helps to reinforce the other, thereby bootstrapping students into a synergetic mindset which sets the stage for elaboration both in programming and in abstract mathematics. Whereas this might at first sound like a college level approach, my contention is that newcomers to programming will leap-frog those who cut their teeth in the hay day of procedural programming -- which doesn't mean the procedural approach has gone out of style, only that it's no longer relevant to consider the object-oriented as "advanced", with mastery of earlier forms a prerequisite. Functional programming methods will also make their debut earlier in a student's career. And group theory has always been accessible at a variety of levels. It makes sense to start phasing in some of these concepts early, so that later plantings of these ideas find fertile ground. PYTHON AS INTRO LANGUAGE The computer language of choice in these explorations is Python. We want a language which is interactive at the command line, like Logo, such that programmed methods may be accessed and combined on the fly, with the screen itself serving as a principal site for i/o. Whereas we'll want the option to read in text files for processing, there should be no demand on students to compile standalone executables which must either support their own GUI for interactivity, or rely on command line arguments pointing to files containing the raw data of interest. ISETL, DrScheme, APL and others share these positive features with Python and there's no stipulation here that only Python is the appropriate vehicle for these kinds of activities (given the OO focus, some of these others do not lend themselves to hitting our double-target) -- only that this author has found the Python environment highly congenial for this kind of undertaking. Let's define our sandbox to be groups of relative primes less than a particular prime modulus n. These are groups under multiplication, where a*b is defined as (a*b) mod n. In Python, the mod operator is %, such that a%b returns the remainder a (mod b). SYNTAX BASICS The primitive built-in function pow() takes a mininum of two arguments a,b such that pow(a,b) = a^b (or a**b in Python, as exponentiation is signified with a double-asterisk). The optional 3rd argument provides a modulus, such that pow(a,b,n) = (a**b) mod n. This 3-argument form of pow() is internally optimized such that the modulus is used to reduce the product as powering proceeds -- far more efficient than applying the syntax (a**b)%n, which can take indefinitely longer to complete for large numbers. Where object-oriented syntax shines in this application is when we go to define multiplication. We're able to override the meaning of * (multiplication operator) in such a way that operator.mul will likewise behave consistently, i.e. will respect the definition we provide for multiplication. This is done be defining __mul__ in the class definition. Similar overriding is done with respect to ** and pow(), by defining __pow__, and for relational operators <, >, and ==, by defining __lt__, __gt__, and __eq__ respectively. I won't go into a full-blown dissection of source code here, but rather will conclude with an interactive command line session which gives the flavor of the final result. In class, or over the web (if a distance learning opportunity), students would be boning up on Python and some of the basics of group theory via supplementary materials. Some of the preliminary prototypical writing is available in draft form on math-learn, an egroup focussed on K-12 math education, with emphasis on the middle school years. [see links below] Further forays into group theory + Python may be found in the 'For further reading' section of my intro page on cryptography. COMMAND LINE INTERFACE (CLI) Here's from the Python command line: >>> from groups import * >>> residues17 = factory(17) # make objects using coprimes of 17 >>> residues17 # display as list of integers [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] >>> table(residues17) # generate a multiplication table 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ---------------------------------------------------- 1| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2| 2 4 6 8 10 12 14 16 1 3 5 7 9 11 13 15 3| 3 6 9 12 15 1 4 7 10 13 16 2 5 8 11 14 4| 4 8 12 16 3 7 11 15 2 6 10 14 1 5 9 13 5| 5 10 15 3 8 13 1 6 11 16 4 9 14 2 7 12 6| 6 12 1 7 13 2 8 14 3 9 15 4 10 16 5 11 7| 7 14 4 11 1 8 15 5 12 2 9 16 6 13 3 10 8| 8 16 7 15 6 14 5 13 4 12 3 11 2 10 1 9 9| 9 1 10 2 11 3 12 4 13 5 14 6 15 7 16 8 10| 10 3 13 6 16 9 2 12 5 15 8 1 11 4 14 7 11| 11 5 16 10 4 15 9 3 14 8 2 13 7 1 12 6 12| 12 7 2 14 9 4 16 11 6 1 13 8 3 15 10 5 13| 13 9 5 1 14 10 6 2 15 11 7 3 16 12 8 4 14| 14 11 8 5 2 16 13 10 7 4 1 15 12 9 6 3 15| 15 13 11 9 7 5 3 1 16 14 12 10 8 6 4 2 16| 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 >>> a = residues17[7] # select a = specific object >>> a 8 >>> a.inv() # compute a's inverse 15 >>> a*a.inv() # a * a^-1 = 1 1 >>> powers(residues17) # compute g to successive powers 1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] 2 = [1, 2, 4, 8, 16, 15, 13, 9, 1, 2, 4, 8, 16, 15, 13, 9] 3 = [1, 3, 9, 10, 13, 5, 15, 11, 16, 14, 8, 7, 4, 12, 2, 6] 4 = [1, 4, 16, 13, 1, 4, 16, 13, 1, 4, 16, 13, 1, 4, 16, 13] 5 = [1, 5, 8, 6, 13, 14, 2, 10, 16, 12, 9, 11, 4, 3, 15, 7] 6 = [1, 6, 2, 12, 4, 7, 8, 14, 16, 11, 15, 5, 13, 10, 9, 3] 7 = [1, 7, 15, 3, 4, 11, 9, 12, 16, 10, 2, 14, 13, 6, 8, 5] 8 = [1, 8, 13, 2, 16, 9, 4, 15, 1, 8, 13, 2, 16, 9, 4, 15] 9 = [1, 9, 13, 15, 16, 8, 4, 2, 1, 9, 13, 15, 16, 8, 4, 2] 10 = [1, 10, 15, 14, 4, 6, 9, 5, 16, 7, 2, 3, 13, 11, 8, 12] 11 = [1, 11, 2, 5, 4, 10, 8, 3, 16, 6, 15, 12, 13, 7, 9, 14] 12 = [1, 12, 8, 11, 13, 3, 2, 7, 16, 5, 9, 6, 4, 14, 15, 10] 13 = [1, 13, 16, 4, 1, 13, 16, 4, 1, 13, 16, 4, 1, 13, 16, 4] 14 = [1, 14, 9, 7, 13, 12, 15, 6, 16, 3, 8, 10, 4, 5, 2, 11] 15 = [1, 15, 4, 9, 16, 2, 13, 8, 1, 15, 4, 9, 16, 2, 13, 8] 16 = [1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16] >>> b = residues17[12] # pick a g the period < totient >>> b 13 >>> sg = subgroup(b) # generate the subgroup using b >>> sg [1, 13, 16, 4] >>> table(sg) # generate the multiplication table 1 4 13 16 ---------------- 1| 1 4 13 16 4| 4 16 1 13 13| 13 1 16 4 16| 16 13 4 1 The source code I'm using is here: http://www.inetarena.com/~pdx4d/ocn/python/groups_draft1.html Links: OO + Polyhedron: http://www.inetarena.com/~pdx4d/ocn/oop.html also: http://www.inetarena.com/~pdx4d/ocn/trends2000.html See bottom of http://www.inetarena.com/~pdx4d/ocn/overcome.html for links to the math-learn postings (these were rough drafts -- a better version for the web is in the works) Also see: http://www.inetarena.com/~pdx4d/ocn/clubhouse.html ============== OREGON CURRICULUM NETWORK ===================== By Kirby Urner, 4D Solutions, Portland, Oregon, USA From sholden at holdenweb.com Tue Mar 13 02:48:30 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 13 Mar 2001 02:48:30 -0500 Subject: Python In A Nutshell - Numpy essential References: <3AAE7E0D@MailAndNews.com> <3AACE20C.AC8D2EA2@northwestern.edu> Message-ID: "Louis Luangkesorn" wrote in message news:3AACE20C.AC8D2EA2 at northwestern.edu... > I have to second that Numeric Python belongs in the ESSENTIAL column. For me, > the fact that Python can replace Matlab was the reason I started using Python. > And when my university discontinued its campus-wide license, and every > installation of Matlab must be paid for, that it is an open-source replacement > for Matlab makes it uniquely valuable (Octave was too slow). > Well, just for balance, I still haven't downloaded NumPy, and don't ever expect to. one-man's-essential-is-another-man's-redundant-ly y'rs - steve From gregj at pobox.com Thu Mar 8 02:02:53 2001 From: gregj at pobox.com (Gregory Jorgensen) Date: Thu, 08 Mar 2001 07:02:53 GMT Subject: grabbing return codes from os.system() call References: <%wFp6.9481$dL4.126404@vixen.cso.uiuc.edu> Message-ID: os.system returns the exit status. The low-order byte of the exit status is the signal number that killed the process, and the high-order byte is the exit status (if the signal number is 0). This only works under Unix; on Windows the exit status is always 0. 768 = 0x0300 -- there's your 3 return value. This is documented in the Python Library Docs, at: http://www.python.org/doc/current/lib/os-process.html You can separate the bytes in many ways. One simple technique: x = os.system('./returncode') signal = x & 0xFF exitcode = (x >> 8) & 0xFF In article <%wFp6.9481$dL4.126404 at vixen.cso.uiuc.edu>, Damian Menscher says... > >I'm new to Python (as in, my experience is essentially the tutorial), >but I've already come up with an interesting question: > >How do I get the return code from an os.system call? I would have >expected I could do something like > >---returncode--- >#/bin/csh >echo do stuff >exit 3 > >and then in my python program I could do > >print os.system('./returncode') Greg Jorgensen Deschooling Society Portland, Oregon, USA gregj at pobox.com From jafo at tummy.com Thu Mar 15 01:29:46 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Wed, 14 Mar 2001 23:29:46 -0700 Subject: RPM Module? In-Reply-To: <3aab687b$1@news.teuto.net>; from ocaner@gmx.de on Sun, Mar 11, 2001 at 12:55:45PM +0100 References: <3aab687b$1@news.teuto.net> Message-ID: <20010314232946.N30951@tummy.com> On Sun, Mar 11, 2001 at 12:55:45PM +0100, ?zg?r Caner wrote: >Does anybody know where to find a Documentation about the RPM Module >for Python? Unfortunately, I've mostly figured out what I use it for by just groping around in the module. Looking at the symbolx in the module, etc... I seem to recall Donnie Barnes replying to somone on usenet at one point about a program that used most of the functionality of it, but I can't seem to find a reference to it. I may be thinking of the "snack" module instead though... Sean -- If I were an Indian, my name would be "Running With No Swap". -- Sean Reifschneider, 1999 Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From phd at phd.pp.ru Mon Mar 26 03:31:27 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Mon, 26 Mar 2001 12:31:27 +0400 (MSD) Subject: Python ready to replace perl In-Reply-To: <86snk1qafw.fsf_-_@jfh00.fernuni-hagen.de> Message-ID: On 26 Mar 2001, Fritz Heinrichmeyer wrote: > So i consider using python in the future. For this python has to have > > 1. sql-interface like dbi, at least for postgres (i think this exists). Exists. There are few different implementations. There is PyGreSQL, PoPy, psycopg. > 2. interface to openldap Exists. > 3. mod_perl beeing able to program authentification procedures using > 1. and 2. for apache and beeing able to program arbitrary URL-redirect > procedures. mod_python or mod_snake, perhaps. > 4. a template system beeing able to manage multiple language versions > (to replace the perlish WML-System)?. DTML can be used outside of Zope. I use it in pure Python CGIs pretty happily. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From aleaxit at yahoo.com Sun Mar 11 03:08:41 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 11 Mar 2001 09:08:41 +0100 Subject: gah! I hate the new string syntax References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97soak$qh9$1@nntp.Stanford.EDU> <97sudi01i26@news1.newsguy.com> <98elrk$li8$1@nntp.Stanford.EDU> Message-ID: <98fc070thh@news1.newsguy.com> "Amit Patel" wrote in message news:98elrk$li8$1 at nntp.Stanford.EDU... [snip] > What I mean to say is that I cannot write new methods on strings. So Perfectly true, just as you cannot on dictionaries, lists, tuples, file objects, and so on. Only classes and extension-classes are extensible (by inheritance and overriding), not types. > has control over the string class. Since I don't control the string > class, I have to use a different syntax than someone who does have > control over the string class gets to use. That seems okay if the > function is some essential part of that class. But it seems "wrong" > if the function is there merely for convenience. string is not a class -- it's a type. To many, the split seems wrong _all_ of the time. I may be one of the few that sees some pluses in the distinction (!), but it does complicate things, and is a strong candidate for "aspect of Python fewest Pythonistas _like_":-). Alex From a2619725 at uni-koeln.de Sun Mar 18 12:17:04 2001 From: a2619725 at uni-koeln.de (Oliver Hofmann) Date: 18 Mar 2001 17:17:04 GMT Subject: Efficiency of UserString Message-ID: <992qig$96$1@news.rrz.Uni-Koeln.DE> This buffer is for notes you don't want to save, and for Lisp evaluation. If you want to create a file, visit that file with C-x C-f, then enter the text in that file's own buffer. 'lo everyone! Got a question regarding UserString's efficiency. I am parsing text and would like to store a word's position (sentence, absolute position) somewhere; this would allow turning the document into a list of words, then removing stopwords or stemming the word and still having the information about it's original position in the document. Figured instead of creating several lists to store and update that info I could put it into the string itself by using UserString; however the Python library reference states: "It should be noted that these classes are highly inefficient compared to real string or Unicode objects; this is especially the case for MutableString." I've tried two basic operations below but couldn't spot much of a difference. Could someone please point me at an error I've made or tell me which operations are slower with UserString? ---- import UserString import profile, pstats text = """ The compound ppp(A2p)3A3[32P]pCp is a commercially available radioactive analogue of the 2,5 oligoadenylate series ppp(A2p)nA, n greater than or equal to 2, commonly referred to as 2-5A. It is used as a probe for measuring concentrations in competition radiobinding and radioimmune assays. We have found that incubation of the probe with extracts from HeLa, CV1, or neuroblastoma cells results in its covalent attachment to two size classes of RNA: the first includes a major species with a molecular weight of approximately 350,000, the second is much smaller (40 +/- 5 nucleotides in length) and could represent tRNA half-molecules. Ligation is to the 3 end of the probe molecule with formation of a 3,5-phosphodiester bond. Thus, probe ligation provides a sensitive and convenient assay for the detection not only of RNA ligase(s) but also of ligatable RNAs (such as the putative tRNA half-molecules) in mammalian cell extracts. """ text = ' '.join(text.split()) text2 = UserString.UserString(text) def fun1(): global text for a in range(0, 1000): text = ' '.join(text.split()) def fun2(): global text for a in range(0, 1000): text.find('neuro') def fun3(): global text2 for a in range(0, 1000): text2 = ' '.join(text2.split()) def fun4(): global text2 for a in range(0, 1000): text2.find('neuro') def main(): for a in range(0, 100): fun1() fun2() fun3() fun4() profile.run('main()', 'profile.tmp') p = pstats.Stats('profile.tmp') p.sort_stats('cumulative').print_stats(10) ---- Here are the stats: 404 function calls in 80.010 CPU seconds Ordered by: cumulative time ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 80.010 80.010 :1(?) 1 0.000 0.000 80.010 80.010 profile:0(main()) 1 0.000 0.000 80.010 80.010 test3.py:48(main) 100 39.050 0.390 39.050 0.390 test3.py:24(fun1) 100 39.040 0.390 39.040 0.390 test3.py:36(fun3) 100 0.960 0.010 0.960 0.010 test3.py:42(fun4) 100 0.960 0.010 0.960 0.010 test3.py:30(fun2) Many thanks once again! Oliver -- Oliver Hofmann - University of Cologne - Department of Biochemistry o.hofmann at smail.uni-koeln.de - setar at gmx.de - connla at thewell.com If you care, you just get disappointed all the time. If you don't care nothing matters so you are never upset. -- Calvin From phrxy at csv.warwick.ac.uk Thu Mar 29 13:01:44 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Thu, 29 Mar 2001 19:01:44 +0100 Subject: Gaussian line profile using numeric python In-Reply-To: References: <3ac31698@zfree.co.nz> Message-ID: On 29 Mar 2001, Konrad Hinsen wrote: > "Geoff Low" writes: > > > I have an extensive set of xy data that I want to convolute with a gaussian > > profile. Below is my algorithm, which doesn't work. Can anyone see where > > I'm being dumb? What goes wrong? Couldn't see your original message. > To be honest, I am too lazy to look through this. However, Me too. :) I do have some working routines that will do gaussian convolution, using the standard Numeric FFT module -- very simple. Or at least would be if I didn't have a lot of stuff for using the FFTW library in there, which doesn't actually work (the docs for the rfftw part of the FFTW python wrapper seem to be wrong: anybody got this working?). > 1) The function Numeric.convolve is certainly a lot more efficient > than your code, and should make it simpler. I seem to recall that it doesn't cover all the possibilities, though. I don't remember exactly why, but since I wrote my own functions to do this there must have been a reason! > 2) If you work with large data sets, you ought to use FFTs to > compute the convolution, that's O(N*log(N)) in the size of the > data set, instead of O(N**2) for the straightforward method. > Any good book on FFTs should explain how this works in detail. but you probably don't need to know in detail, it boils down to inv_FFT(FFT(data)*FFT(kernel)) But if you have small data sets it might be slower, of course. > > P.S. I'm no math wizard but this is my interpretation of the gaussian lineshape > > function > > G(v) = 1/(sqrt(2*PI)*FWHM)*exp(-(v-vo)^2/(2*FWHM^2)) > > Assuming that FWHM stands for full width at half minimum, no, it's not > correct. What you call FWHM is the variance sigma of the Gaussian, the > FWHM is around 2.35*sigma (quick calculation, no guarantee). That number is about right, from memory. John From stephen_purcell at yahoo.com Wed Mar 28 04:47:44 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Wed, 28 Mar 2001 11:47:44 +0200 Subject: Help with regular expression backreferences In-Reply-To: <3AC16D0F.6E33377E@nospammytheworld.com>; from deblNO@nospammytheworld.com on Wed, Mar 28, 2001 at 04:48:08AM +0000 References: <3AC16D0F.6E33377E@nospammytheworld.com> Message-ID: <20010328114744.F8325@freedom.puma-ag.com> David Lees wrote: > I would like to use regular expression back references as keys into a > dictionary when doing substitution. So far all I have is: > > s='This xxMYJunkkxx the string that xxYourJunkxx the thing' > p=re.compile(r'xx(\w+)xx') > new_s=re.sub(p,'junk',s) > print new_s Don't use 're.sub' -- use the 'sub' method of your compiled regex 'p': >>> import re >>> s='This xxMYJunkkxx the string that xxYourJunkxx the thing' >>> p=re.compile(r'xx(\w+)xx') >>> new_s = p.sub(r'\1', s) >>> new_s 'This MYJunkk the string that YourJunk the thing' -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From gmunsey at adobe.com Sat Mar 24 14:08:44 2001 From: gmunsey at adobe.com (Grant Munsey) Date: Sat, 24 Mar 2001 11:08:44 -0800 Subject: [Ann] Python module for Perforce Source Code Management System API/Windows Message-ID: <0h6v6.24$Vu1.40771@news.pacbell.net> I have coded up a C level module that lets Python 2.0 callers access the Perfoce SCM API interface. http://opensource.adobe.com/project6/project.shtml One thing to note ... while Perforce costs $$ per seat you can run a server for two users for free. You can also run a Perforce server for free if you are maintaining an open source site. From gradha at iname.com Sat Mar 10 17:36:41 2001 From: gradha at iname.com (gradha at iname.com) Date: Sat, 10 Mar 2001 23:36:41 +0100 Subject: Problems writting a wrapper around linux' ssh command References: <31rd89.lki.ln@127.0.0.1> Message-ID: Gregory Jorgensen wrote: > ssh explicitly opens /dev/tty to read the password, so it's not looking on stdin > (see the readpass.c file in your ssh sources). In a normal terminal session > stdin is mapped to /dev/tty, but a child process started with popen2 will have > stdin mapped to the Popen3.tochild file descriptor. Can you use one of the other > secure authentication methods ssh supports? Er... I am new to ssh, so I don't even know what other methods there are... So far, I want to write a wrapper on top of sitecopy (a program which allows updating remote web sites through ftp) using ssh and scp to upload files and make directory modifications. If there's any other way of doing this, any help is very welcome. The only restriction is that the program I write from commandline or in background, accepts password only once, and logs everything to files, so I thought wrapping around ssh and scp would be the easiest way. -- Grzegorz Adam Hankiewicz gradha at iname.com - http://gradha.infierno.org Other web pages: http://glub.ehu.es/ - http://welcome.to/gogosoftware/ From hgg9140 at cola.ca.boeing.com Wed Mar 14 13:53:47 2001 From: hgg9140 at cola.ca.boeing.com (Harry George) Date: Wed, 14 Mar 2001 18:53:47 GMT Subject: Who am I: can a class instance determine its own name? References: <98o8fu$2s4dj$1@ID-11957.news.dfncis.de> Message-ID: I'd like to know too. I never actually use that kind of code, but it would be handy. "Emile van Sebille" writes: > Has locals changed so that it may be written to reliably? My documentation > still warns: > > locals () > Return a dictionary representing the current local symbol table. Warning: > The contents of this dictionary should not be modified; changes may not > affect the values of local variables used by the interpreter. > > Emile van Sebille > emile at fenx.com > > > > "Harry George" wrote in message > news:xqxzoeol3ju.fsf at cola.ca.boeing.com... > > class MyName: > > #-------------------------- > > def init(self,name): > > self.name=name > > try: > > raise None > > except: > > c=sys.exc_info()[2].tb_frame.f_back.f_back > > c.f_locals[name]=self > > ... > > > > MyName("me") > > print me.name > > > > "Kevin Cazabon" writes: > > > > > The reason I say it's not elegant is that there is the possibility (read > > > "probability") that the assigned name and the actual name can differ. > > > > > > We're assuming that the programmer assigns exactly the same name to > both, > > > which doesn't seem like a hard task, but it introduces the possibility > of > > > problems, and probably hard ones to debug too. > > > > > > If there were an automatic method, it would be MUCH more reliable. > > > > > > Just MHO. > > > > > > Kevin. > > > > > > > > > > > > "Paul Prescod" wrote in message > > > news:mailman.984324974.25480.python-list at python.org... > > > | Kevin Cazabon wrote: > > > | > > > > | > ... > > > | > You could also > > > | > make it an initialization parameter. > > > | > > > > | > FooBar = Foo(name="FooBar") > > > | > > > > | > Just trying to help... not elegantly though. > > > | > > > | I disagree Kevin. This is not only the canonical way to give an > instance > > > | a name, it is also the elegant way. It gives you a lot more > flexibility > > > | because the name it has at runtime is unrelated to the variable name > you > > > | happened to have given it in your code. If you need to change one or > the > > > | other for any reason, you can do so safely. > > > | > > > | Paul Prescod > > > | > > > > > > > > > > -- > > Harry George E-mail: harry.g.george at boeing.com > > The Boeing Company Renton: (425) 237-6915 > > P. O. Box 3707 02-CA Everett: (425) 266-3868 > > Seattle, WA 98124-2207 Page: (425) 631-8803 > > -- Harry George E-mail: harry.g.george at boeing.com The Boeing Company Renton: (425) 237-6915 P. O. Box 3707 02-CA Everett: (425) 266-3868 Seattle, WA 98124-2207 Page: (425) 631-8803 From aahz at panix.com Sat Mar 3 16:55:28 2001 From: aahz at panix.com (Aahz Maruch) Date: 3 Mar 2001 13:55:28 -0800 Subject: Bug fix releases References: <200103031821.NAA24060@panix3.panix.com> Message-ID: <97rp8g$4th$1@panix3.panix.com> In article , Guido van Rossum wrote: >Aahz writes: >> >> I think so, yes, on that latter clause. I think perhaps it wasn't clear >> at the time, but I believe that much of the yelling over "print >>" was >> less over the specific design but because it came so close to the >> release of 2.0 that there wasn't *time* to sit down and talk things >> over rationally. > >In my eyes the issues are somewhat different: "print >>" couldn't >possibly break existing code; nested scopes clearly do, and that's why >we decided to use the __future__ statement. > >But I understand that you're saying that the community has grown so >conservative that it can't stand new features even if they *are* fully >backwards compatible. Then you understand incorrectly. There's a reason why I emphasized "*time*" up above. It takes time to grok a new feature, time to think about whether and how we should argue in favor or against it, time to write comprehensible and useful arguments. In hindsight, I think you probably did make the right design decision on "print >>", no matter how ugly I think it looks. But I still think you made absolutely the wrong decision to include it in 2.0. >So that relegates us at PythonLabs to a number of things: coding new >modules (boring), or trying to improve performance of the virtual >machine (equally boring, and difficult to boot), or fixing bugs (did I >mention boring? :-). > >So what can we do for fun? (Besides redesigning Zope, which is lots >of fun, but runs into the same issues.) Write new versions of Python. You've come up with a specific protocol in a later post that I think I approve of; I was trying to suggest a balance between lots of grunt work maintenance and what I see as perpetual language instability in the absence of any bug fix releases. >Your math at first confused the hell out of me, but I see what you >mean. You want us to spend time on 2.0.1 which should be a bugfix >release for 2.0, while at the same time working on 2.1 which is a new >feature release. Yup. The idea is that because it's always an N and N-1 pair, the base code is the same for both and applying patches to both should be (relatively speaking) a small amount of extra work. Most of the work lies in deciding *which* patches should go into N-1. >Guess what -- I am secretly (together with the PSU) planning a 2.0.1 >release. I'm waiting however for obtaining the ownership rights to >the 2.0 release, so we can fix the GPL incompatibility issue in the >license at the same time. (See the 1.6.1 release.) I promise that >2.0.1, unlike 1.6.1, will contain more than a token set of real >bugfixes. Hey, we already have a branch in the CVS tree for 2.0.1 >development! (Tagged "release20-maint".) Yay! (Sorry, I'm not much of a CVS person; the one time I tried using it, I couldn't even figure out where to download the software. Call me stupid.) >We could use some checkins on that branch though. Fair enough. >> This means that each feature-based release gets one-and-only-one pure >> bugfix release. I think this will do much to promote the idea of Python >> as a stable platform for application development. > >Anything we can do to please those republicans! :-) >> There are a number of ways I can see this working, including setting up >> a separate project at SourceForge (e.g. pythonpatch.sourceforge.net). >> But I don't think this will work at all unless the PythonLabs team is at >> least willing to "bless" the bugfix release. Uncle Timmy has been known >> to make snarky comments about forever maintaining 1.5.2; I think this is >> a usable compromise that will take relatively little effort to keep >> going once it's set up. > >With the CVS branch it's *trivial* to keep it going. We should have >learned from the Tcl folks, they've had 8.NpM releases for a while. I'm suggesting having one official PythonLabs-created bug fix release as being a small incremental effort over the work in the feature release. But if you want it to be an entirely community-driven effort, I can't argue with that. My one central point is that I think this will fail if PythonLabs doesn't agree to formally certify each release. >> I think one key advantage of this approach is that a lot more people >> will be willing to try out a beta of a strict bugfix release, so the >> release N bugfixes will get more testing than they otherwise would. > >Wait a minute! Now you're making it too complicated. Betas of bugfix >releases? That seems to defeat the purpose. What kind of >beta-testing does a pure bugfix release need? Presumably each >individual bugfix applied has already been tested before it is checked >in! "The difference between theory and practice is that in theory, there is no difference, but in practice, there is." I've seen too many cases where a bugfix introduced new bugs somewhere else. Even if "tested", there might be a border case where an unexpected result shows up. Finally, there's the issue of system testing, making sure the entire package of bugfixes works correctly. The main reason I suggested two betas was to "lockstep" the bugfix release to the next version's feature release. >Or are you thinking of adding small new features to a "bugfix" >release? That ought to be a no-no according to your own philosophy! That's correct. One problem, though, is that sometimes it's a little difficult to agree on whether a particular piece of code is a feature or a bugfix. For example, the recent work to resolve case-sensitive imports could be argued either way -- and if we want Python 2.0 to run on OS X, we'd better decide that it's a bugfix. ;-) >> If there's interest in this idea, I'll write it up as a formal PEP. > >Please do. Okay, I'll do it after the conference. I've e-mailed Barry to ask for a PEP number. -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Nostalgia just ain't what it used to be From juergen.erhard at gmx.net Mon Mar 26 10:53:27 2001 From: juergen.erhard at gmx.net (=?ISO-8859-1?Q?=22J=FCrgen_A=2E_Erhard=22?=) Date: Mon, 26 Mar 2001 17:53:27 +0200 Subject: PEP 240 scares me In-Reply-To: (message from Pearu Peterson on Fri, 23 Mar 2001 07:48:14 +0200) References: <99e2h61aao@news2.newsguy.com> Message-ID: <26032001.4@wanderer.local.jae.ddns.org> >>>>> "Pearu" == Pearu Peterson writes: Hi Pearu, Pearu> Thanks for your replies. I now got it right what's in PEP 240. I was drafting a message very similar to yours... that \d+\.\d+ confused me too. Fortunately I read python-dev before posting it... and it slowly (*sloooowly* ;-) dawned on me that what was really intended was not 1.4 == 1/4. Which would have been royally stupid indeed. So, I can feel with you (I made damn sure I pressed *delete* on that draft and not *send* accidentially! ;-) Bye, J PS: I'm feeding python-dev daily from the pipermail archive... I'm not posting this code anywhere as a) it's not really that impressive and b) anyone who wants it can ask me... TPTB might possibly frown upon such a thwarting of the marvellous "no-one can read the list directly, but anyone can post" ;-P -- J?rgen A. Erhard juergen.erhard at gmx.net phone: (GERMANY) 0721 27326 MARS: http://members.tripod.com/Juergen_Erhard/mars_index.html Advent, Advent, der Faschist brennt. Erst das ?rmchen, nun das Beinchen, bald das ganze Nazischweinchen. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: From drtimcouper at yahoo.co.uk Thu Mar 29 03:11:08 2001 From: drtimcouper at yahoo.co.uk (=?iso-8859-1?q?Tim=20Couper?=) Date: Thu, 29 Mar 2001 09:11:08 +0100 (BST) Subject: OO Windows Registry API In-Reply-To: Message-ID: <20010329081108.12569.qmail@web6405.mail.yahoo.com> Benji I would prefer this style of registry access. Comments: 1. reg[HKEY_LOCAL_MACHINE]['Software']['My App'] I'd prefer to see: reg[HKEY_LOCAL_MACHINE]['Software\My App'] or, perhaps, more Pythonesquely reg[HKEY_LOCAL_MACHINE]['Software','My App'] 2. What about a AddKey-type of method: CurrentKey=reg[HKEY_LOCAL_MACHINE] .... CurrentKey.AddKey('foo') > > After using the _winreg module I was pining for the > fjords -- oh, sorry -- I was pining for a more > Pythonesc API. I noticed that the Python > documentation mentions that a better API may be > written in the future, but none has been > forthcoming. So -- while up at 2AM with my > 6-week-old son last night -- I wrote a wrapper that > exposes the registry as a dictionary-like object. > It seems to work really well, and more importantly > it feels more like a Python module should. > > I decided to search Python-Dev for mentions of a > higher-level API and found a squabble over various > proposals. Did the idea of an OO interface die last > August, or is there any interest in what I've done? > > (Untested) Example code: > > from winreg import Registry, NewKey, > HKEY_CURRENT_USER > reg = Registry() > > # Create a new "My App" key under > HKEY_CURRENT_USER/Software. > reg[HKEY_CURRENT_USER]['Software']['My App'] = > NewKey() > > # Add some values to the newly created key. > # Note: the module only supports strings right now, > but that's > # easy to change. > reg[HKEY_CURRENT_USER]['Software']['My App']['foo'] > = 'value 1' > reg[HKEY_CURRENT_USER]['Software']['My App']['bar'] > = 'value 2' > > # Create a new subkey. > reg[HKEY_CURRENT_USER]['Software']['My > App']['subkey'] = NewKey() > > # Delete a value. > del reg[HKEY_CURRENT_USER]['Software']['My > App']['foo'] > > # Delete a key. > del reg[HKEY_CURRENT_USER]['Software']['My App'] > > > Any comments or suggestions? If anyone is > interested in the code, I'll post it on the web. > > -- > Benji York > york at ficom.net ____________________________________________________________ Do You Yahoo!? Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk or your free @yahoo.ie address at http://mail.yahoo.ie From hgg9140 at cola.ca.boeing.com Fri Mar 9 13:59:20 2001 From: hgg9140 at cola.ca.boeing.com (Harry George) Date: Fri, 9 Mar 2001 18:59:20 GMT Subject: Divorcing Command Line and GUI References: Message-ID: A couple of options: 1. The Model-View-Controller pattern, where the model is your underlying application engine and you have two views: commandline and gui. You will probably need as abstract "user interface" class which defines the available callbacks, and then subclass the comline and gui off that. In the abstract case, you need ways to let the engine get the data it wants (modal dialogs), and for the ui to trigger actions in the engine (modeless actions). 2. Keep the comline app as is. Run it from the gui (e.g., via pipes). Timothy Grant writes: > Hello Everyone. > > This is something of a strange question, but please bear with > me. > > I have a series of tools that I have created that work from the > command line. I have now been tasked with creating GUIs for > those tools. The problem I'm faced with is that the command > line tools and the GUI tools will probably be licensed > differently (e.g, command line will be Open Source, GUI will be > something undetermined as of yet.) This means that I can't put > my GUI code in with my CL code. > > My first cut at this demarcation sort of worked, but was also > troublesome. So while I have some new ideas, I'm looking to see > if anyone else in the python community has ever had to do > something like this, and if there are any easily maintainable > solutions to this problem. > > > > -- > Stand Fast, > tjg. > > Timothy Grant tjg at exceptionalminds.com > Red Hat Certified Engineer www.exceptionalminds.com > Avalon Technology Group, Inc. <>< (503) 246-3630 > >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< > >>>>This machine was last rebooted: 51 days 22:09 hours ago<< > -- Harry George E-mail: harry.g.george at boeing.com The Boeing Company Renton: (425) 237-6915 P. O. Box 3707 02-CA Everett: (425) 266-3868 Seattle, WA 98124-2207 Page: (425) 631-8803 From bbollenbach at homenospam.com Tue Mar 6 11:40:31 2001 From: bbollenbach at homenospam.com (Brad Bollenbach) Date: Tue, 06 Mar 2001 16:40:31 GMT Subject: Can Python replace Visual Basic? Should it? References: <5DZo6.11126$hn5.1578410@news1.rdc1.mb.home.com> <98266k0p5h@news1.newsguy.com> Message-ID: <3q8p6.12338$hn5.1798569@news1.rdc1.mb.home.com> "Alex Martelli" wrote in message news:98266k0p5h at news1.newsguy.com... > "Brad Bollenbach" wrote in message > news:5DZo6.11126$hn5.1578410 at news1.rdc1.mb.home.com... > > Again, I'm much more interested in the real world experience of those who > > used to use the big visual development tools in Windows like VB, Delphi or > > Powerbuilder rather than theoretical answers. > > Why do you focus on 'used to use'? One may perfectly well keep using > some VB (&c) for tasks it's particularly well-suited to, while using > Python wherever feasible (and, indeed, using both in the same project Certainly. And for all intents and purposes "used to use" isn't necessary, but the question happened to be directed (as its subject suggests) at those who _have_ replaced VB with Python. :) But realistically, I just wanted to emphasize my interest in hearing answers from those who have or currently are using VB or one of the other Win32 visual development tools. Personally, I'm a former VB programmer now working in Powerbuilder and am unhappy with both, again based on my dislike of IDE's that obscure the programmer's view of what's going on. I could explain _why_ I don't like the 40,000 foot views of IDE's, but that's another thread. Brad From mwh21 at cam.ac.uk Tue Mar 6 10:24:10 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 06 Mar 2001 15:24:10 +0000 Subject: I come to praise .join, not to bury it... References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> <982a4f0su3@news1.newsguy.com> Message-ID: Erno Kuusela writes: > In article <982a4f0su3 at news1.newsguy.com>, "Alex Martelli" > writes: > > | "Erno Kuusela" wrote in message > > || what's wrong with vague aesthetic?-) if lots of people share it, > || it's not to be dismissed so lightly. > > | Lots of people share the 'vague aesthetic' of desiring > | to use braces instead of whitespace to delimit blocks > | of statements, for example. > > | Python dismisses that lightly, and that is definitely > | a part of what makes it such a wonderful language. > > it could also be argued that python uses whitespace instead > of braces because of vague aesthetic shared by lots of people. :) Some people don't have a problem with, or even quite like, ''.join, too. They tend to be quieter, though. Cheers, M. -- For their next act, they'll no doubt be buying a firewall running under NT, which makes about as much sense as building a prison out of meringue. -- -:Tanuki:- -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html From bedge at troikanetworks.com Tue Mar 20 20:04:07 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Tue, 20 Mar 2001 17:04:07 -0800 Subject: InteractiveConsole locals parameter Message-ID: <3AB7FE07.5F7584F5@troikanetworks.com> I can't get my __main__.__dict__ passed to an InteractiveConsole: def run_python(): import code import __main__ locals = __main__.__dict__ x = code.InteractiveConsole(locals) x.interact("") Shouldn't this have the same namespace as my main interpreter? If not, how can I get my main interp namespace propagated down to my InteractiveConsole? Are there any detailed docs on this? I've read all the ones I can find. Thanks, Bruce. Here's my test: Python 2.0 (#42, Mar 15 2001, 13:24:46) [GCC 2.95.3 20010219 (prerelease)] on linux2 Type "copyright", "credits" or "license" for more information. >>> from CLI import * <--run my CLI app k-> k-> python <-- command to start subshell, calls run_python, above >>> dir() <-- this is all that's defined ['__builtins__', '__doc__', '__name__', 'atexit', 'histfile', 'os', 'readline', 'rlcompleter', 'savehist', 'sys'] >>> >>> <-- exit subshell k-> <-- exit app >>> dir() <-- top level, this is what I want in my subshell: ['CommandException', 'KCompleter', 'Kcmd', 'Port', 'Zone', '__builtins__', '__doc__', '__name__', 'atexit', 'basedir', 'cNode', 'cOpt', 'cType', 'cli', 'cmd', 'cmds', 'copy', 'ctree', 'dprintf', 'dprintf_exception', 'dprintf_init', 'dprintf_level', 'histfile', 'histname', 'kcmd', 'kcompl', 'kcomplMode', 'kcompleter', 'kinterp', 'kuser', 'mType', 'main', 'modules', 'nType', 'os', 'port', 're', 'readline', 'register_new_command', 'rights', 'rlcompleter', 'savehist', 'sl', 'string', 'sys', 'tokens', 'topcmds', 'traceback', 'types', 'util'] From alf at leo.logilab.fr Fri Mar 16 04:49:37 2001 From: alf at leo.logilab.fr (Alexandre Fayolle) Date: Fri, 16 Mar 2001 09:49:37 +0000 (UTC) Subject: Basic information requested References: Message-ID: <98snjh$hsu$1@norfair.nerim.net> Jamie MacIsaac wrote: > Hi, > I've just started looking at Python and would like to use it to perform some > simple admin tasks on a Windows network. However, I'm having difficulty > finding out how to accomplish elementary tasks. > Can someone please point me to sample code that shows how to map a network > share and copy some files? Is there a central resource of code samples? You may want to purchase a copy of 'Python Programming on Win32' (O'Reilly, by Mark Hammond and Andy Robinson, ISBN 1-56592-621-8). Chapter 16 covers this point. You can download the code samples from http://starship.python.net/crew/mhammond/ppw32/ Cheers Alexandre Fayolle -- http://www.logilab.com Narval is the first software agent available as free software (GPL). LOGILAB, Paris (France). From ben.hutchings at roundpoint.com Tue Mar 20 17:24:59 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 20 Mar 2001 14:24:59 -0800 Subject: How to increase PythonWin v2.0: COM browser limits? References: <994psh$so5$1@news1.xs4all.nl> Message-ID: I wrote: > The wrapper for COM enumerators, in true Pythonic style, does not > check the size of the collection in advance, but attempts to read > items until this yields an error. I think that the category > enumerator implementation is reporting the no-more-items error in the > wrong way (returning E_OUTOFMEMORY rather than S_FALSE), so the > wrapper does not translate it into an IndexError exception which > would cause the loop to terminate successfully. OLEView probably > just doesn't check for the error but displays what it already got. Let me revise that: A Python iterator for a COM 'container' is an instance of win32com.client.util.Enumerator, which wraps a PyIEnumVARIANT object that in turn wraps an IEnumVARIANT interface pointer obtained from the container. When an IEnumVARIANT user requests more items than there are left, the implementation should return any items that are left, with a status code of S_FALSE (not an error code). In the case of iteration, Enumerator will request only 1 item each time. PyIEnumVARIANT's wrapper function returns a list of items, which at the end of iteration will have length 0. Enumerator checks for this case and throws an IndexError when it occurs, which is the normal way for iteration to end. Unfortunately it appears that this specific implementation of IEnumVARIANT returns a status code of E_OUTOFMEMORY (an error code), which PyIEnumVARIANT turns into a win32types.com_error exception. OLEView probably treats this error in the same way as a normal end of enumeration, and displays the results it already obtained. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From sholden at holdenweb.com Fri Mar 9 23:33:23 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 9 Mar 2001 23:33:23 -0500 Subject: true newbie References: <3aa9a9e9$0$65277$38c90ffe@news1.twtelecom.net> Message-ID: <8ciq6.46945$1D5.2247691@e420r-atl1.usenetserver.com> Try the Non-Programmer's Tutorial, at http://www.honors.montana.edu/~jjc/easytut/easytut/easytut.html regards Steve "Elaine Sweeny" wrote in message news:3aa9a9e9$0$65277$38c90ffe at news1.twtelecom.net... > can anyone help me find a tutorial for python thats for people just starting > out in programming. The one one that comes with it is ok but its still too > difficult. > thanks > > > From mcfletch at home.com Fri Mar 16 15:04:38 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Fri, 16 Mar 2001 15:04:38 -0500 Subject: can a class intantiate itself to None? In-Reply-To: <20010316112211.E3109@trufflehunter.avalongroup.net> Message-ID: <000001c0ae54$550f0ef0$a9807018@cr706570a> Classic approach is to use a factory function... def foo( bar ): if type(bar) == StringType: return _Foo( bar ) else: return None -----Original Message----- From: Timothy Grant [mailto:tjg at exceptionalminds.com] Sent: Friday, March 16, 2001 2:22 PM To: Python People Subject: can a class intantiate itself to None? I'd like to create a class that can instantiate itself to None when instantiation fails... class foo: def __init__(self, bar): if type(bar) == StringType: self.data = 'This is a String' x = foo('a') y = foo(1) # In this instance I would like y to be None So, can it be done, or do I need to raise an exception, catch it and then set y to None? -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Red Hat Certified Engineer www.exceptionalminds.com Avalon Technology Group, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 58 days 23:33 hours ago<< -- http://mail.python.org/mailman/listinfo/python-list From dnew at san.rr.com Fri Mar 16 13:32:56 2001 From: dnew at san.rr.com (Darren New) Date: Fri, 16 Mar 2001 18:32:56 GMT Subject: list.sort(cmpfunc) question References: <98t9dq$qvu$1@panix6.panix.com> <98tf9d$g3v$1@news.mathworks.com> <3AB249FB.131080CD@san.rr.com> <98thua$i40$1@news.mathworks.com> Message-ID: <3AB25C59.284E58E3@san.rr.com> Fredrik Lundh wrote: > in other words, "recommended but not required" Even more strongly than "recommended", but rather "you better have a darn good reason and know every result of your change before you consider doing this." :-) It's like "Unix root accounts SHOULD have a hard-to-guess password." It's possible to run UNIX with no root password, but you ought to have a good reason. And yes, there's an RFC defining what "SHOULD" and "MUST" and such mean. :-) -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. From qrczak at knm.org.pl Sat Mar 31 16:17:07 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 31 Mar 2001 21:17:07 GMT Subject: list vs tuple References: Message-ID: Sat, 31 Mar 2001 20:23:37 GMT, deadmeat pisze: > In Pascal the programmer defines what is a pointer and what is > not, and the difference is specified in the syntax. In Python does > not. The difference is based on what the name refers to, and that > difference is not specified in the syntax - which is my point. THERE IS NO DIFFERENCE. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From ewilson at nospam.jamdat.com Wed Mar 14 18:57:38 2001 From: ewilson at nospam.jamdat.com (eric wilson) Date: Wed, 14 Mar 2001 23:57:38 GMT Subject: compile / exec Message-ID: hi - i am new to python and i'm trying to use the compile / exec feature for speeding up a loop. i'm using python v2.0 with pythonwin. i don't understand why this doesn't work.... thanks in advance for the help. //eric the code snippet looks like this: exec_code = compile(""" for eachLine in map(strip, allLines): mySequence = split('\s\s+|\t', eachLine) foundFields = str(gm2local(DateTimeFromString(mySequence[0])))[:-3] + '\t' + mySequence[1]+ '\t' + mySequence[4]+ '\t' + mySequence[5]+ '\t' + mySequence[9]+ '\t' + mySequence[16] + '\n' fw.write(foundFields) count = count + 1 """, '', 'exec') exec exec_code the error message that i get when this piece of code runs is: Traceback (most recent call last): File "C:\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript exec codeObject in __main__.__dict__ File "E:\W2\pytest\logman.py", line 114, in ? checkArgs() File "E:\W2\pytest\logman.py", line 110, in checkArgs parmFind(sys.argv[1], sys.argv[2]) File "E:\W2\pytest\logman.py", line 55, in parmFindRAM exec_code = compile(""" File "", line 2 for eachLine in map(strip, allLines): ^ SyntaxError: invalid syntax From bryan at eevolved.com Sat Mar 3 00:12:06 2001 From: bryan at eevolved.com (Bryan Mongeau) Date: Sat, 03 Mar 2001 05:12:06 GMT Subject: Adding a method to an instance Message-ID: Quick one for you guys: I would like to add a method to an instantiated class. class foo: def __init__(self): self.bar = 123 f = foo() Now to add a method to the instance f of class foo: def newMethod(self): print self.bar f.__class__.newMethod = newMethod This works, except that it modifies the definition of class foo! >>> dir(foo) ['__doc__', '__init__', '__module__'] >>> f.__class__.newMethod = newMethod >>> f.newMethod() 123 >>> dir(foo) ['__doc__', '__init__', '__module__', 'newMethod'] Is there a way to add the method only to the instance? Oh, and please don't ask me *why* I want to do this. Just trust me :) Regards, -- <=====================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. Website: http://www.eevolved.com Public key: http://eevolved.com/bcm.pk <=====================================> "The eternal mystery of the world is its comprehensibility."-- Einstein From chris at voodooland.net Sat Mar 10 19:40:31 2001 From: chris at voodooland.net (Chris Watson) Date: Sat, 10 Mar 2001 18:40:31 -0600 (CST) Subject: Poll'able Queue objects. In-Reply-To: Message-ID: As an aside. Granted this is *NON PORTABLE* and BSD specific. BSD has a *really* cool replacement for select/poll called kqueue. It is currently in FreeBSD and NetBSD AFAIK. DESCRIPTION kqueue() provides a generic method of notifying the user when an event happens or a condition holds, based on the results of small pieces of kernel code termed filters. A kevent is identified by the (ident,filter) pair; there may only be one unique kevent per kqueue. The filter is executed upon the initial registration of a kevent in order to detect whether a preexisting condition is present, and is also executed whenever an event is passed to the filter for evaluation. If the filter determines that the condition should be reported, then the kevent is placed on the kqueue for the user to retrieve. The filter is also run when the user attempts to retrieve the kevent from the kqueue. If the filter indicates that the condition that triggered the event no longer holds, the kevent is removed from the kqueue and is not returned. <...snip...> It scales like a fantasy :) http://www.kegel.com/dkftpbench/Poller_bench.html Very very nice. For those of use using BSD that is. Also Doug White wrote a Python wrapper for kqueue. It's in FreeBSD's ports tree as Py-Kqueue. -- ============================================================================= -Chris Watson (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek Work: scanner at jurai.net | Open Systems Inc., Wellington, Kansas Home: scanner at deceptively.shady.org | http://open-systems.net ============================================================================= WINDOWS: "Where do you want to go today?" LINUX: "Where do you want to go tomorrow?" BSD: "Are you guys coming or what?" ============================================================================= irc.openprojects.net #FreeBSD -Join the revolution! ICQ: 20016186 From aweis at gmx.de Wed Mar 21 09:09:31 2001 From: aweis at gmx.de (Arnold Weis) Date: Wed, 21 Mar 2001 14:09:31 GMT Subject: HTML escape in Python 1.5.2 References: <3fQTii$l4N@openbazaar.net> Message-ID: <3ab8ae34.14307242@News.CIS.DFN.DE> Pahud.bbs at openbazaar.net (???J?w) wrote: >I want to do the html escaping in python, however, HTMLgen class >does not ship with python 1.5.2. Is there any alternative? >Thanks in advance. Hi, is cgi.escape() what you are searching for? Regards Arnold From tim.one at home.com Fri Mar 2 18:06:25 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 2 Mar 2001 18:06:25 -0500 Subject: the demise of 'from foo import * and its implications? In-Reply-To: Message-ID: [Tim] > What gave you the idea that "import *" is going away? [Sean 'Shaleh' Perry] > /me needs to take a week off apparently. Either that or stop believing > anything he reads. > > I would have SWORN I read it here, and a fellow python hacker said > something to that affect as well. Oh, that. That's just people panicking. Don't listen to people -- they're always wrong . Here's an item from the 2.1b1 NEWS file, which you can pick up from the 2.1b1 release later today: - Using "from...import *" or "exec" without in-clause in a function scope that also defines a lambda or nested function with one or more free (non-local) variables. The presence of the import* or bare exec makes it impossible for the compiler to determine the exact set of local variables in the outer scope, which makes it impossible to determine the bindings for free variables in the inner scope. To avoid the warning about import *, change it into an import of explicitly name object, or move the import* statement to the global scope; to avoid the warning about bare exec, use exec...in... (a good idea anyway -- there's a possibility that bare exec will be deprecated in the future). So, yes, by the time 2.2 rolls around, using "from ... import *" in a function scope that also contains a lambda or nested function definition whose body contains at least one free variable will go away. It's quite an ambitious act of compression to read that as "import * is going away" . And, according to the Reference Manual, "import *" at other than module scope has never been legitimate (nested functions or not). There's been no hint that import* will ever go away at module scope, despite that it's excellent advice to avoid it whenever *reasonably* possible. Binding to massive, flat systems (like windowing toolkits) can make avoiding it unreasonable. > Whichever, I will promptly use a gag as I am just digging myself a hole > today. Holes are comfy! Take in a blanket and some lavender eye pillows. import* will still be here when you come out again . jealously y'rs - tim From no at thank.you Tue Mar 27 14:59:17 2001 From: no at thank.you (Owen Ap Owen) Date: Tue, 27 Mar 2001 11:59:17 -0800 Subject: Need Help with mxODBC Connection String Message-ID: I'm using Python 2.0 and the latest mxODBC. I'm trying to connect to SQL Server 2000. When I try to connect using this connection string: db =mx.ODBC.Windows.DriverConnect('DSN=JTech_Connection;UID=tech;PWD=tech') I get this error message: "[Microsoft][ODBC SQL Server Driver][SQL Server] Changed database context to 'JTech' That's fine with me because I want the database context to be 'JTech'. But mxODBC does not deal well with this message and the db connection is not created. Nothing I do seems to change this. I've tried specifying the default database in the connection string. I've also tried specifying and not specifying the database to change to in the ODBC driver setup. No matter what I do I get the message about the database context being changed. Does anybody have any insights into how I can modify my connection string so that it is accepted? From gmunsey at adobe.com Mon Mar 12 17:10:00 2001 From: gmunsey at adobe.com (Grant Munsey) Date: Mon, 12 Mar 2001 14:10:00 -0800 Subject: PyArg_ParseTuple on steroids? Message-ID: I have been doing a lot of Python to C library adapters recently. Currently I'm generating the code for each Python cover routine with a Python program which uses a crude IDL to drive the generator. I build the IDL descriptors by hand or with another Python program in the case where the API is described in a "regular" way. Currently the C source that is output by the generator looks pretty much like code that would be generated by hand ... with PyArg_ParseTuple() at the beginning and Py_BuildValue() at the end. I was thinking of changing this to have the generator generate a table of parameter descriptions for each procedure and one call to an "uber" argument handler ... that would check the parameters, get the C values, call the function, and convert the results back into a Python return value. Kind of a PyArg_ParseTuple(), call function, Py_BuildValue() all rolled into one but that could handle many more parameter types than the standard routines do. This would have the benefit of smaller overall code generation and the various parameter handlers would be in one place instead of spread all over a large Python program which generates code. Anyone done this in the past and have any advice? From doughellmann at bigfoot.com Wed Mar 14 06:37:01 2001 From: doughellmann at bigfoot.com (Doug Hellmann) Date: 14 Mar 2001 06:37:01 -0500 Subject: main in mac? In-Reply-To: <20010313123230.19201.00000153@ng-dh1.aol.com> References: <20010313123230.19201.00000153@ng-dh1.aol.com> Message-ID: <20010314113434.MJDD2709.femail4.sdc1.sfba.home.com@[192.168.1.6]> On 13 Mar 2001 17:32:30 +0000, Park997 wrote: > >I don't know what the run all button is (not on mac), but the whole reason > >for this idiom is so it wont 'do anything' when imported. If a file named > >x.py is imported, then it's __name__ is x. If it is being run as a program, > >then it's __name__ is __main__. > > > > > >David > > I knew that was the expected behavior, and the > disadvantage of replacing if __name__ is __main__. > with if 1: is that it does run when imported. Turning the run as main option on > or off produces the expected behavior on the mac. It's not that you're running on a Mac, it's that you're using an IDE. If you double click the saved file in the Finder the __name__ would be set to '__main__' as you expect -- just like if a Windows or UN*X user runs the file directly. Doug From aleaxit at yahoo.com Fri Mar 23 01:48:30 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 23 Mar 2001 07:48:30 +0100 Subject: Why Python/Jython? References: <99cl9e$b2b$1@Merlin.et.bocholt.fh-gelsenkirchen.de> Message-ID: <99erof0173p@news2.newsguy.com> "Steve Holden" wrote in message news:srzu6.12868$_46.475705 at e420r-atl2.usenetserver.com... [snip] > > Programmer performance is usually gauged by coding time and > > number of bugs, both of which are vaguely proportional to the number of > > lines of code in most sane languages*. > > > > * Perl is a noteworthy exception > > > I saw no inconsistency here. Why would Perl be an exception to your rule? Lines of code may not be proportional to 'code size' in languages which afford many styles, one of which is 'insanely compact'. I am not sure this really changes things wrt Perl -- a given individual coder is likely to have roughly constant density of 'code size'/line in his or herl Perl code -- but it surely applies to APL. In any case, #bugs and code time depend on code-size (e.g., number of 'operators' in some vague sense), which in turn may be only indirectly proportional to measures such as SLOC. Alex From duncan at rcp.co.uk Thu Mar 15 05:09:06 2001 From: duncan at rcp.co.uk (Duncan Booth) Date: Thu, 15 Mar 2001 10:09:06 +0000 (UTC) Subject: Regular Expressions and Python 1.5.2 References: <98q0k8$2b77$1@norfair.nerim.net> Message-ID: Alexandre Fayolle wrote in <98q0k8$2b77$1 @norfair.nerim.net>: >Is this a known bug in the module re of python 1.5.2, or am I missing >something obvious? > >>>> import re >>>> t = "m&n" >>>> re.sub('[^/_ -]','*',t) >'***' >>>> re.sub('[^_ -/]','*',t) >'*&*' > I think you are missing something obvious. You specified a range from space to '/', and the ampersand is in that range, so it doesn't get replaced. In the first example the dash doesn't form part of a range so it is treated literally. From timr at probo.com Mon Mar 19 23:58:29 2001 From: timr at probo.com (Tim Roberts) Date: Mon, 19 Mar 2001 20:58:29 -0800 Subject: Python style questions References: <98tb91$9t9$1@saltmine.radix.net> <995o0u$itc$1@news.mathworks.com> Message-ID: <0oodbtgdgc3tv452iiqs29n2rd3534dc2k@4ax.com> Joshua Marshall wrote: > >A switch statement may just be syntactic sugar, but not necessarily in >a simple way. A good compiler will compile switch statements into >jump-tables or, at worst, binary searches. Cluttery to code by hand. > >Sure this is "just" an efficiency thing, but switches can get quite big. But Python, at least today, is not compiled. Switch statements in an interpreted language are not as big of a "win". -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From aleaxit at yahoo.com Tue Mar 13 04:29:54 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 13 Mar 2001 10:29:54 +0100 Subject: Einstein's Riddle References: Message-ID: <98kpaj0p6m@news2.newsguy.com> "Gregory Jorgensen" wrote in message news:NI9r6.2583$54.2812 at www.newsranger.com... > So I'm stupid, is that it? I've taken lots of IQ tests and none of them had this > question on them; that's probably why I don't score so well! Actually I did > figure out that the German owned the fish. Furthermore I was able to determine > that the fish is named Eric. Actually, I'm pretty sure she was called Wanda. Alex From tim.hochberg at ieee.org Fri Mar 9 15:11:12 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Fri, 09 Mar 2001 20:11:12 GMT Subject: "!=" is bad form. Re: sorry....never mind References: Message-ID: "Peter Schneider-Kamp" wrote in message [SNIP] > Well, Python *does* define an ordering of a and b, no matter what > a and b may be. E.g.: > > >>> 1 > (1,2) > 0 > >>> 1 < (1,2) > 1 [SNIP] This used to be true, but for better or for worse this hasn't been true for a while. It's true for most builtin objects still, but for instance: >>> class Uncomparable: def __cmp__(self, other): raise RuntimeError("I can't be compared") >>> u = Uncomparable() >>> u < 5 Traceback (innermost last): File "", line 1, in ? u < 5 File "", line 3, in __cmp__ raise RuntimeError("I can't be compared") RuntimeError: I can't be compared The guarantee of all types being ordered is likely to erode further with the advent of rich comparisons in Python 2.1 (PEP 207). -tim From bedge at troikanetworks.com Thu Mar 15 13:41:44 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Thu, 15 Mar 2001 10:41:44 -0800 Subject: redirecting stdio Message-ID: <3AB10CE8.C4978B35@troikanetworks.com> I'm trying to use pdb to debug an app that uses stdio. I'd like to get pdb, or my app to use another terminal for it's stdio. Can either the pdb class or the cmd class be vectored to use another terminal for I/O? From m.hadfield at niwa.cri.nz Thu Mar 8 15:29:45 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Fri, 9 Mar 2001 09:29:45 +1300 Subject: grabbing return codes from os.system() call References: <%wFp6.9481$dL4.126404@vixen.cso.uiuc.edu> Message-ID: <984083439.472914@clam-ext> "Gregory Jorgensen" wrote in message news:x8Gp6.899$54.943 at www.newsranger.com... > os.system returns the exit status. ... on Windows the > exit status is always 0. Not so. On my Win 2000 box with Python 2.0, successful commands return 0 and unsuccessful commands (where the command is not found) return 1. Of course there may be more to it, but that's what I found in 20 s of experimentation... --- Mark Hadfield m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield National Institute for Water and Atmospheric Research From ej at ee.duke.edu Fri Mar 30 03:23:35 2001 From: ej at ee.duke.edu (eric jones) Date: Fri, 30 Mar 2001 08:23:35 GMT Subject: Performance hit for ALLOW_THREADS macros? Message-ID: Hello, Adding Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS appears to have significant negative impact on my extension module's speed -- even when not using threads. (Linux RH6.1, Python2.1a2) I have a numeric routine that fills a large matrix. The routine is written in FORTRAN and lives in an extension module (wrapped by f2py). The routine has be written such that it can be called twice in parallel with one call filling the upper half of the matrix and one filling the lower half of the matrix (nice for multiprocessors). Placing Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS around the call to the Fortran routine in the extension module allows it to be called independently from two Python threads. Doing this provided very marginal speed-up (10-20% maybe). Because of the run time of the routine (10s of seconds to days), I expected a factor much closer to 100%. I played with sys.setcheckinterval() a little to see if it helped things and it didn't. This is what I expected reasoning that all CPU cycles should be burning in the Fortran routines. Looking for the issue, I ran the routine in single threaded mode, once compiled with (1) Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS, and (2) once without. On a typical small problem, single threaded times showed the following: (1) using ALLOW_THREADS macros 20.54 seconds (2) no macros 13.78 seconds Why would simply adding these macros affect the run time so much? I didn't expect them to have any affect (especially when threads aren't even used). Here's where I put the macros in the code. (1) static PyObject *foo(PyObject *capi_self, PyObject *capi_args, PyObject *capi_keywds, void (*f2py_func)()) { { ... Py_BEGIN_ALLOW_THREADS (*f2py_func)(&alpha,&i12,&cfreq,epstj,muej,...); Py_END_ALLOW_THREADS ... } (2) static PyObject *foo(PyObject *capi_self, PyObject *capi_args, PyObject *capi_keywds, void (*f2py_func)()) { { ... (*f2py_func)(&alpha,&i12,&cfreq,epstj,muej,...); ... } Any hints as to what is happening here? thanks, eric From nas at python.ca Tue Mar 27 00:15:52 2001 From: nas at python.ca (Neil Schemenauer) Date: Mon, 26 Mar 2001 21:15:52 -0800 Subject: fixing map(None, [1,2,3]) ? In-Reply-To: <873dc040ny.fsf@mathdogs.com>; from mkc@mathdogs.com on Mon, Mar 26, 2001 at 04:37:21PM -0600 References: <873dc040ny.fsf@mathdogs.com> Message-ID: <20010326211552.C17390@glacier.fnational.com> Mike Coleman wrote: > Shouldn't "map(None, [1,2,3])" return "[(1,), (2,), (3,)]"? > > Is there any hope that this could be fixed? Probably not. Use zip(). Neil From hans.kristian.ruud at inenco.no Wed Mar 28 12:01:52 2001 From: hans.kristian.ruud at inenco.no (Hans Kristian Ruud) Date: Wed, 28 Mar 2001 17:01:52 GMT Subject: The Scale widget Message-ID: <3AC216C0.F38935C1@inenco.no> Is there a way to modify the scale widget so that the slider only can move in one direction? -- Hans Kristian From tim.one at home.com Mon Mar 19 21:33:07 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 19 Mar 2001 21:33:07 -0500 Subject: Wrong reasons to enhancing the language In-Reply-To: <99661m$scc$1@panix6.panix.com> Message-ID: [Aahz] > ... > Nested scopes are an optional feature of Python 2.1 I wouldn't phrase it that way. Nested scopes are a mandatory feature of Python 2.2, and 2.1 is giving people a one-release grace period to convert their code to the new semantics (if they indeed have any code in need of converting ... seems that conflicts are mighty rare so far). > and the others are simply *proposed* features. > > This is a *great* time to be debating the numerics issues. Indeed it is. So far, though, IEEE-754 aficionados are conspicuous by absence. and-we-really-*need*-a-fifth-group-that-doesn't-agree-with-any-of-the- others-ly y'rs - tim From tjg at exceptionalminds.com Fri Mar 16 14:22:11 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Fri, 16 Mar 2001 11:22:11 -0800 Subject: can a class intantiate itself to None? Message-ID: <20010316112211.E3109@trufflehunter.avalongroup.net> I'd like to create a class that can instantiate itself to None when instantiation fails... class foo: def __init__(self, bar): if type(bar) == StringType: self.data = 'This is a String' x = foo('a') y = foo(1) # In this instance I would like y to be None So, can it be done, or do I need to raise an exception, catch it and then set y to None? -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Red Hat Certified Engineer www.exceptionalminds.com Avalon Technology Group, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 58 days 23:33 hours ago<< From db3l at fitlinxx.com Thu Mar 8 04:20:04 2001 From: db3l at fitlinxx.com (David Bolen) Date: 08 Mar 2001 04:20:04 -0500 Subject: Name of the Script References: <20010304.185354.2114937732.8277@localhost.localdomain> Message-ID: "Tim Hochberg" writes: > Another approach, if __file__ is what you want is to have a module import > itself and grab the __file__ from the imported copy. Here's a (contrived) > example: > > # file test.py > if __name__ == "__main__": > import test > print `test.__file__` > > Unfortunately, this whole __file__ approach fails when using files from an > archive (such as produced with Gordon McMillan's installer), so this isn't > always useful. And isn't this risky in general since it depends on the fact that the module itself is going to be somewhere properly on sys.path? I've had cases where the main script was in a system bin location that wasn't on sys.path since it only contained top level scripts meant to be directly executed. I think I also had some issues with this approach when running a module that resided within a package directory, but my memory is a bit vague. At a minimum you'd want to protect the import with a try/except block to catch a possible ImportError and have some fallback scenario in that case. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From emile at fenx.com Sat Mar 24 19:52:23 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 24 Mar 2001 16:52:23 -0800 Subject: time to invest ??? References: <3abd3a17.7103358@news.vif.com> Message-ID: <99jfmh$1i58c$1@ID-11957.news.dfncis.de> Pick a simple admin task, something you do regularly and feel you understand, work the tutorial, and then implement in python. Two ideal days. If it takes a week, you've started with too big a project. Stop at two days and ask for help/clarification. -- Emile van Sebille emile at fenx.com --------- "Yvon Boulianne" wrote in message news:3abd3a17.7103358 at news.vif.com... > Hello, i start to learn Python some day ago, with lot of knowledge as > a system admin but little as programmer and i wonder what is the > average time/hours someone have to invest to be able to use a language > like that easily. i talk as well about devlopping the way of thinking > of a programmer and the knowledge of the language. please don't tell > me theres no average, at least take the idea of a normal guy, not a > genius and not stupid ;-) > > Thanks verry much and sorry for my english, my first language is > french. > > Yvon Boulianne ; Saphi > mysticsguy at yahoo.ca > www.monunivers.net > Humour,Paradox & Changements From tim.one at home.com Fri Mar 2 14:18:20 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 2 Mar 2001 14:18:20 -0500 Subject: create new statement? In-Reply-To: <3A9FE7C2.1F5525D2@troikanetworks.com> Message-ID: [Bruce Edge] > Can you add a new statement to python? Yes, but you probably can't . That is, the set of statements is fixed, and to add a new statement you would need to change the grammar of the language, rebuild the parse tables, and alter the compiler to generate appropriate code for it. > ... > I want to add my own command to the interp, but not have to use object > calling syntax > eg: > create obj opt > not > create(obj, opt) > > How do I define new statements, or, a way of calling functions using the > former syntax? You don't, in Python. "It's a feature" that everyone's code looks the same here. You can do that in Perl, though. Without changing the language implementation, the closest you could get in Python would be to write a source-to-source (or source-to-bytecode) translator of your own, that output legitimate Python source (or bytecode). python's-syntax-is-neither-extensible-nor-overridable-ly y'rs - tim From DanielK at jBASE.com Fri Mar 16 16:34:54 2001 From: DanielK at jBASE.com (Daniel Klein) Date: Fri, 16 Mar 2001 13:34:54 -0800 Subject: Python creator: Perl users are moving to Python Message-ID: <2Gvs6.11725$a3.27986@typhoon.aracnet.com> http://searchdatabase.techtarget.com/searchDatabase_News_Item/0,281943,53162 9,00.html I apologize if this has already been posted to the group. Dan From thys at klaribel.netsys.co.za Fri Mar 23 12:28:45 2001 From: thys at klaribel.netsys.co.za (Thys) Date: Fri, 23 Mar 2001 19:28:45 +0200 Subject: wxImageList use in wxPanel Message-ID: <01032319371802.09619@klaribel.feetjieland> Hi All, I need to display a few images on several places in a wxPanel, the obvious soluttion would be to use a wxImageList, especially as the panel changes over time (a status screen of sorts). I cant seem to get it to work though, no compilation problems but the graphics refuse to be displayed. The documentation seems to concentrate on wxListCtrl and wxtreeCtrl none of which is applicable in this case. appreciated as always -- Regards Thys -------------------- Thys Meintjes thys at netsys.co.za Netsys International(Pty) Ltd http://www.netsys.co.za +27 12 348-4246 From kens at sightreader.com Tue Mar 20 13:53:16 2001 From: kens at sightreader.com (Ken Seehof) Date: Tue, 20 Mar 2001 10:53:16 -0800 Subject: re.match References: <997skf$qoc$1@bmerhc5e.ca.nortel.com> Message-ID: <005901c0b16f$068d1790$04090a0a@upcast.com> re.match tests whether or not a string -matches- a regular expression. re.search -searches- a string for the first occurrence of a regular expression. "Is this a dead parrot?" vs "Does anyone know where my parrot is?" ----- Original Message ----- From: "Fredrik Lundh" Newsgroups: comp.lang.python To: Sent: Tuesday, March 20, 2001 9:29 AM Subject: Re: re.match > Michael P. Soulier wrote: > > Hey people. Could someone explain the purpose of the match function in the > > re module? If it's only difference from search is to match at the beginning of > > the line, why does it exist? That's what the ^ in the regexp is for. > > no, it's not. read the documentation again. > > Cheers /F > > > -- > http://mail.python.org/mailman/listinfo/python-list > From mwh21 at cam.ac.uk Wed Mar 14 03:47:19 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 14 Mar 2001 08:47:19 +0000 Subject: Console column Width References: Message-ID: "Nathan Heagy" writes: > I can't figure out how to learn the (linux) console's column width from > within a script? That is, without using curses. This works for me: def getwidth(): return getheightwidth()[1] # Eep! this next should be made rather more portable (ie. fallback to # env vars, then tigetstr("lines"), etc). def getheightwidth(): height, width = struct.unpack( "hhhh", ioctl(0, TERMIOS.TIOCGWINSZ ,"\000"*8))[0:2] return height, width Cheers, M. -- Not only does the English Language borrow words from other languages, it sometimes chases them down dark alleys, hits them over the head, and goes through their pockets. -- Eddy Peters From topmind at technologist.com Thu Mar 1 22:01:00 2001 From: topmind at technologist.com (Topmind) Date: Fri, 02 Mar 2001 03:01:00 GMT Subject: Collection interfaces References: <3a90fa97.0@news1.mweb.co.za> <3A933830.7F98D118@ix.netcom.com> <220220010813598042%cmh@bDistributed.com> <8Gem6.473353$U46.14105062@news1.sttls1.wa.home.com> <3A9A86B1.9A8C69A2@ix.netcom.com> <97fjla128ir@news2.newsguy.com> <97h5s40vhc@news2.newsguy.com> <97ifd60sen@news1.newsguy.com> <3A9EEF93.4B18FCA@cosc.canterbury.ac.nz> Message-ID: > Topmind wrote: > > > > There is no polymorphism if there is > > only one "type" with a bunch of independant attributes - > > HAS-A reigns and sub-IS-A is rare. > > Polymorphism is not inherently dependent on any > kind of inheritance or classification system. > In Python, for instance, most functions are quite > promiscuous and will happily operate on any > objects which have the right methods, without there > having to be any inheritance relationship between > them. > > -- > Greg Ewing, Computer Science Dept, University of Canterbury, > Christchurch, New Zealand > To get my email address, please visit my web page: > http://www.cosc.canterbury.ac.nz/~greg > I kind of had (having) this discussion with Jay recently WRT Smalltalk. I would give you a message ID but the designers of usenet were drunk when they designed that part. -tmind- From donn at oz.net Fri Mar 23 01:46:38 2001 From: donn at oz.net (Donn Cave) Date: 23 Mar 2001 06:46:38 GMT Subject: Multiple Processes on Unix with Python References: <3ABA8919.835D8BED@centropolisfx.com> <99eic9$i06$0@216.39.151.169> <3ABADF0E.A1F9E93A@centropolisfx.com> Message-ID: <99erge$bj5$0@216.39.151.169> Quoth Nickson Fong : | this is helpful - what i really want to do is> | for example: i have a 2 processor irix machine and i want to launch 2 | processes. | | proc #1 = render frames 1-10 | proc #2 = render frames 11-20 | | | os.fork os.execv os.wait are things that i have been reading..... | | question: why do you os.spawnv? Just to be different. Seriously, I have always thought that a fork+exec function would be a worthwhile convenience, and here it is. You can see for yourself in os.py, it's no more than a fork and exec, plus waitpid depending on the option, but notice that it has better than average exception handling. And it's actually a Windows function, so it's a little more cross platform portable than fork & exec. Really I think the big payoff is to use it instead of system(), with generated arguments. Like, os.spawnv(os.P_WAIT, '/usr/bin/lpr', ('lpr', '-P', printer, file)) instead of os.system('lpr -P %s %s' % (printer, file)) If the input is bad (printer or file), the first is much less scary than the second. Donn Cave, donn at oz.net From jkahanpa at pcu.helsinki.fi.invalid Tue Mar 13 06:48:51 2001 From: jkahanpa at pcu.helsinki.fi.invalid (Jere Kahanpaa) Date: 13 Mar 2001 11:48:51 GMT Subject: What's wrong with me/Python ? References: <3AAE0652.D68F253E@daimlerchrysler.com> Message-ID: <98l1f3$fnn$1@oravannahka.helsinki.fi> Alexander Stirzel wrote: : 8<----------- error message ----------------------------- : Traceback (most recent call last): : File "/usr/sbin/netscape-killer.py", line 11, in ? : splitted = string.split(line) : NameError: There is no variable named 'string' : 8<----------- error message ----------------------------- : Now here's the script: : 8<------------ script ----------------------------------- : #!/usr/local/bin/python : import os : import time Add 'import string'. The 'string' module is not automatically loaded. You can also import several modules on a single line: import os, time, string Happy Hacking Jere -- Lord, make my words as sweet as honey, for one day I may have to eat them Daryl Benson From tim.one at home.com Thu Mar 1 15:58:41 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 1 Mar 2001 15:58:41 -0500 Subject: A counter-counter-proposal for PEP 236: #pragma( nested_scopes) In-Reply-To: <15006.46745.206128.996289@w221.z064000254.bwi-md.dsl.cnc.net> Message-ID: [Jeremy Hylton] > ... > A word of clarification: __future__ isn't about experimental > features. Instead it is for bleeding edge users to use a new feature > in release X even though the feature won't be standard until release > Y, where X < Y. > > If we want to do experimental stuff, we should probably do something > like: > > from __possible_world__ import __future__ > from __future__ import ... Hmm. Maybe that's why I so dislike Martin's attempt to hijack PEP 236: his current formulation of an alternative leaves only the raw names, without the __future__ or __possible_world__ qualifiers. We have a clear taxonomy in mind when we're doing this stuff, but that's lost in an all-purpose "directive" statement. So, over time, only the experts who introduced various directive gimmicks will remember where their particular raw names fit in the grander scheme. Back to your point , I expect that until release Y happens, it probably *is* most correct to view a __future__ feature as experimental. Indeed, that's why PEP 236 says a MandatoryRelease value may become None (meaning that the feature was withdrawn). But it's experimental in the sense that while it *may* be withdrawn, the presumption is that it won't be -- it's not just random "trying things out" (which is how I suspect you read /F's use of the word, and for which __possible_world__ (whatever) would be more appropriate). words-words-and-more-words-ly y'rs - tim From thomas at cintra.no Tue Mar 6 09:11:57 2001 From: thomas at cintra.no (Thomas Weholt) Date: Tue, 6 Mar 2001 15:11:57 +0100 Subject: [ Cry for help ] Please bugtest my full-text indexer Message-ID: Hi, Just finished my own full-text indexer which is easy to use and seem to be quite fast. BUT, when tested against a lot of data, my archive of RFCs, the thing croaked after inserting approx. 500.000 keys ( size of data stored was ~40 MB ), giving me an error-message from the bsddb-module, (0,'error'). I'm terribly sorry for posting this, with attachments and all, but I need this one to work with HUGE amounts of data. Please let me know if there are anything I can do. The module works fine for smaller amounts of data and it's the easiest full-text indexer I've seen in Python so far ( ok, so I'm biased ;-> ) and it could be useful for other folks here too. The module is located here http://download.sourceforge.net/snipthis/hsindexer.zip Best regards, Thomas Weholt From dnew at san.rr.com Thu Mar 15 18:15:28 2001 From: dnew at san.rr.com (Darren New) Date: Thu, 15 Mar 2001 23:15:28 GMT Subject: I come to praise .join, not to bury it... References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> <3AAF7E47.294617E1@sage.att.com> <98qeco02hn7@news1.newsguy.com> <3AB106CD.7D259EBC@san.rr.com> Message-ID: <3AB14D10.7F3A31F@san.rr.com> > Hmm ... I wonder what I'd do if I could overload __if__ ... That's how Smalltalk works. It has no "if" statement. There's an "IfElse" method that takes two blocks. True evaluates its first argument, False its second, in a polymorphic way. So bool if: [yes yes] else: [no no] doesn't contain any branching code. Just a polymorphic dispatch. Very strange to wrap your head around. :-) (Of course, in reality, it branches for efficiency, recognised by the compiler, but in theory...) -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. From ransen_spam_me_not at nemo.it Sat Mar 3 06:12:29 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Sat, 03 Mar 2001 11:12:29 GMT Subject: PyRun_SimpleFile - impossible to call it under Windows? References: <3aa07704.2672581@news.newsguy.com> Message-ID: <3aa0ccdf.4708595@news.newsguy.com> On Fri, 02 Mar 2001 16:04:54 GMT, ransen_spam_me_not at nemo.it (Owen F. Ransen) wrote: >I've seen that there is an odd bug in PyRun_SimpleFile >probably because of version incompatibilities in the >FILE structure and using DEBUG modes in VC6 > >I'd like to call PyRun_SimpleFile in the debug version >of my VC6 program, is it impossible currently with Python 2? >TIA >Owen Following up my own message, is a possibility that I recompile and create my Python lib using the sources of 2.1b1 ? I'd have to link statically to make sure I do not interfere with outher embedders extenders... ? -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From aahz at panix.com Mon Mar 19 18:51:18 2001 From: aahz at panix.com (Aahz Maruch) Date: 19 Mar 2001 15:51:18 -0800 Subject: Wrong reasons to enhancing the language References: <9960i1$tp0$1@nntp6.u.washington.edu> Message-ID: <99661m$scc$1@panix6.panix.com> In article <9960i1$tp0$1 at nntp6.u.washington.edu>, Russell E. Owen wrote: > >I believe many of the improvements in Python 2.0 fall into the category >of helpful improvements. I am more doubtful about some of the stuff >coming up (including nested scopes, // and rational numbers), but we'll >see how it works out. None of those are Python 2.0 improvements. Nested scopes are an optional feature of Python 2.1 and the others are simply *proposed* features. This is a *great* time to be debating the numerics issues. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 There's a difference between a person who gets shit zie doesn't deserve and a person who gets more shit than zie deserves. --Aahz From qrczak at knm.org.pl Sat Mar 24 10:21:48 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 24 Mar 2001 15:21:48 GMT Subject: python, perl, lisp, tcl / got a decision to make, can you give me a view point please ? and a joke for python users :) References: <3aba3076.14395287@news.vif.com> Message-ID: Ok, it seems that you can't stand Perl's success and everybody here must from time to time say that Perl is evil :-) So to make you laugh, here is my favorite Perl silliness (perl-5.6.0/toke.c). Enjoy the algorithm of disambiguation of the last case! /* S_intuit_more * Returns TRUE if there's more to the expression (e.g., a subscript), * FALSE otherwise. * * It deals with "$foo[3]" and /$foo[3]/ and /$foo[0123456789$]+/ * * ->[ and ->{ return TRUE * { and [ outside a pattern are always subscripts, so return TRUE * if we're outside a pattern and it's not { or [, then return FALSE * if we're in a pattern and the first char is a { * {4,5} (any digits around the comma) returns FALSE * if we're in a pattern and the first char is a [ * [] returns FALSE * [SOMETHING] has a funky algorithm to decide whether it's a * character class or not. It has to deal with things like * /$foo[-3]/ and /$foo[$bar]/ as well as /$foo[$\d]+/ * anything else returns TRUE */ /* This is the one truly awful dwimmer necessary to conflate C and sed. */ STATIC int S_intuit_more(pTHX_ register char *s) { if (PL_lex_brackets) return TRUE; if (*s == '-' && s[1] == '>' && (s[2] == '[' || s[2] == '{')) return TRUE; if (*s != '{' && *s != '[') return FALSE; if (!PL_lex_inpat) return TRUE; /* In a pattern, so maybe we have {n,m}. */ if (*s == '{') { s++; if (!isDIGIT(*s)) return TRUE; while (isDIGIT(*s)) s++; if (*s == ',') s++; while (isDIGIT(*s)) s++; if (*s == '}') return FALSE; return TRUE; } /* On the other hand, maybe we have a character class */ s++; if (*s == ']' || *s == '^') return FALSE; else { /* this is terrifying, and it works */ int weight = 2; /* let's weigh the evidence */ char seen[256]; unsigned char un_char = 255, last_un_char; char *send = strchr(s,']'); char tmpbuf[sizeof PL_tokenbuf * 4]; if (!send) /* has to be an expression */ return TRUE; Zero(seen,256,char); if (*s == '$') weight -= 3; else if (isDIGIT(*s)) { if (s[1] != ']') { if (isDIGIT(s[1]) && s[2] == ']') weight -= 10; } else weight -= 100; } for (; s < send; s++) { last_un_char = un_char; un_char = (unsigned char)*s; switch (*s) { case '@': case '&': case '$': weight -= seen[un_char] * 10; if (isALNUM_lazy_if(s+1,UTF)) { scan_ident(s, send, tmpbuf, sizeof tmpbuf, FALSE); if ((int)strlen(tmpbuf) > 1 && gv_fetchpv(tmpbuf,FALSE, SVt_PV)) weight -= 100; else weight -= 10; } else if (*s == '$' && s[1] && strchr("[#!%*<>()-=",s[1])) { if (/*{*/ strchr("])} =",s[2])) weight -= 10; else weight -= 1; } break; case '\\': un_char = 254; if (s[1]) { if (strchr("wds]",s[1])) weight += 100; else if (seen['\''] || seen['"']) weight += 1; else if (strchr("rnftbxcav",s[1])) weight += 40; else if (isDIGIT(s[1])) { weight += 40; while (s[1] && isDIGIT(s[1])) s++; } } else weight += 100; break; case '-': if (s[1] == '\\') weight += 50; if (strchr("aA01! ",last_un_char)) weight += 30; if (strchr("zZ79~",s[1])) weight += 30; if (last_un_char == 255 && (isDIGIT(s[1]) || s[1] == '$')) weight -= 5; /* cope with negative subscript */ break; default: if (!isALNUM(last_un_char) && !strchr("$@&",last_un_char) && isALPHA(*s) && s[1] && isALPHA(s[1])) { char *d = tmpbuf; while (isALPHA(*s)) *d++ = *s++; *d = '\0'; if (keyword(tmpbuf, d - tmpbuf)) weight -= 150; } if (un_char == last_un_char + 1) weight += 5; weight -= seen[un_char]; break; } seen[un_char]++; } if (weight >= 0) /* probably a character class */ return FALSE; } return TRUE; } -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From mcfletch at home.com Fri Mar 9 10:03:04 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Fri, 9 Mar 2001 10:03:04 -0500 Subject: Can anyone recomend a good intoduction to C... In-Reply-To: <984132875.222868@newsmaster-04.atnet.at> Message-ID: <000001c0a8aa$0b9143b0$a9807018@cr706570a> Perl-ism, http://www.drbbs.com/jsw/jargon/jargon_35.html#TAG1944 Enjoy, Mike -----Original Message----- From: Werner Schiendl [mailto:ws-news at gmx.at] Sent: Friday, March 09, 2001 5:10 AM To: python-list at python.org Subject: Re: Can anyone recomend a good intoduction to C... What's TMTOWTDI, please? -- http://mail.python.org/mailman/listinfo/python-list From emile at fenx.com Sat Mar 31 16:57:35 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 31 Mar 2001 13:57:35 -0800 Subject: list vs tuple References: Message-ID: <9a5k2e$3mk79$1@ID-11957.news.dfncis.de> """Grant me the serenity to accept the things I cannot change, the courage to change the things I can, and, above all, grant me the wisdom to know the difference.""" -- Emile van Sebille emile at fenx.com --------- "deadmeat" wrote in message news:lWrx6.1057$p5.4152 at news1.rivrw1.nsw.optushome.com.au... > > THERE IS NO DIFFERENCE. > > What happens to the objects is not the point, what happens to what I put > into a and b is the point. > > >>> a = 1 a points somewhere > >>> b = a b points to the same place > >>> a = 2 a now points elsewhere > >>> b what else would you expect? > 1 > > >>> a = [1,2,3] a points somewhere > >>> b = a b points to the same place > >>> a[0] = 0 the thing a points to is changed > >>> b what else would you expect? > [0, 2, 3] > > Are you saying there is no difference (IN THE *RESULT*) between these? Are > you able to read? > > What goes on in the background is NOT THE POINT. I only care about the > values I put into them, and what happens after b = a. > > > > From whisper at oz.net Mon Mar 26 13:41:18 2001 From: whisper at oz.net (Dave LeBlanc) Date: 26 Mar 2001 18:41:18 GMT Subject: daemon app in win32 References: <99nk49$a2q$02$1@news.t-online.com> <99nsn3$q39$06$1@news.t-online.com> Message-ID: <99o2ge$9on$0@216.39.170.247> AFAIK, Every Windows app gets sent a WM message when it's about to be terminated. Most apps just let this fall through to the default message processor (which you have to do anyway) without doiing anything to clean up. You can add a message handler for this such that the app can gracefully (make out it's will?) prepare to end it all. Just make sure that in the end, it passes the message on to the default message handler so that windows can do it's own cleanup of your app. Regards, Dave LeBlanc On Mon, 26 Mar 2001 19:02:27 +0200, Michael Bauer wrote: >Steve Purcell wrote: > >> Michael Bauer wrote: >>> i am writing a daemon application that runs both under windows and unix. >>> Since i am not very experienced in win32 - programming, i really would >>> appreciate some hints how to register my app in win32 that i can do some >>> cleanup-functions when windows is shut down. >>> >>> At the moment it is just a standard console application that simply gets >>> killed when windows shuts down. The app does not have/need a GUI, it >>> should just run in the background. >> >> >> If you're using NT, take a look at the win32service API. I think it >> provides hooks like SvcStop that Windows will call for you (if you ask it >> nicely). > >Hmm, seems like this is only available under NT. Is there a more general >way to accomplish this task independently of the underlying Windows-version? > >But maybe i should just get a life and write different wrappers for Win95, >Win98, WinME, Win200, WinNT... :-( > >still hoping... Mike From Karl.Bellve at umassmed.edu Fri Mar 16 11:29:06 2001 From: Karl.Bellve at umassmed.edu (Karl Bellve) Date: Fri, 16 Mar 2001 11:29:06 -0500 Subject: C++ and Python Message-ID: <3AB23F52.FB2E087C@umassmed.edu> I have a class that will use Python and Numpy. There could be several instances of this class, each using and initializing Python. The problem I am having is with PyMethoDef which passes a table of methods and their descriptions to Python. As far as I can tell, this can't be a static structure. Anyone build a PyMethodDef structure inside a C++ class so the appropiate function pointers point to the appropiate instance of the class? Otherwise...I am stuck using static variables and functions inside a C++ class? -- Cheers, Karl Bellve ICQ # 13956200 Biomedical Imaging Group TLCA# 7938 University of Massachusetts Email: Karl.Bellve at umassmed.edu Phone: (508) 856-6514 Fax: (508) 856-1840 PGP Public key: finger kdb at molmed.umassmed.edu From hernan.foffani at iname.com Fri Mar 16 14:18:54 2001 From: hernan.foffani at iname.com (hernan.foffani at iname.com) Date: 16 Mar 2001 19:18:54 GMT Subject: Extending Python: rewriting a single method in C References: <98l1i901k4u@news1.newsguy.com> <98m6g20fgv@news1.newsguy.com> <98ntl80vrp@news2.newsguy.com> Message-ID: <20010316141854.145$sP@newsreader.com> "Alex Martelli" wrote: >... > With the HTML-Help form of the docs (I forget the helpful person > from whose site I downloaded that from), searching throughout the > docs is instantaneous -- which roughly makes up for defects in > the index and/or organizational problems in the docs themselves. You can find it here: http://alldunn.com/python/ or here: http://www.orgmf.com.ar/condor/pytstuff.html regards, -Hernan -- -------------------- http://NewsReader.Com/ -------------------- Usenet for the Web From kens at sightreader.com Sat Mar 3 16:34:18 2001 From: kens at sightreader.com (Ken Seehof) Date: Sat, 3 Mar 2001 13:34:18 -0800 Subject: IPC9 hotel room share Message-ID: <007b01c0a429$b6cb8720$a325fea9@his> If you are interested in saving money by sharing a room at the conference, call me. (650) 575-9186 (cell, any time) (408) 353-5670 (if the cell phone doesn't work) Or email me before 6:00 today, March 3. I have a res at Holiday Inn (2.5 km from IPC9) which can be cancelled by 6pm. Your half is about $50 including tax. I'd also consider splitting a room at the Hilton if you already have a reservation there. - Ken -------------- next part -------------- An HTML attachment was scrubbed... URL: From bhk at dsl.co.uk Wed Mar 14 20:56:46 2001 From: bhk at dsl.co.uk (Brian {Hamilton Kelly}) Date: Thu, 15 Mar 2001 01:56:46 GMT Subject: Einstein's Riddle References: <984587984snz@dsl.co.uk> Message-ID: <984621406snz@dsl.co.uk> In article <984587984snz at dsl.co.uk> bhk at dsl.co.uk "Brian {Hamilton Kelly}" writes: > "No fair", starting a troll by cross-posting to EIGHT groups. One's > supposed to limit the initial posting to no more than eight groups. ^^^^^ s/eight/six/ Sigh. -- Brian {Hamilton Kelly} bhk at dsl.co.uk "We have gone from a world of concentrated knowledge and wisdom to one of distributed ignorance. And we know and understand less while being incr- easingly capable." Prof. Peter Cochrane, BT Labs From stephen_purcell at yahoo.com Fri Mar 9 05:21:17 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Fri, 9 Mar 2001 11:21:17 +0100 Subject: OODB question In-Reply-To: ; from arinagour@yahoo.co.uk on Fri, Mar 09, 2001 at 09:59:16AM -0000 References: Message-ID: <20010309112117.A12238@freedom.puma-ag.com> chris lamb wrote: > I am sure that I read somewhere of an OODB implementation developed > specifically with Python or having a Python interface. > > I am beginning to wonder if I dreamt it up since I cannot remember where I > read about it! > > Can anyone help me ? (I doubt it!) You're probably thinking of ZODB. Take a look at http://www.amk.ca/zodb/ -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From akuchlin at mems-exchange.org Tue Mar 20 18:31:31 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 20 Mar 2001 18:31:31 -0500 Subject: ASCII encoding error: ordinal not in range(128) References: <91o5ih$2kv$1@news.wrc.xerox.com> <20001219172933.B29727@ActiveState.com> Message-ID: <3d4rwo10h8.fsf@ute.cnri.reston.va.us> "Fredrik Lundh" writes: > > UnicodeError: ASCII encoding error: ordinal not in range(128) > > translated to english, this overly cute error message attempts > to say something like "cannot convert this Unicode string to > ASCII as it contains non-ASCII characters" Hmm... hasn't changing this message before been discussed someplace? Was there some reason it wasn't changed? How about: "UnicodeError: ASCII encoding error: character not in ASCII range 0-127" ? (I vaguely recall Marc-Andre arguing for "ordinal", since that's used in the Unicode documents, but if it's less clear...) --amk From max at alcyone.com Thu Mar 29 11:03:20 2001 From: max at alcyone.com (Erik Max Francis) Date: Thu, 29 Mar 2001 08:03:20 -0800 Subject: Printing "%" References: <99vm4k$22l$1@ctb-nnrp2.saix.net> Message-ID: <3AC35CC8.AD0B71E2@alcyone.com> Mix wrote: > How do you print a percenrage (%)sign in Python? > I tried : > return "select * from fax where id LIKE '%s\%'" %ident Use %% instead: Python 2.0 (#5, Nov 10 2000, 21:47:15) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 Type "copyright", "credits" or "license" for more information. >>> "We're at %f%%" % 200 "We're at 200.000000%" -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ People are taught to be racists. \__/ Jose Abad Esperanto reference / http://mirror/alcyone/max/lang/esperanto/ An Esperanto reference for English speakers. From rambo at linuxsecurity.co.kr Thu Mar 8 18:08:46 2001 From: rambo at linuxsecurity.co.kr (rambo) Date: Thu, 8 Mar 2001 15:08:46 -0800 Subject: about environment variable. Message-ID: <9877ho$kqn$1@news2-2.kornet.net> I installed Tkinter ,as follows rpm -Uvh Tkinter-2.0-8.0-3.i386.rpm after that, == python prompt === 1. >>>from Tkinter import * 2. >>> w=Button (text="hello" , command='exit' ) Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.0/lib-tk/Tkinter.py", line 1819, in __init__ Widget.__init__(self, master, 'button', cnf, kw) File "/usr/local/lib/python2.0/lib-tk/Tkinter.py", line 1752, in __init__ BaseWidget._setup(self, master, cnf) File "/usr/local/lib/python2.0/lib-tk/Tkinter.py", line 1727, in _setup _default_root = Tk() File "/usr/local/lib/python2.0/lib-tk/Tkinter.py", line 1482, in __init__ self.tk = _tkinter.create(screenName, baseName, className) after type 2th line , I got error message as above, what environment variable should I set to fix above problem. thanks for your time. From sholden at holdenweb.com Sat Mar 3 15:19:05 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sat, 3 Mar 2001 15:19:05 -0500 Subject: gah! I hate the new string syntax References: Message-ID: "chris" wrote in message news:tN5o6.2746$eH3.14913 at NewsReader... > > at latest since the 19th century; in America, it appears this is normally > > introduced in the 6th or 7th grades (ages 11-12, for those of you in > > inferior countries > > In Scotland that kind of stuff is pre-School! > > Chris Ha! As an Englishman married to a Scot I'm not going to let you get away with that one: this is classic Scottish braggadocio [I expect Italian education form tne martellibot about that]. Brass neck, as we simple Yorkshire folk would term it. Still, at least we can remind all that Scotland and England are different countries on c.l.py. Lest people might think this is intended as criticism rather than humo(u)r, I hasten to add that I lived in Scotland for three years before moving to the USA, and found the Scots to be extraordinarily warm and generous people. As I put it to a taxi-driver on Scotland recently who asked me how I got on in Scotland "I find that once we get past 'Engl***h' and 'bas***d' we can get on all right". He correctly pointed out that this was a racist remark, but we got on fine and agreed that nobody was offended. So, for the record, they don't get their mathmatics degrees until fourth grade in Scotland. coming-from-the socialist-people's-republic-of-yorkshire-and-therefore- not-quite-as-english-as-others-we-won't-mention-y'rs - steve From ajung-ml at andreas-jung.com Wed Mar 28 08:13:29 2001 From: ajung-ml at andreas-jung.com (Andreas Jung) Date: Wed, 28 Mar 2001 08:13:29 -0500 Subject: dynamic web pages? Message-ID: <003001c0b788$e2c65d60$9865fea9@SUXLAP> And we have the small gun: PMZ (Poor Men's Zope): http://pmz.sourceforge.net Andreas "Robert Kiendl" schrieb im Newsbeitrag news:3AC0B262.6F0E30DE at gmx.net... > we have the BIG GUN here: Zope (www.zope.org) dynamic app.server in > native python logic including an OODBMS! > > or use cgi programming with apache From tuttledon at hotmail.com Thu Mar 15 17:40:27 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Thu, 15 Mar 2001 22:40:27 GMT Subject: Python Programming on Win32 (was: Magnitude of the wx* market (was: Python In A Nutshell - suggestions)) References: <3AB16A79@MailAndNews.com> Message-ID: "Laura Lewin" wrote in message news:3AB16A79 at MailAndNews.com... > To try to address your other concerns (your mini rant), we are planning > application-oriented books in the Python space, but these will be for > developers. I hear your concerns about books that cover Python apps, but > ORA's main focus has always been for the developer, and that's where you'll > see most of our books. I can't speak for all of the other publishers/authors > out there. Hmm... I guess I didn't make myself clear. I'm not really interested in Python apps. I'm interested in more specific topics on Python Development. In short, don't make me learn VB, Perl, or C++ just so I can THEN figure out how to do it in Python. (This is a general statement to all publishers, not just O'Reilly.) The void in how to program in Python has been filled by several good books. The basic language is no longer an issue. How to do usefull tasks is. This is where I have to go to current books written for other languages (And yes, I just got my copy yesterday Programming Python 2E. ;-) In Python Programming On Win32's case, it suffers from too much breadth, not enough depth. It would be much better to chop the cookbook sections up into a seperate series of books. As for .NET, if the Common Language Runtime becomes cross platform, you won't have to call this a Win32 series anymore! > Please do check out The Python Cookbook > (http://pythoncookbook.activestate.com/)though. You mention an interest in > system administration, databases, network programming. These are all > sections > in the Cookbook. Feel free to contribute recipes, or take any with you!! It's about time! I was complaining about a need for a Python Cookbook here several months ago! Don From mcalla at home.com Fri Mar 16 17:13:15 2001 From: mcalla at home.com (Mike Callahan) Date: Fri, 16 Mar 2001 22:13:15 GMT Subject: Catching exceptions in Tkinter's mainloop Message-ID: <%dws6.9947$Q47.2723350@news1.rdc1.tn.home.com> I want to make sure that if any exception pops up inside a mainloop, that exception is printed to a log file and the mainloop quits. I tried to simulate this with the following code but failed: from Tkinter import * class Gui: def __init__(self, master): self.master = master self.button = Button(master, text='Crash', command=self.crash) self.button.pack() def crash(self): z = zz # trigger exception root = Tk() app = Gui(root) try: root.mainloop() except: print 'caught' root.quit() It doesn't work. The exception is printed out by standard traceback and the mainloop continues. What am I doing wrong? Mike Callahan From dsavitsk at e-coli.net Mon Mar 12 18:26:15 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Mon, 12 Mar 2001 17:26:15 -0600 Subject: tkinter entry index References: Message-ID: thanks. "Fredrik Lundh" wrote in message news:SJcr6.17936$Qb7.3120517 at newsb.telia.net... > "dsavitsk" wrote: > > how can i get the position of the cursor in an entry widget? .index and > > .icursor don't seem to it. That is, if "foo" is in an entry, and the cursor > > is between the "o" and the other "o", I could get a return of 2. > > position = w.index(INSERT) > > Cheers /F > > > > From l_hill at mindspring.com Mon Mar 5 22:32:54 2001 From: l_hill at mindspring.com (Laura Hill) Date: Mon, 05 Mar 2001 19:32:54 -0800 Subject: OOPSLA 2001 call for participation Message-ID: <3AA45A66.8A4B07F9@mindspring.com> The OOPSLA 2001 submission system is now active at: oopsla.acm.org ************************************************************** OOPSLA 2001 Call for Participation OOPSLA 2001 October 14-18, 2001 Tampa Bay Convention Center Tampa Bay, Florida USA The ACM OOPSLA Conference (Object-Oriented Programming, Systems, Languages, and Applications) is the world's premier forum for object-oriented technology. If you're involved in object technology, OOPSLA 2001 is the place to be. Submissions are solicited in the following categories: Technical Papers, Tutorials, Practitioner Reports, Panels, Demos, Educators' Symposium, Workshops, Posters, Doctoral Symposium, DesignFest, Vendor Exhibits For more info, check out our Web site: http://oopsla.acm.org Important Dates March 23, 2001: Due date for Technical Papers, Practitioner Reports, Educators' Symposium, Tutorials, Workshops, and Panel proposals, and DesignFest problems July 20, 2001: Due date for Posters, Demonstrations, Doctoral Symposium, and Student Volunteers From hinsen at cnrs-orleans.fr Fri Mar 30 05:23:39 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 30 Mar 2001 12:23:39 +0200 Subject: Gaussian line profile using numeric python References: <3ac31698@zfree.co.nz> Message-ID: "John J. Lee" writes: > > 2) If you work with large data sets, you ought to use FFTs to > > compute the convolution, that's O(N*log(N)) in the size of the > > data set, instead of O(N**2) for the straightforward method. > > Any good book on FFTs should explain how this works in detail. > > but you probably don't need to know in detail, it boils down to > > inv_FFT(FFT(data)*FFT(kernel)) Except for zero-padding in case of non-periodic signals. That's why I always recommend to look at a detailed description before doing this; some of my colleagues keep telling me that FFT techniques "don't work", and I suspect this is the reason. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From mwh21 at cam.ac.uk Mon Mar 5 14:49:20 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 05 Mar 2001 19:49:20 +0000 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Mar 5) References: Message-ID: Oleg Broytmann writes: > Michael Hudson continues Andrew Kuchling's marvelous tradition > of summarizing action on the python-dev mailing list twice a > month. FWIW, I'm planning on doing them every other week. This isn't very different from twice a month (not at all in Feb!), but for the sake of accuracy... Cheers, M. -- The rapid establishment of social ties, even of a fleeting nature, advance not only that goal but its standing in the uberconscious mesh of communal psychic, subjective, and algorithmic interbeing. But I fear I'm restating the obvious. -- Will Ware, comp.lang.python From qrczak at knm.org.pl Tue Mar 13 10:26:37 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 13 Mar 2001 15:26:37 GMT Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> <20010312170356.B3513@better.net> <984486395.407379@newsmaster-04.atnet.at> Message-ID: Tue, 13 Mar 2001 13:21:50 +0100, Werner Schiendl pisze: > The most useful approach is to round the numbers to 15 digits for display, > because this is the precision double values can really correctly represent. > The drawback is, that the rounded value does not discover all the > information actually stored in the variable. The most useful approach is to display as much as is needed to read the value back, but no more. I.e. repr(float("0.2")) == "0.2", and there is no other float value whose repr is "0.2". This doesn't solve the problem from the beginning of this thread, because float("0.1") + float("0.2") needs not be equal to float("0.3"). But at least all short numbers entered at the prompt don't have those unnecessary 00000s or 99999s, and conversion to a string and back preserves the value. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From rkiendl at gmx.net Tue Mar 27 09:28:45 2001 From: rkiendl at gmx.net (Robert Kiendl) Date: Tue, 27 Mar 2001 16:28:45 +0200 Subject: Bayes Tools for Python ? Message-ID: <3AC0A39D.389A7F6F@gmx.net> anybody know sources for Bayes Net computing with Python (NumPy) ? -robert From dougfort at downright.com Tue Mar 20 12:50:34 2001 From: dougfort at downright.com (Doug Fort) Date: Tue, 20 Mar 2001 12:50:34 -0500 Subject: python suitability for large critical run forever apps References: <3AB77CE4.78378862@troikanetworks.com> Message-ID: <3AB7986A.206EFB37@downright.com> Our website loadtesting application http://www.stressmy.com has backend agents that 'run forever'. (Actually, we're doing frequent upgrades, so most agents get restarted at least once a week, but we've never had anything fail from memory or resource leaks). I find multithreaded apps much easier to develop and debug in Python than in C/C++ or Java. However, I'm becoming convinced that it's better to use select() than threads for waiting on I/O. -- Doug Fort (dougfort at downright.com) Senior Meat Manager Downright Software LLC http://www.dougfort.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From tim.one at home.com Thu Mar 22 23:39:49 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 22 Mar 2001 23:39:49 -0500 Subject: New PEP: The directive statement In-Reply-To: Message-ID: [Martin von Loewis] > ... > I have my problems with that part of PEP 236 also. While it is > certainly possible to provide the release when a feature was first > released, it is not possible to give an accurate answer to the > question when it will become mandatory. The intent to make it > mandatory in the future should go into the documentation, IMO. If the mandatory release is greater than the release you're running under, it's certain that the feature in question is not yet "the rule". If the mandatory release is less than or equal to the release you're running under, it's certain that the feature in question *is* "the rule". Those are the only two interesting questions at runtime, and they're answered precisely. It doesn't matter if the first prediction is wrong, because __future__.py ships *with* the compiler. This gives the pair of them a consistent view of what the truth is for that version of the compiler; if the prediction is wrong, no problem, it's updated in the next release and then *that* gets a self-consistent view of the world too. The two questions above are always answered correctly for the version you're running under. Of course the docs for a release should explain the state of features too, but info in the docs isn't accessible to programs. > Furthermore, what is the use of that information to a program? Primarily, it's what makes it possible to write a simple tool that nukes obsolete future statements. The tool can't know whether a future_statement is obsolete wrt the release it's being run under unless it has a repository of release info shipped with that release, and in program-accessible form (see above). __future__.py makes that not just possible, but *easy*. In another vein, in my own code I don't hesitate to use new features, and couldn't care less if rare incompatible changes require me to rewrite some code. So I'll likely use future_statements much more than most people. I already have code that does from __future__ import nested_scopes import sys assert nested_scopes.getMandatoryRelease() > sys.version_info This will assert-fail as soon as I run it under a release where nested_scopes is the rule, and at that point I'll simply delete the future_statement and move on. Code like this also works fine: import __future__ if __future__.nested_scopes.getMandatoryRelease() > sys.version_info: import old_version_of_module as amodule else: import amodule I don't know that I'll have an acute need for that wrt nested_scopes specifically (neither do I know that I won't), but there is an endless sequence of proposals for, e.g., changing Python in incompatible ways that would (supposedly) allow it to run faster. In that case I may very well have an acute need to ship one version of my source that exploits the new semantics but falls back to an older & slower module if the compiler it's running under can't play along. Etc. Introspective features *always* find good uses. I'm sure the Python community will think of others that haven't even dimly occurred to me yet. That's why it's there: not because someone already thought far enough ahead to ask for it, but because it's thoroughly predictable that somebody *will*. when-you-don't-have-a-hammer-everything-looks-like-a-brick-wall-ly y'rs - tim From root at rainerdeyke.com Wed Mar 7 21:07:06 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Thu, 08 Mar 2001 02:07:06 GMT Subject: I come to praise .join, not to bury it... References: <000001c0a64c$497df250$a9807018@cr706570a> Message-ID: "D-Man" wrote in message news:mailman.983997159.4842.python-list at python.org... > Even with my newfound understanding, provided by the Martellibot, I > agree with this. Calling a method on an object is fine. Calling it > on a literal looks weird. Take for example something like this > > three = 1.__add__( 2 ) How about 'three = (1).__add__(2)'? Adding parentheses around the literal should make this look right; otherwise you are not calling methods on the results of complex expressions often enough. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From phrxy at csv.warwick.ac.uk Tue Mar 27 11:58:40 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Tue, 27 Mar 2001 17:58:40 +0100 Subject: boolean values in COM / VB / Python In-Reply-To: <3ABFE1F6.4232DE4E@venix.com> Message-ID: On Mon, 26 Mar 2001, Lloyd Kvam wrote: > My guess is that you don't have a COM wrapper in place for the > Document. In other words: > > import win32com.client > ie = win32com.client.Dispatch("InternetExplorer.Application") > ie.Visible = 1 # toggles window visible > ie.Visible = 0 # toggles window invisible > ie.GetHome() # loads the home page > > Now when you refer to > ie.Document > you are actually referring to a new object. Well, yes. And? > I believe that you will > need to do some work to provide the wrapper so that Python values get > translated to the equivalent COM values. [...] But what would the equivalent COM values be? That's the problem! In particular, what would be the Python for 'false' in VB? I've tried 0, -1, '0', None, 1 and other less likely objects, and they all either don't do anything, or pop up a box asking where to save, which would be contrary to the docs if I were succeeding in passing something meaning 'false'. When you talk about a 'COM wrapper', is this in the general sense, or in some specific COM sense? I'm new to COM and windows stuff. John From jcc.ugm at ix.netcom.com Wed Mar 28 14:29:23 2001 From: jcc.ugm at ix.netcom.com (Jonathan Claggett) Date: Wed, 28 Mar 2001 14:29:23 -0500 Subject: Is inheritance broken? In-Reply-To: <15042.11167.848530.564353@beluga.mojam.com> Message-ID: > Jonathan> Isn't this wrong? > >Nope. It's a feature of multiple inheritance, not a bug. The search >through base classes is left-to-right, depth first, thus >parallelogram.angle is found before rectangle.angle. Thank you, I think I understand now. I think the problem is that the depth first searching works fine so long as you don't have a common ancestor in your class tree. If you do have a common ancestor, it will be searched ahead of some of its descendant classes. I wonder if there is a (quick) way to do a depth first search that accounts for common ancestors... If I really wanted this to work, guess one thing I could do is to cheat by creating a 'flat' list of classes and then manually creating my class tree. Something like this: # 'flat' classes class parallelogram_flat: def angle(self): return "variable" def side(self): return "variable" class rhombus_flat: def side(self): return "same" class rectangle_flat: def angle(self): return "90 degree" class square_flat: pass # 'real' classes class parallelogram(parallelogram_flat): pass class rhombus(rhombus_flat, parallelogram_flat): pass class rectangle(rectangle_flat, parallelogram_flat): pass class square(square_flat, rhombus_flat, rectangle_flat, parallelogram_flat): pass # usage s = square() print "squares have", s.angle(), "angles" print "squares have", s.side(), "sides" Ugly and error prone, no? >Someone with more Python years under their belt will have to answer why >Guido chose depth first instead of breadth first search for methods when >multiple inheritance is involved. I'm pretty sure it's a choice that can't >be changed now, however. There's probably too much code that relies on the >current semantics. I second your question (does Guido read this list?) :-) From aleaxit at yahoo.com Fri Mar 9 17:47:53 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 9 Mar 2001 23:47:53 +0100 Subject: gah! I hate the new string syntax References: <97ohh2$polt0$1@ID-77331.news.dfncis.de> <97opsb$nhu$1@nntp6.u.washington.edu> <98an7i01tgp@news2.newsguy.com> <1eq0wih.1s0r5163x0lfkN%francois.granger@free.fr> Message-ID: <98dpoc02ckn@news1.newsguy.com> "Fran?ois Granger" wrote in message news:1eq0wih.1s0r5163x0lfkN%francois.granger at free.fr... [snip] > There are a lot of french citizen wich are descendant from italian. At Not a new development either -- there's a continuity between (notice the Italian surnames of French icons!-) Mazarino, Bonaparte, Gambetta, Platini...:-). [With any luck, one day my descendants will be able to give a similar list of Albanian-surnamed Italian greats...!-)]. > > -- few are aware, for example, > > that such an icon of French popular culture as Yves Montand was > > Italian -- real name Ivo Livi, born of just-as-Italian parents [snip] > And lots of french people are really proud of Yves Montant, knowing or > not his origin as Ivo Livi. (And, joking aside, who could blame them -- besides being a great singer and actor, he was a _true_ human being... his being buried right next to his wife of many decades, such a rare event in the show-business world, being a typical symptom...). Alex From ssartor at bellatlantic.net Wed Mar 28 13:15:29 2001 From: ssartor at bellatlantic.net (Steven Sartorius) Date: Wed, 28 Mar 2001 18:15:29 GMT Subject: How to update status bar in wxPython? Message-ID: <5Tpw6.2172$K%.667185@typhoon1.ba-dsg.net> I'm a newbie to GUI programming in general so apologies if this is a FAQ.... I've got a Python script that does some heavy duty number crunching and file I/O. To track the progress of the script I print a series of messages to the console/x-term ("Working on file #....", etc,etc). As a project, I decided to guify the script with wxPython and Boa-constructor. I've successfully built a window with a single button, a couple of text input fields and a status bar; clicking the button fires off the script. What I'm trying to do (so far unsuccessfully) is redirect the progress messages from the console to the status bar on the window. Because I'm retrofitting an existing script, I've just replaced the original 'print' statements with 'statusBar.SetStatusText("Working on file....") and (for good measure) 'statusBar.Refresh()'. This approach kind of works....the status bar shows the final progress message ("All data processed") but only after I force the window to redraw (moving it or covering and then uncovering it). I'm sure I'm missing something basic here so any help would be much appreciated. Thanks, Steve From scarblac at pino.selwerd.nl Tue Mar 13 09:21:35 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 13 Mar 2001 14:21:35 GMT Subject: What's wrong with me/Python ? References: <3AAE0652.D68F253E@daimlerchrysler.com> Message-ID: Alexander Stirzel wrote in comp.lang.python: > Hi! > > I just wrote a small script for killing some hanging netscape processes, > the source is listed below. > Now if I run this script I get this error message: > > 8<----------- error message ----------------------------- > Traceback (most recent call last): > File "/usr/sbin/netscape-killer.py", line 11, in ? > splitted = string.split(line) > NameError: There is no variable named 'string' > 8<----------- error message ----------------------------- You forgot to import string. Have a nice day. -- Remco Gerlich From spencerm at cruzio.com Fri Mar 30 02:54:01 2001 From: spencerm at cruzio.com (Michael Spencer) Date: Thu, 29 Mar 2001 23:54:01 -0800 Subject: Creation d'un NG francophone sur Python References: <1eqzyk6.gxd4jr1tkjykzN%francois.granger@free.fr> Message-ID: <9a1e6f011es@enews3.newsguy.com> Pardon, mais pourquoi un NG pour Python en fran?ais? Python a cr?? par un nederlandais qui a ?crit en anglais - pas sa langue natif. Il a ?crit en anglais ? assurer la plus grande distribution de ses id?es. Pourquoi on marcherait en arri?re aux temps quand chaque groupe a maintenu sa <> par s'isoler des autres? Fran?ois Granger wrote in message news:1eqzyk6.gxd4jr1tkjykzN%francois.granger at free.fr... > Sorry for this french message. Translation follow. > > Il est encore temps de voter pour la cr?ation d'un NG en fran?ais sur > Python. Allez dans 'fr.usenet.forums.annonces' et cherchez le message > '[AAV 3] Creation de fr.comp.lang.python (non-modere)' > votez en r?pondant ? ce message. > > [en] > It is time for voting to create the french speaking newsgroup > 'fr.comp.lang.python'. Go to 'fr.usenet.forums.annonces' and look for > the message '[AAV 3] Creation de fr.comp.lang.python (non-modere)'. > Votes by replying to this message. > > -- > "La connaissance est le chemin de la tol?rance, c'est valable pour > tous, en toutes saisons." > - Raymond Page From bill-bell at bill-bell.hamilton.on.ca Tue Mar 20 07:17:23 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Tue, 20 Mar 2001 07:17:23 -0500 Subject: Whois client? In-Reply-To: <985032471.1506.6177.l8@yahoogroups.com> Message-ID: <3AB70403.26884.2645462@localhost> Has anyone seen a Whois client coded in Python? Thanks for any leads. Bill Bell, MSc, Software Developer From jschmitt at vmlabs.com Thu Mar 29 20:42:19 2001 From: jschmitt at vmlabs.com (John Schmitt) Date: Thu, 29 Mar 2001 17:42:19 -0800 Subject: issues with mixing and matching python packages Message-ID: <008F0A63472BD311AF9800104BCD102561CD63@minirex.vmlabs.com> I'm talking about the PythonLabs 2.0 versus ActiveState versus the installer on Python.org. I just glanced at the notes for the ActiveState installer and it says: - On Windows, ActivePython 2.0 cannot coexist with other Python 2.0 installations (for example, BeOpen's Python 2.0). Whichever installer is run last will determine what version of Python is used (the registry can only point to one executable). The ActivePython windows installer will warn you if you try to install over an existing Python 2.0 installation. - You must ensure your PYTHONPATH is clean before installation. You should ensure that your machine does not have PYTHONPATH, PYTHONHOME, or other relevant variables set, and that your installation directories are clean. If you have problems importing certain modules after installation, please check these things before submitting a bug report. Does this mean that I can't simply change the installation I'm using by simply changing some environment variables? What's up? What happens when I upgrade to 2.1? Is that going to be a problem? John From erno-news at erno.iki.fi Fri Mar 9 03:02:08 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 09 Mar 2001 10:02:08 +0200 Subject: Apache and os.fork() in CGI-Binaries References: <3aa7ded0@si-nic.hrz.uni-siegen.de> <3AA84BF3.E19873DB@ninenet.com> Message-ID: In article <3AA84BF3.E19873DB at ninenet.com>, Matt Harden writes: | Simon, | You need os.dup2(). Like this: | logfile = os.open("/path/to/logfile",os.O_CREAT|os.O_WRONLY) | os.lseek(logfile, 0, 2) /* seek to end */ | os.dup2(logfile, sys.stdout.fileno()) | os.dup2(logfile, sys.stderr.fileno()) | os.close(logfile) it is better to use O_APPEND with log files. you may also need to lock it so that many processes do not write to it at the same time. -- erno From quinn at retch.ugcs.caltech.edu Wed Mar 14 17:03:34 2001 From: quinn at retch.ugcs.caltech.edu (Quinn Dunkan) Date: 14 Mar 2001 22:03:34 GMT Subject: gah! I hate the new string syntax References: <97sudi01i26@news1.newsguy.com> <98elrk$li8$1@nntp.Stanford.EDU> <98fc070thh@news1.newsguy.com> <98iqo2$56o$1@nntp.Stanford.EDU> <98iv3s01sc2@news2.newsguy.com> Message-ID: On Mon, 12 Mar 2001 17:56:33 +0100, Alex Martelli wrote: >Focusing on the polymorphism needs, I see the issue in the mirror >way from you: it's a _weakness_ (of Python and most other languages) >that I can't add methods 'post-facto, from the outside' to existing >objects -- it impedes the most natural, elegant, typeswitch-free way >to add functionality. If you pursued your "capitalize as a function" >idea, you'd be unable to properly capitalize Unicode (e.g.) without >a typeswitch -- a very unadvisable construct. Something like Haskell's >typeclasses, on the other hand, would provide the best of both worlds >(multimethods would be an even more powerful alternative) -- let the >compiler/interpreter/runtime do the dispatching, and just code in >the most natural, polymorphic way. Note that in ruby, any time you write class Foo ... end you are adding to, not overriding, 'Foo'. Thus, class String def cap s = (if self[0].betwwen?(97, 122) then self[0] - 32 else self[0] end).chr s + self[1 .. self.length] end end is perfectly valid ruby that does what he wanted. I thought this sort of thing was cute when I first saw it, but it makes me a bit nervous: I've introduced a global change in a system-level class. The problem is that, in an imperative language, that change occurs at a pont in time. It makes the order I load modules of possible importance. It could break client modules who are expecting a "clean slate". Naturally, in a statically-typed functional language like haskell, these issues don't come up. But in an imperative language, it's like frobbing __builtins__ ---probably not a very good idea. For classes that are not completely under your control, or if the functionality is only of local interest, I think either a subclass or a "external" function is better style (ruby provides "singleton methods", but I'm happier with a plain non-OO function). For example, I had a set of Cell objects that were to be displayed graphically. The display mechanism required that they each have a special tag to keep track of their position on the screen. The tag was useless to all other clients of Cells, and not even computable by the Cell itself. Unsure of what the "official" solution would be, I wrote the tag computation as a function of the display module, and had the display object cache the tags internally. It seemed more logical that way: the display mechanism should keep track of its own administrivia. But then I wound up with 'tagof(c)', where 'tagof()' was a typeswitch on 'c', which is the sort of thing you're not supposed to have in OO. In haskell, I could have simply defined a 'Taggable' class and instances implementing 'tagof' in the Display module... no problem. But "traditional" OO seems to make the solution much less clear... From martin.skott at propylon.com Wed Mar 7 13:03:41 2001 From: martin.skott at propylon.com (Martin Skott) Date: 07 Mar 2001 18:03:41 +0000 Subject: XML Module problems References: Message-ID: Martin Skott writes: > Sean isn't currently reading newsgroups, but I hope my answer will do Damn finger getting to fast typing. What I meant is that Seand is away and doesn't read news currently :-) -- Martin Skott Software Developer Propylon - Enabling Universal Mobility http://www.propylon.com Tel: +353 096 37245 Mobile: +353 087 9680370 From tim.one at home.com Sun Mar 25 17:12:15 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 25 Mar 2001 17:12:15 -0500 Subject: Python classes on east coast? In-Reply-To: Message-ID: [Robert Hicks] > Is there or are there any plans for Python classes on the east coast > (preferrably around DC)? Learning Tree has DC-area classes: http://www.learningtree.com/us/ilt/courses/430.htm some-even-in-guido's-home-town-ly y'rs - tim From andreas at andreas-jung.com Thu Mar 22 07:55:49 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Thu, 22 Mar 2001 07:55:49 -0500 Subject: Why Python/Jython? References: <99cl9e$b2b$1@Merlin.et.bocholt.fh-gelsenkirchen.de> Message-ID: <99csmm$bbf$1@slb6.atl.mindspring.net> In a former project I used JPython in combinatination with CPython to access an Oracle 8i database. Because the Python bindings for Oracle 8 were incomplete - the combination JPython/JDBC was very cool :-) Working with Java APIs in Pythons interactive mode is nice :-) Performance does not matter in any case. Andreas "Andreas Freier" schrieb im Newsbeitrag news:99cl9e$b2b$1 at Merlin.et.bocholt.fh-gelsenkirchen.de... > In several articles I read that Python/Jython imporoves the programmers > performance many times. Why? > I am considering to use Jython for my job as Java programmer. How should I > use it to achieve this performance? > From hgg9140 at cola.ca.boeing.com Mon Mar 5 18:09:58 2001 From: hgg9140 at cola.ca.boeing.com (Harry George) Date: Mon, 5 Mar 2001 23:09:58 GMT Subject: MySQL-python build griefs References: Message-ID: I installed no problem (MySql 3.23.32, Redhat 6.2) with: export PKGVER=MySQL-python-0.3.1 ln -s ../${PKGVER}.tar.gz . gzip -cd ${PKGVER}.tar.gz | tar xvf - #---1.5.2--- cd ${PKGVER} #===edit Setup=== if sys.platform == "linux-i386": # Red Hat include_dirs = ['/usr/local/mysql/include/mysql'] library_dirs = ['/usr/local/mysql/lib/mysql'] #===end edits=== python setup.py build su -c "python setup.py install" wware at world.std.com (Will Ware) writes: > I'm trying to build MySQL-python on a Red Hat 6.2 box. In order > not to confuse the Red Hat installation, which depends heavily > on Python, I've left Python at 1.5.2. I have Distutils 1.0.1 > installed. The version of MySQL-python is 0.3.0. To get things > to work at all, I needed to build my own copy of Python-1.5.2/* > to populate the /usr/include/python1.5 tree, running "configure" > to produce a suitable "config.h". Now I'm getting an error on > "python setup.py build" that looks like this: > > running build > running build_py > not copying MySQLdb.py (output up-to-date) > not copying CompatMysqldb.py (output up-to-date) > running build_ext > Traceback (innermost last): > File "setup.py", line 90, in ? > extra_objects=extra_objects, > File "/usr/lib/python1.5/site-packages/distutils/core.py", line 138, in setup > dist.run_commands() > File "/usr/lib/python1.5/site-packages/distutils/dist.py", line 829, in run_commands > self.run_command(cmd) > File "/usr/lib/python1.5/site-packages/distutils/dist.py", line 849, in run_command > cmd_obj.run() > File "/usr/lib/python1.5/site-packages/distutils/command/build.py", line 106, in run > self.run_command(cmd_name) > File "/usr/lib/python1.5/site-packages/distutils/cmd.py", line 328, in run_command > self.distribution.run_command(command) > File "/usr/lib/python1.5/site-packages/distutils/dist.py", line 849, in run_command > cmd_obj.run() > File "/usr/lib/python1.5/site-packages/distutils/command/build_ext.py", line 200, in run > customize_compiler(self.compiler) > File "/usr/lib/python1.5/site-packages/distutils/sysconfig.py", line 106, in customize_compiler > (cc, opt, ccshared, ldshared, so_ext) = \ > File "/usr/lib/python1.5/site-packages/distutils/sysconfig.py", line 368, in get_config_vars > func() > File "/usr/lib/python1.5/site-packages/distutils/sysconfig.py", line 274, in _init_posix > parse_makefile(filename, g) > File "/usr/lib/python1.5/site-packages/distutils/sysconfig.py", line 207, in parse_makefile > value = value[:m.start()] + done[n] + after > TypeError: illegal argument type for built-in operation > > Am I using the wrong color duct tape here? Or just not enough > bubblegum? > > -- > -----------------------------------+--------------------- > 22nd century: Esperanto, geodesic | Will Ware > domes, hovercrafts, metric system | wware at world.std.com -- Harry George E-mail: harry.g.george at boeing.com The Boeing Company Renton: (425) 237-6915 P. O. Box 3707 02-CA Everett: (425) 266-3868 Seattle, WA 98124-2207 Page: (425) 631-8803 From m_debusk at deja.com Mon Mar 12 03:18:13 2001 From: m_debusk at deja.com (Michael DeBusk) Date: Mon, 12 Mar 2001 03:18:13 -0500 Subject: Einstein's Riddle References: Message-ID: <3AAC8645.48990315@eclipsetel.com> Gregory Jorgensen wrote: > We have no evidence that any of the five owns fish. I know very little about transformational grammar, but I've picked up enough to respond to this. There's a thing called "presupposition" at play here. A presupposition is an idea one has to pre-suppose so one can make sense of a given sentence. For example, the sentence "tell the dog to get off the sofa" contains presuppositions that such a thing as a dog exists, such a thing as a sofa exists, that both the dog and the sofa exist in such a way that dogs can be on sofas, that dogs can obey commands... even that the speaker believes that the listener speaks and understands English. All the things native speakers of a language intuitively know when they go through the process of understanding a sentence, in other words. The question "Who owns the fish?" contains a linguistic presupposition indicating *someone* owns a fish; the question is not whether, but whom. That presupposition is the evidence. If the question was "Does someone own a fish?" one could then assert there was no available information. Someone else in the thread pointed out the problems involved in translating the puzzle to other languages. I imagine that would create some roadblocks, because the structure of presuppositions would be different in each. -- Use the munged address below to reply: debu4335 [shift-2] eclipsetel [dot] com From dsh8290 at rit.edu Fri Mar 9 11:27:34 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 9 Mar 2001 11:27:34 -0500 Subject: Static typing (was Re: Java guy interested in Python) In-Reply-To: <20010309095209.24339.qmail@web206.mail.yahoo.com>; from hamish_lawson@yahoo.co.uk on Fri, Mar 09, 2001 at 09:52:09AM +0000 References: <20010309095209.24339.qmail@web206.mail.yahoo.com> Message-ID: <20010309112734.G4546@harmony.cs.rit.edu> On Fri, Mar 09, 2001 at 09:52:09AM +0000, Hamish Lawson wrote: | Michael Hudson wrote: | | > If you type-annotate this, you might write (using entirely made up | > syntax): | > | > def write16(file : , int : ): | > file.write(struct.pack("h",int)) | > | > but then what about passing in a StringIO object, or some user | > wrapper of a file object? What makes a ""? At the moment, | > it's just a loose collection of methods, some of which are optional | > in some circumstances. | | Wouldn't there be a hierarchy of interface types for file-like objects, | with some interfaces specifying more methods than others? You'd then | choose the interface type that specified the collection of methods that | you require of your passed object. Yes. It's called Java ;-). | | Not-that-I'd-necessarily-want-this-all-of-the-time-ly yours, I certainly don't. I do like the ERR side of compile-time type checking however. Perhaps someone should create a Py-lint that will check python source for this sort of thing. Then again maybe it's already called PyUnit or doctest. -D From dmaas at dcine.com Thu Mar 8 00:19:45 2001 From: dmaas at dcine.com (Dan Maas) Date: Thu, 08 Mar 2001 05:19:45 GMT Subject: Unicode getting in the way... Message-ID: Python 2.0. All I want to do is construct and parse simple binary packets. e.g. foo = "abcd" + struct.pack("B", 254) foo += "efg%s" % "lalala" At some random point in my code, foo changes from being a 'string' object to a 'unicode' object. Subsequent attempts to manipulate foo fail with a UnicodeError (ASCII decoding error, ordinal not in range(128)). How can I stop this from happening? I just need raw 8-bit strings everywhere! Thanks, Dan From harri at trema.com Fri Mar 16 09:15:06 2001 From: harri at trema.com (Harri Pasanen) Date: 16 Mar 2001 15:15:06 +0100 Subject: list.sort(cmpfunc) question Message-ID: The list.sort(cmp) docs for Python 2.0 state: The sort() method takes an optional argument specifying a comparison function of two arguments (list items) which should return -1, 0 or 1 depending on whether the first argument is considered smaller than, equal to, or larger than the second argument. The build in cmp() function docs state: cmp (x, y) Compare the two objects x and y and return an integer according to the outcome. The return value is negative if x < y, zero if x == y and strictly positive if x > y. So interpreted strictly the built in cmp() could not be used as list.sort() argument, as it can apparently (and does) occasionally return for instance the value 2. In practice list.sort() seems to be happy with having a cmp function that behaves as built in cmp(), but can this be relied upon? And if yes, maybe the doc should be changed? Regards, Harri From grante at visi.com Thu Mar 8 20:50:15 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 09 Mar 2001 01:50:15 GMT Subject: I come to praise .join, not to bury it... References: <000001c0a64c$497df250$a9807018@cr706570a> <989btv$rd4$1@panix3.panix.com> Message-ID: In article <989btv$rd4$1 at panix3.panix.com>, Aahz Maruch wrote: >>>Even with my newfound understanding, provided by the Martellibot, I >>>agree with this. Calling a method on an object is fine. Calling it >>>on a literal looks weird. >>What makes you think a "literal" is not an object? > >It is, but not at the aesthetic level. But, aesthetics is determined largely by cultural influences: i.e. background. ";" isn't an object at the aesthetic level *for a C programmer*. For others with different backgrounds, ";" is just as much an object as anything else -- both at an aesthetic level and at a technical level. >>> Take for example something like this >>> >>>three = 1.__add__( 2 ) >> >>Looks just fine to a ex-Smalltalker: everything is an object. > >Python isn't Smalltalk. Neither is it C. ;) -- Grant Edwards grante Yow! Is it FUN to be at a MIDGET? visi.com From aleaxit at yahoo.com Thu Mar 15 07:35:12 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 15 Mar 2001 13:35:12 +0100 Subject: tiny extension crashes References: Message-ID: <98qcto02fde@news1.newsguy.com> "John J. Lee" wrote in message news:Pine.SOL.4.30.0103141957240.10526-100000 at mimosa.csv.warwick.ac.uk... > > I've been using a tiny little C extension module that I wrote for a while [snip] > double number; > double *intp; > > if (!PyArg_ParseTuple(args, "d", &number)) > return NULL; > if (fabs(modf(number, intp)) >= 0.5) { As others have noted, THIS is your problem -- I just wanted to underscore that this is a very common C-newbie error: when a function takes a "whatever*" (pointer-to-whatever) argument, you need to pass *the address of something* (or possibly, for some functions, an explicit NULL), *NEVER* a generic and not initialized variable of type "whatever*". It's easy to remember: C arguments are by-value -- all you ARE passing is the VALUE of the actual argument; passing as actual-argument a variable is never right unless it's been previously initialized by some suitable expression being assigned to it (for some reason, this programming error typically affects the passing of arguments which are declared to have pointer-type). Alex From jra at dorothy.msas.net Sat Mar 31 01:31:29 2001 From: jra at dorothy.msas.net (Jay R. Ashworth) Date: Sat, 31 Mar 2001 06:31:29 GMT Subject: Linux GPS program References: <3AC01637.4EF3A6F2@crynwr.com> <3AC0D915.83C2C0C3@crynwr.com> <99suho$m7a$2@newsserver.rrzn.uni-hannover.de> <3AC4ADE4.DD629457@crynwr.com> Message-ID: This one time, at band camp, Russell Nelson wrote: > "Jay R. Ashworth" wrote: > > No, actually, I'd bet some cash that the largest collection by size is > > the combined efforts of the US Govenment. That's (almost) all free. > > So, do you have any suggestions on what vector file format and dataset I > should aim at first? No. :-) Depends on whether the target is hikers, road warriors, boaters, or flyers, really. The USGS DRG-O and Shapefile formats seem to be the most common, but the former is scheduled to be replaced by a format I mentioned last week sometime (my laptop went for a swim the other day, and the mouse circuitry is still mildly horked, so I can't find the reference easily for you), which is likely to displace the latter too, in time. Check out freegis.org and nationalatlas.gov, for a couple of useful starting points, I guess. More When I Can Get To More. Cheers, -- jra -- Jay R. Ashworth jra at baylink.com Member of the Technical Staff Baylink The Suncoast Freenet The Things I Think Tampa Bay, Florida http://baylink.pitas.com +1 727 804 5015 From jkraska1 at san.rr.com Thu Mar 22 02:37:33 2001 From: jkraska1 at san.rr.com (Courageous) Date: Thu, 22 Mar 2001 07:37:33 GMT Subject: Good Editor? References: <3ab9a32b$1_1@news2.one.net> Message-ID: On Wed, 21 Mar 2001 23:00:58 -0800, "fjs" wrote: >Can someone recomend a good editor to write python in? Im just getting >started learning python and dont know which ones support python. Vim has a language highliting for python and has friendly tab control. I have mine set, for example, so that "every tab fills in enough spaces to take you to the next tab stop." On all my python projects, actual tab characters are completely forbidden. C// From johnson2 at hiwaay.net Sun Mar 25 23:06:23 2001 From: johnson2 at hiwaay.net (Lyle Johnson) Date: Sun, 25 Mar 2001 22:06:23 -0600 Subject: Python script to create HTML gallery, thumbnails References: <3ABCAC94.B095CB9A@ozemail.com.au> Message-ID: > I recently got a digital camera (Kodak DC4800) and wanted to > put all the crappy photos I shoot on the web. No answer for your question, I was just thinking about how Kodak needs to get in touch with you for their next ad campaign: "With Kodak's new DC4800 digital camera, now you too can put all the crappy photos you shoot on the web!" From ransen_spam_me_not at nemo.it Mon Mar 5 03:32:14 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Mon, 05 Mar 2001 08:32:14 GMT Subject: tokenizer.c crashes in 2.1b1 Message-ID: <3aa34d5c.1284101@news.newsguy.com> Embedding Python 2.1b1 I recreated the DLL and LIB from the sources, VC6 , and any call to PyRun_SimpleFile still crashes. The debugger points to the guilty party: tokenizer.c, the fgets call at line 247 fails. My VC project uses Multithreaded Debug compiler settings, as does the Pythoncore project. What do I do now? -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From claird at starbase.neosoft.com Tue Mar 27 11:31:40 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 27 Mar 2001 10:31:40 -0600 Subject: Why not Tcl/Tk? References: <4211ctgvusgcma0c6ok1cpmjou98lv9714@4ax.com> <8J2w6.3336$SB2.606281@ruti.visi.com> Message-ID: In article <8J2w6.3336$SB2.606281 at ruti.visi.com>, Grant Edwards wrote: . . . >Tcl > Flaws: > Only one data type: string > Incomprehensible quoting semantics > Roll-your-own control flow > No OO support > Strengths: > Tk integration > Lots of code out there > Roll-your-own control flow > >Python: > Flaws: > No roll-your-own control flow > Lots of GUI options > Strengths: > No roll-your-own control flow > Good OO support > Lots of GUI options > Simple syntax and semantics > Library modules > >>-Why do you prefer the one you use over the other? > >I gave up on Tcl after one program and switch to Scheme. Now I >use Python a lot more than Scheme. > >[I don't know much about eithr on Win32, so I'll let others >answer those questions.] . . . Grant of course does fine on his own. I think a few footnotes are pertinent. We mention in that Grant's footnote alludes to the single most crucial difference between Tcl and Python: the latter's current support of and integration with Win* is far superior. Grant is absolutely right in repeating that, in case after case, the same characteristic has both advantages and disadvantages. To further complexify his calculations, I'll testify that many Tcl and Python application developers aren't even aware of the control-flow philosophical differences between the two languages. Many programmers spend their time with rather conventional procedural or OO concerns, and are quite indifferent to metaprogramma- bility or introspective capabilities. I respect that Grant doesn't like Tcl quoting. There are, however, equally sane people who applaud it. It seems to be an ... ambiguous distinction. Among the benefits Tcl has over Python that are easiest to appreciate by the mass of application developers are the former's [exec], [open], and [socket]. They allow for succinct, portable interprocess communication that's simply not as polished (at that level) in Python. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From tim.one at home.com Sat Mar 3 04:54:01 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Mar 2001 04:54:01 -0500 Subject: Bug in Py_Finalize() ? In-Reply-To: <3aa1889e.2213634@news.newsguy.com> Message-ID: [Owen F. Ransen, getting Fatal Python error: UNREF invalid object when running for (UINT i = 0 ; i < 10 ; i++) { Py_Initialize(); Py_Finalize() ; } ] [Tim] > Please try this again with the lastest CVS version, or pick up > 2.1b1 (we'll be releasing that later today). Something "very much like > this" got fixed last month; ... [Owen] > Thanks for the pointer. > > Now I am going to reveal my ignorance, what does CVS stand for? The latest development version of the Python source code is maintained under CVS-- a popular source-control system --and available to the public at SourceForge. Doesn't matter unless you're willing to compile Python from source. Else pick up a 2.1b1 installer (you said you were running on Windows) and just try it: http://www.python.org/2.1/ You didn't give a complete program so it's impossible for me to say whether your problem is fixed. I did put your loop in an extension module and boosted the loop limit to 1000. No problem under Windows Python 2.1b1, under either release or debug builds. From slhath at home.com Sun Mar 4 11:46:09 2001 From: slhath at home.com (Scott Hathaway) Date: Sun, 04 Mar 2001 16:46:09 GMT Subject: sql query results to xml Message-ID: I want to create a tool that will take a valid SQL query and return the results as valid xml. Before I reinvent the wheel, is there a python class or code snippet that someone has that does this already? Thanks, Scott From xu.20 at nd.edu Mon Mar 26 16:58:32 2001 From: xu.20 at nd.edu (C. S. Xu) Date: Mon, 26 Mar 2001 16:58:32 -0500 Subject: Biggest float number? Message-ID: <3ABFBB88.E718B2D@nd.edu> Hi all, It seems the biggest floating number in Python can be: 2.**1024 - 1. which is about 1.8E308. Is there any way to get bigger value than this, just like long intergers almost have no limits? Thanks in advance for any replies. xcs From morelli at alpha.cerm.unifi.it Thu Mar 8 06:31:06 2001 From: morelli at alpha.cerm.unifi.it (Morelli Enrico) Date: Thu, 8 Mar 2001 10:31:06 -0100 Subject: cdrecord output capture Message-ID: Dear all, I am a new user of python. I trying to write a small python program under linux to create and save ISO files using mkisofs, cdrecord and dialog. I'm able to capture mkisofs output using popen2, but I'm not able to do the same thing with cdrecord. I had see the source code of eroaster (graphic python program that use mkisofs and cdrecord) but this program use a difficult way for me, I don't understand all code. Someone explain me what I must to do to capture the cdrecord output? Thanks in advance -- \\\ // (0 0) ------------------------ooO-(_)-Ooo------------------------------- #============================#=====================================# | ENRICO MORELLI | email: morelli at CERM.UNIFI.IT | | * * * * | phone: +39 055 4574269 | | University of Florence | fax : +39 055 4574253 | | CERM - via Sacconi, 6 - 50019 Sesto Fiorentino (FI) - ITALY | #============================#=====================================# From mertz at gnosis.cx Sat Mar 3 02:20:51 2001 From: mertz at gnosis.cx (Dr. David Mertz) Date: Sat, 03 Mar 2001 02:20:51 -0500 Subject: cataloging words in text file (fwd) Message-ID: Stephen Boulet wrote: | I remember this homework assignment for my data structures (c++) | class: read in a large file, and create a data structure containing | every word in the file and the number of times it appears. Funny you should ask. I just finished a program called 'indexer.py' that does EXACTLY this, and then uses the data structure (a dictionary) to perform searches. Find the program at: http://gnosis.cx/download/indexer.py I wrote this module as part of my _Charming Python_ series of articles, and there is an article discussing the design of the module. However, I have been a bit naughty lately in putting up articles to my own site (thanks all my readers) before IBM gets around to publishing them (they pay for them, so should have some rights here[*]). So I don't actually have the accompanying article on my website now. If anyone begs me for it in email, I'll cough it up individually... otherwise, wait a couple weeks (and read it at IBM developerWorks, especially... and excellent site for fine programming information). That said, the above module itself is rather extensively documented... and I very much welcome feedback. Yours, David... ------------------------------------------------------------------------ [*] Actually... I'm not sure they *should* have rights. Information wants to be free, and everything should be available to everyone all the time, gratis. After the revolution, writers, programmers, artists, and us whole merry lot will be paid endowments, and all intellectual creation will be part of the common lot of humankind... and so on... But for now, IBM pays me money, and I agree to a variety of conditions about publications, legal restrictions, and stuff like that. P.S. Strained joke along these lines can be found at gnosis.cx/. From tim.one at home.com Thu Mar 29 18:28:52 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 29 Mar 2001 18:28:52 -0500 Subject: diff lists In-Reply-To: Message-ID: [Michael Hudson] > Tangentially, does anyone know of any good algorithms for "edit > distance" between two sequences? E.g. if I have > > "abcdef" > > and want to get to > > "abQUACKcde" > > I want to get the answer back "insert 'QUACK' at position 3 and delete > a character at position 11". See std library module difflib.py (new in 2.1). This packages the SequenceMatcher class from the heart of the Tools/scripts/ndiff.py tool for easy reuse. Python 2.1b2 (#12, Mar 23 2001, 14:01:30) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.8 -- press F1 for help >>> import difflib >>> a = "abcdef" >>> b = "abQUACKcde" >>> m = difflib.SequenceMatcher(None, a, b) >>> for tag, i1, i2, j1, j2 in m.get_opcodes(): print ("%7s a[%d:%d] (%s) b[%d:%d] (%s)" % (tag, i1, i2, a[i1:i2], j1, j2, b[j1:j2])) equal a[0:2] (ab) b[0:2] (ab) insert a[2:2] () b[2:7] (QUACK) equal a[2:5] (cde) b[7:10] (cde) delete a[5:6] (f) b[10:10] () >>> It does not attempt to produce minimal edit sequences, but does attempt to produce edit sequences that "look right" to people (read the comments in ndiff.py for more on that). > "Good" means "pretty quick", here. For suitably large values of "pretty", sure . not-for-all-though-ly y'rs - tim From qrczak at knm.org.pl Tue Mar 13 17:15:25 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 13 Mar 2001 22:15:25 GMT Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> <20010312170356.B3513@better.net> <984486395.407379@newsmaster-04.atnet.at> <984518199.127140@newsmaster-04.atnet.at> Message-ID: Tue, 13 Mar 2001 22:11:53 +0100, Werner Schiendl pisze: > 15 to 16 digits are the precision double values will provide. So > rounding to 15 digits will normally display the value you have > entered. There is however no guarantee that your value is displayed > exactly. That's why I am asking for not fixing the number of digits but having this functionality: def most_useful_str_or_repr_variant(x): s = str(x) if float(s) == x: return s return repr(x) -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From NoSpam at NoSpam.com Fri Mar 2 18:40:52 2001 From: NoSpam at NoSpam.com (Tom) Date: Fri, 02 Mar 2001 23:40:52 GMT Subject: Unresolved symbols in MSVCRT.DLL when running a py2exe packaged program. References: Message-ID: <8cWn6.16791$UZ4.4554807@news4.rdc1.on.home.com> "Tim Peters" wrote in message news:mailman.983571904.9828.python-list at python.org... > [Tom, on System File Protection in recent flavors of Windows] > > I didn't mean to suggest 'fooling' it - I agree that safeguards > > like SFP are needed - I meant that one had to do it according to > > the rules. > > What rules? Only MS can replace system files now -- there is no provision > for "one" to *ever* do it anymore, if one != MS (no API, no magic dance, not > even an option to turn SFP off). One of the links I posted before suggests > that they *may* make an exception for developers of new hardware. The API that I was referring to was the Setup API (see Platform SDK). I must admit that I've only used it for replacing drivers (I used InstallShield for replacing DLL's), but I had thought it could be used for replacing DLL's. Tom. > > As for not being able to update the DLL's, this would be a problem. If a > > service pack for VC6 updates the MFC or CRT DLL's (which SP's usually do), > > and you ship an app build with it, then you must update these DLL's on your > > target system. Perhaps this is where the new ability to run 'personal' > > instances of DLL's comes in: ie. you can't update the system32 version the > > DLL, but you can install your own personal copy. > > That's my understanding, yes. As one of the links pointed out, .inf files > don't have conditionals, so MS expects you to ship different infs for > different MS OSes now (depending on whether you can or cannot exploit private > system DLLs on the OS in question). > > Python hasn't needed to deal with that yet. Wrestling with Windows esoterica > isn't really a passion of mine, so I'm not looking forward to the day when it > must. > > luckily-i'm-told-everyone-will-be-on-linux-then-anyway-ly y'rs - tim > > From mrq at for.mat.bham.ac.uk Fri Mar 30 04:50:54 2001 From: mrq at for.mat.bham.ac.uk (Martyn Quick) Date: Fri, 30 Mar 2001 10:50:54 +0100 Subject: BLT extensions with BeOpen Python 2.0 In-Reply-To: References: Message-ID: On Thu, 29 Mar 2001, John J. Lee wrote: > On Thu, 29 Mar 2001, Martyn Quick wrote: > > > I've been trying to install the BLT extensions for Tk into my BeOpen > > distribution of Python 2.0. However, it seems that the directory > > structure that the BLT distribution expects (see www.tcltk.com/blt) is > > different to that provided by the python distribution. > > > > Has anyone succeeded in installing BLT with the distribution, or do I need > > to switch distributions? (and to which one?) > > I'm pretty sure I had BLT working with BeOpen 2.0 at some point, at least > on linux, and perhaps windows too. I couldn't tell you exactly where I > put it, though. Make sure you have the right BLT version for the tcl that > comes with python 2.0 . This reply has pointed out to me that I ought to say what platform I was using. I'm running on Windows 95, so downloaded the precompiled version of BLT for Tcl8.3 (which is the version in BeOpen 2.0). Martyn -------------------------------------------------------- Dr. Martyn Quick (Research Fellow in Pure Mathematics) University of Birmingham, Edgbaston, Birmingham, UK. http://www.mat.bham.ac.uk/M.R.Quick From mcfletch at home.com Sat Mar 17 22:01:10 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Sat, 17 Mar 2001 22:01:10 -0500 Subject: module to do euler path and topological sorting in python In-Reply-To: Message-ID: <000001c0af57$b005a770$a9807018@cr706570a> Not sure what a euler path is, but here's two algos that do topological sorting. Guts of the second (toposort) are from Tim Peters, first (sort) is one I built myself, so expect it to have problems :) . I actually built the second after the first without realising I was creating a toposort (I was trying to determine parallelism in a "content compiler"), it's just included for posterity :o) . Enjoy, Mike 8<______________ toposort.py _________________ class RecursionError( OverflowError, ValueError ): '''Unable to calculate result because of recursive structure''' def sort(nodes, routes, noRecursion=1): '''Passed a list of node IDs and a list of source,dest ID routes attempt to create a list of stages where each sub list is one stage in a process. ''' children, parents = _buildChildrenLists(routes) # first stage is those nodes # having no incoming routes... stage = [] stages = [stage] taken = [] for node in nodes: if (not parents.get(node)): stage.append (node) if nodes and not stage: # there is no element which does not depend on # some other element!!! stage.append( nodes[0]) taken.extend( stage ) nodes = filter ( lambda x, l=stage: x not in l, nodes ) while nodes: previousStageChildren = [] nodelen = len(nodes) # second stage are those nodes # which are direct children of the first stage for node in stage: for child in children.get (node, []): if child not in previousStageChildren and child not in taken: previousStageChildren.append(child) elif child in taken and noRecursion: raise RecursionError( (child, node) ) # unless they are children of other direct children... # TODO, actually do that... stage = previousStageChildren removes = [] for current in stage: currentParents = parents.get( current, [] ) for parent in currentParents: if parent in stage and parent != current: # might wind up removing current... if not current in parents.get(parent, []): # is not mutually dependent... removes.append( current ) for remove in removes: while remove in stage: stage.remove( remove ) stages.append( stage) taken.extend( stage ) nodes = filter ( lambda x, l=stage: x not in l, nodes ) if nodelen == len(nodes): if noRecursion: raise RecursionError( nodes ) else: stages.append( nodes[:] ) nodes = [] return stages def _buildChildrenLists (routes): childrenTable = {} parentTable = {} for sourceID,destinationID in routes: currentChildren = childrenTable.get( sourceID, []) currentParents = parentTable.get( destinationID, []) if not destinationID in currentChildren: currentChildren.append ( destinationID) if not sourceID in currentParents: currentParents.append ( sourceID) childrenTable[sourceID] = currentChildren parentTable[destinationID] = currentParents return childrenTable, parentTable def toposort (nodes, routes, noRecursion=1): '''Topological sort from Tim Peters, fairly efficient in comparison (it seems).''' #first calculate the recursion depth dependencies = {} inversedependencies = {} if not nodes: return [] if not routes: return [nodes] for node in nodes: dependencies[ node ] = (0, node) inversedependencies[ node ] = [] for depended, depends in routes: # is it a null rule try: newdependencylevel, object = dependencies.get ( depends, (0, depends)) except TypeError: print depends raise dependencies[ depends ] = (newdependencylevel + 1, depends) # "dependency (existence) of depended-on" newdependencylevel,object = dependencies.get ( depended, (0, depended) ) dependencies[ depended ] = (newdependencylevel, depended) # Inverse dependency set up dependencieslist = inversedependencies.get ( depended, []) dependencieslist.append (depends) inversedependencies[depended] = dependencieslist ### Now we do the actual sorting # The first task is to create the sortable # list of dependency-levels sortinglist = dependencies.values() sortinglist.sort () output = [] while sortinglist: deletelist = [] generation = [] output.append( generation) while sortinglist and sortinglist[0][0] == 0: number, object = sortinglist[0] generation.append ( object ) deletelist.append( object ) for inverse in inversedependencies.get(object, () ): try: oldcount, inverse = dependencies [ inverse] if oldcount > 0: # will be dealt with on later pass dependencies [ inverse] = (oldcount-1, inverse) else: # will be dealt with on this pass, # so needs not to be in the sorting list next time deletelist.append( inverse ) # just in case a loop comes through inversedependencies[object] = [] except KeyError: # dealing with a recursion-breaking run... pass del sortinglist [0] # if no elements could be deleted, then # there is something which depends upon itself if not deletelist: if noRecursion: raise RecursionError( sortinglist ) else: # hack so that something gets deleted... ## import pdb ## pdb.set_trace() dependencies[sortinglist[0][1]] = (0,sortinglist[0][1]) # delete the items that were dealt with for item in deletelist: try: del dependencies [ item ] except KeyError: pass # need to recreate the sortinglist sortinglist = dependencies.values() if not generation: output.remove( generation ) sortinglist.sort () return output if __name__ == "__main__": import pprint, traceback nodes= [ 0,1,2,3,4,5 ] testingValues = [ [ (0,1),(1,2),(2,3),(3,4),(4,5)], [ (0,1),(0,2),(1,2),(3,4),(4,5)], [ (0,1), (0,2), (0,2), (2,4), (2,5), (3,2), (0,3)], [ (0,1), # 3-element cycle test, no orphan nodes (1,2), (2,0), (2,4), (2,5), (3,2), (0,3)], [ (0,1), (1,1), (1,1), (1,4), (1,5), (1,2), (3,1), (2,1), (2,0)], [ (0,1), (1,0), (0,2), (0,3), ], [ (0,1), (1,0), (0,2), (3,1), ], ] print 'sort, no recursion allowed' for index in range(len(testingValues)): ## print ' %s -- %s'%( index, testingValues[index]) try: print ' ', sort( nodes, testingValues[index] ) except: print 'exception raised' print 'toposort, no recursion allowed' for index in range(len(testingValues)): ## print ' %s -- %s'%( index, testingValues[index]) try: print ' ', toposort( nodes, testingValues[index] ) except: print 'exception raised' print 'sort, recursion allowed' for index in range(len(testingValues)): ## print ' %s -- %s'%( index, testingValues[index]) try: print ' ', sort( nodes, testingValues[index],0 ) except: print 'exception raised' print 'toposort, recursion allowed' for index in range(len(testingValues)): ## print ' %s -- %s'%( index, testingValues[index]) try: print ' ', toposort( nodes, testingValues[index],0 ) except: print 'exception raised' -----Original Message----- From: cyberian bear [mailto:cyberian_bear at hotmail.com] Sent: Saturday, March 17, 2001 8:08 PM To: python-list at python.org Subject: module to do euler path and topological sorting in python can anyone suggest where i can find the modules which would do those two things. I have found a website which had a link to topological sorting but it says that access is forbidden. www.python.org doesn't have any matching reuslts. thanx cb -- http://mail.python.org/mailman/listinfo/python-list From loewis at informatik.hu-berlin.de Thu Mar 8 05:30:06 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 08 Mar 2001 11:30:06 +0100 Subject: LONG_BIT error when compiling python2.0 References: Message-ID: Enrico Spinielli writes: > I am trying to install python2.0 on RedHat 7.0 Linux. [...] > Any idea about a possible solution? > In the meanwhile I'll install gcc2.96-69 and retry... Upgrade glibc. When doing so, complain to Redhat for shipping prerelease glibc snapshots with Redhat 7. Regards, Martin From aleaxit at yahoo.com Fri Mar 30 07:42:27 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 30 Mar 2001 14:42:27 +0200 Subject: PEP 245: Python interfaces References: <99o9g4$nh3$0@216.39.170.247> Message-ID: <9a1v0r030up@news1.newsguy.com> "Carlos Alberto Reis Ribeiro" wrote in message news:mailman.985899166.8262.python-list at python.org... [snip] > For example, there is multiple inheritance. I know very few legitimate > cases where it is a good idea. Composition usually attains the same > results, but with less side effects and much better control over the > process. Interfaces are exceptionally well suited for this kind of construct. Multiple inheritance of implementation (mixins) is a highly convenient and practical programming technique; dunno what you mean by "legitimate" cases in this context? Implementation by one object of multiple interfaces (which is also expressed as multiple-inheritance in C++) is more than just convenient -- it's a must to enable most decent modeling techniques ("not relying on absolute taxonomy" is what I mean by "decent" here:-). The two issues are quite separate, of course. Alex From bill-bell at bill-bell.hamilton.on.ca Fri Mar 23 13:11:45 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Fri, 23 Mar 2001 13:11:45 -0500 Subject: TimeoutSocket exceptions handling In-Reply-To: <985369104.693.34698.l7@yahoogroups.com> Message-ID: <3ABB4B91.23301.370A1C@localhost> I'm new to Python. In an effort to understand why I can't get hold of an exception from O'Malley's TimeoutSocket I wrote the following two teeny-tiny scripts. Script2.py: import Script1 try: myFunc() except myErr, (reason): print 'myErr trapped: ', reason Script1.py: class myErr ( Exception ): pass def myFunc(): raise myErr ( 'myErr reason' ) Couldn't be much simpler, huh? And they even seem to work. Timeoutsocket.py (looks fantastic, thanks Alex Martelli), contains the following: ... class Timeout(Exception): pass ... raise Timeout("Attempted connect to %s timed out." % str(addr) ) My code that uses TimeoutSocket has try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((self.whoisserver, 43)) s.send("%s\n" % self.domain) page = "" while 1: data = s.recv(8196) if not data: break page = page + data pass s.close() except Timeout, (reason): raise 'TimedOut', 'Whois server timedout' If my sanity has not departed me this combination appears similar to my would-be autodidactic efforts. However, not so: Python says "NameError: There is no variable named 'Timeout'" for my 'except' statement. I'd appreciate a word of advice, or a pointer to code that works. Bill From paulp at ActiveState.com Mon Mar 12 20:45:51 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 12 Mar 2001 17:45:51 -0800 Subject: FOLLOWUPS!!!!!!! References: Message-ID: <3AAD7BCF.4D4F69B7@ActiveState.com> Please keep follow-ups to just types-sig. I'm very sorry I cross-posted in the beginning and I apologize to everyone on multiple lists. I did direct people to follow up only to types-sig but I should have used a header....or separate posts! -- Python: Programming the way Guido indented it. - (originated with Skip Montanaro?) From gerhard.nospam at bigfoot.de Tue Mar 6 01:29:05 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Tue, 6 Mar 2001 07:29:05 +0100 Subject: Python & mySQL References: Message-ID: On Mon, 05 Mar 2001 18:16:03 GMT, Colin Meeks wrote: >Does anybody have any pointers for integrating mySQL with Python. I've been >using Python a while and am looking to develop a web backend using Python >with mySQL. My site is hosted by a Linux based ISP who has both Python and >mySQL but they don't currently have a link between the two. I'm using >Windows2000 as my development base, so I want something that is usuable on >both, so it's easier for me to track any problems. You'll need the MySQLdb python module. A prebuilt Windows version is available (at my homepage, see the sig). If your ISP isn't so friendly and won't install the MySQL module for you, you can still do that yourself if you have the correct binary version. For Linux, you should only need to copy the following files in your cgi-bin directory: CompatMysqldb.py CompatMysqldb.pyc MySQLdb.py MySQLdb.pyc _mysql.so I have done this successfully under FreeBSD and SunOS, where the ISP were not flexible enough to install a Python module. > >Ideally I want something that doesn't involved recompiling Python if that's >possible, You should never need to recompile Python for an extension module. >as i want the installation to be as straightforward for my ISP and >of course me :-) As simple as python setup.py build python setup.py install ? Gerhard -- mail: gerhard bigfoot de web: http://highqualdev.com From carribeiro at yahoo.com Sun Mar 18 21:02:56 2001 From: carribeiro at yahoo.com (Carlos Ribeiro) Date: Sun, 18 Mar 2001 23:02:56 -0300 Subject: Who am I: can a class instance determine its own name? Message-ID: <5.0.2.1.0.20010318225613.022cc670@pop.mail.yahoo.com> Alex Martelli wrote: >(My dream is actually of a collection of bits in an attribute... While I agree on the *principle*, I disagree on the details. Thinking about this as a bitmap is an artifact of historic optimization techniques. Worse - the performance gain is highly improbable in scripting languages like Python, and should be negligibe in most cases. Any exception to this probably deserve to be implemented in C or some similar, highly optimized compiled language. OTOH, having a set of attributes would make the code more readable and extensible. (the set of attributes is itself in a dictionary and would also be subject to the same control). ------------------------------- Carlos Ribeiro cribeiro-AT-mail-inet-com-br _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From bowman at montana.com Sun Mar 11 08:29:29 2001 From: bowman at montana.com (bowman) Date: Sun, 11 Mar 2001 06:29:29 -0700 Subject: "!=" is bad form. Re: sorry....never mind References: Message-ID: J?rgen A. Erhard wrote in message > > So when can we expect `||' and `&&' to replace `or' and `and'? > Shouldn't we `Beware of the slippery slope'? only if 'or' has lower precedence than '||' to help in evaluating 'die' expressions. From ransen_spam_me_not at nemo.it Fri Mar 2 13:40:37 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Fri, 02 Mar 2001 18:40:37 GMT Subject: Bug in Py_Finalize() ? References: <3a9f636d.2908314@news.newsguy.com> Message-ID: <3aa0c6e5.809467@news.newsguy.com> I tried to report this bug to sorgeforge, signed up, but it kept on giving me page not found errors after I logged in.... On Fri, 02 Mar 2001 09:32:12 GMT, ransen_spam_me_not at nemo.it (Owen F. Ransen) wrote: >Trying to find a bug in my C extension I ended up writing >this loop: > > for (UINT i = 0 ; i < 10 ; i++) { > Py_Initialize(); > Py_Finalize() ; > } > >which crashes Python when i=8 with the message: >Windows 32, VC++ program. > >Fatal Python error: UNREF invalid object > >My understanding is that I can use Py_Initialize() and >Py_Finalize() in pairs to free up memory and to start >with a clean interpreter each time I need it. And that >is why I'd like to use Py_Finalise.... -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From pearu at cens.ioc.ee Mon Mar 5 10:17:38 2001 From: pearu at cens.ioc.ee (Pearu Peterson) Date: Mon, 5 Mar 2001 17:17:38 +0200 Subject: Name of the Script In-Reply-To: References: <20010304.185354.2114937732.8277@localhost.localdomain> Message-ID: On Mon, 5 Mar 2001, Paul Moore wrote: > > This doesn't always include full pathname information. On Windows, > > --- a.py --- > import sys > print sys.argv[0] > --- > > python a.py > > just prints "a.py". Is there a way of getting the *full* script name. > For example, so that the script can locate a data file which is held > in the same directory as the script itself. --- a.py --- import os,sys print os.path.abspath(sys.argv[0]) --- might be what you want. Pearu From claird at starbase.neosoft.com Thu Mar 22 17:28:50 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 22 Mar 2001 16:28:50 -0600 Subject: Why Python/Jython? References: <99cl9e$b2b$1@Merlin.et.bocholt.fh-gelsenkirchen.de> <1901D50DC30D30E4.16551C1AB0FB4363.C0D72E208759F8A7@lp.airnews.net> <99dkg301894@news1.newsguy.com> Message-ID: In article <99dkg301894 at news1.newsguy.com>, Alex Martelli wrote: >"Cameron Laird" wrote in message >news:1901D50DC30D30E4.16551C1AB0FB4363.C0D72E208759F8A7 at lp.airnews.net... > [snip] >> meaningful. People do NOT start learning >> Java lightly; it often takes hours just to >> install and configure a minimal JDK, let > >*blink* -- I'm hardly a Java-ite, myself, but >"install and configure a minimal JDK" I would >estimate as typically a 10-minute job (on, say, >NT -- is it an order of magnitude harder on, >say, Linux?!). Maybe I misunderstand what >you mean...? > >I'll underwrite the rest of your post (haven't >had occasion to use Jython 'in anger', yet, but >from just playing with it it does seem a great >way to exploit the huge libraries available in >and for Java), but this point seems strange. > > >Alex > > > As Andrew mentioned nearby, as confusing as it can be for a newcomer to Python to figure out who and where the players are, Java manages to dwarf this. Java is MUCH less compat- ible between versions, Java downloads are much, MUCH bigger, and Sun makes it (unless something's changed recently) a serious nuisance to locate binaries for anything other than Win*. Those little annoyances do indeed multiply out to an order of magnitude, in many common situations ("Oh, you only have 128 Mb of main memory? Too bad; start over.") (my main machine continues to do fine with 32 Mb, by the way). -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From sdm7g at virginia.edu Tue Mar 13 17:50:33 2001 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Tue, 13 Mar 2001 17:50:33 -0500 (EST) Subject: This math scares me In-Reply-To: Message-ID: On Tue, 13 Mar 2001, Grant Edwards wrote: > In article , John W. Baxter wrote: > >In article <984518199.127140 at newsmaster-04.atnet.at>, > > "Werner Schiendl" wrote: > > > >Bill Gates got this right in the early days, delivering two > >Basic interpreters: binary floating point for speed, and > >decimal floating point for money and such. > > I don't know if you can credit Gates with doing anything other > than following the pack. Back when I first started doing > software (CP/M 1.7), all language packages for "personal" > computers came with both BCD and binary FP math libraries so > you could do exact monetary calculations if you wanted. Exactly what pack do you believe Gates was following ? You do know (don't you?) that Bill's BASIC predates not just MS-DOS (which microsoft bought from another company) but CP/M and just about any other "PC" software (and most of the hardware) since the first version was written to run on the Altair computer -- which was the first microprocessor based personal computer. ( I think you probably had to boost the memory up to 4K to get Basic to run. ) > Of course we'd never imagined we'd ever see hardware FP and BCD > libraries were only marginally slower than binary ones. Now > that FP is usually in hardware, BCD FP (or fixed point) will be > pretty slow by comparison. -- Steve Majewski From Simon.Budig at unix-ag.org Fri Mar 16 18:26:42 2001 From: Simon.Budig at unix-ag.org (Simon Budig) Date: 17 Mar 2001 00:26:42 +0100 Subject: list.sort(cmpfunc) question References: <98t9dq$qvu$1@panix6.panix.com> Message-ID: <3ab2a132@si-nic.hrz.uni-siegen.de> Aahz Maruch wrote: > In article , > Harri Pasanen wrote: >> >>The list.sort(cmp) docs for Python 2.0 state: >> >> The sort() method takes an optional argument specifying a >> comparison function of two arguments (list items) which should >> return -1, 0 or 1 depending on whether the first argument is >> considered smaller than, equal to, or larger than the second >> argument. > > Note that "should" carefully. The current implementation of sort() only > checks for a negative value, but that's not a behavior that should be > relied on in your coding. You can be sure that any anamolies in the > behavior of cmp() will be fixed if the sort() algorithm ever changes. As a related question since I did not find it in the documentation: Is the sort-function guaranteed to be stable? Does it keep the order, when cmpfunc returns 0 for a pair of items? Thanks, Simon -- Simon.Budig at unix-ag.org http://www.home.unix-ag.org/simon/ From jwbnews at scandaroon.com Fri Mar 2 17:50:22 2001 From: jwbnews at scandaroon.com (John W. Baxter) Date: Fri, 02 Mar 2001 14:50:22 -0800 Subject: gah! I hate the new string syntax References: <97ohh2$polt0$1@ID-77331.news.dfncis.de> <97opsb$nhu$1@nntp6.u.washington.edu> Message-ID: In article <97opsb$nhu$1 at nntp6.u.washington.edu>, Donn Cave wrote: > I bet when people see ";".join(...) with fresh eyes, they still > find it strained. This is not about the old school vs. the new, > it's a serious question of how people understand computer programming > languages. Is it like natural language? Can we think about it in > sort of mathematical terms, like symmetry etc.? Does everyone handle > it basically the same way? Take two APLs, or a liberal dose of John Iverson, and all will be well. ;-) Fortunately, it's not the only way to join. --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From gregor at mediasupervision.de Thu Mar 8 10:14:15 2001 From: gregor at mediasupervision.de (Gregor Hoffleit) Date: Thu, 8 Mar 2001 16:14:15 +0100 Subject: News from Python9!!! In-Reply-To: ; from tuttledon@hotmail.com on Thu, Mar 08, 2001 at 03:21:17AM +0000 References: Message-ID: <20010308161415.C30277@mediasupervision.de> On Thu, Mar 08, 2001 at 03:21:17AM +0000, Don Tuttle wrote: > 4)And a bugfix release of Python 2.0 has been released. It includes PPM > (Programmer's Package Manager ) to make finding and installing Python > modules simple. Shouldn't this read 'bugfix release of ActivePython 2.0' ? Gregor From ws-news at gmx.at Thu Mar 8 05:26:19 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Thu, 8 Mar 2001 11:26:19 +0100 Subject: learning C References: <983975751.18833@newsmaster-04.atnet.at> Message-ID: <984047460.29247@newsmaster-04.atnet.at> D-Man wrote in message news:mailman.984014483.6974.python-list at python.org... > On Thu, Mar 08, 2001 at 12:32:47AM +0000, Remco Gerlich wrote: > | Werner Schiendl wrote in comp.lang.python: > | > If it is not obsolete, it should be at least considered deprecated for new > | > projects. > | > | A baseless statement. There are many types of project for which C is still > | the best choice. For one thing, think embedded systems. > > C does have it strong points. After all, python is essentially a C > program. > And it will compile with a C++ compiler, I think this is in fact done. At least on Windows, where the MS-DEV environment is used, AFAIK. So I think, in common use C++ _did_ already replace C, whether you use the new features or not. Some platforms even allow C++ statements in Files ending in .c. Otherwise the same compiler is used, just with some internal things disabled to make it appear C. > | I can imagine something like Java deprecating C++, but C isn't going to go > | away soon. > > Java? I thought Python took care of that. > > ;-) > > -D > > From barry at digicool.com Mon Mar 12 18:15:15 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Mon, 12 Mar 2001 18:15:15 -0500 Subject: [Python-Dev] Revive the types sig? References: <15020.9404.557943.164934@w221.z064000254.bwi-md.dsl.cnc.net> <200103120711.AAA09711@localhost.localdomain> Message-ID: <15021.22659.616556.298360@anthem.wooz.org> >>>>> "UO" == Uche Ogbuji writes: UO> I know this isn't the types SIG and all, but since it has come UO> up here, I'd like to (once again) express my violent UO> disagreement with the efforts to add static typing to Python. UO> After this, I won't pursue the thread further here. Thank you Uche! I couldn't agree more, and will also try to follow your example, at least until we see much more concrete proposals from the types-sig. I just want to make a few comments for the record. First, it seemed to me that the greatest push for static type annotations at IPC9 was from the folks implementing Python on top of frameworks other than C. I know from my own experiences that there is the allure of improved performance, e.g. JPython, given type hints available to the compiler. While perhaps a laudable goal, this doesn't seem to be a stated top priority of Paul's. Second, if type annotations are to be seriously considered for inclusion in Python, I think we as a community need considerable experience with a working implementation. Yes, we need PEPs and specs and such, but we need something real and complete that we can play with, /without/ having to commit to its acceptance in mainstream Python. Therefore, I think it'll be very important for type annotation proponents to figure out a way to allow people to see and play with an implementation in an experimental way. This might mean an extensive set of patches, a la Stackless. After seeing and talking to Neil and Andrew about PTL and Quixote, I think there might be another way. It seems that their approach might serve as a framework for experimental Python syntaxes with minimal overhead. If I understand their work correctly, they have their own compiler which is built on Jeremy's tools, and which accepts a modified Python grammar, generating different but compatible bytecode sequences. E.g., their syntax has a "template" keyword approximately equivalent to "def" and they do something different with bare strings left on the stack. The key trick is that it all hooks together with an import hook so normal Python code doesn't need to know anything about the mechanics of PTL compilation. Given a homepage.ptl file, they just do an "import homepage" and this gets magically transformed into a .ptlc file and normal Python objects. If I've got this correct, it seems like it would be a powerful tool for playing with alternative Python syntaxes. Ideally, the same technique would allow the types-sig folks to create a working implementation that would require only the installation of an import hook. This would let them build their systems with type annotation and prove to the skeptical among us of their overwhelming benefit. Cheers, -Barry From michael at lindrum.de Tue Mar 13 17:02:18 2001 From: michael at lindrum.de (Michael Lindrum) Date: Tue, 13 Mar 2001 23:02:18 +0100 Subject: Python2C Message-ID: <3AAE98EA.2754A358@lindrum.de> I'm searching for the lib that is necessary to compile C-Code generated by Python2C. OS: SunOS Who knows where I can find it? From digitig at cix.co.uk Wed Mar 14 19:42:00 2001 From: digitig at cix.co.uk (Tim Rowe) Date: Thu, 15 Mar 2001 00:42 +0000 (GMT Standard Time) Subject: Magnitude of the wx* market (was: Python In A Nutshell - suggestions) References: Message-ID: In article , claird at starbase.neosoft.com (Cameron Laird) wrote: > In article <3AAA4FE3.B471B689 at northwestern.edu>, > Louis Luangkesorn wrote: > . > . > . > >And while I'm at it, one useful book to have would be on > wxWindows/wxPython. I see references to it in several places, and a > few intros on the web, but > . > . > . > This is an interesting point. It's typical in computer > book publishing that publishers want more than authors > can produce; roughly, someone like ORA would happily > print many more titles than they can find authors willing > and able to write. > > I happen to know, though, that several publishers have > rejected wxWindows proposals. > > I doubt, though, that there'd be much trouble making the > case that the subject deserves a chapter in a larger work. And the larger work in question is "Python Programming on Win32" by Mark Hammond & Andy Robinson, already published by ORA, so I doubt they'd be particularly interested in another! It doesn't have full documentation of the wxPython classes, though, just a tutorial introduction. Maybe the way to go is to get them to extend it in the next edition? From bsb at winnegan.de Sun Mar 18 18:06:30 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 19 Mar 2001 00:06:30 +0100 Subject: NOT A scope problem In-Reply-To: <993bar$7h5$1@news.chatlink.com> References: <993bar$7h5$1@news.chatlink.com> Message-ID: <8766h665jd.fsf@winnegan.de> "Luis Cortes" writes: > Hello, > > I have a piece of code that I think should work fine, but I believe that > I've hit a scope problem (Python 2.1b1). Does anyone out there have a hint > as to how to fix it?? This is definitively no scope problem, you are dealing only with local variables. You're simply not handling len(sys.argv)==4! > code: > > def getarguments(): > > box = ( 160, 120 ) > newgifname = 'new.gif' > gifname = '' > > if (len(sys.argv) < 4 ): > print 'usage: trans.py width height image.xxx newimage.gif' > sys.exit(0) > if (len(sys.argv) >= 4): > # program width, height, image.xxx, newimage.gif > box = ( int(sys.argv[1]), int(sys.argv[2]) ) > gifname = sys.argv[3] > if (len(sys.argv) >= 5 ): > newgifname = sys.argv[4] > > print box, gifname, newgifname > sys.exit(0) > return ( box, gifname, newgifname ) > > THE PROBLEM: when I have more than 3 arguments, the global variables do not > change to the correct variables, but instead print their default values. > Help! Just replace > with >= HTH Siggy -- Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/ ****** ceterum censeo javascriptum esse restrictam ******* From flognat at flognat.myip.org Fri Mar 16 04:19:45 2001 From: flognat at flognat.myip.org (Andrew Markebo) Date: 16 Mar 2001 10:19:45 +0100 Subject: Should I close after popen?? References: <98satl$1t8$0@216.39.151.169> Message-ID: / Donn Cave wrote: | [...] | For a moment there I was awfully confused, since Python won't | even try to run that code, but I see you're running an earlier | version, before 2.0. Ahh hmm yep.. the scripts are running in 1.5.2, so what I do is to remove the waits, (hmm are ther any possibility of doing something similar??? am I supposed to use select/poll?) Uhm how do I get the exit-code of stuff from popen? Looking at popen2 it forks and does waitpid.. Ahh well I suppse the right thing to do(TM) is to go popen2?? /Andy From tim.one at home.com Sun Mar 11 22:59:08 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 11 Mar 2001 22:59:08 -0500 Subject: Einstein's Riddle In-Reply-To: Message-ID: [Gregory Jorgensen] > The 2% that can solve it must be psychic or deranged. The riddle > as posed is not solvable. > ... > But only four types of pet are mentioned: dogs, birds, cats, horse. We > have no evidence that any of the five owns fish. > > More telling: how many people can't quickly determine that this puzzle is > unsolvable? It's a std feature of "advanced" IQ tests that the problem stmts are intentionally somewhat vague: part of what they're testing is whether you can come up with the most reasonable assumptions necessary to make the problem *interesting*. Since the problem statement here asked "Who owns the fish?", and the problem admits of a unique solution if you assume *someone* owns a fish, that's a more interesting assumption to make than to complain that the question is ill-defined; the ability to fill in gaps reasonably is as much a kind of intelligence as the ability to follow chains of reasoning. You could cover both cheeks by answering "if anyone owns a fish, it must be the German". Then again, you may prefer to complain that "on the left of" doesn't necessarily imply adjacent to; or that the problem statement never says that a person who "lives in" a house is also its "owner"; or etc etc. reading-a-question-as-trivial-is-best-reserved-for-saints-ly y'rs - tim From fgeiger at datec.at Wed Mar 28 01:57:47 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Wed, 28 Mar 2001 08:57:47 +0200 Subject: wxPython: How to get a child by name? References: <99qpce$ljk$1@newsreaderg1.core.theplanet.net> Message-ID: <99s26k$uh3$1@newsreaderm1.core.theplanet.net> Hi Robin, thanks for your comprehensive response! Yet these are my first steps with wxDesigner and what you told e was definitly what I was looking for. Though, I saw this Get button right in front of my eyes... Anyway, all works fine now! Thanks a lot and best regards Franz "Robin Dunn" wrote in message news:w88w6.971$NAC.9240731 at news.randori.com... > > "Franz GEIGER" wrote in message > news:99qpce$ljk$1 at newsreaderg1.core.theplanet.net... > > I currently try to polish some of my apps with a GUI and decided to go for > > wxPython. > > > > I use wxDesigner for the layout. As it generates code after every change, > I > > named all the text controls and checkboxes etc. of the dialog hosting all > > those controls by applying SetName() to the controls. The Dialog is small, > > so I do not use validators yet. > > > > To get a text control of the dialog I thought I could write > > theValue = self.FindWindowByName("tcSurname").GetValue(). > > This raises an exception, because the return value is of type wxWindowPtr > > which does not have such a method. > > ... > > > For a "quick" hack in a MSVC project I would downcast the returned pointer > > of GetDlgCtrl() to be able to call the subclassed object's methods. But > how > > do I proceed here? > > > You're on the right track, you're looking for wxPyTypeCast which takes a > shadow object and converts the swigified pointer within it to a different > type and wraps a new shadow object around it of the new type. There are > some comments about it in wx.py. (I'm making some changes soon that will > hopefully let me finally turn this hack into a no-op...) > > But since you are using wxDesigner you could have saved yourself a bunch of > work and let it generate some "getters" for you. Click on the Add Python > Source button to add a new sourcefile to your project, then double click the > filename under Python sources in the tree view to open the file. Once there > you can add classes that create and use the specific forms you've designed, > and also add to the class event handlers and getters for the fields on the > form. I usually end up changing a lot of the code that it generates for the > __init__ method but that's okay since it never regenerates this file, only > adds to it. For the getters it makes code like this: > > def GetLoginBitmap(self): > return wxPyTypeCast( self.FindWindowById(ID_LOGINBITMAP), > "wxStaticBitmap" ) > > def GetPasswd(self): > return wxPyTypeCast( self.FindWindowById(ID_PASSWD), "wxTextCtrl" ) > > def GetUsername(self): > return wxPyTypeCast( self.FindWindowById(ID_USERNAME), > "wxTextCtrl" ) > > def GetURL(self): > return wxPyTypeCast( self.FindWindowById(ID_URL), "wxComboBox" ) > > You just need to be sure that you give each control a unique ID name. Once > you have the getters like this you can write code like: > > self.GetUsername().GetValue() > > > -- > Robin Dunn > Software Craftsman > robin at AllDunn.com Java give you jitters? > http://wxPython.org Relax with wxPython! > > > > From cfelling at iae.nl Wed Mar 28 15:17:59 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 28 Mar 2001 22:17:59 +0200 Subject: diff lists References: <3AC1DD4E.4BA7D421@aon.at> Message-ID: <99tgtn$ght$1@animus.fel.iae.nl> Oliver Vecernik wrote: > Hi, > I've got following two lists: > ['a', 'b', 'c', 'd', 'e', 'f'] > ['e', 'c', 'f'] > I'd like to have the result: > ['a', 'b', 'd'] > The list need not to be ordered. ['d', 'a', 'b'] will also be ok. What > is the most effective way to achive that result? Like proposed in an other thread, dicts are nice to uniquize lists, like: d = {} for k in a: d[k] = 1 for k in b: try: del d[k] except: d[k] = 1 c = d.keys() -- groetjes, carel From dbrueck at edgix.com Fri Mar 16 14:09:22 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Fri, 16 Mar 2001 12:09:22 -0700 Subject: Killing threads In-Reply-To: <20010316192738.A5550@freedom.puma-ag.com> Message-ID: > -----Original Message----- > From: python-list-admin at python.org > [mailto:python-list-admin at python.org]On Behalf Of Steve Purcell > > I have th program below. How does one go about kill a thread once > > started? Why is there no method for killing threads? I thought del > > would do it but obviously it doesn't. > > You should think about using a synchronisation mechanism > (threading.Condition, threading.Semaphore, Queue.Queue) so that the worker > thread can exit itself when told to do so by the main thread changing the > synchronising object. Or just a simple flag. Here's a class I use in designs that use work flows (work objects pulled off one queue, processed, and moved onto the next queue). If you just need an always-processing background thread you can eliminate all the stuff with the semaphore. Use it like this: q = WorkQueue(someHandlerFunc) q.Start() ... q.AddWork(work) q.AddWork(work) ... q.Stop() class WorkQueue: 'Waits (on a background thread) for work to appear on a queue and then dispatches it to a handler' def __init__(self, handler): self.handler = handler self.sem = threading.Semaphore(0) self.keepRunning = 0 self.isRunning = 0 self.workQ = [] def Start(self): 'Start processing' self.keepRunning = 1 if not self.isRunning: threading.Thread(target=self.__thread).start() def Stop(self): 'Shutdown' self.keepRunning = 0 self.sem.release() # Wake up the thread while self.isRunning: time.sleep(0.01) def AddWork(self, work): self.workQ.append(work) self.sem.release() # Wake up the thread def __thread(self): self.isRunning = 1 sem = self.sem workQ = self.workQ handler = self.handler try: while 1: sem.acquire() # Wait for work to appear if not self.keepRunning: break # Someone called Stop so quit work = workQ.pop(0) handler(work) finally: self.isRunning = 0 From cyjair at remove_this_to_mail_me_hitel.net Tue Mar 6 08:55:18 2001 From: cyjair at remove_this_to_mail_me_hitel.net (CY Jair) Date: Tue, 6 Mar 2001 22:55:18 +0900 Subject: IEEE 754 conformance in Python Message-ID: Python's floating-point numbers representations are done by C library, with 17 significant decimal digits preserved by the "%.17g" format in floatobject.c file. It is advertised to be conformant to IEEE 754 double precision standard. Java is advertised as fully conformant to IEEE 754 by Sun. However, when I compare the two, I'm getting a little bit doubtful. ------------------- [from Python 2.0 on Intel win 32] 1) 0.40000000000000005 == 0.4000000000000008 (,which are internally 3FD999999999999B) 2) repr(0.1) == "0.1000000000000001" [from Java and Jython on Intel win 32 and Sun Sparc] 1)0.40000000000000005 == 0.4000000000000001 (,which means internally 3FD999999999999B == 3FD999999999999A) 2)double to string or repr(0.1) == "0.1" ------------------- One more thing that makes me wonder is the way Python does rounding on floating-point numbers. In the IEEE standard, when rounding a "halfway" result to the nearest floating-point number, it picks the one that is even. But Python's way of "%.17g" doesn't seem to work that way. Could anyone shed an insight on this? cheers, Jair. From alex at shindich.com Wed Mar 7 03:15:32 2001 From: alex at shindich.com (Alex Shindich) Date: 7 Mar 2001 09:15:32 +0100 Subject: Static class methods References: <9825od0omq@news1.newsguy.com> Message-ID: <002201c0a6de$e00442a0$0300000a@acer> Hmm... I agree with you Alex that static methods are seldom needed in Python. I have lived without them for a long time. The need actually arose from using the local functions. Ever since the scoping behavior was fixed, the local functions became really useful. The problem however is that an instance method can have a local function, where a class cannot. This seems weird, since the level above the class-- the modules, can have functions. So can the level below-- the instance methods. But the classes cannot. If anything, the absence of static methods creates an inconsistency in the way functions are handled in different scopes. Regards, Alex Shindich visit http://www.shindich.com/sources -------------- next part -------------- An HTML attachment was scrubbed... URL: From d98aron at dtek.chalmers.se Mon Mar 5 15:36:12 2001 From: d98aron at dtek.chalmers.se (Fredrik Aronsson) Date: 5 Mar 2001 20:36:12 GMT Subject: Little problem with the "+" operator References: <983802310.155838463@news.t-online.de> <980i6q$crs$1@news.mathworks.com> Message-ID: <980tbs$gc$1@nyheter.chalmers.se> In article , Johann Hibschman writes: > Joshua Marshall writes: > >>> This is infinitely more sane than: > >>> % perl -e 'print 500 + "cool"' >>> 500 > >> Comparing Python to Perl here doesn't seem very fair. They're very >> different languages. In general, I'm surprised by the urgency with >> which people often jump to compare them. > > Well, Perl's the only language that I know of that lets you add 500 to > "cool" without an error. Well, I suppose tcl might. But it's still a > fairly safe inference that the original poster was coming from Perl. > Well, my first guess was Java. public class Test { public static void main(String[] args) { int variableOne = 500; String myVariable = variableOne + "cool"; System.out.println(myVariable); } } gere(1)> javac Test.java gere(2)> java Test 500cool Since I havn't found a % operator or a printf function, I like it. /Fredrik (Well, I have gotten to like Haskell a lot more after learning Java, wrote a complete parser+typechecker for a little language, 211 lines in Haskell ~2400 lines in Java (and I'm not counting the generated code.)) From syver at NOSPAMcyberwatcher.com Tue Mar 27 13:53:21 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Tue, 27 Mar 2001 20:53:21 +0200 Subject: Python scripts as Drop targets in Windows Explorer Message-ID: <99qogo$o6g$1@troll.powertech.no> Run the attached .reg file (or enter the contained information manually) to make python scripts behave like .exe in the way that you can drop files on them and the files will appear in the sys.argv list as command line arguments. Something to consider for the installer of the win32 port of python maybe? begin 666 python filedrop.reg M__Y7`&D`;@!D`&\`=P!S`" `4@!E`&<`:0!S`'0`<@!Y`" `10!D`&D`= !O M`'(`( !6`&4`<@!S`&D`;P!N`" `-0`N`# `, `-``H`#0`*`%L`2 !+`$4` M60!?`$,`3 !!`%,`4P!%`%,`7P!2`$\`3P!4`%P`4 !Y`'0`: !O`&X`+@!& M`&D`; !E`%P` !<`$0`<@!O`' `2 !A`&X`9 !L`&4` M<@!=``T`"@! `#T`(@![`#@`-@!#`#@`-@`W`#(`, `M`#0`,@!!`# `+0`Q M`# `-@`Y`"T`00`R`$4`. `M`# `. `P`# `,@!"`#,`, `S`# `.0!$`'T` *(@`-``H`#0`*```` ` end From syver at NOSPAMcyberwatcher.com Fri Mar 30 16:43:44 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Fri, 30 Mar 2001 23:43:44 +0200 Subject: Just in time debugging idioms Message-ID: <9a2uqk$oj5$1@troll.powertech.no> I am used to VC++ on Windows giving you the option to debug a program if it raises an assert. The closest I've come so far is like this: try: ........ except AssertionError: import pywin.debugger pywin.debugger.post_mortem(sys.exc_info()[2]) Is putting the above at the top of the call stack the python way to invoke the debugger on asserts, and other uncaught exceptions if you just place an open except statement there instead. Are there other debugging tecniques, idioms that people know of I'd be interested to hear. Especially the possibility to recompile and reload modules while stepping in the debugger would be nice. After all if you can do it in C++ (in a way that is) it should be possible anywhere else. From greg at cosc.canterbury.ac.nz Thu Mar 1 22:12:09 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 02 Mar 2001 16:12:09 +1300 Subject: define a new func on the fly? References: <3A9EE927.8744154E@troikanetworks.com> <3A9EF31B.4105F05C@troikanetworks.com> Message-ID: <3A9F0F89.5A3C6DE2@cosc.canterbury.ac.nz> Bruce Edge wrote: > > Now, how can I get it to create this function in the global namespace? exec "def xxx(): print \"xxxxxxxx\"" in globals() (By the way, you don't need the parentheses around the string to be exec'ed, because exec is a statement, not a function.) -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From aleaxit at yahoo.com Sun Mar 11 15:01:08 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 11 Mar 2001 21:01:08 +0100 Subject: Static typing (was Re: Java guy interested in Python) References: Message-ID: <98glhc02sga@news2.newsguy.com> "Tim Peters" wrote in message news:mailman.984334635.27345.python-list at python.org... > [Rainer Deyke] > > When I type 'int i;' in C++, what I really mean is "'i' behaves like an > > integer variable.". > > Since that's all "int i;" *can* mean in C++, seems tautological . Surely you're joking, Mister Peters? class int { public: int(const char*=0); ~int(); const char* data() const; }; int i; Isn't this perfectly legal C++, meaning something very different from "i behaves like an integer variable"...? int is no "reserved word", after all. Back to "built-in" int...: > > The limited range of type 'int' is part of its defined semantics, > > as is its fast performance. > > I expect you'll search in vain for a promise in the std that ints are "fast" > . 3.9.1.2 says "plain _int_s have the natural size suggested by the architecture of the execution environment", and it would take quite a sea-lawyer to assert that the 'natural' size in this context is any BUT the one providing the best performance on said execution-environment's architecture. But I think you are right that this is not QUITE a "promise":-). Alex From matt at mondoinfo.com Thu Mar 8 14:27:38 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Thu, 08 Mar 2001 19:27:38 GMT Subject: Another Tkinter question References: Message-ID: On Thu, 8 Mar 2001 12:08:47 -0600, dsavitsk wrote: >I have a small tkinter app that contains a (PMW) ScrolledFrame which >in turn has a grid of entry widgets (it sort of emulates a small >spread sheet). What I would like to do is add a new row of entry >widgets while the thing is running, and I'm not sure how to go about >this as I've already .packed them in. Tkinter is very dynamic: that your entry widgets have already been packed shouldn't make a difference. Try just adding more. If that doesn't work, I'd need to see your code to figure out what's up. >(Also, if anyone knows a better way to do this than tons of entry >widgets that would be great.) If the easy way works, I'd do it the easy way. Naturally, it's also possible to move the data around in a bunch of static widgets. That a bit annoying since you have to do your own scrolling. If you'd like to see some code of mine that does that, I'd be glad to point you at it. I've seen combinations of the two approaches done as well, but that was ugly. Regards, Matt From stepheb at comm.mot.com Fri Mar 2 16:36:14 2001 From: stepheb at comm.mot.com (Stephen Boulet) Date: Fri, 02 Mar 2001 15:36:14 -0600 Subject: cataloging words in text file Message-ID: <3AA0124E.74A39783@comm.mot.com> I remember this homework assignment for my data structures (c++) class: read in a large file, and create a data structure containing every word in the file and the number of times it appears. I was wondering how to do this in python. In c++ we had to do it with hash tables and b-trees. Can you do it with dictionaries in python, with the key as the word and the data the number of times it appears? If there's any documentation in this problem domain that people could point out to me I would appreciate it. What about if you had a bunch of objects, like say stars, with attributes like position (two coordinates), magnitude, color. If you had to sort a bunch of them at a time by attributes (say at most 10^3 of them), would using dictionaries be a good idea, or should you start looking at interfaces to, for example, mysql? Thanks. -- Stephen From costas at meezon.com Fri Mar 16 12:30:42 2001 From: costas at meezon.com (costas at meezon.com) Date: Fri, 16 Mar 2001 17:30:42 GMT Subject: Killing threads Message-ID: <3ab23ea7.328575630@News.CIS.DFN.DE> I have th program below. How does one go about kill a thread once started? Why is there no method for killing threads? I thought del would do it but obviously it doesn't. Also the print in the run method does not print until a sys.exit() is executed. # Note: You cannot CTRL-BREAK out of this program in PythonWin. # You have to kill it using the task manager. import threading import time import sys class wasteTime(threading.Thread): def run(self): # run forever while 1: print time.time() time.sleep(1) startTime=time.time() th=wasteTime() th.start() while 1: time.sleep(0.5) if time.time()>startTime+5: # I want to kill the th thread right here. del th sys.exit() TIA Costas From loewis at informatik.hu-berlin.de Fri Mar 2 11:07:06 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Mar 2001 17:07:06 +0100 Subject: WDDX in Python. References: <3a9faea1$1@news1> Message-ID: "Digital Hyakugei" writes: > Hello again. I've scoured the python.org site, used Google and have only had > hints that there _might_ be a WDDX parser/encoder for Python... If anyone > has a more concrete example, source code, link, anything, i'd really > appreciate it! PyXML 0.6.4 (and earlier) has a wddx library, see pyxml.sourceforge.net. Regards, Martin From gherman at darwin.in-berlin.de Mon Mar 19 03:21:50 2001 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Mon, 19 Mar 2001 09:21:50 +0100 Subject: How to find out about free space on a given drive? Message-ID: <3AB5C19E.FA40DDA9@darwin.in-berlin.de> Hi, is there a simple way (or any way at all) to find out for any given hard disk how much free space is left on that device? I looked into the os module, but either not hard enough or there is no such function. Of course, the ideal solution would be platform-independant, too... :) Regards, Dinu From objectway at divalsim.it Thu Mar 8 08:24:48 2001 From: objectway at divalsim.it (Nicola Musatti) Date: Thu, 08 Mar 2001 14:24:48 +0100 Subject: Can anyone recomend a good intoduction to C... References: <3aa366c6_2@nnrp1.news.uk.psi.net> <8gNo6.440$y6.128357@ruti.visi.com> <3aa6551e.212870101@news.laplaza.org> Message-ID: <3AA78820.67A56767@divalsim.it> Grant Edwards wrote: [...] > You had 1's? In my day we had to write everything using nothign but 0's! I believe this condition is called "Turing impaired". Best regards, Nicola Musatti From johngrayson at home.com Fri Mar 23 08:39:47 2001 From: johngrayson at home.com (johngrayson at home.com) Date: Fri, 23 Mar 2001 13:39:47 -0000 Subject: Tkinter - Widget Colours Message-ID: <99fjn3+m14m@eGroups.com> --- In python-list at y..., "O'Rourke Clodagh-corour01" wrote: > > I was wondering does anyone know how the bag/fag colours can be changed after the widget is packed. b = Button(...) b.pack(...) b.configure(background='red') b.config(bg='blue') b['bg'] = "#fea405" etc... John Grayson From kalle at gnupung.net Wed Mar 21 12:05:02 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Wed, 21 Mar 2001 18:05:02 +0100 Subject: help for newbie In-Reply-To: <3AB8D031.2E54827E@rmsb.u-bordeaux2.fr>; from Henri.Valeins@rmsb.u-bordeaux2.fr on Wed, Mar 21, 2001 at 05:00:49PM +0100 References: <3AB8D031.2E54827E@rmsb.u-bordeaux2.fr> Message-ID: <20010321180502.B24260@father> Sez Henri Valeins: > Hi, > > I try to use python program named PLUCKER for retrieve web page on > internet. When I try this program I have this message : > > Retrieved failed: 404 -- [Errno url error] unknown url type: 'http' I have never used (or heard about, I think) PLUCKER, but here's an idea: How do you run the program? If you run it like > PLUCKER http://www.somesite.org/ try > PLUCKER www.somesite.org instead. Peace, Kalle -- Email: kalle at gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From myudkin at compuserve.com Tue Mar 13 01:48:57 2001 From: myudkin at compuserve.com (Mark Yudkin) Date: Tue, 13 Mar 2001 07:48:57 +0100 Subject: Einstein's Riddle References: <98glrd$1si1a$1@ID-75892.news.dfncis.de> <3AABE712.499CCF4C@home.com> <98gp5b$1u0oi$1@ID-75892.news.dfncis.de> <98i5880pl2@news2.newsguy.com> Message-ID: <98kfrl$pug$1@sshuraaa-i-1.production.compuserve.com> Rather than looking at America sites for information about emu's, consider that it's an AUSTRALIAN flightless bird, and there's more to it than eating it. "Alex Martelli" wrote in message news:98i5880pl2 at news2.newsguy.com... > "Boris Popov" wrote in message > news:98gp5b$1u0oi$1 at ID-75892.news.dfncis.de... > > "Bruce Elrick" wrote in message > > news:3AABE712.499CCF4C at home.com... > > > I swear there is no evidence that any of them own a fish. The German > > > owns an emu. > > > > > > Bruce > > > > I am missing something then. I thought my table satisfies all given > > statements and it has fish right under the german... > > > > -Boris > > P.S. What's emu ? > > A large flightless bird, whose meat is appreciated by more and > more connaisseurs (it's red meat, reasonably tasty, quite soft, > light in cholesterol & fats). You can get a LOT of information > about it from the American Emu Association, http://www.aea-emu.org/. > (Particularly with the many recent scares about "mad cow's disease" > aka BSE, emu meat has received a huge market boost -- it's now > quite common for supermarkets around here to offer it, restaurants > to feature it in several dishes, etc). > > Any association with Europe's "Economic and Monetary Union" is, > one can hope, totally coincidental (some people WOULD argue that > _that_ EMU _is_ 'owned' "by the German", but that's a base and > unsubstantiated canard...). > > > Alex > > > From mda at idatar.com Sat Mar 17 13:45:31 2001 From: mda at idatar.com (David Allen) Date: Sat, 17 Mar 2001 18:45:31 GMT Subject: Should I close after popen?? References: Message-ID: In article , "Andrew Markebo" wrote: > I am hacking away a small background program, using popen to call commands, > should I close the file in some way when done or it is taken care of > automagically?? > > I do something like this once every 10 mins.. > > fd1=os.popen("command") fd2=os.popen("command") os.wait(fd1) > os.wait(fd2) values=fd1.read()+fd2.read() > > And.. anything to worry about, nesting popen/wait like this?? > (Linux/Solaris) IIRC when garbage collected, all file handles are closed automagically by python. But that doesn't mean that it's OK to do it, that's just for safety. You should ALWAYS close your own handles, so you can keep track of where they're good and where they're no good. You're not going to really screw things up if you don't explicitly close them but it's a better idea to do it yourself. It's good practice. As for doing two popen()'s concurrently, that shouldn't be a problem as long as you're in an environment where forking is kosher, since popen() does a fork. From the C popen() call manpage: (Python pretty much just wraps the C interface, I think): The popen() function opens a process by creating a pipe, forking, and invoking the shell. -- David Allen http://opop.nols.com/ ---------------------------------------- Be wary of strong drink. It can make you shoot at tax collectors and miss - Lazarus Long, "Time Enough for Love" From tim.one at home.com Fri Mar 2 13:46:59 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 2 Mar 2001 13:46:59 -0500 Subject: extended slices and buffer objects ???? In-Reply-To: <3a9f9581.5089898@news.laplaza.org> Message-ID: [Mats Wichmann] > Perhaps someone can shed light on my confusion about these two Python > features? > > (1) Extended slicing. I've seen claims that it's useful for > "multidimensional data structures such as matrices and arrays", but my > brain just isn't making sense of this. Can anyone give me a practical > example or two? Core Python makes no use of these. They were added for the NumPy extension, and that's where they're used. > [2] Buffer objects. What are buffer objects for, anyway? I find this > description from the Reference Manual somewhat less than enlightening: > > Buffers are not directly supported by Python syntax, but can be > created by calling the builtin function buffer(). They're a not-ready-for-prime-time generalization under the covers, seeking to unify some aspects common to, e.g., processing strings and memory-mapped files. Ignore them for now! This is still wizard-level stuff, and almost wholly undocumented even in the internals. By the way, you forgot to ask about the undocumented file.readinto() method too . if-buffer()-were-ready-for-prime-time-readinto()-would-be-documented-ly y'rs - tim From donn at oz.net Sun Mar 18 01:01:00 2001 From: donn at oz.net (Donn Cave) Date: 18 Mar 2001 06:01:00 GMT Subject: Should I close after popen?? References: <98satl$1t8$0@216.39.151.169> <98uf48$552$1@216.39.151.169> Message-ID: <991ius$8hm$0@216.39.151.169> Quoth Andrew Markebo : | / Donn Cave wrote: | Basically, run two or more popens in parallell, and when there is data | on one of them read it and do some work.. | | Basically what I do now is do two popen2, do a wait on the first, chew | some data, wait for the second, not critical at the moment, just | interested what to do if I had to chew the data from the second | process first. Given two or more inputs, select() is the way to find out which one is readable. "Readable" means os.read() will return right away, with either data or an empty string indicating the pipe was closed. Any I/O on the file object will severely confuse the issue. ... || One unrelated advantage of popen2 is that if you supply a list of || arguments, it will use them directly instead of a shell command || line. That is much safer. A command line constructed at run | | You mean like popen2(["command", "param", "param"]...)? Right. (For the same difference vs. system(), use spawnv().) Donn Cave, donn at oz.net From support at internetdiscovery.com Fri Mar 9 15:54:37 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Fri, 09 Mar 2001 20:54:37 GMT Subject: FW: Need help with Tkinter bind statement References: Message-ID: <3aa92bd1.43265069@24.0.228.33> On Tue, 6 Mar 2001 14:22:49 -0600, "Mellor, Mike" wrote: >I have been working on an RPN calculator program for a while now, and >I am having problems with some bindings. Here is a code snippet of >where I'm having trouble: > ># Bindings >xStack.bind('<+>', lambda event, fxn = 'y+x':Calc(fxn)) >xStack.bind('<->', lambda event, fxn = 'y-x':Calc(fxn)) # This is >causing an error It's a Tcl subtlety/bug. <+> is really a shorthand for But <-> doesn't seem to parse, so use instead. Mike. From scarblac at pino.selwerd.nl Wed Mar 21 07:38:15 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 21 Mar 2001 12:38:15 GMT Subject: Bug or feature? References: <99a433$b8b$1@sun.rhrk.uni-kl.de> Message-ID: Markus Reitz wrote in comp.lang.python: > Hi, > > I'm using Python 2.0 and have found a, according to my opinion, strange > behaviour. > > a=[] > a.extend('Test') > > Printing a results in: > > a=['T','e','s','t'] > > I expected a TypeError message, because a String is not a list and so it > can't be used to extend an existing list. > > On the other hand, a string can be seen as a kind of "list of characters" > ... > > Is this behaviour a bug or a feature? Feature. Strings are sequences, just like lists, tuples and any class instances with the right methods (__getitem__, mostly). >>> for a in "whee": print a w h e e >>> list("whee") ['w','h','e','e'] -- Remco Gerlich From cribeiro at mail.inet.com.br Sat Mar 31 20:41:14 2001 From: cribeiro at mail.inet.com.br (Carlos Alberto Reis Ribeiro) Date: Sat, 31 Mar 2001 22:41:14 -0300 Subject: PythonLabs Team Moves to ActiveState In-Reply-To: Message-ID: <5.0.2.1.0.20010331223927.021590d0@mail.inet.com.br> It's 2 hours before April Fool's Day here (?!?!?) At 19:54 31/03/01 -0500, Guido van Rossum wrote: >PythonLabs Team Moves to ActiveState > >To all Python users and developers: > > Less than half a year ago, I moved with my team to Digital Crations, > in the > hope of finding a new permanent home for Python development. At > Digital Creations we've done several good things for Python, such as > forming > the Python Software Foundation and the management of the Python 2.1 > release. > > Unfortunately, Digital Creations's original plans for PythonLabs didn't > work out as hoped, and we weren't able to reach mutual agreement on > workable alternative plans - despite trying for months. > > I am proud to have found a new home for my entire team: starting > today, Tim Peters, Barry Warsaw, Jeremy Hylton, Fred Drake and myself > are working for ActiveState. We will be spending part of our > time on core Python development (including Jython and Mailman) and > part of our time on Python infrastructure improvements that also > benefit ActiveState's efforts such as Komodo and Python.NET. > > Python will remain Open Source; ActiveState has no desire to > monetize or brand the Python language or specific Python > distributions. All future work we do on Python as ActiveState > employees will be owned by the PSF. > > We're excited to be working for ActiveState: they are one of the companies > most committed to Python, and they have great products! Plus, we know > they have deep financial backing. We trust that ActiveState will > provide a stable home for Python for many years. > > ActiveState has also offered to take over hosting of the > python.org and starship sites. On behalf of the Python community, > we're grateful for this support of the two prime community sites for > Python, and we expect to be implementing the transitions shortly. > > These are exciting times for the PythonLabs team - and also for Python > and its community. Mainstream successes for Python are showing up > everywhere, and we're proud to be a part of such a smart and friendly > community. A great year lies ahead! > > Note, however, that moving to ActiveState will have some minor effects > on the future of Python development. ActiveState is concerned about > the seeming rift between the Perl and Python communities and wants > to do its best to help the Open Source scripting community work together. > In order to make it easier for Perl programmers to transition to Python, > we will add optional curly braces for Python. While we are fully aware > of the effect this will have on Python usability, we have finally decided > to bite the bullet and accept that until this happens, Python will never > be popular. > > Barry has already approved PEP 357, Adding Block Delimiters to Python. > Since we are heavily commited to backwards compatability, a transition > period of three months has been mandated. For those who want the changes > to start sooner, we added "from __future__ import block_delimiters" in > Python 2.1, which will be released about two weeks from now. > > Larry Wall and I agreed that now it makes sense for Perl to have > the Perl compiler enforce correct indentation in Perl sources. This > will probably be implemented in Perl 5.7, and will certainly be in Perl 6. > Also, after some talks with Larry, I've decided to adopt the Perl > numerical model for Python. The Perl model is simple, predictable and > easy to explain. This is a small enough change that it does not need > a PEP, and Moshe will implement it before 2.1rc1 is out. > > Now that the catalog-sig finally has a fully working product, ActiveState > decided they will base a CPAN competitor on it. This server will be able > to deal with both Perl and Python modules. While the client will remain > completely Open Source, it was decided that the server will remain > ActiveState proprietary. While it is true that the original server was > written by the Python community, ActiveState has put a lot of effort > into making it general enough, and we need to justify the costs somehow. > > --Guido van Rossum (home page: http://www.python.org/~guido/) > > >-- >http://mail.python.org/mailman/listinfo/python-list From digitig at cix.co.uk Sun Mar 18 17:35:00 2001 From: digitig at cix.co.uk (Tim Rowe) Date: Sun, 18 Mar 2001 22:35 +0000 (GMT Standard Time) Subject: Thoughts about extensions to the Python language References: Message-ID: In article , carribeiro at yahoo.com (Carlos Ribeiro) wrote: > (flames off please ...) > > First of all, some background information... I'm watching this list for > the past few days. Thats my first contribution to the list. I work on > computer related jobs for some time (since 1984), and I have saw a lot > of things in the past decade or so. I'm learning Python since mid-2000, > mainly for use as a tool to gather network management information. > > What attracted me to Python was the simplicity and cleanliness of the > language. Code written in Python is as clean as code can be. I have > written systems using several other languages, including C, C++ and > Perl, and none of these languages can even come close of Python in > terms of readability. I think that most people on this list will agree > with me that making code readable is one of the most important (and > relegated) steps to improve programming skills. > > I'm not saying that Python is perfect - as a "work in progress" we can > surely think about a lot of things that can be improved. However, I'm > seeing a lot of effort these days toward language extensions. Call it > "featuritis" or anything like it, but I dont like it, and something > inside tells me that this is the wrong approach for Python's evolution. > I can number several ways this approach is failed: [Applause]. This has been worrying me a lot, as /almost/ every suggested "improvement" I see: a. Is an import from a language I have already rejected in favour of Python (at least when I'm programming Python) and b. Muddies the clarity of the language. If people /really/ want these features, could they put them into a new language /based/ on Python, please, so that those of us happy with Python can carry on undisturbed (just as most of us using Modula2 ignored Modula3)? I suggest the name "Monty", as I see it as a retrograde step! I'm not against development of the language -- the set inclusion operators look fine to me, and I've been known to use them (admittedly in an unofficial obfusticated code competition!) but if a feature doesn't fit easily within the present language philosophy (dummy includes to change the semantics of the language, anyone?) then I venture to suggest that the feature probably doesn't belong in Python, and that the great and good should rethink what they're trying to achieve and come up with features that do it the /Python/ way! From iddwb at imap1.asu.edu Fri Mar 9 15:19:54 2001 From: iddwb at imap1.asu.edu (iddwb) Date: Fri, 9 Mar 2001 20:19:54 +0000 Subject: Dictionary attributes and functions Message-ID: I'm looking to read a list of items where their may be duplicates. I'd like to use a dictionary to do this but am way to new to python to know fully how to do it. I'm hoping there is some set of fuctions or attributes that can be reference regarding dictionaries... specifically if key(a) is already in dictionsary x I'd like to know prior to adding. rather than change the value of key(a) I'd like to add the value of key(`a) to the value of key(a) so I end up with {keya: [123]} on insert of keya againg have something like {keya: [123, 234]} Any pointers on what to look for in the docs? btw, I've been going through Mark Lutz's book on "programming python" but I'd like something with a little more langugage reference in it. David Bear College of Public Programs/ASU From stadel at excite.com Sun Mar 4 22:28:32 2001 From: stadel at excite.com (stadel) Date: Sun, 04 Mar 2001 20:28:32 -0700 Subject: Name of the Script References: <20010304.185354.2114937732.8277@localhost.localdomain> Message-ID: <20010304.202832.950390868.8277@localhost.localdomain> Thanks alex . Now that you say that it seems rather obvious. I feel like a dolt :P Thanks again Stadel In article , "Alex Shindich" wrote: > try the following: > > import sys print sys.argv[0] > .... > The first argument in the argument list is the name of the script that > got invoked. > > I hope this helps. > > Regards, > > Alex Shindich visit http://www.shindich.com/sources > "stadel" wrote in message > news:20010304.185354.2114937732.8277 at localhost.localdomain... >> What is the method for returning the file name of the running script? >> >> Thanks in advance. Stadel >> > > From jgraves3 at austin.rr.com Fri Mar 16 06:22:02 2001 From: jgraves3 at austin.rr.com (jay graves) Date: Fri, 16 Mar 2001 11:22:02 GMT Subject: Basic information requested References: Message-ID: <3ab1f558.42256838@news-server.austin.rr.com> On Fri, 16 Mar 2001 09:05:53 -0000, "Jamie MacIsaac" wrote: >Hi, >I've just started looking at Python and would like to use it to perform some >simple admin tasks on a Windows network. However, I'm having difficulty >finding out how to accomplish elementary tasks. >Can someone please point me to sample code that shows how to map a network >share and copy some files? Is there a central resource of code samples? This mapping question was asked in July of 2000 and I saved a couple of the postings. These allowed me to find the relevant thread on Yahoo Groups. (I really miss DejaNews. I can't wait for Google to bring the entrie archive back online) Anyway here is the thread. http://groups.yahoo.com/group/python-list/message/99872 As far as copying files, check out the shutil module in the standard library. http://www.python.org/doc/current/lib/module-shutil.html Hope this helps. ... jay From loewis at informatik.hu-berlin.de Wed Mar 21 17:31:22 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 21 Mar 2001 23:31:22 +0100 Subject: urllib.urlopen doesn't accept Unicode strings. References: <998tau$q6i$1@troll.powertech.no> Message-ID: "Syver Enstad" writes: > The offending line is at 241 in urllib.py (python 2.0) > > def open_http(self, url, data=None): > """Use HTTP protocol.""" > import httplib > user_passwd = None > # next line patched, original line was: if type(url) is type(""): > if type(url) is type("") or type(url) is type(u""): > host, selector = splithost(url) > if host: > > Or maybe this has been fixed in Python 2.1? No, it hasn't. Please submit a patch to sourceforge.net/projects/python. I recommend you start from the current code base, though - using types.UnicodeType is much better than type(u""). I normally write this as if type(url) in [types.StringType, types.UnicodeType] Regards, Martin From fredrik at pythonware.com Thu Mar 22 02:55:32 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 22 Mar 2001 07:55:32 GMT Subject: learning python... References: <3AB8F4E1.184DD9C@noaa.gov> <3ab90559_6@goliath.newsfeeds.com> <99b44s$m5j$1@panix6.panix.com> <3AB9182A.8FEBCF3E@noaa.gov> Message-ID: Don Tuttle wrote: > Why not post a review yourself? I intend to as soon as I've finished > reading it. (Which might be awhile given my penchant for reading 5 > or more books at once. ;-) at 1,200 pages, reading PP2e is pretty much like reading five or more books at once (there's *lots* of stuff in there...) Cheers /F From frank at canyon-medical.com Tue Mar 6 01:18:05 2001 From: frank at canyon-medical.com (Frank Sergeant) Date: Tue, 6 Mar 2001 00:18:05 -0600 Subject: gah! I hate the new string syntax References: Message-ID: "Steve Holden" wrote in message news:Koco6.7518$1D5.244602 at e420r-atl1.usenetserver.com... > Ha! As an Englishman married to a Scot I'm not going to let you get ... > Still, at least we can remind all that Scotland and England are different > countries on c.l.py. Yeah, sure, on c.l.py they are different countries, but that doesn't mean they are different countries in real life. > Lest people might think this is intended as criticism rather than humo(u)r, > I hasten to add that I lived in Scotland for three years before moving to > the USA, and found the Scots to be extraordinarily warm and generous people. Yeah, sure, but what else can you say when you your wife is probably holding one of those damn stocking daggers to your throat. -- Frank frank at canyon-medical.com bag pipes are weapons of war From jeremy at digicool.com Tue Mar 27 15:57:04 2001 From: jeremy at digicool.com (Jeremy Hylton) Date: Tue, 27 Mar 2001 15:57:04 -0500 (EST) Subject: StandaloneZODB at cvs.python.org Message-ID: <15040.65184.461098.646113@w221.z064000254.bwi-md.dsl.cnc.net> I have created a new CVS project based on Andrew Kuchling's ZODB & ZEO packages. The new project is called StandaloneZODB and is available from cvs.zope.org. This is not an official release of any sort. The CVS repository contains the current development versions of the code. The distutils setup scripts have been tested with Python 2.1, but not with earlier versions. (Python 2.0 should work; Python 1.5.2 probably does not.) There is also a mailing list, zodb-checkins at zope.org, that receives checkin messages for the components in StandaloneZODB. If you already subscribe to the zope-checkins at zope.org list, you will see two copies of every checkin message for the components found in both projects. The project is tied directly to the ZODB code used in the Zope2 CVS repository. When a change is made to Zope, it will also appear in StandaloneZODB, and vice versa. Specifically, we use cvs modules to incorporate parts of the Zope2 and ZEO code bases. The project contains the key components you need to run ZODB and ZEO, but not all of the ancillary packages that Andrew's distribution includes. I expect to add more components over time, but only those that are expected to be useful for Python programmers using ZODB. You can check out from cvs.zope.org by following the instructions at http://www.zope.org/Resources/CVS_info. If you want to find out more about ZODB, a good place to start is the ZODB Wiki: http://www.zope.org/Wikis/ZODB/FrontPage Jeremy From mbac at nyct.net Thu Mar 22 10:39:54 2001 From: mbac at nyct.net (Michael Bacarella) Date: Thu, 22 Mar 2001 10:39:54 -0500 Subject: Jython is cool? Message-ID: <20010322103954.A18539@sync.nyct.net> Howdy, When I first read about Jython, what immediately popped into my head was that you get a Python interpreter written in Java that you can say, embedd in a web page and pass a parameter which says which python script to execute. I find myself frustrated by Java which is why the thought of doing web applets in Python was so exciting. Unfortunately, it seems that in downloading Jython, a JDK is still required. Has someone already done this/is it already possible and I just didn't look at the package well enough or am I out of luck until I bite the bullet some day and implement it myself? Thanks -- Michael Bacarella Technical Staff / System Development, New York Connect.Net, Ltd. From fredrik at pythonware.com Wed Mar 28 11:46:14 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 28 Mar 2001 16:46:14 GMT Subject: Speed problems with Python vs. Perl References: <99sv33$8hk$1@news.cineca.it> <1znw6.1969$sk3.665386@newsb.telia.net> <87y9tplvuu.fsf@elbereth.ccraig.org> Message-ID: Christopher A. Craig wrote: > with Python 2.0 and Perl 5.6.0 on a Celeron 300A using a 242000 line > input file and I got the following results: > > python: 61.10s user 0.42s system 87% cpu 1:10.37 total > perl: 11.31s user 0.10s system 76% cpu 14.960 total > > admittedly Python is being hurt by the slower 2.0 line I/O, but I > would guess that regular expressions are still hurting performance. s/regular expressions/re.split/g note that re.split is written in Python, while I'm pretty sure Perl's split is written in C. to get a better idea of how fast the regular expression engine itself is, run your benchmark with "findall" instead of "split". Cheers /F From erno-news at erno.iki.fi Sun Mar 11 17:59:32 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 12 Mar 2001 00:59:32 +0200 Subject: Problems writting a wrapper around linux' ssh command References: <31rd89.lki.ln@127.0.0.1> Message-ID: In article <31rd89.lki.ln at 127.0.0.1>, gradha at iname.com writes: | Hi. | I am trying to write a python wrapper around ssh. The last and only problem | I have is password verification. I try to popen2.popen3 the ssh command, | but no matter what I write to the input file, the ssh command ignores it | and keeps requesting *keyboard* input. | Is there any way to avoid this? do not embed the password in your python program. use a passphraseless rsa key instead, it is safer and less pain. -- erno From ws-news at gmx.at Wed Mar 14 04:05:58 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Wed, 14 Mar 2001 10:05:58 +0100 Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> <20010312170356.B3513@better.net> <984486395.407379@newsmaster-04.atnet.at> <984518199.127140@newsmaster-04.atnet.at> <984521930.27710@newsmaster-04.atnet.at> Message-ID: <984561044.512222@newsmaster-04.atnet.at> > > > >Does this make a difference, as soon as arithmetics takes place? > > Yes. All FP calculations took place in BCD. You got exact > results as long as your values didn't exceed the > representations limits. > Exactly, and this is for example the case for 1/3, 1/7 and so on... Doesn't sound like an real improvement... regards werner From loewis at informatik.hu-berlin.de Sun Mar 11 15:26:34 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 11 Mar 2001 21:26:34 +0100 Subject: segfault with PY file but ok with PYC References: Message-ID: Niki Spahiev writes: > Any suggestions? Not a real suggestion, but I also get the impression that Python 2 sometimes crashes in relation to generating byte code file, and works fine if the byte code file is there. A really useful contribution to Python would be a detailed analysis of the problem, accompanied by a patch. Regards, Martin From sdm7g at Virginia.EDU Thu Mar 29 20:09:35 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Thu, 29 Mar 2001 20:09:35 -0500 (EST) Subject: diff lists In-Reply-To: Message-ID: On 29 Mar 2001, Michael Hudson wrote: > > Tangentially, does anyone know of any good algorithms for "edit > distance" between two sequences? E.g. if I have > > "abcdef" > > and want to get to > > "abQUACKcde" > > I want to get the answer back "insert 'QUACK' at position 3 and delete > a character at position 11". > > "Good" means "pretty quick", here. > I used to have a Levenshtein string edit distance done in Icon, and I think I may have translated it to python once, but I can't find a copy. If you do a google search on that, you'll find a lot of stuff: http://www-apparitions.ucsd.edu/~rmckinle/string/ http://www-igm.univ-mlv.fr/~lecroq/lec_en.html http://www.ling.ohio-state.edu/~cbrew/795M/string-distance.html However, the algorithm for the distance does not give location, but maybe this info can be extracted from the intermediate matrix. -- Steve Majewski From amk at mira.erols.com Fri Mar 9 13:38:59 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 9 Mar 2001 18:38:59 GMT Subject: IPC9 quotes wanted Message-ID: I intended to put a note on the message board about this, but forgot... If you were at IPC9 and heard someone say something quotable, please let me know who it was and what they said, so that it can be added to the quotation file. Thanks! (I reserve the right to not add quotations, so don't feel bad if your submitted quotation doesn't get in.) --amk From mlh at idi.ntnu.no Sun Mar 25 16:19:44 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Sun, 25 Mar 2001 23:19:44 +0200 Subject: Yet Another PEP: Query Protocol Interface or __query__ References: Message-ID: <99lnc6$ck4$1@tyfon.itea.ntnu.no> "Clark C. Evans" wrote in message news:mailman.985490195.2917.python-list at python.org... [snip] > This proposal puts forth a light-weight explicit mechanism > for the adaptation (including verification) of an object to > a context where a specific type, class, interface, or other > protocol is expected. I like the generality here -- nice PEP overall, IMO :) [snip] > To enable the first case listed in the requirements, > the adapt function first checks to see if the objects > type or the objects class are identical to the protocol. > If so, then the adapt function returns the object directly > without further ado. Hm. So in some cases the protocol object is merely an example (prototype) of an object satisfying the protocol, and in other cases it represents the protocol itself (with __prodapt__ etc)? That seems a bit ... impure to me. Maybe I've missed some arguments pertaining to this. How about something like this: def adapt(obj, protocol=None, prototype=None, can_wrap=1): # ... (A standard abbreviation for prototype is "proto", but I'm afraid that could be confusing here... Perhaps "sample" could be used? Or some other word?) Then one could use adapt(obj,protocol) if a protocol was available, and adapt(obj,prototype=someObject) if the protocol was to be inferred from a prototype (i.e. the class or type). In that case, one could perhaps use adapt(obj,SomeClass), and the function would check if obj was an instance of SomeClass; it would *not* check whether SomeClass and obj were instances of the *same* class (which seems semantically weird in this context to me...) Oh, well. Perhaps worth 2 pennies... > Q: The name __prodapt__ sucks. > > A: Suggest a better alternative; I suppose __check__ could > be used for the protocol side, however I dont want to > trample on Paul Prescods proposal. Hm. This could, I guess, be named __adapt__ as well, except that there is no way of marking the transitive mode :) How about __adjust__? Sounds more transitive than __adapt__ to me... >From the good ol' Merriam-Webster: > ADAPT implies a modification according to changing > circumstances (adapted themselves to the warmer > climate) And: > ADJUST suggests bringing into a close and exact correspondence > or harmony such as exists between parts of a mechanism > (adjusted the budget to allow for inflation) Hm... *Or*, the intransitive version of __adapt__ could be called __conform__, which is indeed intransitive. Then the transitive version could be called __adjust__ or __adapt__ or whatever. I think that gets my vote: __conform__ - method in an object which can conform to a protocol __adapt__ - method in a protocol used to adapt an object to it Perhaps not perfect, but __prodapt__ **really** sucks. <0.1 wink> -- Magnus Lie Hetland http://www.hetland.org "Reality is that which, when you stop believing in it, doesn't go away." -- Philip K. Dick From sholden at holdenweb.com Thu Mar 22 22:26:59 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 22 Mar 2001 22:26:59 -0500 Subject: Why Python/Jython? References: <99cl9e$b2b$1@Merlin.et.bocholt.fh-gelsenkirchen.de> Message-ID: "Steve Purcell" wrote in message news:mailman.985260089.28444.python-list at python.org... > Andreas Freier wrote: > > In several articles I read that Python/Jython imporoves the programmers > > performance many times. Why? > > Simple: Python code is usually many times shorter than the corresponding > Java code. > > Programmer performance is usually gauged by coding time and > number of bugs, both of which are vaguely proportional to the number of > lines of code in most sane languages*. > > * Perl is a noteworthy exception > I saw no inconsistency here. Why would Perl be an exception to your rule? regards Steve From sholden at holdenweb.com Mon Mar 5 21:24:14 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 5 Mar 2001 21:24:14 -0500 Subject: gah! I hate the new string syntax References: <97ohh2$polt0$1@ID-77331.news.dfncis.de> Message-ID: "Skip Montanaro" wrote in message news:mailman.983843650.6177.python-list at python.org... > > Sean> Turning a string literal (";") suddenly into a string object and > Sean> then using its methods is not an easy read. > > In Python, everything is an object. Thus, a string literal is a string > object - no "turning into" required. Just because it wasn't created by > instantiating a class doesn't make it any less an object. > > The presence of join methods for strings and why that's where they landed > has been hashed and rehashed several times. Please check out FAQ 4.96 for > details. > This isn't really fair, since I wrote 4.96 in response to this thread. > Sean> ";" . join() # in perl, this means concat ";" with the result of > Sean> join() > > Nobody ever claimed that Python was trying to be Perl... ;-) Just because > '";".join' is a fragment of valid expressions in both languages doesn't mean > they have to mean the same thing. > > (In reality, I actually do my best to make my Perl code look as much like > Python to my Python-infected mind as I can.) > just-getting-the-hang-of-this-time-machine-ly y'rs - steve From jicman at cinops.xerox.com Tue Mar 20 16:28:03 2001 From: jicman at cinops.xerox.com (Jose Isaias Cabrera) Date: Tue, 20 Mar 2001 16:28:03 -0500 Subject: ASCII encoding error: ordinal not in range(128) References: <91o5ih$2kv$1@news.wrc.xerox.com> <20001219172933.B29727@ActiveState.com> Message-ID: <006201c0b184$a60b9430$5aa4af0d@dssc.mc.xerox.com> Greetings all! I have a python program that interfaces with Microsoft Outlook. I am running into a problem when I have attachments and subject titles with different characters that are not your normal everyday character. For example: The program is giving me a Traceback because of the following attachment: "Desenbanco_customiza??o docushare.doc" Here is the Trackback... C:\>qna0.py Traceback (most recent call last): File "C:\myprograms\qna0.py", line 1570, in ? main() File "C:\myprograms\qna0.py", line 1556, in main ProcessAllItems(wf2,workpath,workpath,NSpace) File "C:\myprograms\qna0.py", line 1484, in ProcessAllItems FindIfAttachments(em,Rec['SPAR'],wID,fam) File "C:\myprograms\qna0.py", line 1156, in FindIfAttachments name = code.encode() UnicodeError: ASCII encoding error: ordinal not in range(128) I've search on python sites for this, and though there is something about Unicode, there is no python example code to use. Does anyone have any idea how to fix this? Thanks for your help. jos? > From lsloan at yahoo.com Fri Mar 9 14:12:40 2001 From: lsloan at yahoo.com (Lance E Sloan) Date: Fri, 9 Mar 2001 11:12:40 -0800 (PST) Subject: function access to caller's symbols? Message-ID: <20010309191240.98744.qmail@web9506.mail.yahoo.com> I'm a Python newbie, so if I'm approaching this problem the wrong way, let me know. I defined a function that takes a string and a dictionary as arguments. I wanted the function to use the global symbol table as the dictionary if it was not specified. I defined it this way: def myFunc(theString = None, theDict = vars()): This worked fine when the function was defined in the same file as the code that called it. However, when I moved the function to a different file and used "import" to bring it in, it wouldn't work. theDict in the function didn't contain any of the symbols that were defined in code that called the function. So, how can I make my function access its caller's symbol table? Thanks in advance! ===== Lance E Sloan lsloan at bigfoot.com __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ From NoSpam at NoSpam.com Fri Mar 2 15:05:57 2001 From: NoSpam at NoSpam.com (Tom) Date: Fri, 02 Mar 2001 20:05:57 GMT Subject: how to get the last interactive command enetered Message-ID: Assuming that python is in interactive mode, how do get the text of the command that the user has just entered? For example, say that I set a trace function. I find the frame's code object, look at co_filename and find that it is . But I want to know what the actual command was. Is there anyway to do this (in C or Python)? Thanks, Tom. From bawolk at ucdavis.edu Sun Mar 4 12:21:14 2001 From: bawolk at ucdavis.edu (Bruce Wolk) Date: Sun, 04 Mar 2001 09:21:14 -0800 Subject: PyQt Impressive Message-ID: <3AA2798A.F46081B9@ucdavis.edu> I recently downloaded the PyQt bindings to Qt and after a minor install issue (they don't tell you that you have to run ldconfig) I was up and running and going through the Qt tutorials. The tutorials are a wonderful introduction to Qt and fun to explore. They even contain suggestions for making minor modifications to the programs to test one's grasp of the concepts. I am really impressed with the quality of the documentation and the power and versatility of the Qt classes. The use of "signals" and "slots" at first seemed a bit foreign, but I quickly got the hang of it and I think I like them a lot better than the Tkinter command bindings. Bruce From brangdon at cix.co.uk Fri Mar 2 03:34:00 2001 From: brangdon at cix.co.uk (Dave Harris) Date: Fri, 2 Mar 2001 08:34 +0000 (GMT Standard Time) Subject: Stream interfaces References: Message-ID: topmind at technologist.com (Topmind) wrote (abridged): > s = newStream(....) > s.peekable = true > s.positionable = false > s.external = blah > s.buffered = blah > s.readAble = true > s.writeAble = true > [use the stream now.....] This doesn't seem very extensible. Here are some things we might reasonably expect in a streams library: Formatting End-user (print, reporting) Programmer (display, debug info etc) HTML XML Legacy structured layout Underlying Data Type ASCII Unicode Multi-byte Byte Binary (big-endian integers etc) Object (Integers etc) Filtering Compression Encryption Message digests/digital signatures Buffering Sinks/Sources Collection File TCP/IP Socket Database There is a lot going on here. Few applications will need all of it, and many shops will want to insert their proprietary or legacy formats and algorithms. We need something flexible and extensible. I agree that a single inheritance hierarchy is not the answer. On the other hand, we can't hope to get XML formatting just by writing: s.inXml = true either. I expect we need more delegation. The main thing is to separate out the formatting front-end, which needs a rich and probably varied API, from the data-sink back-end which can use a much smaller and more uniform API. Then we can do buffering etc by means of pluggable adaptors, and construct pipelines like: XmlStream -> CompressionAdaptor -> SocketStream This is roughly the approach of the Java library. As far as I know it works reasonably well. Dave Harris, Nottingham, UK | "Weave a circle round him thrice, brangdon at cix.co.uk | And close your eyes with holy dread, | For he on honey dew hath fed http://www.bhresearch.co.uk/ | And drunk the milk of Paradise." From dg at pearl.tao.co.uk Wed Mar 14 05:54:26 2001 From: dg at pearl.tao.co.uk (David Given) Date: Wed, 14 Mar 2001 10:54:26 +0000 Subject: Atomic Event.{wait,clear} References: Message-ID: <2lin89.ndm.ln@127.0.0.1> In article , "Tim Peters" writes: [...] > Hard to guess what you're doing, but it sounds like you're using an Event as > a "hey, there's something to do!" signal, where there will be something to do > more than once over the life of your job. I had another look at the documentation, and it seems a Lock is easiest for what I want to do (I have a thread that does complicted stuff, and a message queue that tells it what to do; I use the Lock to block when the queue is empty). Everything seems to work, and I don't have a race condition any more. Ta. -- +- David Given ---------------McQ-+ "USER'S MANUAL VERSION 1.0: The | Work: dg at tao-group.com | information presented in this publication | Play: dgiven at iname.com | has been carefully for reliability." --- +- http://wired.st-and.ac.uk/~dg -+ anonymous computer hardware manual From johann at physics.berkeley.edu Thu Mar 15 13:13:32 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 15 Mar 2001 10:13:32 -0800 Subject: gah! I hate the new string syntax References: <97sudi01i26@news1.newsguy.com> <98elrk$li8$1@nntp.Stanford.EDU> <98fc070thh@news1.newsguy.com> <98iqo2$56o$1@nntp.Stanford.EDU> <98iv3s01sc2@news2.newsguy.com> Message-ID: ((I think I accidentally emailed this the first time around, so here goes nothing.)) Fredrik Lundh writes: > Quinn Dunkan wrote: >> Note that in ruby, any time you write >> >> class Foo >> ... >> end >> >> you are adding to, not overriding, 'Foo'. Thus, > does all classes live in the same namespace? No, you can define a 'module', which is simply a namespace, for your own classes and variables. The system classes, such as String, etc., do live in one namespace, however. I actually like this behavior; it makes interactive development easier. If I make a change in a source file, I can simply load it in, and all of the objects in the running system are effectively updated to reflect those changes. This is also how Common Lisp behaves, and CL has similar advantages for interactive development. But that's going far astray. I like features like this because I do very exploratory programming, and have been bitten before by problems having all the modules and classes update correctly when I make a change. Cheers, --J -- Johann Hibschman johann at physics.berkeley.edu From DanielK at jBASE.com Wed Mar 21 14:35:53 2001 From: DanielK at jBASE.com (Daniel Klein) Date: Wed, 21 Mar 2001 11:35:53 -0800 Subject: Substitute for join() Message-ID: I've got to make a script (written in version 2.0) to work on a machine running 1.5.2. The only incompatible line is one that uses the "".join(mylist) method. To 'get out of the woods' quickly, I substituted it with s = '' for element in mylist: s = s + element Is this the most efficient way to code this? Thanks, Daniel Klein From no-spam-popov at bigserver.com Tue Mar 13 11:07:54 2001 From: no-spam-popov at bigserver.com (Boris Popov) Date: Tue, 13 Mar 2001 08:07:54 -0800 Subject: Einstein's Riddle References: <984380185.768920@news.aei.ca> <4w6r6.193645$df5.5192565@news1.crdva1.bc.home.com> <3aae4114.63604234@nntp.interaccess.com> Message-ID: <98lgle$2f04i$1@ID-75892.news.dfncis.de> "Thaddeus L Olczyk" wrote in message news:3aae4114.63604234 at nntp.interaccess.com... > On Mon, 12 Mar 2001 16:08:32 GMT, "David Murphy" > wrote: > > >This reminds me of a test my class was given WAY back in grade 6. It was > >two sheets of paper long, and at the very top, it was clearly stated that > >the student should 'Read the entire test carefully before beginning'. > > > >The point was, at the bottom of the second page, the student was told > >something to the effect of: 'After reading through the test, place your > >pencil on you desk and wait for further instructions'. > > > >Well, 90%+ of the class immediately went to work on this test. There were a > >couple of questions where students had to get up and do things, and it was > >rather amusing to watch them run around. About 30 minutes later, they > >started to get to the end, and they realized that they had been running > >around and scribbling down answers for nothing. It was a rather profound > >lesson, at least for me. > > > The version I saw the last question was sign your name and turn it in. > There were ( AFAIK ) no questions about getting up and running around. > We were given an hour told it was very important. I gave up after > reading the test halfway in the first thirty minutes and started > answering questions. > > It didn't help that we had a strange test two weeks. > For the first time the HS I was in had set up a special schedual for > midterms/finals. In this particular class we would meet for two > seperate hours. THe teacher gave us an exam that should have lasted > one hour ( by her estimation ). She was going to use the second hour > for a class. It turned out that most fiished about 3/4 of the test in > the two hours. So she had a reputation for giving long tests. > > >*IF* Einstein was just talking about people's ability to deal with just the > >facts, and not to make assumptions, I think 2% +/- 5% is probably a good > >estimate. Take a look at the first draft of the next project specification > >you get *grin* > > > The problem is typical of problems published in many magazines ( here > in Dell Crosswords ). I suspect that 2%-5% will have the motivation to > sit through solving the puzzle unless there were some other reward, > but I figure half the population could actually solve it given the > proper motivation. > > I also figure the fish thing was simply a typo, and that this guy ( > who hasn't resdponded ) was probably given this as a homework > assignement, and is simply looking for a cheap way to get it done. There are a lot of references to this puzzle on the internet mentioning Einstein, 2% and non-existing "fish"... But again... You never know... :) -Boris From bdupire at seatech.fau.edu Fri Mar 23 12:17:20 2001 From: bdupire at seatech.fau.edu (Benoit Dupire) Date: Fri, 23 Mar 2001 12:17:20 -0500 Subject: I want to dynamically reload a module... Message-ID: <3ABB8520.D42D5E66@seatech.fau.edu> My goal is to dynamically import a module called 'func' and to get the references to the objects that 'func' created. It works like this: prog1.py dynamically imports func.py. func.py creates a setheading object, and prog1 gets its reference. All works fine ! The result is: >>>reload(prog1) test # prog1.py class foo: def __init__(self, module): self.aa=__import__(module) # dynamically import func chRef= getattr(self.aa, 'setheading') # get reference to the object that func created. chRef.run() my_foo = foo('func') # ---------------------------------- # func.py class SetHeading: def run(self): print 'test' setheading=SetHeading() Now I change func.py, replacing ' setheading=SetHeading()' with 'toto=SetHeading()' Normally, this should create an error when I run prog1.py, because the setheading object does not exist anymore... However: >>> reload(prog1) test func is not reimported! this shouldn't work... How can I force prog1.py to dynamically reload module='func' ? I did not see any __reload__ function in the Library Reference .... From aleaxit at yahoo.com Thu Mar 22 05:04:17 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 22 Mar 2001 11:04:17 +0100 Subject: Standalone executables References: <998igr$4al$1@niagara.nonet> <99aldn$7dh$1@niagara.nonet> <99cf1s$hrsb$1@ID-59885.news.dfncis.de> Message-ID: <99cin701b94@news2.newsguy.com> "Thomas Heller" wrote in message news:99cf1s$hrsb$1 at ID-59885.news.dfncis.de... > > I wonder, for Linux, what if I wrote in Jython, compiled with jythonc, > > then used a Java native-code compiler? Would that be too insane? (-: > > > With virtually every Linux coming with python, why is this needed at all? ...perhaps because each Linux installation has its own, not fully compatible installation of Python...? Alex From emile at fenx.com Tue Mar 27 09:36:25 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 27 Mar 2001 06:36:25 -0800 Subject: who is my caller? References: Message-ID: <99q8nv$2aibn$1@ID-11957.news.dfncis.de> "Remco Gerlich" wrote in message news:slrn9c18o0.ojm.scarblac at pino.selwerd.nl... > > Anyways, yes, it's more like black magic in Python. There is a call stack > you can inspect, but only if you just caught an exception. > If I'm not mistaken, with 2.0 you can directly import traceback without needing to generate an exception first. -- Emile van Sebille emile at fenx.com From nayland at mindspring.com Wed Mar 14 10:26:37 2001 From: nayland at mindspring.com (Mark Tokay) Date: Wed, 14 Mar 2001 10:26:37 -0500 Subject: Can you please post this opening somewhere on your website? Message-ID: <3AAF8DAD.724401A0@mindspring.com> Python Developer needed (Arlington, Virginia) Primary responsibilities will involve integrating Web Design technology with various Website applications. Desired Skill Set: Looking for well rounded individual who has experience developing client side code for client-server applications on various operating systems including Windows (Win32 API) as well as web-based clients. Expert Knowledge (2+ years) of Python is required. A stable work history is required. No contractors or consultants. Principals only. Local candidates only. For more information, please contact: Mark Tokay (828) 686-7777 Email: nayland at mindspring.com From aleaxit at yahoo.com Sun Mar 25 12:10:05 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 25 Mar 2001 19:10:05 +0200 Subject: "object" vs "dynamic" programming styles References: <3ABD117E.1E5492C4@erols.com> <3ABD2390.A2A28A12@letterror.com> Message-ID: <99l8vh01fo3@news1.newsguy.com> "Just van Rossum" wrote in message news:3ABD2390.A2A28A12 at letterror.com... [snip] > My personal preference would definitely be version 3, the factory function. > Less magic, clearer code. Seconded!!! Indeed: thirded, fourthed, etc... > When I first started writing OO code (which was with Python) I was often > tempted to do lots of smart things in the __init__ method. But it only > makes things harder in the long run. I recently had to extend a module I > had written a few years back: all the smart things in the __init__ were > of no use to me now: it assumed a quite different usage. > So I changed the __init__ to be as simple as possible, and added a couple > of factory functions. It's all nice and clean now... An absolutely crucial consideration. Temptation's even greater in languages offering the ability to provide multiple overloaded constructors -- that makes it even easier to yield to the temptation to perform too much clever magic in the constructor[s]. Factory functions rule... Alex From phd at phd.pp.ru Wed Mar 21 04:41:08 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 21 Mar 2001 12:41:08 +0300 (MSK) Subject: Regular expressions and non-standard character set In-Reply-To: <0XMt6.2503$4N4.321668@newsc.telia.net> Message-ID: Hi! What is the python version you are running? I have this problem with python 2.0. Do you use 2.1b? On Tue, 20 Mar 2001, Fredrik Lundh wrote: > Petri Mikael Kuittinen wrote: > > I want to match word boundaries using the special sequences \b and \B > > of regular expressions. They work OK when using the "standard" > > alphanumeric set [a-zA-Z0-9_]. But I would like them to work with > > character set which also contains various "national characters" > > e.g. ?, ?, ?, ?, ?, ?, ? etc. and their uppercase equivalents. > > > > Locale doesn't seem to be the proper way to do it > > are you sure? > > >>> import locale > >>> locale.setlocale(locale.LC_ALL, "") > 'Swedish_Sweden.1252' > >>> import re > >>> re.findall(r"\b...\b", "spam, egg, bacon, and ???") > ['egg', 'and'] > >>> re.findall(r"(?L)\b...\b", "spam, egg, bacon, and ???") > ['egg', 'and', '???'] Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From neelk at alum.mit.edu Tue Mar 20 22:15:11 2001 From: neelk at alum.mit.edu (Neelakantan Krishnaswami) Date: 21 Mar 2001 03:15:11 GMT Subject: Yet Another PEP: Query Protocol Interface or __query__ References: <99917n$2jf$1@panix6.panix.com> Message-ID: On 20 Mar 2001 17:47:35 -0800, Aahz Maruch wrote: >[posted & e-mailed] > >In article , >Clark C. Evans wrote: >> >> A new built-in method, __query__ is proposed. This method has >> a single argument, an interface protocol identifier, and either >> returns an object supporting the given protocol, or throws an >> unknown exception. [...] > > [...] > > Most importantly, how does one find out what interfaces an object *does* > support? Why is this important? If you are writing some client code, presumably all you care about is that the object you receive supports certain interfaces X, Y and Z that you are using. It wouldn't seem to matter at all what -other- interfaces it supports. I can see heavy-duty reflective programs wanting this capability, but it doesn't seem like something that would be used very often in regular code. So perhaps it is better left out of the first draft. Neel From Dan.Rolander at marriott.com Fri Mar 23 08:43:10 2001 From: Dan.Rolander at marriott.com (Rolander, Dan) Date: Fri, 23 Mar 2001 08:43:10 -0500 Subject: Good GUI for Python Message-ID: <6176E3D8E36FD111B58900805FA7E0F80CCF6471@mcnc-mdm1-ex01> I think wxPython is *very* easy to use, if you can maneuver your way through the C++ documentation. Dan -----Original Message----- From: winson at mdsserv.mds.com.tw [mailto:winson at mdsserv.mds.com.tw] Sent: Thursday, March 22, 2001 9:19 PM To: Python List Subject: Good GUI for Python Hi, All I surveyed 3 GUI framework for Python including wxPython, PythonWin's included win32ui and Tkinter. My development environment is Mark Hammond's PythonWin downloaded from ActiveStates. These're my issues: First, ActiveStates' Python tool cannot support Tkinter and I confirmed with their stuff. So Tkinter maybe good, but not compatible with PythonWin. Second, Mark's masterpiece win32ui and total MFC solution is excellent, but I'd wanna bind on Windows platform. Third, wxPython sounds great but not so easy as win32ui. Is there any suggestions ? Change my develop environment or is there another good gui for me ?? -- Best Regards, Winson Chang 3F, 2, 150 Lane, Sec. 5, Hsin I Rd., Taipei, Taiwan, R.O.C. Tel: +886-2-27225333 ext 376 Fax: +886-2-27222330 Email: winson at mdsserv.mds.com.tw -------------- next part -------------- An HTML attachment was scrubbed... URL: From qrczak at knm.org.pl Tue Mar 13 13:22:16 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 13 Mar 2001 18:22:16 GMT Subject: From SETL to Python translation References: Message-ID: Mon, 12 Mar 2001 00:55:06 -0500, Tim Peters pisze: > > if #(odds := {x in nodes | odd(#G{x})}) > 2 then > > is the Python: > > odds = [] > for x in nodes: > successors = [y for (z, y) in G if z == x] > if len(successors) % 2: > odds.append(x) > if len(odds) > 2: Or: def successors(G, x): return [y for (z, y) in G if z == x] odds = [x for x in nodes if len(successors(G, x)) % 2] if len(odds) > 2: -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From ruediger.maehl at dzsh.de Thu Mar 29 04:23:19 2001 From: ruediger.maehl at dzsh.de (Ruediger Maehl) Date: Thu, 29 Mar 2001 11:23:19 +0200 Subject: i need help on builtin function math References: Message-ID: Marcus Konermann schrieb in Nachricht ... >i want to use the sqrt() function of the builtin funtion math in that >kind: > >import math >... >a=0 >a=sqrt(whatever) > Try this: >>> import math >>> a = 0 >>> a = sqrt(34) Traceback (innermost last): File "", line 1, in ? NameError: There is no variable named 'sqrt' >>> a = math.sqrt(34) >>> a 5.8309518948453007 or this: >>> from math import * >>> a = sqrt(34) >>> a 5.8309518948453007 HTH, R?diger From jim.vickroy at noaa.gov Fri Mar 9 16:26:02 2001 From: jim.vickroy at noaa.gov (j vickroy) Date: Fri, 09 Mar 2001 14:26:02 -0700 Subject: how to make a function thread-safe ? Message-ID: <3AA94A6A.50138001@noaa.gov> If a function may be applied (simultaneously) by multiple threads is the safe (correct) procedure to wrap the function inside a class and have each thread create its own instance of the class? Thanks From neelk at alum.mit.edu Fri Mar 16 23:01:06 2001 From: neelk at alum.mit.edu (Neelakantan Krishnaswami) Date: 17 Mar 2001 04:01:06 GMT Subject: Who's minister of propaganda this week? References: <98otuq0nnf@news1.newsguy.com> <98q6ro2uoa@news2.newsguy.com> <98t8830nlb@news1.newsguy.com> Message-ID: On Fri, 16 Mar 2001 15:33:08 +0100, Alex Martelli wrote: >"Neelakantan Krishnaswami" wrote in message >news:slrn9b2u0r.j74.neelk at alum.mit.edu... > [snip] >> > Keying a dict on class has the unfortunate side-effect of >> > not allowing polymorphism by inheritance -- objects of classes >> > _derived from_ the one used as the key will not match. >> > >> > You can preserve this basic idea by using as key, instead of the >> > class, some ad-hoc attribute which will be inherited (if it IS > [snip] >> I actually have a function that walks the class tree checking it >> against the dictionary, which solves this problem. You don't need to >> add a special attribute in Python since __class__ gives you what you >> need for free. > > ...except it doesn't, because it's _not_ inherited -- you have > to 'manually' walk the directed acyclic graph (tree? what tree? > we have _multiple_ inheritance:-) or iterate through the dictionary's > keys (assumed to be types) using isinstance for each on your > object. Okay, I don't understand what you're saying at all. If I call __class__ on an object, I get its class. Now, I can ask each class what its superclasses are using the __bases__ attribute on each class. This is okay to leave as a function, because Python promises to walk the class heterarchy (happy? :) in a depth-first left-to-right order. So I have a dictionary like this >>> d {: 2, : 3, : 1} and when I call lookup(d, Baz()) where Baz is a direct subclass of Foo, it will return 1. (C types are easy to handle, because they don't admit any subtyping.) Am I off-base here? >> I only added it to my toolkit recently, though, sine I tend to use >> classes like algebraic data types in ML or Haskell -- as tagged >> variants rather than designed for user-extension. I find >> subclassing friendly designs are a lot harder to design in a way >> that doesn't reveal too much internal structure. > > Inheritance (of implementation) is strong coupling, yes. But, > it IS a very handy implementation technique [...] No disagreement here. I'm just hesitant to use it much because I don't want to accidentally break some invariant I accidentally left out of my unit tests 6 months ago. :) > Here's a sketch of a general-by-type dispatcher module to ensure one > can dispatch on either type OR class (and in the latter case gets > inheritance by default, unless it's explicitly overridden): This looks a lot like the one I have, except that I pass all information in arguments, and you've factored into smaller functions. (Good for you!) Neel From jmg at ecs.soton.ac.uk Wed Mar 14 05:26:10 2001 From: jmg at ecs.soton.ac.uk (Jacek Generowicz) Date: 14 Mar 2001 10:26:10 +0000 Subject: Extending Python: rewriting a single method in C References: <98l1i901k4u@news1.newsguy.com> <98m6g20fgv@news1.newsguy.com> Message-ID: "Alex Martelli" writes: > "Jacek Generowicz" wrote in message > news:g0lmq9xxz0.fsf at scumbag.ecs.soton.ac.uk... > [snip] > > As I understand it, I have to provide a __getattr__ method in my > > python class which will get called when I use PyObject_GetAttr. (If > > this is so then I don't see why the function isn't automatically > > provided; any creative definition---ie differing from the blatantly > > obvious (and hence tedious)---surely only opens the door to > > horrors. Still, mine is not to reason why.) > > You need only provide __getattr__ if you have to do something > special -- and when you do need it, it's nice to have the ability. > But attribute-getting works just fine for simple cases without > you writing anything special! That's what I thought until I tried something like the following: >>> class foo: ... def __init__ ( self, a ): ... self.bar = a ... def show ( self ): ... print self.bar ... >>> a = foo( 4 ) >>> a.show() 4 >>> print a.__getattr__("bar") Traceback (most recent call last): File "", line 1, in ? AttributeError: 'foo' instance has no attribute '__getattr__' So I had a look at some documentation. Let me quote Beazley, page 30: a = x.s # Invokes __getattr__(x,"s") You never know, strager things have happened, let's give it a go : >>> z = __getattr__(foo,"bar") Traceback (most recent call last): File "", line 1, in ? NameError: There is no variable named '__getattr__' Hmmmmm. OK . . . I guess this means that the default implementation is not accessible via __getattr__, but it is available via PyObject_GetAttr ? [Useful references to relevant documentation snipped] > > (Would it be fair to say that the documentaion is, on the whole, less > > that satisfactory ?) > > I find it pretty decent, myself. I guess that it is if you know what you are looking for and where to find it :-) Cheers, Jacek From syver at NOSPAMcyberwatcher.com Fri Mar 16 01:27:48 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Fri, 16 Mar 2001 07:27:48 +0100 Subject: Python and ADO References: <98r9qn$tbi$1@troll.powertech.no> <98rk2k04jt@news2.newsguy.com> Message-ID: <98sbtb$936$1@troll.powertech.no> "Alex Martelli" wrote in message > > > Has anyone considered making a DB API compliant wrapper around MS ADO? > Or > > > isn't this considered worthwhile? > > I _considered_ it often, but never got a round tuit... yet! Ok, then I'll be considering it too, and we will see if I will ever get round to it ;-) From mhuening at zedat.fu-berlin.de Wed Mar 28 10:44:53 2001 From: mhuening at zedat.fu-berlin.de (Matthias Huening) Date: Wed, 28 Mar 2001 17:44:53 +0200 Subject: Speed problems with Python vs. Perl References: <99sv33$8hk$1@news.cineca.it> Message-ID: <99t0u9$2liv2$1@fu-berlin.de> Did you try to avoid re for this simple task and to use the string method 'split' instead (or the string module if you are using 1.5)? It defaults to any whitespace string as separator and should be faster: f = line.split() Matthias From support at internetdiscovery.com Sun Mar 25 22:10:25 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Mon, 26 Mar 2001 03:10:25 GMT Subject: Jython and IDE/debugger References: <9980fp$sm0$1@news.ost.eltele.no> Message-ID: <3abeaf46.110041538@24.0.228.33> On Tue, 20 Mar 2001 17:28:45 +0100, "Steinar Eriksen" wrote: >I would like to prototype my Java application in Jython, byt calling up >Jython scripts from my Java classes. Whilst developing my Jython scripts; I >am looking for some IDE or debugging tool to help me test my code. Anyone >seen that available for Jython ? Tkinter was ported to jPython using JNI (http://sourceforge.net/projects/jtkinter) Could it be brought up to date for jython 2? I know it is not a "pure" Java solution, but there are a lot of people like myself who need to use some of the massive Java libraries, and are looking to Jython to help provide a practical solution. Moreover, it would help to extend the completeness of CPython/Jython to include GUI work, wich is an added plus. >I know the Python IDE's are excellent, but since the libraries differ I >suppose they are not applicable, Finn, how hard would it be to bring it up to date for jython 2? Many thanks, Mike. From support at internetdiscovery.com Sat Mar 17 16:20:19 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Sat, 17 Mar 2001 21:20:19 GMT Subject: How do I avoid the Tkinter 30 msec polling loop. References: <98s781$7a8o$1@fido.engr.sgi.com> Message-ID: <3ab3d191.6695740@24.0.228.33> On 16 Mar 2001 05:10:25 GMT, pj at sgi.com (Paul Jackson) wrote: > > [Sorry if this is a repeat - I don't see my post from yesterday. -pj] > >I have a little 'biff' (BSD-speak for email watchdog) like >program, written in Python, using Tkinter, that shows one of >two text messages in a little window, depending on whether my >email box has new mail in it. The app polls the mailbox every >minute, with an os.stat() call. > >Unfortunately, the app consumes cpu almost continuously, >even when I wish it would sleep for the minute. > >The same busy loop can be see even on the smallest "Hello, >world" example, such as: > > import Tkinter > root = Tkinter.Tk() > label = Tkinter.Label(root, text = "Hello, world.") > label.pack() > root.mainloop() > >A system call trace of the above, on Irix 6.5.11, using > > Python 2.1a1 (#23, Feb 2 2001, 17:25:50) [C] on irix6, > >shows the following 2 select() system calls, every 30 msec, >non-stop: > > hello.py( 3693): select(4, [3], [], [], {sec=0, usec=0}) > hello.py( 3693): select(0, 0, 0, 0, {sec=0, usec=20000}) > >This is on a system with a 10 msec TICK, and a timeout on >the select of 20 msec, which ends up taking 30 msec each >loop (timeouts are rounded up to the next TICK). > >=== > >Anyhow, is there anyway to stop or radically slow this loop? The short answer is no - you cannot stop or radically slow this loop. It comes from the way _tkinter.c is handling threads, tcl events and Python signals. I spoke to Guido about it at Python9, and am hoping we can do a non-looping solution using Tcl_CreateEventSource. For the long answer, look at the attached email I sent to someone who kindly offered to help take a look at this problem. > I won't rest till it's the best ... > Manager, Linux System Software > Paul Jackson 1.650.933.1373 If you can't rest until it's the best, and if you know Tcl and Python, send me email, and maybe you can help solve this misfeature. Mike. ---------------------------------------------------------------------------------------- At 03:26 PM 1/29/01 +0100, you wrote: Subject: Fundamental Tkinter inefficiency? I'm looking at the implementation of Tk_MainLoop in _tkinter.c: quitMainLoop = 0; while (Tk_GetNumMainWindows() > threshold && !quitMainLoop && !errorInCmd) { int result; #ifdef WITH_THREAD Py_BEGIN_ALLOW_THREADS PyThread_acquire_lock(tcl_lock, 1); tcl_tstate = tstate; result = Tcl_DoOneEvent(TCL_DONT_WAIT); tcl_tstate = NULL; PyThread_release_lock(tcl_lock); if (result == 0) Sleep(20); Py_END_ALLOW_THREADS #else result = Tcl_DoOneEvent(0); #endif if (PyErr_CheckSignals() != 0) return NULL; if (result < 0) break; } and was wondering if it would be better to use a Tcl Event procedure with a MaxBlock time to check the Python signals, instead of calling Sleep. Then it wouldn't be calling a hard sleep. This means Python burns a fair amount of CPU idling. You can see a significant difference between Tk applications and the identical TkInter application for CPU usage, I suspect because of this tight Sleep loop. This even if you don't "use" threads - it's if you compile with threads enabled. The idea would be to establish a Tcl Event procedure that would check for Python signals every (say) 100 msec., and handle Tcl events all of the rest of the time. Does anyone know how to do this in Tcl - it shouldn't be more than a few lines I suspect. Look at Tcl_CreateEventSource and Tcl_SetMaxBlockTime in tcl/generic/tclNotify.c Many thanks, Mike. From moshez at zadka.site.co.il Tue Mar 20 04:24:49 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Tue, 20 Mar 2001 11:24:49 +0200 Subject: [Very Long (11K)] Numeric PEPs, first public posts In-Reply-To: <99669h$so4$1@panix6.panix.com> References: <99669h$so4$1@panix6.panix.com>, Message-ID: On 19 Mar 2001 15:55:29 -0800, aahz at panix.com (Aahz Maruch) wrote: > Because a lot of people don't have time to subscribe to every mailing > list that comes along. I respectfully disagree. The numerics sig has managed to get many people that probably don't read c.l.py subscribed to it. ''' The champion offers to take the discussion off-line and specifies a location (e.g. egroups, python.org, Roundup). ''' > If I have the time, I'm going to be posting some > comments about your proposal, and they're going to be here on c.l.py. Comments posted here have much less of a chance to get into my PEPs (as open issues or as changes), simply because here I have *less* of a peer review (for example, I don't think Paul D. or Guido read c.l.py regularily, and their opinions are very important to me.) So, you're much better off CCing python-numerics. (I do try to read c.l.py regularily, and I try to integrate things. But I am a finite person, and python-numerics seems to me to strike a perfect balance between mailing me personally (people accused me of being unfair in the past -- on a public mailing list they have the feeling that it doesn't go into a black hole) and being on .c.l.py (which I occasioanlly have to purge do to my thoroughly non-robotic nature)). > Note carefully this quote from PEP 1: > > A PEP that has not been discussed on python-list and python-dev will > not be accepted for review. However, wherever possible, long > open-ended discussions on public mailing lists should be avoided. Of course. But the PEP won't be ''accepted for review'' anyway until all the Open Issues are resolved, and that has much less of a chance happening here. -- "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than Python? looking for someplace else to grab power."|YODA: No...no... no. Quicker, -- Wichert Akkerman (on debian-private)| easier, more seductive. For public key, finger moshez at debian.org |http://www.{python,debian,gnu}.org From syver at NOSPAMcyberwatcher.com Tue Mar 27 14:08:22 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Tue, 27 Mar 2001 21:08:22 +0200 Subject: Threading legality/morality References: <99nnbv$phs$1@panix6.panix.com> <99qa3v$6e0$1@panix6.panix.com> Message-ID: <99qoje$o6q$1@troll.powertech.no> "Aahz Maruch" wrote > There is a misfeature in urllib such that the standard FancyURLOpener > class prompts for input if it gets an HTTP 401 (authorization needed). > You probably pressed ENTER. Think so yes, how can it be fixed? I am pretty well versed in python but a pointer could be nice so I didn't use quite so much time on it. From gtalvola at nameconnector.com Tue Mar 20 11:10:02 2001 From: gtalvola at nameconnector.com (Geoff Talvola) Date: Tue, 20 Mar 2001 11:10:02 -0500 Subject: Python and ADO References: <98r9qn$tbi$1@troll.powertech.no> <3AB130B7.6A09C3F1@NameConnector.com> Message-ID: <3AB780DA.70B5DD4@NameConnector.com> Geoff Talvola wrote: > Syver Enstad wrote: > > > Has anyone considered making a DB API compliant wrapper around MS ADO? Or > > isn't this considered worthwhile? > > > > As ADO is the database api that I use, I could have a look at making a > > wrapper for it if there was any interest in it and if making such a thing is > > not too involved. > > Michel Orengo already wrote a preliminary version of a DB-API wrapper for ADO but I don't think he ever finished it. I have a copy of it, but I have never actually tried it. If you can't find it in the newsgroup archives, drop me an email and I'll send you a copy. > > And I do think this would be quite useful... I've now sent a copy of this to at least a dozen people, so there's clearly a lot of interest for a DB-API ADO wrapper. At least one of you is bound to take it and make improvements -- please share it with the list if and when you do; a lot of people will appreciate your work! -- - Geoff Talvola Parlance Corporation gtalvola at NameConnector.com From not.this at seebelow.org Thu Mar 15 23:25:07 2001 From: not.this at seebelow.org (Grant Griffin) Date: Thu, 15 Mar 2001 22:25:07 -0600 Subject: inverse of asctime References: <98rfn6016rf@drn.newsguy.com> Message-ID: <3AB195A3.CFC511@seebelow.org> Andrew Markebo wrote: > > / Grant Griffin wrote: > | Hi Gang, > | > | I'm in the market for the inverse of asctime(). I looked in the time module but > | couldn't find it. (Nope, strptime isn't available on my Windows installation.) > | Seems like there oughtta be sucha thing somewhere. > > Ehm.. I actually have a strptime.py, used by RogueWave ;-) *stretches > his back* You can locate it at my mismaintained code-page, will have > to make it come back to life some day. > > http://www.fukt.hk-r.se/~flognat/hacks/ > http://www.fukt.hk-r.se/~flognat/hacks/strptime.py > > *stretching-his-backly-yours* > > /Andy > > BTW Have you actually tried searching the python site :-) > Nope--not a bad idea, thanks. I'm embarassed that I hadn't thought of it: after I had searched Google (Deja) and came up with nothing, the very next thing I thought of was to ask you folks. (That way, I'll be able to find it in Google _next_ time. ) Your code looks great, but as it turned out, I only needed a conversion for purposes of sorting in terms of day, so I just wrote a little funtion that generates a bogus "day number", which worked OK for that. (So I guess I must be deliberately wasting your time .) somebody-oughtta-should-write-a-pep-to-add-strptime.py-to-the -time-module--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From max at alcyone.com Tue Mar 13 11:59:42 2001 From: max at alcyone.com (Erik Max Francis) Date: Tue, 13 Mar 2001 08:59:42 -0800 Subject: What's wrong with me/Python ? References: <3AAE0652.D68F253E@daimlerchrysler.com> Message-ID: <3AAE51FE.AAB1234C@alcyone.com> Alexander Stirzel wrote: > I just wrote a small script for killing some hanging netscape > processes, > the source is listed below. > Now if I run this script I get this error message: > > 8<----------- error message ----------------------------- > Traceback (most recent call last): > File "/usr/sbin/netscape-killer.py", line 11, in ? > splitted = string.split(line) > NameError: There is no variable named 'string' > 8<----------- error message ----------------------------- > > Now here's the script: > > 8<------------ script ----------------------------------- > #!/usr/local/bin/python > import os > import time ... > What did I do wrong? And why does Python want a "variable named > 'string'" here? Because you're referencing `string' and it's never seen the variable before. You're missing an `import string' statement at the top. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ I am a gentlemen: I live by robbing the poor. \__/ George Bernard Shaw Kepler's laws / http://www.alcyone.com/max/physics/kepler/ A proof of Kepler's laws. From aleaxit at yahoo.com Fri Mar 23 01:43:30 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 23 Mar 2001 07:43:30 +0100 Subject: extending the built in dictionary type References: Message-ID: <99eren016ps@news2.newsguy.com> "Steve Holden" wrote in message news:YJzu6.12928$_46.482847 at e420r-atl2.usenetserver.com... > Look in the library and inherit from UserDict. A search on UserDict revelas > that this probably isn't quite as FAQtually recorded as it might be. Or else, as for any other built-in object, use the "automatic delegation in lieu of inheritance" pattern. But, from context, it seems Robin is trying to extend dictionaries _in a C-coded extension_, which is a whole 'nother ball of wax...: > > Seems that although it exists I can't chain the original mapp_methods of > > dictobject as that is not visible outside pythonxx.dll. So is there an > > easier way to get at these internal types? Alex From Eugene.Leitl at lrz.uni-muenchen.de Wed Mar 7 04:41:57 2001 From: Eugene.Leitl at lrz.uni-muenchen.de (Eugene Leitl) Date: Wed, 7 Mar 2001 10:41:57 +0100 (MET) Subject: GadFly and gfplus.py working with Python 2.0? Message-ID: See subject. Aye, nay, maybe? TIA, -- Eugene ______________________________________________________________ ICBMTO : N48 10'07'' E011 33'53'' http://www.lrz.de/~ui22204 57F9CFD3: ED90 0433 EB74 E4A9 537F CFF5 86E7 629B 57F9 CFD3 From bowman at montana.com Sun Mar 18 10:21:57 2001 From: bowman at montana.com (bowman) Date: Sun, 18 Mar 2001 08:21:57 -0700 Subject: windows script host and python References: <%tKr6.2570$pX.26174@news1.onlynews.com> <98oq3r$1e0$1@troll.powertech.no> <8Aps6.104$pl.1515@newsfeed.slurp.net> <98tc4d0rmk@news1.newsguy.com> Message-ID: Tim Roberts wrote in message > > > >Here, for example, is the "list all running processes" WMI scripting > >example translated into Python: > > Cool! Is this supposed to be NT-only? It doesn't fly on my Win98 box. http://msdn.microsoft.com/downloads/default.asp?URL=/code/sample.asp?url=/ms dn-files/027/001/576/msdncompositedoc.xml don't know if that reference will work. if not, go to msdb.microsoft.com, click on 'downloads' and look for 'Windows Management Instrumentation'. ignore the pessimistic blurb about Win98 SE. no. there is a core WMI that installs on Win9.x and NT. I don't believe it is on NT4.0 by default, but can be installed there. The SDK will install on NT also, but i'm not sure it will install on Win9.x. The problem is the SDK contains the .chm file that is required reading for playing around. it is available on line at msdn.microsoft.com. It is a part of 2000/ME. the WMI is ms's shot at WBEM. The long form to invoke it would be (sorry 'bout the Perl, but the Python calls are very similar): $locator = Win32::OLE->new("WbemScripting.SWbemLocator"); if (!defined $locator) { die "couldn't get the locator object"; } $server = $locator->ConnectServer(); if (!defined $server) { die "couldn't get the server object"; } $processes = $server->InstancesOf("Win32_process"); if (!defined $processes) { die "couldn't get the processes"; } The whole thing is pretty integral to the Win2000 world view. The idea is to reduce TCO by allowing the sysadmin to query all systems in the net. WMI probably gets into the AD implementation,too. wbem is an industry initiative, so in theory one could use the locator to connect to a linux, mac, etc server and access CIM data in a platform independent way. I recently did a unix style 'ps' for NT/2000 in C, and it was about 200 lines of pretty arcane calls into the HKEY_PERFORMANCE_DATA, psapi, ntdll etc to get stuff like the parent pid, user name, ccommand line, etc, with WMI, it take about 10 lines of Python/Perl/JScript/VBScript. the scripts are a little slower, with the native WSH engines and Perl the fastest, and Python lagging a bit. Still quite usable on a 233 mhz Win95 box. From support at internetdiscovery.com Sat Mar 24 07:08:21 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Sat, 24 Mar 2001 12:08:21 GMT Subject: Why Python/Jython? References: <99cl9e$b2b$1@Merlin.et.bocholt.fh-gelsenkirchen.de> Message-ID: <3abc8d36.83155745@24.0.228.33> On Thu, 22 Mar 2001 22:26:59 -0500, "Steve Holden" wrote: >"Steve Purcell" wrote in message >> Programmer performance is usually gauged by coding time and >> number of bugs, both of which are vaguely proportional to the number of >> lines of code in most sane languages*. >> >> * Perl is a noteworthy exception >> >I saw no inconsistency here. Why would Perl be an exception to your rule? It's not a sane language :-) It's like vicegrips: the wrong tool for every job. Mike. From owen at astrono.spamwashington.emu Fri Mar 2 10:59:12 2001 From: owen at astrono.spamwashington.emu (Russell E. Owen) Date: Fri, 02 Mar 2001 07:59:12 -0800 Subject: PEP 227 (was Re: Nested scopes resolution -- you can breathe again!) References: <200102230259.VAA19238@cj20424-a.reston1.va.home.com> <97lqsr0311d@news2.newsguy.com> Message-ID: In article , Robin Becker wrote: >In article , Jeremy >Hylton writes >>Or: global NAME in FUNCTION >> >>def eggs(): >> z = 2 >> def spam(): >> def inner(): >> global x in spam, z in eggs >> x += 1 >> z += x >> x = 23 >> inner() >> >>Jeremy >> >I like that a lot better than having it default possibly wrongly, but >how would this be doable/spelled in the lambda case? As somebody else pointed out, a nice possible notation for that has been proposed. lambda arg1, arg2; externalVar1, externalVar2: expression One interesting question is whether we could just implement that and throw out the rest of the nested scope proposal. If so, that gets my vote, followed by an explicit keyword for external variables, followed by chucking the whole thing and living with ugly lambdas. I loathe the idea of externally declared variables polluting a function's namespace. That works fine in languages that make you declare all variables, but I do not think it is safe or reasonable in Python. -- Russell From aleaxit at yahoo.com Wed Mar 14 09:02:20 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 14 Mar 2001 15:02:20 +0100 Subject: Extending Python: rewriting a single method in C References: <98l1i901k4u@news1.newsguy.com> <98m6g20fgv@news1.newsguy.com> Message-ID: <98ntl80vrp@news2.newsguy.com> "Jacek Generowicz" wrote in message news:g0g0ggy7ct.fsf at scumbag.ecs.soton.ac.uk... [snip] > > But attribute-getting works just fine for simple cases without > > you writing anything special! [snip] > OK . . . I guess this means that the default implementation is not > accessible via __getattr__, but it is available via PyObject_GetAttr ? Yes, and also available via builtin-function getattr. > > > (Would it be fair to say that the documentaion is, on the whole, less > > > that satisfactory ?) > > > > I find it pretty decent, myself. > > I guess that it is if you know what you are looking for and where to > find it :-) With the HTML-Help form of the docs (I forget the helpful person from whose site I downloaded that from), searching throughout the docs is instantaneous -- which roughly makes up for defects in the index and/or organizational problems in the docs themselves. It does help to read the sources (which are very well organized, clear, and readable) -- except that sometimes one may be left in doubt if something "just happens to work this way today" vs "is _designed_ to work this way forever":-). Alex From root at [127.0.0.1] Thu Mar 29 02:11:43 2001 From: root at [127.0.0.1] (deadmeat) Date: Thu, 29 Mar 2001 07:11:43 GMT Subject: list vs tuple References: <000e01c0b7ac$25f9f510$b503a8c0@activestate.ca> <2595ctkf19m63bmkd62dq73cgvbl6d002j@4ax.com> Message-ID: > >>> dir_list = ('/path', '/foo/bar', '/baz/bat/files') > >>> print dir_list > ('/path', '/foo/bar', '/baz/bat/files') > >>> dir_list = ('/usr/bin/env', '/usr/bin', '') > >>> print dir_list > ('/usr/bin/env', '/usr/bin', '') > I don't see how dir_list is a constant? The values within it are read-only, not the name 'dir_list' dir_list[0] = 'this will fail' convert to a list and run it again it'll work fine. From vlouie at telusplanet.net Sun Mar 25 16:44:06 2001 From: vlouie at telusplanet.net (Victor Louie) Date: Sun, 25 Mar 2001 21:44:06 GMT Subject: Is it possible to sort a dictionary? Message-ID: Hi I was just wondering if anyone knows how to sort a dictionary by value...since the dictionary is and where my value is a list. Thanks in advance Victor From thomas at xs4all.net Wed Mar 7 17:30:07 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 7 Mar 2001 23:30:07 +0100 Subject: setjmp.h In-Reply-To: <3AA52B80.507E23A7@packeteer.com>; from nospam@packeteer.com on Tue, Mar 06, 2001 at 10:25:04AM -0800 References: <3AA52B80.507E23A7@packeteer.com> Message-ID: <20010307233007.E404@xs4all.nl> On Tue, Mar 06, 2001 at 10:25:04AM -0800, Bob Purvy wrote: > I'm trying to port Python 2.0 to pSOS (yes, that's just our little cross > to bear here!). I hit a roadblock with pypcre.c: it seems to require > long jumps, and there is no way to configure that out. I'm still > checking whether it's possible for us to enable them in our software, > but we definitely don't have them right now. > Is there any way around this requirement? Maybe an earlier version of > Python? You can probably disable the pre module altogether, which would avoid the use of pypcre.c. Python 2.0 comes with two regular expression engines, 'pre' for the old, Perl Compatible Regular Expression Engine, and 'sre' for the new, unicode aware, much more flexible Secret Labs Regular Expressions Engine. 'sre' is the default, but 'pre' is still around for backward compatiblity. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From ws-news at gmx.at Thu Mar 8 04:54:33 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Thu, 8 Mar 2001 10:54:33 +0100 Subject: pipe problems References: <3AA6D886.4DD8D3A4@iems.nwu.edu> Message-ID: <984045555.82149@newsmaster-04.atnet.at> If there is no data to read, readline it will block for such to become available. I don't think that cout.flush() is of any use, btw. Maybe I'm wrong, but I think data can only be flushed out by the sender of a pipe... Further, what's if the program prints out something in between, or more than 1 line? Maybe you can do the reading in a seperate thread. Alternatively you can try to find out if there _is_ sth you can read. hth werner Leonardo B Lopes wrote in message news:3AA6D886.4DD8D3A4 at iems.nwu.edu... > I use a program that doesn't have readline compiled in. So I figured, it > would be easy to add a python wrapper around it. So I wrote the wrapper, > using 'cat' as a test command. With 'cat' it works fine. But when I try > using another program, such as 'python', the program just hangs at > readline(). Anybody know how to accomplish this? Here is the code: > > #!/usr/local/bin/python > > import sys,os > import cmd > > class Amplcmd(cmd.Cmd): > > def __init__(self): > cmd.Cmd.__init__(self) > self.cin,self.cout = os.popen2('/usr/local/bin/python') > > def default(self,line): > self.cin.write(line+'\n') > self.cin.flush() > self.cout.flush() > print self.cout.readline(), > > def do_EOF(self,line): > sys.exit() > > mycmd = Amplcmd() > mycmd.cmdloop() > > > > -- > ======================================================================= > Leonardo B. Lopes leo at iems.nwu.edu > Ph.D. Student (847)491-8470 > IEMS - Northwestern University http://www.iems.nwu.edu/~leo From deblNonOspammy at theworld.com Wed Mar 14 23:14:51 2001 From: deblNonOspammy at theworld.com (David Lees) Date: Thu, 15 Mar 2001 04:14:51 GMT Subject: Help doing simple threading References: Message-ID: <3AB041C6.FDDB84D3@theworld.com> Thanks, these comment were quite helpful. The most serious error was 'a)'. when I just put the main to sleep after starting up the threads it worked fine. The problem was that I was printing out the array values, before all the threads finished executing. David Andreas Jung wrote: > > > Your code has several problems: > > a) You don't synchronize your main thread with the threads you start. > That means your main thread continues running BEFORE the > started threads make any work. > > b) Modifying shared resources within threads is dangerous. Think > about using locks to get rid of this problem. > > c) Try the threading module. It gives you a better control and programmer > interface to work with thread in Python. > > ---- > Andreas Jung (andreas at digicool.com) > Digital Creations - www.digicool.com, www.zope.org From rcameszREMOVETHIS at dds.removethistoo.nl Sat Mar 31 17:29:20 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Sat, 31 Mar 2001 22:29:20 GMT Subject: Gaussian line profile using numeric python References: <3ac31698@zfree.co.nz> Message-ID: Konrad Hinsen wrote: >"John J. Lee" writes: > >> > 2) If you work with large data sets, you ought to use FFTs to >> > compute the convolution, that's O(N*log(N)) in the size of the >> > data set, instead of O(N**2) for the straightforward method. >> > Any good book on FFTs should explain how this works in detail. >> >> but you probably don't need to know in detail, it boils down to >> >> inv_FFT(FFT(data)*FFT(kernel)) > >Except for zero-padding in case of non-periodic signals. That's why >I always recommend to look at a detailed description before doing >this; some of my colleagues keep telling me that FFT techniques "don't >work", and I suspect this is the reason. Well, why dont you/they try a different kind of integral transform, that might give a better result. Perhaps something like wavelets? Of course, a fast algorithm must be available to do the transform and its inverse but if there is it might be worth to do some experimenting. Robert Amesz From kalle at gnupung.net Tue Mar 27 08:12:30 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Tue, 27 Mar 2001 15:12:30 +0200 Subject: Reading e-mail body (newbie) In-Reply-To: <3AC08CBB.52061537@geo.co.za>; from jacobus@geo.co.za on Tue, Mar 27, 2001 at 02:51:08PM +0200 References: <3AC08CBB.52061537@geo.co.za> Message-ID: <20010327151230.A17310@father> Sez Jacobus van der Merwe: > Hi, > > I have a script to which e-mail to a certain address is relayed. > > I need to write the body of the e-mail to a file. > > I use > > rfc822.Message(sys.stdin) > > to read the e-mail, but I can't figure out how to access the body. > It seems that rfc822 only have methods to access the headers. ???? Read from rfcobj.fp, I think: rfcobj = rfc822.Message(sys.stdin) body = rfcobj.fp.read() Peace, Kalle -- Email: kalle at gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From francois.granger at free.fr Fri Mar 16 15:43:28 2001 From: francois.granger at free.fr (=?ISO-8859-1?Q?Fran=E7ois_Granger?=) Date: Fri, 16 Mar 2001 20:43:28 GMT Subject: Python style questions References: <98tb91$9t9$1@saltmine.radix.net> <98tdu1$cfk$1@panix2.panix.com> Message-ID: <1eqdo5u.1xxmzfi2kjk0qN%francois.granger@free.fr> Aahz Maruch wrote: > In article <98tb91$9t9$1 at saltmine.radix.net>, > Cary O'Brien wrote: > >3. I really miss not having a "switch" or "case" statement. Sniff. > Use a dictionary. Some code snippet as exemple ? At this point, I can't imagine a good way, and I don't remember seeing something on this. -- Le "bon sens" ?tant la chose du monde la mieux partag?e, il est normal que chacun en ai si peu - Inconnu From fredrik at pythonware.com Thu Mar 29 03:53:32 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 29 Mar 2001 08:53:32 GMT Subject: htmllib samples References: <3AC2F48E.4EF77C71@aon.at> Message-ID: Oliver Vecernik wrote: > has anyone got some samples or point me to where to find them on how to > implement this module? you mean "use", I assume? http://www.oreilly.com/catalog/pythonsl/chapter/ch05.html#HTMLLIB-MODULE http://www.oreilly.com/catalog/pythonsl/chapter/ch05.html#FORMATTER-MODULE note that when you think you need the htmllib module, you usually want the sgmllib module: http://www.oreilly.com/catalog/pythonsl/chapter/ch05.html#SGMLLIB-MODULE Cheers /F From aleaxit at yahoo.com Tue Mar 13 05:46:28 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 13 Mar 2001 11:46:28 +0100 Subject: Extending Python: rewriting a single method in C References: Message-ID: <98l1i901k4u@news1.newsguy.com> "Jacek Generowicz" wrote in message news:g0ofv6xbj4.fsf at scumbag.ecs.soton.ac.uk... [snip] > AM> > Yes, but I was trying to avoid the function call overhead > AM> > (particularly as one of the functions I need to rewrite is very short > AM> > indeed). > AM> > AM> No way to do that -- the function call overhead is there even > AM> if you call directly from Python to the C extension. > > But isn't the function call overhead greater for calling python > functions than it is for calling the C extensions ? On my old box (Pentium-II 266) I measure about 1 microsecond difference per call, yes: a loop of 1,000 'pass' takes about 1.1 msec, one of 1,000 calls to an empty built-in (which ignores its args and returns None) about 2.2, one of 1,000 calls to a similarly-empty (takes *args, body is 'pass') Python-coded function about 3.2 (that's in WinNT4 SP6, with Python 2). Much of that is overhead of global-name lookup, of course (for uniformity I assigned either kind of function to a global variable and called through that); moving it to a local name is an important optimization: def timecals(afun): start = time.clock() for i in range(1000): afun() stend = time.clock() print stend-start Here, it's about 1.8 msec if the empty C-coded function is passed as the argument, about 2.8 if the Python one is -- so, the global name lookup overhead was about 0.4 msec in each case (and the rest of the empty-loop overhead another 0.7 msec or so, leaving about 0.7 vs 1.7 for C vs Python coded function's _sheer_ call overhead from Python). If microseconds (small fractions thereof on more modern machines, actually) are so crucial, then, yes, you can shave some further tiny fractions this way. > AM> If the function/method is called from a few places, you might > AM> manually inline in there, maybe. > > Not sure I understand what you mean exactly. Are you suggesting that I > call an extension function wherever I would previously have called and > instance method ? Yes. > How do I get at the members of a class in C if that class was defined > in python ? By passing the reference to the instance to the function, and receiving it on the C side as a PyObject* -- you can then call methods and access attributes on it from C, just as you could from Python. See the "O" format code in the documentation of PyArg_ParseTuple (1.7 in the "Extending and Embedding" manual). > JE> In fast_a and fast_b, you can get arguments by using the ParseTuple string > JE> "(Oii)" and then use PyObject_SetAttrString and PyObject_GetAttrString > JE> to store or retrieve attributes (including, if necessary, instance > JE> methods) from the instance by their name. > > Is there an organized reference where I can find the specifications of > all these functions ? All I have come across shows example code, but > no full descriptions of what can/must be done. It's somewhat disorganized. I think Beazley's "Python Essential Reference" (New Riders) is your best bet among current books (but it only covers Python 1.5.2). > Maybe some kind soul could show me what the correct code for a minimal > extension type is ? > > For example, I tried to write an extension type equivalent to > > class foo: > def __init__ ( self, a ): > self.a = a > def show ( self ): > print a > > My various attempts, almost work, but there is always something not > quite right. Getting equivalence to this is not going to be easy -- the type/class separation hits hard, and calling Python's "print" statement from C is not quite trivial either. > Incidentally, why does the xxobject.c file in the Objects directory of the > Python distribution contain no initxxobject function ? Hmmm, because it's meant for a "real builtin type" (in a hypothetical modification of Python) rather than for an extension...? Alex From juergen0509 at web.de Sun Mar 4 16:07:42 2001 From: juergen0509 at web.de (Juergen Bocklage) Date: Sun, 04 Mar 2001 22:07:42 +0100 Subject: should i or shouldnt i? References: <1103_983731947@breakdown> Message-ID: <3AA2AE9E.91D351C@web.de> Fist take a look at the tutorial which comes with the python distribution. When you still think that you need a book, I'm happy with the Quick Python Book from Daryl Harms and Kenneth Mc Donald. Also the is a online book Dive into Python from Mark Pilgrim (www.diveintopython.org), which makes a good impression. - JB matt wrote: > > i'm doing a course which revolves around smalltalk, but the pace is a bit slow for me. > i was thinking of tackling another language to fill the hours and wondered about python. > am i mad or would it be a good idea? what can python offer me? if theres 1 book to buy (ive already downloaded eckels book), which should it be? > i run win98 and linux. > thanks -- Juergen Bocklage ================================ mailto:juergen.bocklage at gmx.net From eye at niksula.hut.fi Tue Mar 20 12:16:46 2001 From: eye at niksula.hut.fi (Petri Mikael Kuittinen) Date: 20 Mar 2001 19:16:46 +0200 Subject: Regular expressions and non-standard character set Message-ID: I want to match word boundaries using the special sequences \b and \B of regular expressions. They work OK when using the "standard" alphanumeric set [a-zA-Z0-9_]. But I would like them to work with character set which also contains various "national characters" e.g. ?, ?, ?, ?, ?, ?, ? etc. and their uppercase equivalents. Locale doesn't seem to be the proper way to do it and appending these characters to string.letters, string.uppercase, string.lowercase, before import re doesn't help at all. What is the proper way of doing it? Petri -- <(O)> Petri Kuittinen, also known as Eye, Dj Eye or Peku <(O)> <(O)> ADDRESS: Postipuuntie 10 A 14, FIN-02600 Espoo, Finland <(O)> <(O)> EMAIL: eye at iki.fi WWW: http://www.iki.fi/~eye/ PHONE: 09-5472380 <(O)> ~If dandelions were hard to grow, they would be most welcome on any lawn. From kca17 at dial.pipex.com Thu Mar 29 08:22:10 2001 From: kca17 at dial.pipex.com (Eddie and Babs) Date: Thu, 29 Mar 2001 14:22:10 +0100 Subject: Quoted identifiers in Python? Message-ID: <3ac3387f$0$12248$cc9e4d1f@news.dial.pipex.com> While reading an article about the Dylan language a few years ago, I was surprised to find that you could have quoted identifiers (ie, variable and function names, etc). So you could have a function named "turn around" (with quotes) and then call it using something like: "turn around"(xxx) The idea is that you can put any characters within the quotes. NOW... would this be a good thing for Python to have in the future? It would make element access consistent with subscripting:- x = obj."Ivor the engine" ...would be the same as x = obj["Ivor the engine"] ..no? But the particular advantage would be with __getattr__ (ie, defining attribute access for a class). It seems that the most obvious use of __getattr__ is to allow Python-esque access to a dynamic system external to Python. For example, you could have a class which allowed access to the file system via Python objects:- import filesys # MyHD is a hard disk which contains the path "MyHD/projects/web/index". fileObj = FileSys() textOfFile = fileObj.MyHD.projects.web.index.readAll() ...etc. This falls down (slightly) when the file is called "index.htm", as the dot is interpreted incorrectly by Python. What you need to be able to say is:- textOfFile = fileObj.MyHD.projects.web."index.htm".readAll() You could of course use the subscripting notation (MyHD.projects.web["index.htm"]) but this seems to disrupt the flow somewhat. Maybe this idea is flawed in ways I can't see, but I thought it was at least worth mentioning. Cheers, &. From tim.one at home.com Mon Mar 12 23:41:37 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 12 Mar 2001 23:41:37 -0500 Subject: This math scares me In-Reply-To: Message-ID: [Andrew Koenig] > I'm curious -- Does Python now follow either the IEEE or the more > restrictive Scheme rules for floating-point conversion? > ... All aspects of Python fp are inherited from whatever the platform C compiler and libraries happen to do. repr() conversion to string uses the platform sprintf's %.17g format; str() conversion %.12g; both are fiddled just a little to ensure that an exponent or a decimal point (or both) appears. string->float is a x-platform adventure, since some platforms can't read back all the C doubles they print (thinking of infinities and NaNs here); Python inherits that too, whenever it happens. it's-all-x3j11's-fault-ly y'rs - tim From loewis at informatik.hu-berlin.de Tue Mar 20 15:14:55 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 20 Mar 2001 21:14:55 +0100 Subject: New PEP: The directive statement References: Message-ID: "Clark C. Evans" writes: > > Introducing 'directive' as a new keyword might cause > > incompatibilities with existing code. Following the guideline in > > [1], in the initial implementation of this specification, > > directive is a new keyword only if it was used in a valid > > directive_statement (i.e. if it appeared as the first non-string > > token in a module). > > I'm new to python, but why not have the module have a built-in > set of directives as a list? As this could then be an attribute > of many different objects, including modules. > > __directives__ = { 'transitional', 'nested-scopes' } The main problem is that the intended use really is not for run-time semantics, i.e. the interpreter won't dynamically look at __directives__ and do magic things. Instead, it is meant as a "compile-time" thing, i.e. with effects when the source code is interpreted. In that sense, it is the second declaration in python (after global); normally, Python statements are actions (including def and class). That is also why the PEP 236 proposal (__future__ imports) finds that much resistance: it uses an action statement to declare things. Regards, Martin P.S. If "directive transitional nested_scopes" is approved, an interesting observation is that all Python declarations deal with variable visibility and name binding. From grante at visi.com Wed Mar 7 14:17:22 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 07 Mar 2001 19:17:22 GMT Subject: ANNOUNCE: 2.1b1 SRPM References: <3aa861c3.1122387@news.newsguy.com> Message-ID: <6Pvp6.1459$y6.239152@ruti.visi.com> In article <3aa861c3.1122387 at news.newsguy.com>, Owen F. Ransen wrote: >On Tue, 6 Mar 2001 22:48:35 -0700, Sean Reifschneider > wrote: > >>The SRPM is available at: >What is an SRPM? RPM is Redhat Package Manager: an open-source project that provides an infrastructure to install/uninstall packages under Unix (with support for package dependancies). Packages can be distribute as binaries or sources. SRPM is a Source RPM package that contains package sources as well as configuration build information. A binary package is often referred to as an "RPM". (e.g. I found a SPARC Python2.1 RPM at .....) RPM is the "native" package format used by several Linux distributions (RedHat, Mandrake, Caldera?). -- Grant Edwards grante Yow! An INK-LING? Sure -- at TAKE one!! Did you BUY any visi.com COMMUNIST UNIFORMS?? From fpm at u.washington.edu Thu Mar 8 17:26:10 2001 From: fpm at u.washington.edu (Frank Miles) Date: 8 Mar 2001 22:26:10 GMT Subject: Database with Python ?? References: <988vmn$t77$05$1@news.t-online.com> Message-ID: <9890u2$uiq$1@nntp6.u.washington.edu> In article <988vmn$t77$05$1 at news.t-online.com>, Thomas Mundt wrote: >Has Python a own database language and do someone know a link to a Tutorial >in database-working with python? pygresql is commonly available with postgres. There's some sort of python link to mysql as well. HTH... -frank -- From fredrik at pythonware.com Thu Mar 22 10:45:02 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 22 Mar 2001 15:45:02 GMT Subject: email address verification References: <99d5qi$95l$1@solaria.cc.gatech.edu> Message-ID: <26pu6.3007$4N4.413401@newsc.telia.net> Joseph wrote: > does python provide quick/simple way to verify that an email address exist? not more than any other programming language -- there is no way to do what you want. for the full story, see: http://www.perl.com/pub/doc/manual/html/pod/perlfaq9.html#How_do_I_check_a_valid_mail_addr Q: How do I check a valid mail address? A: You can't, at least, not in real time. Bummer, eh? Cheers /F From cce at clarkevans.com Tue Mar 27 04:20:30 2001 From: cce at clarkevans.com (Clark C. Evans) Date: Tue, 27 Mar 2001 04:20:30 -0500 (EST) Subject: Yet Another PEP: Query Protocol Interface or __query__ In-Reply-To: <5.0.2.1.0.20010326100519.02198bb0@mail.inet.com.br> Message-ID: On Mon, 26 Mar 2001, Carlos Alberto Reis Ribeiro wrote: > a) The proxy adapter is completely transparent to the object instance. > b) The adapter maps only the methods that are mandatory by the protocol > specification. This leads to better encapsulation and abstraction (all > details of the object are hidden from the protocol user). > c) Method names may be different in the object. The protocol does the name > translation. > d) The protocol instance may point to methods in disparate objects, which > leads to a interesting type of 'composition'. Right. I think this complements what I was proposing nicely; and could be built-in as a way for adapter/proxy to be built. > Hummm... I see your point. My intention is different - avoid mixing > 'protocols' and 'class definitions'. One of the reasons was the potential > for name clashes, as shown in my example. A protocol does not need to be > represented *exclusively* by a class in the hierarchy. A single class may > implement multiple protocols, but some protocols may need a composition of > objects to do the work. For example, a composite object may contain lots of > objects that gets exposed through interfaces in the container. > > Also I see no reason to avoid defining some kind of 'simple' interfaces in > this PEP - in the end, protocols are better mapped to 'interfaces' than to > 'classes'. It's much more flexible in this way. Yep. I like your mechansim for supporting interface proxy's. > class ProtocolSequence: > """ Protocol to implement sequence-like objects """ > def __len__ (self): pass > def __getitem__(self, key): pass > def __setitem__(self, key, value): pass > def __delitem__(self, key): pass > > In this example, ProtocolSequence is the specification of the methods used > for sequence type objects. Sequence objects does not need to be derived > from ProtocolSequence; they may be written from the scratch, or be derived > from UserList, etc. Again, keep in mind the potential of composition as a > technique to build large systems. It is important to avoid the assumption > that inheritance is *the only way* to build OO systems. In this respect, what you are proposing is very much aligned to what the interface proposals out there try to do, i'd hazard to say this is the "bridge" between the two proposals. No? Best, ;) Clark From root at rainerdeyke.com Sat Mar 3 13:22:18 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sat, 03 Mar 2001 18:22:18 GMT Subject: Missing the functional mind set References: Message-ID: "Daniel Klein" wrote in message news:mlb2at8ptrr7sh5dgq8qlk2201kquh6tfl at 4ax.com... > The purpose of this code is to return a list of dictionary values sorted by > key, resulting in 'templist'. > > >>> d = {3: 'd', 2: 'b', 1: 'a', 0: 'z'} > >>> templist = [] > >>> for n in range(len(d)): > templist.append(d[n]) This is equivalent to: templist = [d[n] for n in range(len(d))] But if you are indexing with integers from 0 to n, why are you using a dictionary in the first place? -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From James_Althoff at i2.com Fri Mar 16 14:40:15 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Fri, 16 Mar 2001 11:40:15 -0800 Subject: I come to praise .join, not to bury it... Message-ID: All joking aside ... Although overloading __if__ is not so common, overloading the equivalent of "__for__ __in__" is a very common, convenient, and powerful design pattern in Smalltalk (see "Smalltalk Best Practice Patterns", Kent Beck, 1997, ISBN 0-13-476904-X, page 146). The idea is that for a collection class you define a "do:" method that takes a block of code as the argument (this is very easy to do in Smalltalk). When invoked, the "do:" method in the collection class executes the code block for each item in the collection. That way the collection class does not have to export artifacts like lists, iterators, or indexed-access to contained items just so that the collection can be used inside built-in looping control structures (such as "for in"). Rather, the collection class takes care of the iteration across its contained items in its own internal implementation. The Python equivalent defining a method that takes as the argument a pre-defined function (too inconvenient to have to create a function for a random block of code -- and lambdas can't have statements) or a code-string to eval or exec (too slow and unreadable) is not anywhere near as convenient or usable, so this design pattern is rarely seen in Python programs (compared to just pulling each item out of the collection in a "for in" or "while" loop). Jim "Ken Seehof" com> cc: Sent by: Subject: Re: I come to praise .join, not to bury it... python-list-admin@ python.org 03/15/01 09:47 AM Hmm ... I wonder what I'd do if I could overload __if__ ... Hey, I know! You could use it to implement fuzzy logic for quantum computers. The new __if__ would cause multiple superimposed quantum states based on the probability wave distribution of the quantum bit argument. ----- Original Message ----- From: "Darren New" Newsgroups: comp.lang.python To: Sent: Thursday, March 15, 2001 12:15 PM Subject: Re: I come to praise .join, not to bury it... > Alex Martelli wrote: > > And then again, the _appearance_ that too much emphasis > > was being placed on syntax-sugary issues kept me *AWAY* > > from Python for longer than it should have > > Actually, what I found quite cool about Python is that the procedural syntax > maps to OO semantics. I.e., in Smalltalk, everything looks like a method > call, including "if". In Eiffel, everything that isn't a method call doesn't > look like a method call, and vica versa. But in Python, the convenient and > familiar "x = y[5:10]" maps to a real live method call you can override. > > Well, *I* thought it was neat. It lets you be OO where you want, and keeps > it out of your face otherwise. > > -- > Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. > San Diego, CA, USA (PST). Cryptokeys on demand. > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list From f8dy at yahoo.com Fri Mar 2 09:59:57 2001 From: f8dy at yahoo.com (Mark Pilgrim) Date: Fri, 2 Mar 2001 09:59:57 -0500 Subject: Has anyone been able to convince Bruce Eckel to write "Thinking in Python" References: Message-ID: <97oce8$pdrjf$1@ID-77331.news.dfncis.de> "Bruce Eckel" wrote in message news:mailman.983482202.19147.python-list at python.org... > See: > http://www.mindview.net/Python/ThinkingInPython.html Sounds very promising. Until this project gets underway, may I humbly suggest my free book, "Dive Into Python": http://diveintopython.org/ It is targeted at programmers who have some experience at least one other language (Java, Perl, C++, Delphi, Powerbuilder, or even just Visual Basic) who can build on that experience to learn Python quickly. It is organized around annotated code examples, and it has "futher reading" links in each section to relevant resources elsewhere on the web. 3 chapters are already complete; more are coming. -M You're smart; why haven't you learned Python yet? http://diveintopython.org/ From joconnor at cybermesa.com Thu Mar 1 11:14:13 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Thu, 01 Mar 2001 09:14:13 -0700 Subject: str behaviour References: Message-ID: <3A9E7555.E3E7CC39@cybermesa.com> "Igor V. Rafienko" wrote: > Hi, > > I was playing around with printing tuples, when I noticed how str > behaves with "compound" types (such as tuples): > > >>> class A: > ... def __str__( self ): > ... return "I'm A" > ... > >>> a = A() > >>> t = ( A, a ) > >>> str( t ) > '(, <__main__.A instance at 810f090>)' > >>> str( a ) > "I'm A" > >>> > > I expected str to be called recursively for the constituent types. > But, alas, that did not happen. Am I misunderstanding something or is > it the intended behaviour? If the latter is the case, could someone > elaborate on why this behaviour was chosen? Not looking inside the code for printing a code, experimation indicates that __str__ is not being called, but __repr__ is... >>> class ClassA: def __str__(self): return "I'm an A" def __repr__(self): return "I'm really an A" >>> a = ClassA() >>> a I'm really an A >>> t = (ClassA, a) >>> t (, I'm really an A) >>> -- Jay O'Connor joconnor at cybermesa.com http://www.cybermesa.com/~joconnor Python Language Forum - http://pub1.ezboard.com/fobjectorienteddevelopmentpython From lars at pixar.com Thu Mar 8 01:54:05 2001 From: lars at pixar.com (Lars Damerow) Date: Wed, 7 Mar 2001 22:54:05 -0800 Subject: class object access in class definition? In-Reply-To: References: Message-ID: That's a good compromise. It would have been nice to have everything under the scope of the class definition, but certainly not crucial. Thanks! -lars On Wed, 7 Mar 2001, Steve Holden wrote: | Well, if you're prepared to be pragmatic about it, what's wrong with: | | derivedClasses = [] | | class BaseClass: | pass | | class DerivedClass(BaseClass): | pass | | derivedClasses.append(DerivedClass) | | Not elegant, but practical. | | regards | Steve | | | | ___________________________________________________________ lars damerow button pusher lars at pixar.com "Nauseous. Nauseated. The first means 'sickening to contemplate'; the second means 'sick at the stomach.' Do not, therefore, say, "I feel nauseous," unless you are sure you have that effect on others." - William Strunk Jr., "The Elements of Style" From fuess at att.net Thu Mar 15 07:48:13 2001 From: fuess at att.net (David Fuess) Date: Thu, 15 Mar 2001 12:48:13 GMT Subject: Problem with string.translate Message-ID: I am using Python 2.0 and attempting to perform a string.translate. The translate string is statically allocated in the setup phase. I perform a result = string.translate(source, ttab) I have also tried result = source.translate(ttab) The error I get is that an internal library function in the string module is calling a builtin function translate with too few arguments! Is this an implementation problem in the new string class? I have tried changing the library function, but then it generates other errors. Please advise. Thanks, Dave From matt at mondoinfo.com Tue Mar 6 19:34:15 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Wed, 07 Mar 2001 00:34:15 GMT Subject: from Tkinter import * References: Message-ID: On Tue, 6 Mar 2001 15:16:31 -0800, Timothy Grant wrote: > All of Fredrik's examples in his guide on Tkinter use >from Tkinter import * >Now, I'm aware that the effbot is never wrong about anything, >but is it safe to assume that I should not be using the above idiom, >but the import Tkinter idiom instead? Rest assured, the effbot is right as usual. There are really two things going on with "from foo import *": The first is that under some circumstances doing it at other than module scope (e.g. in a function or method) is eventually going to become illegal. That's unlikely to be a problem for very many people since "from Tkinter import *" is almost always at the left margin. The second reason someone might not want to do "from foo import *" is that it's possible to cause surprises by importing a name that shadows something important. If my module foo defines foo.open and I do "from foo import *", I may get surprising results the next time I try to open a file. Tkinter's names are chosen to make that sort of problem unlikely. Everyone assumes that everyone does "from Tkinter import *" and I don't think that anyone is going to make it a bad idea any time soon. Regards, Matt From danielk at aracnet.com Tue Mar 6 09:10:30 2001 From: danielk at aracnet.com (Daniel Klein) Date: Tue, 06 Mar 2001 06:10:30 -0800 Subject: Static class methods References: <7SZo6.7063$qv3.3125634@nnrp5-w.sbc.net> Message-ID: On Mon, 5 Mar 2001 20:40:29 -0800, "Alex Shindich" wrote: >There are indeed many ways to simulate the behavior. But shouldn't such a >strong OOP language like Python have support for static methods? It's not really necessary to be honest. The approach outlined in TQJB was just a 'suggestion' cos you seemed 'distressed' you couldn't define a class method associated to a specific class. When I need such a method I simply define it as a 'top level' function in the module and call if from the class instances. The fact that it isn't 'bound' to a particular class does not bother me. That's what doc strings are for. :-) On occasion there are situations where one of these 'top level' methods becomes useful to more than one class in the module and then I reap the benefits of reuse. Daniel Klein Portland OR USA From Jaeho.Lee at brooks.com Wed Mar 21 17:34:17 2001 From: Jaeho.Lee at brooks.com (Lee, Jaeho) Date: Wed, 21 Mar 2001 17:34:17 -0500 Subject: learning python... Message-ID: <857F15D7E3D8D3118D290008C7CF058602C9757F@mail-naeast1.brooks.com> > I've also got "Core Python Programming" and if I had to review it, I would > say that it tries to be all things to everyone but never quite hits the > mark. The examples always seem to fall short of what you are really looking > for. The author seems to explain the fundamental stuff very well but just as > it starts to get interesting, the section/chapter ends. I think instead of > using extra thick paper and large fonts to give the visual appearance of an > impressive body of work, the author should have provided a bit more detail > in some of the more advanced areas like network programming. I was looking a second Python book in addition to "Programming Python 1". I could not wait PP2. When I scan "Core Python Programming" through, my impression is that "too small contents compared with the thickness of the book". It contains about half of the contents that PP1, I think. And the explanation is not that great. So I did not buy it. I did not read it through. But I don't think it is worth to read. My case, I read PP1 and using "python reference manual" as reference (as the name says ^^). PP1 taught me how python is different from other language. But I agree that it is not good for reference. I am waiting PP2 now. So I can not say about it. /Jaeho From vecernik at aon.at Wed Mar 28 07:47:10 2001 From: vecernik at aon.at (Oliver Vecernik) Date: Wed, 28 Mar 2001 14:47:10 +0200 Subject: diff lists Message-ID: <3AC1DD4E.4BA7D421@aon.at> Hi, I've got following two lists: ['a', 'b', 'c', 'd', 'e', 'f'] ['e', 'c', 'f'] I'd like to have the result: ['a', 'b', 'd'] The list need not to be ordered. ['d', 'a', 'b'] will also be ok. What is the most effective way to achive that result? Oliver From Eugene.Leitl at lrz.uni-muenchen.de Wed Mar 28 10:56:16 2001 From: Eugene.Leitl at lrz.uni-muenchen.de (Eugene Leitl) Date: Wed, 28 Mar 2001 17:56:16 +0200 (MET DST) Subject: help with passing arguments to published objects a la Zope Message-ID: ...but without Zope. I'm trying to build an application with an embedded webserver, so far with limited success. Frozen CGIHTTPServer.py is ideal in terms of performance and footprint, the more so, since I can trap access to fake document in the URI to a python method, packing the bulk of the application into a single binary. However, is there a simple mechanism, allowing me to pass arguments via the URI, as well as use the CGI module (i.e. to parse arguments into a dictionary)? For instance, I've got a java applet passing on information via a POST method. This seems to be done wia a JavaScript document.submitform.action, which calls a cgi-bin script. Assuming, I'll trap a call to that document tree, where will the POSTed stuff be coming through, STDIN? What about arguments passed via the standard http://blah.net:666/cgi/raowr.cgi?rhesus=positive#maybe scheme. How can I get at them, preferably mapped to function parameters? The all singing/dancing/juggling Zope is too fat for my needs (and I might have to support a lot of weird platforms, starting with AIX, where it may not even build), as is Medusa. If it's impossible to add this functionality to CGIHTTPServer without jumping through a lot of hoops, I guess I could use Medusa/Bobo. It's still plain Python, so I only need to get Python to build. If I could get Bobo, that is. It seems to have vanished into Zope's entrails. I'm browsing through Zope's source tree right now, and can't even find it. Gah. So, what are my options? Some help would be really appreciated. TIA, Eugene From emile at fenx.com Sat Mar 31 08:03:20 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 31 Mar 2001 05:03:20 -0800 Subject: newbie variables question References: Message-ID: <9a4kol$3j756$1@ID-11957.news.dfncis.de> This is the normal way to get variables into strings. -- Emile van Sebille emile at fenx.com --------- "Michael Hall" wrote in message news:mailman.986005960.10805.python-list at python.org... > > I've been trying to do this: > > SYSPRODIR = /home/admin/systemprofile > os.system('mv /tmp/install.log SYSPRODIR/install.log') > > No matter how I play around with single and double quotes, this won't > work. > > But this does work: > > os.system('mv /tmp/install.log %s/install.log' %s SYSPRODIR) > > Is this the normal/best way to do this in Python ... seems a little > convoluted me, like there must be a simpler way. Bash for example would be > happy with something like: > > mv /tmp/install.log $SYSPRODIR/install.log > > while PHP is happy with things like: > > include ("$SYSPRODIR/install.log"); > > Thanks for any advice. I haven't found any clear info about this in > Learning Python yet. > > Mick > > From slhath at home.com Wed Mar 7 10:31:50 2001 From: slhath at home.com (Scott Hathaway) Date: Wed, 07 Mar 2001 15:31:50 GMT Subject: how to move a window with overrideredirect(1) in tkinter Message-ID: Hello All, Can anyone tell me how to move a window with overrideredirect(1) in tkinter (with a drag event)? Thanks, Scott From mcfletch at home.com Sun Mar 18 23:32:02 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Sun, 18 Mar 2001 23:32:02 -0500 Subject: Help Rewriting/Refactoring/Rethinking Parsing Algorythm In-Reply-To: <3AB5675A.8363C9F2@mindspring.com> Message-ID: <000501c0b02d$8c35b200$a9807018@cr706570a> Not precisely what you're trying to do, but I do most of my programming with voice dictation (Dragon NS 5), and I find that a few command phrases are fairly useful and let me program in just about any editor: py-equal (pie-equal) -> == py-init -> __init__ py-main -> __main__ py-name -> __name__ # would be redefined for you... py-def -> def dublex (dooblex) -> wx\Caps Next Word\No-Space After triple-quote -> \No-Space ''' \No-Space py-len -> len Looking at your list, adding: py-caps -> \No-Space-On\Caps-On py-norm -> \No-Space-Off\Caps-Off py-name -> \No-Space-On\Caps-On [ not sure if you can do this without a macro... ] Would give you: py-name number customers py-norm py-caps Abstract Class py-norm if error type py-equal 5 then dublex-python equalsign 6 py-name whiskey type py-norm equalsign 'peachy' print "what's wrong with %s?" % py-name first name py-norm For the indicated phrases. I find that the py-phrases give a decent recognition rate. With vocedit (for Dragon) you can setup the options for the words easily (e.g. for dublex-, and making _ put no spaces around itself). I like the idea of adding "py-name" modes to the mix (would save lots of mucking around with \Cap \No-space. Will give it a try. The dublex- thing saves lots of headaches for me, I had a similar one for Fox when I was using that library. As for travelling the parsing-path: I think Aycock's parsing framework would fairly easily handle this kind of work, it's got an extremely flexible algo (which is apparently fairly slow, but should hold for interactive work I'd think). Good luck, will be interested to see what you finally build, Mike -----Original Message----- From: Boopy Bootles [mailto:aschneid at mindspring.com] Sent: Sunday, March 18, 2001 8:57 PM To: python-list at python.org Subject: Help Rewriting/Refactoring/Rethinking Parsing Algorythm I'm trying to write a simple piece of code to make programming by voice recognition software easier to do. I wrote a very simple function that would, for example, convert "number customers equals 5" to "numberCustomers = 5". But once I started using it, I quickly discovered several more cases I had to handle. So far, this is the list: number customers - > numberCustomers Abstract Class -> AbstractClass if error type == 5 then -> if errorType == 5: whiskey x-ray python equals 6 -> wxPython = 6 normal whiskey type = 'peachy' -> whiskeyType = 'peachy' print "what's wrong with %s?" % first name -> print "what's wrong with %s?" % firstName (the whiskey x-ray stuff is the International Communications Alphabet, which you use when spelling something out in Dragon NaturallySpeaking if NaturallySpeaking is having trouble understanding you). I've gotten all but the last case to work. But once I started trying to incorporate the last case--not messing up quoted strings--my already overly messy code turned into a hideous snarl. I know there's _got_ to be a better way to parse this input, but I don't have a clue where to start. I'd like to avoid building a full-blown language parser, which seems like overkill. I've included the code below, which correctly translates all but the last case. Any thoughts would be greatly appreciated, esp. thoughts re: a simple object-oriented approach (I'm pretty sure there is one, I just don't have enough experience writing OO code to figure it out). Thanks, Anders Schneiderman P.S. Once I've gotten this code in better shape, I'll post it somewhere. Even at this primitive stage, it makes a _huge_ difference in writing code by voice (I use NaturallySpeaking plus Natlink, Joe Gould's terrific system for writing NaturallySpeaking macros using Python). --------------------------------------------------------------------------- """ voicecode.py: routines for translating and otherwise manipulating voice input into code. """ from string import * SpecialWords = {'equals': ' = ', '=': ' = ', '==': ' == ', '%': ' % ', 'if': 'if ', 'then': ':', 'elsif': 'elif', 'dot': '.', '.':'.', 'open': ' = open(', 'try': 'try:', 'init': '__init__ (self, ', 'define': 'def ', 'except':'except:', 'finally':'finally:', 'tab':' ', 'blank': ' '} ICA = {'alpha': 1, 'bravo': 1, 'charlie':1, 'delta':1, 'echo':1, 'foxtrot': 1, 'golf':1, 'hotel':1, 'india':1, 'juliet': 1, 'kilo':1, 'lima': 1, 'mike':1, 'november':1, 'oscar':1, 'papa':1, 'quebec':1, 'romeo':1, 'sierra':1, 'tango':1, 'uniform':1, 'whiskey':1, 'x-ray':1, 'xray':1, 'yankee':1, 'zulu':1 } quote = {"'":1, '"':1 } def translate(words): """Given an array of words, translate into code. The rules are: * In general, convert lists of words into wordWordWord * For certain words/symbols, aka "special words", convert 'em * For ICA words--alpha, bravo, etc.--convert to a single letter * If the word is "normal", use the next word exactly as is NOTE: Right now, this will NOT work on lines that are quoted: print 'this is a test' will translate to 'thisIsATest'. I need to find a cleaner way to solve this problem. """ line = '' firstWord = 1 normalWord = 0 for word in words: if normalWord: # This word should be used exactly as is (prev word was 'normal') if firstWord: # Don't capitalize the first word of a variable or a word in a quote line = line + word firstWord = 0 else: line = line + capitalize(word) normalWord = 0 elif lower(word) == 'normal': normalWord = 1 # next word should be used exactly as is elif SpecialWords.has_key(word): line = line + SpecialWords[word] firstWord = 1 elif ICA.has_key(lower(word)): # International Alphabet -- convert 'alpha' to 'a', etc. line = line + word[0] firstWord = 0 elif firstWord: # Don't capitalize the first word of a variable or a word in a quote line = line + word # Don't capitalize the first word of a variable firstWord = 0 else: line = line + capitalize(word) return line -- http://mail.python.org/mailman/listinfo/python-list From mda at idatar.com Fri Mar 30 16:12:10 2001 From: mda at idatar.com (David Allen) Date: Fri, 30 Mar 2001 21:12:10 GMT Subject: Know of Substantial Apps Written in Python? References: <3ac4e4a8_1@news4.newsfeeds.com> Message-ID: In article <3ac4e4a8_1 at news4.newsfeeds.com>, "Dry Ice" wrote: > Know of substantial apps written in Python? > > Preferably something one could download for examination. > > Source code would be nice, but not essential. > > I'm operating under the theory that whatever the POTENTIAL of a language, or > the 'elegance' of a language's syntax and structure, how large apps actually > behave in the real world will speak volumes. > > I like, for example, much about Java. But nearly every example I have seen > running in the Windows environment has been slow, leaked resources and > eventually contributed to system crashes. > > (I don't care whether it's the language or the OS > or the VM or even "bad programming." What counts are the usual results > obtained by normal application developers.) > > Suggestions? > > What's the definition of "substantial"? There's Grail, a web browser http://grail.sourceforge.net There's ZOPE, an internet publishing thingy (thingy is a technical term :) Check www.python.org - there are plenty of examples of programs with thousands and thousands of lines of code. I'm not sure if you mean "large" when you say substantial or if you mean well known and widely used... -- David Allen http://opop.nols.com/ ---------------------------------------- Anarchy may not be the best form of government, but it's better than no government at all. From embed at geocities.com Wed Mar 14 13:37:21 2001 From: embed at geocities.com (Warren Postma) Date: Wed, 14 Mar 2001 13:37:21 -0500 Subject: Dynamic construction of a print format string References: <3AAFB663.57FCCE7@troikanetworks.com> Message-ID: "Bruce Edge" quoth: > fmtstr = "%s%s%s" % ( " %", namelen, "s - %s" ) > to get: > " %19s - %s" fmtstr = " %"+`namelen`+" - %s" From kens at sightreader.com Thu Mar 15 16:29:15 2001 From: kens at sightreader.com (Ken Seehof) Date: Thu, 15 Mar 2001 15:29:15 -0600 Subject: Magnitude of the wx* market (was: Python In A Nutshell - suggestions) Message-ID: <005501c0ad96$fd34f5e0$04090a0a@upcast.com> oops, sorry bout the accidental cross post. ----- Original Message ----- From: "Ken Seehof" To: "python-list" Sent: Thursday, March 15, 2001 3:27 PM Subject: Re: Magnitude of the wx* market (was: Python In A Nutshell - suggestions) > I'll definitely buy a wxPython book when it comes out. ... From robin at jessikat.fsnet.co.uk Wed Mar 28 11:44:46 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 28 Mar 2001 17:44:46 +0100 Subject: StandaloneZODB at cvs.python.org References: Message-ID: In article , Jeremy Hylton writes ... >The project is tied directly to the ZODB code used in the Zope2 CVS >repository. When a change is made to Zope, it will also appear in >StandaloneZODB, and vice versa. Specifically, we use cvs modules to >incorporate parts of the Zope2 and ZEO code bases. > >The project contains the key components you need to run ZODB and ZEO, >but not all of the ancillary packages that Andrew's distribution >includes. I expect to add more components over time, but only those >that are expected to be useful for Python programmers using ZODB. ... so is there some advantage in maintaining two projects? -- Robin Becker From tuttledon at hotmail.com Fri Mar 9 09:22:11 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Fri, 09 Mar 2001 14:22:11 GMT Subject: Python In A Nutshell Message-ID: Hey Alex, congrats on landing "Python In A Nutshell" book deal. One problem. I went down to the book store and it's not there. What gives? Don From stephen_purcell at yahoo.com Sun Mar 18 05:00:22 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Sun, 18 Mar 2001 11:00:22 +0100 Subject: Help with 500 error on cgi script In-Reply-To: ; from sheila@spamcop.net on Sun, Mar 18, 2001 at 09:33:57AM +0000 References: Message-ID: <20010318110022.C7546@freedom.puma-ag.com> Sheila King wrote: > Well, I was getting 500 internal server errors. I've checked everything. The > path, etc... > > I've compared my file to the other two files and just can't see what I'm doing > wrong. > > So, here is my script. I'm sure someone here will see it right off? You need to write out a 'Content-type' header when form_ok is true, too! It's the lack of that header that causes the 500 error. If you're pretty sure your content is going to be text/html, it can be good practice to write out the content header before any other code. -Steve P.S. What's with the 'spamcop' reply address? Is that your real address or do unsuspecting helpful responders get their mail accounts terminated? -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From qrczak at knm.org.pl Mon Mar 5 17:25:28 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 5 Mar 2001 22:25:28 GMT Subject: the demise of 'from foo import * and its implications? References: <3kVBAfATrDo6EwEM@jessikat.fsnet.co.uk> Message-ID: Mon, 5 Mar 2001 11:47:51 -0500, Steve Holden pisze: > I did begin to wonder whether it might be possible to specify a > name prefix, along the lines of > > from modulewithaverylongname import * prefix sh_ > > to allow > > sh_i import modulewithaverylongname as sh for name in dir(sh): globals()['sh_'+name] = getattr(sh, name) del sh I don't see why do to this, and it's certainly not a feature to go into the standard language. An opposite trick can be used if a module is designed to be star-imported and uses name prefixes, but we dislike star-import. We can remove prefixes while moving objects to a separate namespace. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From spamfranke at bigfoot.de Fri Mar 9 20:10:31 2001 From: spamfranke at bigfoot.de (Stefan Franke) Date: Sat, 10 Mar 2001 01:10:31 GMT Subject: A counter-counter-proposal for PEP 236: #pragma( nested_scopes) References: Message-ID: <3aaa72c4.9442134@news.btx.dtag.de> On Sat, 3 Mar 2001 16:59:01 -0500, "Tim Peters" wrote: >last-msg-from-me-on-this-until-there's-a-pep-ly y'rs - tim > Hmm. Propably somewhat late to reply to this thread, but it's hard to keep up with c.l.py these days... I thought a little bit about the "from __future__ import nested_scopes" stmt, and what I found most disturbing is that it breaks the "explicit is better than implicit" rule. Wasn't it you who...? IMO the fact that we have a real module __future__ in the filesystem that is *really* imported, but silently triggers some additional magic, is not a feature but rather dangerous. Consider a newbie who read one of the many pre-2.1 books or a Python veteran who hasn't used the language for a while. What would they do if they see the import statement? They would propably see the __future__ module in the filesystem, notice that a tuple was imported and that's it! In the best case some comments around the definitions in the __future__ module are recognized that explain the additional magic. But since the whole process is implicit, they wouldn't possibly ever dream up that there might be something special about it. > "__future__" screams "Deep Magic" because of the double > double-underscores; I don't think so. We already have __init__.py modules all over. IMO they signal that the files are used by Python's runtime system, but not necessarily "black magic". * * * (Now for my own little ?0.02 proposal..) Why not make __future__ an additional builtin function? Double underscore names are reserved anyway, so we don't have the additional statement problem. Ok, we still have the magic here, but the first thing I guess my imaginary newbies/veterans would do is to look up the behaviour of the __future__("nested_scopes") call in the docs, since it is something unknown, and it must be built in (it appears before any other statement or imports). Maybe it's just my personal sense, but I find this explicit enough to make someone looking into the docs, whereas the implicit import variant looks normal enough to be taken for a standard case. Of course __future__ might not be the best name for the function(*). Note that we get the other benefits too: - Like before, the __future__("nested_scopes") call has to appear among the first statements of a module, otherwise an exception is raised - The version tuple could be the return value - Additional parameters are possible - There's no syntax change involved from __future__ import *-ly y'rs Stefan [* Perhaps the name is everything: from __RTFM_immediately_when_you_see_this__ \ import stackless_behaviour_now might be just as effective..] From bsass at freenet.edmonton.ab.ca Thu Mar 1 16:13:13 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 1 Mar 2001 14:13:13 -0700 (MST) Subject: [Distutils] Re: CPAN functionality for python - requirements In-Reply-To: <20010228170725.B1781@tummy.com> Message-ID: > >Interestingly, developers probably don't "expect" to have to include > >dependency information, and hence many don't - resulting in the problems you > > I think we can deal with that in an iterative manner. First get them to build > distutils packages, then when it fails to install on some user's machine > because they don't have foo.py we can educate them on the joys of listing > third-party module requirements. Has anyone written a program that looks at a .py and tries to determine the versions of Python it will work with? Maybe have a module that grabs info about the system the code is being developed on, then use some of that to generate default dependencies which the developer can modify (be made less restrictive in most cases, I imagine) before submitting the package to the archive. Even if the developer doesn't modify the dependencies, the user will at least have some idea of what is required. - Bruce From jcm at bigskytel.com Fri Mar 16 01:07:09 2001 From: jcm at bigskytel.com (David Porter) Date: Thu, 15 Mar 2001 23:07:09 -0700 Subject: tempfile.tempdir In-Reply-To: <3ab1a806$0$48743$6e49188b@news.goldengate.net>; from volucris@hotmail.com on Thu, Mar 15, 2001 at 11:43:41PM -0600 References: <3ab1a806$0$48743$6e49188b@news.goldengate.net> Message-ID: <20010315230709.A7453@bigskytel.com> * Voluciris : > If I change the value of tempfile.tempdir is it necessary to change it back > when I'm finished? no. > Does the change just happen inside Python, without affecting any enviroment > variables? yes. From tim.one at home.com Thu Mar 1 00:09:25 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 1 Mar 2001 00:09:25 -0500 Subject: long int behaviour In-Reply-To: <20010228172937.L14262@trufflehunter.avalongroup.net> Message-ID: [Timothy Grant] > ... > Given the following experimenting... > > >>> hex(4294965248L) > '0xFFFFF800L' > >>> hex(~4294965248L) > '-0xFFFFF801L' > >>> > > The first output is what I would expect, however, I would have > expected the second output to be > > 0x000007FFL > > It appears to be something to do with two's complement storage, > but I'm at a loss as to why my expectations were so incorrect. Take heart! Your expectations weren't born incorrect, they were made incorrect, by a world of evil languages promulgating their blasphemous treachery that integers are finite . Python does store longs in 2's-comp form, but remember that Python longs are unbounded: a long less than 0 has a (conceptually) infinite string of leading 1 bits, just as a long >= 0 has an infinite string of leading 0 bits. It's easy to show you an infinite string of leading 0 bits: we just ignore them. That infinite string of leading 1 bits isn't so easy to hide, though! You've been further warped into believing that 32 bits is somehow a "natural" size for an int. If that's what you believe, you can force the issue: >>> hex(~4294965248L & (2L**32 - 1)) '0x7FFL' >>> That is, by masking your input with a string of 32 low-order 1-bits, the infinite string of leading 1 bits goes away, leaving the output you expected. Or, if you're lucky enough to believe that ints have 101 bits, similarly: >>> hex(~4294965248L & (2L**101 - 1)) '0x1FFFFFFFFFFFFFFFFF000007FFL' >>> So that's the trick: to represent the infinite by the finite, you either need a convention, or you need to throw an infinite amount of info away. The "-" in '-0xFFFFF801L' is Python's convention for compressing the unbounded string of sign bits in such a way that no info is lost: >>> eval(hex(~4294965248L)) == ~4294965248L 1 >>> next-step:-infinite-memory-ly y'rs - tim From aahz at panix.com Fri Mar 16 18:46:37 2001 From: aahz at panix.com (Aahz Maruch) Date: 16 Mar 2001 15:46:37 -0800 Subject: list.sort(cmpfunc) question References: <98t9dq$qvu$1@panix6.panix.com> <3ab2a132@si-nic.hrz.uni-siegen.de> Message-ID: <98u8kt$35e$1@panix6.panix.com> In article <3ab2a132 at si-nic.hrz.uni-siegen.de>, Simon Budig wrote: > >As a related question since I did not find it in the documentation: > >Is the sort-function guaranteed to be stable? Does it keep the order, >when cmpfunc returns 0 for a pair of items? IIRC, the current implementation is stable but is not guaranteed to be stable. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Three sins: BJ, B&J, B&J From aleaxit at yahoo.com Sun Mar 4 16:39:53 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 4 Mar 2001 22:39:53 +0100 Subject: Missing the functional mind set References: <97rqgb$lt2$1@tyfon.itea.ntnu.no> <3AA298F5.7742810E@wwc.com> Message-ID: <97ucs102v2k@news1.newsguy.com> "Steve Williams" wrote in message news:3AA298F5.7742810E at wwc.com... [snip] > To be consistent with the "index == offset" mindset, counting should > start at zero. > > As in: "I have 2 children--0 boy and 1 girls". Counting _does_ start at 0 -- you enumerate elements of a set and check which ones satisfy a certain property, the count starts and stays at zero until it's bumped up the first time, then it goes to 1, and so on. But 0+1=1, so you have an off-by-one error somewhere in your family, I'm afraid... Alex From Dan.Rolander at marriott.com Fri Mar 2 13:23:52 2001 From: Dan.Rolander at marriott.com (Rolander, Dan) Date: Fri, 2 Mar 2001 13:23:52 -0500 Subject: Unresolved symbols in MSVCRT.DLL when running a py2exe packag ed program. Message-ID: <6176E3D8E36FD111B58900805FA7E0F80CCF63F3@mcnc-mdm1-ex01> The problem with replacing individual DLLs is that they come in matched sets. Unless you replace the whole set bad things can happen. It is often easiest to install a service pack or product that'll upgrade the DLLs for you. Or if you do use a professional installer like IPWI, load a merge module to handle it for you. This is an excellent article from Microsoft which explains the DLL Hell pitfalls and how Win2K is attempting to handle it (along with a troubleshooting tool for all Win32 systems): http://msdn.microsoft.com/library/default.asp?URL=/library/techart/DLLdanger 1.htm Dan -----Original Message----- From: Tim Peters [mailto:tim.one at home.com] Sent: Friday, March 02, 2001 1:10 PM To: python-list at python.org Subject: RE: Unresolved symbols in MSVCRT.DLL when running a py2exe packaged program. [Tom] > I disagree. > > You can distribute system dll's. You are expected to, and sometimes you > have to. You must insure that the version you load is at least > equal to the version that you linked against. > > I have done this (distribute system DLL's) on all windows except WinME and > the 16bit ones. Unfortunately I can't say how I did it precisely, because > I just used InstallShield. And Python just uses the Wise installer. They aren't that fancy under the covers, though -- they just "follow the rules", checking version numbers, bumping refcounts on refcounted DLLs, and arranging for a reboot if they need to replace something. But that stuff is ineffective on the newer systems with SFP. > But I believe that, where SFP exists, you must use specific and new > API's to replace DLL's, otherwise the system will back out your changes. My understanding is that SFP isn't so easily fooled; e.g., http://support.microsoft.com/support/kb/articles/Q253/5/71.ASP http://www.microsoft.com/hwdev/sfp/wfp.htm SFP won't allow replacement of protected files via just using API tricks; it also sucks in a digital signature scheme, and only MS can supply signatures that work. > One solution is to specify the changes in an .INF file and let the system > worry about these details (but this has its limitations). > > I assume that Python itself updates the MSVCRT.dll. The PythonLabs Windows installer tries to, yes. > Might look at how it does it on Win2K. My understanding is that it can't (but Win2K ships with a "good enough" set of DLLs, so the version check shouldn't trigger there -- yet). BTW, I'm *glad* MS is doing SFP! Whatever Windows Life may be in theory, DLLs in practice cannot be mixed and matched -- you need a self-consistent set else Very Strange Things Happen. And with about 1,000 DLLs under a typical Windows system directory, that's just impossible for app developers to keep straight. May well be impossible for MS to keep straight too, but at least it's no longer impossible for them to *try* to keep 'em straight now. something-to-ponder-each-time-your-win9x-crashes-ly y'rs - tim -- http://mail.python.org/mailman/listinfo/python-list From sholden at holdenweb.com Mon Mar 5 11:47:51 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 5 Mar 2001 11:47:51 -0500 Subject: the demise of 'from foo import * and its implications? References: <3kVBAfATrDo6EwEM@jessikat.fsnet.co.uk> Message-ID: "Jeremy Hylton" wrote in message news:mailman.983746566.27513.python-list at python.org... > >>>>> "RB" == Robin Becker writes: > > RB> my preference would be that statements legal in one context > RB> should be legal in another where they make sense. I cannot see > RB> how using import * or eval etc in nested scopes is somehow > RB> obviously bad or different from the same usage in non-nested > RB> scopes. The fact that the prohibition comes from making things > RB> easier for the compiler adds to my confusion. > > Using import * in function's is asking for trouble, because it makes > it impossible for someone reading the code to know what a variable > refers to. Consider this hypothetical bit of code: > [ ... ] I would go further, and remove "in functions" from the above. While it is true that wildcard imports are more manageable at module level there is still always the chance that a badly-designed module will stamp on your names. Of course, the "import module as name" variant allows us to define shorter names to be qualified by the names from the module. This can help a lot if you wnat to do import modulewithaverylongname but don't want to have to refer to modulewithaverylongname.i In that case you can just do import modulewithaverylongname as sh and refer to sh.i I did begin to wonder whether it might be possible to specify a name prefix, along the lines of from modulewithaverylongname import * prefix sh_ to allow sh_i as a reference to the module's "i", but I'm not sure that the gain is worth the pain. Even if such a proposal were to be PEP-ified and accepted it could not be mandated because that would break humongous amounts of existing code. Thoughts? regards Steve From shaleh at valinux.com Wed Mar 21 15:09:05 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Wed, 21 Mar 2001 12:09:05 -0800 (PST) Subject: Substitute for join() In-Reply-To: Message-ID: On 21-Mar-2001 Daniel Klein wrote: > I've got to make a script (written in version 2.0) to work on a machine > running 1.5.2. The only incompatible line is one that uses the > "".join(mylist) method. To 'get out of the woods' quickly, I substituted it > with > > s = '' > for element in mylist: s = s + element > > Is this the most efficient way to code this? > or use the syntax that works in both: import string # or from string import join string.join(mylist, "") From tjg at exceptionalminds.com Wed Mar 7 12:15:14 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Wed, 7 Mar 2001 09:15:14 -0800 Subject: from Tkinter import * In-Reply-To: ; from matt@mondoinfo.com on Wed, Mar 07, 2001 at 12:34:15AM +0000 References: Message-ID: <20010307091514.S3579@trufflehunter.avalongroup.net> Thanks for the input. I realized that most of the issues come from importing deeper than the module level, but the discussion of from blah import * has been fascinating. My primary concern was name clashes. On Wed, Mar 07, 2001 at 12:34:15AM +0000, Matthew Dixon Cowles wrote: > On Tue, 6 Mar 2001 15:16:31 -0800, Timothy Grant > wrote: > > > All of Fredrik's examples in his guide on Tkinter use > > >from Tkinter import * > > >Now, I'm aware that the effbot is never wrong about anything, > >but is it safe to assume that I should not be using the above idiom, > >but the import Tkinter idiom instead? > > Rest assured, the effbot is right as usual. -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Red Hat Certified Engineer www.exceptionalminds.com Avalon Technology Group, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 49 days 21:27 hours ago<< From grante at visi.com Fri Mar 2 17:29:47 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 02 Mar 2001 22:29:47 GMT Subject: cataloging words in text file References: <3AA0124E.74A39783@comm.mot.com> Message-ID: In article <3AA0124E.74A39783 at comm.mot.com>, Stephen Boulet wrote: >I remember this homework assignment for my data structures (c++) >class: read in a large file, and create a data structure containing >every word in the file and the number of times it appears. > >I was wondering how to do this in python. In c++ we had to do it >with hash tables and b-trees. > >Can you do it with dictionaries in python, with the key as the word >and the data the number of times it appears? Sure: #!/usr/local/bin/python2.1 import sys d={} for w in sys.stdin.read().split(): if d.has_key(w): d[w] += 1 else: d[w] = 1 print d You may want something a little more sophisticated than split(), since this solution is case sensitive and treats "foo" and "foo." as two different words. -- Grant Edwards grante Yow! .. I don't understand at the HUMOR of the THREE visi.com STOOGES!! From tim.one at home.com Sat Mar 3 23:44:19 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Mar 2001 23:44:19 -0500 Subject: [Python-Dev] Re: Bug fix releases In-Reply-To: Message-ID: [Don Tuttle] > But there is the CVS. And there are those like myself who are CVS > impaired. Right now there are Fredric's SRE Which you already have. > and _tkinter on steroids updates, AFAICT, PythonWare makes uiToolkit for Tkinter available only to their PythonWorks Pro customers, so we couldn't distribute that regardless. > and Mark's improved COM support. Also outside PythonLabs' cherubic little hands. > I'd love to have these. And while Guido may love to give them to you, they're not his to give. It's also curious that none of these have to do with bugfixes, they're all "shinier feature" things -- exactly what Aahz is telling us users *don't* want between major releases. Good thing I don't believe anything you read . > (Alright I've got /F's. He compiled 'em. But Mark's is still in the > damn CVS.) I've prodded ActiveState to issue Python updates and > they've indicated they would--they just haven't decided when. > > I don't think it has to be as formal as an official pep or separate > development track. Just whenever our fearless dictator sees that there's > enough good stuff in the CVS, let him decree that a new build > shall be made. None of the stuff above is in our SourceForge CVS tree. So you've made an excellent case that there's nothing whatsoever we can do for you . If we could, barking a decree is easy but isn't enough to make a release *happen*. I put in at least 80 hours during the week of a release, and I'm only looking out for Windows (+ masses of general patches and bugfixes and email panics, etc). The other PythonLabs guys aren't on vacation either. Somebody has to step up and do *work*. But, historically, nobody volunteers. If you look at Misc/HISTORY, you may be surprised to discover that the most recent "pure bugfix release" was in November of 1994(! and despite what it was *called*, it snuck some new Tkinter features anyway). > Of course we've gotta sell the idea to the dictator. That's easy -- he's always been in favor of bugfix releases, but provided somebody else volunteers the work to produce them. > Nobody's lost their head trying to do that (gulp) have they? I try not to think too much about that we don't hear much about Jim Hugunin anywore . OTOH, the PSU From dougfort at downright.com Thu Mar 22 18:26:27 2001 From: dougfort at downright.com (Doug Fort) Date: Thu, 22 Mar 2001 18:26:27 -0500 Subject: PyUnit in Python 2.1 standard library Message-ID: <3ABA8A23.85EA76CE@downright.com> Just recieved word that Steve Purcell has checked PyUnit into the standard library. Aside from being a useful tool to me PyUnit typifies the kind of development that ESR advocates in 'The Cathedral and the Bazaar'. A project started to 'scratch an itch', then shared with the communityto evolve and grow. None of the stuff I work on seems to come out so clean. Congratulations Steve! PyUnit is an example to us all. -- Doug Fort (dougfort at downright.com) Senior Meat Manager Downright Software LLC http://www.dougfort.net From bedge at troikanetworks.com Wed Mar 14 18:19:52 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Wed, 14 Mar 2001 15:19:52 -0800 Subject: Dynamic construction of a print format string References: <3AAFB663.57FCCE7@troikanetworks.com> <7MOr6.281$4d3.61498@newsb.telia.net> Message-ID: <3AAFFC98.8322CCB3@troikanetworks.com> Ahh, %*s, the magic trick. Thanks to all who responded. -Bruce. Fredrik Lundh wrote: > > Bruce Edge wrote: > > I'm using: > > > > fmtstr = "%s%s%s" % ( " %", namelen, "s - %s" ) > > > > to get: > > > > " %19s - %s" > > how about: > > format = " %%%ds - %%s" % namelen > text = format % (arg1, arg2) > > or > > text = " %*s - %s" % (namelen, arg1, arg2) > > Cheers /F From winson at mdsserv.mds.com.tw Thu Mar 29 00:36:50 2001 From: winson at mdsserv.mds.com.tw (=?big5?B?sWm4zq9x?=) Date: Thu, 29 Mar 2001 13:36:50 +0800 Subject: Python GUI with Swing Message-ID: <001e01c0b812$43f00760$340210ac@winson> Hi All, Is there any good solution for using Java Swing in Python ?? I surveyed Jython, PyJava, JPE and JPI. Jython sounds great but I only needs Swing as my GUI and the whole Jython is based on Java, speed will be a issue. Actually, I would like to find out a module can access Java's Swing package. PyJava, JPE and JPI only for AWT package, no Swing. -- Best Regards, Winson Chang 3F, 2, 150 Lane, Sec. 5, Hsin I Rd., Taipei, Taiwan, R.O.C. Tel: +886-2-27225333 ext 376 Fax: +886-2-27222330 Email: winson at mdsserv.mds.com.tw -------------- next part -------------- An HTML attachment was scrubbed... URL: From qrczak at knm.org.pl Thu Mar 22 17:46:14 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 22 Mar 2001 22:46:14 GMT Subject: gah! I hate the new string syntax References: <97sudi01i26@news1.newsguy.com> <98elrk$li8$1@nntp.Stanford.EDU> <98fc070thh@news1.newsguy.com> <98iqo2$56o$1@nntp.Stanford.EDU> <98t5bv0l8b@news1.newsguy.com> <98tet00v03@news1.newsguy.com> Message-ID: Fri, 16 Mar 2001 17:27:10 +0100, Alex Martelli pisze: > Non-invasive mods would be a better target -- and I think a > runtime variation of Haskell typeclasses might be a nice way > to present such mods. E.g., suppose that, parallel to the > existing builtin 'isinstance(object, [class or type object])', > that just returns 0 or 1, we have in some future Python a > new builtin: > getinstance(object, [typeclass object, or etc etc]) > which returns either None (meaning the required 'cast' is > not feasible) OR a reference x such that the axiom: > x = getinstance(y, z) > => > x is None or isinstance(x, z) > is satisfied, and x 'represents y as a z' I imagine it differently, although it's perhaps shifted too far from current Python's practice towards Haskell. Interfaces (corresponding to Haskell's typeclasses) are objects which contain attributes (usually functions). These functions examine types/classes of arguments they are applied to, and dispatch the implementation according to registered instances of that interface, or raise an exception if the combination has not been registered. An interface also offers querying whether a combination of types/classes is valid. This is an alternative to methods having magical names. Instead of __hash__ method there would be a Hasbable interface. The builtin function hash is bound to Hashable.hash. A class C can be made hashable by executing the following: instance Hashable(C): def hash(obj): return obj.spam ^ obj.eggs It smoothly extends to multiple dispatch: instance Collide(Ship, Rock): def collide(ship, rock): ... -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From stephen_purcell at yahoo.com Tue Mar 27 11:30:51 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 27 Mar 2001 18:30:51 +0200 Subject: Uploading a file via POST ? In-Reply-To: <99qdlf$a9r$1@news.rrz.Uni-Koeln.DE>; from a2619725@uni-koeln.de on Tue, Mar 27, 2001 at 04:03:59PM +0000 References: <99qdlf$a9r$1@news.rrz.Uni-Koeln.DE> Message-ID: <20010327183051.D1260@freedom.puma-ag.com> Oliver Hofmann wrote: > Is there an easy way to upload a file and pass parameters to the > server script? If what you really want to do is programmatically upload a file from a python script to a CGI on the server, you may be able to use or steal some code from http://webunit.sourceforge.net/ It's a side project I'm just starting to hack on, related to web testing; the code currently there supports multipart form submissions. -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From arinagour at yahoo.co.uk Fri Mar 9 04:59:16 2001 From: arinagour at yahoo.co.uk (chris lamb) Date: Fri, 9 Mar 2001 09:59:16 -0000 Subject: OODB question Message-ID: I am sure that I read somewhere of an OODB implementation developed specifically with Python or having a Python interface. I am beginning to wonder if I dreamt it up since I cannot remember where I read about it! Can anyone help me ? (I doubt it!) Best wishes Chris From reinhold.koch at computer.org Fri Mar 16 06:21:41 2001 From: reinhold.koch at computer.org (Reinhold Koch) Date: Fri, 16 Mar 2001 12:21:41 +0100 Subject: os.spawnv problem Message-ID: <3AB1F745.865F01A@computer.org> Hi python experts! As a newcomer I just hit a wall with the little one-liner: os.spawnv('P_WAIT',r'C:\rei\bin\PFE32.EXE', ('xx','yy')) resulting in: Traceback (innermost last): File "", line 1, in ? os.spawnv('P_WAIT',r'C:\rei\bin\PFE32.EXE', ('xx','yy')) TypeError: an integer is required First question: where is which integer required? Trying to debug and view stack did not yield anything reasonable to me. Second question: is spawnv generally not (yet) stable? My environment: Win2000 SP1 Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 IDLE 0.6 -- press F1 for help TIA for any comments Reinhold Koch reinhold.koch at computer.org From aleaxit at yahoo.com Fri Mar 16 08:53:39 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 16 Mar 2001 14:53:39 +0100 Subject: I come to praise .join, not to bury it... References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> <3AAF7E47.294617E1@sage.att.com> <98qeco02hn7@news1.newsguy.com> <98srjf$fov$1@tyfon.itea.ntnu.no> Message-ID: <98t5t40lle@news1.newsguy.com> "Magnus Lie Hetland" wrote in message news:98srjf$fov$1 at tyfon.itea.ntnu.no... [snip] > > Good thing (for me) that I eventually looked beyond the > > pretty face, of course:-). > > Why? If you don't care about the pretty face, what are > the advantages of Python as opposed to, say, Perl? Transparent, predictable, repeatable, regular behavior, WITHOUT a horde or three of 'convenient' ad-hoc cases. > To me it would seem that syntax (sugar or not) is > the main issue... Not that I've used Perl a lot, but > it seems very much like Python with a lot of ugly bits > thrown in... If you HAD used Perl a lot (and I have) you might well go beyond this "very surface" impression. Basically, Python goes a good way towards meeting the principle of least astonishment. A common and delightful experience of the Python learner -- you learn about something new but don't know the details yet -- you guess at those details *and more often than not, you guess right*! Perl seems to be designed by and for poets (not so far off the mark...) who subscribe to Giovan Battista Marino's 1619 manifesto of what poetry is all about: E` del poeta il fin la meraviglia, chi non sa far stupir vada alla striglia ("The purpose of the poet is astonishment", with a strong recommendation to those who don't know how to astonish that a preferable career path for them might be as stable-lads). Alex From tjreedy at udel.edu Tue Mar 20 12:05:08 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 20 Mar 2001 12:05:08 -0500 Subject: Thinking Outside the Box References: Message-ID: <9982ic$ei$1@news.udel.edu> ... > > http://washingtonpost.com/wp-dyn/articles/A23937-2001Mar18.html > (found on /.) I really like the idea of substituting a War on Bugs for the War on Drugs! A fun read. Thanks for posting something I would certainly have missed otherwise. TJR From doughellmann at bigfoot.com Thu Mar 15 08:12:55 2001 From: doughellmann at bigfoot.com (Doug Hellmann) Date: 15 Mar 2001 08:12:55 -0500 Subject: Who's minister of propaganda this week? In-Reply-To: <3AB0176D.8070903@yahoo.com> References: <98nu1m$12e@dispatch.concentric.net> <660ACCA1E4816F7E.C359CDF4168EF3FB.3B6B05538D619770@lp.airnews.net> <3AAFA13D.76E32C3F@divalsim.it> <98oa4o01i4v@news2.newsguy.com> <3AB0176D.8070903@yahoo.com> Message-ID: <20010315131024.CPTY4364.femail4.sdc1.sfba.home.com@localhost> On 14 Mar 2001 19:14:21 -0600, Michael Chermside wrote: > Alex Martelli wrote: > ... [snip]... > > > > > So, all the compile-time checking is buying is catching (a small > > subset of) the errors that would be caught in testing anyway, a > > little bit earlier (thus, a little bit cheaper) -- it's never the > > case that one has to write a test which would not be needed at > > all if type-checking was static, since "the object has the right > > type" is a small subcase of "the object _behaves_ per the specs". > > > I'm really not sure I see it this way. If the method foo(x) is known to > take a FancyDateObject > there are three kinds of errors we could make. One is that foo() is > written badly so it > doesn't do what it's supposed to. The unit tests of foo() need to guard > against this. > Another possible error is that FancyDateObject isn't written properly. > The unit tests > of FancyDateObject need to guard against this. And the third type of > error is that > that somewhere where we CALL foo(), we might pass it a DateObject > instead... or > even a String... which will cause it to perform wrong. To guard against > this in a > dynamically typed language, we have to write unit tests for *every > single place* > that we call foo(). Of course, we'd be writing unit tests for those > functions anyway, > but we won't be able to assume that foo() works properly, and will need > extra > tests to ensure this. We *can* assume foo() works correctly, because we have already written unit tests for foo() above. So, when bletch() calls foo() I write tests of bletch() to verify that *bletch()* works correctly. If it does not, it could be because it is using foo() incorrectly, but that is not a bug in foo(). So we need 3 sets of unit tests ( for foo(), for FancyDateObject, and for bletch() ) but *unit* tests focus on the unit they are testing. :-) Doug From jmarshal at mathworks.com Wed Mar 21 08:44:48 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 21 Mar 2001 13:44:48 GMT Subject: New PEP: The directive statement References: Message-ID: <99ab8g$8q8$1@news.mathworks.com> Delaney, Timothy wrote: > There are however, two things against this PEP. > 1. It allows for one incompatible language change (directive as keyword can > interfere with binding to name "directive" as the first line of a file). Again (and parser-engineering aside), this does not need to cause any backward-incompatibility. The proposed syntax is not ambiguous. From jepler at inetnebr.com Mon Mar 26 18:31:09 2001 From: jepler at inetnebr.com (Jeff Epler) Date: Mon, 26 Mar 2001 23:31:09 GMT Subject: close(), exceptions and problems References: <99i3j7$lqr$1@news.cybercity.dk> <99l8f4$1fob$1@news.cybercity.dk> Message-ID: On 26 Mar 2001 21:56:43 GMT, Antti Kuntsi wrote: >Close, the problem is that the implementation in at least Python 1.5.2 >does not check the return code of the close() and thus does not raise an >exception, at least not with sockets. This appears to be true of Python 2.0 as well. It looks like PySocketSock_{accept,close,dup,makefile,dealloc} and PySocket_socket all potentially need to be modified to correctly deal with -EINTR (or other) returns from close(socket). (The users of the SOCKETCLOSE macro) Jeff From alex at shindich.com Sun Mar 4 22:17:52 2001 From: alex at shindich.com (Alex Shindich) Date: Sun, 4 Mar 2001 19:17:52 -0800 Subject: Static class methods References: <0bDo6.16804$7Y1.1656672@newsread2.prod.itd.earthlink.net> Message-ID: That will indeed work. But it's plain ugly. Thanks for sharing the trick though! "Chris Tavares" wrote in message news:0bDo6.16804$7Y1.1656672 at newsread2.prod.itd.earthlink.net... > Try this: > > >>> class Foo: > ... class FooMethods: > ... def foo1(self): > ... print "FooMethods.foo1" > ... class_methods = FooMethods() > ... > >>> foo = Foo() > >>> foo.class_methods.foo1() > FooMethods.foo1 > >>> Foo.class_methods.foo1() > FooMethods.foo1 > >>> > > -Chris > > "Alex Shindich" wrote in message > news:rdzo6.154$gc4.80445 at news.pacbell.net... > > Just out of my curiosity, have any of you ladies and gentlemen experienced > a > > need for an equivalent of C++/Java static method? > > Because I have, but it is impossible add them to Python classes -- all > class > > methods are treated as instance methods. > > This is especially unfortunate given that local functions now work > properly > > thanks to PEP 227. > > I was thinking that a new keyword "unbound" could be used to identify > > functions that belong to a class but do not expect "self" as their first > > attribute. > > From outside the class "unbound" methods would be invoked by specifying > the > > class name -- Foo.my_static_method (). From within the class they would > work > > similar to local functions that are defined at the class level. The __ > trick > > should work for the "unbound" methods as well to allow for creation of > > private static methods. > > > > Examples: > > >>>class Foo: > > """This is a sample class...""" > > > > __myPrivateStaticVariable = None > > > > unbound getMyPrivateStaticVariable (): > > """getMyPrivateStaticVariable (obj) -> obj > > > > This method returns the value stored in private static variable... > > """ > > return Foo.__myPrivateStaticVariable > > > > > > unbound modifyMyPrivateStaticVariable (obj): > > """modifyMyPrivateStaticVariable (obj) -> void > > > > This method assigns obj to the private static variable... > > """ > > Foo.__myPrivateStaticVariable = obj > > > > >>> type (Foo.modifyMyPrivateStaticVariable) > > > > >>> type (Foo.getMyPrivateStaticVariable ()) > > > > >>> Foo.modifyMyPrivateStaticVariable ("abc") > > >>> Foo.getMyPrivateStaticVariable () > > "abc" > > >>> > > > > > > > > > > > From tim.one at home.com Fri Mar 2 16:58:38 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 2 Mar 2001 16:58:38 -0500 Subject: the demise of 'from foo import * and its implications? In-Reply-To: Message-ID: [Sean 'Shaleh' Perry] > ## as an example of what happens > ## and sure, I could try to list every function I want to import, > ## but man does that get ugly > ... What gave you the idea that "import *" is going away? From grante at visi.com Fri Mar 30 13:59:33 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 30 Mar 2001 18:59:33 GMT Subject: Why not an __assign__ method? References: Message-ID: In article , Pete Shinners wrote: >> The question is: Why not have a __assign__ method, that gets called on >> assignment? It should be called on the *right side* of the expression (at >> the left side it does not make sense - I leave the proof as an exercise for >> the reader ). The return value would be then assigned to the left >> side of the expression. This is the default behavior: > >i'm not quite sure how this would work. assigning variables >have nothing to do with the type a variable 'currently' refers to. That's not a problem for his proposal. >a = None >a = huge_array1 + huge_array2 > >the variable could point to anything before being assigned. Exactly -- his proposal doesn't care what the left-side name points to. >the assignment in no way effects what the variable originally >refers to, so it doesn't seem like whatever that was should get >a say in what happens to the "new owner" a = huge_array1 + huge_array2 What he wants (as I understand it) is to evaluate the RHS, call the __assign__ method on the result of that evaluation, and bind "a" to whatever the __assign__ method returns. -- Grant Edwards grante Yow! Yow! I like my new at DENTIST... visi.com From francois.granger at free.fr Sat Mar 17 13:40:21 2001 From: francois.granger at free.fr (=?ISO-8859-1?Q?Fran=E7ois_Granger?=) Date: Sat, 17 Mar 2001 18:40:21 GMT Subject: Python style questions References: <98tb91$9t9$1@saltmine.radix.net> <98tdu1$cfk$1@panix2.panix.com> <1eqdo5u.1xxmzfi2kjk0qN%francois.granger@free.fr> <98u24p0a98@news2.newsguy.com> <1eqfb5l.10gfjcu1qi9xrwN%francois.granger@free.fr> Message-ID: <1eqfi2c.nllfyvqv0srvN%francois.granger@free.fr> Rainer Deyke wrote: > Game(HumanPlayer(), NNPlayer()).run() Wow greet! It will do for many evening of coding ! -- "Le sol n'oublie rien, il transmet." - Dani?le From danielk at aracnet.com Sun Mar 4 23:54:02 2001 From: danielk at aracnet.com (Daniel Klein) Date: Sun, 04 Mar 2001 20:54:02 -0800 Subject: Overriding UserList methods Message-ID: I must be missing something, cos I can't figure out how to override a method using the UserList module. Here is some code: import UserList class MyList(UserList.UserList): __def __init__(self): UserList.UserList.__init__(self) def append(self, object): self.append(object) Understandably, this goes into a recursive frenzy until it hits the stack limit. :-( The only way I could get this to work was to give the method another name, ie def add(self,object): ## This works but I would rather use 'append' self.append(object) ## as the method name. So how can I override the append() method so that I can add my specialized code to it? Daniel Klein From aahz at panix.com Sat Mar 10 10:18:03 2001 From: aahz at panix.com (Aahz Maruch) Date: 10 Mar 2001 07:18:03 -0800 Subject: How to efficently build a nested dictionary References: <3AAA2042.E69A53FC@gmx.de> Message-ID: <98dgjb$iee$1@panix3.panix.com> In article <3AAA2042.E69A53FC at gmx.de>, Carsten Gaebler wrote: > >I wrote a script for FTP traffic accounting, i.e. for each "top level" >FTP directory it counts the bytes transferred per day. The traffic is >stored in a dictionary that has the following structure: > >traffic = {dir: {year: {month: {day: 42}}}} I think Emile's suggestion to use a single compound key is a good one. If that's not sufficient *and* you can use Python 2.0, take a look at the dict.setdefault() method. -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Perhaps God rewards martyrs, but life seldom does..." --Ulrika O'Brien From ddb at crystal.uwa.edu.au Sun Mar 18 23:32:31 2001 From: ddb at crystal.uwa.edu.au (Douglas du Boulay) Date: Mon, 19 Mar 2001 12:32:31 +0800 Subject: Jython and jpythonc2 Message-ID: <3AB58BDF.56EA463C@crystal.uwa.edu.au> Hi, I'm using JPython1.1 and am in the process of trying to run the jpythonc2 compiler on some python sources. The problem I'm having is that some component of the JVM/jpython/jpythonc2 compiler seems to be incredibly memory hungry. Essentially, by the time around 15 source files (~2000 lines of code) have been processed, the compiler has consumed around 80 Megabytes of ram. At that point on a 128Meg(RAM) Compaq Alpha the process apparently gets stashed in the swap space. Thereafter, instead of running with 98% of the CPU time it runs at about 2%, with continuous disk thrashing. At the moment, after 3 hours real time, the process has only had 8 minutes of actual CPU time and is using 180 megabytes of virtual RAM. (There are about 80 source files involved here) My questions are: Has any work been done on the jpythonc2 compiler regarding memory use optimization (i.e. would upgrading to Jython2.? help), and, are there programming constructs which are known to consume vast amounts of memory during a jpythonc2 compile (i.e. are there coding rules that "power users" know in order to avoid such problems)? TIA Doug From aleaxit at yahoo.com Thu Mar 29 07:25:09 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 29 Mar 2001 14:25:09 +0200 Subject: C++ and Python References: <99q99l$g21$1@news.clinet.fi> Message-ID: <99v9kc028u3@news2.newsguy.com> "Ahto" wrote in message news:99q99l$g21$1 at news.clinet.fi... > I'm very new to Python and haven't quite figured out how to use c++ and > python together on windows...if someone could send me an example program of > tutorial webpage where this is explained?!? One possibility is http://www.boost.org/libs/python/doc/index.html. Alex From thomas at xs4all.net Mon Mar 12 03:27:37 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 12 Mar 2001 09:27:37 +0100 Subject: from Tkinter import * In-Reply-To: ; from kevin_cazabon@hotmail.nospamplease!.com on Thu, Mar 08, 2001 at 08:34:07PM -0700 References: Message-ID: <20010312092737.O404@xs4all.nl> On Thu, Mar 08, 2001 at 08:34:07PM -0700, Kevin Cazabon wrote: > The screwey thing about Fred's document using "from Tkinter import *" is > that there is an "Image" method in Tkinter that totally mucks up the PIL > Image module if you did an "import Image" prior to this... > Seeing as both are in Fred's court, it's kinda a bad idea... FredRIK. Fred and Fredrik are two different people. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From garry at sage.att.com Mon Mar 26 14:37:21 2001 From: garry at sage.att.com (Garry Hodgson) Date: Mon, 26 Mar 2001 14:37:21 -0500 Subject: warrior geeks References: <3ABF72F1.98CB78F@sage.att.com> <3ABFA209.CF27BC20@optushome.com.au> Message-ID: <3ABF9A71.28C2D8C4@sage.att.com> Tim Churches wrote: > I'll use our time zone advantage to jump in early on this thread and > opine that it is way off-topic. Not that I am opposed to > marital...whoops...martial arts (although they are not my cup of tea), > but I am concerned that if this threads continues, sooner or later > someone will mention the whole "Geeks with Guns" thing that Eric S. > Raymond promotes (see http://www.tuxedo.org/~esr/geeks-with-guns/ or for > even worse IMHO see http://www.tuxedo.org/~esr/guns/ ), especially given > ESR's apparent fondness for Python. That sort of thing gives me a fit of > the shudders (playing with guns, not ESR's fondness for Python). I would > have thought that if male hackers were looking for a hobby which > involves phallic-shaped objects and chemically-propelled projectiles, > then model rocketry would be just the ticket. > > There, that should put an immediate end to this very off-topic thread... sounds to me like you just created one. -- Garry Hodgson Once in a while Senior Hacker you can get shown the light Software Innovation Services in the strangest of places AT&T Labs if you look at it right From ws-news at gmx.at Fri Mar 9 05:41:07 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Fri, 9 Mar 2001 11:41:07 +0100 Subject: learning C References: <983975751.18833@newsmaster-04.atnet.at> <3AA82422.53026D3D@cosc.canterbury.ac.nz> Message-ID: <984134753.143458@newsmaster-04.atnet.at> ROTFL This one I like too... :-) regards werner Gregory Jorgensen wrote in message news:kh%p6.1339$54.1462 at www.newsranger.com... > Stroustrup himself said it best: "C makes it easy to shoot yourself in the foot; > C++ makes it harder, but when you do it blows your whole leg off." > > http://www.research.att.com/~bs/bs_faq.html#really-say-that > > > In article , D-Man says... > > > >On Fri, Mar 09, 2001 at 01:30:26PM +1300, Greg Ewing wrote: > >| Werner Schiendl wrote: > >| > > >| > The fine thing is: C++ still HAS the scalpel, so what? > >| > >| C++ is a Swiss army knife with both scissors and scalpel, > >| and a nasty tendency for the scalpel to shoot out and > >| stick you in the palm when all you were trying to do > >| was use the scissors... > >| > > > >Nice. I like this description. > > > >yet-not-joining-the-war-ly y'rs -D > > > > > > Greg Jorgensen > Deschooling Society > Portland, Oregon, USA > gregj at pobox.com From andymac at bullseye.apana.org.au Wed Mar 28 06:19:49 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Wed, 28 Mar 2001 21:19:49 +1000 (EST) Subject: warrior geeks In-Reply-To: Message-ID: On Tue, 27 Mar 2001, Delaney, Timothy wrote: > Australians in general are not overly keen on guns. Except for certain > security guards, non-military and non-police *cannot* get a license for a > handgun (and military and police cannot carry a gun unless on duty). > Likewise, it is almost impossible to buy ammunition for handguns. I'm sorry, but the above is complete garbage. But this isn't the forum for debating the details. -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andrew.macintyre at aba.gov.au (work) | Snail: PO Box 370 andymac at bullseye.apana.org.au (play) | Belconnen ACT 2616 andymac at pcug.org.au (play2) | Australia From ws-news at gmx.at Fri Mar 9 05:24:30 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Fri, 9 Mar 2001 11:24:30 +0100 Subject: "!=" is bad form. Re: sorry....never mind References: <3AA6E308.5B63ECC6@cosc.canterbury.ac.nz> <3AA72253.FB021815@Lugoj.Com> <984047188.296438@newsmaster-04.atnet.at> Message-ID: <984133751.749323@newsmaster-04.atnet.at> I'm happy not to be alone there liking C and C++ for some purposes :-) Tim Hammerquist wrote in message news:slrn9agdkv.9ms.tim at vegeta.ath.cx... > Werner Schiendl wrote: > > > I hate '<>' because it's too much like VB (and so many other BASIC > > > variants). > > > > I think there are at least the same number of programmers that hate the > > other way because it looks to much like C. > > Maybe we should invent some completely new operator, ending up with line > > noise one day... :-] > > I realize I seem to be in the minority in this group when I say I like > C/C++. NB: I like them as _languages_, but would prefer NOT to do > everyday programming in them, as they're just a pain in the ass most of > the time. > > I started out programming in BASIC on the TRS-80 and remember the utter > confusion upon seeing the '<>' operator ("It's greater than _and_ less > than?") I had no Pascal background. I like C's '!=' because it just > makes more sense to my logical, math-adept brain. > > I have no problem with anyone else using it, and if I saw it in > someone's code, I would understand it. I just prefer not to use it. > And since I've not heard any mention of either inequality operator being > deprecated, I have no cause to change. ;) > > -- > -Tim Hammerquist > > I don't have any solution, but I certainly admire the problem. > -- Ashleigh Brilliant From colinmeeks at home.com Mon Mar 5 13:16:03 2001 From: colinmeeks at home.com (Colin Meeks) Date: Mon, 05 Mar 2001 18:16:03 GMT Subject: Python & mySQL Message-ID: Does anybody have any pointers for integrating mySQL with Python. I've been using Python a while and am looking to develop a web backend using Python with mySQL. My site is hosted by a Linux based ISP who has both Python and mySQL but they don't currently have a link between the two. I'm using Windows2000 as my development base, so I want something that is usuable on both, so it's easier for me to track any problems. Ideally I want something that doesn't involved recompiling Python if that's possible, as i want the installation to be as straightforward for my ISP and of course me :-) Many thanks in advance Colin From aahz at panix.com Thu Mar 29 00:36:47 2001 From: aahz at panix.com (Aahz Maruch) Date: 28 Mar 2001 21:36:47 -0800 Subject: Various issues regarding thread References: Message-ID: <99uhlf$9kl$1@panix6.panix.com> In article , Gabriel Ambuehl wrote: > >I've been developping a small resource monitoring syste, in Python in >the last time and got some questions regarding threading.thread. I >figured it would probably be the easiest way (forking of new processes >seems very unwise as RAM to useage) to have a dedicated thread for >every resource that has to be monitored so it would be possible to just >have them sleep between the work and let Python do the scheduling. Now >however, I thought it could be cool to have the thing using pickle to >dump its state before it exits so it could continue its work right >where it left last time (not yet sure if this makes much sense though >;-). The only problem there is that pickle doesn't appear to be working >on lock objects which the thread subclasses inherently got. So is there >any possibility to serialize a class that has been inherited from >threading.thread? I haven't tested this, so I don't know whether pickle can handle lock objects (though it makes sense to me that they can't). What might make sense for you would be to create a "worker" class that isn't directly thread-aware (but is thread-safe), which you can then pickle, and have the thread class do all the locking around method calls to the worker class. >Another thing I couldn't figure out is how one could stop a thread >reliably. I first thought one could have a flag that gets checked by >the run method every now and then but then found this to be to slow as >it could well be that a thread sleeps for several minutes before it >notices that the flag had been set and thus should have exited some >time ago. What am I overlooking? Have the resource threads wait on a Queue.Queue(). Have one timer thread that puts work/die tokens on the queue. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Boost the stock market -- fire someone" From dnagata at creo.com Fri Mar 23 22:52:40 2001 From: dnagata at creo.com (Dale Nagata) Date: Sat, 24 Mar 2001 03:52:40 GMT Subject: Python Script to dial a VPN connection, automate VPN routing table updates. References: Message-ID: <3ABC1A08.247@creo.com> Warren Postma wrote: > > Sorry for the nearly-off-topic nature of this post, but .... > > I work from home now, and there's something in Windows 2000 that's > annoyingly manual: > > I have a permanent internet connection via @home cable modem, and I "dial" > through that to create a VPN connection to the office. The problems are > two: > > (1) Windows won't accept or save my userid, password and the domain name, so > I have to enter it manually. > > (2) After connecting, I have two default gateways in my routing tables > (ROUTE PRINT) and I need to update it so only the traffic that is destined > to the office goes through that interface. The IP addresses I get given are > different each time, making a batch file insufficient, so voila, a perfect > use for python. > > So after solving #2 above in Python, I wondered, does anyone know how, in > Python win32 extensions, one might dial an RAS connection, and if it's > possible to do so through the win32 API somewhere or through COM? Then I > could solve #1 above as well. > > Anyone else think this might make a nice little Python applet if I build in > some more VPN/RAS stuff and maybe even Gui-fy it a bit in wxPython or > tkInter. > I have a similar home setup. The win32ras module didn't have all the functions that I needed, so I used a combination of shelling out to the GUI dialer and monitoring the RAS connection state via some calls to RASAPI32.DLL using the windll module, then I just shell out to the route command to set up the routing table. The attached script should work if you have set up a dialup networking entry named 'Office VPN', but you can change PHONEBOOK_ENTRY at the top of the script to whatever you want (heck, you can change the whole script to whatever you want :-) Rename the script to vpnadmin.cmd or .bat - our mail system screens out attachments that look like executable content works for me -- Dale Nagata | tel : +1 604.451.2700 ext. 2254 (UTC-0800) Software Developer | fax : +1 604.437.9891 Creo Products Inc. | pgr : +1 604.691.8279 Burnaby BC Canada | http://www.creo.com/ -------------- next part -------------- @python -x %~f0 %* && pause && goto :EOF # # vpnadmin.py # # 1. Dial RAS phonebook entry PHONEBOOK_ENTRY. (skip if already connected) # 2. figure out what IP address was assigned to connection. # 3. Modify routing table so that office network goes through this gateway address. # # This works with my ADSL connection. # # W2K: disable default prompting for username/password # or wait in script while in this state??? # # also remember to disable default gateway for PPTP connection entry # # ---------------------------------------------------------------------------- # standard Python modules import os import sys import time import string import struct import msvcrt # Win32 Extension modules import win32api import win32con import win32ras import winerror # DLL pseudo-modules, for directly callng raw Win32 APIs that aren't wrapped import windll user32 = windll.module( 'user32' ) rasapi32 = windll.module( 'rasapi32' ) # ---------------------------------------------------------------------------- # name of phonebook entry to dial, in default system phonebook PHONEBOOK_ENTRY = 'Office VPN' # ---------------------------------------------------------------------------- # other constants... RESERVED = 0 # RASCS_PAUSED = 0x1000 RASCS_DONE = 0x2000 RASCS_OpenPort = 0 RASCS_PortOpened = 1 RASCS_ConnectDevice = 2 RASCS_DeviceConnected = 3 RASCS_AllDevicesConnected = 4 RASCS_Authenticate = 5 RASCS_AuthNotify = 6 # sending username and password... RASCS_AuthRetry = 7 RASCS_AuthCallback = 8 RASCS_AuthChangePassword = 9 RASCS_AuthProject = 10 RASCS_AuthLinkSpeed = 11 RASCS_AuthAck = 12 RASCS_ReAuthenticate = 13 RASCS_Authenticated = 14 RASCS_PrepareForCallback = 15 RASCS_WaitForModemReset = 16 RASCS_WaitForCallback = 17 RASCS_Projected = 18 #if (WINVER >= 0x400) RASCS_StartAuthentication = 19 RASCS_CallbackComplete = 20 RASCS_LogonNetwork = 21 #endif RASCS_SubEntryConnected = 22 RASCS_SubEntryDisconnected = 23 RASCS_Interactive = RASCS_PAUSED RASCS_RetryAuthentication = RASCS_PAUSED + 1 RASCS_CallbackSetByCaller = RASCS_PAUSED + 2 RASCS_PasswordExpired = RASCS_PAUSED + 3 RASCS_Connected = RASCS_DONE RASCS_Disconnected = RASCS_DONE + 1 RASP_PppIp=0x8021 # ---------------------------------------------------------------------------- # return string formatted like default exception traceback def format_traceback(): import sys x = sys.exc_info() buf = 'Traceback (innermost last):\n' import traceback tblist = traceback.extract_tb( x[2] ) for tb in tblist: buf = buf + ' File "%s", line %d, in %s\n %s\n' % tb buf = buf + '%s: %s\n' % ( x[0].__name__, str( x[1] ) ) return buf # print traceback to stdout def print_traceback( buf=None ): if not buf: buf = format_traceback() import sys sys.stderr.write( buf ) # ---------------------------------------------------------------------------- # get HWND of window matching given class name and title def FindWindow( wndclassname, windowname ): hwnd = user32.FindWindow( windll.cstring( wndclassname ), windll.cstring( windowname ) ) if hwnd == 0: errcode = win32api.GetLastError() errmsg = win32api.FormatMessage( errcode ) raise win32api.error( errcode, 'FindWindow', errmsg ) return hwnd # ---------------------------------------------------------------------------- # dial a phonebook entry if it isn't already connected # run the GUI tool so it looks nicer # wait for the dialog to close # check connection status afterwards def DialPhoneBookEntry( phonebook_entry ): isconnected = 0 conns = win32ras.EnumConnections() for conn in conns: #print conn if conn[1] == phonebook_entry: isconnected = 1 if isconnected: print 'Connected to', phonebook_entry else: print 'Dialing %s . . .' % phonebook_entry win32api.WinExec( 'rasphone -d \"%s\"' % phonebook_entry ) # TODO: handle Cancel within rasphone status = RASCS_Disconnected while not isconnected: win32api.Sleep( 1000 ) conns = win32ras.EnumConnections() for conn in conns: if conn[1] == phonebook_entry: hConn = conn[0] status = win32ras.GetConnectStatus( hConn ) # intermediate states 5 = RASCS_Authenticate, 14=RASCS_Authenticated if status[0] == RASCS_Authenticate: if status != status[0]: status = status[0] print 'Authenticating...' elif status[0] == RASCS_Authenticated: if status != status[0]: status = status[0] print 'Authenticated.' elif status[0] == RASCS_Connected: print 'Connected.' isconnected = 1 break else: print 'status:', status else: # *** this only works in NT4 # *** need to figure out equiv for W2K winver = win32api.LOWORD( win32api.GetVersion() ) if winver < 5: try: hwnd = FindWindow( '#32770', 'Connecting to %s...' % phonebook_entry ) except win32api.error, err: if err[0] == winerror.ERROR_PROC_NOT_FOUND: print 'Connection cancelled.' time.sleep( 1 ) return #while not connected #else not connected return isconnected #DialPhoneBookEntry # ---------------------------------------------------------------------------- # return dotted decimal IP address for RAS connection def GetRasIpAddress( phonebook_entry ): connlist = win32ras.EnumConnections() #[(655360, 'Office PPTP', 'VPN', 'RASPPTPM')] for conninfo in connlist: if conninfo[1] == phonebook_entry: break else: print "RAS connection '%s' not found" % phonebook_entry sys.exit(1) hrasconn = conninfo[0] structsize = struct.calcsize( 'L L 16s' ) dw = windll.membuf( struct.calcsize( 'i' ) ) dw.mb.write( struct.pack( 'i', structsize ) ) buf = windll.membuf( structsize ) buf.mb.write( struct.pack( 'L', structsize ) ) # MUST set struct member # on W2K/laptop, need a bit of a delay??? maxretries = 10 count = 0 while count < maxretries: err = rasapi32.RasGetProjectionInfo( hrasconn, RASP_PppIp, buf, dw ) if err == 0: break else: count = count + 1 if count < maxretries: win32api.Sleep( 1000 ) else: print 'RasGetProjectionInfo error %d' % err print 'go look up the error code in ' sys.exit( 1 ) dwSize, err, rawipaddr = struct.unpack( 'L L 16s', buf.mb.read() ) ipaddr, junk = string.split( rawipaddr,'\0', 1 ) #'192.168.91.4\000_ma' print 'IP address:', ipaddr return ipaddr #GetRasIpAddress # ---------------------------------------------------------------------------- # update routing table for office subnets given IP address to use as gateway def SetupOfficeRouting( gateway ): os.system( 'route add 192.197.216.0 mask 255.255.252.0 %s' % gateway ) os.system( 'route add 192.168.0.0 mask 255.255.128.0 %s' % gateway ) os.system( 'route add 204.174.12.32 mask 255.255.255.240 %s' % gateway ) os.system( 'route add 204.174.12.48 mask 255.255.255.240 %s' % gateway ) os.system( 'route add 204.174.12.112 mask 255.255.255.240 %s' % gateway ) print 'IP routing established for office network using PPTP connection.' # ---------------------------------------------------------------------------- # hangup RAS connection, if connected def HangUpConnection( phonebook_entry ): connlist = win32ras.EnumConnections() #[(655360, 'Office PPTP', 'VPN', 'RASPPTPM')] for conninfo in connlist: if conninfo[1] == phonebook_entry: hrasconn = conninfo[0] win32ras.HangUp( hrasconn ) break else: print 'Not connected.' #print "RAS connection '%s' not found" % phonebook_entry sys.exit(1) # ---------------------------------------------------------------------------- # manage Office PPTP connection def vpnadmin(): USAGE = 'Usage: vpnadmin { dial | hangup | print }' argc = len( sys.argv ) if argc != 2: print USAGE sys.exit( 1 ) cmd = sys.argv[1] if cmd == 'dial': try: isp_entry = os.environ['ISP_PHONEBOOK_ENTRY'] DialPhoneBookEntry( isp_entry ) pass except KeyError: pass DialPhoneBookEntry( PHONEBOOK_ENTRY ) ipaddr = GetRasIpAddress( PHONEBOOK_ENTRY ) SetupOfficeRouting( ipaddr ) elif cmd == 'hangup': HangUpConnection( PHONEBOOK_ENTRY ) elif cmd == 'print': os.system( 'ipconfig /all' ) os.system( 'route print' ) else: print 'Unrecognized command:', cmd print USAGE sys.exit( 1 ) def main(): try: vpnadmin() except SystemExit: pass except: print_traceback() raw_input( 'Press ENTER to finish . . . ' ) if __name__ == '__main__': main() From ws-news at gmx.at Wed Mar 7 09:50:38 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Wed, 7 Mar 2001 15:50:38 +0100 Subject: Python script for deMSWordification? References: <985h02$1pbm$1@swen.emba.uvm.edu> Message-ID: <983976916.181372@newsmaster-04.atnet.at> If you have it on your machine you can use itself with Automation to do the job. otherwise .doc Files are basically OLE Compound Documents that represents an IStorage. IStorage is an interface that models DCOM structured storage alongside IStream. Comapred to a file system IStorage is a directory, and IStream is a file. There are APIs to cope with that kind of file. With Visual Studio comes a tool called DocFile Viewer that shows the basic content of the file. But I guess you want to do that on non-MS platform. This sounds to me like big fun, so enjoy it! hth werner wrote in message news:985h02$1pbm$1 at swen.emba.uvm.edu... > Dear fellow Pythoneers; > > Numerous colleagues and administration types send memos, colloqium > announcements and other things around in Micro$oft word format. Has anyone > written a filter in Python that can convert these things into normal text? > > If not, is there a basic set of rules for decoding .doc format files > anywhere that I can look at? > > Cheers, > > -k > > -- > > kelvin.chu at uvm.edu (802) 656-0064 > http://www.uvm.edu/~kchu/ FAX: (802) 656-0817 > From danielk at aracnet.com Mon Mar 12 09:52:24 2001 From: danielk at aracnet.com (Daniel Klein) Date: Mon, 12 Mar 2001 06:52:24 -0800 Subject: Private class and instance methods? References: <3AAA73BF.9CDCF3B2@alcyone.com> Message-ID: I'm trying to get a grasp of the Python paradigm. Could you expound a bit on the advantages of this over the seemingly simpler getX/setX methodology? Seeing as there is virtually nothing that is really 'hidden' in Python (which is a _good_ thing imo), why not simply use the _underscore rules (and good documentation) to specify privacy? Thanks, Daniel Klein On Sat, 10 Mar 2001 16:04:14 -0500, Mark Pilgrim wrote: >There is a better way to do this in Python, using the __getattr__ and >__setattr__ special methods. > >class foo: > privatekeys = ('x',) > > def __init__(self, x): > self.x = x > def __getattr__(self, key): > print "getting private value %s" % key > return self.__dict__['__%s' % key] > def __setattr__(self, key, value): > if key in self.__class__.privatekeys: > print "setting private value %(key)s to %(value)s" % locals() > self.__dict__['__%s' % key] = value > else: > self.__dict__[key] = value > >if __name__=='__main__': > f = foo('abc') > print "f.x = %s" % f.x > f.y = [] > print "f.y = %s" % f.y > f.x = 10 > print "f.x = %s" % f.x From ben at . Wed Mar 21 13:37:21 2001 From: ben at . (Benjamin.Altman) Date: Wed, 21 Mar 2001 13:37:21 -0500 Subject: learning python... Message-ID: <3AB8F4E1.184DD9C@noaa.gov> Hello. From the perspective of someone who already has programming experience, would anyone know if O'reillys "Learning Python" book would be better than say Prentice Hall's "Core Python Programming"? Or would it be better to go straight into something like "Programming Python"? Thanks, Ben From edwardt at trillium.com Mon Mar 26 18:39:27 2001 From: edwardt at trillium.com (edwardt at trillium.com) Date: 26 Mar 2001 23:39:27 GMT Subject: how to write a text file search & replace script Message-ID: <99ojvf$ufj$1@news.netmar.com> Hi I am trying to write a python script to do the following. Situation: There are currently a bunch of files which need the following to be replaced: 1. Function names, 2. the function arguments and 3. some global variables These are a bunch of private library functions that these files are calling. Since all these library function names are changed. Some of the function argument names need to be changed too, and there are some extra function arguments!! The files calling thest functions need to be changed too! But too many files, so too many changes. I want to automate this with a python script. For example: def main(): tstPrp = "Damn this thing" pixitObj.variant = "Python" PrnHdr(sid, a="OLD function name", b="those people should think before they write the library functions", c="I am frustrated") shall be replaced by def main(): testPurpose = "Damn this thing" guiCb.pixitObj.variant = "Python" CtfPrintHeader(sid,a1="OLD function name",b1="those people should think before they write the library functions",c="I am frustrated", d="Please help") Can anyone help? Also, can some kind of data structure store a list of the function name and the associated function arguments that the script canr ead from? So that if there are more to be changed, all I need to do just to go in and edit the entry like a spread sheet? Thanks ----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web ----- http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups NewsOne.Net prohibits users from posting spam. If this or other posts made through NewsOne.Net violate posting guidelines, email abuse at newsone.net From not.this at seebelow.org Thu Mar 15 17:28:54 2001 From: not.this at seebelow.org (Grant Griffin) Date: 15 Mar 2001 14:28:54 -0800 Subject: inverse of asctime Message-ID: <98rfn6016rf@drn.newsguy.com> Hi Gang, I'm in the market for the inverse of asctime(). I looked in the time module but couldn't find it. (Nope, strptime isn't available on my Windows installation.) Seems like there oughtta be sucha thing somewhere. either-the-forest-is-missing-a-tree-or-it's-got-too-many -tress-that-i-don't-need-ly y'rs, =g2 _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From moshez at zadka.site.co.il Thu Mar 22 04:02:32 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Thu, 22 Mar 2001 11:02:32 +0200 Subject: New PEP: The directive statement In-Reply-To: <20010321215413.B25810@glacier.fnational.com> References: <20010321215413.B25810@glacier.fnational.com>, Message-ID: On Wed, 21 Mar 2001 21:54:13 -0800, Neil Schemenauer wrote: > May I suggest reading the PEP: > > http://python.sourceforge.net/peps/pep-0236.html > > Its not long and reading it will make you better in bed. Like Python2C, I wouldn't expect great miracles: 30% is probably the most one can expect. python.ca-addresses-huh?-cool!-ly y'rs, Z. -- "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than Python? looking for someplace else to grab power."|YODA: No...no... no. Quicker, -- Wichert Akkerman (on debian-private)| easier, more seductive. For public key, finger moshez at debian.org |http://www.{python,debian,gnu}.org From fig at monitor.net Tue Mar 20 04:04:20 2001 From: fig at monitor.net (Stephen R. Figgins) Date: Tue, 20 Mar 2001 01:04:20 -0800 Subject: HELP - beginner to programing/python References: <3AB6B6F7.5BF4BBD7@northwestern.edu> Message-ID: <3AB71D14.DB007A1B@monitor.net> > As proof of Stephen Figgins genuineness, even though he is writing for the > O'Reilly web site, he does not recommend any of the O'Reilly books :-) Thanks, Louis. I do actually recommend O'Reilly books, just not for beginning programmers. I like Learning Python and find it very useful when I need something wordier than Python Essential Reference. My top recommendation for beginning programmers, however, isn't a particular book or tutorial at all. The best thing a beginner could do is find a good mentor. Books are okay, but good mentors are invaluable. It is best if it is someone you know personally, someone who is doing the kinds of things you want to be able to do. If you don't know anyone like that, find people who really want to see you succeed and are willing to help you. For that, both this list and the Python Tutor list are great resources. Pick any beginning tutorial and dive in. Try some things out and when you have questions, ask. Stephen From parkw at better.net Thu Mar 8 17:35:35 2001 From: parkw at better.net (William Park) Date: Thu, 8 Mar 2001 17:35:35 -0500 Subject: Database with Python ?? In-Reply-To: <988vmn$t77$05$1@news.t-online.com>; from lux_mundt@t-online.de on Thu, Mar 08, 2001 at 11:13:04PM +0100 References: <988vmn$t77$05$1@news.t-online.com> Message-ID: <20010308173535.A32695@better.net> On Thu, Mar 08, 2001 at 11:13:04PM +0100, Thomas Mundt wrote: > Has Python a own database language No. > and do someone know a link to a Tutorial in database-working with > python? Browse "special topic" at . ---William Park, Open Geometry Consulting, Linux/Python, 8 CPUs. From aleaxit at yahoo.com Wed Mar 21 10:42:13 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 21 Mar 2001 16:42:13 +0100 Subject: Yet Another PEP: Interface Adapter Mechanism __adapt__ References: Message-ID: <99ai4i01t4a@news2.newsguy.com> "Robin Thomas" wrote in message news:mailman.985177412.11344.python-list at python.org... [snip] > could assimilate issubclass(). I support that work, but I see that it gives > some complexity to the meaning of the return value -- in adapter-like > cases, you want to return self or an adapter of self; in test-like cases, > you want to return a boolean. I also think that is very cool. Yes, but, None/non-None generally works fine in a Boolean context (just test with 'is None'/'is not None' if need be). Not that I think boolean use will be frequent, see later. > A word that works nicely as an operator name, especially a simple word that > novices can grasp quickly, would be ideal as a name for this new feature. > > Suggestions: > > 1) "like" I suggest 'as' instead -- if the same will-become-an-operator considerations apply ("give me X ``as'' an Y" sounds more natural to me than ``like'' does in this context); 'like' would strongly suggest the boolean reading, which is less often appropriate (all that boolean testing does is tell you that, yes, you COULD use X as an Y if you redid the same operation you just did but avoided throwing away the result...?!-). Alex From tino at wildenhain.de Fri Mar 2 04:34:51 2001 From: tino at wildenhain.de (Tino Wildenhain) Date: Fri, 02 Mar 2001 10:34:51 +0100 Subject: catching a del References: Message-ID: <3A9F693B.BF42BE36@wildenhain.de> Hi Dan, Dan Parisien wrote: > > class obj: > def __init__(self, name, parent): > parent.children[name] = self > self.parent = parent > self.name = name > > def onDelete(self): #?! > del self.parent[self.name] > > I want to be able to catch a del of an instance of the above class so I can > remove it from its parent dictionary. Is there a way? (note it cannot be in > a destructor because there will always be a reference inside the parent > dict) perhaps its __del__() ? Regards Tino From aahz at panix.com Sat Mar 24 09:47:22 2001 From: aahz at panix.com (Aahz Maruch) Date: 24 Mar 2001 06:47:22 -0800 Subject: [ANN] HappyDoc 1.4 released References: Message-ID: <99ic1q$e1t$1@panix6.panix.com> In article , Doug Hellmann wrote: > >Announcing the latest version of HappyDoc, a Python documentation >extraction tool. Do not taunt fun HappyDoc. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "I won't accept a model of the universe in which free will, omniscient gods, and atheism are simultaneously true." -- M From qrczak at knm.org.pl Wed Mar 14 17:30:40 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 14 Mar 2001 22:30:40 GMT Subject: Expect -- or popen2 -- or what? References: <98ojsa$95n$1@tyfon.itea.ntnu.no> Message-ID: Wed, 14 Mar 2001 21:22:30 +0100, Magnus Lie Hetland pisze: > I'm trying to communicate with an interactive program which seems > to be a bit reluctant to flush its output... import pty I'm sorry to not give more details. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From LangaK at discoveryhealth.co.za Fri Mar 2 06:22:40 2001 From: LangaK at discoveryhealth.co.za (Langa Kentane) Date: Fri, 2 Mar 2001 13:22:40 +0200 Subject: playing with IP's Message-ID: Greetings. Here is what I wanna do: Given a network number and mask ie: 192.168.1.0/26 I want to create a list with all the valid hosts on that range. Problem is I don't know how to play with binary Where would I start.. any sample code? Thanks _________________________________________________________ Langa Kentane | Tel: [011] 290 3218 Security Administrator | Cell: 082 606 1515 [CNA MCSE CCSA CCNA] | www.discoveryhealth.co.za _________________________________________________________ From gerhard.nospam at bigfoot.de Sat Mar 3 01:07:13 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sat, 03 Mar 2001 07:07:13 +0100 Subject: PyRun_SimpleFile - impossible to call it under Windows? References: <3aa07704.2672581@news.newsguy.com> Message-ID: <3AA08A11.95BC7745@bigfoot.de> "Owen F. Ransen" wrote: > > I've seen that there is an odd bug in PyRun_SimpleFile > probably because of version incompatibilities in the > FILE structure and using DEBUG modes in VC6 > > I'd like to call PyRun_SimpleFile in the debug version > of my VC6 program, is it impossible currently with Python 2? I suggest that you use the debug version of the Python libraries, available at http://www.activestate.com/Products/ActivePython/Download.html and elsewhere that I don't remember. Gerhard -- Sorry for the fake email, please use the real one below to reply. contact: g e r h a r d @ b i g f o o t . d e web: http://highqualdev.com From ransen_spam_me_not at nemo.it Mon Mar 12 00:52:29 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Mon, 12 Mar 2001 05:52:29 GMT Subject: PyRun_SimpleFile - impossible to call it under Windows? References: <3aa07704.2672581@news.newsguy.com> <3AA08A11.95BC7745@bigfoot.de> <3aa0bd3f.708696@news.newsguy.com> <3AAACE47.8000802@ActiveState.com> Message-ID: <3aab28f3.1012326@news.newsguy.com> On Sun, 11 Mar 2001 01:04:05 GMT, Mark Hammond wrote: >Owen F. Ransen wrote: > >> I am already linking to Python20_d.lib, is that not the correct >> version? > >I hope I am not too late - but make sure your extension is compiled with >"/MD" for release builds and "/MDd" for debug builds. > >Mark. Yes. Thanks Mark. After help from this newsgroup I've managed to get things going now. Apart from a few memory leaks at the very end of the program instance things look pretty good :) -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From tim.one at home.com Thu Mar 1 17:41:06 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 1 Mar 2001 17:41:06 -0500 Subject: A counter-proposal to __future__ in PEP 236 In-Reply-To: <97ll2u02qmp@news2.newsguy.com> Message-ID: [Alex Martelli] > ... > The _semantics_ of PEP 236 are a great idea; I do earnestly hope there > is some way, ANY way, to avoid its syntax, and this 'directive' idea > gives me a glimmer of hope...! ANY way, you say? OK, the new syntax is from __future__ >> nested_scopes I thought you'd like that better than print __future__ << nested_scopes although both work for me . From jsoons at juilliard.edu Wed Mar 21 11:32:39 2001 From: jsoons at juilliard.edu (Jonathan Soons) Date: Wed, 21 Mar 2001 11:32:39 -0500 Subject: os.system output Message-ID: I am trying to save the output of >>>dirs = os.system('ls') into a variable but I do not need any output to the screen (altho it doesn't hurt). How do I go about this? My fat book only explains how to get output to the screen. I could do >>>os.system('ls > file') >>>f = open('file') >>>dirs = f.readlines() but it looks crude. Is there a better way? From aleaxit at yahoo.com Tue Mar 20 19:04:43 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 21 Mar 2001 01:04:43 +0100 Subject: Yet Another PEP: Query Protocol Interface or __query__ References: Message-ID: <998r4j02vmb@news2.newsguy.com> "Clark C. Evans" wrote in message news:Pine.LNX.4.21.0103201837570.21343-100000 at clarkevans.com... > Please have a look at the PEP below, it is intended to be a > light-weight solution to "typing" based on programmer intent. At least when read at 1 AM -- sounds cool. Further, the builtin query function could support _adding interfaces to an object post-facto, non-invasively_, much like the 'typeclass'-based ideas that were floating in my mind recently and surfaced in some of my recent posts. I.e., the query() builtin would both try getting the interface from the _object_, by passing that interface to the obj's query method, AND also try doing it the other way 'round -- asking the interface if it knows how to wrap the object so it (the interface) gets implemented. That would require interface-identifiers to be richer objects than just string, or a registry which associates a string identifying an interface with such a richer object. I fully agree (as a COM expert) that COM's identity rules are not appropriate as the semantics of query(). Indeed, COM defines an alternate approach to getting an interface providing a service (the IServiceProvider interface) for the specific purpose of uncoupling the identity of the object providing the service from that of the object being queried for it -- it's OK if the same object does both, but not a requirement. Particularly if we accept the idea that the query built-in can query both the object AND the interface, this decoupling seems the right semantics for this case. Since 'interface' is so deucedly overloaded a word, maybe 'protocol' might be be better -- so we only get confused with FTP, HTTP and the like:-). Alex From fredrik at pythonware.com Wed Mar 21 10:29:36 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Mar 2001 15:29:36 GMT Subject: Html entities References: Message-ID: Syver Enstad wrote: > Is there an easy way to convert ISO Latin-1 characters that are above 127 > ascii to their HTML, XML entity form? something like this might work: # htmlentitydefs-example-3.py # from (the eff-bot guide to) the standard python library import htmlentitydefs import re, string # this pattern matches substrings of reserved and non-ASCII characters pattern = re.compile(r"[&<>\"\x80-\xff]+") # create character map entity_map = {} for i in range(256): entity_map[chr(i)] = "&%d;" % i for entity, char in htmlentitydefs.entitydefs.items(): if entity_map.has_key(char): entity_map[char] = "&%s;" % entity def escape_entity(m, get=entity_map.get): return string.join(map(get, m.group()), "") def escape(string): return pattern.sub(escape_entity, string) print escape("") print escape("? i ?a ? e ?") ## prints: ## <spam&eggs> ## å i åa ä e ö Cheers /F From ixokai-nf at myNOSPAM.org Wed Mar 28 05:56:08 2001 From: ixokai-nf at myNOSPAM.org (Ixokai) Date: Wed, 28 Mar 2001 02:56:08 -0800 Subject: types.AnyType - describing interfaces with sequences of types References: Message-ID: <3ac1c5b3_1@goliath.newsfeeds.com> Try this: class _AnyType: def __cmp__(self, other): return 0 def __rcmp(self, other): return 0 AnyType = _AnyType() >>> IntType == AnyType 1 >>> type("string") == AnyType 1 You get the idea. AnyType above will be eternally happy to be equivelent to anything you compare it to. Note that you can't do 'IntType is AnyType', that tells you actual object identity. Now, if you wanted it to only show up as 'equivelent' to TypeTypes, and not say, strings, (e.g. "string" == AnyType) you could do a check to make sure what its being compared to is a TypeType..... Its a hack, yes.. :) --Ixokai ( Replace 'NOSPAM with 'seraph' to respond) Carlos Alberto Reis Ribeiro wrote in message ... >My problem - short question: > >I would like to have a type description called AnyType, in such a way that >it always return true when compared for equality or membership against any >valid type. Do something like this exist? Does it make sense? > > Example: > >>> IntType is AnyType > 1 > >>> FloatType == AnyType > 1 > >>> "" = AnyType > 0 > >Long question: > >I was tinkering with some of my proxy experiments, trying a lot of >different ideas to describe interfaces using only plain Python. One of them >is the following code snippet: > >from types import * > >class Interface: > """ base class for interface specification """ > pass > >class InterfaceSequence(Interface): > """ interface to implement sequence-like objects """ > __len__ = ((), (IntType,)) > __getitem__ = ((IntType,), (NoneType,)) > __setitem__ = ((IntType,NoneType), ()) > __delitem__ = ((IntType,), ()) > >The idea here is to define some member attributes inside the >InterfaceSequence class. A helper function then scans >InterfaceSequence.__dict__ to build the proxy object. Take this only as an >example, please - the issue here is not the interface, but the types the >are available in the the 'types' module. > >My problem now is: how to describe the method signature? I'm using the >following data structure in my example: > > = (, ) > = sequence of type > = type > >For example, take the __getitem__ method: > > __getitem__ = ((IntType,), (NoneType,)) > >This means that __getitem__ have one parameter of IntType (for a sequence, >remember!), and returns a value of... NoneType (?!?!). This would be much >better: > > __getitem__ = ((IntType,), (AnyType,)) > >So that's the problem. I would like to use a value of AnyType for cases >like this, however, I dont have AnyType as a valid type description. What >is worse, there is no UserType module to extend type definitions. > > >p.s. I have some approaches being explored for the interface definition. >This is one of the alternatives. As for the method signature, there are >some other alternatives that include more information, such as: > >a) __getitem__ = ((('key', IntType), ), (AnyType,)) >b) __getitem__ = ({'key':IntType}, (AnyType,)) >c) __getitem__ = ({'key':IntType}, AnyType) > >The last one seems to be the cleanest. It limits the return value >description to asingle type, but this seems to be enough for my intentions. >However, the problem with 'AnyType' is still there. > > >Carlos Ribeiro > > > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From deblNoNoSpammy at theworld.com Tue Mar 6 12:14:23 2001 From: deblNoNoSpammy at theworld.com (David Lees) Date: Tue, 06 Mar 2001 17:14:23 GMT Subject: Trouble running a Grayson Example References: <3AA3E573.6DBE6D2E@theworld.com> <3aa43d78.258996734@news1.on.sympatico.ca> Message-ID: <3AA51AF7.336BA869@theworld.com> Robert, Thanks, you figured it out. I made your suggested changes and the example works fine. David Lees Robert Roy wrote: > > On Mon, 05 Mar 2001 19:13:50 GMT, David Lees > wrote: > > >I am trying to run example 8.9 (Example_8_9.py) from Graysons book, > >under Python 2.0 and get the following errors. Can someone tell me what > >is going on? Perhaps this has to do with changes between 1.5.2 and 2.0 > >Python? > > > >Thanks in advance. > > > >david lees > > > > > >Traceback (most recent call last): File > >"d:\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in > >RunScript > > exec codeObject in __main__.__dict__ > > File "E:\Grayson1\Chapter08\Example_8_9.py", line 79, in ? > > ddnotebook = DDNotebook() > > File "E:\Grayson1\Chapter08\AppShell.py", line 55, in __init__ > > self.__createInterface() > > File "E:\Grayson1\Chapter08\AppShell.py", line 282, in > >__createInterface > > self.createInterface() > > File "E:\Grayson1\Chapter08\Example_8_9.py", line 75, in > >createInterface > > self.createNotebook() > > File "E:\Grayson1\Chapter08\Example_8_9.py", line 26, in > >createNotebook Pmw.NoteBookR,(self.interior(),),) > > File "E:\Downloads\pmw\Pmw\Pmw_0_8_4\lib\PmwLoader.py", line 174, in > >__getattr__ > >AttributeError: NoteBookR > > The examples in the Grayson book were written using an older version > of Pmw probably 0_8_1. NoteBookR ceased to exist in 0_8_3 and you are > using 0_8_4. There were some fundamentat changes to the way Notebook > works. > > The following code will work. > > def createNotebook(self): > # changed Pmw.NoteBookR to Pmw.NoteBook > self.notebook = self.createcomponent('notebook', (), None, > Pmw.NoteBook, > (self.interior(),),) > self.notebook.pack(side=TOP, expand=YES, fill=BOTH, padx=5, > pady=5) > self.formwidth = self.root.winfo_width() > > def addPage(self, dictionary): > table, top, anchor, incr, fields, \ > title, keylist = dataDict[dictionary] > # there is no label attribute anymore but a tab_text attribute > #(optional) > # self.notebook.add(table,label=title) > self.notebook.add(table, tab_text=title) > self.current = 0 > ypos = top > idx = 0 > for label, field, width, proc, valid, nonblank in fields: > pstr = 'Label(self.notebook.page(table),'\ > 'text="%s").place(relx=%f,rely=%f, anchor=E)\n' % \ > (label, (anchor-0.02), ypos) > if idx == keylist[0]: > # self.notebook.page(table).interior() to self.notebook.page(table) > # did this in 3 places > pstr = '%sself.%s=Entry(self.notebook.page(table),'\ > 'text="",insertbackground="yellow", > width=%d+1,'\ > 'highlightthickness=1)\n' % (pstr,field,width) > else: > pstr = '%sself.%s=Entry(self.notebook.page(table),'\ > 'text="", insertbackground="yellow",'\ > 'width=%d+1)\n' % (pstr,field,width) > pstr = '%sself.%s.place(relx=%f, rely=%f,'\ > 'anchor=W)\n' % (pstr,field,(anchor+0.02),ypos) > exec '%sself.%sV=StringVar()\n'\ > 'self.%s["textvariable"] = self.%sV' % \ > (pstr,field,field,field) > ypos = ypos + incr > idx = idx + 1 From andy at reportlab.com Fri Mar 23 11:57:37 2001 From: andy at reportlab.com (Andy Robinson) Date: Fri, 23 Mar 2001 16:57:37 +0000 Subject: Reportlab Enterprise Reporting suite - downloads available Message-ID: ReportLab announces the availability of evaluation beta downloads for its forthcoming enterprise reporting tools: RML2PDF: Translates high level XML document descriptions to PDF format. ** DOWNLOAD NOW: http://www.reportlab.com/rml ** PageCatcher: Creates PDF documents which import and modify pages and graphics from existing PDF documents. ** DOWNLOAD NOW: http://www.reportlab.com/pageCatcher ** ReportLab's Document Creation Solution ======================================== ReportLab's solution solves several central problems that ebusinesses face in creating publishing caliber reports that are customized, produced in real time, in volume, and platform independent. Existing reporting tools are limited to database reports, are typically Windows-based, have problematic restrictions on layout and graphic design, and go straight to a printer. More complex publishing systems involve pipelines of applications which are simply too unwieldy for real-time use in large scale enviroments ReportLab's product suite allows direct creation of rich PDF reports on web or application servers in real time. The tools run on any platform, can actively acquire data from any source (XML, flat files, databases, COM/Corba/Java), place no limits on the output, and facilitate electronic delivery and archival. The ReportLab suite lets you define your own business rules to automatically create custom online reports, catalogs, business forms, and other documents. Today's businesses must provide concise and timely information to customers, potential customers, investors, partners, regulators and other "information consumers," preferably customized to an audience of one. In many cases these documents can begenerated automatically, and the ReportLab toolkit provides the best tool for generating these documents. The ReportLab suite can assemble complex documents from a mix of pre-prepared and automatically constructed text, images, tables, and graphics. The integrated ReportLab document generation suite links the flexibility of XML and HTML with precise control of PDF to deliver targeted and personalized documents in the right format and with the right impact. Components: =========== The ReportLab suite's three main components are the commercial RML2PDF and PageCatcher products, together with the Open Source ReportLab core API. Our RML2PDF product is a translator which takes a document specification written in RML and translates the specification into a PDF document. RML (Report Markup Language) is an XML dialect which is as easy to use as HTML but which also provides a high degree of control for page layouts and graphical presentations. RML also includes interfaces to PageCatcher (see below), and plug-in functionality allowing custom charts and data displays to be added. Companies can use the tools they know best to generate RML files much as they would HTML. To create a PDF document, describe the document using RML, possibly importing whole pages directly from other PDF documents, and RML2PDF will construct the document for you. No programming required! ** DOWNLOAD NOW: http://www.reportlab.com/rml ** Our PageCatcher product enables the reuse of any existing PDF files, allowing firms to use their favorite design elements and tools. PageCatcher extracts graphical elements fromPDF files for inclusion in documents generated by RML2PDF or the ReportLab core API. Since any external program with the ability to print can produce PDF files via Adobe Acrobat, this means that a ReportLab document can include graphical elements created by virtually any program. ** DOWNLOAD NOW: http://www.reportlab.com/pageCatcher ** The ReportLab core API provides programming interfaces for PDF file generation. Using the API programmers can build plug in components for RML2PDF, or whole programs for creating PDF documents. ** DOWNLOAD NOW: http://www.reportlab.com/download.html ** Example Uses ============= These are some of the many possible applications for Reportlab technology: Electronic Forms and Fulfilment: -------------------------------- Invoices, purchase orders and custom contracts which would normally be sent by post can be generated at the point of sale and delivered immediately. Application forms can be generated with pre-filled data for signature by clients, increasing response rates and accuracy. The same PDF document can be archived on the vendor's system, providing a complete record; delivered through the web or email; and, if needed, routed for subsequent printing and posting. Realtime online securities statement. ------------------------------------- A securities firm, fund manager, or bank could use the ReportLab toolkit to build a downloadable customer statement in real time, in response to a click on a web form. The statement would be indistinguishable from a personalized investment analysis with charts and tables reflecting the customer's investment portfolio, and perhaps some automatic risk/return analysis together with hypothetical projections and analysis. The attractively laid out statement could provide several views of the customers portfolio data, performance histories of the securities held, and various analytical reports such as portfolio analysis indicating opportunities to rearrange the holdings according to the customer's stated goals. Management, scientific and engineering reporting. ------------------------------------------------- Periodic reports are an essential tool of modern corporate life. These reports frequently integrate text, tables, and charts, often in a standard format. An automated script can use the ReportLab toolkit to construct these reports by querying multiple databases and accounting systems, acquiring text, and constructing charts to order. Other programs could automatically send the reports out by electronic mail or print them on appropriate printers, or otherwise archive and distribute the reports electronically. Personalized portal newsletter. ------------------------------- Many web portals provide personalized spaces associated with personalized advertising. A portal could use the ReportLab toolkit to create downloadable personalized documents, and include personalized advertising targeted to the user's profile and interests. PDF is much better for framing personalized content and advertizing than HTML since PDF provides complete control of page layout, rather than the limited control in HTML. Content and advertising presented in PDF could attain magazine quality presentation even when printed on a user's low-priced color printer. Bottom Line: ============ The modern world is awash in information and data. To be successful, the modern business must present the right information to the right person in the right way. ReportLab's document creation suite is the next generation in easy, fast, scalable presentation-caliber reporting. CONTACT: info at reportlab.com http://www.reportlab.com/ From john at underdog.nmt.edu Sat Mar 24 12:16:44 2001 From: john at underdog.nmt.edu (John Shipman) Date: Sat, 24 Mar 2001 17:16:44 +0000 (UTC) Subject: New Tkinter and PIL documentation (free) References: <99en42$2vl6$1@newshost.nmt.edu> Message-ID: <99ikps$1qmo$1@newshost.nmt.edu> First I wrote: +-- | At this site you will find my newly written reference document | for Tkinter: | | http://www.nmt.edu/tcc/help/pubs/lang.html +-- Then Don Tuttle replied: +-- | I downloaded the Tkinter PDF, but apparently I don't have the same | font you used. (The text is very fuzzy) Assuming this is the | problem, would you consided remaking the PDFs with a more standard | font? Thanks. +-- The document was designed for print, not for screen use. It should print cleanly. If you're reading it with Acrobat, try increasing the magnification. -- John Shipman (john at nmt.edu), Applications Specialist, NM Tech Computer Center, Speare 128, Socorro, NM 87801, (505) 835-5950, http://www.nmt.edu/~john ``Let's go outside and commiserate with nature.'' --Dave Farber From nas at python.ca Fri Mar 30 23:39:46 2001 From: nas at python.ca (Neil Schemenauer) Date: Fri, 30 Mar 2001 20:39:46 -0800 Subject: Is there a bug tracker program written in Python? In-Reply-To: <20010330.110051.1782436840.1258@scoot.zenplex.com>; from scott@zenplex.com on Fri, Mar 30, 2001 at 11:00:51AM -0500 References: <20010330.110051.1782436840.1258@scoot.zenplex.com> Message-ID: <20010330203946.A2623@glacier.fnational.com> scott at zenplex.com wrote: > I'm looking for a Bug Track system like bugzilla but written in Python. > Does anybody know of such? Just learned Python and would would like to > use a system based on Python if at all possible. Roundup is cool. My college, Greg Ward, is also working on a system called SPLAT! which uses Quixote and bsdbd3. Its not done yet though. Neil From qrczak at knm.org.pl Sat Mar 24 11:22:43 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 24 Mar 2001 16:22:43 GMT Subject: close(), exceptions and problems References: <99i3j7$lqr$1@news.cybercity.dk> Message-ID: Sat, 24 Mar 2001 12:23:03 +0000 (UTC), Erwin S. Andreasen pisze: > But if you call close(fd) you aren't supposed to do something like: > > int fd, rv; > while (((rv = close(fd)) < 0 && errno == EINTR)) > ; > if (rv < 0) > perror("close"); Linux documentation says otherwise. File: libc.info, Node: Opening and Closing Files, Next: I/O Primitives, Up: Low-Level I/O [...] - Function: int close (int FILEDES) The function `close' closes the file descriptor FILEDES. Closing a file has the following consequences: * The file descriptor is deallocated. * Any record locks owned by the process on the file are unlocked. * When all file descriptors associated with a pipe or FIFO have been closed, any unread data is discarded. This function is a cancellation point in multi-threaded programs. This is a problem if the thread allocates some resources (like memory, file descriptors, semaphores or whatever) at the time `close' is called. If the thread gets cancelled these resources stay allocated until the program ends. To avoid this, calls to `close' should be protected using cancellation handlers. The normal return value from `close' is 0; a value of -1 is returned in case of failure. The following `errno' error conditions are defined for this function: `EBADF' The FILEDES argument is not a valid file descriptor. `EINTR' The `close' call was interrupted by a signal. *Note Interrupted Primitives::. Here is an example of how to handle `EINTR' properly: TEMP_FAILURE_RETRY (close (desc)); `ENOSPC' `EIO' `EDQUOT' When the file is accessed by NFS, these errors from `write' can sometimes not be detected until `close'. *Note I/O Primitives::, for details on their meaning. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From kalle at gnupung.net Thu Mar 29 11:24:18 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Thu, 29 Mar 2001 18:24:18 +0200 Subject: Printing "%" In-Reply-To: <99vm4k$22l$1@ctb-nnrp2.saix.net>; from mix77@usa.net on Thu, Mar 29, 2001 at 05:58:46PM +0200 References: <99vm4k$22l$1@ctb-nnrp2.saix.net> Message-ID: <20010329182418.A5741@father> Sez Mix: > How do you print a percenrage (%)sign in Python? > I tried : > return "select * from fax where id LIKE '%s\%'" %ident Use double %-sign: return "select * from fax where id LIKE '%s%%'" % ident Peace, Kalle -- Email: kalle at gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD [ Not signed due to lossage. Blame Microsoft Outlook Express. ] From francois.granger at free.fr Fri Mar 9 16:59:12 2001 From: francois.granger at free.fr (=?ISO-8859-1?Q?Fran=E7ois_Granger?=) Date: Fri, 09 Mar 2001 21:59:12 GMT Subject: gah! I hate the new string syntax References: <97ohh2$polt0$1@ID-77331.news.dfncis.de> <97opsb$nhu$1@nntp6.u.washington.edu> <98an7i01tgp@news2.newsguy.com> Message-ID: <1eq0wri.16iujikxa9nloN%francois.granger@free.fr> D-Man wrote: > So we think, but no one has such records. Actually, we are all > "people" and came from the Garden of Eden Sorry, I can't find it on a map ? But I have heard of Lucy and some toher beeing our common grand mother... -- La realit?, y compris la realit? ?comonique, est toujours complexe. - Noelle Adam From sholden at holdenweb.com Fri Mar 2 22:31:01 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 2 Mar 2001 22:31:01 -0500 Subject: To the point of defeat.....IDLE References: <3A9AE62B.5070402@yahoo.com> <%ftn6.12742$zL.491362@e420r-atl1.usenetserver.com> Message-ID: "Deon Garrett" wrote in message news:slrn99ubbn.9ul.garrett at eagle.cs.colostate.edu... > > Well, don't take this as the gospel truth -- I haven't actively tried to > break anything since upgrading my Python to 2.0. But, it has been a while > and nothing has failed in my day-to-day use of the machine. I'm actually > using Mandrake 7.2, but I use some of the RedHat stuff for administration > and it all seems to work. Of course, I don't mind re-installing stuff from > scratch if I screw it up. If you're talking about a mission critical system, > it would definitely be worth checking out before you bail right in to the > upgrade. Just my two cents... > > Deon > > > > > >Has anyone actually verified that the myriad pieces of RedHat Python aren't > >incompatible with 2.x? [...] Well, actual experience is a good substitute for rumor and guess! THanks for letting me know: it wouldn;t be critical if a reinstall was required. regareds Steve From root at rainerdeyke.com Thu Mar 22 17:18:55 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Thu, 22 Mar 2001 22:18:55 GMT Subject: PEP 240 scares me References: Message-ID: "Pearu Peterson" wrote in message news:Pine.LNX.4.21.0103222338530.29360-100000 at kev.ioc.ee... > It is true that 1/2 == 0 surprise new (Python) programmers (but I quickly > learned to write 1./2 or 1/2. or 1/float(n) etc). > But making 1.2 to be a rational > 1 > --- > 2 That would be stupid. '1.2' should be the rational '6/5'. To write '1/2', you would actually write '1/2' (possibly with some operator other than '/'). I don't think anybody was arguing differently. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From Jerry.Spicklemire at IFLYATA.COM Fri Mar 16 09:22:09 2001 From: Jerry.Spicklemire at IFLYATA.COM (Spicklemire, Jerry) Date: Fri, 16 Mar 2001 09:22:09 -0500 Subject: Complete Docs for Python Programming (was several other things) Message-ID: <977A39E65CFCD3119ABF00D0B741D849E0FFD6@innt-73.ata.com> Don Tuttle wrote: >Hmm... I guess I didn't make myself clear. I'm not really interested in >Python apps. I'm interested in more specific topics on Python Development. >In short, don't make me learn VB, Perl, or C++ just so I can THEN figure out >how to do it in Python. Amen. This sums up my exasperation with a wonderful product with great potential, that fell off the face of the planet. GFA Basic for Windows was a port of the popular GFA product, a staple of european developers. It could do "anything", and was so far ahead of VB that it was painful. However, the pitch was, "Do MS Windows development without having to use C, C++". Sound familiar? Really the same as the VB appeal, except GFA Basic actually delivered, at least for some. So what was the problem? All the documentation said something to the effect of, "See Programming Windows" (a C/C++ book) "for details". Perfect, all I have to do to use this product, so I won't have to use C/C++, is to learn how to do everything in C/C++, and then translate it. Let's not leave Python in the same fix! There are so many amazing tools out there, but the examples in the docs are rarely adequate to tell a newby how to do anything real. It's difficult, and time consuming, but next time you are moved to send an example in answer to a question, think about whether a newby will have to learn three other things before it makes sense. A few basic comments, and pointers to further documentation can do wonders. To all of the very generous Guru class Pythoneers that frequent this list, please don't take this the wrong way. I am so grateful for the effort and support. It's just that there are lot's of folks out here who need Python, and the best way for them to see that is with clear, complete instructions. Sincerely, Jerry S. From achim.domma at syynx.de Tue Mar 20 05:36:09 2001 From: achim.domma at syynx.de (Achim Domma) Date: Tue, 20 Mar 2001 11:36:09 +0100 Subject: xml,sax,EntityResolver References: <997bvq$2p7$07$1@news.t-online.com> Message-ID: <997c1v$soi$03$1@news.t-online.com> ups ... sorry for the pgp-post ! Hi, I try to process a sgml-file via sax. The file contains 'undefined entities' which I don't care about, so would like to ignore them. I have tried to derive my Handler from EntityResolver and have resolveEntity overloaded. Here is some code : class MyHandler(handler.ContentHandler,handler.ErrorHandler,handler.EntityRe solver): def __init__(self): handler.ContentHandler.__init__(self) def startDocument(self): print "start" def startElement(self,name,attrs): print name def error(self, exception): print exception def fatalError(self, exception): print exception def warning(self, exception): print exception def resolveEntity(self, publicId, systemId): print publicID print systemID parser = make_parser() h = MyHandler() parser.setContentHandler(h) parser.setErrorHandler(h) parser.setEntityResolver(h) parser.parse("main.sgm") If the parser reaches α in main.sgm fatalError is called twice, but it seams that resolveEntity is never called - why ? What's the simplest way to ignore such entities ? greetings Achim From winson at mdsserv.mds.com.tw Fri Mar 30 02:21:45 2001 From: winson at mdsserv.mds.com.tw (???) Date: Fri, 30 Mar 2001 15:21:45 +0800 Subject: Python GUI with Swing References: <001e01c0b812$43f00760$340210ac@winson> <3AC3BE89.3F95C8DC@ou.edu> Message-ID: <001e01c0b8ea$16a14660$340210ac@winson> Let me explain more about it. I mean my customer need Swing, but I need Python to build a pilot system. Swing maybe slow but my customer can accept. If I use Swing thru Jython, it will be slower then directly using Java to develop the system. So I need a solution to use Swing in Python, that's all. Is there a module for Python called PySwing, only use Swing's look and feel GUI ?? It maybe a big issue to rewrite Java's Swing library into C source and transfer into Python' s module. Thanks all guys here. -- Best Regards, Winson Chang 3F, 2, 150 Lane, Sec. 5, Hsin I Rd., Taipei, Taiwan, R.O.C. Tel: +886-2-27225333 ext 376 Fax: +886-2-27222330 Email: winson at mdsserv.mds.com.tw ----- Original Message ----- From: "Luke L" Newsgroups: comp.lang.python To: Sent: Friday, March 30, 2001 7:00 AM Subject: Re: Python GUI with Swing > > If speed is an issue, don't use Swing. Swing is quite slow (from > > experience) as it is implemented entirely in Java. If you only need > > to support a single platform you can use Jython+Swing+JNI+C using JNI > > to connect Java to the speed critical stuff written in C. Otherwise I > > would recommend looking at other toolkits such as PyGTK and wxPython. > > Yeah tell me about it...lightweight components are the wrong way to go.... > Awt would be a step faster, but that's still using Java of course > > -- > http://mail.python.org/mailman/listinfo/python-list > From max at alcyone.com Sat Mar 31 02:35:00 2001 From: max at alcyone.com (Erik Max Francis) Date: Fri, 30 Mar 2001 23:35:00 -0800 Subject: very basic, how do you find square roots? References: <9a408a$1mpp$1@raewyn.paradise.net.nz> Message-ID: <3AC588A4.AF93BFAC@alcyone.com> johnston112 wrote: > Yes, that is my question :) > I am trying to make a program that dose the quadratic equation. Python 2.0 (#5, Nov 10 2000, 21:47:15) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import math >>> print math.sqrt.__doc__ sqrt(x) Return the square root of x. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Money talks / But love is for real / And you know that \__/ Neneh Cherry Physics reference / http://www.alcyone.com/max/reference/physics/ A physics reference. From aleaxit at yahoo.com Thu Mar 1 10:37:29 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 1 Mar 2001 16:37:29 +0100 Subject: Combinations of n Lists References: <89bn6.1121$DY.186465@news1.rdc1.az.home.com> Message-ID: <97lqcm030au@news2.newsguy.com> "Tim Hochberg" wrote in message news:89bn6.1121$DY.186465 at news1.rdc1.az.home.com... [snip] > > def combinations(list1,list2): > > return [ (i,j) for i in list1 for j in list2 ] > > > > print combinations( [1,2,3], ['a','b','c'] ) > > > > [(1, 'a'), (1, 'b'), (1, 'c'), (2, 'a'), (2, 'b'), (2, 'c'), (3, 'a'), (3, [snip] > zip([1,2,3], [4,5,6], [7,8,9], .... ) Nope -- this only gives [(1,4,7),(2,5,8),(3,6,9)], *not* all of the other 24 requested combinations (1,4,8), (1,4,9), ..., (3,6,8). Alex From scarblac at pino.selwerd.nl Mon Mar 19 12:27:27 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 19 Mar 2001 17:27:27 GMT Subject: Why "from __future__" stinks; a counter-offer References: Message-ID: John W. Baxter wrote in comp.lang.python: > For the future, the time to complain about PEP contents is when the PEP > is posted, not after it has been posted, discussed, implemented, and the > result distributed. And the place to complain is the Python-DEV list, which is not public, although everyone can post to it and everyone can read it using some archives... And counterproposals need their own PEP unless it's a minor change in the proposal. (both only 'as far as I know') -- Remco Gerlich From dg at pearl.tao.co.uk Fri Mar 9 15:28:42 2001 From: dg at pearl.tao.co.uk (David Given) Date: Fri, 9 Mar 2001 20:28:42 +0000 Subject: PIL & XPM saving? Message-ID: I notice that the PIL XPM plugin doesn't save XPMs. I really need this; is there anywhere where I get code to do this? (I'm using Python 1.5, Linux, Debian testing.) -- +- David Given ---------------McQ-+ "I told you to make one longer than | Work: dg at tao-group.com | another, and instead you have made one | Play: dgiven at iname.com | shorter than the other -- the opposite." +- http://wired.st-and.ac.uk/~dg -+ --- Sir Boyle Roche From sholden at holdenweb.com Thu Mar 8 05:39:37 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 8 Mar 2001 05:39:37 -0500 Subject: "!=" is bad form. Re: sorry....never mind References: <3AA6E308.5B63ECC6@cosc.canterbury.ac.nz> <3AA72253.FB021815@Lugoj.Com> <984047188.296438@newsmaster-04.atnet.at> Message-ID: <8nJp6.33937$ML1.1663316@e420r-atl2.usenetserver.com> "Werner Schiendl" wrote in message news:984047188.296438 at newsmaster-04.atnet.at... > > I hate '<>' because it's too much like VB (and so many other BASIC > > variants). > > > > I think there are at least the same number of programmers that hate the > other way because it looks to much like C. > Maybe we should invent some completely new operator, ending up with line > noise one day... :-] > > regards > werner > > How about >< ? Actually, I have no problem with !=. regards Steve From scarblac at pino.selwerd.nl Mon Mar 19 10:15:15 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 19 Mar 2001 15:15:15 GMT Subject: newbie - infinite loop References: <985012513.18971.0.nnrp-12.c1c3e154@news.demon.co.uk> Message-ID: Paul Brian wrote in comp.lang.python: > I have solved the opriginal problem but am left with a serious question. > > Before I discovered the keywords in and not in, I tried to count unique > instances of names in a file. > I devcided to create a (neaarly) empty list, compare each name in the file > with that list. If the name was not in, append to list, otherwise leave it > alone. Your code belows does the opposite: if it *is* already in the list, append it once more. And since you change the list you're currently looping over (which is a mortal sin, etc) you get an infinite loop. > After the following was run (and crashed) a couple of times I started using > my brain and realised there must be some "in" operator. However the problem > still stands - a for condition seems completely mutable. It's a list. It's mutable. It's not a "for condition", for just tries to get new elements from the list until that gives an error, then the loop is finished. If you append to the list during the loop, the new elements are also visited. If you add or delete things in the middle of the list, anything might happen. Do not taunt happy fun for loops. Do not change lists you are looping over. > Surely this should not happen. Surely the line 3 condition "for every > element in this list", should not constantly expand but should be set solid > till the next pass? > > What have I done wrong - is it the mutable list v the immutable tuple > problem (but it should work..surely?) Or is this just the way things are - > "live with it and do not try anything like this again?" > > thanks in advance > ============== > uniqueList = ['q'] # create an nearl empyty list (seems to > ignore line 3 if truly empty) > line = 'q' # fake the retrieval of line from file > > for listElement in uniqueList: #3 > if listElement == line: #4 > uniqueList.append(line) #5 at this point it seems to > think that there is now another list > #element to compare > and so loops for ever...help! > > print len(uniqueList) This idea would work something like this (although the better method is to use a dictionary, see below): uniqueList = [] # No words seen yet line = 'q' # Or get some line some other way for listElement in uniqueList: if line == listElement: break # Do nothing, we have this word already, stop the for loop else: # The else clause runs after the for loop finishes, if no break was hit uniqueList.append(line) But this still has to go through the whole list for every new word, which is very slow. Use a dictionary, set dict["word"] to 1 for every word, it doesn't matter if the word was already seen once since it's just overwritten, at the end you have all the unique words in dict.keys(): uniqueDict = {} # Do the following for every line, of course line = 'q' uniqueDict[line] = 1 # This prints all the unique lines we've seen print uniqueDict.keys() -- Remco Gerlich From costas at meezon.com Fri Mar 2 20:57:20 2001 From: costas at meezon.com (Costas Menico) Date: Sat, 03 Mar 2001 01:57:20 GMT Subject: Crashed PythonWin. How can I fix it? Message-ID: <3aa04cf5.34464140@News.CIS.DFN.DE> I crashed PythonWin and cant get it backup and running. I was using Tkinter when this happened. Does anyone wknow what this Traceback window means when I start PythinWin? I tried deleting.pyc files but no luck... And there is no file called glob2.py that I could find. . File "c:\python20\pythonwin\pywin\framework\intpyapp.py", line 163, in InitInstance import interact File "c:\python20\pythonwin\pywin\framework\interact.py", line 26, in ? import winout File "c:\python20\pythonwin\pywin\framework\winout.py", line 46, in ? from pywin.scintilla.view import is_platform_unicode File "c:\python20\pythonwin\pywin\scintilla\view.py", line 650, in ? LoadConfiguration() File "c:\python20\pythonwin\pywin\scintilla\view.py", line 634, in LoadConfiguration from config import ConfigManager File "c:\python20\pythonwin\pywin\scintilla\config.py", line 20, in ? import glob File "glob.py", line 11, in ? glob2.what2() File "glob2.py", line 3, in what2 print x exceptions.NameError: There is no variable named 'x' From chris.gonnerman at usa.net Sat Mar 10 10:53:26 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sat, 10 Mar 2001 09:53:26 -0600 Subject: Sucking in a text file References: <53hkats5d5noic51fskjv0dm72f1rgc29g@4ax.com> Message-ID: <003b01c0a97a$48271900$a100000a@local> ----- Original Message ----- From: "Simon Faulkner" Subject: Sucking in a text file > I have a .py cgi script that writes a page to the web and it works! > > To allow the users to customise the out put I would like the script to > suck in the first part of the page from a text file and then to spit > this out to the web server. > > Is this easy or do I need to open the file and read each byte in turn? hdrf = open("my_header.html", "r") # the "r" is not required actually header = hdrf.read() hdrf.close() sys.stdout.write(header) Hope this helps. From barry at digicool.com Sat Mar 3 03:39:57 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Sat, 3 Mar 2001 03:39:57 -0500 Subject: ANNOUNCE Mailman 2.0.2 (important privacy patch) Message-ID: <15008.44509.146939.425219@anthem.wooz.org> I'm please to announce the 2.0.2 release of Mailman, the GNU Mailing List Manager. Mailman is released under the GNU General Public License (GPL). Version 2.0.2 is an important bug fix release that also fixes a potential privacy hole, which could allow a list administrator to get access to user passwords. Even with those passwords, I believe there's little additional harm that a list admin could do, but still they probably shouldn't have access to those passwords. There are a few other important fixes in this release, so I recommend that all sites running Mailman 2.0 or 2.0.1 should upgrade. Mailman 2.0.2 is being released as both a gzip'd source tarball and as a patchfile. Mailman is software to help manage electronic mail discussion lists, much like Majordomo or Smartmail. Mailman gives each mailing list a unique web page and allows users to subscribe, unsubscribe, and change their account options over the web. Even the list manager can administer his or her list entirely via the web. Mailman has most of the features that people want in a mailing list management system, including built-in archiving, mail-to-news gateways, spam filters, bounce detection, digest delivery, and so on. Mailman is compatible with most web servers, web browsers, and mail servers. It should run on any Unix-like operating system. Mailman 2.0.2 requires Python 1.5.2 or newer. To install Mailman from source, you will need a C compiler. For more information on Mailman, including links to file downloads, please see the following mirrors: http://www.gnu.org/software/mailman http://mailman.sourceforge.net http://www.list.org [Only the SourceForge site is up-to-date at the moment, the others will be updated soon.] There are email lists (managed by Mailman, of course!) for both Mailman users and developers. See the web sites above for details. Enjoy, -Barry [From the NEWS file] 2.0.2 (03-Mar-2001) Security fix: - A fix for a potential privacy exploit where a clever list administrator could gain access to user passwords. This doesn't allow them to do much more harm to the user then they normally could, but they still shouldn't have access to the passwords. Bug fixes: - In the admindb page, don't complain when approving a subscription of someone who's already on the list (SF bug #222409 - Thomas Wouters). Also, quote for HTML the Subject: text printed for held messages, otherwise messages with e.g. "Subject: " could royally screw page formatting. - In Netscape.py bounce processor, don't bomb out on ill-formed messages (no semi-colon separating parameters), otherwise mail delivery could grind to a halt. Bug reported by Kambiz Aghaiepour. - Docstring fix bin/newlist to remove mention of "immediate" argument (Thomas Wouters). - Fix for bin/update when PREFIX != VAR_PREFIX (SF bug #229794 -- Thomas Wouters). From garry at sage.att.com Fri Mar 16 16:28:40 2001 From: garry at sage.att.com (Garry Hodgson) Date: Fri, 16 Mar 2001 21:28:40 GMT Subject: I come to praise .join, not to bury it... References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> <3AAF7E47.294617E1@sage.att.com> <98qeco02hn7@news1.newsguy.com> <98srjf$fov$1@tyfon.itea.ntnu.no> <98t5t40lle@news1.newsguy.com> Message-ID: <3AB28588.35EC06FD@sage.att.com> "John W. Baxter" wrote: > I came to Python (and dragged my company along) by way of a flooded > Tower Books store [Bellevue, WA]. They had a [slightly] water damaged > "Programming Python" on the shelf at something like 60% off as part of > their flood sale. [The bottoms of most of the pages are still stained > and oddly curled.] you might want to arrange for another flood. the 2nd edition is out, effectively a whole new book, and it looks to be *really* good. -- Garry Hodgson Once in a while Senior Hacker you can get shown the light Software Innovation Services in the strangest of places AT&T Labs if you look at it right From bob at staff.cs.usyd.edu.au Mon Mar 26 06:19:51 2001 From: bob at staff.cs.usyd.edu.au (Bob Kummerfeld) Date: 26 Mar 2001 21:19:51 +1000 Subject: python 2.0 rpm for redhat 7.0? Message-ID: <99n8kn$kn@staff.cs.usyd.edu.au> Can anyone point me to an rpm for Python 2.0 that will install on a stock standard redhat 7.0 system? My daughter asked me to help install python 2.0 on her new system. I told her it was trivial..... some hours later I'm advising her to reformat the disk and install Mandrake 7.2! The BeOpen rpm for py2.0 complains of missing libraries. I decided to make py2.0 from source (normally a trivial exercise). It complains that gcc appears to be broken. I install the many update rpms for gcc from redhat. It's STILL broken.... help :-( Bob Kummerfeld -- From ejr at cs.berkeley.edu Fri Mar 16 22:43:57 2001 From: ejr at cs.berkeley.edu (Edward Jason Riedy) Date: 17 Mar 2001 03:43:57 GMT Subject: More accurate summations [was Re: This math scares me] References: Message-ID: <98umht$7e0$1@agate.berkeley.edu> And writes: - - Try summing all financial operations of one day together, or - better, all operations involving percentages and then adding them - together : cumulative errors. More concretely, look at the Vancouver Stock Exchange index's problems of the late 70s-early 80s. They had chosen to truncate floating point values rather than round them, causing a downward drift of around 20 points a month[1]. You could say that's because of poor handling of floating-point arithmetic, and you'd be right. However, just about every inaccuracy in floating-point financial calculations can be attributed to poor handling of fp arithmetic. That doesn't mean floating point is a poor choice for all financial programs. Indeed, the HP financial calculators _all_ use floating point, although decimal. Those calculators were designed twenty-odd years ago, and they're still selling for almost as much as a Pilot. If you want a _very_ accurate sum for all the operations in one day, use the following algorithm. It is often attributed to Kahan, but, if I recall his comments correctly, he's not entirely sure of the origins of the embodied idea. Other names around this style of algorithm are Moller (with a backwards slash through the o), Dekker, Pichat, Knuth, Bohlender, and Linnainmaa in no particular order. That's a surprising number of people for just adding numbers. ;) class DistilledSum: "Keep an accurate running sum." def __init__ (self): self.s = 0.0 self.c = 0.0 def add (self, x): "Incorporate x into the running sum." y = x - self.c t = self.s + y self.c = (t - self.s) - y self.s = t def value (self): "Return the sum itself." return self.s def asTuple (self): "Return both the sum and the error term." return (self.s, self.c) The accumulated error in s from floating-point calculations is at most one unit in the last place of each summand x, and the value of c gives you a tighter bound on that error. With not entirely horrible amounts of extra work, you can have however much precision you need[2]. Unless your numbers are horribly scaled (perhaps the debt and GNPs of the entire globe along with a person's), this in double plus rounding the stored answer to float works wonders for financial accumulations. You can find an explanation of how this works either in [2] or [3]. Essentially, the self.c term serves as a small correction. The trick with (t - self.s) - y first zeros the high-order bits that are shared between the old and new sum, then zeros the bits shared with the pre-corrected x, giving a new correction. Jason, unsure of how to create other languages' characters from this particular keyboard... [1] Q20 at http://catless.ncl.ac.uk/Risks/3.41.html#subj4.1 [2] http://citeseer.nj.nec.com/priest92propertie.html [3] http://www.validlab.com/goldberg/paper.ps -- From Eugene.Leitl at lrz.uni-muenchen.de Fri Mar 23 08:33:22 2001 From: Eugene.Leitl at lrz.uni-muenchen.de (Eugene Leitl) Date: Fri, 23 Mar 2001 14:33:22 +0100 (MET) Subject: Python MPI Message-ID: I've just came back from a 3 day MPI course, and promptly noticed that I can use Python with MPI (yay!): http://www.fysik.dtu.dk/~schiotz/comp/PythonAndSwig/pythonMPI.html Any MPI Python users here? I'll be interested in hearing your experiences. From jafo at tummy.com Thu Mar 1 22:30:06 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Thu, 1 Mar 2001 20:30:06 -0700 Subject: python irc channel? In-Reply-To: <97n15e$9g3$1@nntp1.ba.best.com>; from mjbjr@best.com on Fri, Mar 02, 2001 at 02:39:42AM +0000 References: <97n15e$9g3$1@nntp1.ba.best.com> Message-ID: <20010301203006.A1619@tummy.com> On Fri, Mar 02, 2001 at 02:39:42AM +0000, Martin Brown wrote: >So, is there a preferred irc channel where python people hangout? I believe that the EFNet #python is gatewayed to the IRC server at irc.openprojects.net #python. I haven't been on EFNet in quite a while. It was more a social channel that occasionally broke out into code, but usually was talking about computers and cars and motorcycles. ;-) Good group of people. Sean -- "Action... Romance... Welding... That movie has everything." -- Evelyn Mitchell speaking about _Subway_, 1998 Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From mcherm_python at yahoo.com Sat Mar 17 20:14:11 2001 From: mcherm_python at yahoo.com (Michael Chermside) Date: Sat, 17 Mar 2001 19:14:11 -0600 Subject: Who's minister of propaganda this week? References: <98nu1m$12e@dispatch.concentric.net> <660ACCA1E4816F7E.C359CDF4168EF3FB.3B6B05538D619770@lp.airnews.net> <3AAFA13D.76E32C3F@divalsim.it> <98oa4o01i4v@news2.newsguy.com> <3AB0176D.8070903@yahoo.com> <3AB0C70A.C6A55DF5@ActiveState.com> Message-ID: <3AB40BE3.3080001@yahoo.com> Paul Prescod wrote: > Michael Chermside wrote: > >> ... >> I'm really not sure I see it this way. If the method foo(x) is known to >> take a FancyDateObject there are three kinds of errors we could make. >> One is that foo() is written badly so it doesn't do what it's supposed >> to. The unit tests of foo() need to guard against this. >> Another possible error is that FancyDateObject isn't written properly. >> The unit tests of FancyDateObject need to guard against this. And >> the third type of error is that that somewhere where we CALL foo(), >> we might pass it a DateObject instead... or even a String... which >> will cause it to perform wrong. To guard against this in a >> dynamically typed language, we have to write unit tests for *every >> single place* that we call foo(). > > > Your analysis is incomplete in two ways: > > 1. I don't think it makes sense to speak of writing a unit test for "one > thing calling another". You test the first thing, you test the second > thing and if the second thing depends upon the first then you've > implicitly tested the connection between them. If foo() is supposed to be passed a FancyDateObject, then the unit tests for foo() will only pass it FancyDateObject's... it's basically a precondition on foo(). If bar() calls foo(), then SOMEWHERE we need to ensure that the value being passed to foo() is, indeed, a FancyDateObject. (Or, in a dynamically typed language, an object which behaves as a FancyDateObject is expected to behave.) Failure to meet this condition might result in subtle behavior (eg, foo() counts on the special rounding behavior in FancyDateObject, and when passed a plain DateObject instead, certain invariants in foo() get broken). It's possible to write unit tests for bar() which test this, but that requires the author of unit tests for bar() to know something about foo(). And bar2() and bar3() and bar4()... all of which also call foo(). In this senario it's particularly convenient to express the precondition "argument to foo must have special rounding behavior" by declaring foo(FancyDateObject: x). > 2. In object oriented programming languages, we can't just test one > function against one input object class and be confident that the code > is correct. There are an infinite number of potential subclasses of > FancyDateObject. Therefore we should NOT depend on testing every single > one of them with foo. We just need to make sure that foo is correct, > that each FancyDateObject is correct and that the communication protocol > between them is well-understood and tested by both. Here I agree. Test FancyDateObject in its unit tests. When writing foo(), test that it works when passed a FancyDateObject. When you write FancyDateObjectWithBellsOnIt, test that it fulfills the contract of FancyDateObject. Now you know that foo(x) works when x is a FancyDateObjectWithBellsOnIt. But you could STILL mistakenly call foo(y) where y is NOT a DateObject... that's my case 3 above. > 3. Statically typed languages are absolutely not immune to type errors > for a variety of reasons: > > * Null pointer exceptions are type errors. You've passed the null > object when the code expected some other object. Excellent point! > * Almost every statically typed language also has a set of features for > working around the type system (dynamic casts). This I don't feel bad about. If a language protects you against a class of errors EXCEPT when the programmer specially asks to turn OFF the protection, then the programmer cannot complain of the language that it fails to protect you when you turn it off. If you want protection, don't turn it off (ie, don't dynamic cast except in cases where you don't MIND finding out at runtime). > * Even when the compiler thinks the "type" of your object is correct, > there are a variety of type-related errors you can make such as passing > a negative number where only positive ones are allowed, passing an > gopher: URL where only an http: URL is allowed, passing an absolute > pathname where only a relative pathname is allowed and so forth. If you > try to catch all of these in the static type checking system you wlil > spend more of your life doing conversions than actually coding. *PLUS* > you will need to do the runtime conversion-compatibility checks > YOURSELF! True. Your point here is unassailable... static type checking will only catch a subset of all possible type errors. Excellent examples! > 4. Yes, if you unit test every unit in your program, and do good > coverage testing you WILL catch ever occurrence of some code calling > foo. That's what good testing is about. And you need it, not to catch > the basic type errors but to catch the subtle semantic errors. Catching > the basic type errors comes for free. Yes, I can see that. But sometimes it's awefully nice to have the compiler do it for you automatically. It certainly doesn't hurt. (But see Alex's response, where he argues that perhaps it DOES hurt, for other reasons.) -- Michael Chermside _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From erno-news at erno.iki.fi Sat Mar 3 17:11:55 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 04 Mar 2001 00:11:55 +0200 Subject: Bug fix releases References: <200103031821.NAA24060@panix3.panix.com> Message-ID: In article , Guido van Rossum writes: | But I understand that you're saying that the community has grown so | conservative that it can't stand new features even if they *are* fully | backwards compatible. | I wonder, does that extend to new library modules? Is there also | resistance against the growth there? I don't think so -- if anything, | people are clamoring for more stuff to become standard (while at the | same time I feel some pressure to cut dead wood, like the old SGI | multimedia modules). it is good if the library is big and plentiful and i don't even mind if it's bloated. the core language on the other hand should be simple, and it should not have spurious features. -- erno From loewis at informatik.hu-berlin.de Sat Mar 3 04:47:48 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 03 Mar 2001 10:47:48 +0100 Subject: how to get the last interactive command enetered References: Message-ID: "Tom" writes: > For example, say that I set a trace function. I find the frame's code > object, look at co_filename and find that it is . But I want to know > what the actual command was. Is there anyway to do this (in C or Python)? No. Once the code is executed, the source code is dropped. All you can get at is the binary code. Of course, "in C", you can rewrite the Python interpreter to behave differently. It takes more than an extension module to do so, though. Regards, Martin From n8gray at caltech.edu.is.my.e-mail.address Thu Mar 22 22:30:49 2001 From: n8gray at caltech.edu.is.my.e-mail.address (Nathaniel Gray) Date: Thu, 22 Mar 2001 19:30:49 -0800 Subject: Good Editor? References: <3ab9a32b$1_1@news2.one.net> Message-ID: <99egd0$mse@gap.cco.caltech.edu> fjs wrote: > Can someone recomend a good editor to write python in? Im just getting > started learning python and dont know which ones support python. > > thanks On *NIX check out NEdit (http://www.nedit.org). It's got syntax highlighting support for a ton of languages, a simple and powerful scripting language, rock-solid stability, and it's light on resources. Plus, you don't have to time-warp backwards 30 years to understand the keyboard accellerators (unless you already think C-x C-f for "open file" is intuitive. I'd bash the vi command too if I'd ever bothered to learn what it was...). -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From roy at panix.com Sat Mar 17 11:39:54 2001 From: roy at panix.com (Roy Smith) Date: Sat, 17 Mar 2001 11:39:54 -0500 Subject: Thoughts about extensions to the Python language References: <3AB2FA0F.E61862B0@seebelow.org> <3AB38DE8.788C86D6@earthlink.net> Message-ID: Mitch Chapman wrote: > I think he meant "write Python code with the mindset of a > Fortran programmer." This would entail lots of global variables, > humongous function bodies and modules, etc. Gee, sounds like the last perl program I worked on :-) From bbollenbach at homenospam.com Thu Mar 22 18:35:01 2001 From: bbollenbach at homenospam.com (Brad Bollenbach) Date: Thu, 22 Mar 2001 23:35:01 GMT Subject: Good Editor? References: <3ab9a32b$1_1@news2.one.net> <5Xju6.601501$U46.18300887@news1.sttls1.wa.home.com> Message-ID: [snip] > Most of my Python programs are so small that IDLE works for me. My favorite > editors are: > > Windows: EditPlus (www.editplus.com) [snip] I'll definitely second EditPlus when working on Win32. It's syntax highlighting isn't nearly as nice as vim's (but this may have been due to the fact that the syntax highlighting config files just weren't well written enough, I haven't take the time to verify). One thing to be weary of though: watch out for autocomplete config files that use tabs instead of spaces in the config syntax. You'll especially love Editplus if you happen to also be needing a text editor that's good for writing HTML. I also think PythonWin makes a nice editor. On Unix, I'd be using vim. From sverker.is at home.se Thu Mar 1 07:04:30 2001 From: sverker.is at home.se (Sverker Nilsson) Date: Thu, 01 Mar 2001 13:04:30 +0100 Subject: Allow anything in identifiers? References: <3A9DC13A.1647EE51@home.se> Message-ID: <3A9E3ACE.60F8C639@home.se> David Porter wrote: > > * Sverker Nilsson : > > This would be a new kind of identifiers, I suppose one > > can make them by writing for example id like in: > > > > id 'a>b' = a > b > > id 'x.b' = x.b > > alu.id'+' = lambda x, y... > > > > I think it could make programs easier to read by allowing > > more evident identifiers in many cases. The extended identifier > > syntax should not break anything, and it seems it might be easy to > > implement... > > It would break any code using the name 'id', likely a lot of code. How? Not id , should likely be on the same line, may allow space in between. That gives a syntax error currently, except when id is some of a few special ones like r, u, etc. Adding id (or i?) to that set of string prefixes shouldn't break anything, if I understand it correctly and I'm pretty sure... to prove your statement you just need to come up with an example that would be broken so I'll not try to refute it (more) right now. Well thanks for the comment and giving me the opportunity to come up with some examples of where this could be useful: * Equivalents to the operator module would need (less) new names invented. eg. operator.id'+', operator.id'<' etc instead of operator.__add__, operator.__lt__ (though I am just guessing about the latter one and I am sure it's wrong - that's a point of the argument :-) * Same holds for the corresponding class methods __add__ etc. * Command interpreters could dispatch to functions that had obvious names corresponding to the actual commands. * Variables corresponding to files with fixed name, could have the obvious name. * Temporary constants could be named after their initializing expression, i.e. if a variable is introduced to avoid recalculation of a[i] in an inner loop it could be clearer if it was called precisely that: id'a[i]'. (Note that the extended identifier shouldn't incur any extra overhead in the interpreter.) * Variables could be named in any language, with national specific characters in Unicode for example. One drawback I can think of myself right now is a kind of uglyness by using quotes but at least they make the construct stand out so it should not be so confusing to ordinary id's. I guess there are alternative syntaxes but I couldn't think of any better myself yet. Sverker From ben.hutchings at roundpoint.com Tue Mar 6 17:34:27 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 06 Mar 2001 14:34:27 -0800 Subject: package/namespace confusion References: <3AA3EDD2.60393490@troikanetworks.com> Message-ID: Bruce Edge writes: > Hi, > I'm sure this is a real rookie issue here, but I can't seem to define a > global then access it in a package. > I'm using __init__.py to define glob_var, then load util.py. > > I would have expected util/ufunc() to have access to glob_var. > > test/__init__.py: > > glob_var=0 <- is this where I should stick package globals? Yes. > __all__=["util"] > > > test/util.py: > > def ufunc(): > global glob_var The global namespace for this function is the namespace of the module (test.util) not that of the package (test). If you want package globals to be module globals too, then use 'from test import *' at the top of your modules. Alternatively you can 'import test' and refer to 'test.glob_var'. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From syver at NOSPAMcyberwatcher.com Wed Mar 7 06:40:58 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Wed, 7 Mar 2001 12:40:58 +0100 Subject: How to Xml escaping of characters above 7 bit ascii. Message-ID: Hi, Is there a method in Python that takes a unicode string and escapes it according to the xml file format? Or will I have to do it myself? From howardbgolden at earthlink.net Fri Mar 16 17:08:14 2001 From: howardbgolden at earthlink.net (Howard B. Golden) Date: Fri, 16 Mar 2001 22:08:14 GMT Subject: Using INRIA's Thot toolkit from Python? Message-ID: Has anyone used INRIA's Thot toolkit from Python? (Thot is the basis for the W3C Amaya editor.) Is a Python wrapper available? I would appreciate any information or suggestions. Thanks in advance. From paulp at ActiveState.com Sun Mar 11 14:29:42 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 11 Mar 2001 11:29:42 -0800 Subject: any interest in type-scoped static constants? References: <3AAB9578.4C8754E4@fxtech.com> Message-ID: <3AABD226.25D30254@ActiveState.com> Paul Miller wrote: > > ... > > If I create an extension type for Point, I can't do this: > > p = Point.ZERO > > But I'd like to. Yes you can! [out of order] > .... > My solution would be to add a dictionary to the extension type for > constants, that the extension code can initialize, and then add a > scoping test for Type.ATTR to add a check in the Type's attribute > dictionary. Right, you can do this in any extension type. > I'm seriously considering working on a patch to add type-specific > constants to provide OO access to extension type constants, rather than > putting all constants in the module scope. I wonder if anyone has > started this, and if this is considered a good idea. Do I need to write > a PEP? Why do you need a PEP when you can implement it for any extension you need. Just put a dictionary in the type and using type.getattr to look stuff up in your dictionary. -- Python: Programming the way Guido indented it. - (originated with Skip Montanaro?) From stephen_purcell at yahoo.com Fri Mar 16 06:41:00 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Fri, 16 Mar 2001 12:41:00 +0100 Subject: os.spawnv problem In-Reply-To: <3AB1F745.865F01A@computer.org>; from reinhold.koch@computer.org on Fri, Mar 16, 2001 at 12:21:41PM +0100 References: <3AB1F745.865F01A@computer.org> Message-ID: <20010316124100.A2303@freedom.puma-ag.com> Reinhold Koch wrote: > Hi python experts! > > As a newcomer I just hit a wall with the little one-liner: > > os.spawnv('P_WAIT',r'C:\rei\bin\PFE32.EXE', ('xx','yy')) 'P_WAIT' should not be quoted. Try the following: os.spawnv(os.P_WAIT,r'C:\rei\bin\PFE32.EXE', ('xx','yy')) -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From lloyd at venix.com Thu Mar 1 09:11:27 2001 From: lloyd at venix.com (Lloyd Kvam) Date: Thu, 01 Mar 2001 09:11:27 -0500 Subject: Collection interfaces References: <3a90fa97.0@news1.mweb.co.za> <3A933830.7F98D118@ix.netcom.com> <220220010813598042%cmh@bDistributed.com> <8Gem6.473353$U46.14105062@news1.sttls1.wa.home.com> <3A9A86B1.9A8C69A2@ix.netcom.com> <97fjla128ir@news2.newsguy.com> <97h5s40vhc@news2.newsguy.com> <97ibmc0k47@news1.newsguy.com> Message-ID: <3A9E588F.406A7C3E@venix.com> One of the beauties of Python is the ease with which you can combine "table lookup" style logic with "OOP inheritence" style logic within the same program. Fredrik Lundh wrote: > > > Before you knock it, TRY it > > the martelli battlebot vs. the "galileo of > programming" crackpot? > > now this could be really entertaining ;-) > > Cheers /F -- Lloyd Kvam Venix Corp. 1 Court Street, Suite 378 Lebanon, NH 03766-1358 voice: 603-443-6155 fax: 801-459-9582 From sholden at holdenweb.com Fri Mar 9 18:53:46 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 9 Mar 2001 18:53:46 -0500 Subject: gah! I hate the new string syntax References: <98amlj01sp6@news2.newsguy.com> <98asrq$645$1@panix6.panix.com> Message-ID: "Aahz Maruch" wrote in message news:98asrq$645$1 at panix6.panix.com... > In article <98amlj01sp6 at news2.newsguy.com>, > Alex Martelli wrote: > >"Steve Holden" wrote in message > >news:BcCp6.37817$1D5.1582482 at e420r-atl1.usenetserver.com... > > [snip] > >> > | > What about one who is both English and Scots, yet never set foot on > >> > | > that island ;-)? > > [snip] > >> Either you were born in England, or you were born in Scotland, or you are > >> neither English nor a Scot. Part-either-or-both, maybe, but not fully > > > >Wrong! You're talking about people whose seafaring skills and > >traditions are (deservedly) legendary. It's perfectly acceptable > >for either an English or a Scot to be born aboard a ship...!!! > > Since when are *women* allowed aboard ships? Women were allowed aboard British ships in the eighteenth and nineteenth centuries, I believe. The phrase "shake a leg" (meaning to stop lazing about and start work) is held to have been used by ships' mates to get the seamen out of their bunks. A woman would show her leg to let the mate know she should not be rousted out to work. regard Steve From tim.one at home.com Thu Mar 1 14:30:25 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 1 Mar 2001 14:30:25 -0500 Subject: A counter-proposal to __future__ in PEP 236 In-Reply-To: <3A9E9B23.23FFCEDF@home.se> Message-ID: [Sverker Nilsson] > I think the directive directive is better too. When I read about > the future import I was worried over what the new semantics > of import would be, for example what would happen to the > identifier that would be imported: would it be visible, > probably not but that's a new semantics to understand & learn. No, I think PEP 236 is quite clear that, at runtime, future_statements *are* utterly vanilla import statements. They do import module __future__.py, and they do import the feature names (which are bound to detailed release info, which is important metadata for people who use this; the "directive" proposal loses that). From leo at iems.nwu.edu Thu Mar 8 14:27:18 2001 From: leo at iems.nwu.edu (Leonardo B Lopes) Date: Thu, 08 Mar 2001 13:27:18 -0600 Subject: pipe problems References: <3AA6D886.4DD8D3A4@iems.nwu.edu> <984045555.82149@newsmaster-04.atnet.at> Message-ID: <3AA7DD16.93C0730D@iems.nwu.edu> Werner Schiendl wrote: > > If there is no data to read, readline it will block for such to become > available. > I don't think that cout.flush() is of any use, btw. When I tried the program with 'cat', it only worked if I used cout.flush(). But maybe it doesn't work in general. My guess is that this call is the crux of the problem. > Maybe I'm wrong, but I think data can only be flushed out by the sender of a > pipe... > Further, what's if the program prints out something in between, or more than > 1 line? That is something I'll deal with at a later point, when I get the basic stuff working. I have the impression there is something about pipes that I don't understand correctly. Thanks, Leo. > > Maybe you can do the reading in a seperate thread. > Alternatively you can try to find out if there _is_ sth you can read. > > hth > werner > > Leonardo B Lopes wrote in message > news:3AA6D886.4DD8D3A4 at iems.nwu.edu... > > I use a program that doesn't have readline compiled in. So I figured, it > > would be easy to add a python wrapper around it. So I wrote the wrapper, > > using 'cat' as a test command. With 'cat' it works fine. But when I try > > using another program, such as 'python', the program just hangs at > > readline(). Anybody know how to accomplish this? Here is the code: > > > > #!/usr/local/bin/python > > > > import sys,os > > import cmd > > > > class Amplcmd(cmd.Cmd): > > > > def __init__(self): > > cmd.Cmd.__init__(self) > > self.cin,self.cout = os.popen2('/usr/local/bin/python') > > > > def default(self,line): > > self.cin.write(line+'\n') > > self.cin.flush() > > self.cout.flush() > > print self.cout.readline(), > > > > def do_EOF(self,line): > > sys.exit() > > > > mycmd = Amplcmd() > > mycmd.cmdloop() > > > > > > > > -- > > ======================================================================= > > Leonardo B. Lopes leo at iems.nwu.edu > > Ph.D. Student (847)491-8470 > > IEMS - Northwestern University http://www.iems.nwu.edu/~leo -- ======================================================================= Leonardo B. Lopes leo at iems.nwu.edu Ph.D. Student (847)491-8470 IEMS - Northwestern University http://www.iems.nwu.edu/~leo From gzeljko at sezampro.yu Fri Mar 16 08:19:55 2001 From: gzeljko at sezampro.yu (gzeljko) Date: Fri, 16 Mar 2001 14:19:55 +0100 Subject: How do I get Win32 to locate DLLs elsewhere (not really a Python thing)? References: <3AB1F697.485A776D@yahoo.fr> Message-ID: <98t3sn$8t9$1@neptun.beotel.net> Francois Forest wrote in message news:3AB1F697.485A776D at yahoo.fr... > I got the same kind of problem on WinNT and Tcl80.dll, > I did the same tinkering you did and saw no improvement either. > Finally, I cleaned up the registry of all useless path (a poor install > program had set some C:\RECYCLER\123456xxx\... in many paths). > Do not forget to reboot (actually I logged off). > I suspect one PATH variable to have reached a maximum length. > Anyway, the PATH variables on NT are totally unclear to me > Your have system provaided interface: ControlPanel/System/Environment (No need for reboot or 'relog') search algoritam for dll's: current dir, exe's dir, path dir's Note: User environment is just appendix to system environment (except in overriding case) and user path is just appendix to system path. ly-y'rs-gzeljko From frohne at gci.net Thu Mar 1 19:55:37 2001 From: frohne at gci.net (Ivan Frohne) Date: Thu, 1 Mar 2001 15:55:37 -0900 Subject: Hypergeometric distribution ? References: Message-ID: ----- Original Message ----- From: "Thomas Sicheritz-Ponten" > Does anybody have a python function/class for calculating the > hypergeometric distribution ? The reference here is to the discrete hypergeometric probability distribution, not the mathematical special function. Calculating hypergeometric distribution probabilities requires some utility functions -- factorial(n) and log-factorial(n), n a non-negative integer. Some care needs to be taken to avoid impossible combinations of parameters, and there are symmetries which can be exploited. Then, for large parameters, you need to approximate using the normal, binomial or Poisson distributions. Your particular situation may allow cutting some corners here. You will probably end up translating Fortran or C code, and you will end up with a package, not just a function. --Ivan Frohne From grante at visi.com Wed Mar 7 14:02:58 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 07 Mar 2001 19:02:58 GMT Subject: Can anyone recomend a good intoduction to C... References: <983896344.701456@newsmaster-04.atnet.at> <983911749.217622@newsmaster-04.atnet.at> <983916572.286918@newsmaster-04.atnet.at> <9852b8015jm@news1.newsguy.com> <983967284.246700@newsmaster-04.atnet.at> <983989153.204220@newsmaster-04.atnet.at> Message-ID: In article <983989153.204220 at newsmaster-04.atnet.at>, Werner Schiendl wrote: >> >What use would it be to check the language? >> >> The point is that the more complex the language, the more >> difficult it is to inspect the application. You can look at a >> few lines of C and have a pretty good chance at guessing what >> they do. In C++ it's much harder to look at snippet of code >> and figure out what it's going to do. >> > >At least if the design is bad. > >Usually an object oriented program should be easier to read. >Just because the syntax does more closely resemble the way >humans think. It _should_ be easier to read. But in my experience it isn't. The problem is that C++ is a very complex language. It's difficult to determine by inspection what a piece of code does because of all the overloading/templating/whatnot that C++ allows. There are too many times when a line of code doesn't do what it appears to do to a reader. Just the problem of deciding whether "foo" is a local, global, or instance variable can be difficult for a human inspector. Throw in some cpp tricks and it's hopeless. I know that C++ was supposed to eliminate the need for cpp, but it still gets used. >(But I saw enough examples that demonstrated just the >opposite...) In my experience, C++ is too complex a language to allow for practical, thorough inspection of source code. And since C++ still allows you to generate dangling pointers, memory leaks, indexes out of range and whatnot, you _need_ to inspect source code to detect many of those types of problems. C also allows you to generate those problems, but the language is simple enough that inspection is a practical exercise. OTOH, Python (or Modula-3 or Smalltalk or ....) won't _allow_ you to generate a pointer to nothing or index off the end of an array. Additionally, they're far simpler languages than C++, so other types of errors are easier to spot. -- Grant Edwards grante Yow! Either CONFESS now or at we go to "PEOPLE'S COURT"!! visi.com From dallen at wi.net Sat Mar 3 19:27:21 2001 From: dallen at wi.net (mark) Date: Sat, 3 Mar 2001 18:27:21 -0600 Subject: Beginer Message-ID: <3aa18bf8$0$65279$38c90ffe@news1.twtelecom.net> can anyone tell me where i can find a real beginer tutorial for python? The one that comes with the program is still to complicated.thanks> From aleaxit at yahoo.com Sun Mar 25 16:59:00 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 25 Mar 2001 23:59:00 +0200 Subject: Yet Another PEP: Query Protocol Interface or __query__ References: <99lnc6$ck4$1@tyfon.itea.ntnu.no> Message-ID: <99lpkt0235c@news1.newsguy.com> "Magnus Lie Hetland" wrote in message news:99lnc6$ck4$1 at tyfon.itea.ntnu.no... [snip] > > To enable the first case listed in the requirements, > > the adapt function first checks to see if the objects > > type or the objects class are identical to the protocol. > > If so, then the adapt function returns the object directly > > without further ado. > > Hm. So in some cases the protocol object is merely an example > (prototype) of an object satisfying the protocol, and in other I suspect a mis-reading here. What I read is 'type or class identical to the protocol', i.e. the protocol can be a type object or class object; NOT 'identical to *that of* the protocol'. Maybe the wording needs clarification (make more explicit). > How about __adjust__? Sounds more transitive than __adapt__ to > me... Or __accept__. > __conform__ - method in an object which can conform to > a protocol > __adapt__ - method in a protocol used to adapt an > object to it Agree, probably best. Alex From kevin_cazabon at hotmail.nospamplease!.com Sat Mar 17 13:49:19 2001 From: kevin_cazabon at hotmail.nospamplease!.com (Kevin Cazabon) Date: Sat, 17 Mar 2001 11:49:19 -0700 Subject: image handling References: Message-ID: Check out the Python Imaging Library... join the Image-SIG at Python.com. You can download source and binaries at: www.pythonware.com... they've recently renamed the library the "Pythonware Image Library", still PIL... don't like the commercialism of the new name though myself... They've done most of it, but a LOT of people have contributed (including myself). Kevin. "Michael Hall" wrote in message news:mailman.984795862.9586.python-list at python.org... | | G'day people: | | I'm brand new on this list and am looking for resources about image | processing in a web environment in Python. I'm wondering if there exists a | module that does things like the PHP image handling functions | (creating, copying, resizing, etc). | | I've had a look at the Python Functions Library but there doesn't appear | to be much in there. I've started to use Python a bit in a web environment | and like what I've seen so far, and from what I've heard I'm sure there | must be some pretty flash image handling capabilities hanging around | somewhere. | | Thanks | Mick | | *********************************************** | Michael Hall - mick at mulga.com.au - mulga.com.au | *********************************************** | | | From barry at digicool.com Mon Mar 12 17:42:41 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Mon, 12 Mar 2001 17:42:41 -0500 Subject: ANNOUNCE Mailman 2.0.3 Message-ID: <15021.20705.958300.336520@anthem.wooz.org> [I think I forgot to announce the Mailman 2.0.2 release on these mailing lists. Apologies. -Barry] I've just announced the 2.0.3 release of Mailman, the GNU Mailing List Manager. Mailman is released under the GNU General Public License (GPL). I highly recommend that all sites running earlier versions of Mailman upgrade to 2.0.3. This release includes the important privacy patch from Mailman 2.0.2. Sadly, Mailman 2.0.2 contained a small but nasty typo requiring this new version. Mailman 2.0.3 is being released as both a gzip'd source tarball and as a patchfile. Mailman is software to help manage electronic mail discussion lists, much like Majordomo or Smartmail. Mailman gives each mailing list a unique web page and allows users to subscribe, unsubscribe, and change their account options over the web. Even the list manager can administer his or her list entirely via the web. Mailman has most of the features that people want in a mailing list management system, including built-in archiving, mail-to-news gateways, spam filters, bounce detection, digest delivery, and so on. Mailman is compatible with most web servers, web browsers, and mail servers. It runs on GNU/Linux and should run on any other Unix-like operating system. Mailman 2.0.3 requires Python 1.5.2 or newer. To install Mailman from source, you will need a C compiler. For more information on Mailman, including links to file downloads, please see the Mailman WWW page: http://www.gnu.org/software/mailman And its mirrors at: http://mailman.sourceforge.net http://www.list.org [Only the SourceForge and list.org sites are up-to-date at the moment, I expect the gnu.org site to be updated shortly.] If you want to download just the 2.0.2 -> 2.0.3 patch, please see: http://sourceforge.net/project/showfiles.php?group_id=103 There are email lists (managed by Mailman, of course!) for both Mailman users and developers. See the web sites above for details. Enjoy, -Barry From max at alcyone.com Mon Mar 5 12:09:03 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 05 Mar 2001 09:09:03 -0800 Subject: the demise of 'from foo import * and its implications? References: <3kVBAfATrDo6EwEM@jessikat.fsnet.co.uk> Message-ID: <3AA3C82F.E2F6CA7F@alcyone.com> Steve Holden wrote: > I did begin to wonder whether it might be possible to specify a name > prefix, > along the lines of > > from modulewithaverylongname import * prefix sh_ > > to allow > > sh_i > > as a reference to the module's "i", but I'm not sure that the gain is > worth > the pain. Even if such a proposal were to be PEP-ified and accepted it > could > not be mandated because that would break humongous amounts of existing > code. > > Thoughts? I don't see how changing a . to an _ really helps anything, and all it does is make the language more complex, and add a new keyword which is _very_ likely to be used in existing code. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Even paranoids have real enemies. \__/ Delmore Schwartz Crank Dot Net / http://www.crank.net/ Cranks, crackpots, kooks, & loons on the Net. From aahz at panix.com Fri Mar 16 22:40:17 2001 From: aahz at panix.com (Aahz Maruch) Date: 16 Mar 2001 19:40:17 -0800 Subject: This math scares me References: <20010312170356.B3513@better.net> <98qnq0$qc2$1@panix3.panix.com> Message-ID: <98umb1$f2i$1@panix3.panix.com> In article <98qnq0$qc2$1 at panix3.panix.com>, Aahz Maruch wrote: >In article , >Grant Edwards wrote: >> >>One step further is base-60, which is still used for many >>things. Time and angular measurement for example is partially >>a base-60 system. I believe that one or more of the ancient >>Aztecs/Incans/Mayans used a base-60 number system. > >Paging Ivan Van Laningham..... Ivan isn't reading c.l.py these days, but he sent me an e-mail response that he said I could post: We get base 60 from the Babylonians, who got it from the Sumerians. Base 60 is *much* more useful for time/date/astronomical calculations than any other. One of the projects in my datebook is a base60 package, but if anyone else writes one I'll be happy to use it;-) Aztecs and Mayans used base 20, expanded from an earlier base 10 system, which appears to have grown from an earlier base 5. Counting in Mayan civilization was, um, weird. Check Lounsbury, Floyd G., ``Maya Numeration, Computation, and Calendrical Astronomy,'' in Dictionary of Scientific Biography, ed., Charles Coulston Gillespie, Vol. 15, Supplement 1 (1978), Scribners, New York, 1978. As a small example, instead of saying "twenty-three," Mayans would say "three towards forty." The Incans used base ten exclusively, but recorded the numbers in knot form (on _quipus_). Many other radices were popular in pre-Conquest America. Base 3, bases 4, 5, 6, 8, 10 and 20. Check out Closs, Michael P., ed., Native American Mathematics, University of Texas Press, Austin, 1986. Still in print, in trade paper edition. -ly y'rs, Ivan;-) ---------------------------------------------- Ivan Van Laningham Symantec http://www.pauahtun.org/ http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 Author: Teach Yourself Python in 24 Hours From tim.one at home.com Thu Mar 1 15:45:17 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 1 Mar 2001 15:45:17 -0500 Subject: A counter-proposal to __future__ in PEP 236 In-Reply-To: Message-ID: [Martin von Loewis] > To selectively activate nested scopes in Python 2.1, PEP 236 proposes > the "future" statement. That means that you have to write > > from __future__ import nested_scopes > > Even though this looks like an import statement, it is not: Not so: it is an import statement. Read the PEP <0.9 wink>. > instead, it changes the meaning of variable binding in the presence > of nested functions. Which (the compile-time meaning) is the more important part, but not the only part (at run-time it's an ordinary import statement). > I personally consider this a confusing notation, I don't. "__future__" screams "Deep Magic" because of the double double-underscores; it *is* a perfectly vanilla import statement at runtime; the word "future" helpfully suggests temporality; it works with all existing tools today without change (so it's not confusing even the stupidest of them <0.1 wink>); and the imported nested_scopes name gets bound to release data that the importing code can examine; e.g., from __future__ import nested_scopes assert nested_scopes[1] > sys.version_info, "don't need this anymore" > and propose a different syntax, which would read > > directive nested_scopes Which loses all of that. Incompatible language changes are a serious special case, and I don't want to see them swallowed up by some perfectly general mechanism that makes them impossible to distinguish visually from some innocuous request to, e.g., optimize for space instead of time. > The directive statement currently only supports activating nested > scopes, I really dislike that directive nested_scopes *looks* exactly the same as directive favor_space or directive favor_time or directive alabaster_weenoblobs That will add to confusion over time, not reduce it. Incompatible language changes have to kick you in the teeth. > but it may get further use later, e.g. to activate case-insensitivity > or set the source file character set. > > A patch implementing the directive statement is at > > http://sourceforge.net/tracker/index.php?func=detail&aid=404997&gro > up_id=5470&atid=305470 > > In this implementation, directive is only considered as a keyword if > it appears at the beginning of the module. In that case it's too feeble for a pragma facility; e.g., perhaps I want to optimize one method for space but another for time. Or perhaps I want to specify that one class in a module uses traditional dicts for its namespace, but another freezes its attributes into integer-indexable vectors at compile-time. Etc. A usefully general pragma facility can't be restricted to the top of the module, because not all useful pragmatic choices apply to an entire module. > Therefore, code that happens to use directive as an identifier will > not break (unless it assigns to directive as the first thing in the > module). Make it general enough to be useful, and it will get hairier than that. Bite the bullet: if you want a new statement, make directive a reserved word. Then we can introduce it via from __future__ import directive_is_reserved in the release before it breaks code <0.7 wink>. Note that it's also not enough to allow just one or two optional tokens following "directive". One of the primary reasons no pragma facility ever got into Python is that in previous attempts nobody could agree on syntax that *was* sufficiently general (as a hint of the horrors you're signing up for, note that "optional static typing" fits-- because of the "optional" part --into a pragma framework; and once people realize that, they're going to hijack your proposal into an overly-generalized mess too). > I'd appreciate any comments as to whether this directive statement is > better or worse for the purpose of indicating that nested scopes are > used in a module. IMO it would be *much* better for everything *except* incompatible language changes, for which latter purpose I dislike it. The future_statement is specifically aimed at the latter, and I believe will support it very well. And I want not to confuse that purpose with other stuff. > Please note that making nested scopes the default in a major release > after 2.1 is an unrelated issue: It is related: the "__future__" in a future_statement helpfully implies that a future_statement is temporary (lost via "directive"); the detailed release info in __future__.py supplies a programatic means for automating tasks related to when a future_statement becomes obsolete (lost via "directive"); and ditto for the feature name imported (lost via "directive"). > it can happen with either future statements or directives; Except that directives lack all of the special support built into PEP 236 for supporting incompatible language changes specifically. > when it happens, both the future statement and the directive can continue > to work (although they would be unnecessary); tools could automatically > remove unnessary directives if desired. But much more easily for future_statements, and especially if you generalize the directive stmt enough to cover all the easily predictable uses for it, and don't make "directive" a reserved word. Note that I'm not opposed to a general pragma facility. It could be a nice hammer. But that doesn't mean everything is a nail. sell-it-on-its-real-merits-ly y'rs - tim From chega_ at yahoo.com Sun Mar 18 23:05:20 2001 From: chega_ at yahoo.com (Vadim Chugunov) Date: Mon, 19 Mar 2001 04:05:20 GMT Subject: Why "from __future__" stinks; a counter-offer References: Message-ID: <4Aft6.2171$pP2.372173@paloalto-snr1.gtei.net> "Tim Peters" wrote in message news:mailman.984949523.1896.python-list at python.org... > [Jason Orendorff] > > Okay, nested scopes are a good idea. Having the feature > > "disabled by default" in 2.1 is a good idea. But this > > "from __future__" stuff isn't so hot. > Did you read Martin's messages on this? He picked "directive", and submitted > a patch to implement it (or some part of it). But he didn't write a PEP, so > you'll have to search c.l.py and SourceForge for the relevant bits. He had > in mind a more general facility, and in particular wants to specify > source-file character encodings someday; I actively want not to conflate > future_statements with "general directives" (although "directive future xxx" > might be OK -- alas, without a PEP, it's a non-starter). But, surely, the PEP can be updated! This "from __future__" syntax is ugly, ugly, ugly!!! From aahz at panix.com Fri Mar 16 19:16:25 2001 From: aahz at panix.com (Aahz Maruch) Date: 16 Mar 2001 16:16:25 -0800 Subject: Newbie confusion about 'return' References: <3AB2A2BE.A467DE00@hotmail.com> Message-ID: <98uacp$ads$1@panix2.panix.com> In article <3AB2A2BE.A467DE00 at hotmail.com>, scott wrote: >I'm mystified. The same code in IDLE (or at the interactive prompt) >gives a different result compared to entering it into a file and running >it. I'm using Python 2.0 from python .org on NT4. I checked on Solaris 8 >with python 2.0 (interactive vs running the file) and got the same >result. The code is from "How to think like a computer scientist Chapter >7" >----------------------------------- >IDLE: > >>>> def find(str, ch): > index = 0 > while index < len(str): > if str[index] == ch: > return index > index = index + 1 > return -1 > >>>> find ("abcde", "d") >3 (in blue indicating stdout) > >The above is what I expected. That's because IDLE itself is a Python program that captures the output of return. Try entering *any* Python expression, and its output will be printed. You don't want that in a regular program, though, so you need to be explicit: > >Running python on the file (find.py): > >def find(str, ch): > index = 0 > while index < len(str): > if str[index] == ch: > return index > index = index + 1 > return -1 > >find ("abcde", "d") Try print find ("abcde", "d") -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Three sins: BJ, B&J, B&J From NoSpam at NoSpam.com Tue Mar 27 12:46:36 2001 From: NoSpam at NoSpam.com (Tom) Date: Tue, 27 Mar 2001 17:46:36 GMT Subject: macro file (containing C def's) for source navigator? Message-ID: <0m4w6.91100$A6.20818962@news4.rdc1.on.home.com> Does anyone have a Source Navigator macro file for the Python source code? (This is a file that lists the preprocessor symbol definitions for a project.) Do the python internals hackers use Source Navigator? What do they use? Is this information available somewhere in the source distribution, so I can make my own macro file? Thanks, Tom. From bbollenbach at homenospam.com Wed Mar 7 21:10:22 2001 From: bbollenbach at homenospam.com (Brad Bollenbach) Date: Thu, 08 Mar 2001 02:10:22 GMT Subject: Can Python replace Visual Basic? Should it? References: <5DZo6.11126$hn5.1578410@news1.rdc1.mb.home.com> Message-ID: [snip] > I'd say go for it -- get the Python on Windows book and convert one of your [snip] "I'd say go for it" too...I'm looking for people that ARE going for it though. :) > distribution). I converted one of our ASP pages to Python from VBScript to > see if it would be faster (it wasn't), and was pleasantly surprised at how > easy it was. Yes, and that's WEB programming, not end-user GUI. In CGI or ASP, using Python isn't something that would surprise me, and if I knew more about it right this minute, I might not use Perl to do the odd consulting jobs I do. But I'm not at that stage just yet. > I should say, though, that we haven't used any of the GUI toolkits -- maybe > someone else can recommend the best one to use when migrating from VB Forms. [snip] Yes, and those were the people I was hoping (as in Mr. Dukarm's case) would be answering my post, not theoretical "give it a try!"'s...I coulda said that. :) Anyways, do I sound bitter? :) No, but maybe the fact that only one person who saw my original post has actually migrated from VB to Python is an answer in itself. From f8dy at diveintopython.org Fri Mar 16 19:00:00 2001 From: f8dy at diveintopython.org (Mark Pilgrim) Date: Fri, 16 Mar 2001 19:00:00 -0500 Subject: HTMLparsing abnormal html pages References: <98pvp1$15t$1@news.netmar.com> Message-ID: in article 98pvp1$15t$1 at news.netmar.com, asle at spam.com at asle at spam.com wrote on 3/15/01 3:50 AM: > Considering the small program below. Running it will show that the > HTMLparser > is truncating urls in the HTML page. > [...] > import htmllib > [...] > One solution is of course to preprosess the whole HTML page and > replacing invalid URL's whith valid URL's (using regex??), however I have Don't use htmllib, use sgmllib. It does exactly what you want: uses regular expressions to pull out the tags and attributes of potentially messy HTML, then calls methods on itself based on the tags. You can subclass it and provide methods for each tag. from sgmllib import SGMLParser class MessyURLParser(SGMLParser): def reset(self): SGMLParser.reset(self) self.urls = [] def start_a(self, attrs): # at this point, attrs is a list of tuples (attrname, attrvalue) # attrname is converted to lowercase by SGMLParser # so for a tag , attrs would be # [('href', 'index.html')] hrefpair = [v for k, v in attrs if k=='href'] if hrefpair: self.urls.append(hrefpair[0]) This is such a useful technique, I'm writing an entire chapter on it in my book, "Dive Into Python". The code example in the book is more complicated than what you're looking for (it's designed to both consume and produce HTML, whereas you want to consume HTML and produce a list), and the chapter is barely started, but all the code is there along with a more complete explanation of how sgmllib works: http://diveintopython.org/dialect_divein.html Hope this helps. -M You're smart; why haven't you learned Python yet? http://diveintopython.org/ From shaleh at valinux.com Wed Mar 21 18:33:19 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Wed, 21 Mar 2001 15:33:19 -0800 (PST) Subject: Simple regex that has me banging my head against a wall In-Reply-To: <20010321150205.N24341@trufflehunter.avalongroup.net> Message-ID: > >>>> re.sub(r'\$', '\$', x) > '\\$1\\$asdfjke\\$lkjasdkjfsdasdfj' > > That's why I'm a bit confused. > The double \ is printed by python. If you do s = re.sub() and then print s, it looks just fine. I was confused by this when I tried it out myself. From ws-news at gmx.at Wed Mar 14 09:18:08 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Wed, 14 Mar 2001 15:18:08 +0100 Subject: How can I get the logged in users username on Win32? References: <3aaf7ab4.3152221@news.is.co.za> Message-ID: <984579774.633036@newsmaster-04.atnet.at> > As a side note, how can I enable Windows Scripting Host support for > python - there is mention of python in the original WSH docs - and if > I can use python scripts in WSH how would I call the built-in > Wscript. > I installed the ActivePython distribution from ActiveState and this works by default. Just give your file the extension ".pys" and it works. Samples are found in the installation as well (Python 2.0) \win32comext\axscript\demos\client\wsh hth werner > TIA > > nomad From tanzer at swing.co.at Wed Mar 14 01:54:51 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Wed, 14 Mar 2001 07:54:51 +0100 Subject: Yet another Python vs. Perl speed issue/question In-Reply-To: Your message of "Tue, 13 Mar 2001 22:17:49 GMT." <98m6ad+i25s@eGroups.com> Message-ID: nanotech at europa.com wrote: > Python 2.0 on an HP (nice and big) takes ~30 seconds to lowercase all > the lines in a 3meg file. Perl takes less than a second. What am I > doing wrong?!? > > Python > ------ > import sys > import string > > stdin=sys.stdin > lower=string.lower > > print map(lower,stdin.readlines()) > > Perl > ---- > > print map(lc,); Your Python code is doing unnecessary work (BTW, it doesn't do what you expect). Just for comparison, the timings for a 3MB file on my aging Pentium Pro 200 MHz machine: $ time python /tmp/test1.py < /tmp/test.txt > /tmp/test.out real 0m10.246s user 0m4.810s sys 0m1.190s $ time python /tmp/test2.py < /tmp/test.txt > /tmp/test.out real 0m0.781s user 0m0.200s sys 0m0.270s #### test1.py #### test2.py import sys import sys import string import string stdin=sys.stdin stdin=sys.stdin lower=string.lower lower=string.lower print map(lower,stdin.readlines()) sys.stdout.write(lower(stdin.read())) Your perl code gives a compilation error: $ time perl /tmp/test1.pl < /tmp/test.txt > /tmp/test.out Not enough arguments for lower case at /tmp/test1.pl line 1, near "lc," Execution of /tmp/test1.pl aborted due to compilation errors. Slightly changed, it lies halfway between the two python versions: $ time perl /tmp/test2.pl < /tmp/test.txt > /tmp/test.out real 0m3.297s user 0m2.830s sys 0m0.360s #### test2.pl print map {lc ($_)} ; -- Christian Tanzer tanzer at swing.co.at Glasauergasse 32 Tel: +43 1 876 62 36 A-1130 Vienna, Austria Fax: +43 1 877 66 92 From hinsen at cnrs-orleans.fr Fri Mar 30 05:27:18 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 30 Mar 2001 12:27:18 +0200 Subject: NumPy loop efficiency References: <3ac44e27$0$16692$73bec57d@news.be.uu.net> Message-ID: "S?bastien de Menten" writes: > I was wondering if writing the following statement with NumPy arrays z,a,b > and c: > z = a + b + c Two loops plus creation of a temporary array. > And if > a[:]=cos(a)+sin(a) > creates temporary variables or assigns directly the result (like > a[i]=cos(a[i])+sin(a[i]) It does create a temporary array. Getting rid of this would be a lot of work, array expressions would have to use lazy evaluation. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From loewis at informatik.hu-berlin.de Sun Mar 4 05:51:04 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 04 Mar 2001 11:51:04 +0100 Subject: how to get the last interactive command enetered References: Message-ID: "Tom" writes: > > No. Once the code is executed, the source code is dropped. All you can > > get at is the binary code. > > But when I catch a 'call' trace event the code has not been executed. I > believe that it has been parsed and compiled but not executed (till I get > the 'return' trace event). Yes, it has been parsed and compiled, the result of which was a code object (which in turn was put into a function object). After that, the source code, and the abstract syntax tree, is discarded (actually the source code is discarded in the process of parsing). The code object has a file name in it and line numbers, that's all that's left from the source. Regards, Martin From erno-news at erno.iki.fi Mon Mar 12 16:52:17 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 12 Mar 2001 23:52:17 +0200 Subject: Problems writting a wrapper around linux' ssh command References: <31rd89.lki.ln@127.0.0.1> Message-ID: In article , gradha at iname.com writes: | Erno Kuusela wrote: || do not embed the password in your python program. use a passphraseless || rsa key instead, it is safer and less pain. | At the moment I am using the getpass module to retrieve the pass from the | user and feed it directly to ssh and scp. Is that secure enough? ah, if you are getting the password from the user, there is no security issue. i had assumed you were storing the password embedded in your python program. rsa keys are more convenient though. ssh-agent + rsa key with passphrase = safe yet no need to type in passwords all the time. -- erno From grante at visi.com Fri Mar 23 08:58:23 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 23 Mar 2001 13:58:23 GMT Subject: Tkinter - Widget Colours References: Message-ID: <3EIu6.1971$SB2.254481@ruti.visi.com> In article , O'Rourke Clodagh-corour01 wrote: >I was wondering does anyone know how the bag/fag colours can >be changed after the widget is packed. widgetObject.configure(foreground="#000") # black? widgetObject.configure(background="#fff") # white? -- Grant Edwards grante Yow! It's OKAY --- I'm an at INTELLECTUAL, too. visi.com From chris.gonnerman at usa.net Sat Mar 31 23:37:13 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sat, 31 Mar 2001 22:37:13 -0600 Subject: Know of Substantial Apps Written in Python? References: Message-ID: <004101c0ba65$7098cfe0$a100000a@local> ----- Original Message ----- From: "Tim Peters" Subject: RE: Know of Substantial Apps Written in Python? > [Moshe Zadka] > > ... > > Python would never fit on a floppy. > > Sure it can! Python + the entire base std library (top level of Lib/) still > fits on a floppy with ease, if you use any common compression scheme. Just > for fun, I just built a zip file with that stuff for the Windows 2.1b2 > distribution, and it came in at just over a tad above 1Mb (so about 70% of > one floppy). What that leaves out from the *std* Windows distribution is, > primarily, 7Mb (unpacked) of HTML docs, Tcl/Tk, the C header files and link > libraries, and the Tools/ directory (incl. IDLE). Have you seen Marc-Andr? Lemburg's mxCGIPython project? Most of the all-in-one-file Python interpreters there fit on a floppy (although of course supporting libraries/DLL's may not). I use CGIPython for WinNT on CD-ROM's for Win95/98 with good success, and am using the Linux version for CGI's on a Linux-based free hosting service which does not otherwise support Python. Don't let the CGI prefix fool you, you can do non-CGI work (basically anything not needing the interactive mode) with this package. Most of the binary builds are 1.5.2 but that doesn't bother me. From topmind at technologist.com Sat Mar 3 20:00:30 2001 From: topmind at technologist.com (Topmind) Date: Sun, 04 Mar 2001 01:00:30 GMT Subject: Collection interfaces References: <3a90fa97.0@news1.mweb.co.za> <3A933830.7F98D118@ix.netcom.com> <220220010813598042%cmh@bDistributed.com> <8Gem6.473353$U46.14105062@news1.sttls1.wa.home.com> <3A9A86B1.9A8C69A2@ix.netcom.com> <97fjla128ir@news2.newsguy.com> <97h5s40vhc@news2.newsguy.com> <97ibmc0k47@news1.newsguy.com> <97m0c7080c@news2.newsguy.com> Message-ID: > "Topmind" wrote in message > news:MPG.15085517debf4b649896ca at news.earthlink.net... > > > > Well, my experience tells me that the "task axis" > > is the most "business friendly" axis to build > > along (being that multi-axis paradigms still need > > a lot of work and thus we are forced to emphasize > > one at the expense of others for now.) > > > We'll make an OOer of you yet. > Psst. Less structural taxonomy and more task-oriented > thought. You might even think of a little "agent" doing > that task for you. Then, you'll dress that little agent up > in some nice clothes, and presto, an object. > If you can show a benefit of such wrapping. > Or component. Perhaps you should just skip OO and > go right to components. Just don't suggest components > should be wrapped in tables. > Sometimes the interfaces can. > I vote YES for comp.top > Only because you want to get rid of me. -tmind- From fredp at mygale.org.nospam Wed Mar 21 12:11:29 2001 From: fredp at mygale.org.nospam (Fred Pacquier) Date: 21 Mar 2001 17:11:29 GMT Subject: Accessing Oracle from Python remotely ? References: Message-ID: claird at starbase.neosoft.com (Cameron Laird) said : >In article , >gkiffney wrote: >>There's http://www.zope.org/Products/DCOracle which should get you >>started. There was an article by Uche Ogbuji in Linuxworld that helped >>me get going with this, but it's apparently fallen off the Internet map >>into the bit bucket. Using the dcoracle module (which is a bit of a >>pain to get going, > . >Do you mean >? Excellent ! Thanks ! Truly scary though... :-)) -- YAFAP : http://www.multimania.com/fredp/ From donn at u.washington.edu Tue Mar 20 14:11:29 2001 From: donn at u.washington.edu (Donn Cave) Date: 20 Mar 2001 19:11:29 GMT Subject: Functionalism, aesthetics Was:(RE: I come to praise .join, not References: <996vss013mp@news2.newsguy.com> Message-ID: <998a11$q3e$1@nntp6.u.washington.edu> Quoth "Alex Martelli" : ... | Buildings as such (and more generally dwelling-places) are old | enough that it's quite possible that we all share some basic | biological basis for sound judgment -- I'm not pronouncing | on that, but that's what Alexander is mostly writing about. I don't know if that means he was looking for a habitat evaluation gene, though. The way I read it, he was talking about a kind of thinking. It works because we have a biological basis for sound judgement, but not specifically about buildings, we just have a deep knowledge of the world we live in and don't do well to defer to architects to tell us what will work for us, based on their diagrams or their trained esthetics. I certainly would not want to argue with an architect who is talking about what will hold up to an earthquake, but an architect's ideas about form and function are no substitute for the shared sense of an evolved cultural landscape. I don't know about his pattern language. Like the other ideas Alexander had along those lines - user on-site design, some kind of weird construction techniques - he was looking for a route from here to there, from modern western building and land use to the kind of vernacular tradition that can use that shared sense. It has been too long since I read the book, but I don't think he meant the patterns to be adopted as that vernacular tradition, they were more like crutches until we could walk on our own. Anyway, as long as we're talking about things that we spend our days doing, we certainly do have the capacity for sound judgement. It doesn't mean our judgement is therefore infallibly sound, but the collective judgement of an established culture brings a kind of sense to bear that can dwarf a brilliant appeal to abstract principles. Donn Cave, donn at u.washington.edu From daniel.dittmar at sap.com Wed Mar 28 03:30:52 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Wed, 28 Mar 2001 10:30:52 +0200 Subject: Where is the DBI module? References: Message-ID: <99s7ft$hjt$1@news1.wdf.sap-ag.de> > I can "import DBI" but when I try to find the actual module in order to > examine it I can't. Am I missing something obvious? General solution: [0] d:\ >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 >>> import dbi >>> dbi >>> -- Daniel Dittmar daniel.dittmar at sap.com SAP DB, SAP Labs Berlin http://www.sapdb.org/ From tuttledon at hotmail.com Sat Mar 3 22:37:12 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Sun, 04 Mar 2001 03:37:12 GMT Subject: [Python-Dev] Re: Bug fix releases References: Message-ID: "Tim Peters > Note there was never a bugfix release for 1.5.2, despite that 1.5.2 had some > serious bugs, and that 1.5.2 was current for an unprecedentedly long time. > Guido put out a call for volunteers to produce a 1.5.2 bugfix release, but > nobody responded. Past is prelude ... > > everyone-is-generous-with-everyone-else's-time-ly y'rs - tim But there is the CVS. And there are those like myself who are CVS impaired. Right now there are Fredric's SRE and _tkinter on steroids updates, and Mark's improved COM support. I'd love to have these. (Alright I've got /F's. He compiled 'em. But Mark's is still in the damn CVS.) I've prodded ActiveState to issue Python updates and they've indicated they would--they just haven't decided when. I don't think it has to be as formal as an official pep or separate development track. Just whenever our fearless dictator sees that there's enough good stuff in the CVS, let him decree that a new build shall be made. Of course we've gotta sell the idea to the dictator. Nobody's lost their head trying to do that (gulp) have they? Don From cognoscente at rediffmail.com Thu Mar 22 23:58:09 2001 From: cognoscente at rediffmail.com (prashant patel) Date: 23 Mar 2001 04:58:09 -0000 Subject: Ruby will overtake Python within four years. Message-ID: <20010323045809.9369.qmail@mailweb22.rediffmail.com> No I am not a ruby programmer not even using any scripting language other once used vbscript in ASP. my major programming language has been java. But with the experience in java, I want learn a scripting language which increases my productivity, java is simply to redundant. for example : doing an IO required to use so many classes. for the past one month i have been find a alternative, and found three scripting language python,perl,and ruby. for now python is my choice, perl is surelty a no for its syntax.but how about python and ruby, as i would be allocating a lot of time learing language the particular language, could some one give out facts about ruby. I would be unjustified actually to ask python lover's the good and bad of ruby compared to python, but these discusions will help us also evaluate python. And yes the subject line and be taken from. http://www.amazon.com/exec/obidos/tg/feature/-/99126/102-2233024-4095364 But my inclination are towards python. _____________________________________________________ Chat with your friends as soon as they come online. Get Rediff Bol at http://bol.rediff.com From aleaxit at yahoo.com Wed Mar 7 05:36:03 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 7 Mar 2001 11:36:03 +0100 Subject: ScriptControl (was Re: Can Python replace Visual Basic? Should it?...and generalities : )) References: <2Ybp6.12845$hn5.1818206@news1.rdc1.mb.home.com> Message-ID: <9852ui0166a@news1.newsguy.com> "Brad Bollenbach" wrote in message news:2Ybp6.12845$hn5.1818206 at news1.rdc1.mb.home.com... > This reply is interesting, but still contains a lot of the "I've started > invistigating Python and these are the things I like about it" comments, > which I was hoping to avoid. > > [snip] > > > A Python "OCX" control needs to be written. This control > > would simply encapsulate Python for us Visual Basic idiots. > > This way we could 'pop in the control in our VB project and > > start using Python for parts of the program. > > That's a neat idea. I hope someone smarter than me decides to do it. :) Microsoft has done it!-) They cleverly call it the ScriptControl, so it won't be immediately obvious that its real purpose is to let you embed Python in your VB programs without breaking a sweat; and, accordingly, you have to explicitly set its Language property to "Python" (but that, no doubt, is in pursuance of Python's "explicit is better than implicit" philosophy -- bet you never expected THAT one from MS, hm?-). You also have to have the ActiveState build of Python installed (or, install the standard build, then go to ActiveState anyway to pick up the win32all extensions and install those on top of the standard Python distribution). > As, you mentioned in a reply to the other thread of this thread (heh), > coding really is the most insignificant part of a large programming project > in a coporate environment. In theory at least, you should have a clear idea > of what you're going to do before you do it, in which case the coding > (almost irregardless of the language) is often times just grunt work. The *maintenance* part of the program's lifetime costs is paramount, and that involves LOTS of fiddling with code too -- therefore, the claim that "coding ... is insignificant" (while not absurd if only applied to the INITIAL coding) is quite misleading. That code will have to be read/understood/fixed/modified a thousand times...! Alex From tjg at exceptionalminds.com Fri Mar 9 12:59:33 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Fri, 9 Mar 2001 09:59:33 -0800 Subject: Divorcing Command Line and GUI Message-ID: <20010309095933.T3579@trufflehunter.avalongroup.net> Hello Everyone. This is something of a strange question, but please bear with me. I have a series of tools that I have created that work from the command line. I have now been tasked with creating GUIs for those tools. The problem I'm faced with is that the command line tools and the GUI tools will probably be licensed differently (e.g, command line will be Open Source, GUI will be something undetermined as of yet.) This means that I can't put my GUI code in with my CL code. My first cut at this demarcation sort of worked, but was also troublesome. So while I have some new ideas, I'm looking to see if anyone else in the python community has ever had to do something like this, and if there are any easily maintainable solutions to this problem. -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Red Hat Certified Engineer www.exceptionalminds.com Avalon Technology Group, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 51 days 22:09 hours ago<< From dave at see.sig.for.address Wed Mar 28 13:55:48 2001 From: dave at see.sig.for.address (Dave) Date: Wed, 28 Mar 2001 18:55:48 GMT Subject: ANNOUNCE: Python Mock Objects Message-ID: <5oc4cto5ec8iqvkdflaivv52805dn9rfdd@4ax.com> [This is a repost, since the original seems to have got lost between me and my ISP. My appologies if you receive it twice.] I have released to the Python and XP communities a small Python module for creating mock objects. A mock object can be passed to a class or method being tested to replace objects that are outside the scope of the test. The file has been uploaded to the Extreme Programming mailing list on yahoo groups, and may be downloaded from: http://groups.yahoo.com/group/extremeprogramming/files/PythonMock.zip The idea is simple. A mock object created with this class will allow any method to be invoked on it, with any parameters (including keyword arguments). The method calls are stored and can be examined later to see what parameters were passed. By default all methods return None, but the class constructor can take a dictionary of method names and values to return for those methods. The zip file contains documentation and a test suite using OmPyUnit, which should easily be convertible to the other versions of PyUnit. OmPyUnit can be downloaded from http://www.xprogramming.com/software.htm or from http://www.objectmentor.com/freeware/downloads.html. If anyone finds this useful or converts it to other languages then please let me know. I believe Smalltalk or Ruby should be easy, but if anyone figures out how to do this in Java or C++ then please let *everyone* know. 8^) Share and Enjoy Dave Kirby -------------------------------------------------- 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 tim.one at home.com Sun Mar 11 23:35:31 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 11 Mar 2001 23:35:31 -0500 Subject: Static typing (was Re: Java guy interested in Python) In-Reply-To: <98glhc02sga@news2.newsguy.com> Message-ID: [Rainer Deyke] > When I type 'int i;' in C++, what I really mean is "'i' behaves like an > integer variable.". [Tim] > Since that's all "int i;" *can* mean in C++, seems tautological . [Alex Martelli] > Surely you're joking, Mister Peters? > > class int { > public: > int(const char*=0); > ~int(); > const char* data() const; > }; > > int i; > > Isn't this perfectly legal C++, meaning something very different from > "i behaves like an integer variable"...? int is no "reserved word", > after all. As in the "Einstein's Riddle" thread, I was doing Rainer the favor of assuming he was trying to say something . If I don't extend you the same favor, then before I can answer your question I have to be assured of a great many things, such as that e.g. this fragment isn't in the scope of #define char const or #define const ( or etc . there's-more-than-meets-the-eye-when-there's-more-than-meets-the-eye-ly y'rs - tim From menscher+python at uiuc.edu Thu Mar 8 01:20:43 2001 From: menscher+python at uiuc.edu (Damian Menscher) Date: Thu, 08 Mar 2001 06:20:43 GMT Subject: grabbing return codes from os.system() call Message-ID: <%wFp6.9481$dL4.126404@vixen.cso.uiuc.edu> I'm new to Python (as in, my experience is essentially the tutorial), but I've already come up with an interesting question: How do I get the return code from an os.system call? I would have expected I could do something like ---returncode--- #/bin/csh echo do stuff exit 3 and then in my python program I could do print os.system('./returncode') But it prints out 768. Not particularly useful, even after I recognize the trick of dividing by 256 (byte-swapping going on? No, because a return code of 768 reports as 0). Given that my real return codes will be (possibly large) integers, this limitation will likely cause some serious problems down the line. Even better would be a way of returning a string (the script I run can be something other than csh, but it has to be a separate script). Ideas? I'm trying to avoid writing the string out to a file and then read the file back in to the python program.... Damian Menscher -- --==## Grad. student & Sys. Admin. @ U. Illinois at Urbana-Champaign ##==-- --==## www.uiuc.edu/~menscher/ Ofc:(217)333-0038 ##==-- --==## Physics Dept, 1110 W Green, Urbana IL 61801 Fax:(217)333-9819 ##==-- From andreas at andreas-jung.com Thu Mar 15 08:25:00 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Thu, 15 Mar 2001 08:25:00 -0500 Subject: Help doing simple threading References: <3AB041C6.FDDB84D3@theworld.com> Message-ID: <98qg4q$f4c$1@slb2.atl.mindspring.net> "David Lees" schrieb im Newsbeitrag news:3AB041C6.FDDB84D3 at theworld.com... > Thanks, these comment were quite helpful. The most serious error was > 'a)'. when I just put the main to sleep after starting up the threads > it worked fine. The problem was that I was printing out the array > values, before all the threads finished executing. Using sleep() is also dangerous. This is not the way to synchronize threads. The threading module offers you several possibilites (e.g. join() method) for a clean, working solution. Andreas From park997 at aol.comnotospam Tue Mar 13 09:53:39 2001 From: park997 at aol.comnotospam (Park997) Date: 13 Mar 2001 14:53:39 GMT Subject: main in mac? Message-ID: <20010313095339.19264.00000243@ng-dh1.aol.com> Hi, I am using Python 2.0 on a PPC mac. I have a module that is set up as follows: from Numeric import * class Epower: 3 class functions defined if __name__ == '__main__': test class and print output This code does nothing if the run all button is pressed or if it is imported into interactive python. when the above if statement is replaced by: if 1: the program runs properly with output. I thought that if __name__ == '__main__': is standard syntax. Does this need to be changed for mac Python? Thanks, Wendell Cropper From stadt at cs.utwente.nl Sat Mar 3 21:01:11 2001 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Sun, 04 Mar 2001 03:01:11 +0100 Subject: multipart/form-data submission with httplib + MimeWriter? References: Message-ID: <3AA1A1E7.1360139A@cs.utwente.nl> Steve Purcell wrote: > > Wise ones, > > Can anyone point me towards some example code for performing > 'multipart/form-data' submissions of form values and file contents > using httplib and MimeWriter? > I'm not sure what you mean. Are you asking about - how to *fill in* such webforms automatically, or - how to create a form with which a file can be uploaded, or - how to deal with the contents of such a form when submitted? Richard. From bbhaydon at bigpond.com Sat Mar 10 11:17:09 2001 From: bbhaydon at bigpond.com (Brett Haydon) Date: Sun, 11 Mar 2001 03:17:09 +1100 Subject: cursor.execute fails under mxODBC References: <3AA7FF0E.50E6D70F@northwestern.edu> Message-ID: Hmmm looks like the new version is broken. I am running mxODBC 1.1.1 no problems with both MySQL and Access for the last 6 months on W2k. I just tried the new version also with exactly the same problems. The old one still works fine though.. regards, bbhaydon "Louis Luangkesorn" wrote in message news:3AA7FF0E.50E6D70F at northwestern.edu... > I have the same problem. Below is my output. I will first use the odbc > that comes included with ActivePython, then the mxODBC module (by the way, > I've tried to rename the odbc.pyc file, that did not help, except break > odbc) > > PythonWin 2.0 (#8, Oct 19 2000, 11:30:05) [MSC 32 bit (Intel)] on win32. > Portions Copyright 1994-2000 Mark Hammond (MarkH at ActiveState.com) - see > 'Help/About PythonWin' for further copyright information. > >>> > >>> import dbi,odbc > >>> import pprint > >>> channel = odbc.odbc('sqltutor') > >>> ch1 = channel.cursor() > >>> ch1.execute('SELECT FirstName, LastName, Address, City, State FROM > EmployeeAddressTable') > 0 > >>> test1 = ch1.fetchall() > >>> pprint.pprint(test1) > [('Joe', 'Smith', '83 First Street', 'Howard', 'Ohio'), > ('Mary', 'Scott ', '842 Vine Ave.', 'Losantiville', 'Ohio '), > ('Sam', 'Jones ', '33 Elm St.', 'Paris', 'New York '), > ('Sarah', 'Ackerman ', '440 U.S. 110', 'Upton', 'Michigan ')] > >>> ch1.close() > >>> channel.close() > >>> import mx.ODBC > >>> channel = mx.ODBC.Windows.connect('sqltutor') > >>> ch1 = channel.cursor() > >>> ch1.execute('SELECT FirstName, LastName, Address, City, State FROM > EmployeeAddressTable') > > at this point the whole thing dies. No error messages. I didn't see any > log files anywhere either. > > Louis > > -- > K Louis Luangkesorn > lluang at northwestern.edu http://pubweb.nwu.edu/~kll560 PGP:0xF3E2D362 > Whatsoever things are true, ... honest, ... just, ... pure, ... lovely, ... > of good report; if there be any virtue, and if there be any praise, think on > these things.- motto - Northwestern University > > From hamish_lawson at yahoo.co.uk Tue Mar 20 12:31:01 2001 From: hamish_lawson at yahoo.co.uk (=?iso-8859-1?q?Hamish=20Lawson?=) Date: Tue, 20 Mar 2001 17:31:01 +0000 (GMT) Subject: Should __future__ statements ever be phased out? Message-ID: <20010320173101.21650.qmail@web217.mail.yahoo.com> The __future__ proposal envisages that future statements in a piece of code will be phased out once the language change becomes standard. (Many of the alternative proposals also envisage this.) Does this not pose possible problems with running post-change-aware code on an pre-change version of the interpreter? Let me take a fanciful (and hopefully highly improbable!) example. Suppose in Python 4.0 it is decided to introduce a change in the semantics of the print statement so that it outputs its arguments in uppercase. This change is inrended to become mandatory in Python 3.1 and those wanting the old behaviour after that will have to use write statements. During the 4.0-to-4.1 transition I use a future statement in my code to specify whether I want the old or the forthcoming behaviour. After 4.1 comes out and I upgrade my interpreter, I phase out all the print-related future statements from my code. However one day I give my program to a friend who (unknown to me) is still running Python 2.1. When he runs my program any print statements in it will behave differently from what I intended, but without any warning. Hamish Lawson ____________________________________________________________ Do You Yahoo!? Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk or your free @yahoo.ie address at http://mail.yahoo.ie From erno-news at erno.iki.fi Fri Mar 30 18:55:30 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 31 Mar 2001 02:55:30 +0300 Subject: best practice? null/None vs 'None' vs '' (in web/sql) References: Message-ID: In article , fluxent at yahoo.com writes: | I can see that the ODBC result set distinguishes them. But of course | when things get rendered out to HTML you don't want to see single | quotes around every string value, so 'None' and None become the same | thing. if you are dynamically generating the form, you can omit the fields that you want to correspond to null. that is conceptually the same thing as null. (if you are using the cgi module, reember to pass keep_empty_fields=1 - it defaults to 0 for some reason) -- erno From erwin at andreasen.com Sat Mar 24 07:23:03 2001 From: erwin at andreasen.com (Erwin S. Andreasen) Date: Sat, 24 Mar 2001 12:23:03 +0000 (UTC) Subject: close(), exceptions and problems References: Message-ID: <99i3j7$lqr$1@news.cybercity.dk> On 23 Mar 2001 09:30:46 GMT, Antti Kuntsi wrote: >I have run into the following problem with python and close()s. When the >system is under a heavy load the close() system call can be interrupted, >but the Python never detects this. This leads into a lot of problems, >including at least the following: What exactly do you mean by "interrupted" ? close(), the system call, usually cannot fail (unless you try to close a fd that is not open). If a system call is interrupted by a signal, it is restarted automatically (unless the signal handler was setup with SA_NORESTART *or* the system call in question is select(), which is never automatically restarted). But if you call close(fd) you aren't supposed to do something like: int fd, rv; while (((rv = close(fd)) < 0 && errno == EINTR)) ; if (rv < 0) perror("close"); the system call will be automatically restarted for you. -- ======================================================================= Herlev, Denmark Software Designer <*> LASAT^WEicon Networks ======================================================================= From paulp at ActiveState.com Wed Mar 14 09:55:38 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 14 Mar 2001 06:55:38 -0800 Subject: [Python-Dev] Revive the types sig? References: <15020.9404.557943.164934@w221.z064000254.bwi-md.dsl.cnc.net> <200103120711.AAA09711@localhost.localdomain> Message-ID: <3AAF866A.968411B8@ActiveState.com> Paul Moore wrote: > >... > > My view on all this is that type annotations are likely to be counterproductive, > in the face of Python's high degree of polymorphism. For example, what is the > type of > > def fac(n): > if n <= 1: return 1 > return n * fac(n-1) > > ? > > Obvious answer, integer -> integer. And that's likely what the programmer would > say. > > But why can't this function be used with *any* type which supports comparison > with the number 1, multiplication, and subtraction of 1? Sure it can. But as a programmer, I probably haven't really thought through the meaning of this code for users who pass in strings or lists of SocketObjects. Therefore I should not be blamed when someone passes in a random type and gets strange behavior. Anyhow, this kind of totally polymorphic code is exceedingly rare. If you had done division in there, floats would work radically differently than integers. It isn't safe to say that just because the right operators are defined, they mean the right thing. Type annotations of any type are a known trade-off between raw flexibility, safety and error reporting. C++ and ML are way on one end of the spectrum. Python is way on the other end. There is a middle ground. -- Python: Programming the way Guido indented it. - (originated with Skip Montanaro?) From hzhu at users.sourceforge.net Mon Mar 19 22:40:01 2001 From: hzhu at users.sourceforge.net (Huaiyu Zhu) Date: Tue, 20 Mar 2001 03:40:01 GMT Subject: So what's wrong with __future__? (Was Re: Why "from __future__" stinks ...) References: Message-ID: I don't quite see what the complaint about __future__ is really about. So let me try to analyze a little bit. Maybe this could encourage someone to write a PEP to clarify. What's wrong with import __future__? 1. It is ugly. Does this apply to syntax or semantics? Syntax. But how? It looks to me to be good on two accounts: 1. It stands out clearly as saying "magic". 2. It does not introduce new syntax or keyword. Just a new module name. How much better can you get if you want both? Semantics. It does not SHOUT "magic". A new keyword should be cleaner. Not so. Python __magic__ words have (at least) two effects: 1. automatic, like __init__. 2. side effect, like __setattr__, __builtin__. The only magic of __future__ is side effects. Does its semantics go beyond a regular module? Well, yes. But so what? If you redefine __setattr__, is its effect confined to itself? If you redefine operator.__add__, is its effect only felt when you call it explicitly? Clearly you can complain that __setattr__ is not like any other method. But what would it look like if you introduce a new keyword in its place? 2. Future is the wrong word, because it concerns time. A keyword like __incompatible__ would convey meaning better. Well, I can see both ways of thinking: If you consider any given moment in time, its effect is indeed incompatible change. It's whether you want or don't want this change. But if you consider the process of change, its effect is merely when a change happens. Your choice is only whether you want it now or in the future. (Maybe from __preview__ import *?) I think Tim's intend is that anything that goes into __future__ will be mandatory in some future version. 3. It will introduce confusion about versions. This complaint will hold true no matter how you spell it. The version info in the __future__ module seems to minimize this problem. In fact, if you adopt the view that it is not an optional feature mechanism, but a time travel mechanism, then the mechanism built in the PEP should be sufficient. Now that's my rant about the complaints about __future__. I'm even less certain about what the proposed alternatives look like, and how they address these problems. Hopefully some proponents of the alternatives could write a PEP along these lines? I believe you will find the truth in Tim's comment that any concrete proposal will attract lots of criticism. If you are saying, __future__ is not good, but I do not have anything substantially better, well then, what can be done? Huaiyu From deblNo at spammytheworld.com Fri Mar 30 00:27:36 2001 From: deblNo at spammytheworld.com (David Lees) Date: Fri, 30 Mar 2001 05:27:36 GMT Subject: Looking for Python equivalent to a Perl'ism References: <3AC375A7.A4BA87F1@spammraqia.com> <3d3dbwwbk1.fsf@ute.cnri.reston.va.us> Message-ID: <3AC41952.549DCA85@spammytheworld.com> Thanks for the solution. Also, this is a big help to my understanding the 'sub' section of the documentation at: http://www.python.org/doc/current/lib/Contents_of_Module_re.html david lees Andrew Kuchling wrote: > > To simply substitute the contents of a single group, you can > include \N, or \g: > > p=re.compile(r'zz(\w+)zz') > s='this is and so is zzxxxzz abc that an zzyyyzz abc zzxxxzz or else' > print p.sub('\g<1>', s) > > This produces "this is and so is xxx abc that an yyy abc xxx or else" > You want to do a dictionary lookup, though; instead of passing a > replacement string, you can pass a function which will be handed the > match object, and can return whatever string it likes: > > def sub_func(match): > return dict[ match.group(1) ] > > print p.sub(sub_func, s) > From f8dy at diveintopython.org Fri Mar 16 19:30:53 2001 From: f8dy at diveintopython.org (Mark Pilgrim) Date: Fri, 16 Mar 2001 19:30:53 -0500 Subject: HTMLparsing abnormal html pages References: <98pvp1$15t$1@news.netmar.com> <98ua8j$a6h$1@panix2.panix.com> Message-ID: in article 98ua8j$a6h$1 at panix2.panix.com, Aahz Maruch at aahz at panix.com wrote on 3/16/01 7:14 PM: > In article <98pvp1$15t$1 at news.netmar.com>, wrote: >> >> Considering the small program below. Running it will show that the >> HTMLparser >> is truncating urls in the HTML page. Now, most of you will probably say that >> the page and in particular the URL's of this page are not valid according to >> the RFC1738 protocol --bad luck. But there must be a work-around for this? > > For this specific case, Mark's solution may well work (haven't tested it > myself). But you cannot easily find a generic solution because of all > the different ways to mangle HTML. My solution does work, (only) because the page the original poster was trying to parse had unquoted attribute values, like . sgmllib works fine in these cases. In fact, the BaseHTMLProcessor class I define in my book can be used to properly quote all attribute values, since it works by breaking down the entire HTML (via sgmllib) and building up equivalent HTML with proper quotes around attribute values. This is decidedly *not* why it was written; I just happened to notice it one day when I was testing the code for other reasons. http://diveintopython.org/dialect_divein.html -M You're smart; why haven't you learned Python yet? http://diveintopython.org/ From kens at sightreader.com Tue Mar 20 14:24:36 2001 From: kens at sightreader.com (Ken Seehof) Date: Tue, 20 Mar 2001 11:24:36 -0800 Subject: Insertin **keywords into a class References: <9960i1$tp0$1@nntp6.u.washington.edu> <99661m$scc$1@panix6.panix.com> <99877b$uss$1@nntp6.u.washington.edu> Message-ID: <006701c0b173$6bb5dd10$04090a0a@upcast.com> Use setattr(). You are confusing an attribute with an attribute name (a string). Each time through the loop you are assigning to the attribute 'kw' rather than the attribute whose name is the value of kw. def __init__(self, *arguments, **keywords): self.radius = 0.0 for kw in keywords.keys(): print kw, ":", keywords[kw] setattr(self, kw, keywords[kw]) print "self.radius =", self.radius or simply... def __init__(self, *arguments, **keywords): self.__dict__.update(keywords) ----- Original Message ----- From: "C. Porter Bassett" Newsgroups: comp.lang.python To: Cc: Sent: Tuesday, March 20, 2001 10:53 AM Subject: Insertin **keywords into a class > cCan you please tell me why the following code snippet doesn't update the > value of radius? > > > class myClass: > def __init__(self, *arguments, **keywords): > self.radius = 0.0 > for kw in keywords.keys(): > print kw, ":", keywords[kw] > self.kw = keywords[kw] > print "self.radius =", self.radius > > > b = myClass(radius = 1.0) > > > -------------------------------------------------------------------------- > "Pretend like this is a really witty saying." - Anonymous > -------------------------------------------------------------------------- > > > > -- > http://mail.python.org/mailman/listinfo/python-list > From fredrik at pythonware.com Thu Mar 1 01:26:58 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 01 Mar 2001 06:26:58 GMT Subject: Intersesting Questions involving extending and embedding References: <3a9c6f89.9613214@news.digital.net> <0D1n6.15927$Qb7.2600092@newsb.telia.net> <3a9f0af7.37387355@news.digital.net> <508n6.15966$Qb7.2607706@newsb.telia.net> <3a9dc27e.1325053@news.digital.net> Message-ID: "Dev_NuLL" wrote: > > > The writers of Blender modules release the modules compiled to protect > > > the source code, and that is what I am also interested in doing. > > > >compiled as in DLL/SO, or compiled as in PYC? > > from the original message: > > How would I go about creating a Windows DLL or Linux > .so that would do this? from your original message: > [a piece of python code] > I would like to create a primitives module to create 3D solids I would > like to wrap the above code (or similar) into a module and call it > 'Primitives' with a 'plane' function [...] to which the answer is to use a PY or PYC file, like everyone else. if you insist on wrapping the PYCs in DLL/SO files (as if that would make them harder to reverse engineer), search the net for python2c [1], or study the freeze sources [2] Cheers /F 1) last seen here: http://lima.mudlib.org/~rassilon/p2c 2) in the source distribution From mwh21 at cam.ac.uk Thu Mar 29 17:02:46 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 29 Mar 2001 23:02:46 +0100 Subject: Python assembler References: Message-ID: "Mike C. Fletcher" writes: > I _think_ (not really sure, as never used it) that bytecodehacks > provides an "assembler" language for Python. Project is at: > http://bytecodehacks.sourceforge.net/ It's a bit of a joke, and the bytecodehacks are somewhat out of date (sorta work with Python 2.0, probably die horribly with 2.1). I haven't really had any motivation to hack on the bytecodehacks lately. I might get another rush of enthusiasm at some point, but don't hold your breath. Cheers, M. -- I'm sorry, was my bias showing again? :-) -- William Tanksley, 13 May 2000 From cce at clarkevans.com Mon Mar 26 05:18:47 2001 From: cce at clarkevans.com (Clark C. Evans) Date: Mon, 26 Mar 2001 05:18:47 -0500 (EST) Subject: win32com:MakePy -- Early Binding without the size jitters? In-Reply-To: Message-ID: On Mon, 26 Mar 2001, Clark C. Evans wrote: > > doc = msxml.DOMDocument.default_interface( > pythoncom.CoCreateInstance( > "MSXML2.DOMDocument",None, > pythoncom.CLSCTX_INPROC, > pythoncom.IID_IDispatch)) > ... > import msxml3 > doc = msxml3.DOMDocument() *blush* I was working too hard, as the following is all I need: msxml.DOMDocument.default_interface(msxml.DOMDocument()) I was wondering if the wrapper generator could be fixed to do this automatically? For some reason, the __init__ below isn't doing it... go figure. class CoClassBaseClass: def __init__(self, oobj=None): if oobj is None: oobj = pythoncom.new(self.CLSID) self.__dict__["_dispobj_"] = self.default_interface(oobj) ... Anyway, thank you for such an Excelent product! Wow! I can finally *DITCH* Visual Basic for "object scripting" ... I think. Kind Regards, ;) Clark From careye at spamcop.net Wed Mar 28 02:16:33 2001 From: careye at spamcop.net (Carey Evans) Date: 28 Mar 2001 19:16:33 +1200 Subject: large arbitrary binary data in python References: Message-ID: <87wv9ajrce.fsf@psyche.dnsalias.org> [...] > 3) pipe the data to a shell command like this "gunzip -dc | dd of=device" As well as using the md5 module, as Steve has pointed out, you can do all this in Python too, using the gzip module to decompress the data. Instead if dd, you can use just a standard file object to output it. If there is some need for blocks of a certain size, and the file write() method doesn't cut it, use the os.open() and os.write() functions. > How will python handle the large amount of binary data? Is there a limit to > the size of a binary string in python? The various string object functions in Python take the length as an int, so you can fit however much that can measure on your platform. If int is 32 bits, that's two gigabytes of data. -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "Quiet, you'll miss the humorous conclusion." From aahz at panix.com Fri Mar 9 21:49:56 2001 From: aahz at panix.com (Aahz Maruch) Date: 9 Mar 2001 18:49:56 -0800 Subject: Python In A Nutshell References: Message-ID: <98c4ok$fhd$1@panix2.panix.com> In article , Don Tuttle wrote: > >Planning stages? We've all seen his posts (a.k.a. treatises) here. I'd say >he should have the final draft to you in 3 weeks tops. ;-) ITYM "first draft". It will take another three-to-six months for Alex to edit it down. ;-) -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "..., and some of you may regard all women as evil traps that exist only to tease, torture, and suck out your very soul." --DrMax From stephen_purcell at yahoo.com Sun Mar 18 04:52:58 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Sun, 18 Mar 2001 10:52:58 +0100 Subject: HTMLparsing abnormal html pages In-Reply-To: <6ej8btssj4tf5t14gca2ge4dt6bdbajbtc@4ax.com>; from timr@probo.com on Sat, Mar 17, 2001 at 09:58:10PM -0800 References: <98pvp1$15t$1@news.netmar.com> <98ua8j$a6h$1@panix2.panix.com> <6ej8btssj4tf5t14gca2ge4dt6bdbajbtc@4ax.com> Message-ID: <20010318105258.A7546@freedom.puma-ag.com> Tim Roberts wrote: > I have been searching for an HTML pretty-printer; something where I can > feed an arbitrary page and get a more structured, indented view. I wrote a > simple one myself, based on sgmllib; it does a fair job, but it is easily > confused by such common offenses as omitted

tags. It sounds like your > BaseHTMLProcessor might be such a thing. Is it available yet? > > If not, is anybody aware of a fair HTML cleaner-upper? You could use the python-xml code to slurp the HTML into a DOM, and then format it using HtmlLineariser: >>> from xml.dom.writer import HtmlLineariser >>> from xml.dom.html_builder import HtmlBuilder >>> builder = HtmlBuilder() >>> builder.ignore_mismatched_end_tags = 1 # make less fussy >>> html_text = open('public_html/index.html').read() >>> builder.feed(html_text) >>> pretty_printed = HtmlLineariser().linearise(builder.document) pretty_printed is now a nicely indented version of html_text. It's not the fastest thing in the world, but it might help you. -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From gregj at pobox.com Thu Mar 22 04:52:01 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Thu, 22 Mar 2001 09:52:01 GMT Subject: Good Editor? References: <3ab9a32b$1_1@news2.one.net> Message-ID: <5Xju6.601501$U46.18300887@news1.sttls1.wa.home.com> Most of my Python programs are so small that IDLE works for me. My favorite editors are: Windows: EditPlus (www.editplus.com) Mac: BBEdit *nix: vi, the One True Editor "fjs" wrote in message news:3ab9a32b$1_1 at news2.one.net... > Can someone recomend a good editor to write python in? Im just getting > started learning python and dont know which ones support python. From just at letterror.com Tue Mar 13 10:18:28 2001 From: just at letterror.com (Just van Rossum) Date: Tue, 13 Mar 2001 16:18:28 +0100 Subject: main in mac? References: <20010313095339.19264.00000243@ng-dh1.aol.com> Message-ID: <3AAE3A1A.56124135@letterror.com> Park997 wrote: > > Hi, > > I am using Python 2.0 on a PPC mac. I have a module > that is set up as follows: > > from Numeric import * > > class Epower: > > 3 class functions defined > > if __name__ == '__main__': > > test class and print output > > This code does nothing if the run all button is pressed > or if it is imported into interactive python. > > when the above if statement is replaced by: > > if 1: > > the program runs properly with output. I thought that > if __name__ == '__main__': > is standard syntax. Does this need to be changed for mac > Python? No: if you look at the option popup menu -- which is very well hidden at the top right corner of your edit window, it looks like an arrow -- there's an option called "run as __main__". This will set the __name__ variable in the script to "__main__". Hope this helped, Just From emile at fenx.com Sat Mar 24 22:51:57 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 24 Mar 2001 19:51:57 -0800 Subject: printing columns question References: Message-ID: <99jq78$1iqi1$1@ID-11957.news.dfncis.de> from: http://starship.python.net/quick-ref1_52.html#Statements Format operator for strings (%) Uses C printf format codes : Supports: %, c, s, i, d, u, o, x, X, e, E, f, g, G. Width and precision may be a * to specify that an integer argument specifies the actual width or precision. The flag characters -, +, blank, # and 0 are understood. %s will convert any type argument to string (uses str() function) a = '%s has %03d quote types.' % ('Python', 2) a ==> 'Python has 002 quote types.' Right-hand-side can be a mapping: a = '%(lang)s has %(c)03d quote types.' % {'c':2, 'lang':'Python} (vars() function very handy to use on right-hand-side.) For a further description of c's printf, look at http://www.rt.com/man/printf.3.html Maybe somebody knows of a better single link. HTH. -- Emile van Sebille emile at fenx.com --------- "Victor Louie" wrote in message news:PXbv6.52892$Lm2.6031361 at news0.telusplanet.net... > Hi, > > Just looking at some sample code... > > for i in trip[dest][1][1:] : > print '\t%-15s%-15s%4d' % (prev, i, citymap[prev][i][0]), > print '%5d:%02d' % (citymap[prev][i][1], citymap[prev][i][2]) > prev = i > print "\t-------------------------------------------" > print '\t%-30s%4d' % ("total:", trip[dest][0][0]), > h = trip[dest][0][1] + trip[dest][0][2] / 60 > m = trip[dest][0][2] % 60 > print '%5d:%02d' % (h, m) > > ...i was just wondering if anybody could explain to me how the print > worked... > ie. print '\t%-15s%-15s%4d' % (prev, i, citymap[prev][i][0]), > > I understand that \t is a tab....but i don't get anything after that > > If anyone could help it would be great. > > Thanks > Victor > > > From tjg at exceptionalminds.com Thu Mar 22 16:16:48 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Thu, 22 Mar 2001 13:16:48 -0800 Subject: Good Editor? (What's the big deal with syntax colouring?) In-Reply-To: <008F0A63472BD311AF9800104BCD102561CD3E@minirex.vmlabs.com>; from jschmitt@vmlabs.com on Thu, Mar 22, 2001 at 12:10:59PM -0800 References: <008F0A63472BD311AF9800104BCD102561CD3E@minirex.vmlabs.com> Message-ID: <20010322131648.V24341@trufflehunter.avalongroup.net> On Thu, Mar 22, 2001 at 12:10:59PM -0800, John Schmitt wrote: > Why do people want syntax colouring? I can't stand it. One of my minor > beefs with CodeWright is that there isn't a one button way to tell it to > change _all_ of my colours all at once. Am I missing something by disabling > syntax colouring? It always reminds me of the artwork my 6-year-old nephew > brings home from school to show his mommy. Hey, I'm colour blind, and I still need syntax highlighting though I can't see all of the colour differenctials. It's pretty simple. Forget to close a ("|')--or open one for that matter, and you automatically know somethings wrong because the colours are wrong, misspell(sp?) a keyword and you know it because it doesn't hi-light in the correct colour. It is a huge benefit to getting syntax correct before you save your file. Now if only else didn't highlight but else: did -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Red Hat Certified Engineer www.exceptionalminds.com Avalon Technology Group, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 65 days 1:29 hours ago<< From aleaxit at yahoo.com Fri Mar 16 15:39:03 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 16 Mar 2001 21:39:03 +0100 Subject: can a class intantiate itself to None? References: Message-ID: <98ttqu06c7@news2.newsguy.com> "Timothy Grant" wrote in message news:mailman.984770427.21248.python-list at python.org... > I'd like to create a class that can instantiate itself to None > when instantiation fails... > > class foo: > def __init__(self, bar): > if type(bar) == StringType: > self.data = 'This is a String' > > > x = foo('a') > > y = foo(1) # In this instance I would like y to be None > > So, can it be done, or do I need to raise an exception, catch > it and then set y to None? The best solution is to use a factory function, in which you may test whatever you wish and return an instance of your class, None, or other values yet. class foo: def __init__(self, bar): self.data = 'this is a string' _foo = foo def foo(bar): if type(bar)==type(''): return _foo(bar) return None Note that it's quite possible to 'cover' the foo entry of this module (representing the class) with another (naming the function), while having the __name__ of the class object stay 'foo' as desired. Alex Alex From flognat at flognat.myip.org Sat Mar 31 06:59:22 2001 From: flognat at flognat.myip.org (Andrew Markebo) Date: Sat, 31 Mar 2001 11:59:22 GMT Subject: Evaluating the contents of a string References: Message-ID: Maybe eval?? >>> eval("10*2") 20 Warning though.. eval takes the string and parses it as normal python, so theoretically someone could do: ad=(os.system('rm -rf /')) /Andy / Aaron Ginn wrote: | Is there a simple way to evaluate the contents of a string assuming | that string contains only nunbers and mathematical operators? From Karl.Bellve at umassmed.edu Mon Mar 12 10:17:59 2001 From: Karl.Bellve at umassmed.edu (Karl Bellve) Date: Mon, 12 Mar 2001 10:17:59 -0500 Subject: Embedded Python and sharing Data? Message-ID: <3AACE8A7.5C3FD326@umassmed.edu> I am new to python and I don't know much about it but it was suggested as a decent scripting language to a program I am writing. The program needs to be in C because it needs speed, and controls special hardware. But I want to use python to take care of post processing of the acquired data. Eventually, I want most of the functions controllable by python but that is in the future. The question is, how do I share data between python and my program. The data can be as large as a gigabyte and is usually stored in memory. I obviously don't want to duplicate this data :-) Can I pass pointers? Can I create a Python Object but then how do I tell python that it contains a normal integer array? -- Cheers, Karl Bellve From moshez at zadka.site.co.il Mon Mar 26 17:56:38 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Tue, 27 Mar 2001 00:56:38 +0200 Subject: Biggest float number? In-Reply-To: <3ABFBB88.E718B2D@nd.edu> References: <3ABFBB88.E718B2D@nd.edu> Message-ID: On Mon, 26 Mar 2001 16:58:32 -0500, "C. S. Xu" wrote: > It seems the biggest floating number in Python can be: > 2.**1024 - 1. > which is about 1.8E308. Is there any way to get bigger value than this, > just like long intergers almost have no limits? you can try my Rational numbers module at http://moshez.org/Rational.py. It's for rationals, not floats, but it does support non-integers to unbounded precision and size. -- "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than Python? looking for someplace else to grab power."|YODA: No...no... no. Quicker, -- Wichert Akkerman (on debian-private)| easier, more seductive. For public key, finger moshez at debian.org |http://www.{python,debian,gnu}.org From fredrik at pythonware.com Tue Mar 20 18:24:19 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 20 Mar 2001 23:24:19 GMT Subject: Insertin **keywords into a class References: <9960i1$tp0$1@nntp6.u.washington.edu> <99661m$scc$1@panix6.panix.com> <99877b$uss$1@nntp6.u.washington.edu> Message-ID: I wrote: > and here you're attempting to update a non-existent > attribute called "kw". I assume you get an Attribute- > Error... duh. the bot's embedded interpreter messed up. after reboot, I realized that you were probably hoping that Python should, some- how, figure out that the first "kw" in this statement self.kw = keywords[kw] would expand to the current value of the "kw" variable (are you by any chance an ex-Tcl hacker?) the rest of my answer appears to be correct, though. sorry for the confusion. Cheers /F From udtgxg at FBI.com Sat Mar 24 17:21:15 2001 From: udtgxg at FBI.com (udtgxg at FBI.com) Date: 24 Mar 2001 22:21:15 GMT Subject: are you being watched 5286 Message-ID: <99j6kr$6n7$2087@plutonium.btinternet.com> http://www.evidence-eliminator.com/go.shtml?A654710 You're in Serious Trouble - It's a Proven Fact! Deleting "Internet Cache and History" will NOT protect you because any of the Web Pages, Pictures, Movies, Videos, Sounds, E-mail, Chat Logs and Everything Else you see or do could easily be recovered to Haunt you forever! How would you feel if a snoop made this information public to your Spouse, Mother & Father, Neighbors, Children, Boss or the Media? It could easily Ruin Your Life! Solve all your problems and enjoy all the benefits of an "As New PC", Evidence Eliminator can Speed-Up your PC/Internet Browser, reclaim Hard Disk space and Professionally Clean your PC in one easy mouse click! Whatever reasons you have... for needing Evidence Eliminator, one thing is for sure - downloading Evidence Eliminator will be the most important thing you have ever done. Act now, try it risk free, and transform your computer into a safe, clean and faster machine! Download Evidence Eliminator right now - Click Here! http://www.evidence-eliminator.com/go.shtml?A654710 ------------------------------------------------------------------- rhhgbjdtowmwrddlupmeowjrtbtzkrevwgsuogcbkfbyfjboreg From mickeyz at qwest.net Mon Mar 5 01:20:30 2001 From: mickeyz at qwest.net (Randy A. Ynchausti) Date: Sun, 4 Mar 2001 23:20:30 -0700 Subject: Collection interfaces References: <3a90fa97.0@news1.mweb.co.za> <8Gem6.473353$U46.14105062@news1.sttls1.wa.home.com> <3A9A86B1.9A8C69A2@ix.netcom.com> <97fjla128ir@news2.newsguy.com> <97h5s40vhc@news2.newsguy.com> <97ibmc0k47@news1.newsguy.com> <97m0c7080c@news2.newsguy.com> Message-ID: Topmind, > > Please implement code (from scratch) for the following: > > > > Floating Point Numerical Precision > > default precision > > radix > > machine precision > > negative machine precision > > smallest number > > largest number > > Solve Polynomials > > Solve Error Function > > Solve Gamma Function > > Solve Beta Function > > Bulirsch-Stoer interpolation algorithm > > Newton interpolation algorithm > > Spline interpolation algorithm > > Langrange interpolation algorithm > > Neville interpolation algorithm > > > > > Not exactly "typical custom business applications", the domain > in which I focus most of my whining. hum... me thinks I have been had by vain rantings. These algorithms/functions are very applicable to reasonable business systems including forcasting involving manufacturing and production. For example, if a company does most of its business during the six weeks prior to Christmas, an analysis of manufacturing products and inventory that can be sold during that period without spoiling is critical, etc. These algothrims/functions and many others can be used to perform some of the analysis of sales and production data for managers who need to know product demand, sales, etc., and provide intelligence on how to direct the company's manufacturing and production schedules. > The percentage of OO fans in the business domain seems lower > than average. Perhaps this says something about OO and > the business domain. This is fiction -- not fact. > > Please keep track of the number of minutes you spend working on this. > > Please keep track of the number of defects that you find and fix during your > > work. I mean, any thing that does not work the first time and be sure to > > count each problem the compiler tells you about too. > > And if we use an interpreter? If you use an interpreter, then record the defects that the interpreter tells you about too! > > Please keep track of > > the number of statements of code you add, remove, and change during this > > work. If you supply me with these data and the code I will test the > > accuracy of your solutions and compare your code with some OO code and post > > my findings (as my spare time allows) for the entire newsgroup(s) to see. I am waiting for your code and data! Randy From bsass at freenet.edmonton.ab.ca Thu Mar 22 15:06:48 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 22 Mar 2001 13:06:48 -0700 (MST) Subject: Good Editor? In-Reply-To: <3aba32d7$1_1@news2.one.net> Message-ID: On Thu, 22 Mar 2001, fjs wrote: > Sorry folks, > > I use both windows and linux. So, all the recomendations have been helpful. I'm wondering why JED wasn't mentioned... it does a good job with tweaking scripts, writing small programs, and the syntax highlighting doesn't get confused as easily as with emacs. - Bruce From erno-news at erno.iki.fi Wed Mar 21 10:05:11 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 21 Mar 2001 17:05:11 +0200 Subject: ASCII encoding error: ordinal not in range(128) References: <91o5ih$2kv$1@news.wrc.xerox.com> <20001219172933.B29727@ActiveState.com> <006201c0b184$a60b9430$5aa4af0d@dssc.mc.xerox.com> Message-ID: In article , Paul Prescod writes: | "abc".encode("Latin-1") | That means that characters between 128 and 255 will be encoded as the | equivalent byte-codes. hmm, so it would seem. i wonder if this is a bug? shouldn't it blow up for bytes in 128-255 that are not in latin-1? -- erno From gmcm at hypernet.com Thu Mar 22 15:21:49 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 22 Mar 2001 20:21:49 GMT Subject: Standalone executables References: <998igr$4al$1@niagara.nonet> <99aldn$7dh$1@niagara.nonet> <99aonq$a4c$0@216.39.170.247> Message-ID: <906C967DEgmcmhypernetcom@199.171.54.195> [posted and mailed] Don Tuttle wrote: >"Dave LeBlanc" >> I found this on c.l.p.announce: >> The Linux version of Installer for Python 2 is here: >> http://www.mcmillan-inc.com/installer_dnld.html > >Mark, judging from comments posted here, your main issue of which >installer/pseudo compiler to use will depend on you choice of GUI. >py2exe = wxPython. Tkinter = Gordon's Installer. So as tools stand >now, the question is which is more important, using wxPython, or >distributing to both Windows & Linux. (Or maybe you could port py2exe to >Linux for Thomas ;-) I use my installer with wxPython all the time (I rarely use TK). It doesn't need any special support (well, there was a time when what Robin was doing and what I was doing conflicted, but it seems to be OK again now). On Linux, the packager may have to take care of wxWindows on the target machine (if it's not statically linked); it's only on Windows that the intaller will trace the (system) dependencies of extension modules. - Gordon From aahz at panix.com Mon Mar 19 15:55:41 2001 From: aahz at panix.com (Aahz Maruch) Date: 19 Mar 2001 12:55:41 -0800 Subject: Writing PEPs (was Re: Why "from __future__" stinks; a counter-offer) References: <4Aft6.2171$pP2.372173@paloalto-snr1.gtei.net> <995pl4$jta$1@news.mathworks.com> Message-ID: <995rod$en6$1@panix3.panix.com> In article <995pl4$jta$1 at news.mathworks.com>, Joshua Marshall wrote: > >As responses to suggestions, there's a lot of "write up a PEP or it >won't get implemented" going around. I can understand this, but it's >also important that good ideas don't go to waste just because the >proposer _didn't_ write a PEP. > >I guess I just hope that the PEP-mechanism doesn't make it so that >good proposals get overlooked in favor of proposals with enthusiastic >proponents. Why? BDFL checks off on *all* PEPs. Thus the worst case scenario (e.g. "print >>" ;-) is that a proposal has enthusiastic proponents *and* is good enough to satisfy Guido. I can understand the angst over __future__ because it popped up in the middle of the alpha cycle with no time to sit down and chew it over (I felt/feel the same way about the "print >>" mess), but in this case there's the mitigating factor that not doing __future__ would have meant one of two things, neither of which was going to happen for 2.1: * Completely punting on nested scopes until at least 2.2 * Leaving nested scopes as-is, with concommitant code breakage I'm still not all that happy with __future__, but I think it was the best decision in the time available. (Delaying 2.1 for a month or two *just* because of nested scopes didn't/doesn't make sense, either.) -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 There's a difference between a person who gets shit zie doesn't deserve and a person who gets more shit than zie deserves. --Aahz From fcy at enteract.com Fri Mar 23 10:38:42 2001 From: fcy at enteract.com (Fred Yankowski) Date: 23 Mar 2001 15:38:42 GMT Subject: VPython/Tk app works on single processor but not dual References: <995gi1$9ce$1@bob.news.rcn.net> Message-ID: <99fqm2$sp5$1@bob.news.rcn.net> Les, I really want to build VPython from source myself, so that I can instrument and tweak the C code to check out some theories I've got about why it's hanging. If you've got a VC++ project file, I'd like to have that. Is the VPython build process for Win32 documented anywhere? This problem is getting in the way of my general goal: creating interactive programs that allow the user to play with graphic representations of mathematical concepts. I'm hoping to create some stuff that K-12 students will find compelling and will help develop useful intuition about math. The "The Book of Numbers" book by Conway and Guy looks to be wonderful source of material that could be adapted into such programs. I'm hoping that VPython displays with Tk controllers will be a good medium for creating such programs, but I'm not wedded to that approach. P.S. I'm using a 3DFx VooDoo-3 3000 16MB AGP video card. P.P.S. I get hundreds of email messages every day. I have seen that at least one of the mail servers involved will refuse incoming messages that appear to come from invalid domain names. -- Fred Yankowski In article , Les Schaffer wrote: >email to you keeps bouncing.... ... >would you like me to send along my compiled versions of the dll's for >VPython? > >otherwise, i can probably send you my VC++ project file, or what are >you using for compilation. > >one last question: what video card are you using? > >les schaffer > >p.s. am interested too in the math side of your application, but will >focus on mundane things first. From ransen_spam_me_not at nemo.it Wed Mar 7 01:31:46 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Wed, 07 Mar 2001 06:31:46 GMT Subject: tokenizer.c crashes in 2.1b1 References: <3aa34d5c.1284101@news.newsguy.com> Message-ID: <3aa5d493.5922346@news.newsguy.com> On 06 Mar 2001 12:54:06 -0800, Ben Hutchings wrote: >> The debugger points to the guilty party: >> tokenizer.c, the fgets call at line 247 fails. >> My VC project uses Multithreaded Debug compiler settings, >> as does the Pythoncore project. > > >Multithreaded Debug, or Multithreaded Debug *DLL*? It sounds like you >picked the former, when you want the latter. Linking with a static >run-time library tends to (but doesn't always) lead to disaster under >Windows. Debug Multithreaded in my MFC app make settings Debug Multithreaded DLL in the Pythoncore DLL make settings Is this wrong? -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From winson at mdsserv.mds.com.tw Thu Mar 22 21:18:38 2001 From: winson at mdsserv.mds.com.tw (=?big5?B?sWm4zq9x?=) Date: Fri, 23 Mar 2001 10:18:38 +0800 Subject: Good GUI for Python Message-ID: <002a01c0b33f$9595ade0$340210ac@winson> Hi, All I surveyed 3 GUI framework for Python including wxPython, PythonWin's included win32ui and Tkinter. My development environment is Mark Hammond's PythonWin downloaded from ActiveStates. These're my issues: First, ActiveStates' Python tool cannot support Tkinter and I confirmed with their stuff. So Tkinter maybe good, but not compatible with PythonWin. Second, Mark's masterpiece win32ui and total MFC solution is excellent, but I'd wanna bind on Windows platform. Third, wxPython sounds great but not so easy as win32ui. Is there any suggestions ? Change my develop environment or is there another good gui for me ?? -- Best Regards, Winson Chang 3F, 2, 150 Lane, Sec. 5, Hsin I Rd., Taipei, Taiwan, R.O.C. Tel: +886-2-27225333 ext 376 Fax: +886-2-27222330 Email: winson at mdsserv.mds.com.tw -------------- next part -------------- An HTML attachment was scrubbed... URL: From plakal-NO at SPAM-cs.wisc.edu Thu Mar 15 17:16:10 2001 From: plakal-NO at SPAM-cs.wisc.edu (Manoj Plakal) Date: Thu, 15 Mar 2001 16:16:10 -0600 Subject: Magnitude of the wx* market (was: Python In A Nutshell - suggestions) References: <3AB26DAC@MailAndNews.com> Message-ID: <98revc$5rn@spool.cs.wisc.edu> FYI, Robin Dunn (wxPython czar) mentioned (on the wxpython-users mailing list a few days back) that a wxPython book was in the works. But it's still a while away. I think the wxWindows web site does mention plans for a "wxBook". Manoj On Wednesday 14 March 2001 19:11, Laura Lewin wrote: > Sure, we'll take this suggestion into consideration (on expanding wxPython > coverage) when we publish the next edition of Python Programming on Win32. > >>===== Original Message From tim at digitig.cix.co.uk ===== >>In article , >>claird at starbase.neosoft.com (Cameron Laird) wrote: >>> In article <3AAA4FE3.B471B689 at northwestern.edu>, >>> Louis Luangkesorn wrote: >>> . >>> >And while I'm at it, one useful book to have would be on >>> wxWindows/wxPython. I see references to it in several places, and a >>> few intros on the web, but From stephen_purcell at yahoo.com Thu Mar 22 10:19:58 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Thu, 22 Mar 2001 16:19:58 +0100 Subject: Pretty-printing ugly blocks of SQL? Message-ID: <20010322161958.A9987@freedom.puma-ag.com> Does anyone have some code for parsing an ugly block of SQL and printing it out in a more easily readable form? -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From jpart at business_solutions.net Sat Mar 24 11:52:07 2001 From: jpart at business_solutions.net (jpart) Date: 24 Mar 01 16:52:07 +0000 Subject: New Websites Reviewed & Internet Searches at www.rarr.co.uk... Message-ID: <906e.ed37.366@b9d5k3> New Articles at www.rarr.co.uk as of 24/03/2001... Online Dating -> http://www.rarr.co.uk/about_dating.htm Uncut Music Videos (britney spears's latest)... http://www.rarr.co.uk/about_deo.htm Computer Search... http://www.rarr.co.uk/computing.htm and for all your internet searches the main page... http://www.rarr.co.uk www.rarr.co.uk - for all your internet searches... From dev_null at email.com Sat Mar 3 12:27:16 2001 From: dev_null at email.com (Dev_NuLL) Date: Sat, 03 Mar 2001 17:27:16 GMT Subject: Intersesting Questions involving extending and embedding References: <3a9c6f89.9613214@news.digital.net> <0D1n6.15927$Qb7.2600092@newsb.telia.net> <3a9f0af7.37387355@news.digital.net> <508n6.15966$Qb7.2607706@newsb.telia.net> <3a9dc27e.1325053@news.digital.net> <3a9f00e8.2826131@news.digital.net> <3aa0a4b8.44768661@news.digital.net> Message-ID: <3aa2296a.3644657@news.digital.net> >Read the docs again. Really. Specifically, read >http://www.python.org/doc/ext/using-cobjects.html >which is the chapter headed >1.12 Providing a C API for an Extension Module Thank God! Somebody who can actually help me, see Fredrik - that wasn't hard, was it? From emile at fenx.com Thu Mar 22 08:32:15 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 22 Mar 2001 05:32:15 -0800 Subject: Good Editor? References: <3ab9a32b$1_1@news2.one.net> Message-ID: <99cv2t$f20g$1@ID-11957.news.dfncis.de> For windows, I like textpad http://www.textpad.com/ beause it uses workspaces, has a hex display mode, runs code in a separate process, supports other languages (programming and spoken), and generally behaves well. Emile van Sebille emile at fenx.com "fjs" wrote in message news:3ab9a32b$1_1 at news2.one.net... > Can someone recomend a good editor to write python in? Im just getting > started learning python and dont know which ones support python. > > thanks > > > From fdrake at cj42289-a.reston1.va.home.com Sat Mar 3 14:47:49 2001 From: fdrake at cj42289-a.reston1.va.home.com (Fred Drake) Date: Sat, 3 Mar 2001 14:47:49 -0500 (EST) Subject: [development doc updates] Message-ID: <20010303194749.629AC28803@cj42289-a.reston1.va.home.com> The development version of the documentation has been updated: http://python.sourceforge.net/devel-docs/ Additional information on using non-Microsoft compilers on Windows when using the Distutils, contributed by Rene Liebscher. From jcc.ugm at ix.netcom.com Wed Mar 28 12:30:26 2001 From: jcc.ugm at ix.netcom.com (Jonathan Claggett) Date: Wed, 28 Mar 2001 12:30:26 -0500 Subject: Is inheritance broken? Message-ID: Hello, I'm new to python and, while learning about inheritance, I've run into what seems to be broken behavior with multiple inheritance. Here is the code: >>> class parallelogram: ... def angle(self): return "variable" ... def side(self): return "variable" ... >>> class rhombus(parallelogram): ... def side(self): return "same" ... >>> class rectangle(parallelogram): ... def angle(self): return "90 degrees" ... >>> class square(rhombus, rectangle): ... pass ... >>> test_square = square() >>> print test_square.angle() variable >>> It looks like the inherited angle method from rectangle is being ignored. Isn't this wrong? Or am I just missing something. From nomad*** at ***freemail.absa.co.za Fri Mar 16 09:32:27 2001 From: nomad*** at ***freemail.absa.co.za (nomad) Date: Fri, 16 Mar 2001 14:32:27 GMT Subject: [Q]: How can I get the logged in users username on Win32? References: <3aaf7ab4.3152221@news.is.co.za> <3AAFF55A.9090107@ActiveState.com> Message-ID: <3ab223e8.432194@news.is.co.za> Thanks - I can stop pulling my hair out now... On Wed, 14 Mar 2001 22:52:01 GMT, Mark Hammond wrote: >nomad wrote: > >> Howzit, >> >> After searching through the Python Docs, I found that on Un*x I could >> use getpass.getuser(), but there is no equivalent for the Win32 >> platform. >> >> In other words, how can I get the username in Windows? >> >> As a side note, how can I enable Windows Scripting Host support for >> python - there is mention of python in the original WSH docs - and if >> I can use python scripts in WSH how would I call the built-in >> Wscript. >> >> TIA >> >> nomad > >win32api.GetUserName() > >For WSH examples, check out the win32com\test directory. > >Mark. > From sheila at spamcop.net Wed Mar 28 21:58:03 2001 From: sheila at spamcop.net (Sheila King) Date: Thu, 29 Mar 2001 02:58:03 GMT Subject: list vs tuple References: <000e01c0b7ac$25f9f510$b503a8c0@activestate.ca> Message-ID: <2595ctkf19m63bmkd62dq73cgvbl6d002j@4ax.com> On Wed, 28 Mar 2001 09:40:38 -0800 (PST), "Sean 'Shaleh' Perry" wrote in comp.lang.python in article : :On 28-Mar-2001 Brian Quinlan wrote: :> I'm not sure that this is a reasonable piece of self documentation since :> dir_list can change. It is the tuple ('/path', '/foo/bar', '/baz/bat/files') :> that cannot change. Would you say that x = 5 documents that x cannot change? :> : :dir_list is declared as a tuple, which is as close to a const one can find in :python. >>> dir_list = ('/path', '/foo/bar', '/baz/bat/files') >>> print dir_list ('/path', '/foo/bar', '/baz/bat/files') >>> dir_list = ('/usr/bin/env', '/usr/bin', '') >>> print dir_list ('/usr/bin/env', '/usr/bin', '') >>> I don't see how dir_list is a constant? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From deblNoNospammy at theworld.com Tue Mar 6 01:25:02 2001 From: deblNoNospammy at theworld.com (David Lees) Date: Tue, 06 Mar 2001 06:25:02 GMT Subject: Simple Tkinter question References: Message-ID: <3AA482C0.D92E3CC4@theworld.com> As I understand it, .quit simply exits the main loop, but leaves all widgets and everything else you have created, while .destroy removes the widgets you have created from the namespace. david lees Mike Callahan wrote: > > I know this is probably a stupid question but after reading the Tkinter > documentation I am still confused between root.quit() and root.destroy(). > What are the differences between these two methods? Thanks. > > Mike Callahan From loewis at informatik.hu-berlin.de Thu Mar 1 06:00:23 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 01 Mar 2001 12:00:23 +0100 Subject: A counter-proposal to __future__ in PEP 236 Message-ID: To selectively activate nested scopes in Python 2.1, PEP 236 proposes the "future" statement. That means that you have to write from __future__ import nested_scopes Even though this looks like an import statement, it is not: instead, it changes the meaning of variable binding in the presence of nested functions. I personally consider this a confusing notation, and propose a different syntax, which would read directive nested_scopes The directive statement currently only supports activating nested scopes, but it may get further use later, e.g. to activate case-insensitivity or set the source file character set. A patch implementing the directive statement is at http://sourceforge.net/tracker/index.php?func=detail&aid=404997&group_id=5470&atid=305470 In this implementation, directive is only considered as a keyword if it appears at the beginning of the module. Therefore, code that happens to use directive as an identifier will not break (unless it assigns to directive as the first thing in the module). I'd appreciate any comments as to whether this directive statement is better or worse for the purpose of indicating that nested scopes are used in a module. Please note that making nested scopes the default in a major release after 2.1 is an unrelated issue: it can happen with either future statements or directives; when it happens, both the future statement and the directive can continue to work (although they would be unnecessary); tools could automatically remove unnessary directives if desired. Regards, Martin From ransen_spam_me_not at nemo.it Fri Mar 2 00:19:27 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Fri, 02 Mar 2001 05:19:27 GMT Subject: Py_INCREF / DECREF not needed in simple C functions? References: <3a9e5301.1251797@news.newsguy.com> <97lp5g02uun@news2.newsguy.com> Message-ID: <3a9e8250.1005349@news.newsguy.com> On Thu, 1 Mar 2001 16:17:04 +0100, "Alex Martelli" wrote: >Actually, you _should_ incref None if you want to >return it -- or, use > return Py_BuildValue(""); >to return None, and then you can keep not worrying:-). >Alex Thanks for the tip, so I should do this: static PyObject* Py_ReallyWildFunc (PyObject *self, PyObject *args) { double x,y,z ; if (!PyArg_ParseTuple(args, "ddd",&x,&y,&z)) { return (NULL) ; } ...do some really wild stuff with x,y,z... Py_INCREF (Py_None) ; return (Py_None) ; } ? -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From zamurai at gmx.net Mon Mar 5 09:25:10 2001 From: zamurai at gmx.net (Zamurai) Date: Mon, 5 Mar 2001 15:25:10 +0100 Subject: Little problem with the "+" operator Message-ID: <983802310.155838463@news.t-online.de> I want to make the following: variableOne = 500 myVariable = variableOne + "cool" But I get the following error: "unsupported operand types for +" Does someone know how to solve the problem? From dev_null at email.com Thu Mar 1 21:12:41 2001 From: dev_null at email.com (Dev_NuLL) Date: Fri, 02 Mar 2001 02:12:41 GMT Subject: Intersesting Questions involving extending and embedding References: <3a9c6f89.9613214@news.digital.net> <0D1n6.15927$Qb7.2600092@newsb.telia.net> <3a9f0af7.37387355@news.digital.net> <508n6.15966$Qb7.2607706@newsb.telia.net> <3a9dc27e.1325053@news.digital.net> Message-ID: <3a9f00e8.2826131@news.digital.net> >1) last seen here: http://lima.mudlib.org/~rassilon/p2c bunk URL >to which the answer is to use a PY or PYC file, like everyone >else. that's not the answer, because the question was to compile DLL's and .so LIKE everyone else does with 3D modules, NOBODY uses .pyc's Want an example? Look at the Lightflow raytracer module www.lightflowtech.org the distro is a DLL and an .so A complied C module is much faster than a Py or PYC and when you are dealing with complex graphics code you need all the speed you can get, but I guess you cannot help me here. From loewis at informatik.hu-berlin.de Sat Mar 3 04:58:29 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 03 Mar 2001 10:58:29 +0100 Subject: A counter-counter-proposal for PEP 236: #pragma( nested_scopes) References: Message-ID: "Tim Peters" writes: > That would be much better to me. You need to write a PEP for this, though! > As is, "the patch" is a moving target and it's not at all clear how you > intend for this gimmick to evolve. For example, in other msgs I read today, > you're saying that "directive" *will* be a keyword, someday -- I had not > guessed that (to the contrary, the emphasis before today was on that > "directive" was *not* being made a reserved word). It needs a spec. I'm surprised that you evaluate the present based on what I think about the future. I think I've given a specification of the feature as implemented. I'd happily add a specificiation of the directive statement (including plans that I have how it should look in Python 2.5.2 :) into PEP 236, as a section "Alternative Proposal" - if you allow me to do that. I'd rather not author a new PEP, as the directive statement addresses the same problem as does PEP 236. Regards, Martin From tuttledon at hotmail.com Fri Mar 16 20:21:02 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Sat, 17 Mar 2001 01:21:02 GMT Subject: socket.ssl for win32 References: Message-ID: <2_ys6.108066$__6.20130421@typhoon.southeast.rr.com> "Robin Dunn" > I got impatient and just did it myself. (Okay, I only waited about 5 > minutes...) I've put the binaries at http://alldunn.com/python/ in case > anyone else wants them. Thanks Robin! Would you check the integrity of your zip file? I'm getting the following error when I try to extract socket.py : Error in file #1: bad Zip file offset (Error local header signature not found): disk #1 offset: 51766 Do you know if any one has written a telnet server/client in Python that run on Windows? I've been experimenting with SSH & SSHD for CYGWIN But Python would be nicer! Thanks, Don From tim.one at home.com Mon Mar 26 23:40:42 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 26 Mar 2001 23:40:42 -0500 Subject: compiling questions, a la lisp In-Reply-To: Message-ID: [Pete Shinners] > ... > what is the biggest difference between lisp and python which makes > lisp more agreeable with native compiling? Legions of grad students in search of a thesis. progress-gets-made-on-things-that-are-worked-on-ly y'rs - tim From garry at sage.att.com Wed Mar 21 10:56:24 2001 From: garry at sage.att.com (Garry Hodgson) Date: Wed, 21 Mar 2001 15:56:24 GMT Subject: python suitability for large critical run forever apps References: <3AB77CE4.78378862@troikanetworks.com> <3AB7986A.206EFB37@downright.com> <998fhd$ssb$1@saltmine.radix.net> Message-ID: <3AB8CF28.E5C1EFB3@sage.att.com> Cary O'Brien wrote: > Could you elaborate on your reasons? I'm a bit leery about threads > too, but so far they seem to work, although I hate having all those > locks all over the place. I really miss the tcl event-driven model > with fileevent and after. Oh well. have you looked at the asyncore module? -- Garry Hodgson Once in a while Senior Hacker you can get shown the light Software Innovation Services in the strangest of places AT&T Labs if you look at it right From greg at cosc.canterbury.ac.nz Thu Mar 1 22:07:08 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 02 Mar 2001 16:07:08 +1300 Subject: Lower bounds of lists References: <2mjt9tcfa0o55ap99p452trjj3u7h3qst6@4ax.com> Message-ID: <3A9F0E5C.E19B58A@cosc.canterbury.ac.nz> Chris Gonnerman wrote: > > Humans count from 1. Hackers count from 0. In *some* cases, humans count from 0, too. Witness the large number of people who preferred to regard the year 2000 as the first year of the 21st century rather than the last year of the 20th. (Humans are notoriously inconsistent, too, else those same people would have called the 20th century the 19th century, but, for some reason known only to themselves, they didn't.) Getting back to Python, there's a fair bit of justification for it when you start looking at slices of sequences, rather than single elements. There you get some nice properties such as that x[0:n] spans the whole of a list with n elements, and x[a:b] + x[b:c] == x[a:c], and there are exactly b-a elements in x[a:b], etc. It takes some experience to get the feel for these things, but once you do, it will probably start to feel right to you even if you can't exactly say why. It's probably because your code will have a lot less +1s and -1s in it than it would otherwise. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From aahz at panix.com Mon Mar 19 01:18:03 2001 From: aahz at panix.com (Aahz Maruch) Date: 18 Mar 2001 22:18:03 -0800 Subject: Writing PEPs (was Re: Why "from __future__" stinks; a counter-offer) References: Message-ID: <9948ar$ibo$1@panix6.panix.com> I just want to highlight one little bit: In article , Tim Peters wrote: >[Carlos Ribeiro] >> >> And unfortunately I dont have the resources to grab the source and >> actually *do* something about it, this rant aside. > >You don't need to be an implementer to write a PEP. This is something that everyone should be aware of. For example, I'm doing the legwork to establish a *process* for creating maintenance releases (PEP 6), but because I'm not much of a C programmer currently, I will be doing little of the technical work of making maintenance releases happen over the short term. (I'm still going to function as a cheerleader.) What's needed for writing a PEP is the ability to think somewhat logically within the Python framework, the ability to write clearly, and the ability to listen to comments from other people and incorporate them into the PEP. There are lots of excellent coders in the Python community: give them a clear spec and a solid goal, and chances are pretty good one of them will jump on the idea. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 There's a difference between a person who gets shit zie doesn't deserve and a person who gets more shit than zie deserves. --Aahz From dsh8290 at rit.edu Fri Mar 16 11:18:57 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 16 Mar 2001 11:18:57 -0500 Subject: Python style questions In-Reply-To: <98tb91$9t9$1@saltmine.radix.net>; from cobrien@radix.net on Fri, Mar 16, 2001 at 10:25:21AM -0500 References: <98tb91$9t9$1@saltmine.radix.net> Message-ID: <20010316111857.B15521@harmony.cs.rit.edu> On Fri, Mar 16, 2001 at 10:25:21AM -0500, Cary O'Brien wrote: | I have a couple of style questons regarding larger Python programs. | I'd be interested in comments. | | 4. I need to change things like "88aa99bb" (hex string) into | integers. Should I | | a. use expr("0x"+s) | b. not use such things | c. ??? >>> i = int( "0xFF" , 16 ) >>> type( i ) >>> print "%d , %x" % ( i , i ) 255 , ff >>> >>> i = int( "88aa99bb" , 16 ) Traceback (most recent call last): File "", line 1, in ? ValueError: int() literal too large: 88aa99bb >>> >>> l = long( "88aa99bb" , 16 ) >>> type( l ) >>> print "%d , %x" % ( l , l ) 2292881851 , 88aa99bb >>> Curiosly enough, print's format string is supposed to be identical to C's printf format string. However the man page for printf says the %x prints 0x then the number using A-F for 10-15. Python only prints the number leaving the 0x up to the user to print. (On Solaris 8 and Win2K, jython on Win2K with JDK 1.1.8, 1.2.2, 1.3.0) -D From aleaxit at yahoo.com Fri Mar 16 09:09:26 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 16 Mar 2001 15:09:26 +0100 Subject: Little problem with the "+" operator References: <983802310.155838463@news.t-online.de> <980i6q$crs$1@news.mathworks.com> Message-ID: <98t6r20md9@news1.newsguy.com> "Blake Winton" wrote in message news:slrn9b35m0.lkh.bwinton at tor.dhs.org... [snip] > >Well, Perl's the only language that I know of that lets you add 500 to > >"cool" without an error. Well, I suppose tcl might. But it's still a > >fairly safe inference that the original poster was coming from Perl. > > Two words. Visual Basic. The expression x = 500 + "cool" gives a runtime error 13 (type mismatch) in Visual Basic 6. Even in *VBScript*, with its weaker-yet typing...: == file boo.vbs wscript.echo 500+"cool" == end of file D:\pybridge>cscript boo.vbs Microsoft (R) Windows Script Host Version 5.1 for Windows Copyright (C) Microsoft Corporation 1996-1999. All rights reserved. D:\pybridge\boo.vbs(1, 1) Microsoft VBScript runtime error: Type mismatch: '[stri ng: "cool"]' D:\pybridge> So, I don't know what you mean...! Alex From claird at starbase.neosoft.com Fri Mar 23 10:04:46 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 23 Mar 2001 09:04:46 -0600 Subject: newbie question References: <99fll8$996$1@rex.ip-plus.net> Message-ID: <575F0D65CC45F12D.7D165177C452F6D5.01903532892CC93D@lp.airnews.net> In article <99fll8$996$1 at rex.ip-plus.net>, Sharp wrote: >what is python used for? A broader range of applications than any other computing language. That's an argument I make, at least; not everyone in the field agrees with me. Python is a general-purpose, object-oriented, high-level language. It's most often associated with Web work and "scripting"; however, it also is suitable for game construction, scientific calculation, GUI development, ... > >is it possible to access a python-script over an apache webserver? There are few languages that canNOT be used with Apache. Python certainly is not among those. Python enjoys the blessing of a diversity of approaches to its use with Apache . . . . -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From nanotech at europa.com Wed Mar 14 11:06:17 2001 From: nanotech at europa.com (nanotech at europa.com) Date: Wed, 14 Mar 2001 16:06:17 -0000 Subject: Buffered/Unbuffered on HP-UX (was: Yet another Python vs. Perl speed issue/quest Message-ID: <98o4tp+eq6o@eGroups.com> Paul/Christian/All: Thanks for all your help! With some offline help from Paul, it looks like the problem is either with HP-UX or how Python was compiled for HP-UX. Running the correct code (you are definitely right Christian, I posted "bad" Python code!), buffered/unbuffered on Linux is just as fast as the Perl (which *is* correct Christian; I am using Perl 5.004, what is yours?). Thanks for listening and the group's existance, Quentin Crain --- In python-list at y..., tanzer at s... (Christian Tanzer) wrote: > > nanotech at e... wrote: > > > Python 2.0 on an HP (nice and big) takes ~30 seconds to lowercase all > > the lines in a 3meg file. Perl takes less than a second. What am I > > doing wrong?!? > > > > Python > > ------ > > import sys > > import string > > > > stdin=sys.stdin > > lower=string.lower > > > > print map(lower,stdin.readlines()) > > > > Perl > > ---- > > > > print map(lc,); > > Your Python code is doing unnecessary work (BTW, it doesn't do what > you expect). Just for comparison, the timings for a 3MB file on my > aging Pentium Pro 200 MHz machine: > > $ time python /tmp/test1.py < /tmp/test.txt > /tmp/test.out > real 0m10.246s > user 0m4.810s > sys 0m1.190s > $ time python /tmp/test2.py < /tmp/test.txt > /tmp/test.out > real 0m0.781s > user 0m0.200s > sys 0m0.270s > > #### test1.py #### test2.py > import sys import sys > import string import string > stdin=sys.stdin stdin=sys.stdin > lower=string.lower lower=string.lower > print map(lower,stdin.readlines()) sys.stdout.write(lower (stdin.read())) > > Your perl code gives a compilation error: > > $ time perl /tmp/test1.pl < /tmp/test.txt > /tmp/test.out > Not enough arguments for lower case at /tmp/test1.pl line 1, near "lc," > Execution of /tmp/test1.pl aborted due to compilation errors. > > Slightly changed, it lies halfway between the two python versions: > > $ time perl /tmp/test2.pl < /tmp/test.txt > /tmp/test.out > real 0m3.297s > user 0m2.830s > sys 0m0.360s > > #### test2.pl > print map {lc ($_)} ; > > -- > Christian Tanzer tanzer at s... > Glasauergasse 32 Tel: +43 1 876 62 36 > A-1130 Vienna, Austria Fax: +43 1 877 66 92 > > > -- > http://mail.python.org/mailman/listinfo/python-list From sverker.is at home.se Thu Mar 1 12:26:14 2001 From: sverker.is at home.se (Sverker Nilsson) Date: Thu, 01 Mar 2001 18:26:14 +0100 Subject: Allow anything in identifiers? References: <3A9DC13A.1647EE51@home.se> <3A9E3ACE.60F8C639@home.se> <20010301152213.K9678@xs4all.nl> Message-ID: <3A9E8636.34622EAA@home.se> Thomas Wouters wrote: > > On Thu, Mar 01, 2001 at 01:04:30PM +0100, Sverker Nilsson wrote: > > David Porter wrote: > > > > > alu.id'+' = lambda x, y... > > > > It would break any code using the name 'id', likely a lot of code. > > > How? Not id , should likely be on the same line, may allow > > space in between. That gives a syntax error currently, except when id > > is some of a few special ones like r, u, etc. > > If you want for id"string" as a string literal, the example above will not No, id"string" should work exactly as an identifier! > work. String literals create strings, not identifiers. Creating a special > kidn of string that really creates an identifier would be... Weird. Humm, 'weird', that might be what I was refering to with 'a kind of uglyness'. I thought of other ways, maybe some other kinds of quotes, maybe curly brackets... id{asdf} ? Not sure if it clashes with anything in Python. It would confuse Perl programmers though. I'd like to note though that Ada allows strings as function names, albeit restricted: you can define functions overloading the predefined operators symbols like this: function "=" (left, right: my_type) return boolean; I don't think that was or is considered one of the more controversial or weirdest features in Ada, on the contrary. > > > operator.__lt__ (though I am just guessing about > > [that] one and I am sure it's wrong - that's a point of the > > argument :-) > > The latter doesn't exist. But neither does operator.__cmp__, so it's not > that big a suprise. > Well sorry for that confusion, I was sloppy. For an example that has actually lead to demonstratable confusion: operator.__invert__ that IIRC corresponds to the ~ operator. But in the magic method for objects, it's called __inv__. I found this some weeks ago in Python 1.5.2 and had to work around it. (quite easily admittedly, when I had found it out) I have not reported it as a bug 'cause I thought it might be fixed in versions 2... or didnt know how to submit it and/or was lazy... anyway I'd say it's a typical example of how having to invent new names may lead to misunderstandings & bugs. > > * Same holds for the corresponding class methods __add__ etc. > > Actually, you guessed exactly right with __lt__. That's the name for the > less-than operator 'magic method'. But even with special syntax to declare Oh, that's actually new for me, I thought they only had the __cmp__ operator. New in version 2.. I suppose? > operator'+', you can't throw away all magic names. What to do with __cmp__, > __init__, __del__, __setitem/attr__ ? Nothing I suppose, if they are not renaming something obvious. If one wants to get fancy, maybe one could think of some regexp that matches the occurence in a program, but it seems that could be unnecessarily complicated. > > > * Command interpreters could dispatch to functions that had obvious > > names corresponding to the actual commands. > > > * Variables corresponding to files with fixed name, could have > > the obvious name. > > >>> class X: > ... pass > ... > >>> x = X() > >>> setattr(x, '%$@(*#@$+', 2) > >>> getattr(x, '%$@(*#@$+') > 2 > > I don't see a lot of people using that hack. I also don't see how using that Maybe because they already need to come up with some other name anyway. I.E. if you need to define a function that can't be expressed by a lambda, then you need a name for it anyway, and then you have already lost the advantage you might get from having it named more naturally. If you can define your function with a simple lambda, I think it can be natural to use the operators name when applicable. I did that myself in making an interpreter for a Python-like language. To define some operators I made a table: comparison_op_table = { '<' : lambda a, b: a.cmp_op(b, lambda c : c < 0), '>' : lambda a, b: a.cmp_op(b, lambda c : c > 0), ... } I defined this at a separate table at the global level. I think it would have been more natural if I could have definied it directly in the class it was used, with a method for each case. I could do that by setattr I suppose, as you suggested, but that wouldn't be quite as clear, longer to write, and not in declarative form, so to say. And if the functions wouldn't fit in simple lambdas I'd had to make named functions from them anyways. > kind of variable name can be any clearer. I especially dont believe in Well for an other example, I have always found writing type(()) being _clearer_ than types.TupleType --- it's more direct, you see directly what it is, don't need to remember or lookup another name. Only reason I see not to use type(()) is that it might be a bit slower, I suppose. If the names were types.id'type(())', I think that might be both faster and clearer... not? In general, I think the less names you need to invent and remember, and the more you can depend on general constructs, the clearer the programs would be. > 'fixed named files': you should name your variables according to what Well you are right about not tying general programs to file names that can be parameters-in-some-sense to the program. > function they perform, not what they contain -- what they contain is already > obvious ;) I might call a template file > '/usr/local/lib//.tmpl', but the variable > would simply be called 'tmpl' or 'TEMPLATE' or some such. Right, I suppose. But if I make a special short script to handle a hard-coded file 'mother's recipes', why do I need to invent a new name to hold the file object? I don't usually do that with imported modules - despite they are file names in the same way, only difference is that their creators know they'r going to be used as Python identifiers. Mother doesn't necessarily know that. Well I'm hesitating about file names my self. Maybe if the file system was more integrated with the variables it would be more obvious. Repeating a quote taking it in another context: > function they perform, not what they contain -- what they contain is already > obvious ;) I'd agree at least for a variable that can contain different things that perform similar things - one would want to name it according to what is similar. Actually I think these new identifiers could be mostly applicable to constants. Functions and other constants. Example: From the math constants: Looking in C's math.h you have examples of how having more general identifiers would have helped. There are constants for simple constants like pi, e, but also 2/sqrt(pi), sqrt(2), 1/sqrt(2) with non-obvious names like M_2_SQRTPI, M_SQRT2, M_SQRT1_2. (They may follow a pattern but it's not THAT obivous and not general enough to allow for more complicated expressions, lacking parenthesises for example.) >From Python's math.h I recall only having constants e and pi last time I looked. I suppose more constants would be useful and maybe it would help if we could define many of them with the 'obvious' names so we don't have to think longer about what to call them... and also not be tied to C's more or less arbitrarily subset of useful constants. > > > One drawback I can think of myself right now is a kind of uglyness > > by using quotes but at least they make the construct stand out so it > > should not be so confusing to ordinary id's. > > The main drawback I see is your 'strong point': I don't believe allowing > more characters in identifiers is going to make programs easier to read or > follow, or going to make constructs more selfexplanatory. I just see added > complexity with no obvious benifit. Humm. Well, I am trying to understand why you are beliving and seeing those things but I haven't managed yet. If you'd like to explain it more it would be helpful, I would appreciate it but of course it's about your time and effort. I'am interested in this not only as a possible addition to Python but also more in general, I am thinking about whether to add or not to add this feature to a small language that I am making that is based on Python. (Part of a bigger project.) Thanks for your comments so far! Sverker Nilsson From nas at arctrix.com Wed Mar 21 19:59:43 2001 From: nas at arctrix.com (Neil Schemenauer) Date: Wed, 21 Mar 2001 16:59:43 -0800 Subject: New PEP: The directive statement In-Reply-To: ; from piet@cs.uu.nl on Wed, Mar 21, 2001 at 12:18:24PM +0100 References: <200103201042.LAA20248@pandora.informatik.hu-berlin.de> <9988ie02k7u@drn.newsguy.com> Message-ID: <20010321165943.A25383@glacier.fnational.com> On Wed, Mar 21, 2001 at 12:18:24PM +0100, piet at cs.uu.nl wrote: > It would be much less of a joke when __future__ would be replaced by > __features__, I think. __features__ is a terrible name. Its pretty obvious that you (and a lot of other people on this list) don't understand what __future__ does. A small hint: pretend you are using 2.2 and want to use nested scopes. Will you be using "from __future__ import nested_scopes"? What if you are using 2.2 and don't want nested scopes? Neil From jmarshal at mathworks.com Mon Mar 26 17:19:22 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 26 Mar 2001 22:19:22 GMT Subject: Biggest float number? References: <3ABFBB88.E718B2D@nd.edu> Message-ID: <99of9a$q0c$1@news.mathworks.com> C. S. Xu wrote: > Hi all, > It seems the biggest floating number in Python can be: > 2.**1024 - 1. > which is about 1.8E308. Is there any way to get bigger value than this, > just like long intergers almost have no limits? One possible workaround is to use a pair of long ints as numerator and denominator of a rational number. From bedge at troikanetworks.com Thu Mar 22 16:18:58 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Thu, 22 Mar 2001 13:18:58 -0800 Subject: InteractiveConsole locals parameter, solved, but UGLY! References: <3AB7FE07.5F7584F5@troikanetworks.com> Message-ID: <20010322.131857.352118606.18970@mead.troikanetworks.com> I found a way to do it, but, tell me there's a cleaner way: change the run_python() as follows def run_python(): banner = "Use Ctrl-D to exit python and return to CLI" import code import __main__ locals = __main__.__dict__ x = code.InteractiveConsole(locals) x.locals.update( { "run_python": run_python } ) <-- add this line !!!! x.interact( banner ) In short, you have to manually add items to the namespace. At least this is true for items which the application creates. In article <3AB7FE07.5F7584F5 at troikanetworks.com>, "Bruce Edge" wrote: > I can't get my __main__.__dict__ passed to an InteractiveConsole: > > def run_python(): > import code import __main__ locals = __main__.__dict__ x = > code.InteractiveConsole(locals) x.interact("") > > Shouldn't this have the same namespace as my main interpreter? > > If not, how can I get my main interp namespace propagated down to my > InteractiveConsole? > > Are there any detailed docs on this? I've read all the ones I can find. > > Thanks, Bruce. > > > Here's my test: > > Python 2.0 (#42, Mar 15 2001, 13:24:46) > [GCC 2.95.3 20010219 (prerelease)] on linux2 > Type "copyright", "credits" or "license" for more information. > >>>> from CLI import * <--run my CLI app > > k-> k-> python <-- command to start subshell, calls run_python, above >>>> dir() <-- this is all that's defined > ['__builtins__', '__doc__', '__name__', 'atexit', 'histfile', 'os', > 'readline', 'rlcompleter', 'savehist', 'sys'] >>>> >>>> <-- exit subshell > k-> <-- exit app >>>> dir() <-- top level, this is what I want in my subshell: > ['CommandException', 'KCompleter', 'Kcmd', 'Port', 'Zone', > '__builtins__', '__doc__', '__name__', 'atexit', 'basedir', 'cNode', > 'cOpt', 'cType', 'cli', 'cmd', 'cmds', 'copy', 'ctree', 'dprintf', > 'dprintf_exception', 'dprintf_init', 'dprintf_level', 'histfile', > 'histname', 'kcmd', 'kcompl', 'kcomplMode', 'kcompleter', 'kinterp', > 'kuser', 'mType', 'main', 'modules', 'nType', 'os', 'port', 're', > 'readline', 'register_new_command', 'rights', 'rlcompleter', 'savehist', > 'sl', 'string', 'sys', 'tokens', 'topcmds', 'traceback', 'types', > 'util'] From neilh at scintilla.org Sun Mar 18 02:19:49 2001 From: neilh at scintilla.org (Neil Hodgson) Date: Sun, 18 Mar 2001 07:19:49 GMT Subject: Cameron Laird Quote on www.unixinsider.com -- Probably old news to y'all, but new to me. References: Message-ID: Warren Postma: > I found this quote on www.unixinsider.com's main page when I went there > today: > > "I think we are seeing an end to the emphasis on statically typed languages > like C++ and Java. As this decade progresses, I expect to see an ever > increasing use of dynamically typed languages, such as Python, Ruby, and > even Smalltalk. > ... > They are much easier to refactor and have virtually zero > compile time." > --Robert C. Martin, talking to Cameron Laird in the Interviews forum C compilation time is also close to zero for much code now. For 'scripting size' problems where you have up to a few hundred lines in a single file and fairly simple linkage you can press the go button in an editor and see results starting immediately. For larger programs, precompiled headers and incremental compilation and linking can reduce edit-to-go time greatly. With Java, using a fast compiler such as IBM's will produce similar development speed. Modern C++ that uses the standard C++ library and so requires a lot of template expansion may slow down compilation to half a second but that is still quite competitive with Python. This is one benefit of the 'scripting languages' that is rapidly disappearing as machines get faster and C++ compilers are optimised. Neil From bawolk at ucdavis.edu Mon Mar 19 00:15:56 2001 From: bawolk at ucdavis.edu (Bruce Wolk) Date: Sun, 18 Mar 2001 21:15:56 -0800 Subject: stripping punctuation from tuples References: <3AB57F0C.594CF3E9@northwestern.edu> Message-ID: <3AB5960C.C65EE8B6@ucdavis.edu> How about this? >>> a=[('Alan Tsang',),('George Bush',)] >>> b = [i[0].split() for i in a] >>> b [['Alan', 'Tsang'], ['George', 'Bush']] Cheers, Bruce Louis Luangkesorn wrote: > How do you strip the punctuation from tuples? In particular, say I have > a tuple a[10] (which happened to come from a not very well designed > database) > > >>> a[10] > ('Alan Tsang',) > > How do I get something to say 'Alan Tsang' with out the parens or the > ',' > > Or, what I'm really trying to do is make this so > >>>b = breakname(a[10]) > >>>b[0], b[1] > > 'Alan','Tsang' > > I've tried to do: > >>> d = split(str(a[0])) > >>> d > ["('Aaron", "Fan',)"] > >>> d[0] > "('Aaron" > >>> d[1] > "Fan',)" > > But that is not quite what I want. > Many thanks. > Louis > -- > K Louis Luangkesorn > lluang at northwestern.edu http://pubweb.nwu.edu/~kll560 PGP:0xF3E2D362 > > Whatsoever things are true, ... honest, ... just, ... pure, ... lovely, > ... of good report; if there be any virtue, and if there be any praise, > think on these things. > - motto - Northwestern University (Phil 4:8) From pnwlhc at cleaning-your-pc.com Sat Mar 24 04:41:47 2001 From: pnwlhc at cleaning-your-pc.com (pnwlhc at cleaning-your-pc.com) Date: 24 Mar 2001 09:41:47 GMT Subject: KEEP YOUR PC CLEAN --- CLICK HERE 9879 Message-ID: <99hq4r$oi6$835@uranium.btinternet.com> http://www.evidence-eliminator.com/go.shtml?A654710 You're in Serious Trouble - It's a Proven Fact! Deleting "Internet Cache and History" will NOT protect you because any of the Web Pages, Pictures, Movies, Videos, Sounds, E-mail, Chat Logs and Everything Else you see or do could easily be recovered to Haunt you forever! How would you feel if a snoop made this information public to your Spouse, Mother & Father, Neighbors, Children, Boss or the Media? It could easily Ruin Your Life! Solve all your problems and enjoy all the benefits of an "As New PC", Evidence Eliminator can Speed-Up your PC/Internet Browser, reclaim Hard Disk space and Professionally Clean your PC in one easy mouse click! http://www.evidence-eliminator.com/go.shtml?A654710 mrkkjflwpwnlpxjdgkekseryyytiddxddbfgdhipgrdsntcdmqlkdubuigzheedjvnynsyuwkbftmuoebfbqylqhyu From paulp at ActiveState.com Sat Mar 10 06:43:15 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sat, 10 Mar 2001 03:43:15 -0800 Subject: Urgent Question about Python licensing References: <98cpfe$5oj$0@216.39.170.247> Message-ID: <3AAA1353.7B7AA72D@ActiveState.com> Dave LeBlanc wrote: > >... > My questions are these: > 1. What prevents Python and GPL code from being distributed together? > If I write some Python code that drives a GPL'd app (but which does > not depend on that app), what prevents me from offering both my python > code and the GPL'd app on the same medium (disk/CD/web)? Nothing. But many people want to build apps that combine GPL'ed code with the Python code base. > 2. Is it currently so, or will Python end up with, some license that > requires that python scripts be covered by the GPL? I'll go out on a limb and say that will never, ever happen. There is very low interest in the Python community in promoting the philosophy behind the GPL. Very little software in the Python world is licensed under GPL-like terms. And even if Guido were to jump on the FSF bandwagon, it would require a whole new level of religion to require that *SCRIPTS* also use the GPL. Even Richard Stallman would not suggest that Guido should be that restrictive. Gnu compiler tools are not that restrictive. Scripts are not at issue. The interpreter is at issue. -- Python: Programming the way Guido indented it. From aleaxit at yahoo.com Wed Mar 7 05:11:17 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 7 Mar 2001 11:11:17 +0100 Subject: polymorphjsm &c (was Re: I come to praise .join, not to bury it...) References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> <9811a8$k5k$1@nntp6.u.washington.edu> <982cja0v5c@news1.newsguy.com> <983u1l$6mk$1@animus.fel.iae.nl> Message-ID: <9851gf014vq@news1.newsguy.com> "Carel Fellinger" wrote in message news:983u1l$6mk$1 at animus.fel.iae.nl... [snip] > >>> class MixedSplitter: > ... def __init__(self, splitter1, splitter2): > ... self.splitter1, self.splitter2 = splitter1, splitter2 > ... def split(self, sequence): > ... s = self.splitter1(sequence) > ... return s[:-1] + self.splitter(s[-1]) self.splitter will give an AttributeError here (you mean .splitter2). But you won't get here unless self.splitter1 is callable, and who ever said it was? Guess you mean self.splitter1.split(sequence) on the first line, and similarly self.splitter2.split on the second. With these changes, you get no errors any more out of your code: > >>> ms = MixedSplitter(', ', ' and ') > >>> ms.split('1, 2, 3 and 4') > some nasty errormessage snipped but neither do you get what you want, because a.split(b) works irregularly...: -- if a is a re object, or if it's module-object os.path, then string b is split using splitter-object a -- if a is a string object (including a Unicode string), then string a is split using splitter-object b (which must also be a string) I.e., the semantics are backwards in the two cases, alas. > But the real evil is that no code out there will allow us to easily > use the polimorphic nature of this splitter. Actually, code written to split by a regular-expression object (which it takes as an argument and only uses for splitting) will work fine, polymorphically, with your MixedSplitter (when the latter is amended to call the split methods of its splitter attribute objects!-) -- as long as MixedSplitter is correctly primed with two splitter objects, and string objects are not splitter-objects in Python's architecture; they have a .split method, but it doesn't work at all like those of regular expression objects and the os.path module object do -- it's backwards. > The moral being that we shouldn't argue about the uglines joiner.join > but of the lack of a tru polymorphic splitter.split! It's no doubt too late to remedy the discrepancy between the semantics of a.split(b) depending on a's type (string versus re) and the resulting irregularity (which we no doubt will have to live with anyway) is unpleasant, to say the least. Alex From loewis at informatik.hu-berlin.de Tue Mar 20 15:32:53 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 20 Mar 2001 21:32:53 +0100 Subject: re.match References: <997skf$qoc$1@bmerhc5e.ca.nortel.com> <998bke$88i$1@bmerhc5e.ca.nortel.com> Message-ID: msoulier at nortelnetworks.com (Michael P. Soulier) writes: > No biggy, but surprising compared to every other implementation > of regexps that I've seen. What implementations of regexps have you seen? /usr/include/regex.h defines both re_search and re_match; I believe this is the POSIX interface to regular expressions. Regards, Martin From aahz at panix.com Tue Mar 20 16:27:53 2001 From: aahz at panix.com (Aahz Maruch) Date: 20 Mar 2001 13:27:53 -0800 Subject: Functionalism, aesthetics Was:(RE: I come to praise .join, not References: <997v08$s4o$1@panix3.panix.com> Message-ID: <998i0p$621$1@panix3.panix.com> In article , Fredrik Lundh wrote: >Aahz Maruch wrote: >> Carlos Ribeiro wrote: >>> >>>Its unfortunate that in many cases the non-expert user keeps quiet, >>>assuming that whatever opinion the "master" haves, its going to be better >>>than theirs - after all they are the so-called experts. >> >> There's some truth to that -- but rarely on Usenet newsgroups. > >I doubt most experts bother to post to Usenet newsgroups >(or read them, for that matter). Fair enough... >and yes, this is true for Python too... ...although I think it's less true for Python than some others, given people like you in this fine newsgroup. ;-) -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "I won't accept a model of the universe in which free will, omniscient gods, and atheism are simultaneously true." -- M From mcalla at home.com Mon Mar 19 21:46:44 2001 From: mcalla at home.com (Mike Callahan) Date: Tue, 20 Mar 2001 02:46:44 GMT Subject: Catching exceptions in Tkinter's mainloop References: <%dws6.9947$Q47.2723350@news1.rdc1.tn.home.com> Message-ID: I tried the following with no luck: import Tkinter as T import sys class Gui: def __init__(self, master): T.Button(master, text='Crash2', command=self.crash).pack() def crash(self): z = zz class Catcher: def __init__(self, func, subst, widget): self.func = func self.subst = subst self.widget = widget def __call__(self, *args): try: if self.subst: args = apply(self.subst, args) return apply(self.func, args) except SystemExit, msg: raise SystemExit, msg except: import traceback traceback.print_exc() self.widget.quit() root = T.Tk() f = open('test.log', 'w') sys.stderr = f T.CallWrapper = Catcher app = Gui(root) root.mainloop() What am I doing wrong? "Richard Townsend" wrote in message news:drMs6.32482$HR6.3694604 at nnrp4.clara.net... > "Mike Callahan" wrote in message > news:%dws6.9947$Q47.2723350 at news1.rdc1.tn.home.com... > > I want to make sure that if any exception pops up inside a mainloop, that > > exception is printed to a log file and the mainloop quits. I tried to > > simulate this with the following code but failed: > > > > from Tkinter import * > > > > class Gui: > > def __init__(self, master): > > self.master = master > > self.button = Button(master, text='Crash', command=self.crash) > > self.button.pack() > > > > def crash(self): > > z = zz # trigger exception > > > > root = Tk() > > app = Gui(root) > > try: > > root.mainloop() > > except: > > print 'caught' > > root.quit() > > > > It doesn't work. The exception is printed out by standard traceback and > the > > mainloop continues. What am I doing wrong? > > > > Mike Callahan > > > > Tkinter catches exceptions raised in callbacks and Tk by using the class > 'CallWrapper' (defined in Tkinter.py). I copied the technique used by Pmw, > and created my own CallWrapper class (based on Tkinter.CallWrapper) and then > after initialising Tk, I use the following statement: > > Tkinter.CallWrapper = MyCallWrapper > > MyCallWrapper's __call__ method invokes my error logging function in the > final except clause, you could get yours to print info to your log file and > quit. > > Note, you must always have an except clause for SystemExit (like > Tkinter.CallWrapper does) otherwise calling sys.exit() in a callback won't > work! > > e.g. > > class MyCallWrapper: > """Internal class. Stores function to call when some user > defined Tcl function is called e.g. after an event occurred.""" > def __init__(self, func, subst, widget): > """Store FUNC, SUBST and WIDGET as members.""" > self.func = func > self.subst = subst > self.widget = widget > def __call__(self, *args): > """Apply first function SUBST to arguments, than FUNC.""" > try: > if self.subst: > args = apply(self.subst, args) > return apply(self.func, args) > except SystemExit, msg: > raise SystemExit, msg > except: > # substitute your functionality here... > > Richard > > > > From Arthur_Siegel at rsmi.com Fri Mar 23 15:02:53 2001 From: Arthur_Siegel at rsmi.com (Arthur_Siegel at rsmi.com) Date: Fri, 23 Mar 2001 14:02:53 -0600 Subject: Subject: Re: VPython/Tk app works on single processor but not dual Message-ID: <005B2EE9.N22121@rsmi.com> Fred wrote - >If you've got a VC++ project file, I'd like >to have that. Is the VPython build process for Win32 documented >anywhere? The source distro at: http://virtualphoton.pc.cc.cmu.edu/projects/visual/developers.htm has a VC++ project file. Build was very straightforward. Redirect to my Python20 include and libs and shoot. >This problem is getting in the way of my general goal: creating >interactive programs that allow the user to play with graphic >representations of mathematical concepts. As you might know from my edu-sig ramblings, I am using VPython to similar end - concentrating on pure geometric rather than number based math concepts. You will have something to share sometime soon? From mud at mud... Tue Mar 13 10:57:50 2001 From: mud at mud... (mudshark) Date: 13 Mar 2001 15:57:50 GMT Subject: Einstein's Riddle References: <98glrd$1si1a$1@ID-75892.news.dfncis.de> <3AABE712.499CCF4C@home.com> <98gp5b$1u0oi$1@ID-75892.news.dfncis.de> <98lf4g$2dqj2$1@ID-63952.news.dfncis.de> Message-ID: <98lg1u$iuh$1@porthos.nl.uu.net> "J. A. Durieux \(reply from http://www.biep.org/\)" wrote in <98lf4g$2dqj2$1 at ID-63952.news.dfncis.de>: >"Boris Popov" wrote in message >news:98gp5b$1u0oi$1 at ID-75892.news.dfncis.de... >> P.S. What's emu ? > >A European currency unit, now replaced by the Euro.. > That's ecu (echo? echo echo echo ....) From tim.one at home.com Sat Mar 10 14:21:18 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 10 Mar 2001 14:21:18 -0500 Subject: "!=" is bad form. Re: sorry....never mind In-Reply-To: <15018.30583.852611.836468@anthem.wooz.org> Message-ID: [Barry A. Warsaw] > Personally, I agree. I hate "!="; to me <> looks much better and I > use it all the time. Guido has been known to disagree with me so > violently that he'll make a patch to my code just to change that. :) I'm afraid it's again time to quote the Reference Manual: The forms <> and != are equivalent; for consistency with C, != is preferred; where != is mentioned below <> is also accepted. The <> spelling is considered obsolescent. Now I can channel many things in Guido's absence, but not even by asking outright have I been able to divine the differences among "obsolescent", "obsolete" and "deprecated" when applied to snake scales. All we can be sure of is that they each refer to one of the modes in which a python seeks to shed old skin. If you look at the CVS history of Grammar/Grammar, you'll discover that In The Beginning, Python allowed only the <> spelling. != wasn't added until revision 1.5 (of Grammar, not Python). So this is a curious case where Guido disowned his first impression (from only <>, to <> is obsolescent); but since this is the same process by which your print>>file got into the language, you had better not protest too loudly . print>>-got-in-for-"consistency-with-c"-too-ly y'rs - tim From syver at NOSPAMcyberwatcher.com Tue Mar 27 14:06:56 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Tue, 27 Mar 2001 21:06:56 +0200 Subject: Threading legality/morality References: <99nnbv$phs$1@panix6.panix.com> <99qa3v$6e0$1@panix6.panix.com> Message-ID: <99qogp$o6g$2@troll.powertech.no> "John J. Lee" wrote in message > Perhaps you're right, but I've seen the same behaiviour on win95, without > multi-threading. When you run command-line (do we mean the same thing by > console and command-line?) apps it freezes until a key gets pressed. Not > using urllib either. > > It is possible (likely, even) that I was using cygwin, so maybe that's > where the blame lies. I'll see if I can reproduce it with the standard > DOS shell. I am using console program/command line whatever you like, and I am not using Cygwin. I've experienced this both on the BeOpen and ActiveState distros. From nomad*** at ***freemail.absa.co.za Fri Mar 2 02:56:06 2001 From: nomad*** at ***freemail.absa.co.za (nomad) Date: Fri, 02 Mar 2001 07:56:06 GMT Subject: [Q]: How can I get the logged in users username on Win32? Message-ID: <3a9f50fd.58862977@news.is.co.za> Howzit, After searching through the Python Docs, I found that on Un*x I could use getpass.getuser(), but there is no equivalent for the Win32 platform. In other words, how can I get the username in Windows? As a side note, how can I enable Windows Scripting Host support for python - there is mention of python in the original WSH docs - and if I can use python scripts in WSH how would I call the built-in Wscript. TIA nomad From bob_cannard at mentor.com Tue Mar 27 13:46:40 2001 From: bob_cannard at mentor.com (Bob Cannard) Date: Tue, 27 Mar 2001 10:46:40 -0800 Subject: R: unique items in lists References: <_nZv6.2878$yU4.468236@news.infostrada.it> Message-ID: <3AC0E010.3CDC94FC@mentor.com> Remco Gerlich wrote: > > comp.lang.python wrote in comp.lang.python: > > Here is what I'm doing now: > > > > for w in words: > > while words.count(w) > 1: > > words.remove(w) > > > > comments? > > First, you modify a list that you are looping over. That can give > unpredictable results, but in this case it seems to work. The list [1,1,2,2,3,3,2,1] breaks this algorithm, which produces [3,3,2,1]. The reason it fails is that the algorithm preserves the last element of each value, not the first, so the 3's are moving to the left while the for loop's internal pointer is moving to the right; the two cross each other without ever meeting. Heed that warning in the language reference; iterating over a changing list can seriously damage your mental health, not to mention your algorithm! > It will take a long time. 'words.remove(w)' takes time proportional to the > length of the list; words.count(w) takes time proportional to the length of > the list itself, and you repeat that for every duplicate of a word, and the > total is repeated for every unique word. In total it takes time proportional > to N^3 (for a list of length N), I think. That's right. It's a horrific run time for any reasonably large N: a billion operations for N = 1000. > The dictionary method does one dictionary action for each word, and then it > does a dict.keys() which takes time proportional to each unique word. I don't know how dictionaries are implemented, but hopefully they're a lot faster than that - one would expect a hash or tree implementation, giving a logarithmic run time for each lookup. A linear implementation would be an obvious cause of poor run time performance for Python generally. > In total > it takes time proportional to N. More than that; it would be order N for a list such as [1,1,1,1,1...]. I would estimate something between N and N log N depending on the input data and the implementation of dictionaries. In any case, it's vastly better than the previous method: only several thousand operationsfor N = 1000. In the worst case (a linear implementation of dictionaries plus pathological data) the run time is still only N^2, or a million operations for N = 1000. Cheers, Bob. From robin at jessikat.fsnet.co.uk Thu Mar 22 11:52:03 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 22 Mar 2001 16:52:03 +0000 Subject: extending the built in dictionary type Message-ID: I'm interested in extending the built in dictionary. It's fairly simple to wrap, but seems incredibly hard to chain the methods. Is there any obvious way to use most of the built in methods whilst modifying a few. Seems that although it exists I can't chain the original mapp_methods of dictobject as that is not visible outside pythonxx.dll. So is there an easier way to get at these internal types? -- Robin Becker From steven at haryan.to Sun Mar 11 10:28:52 2001 From: steven at haryan.to (Steven Haryanto) Date: Sun, 11 Mar 2001 22:28:52 +0700 Subject: Going ZODB Message-ID: <4.3.2.7.2.20010311222003.02c2aad0@202.53.255.51> I am curious as to how many people in this list actually use ZODB in production environment and what is the typical uses of it (especially ZODB with relational/berkeleydb storage). Aside from along with Zope, of course. Also, there are one issue I am considering before going ZODB. If later on the application grows beyond the scale that ZODB can provide at the moment, would it be awkwardly hard to convert the code to use other backend. For example in the relational world, if I keep the SQL statements portable enough, I can just, theoretically, switch the backend with another DB. Thanks, Steve From fredrik at pythonware.com Wed Mar 14 02:44:27 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 14 Mar 2001 07:44:27 GMT Subject: Unpickling from strings References: <3gyr6.159$4d3.34762@newsb.telia.net> <3AAEB597.4010007@ntlworld.com> Message-ID: Marcin Chady wrote: > Both pickling and unpickling is done by the same script, and the classes > are defined in a separate module imported by that script. should work. better post some code. Cheers /F From claird at starbase.neosoft.com Fri Mar 23 17:36:13 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 23 Mar 2001 16:36:13 -0600 Subject: Install Python on Apache References: <99fph5$a2n$1@rex.ip-plus.net> Message-ID: In article <99fph5$a2n$1 at rex.ip-plus.net>, Sharp wrote: >Hi Everybody > >I sucked down Python from python.org and started to install the program >on a win2000 apache system. that has worked perfectly. but then I tried >to set up the apache httpd.conf file with the following options > >AddType application/x-httpd-py .py >Action application/x-httpd-py /cgi-bin/Python/python.exe > >(cgi.bin is set to the right place because php and perl do work) > >But then it did not work. I hava also tried several variations but always >with the same comands. >The Error Message in the Apache error.log was > >[Fri Mar 23 15:54:50 2001] [error] [client xxx.xxx.xxx.xxx] Premature end of >script headers: c:/web/cgi-bin/python/python.exe > >the script is looking like this > >#!c:/web/cgi-bin/Python/python.exe >print ""; . . . I confess I've never used Apache on Win*. I'm willing to bet, though, that starting this with #!c:/web/cgi-bin/Python/python.exe print "Content-type: text/html\n" print ""; ... instead will get you closer to what you want. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From petasis at iit.demokritos.gr Mon Mar 12 01:58:48 2001 From: petasis at iit.demokritos.gr (Petasis George) Date: Mon, 12 Mar 2001 08:58:48 +0200 Subject: Einstein's Riddle References: <984380185.768920@news.aei.ca> Message-ID: <3AAC73A8.F12BC8B3@iit.demokritos.gr> sulfugor wrote: > > Gregory Jorgensen wrote in message ... > >The 2% that can solve it must be psychic or deranged. The riddle as posed > is not > >solvable. > > > >We are told of five houses anf five people. The hints mention five colors > (red, > >green, white, yellow, blue), five drinks (tea, coffee, milk, beer, water), > five > >smokes (Pall Mall, Dunhill, Blends, Bluemaster, Prince), and five > nationalities > >(Brit, Swede, Dane, Norwegian, German). But only four types of pet are > >mentioned: dogs, birds, cats, horse. We have no evidence that any of the > five > >owns fish. > > But the fish is mentionned in the question before the clues are given. We > are able to find who owns each of the 4 pets mentionned in the hint list. is > it so unreasonable to assume then that the last pet is a fish, since we were > asked about it ? The question IMplied that one of the 5 people owned a fish. > > sulfugor > > ps = by the way, how long is this supposed to take ( solving the riddle) ? > Yes, that the problem: it implies, it does not states :-) It took me about 20 minutes to solve it (with paper+pencil of-course :-))... George From aleaxit at yahoo.com Fri Mar 16 10:10:19 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 16 Mar 2001 16:10:19 +0100 Subject: I come to praise .join, not to bury it... References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> <3AAF7E47.294617E1@sage.att.com> <98qeco02hn7@news1.newsguy.com> <98rmod$c8p$1@animus.fel.iae.nl> Message-ID: <98tacr0q5s@news1.newsguy.com> "Carel Fellinger" wrote in message news:98rmod$c8p$1 at animus.fel.iae.nl... [snip] > > some people (just as it is going to attract others), so, > > it's not a clear "win" either way, even if you just frame > > it as a popularity-race. Focus on *substance*, on the > > but if you get too blinded by this substance thing, you might easily > overlook that in the end you have to weight things and there again the > seasoned sense of aesthetics of the gifted ones is what makes the > difference. I appreciate "form follows function" as an aesthetic principle. Clearly, given such masterpieces of functional spareness as Bauhaus and other artistic schools of this century have been able to produce, I'm not alone in this (and the spare functional beauty of Medieval Francescan churches, etc, stands to prove that this is not by any means an idea new to this century; also, of course, it's NOT by any means an idea limited to Western culture, as for example a certain Zen-inspired style of Japanese furniture shows). Just as clearly, given such masterpieces of rich ornamentation as great Baroque architects (etc, etc -- again, this is not limited to one century, or one continent!) have produced, it is anything but a _universally accepted_ guiding principle for the fashioning of beauty in human artefacts. You seem to imply some moderation (have to weight things) is key to YOUR aesthetics -- fine, Aristotle will agree, as will no doubt others, but much breathtaking beauty is instead in works which pushed their guiding principles to absolute extremes (Bach's "Art of the Fugue", Picasso's "Guernica", Olbrich's "Sezession Haus", Leopardi's "Infinito" -- where is any 'moderation' or 'weighting' in these and many other masterpieces across all arts and centuries and continents?!). In my own profession, I make certain choices which I perceive as guided by 'aesthetics' when I cannot afford to articulate in full detail the path back from the practical example up to the guiding-principle; my experience (and 'gift', if any) may help this synthesis (a productivity plus) by helping me perceive as "elegant" an architecture which will prove helpful to the design-task at hand. If and when challenged, though, I can and will fall back to the time-consuming, perhaps boring, but often enlightening task of detailed analysis of the constituent elements -- there is nothing 'inherently ineffable' in this. I see architects of manufacts with more psychological interactions, such as GUI's or buildings, perform similarly -- a sense of beauty to guide their everyday work (as reasoning back to first principles would take forever and slow things down unacceptably), but solid, explainable reasons they can trace back if and when needed... *IF* they're worth a dime as building-architects and/or GUI-architects. And for the only 'art per se' I _do_ know a little bit about, cinema, I see a very similar pattern again -- yet farther removed, OK, but a great movie can be fully analyzed (and IS, over and over again, in all sorts of debates and critical publications). That doesn't mean it's possible to make somebody _without_ appropriate gifts into a great movie director, GUI designer, building architect, OR software architect, of course -- but, it DOES mean each of these professionals need not fall back on vague generalities and empty hand-waving if and when their design choices get challenged. Somebody who's unable to do anything but talk of aesthetics when discussing a choice in the architecture of a software component is simply not contributing to the discussion. It looks good to you, it looks bad to him, it looks indifferent to her, yawn, great debate, now let's get beyond this to the REAL meat of the issue, please -- the technical implications of this, that, or the other choice in a specific matter. If you _can't_ get down to concrete specifics, then either you're not investing enough time & energy to contribute (in which case, staying out of a debate WOULD be a nice matter of courtesy), or you lack some specific (experience, culture, professional background, whatever) to be able to analyze and express your surface impressions in the issue -- in which case, it's quite possible that they're misfounded, and, IF the huge investment of time and energy doesn't faze you, in-depth analysis to see if they ARE might well be warranted (and that is basically what I've been doing throughout this thread -- striving to help others articulate their objections, in great detail, by first laying out in just as much details my reason for NOT objecting at all to the architecture Guido has chosen for .join; it won't of course have any direct repercussion on how Python behaves in the matter, but it MAY have positive implications on technical growth of the people involved, and thus, very indirectly, on future efforts on their part). > > other hand, is going to be a win for all who _are_ involved > > with Python -- not just those who happen to be on the > > "I like it" side vs the "I like it not" one (and I've > > never seen any argument about _aesthetics_ [as opposed to > > I hope you'll see the argument in the above:) > > > _usability_ -- human-factors studies DO have a substantial > > side too:-)] that doesn't boil down to such trifles]). Nope: it _still_ boils down to aesthetics being AT BEST a mental and verbal shorthand to avoid the considerable investment required to articulate the concrete underlying realities in detail. AT WORST (and, I suspect, more often, particularly in Usenet debates) a way for somebody to keep spewing words on a subject on which they actually have nothing concrete, constructive, and useful to say. Alex From benjamin.altman at noaa.gov Wed Mar 21 16:13:59 2001 From: benjamin.altman at noaa.gov (Benjamin.Altman) Date: Wed, 21 Mar 2001 16:13:59 -0500 Subject: learning python... References: <3AB8F4E1.184DD9C@noaa.gov> <3AB91006.6D7E35F2@seatech.fau.edu> Message-ID: <3AB91997.3ECD003C@noaa.gov> Do you know how it compares to the first edition in terms of presentation and indexing? I have heard from a few people that it is difficult to look up things in the 1st edition. The only review on amazon of the 2nd ed. claims it is a complete rewrite despite his admitance that he has never read the book... Thanks, Ben Benoit Dupire wrote: > Simon Kesenci wrote: > > > If you know programming, forget _Learning_ _Python_. I tried _Programming_ > > _Python_ last year, but it covered version 1.3. A good book if they > > updated it since then. As a programmer, you should find the online > > tutorial easy and helpful . > > Programming Python was updated and now covers Python 2.0 > I am reading it, actually, and, till now, I find it great.. (but I am only page > 35! ;o) ). > > This edition is intended to be the 'sequel' to " Learning Python"... so yes, > you can try to read the Python tutorial and this book... From bkc at Murkworks.com Thu Mar 1 09:01:58 2001 From: bkc at Murkworks.com (Brad Clements) Date: Thu, 1 Mar 2001 09:01:58 -0500 Subject: [ANNOUNCE] pyAda, first public release References: <3A9DB9E1.8DD0E36D@bigfoot.de> Message-ID: I thought one of the big points of using Ada was its verifiability -- making it more suitable for complex, "large-scale" (i.e, expensive) projects, like missile defense. Plugging in a "non-verifiable" script plug-in kinda defeats this purpose.. doesn't it? -- Brad Clements, bkc at murkworks.com "Gerhard H?ring" wrote in message news:3A9DB9E1.8DD0E36D at bigfoot.de... > PS: This is my first major Ada project, so I am open to any suggestions > for improvement. From aleaxit at yahoo.com Sat Mar 17 03:13:26 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 17 Mar 2001 09:13:26 +0100 Subject: Pep 238 Why new // operator (Non-integer Division) References: Message-ID: <98v77t01qcg@news2.newsguy.com> "Tim Peters" wrote in message news:mailman.984811161.25962.python-list at python.org... [snip] > > So maybe some other symbol should be used. > > Why bother? Python's # looks an awful lot like C++'s preprocessor directive > flag too. Guido would probably prefer infix "div" (a la Pascal), but a new > keyword is a very hard sell. So what's so terrible about non-infix notation, a builtin div(a,b) [and mod(a,b) too since we're at it...?]. Sure, infix can be handy -- but then this might be the occasion to steal a leaf from Haskell's book... let any 2-operand function be used as an infix operator (possibly with some stropping if that is needed to disambiguate syntax). Alex From danielk at aracnet.com Sat Mar 24 13:19:47 2001 From: danielk at aracnet.com (Daniel Klein) Date: Sat, 24 Mar 2001 10:19:47 -0800 Subject: Komodo Message-ID: I just spent that last couple of hours getting comfortable with the ActiveState Komodo IDE. Let me say "Nice job ActiveState!". I especially like the project management and the ability to expand/collapse the classes/functions in-place. Good work! Daniel Klein Portland OR USA From emile at fenx.com Sun Mar 25 12:29:38 2001 From: emile at fenx.com (Emile van Sebille) Date: Sun, 25 Mar 2001 09:29:38 -0800 Subject: Newbie needs help to find bug in his first Perl program References: <3ABCC757.6C6F17CA@earthlink.net> Message-ID: <99la4f$1pl7q$1@ID-11957.news.dfncis.de> >>> print "%y" % 1 Traceback (innermost last): File "", line 1, in ? print "%y" % 1 ValueError: unsupported format character 'y' (0x79) >>> HTH, -- Emile van Sebille emile at fenx.com --------- "Ron Stephens" wrote in message news:3ABCC757.6C6F17CA at earthlink.net... > Ok, I am a total newbie. I took some programming course in college, did > some relatively simple programs in Fortran, Basic, PL/1 and even one in > assembler for an old IBM "mainframe" using punched cards. But that was > along time ago. > > OK, I have just fallen head over heels in love with Python. Wrote my > first little "program", about 200 lines of a thing to do simple > "Decision Analysis" in a general sort of way, to take input from an > "expert" in any given (simple) field, and set up criteria based on the > experts experience, then calculate a weighted average to decide which > option to choose. > > I find the debugging to be extraordinarily good, but I have one bug I > cant seem to figure out yet. Been up all night its noon of the next day > ;-))) Need some sleep > > The offending line of code is > > sixtwo = raw_input ("where does %s rank for %y ?" % (option6, > criteria2)) > > Can anyone see what is wrong with this? I have several lines like this > and they all give me error messages. > > Sorry for the trivial newbie nature of my question and first post ;-))) > > But I do luv Python.... > From jarober at mail.com Sun Mar 4 15:37:26 2001 From: jarober at mail.com (James A. Robertson) Date: Sun, 04 Mar 2001 20:37:26 GMT Subject: Collection interfaces References: <3a90fa97.0@news1.mweb.co.za> <8Gem6.473353$U46.14105062@news1.sttls1.wa.home.com> <3A9A86B1.9A8C69A2@ix.netcom.com> <97fjla128ir@news2.newsguy.com> <97h5s40vhc@news2.newsguy.com> <97ibmc0k47@news1.newsguy.com> <97m0c7080c@news2.newsguy.com> Message-ID: <3AA2A898.450B659E@mail.com> Topmind wrote: > > > Not exactly "typical custom business applications", the domain > in which I focus most of my whining. > > The percentage of OO fans in the business domain seems lower > than average. Perhaps this says something about OO and > the business domain. > 90% + of the customers using VisualWorks are writing 'typical' business apps. > > Please keep track of the number of minutes you spend working on this. > > Please keep track of the number of defects that you find and fix during your > > work. I mean, any thing that does not work the first time and be sure to > > count each problem the compiler tells you about too. > > And if we use an interpreter? > > > Please keep track of > > the number of statements of code you add, remove, and change during this > > work. If you supply me with these data and the code I will test the > > accuracy of your solutions and compare your code with some OO code and post > > my findings (as my spare time allows) for the entire newsgroup(s) to see. > > > > Oh... and a... no pair programming please! > > > > Randy > > > > > > -tmind- -- James A. Robertson Product Manager (Smalltalk), Cincom jarober at mail.com From NoSpam at NoSpam.com Thu Mar 1 19:35:25 2001 From: NoSpam at NoSpam.com (Tom) Date: Fri, 02 Mar 2001 00:35:25 GMT Subject: Unresolved symbols in MSVCRT.DLL when running a py2exe packaged program. References: Message-ID: One difference (between the Win2K & WinNT machines) is the new system file protection 'feature' in Win2K. It is supposed to disallow inappropriate updates to system DLL's (of which MSVCRT.DLL is one). Another aspect of this feature is that apps can load their own versions of system DLL's, so multiple different versions MSVCRT.DLL can be memroy resident at the same time (but not on NT, just 2K). Someone suggested deleting the DLL to see if it is in use. I'm not sure about DLL's, but with drivers (.SYS) you can delete it even while it is in use (wierd). There are utilities around that will tell you what DLL's your app has loaded. Maybe even the sysinfo utility, included in Win2K, might tell you this? When you replace the MSVCRT.DLL in system32, you will have to reboot before it takes effect. Tom. "Parzival Herzog" wrote in message news:RKln6.6630$hn5.853203 at news1.rdc1.mb.home.com... > I have a Python application (which uses the wxPython extension) that I have > packaged > for distribution with py2exe. The dfistributed app works on my own > computer, > and on another machine I have, which has never seen any Python software, nor > any > development software (i.e. no dll's not a part of a standard Win2000 > installation are present). > > I delivered my app to my client, who is expected to modify some > configuration code, then > use py2exe to package the app, and run the packaged app on a server machine. > My client > has a notebook computer, running Win NT (Sp 6), plus MsVc and assorted > development tools. > My app worked on that noebook, and py2exe again packaged the app and the > package was > copied to the server machine, a Win NT sp 6 desktop computer. When we > attempted to > start the app, it failed immediatly, with the message that the symbol > ??_U at YAPAXI@Z could > not be found in MSVCRT.DLL. > > That symbol is apperrently defined in the MSVCRT.DLL file in the py2exe > package, but the > MSVCRT.DLL in the package is not the same as MSVCRT.DLL in the windows > system32 > directory, and that version of the dll appears to have the symbol > ??2 at YAPAXCI@Z defined > (what horrible identifiers!). So we assumed that instead of finding the > py2exe supplied > dll, the packaged python app is finding the other dll, which is much older > (dated 1997). > Of course, we don't have any way of determining the dll that is actually > being searched). > So, we attempted to replace the old MSVCRT, by installing a recent copy of > MSVC++ 6.0. > This indeed did replace the dll, replacing it with a version dated July 7, > 2000. However, > the problemwith the python app persisted exactly as before. > > What I can tell, with the computers I have available, is that the the Python > app works > on three different machines, 2 running Windows 2000, with the latest > MSVCRT.DLL > and one running Win NT (sp 6), with an MSVCRT.DLL dated 1999. What I can't > tell > is whether or not the py2exe packeged MSVCRT.DLL is being used by the python > app, > or the system32 dll that happens to be on the machine where the app is to > run. > > Can anyone help me towards resolving this problem? Truly, I program in > Python, because I > really am far too stupid to cope with ??2 at YAPAXCI@Z missing symbol problems, > and I > fancy that I shouldn't have to either. But I appear to be misguided, and I > need some help. > > - Parzival > > > > From scarblac at pino.selwerd.nl Thu Mar 22 10:49:59 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 22 Mar 2001 15:49:59 GMT Subject: New PEP: The directive statement References: Message-ID: Martin von Loewis wrote in comp.lang.python: > Generalization is a dangerous thing: you can too easily cross the > border to over-generalization. This is exactly what 'directive' is trying to do, lumping transitional language changes in with options. -- Remco Gerlich From flognat at flognat.myip.org Thu Mar 15 18:41:04 2001 From: flognat at flognat.myip.org (Andrew Markebo) Date: 16 Mar 2001 00:41:04 +0100 Subject: Should I close after popen?? References: Message-ID: / "Ken Seehof" wrote: | [...] | Your usage of wait is fine, (assuming that the fd1 process is never | dependent on the fd2 process). Hmm is it possible to do some kind of wait (fd1, fd2) to continue when either of them are finished, or thats what select and poll are for?? Hmm poll seems to be a choice.. /Andy From cribeiro at mail.inet.com.br Sat Mar 31 22:01:43 2001 From: cribeiro at mail.inet.com.br (Carlos Alberto Reis Ribeiro) Date: Sun, 01 Apr 2001 00:01:43 -0300 Subject: PythonLabs Team Moves to ActiveState Message-ID: <5.0.2.1.0.20010401000139.0222ab10@mail.inet.com.br> Guido, This is the best news that I could ever get from you. Now that we have peace with the Perl camp, why not rename the language? I propose the name Pyrl, and the motto: TINWTMIWNMHHYT, for: "There is no way to make it work no matter how hard you try". As for the numeric PEP, I have a sugestion of my own: implement a IRRATIONAL number type. With irrationals, we will be able to represent pi with more precision than any other language on earth! We will be also giving a great contribution to all the students of the world, who would not need to worry *anymore* about such numbers as sqrt(2). Best regards, and keep with the good work. At 19:54 31/03/01 -0500, you wrote: >PythonLabs Team Moves to ActiveState > >To all Python users and developers: > > Less than half a year ago, I moved with my team to Digital Crations, > in the > hope of finding a new permanent home for Python development. At > Digital Creations we've done several good things for Python, such as > forming > the Python Software Foundation and the management of the Python 2.1 > release. > > Unfortunately, Digital Creations's original plans for PythonLabs didn't > work out as hoped, and we weren't able to reach mutual agreement on > workable alternative plans - despite trying for months. > > I am proud to have found a new home for my entire team: starting > today, Tim Peters, Barry Warsaw, Jeremy Hylton, Fred Drake and myself > are working for ActiveState. We will be spending part of our > time on core Python development (including Jython and Mailman) and > part of our time on Python infrastructure improvements that also > benefit ActiveState's efforts such as Komodo and Python.NET. > > Python will remain Open Source; ActiveState has no desire to > monetize or brand the Python language or specific Python > distributions. All future work we do on Python as ActiveState > employees will be owned by the PSF. > > We're excited to be working for ActiveState: they are one of the companies > most committed to Python, and they have great products! Plus, we know > they have deep financial backing. We trust that ActiveState will > provide a stable home for Python for many years. > > ActiveState has also offered to take over hosting of the > python.org and starship sites. On behalf of the Python community, > we're grateful for this support of the two prime community sites for > Python, and we expect to be implementing the transitions shortly. > > These are exciting times for the PythonLabs team - and also for Python > and its community. Mainstream successes for Python are showing up > everywhere, and we're proud to be a part of such a smart and friendly > community. A great year lies ahead! > > Note, however, that moving to ActiveState will have some minor effects > on the future of Python development. ActiveState is concerned about > the seeming rift between the Perl and Python communities and wants > to do its best to help the Open Source scripting community work together. > In order to make it easier for Perl programmers to transition to Python, > we will add optional curly braces for Python. While we are fully aware > of the effect this will have on Python usability, we have finally decided > to bite the bullet and accept that until this happens, Python will never > be popular. > > Barry has already approved PEP 357, Adding Block Delimiters to Python. > Since we are heavily commited to backwards compatability, a transition > period of three months has been mandated. For those who want the changes > to start sooner, we added "from __future__ import block_delimiters" in > Python 2.1, which will be released about two weeks from now. > > Larry Wall and I agreed that now it makes sense for Perl to have > the Perl compiler enforce correct indentation in Perl sources. This > will probably be implemented in Perl 5.7, and will certainly be in Perl 6. > Also, after some talks with Larry, I've decided to adopt the Perl > numerical model for Python. The Perl model is simple, predictable and > easy to explain. This is a small enough change that it does not need > a PEP, and Moshe will implement it before 2.1rc1 is out. > > Now that the catalog-sig finally has a fully working product, ActiveState > decided they will base a CPAN competitor on it. This server will be able > to deal with both Perl and Python modules. While the client will remain > completely Open Source, it was decided that the server will remain > ActiveState proprietary. While it is true that the original server was > written by the Python community, ActiveState has put a lot of effort > into making it general enough, and we need to justify the costs somehow. > > --Guido van Rossum (home page: http://www.python.org/~guido/) > > >-- >http://mail.python.org/mailman/listinfo/python-list From johann at physics.berkeley.edu Mon Mar 26 14:56:11 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 26 Mar 2001 11:56:11 -0800 Subject: python, OS X, and fcntl Message-ID: Hi folks, I'm having trouble with the fcntl module under Mac OS X. It sounds like this is an old problem that has resurfaced, since I can only find references to it in 1999 archives about OS X Server. Is there a known workaround? I get, while running test_fcntl: Status from fnctl with O_NONBLOCK: 0 struct.pack: '\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' Traceback (most recent call last): File "test_fcntl.py", line 31, in ? rv = fcntl.fcntl(f.fileno(), FCNTL.F_SETLKW, lockdata) Any hints? -- Johann Hibschman johann at physics.berkeley.edu From jhg at galdon.com Wed Mar 21 06:36:57 2001 From: jhg at galdon.com (Juan Huertas) Date: Wed, 21 Mar 2001 12:36:57 +0100 Subject: Pick Systems D3 Database References: Message-ID: <99a3ce$hma$1@talia.mad.ttd.net> You can try to obtain information on www.picksys.com, (Raining Data). I use D3 very years, it's good. I think the best is to use ODBC, but D3 has te possibility to import/export data to ASCII format using the copy instruction to logical devices. Into Aix, the normal solution is to use Telnet to work with the Server D3 (D3Vme). Un saludo. Juan Huertas. Ben escribi? en el mensaje de noticias rG%t6.555$45.2416 at newsfeeds.bigpond.com... > Hi, > > I have not been able to find any direct information about this so I thought > I would ask here in the slim chance someone may have had to do something > similar ... what would be the best way to push/pull information from a D3 > (PickSystems) database running on AIX using Python? Is ODBC my only option > or are there others? If you have done something similar how succesful was > your solution? > > Thanks in advance > > From carribeiro at yahoo.com Mon Mar 19 20:49:22 2001 From: carribeiro at yahoo.com (Carlos Ribeiro) Date: Mon, 19 Mar 2001 22:49:22 -0300 Subject: Functionalism, aesthetics Was:(RE: I come to praise .join, not Message-ID: <5.0.2.1.0.20010319224910.021134d0@mail.inet.com.br> I'm lost for words... This summarizes a lot of concerns that sometimes I find so hard to explain. Anyone who has actually *read* Christopher Alexander's books on design should know that the best solutions are the ones that take into account the inner sense of satisfaction of their end users. As Alexander puts it itself, it is a rewarding experience born out of the "completeness" of the solution. The best solutions also share another common trait: they look *and feel* good to the untrained eye. Beware of works that can only be appreciated by experts - they are way too trained to see the obvious. Mike C. Fletcher wrote: > The reason I felt it necessary to jump in here again is the implicit >creation of a "inner circle" of the "initiated" who are considered "worthy" >to contribute to a discussion about the evolution of the language. The >users of a system, whether it is a building, a language, a piece of >software, or a chair, need to be heard. A user complaining that something >is "ugly", "bad" or "wrong" needs the nature of their discomfort >ascertained, and that knowledge integrated into further design decisions. > Designers who ignore their users, assuming that their own > understanding of >the system is correct, and that anyone who is unable to speaking the dialect >of designers cannot possibly contribute to a design, will create >monstrosities which are next to impossible to inhabit. Functionalism only >works when the understanding of "function" is broadened to include the >entire process of inhabitation, not just the parti-sketch with which the >architect is fascinated. The modernist movement proved this time and again >with awe-inspiring buildings which failed to be good places to live. The >postmodernists continue to prove it with each building they inflict upon the >world. >Your friendly neighbourhood designer signing off... >Mike To summarize it: a *technically* optimal solution for a problem is not always the *best* solution. If it does not look intuitively good for most users, its probably a bad solution. Its unfortunate that in many cases the non-expert user keeps quiet, assuming that whatever opinion the "master" haves, its going to be better than theirs - after all they are the so-called experts. Carlos Ribeiro _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From senum at singnet.com.sg Sun Mar 11 22:08:07 2001 From: senum at singnet.com.sg (dr0) Date: Mon, 12 Mar 2001 11:08:07 +0800 Subject: looking for old python books Message-ID: Hi all, I was wondering if any of you have any old books on python you can sell to me? I'm a student and the prices for online stores's a bit high. Email me if you can help. Any help is deeply appreciated, thanks. Kenny From thomas at cbs.dtu.dk Thu Mar 1 11:44:19 2001 From: thomas at cbs.dtu.dk (Thomas Sicheritz-Ponten) Date: 01 Mar 2001 17:44:19 +0100 Subject: Hypergeometric distribution ? Message-ID: Does anybody have a python function/class for calculating the hypergeometric distribution ? thx -thomas -- Sicheritz-Ponten Thomas, Ph.D CBS, Department of Biotechnology thomas at biopython.org The Technical University of Denmark CBS: +45 45 252489 Building 208, DK-2800 Lyngby Fax +45 45 931585 http://www.cbs.dtu.dk/thomas De Chelonian Mobile ... The Turtle Moves ... From jkraska1 at san.rr.com Mon Mar 26 00:59:48 2001 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 26 Mar 2001 05:59:48 GMT Subject: So what's wrong with __future__? (Was Re: Why "from __future__" stinks ...) References: Message-ID: >I'm glad that it appears that even the Python gods are >implementing this hideous travesty under protest. It is truly >the ugliest hack ever--far worse than lambda, which to some >extent could have been expected. While I may be guilty of not paying attention, I just don't understand why it's needed at all? Those who don't want to play with new features should keep to an older Python revision. This is the standard way of doing things in the language business. This import from __future__ thing seems not on like a glorious hack, but terribly unnecessary. What am I missing? C// From magnus.heino at rivermen.se Thu Mar 8 09:20:04 2001 From: magnus.heino at rivermen.se (Magnus Heino) Date: Thu, 8 Mar 2001 15:20:04 +0100 Subject: m2crypto Message-ID: <9880lf$rgu$1@Merlin.et.bocholt.fh-gelsenkirchen.de> Has anyone successfully compiled M2Crypto 0.06 snapshot #2 on a linux box? This version seems to be depending on OpenSSL 0.9.6, but if I use that version I get this errormessage after installation: >>> import M2Crypto Traceback (innermost last): File "", line 1, in ? File "M2Crypto/__init__.py", line 7, in ? import _m2crypto File "M2Crypto/_m2crypto.py", line 2, in ? import _m2cryptoc ImportError: M2Crypto/_m2cryptoc.so: undefined symbol: sk_new_null I have tried different versions of SWIG, but that doesn't seem to be the problem. Any clues? -- / Magnus From chris.gonnerman at usa.net Sat Mar 31 01:50:15 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sat, 31 Mar 2001 00:50:15 -0600 Subject: newbie variables question References: Message-ID: <00af01c0b9ae$e20377a0$a100000a@local> ----- Original Message ----- From: "Michael Hall" Subject: newbie variables question> > I've been trying to do this: > > SYSPRODIR = /home/admin/systemprofile > os.system('mv /tmp/install.log SYSPRODIR/install.log') > > No matter how I play around with single and double quotes, this won't > work. You're thinking /bin/sh. Quoting has little to do with it. > But this does work: > > os.system('mv /tmp/install.log %s/install.log' %s SYSPRODIR) I hope it actually says: os.system('mv /tmp/install.log %s/install.log' % SYSPRODIR) This is one correct way to do what you want. > Is this the normal/best way to do this in Python ... seems a little > convoluted me, like there must be a simpler way. Bash for example would be > happy with something like: > > mv /tmp/install.log $SYSPRODIR/install.log > > while PHP is happy with things like: > > include ("$SYSPRODIR/install.log"); The other way in Python is this: os.system('mv /tmp/install.log ' + SYSPRODIR + '/install.log') which works fine so long as SYSPRODIR is a string. Substitution into a string is almost always done with the % operator, as in "format string" % value or for multiple values: "format string" % (v1, v2, v3) where the second operand is obviously a tuple. > Thanks for any advice. I haven't found any clear info about this in > Learning Python yet. > > Mick Happy to help. From thomas at xs4all.net Mon Mar 12 21:51:10 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Tue, 13 Mar 2001 03:51:10 +0100 Subject: ANNOUNCE Mailman 2.0.3 In-Reply-To: ; from robin@jessikat.fsnet.co.uk on Tue, Mar 13, 2001 at 12:05:06AM +0000 References: Message-ID: <20010313035110.Z404@xs4all.nl> On Tue, Mar 13, 2001 at 12:05:06AM +0000, Robin Becker wrote: > In article , Barry A. > Warsaw writes > >I've just announced the 2.0.3 release of Mailman, the GNU Mailing List > >Manager. Mailman is released under the GNU General Public License > >(GPL). > > > >I highly recommend that all sites running earlier versions of Mailman > >upgrade to 2.0.3. This release includes the important privacy patch > >from Mailman 2.0.2. Sadly, Mailman 2.0.2 contained a small but nasty > >typo requiring this new version. Mailman 2.0.3 is being released as > >both a gzip'd source tarball and as a patchfile. > thanks, I've just installed 2.0.2 and set up my first list. It's not a > problem for me now, but is it easy to install over an existing > installation? Dead easy. You can even hand-patch your 2.0.2 installation if you wish to do so. Still, patching your source tree and then running 'make install' does all that is required, and even if something other than a few modules were changed (like the format of the config.db), 'make install' would handle it. Just patch, 'make', 'make install' and all should be fine. Making a backup first is always a good idea, of course, but shouldn't be necessary :) Crossing-fingers-is-what-caused-the-typo-in-the-first-place-ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From f8dy at yahoo.com Fri Mar 2 13:35:09 2001 From: f8dy at yahoo.com (Mark Pilgrim) Date: Fri, 2 Mar 2001 13:35:09 -0500 Subject: gah! I hate the new string syntax References: Message-ID: <97op1m$plqrt$1@ID-77331.news.dfncis.de> "Sean 'Shaleh' Perry" wrote in message news:mailman.983552044.31198.python-list at python.org... > > 3. I *like* string methods, even .join() > > ";" . join() # in perl, this means concat ";" with the result of join() > > Yes, I know this is an issue you learn to deal with. However, the nice, pretty > string module at least makes python look like python. I can't help you deal with the Perl issues of your childhood, but I can recommend a good therapist. ;) > Mark, I like a lot of what I read in your book. The apihelper is a nifty idea > (if only it worked on the re module )-:). However, the coding style and Heh heh, it does work on the re module, it's just not very helpful because the module doesn't include docstrings for the top-level functions. The authors are actually aware of this; see sre.py, line 41: # FIXME: add docstrings > decisions seem counter to the python way. But maybe that is just me and my > hyper sensitivity to hard to read code after way too many lines of perl. I am always open to suggestions. I have already made some code rewrites after discussions with readers, including several clarifications in chapter 1 and a substantial rewrite in chapter 2 (using getattr instead of eval). A better place to discuss "Dive Into Python"-specific issues is Andamooka, which is hosting a mirror of the book with an integrated discussion board on each page. Unfortunately, the version of the book they have is a month out of date (and doesn't include the getattr rewrite), but it's better than cluttering up the newsgroup. http://www.andamooka.org/index.pl?section=divein -M You're smart; why haven't you learned Python yet? http://diveintopython.org/ From nkauer at users.sourceforge.net Mon Mar 12 19:09:10 2001 From: nkauer at users.sourceforge.net (Nikolas Kauer) Date: Mon, 12 Mar 2001 18:09:10 -0600 (CST) Subject: syntax exploration tool In-Reply-To: <15021.22659.616556.298360@anthem.wooz.org> Message-ID: I'd volunteer to put in time and help create such a tool. If someone sufficiently knowledgeable decides to go ahead with such a project please let me know. --- Nikolas Kauer > Second, if type annotations are to be seriously considered for > inclusion in Python, I think we as a community need considerable > experience with a working implementation. Yes, we need PEPs and specs > and such, but we need something real and complete that we can play > with, /without/ having to commit to its acceptance in mainstream > Python. Therefore, I think it'll be very important for type > annotation proponents to figure out a way to allow people to see and > play with an implementation in an experimental way. From duncan at rcp.co.uk Mon Mar 26 09:44:38 2001 From: duncan at rcp.co.uk (Duncan Booth) Date: Mon, 26 Mar 2001 14:44:38 +0000 (UTC) Subject: Lists and Files References: <99njdo$oa3$1@news.lth.se> Message-ID: "David Andreas Alderud" wrote in <99njdo$oa3$1 at news.lth.se>: >I'm new to Python, started yesterday, is there a good way to handle >lists and files? > See the documentation for the pickle and cPickle modules: >>> stooges ['val1', 'val2', 1, [['val2_1', 'val2_2', 0], ['val2_1', 'val2_2', 0]]] >>> fds = open('stooges', 'w') >>> import cPickle >>> p = cPickle.Pickler(fds) >>> p.dump(stooges) >>> fds.close() >>> fds = open('stooges', 'r') >>> u = cPickle.Unpickler(fds) >>> new_stooges = u.load() >>> print new_stooges ['val1', 'val2', 1, [['val2_1', 'val2_2', 0], ['val2_1', 'val2_2', 0]]] >>> Most common object types are picklable. From loewis at informatik.hu-berlin.de Thu Mar 22 04:15:52 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 22 Mar 2001 10:15:52 +0100 Subject: New PEP: The directive statement References: Message-ID: hzhu at users.sourceforge.net (Huaiyu Zhu) writes: > So with this directive PEP, the parallel would be > > directive transitional nested_scope > directive experimentatal stackless > directive optional static_type > directive mandatory string_methods > > Is this correspondence correct? (You may not agree on the need for other > directives, but I want to know if the keyword translations are correct.) That is a possible application. The syntax allows other choices as well, e.g. directive static_type directive stackless 0 > 1. It introduces a new syntax while an existing syntax could be reused > without much cost. You mean, import can be reused without much cost? The cost of reusing import is quite high; it causes irritation among users. > 2. There is no place for version and documentation info. That is true. > So far as I can see, the impetus for directive keyword is that import is a > run time action, while the __future__ is a compile time declaration. But is > it so far a stretch? All Python __magic__ words go beyond normal meaning. > Defining __setattr__ will affect more than this method alone. Having > __init__.py will cause other modules to be imported. And so on. That is what I dislike in the __ convention. Syntactically, they are identifiers. Semantically, they are reserved words. > If we look more broadly, in *nix, devices, processes, pipe and others are > also represented as files. Would it better to assign special syntax to all > of them? Or, taking the analogy further: sockets should be represented as files as well, to open a socket, you should really open some file, not invoke a special function. Yet, history shows that the version with the special API was the successful one, not the version with the files. Generalization is a dangerous thing: you can too easily cross the border to over-generalization. > IMHO, reusing existing syntax is closer to Python than Perl, which > introduces new syntax for many things that are only slightly different. Are you saying that activating nested scopes is only slightly different from importing modules? Regards, Martin From petr at ai.mit.edu Fri Mar 23 23:48:37 2001 From: petr at ai.mit.edu (Petr Swedock) Date: Fri, 23 Mar 2001 23:48:37 -0500 Subject: python, perl, lisp, tcl / got a decision to make, can you give me a view point please ? and a joke for python users :) In-Reply-To: References: <3aba3076.14395287@news.vif.com> Message-ID: On Sat, 24 Mar 2001, Tim Hammerquist wrote: > Yvon Boulianne wrote: > > i know a bit of perl and tcl, (i find > > perl too much cryptics, difficult to understand other people scripts) > > Damn! Not even a mystic can make sense of Perl. =) Normally, a mystic wouldn't have to, they'd just divine intent. This too is impossible to do with Perl =-) And while I don't have a 'joke for python users', I do often tell others that if Guido van Rossum were a true Monty Python fan he'd have named the language "Raymond Luxury-Yacht" AND require that people pronounce it "Throat Warbler Mangrove." =-) Does that count? Peace, Petr Systems, Networks and Gadgets, done with Artful Intelligence -<>-<_>-<__>-<_>-<>- Policy: ASCII/text attchmnts alway read. PDF maybe read. Others, by neccesity, may be ignored. Don't take it personally, it's a time issue. From topmind at technologist.com Thu Mar 1 22:11:54 2001 From: topmind at technologist.com (Topmind) Date: Fri, 02 Mar 2001 03:11:54 GMT Subject: Stream interfaces References: <3A9E54F9.7AF90BCA@ix.netcom.com> Message-ID: > tgagne at ix.netcom.com (Thomas Gagne) wrote (abridged): > > Your correct. People are confusing inheritence and usefulness. I > > don't have enough spare cycles to worry about a class' > > inheritence unless I've discovered missing functionality. Since > > I haven't, I haven't. > > Well, I have. In the streams hierarchy, too. Albeit not that vendor and > in a beta product so I probably shouldn't say too much about it, but the > hierarchy was very similar. The problem was analogous to methods added to > WriteStream not magically appearing in ExternalWriteStream. > > The vendor's fix was to cut&paste methods from one class to the other. > But this is just sticking plaster. The class hierarchy is deeply wrong, > violates "once and only once" all over the place and needs refactoring. > It's not about missing functionality so much as how we can add new kinds > of stream without more error-prone cut&paste. > > Whether this can be fixed without breaking existing clients, or fixed at > all without multiple inheritance, I don't know because I've not tried it. > I hope it can be and the problem is not with Smalltalk generally but just > this particular bit of library design. But for whatever reason, this bit > of library design is not ideal. > Where did the deep hierarchy kind of library design trend start? Can anybody pinpoint an event or "leader" who appears to have started that trend/fad? And, why did the other vendors follow? "Technical sociology" would make a fascnating topic or study area IMO. > Dave Harris, Nottingham, UK -tmind- From emile at fenx.com Wed Mar 21 17:21:00 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 21 Mar 2001 14:21:00 -0800 Subject: I'm sure there's a good reason! References: Message-ID: <99b9m8$gq44$1@ID-11957.news.dfncis.de> You aren't allowed to end a raw string with an odd number of \'s. Emile van Sebille emile at fenx.com "Tim Rowe" wrote in message news:memo.20010321220225.57471D at digitig.compulink.co.uk... > Can any of the assembled experts explain to me why: > print r"\hello" > is fine, but > print r"hello\" > isn't? In other words, why does the backslash escape quotes in a raw > string? At one level I'm going to guess (without reading the spec) that > it's because "that's what the spec says", but why? I thought the idea of > raw strings was that they /didn't/ handle escapes! > > TIA, > > Tim > From rav at smo3k.z.pl Tue Mar 6 06:39:11 2001 From: rav at smo3k.z.pl (Rafal Smotrzyk) Date: Tue, 6 Mar 2001 12:39:11 +0100 Subject: python cgi syntax highlighter References: Message-ID: <982i66$rrh$1@news.tpi.pl> # Rafal Smotrzyk # 24/11/2000 # mailto:rsmotrzyk at mikroplan.com.pl import tokenize import token import keyword import string import sys import os d_builtins = { '__debug__' : 1, '__doc__' : 1, '__import__' : 1, '__name__' : 1, 'abs' : 1, 'apply' : 1, 'buffer' : 1, 'callable' : 1, 'chr' : 1, 'cmp' : 1, 'coerce' : 1, 'compile' : 1, 'complex' : 1, 'delattr' : 1, 'dir' : 1, 'divmod' : 1, 'eval' : 1, 'execfile' : 1, 'exit' : 1, 'filter' : 1, 'float' : 1, 'getattr' : 1, 'globals' : 1, 'hasattr' : 1, 'hash' : 1, 'hex' : 1, 'id' : 1, 'input' : 1, 'int' : 1, 'intern' : 1, 'isinstance' : 1, 'issubclass' : 1, 'len' : 1, 'list' : 1, 'locals' : 1, 'long' : 1, 'map' : 1, 'max' : 1, 'min' : 1, 'oct' : 1, 'open' : 1, 'ord' : 1, 'pow' : 1, 'quit' : 1, 'range' : 1, 'raw_input' : 1, 'reduce' : 1, 'reload' : 1, 'repr' : 1, 'round' : 1, 'setattr' : 1, 'slice' : 1, 'str' : 1, 'tuple' : 1, 'type' : 1, 'unload' : 1, 'vars' : 1, 'xrange' : 1, } class PrettyPyPrinter: def __init__(self,aspage=1): self.AsPage=aspage def TokenEater(self,atokentype,atokenstring,abeginrowcolumntuple,aendrowcolumntu ple,aline): brow,bcol=abeginrowcolumntuple erow,ecol=aendrowcolumntuple self.token_list.append([brow,bcol,erow,ecol,atokentype,atokenstring]) def Process(self,fnamein,fnameout): fin=open(fnamein,'r') try: self.Tokenize(fin) finally: fin.close() fout=open(fnameout,'w') try: self.Generate(fout) finally: fout.close() def InsertTag(self,arow,acol,s): self.lines[arow-1]=self.lines[arow-1][:acol]+s+self.lines[arow-1][acol:] def Tokenize(self,fin): self.token_list=[] tokenize.tokenize(fin.readline,self.TokenEater) fin.seek(0) self.lines=fin.readlines() self.token_list.sort() self.token_list.reverse() def Generate(self,fout): for i in range(len(self.token_list)): brow,bcol,erow,ecol,atokentype,atokenstring=self.token_list[i] processed=' ' if atokentype==token.OP: self.InsertTag(erow,ecol,'') self.InsertTag(brow,bcol,'') processed='*' elif atokentype==token.NAME: if keyword.iskeyword(atokenstring): self.InsertTag(erow,ecol,'') self.InsertTag(brow,bcol,'') elif d_builtins.has_key(atokenstring) and self.token_list[i+1][5]!='.': self.InsertTag(erow,ecol,'') self.InsertTag(brow,bcol,'') elif i>0 and self.token_list[i+1][5] in ['def','class']: self.InsertTag(erow,ecol,'') self.InsertTag(brow,bcol,'') elif i>0 and self.token_list[i-1][5]=='(': self.InsertTag(erow,ecol,'') self.InsertTag(brow,bcol,'') elif atokenstring=='None': self.InsertTag(erow,ecol,'') self.InsertTag(brow,bcol,'') else: self.InsertTag(erow,ecol,'') self.InsertTag(brow,bcol,'') processed='*' elif atokentype==token.NUMBER: self.InsertTag(erow,ecol,'') self.InsertTag(brow,bcol,'') processed='*' elif atokentype==token.STRING: self.InsertTag(erow,ecol,'') self.InsertTag(brow,bcol,'') processed='*' elif atokentype==token.N_TOKENS: self.InsertTag(erow,ecol,'') self.InsertTag(brow,bcol,'') processed='*' elif atokentype in [token.NEWLINE,token.INDENT,token.DEDENT,token.ENDMARKER,40]: #40==NL processed='*' if processed==' ': print '%s %5d%5d%5d%5d | %d%20s >%s<'%(processed,brow,bcol,erow,ecol,atokentype,token.tok_name[atokentype],r epr(atokenstring)) i=i+1 if self.AsPage: fout.write('\n') fout.write('
')
      for aline in self.lines:
         s=string.replace(aline,'\n','
\n') s=string.replace(aline,chr(255),' ') fout.write(s) fout.write('
') if self.AsPage: fout.write('\n') if __name__=='__main__': if len(sys.argv)==3: fname1=sys.argv[1] fname2=sys.argv[2] elif len(sys.argv)==2: fname1=sys.argv[1] fname2=os.path.splitext(fname1)[0]+'.html' else: print 'py2html input.py [output.html]' sys.exit() aprinter=PrettyPyPrinter() aprinter.Process(fname1,fname2) From not.this at seebelow.org Fri Mar 30 22:44:29 2001 From: not.this at seebelow.org (Grant Griffin) Date: Fri, 30 Mar 2001 21:44:29 -0600 Subject: Know of Substantial Apps Written in Python? References: <3ac4e4a8_1@news4.newsfeeds.com> Message-ID: <3AC5529D.8D7BCC63@seebelow.org> Grant Edwards wrote: > > In article , David Allen wrote: > > >What's the definition of "substantial"? > > > >There's Grail, a web browser > >http://grail.sourceforge.net > > Anybody get Grail to work lately? Last time I tried it > wouldn't run. > > >There's ZOPE, an internet publishing thingy > >(thingy is a technical term :) > > Sketch is one of my favorites: > > http://sketch.sourceforge.net/ Hi Grant, Hey, I looked at that, and it looks cool. But I was somewhat puzzled by the following statement: Sketch is an interactive vector drawing program for Linux and other UNIX compatible systems. A somewhat unique(for a drawing program) feature of Sketch is that it is implemented almost completely in a very high-level, interpreted language, Python. If it's implemented almost completely in Python, why does it only run on "UNIX-compatible" systems? (BTW, does it delete hyphens? ) Is there something about its "almost" part that can't be done in Windows. free-software-isn't-just-for-unix-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From db3l at fitlinxx.com Fri Mar 30 13:17:33 2001 From: db3l at fitlinxx.com (David Bolen) Date: 30 Mar 2001 13:17:33 -0500 Subject: mxODBC chokes on dates! Any Help? References: Message-ID: Owen Ap Owen writes: > I'm using mxODBC from Python 2.0 under Win32. I have a functional ODBC > connection but when I try to select data that includes date fields mxODBC > chokes. I ran into the same problem with some date fields in an MS SQL Server database, and Marc-Andre was able to revert back to an earlier way of handling date fields (he preferred a different C data type if defined in 2.0.0 than in earlier versions) to resolve it. I was traveling and was a little tardy getting back to verify that the fix worked, but I expect it will show up in the next release of mxODBC. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From djc at object-craft.com.au Thu Mar 1 20:00:13 2001 From: djc at object-craft.com.au (Dave Cole) Date: 02 Mar 2001 12:00:13 +1100 Subject: Help with finding how much memory a variable is using References: <97dhh2$p9ul0$1@ID-11957.news.dfncis.de> Message-ID: >>>>> "Rich" == Rich Somerfield writes: Rich> That code would be gratefully received. Rich> rich_somerfield at nO-sPaM.tertio.com Oops - I somehow missed your response. I wrote the code for someone else quite a while ago to demonstrate a point. They wanted to be able to load massive electronic schematic files and make them available to Python. The problem was similar to yours, due the amount of the data they were loading, Python was just too slow and too resource hungry. They had a yacc grammar which they were using and wanted to make the parse tree available to their Python code. I did not have any schematic files I could load, so I picked the largest text file I could find on my computer; the Debian Packages file. Since I was only trying to demonstrate a technique, I took a few shortcuts. I did not bother trying to write a yacc grammar, I just wrote a simple parser in C. Instead of building my own collections, I used those which come in GLIB. There is too much code to post here, so I have placed it on our web server. http://www.object-craft.com.au/projects/lazy/ There is a benchmark program which compares the speed of the raw parser and the parser accessed through a Python module. On my machine, the Packages file is 121,111 lines and 4,471,834 bytes. The benchmark program prints the following: Raw parser loads in 0.70 seconds aalib1 1.2-18 aalib1 1.2 libc6 2.2.1 libgpmg1 1.14-16 slang1 1.3.0-0 xlibs 4.0.1-11 Wrapped parser loaded and used in 0.75 seconds - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #!/usr/bin/env python import os import time file = '/var/state/apt/lists/ftp.us.debian.org_debian_dists_unstable_main_binary-i386_Packages' # Prime the buffer cache os.system('./pkg_test %s' % file) t0 = time.time() os.system('./pkg_test %s' % file) t1 = time.time() print 'Raw parser loads in %.2f seconds' % (t1 - t0) import dpkg main = dpkg.load_file(file) deps = main.packages['aalib-bin'].Depends for dep in deps: print dep.Package, dep.Version t2 = time.time() print 'Wrapped parser loaded and used in %.2f seconds' % (t2 - t1) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The files are: Makefile.pre.in -- used to build module Setup.in -- used to build module benchmark.py -- the above benchmark program dpkg.c -- the Python wrapper of the parser pkg.c -- simple (and incomplete) Packages file parser pkg.h -- parser interface pkg_test.c -- drives the parser from C The key to the technique is that Python proxies for the parse tree nodes are created on demand. The Python attributes of each parse tree node are created on demand. dpkg.c is the interesting file as it demonstrates the technique. The dpkg.c file should have probably been two files as it contains two things; but what the hell, I wrote this for someone to demonstrate a point. It contains the building blocks for constructing the lazy evaluation proxy objects, and it also contains the proxies for the pkg.c parser. If enough people are interested, I will do some more work on splitting the code up to make it more general. Oh, to build and test the code do this: % make -f Makefile.pre.in boot % make % cc -g -Wall -o pkg_test pkg_test.c pkg.c `glib-config --cflags --libs` % ./benchmark.py Traps for young players: 1- The data is read-only. 2- If you drop the reference to the top level parse tree object, things will go bad very quickly (main in the benchmark program). - Dave -- http://www.object-craft.com.au From digitig at cix.co.uk Wed Mar 14 19:42:00 2001 From: digitig at cix.co.uk (Tim Rowe) Date: Thu, 15 Mar 2001 00:42 +0000 (GMT Standard Time) Subject: DOS python? References: <20010311104606.07469.00000559@ng-cj1.aol.com> Message-ID: In article <20010311104606.07469.00000559 at ng-cj1.aol.com>, park997 at aol.comnotospam (Park997) wrote: > Hi, > > I would appreciate any pointers on obtaining a version of > python that operates on an HP LX200 (DOS 5, 80186 CPU; > essentially 8 bit IBM XT equivalent). I found a python16 that > runs on Windows, but not on the LX200. I'd like that too, but I doubt you'd get much of the library in there even if you had the interpreter! From ransen_spam_me_not at nemo.it Sun Mar 4 11:15:39 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Sun, 04 Mar 2001 16:15:39 GMT Subject: Bug in Py_Finalize() ? References: <3a9f636d.2908314@news.newsguy.com> Message-ID: <3aa20ae3.3454319@news.newsguy.com> On Fri, 02 Mar 2001 09:32:12 GMT, ransen_spam_me_not at nemo.it (Owen F. Ransen) wrote: With Python 2.1b1 this now works for (UINT i = 0 ; i < 100 ; i++) { Py_Initialize () ; Py_Finalize () ; } This is all the Python I am using in my VC6 MFC based program in the InitInstance function and which previously crashed Python. -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From aleaxit at yahoo.com Tue Mar 20 04:36:01 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 20 Mar 2001 10:36:01 +0100 Subject: Sequence-spreading References: <3AB7167F.2816AA21@student.liu.se> Message-ID: <99790u01c73@news2.newsguy.com> "Rikard Bosnjakovic" wrote in message news:3AB7167F.2816AA21 at student.liu.se... > Hi. > > I made a small spreading-sequence with the following code: > > ------ > arg = "some string" > pm = 3 > offsets = [] > for i in xrange(pm): > everyX = filter(lambda y: not divmod(y, pm)[1], range(len(arg))) > added = map(lambda x: x+i, everyX) > offsets.append(filter(lambda x: x > print offsets > ------ > > which gives the correct result: > > >>> ## working on region in file /usr/tmp/python-3115DCp... > [[0, 3, 6, 9], [1, 4, 7, 10], [2, 5, 8]] > > "pm" is the number of sequences, and then the sequences are increasing. > 0 in first, 1 in second, 2 in third, 3 in first and so on, until the > length of the string 'arg' is reached. However, the loop-code is pretty > unreadable and awkward. > > Anyone got a better solution for it? The following is simpler: offsets = [ [] for i in range(pm) ] for i in range(len(arg)): offsets[i%pm].append(i) Alex From mcfletch at home.com Mon Mar 19 00:22:16 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Mon, 19 Mar 2001 00:22:16 -0500 Subject: Dragon Macros (was: RE: Help Rewriting/Refactoring/Rethinking Parsing Algorythm) Message-ID: <000601c0b034$90c79200$a9807018@cr706570a> For those who are curious, here's a set of macros that seem to work nicely for the names: In VocEdit, define the following, then train them in vocabulary editor (the items with nothing before the slash are supposed to have nothing there, these are non-visible elements)... \pyname, LowerCase next word, Turn Capitalisation On, Turn off Spacing between words \pycaps, Turn Capitalisation On, Turn off Spacing between words \pynorm, Restore Normal Capitalisation, Restore Normal Spacing \pynormal, Restore Normal Capitalisation, Restore Normal Spacing if __name__ == "__main__":\pymainline, Follow with one newline character The last entry eliminates the need for a __name__ and __main__ entry, which frees up the pyname entry for use as a lowerUpperUpper macro (and yes, I did dictate that using the macro :) ). pynormal is more natural feeling than pynorm when you're first getting used to it. I'm considering adding "add an extra space following this word" for pynorm (without it you get some less-than-attractive effects, but with it I'd need another phrase for "stop the caps and spaces but don't space" for when doing a dotted name. Oh, pyconstant might be introduced to give an ALL-CAPS + No Space macro. Making a script that auto-created all those + the def, equals, triple-quote, etceteras and asked the user to train each a couple of times would be cool. Maybe when I'm out of a job I'll look into it. Anyway, enjoy all, Mike -----Original Message----- From: Mike C. Fletcher [mailto:mcfletch at home.com] Sent: Sunday, March 18, 2001 11:32 PM To: 'Boopy Bootles'; python-list at python.org Subject: RE: Help Rewriting/Refactoring/Rethinking Parsing Algorythm ... Looking at your list, adding: py-caps -> \No-Space-On\Caps-On py-norm -> \No-Space-Off\Caps-Off py-name -> \No-Space-On\Caps-On [ not sure if you can do this without a macro... ] ... -----Original Message----- From: Boopy Bootles [mailto:aschneid at mindspring.com] Sent: Sunday, March 18, 2001 8:57 PM To: python-list at python.org Subject: Help Rewriting/Refactoring/Rethinking Parsing Algorythm I'm trying to write a simple piece of code to make programming by voice recognition software easier to do. I wrote a very simple function that would, for example, convert "number customers equals 5" to "numberCustomers = 5". But once I started using it, I quickly discovered several more cases I had to handle. So far, this is the list: ... From me at nospam.net Sun Mar 25 02:09:34 2001 From: me at nospam.net (Scottie) Date: Sat, 24 Mar 2001 23:09:34 -0800 Subject: "object" vs "dynamic" programming styles References: <3ABD117E.1E5492C4@erols.com> <3ABD2390.A2A28A12@letterror.com> Message-ID: "Just van Rossum" wrote in message news:3ABD2390.A2A28A12 at letterror.com... > "Edward C. Jones" wrote: > > Here are three methods for doing the same thing. When is it better to use > > one of the approaches rather than another? > > > # Program 3 > > > > # The function New_X returns an instance of either class A or class B. > > def New_X(c): > > if c == 'a': > > return A() > > if c == 'b': > > return B() > > My personal preference would definitely be version 3, the factory function. > Less magic, clearer code. I concur, but would cause an exception when your cases don't match. This inspires a variation as follows: generators = {'a':A, 'b':B, 'c':C} def New_X(c): return generators[c]() -Scott David Daniels From cribeiro at mail.inet.com.br Sat Mar 31 09:35:37 2001 From: cribeiro at mail.inet.com.br (Carlos Alberto Reis Ribeiro) Date: Sat, 31 Mar 2001 11:35:37 -0300 Subject: list vs tuple In-Reply-To: References: <3AC20CD3.265A2D94@alcyone.com> <71q9ct4le63anefmiajj5cbh3mg04qu1ga@4ax.com> <7Bfx6.989$p5.3791@news1.rivrw1.nsw.optushome.com.au> Message-ID: <5.0.2.1.0.20010331111632.021e92e0@mail.inet.com.br> At 10:01 31/03/01 +0000, deadmeat wrote: >What python DOES is irrelevant - the way it's written (and therefore viewed >by programmers coming from other languages) makes it inconsistant. The same >statement (a = b) behaves entirely differently in each case. I also came from a Pascal background (I used UCSB Pascal 15 years ago, and Turbo Pascal 1.0 (!) :-P), and I can tell you that this is not exactly true for Pascal either. Using "pure" Pascal, an assignment is expected to copy the value from the right side to the left side. There is a number of catches, however: - The copy operation can be expensive if the variable is a large object. - Stack space is a concern. Copying large parameters take up a lot of stack space. There were some limitations on the return types accepted in older version of Pascal because of this also. - There is an difference between "copy" and "deep copy". What happens if you make copy a structure that contains pointers in it? The pointers themselves are copied, but the "pointed" copy is still the same. As you don't have garbage collection or ref count, it's up to you to manage the situation to avoid freeing memory space while some copy of your structure is still pointing to the original memory area. In Delphi, and also in other variants of Object Pascal, you have classes, and that changes everything. Class instances are always references, in a way very similar to Python classes. So if you do the following in Delphi, what do you get? a := TStringList.Create; b := a; a.Add('One line'); /* b now contains the same line added to A */ As you may see, reference copy is everywhere - even inside Pascal :-) Carlos Ribeiro From lloyd at venix.com Mon Mar 26 19:42:30 2001 From: lloyd at venix.com (Lloyd Kvam) Date: Mon, 26 Mar 2001 19:42:30 -0500 Subject: boolean values in COM / VB / Python References: Message-ID: <3ABFE1F6.4232DE4E@venix.com> My guess is that you don't have a COM wrapper in place for the Document. In other words: import win32com.client ie = win32com.client.Dispatch("InternetExplorer.Application") ie.Visible = 1 # toggles window visible ie.Visible = 0 # toggles window invisible ie.GetHome() # loads the home page Now when you refer to ie.Document you are actually referring to a new object. I believe that you will need to do some work to provide the wrapper so that Python values get translated to the equivalent COM values. "John J. Lee" wrote: > > ie.Document.execCommand("SaveAs", false, pathname) > > where ie is an Internet Explorer object, pops up a dialogue box, no matter > what value for false I try, from (1==0, 0, "0", None). According to the MS > docs at > > http://msdn.microsoft.com/workshop/author/dhtml/reference/constants/saveas.asp > > and > > http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/execCommand.asp > > this isn't supposed to happen, because when the second argument to > execCommand is 'false', the command 'Does not display a user interface'. > According to Mark Hammond just last month, 0 should do fine as a way of > representing 'false': > > http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=1cd0ed3943dead44&thn=Setting+boolean+COM+properties&seekd=926499672 > > Any clues as to what is happening? > > Tips on the differences between C++ / VB and Python in general would also > be appreciated -- presumably there must be some reliable and mechanical > way of doing this? > > John -- Lloyd Kvam Venix Corp. 1 Court Street, Suite 378 Lebanon, NH 03766-1358 voice: 603-443-6155 fax: 801-459-9582 From phlip_cpp at my-deja.com Sat Mar 31 14:27:06 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 31 Mar 2001 19:27:06 GMT Subject: Billy vs. Idle Message-ID: <9a5b2a$fh9@freepress.concentric.net> Hy on pt: I done noticed that Bill Gate's program VC++ has this irrelevant little feature that nobody hardly notices: If you compile and your source has an error, you can tap and the editor will raise the offending file and highlight the offending line. Why on earth doesn't IDLE have this feature? (I know I know - because I haven't added it yet...) -- Phlip phlip_cpp at my-deja.com ============== http://phlip.webjump.com ============== -- Because I'm the sysadmin. That's why. -- From me at nospam.net Sat Mar 31 21:27:49 2001 From: me at nospam.net (Scottie) Date: Sat, 31 Mar 2001 18:27:49 -0800 Subject: PythonLabs Team Moves to ActiveState References: Message-ID: "Pete Shinners" wrote in message news:v4wx6.121194$Ch.16134973 at typhoon.we.rr.com... > i've got a knot in my stomach. i can't tell if this is a terrific > april fools joke or just about the worst news i've heard in a long > time. I agree completely. Imagine having to indent Perl! the horror, the horror.... From johann at physics.berkeley.edu Wed Mar 28 17:13:08 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 28 Mar 2001 14:13:08 -0800 Subject: Is inheritance broken? References: Message-ID: Jonathan Claggett writes: > Interesting. Are there conventions for mixin classes which distinguish them > from normal classes? For example, are mixins not suppposed to use > inheritance (or at least not use mulitple inheritance)? Thanks for the help, When I use mixins, I never use inheritance. The mix-in just provides methods, to be included into other classes. There is no enforced protocol, but I find that useful. Otherwise, I have to start worrying about how python will search the mix- ins, and that gets ugly quickly. I also often define classes which are simply different combinations of mix-ins, such as class SpecPlotStepper(SpecMixin, PlotMixin, Stepper): pass I hope that helps. In theory, I like the way Common Lisp implemented multiple inheritance, but that would require too much searching given python's class system. --J -- Johann Hibschman johann at physics.berkeley.edu From aahz at panix.com Fri Mar 2 12:01:45 2001 From: aahz at panix.com (Aahz Maruch) Date: 2 Mar 2001 09:01:45 -0800 Subject: gah! I hate the new string syntax References: <97ohh2$polt0$1@ID-77331.news.dfncis.de> Message-ID: <97ojlp$g53$1@panix3.panix.com> In article <97ohh2$polt0$1 at ID-77331.news.dfncis.de>, Mark Pilgrim wrote: > >-M feeling-old-and-crotchety-already-ly There, there, sonny, I know just how you feel. -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Nostalgia just ain't what it used to be From nomail at nomail.com Fri Mar 30 15:02:14 2001 From: nomail at nomail.com (Dry Ice) Date: Fri, 30 Mar 2001 12:02:14 -0800 Subject: Know of Substantial Apps Written in Python? Message-ID: <3ac4e4a8_1@news4.newsfeeds.com> Know of substantial apps written in Python? Preferably something one could download for examination. Source code would be nice, but not essential. I'm operating under the theory that whatever the POTENTIAL of a language, or the 'elegance' of a language's syntax and structure, how large apps actually behave in the real world will speak volumes. I like, for example, much about Java. But nearly every example I have seen running in the Windows environment has been slow, leaked resources and eventually contributed to system crashes. (I don't care whether it's the language or the OS or the VM or even "bad programming." What counts are the usual results obtained by normal application developers.) Suggestions? From vincent_a_primavera at netzero.net Tue Mar 27 10:57:03 2001 From: vincent_a_primavera at netzero.net (Vincent A. Primavera) Date: Tue, 27 Mar 2001 10:57:03 -0500 Subject: Curses... Message-ID: <01032710570303.00574@tos1> Hello, I recently downloaded the "Curses Programming with Python" HOWTO and it suggests to begin by importing the curses module. I tried to do this with: 'import curses' to no effect. I realize that there is a module wrapper.py in the /usr/lib/python2.0/curses directory but I am unsure of how to use this module to access the curses functions directly. Any suggestions would be much appreciated. Thank You, Vincent A. Primavera From phd at phd.pp.ru Wed Mar 21 07:05:10 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 21 Mar 2001 15:05:10 +0300 (MSK) Subject: Checking the type In-Reply-To: <99a493$bhl$1@sun.rhrk.uni-kl.de> Message-ID: On Wed, 21 Mar 2001, Markus Reitz wrote: > is there a possibilty to check if a variable refers to an object of type x? Yes, builtin fuction type(x): if type(x) <> type([]): print "not list!" Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From amused at webamused.com Thu Mar 22 17:23:03 2001 From: amused at webamused.com (Joshua Macy) Date: Thu, 22 Mar 2001 22:23:03 GMT Subject: Why Python/Jython? References: <99cl9e$b2b$1@Merlin.et.bocholt.fh-gelsenkirchen.de> <1901D50DC30D30E4.16551C1AB0FB4363.C0D72E208759F8A7@lp.airnews.net> <99dkg301894@news1.newsguy.com> Message-ID: <3ABAB2F7.127D3872@webamused.com> Alex Martelli wrote: > > "Cameron Laird" wrote in message > news:1901D50DC30D30E4.16551C1AB0FB4363.C0D72E208759F8A7 at lp.airnews.net... > [snip] > > meaningful. People do NOT start learning > > Java lightly; it often takes hours just to > > install and configure a minimal JDK, let > > *blink* -- I'm hardly a Java-ite, myself, but > "install and configure a minimal JDK" I would > estimate as typically a 10-minute job (on, say, > NT -- is it an order of magnitude harder on, > say, Linux?!). Maybe I misunderstand what > you mean...? > It only takes about 10 minutes to download a Win32 installer and run it--but if by configure one means understand and implement workable solutions to the cryptic and bizarre interaction between Java package namespaces, classpaths, and the WinNT filesystem, I think an hour might be an underestimate. Most programmers I know who art trying to "get into" Java end up either putting every jar in the world into their CLASSPATH environment variable, or downloading and installing something like SmartJ...but it takes them more than an hour to arrive at one of those solutions unless they have someone to help them. Joshua From gradha at iname.com Sat Mar 10 13:16:03 2001 From: gradha at iname.com (gradha at iname.com) Date: Sat, 10 Mar 2001 19:16:03 +0100 Subject: Problems writting a wrapper around linux' ssh command Message-ID: <31rd89.lki.ln@127.0.0.1> Hi. I am trying to write a python wrapper around ssh. The last and only problem I have is password verification. I try to popen2.popen3 the ssh command, but no matter what I write to the input file, the ssh command ignores it and keeps requesting *keyboard* input. Is there any way to avoid this? -- Grzegorz Adam Hankiewicz gradha at iname.com - http://gradha.infierno.org Other web pages: http://glub.ehu.es/ - http://welcome.to/gogosoftware/ From grante at visi.com Fri Mar 30 10:45:11 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 30 Mar 2001 15:45:11 GMT Subject: Creation d'un NG francophone sur Python References: <1eqzyk6.gxd4jr1tkjykzN%francois.granger@free.fr> <9a1e6f011es@enews3.newsguy.com> Message-ID: In article <9a1e6f011es at enews3.newsguy.com>, Michael Spencer wrote: >Pardon, mais pourquoi un NG pour Python en fran?ais? > >Python a cr?? par un nederlandais qui a ?crit en anglais - pas >sa langue natif. Il a ?crit en anglais ? assurer la plus grande >distribution de ses id?es. Pourquoi on marcherait en arri?re >aux temps quand chaque groupe a maintenu sa <> >par s'isoler des autres? I certainly would never vote against a French Python newsgroup. But, I want to let you know that French language postings are quite welcome in this group -- as are threads in any other language. You've even got a fair chance of getting replies to questions posted in Esperanto. -- Grant Edwards grante Yow! A GRAM?? A BRAM... A at GROOM... A BROOM... Oh, visi.com Yeh!! Wash the ROOM!! From greg at cosc.canterbury.ac.nz Thu Mar 8 19:25:18 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 09 Mar 2001 13:25:18 +1300 Subject: "!=" is bad form. Re: sorry....never mind References: <3AA6E308.5B63ECC6@cosc.canterbury.ac.nz> <3AA72253.FB021815@Lugoj.Com> Message-ID: <3AA822EE.F77D956F@cosc.canterbury.ac.nz> Marcin 'Qrczak' Kowalczyk wrote: > > Icon uses "~=" for numbers and "~==" for strings. And I seem to recall it also uses ~=== for something else as well (lists? dictionaries?). By the time I got to the part about the corresponding assignment operators (~===:= et al) my brain was laughing itself silly and thinking "This has *got* to be a joke!" Unfortunately, it wasn't. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From mwh21 at cam.ac.uk Thu Mar 29 17:52:18 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 29 Mar 2001 23:52:18 +0100 Subject: macro file (containing C def's) for source navigator? References: <0m4w6.91100$A6.20818962@news4.rdc1.on.home.com> Message-ID: "Tom" writes: > Does anyone have a Source Navigator macro file for the Python source > code? (This is a file that lists the preprocessor symbol > definitions for a project.) Well, I don't. > Do the python internals hackers use Source Navigator? What do they use? Not a fully fledged python internals hacker, but I use emacs, occasionally etags, cscope. And gcc, of course. > Is this information available somewhere in the source distribution, > so I can make my own macro file? Aren't there tools analagous etags & ctags to generate this sort of info? Cheers, M. -- ARTHUR: Why should a rock hum? FORD: Maybe it feels good about being a rock. -- The Hitch-Hikers Guide to the Galaxy, Episode 8 From ct at gocept.com Thu Mar 22 11:56:22 2001 From: ct at gocept.com (Christian Theune) Date: Thu, 22 Mar 2001 17:56:22 +0100 Subject: Curses under python 2.0 Message-ID: <99darm$o3o$00$1@news.t-online.com> hmm ... it seems as the python-curses mod won't work: Python 2.0 (#3, Feb 10 2001, 16:51:03) [GCC 2.95.2 19991024 (release)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import curses Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.0/curses/__init__.py", line 15, in ? from _curses import * ImportError: No module named _curses >>> any idea? it is the installation from the python2.0 source, and I tested the curses lib with python 1.5.2 - and it is working. Thanks for replying to my mail address too. best regards Christian Theune From danielk at aracnet.com Fri Mar 9 11:03:35 2001 From: danielk at aracnet.com (Daniel Klein) Date: Fri, 09 Mar 2001 08:03:35 -0800 Subject: Python RMI? Message-ID: Does Python have an equivalent or substitute for Java's RMI? Daniel Klein From aahz at panix.com Fri Mar 23 14:58:31 2001 From: aahz at panix.com (Aahz Maruch) Date: 23 Mar 2001 11:58:31 -0800 Subject: New PEP: The directive statement References: <200103201042.LAA20248@pandora.informatik.hu-berlin.de> <3d1yrp1osi.fsf@ute.cnri.reston.va.us> <3ABBA837.DEB8AB1B@san.rr.com> Message-ID: <99g9t7$r9j$1@panix6.panix.com> In article <3ABBA837.DEB8AB1B at san.rr.com>, Darren New wrote: >Andrew Kuchling wrote: >> >> It's really a documentation issue; people who release software should >> say "I've tested this with Python 2.0", and people with 1.5.2 or 2.1 >> will have to look out, and perhaps provide patches to fix problems. > >What is the Python mechanism for ensuring a particular (or minimal) version >of Python is being used? Is there one? I'm talking about something like >Tcl's [package require Tcl 8.3] or some such. assert (sys.version_info[0] >= 2) and (sys.version_info[1] > 0) (If you want this to work on Python 1.5.2 and earlier, use sys.version.) -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "I won't accept a model of the universe in which free will, omniscient gods, and atheism are simultaneously true." -- M From dnew at san.rr.com Thu Mar 22 11:25:40 2001 From: dnew at san.rr.com (Darren New) Date: Thu, 22 Mar 2001 16:25:40 GMT Subject: email address verification References: <99d5qi$95l$1@solaria.cc.gatech.edu> Message-ID: <3ABA2785.3CF81953@san.rr.com> > does python provide quick/simple way to verify that an email address exist? It depends on what you mean by "exist" to a great extent. > i looked at the smtp library and the verify method but that does not seem > to be very standard anymore. It is standard, except spammers have caused most ISPs to turn off this useful functionality, yes. (Pendatically yours...) > is there anything else that is simalar? The best way to do this is to take the email address (fred at example.com) and look up the MX records for the domain (example.com), or the A record if no MX records. Find the MX record with the lowest priority number. Open an SMTP connection to that host. Do a MAIL FROM:<> and then a RCPT TO: then a RSET and a QUIT. If the RCPT TO and everything before it succeeds, you have an "existing" email address. It might not be the address that gets delivered to fred, but the mail will get delivered. I.e., it might generate a bounce return, but there's no way to distinguish between "I delivered it successfully to a program from which Fred will fetch it" and "I delivered it successfully to a program which will automatically generate a message saying Fred doesn't live here." Hope this helps. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. A million monkeys in a room with a million typewriters will only yield half a million pregnant monkeys. From sholden at holdenweb.com Mon Mar 5 20:58:53 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 5 Mar 2001 20:58:53 -0500 Subject: Can anyone recomend a good intoduction to C... References: <3aa366c6_2@nnrp1.news.uk.psi.net> <3aa3a3f0.36440038@news.laplaza.org> Message-ID: <0zXo6.19377$ML1.968149@e420r-atl2.usenetserver.com> "Timothy Grant" wrote in message news:mailman.983829368.26447.python-list at python.org... > Hear, Hear. > > Another vote for K&R. It's ancient, but I still use it when I > have to do C stuff. > > I used it to learn C programming 14 years ago. When I first > picked it up, I said "I can't learn how to programme from this > book!" So I bought one of those 1000 page doorstops referenced > below. I quickly returned to K&R. > > On Mon, Mar 05, 2001 at 02:42:16PM +0000, Mats Wichmann wrote: > > On Mon, 5 Mar 2001 10:14:35 -0000, "Simon Brunning" > > wrote: > > > > >... for a Python programmer? > > > > > >I'm going to have to bite the bullet and learn a bit of C. I'd at > > >least like to learn the *right* way to do it. > > > > My advice is similar to the one that gets given to prospective Python > > programmers: start with the source - K&R (Kernighan & Ritchie). It's > > kind of similar to the Python tutorial in ways: concise but completely > > to the point, from people who know why the language was written that > > way. This is what everyone learned the language from in the early > > days. Stay away from those 1000-page doorstops with CDroms included. > > -- However, if you want to *read* C or C++ code rather than write it, Harbison and Steele might be a better choice. regards Steve From mhuening at zedat.fu-berlin.de Wed Mar 21 10:59:02 2001 From: mhuening at zedat.fu-berlin.de (Matthias Huening) Date: Wed, 21 Mar 2001 16:59:02 +0100 Subject: python and mysqldb References: Message-ID: <99aj4a$digd$1@fu-berlin.de> How did you try to insert the variable? The following should work: statement = "INSERT INTO test_table VALUES ('%s', 'test2', 'test3')" % temp Matthias From tjg at exceptionalminds.com Wed Mar 21 13:26:51 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Wed, 21 Mar 2001 10:26:51 -0800 Subject: pwd behaviour when new users are added In-Reply-To: ; from jepler@inetnebr.com on Wed, Mar 21, 2001 at 03:38:28AM +0000 References: Message-ID: <20010321102651.H16442@trufflehunter.avalongroup.net> On Wed, Mar 21, 2001 at 03:38:28AM +0000, Jeff Epler wrote: > On Mon, 19 Mar 2001 12:31:23 -0800, Timothy Grant > > > >if I 'reload(pwd)' it still doesn't work if I 'del pwd' and > >then 'import pwd' it doesn't work. > > > >What am I doing wrong? > > Calls to the underlying C library functions don't appear to re-open > the password file. > Thanks for the confirmation Jeff. As stated, I have written Python version of all the functions in pwd and they work quite well, with the added benefit that they return shadow information as well. If anyone is interested, let me know. -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Red Hat Certified Engineer www.exceptionalminds.com Avalon Technology Group, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 63 days 22:40 hours ago<< From shaleh at valinux.com Fri Mar 2 17:43:31 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Fri, 02 Mar 2001 14:43:31 -0800 (PST) Subject: cataloging words in text file In-Reply-To: <3AA0124E.74A39783@comm.mot.com> Message-ID: On 02-Mar-2001 Stephen Boulet wrote: > I remember this homework assignment for my data structures (c++) > class: read in a large file, and create a data structure containing > every word in the file and the number of times it appears. > > I was wondering how to do this in python. In c++ we had to do it > with hash tables and b-trees. > > Can you do it with dictionaries in python, with the key as the word > and the data the number of times it appears? If there's any > documentation in this problem domain that people could point out to > me I would appreciate it. > the algorithm is basically just like the C++ version (and same in any language that supports hash/dictionaries). while input: pieces = split input for each piece in pieces if hash.has_key(piece): hash[piece] = hash[piece] + 1 else: hash[piece] = 0 the python advantage is the easy string manip. > What about if you had a bunch of objects, like say stars, with > attributes like position (two coordinates), magnitude, color. If you > had to sort a bunch of them at a time by attributes (say at most > 10^3 of them), would using dictionaries be a good idea, or should > you start looking at interfaces to, for example, mysql? > depends on the application, speed, storage ability, etc. If this start list will continue to grow a db sounds right. From aleaxit at yahoo.com Fri Mar 2 04:43:07 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 2 Mar 2001 10:43:07 +0100 Subject: catching a del References: Message-ID: <97npvd01b43@news1.newsguy.com> Dan Parisien" wrote in message news:j%zn6.322252$f36.11513719 at news20.bellglobal.com... > class obj: > def __init__(self, name, parent): > parent.children[name] = self > self.parent = parent > self.name = name > > def onDelete(self): #?! > del self.parent[self.name] > > I want to be able to catch a del of an instance of the above class so I can > remove it from its parent dictionary. Is there a way? (note it cannot be in > a destructor because there will always be a reference inside the parent > dict) You need a "weak reference" in the 'parent' -- one that, by itself, will not suffice to keep the referred-to entity 'alive' if no other references exist. See PEP 205, "Weak References" -- its URL is http://python.sourceforge.net/peps/pep-0205.html, and the text includes a good general explanation and pointers to previous work on the subject. If you need it right now, your best bet is probably mxProxy, http://www.lemburg.com/files/python/mxProxy.html, but you should also explore the other references in the PEP text. Alex From will at nospam.misconception.org.uk Mon Mar 19 13:04:56 2001 From: will at nospam.misconception.org.uk (Will Newton) Date: Mon, 19 Mar 2001 18:04:56 +0000 Subject: Subsetting a dictionary References: <993dkm$ttr$1@news6.svr.pol.co.uk> <993qq3$4bajg$1@ID-11957.news.dfncis.de> Message-ID: <995hj6$dk6$1@newsg3.svr.pol.co.uk> Emile van Sebille wrote: > Rather than copying and then deleting from the copy, try building a new > dictionary while adding only those that qualify. On average this makes the code ~10x slower. I haven't done an in depth analysis of how the routine is called, but my "backwards" way of doing things seems much faster for my task. From tim.one at home.com Wed Mar 21 19:59:59 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 21 Mar 2001 19:59:59 -0500 Subject: What is being compared? In-Reply-To: Message-ID: [Daniel Klein] > Comparing a string to an integer... > > >>> 'a' < 1 > 0 > > ...what is it actually comparing? Is it 'casting' anything? No cast, but what is being compared isn't defined, just that cross-type comparisons (except for cross-type all-numeric comparisons) are "consistent". As a matter of implementation accident, CPython actually compares the string names of the *types* in such cases, so the accident du jour is that cmp(some_string, some_int) == cmp("string", "int"), which is greater than 0 (i.e., any string is "bigger than" any int -- today). not-the-whole-truth-but-there's-not-much-future-seeking-truth- in-accidents-anyway-ly y'rs - tim From aleaxit at yahoo.com Sat Mar 10 17:21:07 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 10 Mar 2001 23:21:07 +0100 Subject: Setting an attribute on a Python object from C References: <8Adq6.46418$1D5.2158622@e420r-atl1.usenetserver.com> Message-ID: <98ea2a02ttb@news1.newsguy.com> "Steve Holden" wrote in message news:8Adq6.46418$1D5.2158622 at e420r-atl1.usenetserver.com... > "G. Sumner Hayes" wrote in message > news:mailman.984151691.9715.python-list at python.org... [snip] > > Here's what I'm doing (implementing a Python DB 2.0 driver for Microsoft > > SQL server): [snip] > Are you aware of mxODBC? Without wishing to steal your thunder, it's a > pretty good ODBC for (SQL Server, Access, ...) Yes, but ODBC is not the be-all, end-all of database interfacing -- it is a pretty old technology, which its originator (Microsoft) is busy trying to bury, and it does have its problems. It may be a good thing to have alternate, API-DB compliant ways to access RDBMS's...!!! Alex From jcm at bigskytel.com Tue Mar 6 19:05:56 2001 From: jcm at bigskytel.com (David Porter) Date: Tue, 6 Mar 2001 17:05:56 -0700 Subject: from Tkinter import * In-Reply-To: <20010306151631.M3579@trufflehunter.avalongroup.net>; from tjg@exceptionalminds.com on Tue, Mar 06, 2001 at 03:16:31PM -0800 References: <20010306151631.M3579@trufflehunter.avalongroup.net> Message-ID: <20010306170556.A6401@bigskytel.com> * Timothy Grant : > With all the discussion around here recently about the > > from foo import * > > idiom, I thought I'd ask about Tkinter. All of Fredrik's > examples in his guide on Tkinter use > > from Tkinter import * > > Now, I'm aware that the effbot is never wrong about > anything, but is it safe to assume that I should not be > using the above idiom, but the import Tkinter idiom instead? I don't recall reading any statements to that effect. Have you seen him use it outside of the module scope (such as in a function)? The Language Ref forbids doing that, and the addition of nested scopes further complicates things. None of this would indicate that you shouldn't use the above idiom at the module scope though (which is how I see it used). David From timo at alum.mit.edu Wed Mar 21 00:46:05 2001 From: timo at alum.mit.edu (Timothy O'Malley) Date: Wed, 21 Mar 2001 00:46:05 -0500 Subject: Cookies References: Message-ID: <210320010046053593%timo@alum.mit.edu> [[ This message was both posted and mailed: see the "To," "Cc," and "Newsgroups" headers for details. ]] hola. > Thanks for your help and persistence. I have come to an adequate > compromise solution. . . . Here's a wacky idea. You could generate the id on the server or client side. If the client generates it in JavaScript, then he sends it to the server. If the server generates it, then he already has it. In either case, the the server who responds with an web page that includes an HTTP link that points to the following URL http://localhost:8080/id=1234 On this page, you instruct the user to 1) start up your Python application 2) click on the link The Python application should include a small (and stupid) HTTP sever that listens on port 8080 of the localhost. When it detects a connection, it reads the ID out of the requested URL. (In the above example, the ID is the string "1234".) When the user clicks on the link, the client browser makes a request to the Python application running on his machine. By this mechanism is the unique key passed to the application. (To be nice, the Python application should respond with a nice web page.) From shaleh at valinux.com Fri Mar 2 16:36:25 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Fri, 02 Mar 2001 13:36:25 -0800 (PST) Subject: the demise of 'from foo import * and its implications? In-Reply-To: Message-ID: ## as an example of what happens ## and sure, I could try to list every function I want to import, ## but man does that get ugly import _gtk import GTK def hello(*args): print "Hello World" _gtk.gtk_widget_destroy(window) def destroy(*args): _gtk.gtk_widget_hide(window) _gtk.gtk_main_quit() _gtk.gtk_init() window = _gtk.gtk_window_new(GTK.WINDOW_TOPLEVEL) _gtk.gtk_signal_connect(window, "destroy", destroy) _gtk.gtk_container_set_border_width(window, 10) button = _gtk.gtk_button_new_with_label("Hello World") _gtk.gtk_signal_connect(button, "clicked", hello) _gtk.gtk_container_add(window, button) _gtk.gtk_widget_show(button) _gtk.gtk_widget_show(window) _gtk.gtk_main() From t*b*r*u*m*l*e*y at f*u*s*e.n*e*t Thu Mar 22 07:41:01 2001 From: t*b*r*u*m*l*e*y at f*u*s*e.n*e*t (Troy Brumley) Date: Thu, 22 Mar 2001 07:41:01 -0500 Subject: Collection interfaces References: <3a90fa97.0@news1.mweb.co.za> <3A9A86B1.9A8C69A2@ix.netcom.com> <97ibmc0k47@news1.newsguy.com> <97m0c7080c@news2.newsguy.com> s.earthlink.net> <3AA2A898.450B659E@mail.com> <3AB755F8.67E84126@mail.com> <%a%t6.17245$227.1601569@newsread2.prod.itd.earthlink.net> <3AB8A730.4BE13D22@mail.com> Message-ID: in article anhu6.18497$Im6.1938203 at newsread1.prod.itd.earthlink.net, topmind at topmind at technologist.com wrote on 3/22/01 1:57 AM: > > "Troy Brumley" wrote in message > news:B6DE17D2.D6B0%t*b*r*u*m*l*e*y at f*u*s*e.n*e*t... >> in article 3AB8A730.4BE13D22 at mail.com, James A. Robertson at >> jarober at mail.com wrote on 3/21/01 8:06 AM: >> >>> topmind wrote: >>>> >>> >>>>> http://www.cincom.com/smalltalk >>>>> >>>> >>>> I only see a front page, not a parsing example. >>>> >>> >>> Follow the tutorial link - it's right there on that page. >>> >>> >>>> Besides, what are you comparing it to so say >>>> it is better than a procedural/relational approach? >>> >>> It's vastly easier than similar code done in C or basic, for example >> >> User testimonial here ... last week I had to rip thorugh a pile of IIS > logs >> to get some statistics for some people, and I used the original (non-gui) >> tutorial code as a starting point. I was once again impressed with how > much >> easier it was to do several common data processing tasks in Smalltalk than >> it was in Assembly language or C or Pascal. >> > > Give me specific requirements and I bet I can match it on code size. > > C, Pascal, and Assembly are hardly what I would use for code-size > contests. > > Of course, there is more to comparing than code size, but those often > get very subjective or fuzzy. I rarely worry about code size except how it relates to code clarity. Even back in my assembly oriented youth I tried to keep functions under one page on a listing for the sake of clarity. I mention C, Pascal, and Assembly because they are my usual tool set, or were until I discovered Smalltalk. I've done a lot of business programming over the years in procedural environments and used more languages than those (even COBOL and RPG) but for the heavy lifting I would always stick with them. Again, until I discovered Smalltalk :) I've seen Perl and run away screaming. Python and Eiffel are on the to learn list, but Smalltalk seems to have the power I need for the tasks I want to do these days. Objects are becoming more and more natural as I use them, and my code improves contantly. > >> I'm a long time procedural type, learning to really think in and use >> Smalltalk has been an interesting experience. >> >> I've also done a lot of database "fixing" and Smalltalk has usually beat > out >> raw SQL for anything but the most trivial tasks. >> > > Fixing what? SQL is not good at string parsing. Usually sweeping changes, or dangling referential integrity problems. >> All that said, I think it's the environment (interactive) that improves > the >> experience as much as the language itself. If I had a reasonable >> interpretive BASIC environment available, I could probably do many of the >> things I did in Smalltalk almost as easily ... certainly more easily than >> with C. >> > > I find interpretive environments potentially more compact code-wise than > static ones. No argument here. > >> >>> >>>> >>>>>> >>>>>>> [snip] >>>>>> >>>>>> -tmind- >>>>>> oop.ismad.com >>>>> >>>>> -- >>>>> James A. Robertson >>>>> Product Manager (Smalltalk), Cincom >>>>> jarober at mail.com >>>>> >>>>> >> > > From dbrueck at edgix.com Fri Mar 9 14:57:27 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Fri, 9 Mar 2001 12:57:27 -0700 Subject: "!=" is bad form. Re: sorry....never mind In-Reply-To: <3AA928BC.1DAB4284@schneider-kamp.de> Message-ID: > [mailto:python-list-admin at python.org]On Behalf Of Peter Schneider-Kamp > Sent: Friday, March 09, 2001 12:02 PM > To: Dave Brueck > Cc: python-list at python.org > Subject: Re: "!=" is bad form. Re: sorry....never mind > Dave Brueck wrote: > > > > I don't really care if Python keeps <>, but the reason I don't > like it is > > because of the example listed above: to me seeing "<>" implies something > > about the ordering of a and b, namely (a < b) or (a > b), even > when such an > > Well, Python *does* define an ordering of a and b, no matter what > a and b may be. E.g.: > > >>> 1 > (1,2) > 0 > >>> 1 < (1,2) > 1 > >>> {"a":1} < u"hello world" > 1 > >>> {"a":1} > u"hello world" > 0 > > So, yes, interpreting "a <> b" as "(a < b) or (a > b)" makes > perfect sense in Python. Works? Yes. Makes sense? Definitely not. My point wasn't about what is or isn't legal in Python but the intuitiveness of '!=' vs '<>': at first glance the former says to me, "a is not the same as b" while the latter says "a is less than b or a is greater than b". The former intuitively makes sense for any "thing" while the latter makes sense only on objects that can be ordered in some meaningful way. Put another way, it doesn't really make any difference to me personally, but '!=' would be easier to explain to a non-programmer than '<>'. -Dave From fredrik at pythonware.com Thu Mar 22 18:23:31 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 22 Mar 2001 23:23:31 GMT Subject: python, perl, lisp, tcl / got a decision to make, can you give me a view point please ? and a joke for python users : ) References: <3aba3076.14395287@news.vif.com> Message-ID: Tim Churches wrote: > > from __future__ import * > > Crystal-ball-gazingly yours, doesn't work; it imports both "warnings_are_errors" and "from_import_star_is_evil", and as I've pointed out before, catching ParadoxErrors is really hard. (I'm sure Dave Beazley will fix WAD any day soon, though) Cheers /F From dusty at strike.wu-wien.ac.at Thu Mar 8 12:48:31 2001 From: dusty at strike.wu-wien.ac.at (Hermann Himmelbauer) Date: Thu, 8 Mar 2001 18:48:31 +0100 Subject: "Wrap" a python-cgi Message-ID: <3aa7c5f9$0$21482@SSP1NO25.highway.telekom.at> Hi, I am currently using python for several cgi programs. One problem is that if my cgi-script has a bug it exits with an exception and the user gets an ugly error message done by the webserver. I would like to put some really simple "bugfree" (if something like this can exist :-) "wrapper" around my cgi-scripts, let it trap Exceptions, log the error and let it output a nice error page to the user. My first approach would perhaps be to wrap the whole script into a "try: except" clause but at first I don't know if nested try/except clauses are allowed and moreover the whole script looks somehow ugly as every line is indented. Perhaps you know a better solution? Best Regards, Hermann -- ,_, (O,O) "There is more to life than increasing its speed." ( ) -- Gandhi -"-"-------------------------------------------------------------- From n8gray at caltech.edu.is.my.e-mail.address Thu Mar 1 21:29:08 2001 From: n8gray at caltech.edu.is.my.e-mail.address (Nathan Gray) Date: Thu, 01 Mar 2001 18:29:08 -0800 Subject: A counter-proposal to __future__ in PEP 236 References: Message-ID: <3A9F0574.4040805@caltech.edu.is.my.e-mail.address> Tim Peters wrote: > [Martin von Loewis] >> I personally consider this a confusing notation, > > > I don't. "__future__" screams "Deep Magic" because of the double > double-underscores; it *is* a perfectly vanilla import statement at runtime; > the word "future" helpfully suggests temporality; it works with all existing > tools today without change (so it's not confusing even the stupidest of them > <0.1 wink>); and the imported nested_scopes name gets bound to release data > that the importing code can examine; e.g., > > from __future__ import nested_scopes > assert nested_scopes[1] > sys.version_info, "don't need this anymore" > > >> and propose a different syntax, which would read >> >> directive nested_scopes > > > Which loses all of that. Incompatible language changes are a serious special > case, and I don't want to see them swallowed up by some perfectly general > mechanism that makes them impossible to distinguish visually from some > innocuous request to, e.g., optimize for space instead of time. I don't understand. "import" is a pretty general mechanism and the proposed syntax is visually indistinguishable from a normal import except for the double- double underbars. There's no reason Martin's proposal couldn't be tweaked: import_directive __future__.nested_scopes import sys assert nested_scopes.mandatory_release > sys.version_info \ "don't need this anymore" with the same semantics (including importing the nested_scopes module) as your proposal. Now you've got *both* the underbars *and* a new, scary keyword to warn you that voodoo is being done. Call it "import_directive" to make the "importish" nature more explicit (and reduce possibilities of code-breakage because of "directive" being used as an identifier). And yes, definitely make the new thing a keyword! No sense beating around the bush! If we're going to add "magic imports" to the language, why not make them explicit? As for the tool-breakage argument, the smart tools are going to have to be rewritten to understand nested scopes anyhow. How hard is adding a new keyword relative to that? And with "import_directive", the only change that needs to be made to the stupid tools is a cut-and-paste of the "import" code. > > >> The directive statement currently only supports activating nested >> scopes, > > > I really dislike that > > directive nested_scopes > > *looks* exactly the same as > > directive favor_space >[snip] > That will add to confusion over time, not reduce it. Incompatible language > changes have to kick you in the teeth. But from __future__ import nested_scopes has the insidious effect of fooling the naive user into thinking he understands what's going on when he actually doesn't! At least with import_directive or directive the naive user is forced to look at the documentation. Once he does, it's immediately clear that deep, dark things can be happening at compile time. > > Note that it's also not enough to allow just one or two optional tokens > following "directive". One of the primary reasons no pragma facility ever > got into Python is that in previous attempts nobody could agree on syntax > that *was* sufficiently general (as a hint of the horrors you're signing up > for, note that "optional static typing" fits-- because of the "optional" > part --into a pragma framework; and once people realize that, they're going > to hijack your proposal into an overly-generalized mess too). Guilty as charged. import_directive static_typing seems pretty clear to me. If people are dead-opposed this becoming a general-purpose mechanism, call it "import__future__" and only use it for the case PEP 236 addresses. I think our objections are syntactic, not semantic. I can understand the advantages that import semantics bring to the situation, but I hate to see a keyword with clear, focussed meaning being extended for a single special situation. -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From tuttledon at hotmail.com Thu Mar 15 13:50:35 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Thu, 15 Mar 2001 18:50:35 GMT Subject: Python Programming on Win32 (was: Magnitude of the wx* market (was: Python In A Nutshell - suggestions)) References: <3AB26DAC@MailAndNews.com> Message-ID: <%98s6.116559$Z8.23732829@typhoon.southeast.rr.com> "Laura Lewin" wrote in message news:3AB26DAC at MailAndNews.com... > Hi, > Sure, we'll take this suggestion into consideration (on expanding wxPython > coverage) when we publish the next edition of "Python Programming on Win32". When do you plan to do that? And please greatly expand the chapter on system administration! Better yet, create an entire book along the lines of Dave Roth's excellent "Win32 Perl Scripting: The Administrators Handbook". In fact many sections of "Python Programming on Win32" need to be entire books, not just quick intros. This leads me to a mini rant that has been building for some time now. I'll try to contain myself ;-) Over the last year I've spent several hundred dollars on NON Python books in order to learn Python. Or more precisely, what to do with Python. It's not that Python can't do it, it's that I don't know how to do it, or for that matter, that I can do "it". (I'm finding new "its" everyday.) And most of the "How To" books are written for other languages. So I have many books on VBScript, JScript, WSH, Perl and Batch files. And this is just for Admin work. I haven't even started trying to use Python with databases.- Yet- But I will. (And then there's that network programming stuff...) So, all you authors and Publishers out there...Put out more topic specific Python "How-To" books. Let's liberate Python from the hands of highly skilled developers and give it to your average power user! Power to the Python! Don PS And don't forget all those pissed off VB programmers that are ripe for the picking! From igorr at ifi.uio.no Fri Mar 2 13:17:39 2001 From: igorr at ifi.uio.no (Igor V. Rafienko) Date: 02 Mar 2001 19:17:39 +0100 Subject: str behaviour References: Message-ID: * Tim Peters [snip] Thanks to everyone who replied. > You're on the edge of a very deep pit. The builtin container types > (lists, tuples, dicts) "pass repr down" regardless of whether str() > or repr() is applied at the top level. I've been whining about that > for years myself . Argggh! This is silly -- why won't repr call repr and str call str recursively? It seems like a very logical solution (consistent, imvho, at least). > The primary reason is maddeningly simple: it's for the benefit of > contained strings. If str() "got passed down", then, e.g., > > d = {"colon": ":", "comma": ",", "' greeting": "I'm A"} > print d # note that print implicitly applies str() > > would print > > {' greeting: I'm A, comma: ,, colon: :} > > instead of today's > > {"' greeting": "I'm A", 'comma': ',', 'colon': ':'} > > so it would be an unreadable mess. Suits me fine :) Jokes aside, if that were the case, I'd be more than happy to write >>> print repr( d ) rather than >>> print d and be very happy with the fact that repr did in fact call repr and str did in fact call str. But maybe I am a very strange person... BTW, since things are the way they are, could someone provide a cleaner alternative to this snippet: try: # some code that might raise something nasty except: return MyError( "Something went wrong: (%s, %s)" % ( sys.exc_info()[0], sys.exc_info()[1] ) ) # yrt (yes, I can teach emacs to do that for me, but this is very painful on the eyes of a reader). All I wanted to do was to extract the value and type of the exception raised in an elegant way: return MyError( "Something went wrong: %s" % sys.exc_info()[:2] ) (which, obviously (gaah!), does not work as intended). A possible solution is to use repr, of course (and define a repr for the class that can be raise'd). [snip] > Like most other issues involving repr-vs-str, it doesn't often bite > so long as you stick to the builtin types. But once you write > classes that implement their own notions of __str__ and __repr__, it > seems that more often than not *neither* of them does what you want > when instances end up in builtin containers. I'd rather have str/repr call str/repr, than not. Am I missing something obvious (apart from ugliness of strings, as you've exemplified above)? ivr -- Besides, meat tends to run away when possible, or fights. Either response presents behavioral challenges too complex for any existing robot. -- Stuart Wilkinson, inventor of the "gastrobot" From fig at monitor.net Sat Mar 31 21:41:22 2001 From: fig at monitor.net (Stephen R. Figgins) Date: Sat, 31 Mar 2001 18:41:22 -0800 Subject: PythonLabs Team Moves to ActiveState References: <9a62cg$3it52$1@ID-11957.news.dfncis.de> Message-ID: <3AC69552.7D6FAD6A@monitor.net> This was a good one! I was halfway through it before I realized it was almost word for word the same as the DC announcement. When I got to the part about braces I about fell out of seat laughing. Check out the X-Apology header. -Stephen From ben.hutchings at roundpoint.com Wed Mar 28 17:15:48 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 28 Mar 2001 14:15:48 -0800 Subject: daemon app in win32 References: <99nk49$a2q$02$1@news.t-online.com> <99nsn3$q39$06$1@news.t-online.com> <99o2ge$9on$0@216.39.170.247> <99rhsp$i4$06$1@news.t-online.com> Message-ID: Michael Bauer writes: > Ben Hutchings wrote: > > Console applications can register to receive such notifications in the > > same way they receive control-C notifications under *some* versions of > > Windows. > > Do you have any more details about this? Because i experienced that my app > does actually *not* receive the CTRL-Cs or similar i am pressing when i try > to cancel it "by hand"... (btw, this is win98) CPython is supposed to generate a KeyboardInterrupt exception in this case. If this doesn't work, Ctrl-Break might. If your program has stuck in a system function then the exception won't be thrown until that returns. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From tjreedy at udel.edu Wed Mar 14 14:55:02 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 14 Mar 2001 14:55:02 -0500 Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> <20010312170356.B3513@better.net> <984486395.407379@newsmaster-04.atnet.at> <984518199.127140@newsmaster-04.atnet.at> Message-ID: <98ohuc$du9$1@news.udel.edu> > Bill Gates got this right in the early days, delivering two Basic > interpreters: binary floating point for speed, and decimal floating > point for money and such If one counts pennies instead of dollars, then 32 bit ints (+- $20 million) will serve for many purposes. Exact, faster, and more widely available than BCD From tim.one at home.com Tue Mar 20 22:18:25 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 20 Mar 2001 22:18:25 -0500 Subject: ASCII encoding error: ordinal not in range(128) In-Reply-To: <3d4rwo10h8.fsf@ute.cnri.reston.va.us> Message-ID: [Fredrik Lundh] >> UnicodeError: ASCII encoding error: ordinal not in range(128) > > translated to english, this overly cute error message attempts > to say something like "cannot convert this Unicode string to > ASCII as it contains non-ASCII characters" [Andrew Kuchling] > Hmm... hasn't changing this message before been discussed someplace? Yes, /F griped about this on Python-Dev, Sat, 26 Aug 2000 17:43:38 +0200, and suggested ASCII decoding error: character not in range 0-127 instead. I counter-proposed ASCII decoding error: ord(character) > 127 since characters aren't integers in Python. AFAICT, that's the grand total of the debate. > Was there some reason it wasn't changed? None apparent. > How about: "UnicodeError: ASCII encoding error: character not in > ASCII range 0-127" ? (I vaguely recall Marc-Andre arguing for > "ordinal", since that's used in the Unicode documents, but if it's > less clear...) Anything is better than what it says now! even-a-ham-sandwich-ly y'rs - tim From lrl at ou.edu Wed Mar 28 17:14:37 2001 From: lrl at ou.edu (Luke L) Date: Wed, 28 Mar 2001 16:14:37 -0600 Subject: Recommendations for Python Books References: <3ac2582c$1@news.starhub.net.sg> Message-ID: <3AC2624D.F8704C44@ou.edu> "Learn to Program using Python" http://www.amazon.com/exec/obidos/ASIN/0201709384/qid=985817618/sr=1-10/ref=sc_b_11/102-6408521-3462514 From dougfort at downright.com Mon Mar 5 09:47:01 2001 From: dougfort at downright.com (Doug Fort) Date: Mon, 5 Mar 2001 09:47:01 -0500 Subject: iis and python References: Message-ID: My boss (David Cohen) has coined the acronym 'WIMP' (Windows, IIS, MySQL, Python) corresponding to 'LAMP' (Linux, Apache, MySQL, Python). Our CGI stuff will run under either Apache or IIS. "tech" wrote in message news:F5622749FED6DA5D.AF4594816A4865C9.16CD98F1C1FAC3F6 at lp.airnews.net... > I am going to do a project building a web front end while my friend is > going to build the back end. > > The backend will be MS SQL. The front end will be a web interface, IIS 5.0 > or whatever comes with win2k . > > I have a choice of doing php or python. > > In order to use python it would have to entail cgi or ASP. Is this correct. > Or is there an alternative. I dont know if Zope is the right thing. I hate > DTML. > > Is using python in ASP a pain in the but? Am I going to have to learn a > whole technology just to implelment python well into it? > > I hear troubleshooting ASP pages is not fun. > > The only time I have used iis is with php and it was a total snap. Painless. > > From tchur at optushome.com.au Thu Mar 8 14:53:12 2001 From: tchur at optushome.com.au (Tim Churches) Date: Fri, 09 Mar 2001 06:53:12 +1100 Subject: Who am I: can a class instance determine its own name? References: Message-ID: <3AA7E328.3A28AF26@optushome.com.au> Thanks to Gregory Jorgensen, Jeremy Reed, Steve Purcell, Steve Holden, Matthias Oberlander, Daniel Klein and Remco Gerlich for responding to my question: can a class instance determine the name of the variable which refers to it? The answer appears to be "no, it can't". A number of respondents pointed out that multiple variables may all refer to the same class instance, so my question should have been: "can a class instance determine the name(s) of the variable(s) which refer(s) to it?". The answer is still no, and that the solution is to explicitly assign each instance a name attribute at instantiation. A number of people asked why I needed to know. Consider the problem of composition. You define a container class Foo which can contain many instances of the Bar class, which are added to Foo with the addBar method. ###################################### Foo_One = Foo(name="Foo_One") Foo_Two = Foo(name="Foo_Two") Bar_A = Bar(name="Bar_A") Bar_B = Bar(Name="Bar_B") Foo_One.addBar(Bar_A) Foo_One.addBar(Bar_B) Foo_Two.addBar(Bar_B) Foo_One.listBars() ...returns a sequence of Bar instance names: ['Bar_A','Bar_B'] Foo_Two.listBars() ...returns a sequence of Bar instance names: ['Bar_B'] ######################################  I was just trying to avoid the inelegant redundancy of having to name each Bar instance twice - once when specifying the name of the variable which refers to the Bar instance, and once as an attribute of that instance (the use of a keyword parameter to __init__ to specify the name is just for clarity). What I was aiming at was this sort of functionality: ###################################### Foo_One = Foo(name="Foo_One") Foo_Two = Foo(name="Foo_Two") Bar_A = Bar() Bar_B = Bar() Foo_One.addBar(Bar_A) Foo_One.addBar(Bar_B) Foo_Two.addBar(Bar_B) Foo_One.listBars() ...returns a sequence of Bar instance names: ['Bar_A','Bar_B'] Foo_Two.listBars() ...returns a sequence of Bar instance names: ['Bar_B'] ###################################### One solution would be: ###################################### Foo_One = Foo(name="Foo_One") Foo_Two = Foo(name="Foo_Two") Foo_One.addBar(Bar(name="Bar_A")) Foo_One.addBar(Bar(name="Bar_B")) Foo_Two.addBar(Bar(name="Bar_B")) Foo_One.listBars() ...returns a sequence of Bar instance names: ['Bar_A','Bar_B'] Foo_Two.listBars() ...returns a sequence of Bar instance names: ['Bar_B'] ###################################### ...but that just creates a different form of redundancy... The solution I have settled on is to accept the minor inelegance and move on to more important matters... Cheers, Tim C From jmarshal at mathworks.com Thu Mar 1 16:21:40 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 1 Mar 2001 21:21:40 GMT Subject: A counter-proposal to __future__ in PEP 236 References: Message-ID: <97meh4$c0g$1@news.mathworks.com> Tim Peters wrote: > [Joshua Marshall] >> ... >> Note that it doesn't need to be implemented this way. Currently, >> >> directive foo >> >> is a syntax error. Meaning can be assigned to this syntax without >> breaking any existing code--it is unambiguous. > You should study Python's parser before getting too optimistic about that > . So anybody care to post an example of how this can be ambiguous (in context) so I don't need to go study Python's parser...? From sholden at holdenweb.com Wed Mar 28 16:50:58 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 28 Mar 2001 16:50:58 -0500 Subject: list vs tuple References: <3AC1EB93.7BC87292@hack.org> <3AC1F93A.BAC9E34B@hack.org> <99teuu02p5f@news1.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:99teuu02p5f at news1.newsguy.com... > "Rikard Bosnjakovic" wrote in message > news:3AC1F93A.BAC9E34B at hack.org... > > deadmeat wrote: > > > > > so is that the only difference? > > > > Both are sequences, but tuples are "read-only", that's the only > > difference (except for the in-place-methods which requires mutability). > > Actually, tuples have NO methods -- including those that would > require no mutability at all: > > D:\pybridge\pybr>python > Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license" for more information. > >>> dir([]) > ['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', > 'sort'] > >>> dir(()) > [] > >>> > > Note the lack of 'count' and 'index', which do not mutate a list > when applied to it, but are still missing from tuples. > So, tuples are not only immutable, they are also uncooperative. regards Steve From ulf at light.mobiliant.com Thu Mar 15 08:13:26 2001 From: ulf at light.mobiliant.com (=?iso-8859-1?Q?Ulf_Engstr=F6m?=) Date: Thu, 15 Mar 2001 14:13:26 +0100 Subject: Problem with string.translate References: Message-ID: <00b001c0ad51$bc0d0520$968647c1@asker> What version and what platform are you using? Works fine for me with 2.0final on a Windows2000 and on a SuSE Linux. Include traceback (with orginial version of the library function) and I'll see if I can help :) Ulf "David Fuess" : > I am using Python 2.0 and attempting to perform a string.translate. > The translate string is statically allocated in the setup phase. I > perform a > > result = string.translate(source, ttab) > > I have also tried > > result = source.translate(ttab) > > The error I get is that an internal library function in the string > module is calling a builtin function translate with too few arguments! > Is this an implementation problem in the new string class? I have > tried changing the library function, but then it generates other > errors. Please advise. From phrxy at csv.warwick.ac.uk Tue Mar 27 12:54:57 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Tue, 27 Mar 2001 18:54:57 +0100 Subject: Threading legality/morality In-Reply-To: <99qa3v$6e0$1@panix6.panix.com> References: <99nnbv$phs$1@panix6.panix.com> <99qa3v$6e0$1@panix6.panix.com> Message-ID: On 27 Mar 2001, Aahz Maruch wrote: > In article , > Syver Enstad wrote: > > > >I have seen some strange behaviour in some multi threaded programs I have > >made in python, where they seem to lockup, but a push on the the return key > >(or another key, I don't know) keeps them going. These are console programs, > >running under Win2000 server and professional, Python 2.0. [...] > There is a misfeature in urllib such that the standard FancyURLOpener > class prompts for input if it gets an HTTP 401 (authorization needed). > You probably pressed ENTER. [...] Perhaps you're right, but I've seen the same behaiviour on win95, without multi-threading. When you run command-line (do we mean the same thing by console and command-line?) apps it freezes until a key gets pressed. Not using urllib either. It is possible (likely, even) that I was using cygwin, so maybe that's where the blame lies. I'll see if I can reproduce it with the standard DOS shell. (using standard (BeOpen) Python 2.0 distribution) John From emile at fenx.com Wed Mar 21 07:26:49 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 21 Mar 2001 04:26:49 -0800 Subject: Checking the type References: <99a493$bhl$1@sun.rhrk.uni-kl.de> <99a539$buco$1@ID-59026.news.dfncis.de> Message-ID: <99a6s1$b9no$1@ID-11957.news.dfncis.de> There is "type" as well: if type(a) == type(1) if type(b) == type({}) etc Emile van Sebille emile at fenx.com "Nils Hensel" wrote in message news:99a539$buco$1 at ID-59026.news.dfncis.de... > Look for the types module: > > from types import * > if type(a) is ListType: > # do list stuff > > HTH, > Nils > > "Markus Reitz" schrieb im Newsbeitrag > news:99a493$bhl$1 at sun.rhrk.uni-kl.de... > > Hi, > > > > is there a possibilty to check if a variable refers to an object of type > x? > > Does a typeof-command exist in Python: > > > > if a typeof list: > > #Commands only useable with list > > > > I read the Python Tutorial, but have not found a hint to this topic. > > > > Thanks > > > > Markus > > > > > > From topmind at technologist.com Thu Mar 1 21:57:53 2001 From: topmind at technologist.com (Topmind) Date: Fri, 02 Mar 2001 02:57:53 GMT Subject: Collection interfaces References: <3a90fa97.0@news1.mweb.co.za> <3A933830.7F98D118@ix.netcom.com> <220220010813598042%cmh@bDistributed.com> <8Gem6.473353$U46.14105062@news1.sttls1.wa.home.com> <3A9A86B1.9A8C69A2@ix.netcom.com> <97fjla128ir@news2.newsguy.com> <97h5s40vhc@news2.newsguy.com> <97ibmc0k47@news1.newsguy.com> <97m0c7080c@news2.newsguy.com> Message-ID: > >I've often noticed that demanding metrics is the last >line of defense of the conservatives in our field against >innovation So science be damned? At least it is official now. I am *not* against innovation. I am against the overhyping of fads without proof. Relational DB's are newer than OO, does that mean that OO defenders are "holdouts"? If OO is an "experiment", then fans of it should admit it as such. The road is littered with paradigms and ideas that were over-hyped, and then shrank back to where they belong. Heavy top-down is an example that ran about a decade in the limelight. Expert systems, CASE, etc, are others. I hope Table Oriented Programming hits hard and does the same. All the OO celebs will squirm. Call me cruel, but they deserve it. It deserves as much of a chance for experimentation in the mainstream as anything out there now. > -- since nobody's really funded to run serious >(and hugely costly) controlled experiments, such demanders >can rest reasonably tranquil that they won't be faced with >such metrics. Unfortunately, the world has this habit of >passing them by anyway. No, just learning by trial and error. 50 years from now we will have a better perspective on this OO experiment. > Been there, done that, more or less whatever you mean by > "table-oriented programming" It may be purely subjective. I had an affinity for grids and tables even in 2nd grade. Born to Table if you will. > ...then your resulting sources will never be as good, > clear, clean, maintainable, and high-quality, as those > of a better programmer, who DOES refactor every time > the occasion affords. My favorite approaches are *not* orthogonal to refactoring, but simply *less* fragile or messed up if you refactor regularly. > And, depending on the axis of change, any paradigm > can result in code that is hard to change to meet > the new/changed needs at equally high quality Well, my experience tells me that the "task axis" is the most "business friendly" axis to build along (being that multi-axis paradigms still need a lot of work and thus we are forced to emphasize one at the expense of others for now.) >You still need design ability, flair, and a decent >amount of domain-specific experience somewhere in >the team, to enjoy a substantial chance of delivering >LARGE software-systems that present all the desired >quality attributes The SIZE thing again? 1. What is good for large size may not be optimal for other sizes. 2. OO fans disagree about at what size OO shines in. 3. The task-centric approach is size friendly because the task is mostly impervious to the rest of the system (unless the task changes it's requirements, which is an issue in any paradigm). OO's noun-centricity seems more scale-poor in that regard because schemas change when growth appears. The 3-graph approach puts a layer between schema changes and the task more or less. > Fortunately, given the current market for IT professionals (and > this comment applies to the last 25 years), no competent worker > in the field ever needs to be stuck for long under management > that is totally impervious to common sense and reason For one, I don't buy the labor shortage crap. For example, try to get a telecommuting job. If there was an IT labor shortage, then bosses would fold on their demand to see a physical butt in a physical chair. Second, the percentage of PHB's is too great to avoid. The supply of non-PHB's is too low to satisfy the desire of tech workers to escape them. >> I have shown in great detail why procedural seems better able >> to deal with non-boundaried differences, and I have yet to > > You have done no such thing (at least in your posts in > this thread, and the URL you mentioned here). I don't know what you have not seen yet, but my collection of examples is far greater than what the other side offers as far as comparative examples. All I get from them are the typical shape, animal, and stack examples (and a few other "classics"). Regarding an internal* component view, I will believe it when I actually see it work. Like much in OO lore, it sounds wonderful on paper, but rubs rough with the nitty gritty of reality. I guess that is what happens when you design an entire paradigm around idealized shape, animal, and stack examples. * External components are quite successful, but nobody has figured out how to apply it to internal systems very well. BTW, OO is not a prerequisite for external components. > maybe because you lack the experience to do it well. Well, youses all seem to lack the articulation skills/experience to describe why granularity is not a problem. You still have not found an easy way to override 1/3 of a method. You just hand-wave that "experience will magically fix it all". I seems like you just "get used to" refactoring when it happens. IOW, tolerate bad weather because you lived their for so long. > But -- without calling it that way, without the productivity > that reusable patterns or good tools can give me Patterns are not native to OO and "good tools" can be built to lessen the shortcomings of *any* paradigm. Name a p/r fault and I could describe a potential tool to help. -tmind- From cfelling at iae.nl Mon Mar 12 10:24:45 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 12 Mar 2001 16:24:45 +0100 Subject: I have no idea References: <98io58$462$1@animus.fel.iae.nl> Message-ID: <98ipnt$4jf$1@animus.fel.iae.nl> Carel Fellinger wrote: ... > or add a ',' to the print statement, like: > >>> while 1: > ... print "Hello World" I said add a ',', so I should, shouldn't I. ... print "Hello World", -- groetjes, carel From sholden at holdenweb.com Thu Mar 22 23:37:09 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 22 Mar 2001 23:37:09 -0500 Subject: Good Editor? References: <3ab9a32b$1_1@news2.one.net> <99cv2t$f20g$1@ID-11957.news.dfncis.de> <99ej5k$t8im$1@ID-11957.news.dfncis.de> Message-ID: That's impressively well-though-out. Although really I meant Unicode literals in Python sources, which might be a horse of a different color. regards Steve "Emile van Sebille" wrote in message news:99ej5k$t8im$1 at ID-11957.news.dfncis.de... > > > What's unicode look like in hex? How would I test it? > > > > > Oh wait, from the Help page: > > How to Work with Unicode Files > Overview: > TextPad automatically detects 16-bit Unicode and UTF-8 encoded characters, > when opening files. Unicode characters may be in "little endian" (Intel) or > "big endian" (RISC) order, and the order is preserved when a file is saved. > > Internally, these files are converted to single or double byte characters > (DBCS), using the locale corresponding to the font script selected for the > document class. For example, if the screen font for the Text document class > is MS Mincho, with the script set to Japanese, Unicode characters in *.TXT > files will be converted to the corresponding DBCS characters in code page > 932. > > > > Emile van Sebille > emile at fenx.com > > > "Steve Holden" wrote in message > news:sqzu6.12865$_46.475246 at e420r-atl2.usenetserver.com... > > "Emile van Sebille" wrote in message > > news:99cv2t$f20g$1 at ID-11957.news.dfncis.de... > > > > > > For windows, I like textpad http://www.textpad.com/ beause it uses > > > workspaces, has a hex display mode, runs code in a separate process, > > > supports other languages (programming and spoken), and generally behaves > > > well. > > > > > > Emile van Sebille > > > emile at fenx.com > > > > > Does it show Unicode string constants correctly in hex? > > > > regards > > Steve > > > > > > > > From paulp at ActiveState.com Fri Mar 16 01:40:40 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Thu, 15 Mar 2001 22:40:40 -0800 Subject: Python & XSLT? References: Message-ID: <3AB1B568.7B98C58F@ActiveState.com> "John E. Barham" wrote: > >... > > So I want to use XSLT. Short of wrapping a C++ XSLT engine like Apache's > Xalan, is there any way to do XSLT from within Python? As far as I can > tell, the existing Python XML tools don't go much above DOM/SAX style > processing... I think you're looking for this: http://4suite.org/index.epy -- Take a recipe. Leave a recipe. Python Cookbook! http://www.activestate.com/pythoncookbook From juergen.erhard at gmx.net Sun Mar 11 07:51:17 2001 From: juergen.erhard at gmx.net (=?ISO-8859-1?Q?=22J=FCrgen_A=2E_Erhard=22?=) Date: Sun, 11 Mar 2001 13:51:17 +0100 Subject: "!=" is bad form. Re: sorry....never mind In-Reply-To: References: Message-ID: <11032001.1@wanderer.local.jae.ddns.org> >>>>> "Tim" == Tim Peters writes: Tim> I'm afraid it's again time to quote the Reference Manual: Tim> [...] for consistency with C, != is preferred; [...] Tim> print>>-got-in-for-"consistency-with-c"-too-ly y'rs - tim So when can we expect `||' and `&&' to replace `or' and `and'? Shouldn't we `Beware of the slippery slope'? Bye, J -- J?rgen A. Erhard juergen.erhard at gmx.net phone: (GERMANY) 0721 27326 MARS: http://members.tripod.com/Juergen_Erhard/mars_index.html The Python Programming Language (http://www.python.org) C> (A)bort (R)etry (I)nfluence with a large hammer -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: From sheila at spamcop.net Sun Mar 18 05:29:08 2001 From: sheila at spamcop.net (Sheila King) Date: Sun, 18 Mar 2001 10:29:08 GMT Subject: Help with 500 error on cgi script References: Message-ID: <5739bt04e50ku01rn3dptgqch3l07p2cnf@4ax.com> On Sun, 18 Mar 2001 11:00:22 +0100, Steve Purcell wrote in comp.lang.python in article : :You need to write out a 'Content-type' header when form_ok is true, too! : :It's the lack of that header that causes the 500 error. If you're pretty :sure your content is going to be text/html, it can be good practice to write :out the content header before any other code. That is a good point, although I don't think that that is what the problem was, because now I've changed the script to this, where I print the Content header right away, and still I'm having problems. More below: #!/usr/bin/env python import cgi print "Content-type: text/html\n" print "\n\nResult Page" form = cgi.FieldStorage() form_ok = 0 if form.has_key("subscriberEmail") and form.has_key("command"): form_ok = 1 if not form_ok: output = '''

Error

You have not filled out all necessary information to complete this request You MUST fill in your subscriber e-mail in the From: box and you MUST select some action to modify your delivery options. Please use the back button on your browser to return to the form and fill in the required information \n ''' print output else: print "

Good Result!

print "\n" """ for k in form.keys(): print k, " : ", form[k] print "All done!""" And I'm still getting errors. The Apache error log says, on the last run: [Sun Mar 18 02:18:42 2001] [error] [client 4.3.200.226] Premature end of script headers: e:/apache/cgi-bin/testform.py [Sun Mar 18 02:18:42 2001] [error] [client 4.3.200.226] File "e:/apache/cgi-bin/testform.py", line 25 [Sun Mar 18 02:18:42 2001] [error] [client 4.3.200.226] print "

Good Result!

[Sun Mar 18 02:18:42 2001] [error] [client 4.3.200.226] ^ [Sun Mar 18 02:18:42 2001] [error] [client 4.3.200.226] SyntaxError: invalid token But I'm at a loss to figure out what is wrong. :-( :-Steve : :P.S. What's with the 'spamcop' reply address? Is that your real address or :do unsuspecting helpful responders get their mail accounts terminated? http://spamcop.net is a service that I subscribe to. Nothing untoward happens to helpful responders. It is a protection for me, so that I do not have to reveal my "real" e-mail address in the newsgroups. But, if you reply, the replies will be delivered to me. If spammers reply, though, they will be easily and promptly reported. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From sholden at holdenweb.com Tue Mar 20 02:31:48 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 20 Mar 2001 02:31:48 -0500 Subject: Why "from __future__" stinks; a counter-offer References: <3xDt6.2394$4N4.290991@newsc.telia.net> Message-ID: "Fredrik Lundh" wrote in message news:3xDt6.2394$4N4.290991 at newsc.telia.net... > Tim Peters wrote: > > Fine, so I'm an idiot > > Me too! > > Cheers /F > With idiots like you two guys, who needs gurus? regards Steve From hinsen at cnrs-orleans.fr Thu Mar 1 04:41:41 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 01 Mar 2001 10:41:41 +0100 Subject: d = {}; d[0:1] = 1; d[0:1] = 2; print d[0:1] References: Message-ID: Robin Thomas writes: > The question remains: should slice objects be hashable/comparable so that > > >>> slice(0,1) == slice(0,1) > 1 > > I say YES YES YES. What do you say? Another YES YES YES. That's what anyone would expect in my opinion. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From fgeiger at datec.at Sat Mar 10 03:00:38 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Sat, 10 Mar 2001 09:00:38 +0100 Subject: Python In A Nutshell References: <3AB1700C@MailAndNews.com> Message-ID: <98cn2d$oad$1@newsreaderg1.core.theplanet.net> > We all know Alex--hi Alex!--uses lots and lots of words to say things. That's one of his qualities and should be greatly appreciated. Alex EXPLAINS things and allways figures out the PYTHONIC way to do things. For me it always is a pleasure to read Alex' answers. It' s high time that Alex writes a book, isn't it? Consider this: A book has to save you time. If one writes too much you can pick out what you need for your problem at hand. If one writes too little, the book is a waste of time. Regards Franz "Laura Lewin" wrote in message news:3AB1700C at MailAndNews.com... > Hi, > We all know Alex--hi Alex!--uses lots and lots of words to say things. > > But he certainly knows how to make a point....(wait and see!) It will be a > nutshell not a treatise. No schedule yet. > Laura > LLewin at oreilly.com > > >===== Original Message From "Don Tuttle" ===== > >> [Don Tuttle] > >> >Planning stages? We've all seen his posts (a.k.a. treatises) here. I'd > >say > >> >he should have the final draft to you in 3 weeks tops. ;-) > >> > >>[Aahz ] > >> ITYM "first draft". It will take another three-to-six months for Alex > >> to edit it down. ;-) > > > >Good point Aahz. And of course another six months for O'reilly to cut it > >down to a mere 1,200 pages! All in all, it MIGHT be out just in time for > >Christmas 2002 ;-) > > > >Don > > > > > From not.this at seebelow.org Fri Mar 30 23:27:52 2001 From: not.this at seebelow.org (Grant Griffin) Date: Fri, 30 Mar 2001 22:27:52 -0600 Subject: Know of Substantial Apps Written in Python? References: <3ac4e4a8_1@news4.newsfeeds.com> <3ac4ff12$1_2@news4.newsfeeds.com> Message-ID: <3AC55CC8.44850ECF@seebelow.org> Dry Ice wrote: > ... > What "substantial" is might be defined in terms > of project length. Perhaps something which would > take a good programmer several months. If you measure "substantial" in terms of months, the answer is a no-brainer. Yup, legions of folks have "been there, done that". For example, I did a Python project recently which grew "organically", in spurts, over a period of about a year; it probably took several months of total work. The project was one of those things that nobody really planned to do, but just needed doing. It started out small and grew bigger with each feature request. In terms of Python code, features grew into functions, functions grew into classes, classes grew into modules, and modules grew into libraries. Even though the project had not been planned whatsoever in advance, virtually no code got thrown away: it was always a forward process. Python code wears well. > Something as complex as a web browser might do, > if the language in question does not merely act as > glue for modules written in C or whatever. Rumor has it that Google is implemented in Python. (OK, maybe not _all_ of it. ) > In the end, this is like evaluating people. We can > listen to what others say about a person, or what a > person says about his or her self- or we can simply > see how they BEHAVE. Then you probably won't be much intersted in what I'm about to say. A related question that is often asked about a programming language is, "does it scale well"? To that, I think the answer for Python is definitely "yes", because: - It is extremly readable--more so than any other programming language I've seen. (I can't think of anything that might constrain complexity more than Humans not being able to understand something. Take Perl, for example. ) - It supports namespaces: you can write large pieces of code that don't conflict with each other. - It's extensible and embed-able: if you need more speed or whatever, you can get it. In fact, if we turn your question around to consider what might _limit_ complexity (in the extreme), the only thing I can think of is Python's lack of a formal interface mechanism. (For more about that, see PEP 245, at http://python.sourceforge.net/peps/pep-0245.html.) It's no coincidence that this issue is of interest to the Zope folks. complex-is-better-than-complicated-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From shaleh at valinux.com Mon Mar 26 20:43:39 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Mon, 26 Mar 2001 17:43:39 -0800 (PST) Subject: math.choice attribute error In-Reply-To: Message-ID: On 27-Mar-2001 iddwb wrote: > > from the ref man math.choice says it takes a sequence object and returns a > random choice. perfect for my needs. the follow happens: > >>>> import math >>>> list = ['apple', 'orange', 'pear'] >>>> print math.choice(list) > Traceback .... > attributerror: choice > I know random does: >>> import random >>> l = [1, 2, 3] >>> random.choice(l) 2 From kens at sightreader.com Wed Mar 21 18:38:34 2001 From: kens at sightreader.com (Ken Seehof) Date: Wed, 21 Mar 2001 15:38:34 -0800 Subject: Dynamically reloading extension modules Message-ID: <00ff01c0b260$0bd225a0$04090a0a@upcast.com> Not exactly. I didn't state the problem very clearly. The problem is that while an extension module is loaded, the module file (pyd on windows) is read-only. At least this is true on windows. On unix, I think maybe you can rename the module file, rebuild it, and do a reload(module). Is this true? Windows doesn't allow you to rename or rewrite a dll while it is in use, so something like FreeLibrary would be necessary. "Timothy Grant" says: > On Wed, Mar 21, 2001 at 02:01:44PM -0800, Ken Seehof wrote: > > Has anyone found a technique for dynamically unloading and > > reloading an extension module? I want to be able to modify, > > build, and reload an extension module from within my program. > > > > Unfortunately python apparently doesn't use FreeLibrary when > > a module object is released. Maybe I can do some kind of > > hack to call FreeLibrary explicitly. Is there a way to do this that > > is portable? > > I'm not sure I know what your asking, but does > > reload(modulename) fit the bill? ---------------------------------------------------- Copyright (c) 2001 by Ken Seehof This document may not be distributed, copied, duplicated, or replicated in any form without express written permission by Ken Seehof. Express permission is hereby granted. kens at neuralintegrator.com ---------------------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From ws-news at gmx.at Thu Mar 22 10:50:04 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Thu, 22 Mar 2001 16:50:04 +0100 Subject: Text printing under Windows References: Message-ID: <985276499.676502@newsmaster-04.atnet.at> I think you can just open the file 'LPT1' and write your data there, but not sure about that - do not have a printer connected which I could use to try. You probably need to open the device with Windows' CreateFile() API function, provided by the win32file module in Python. Another possibility is to dump the data to a text file and print it with notepad.exe (it has an option /p to just print and exit...). One more possibility is to use the ShellExecute(Ex) APIs, using 'print' as the verb for that file (it must be a textfile (*.txt) for that to work) hth werner "Gabriele Favalessa" wrote in message news:slrn9bk130.10l.ego at macondo.visconti.home... > Hi, > > how do I print using a dot matrix printer in text mode under Windows > 98? I have both a local and a remote printer. > > I use python 2.0 and wxPython 2.2.5. The latter seems to support > printing only in bitmap mode. > > My knowledge of win32 APIs is poor, I'm looking for a simple > open/write/close API. Something similar to: > > printer = os.popen ("lpr -Pprinter1") > printer.write ("Hello world!\n") > printer.close () > > that works fine under unix. > > Thanks in advance. > > Gabriele From TCHUR at doh.health.nsw.gov.au Wed Mar 21 01:43:43 2001 From: TCHUR at doh.health.nsw.gov.au (Tim CHURCHES) Date: Wed, 21 Mar 2001 17:43:43 +1100 Subject: Base 2 to long integers and back Message-ID: Brian, Thanks. I just discovered that the string.atol() function (or the long() built-in in 2.x) takes an optional radix argument, thusly: >>> a = '0000101010100000111010101001010000111110100101010100101010010100101010100101010100000111110101010101000101001001001010'>>> print string.atol(a,2)13796684847850186040196945077883466L but there is no built-in or library function which does the reverse, it would seem. However your code does the trick nicely and quite quickly, although a small C extension to do the same would be nifty. Now where did I put my copy of "Teach Yourself C in 23 Minutes or More"? Cheers, Tim C >>> Brian Quinlan 21/03/2001 17:19:11 >>> I can't think of a library function that does this, but it should be pretty easy to do it yourself. String to int: >>> test = '10110' >>> val = 0L >>> for i in test: ... val <<= 1 ... if i == '1': ... val += 1 >>> val 22 OR, for the anal and efficiency oriented: >>> test = '10110' >>> val = 0L >>> for i in test: ... val = ( val << 1 ) + ( ord( i ) & 1 ) >>> val 22 Int to string: >>> out = '' >>> val = 100 >>> while val: ... out = str( val & 1 ) + out ... val >>=1 >>> out '1100100' -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Tim CHURCHES Sent: Tuesday, March 20, 2001 7:23 PM To: python-list at python.org Subject: Base 2 to long integers and back Can anyone suggest a fast method of converting base2 strings (e.g. '0000101110') to Python long integers, and back? I couldn't locate any functions in the standard library to do this, but no doubt I am overlooking something obvious. Cheers, Tim Churches Sydney, Australia -- http://mail.python.org/mailman/listinfo/python-list From sebastien.libert at comexis.com Tue Mar 13 05:11:30 2001 From: sebastien.libert at comexis.com (Sébastien Libert) Date: Tue, 13 Mar 2001 11:11:30 +0100 Subject: file - codecs - unicode ??? References: <3aace9da$0$382$446d705c@news.skynet.be> Message-ID: <3aadf0bf$0$384$5a62924d@news.skynet.be> Hi, Thx for your advice !!!!! It work ( ?? sometimes !!!!) But i have a lot of problem with the /012 : If i keep it : >>> fline=unicode(fline,'UTF-16').encode('LATIN-1') Traceback (innermost last): File "", line 1, in ? UnicodeError: UTF-16 decoding error: truncated data if i delete it : >>> fline=fline[:-1] >>> fline=unicode(fline,'UTF-16').encode('LATIN-1') Traceback (innermost last): File "", line 1, in ? UnicodeError: Latin-1 encoding error: ordinal not in range(256) Another clue : I have converted the file in UTF-8 ( with notepad ) : gline '0.00\011info\011Log_Version\0111.2\012' >>> gline=unicode(gline,'UTF-8').encode('LATIN-1') >>> gline '0.00\011info\011Log_Version\0111.2\012' ;-) So the file was in UTF-16 and is now in UTF-8 : The result is good for me ! When i do that with python : f=open("c:\\mylog.log") >>> fline=f.readline() >>> fline=unicode(fline,'UTF-16').encode('utf-8') Traceback (innermost last): File "", line 1, in ? UnicodeError: UTF-16 decoding error: truncated data If you have another advise for me !! Fell free to answer ! thx "Marcin 'Qrczak' Kowalczyk" wrote in message news:slrn9aqka1.3vk.qrczak at qrnik.zagroda... > Mon, 12 Mar 2001 16:29:42 +0100, S?bastien Libert pisze: > > > >>> line > > '\377\3760\000.\0000\0000\000\011\000i\000n\000f\000o\000\011\000L\000o\000g > > \000_\000S\000t\000a\000n\000d\000a\000r\000d\000\011\000n\000g\000L\000o\00 > > 0g\000\015\000\012' > > > > What can i do with this kind of thing ????? > > It's encoded in UTF-16, so: > unicode(line, 'UTF-16').encode('ASCII') > except that the '\012' at the end is bogus. It shouldn't be there. > > You may want to use a different encoding than ASCII, because ASCII > is only able to encode Latin letters without accents. If the string > contains other character, you will get an exception. > > -- > __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ > \__/ > ^^ SYGNATURA ZAST?PCZA > QRCZAK From mda at idatar.com Sat Mar 17 13:41:52 2001 From: mda at idatar.com (David Allen) Date: Sat, 17 Mar 2001 18:41:52 GMT Subject: How do I avoid the Tkinter 30 msec polling loop. References: <98toci$ktjh$1@fido.engr.sgi.com> Message-ID: In article <98toci$ktjh$1 at fido.engr.sgi.com>, "Paul Jackson" wrote: > Anyhow, is there anyway to stop or radically slow this loop? > > The little window responds to no key or mouse input. It just changes the > text message when Label.configure (text="you have mail") or some such is > executed after the once a minute thread wakes up and notices a change in the > mail box. Check out: http://www.pythonware.com/library/tkinter/introduction/x9129-alarm-handlers-and-other.htm It is a page on Tkinter non-event callbacks. It has a set of methods described there for Tkinter where you can call a certain function once every X milliseconds where you specify X. If you read that page, I think it will answer your questions. -- David Allen http://opop.nols.com/ ---------------------------------------- Be wary of strong drink. It can make you shoot at tax collectors and miss - Lazarus Long, "Time Enough for Love" From aleaxit at yahoo.com Sun Mar 25 11:50:49 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 25 Mar 2001 18:50:49 +0200 Subject: static methods References: <3ABD7673.9D447A32@home.com> Message-ID: <99l7mu01ed6@news1.newsguy.com> "Rick Lee" wrote in message news:3ABD7673.9D447A32 at home.com... > Thanks, and thanks to Alex. This is very useful, also very telling that it > is pretty obscure. For me, static, or class-wide methods are very useful. > With this, you only have to pass the class reference to the caller. > Otherwise, you have to pass both the class reference and the module > reference to the caller. Actually, the module reference will suffice; it will contain suitably named callables to: -- generate instances of the class (the class-object itself and/or suitable factory functions), -- do whatever else you need to be done class-wise. You can package up those callables any way you want; there is really no special reason they should be attributes of the class object as opposed to that of any other object, and a module object is typically handiest. The desire to use the class-object specifically, rather than any other, typically seems to have more to do with familiarity with other languages where classes must play certain special roles (C++, Java, Smalltalk, Eiffel) than with any actual programming needs. Alex From syver at NOSPAMcyberwatcher.com Thu Mar 29 01:02:05 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Thu, 29 Mar 2001 08:02:05 +0200 Subject: Recommendations for Python Books References: <3ac2582c$1@news.starhub.net.sg> Message-ID: If you're using Win32 buy Andy Robinson and Mark Hammond's Python Programming on Win32. Also be sure to check out www.python.org and the documentation that comes with Python. There are also much to learn from studying the library and samples that come with python, check out the Tool/scripts directory in the Python directory for lots of small and interesting python programs. "Wong Da Qiang" wrote in message news:3ac2582c$1 at news.starhub.net.sg... > Just a newbie to programming and python, need some recommendations on books > to buy > > From loewis at informatik.hu-berlin.de Wed Mar 14 05:50:58 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 14 Mar 2001 11:50:58 +0100 Subject: Embedded Python and sharing Data? References: Message-ID: Karl Bellve writes: > The question is, how do I share data between python and my > program. The data can be as large as a gigabyte and is usually > stored in memory. I obviously don't want to duplicate this data :-) > Can I pass pointers? Can I create a Python Object but then how do I > tell python that it contains a normal integer array? The best way would be to define your own data type, which should implement the buffer protocol (see http://www.python.org/doc/current/api/buffer-structs.html for the definition of the buffer protocol, and xxmodule.c for a minimum example of a C type). Then you get an object for which you can do indexed access to bytes, slicing, etc. You can even use PyBuffer_FromMemory if it is *always* stored in memory (i.e. accessible through a pointer); in that case you don't have to implement your own type. If you want to expose the data in a more structured way (e.g. as an array of ints), you again have to define your own type, and provide it with accessor functions. You'ld implement the sequence protocol, and construct integer objects when given an integer index. Regards, Martin From nanotech at europa.com Wed Mar 28 16:47:56 2001 From: nanotech at europa.com (nanotech at europa.com) Date: Wed, 28 Mar 2001 21:47:56 -0000 Subject: Getting all the *files* from a directory -- A better way?? Message-ID: <99tm6c+bsk6@eGroups.com> Thanks to everyone who answered! Notice that: dir="/a/b/c" files1=[f for f in os.listdir(dir) if os.path.isfile(f)] files2=[os.path.basename(f) for f in os.listdir(dir) if os.path.isfile(f)] would be much "prettier" than: files1=[os.path.join(dir,f) for f in os.listdir(dir) if os.path.isfile(os.path.join(dir,f))] files2=[f for f in os.listdir(dir) if os.path.isfile(os.path.join(dir,f))] if os.listdir returned the given path prepended -- but oh well!! Quentin Crain From moshez at zadka.site.co.il Fri Mar 30 15:24:19 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Fri, 30 Mar 2001 22:24:19 +0200 Subject: Know of Substantial Apps Written in Python? In-Reply-To: <3ac4e4a8_1@news4.newsfeeds.com> References: <3ac4e4a8_1@news4.newsfeeds.com> Message-ID: On Fri, 30 Mar 2001 12:02:14 -0800, "Dry Ice" wrote: > Know of substantial apps written in Python? Two big ones come to mind: Mailman (www.list.org) and Zope (www.zope.org) Oh, and Sketch (sketch.sourceforge.net) -- "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than Python? looking for someplace else to grab power."|YODA: No...no... no. Quicker, -- Wichert Akkerman (on debian-private)| easier, more seductive. For public key, finger moshez at debian.org |http://www.{python,debian,gnu}.org From francois.granger at free.fr Fri Mar 9 16:59:07 2001 From: francois.granger at free.fr (=?ISO-8859-1?Q?Fran=E7ois_Granger?=) Date: Fri, 09 Mar 2001 21:59:07 GMT Subject: gah! I hate the new string syntax References: <97ohh2$polt0$1@ID-77331.news.dfncis.de> <97opsb$nhu$1@nntp6.u.washington.edu> <98an7i01tgp@news2.newsguy.com> Message-ID: <1eq0wih.1s0r5163x0lfkN%francois.granger@free.fr> Alex Martelli wrote: > (Of course, intentions to > return are not always carried out There are a lot of french citizen wich are descendant from italian. At some point of time we were really welcoming of political refugees. We are not any more, and I am sorry for this. We also needed a lot of workers for house building, and italian made a perfect fit between the world wars. Later we "used" spanish, then north african... > -- few are aware, for example, > that such an icon of French popular culture as Yves Montand was > Italian -- real name Ivo Livi, born of just-as-Italian parents > in a village near Florence; his father, a socialist, had to flee > [and ended up in France] when the Fascists took power, and Ivo, > as well as the rest of the family, followed him a while later; > I'm not sure when he changed his citizenship over to France). And lots of french people are really proud of Yves Montant, knowing or not his origin as Ivo Livi. -- "La connaissance est le chemin de la tol?rance, c'est valable pour tous, en toutes saisons." - Raymond Page From loewis at informatik.hu-berlin.de Fri Mar 2 11:10:11 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Mar 2001 17:10:11 +0100 Subject: Editing Python source as XML? References: Message-ID: Steven Haryanto writes: > A recent experience of having to modify a long C source file has > led me to wonder whether there are any tool/effort towards editing > Python source code as XML or other form of structured document. Not sure *why* you'd want to do that, but it is certainly possible to convert any script automatically to an XML document with the help of the parser module. > What I would like is an editor that presents the source file as a > tree outline, where I can collapse selected class or function > definition body, certain long if's/for's, some section of code, > view/hide the asserts, etc. PythonWin, and the Emacs Python mode, both can do that today. Regards, Martin From shaleh at valinux.com Thu Mar 22 15:59:02 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Thu, 22 Mar 2001 12:59:02 -0800 (PST) Subject: Python and emacs In-Reply-To: <99dkg711894@news1.newsguy.com> Message-ID: On 22-Mar-2001 Alex Martelli wrote: > "Sean 'Shaleh' Perry" wrote in message > news:mailman.985287273.17896.python-list at python.org... >> >> On 22-Mar-2001 Don Dwiggins wrote: >> > A semi-idle question: has anyone looked into embedding Python as an >> > extension language in Emacs, alongside Elisp? I'm toying with the idea > of >> > doing some Emacs enhancements/modifications, and given the choice, I'd > much >> > rather do them in Python. (One such enhancement would be to add >> > Pythonwin-style "intellisense" popups to python-mode.) >> >> An editor that spoke python would not be a bad thing. However, trying to > get > > Whaddya mean, 'would'? VIM does that right now, and has for years > (see www.vim.org)... > rephrase that -- 'something like emacs, but based on python'. I grew up on vi, but now I am an adult and have put away my toys (to paraphrase a famous poem). From aleaxit at yahoo.com Mon Mar 19 07:19:22 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 19 Mar 2001 13:19:22 +0100 Subject: Who's minister of propaganda this week? References: <98nu1m$12e@dispatch.concentric.net> <660ACCA1E4816F7E.C359CDF4168EF3FB.3B6B05538D619770@lp.airnews.net> <3AAFA13D.76E32C3F@divalsim.it> <98oa4o01i4v@news2.newsguy.com> <98q9h60122v@news2.newsguy.com> <9937en0bge@news2.newsguy.com> <994ab801h5o@news2.newsguy.com> Message-ID: <994tg9026qa@news1.newsguy.com> "Marcin 'Qrczak' Kowalczyk" wrote in message news:slrn9bbin2.11r.qrczak at qrnik.zagroda... [snip] > Design patterns designed for C++ and Java are not applicable to > languages which use algebraic types and don't use subtyping. C++ > and Java don't have a convenient way to express "either this or that > or these" (wrapping each case in a class is not convenient enough). > OTOH Haskell and OCaml don't work by implicit coercion of elements > to a common supertype. Isn't that what the "O" in O'Caml adds to plain good old Caml? (And the "O" in O'Haskell too, but you're not addressing that one). > Note that in these languages it's meaningless to mix all types of > objects together in a container. If they are unrelated, you can't > apply any operation to an unspecified member of them. Not sure if by "these" you mean, here, "the former" (C++, Java, ...) or "the latter" (ML, Haskell, ...). In Java, objects can never be truly unrelated, as they all derive from a common ancestor (Object); thus, you can always hold anything through a reference to Object, and try casting (which will fail with a predictable, catchable exception if need be) to obtain usable interfaces. The exact C++ translation is not standard, as dynamic_cast<> with a void* argument need not be implemented by all standard C++ compilers, so, you _do_ need to explicitly provide some 'remote relation' on which dynamic_cast<> can be portably applied (that 'relation' need not DO anything, just as the interface used in 'Acyclic Visitor' doesn't -- as long as it has SOME virtual, typically a virtual destructor, dynamic_cast<> will work). > Tell what do you really want to archieve. The whole thing looks like > a poor fit to the style of these languages. You don't want to have a > net of containers of everything. For example if they are registered I'm not going to retype the whole relevant section of "Design Patterns" -- please look it up for yourself. Again, there is pronominal ambiguity in the "these". Assuming now that by 'these' you mean 'Haskell' (or ML or Caml without the 'O'), it's not true that I don't _want_ to built heterogeneous, structured containers -- it's that I _can't_ do it conveniently, because of the language limitations imposed by the desire to allow static type-checking. > to let somebody do something with them, you would rather register > "do something with them" actions instead of objects themselves. > Objects are rarely mutable so even this looks very suspicious. Objects are rarely mutable _in functional programming_ -- they are commonly mutable _in object oriented programming_, and this makes a very substantial difference. Python allows and strongly encourages object-oriented programming, as do other languages which implement compile-time static type checking. Haskell (as opposed to O'Haskell) doesn't; O'Caml, to the extent that it does, also introduces ref/mutability and other complexities. Debating the need/opportunity for static/dynamic typing in languages that focus on FP, not O-O, may no doubt be quite interesting (I keep thinking that Erlang's real-world success, and the huge boost it gives to programmer productivity, may have something to do with its being dynamically typed albeit in an FP context) but has precious little to do with this thread, or with any language lacking such an FP focus. Alex From aleaxit at yahoo.com Mon Mar 26 05:52:52 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 26 Mar 2001 12:52:52 +0200 Subject: static methods References: Message-ID: <99n72706g0@news2.newsguy.com> "Christian Tanzer" wrote in message news:mailman.985586915.11526.python-list at python.org... [snip] > > Otherwise, you have to pass both the class reference and the module > > reference to the caller. > > Actually, the module reference will suffice; it will contain suitably > named callables to: > -- generate instances of the class (the class-object itself and/or > suitable factory functions), > -- do whatever else you need to be done class-wise. > > You can package up those callables any way you want; there is > really no special reason they should be attributes of the class > object as opposed to that of any other object, and a module > object is typically handiest. : This seems to be the standard answer on c.l.py. I'm not convinced. : There are two cases: : - Modules defining a single class. : In this case, most people would use the same name for both module : and class. If you need the module object for scoping purposes, you : end up with code using lots of `Bletch.Bletch' which I find atrocious. You don't often need to obtain *the class-object* from your caller -- it's generally only needed when you're defining a class of yours *that _inherits_ from a caller-supplied class-object*; a pretty rare, although undoubtedly elegant, highly-dynamic idiom. For those pretty rare needs, _when you also further need a few other functions that are not-instance specific_ (also caller-supplied ones), I find that just about any way to package things up works -- sure, you and your caller may need to agree on attribute-names or whatnot, unless you want to pass several objects, but then, you'd anyway need to agree on the N names of the various non-instance-specific functions' names, and one more agreed-upon attribute name (for the class-object itself), for a total of N+1 instead of N, is hardly a hardship such as to justify language-changes! More often, what you need to get from your caller is just *a bunch of callables* -- one or more to generate objects of the appropriate class[es], zero or more to operate 'generically' (not as methods of some instance). Here, the class object _might_ be one of the callables in the first subset (factory-callables), but there is really no advantage in singling it out for special treatment as against other factory-callables, and why should the *other* (if any) generic functions be preferably packaged up as attributes of one of the factory-callables?! It seems a peculiar arrangement indeed. I see nothing wrong with needing a trivial wrapper to setup this packaging arrangement if you're really keen on it. Note that, in any case, you'll STILL need naming-conventions for (at best) all but one of the callables (unless you want to pass them as separate objects, of course). The handiest packaging helper is the usual suspect: class ABunchOfStuff: def __init__(self, **kwds): self.__dict__.merge(kwds) whenever you need to package up, and pass as a function argument, a bunch of stuff with some set of agreed names, you do so by passing a suitably initialized ABunchOfStuff instance. There are no restrictions to the kinds of callables (or other objects) that can live as attributes of this bunch-o'-stuff, nor on their names. : Rick also talked about passing around a reference to the class. If : you pass a reference to a module instead, you need a convention how : to refer to the class defined by the module. If you don't need other callables, but just one factory callable, it's fine to pass just that callable object, of course -- it may, as a special case, be the class-object, just as of-course. When you DO need to pass N+M callables (M of them being factories, the other N non-factory, non-instance-directed generics) you do need to pass them separately, or to have some naming convention if you want them to pass them as attributes of some object, or other kind of similar conventions (e.g. you could pass one or two tuples or other sequences, but then you'll need conventions on the order in which various callables occupy item slots in those sequences -- quite analogous to a naming-convention:-). There's nothing intrinsically superior about the packaging convention of passing one object and having the other N+M-1 be attributes of that distinguished object (and that still needs a naming convention anyway). You can get that sort of arrangement if you want, but I don't see why a language should go out of its way to make it handier for you wrt other kinds of arrangements. : Modules defining multiple classes. In this case, passing a module : reference instead of a class reference won't fly, anyway. It's still an issue of how you arrange/package things up, naming (or other organizational) conventions, etc. If I have multiple similar classes in a module, I'm _particularly_ likely to want to pass from it, as the factory callable, something OTHER than one of those class-objects -- a factory function that will choose _which_ exact class to instantiate depending on arguments, environment, etc. If the other generic functions need to know what specific _class_ has been instantiated, i.e. they're not really as generic as all that, then having them as attributes of the actual _instance_ (not necessarily the _class_ thereof) may work. The module-object may be the appropriate object to pass if you rely on naming conventions for the factory function[s] and semi-generics. Alternatively, repackaging whatever appropriate subset of callables into a BunchOStuff instance works just fine; as do other somewhat more complex approaches, but I tend to prefer simplicity whenever feasible. : You could dismiss modules with multiple classes out of hand, but : IMNSHO this would be rash (and inconsistent with your approval of : Lakos' ideas about large scale design). Why should modules with multiple classes be problematic here? A given factory-function may instantiate the proper class, whether the candidate classes are all in one module, or spread among several modules, just as easily. > The desire to use the class-object specifically, rather than any > other, typically seems to have more to do with familiarity with > other languages where classes must play certain special roles > (C++, Java, Smalltalk, Eiffel) than with any actual programming > needs. : I used languages with strong emphasis on the module as primary : construct (like Modula-2 and Ada) and languages favoring the : class as the primary construct (like Eiffel and C++). I found the : latter much better suited to my programming needs. That doesn't mean But does Modula-2 (or the Ada version you used) offer classes *at all*? Modules per se don't offer enough _polymorphism_ (if any), which is a rather different issue; classes (or at-least equivalent constructs, such as 'prototype objects' in languages oriented to their use) are a real need because of that, while not necessarily usurping modules' role for subsystem packaging. : that I shun modules, though. Fortunately, Python doesn't force either : direction (with some tricks to get class functions). The well-known tricks are one possibility, sure, but different organizations of the needed callables often shine brighter. Alex From hzhu at users.sourceforge.net Wed Mar 21 16:37:16 2001 From: hzhu at users.sourceforge.net (Huaiyu Zhu) Date: Wed, 21 Mar 2001 21:37:16 GMT Subject: New PEP: The directive statement References: Message-ID: With the __future__ PEP, I envision there could also be things like from __future__ import nested_scope from __experimentatal__ import stackless from __optional__ import static_type from __mandatory__ import string_methods New feature would migrate from __experimental__, to __future__, then to either __optional__ or __mandatory__. Things in __experimental__ are not guaranteed to be there in later versions. Things in __future__ will definitely be there in a later version. The __mandatory__ could be used to make the intention about version requirement more explicit than __version__ would allow. (Someone asked about whether __future__ should be phased out in later code.) The __optional__ could be used for permament optional features that affect syntax. So with this directive PEP, the parallel would be directive transitional nested_scope directive experimentatal stackless directive optional static_type directive mandatory string_methods Is this correspondence correct? (You may not agree on the need for other directives, but I want to know if the keyword translations are correct.) If so, I see two problems. 1. It introduces a new syntax while an existing syntax could be reused without much cost. 2. There is no place for version and documentation info. So far as I can see, the impetus for directive keyword is that import is a run time action, while the __future__ is a compile time declaration. But is it so far a stretch? All Python __magic__ words go beyond normal meaning. Defining __setattr__ will affect more than this method alone. Having __init__.py will cause other modules to be imported. And so on. If we look more broadly, in *nix, devices, processes, pipe and others are also represented as files. Would it better to assign special syntax to all of them? IMHO, reusing existing syntax is closer to Python than Perl, which introduces new syntax for many things that are only slightly different. Huaiyu From klxsyi at e.eliminate.com Tue Mar 27 07:48:30 2001 From: klxsyi at e.eliminate.com (klxsyi at e.eliminate.com) Date: Tue, 27 Mar 2001 12:48:30 GMT Subject: Warning.............please read.................................................................... . 1857 Message-ID: Do you want your family or the authorities to find out what sites you surfed? When you access the Internet, your computer keeps permanent hidden records of your activities! Files I shredded months earlier were clearly visible using this software. I advise you to check it out........... http://www.evidence-eliminator.com/go.shtml?A653704 qkjbtbodsvrsknpcwolfcrezvxyeewlrtbndsnbvscdtbhjwhwrqbrccykvnyuui From bob_cannard at mentor.com Wed Mar 21 12:37:35 2001 From: bob_cannard at mentor.com (Bob Cannard) Date: Wed, 21 Mar 2001 09:37:35 -0800 Subject: re.match References: <997skf$qoc$1@bmerhc5e.ca.nortel.com> Message-ID: <3AB8E6DF.A2C32AD8@mentor.com> "Michael P. Soulier" wrote: > > Hey people. Could someone explain the purpose of the match function in the > re module? If it's only difference from search is to match at the beginning of > the line, why does it exist? That's what the ^ in the regexp is for. I'd like to add my own recent experience as a Python newbie getting to grips with its implementation of regexps. Once upon a time there was a regular expression which matched a - well, let's call it a Thing. There were 3 questions that needed to be asked: - Does this string contain any Things? (re.search, obviously) - Find all the Things in this string. (re.findall) - Is this string a Thing? (re.match - er, no, that doesn't work, it only asks if this string begins with a Thing.) Life would have been perfect if re.match, or some similar function, required a match of the entire string against the regular expression. But it doesn't, and there doesn't seem to be a function that does, so the regular expression spawned another with a dollar sign on the end. (Curious assymetry.) Alternatively the regexp could have been left uncompiled so it could be manipulated, but that would have caused a loss of speed and generality in my lower-level functions. Another possibility would have been to combine compiled regular expressions, but there doesn't seem to be a way to do this. Does anyone know of a function or piece of magic that I've missed? Anyway, my point is that there does seem to be a case, from my experience, for having different functions that do different things with the same regular expression. If anything I'd like to see more of them. Cheers, Bob. From mwh21 at cam.ac.uk Fri Mar 2 18:51:36 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 02 Mar 2001 23:51:36 +0000 Subject: python-dev summary 2001-02-15 - 2001-03-01 References: Message-ID: "Tim Peters" writes: > [Michael Hudson] > > ... > > The iteraators discussion seems to have disappeared. At least, your > > author can't find it! > > Greg Wilson set up an egroups (now Yahoo) discussion group for it, where > debate has continued: > > http://groups.yahoo.com/group/python-iter > > Marc-Andre Lemburg set up another (or agitated toward this end) mailing list > for it on SourceForge, for reasons that escape me at the moment. I never got > around to subscribing to that too; the link on SF: > > http://www.geocrawler.com/redir-sf.php3?list=python-iterators > > appears broken, and the archive link: > > http://lists.sourceforge.net/archives//python-iterators/ > > leads to a page that doesn't make sense. Ah, I'm subscribed to the sf one, which seems to be silent. I shall have to check out the Yahho!(bletch)groups one. Cheers, M. -- It's actually a corruption of "starling". They used to be carried. Since they weighed a full pound (hence the name), they had to be carried by two starlings in tandem, with a line between them. -- Alan J Rosenthal explains "Pounds Sterling" on asr From ullrich at math.okstate.edu Sat Mar 3 13:07:35 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sat, 03 Mar 2001 18:07:35 GMT Subject: Hitting two targets: OO + group theory (pedagogy) References: <3aa1077a.1110803@nntp.sprynet.com> <0932atgt9v8d8aboq90evoi5ipj5c0sk8s@4ax.com> <3aa11a91.5998558@nntp.sprynet.com> Message-ID: <3aa13152.173635120@news.okstate.edu> On Sat, 03 Mar 2001 09:16:14 -0800, Kirby Urner wrote: >ullrich at math.okstate.edu (David C. Ullrich) wrote: > >>Some people would say that the reference to Genesis >>is out of place here... probably you know that some >>people would say that. Might be regarded as just >>generally inappropriate - some other people might >>think that the bit about Abel is misleading, since >>"Abelian" _does_ refer to a man named Abel, but >>not the one in Genesis. > >True, but it's a useful mnemonic connected to a >well-known story. Making allusions to Biblical >characters need be no more or less churchy than >alluding to Greek mythology or to cartoon characters >like Bugs Bunny (or Coyote in Native American lore) >-- just taking advantage of some shared cultural >heritage. Right. I didn't say it was inappropriate. Although in fact something about the bit about "If you've studied Genesis" or however you put it seems a little off-putting; if you were referring to Bugs Bunny or Zeus you'd just refer to them. Never mind - could be I've been in Okllahoma too long. >Anyway, I learned this mnemonic from a very strait- >laced group theory book (which I've since returned >to the library), plus saw it mentioned on another >list frequented by math heads -- sort of assumed >this clever CAIN/Abel thing was cited routinely >by those more familiar with the literature. Agreed >though: we should make clear who the Abel in Abelian >was. > >>But why not start with a class Group instead >>of special cases? (Would be a class with a >>__mul__ method that does nothing but raise >>an exception "must implement __mul__ in >>a subclass", an Id attribute, etc. I can't think >>of anything offhand that Group would actually >>_do_, but if we're bent on this OO-math thing >>it seems like groups _should_ be descendants >>of a class Group...) >> > >In my example, it's the elements of a group which >get instantiated as separate objects, with each >element inheriting the same meaning for *, whatever >that might be. Right. That's actually what I meant, a class Group instances of which would represent elements of a generic group - of course there's no such thing so you'd never create instances of Group. Then subclasses of Group represent actual groups; instances of the subclasses being elements of actual groups. Not important, just seems to me like what it "should" be. From Laura_01 at MailAndNews.com Wed Mar 14 20:11:09 2001 From: Laura_01 at MailAndNews.com (Laura Lewin) Date: Wed, 14 Mar 2001 20:11:09 -0500 Subject: Magnitude of the wx* market (was: Python In A Nutshell - suggestions) Message-ID: <3AB26DAC@MailAndNews.com> Hi, Sure, we'll take this suggestion into consideration (on expanding wxPython coverage) when we publish the next edition of Python Programming on Win32. Thanks! Laura LLewin at oreilly.com >===== Original Message From tim at digitig.cix.co.uk ===== >In article >, >claird at starbase.neosoft.com (Cameron Laird) wrote: > >> In article <3AAA4FE3.B471B689 at northwestern.edu>, >> Louis Luangkesorn wrote: >> . >> . >> . >> >And while I'm at it, one useful book to have would be on >> wxWindows/wxPython. I see references to it in several places, and a >> few intros on the web, but >> . >> . >> . >> This is an interesting point. It's typical in computer >> book publishing that publishers want more than authors >> can produce; roughly, someone like ORA would happily >> print many more titles than they can find authors willing >> and able to write. >> >> I happen to know, though, that several publishers have >> rejected wxWindows proposals. >> >> I doubt, though, that there'd be much trouble making the >> case that the subject deserves a chapter in a larger work. > >And the larger work in question is "Python Programming on Win32" by Mark >Hammond & Andy Robinson, already published by ORA, so I doubt they'd be >particularly interested in another! It doesn't have full documentation of >the wxPython classes, though, just a tutorial introduction. Maybe the way >to go is to get them to extend it in the next edition? From kens at sightreader.com Wed Mar 21 18:57:01 2001 From: kens at sightreader.com (Ken Seehof) Date: Wed, 21 Mar 2001 15:57:01 -0800 Subject: Dynamically reloading extension modules References: <007f01c0b252$852bb370$04090a0a@upcast.com> <20010321145901.M24341@trufflehunter.avalongroup.net> <00e201c0b25f$b95d4a70$04090a0a@upcast.com> <20010321154600.Q24341@trufflehunter.avalongroup.net> Message-ID: <012301c0b262$9fab59c0$04090a0a@upcast.com> > On Wed, Mar 21, 2001 at 03:36:15PM -0800, Ken Seehof wrote: > > Not exactly. I didn't state the problem very clearly. The > > problem is that while an extension module is loaded, the > > module file (pyd on windows) is read-only. > > > > At least this is true on windows. On unix, I think maybe you > > can rename the module file, rebuild it, and do a reload(module). > > Is this true? Windows doesn't allow you to rename or rewrite > > a dll while it is in use, so something like FreeLibrary would be > > necessary. > > Sorry, I can't answer Windows questions. I haven't had to run > Windows in years. > > But I would still think that reload() should work as long as > you are using python modules, *not* c/c++ modules. I -am- talking about c/c++ modules (which I have been referring to as "extension" modules). Hence there's a bit more to it than reload(). I want to recompile and reload a c/c++ extension module from within a continuously running python program. > Beazley has no disclaimers about reload working only on > specific platforms. > > There is a caveat, objects created with the old module won't be > updated. From Marc.Poinot at onera.fr Mon Mar 12 10:51:34 2001 From: Marc.Poinot at onera.fr (Marc Poinot) Date: Mon, 12 Mar 2001 16:51:34 +0100 Subject: [ANNOUNCE] European Python Meeting Message-ID: <3AACF086.31D78DBC@onera.fr> *** Another Python Meeting... in Europe ;) *** ------------------------------------------------------------ Hallo Python-Freunde, zwei Jahre nach JPF001 findet erstmals eine europaeische Python-Konferenz statt, im Rahmen des Treffens "Freie Software" in Bordeaux (Frankreich). Mehr Informationen gibt es bei http://lsm.abul.org Die Python-Konferenz hat die Nummer 19. ------------------------------------------------------------ Hi you all Pythoneers. Two years after JPF001, I'm proud to announce the first attempt to organise an European Python event This event will take place into the Libre Software Meeting in Bordeaux, France. For more information see: http://lsm.abul.org The Python topic is number 19. ------------------------------------------------------------ Saluton, amikoj de Pitono, du jarojn post JPF001, okazos la unua euxropa kongreso pri Pitono, kadre de la Renkontigxo pri Libera Programaro en Bordozo (Francio). Pli da informoj (en la angla) haveblas cxe http://lsm.abul.org La sesio pri Pitono havas la numeron 19. ------------------------------ Salut a toi, ami(e) de Python Deux ans apres JPF001, une nouvelle conference Python vous est proposee dans le cadre des Journees du Logiciel Libre de Bordeaux: http://lsm.abul.org La session Python est la 19. Ceci *est* l'occasion pour se rencontrer, Pythoniens(niennes) de France et d'Europe. Pour le groupe de traduction en Francais, des ateliers seront mis en place, sous la houlette hop-la youpi la-houlette de Benoit Lacherez... ------------------------------ Marcvs [alias Translations by Konrad Hinsen ;] From jeremy at alum.mit.edu Wed Mar 28 12:06:17 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Wed, 28 Mar 2001 12:06:17 -0500 (EST) Subject: StandaloneZODB at cvs.zope.org In-Reply-To: References: Message-ID: <15042.6665.731184.238118@w221.z064000254.bwi-md.dsl.cnc.net> >>>>> "RB" == Robin Becker writes: RB> ... so is there some advantage in maintaining two projects? -- That remains to be seen. The administration of the project is different, but the end goal is the same. In the long term, I imagine we'd have a single project, but it's hard to be sure. The administrative different is that StandaloneZODB comes out of our CVS repository (cvs.zope.org) will always have the latest changes made by Zope developers at Digital Creations. The project at SF needs to be manually updated by someone. Jeremy From eferro at inicia.es Mon Mar 19 09:26:14 2001 From: eferro at inicia.es (Eduardo Ferro) Date: Mon, 19 Mar 2001 15:26:14 +0100 Subject: I lost characters at read Message-ID: <9955b4$i7b$1@diana.bcn.ttd.net> Hi! I am trying to create a window to log the contents of a file, to do this i first read all the file and later i periodically read the file if it grow up The problem is that when my periodic callback read from file i lost one or two characters per line and I don`t understand why Me code is (the problem is at the checkFichero fuction): class LogWindow: '''Clase para mostrar a modo de log lo leido de un fichero de texto''' def __init__(self,gtkContainer,fich,maxLineas): self.maxLineas = maxLineas self.numLineas = 0 self.intervalo = 1000 self.fich = fich self.gtkScrolledWindow = GtkScrolledWindow() gtkContainer.add(self.gtkScrolledWindow) self.gtkText = GtkText() self.gtkScrolledWindow.add_with_viewport(self.gtkText) self.gtkScrolledWindow.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC) self.gtkScrolledWindow.show_all() self.lstLineas = [] self.timer = timeout_add(self.intervalo,self.checkFichero) def checkFichero(self): self.gtkText.freeze() linea = self.fich.read() while linea != '': print '"%s"', % linea self.lstLineas.append(linea) self.gtkText.insert_defaults(linea) linea = self.fich.read() self.gtkText.thaw() print 'checkFichero' return 'true' #------------------------------------- def main(): gtkWindowMain = GtkWindow(type='toplevel') gtkWindowMain.connect('destroy',mainquit) fich = open('menu.txt','r') logWin = LogWindow(gtkWindowMain,fich,50) gtkWindowMain.show_all() mainloop() #------------------------------------- if __name__ == '__main__': main() From ubmurzyn at cyf-kr.edu.pl Tue Mar 27 06:29:10 2001 From: ubmurzyn at cyf-kr.edu.pl (Krzysztof Murzyn) Date: Tue, 27 Mar 2001 13:29:10 +0200 Subject: Building Python with Alpha Compaq compiler Message-ID: <3AC07985.2938D3AA@cyf-kr.edu.pl> I was wondering whether anyone managed to compile Python with Compaq compiler on Alpha running Linux RedHat. Any hints will be appreciated... Thanks, Krzysztof From fredrik at pythonware.com Mon Mar 12 18:12:50 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 12 Mar 2001 23:12:50 GMT Subject: tkinter entry index References: Message-ID: "dsavitsk" wrote: > how can i get the position of the cursor in an entry widget? .index and > .icursor don't seem to it. That is, if "foo" is in an entry, and the cursor > is between the "o" and the other "o", I could get a return of 2. position = w.index(INSERT) Cheers /F From emile at fenx.com Thu Mar 22 08:54:55 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 22 Mar 2001 05:54:55 -0800 Subject: tempfile problem on win98 References: Message-ID: <99d0dg$os92$1@ID-11957.news.dfncis.de> The mktemp routine guarantees to return a name unique in the target directory. Are you sure you're using fully qualified path names throughout when subsequently discovering duplicate files? Emile van Sebille emile at fenx.com "Steven Adams" wrote in message news:g3nu6.369$hb.2141 at news1.belrs1.nsw.optushome.com.au... > Hi, > > I'm using the tempfile module in Python 1.5.2 and it keeps giving me > duplicate filenames. > > It's being called only once each time the script runs, (small cgi > messageboard) with this is the code related to the tempfile: > > import tempfile > tempfile.tempdir=SOME_DIRECTORY > tempfile.template=None > id=tempfile.mktemp() > > shouldn't this give me a unique value for id every time? I initially > had it running without the tempfile.template being assigned None, but > when I noticed the duplicate filenames, so I thought I'd try that. > > Currently I'm making it recompute tempfile names until it has one that > does not already exist, but why does this happen?once I get a lot of > messages in the system I don't want to be possibly iterating through > the whole lot checking their names (unfortunately I don't have > permissions or the space to use a proper database) > > thanks for any help, > > Steven > > From s.sharp at fh-aargau.ch Fri Mar 23 10:21:02 2001 From: s.sharp at fh-aargau.ch (Sharp) Date: Fri, 23 Mar 2001 16:21:02 +0100 Subject: Install Python on Apache Message-ID: <99fph5$a2n$1@rex.ip-plus.net> Hi Everybody I sucked down Python from python.org and started to install the program on a win2000 apache system. that has worked perfectly. but then I tried to set up the apache httpd.conf file with the following options AddType application/x-httpd-py .py Action application/x-httpd-py /cgi-bin/Python/python.exe (cgi.bin is set to the right place because php and perl do work) But then it did not work. I hava also tried several variations but always with the same comands. The Error Message in the Apache error.log was [Fri Mar 23 15:54:50 2001] [error] [client xxx.xxx.xxx.xxx] Premature end of script headers: c:/web/cgi-bin/python/python.exe the script is looking like this #!c:/web/cgi-bin/Python/python.exe print ""; print " "; print " Test Page for Apache Test Suite"; print " "; print " "; print "

It Worked!

"; print " "; print ""; have you got me a solution? that would be great. yours Sharp From glenfant at equod.com.nospam Wed Mar 7 06:30:09 2001 From: glenfant at equod.com.nospam (Gillou) Date: Wed, 7 Mar 2001 12:30:09 +0100 Subject: Remote script execution with Python ... References: <7Ybp6.7729$r4.7336@news.indigo.ie> Message-ID: <9855om$aa5$1@reader1.imaginet.fr> rsh is in cygwin distribution (www.cygwin.com) so... this script should work with any python version on any Win32 system if the client script is launched from cygwin bash. "Ben Hutchings" a ?crit dans le message news: ulmqil8qu.fsf at roundpoint.com... > "Robert Gahan" writes: > > > Hi there, > > > > I have installed python on a Windows PC and I am looking to > > remotely execute a script on a UNIX box from a python program. > > I need to be able to pipe a "y" to stdin also. Is there a windows > > equivalent of the unix "rexec" that could help me ?. What is the > > most appropriate way of doing this ?. > > You might be able to do this with something like: > > script_in, script_out = os.popen2("rsh otherhost -c myscript") > print >>script_in 'y' > result = script_out.readlines() > > Windows 2000 includes an rsh client but I'm not sure about other > versions of Windows. You might want to use ssh instead for greater > security. > > -- > Any opinions expressed are my own and not necessarily those of Roundpoint. From erwin at andreasen.com Sun Mar 25 12:04:36 2001 From: erwin at andreasen.com (Erwin S. Andreasen) Date: Sun, 25 Mar 2001 17:04:36 +0000 (UTC) Subject: close(), exceptions and problems References: <99i3j7$lqr$1@news.cybercity.dk> Message-ID: <99l8f4$1fob$1@news.cybercity.dk> On 24 Mar 2001 16:22:43 GMT, Marcin 'Qrczak' Kowalczyk wrote: >Sat, 24 Mar 2001 12:23:03 +0000 (UTC), Erwin S. Andreasen pisze: > >> But if you call close(fd) you aren't supposed to do something like: >> >> int fd, rv; >> while (((rv = close(fd)) < 0 && errno == EINTR)) >> ; >> if (rv < 0) >> perror("close"); > >Linux documentation says otherwise. That's GNU libc documentation actually. > `EINTR' > The `close' call was interrupted by a signal. *Note > Interrupted Primitives::. Here is an example of how to > handle `EINTR' properly: > > TEMP_FAILURE_RETRY (close (desc)); But this only happens when SA_RESTART is not set (OK, I thought it was SA_NORESTART to *disable* restarting but it's SA_RESTART to enable restarting). Read the "Interrupted Primitives" node for more information. Maybe the threading library on the platform the original poster uses does not set the SA_RESTART flag (if its threads are userspace, switched by receiving SIUGUSR1) ? But that's hard to believe. -- ======================================================================= Herlev, Denmark Software Designer <*> LASAT^WEicon Networks ======================================================================= From nomail at nomail.com Fri Mar 30 16:55:04 2001 From: nomail at nomail.com (Dry Ice) Date: Fri, 30 Mar 2001 13:55:04 -0800 Subject: Know of Substantial Apps Written in Python? References: <3ac4e4a8_1@news4.newsfeeds.com> Message-ID: <3ac4ff12$1_2@news4.newsfeeds.com> > > Know of substantial apps written in Python? [...] > What's the definition of "substantial"? Good question. To sharpen the point of my inquiry: As programs grow in size and complexity, both programmers and the results begin to show fatigue. Slick as Java is, for example, I have found the real-world results of which I'm aware so far to be troubling in the Windows environment. Still evaluating, but it does not look good. What "substantial" is might be defined in terms of project length. Perhaps something which would take a good programmer several months. Something as complex as a web browser might do, if the language in question does not merely act as glue for modules written in C or whatever. In the end, this is like evaluating people. We can listen to what others say about a person, or what a person says about his or her self- or we can simply see how they BEHAVE. > There's Grail, a web browser > http://grail.sourceforge.net > > There's ZOPE, an internet publishing thingy > (thingy is a technical term :) > > Check www.python.org - there are plenty of examples > of programs with thousands and thousands of lines of > code. I'm not sure if you mean "large" when you > say substantial or if you mean well known and widely > used... Yes, those are what I mean. :-) From digitig at cix.co.uk Wed Mar 7 17:24:00 2001 From: digitig at cix.co.uk (Tim Rowe) Date: Wed, 7 Mar 2001 22:24 +0000 (GMT Standard Time) Subject: Can Python replace Visual Basic? Should it? References: <5DZo6.11126$hn5.1578410@news1.rdc1.mb.home.com> Message-ID: In article <5DZo6.11126$hn5.1578410 at news1.rdc1.mb.home.com>, bbollenbach at homenospam.com (Brad Bollenbach) wrote: > Okay, sure this has been asked again and again, but I've never really > seen a > clear answer to this question: > > Can Python replace Visual Basic? Should it? I've seen a yes/no and a yes/yes answer so far to this. I'll add a no/maybe answer. That "no" is a /technical/ yes, but Python is never likely to have Microsoft's marketing muscle behind it (I hope!) and so will never replace Microsoft's language of choice. I work in a corporate environment that mandates VB (& VBA) for everything because it mandates Microsoft for everything and the people who do the mandating aren't interested in the technical issues -- we deliver using VB, so why should they have the maintenance overhead of multiple languages (even multiple MS languages)? Python isn't going to overcome that sort of corporate mindset. But when I'm given a choice, I now use Python for everything. There is stuff I wouldn't use it for (safety critical, for one) but I don't do that stuff. I keep C++, Delphi, Eiffel and Ada in a back pocket; I have Perl, Java, Fortran, Prolog and even Forth on a mental back-shelf, and I would pull any of them out if needed. But at the moment I don't need them. I don't know if that's because of the nature of what I do in my own time (mainly scientific and data manipulation, no serious GUI stuff) or if it's across the board advantages of the language. I suspect the former; I'm reminded of Michael Jackson's comment that if something helps you with every possible problem then it's not going to help you very /much/ on any /particular/ problem. I'm going to try to keep a varied set of programming tools clean and sharp. So that's another reply in vague generalities that's not going to be much use to you :-) From tdelaney at avaya.com Tue Mar 20 22:06:07 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 21 Mar 2001 14:06:07 +1100 Subject: Yet Another PEP: Query Protocol Interface or __query__ Message-ID: So far as I can see, this PEP does not solve one basic problem - interfaces which the class writer doesn't know about. For example, I have an interface, mapped to "org.mydomain.something". Then I have a slightly different interface mapped to "org.mydomain.somethingelse". I have a class which implements org.mydomain.something. However, whilst it can perfectly implement org.mydomain.somethingelse, it would be rejected as it doesn't actually know about it. I think it would be better if an interface was actually a class instance which specified exactly what it required. This could not only be methods (or other attributes), but also the (minimum) parameters required (and possibly their types) and even any pre- or post- conditions required by the interface. It could also mark "optional" features which if available will be used. FOr example, an interface could specify an optional readlines() method, but if it is not available the object would still meet the requirements for the interface if it provided the read() method. This instance then gets passed to the __query__() method. The __query__() method then inspects the requirements, and returns either a class instance or None. The class instance could either be self or a proxy to self or something completely separate. A None of course means that it cannot meet the requirements for the interface. If no __query__() method is defined on the class, the query() function would then inspect the methods and other attributes of the class to determine if it meets the requirements of the interface. Naturally, interfaces with post-conditions would have to fail immediately in this case, and any pre-conditions which could not be readily determined would also have to fail the interface test immediately. A "readily-determined" pre-condition would be something like "attribute x == 3" (not a good example, but a simple one). This seems to me a much more general and useful way of specifying interfaces, whilst covering all the things an interface may need. It allows the __query__() method to return different things on different invocations for the same interface, depending on the state of the class. For example, a file-like object may be unable to meet the "file-like" interface until it has all its data in memory. Until this is the case, it would return None from its __query__() method for an interface which required the read() method. I may well just try implementing this some time ... most of it shouldn't be too hard. Unfortunately, I've got a nasty deadline coming up ... :( Tim Delaney Avaya Australia +61 2 9352 9079 All recipient(s) of this email have permission to forward or reply to this email, quoting this email in full or in part. > Let me see, a string goes in, and an object > comes out. Sure. Looks good to me! From root at [127.0.0.1] Sat Mar 31 16:43:18 2001 From: root at [127.0.0.1] (deadmeat) Date: Sat, 31 Mar 2001 21:43:18 GMT Subject: list vs tuple References: <3AC20CD3.265A2D94@alcyone.com><71q9ct4le63anefmiajj5cbh3mg04qu1ga@4ax.com><7Bfx6.989$p5.3791@news1.rivrw1.nsw.optushome.com.au> Message-ID: > Here's the root of your problem. a = b does NOT, I repeat, does NOT do any > data copying!!!!! That is what happens in Pascal, and that is what it _looks_ like is happening in the first python example (integers only). But then substitute a list for the integer, and they behave like pointers. > Did this help? I'm not looking for assistance. I'm making an observation. From mwh21 at cam.ac.uk Thu Mar 8 17:47:46 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 08 Mar 2001 22:47:46 +0000 Subject: I got 2.1b to dump core. References: Message-ID: Laura Creighton writes: > Here is a traceback. Should I send this some place other than here? http://sourceforge.net/tracker/?group_id=5470&atid=105470 What did you *do*? Cheers, M. -- The "of course, while I have no problem with this at all, it's surely too much for a lesser being" flavor of argument always rings hollow to me. -- Tim Peters, 29 Apr 1998 From mcherm_python at yahoo.com Sun Mar 18 18:17:24 2001 From: mcherm_python at yahoo.com (Michael Chermside) Date: Sun, 18 Mar 2001 17:17:24 -0600 Subject: Why "from __future__" stinks; a counter-offer References: Message-ID: <3AB54204.1030808@yahoo.com> Hear hear!! I agree! "from __future__" is ugly. It is non-intuitive. It suggests that something having to do with modules is going on... which it isn't. And it is very difficult to explain to people who don't REALLY REALLY understand what's going on. I don't really expect to get any vote in the matter, but if we're just looking for opinions to be expressed, then I'll agree with Jason -- Michael Chermside > _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From bos at hack.org Tue Mar 27 04:51:49 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Tue, 27 Mar 2001 11:51:49 +0200 Subject: PIL-resize, aspect ratio Message-ID: <3AC062B5.D5D0D471@hack.org> Image.resize() takes a tuple with x,y when I resize, but how do I keep the aspect ratio? Do I need to calculate it on my own? -- Rikard Bosnjakovic - http://a214.ryd.student.liu.se/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From dsavitsk at e-coli.net Sun Mar 4 01:38:39 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Sun, 4 Mar 2001 00:38:39 -0600 Subject: python cgi syntax highlighter References: Message-ID: i just uploaded it to http://home.uchicago.edu/~dsavitsk/ if this is a problem, that is, if i shouldn't leave it there, please let me know. "Gregory (Grisha) Trubetskoy" wrote in message news:Pine.BSF.4.32.0103032234260.88338-100000 at localhost... > > Hello - > > I remember coming across a script that displayed python code in HTML with > color syntax highlighting - does anyone know where I can find one? My > searches don't turn up anything. > > Thanks, > > Grisha > From tjg at exceptionalminds.com Mon Mar 26 12:38:20 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Mon, 26 Mar 2001 09:38:20 -0800 Subject: So what's wrong with __future__? (Was Re: Why "from __future__" stinks ...) In-Reply-To: <99nn3o$p0v$1@panix6.panix.com>; from aahz@panix.com on Mon, Mar 26, 2001 at 07:26:48AM -0800 References: <99nn3o$p0v$1@panix6.panix.com> Message-ID: <20010326093820.Q11655@trufflehunter.avalongroup.net> On Mon, Mar 26, 2001 at 07:26:48AM -0800, Aahz Maruch wrote: > > Overall, this is an ugly solution, but given the axioms that Tim was > working with, probably the best possible solution in a short period of > time. Change the axioms and you get a different solution.... Then I would vote to change the axioms. I think we are seeing long term ugliness to resolve a short term goal. Lets have some short term ugliness and continue with the goal of keeping Python Pythonic. -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Chief Technology Officer www.exceptionalminds.com HyperLINq Technologies, Inc. <>< (503) 246-3630 >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< >>>>This machine was last rebooted: 68 days 21:53 hours ago<< From phrxy at csv.warwick.ac.uk Tue Mar 20 17:51:03 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Tue, 20 Mar 2001 22:51:03 +0000 Subject: Insertin **keywords into a class In-Reply-To: References: <9960i1$tp0$1@nntp6.u.washington.edu> <99661m$scc$1@panix6.panix.com> <99877b$uss$1@nntp6.u.washington.edu> Message-ID: On Tue, 20 Mar 2001, C. Porter Bassett wrote: > cCan you please tell me why the following code snippet doesn't update the > value of radius? > > > class myClass: > def __init__(self, *arguments, **keywords): > self.radius = 0.0 > for kw in keywords.keys(): > print kw, ":", keywords[kw] > self.kw = keywords[kw] > print "self.radius =", self.radius > > > b = myClass(radius = 1.0) You're setting self.kw to 1.0 when you do self.kw = keywords[kw] You want to set self.radius to 1.0, and you can do that with self.__dict__[kw] = keywords[kw] John From ct at gocept.com Wed Mar 7 18:47:54 2001 From: ct at gocept.com (Christian Theune) Date: Thu, 08 Mar 2001 00:47:54 +0100 Subject: Copying objects References: <986h3g$m3s$04$1@news.t-online.com> Message-ID: <986hba$pi6$03$1@news.t-online.com> ok ... like everytime ... i found the matching hint 2 minutes after posting import copy .... excuse me for the traffic From s.sharp at fh-aargau.ch Fri Mar 23 09:14:57 2001 From: s.sharp at fh-aargau.ch (Sharp) Date: Fri, 23 Mar 2001 15:14:57 +0100 Subject: newbie question Message-ID: <99fll8$996$1@rex.ip-plus.net> what is python used for? is it possible to access a python-script over an apache webserver? thanx for your answer Sharp From cgaebler at gmx.de Sat Mar 10 07:38:26 2001 From: cgaebler at gmx.de (Carsten Gaebler) Date: Sat, 10 Mar 2001 13:38:26 +0100 Subject: How to efficently build a nested dictionary Message-ID: <3AAA2042.E69A53FC@gmx.de> Hi there! I wrote a script for FTP traffic accounting, i.e. for each "top level" FTP directory it counts the bytes transferred per day. The traffic is stored in a dictionary that has the following structure: traffic = {dir: {year: {month: {day: 42}}}} for several dirs, years, months, days, of course. While parsing the FTP log files I am building up the dictionary in this way: if not traffic.has_key(dir): traffic[dir] = {year: {month: {day: bytes}}} elif not traffic[dir].has_key(year): traffic[dir][year] = {month: {day: bytes}} elif not traffic[dir][year].has_key(month): traffic[dir][year][month] = {day: bytes} elif not traffic[dir][year][month].has_key(day): traffic[dir][year][month][day] = bytes else: traffic[dir][year][month][day] += bytes Now, this looks a bit clumsy to me, especially if I consider you-know-which-language-I-mean which would simply allow to write $traffic{$year}{$month}{$day} += $bytes; Any ideas how to do this more elegantly? Regards Carsten. From shredwheat at mediaone.net Fri Mar 30 12:48:20 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Fri, 30 Mar 2001 17:48:20 GMT Subject: Why not an __assign__ method? References: Message-ID: > The question is: Why not have a __assign__ method, that gets called on > assignment? It should be called on the *right side* of the expression (at > the left side it does not make sense - I leave the proof as an exercise for > the reader ). The return value would be then assigned to the left > side of the expression. This is the default behavior: i'm not quite sure how this would work. assigning variables have nothing to do with the type a variable 'currently' refers to. a = None a = huge_array1 + huge_array2 the variable could point to anything before being assigned. the assignment in no way effects what the variable originally refers to, so it doesn't seem like whatever that was should get a say in what happens to the "new owner" From m.wilson at bibliocraft.com Mon Mar 5 00:29:56 2001 From: m.wilson at bibliocraft.com (Mark Wilson) Date: Mon, 5 Mar 2001 05:29:56 -0000 Subject: Overriding UserList methods Message-ID: <004b01c0a535$79cb7300$4a824ac3@mwdell1> Daniel try this: def append(self, object): UserList.UserList.append(object) that will call your superclass method. Mark From gregj at pobox.com Fri Mar 16 01:42:46 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Fri, 16 Mar 2001 06:42:46 GMT Subject: tiny extension crashes References: Message-ID: "John J. Lee" wrote in message news:Pine.SOL.4.30.0103152349300.26347-100000 at mimosa.csv.warwick.ac.uk... > What I still don't get, though, is why it was crashing even when only the > hcf() function was being imported and called by my (pure) Python code. > Surely if it doesn't get called, the uninitialised pointer can't scribble > over anything? I don't see anything else as obvious as that dangling pointer. Can you give any more debugging info? I would simplify the extensions bit by bit until the code didn't crash, and then figure out what I had removed that was causing the crash. I haven't used the Numeric module's C API, but I did glance through the docs. In both your array_max and hcf functions you pull long integers out of the array with the expression *(long *)(array->data + i*array->strides[0]). But the data elements aren't necessarily C long integers; your hcf function will accept an array of short or long ints, and array_max doesn't check the type at all. By casting the array pointer to long* and then fetching the value pointed to, you are always fetching sizeof(long) bytes rather than the size of the actual array elements. This may cause a crash if the OS is watching your memory references, because at the end of the array you will be fetching memory that isn't allocated to the array. You can either test for the type like this: long elem; char *p; ... /* extract array[i] into elem, converting it to a long integer */ p = array->data + i*array->strides[0]; switch (array->descr->type_num ) { case PyArray_SHORT: elem = *(short *)p; case PyArray_INT: elem = *(int *)p; case PyArray_LONG: elem = *(long *)p; default: /* error */ } ... The Numeric module and C API may have better/easier ways to handle this. > In fact I'll probably scrap all of these functions eventually -- they're > only there because they were the simplest functions I had lying around, > and I knew I'd certainly get tangled up in C if I picked something more > complicated for my first extension.) Here's a Python GCD implementation. It would of course be faster in C. The algorithm is a little better than the one you are using. ;-) def gcd(a,b) " return greatest common denominator of a and b" g = b while a > 0: g = a a = b % a y = g return g def gcdlist(a) " return gcd of all numbers in list" g = a[0] for v in a: g = gcd(g,v) return g Argument checking and error handling omitted for brevity. -- Greg Jorgensen PDXperts Portland, Oregon, USA gregj at pobox.com From BrianQ at ActiveState.com Mon Mar 26 22:20:50 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Mon, 26 Mar 2001 19:20:50 -0800 Subject: math.choice attribute error In-Reply-To: Message-ID: <004401c0b66c$ed0d02f0$b503a8c0@activestate.ca> To be more explicit, the choice method does not live in the math module, it lives in the random module. i.e.: >>> import random >>> list = ['apple', 'orange', 'pear'] >>> random.choice( list ) 'apple' Results should vary :-) -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Sean 'Shaleh' Perry Sent: Monday, March 26, 2001 5:44 PM To: iddwb Cc: python-list at python.org Subject: RE: math.choice attribute error On 27-Mar-2001 iddwb wrote: > > from the ref man math.choice says it takes a sequence object and returns a > random choice. perfect for my needs. the follow happens: > >>>> import math >>>> list = ['apple', 'orange', 'pear'] >>>> print math.choice(list) > Traceback .... > attributerror: choice > I know random does: >>> import random >>> l = [1, 2, 3] >>> random.choice(l) 2 -- Brian Quinlan Python and XSLT Developer BrianQ at ActiveState.com Use the power of the dragon for your programming needs. Download Komodo, our Mozilla-based, cross-platform IDE. http://www.ActiveState.com/Komodo From wayne.izatt at _nospam_myself.com Fri Mar 9 01:00:23 2001 From: wayne.izatt at _nospam_myself.com (Wayne Izatt) Date: Fri, 09 Mar 2001 06:00:23 GMT Subject: is it possible to use Tkinter on linux References: <98714n$3p8$1@news2-2.kornet.net> Message-ID: as i recall (this was with 1.5.2 anyway) tkinter could be enabled as part of the build process (by default it wasn't). it was quite well documented in the source code, so start there. the whole thing may have changed with 2.0, but i would start by checking the source. cheers "rambo" wrote in message news:98714n$3p8$1 at news2-2.kornet.net... > Hello, there. > someone knows that it is possible to use Tkinter on linux? > if it is, what program I should need to use Tkinter on linux, > how to install , which environment variable should I set. > > thanks for your time. > > > > > From vecernik at aon.at Thu Mar 29 03:38:38 2001 From: vecernik at aon.at (Oliver Vecernik) Date: Thu, 29 Mar 2001 10:38:38 +0200 Subject: htmllib samples Message-ID: <3AC2F48E.4EF77C71@aon.at> Hi, has anyone got some samples or point me to where to find them on how to implement this module? Oliver From djc at object-craft.com.au Thu Mar 1 07:29:31 2001 From: djc at object-craft.com.au (Dave Cole) Date: 01 Mar 2001 23:29:31 +1100 Subject: writing a C function to manipulate python lists References: Message-ID: >>>>> "Michael" == Michael Vanier writes: Michael> I've been programming in python for many years but have never Michael> had to solve this particular problem. I would like to write Michael> a short C function that will be part of a python-callable Michael> module. The function will receive two python lists as Michael> arguments. Currently I do this in python, but my code uses Michael> this function very heavily and it's the major speed Michael> bottleneck in the code. The hope is that the C function will Michael> be much faster than iterating through the lists in python Michael> (which may not be true, but I'd like to see for myself). Since I have been doing a few of these for people on this newsgroup lately, I suppose I should be fair and extend the same offer to you :-) If you post the code and it is simple enough, I might be able to whip up the C equivalent in an hour or so. - Dave -- http://www.object-craft.com.au From aleaxit at yahoo.com Wed Mar 14 18:30:41 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 15 Mar 2001 00:30:41 +0100 Subject: gah! I hate the new string syntax References: <97sudi01i26@news1.newsguy.com> <98elrk$li8$1@nntp.Stanford.EDU> <98fc070thh@news1.newsguy.com> <98iqo2$56o$1@nntp.Stanford.EDU> <98iv3s01sc2@news2.newsguy.com> Message-ID: <98out40osr@news1.newsguy.com> "Quinn Dunkan" wrote in message news:slrn9avqlm.8ee.quinn at retch.ugcs.caltech.edu... > On Mon, 12 Mar 2001 17:56:33 +0100, Alex Martelli wrote: [snip] > >a typeswitch -- a very unadvisable construct. Something like Haskell's > >typeclasses, on the other hand, would provide the best of both worlds > >(multimethods would be an even more powerful alternative) -- let the > >compiler/interpreter/runtime do the dispatching, and just code in [snip] > Note that in ruby, any time you write > > class Foo > ... > end > > you are adding to, not overriding, 'Foo'. Thus, In Python, you can similarly add whatever Foo attribute you desire at any time (even add a whole mixin class, &c); the tradeoffs are similar (for classes -- Python has the added issue of the type/class split). > Naturally, in a statically-typed functional language like haskell, these > issues don't come up. But in an imperative language, it's like frobbing > __builtins__ ---probably not a very good idea. Right. But typeclasses need not be 'invasive' -- I think they could be implemented dynamically, e.g. in some future Python version. Now that might be a really powerful use for 'typechecking'. At any point I can assert that object X belongs to typeclass Y and get back a Y-reference -- same as X if isinstance(X,Y) in the normal Pythonic sense, or else some suitable wrapper when I've registered with typeclass Y the way to make some existing type X conform to it. Now, I can call whatever methods of Y I desire on that reference. Hmmm, that might not be _too_ hard to implement in Python, syntactic sugar apart, now that I think of it. > In haskell, I could have simply defined a 'Taggable' class and instances > implementing 'tagof' in the Display module... no problem. But "traditional" > OO seems to make the solution much less clear... Interesting train of thought... Alex From thomas.heller at ion-tof.com Thu Mar 1 07:28:09 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 1 Mar 2001 13:28:09 +0100 Subject: [Distutils] Re: CPAN functionality for python - requirements References: Message-ID: <032e01c0a24b$13d30fa0$e000a8c0@thomasnotebook> > [...] But *only* if there are actually some proper docs and good > howto examples for Distutils itself!! What happened to the effort a while > back on that? What remains to be done -- a todo list would be useful to > spread the load, wouldn't it? > I wrote some docs. They are online already in Fred Drake's development version: http://python.sourceforge.net/devel-docs/ Thomas From victor at prodigy.net Fri Mar 23 12:35:36 2001 From: victor at prodigy.net (Victor Muslin) Date: Fri, 23 Mar 2001 17:35:36 GMT Subject: Commercial Products in Python? Message-ID: <3abb86ee.142862695@localhost> A friend of mine is considering developing a shrink-wrapped commercial product. Python seems like a possible choice, but it is not clear whether there are any precedents (though probably similar concerns apply to a Perl-based product). I would very much appreciate an advice in this area and possibly answers to some of the following questions: 1. Are there any existing shirnk-wrap commercial products written in Python? 2. If so, what are they? 3. What is the best way to go about it? Is it better to have customers install Python and give them bytecode files or use one of the programs that creates an executable? 4. There is an easy shrink-wrap install for Python (at least on Windows NT). Are there such on Unix/Linux platforms? (Typically customers don't like having to compile software from source). 5. If the answer to question #1 is "no", why not? 6. Are there any licensing issues to be aware of? Anything else that comes to mind in this direction would be very helpful. TIA From francois.granger at free.fr Sun Mar 25 09:28:47 2001 From: francois.granger at free.fr (=?ISO-8859-1?Q?Fran=E7ois_Granger?=) Date: Sun, 25 Mar 2001 14:28:47 GMT Subject: Good Editor? References: <3ab9a32b$1_1@news2.one.net> <5Xju6.601501$U46.18300887@news1.sttls1.wa.home.com> Message-ID: <1eqsula.zv2tmfz7njr5N%francois.granger@free.fr> Greg Jorgensen wrote: > Most of my Python programs are so small that IDLE works for me. My favorite > editors are: > > Windows: EditPlus (www.editplus.com) > Mac: BBEdit On the Mac, have a look at Pepper http://www.hekkelman.com -- "De quelque mani?re que l'on divise le monde, il y a toujours la m?me proportion d'imb?ciles et de c.." - Propos de O.L.Barenton, Confiseur A. Detoeuf From smnordby at yahoo.com Tue Mar 6 08:22:05 2001 From: smnordby at yahoo.com (Steve) Date: Tue, 06 Mar 2001 05:22:05 -0800 Subject: Can anyone recomend a good intoduction to C... References: <3aa366c6_2@nnrp1.news.uk.psi.net> Message-ID: <3AA4E47D.736CBD84@yahoo.com> I like that K&R is concise, but when just starting out it's nice to have more complete example code. I found this Web tutorial which complements K&R nicely: http://www.howstuffworks.com/c1.htm -SteveN- Wayne Izatt wrote: > > Kerninghan and Ritchie - "The C Programming Language" is a beautiful text. > Everything you want , nothing you don't. Plus, it weighs about as much as a > magazine. Not many languages can teach you all you need to know in that kind > of space. The Python Tutorial, of course, is in the same league! > > cheers > > "Simon Brunning" wrote in message > news:3aa366c6_2 at nnrp1.news.uk.psi.net... > > ... for a Python programmer? > > > > I'm going to have to bite the bullet and learn a bit of C. I'd at > > least like to learn the *right* way to do it. > > > > -- > > Cheers, > > Simon Brunning > > sbrunning at bigfoot.com > > > > > > From cfelling at iae.nl Thu Mar 29 17:46:02 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 30 Mar 2001 00:46:02 +0200 Subject: Is it possible to sort a dictionary? References: <3ABE771B.7B9E1631@student.liu.se> <99o33k$aq4$0@216.39.170.247> <99o51301qgb@news1.newsguy.com> <99q70i$1le$1@animus.fel.iae.nl> <99vap202a1b@news2.newsguy.com> Message-ID: <9a0dva$ekv$1@animus.fel.iae.nl> Alex Martelli wrote: > "Carel Fellinger" wrote in message > news:99q70i$1le$1 at animus.fel.iae.nl... > [snip] >> I just wonder why the items() method is slooow; values() and keys() >> are both much faster, going over the whole dict indexing from keys() >> is even faster. Is tuple making/unpacking so expensive? Or is a dict > I can't reproduce this observation... here's a datapoint: > sortWithItems: 0.0438600314118 ... > sortWithKeys: 0.0460969072614 > i.e., items() seems a bit _faster_ than keys() then hm, so it seems. > going over the dict -- with the script b.py being: > def sortWithKeys(adict): > keys = adict.keys() > keys.sort() > return [ (key, adict[key]) for key in keys ] Ah, but besides going over the dict indexing from keys() you're building an items list here too:) If you make a list of only the values instead of key,value tuples, it will be the faster one. And that's what surprised me. I expected items() to be faster then the combination of dict.keys(); [dict[key] for key in dict.keys] as items is all done in C and the alternative is mostly done in Python. E.g., in items there is no need to check that dict is still the same for each key, but in the Python loop, dict has to be looked-up for each key. Somehow I thought that such things would make up for the building of tuples. -- groetjes, carel From bvdpoel at uniserve.com Thu Mar 29 13:36:30 2001 From: bvdpoel at uniserve.com (Bob van der Poel) Date: Thu, 29 Mar 2001 11:36:30 -0700 Subject: forcing dictionary order Message-ID: <3AC380AE.B225C07F@uniserve.com> I'd like (not a must!) to walk a dictionary in the same order in which it was created. Example: foo={ key1: (), key2: (), key3: () } If I do: for a in foo.keys(): ... the order is not "key1, key2, key3", which is what I want. Note, I can't do something simple like sort() on the keys since the are not in any alphanumeric order. I'm just using this to generate a largish table for another program, and the actual order doesn't matter for it to work properly, but it would nicer if it were in the correct logical order. So, I'm not going to spend a lot of time on this, but if there is a simple way???? -- Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: bvdpoel at uniserve.com WWW: http://users.uniserve.com/~bvdpoel From guijarro at wanadoo.fr Thu Mar 22 12:29:21 2001 From: guijarro at wanadoo.fr (guijarro) Date: Thu, 22 Mar 2001 18:29:21 +0100 Subject: Sockets in Python Message-ID: <99dcpm$am1$1@wanadoo.fr> Hello guys, here is my problem : I'd like to create a simple network card game with Python, but I've got some troubles with the sockets... In fact I'd like to find some kind of tutorial about this subject, because although my first-time code quite works, I don't think it is really good. When I try all the samples I've found on the 'net about sockets, the "main" loop for communicating, generally implemented with a While 1: ..., makes my computer frozen up (under Windows, not under Linux). That's why I thought it would be better to use threads, for the listening function for example, but it doesn't work well under Windows (sometimes it hangs up, I can't figure out why !). I'm sure it's possible creating a robust and nice app which uses the sockets encapsulation provided with Python under Windows, but how ? What are the "good" things to do ? What is the best module to use between socket or asyncore ? Well, if someone can help me with the sockets in general and the sockets with Python, it would be greatly appreciated... (I've already read the "classic" tutorials about sockets, I followed the links on the Python website, etc..) Thanks in advance. From corour01 at motorola.com Tue Mar 20 12:47:56 2001 From: corour01 at motorola.com (O'Rourke Clodagh-corour01) Date: Tue, 20 Mar 2001 17:47:56 -0000 Subject: Tkinter Problem Message-ID: <13EE655665F4D311AB4D0008C789498A01EE2C85@zei02exm02.cork.cig.mot.com> Hi all, I hope someone can help me because this problem is driving me mad..... I am creating a GUI system in Python. Each window is a class and launches ok on it's own. Classes: AuditResync.py* GuiSelection.py* System.py* Cell.py* InitialWin.py* EnvVar.py* There is one Initial selection window (InitialWin.py) which contains several button each of which destroys the current window and launches a new one whcih is an instance of one of the other 4 classes. self.destroy() (self.parent) I am getting a NameError (below) even though the classes does exist and launch perfectly as a stand-alone. I have imported imported thef iles I am trying to access too. The first instance created of a window launches fine and when I replace that with another window everything is still fine. However if I go back to a window that I had already visited then this is where the error arises. Exception in Tkinter callback Traceback (innermost last): File "/usr/vob/omc_reference/ThirdParty/scriptSources/lib/python1.5/lib-tk/Tkinter.py", line 764, in __call__ return apply(self.func, args) File "AuditResync.py", line 54, in newGui GuiSelection(self.parent) NameError: GuiSelection Has anyone else had any similar errors or knows of any possible causes? Thanks a lot, Clodagh O' Rourke From nelson at crynwr.com Tue Mar 6 01:56:24 2001 From: nelson at crynwr.com (Russell Nelson) Date: Tue, 06 Mar 2001 01:56:24 -0500 Subject: Can Python replace Visual Basic? Should it? References: <5DZo6.11126$hn5.1578410@news1.rdc1.mb.home.com> Message-ID: <3AA48A18.FEEDA8B9@crynwr.com> Brad Bollenbach wrote: > Again, I'm much more interested in the real world experience of those who > used to use the big visual development tools in Windows like VB, Delphi or > Powerbuilder rather than theoretical answers. I've built a little program in VB, and a program in glade/pygtk/libglade/Python. I can say for sure that the latter is nearly as good as the former. It needs to cooperate better with an external text editor. But there's no reason why it couldn't do that. The really neat thing I've discovered so far is that when you use libglade, your user interface layout has very little to do with the user interface that drives it. Your code knows to look for certain widgets, and manipulate them as you have specified. The user interface designer knows to name certain widgets certain things. Beyond that, though, there's a nearly complete separation of functionality. You can make the same application run on wildly different size screens with NO code changes. Or, users can customize their screens. -- -russ nelson http://russnelson.com Crynwr sells support for free software | PGPok | Watch out! He's got an 521 Pleasant Valley Rd. | +1 315 268 1925 voice | opinion, and he's not Potsdam, NY 13676-3213 | +1 315 268 9201 FAX | afraid to share it! From aahz at panix.com Wed Mar 14 00:14:29 2001 From: aahz at panix.com (Aahz Maruch) Date: 13 Mar 2001 21:14:29 -0800 Subject: [Python-Dev] Re: Bug fix releases References: <3aa2e9c3.210139114@news.laplaza.org> Message-ID: <98munl$fup$1@panix3.panix.com> [I'm writing up a PEP for this, but wanted to respond to one bit before this post scrolls off my spool.] In article <3aa2e9c3.210139114 at news.laplaza.org>, Mats Wichmann wrote: > >I can't see that this will actually happen until there's a champion who >will handle the "boring stuff" - that is, babysit the older released >line (we don't all think that's boring work, but what the heck). If >I can point at the Linux kernel development (don't anybody gack now), >Linus handles the "interesting stuff" - the latest branch; when it >reaches a certain degree of stability he hands over to Alan Cox. Did >Aahz just volunteer to be our Alan Cox? Maybe. ;-) Depends on what Alan Cox actually does; if he decides which patches go in, I can't be Alan, not by myself. I just don't have enough knowledge of the Python kernel and I'm not all that good of a C programmer (that's why I use Python!). Can someone write a bit more about the actual Linux maintenance process? -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Python: Programming the way Guido indented it From f8dy at diveintopython.org Sat Mar 3 14:04:46 2001 From: f8dy at diveintopython.org (Mark Pilgrim) Date: Sat, 03 Mar 2001 14:04:46 -0500 Subject: Missing the functional mind set In-Reply-To: References: Message-ID: in article mlb2at8ptrr7sh5dgq8qlk2201kquh6tfl at 4ax.com, Daniel Klein at danielk at aracnet.com wrote on 3/3/01 1:08 PM: > The purpose of this code is to return a list of dictionary values sorted by > key, resulting in 'templist'. > >>>> d = {3: 'd', 2: 'b', 1: 'a', 0: 'z'} >>>> templist = [] >>>> for n in range(len(d)): > templist.append(d[n]) > >>>> templist > ['z', 'a', 'b', 'd'] > > My question is, is there a 'functional' (or list comprehension) solution to > this? Since you explicitly asked for hints, not answers, here are some hints: - AFAIK, the fastest way for me to sort things in Python is with the sort() method of a list, because it's written in C and has been optimized by people smarter than me. - sort() modifies an existing list in place; it does not return a new list. - sort() will sort a list of any type of object, not just simple datatypes. For instance, if you have a list of tuples, sort() will perform a multi-key sort, treating the first element of each tuple as the primary key, the second element as the secondary key (to break ties where the first elements are the same), and so forth. - Dictionaries have an items() method that returns a list of tuples [(key1, value1), (key2, value2), ...] - Once you have a list of sorted key/value pairs, you can use a list comprehension to pull out just the value from each pair. You can do it in 3 lines using a list comprehension. Or 5 lines using a for loop. Or 1 heinous-looking UNIX command line. Your choice. -M You're smart; why haven't you learned Python yet? http://diveintopython.org/ From aleaxit at yahoo.com Wed Mar 21 10:32:10 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 21 Mar 2001 16:32:10 +0100 Subject: Html entities References: <3AB8BA56.9E41A333@downright.com> Message-ID: <99ahho01sj1@news2.newsguy.com> "Doug Fort" wrote in message news:3AB8BA56.9E41A333 at downright.com... > Syver Enstad wrote: > > > Is there an easy way to convert ISO Latin-1 characters that are above 127 > > ascii to their HTML, XML entity form? > > See 'htmlentitydefs' in the Python library This maps entitydef->ISO-Latin-1-character -- you'll need to 'reverse the dictionary' for Syver's purposes. Alex From corour01 at motorola.com Wed Mar 21 08:48:14 2001 From: corour01 at motorola.com (O'Rourke Clodagh-corour01) Date: Wed, 21 Mar 2001 13:48:14 -0000 Subject: Access Issues Message-ID: <13EE655665F4D311AB4D0008C789498A01EE2C93@zei02exm02.cork.cig.mot.com> Hi all, I wonder if anyone can help. I am trying call the constructor of the EnvVar class from the newEnvWin function of the Cell class. But I am getting the following error Exception in Tkinter callback Traceback (innermost last): File "/usr/vob/omc_reference/ThirdParty/scriptSources/lib/python1.5/lib-tk/Tkinter.py", line 764, in __call__ return apply(self.func, args) File "Cell.py", line 63, in newCellMgt self.newEnvWin('cellmgt') File "Cell.py", line 60, in newEnvWin instance = EnvVar.__init__(g, self.parent) AttributeError: __init__ I have include some extracts of the code. Thank you, Clodagh. ********************************************** import EnvVar, GuiSelection, AuditResync, System from shellgui import EnvVarSite import Pmw from Tkinter import * class Cell(EnvVarSite): def __init__(self, parent=None, **kw): ...... def newCellMgt(self): self.newEnvWin('cellmgt') def newEnvWin(self, g): newParent = Toplevel() instance = EnvVar.__init__(g, self.parent) ******************************************** import informixdb, os, sys, string, Pmw from Tkinter import * from shellgui import EnvVarSite import GuiSelection, AuditResync, Cell, System class EnvVar(EnvVarSite): def __init__(self, g, parent=None): self.sels = None self.parent = parent self.group = g self.edit = 1 self.GetDBValues() EnvVarSite.__init__(self,parent) ************************************************ From mwh21 at cam.ac.uk Wed Mar 14 15:32:02 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 14 Mar 2001 20:32:02 +0000 Subject: Extending Python: rewriting a single method in C References: <98l1i901k4u@news1.newsguy.com> Message-ID: "Fredrik Lundh" writes: > Jacek Generowicz wrote: > > No, I'm quite sure that I didn't . . . for some reason I was buried > > in http://www.python.org/doc/current/ext > > > > (Oops! Blush) > > > > > http://www.python.org/doc/current/api/ > > > > This is much more like it. > > maybe it's time to merge these two documents into one? > > (or at least make them refer/link to each other) They could both do with being rewritten from scratch (especially ext; api just needs completing). If I had a spare month... Cheers, M. -- Programming languages should be designed not by piling feature on top of feature, but by removing the weaknesses and restrictions that make the additional features appear necessary. -- Revised(5) Report on the Algorithmic Language Scheme From paulp at ActiveState.com Sun Mar 11 10:36:29 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sun, 11 Mar 2001 07:36:29 -0800 Subject: "!=" is bad form. Re: sorry....never mind References: <11032001.1@wanderer.local.jae.ddns.org> Message-ID: <3AAB9B7D.E7D892B6@ActiveState.com> "J?rgen A. Erhard" wrote: > > ... > So when can we expect `||' and `&&' to replace `or' and `and'? > Shouldn't we `Beware of the slippery slope'? Slippery slope arguments are not helpful in language design or for that matter most kinds of design. Each decision is distinct. Guido must weigh a host of costs and benefits every time. If a "benefit" is compatibility with C and the costs are low or non-existent then he will choose to be compatible with C. -- Python: Programming the way Guido indented it. From whisper at oz.net Mon Mar 26 15:40:36 2001 From: whisper at oz.net (Dave LeBlanc) Date: 26 Mar 2001 20:40:36 GMT Subject: PEP 245: Python interfaces References: Message-ID: <99o9g4$nh3$0@216.39.170.247> Having read the PEP briefly, I have one question: Is there a good reason to add the "implements" keyword? Current syntax is (from Language Reference 7.6): classdef: "class" classname [inheritance] ":" suite inheritance: "(" [expression_list] ")" classname: identifier (i'm adding this based on the text of 7.6:) expression_list: Expression(s) which evaluate to a class object. Any reason why expression_list couldn't include an interface? Seems to me it's easier to just extend the semantics of expression_list to include interface_name(s) instead of adding a variation like '"class" classname [inheritance] ["implements" interfaces] ":" suite'. (Besides, two optional elements in a row makes for messy parsing :-).) The end of a class definition might be slightly more complex to check that all "pure" methods have implementations, but (almost certianly) not hopelessly so... and you get to detect the "not implemented" error early with a "missing definition" error rather then later with a "can't instantiate" error. Surely a python interpreter could be smart enough to realize that some name in the list of inherited objects is actually an interface? (OTOH, it doesn't seem smart enough to infer that the first argument of a method within a class is "self" ). Of course, one could do '"class" classname [" inherits" inheritance] ["implements" interfaces] ":" suite' if verbosity is the goal. (This would also be easier to parse :-).) Just my $.02 worth. Dave LeBlanc On Thu, 22 Mar 2001 23:02:35 -0800, Michel Pelletier wrote: > >Hi! > >I'm the author of PEP 245, a framework and syntax for interface objects in >Python. > >http://python.sourceforge.net/peps/pep-0245.html > >It has just recently been made a PEP, and I'd like to solicite some more >input from the community (you). > >For those of you who don't know the formal defintion of "interface", don't >worry (there isn't one!). There are, however, a lot of agreed and >disagreed upon definitions out there in the world, and PEP 245 is one >particular take on the situation, based on pioneering work done by the >Type-sig and Jim Fulton over the last couple of years. > >There is a Wiki (referenced in the PEP) for formal discussion and, of >course, this newsgroup, which I will hanging out in for the next few days >answering any questions about the proposal. > >Thanks! > >-Michel > From mlh at idi.ntnu.no Fri Mar 16 05:58:43 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Fri, 16 Mar 2001 11:58:43 +0100 Subject: I come to praise .join, not to bury it... References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> <3AAF7E47.294617E1@sage.att.com> <98qeco02hn7@news1.newsguy.com> Message-ID: <98srjf$fov$1@tyfon.itea.ntnu.no> "Alex Martelli" wrote in message news:98qeco02hn7 at news1.newsguy.com... [...] > And then again, the _appearance_ that too much emphasis > was being placed on syntax-sugary issues kept me *AWAY* > from Python for longer than it should have -- sure, sure, > I could save some punctuation, but, *WHAT DID I CARE*?! > > Good thing (for me) that I eventually looked beyond the > pretty face, of course:-). Why? If you don't care about the pretty face, what are the advantages of Python as opposed to, say, Perl? To me it would seem that syntax (sugar or not) is the main issue... Not that I've used Perl a lot, but it seems very much like Python with a lot of ugly bits thrown in... -- Magnus Lie Hetland http://www.hetland.org "Reality is what refuses to disappear when you stop believing in it" -- Philip K. Dick From mwh21 at cam.ac.uk Thu Mar 15 13:29:23 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: Thu, 15 Mar 2001 18:29:23 +0000 (GMT) Subject: python-dev summary, 2001-03-01 - 2001-03-15 Message-ID: This is a summary of traffic on the python-dev mailing list between Mar 1 and Mar 14 (inclusive) 2001. It is intended to inform the wider Python community of ongoing developments. To comment, just post to python-list at python.org or comp.lang.python in the usual way. Give your posting a meaningful subject line, and if it's about a PEP, include the PEP number (e.g. Subject: PEP 201 - Lockstep iteration) All python-dev members are interested in seeing ideas discussed by the community, so don't hesitate to take a stance on a PEP if you have an opinion. This is the third python-dev summary written by Michael Hudson. Previous summaries were written by Andrew Kuchling and can be found at: New summaries will appear at: and will continue to be archived at Andrew's site. Posting distribution (with apologies to mbm) Number of articles in summary: 264 50 | ]|[ | ]|[ | ]|[ | ]|[ 40 | ]|[ ]|[ | ]|[ ]|[ | ]|[ ]|[ | ]|[ ]|[ ]|[ 30 | ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ 20 | ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ 10 | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ 0 +-050-022-012-004-009-006-003-002-003-005-017-059-041-031 Thu 01| Sat 03| Mon 05| Wed 07| Fri 09| Sun 11| Tue 13| Fri 02 Sun 04 Tue 06 Thu 08 Sat 10 Mon 12 Wed 14 A quiet fortnight on python-dev; the conference a week ago is responsible for some of that, but also discussion has been springing up on other mailing lists (including the types-sig, doc-sig, python-iter and stackless lists, and those are just the ones your author is subscribed to). * Bug Fix Releases * Aahz posted a proposal for a 2.0.1 release, fixing the bugs that have been found in 2.0 but not adding the new features. Guido's response was, essentially, "Good idea, but I don't have the time to put into it", and that the wider community would have to put in some of the donkey work if this is going to happen. Signs so far are encouraging. * Numerics * Moshe Zadka posted three new PEP-drafts: which on discussion became four new PEPs, which are not yet online (hint, hint). The four titles are Unifying Long Integers and Integers Non-integer Division Adding a Rational Type to Python Adding a Rational Literal to Python and they will appear fairly soon at respectively. Although pedantically falling slightly out of the remit of this summary, I should mention Guido's partial BDFL pronouncement: A new mailing list had been setup to discuss these issues: * Revive the types-sig? * Paul Prescod has single-handedly kicked the types-sig into life again. The discussion this time seems to be centered on interfaces and how to use them effectively. You never know, we might get somewhere this time! * stackless * Jeremy Hylton posted some comments on Gordon McMillan's new draft of the stackless PEP (PEP 219) and the stackless dev day discussion at Spam 9. The discussion has mostly focussed on technical issues; there has been no comment on if or when the core Python will become stackless. * miscellanea * There was some discussion on nested scopes, but mainly on implementation issues. Thomas Wouters promised to sort out the "continue in finally: clause" wart. Cheers, M. From jasonic at nomadicsltd.com Sat Mar 31 01:11:13 2001 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Sat, 31 Mar 2001 01:11:13 -0500 Subject: Know of Substantial Apps Written in Python? References: <3ac4e4a8_1@news4.newsfeeds.com> <3AC5529D.8D7BCC63@seebelow.org> Message-ID: > Hey, I looked at that, and it looks cool. But I was somewhat puzzled by > the following statement: > > Sketch is an interactive vector drawing program for Linux > and other UNIX compatible systems. > > A somewhat unique(for a drawing program) feature of Sketch is > that it is implemented almost completely in a very high-level, > interpreted language, Python. > > If it's implemented almost completely in Python, why does it only run on > "UNIX-compatible" systems? (BTW, does it delete hyphens? ) Is > there something about its "almost" part that can't be done in Windows. The logic Python arhitecture in 'Sketch' is likely very portable, but I _imagine_ the UI toolkit chosen may be the {for the time being} the reason it is restricted to *nixen A major issue for cross platform 'substantial' apps is the GUI part of the code. And typically a lot of work goes into cool widgets. Python is more prtable than GUIs wxPython is a very cool interface to wxWindows.. For a substantial python app take a look at it first, and then BOAConstructor http://boa-constructor.sourceforge.net/ [I think the Mac versions of wxWindows/wxPython still lag behind..not Python's fault. Hopefully MacOSX will improve much of this scenario. Within, say, a year the Mac could have many more interesting tools migrated from Linux/Unix developers] The major alternatives to wxWindows appear to be Tkinter and Qt. Check on the Vaults of Parnassus for latest on these. http://www.vex.net/parnassus/ .. check under User Interfaces section. for example http://www.vex.net/parnassus/apyllo.py?i=247038364 For substantial Python apps thre is also the section titled Applications under the 'tree' menu .. http://www.vex.net/parnassus/apyllo.py?i=77689886 In general checking the 'Latest' page will provide a wnoderful insight into the substantial work onoing by dedicated python creative teams Another little discussed substantial is 'OpenEV', writen by some very smart dedicated GIS people in Python: http://openev.sourceforge.net/ enjoy :-) - Jason ___________________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology'] From aahz at panix.com Tue Mar 20 11:06:01 2001 From: aahz at panix.com (Aahz Maruch) Date: 20 Mar 2001 08:06:01 -0800 Subject: Functionalism, aesthetics Was:(RE: I come to praise .join, not References: Message-ID: <997v59$sbf$1@panix3.panix.com> In article , Clark C. Evans wrote: > >Well, this is a problem with open source in general. Most >coders have the attitude: "If you can't code, get out of >the kitchen". Sad, but true. There's some of this in the Python community, but more often around here it's simply a demand to be clear about what's wanted. As Tim is fond of pointing out, every time he asks people how to do floating point "the right way", he gets *at* *least* as many answers as people responding. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 There's a difference between a person who gets shit zie doesn't deserve and a person who gets more shit than zie deserves. --Aahz From scarblac at pino.selwerd.nl Wed Mar 7 05:22:52 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 7 Mar 2001 10:22:52 GMT Subject: class object access in class definition? References: Message-ID: Lars Damerow wrote in comp.lang.python: > Is it possible to reference a class from within its own definition? Something > along the lines of: > > class Foo: > print Foo > > This works for functions--that is, > > >>> def foo(): > ... print foo > ... > >>> foo() > > > works as expected, but the class definition above raises a NameError: > > >>> class Foo: > ... print Foo > ... > Traceback (most recent call last): > File "", line 1, in ? > File "", line 2, in Foo > NameError: There is no variable named 'Foo' The difference is that the function is executed *after* you defined it, so that by then the name exists. In the case of the class, it is executed during its definition, and at that time the name doesn't exist yet. I have no idea what you're trying to do, but maybe a workaround is to create an empty class of another name first, and inherit from that. You can then use references to that class, and be able to influence the current class. But well, no idea what you're trying to do :) -- Remco Gerlich From cribeiro at mail.inet.com.br Mon Mar 26 21:37:29 2001 From: cribeiro at mail.inet.com.br (Carlos Alberto Reis Ribeiro) Date: Mon, 26 Mar 2001 23:37:29 -0300 Subject: Is it possible to sort a dictionary? In-Reply-To: <99op90$2tr$1@animus.fel.iae.nl> References: <3ABE771B.7B9E1631@student.liu.se> <99o33k$aq4$0@216.39.170.247> <99o51301qgb@news1.newsguy.com> Message-ID: <5.0.2.1.0.20010326232409.021e4930@mail.inet.com.br> At 03:09 27/03/01 +0200, you wrote: >Alex Martelli wrote: > > > Fine! Even faster & simpler: > >Simpler yes, but faster? Are you sure? Lately I tested something >similar and was surprised when I found the dict.items function to be >soo slow that going through the whole dict indexing each entry >one by one was faster. I was thinking about something similar today. It would be useful to have a "xitems()" method, behaving exactly like items(), but *without* the need to build the tuple in advance. I see two advantages: - it would use less memory (no need to store the items sequence elsewhere). Python don't copy all the data, only the references, but even this can be big for a large dictionary. - it would run faster for most cases, and possibly *much* faster if the loop have a "break" for some condition. The startup time would also be greatly reduced for a large dictionary. As part of my recent work with adapters (as discussed on the list), I was thinking about implementing a 'proxy' object to take the dictionary and make it behave like a sequence of items. For the xitems() version to work, I need to find a way to walk sequentially through the hash table directly, and I haven't figured out to make it - I was far away from the computer when the idea ocurred to me. If someone know I would be glad to learn Carlos Ribeiro From gregj at pobox.com Mon Mar 12 03:31:22 2001 From: gregj at pobox.com (Gregory Jorgensen) Date: Mon, 12 Mar 2001 08:31:22 GMT Subject: Einstein's Riddle References: <984380185.768920@news.aei.ca> Message-ID: Assuming the unknown pet is the fish, solving the puzzle doesn't take any great skill with logic or math; certainly more than 2% of the population can figure it out. I think the riddle demonstrates the fallacy of unwarranted assumptions. It's a trick question; you work out the solution only to be told "I never said anyone had fish." The more literal-minded the reader, the more likely they will be taken in. In article <984380185.768920 at news.aei.ca>, sulfugor says... >But the fish is mentionned in the question before the clues are given. We >are able to find who owns each of the 4 pets mentionned in the hint list. is >it so unreasonable to assume then that the last pet is a fish, since we were >asked about it ? The question IMplied that one of the 5 people owned a fish. > >sulfugor > >ps = by the way, how long is this supposed to take ( solving the riddle) ? Greg Jorgensen Deschooling Society Portland, Oregon, USA gregj at pobox.com From ullrich at math.okstate.edu Sat Mar 3 11:32:27 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sat, 03 Mar 2001 16:32:27 GMT Subject: Hitting two targets: OO + group theory (pedagogy) References: <3aa1077a.1110803@nntp.sprynet.com> <0932atgt9v8d8aboq90evoi5ipj5c0sk8s@4ax.com> Message-ID: <3aa11a91.5998558@nntp.sprynet.com> On Sat, 03 Mar 2001 07:54:43 -0800, Kirby Urner wrote: >ullrich at math.okstate.edu (David C. Ullrich) wrote: > [...] >>Seems more interesting to me to start with a class >>Group that includes stuff common to all groups, so >>that a subclass can represent any group at all. If we're >>going to implement what's above as part of a >>"curriculum" then at least we should make it clear >>that our sandbox is not "groups", it's a tiny part of >>the category of all groups. > >Yes, just an example of a group. In another essay, I >go with permutations, showing how these might be associated >with "clubhouse codes" (exchanging letters for other >letters as in a Julius Caesar code). I'd also like >to build on my OO + Polyhedra approach to get into >symmetry groups -- getting topics to connect around to >other topics as much as feasible is what I mean by a >"curriculum" (stuff connecting around in all >circumferential directions, to form a system -- the >notion of circling-back is built right into the >etymology). > >I try to be fairly general in my approach to the >group of relatively prime integers under multiplication >vis-a-vis modulus n in my little essay for 8th graders: > > When we study group theory, we have a mnemonic > that's helpful if you've studied the book of > Genesis at least enough to know the story of > Cain and Abel (use a search engine maybe). Use > the letters CAIN to stand for "Closure, Associative, > Inverse, Neutral" -- and there you have the > properties you need to call your set & operation > a "group". > > These properties are defined with respect to a set > of elements, and an operation for relating them > (we generally call the operation "multiplication", > no matter what it actually does). If multiplication > is not just associative, but commutative as well, > then that's where Abel comes in -- we call it an > Abelian Group. > >Probably there's some syntax that could be tightened >up here too. Some people would say that the reference to Genesis is out of place here... probably you know that some people would say that. Might be regarded as just generally inappropriate - some other people might think that the bit about Abel is misleading, since "Abelian" _does_ refer to a man named Abel, but not the one in Genesis. But what the heck, now that W's in charge we're not worrying about technicalities like separation of church and state anymore. But why not start with a class Group instead of special cases? (Would be a class with a __mul__ method that does nothing but raise an exception "must implement __mul__ in a subclass", an Id attribute, etc. I can't think of anything offhand that Group would actually _do_, but if we're bent on this OO-math thing it seems like groups _should_ be descendants of a class Group...) >Thanks for your useful feedback. Much appreciated. > >Kirby > From dev1.gemodek at t-online.de Wed Mar 14 04:37:19 2001 From: dev1.gemodek at t-online.de (Stephane) Date: Wed, 14 Mar 2001 10:37:19 +0100 Subject: zipfile: how to find out if a zipinfo object is a directory or file Message-ID: <3AAF3BCF.580F3ECC@t-online.de> Hi, does somebody know how to find out in a zipinfo object represents a file or directory. I have zipfiles created on Linux and in Win32 filesystem. Or is this a planed feature for Py 2.1? Thanks Stephane From tim.hochberg at ieee.org Thu Mar 15 10:57:02 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Thu, 15 Mar 2001 15:57:02 GMT Subject: reversing a dictionary (newbie) References: Message-ID: "Christopher Brewster" wrote in message : > The processing of the files is quite quick (700 odd files (@ 100k mean size) > of directory 'A' in about 20 minutes) > but the reversing of the dictionary took hours and hours. I have run the > program successfully on a PC (500 MHz, 256 RAM, running Windows NT) and I am > still waiting for results from a Sun (1 Giga RAM) since yesterday. Here is > the code - what have I done wrong? [Reversal function that Outlook mangled anyway] It's not obvious (to me anyway) why this so slow. There is some extraneous list munging going on, but I'd be suprised if that slowed things down that much. In any event here's are two version that might be somewhat faster (untested): def revdict1(diction): "The long form" revdict = {} for wordpair in diction.keys(): freq = diction[wordpair] if revdict.has_key(freq): revdict[freq].append(wordpair) else: revdict[freq] = [wordpair] return revdict def revdict2(dict): "The short form (assumes python 2.0)" rev = {} for wp, freq in dict.items(): rev.setdefault(freq, []).append(wp) return rev Perhaps that'll help. Who knows? -tim From grante at visi.com Wed Mar 7 12:24:36 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 07 Mar 2001 17:24:36 GMT Subject: Can anyone recomend a good intoduction to C... References: <983896344.701456@newsmaster-04.atnet.at> <983911749.217622@newsmaster-04.atnet.at> <983916572.286918@newsmaster-04.atnet.at> <9852b8015jm@news1.newsguy.com> <983967284.246700@newsmaster-04.atnet.at> Message-ID: In article <983967284.246700 at newsmaster-04.atnet.at>, Werner Schiendl wrote: >> > That is of course a point, if you need to let the program >> > inspect you will try to keep it as simple as possible. But >> > given the same functionality, I think a C++ program will not be >> > more complex. >> >> The program will not be, the language is. It's a hard-to-judge >> tradeoff. > >As to my knowledge, the application itself is inspected for >safety critical appliances. And you must not change anything >afterwards in the software or you need to re-inspect the >software. > >What use would it be to check the language? The point is that the more complex the language, the more difficult it is to inspect the application. You can look at a few lines of C and have a pretty good chance at guessing what they do. In C++ it's much harder to look at snippet of code and figure out what it's going to do. -- Grant Edwards grante Yow! Somewhere in DOWNTOWN at BURBANK a prostitute is visi.com OVERCOOKING a LAMB CHOP!! From quickdry at users.sourceforge.net Fri Mar 23 09:43:39 2001 From: quickdry at users.sourceforge.net (Steven Adams) Date: Fri, 23 Mar 2001 14:43:39 GMT Subject: tempfile problem on win98 References: <99d0dg$os92$1@ID-11957.news.dfncis.de> Message-ID: "Emile van Sebille" wrote in message news:99d0dg$os92$1 at ID-11957.news.dfncis.de... > The mktemp routine guarantees to return a name unique in the target > directory. Are you sure you're using fully qualified path names throughout > when subsequently discovering duplicate files? > > Emile van Sebille > emile at fenx.com ugh, I feel dumb, thats exactly the problem Emile, the file was getting an extension added and so it wasn't actually unique, is there a way to have a suffix included in the calculation of the filename instead of the prefix? thanks for opening my eyes to the glaringly obvious :-) Steven From bernhard at abnoba.intevation.de Wed Mar 28 10:04:24 2001 From: bernhard at abnoba.intevation.de (Bernhard Reiter) Date: 28 Mar 2001 15:04:24 GMT Subject: Linux GPS program References: <3AC01637.4EF3A6F2@crynwr.com> <3AC0D915.83C2C0C3@crynwr.com> Message-ID: <99suho$m7a$2@newsserver.rrzn.uni-hannover.de> In article , jra at dorothy.msas.net (Jay R. Ashworth) writes: > This one time, in band camp, > Russell Nelson wrote: >> "Jay R. Ashworth" wrote: >> > Any plans to do vector map data as well? >> >> I'm pretty ignorant here. What sources of vector information are there, >> how big is the dataset, and how do I render it so I can use lat/lon or >> easting/northing to get my location? > > There are *stunning* amounts of vector data, all in different formats. I agree, though most proprietory. > I'm trying to (get time cleared up to) sort some of that all out even > as I type. The shapefile format is used for a couple of things. Check www.freegis.org for several libraries dealing with it (and other gps packages, btw). There is a python wrapper for the shapereading library. Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From tim.one at home.com Sun Mar 25 04:10:47 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 25 Mar 2001 04:10:47 -0500 Subject: So what's wrong with __future__? (Was Re: Why "from __future__" stinks ...) In-Reply-To: Message-ID: [Huaiyu Zhu] > I don't quite see what the complaint about __future__ is really about. > So let me try to analyze a little bit. Maybe this could encourage > someone to write a PEP to clarify. > > What's wrong with import __future__? > ... Oh, I don't think it's hard to grasp the primary complaint: it's a hack! Nobody in their right mind would *expect* an import statement to have profound effects on the syntax and/or semantics of the module containing the import, and it's un-Pythonically surprising to abuse import statements this way. OTOH, it was the best hack we could dream up under the constraints that (a) we had to dream up *something*; (b) it had to be 100% backward compatible, no exceptions no way no how; and, (c) since it was late in the release cycle, any form of new syntax was a non-starter (there was no conceivable way to make time to adjust all the tools we ship, let alone pull that trick with such scant warning on other people supplying Python tools). It will probably go away by the time 2.2 ships. In the meantime, it should do the job it was designed to do, for the three highly vocal people who are afraid of nested_scopes damage they won't actually suffer <0.9 wink>. you've-seen-__future__-on-c.l.py-more-than-you'll-ever-see-it-in- real-life-ly y'rs - tim From fluxent at yahoo.com Fri Mar 30 11:12:47 2001 From: fluxent at yahoo.com (fluxent at yahoo.com) Date: Fri, 30 Mar 2001 16:12:47 -0000 Subject: best practice? null/None vs 'None' vs '' (in web/sql) Message-ID: <9a2b9v+lrgp@eGroups.com> (Python 2.x, Win2K, IIS5) I've got some simple pages for viewing and editing SQL records via Python in ASP. I would really like to distinguish between fields with null values and fields that might actually include the text string 'None'. Right now both cases come out from a SELECT as showing up as 'None', and then when I submit and edit they definitely get changed to 'None', so I end up with no nulls. I can see that the ODBC result set distinguishes them. But of course when things get rendered out to HTML you don't want to see single quotes around every string value, so 'None' and None become the same thing. So, I guess this isn't a platform bug, it's a nasty area calling for some sort of interface standard. Is there a best practice I should adopt? Maybe (a) transform the outputs of each SELECT to a different representation of None (either '' or 'null'?), then (b) transform all UPDATE query strings before executing them to change any ='' (or ='null') to =NULL? From robin at alldunn.com Tue Mar 13 00:44:19 2001 From: robin at alldunn.com (Robin Dunn) Date: Mon, 12 Mar 2001 21:44:19 -0800 Subject: Easiest way to get Berkley DB 3.x running on Windows References: Message-ID: <_sir6.57$XlD.26870131@news.randori.com> "Thomas Weholt" wrote in message news:SQ3r6.1961$NY6.31072 at news3.oke.nextra.no... > Hi, > > Do I have to compile Berkley DB to get an updated bsddb-module for Python on > win32? > I want to try the latest version available with python-bindings, cuz there > seems to be a memory leak > and a problem with deadloc(k)s in the one in the current Python lib. > > Thanks for any pointers. > http://pybsddb.sourceforge.net/ Binaries for Windows are available. -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From nas at arctrix.com Thu Mar 22 10:54:41 2001 From: nas at arctrix.com (Neil Schemenauer) Date: Thu, 22 Mar 2001 07:54:41 -0800 Subject: Jython is cool? In-Reply-To: <20010322103954.A18539@sync.nyct.net>; from mbac@nyct.net on Thu, Mar 22, 2001 at 10:39:54AM -0500 References: <20010322103954.A18539@sync.nyct.net> Message-ID: <20010322075441.A26566@glacier.fnational.com> On Thu, Mar 22, 2001 at 10:39:54AM -0500, Michael Bacarella wrote: > Has someone already done this/is it already possible and I just > didn't look at the package well enough or am I out of luck until I > bite the bullet some day and implement it myself? AFAIK, its possible to make Jython applets. The problem is that the whole Jython runtime has to be downloaded to the client. I'm hoping that the Mozilla guys catch the Python bug based on what Active State has been doing with Komoto and adds " Is this known to work by a different path? Known not to work at all? Pl. advise. Tx. From db3l at fitlinxx.com Fri Mar 9 20:00:17 2001 From: db3l at fitlinxx.com (David Bolen) Date: 09 Mar 2001 20:00:17 -0500 Subject: from Tkinter import * References: <989dot$t6t$1@panix3.panix.com> Message-ID: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) writes: > 08 Mar 2001 22:39:42 -0500, David Bolen pisze: > > > the one place I still see a use for "import *" even in production > > code is large wrapped C libraries that already name everything > > according to a flat namespace (for example, staying in the GUI > > vein, wxPython). > > I would prefer to remove these prefixes while porting to a language > with a module system. Generally the issue arises when the library isn't being "ported" but just wrapped, and in most cases largely in an automatic fashion. I certainly wouldn't object to modularizing, but it's bound to make it harder to keep the wrappings up to date - unless tools such as SWIG are augmented to take care of the prefix processing for you. In the meantime, I'd still happy to have flat wrapping than nothing. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From brangdon at cix.co.uk Thu Mar 1 15:03:00 2001 From: brangdon at cix.co.uk (Dave Harris) Date: Thu, 1 Mar 2001 20:03 +0000 (GMT Standard Time) Subject: Stream interfaces References: <3A9E54F9.7AF90BCA@ix.netcom.com> Message-ID: tgagne at ix.netcom.com (Thomas Gagne) wrote (abridged): > Your correct. People are confusing inheritence and usefulness. I > don't have enough spare cycles to worry about a class' > inheritence unless I've discovered missing functionality. Since > I haven't, I haven't. Well, I have. In the streams hierarchy, too. Albeit not that vendor and in a beta product so I probably shouldn't say too much about it, but the hierarchy was very similar. The problem was analogous to methods added to WriteStream not magically appearing in ExternalWriteStream. The vendor's fix was to cut&paste methods from one class to the other. But this is just sticking plaster. The class hierarchy is deeply wrong, violates "once and only once" all over the place and needs refactoring. It's not about missing functionality so much as how we can add new kinds of stream without more error-prone cut&paste. Whether this can be fixed without breaking existing clients, or fixed at all without multiple inheritance, I don't know because I've not tried it. I hope it can be and the problem is not with Smalltalk generally but just this particular bit of library design. But for whatever reason, this bit of library design is not ideal. Dave Harris, Nottingham, UK | "Weave a circle round him thrice, brangdon at cix.co.uk | And close your eyes with holy dread, | For he on honey dew hath fed http://www.bhresearch.co.uk/ | And drunk the milk of Paradise." From jwbnews at scandaroon.com Mon Mar 19 23:49:54 2001 From: jwbnews at scandaroon.com (John W. Baxter) Date: Mon, 19 Mar 2001 20:49:54 -0800 Subject: Pep 238 Why new // operator (Non-integer Division) References: <995tbo0oce@drn.newsguy.com> Message-ID: In article <995tbo0oce at drn.newsguy.com>, Grant Griffin wrote: > Now don't get me start on that: to me, it had looked more like _Perl's_ #! > (That has too many sharp edges!) To me, it just looks like an octotherp. ;-) --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From sholden at holdenweb.com Thu Mar 22 23:32:25 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 22 Mar 2001 23:32:25 -0500 Subject: PyUnit in Python 2.1 standard library References: <3ABA8A23.85EA76CE@downright.com> Message-ID: <7pAu6.9141$G72.244697@e420r-atl1.usenetserver.com> "Don Tuttle" wrote in message news:zZxu6.150312$__6.27726222 at typhoon.southeast.rr.com... > "Doug Fort" > > Just recieved word that Steve Purcell has checked PyUnit into the > > standard library. Aside from being a useful tool to me PyUnit typifies > > the kind of development that ESR advocates in 'The Cathedral and the > > Bazaar'. A project started to 'scratch an itch', then shared with the > > communityto evolve and grow. None of the stuff I work on seems to come > > out so clean. Congratulations Steve! PyUnit is an example to us all. > > So what kind of itch does PyUnit scratch? > The one you get about an hour before you start receiving emails about a bug in your software. regards Steve From cce at clarkevans.com Sat Mar 24 22:22:20 2001 From: cce at clarkevans.com (Clark C. Evans) Date: Sat, 24 Mar 2001 22:22:20 -0500 (EST) Subject: Yet Another PEP: Query Protocol Interface or __query__ In-Reply-To: References: Message-ID: Below is an updated version of the proposal Ive been a champion for. It incorporates a great deal of feedback that Ive received. Changes include: * By default, adapt now throws an error again, however an alternate object can be provided upon failure much like getattr. * Now __adapt__ can either return None or throw a TypeError with the same effect. * This now includes reverse adaptation of the object by the protocol via __prodapt__ (better name?), which is very similar to Paul Prescods __check__ * The text has been tightened (hopefully eliminating much superfluous material) * The sample implementation code has been cleaned up and tested in more detail. * Ive received much comment to remove the type-checking stuff. I have a question: Is type-checking a component of adapting? I would very much appreciate any comments and feedback. Especially if the intent/value of this proposal is not clear as I seem to be having a difficult time with the expression of this. Further, I still do not have a PEP number. Either I have not asked correctly, am being stupid, have pissed someone off, or am proposing something that has already been rejected. In any case, what do I do? Kind regards, Clark P.S. Id like to thank Alex Martelli for his most helpful comments and hope that I have dutifully incorporated his suggestions appropriately. PEP: XXX Title: Protocol Checking and Adaptation Version: $Revision$ Author: Clark Evans Python-Version: 2.2 Status: Draft Type: Standards Track Created: 21-Mar-2001 Updated: 23-Mar-2001 Abstract This proposal puts forth a light-weight explicit mechanism for the adaptation (including verification) of an object to a context where a specific type, class, interface, or other protocol is expected. This proposal can leverage existing protocols such as the type system and class hierarchy and is orthogonal, if not complementary to the pending interface mechanism [1] and signature based type-checking system [2] This proposal allows a standard and extensible method to ask two types of questions: Is a particular object compliant with a given protocol? (b) And if not, can the object be wrapped so that it is complaint? This proposal does not limit what a protocol is, what compliance to the protocol means, nor what a wrapper constitutes. Motivation Currently there is no standardized mechanism in Python for asking if an object supports a particular protocol. Typically, existence of particular methods, particularly those that are built-in such as __getitem__, is used as an indicator of support for a particular protocol. This technique works for protocols blessed by GvR, such as the new enumerator proposal identified by a new built-in __iter__. However, this technique does not admit an infallible way to identify interfaces lacking a unique, built-in signature method. More so, there is no standardized way to obtain an adapter for an object. Typically, with objects passed to a context expecting a particular protocol, either the object knows about the context and provides its own wrapper or the context knows about the object and wraps it appropriately. The difficulty with these approaches is that such adaptations are one-offs, are not centralized in a single place of the users code, and are not executed with a common technique, etc. This lack of standardization increases code duplication with the same adapter occurring in more than one place or it encourages classes to be re-written instead of adapted. In either case, maintainability suffers. It would be very nice to have a standard function that can be called upon to verify an objects compliance with a particular protocol and provide for a wrapper if one is readily available -- all without having to hunt through a librarys documentation for the appropriate incantation. Requirements When considering an objects compliance with a protocol, there are several cases to be examined: a) When the protocol is a type or class, and the object has exactly that type or is a member of the class. In this case compliance is automatic. b) When the object knows about the protocol and either considers itself compliant or knows how to wrap itself appropriately. c) When the protocol knows about the object and either it complies or can be wrapped accordingly. d) When the protocol is a class, and the object is a member of a subclass. This is distinct from the first case (a) above, since inheritance does not necessarily imply substitutability and must be handled carefully. e) When the context knows about the object and the protocol and knows how to adapt the object so that the required protocol is satisfied. This could use an adapter registry or similar method. For this proposal's requirements, the first case should be come for free and the next three cases should be relatively relatively easy to accomplish. This proposal does not address the last case, however it provides a base mechanism upon which such an approach could be developed. Further, with only minor implementation changes, this proposal should be able to incorporate a new interface type or type checking system. The fourth case above is subtle. A lack of substitutability can occur when a method restricts an argument's domain or raises an exception which a base class does not or extends the co-domain to include return values which the base class may never produce. While compliance based on class inheritance should be automatic, this proposal should allow an object to signal that it is not compliant with a base class protocol. Specification This proposal introduces a new built-in function, adapt, which is the basis for supporting these requirements. The adapt function has four parameters: 1) the object to be adapted ("obj"), 2) the protocol requested of the object ("protocol"), 3) an optional object to return if the object could not be adapted ("alternate"), and 4) an optional flag which can be used to prevent a wrapper from being generated ("can_wrap") if provided. A successful result of the adapt function returns either the object passed ("obj") if the object is already compliant with the protocol, or a secondary object ("wrapper"), which provides a view of the object compliant with the protocol. The definition of wrapper is explicitly vague and a wrapper is allowed to be a full object with its own state if necessary. A failure to adapt the object to the protocol will raise a TypeError unless the alternate parameter is used, in this case the alternate argument is returned. To enable the first case listed in the requirements, the adapt function first checks to see if the objects type or the objects class are identical to the protocol. If so, then the adapt function returns the object directly without further ado. To enable the second case, when the object knows about the protocol, the object must have an __adapt__ method. This optional method takes three arguments, the object being adapted ("self"), the protocol requested ("protocol"), and a flag ("can_wrap"). The object may return itself through this method to indicate compliance. Alternatively, if the can_wrap flag is true the object also has the option of returning a wrapper object compliant with the protocol. Finally, if the object cannot determine its compliance, it should either return None or raise a TypeError to allow other mechanisms to be checked. To enable the third case, when the protocol knows about the object, the protocol must have a __prodapt__ method. This optional method takes three arguments, the protocol requested ("self"), the object being adapted ("obj"), and a flag ("can_wrap"). If the protocol finds the object to be compliant, it can return obj directly. Alternatively, if the can_wrap flag is true, the method may return a wrapper compliant with the protocol. Finally, compliance cannot be determined, this method should either return None or raise a TypeError so other mechanisms can be tried. The fourth case, when the objects class is a sub-class of the protocol, is handled by the built-in adapt function. Under normal circumstances, if isinstance(object,protcol) then adapt returns the object directly. However, if the object is not substitutable, either the __adapt__ or __prodapt__ methods above may raise an adaptForceFailException to prevent this default behavior. This proposal could introduce one more built-in function, "isa", perhaps implemented as an operator. If this is deemed useful, the function would take two arguments, the first is the object to be checked ("obj"), and the second is the protocol to check the object against ("protocol"). The return value of the operator will be either be the obj or None. This function would be implemented by calling the adapt function with the can_wrap being false and an alternate argument of None. Please note two important things. First, this proposal does not preclude the addition of other protocols. Second, this proposal does not preclude other possible cases where adapter pattern may hold, such as the context knowing the object and the protocol (the last case in the requirements). In fact, this proposal opens the gate for these other mechanisms to be added; while keeping the change in manageable chunks. Reference Implementation and Example Usage ----------------------------------------------------------------- adapter.py ----------------------------------------------------------------- import types adaptRaiseTypeException = "(raise a type exception on failure)" adaptForceFailException = "(forced failure of adapt)" def adapt(obj, protocol, alternate = \ adaptRaiseTypeException, can_wrap = 1): # first check to see if object has the exact protocol if type(obj) is types.InstanceType and \ obj.__class__ is protocol: return obj if type(obj) is protocol: return obj # procedure to execute on success def succeed(retval,obj,protocol,can_wrap): if can_wrap: return retval return obj # procedure to execute on failure def fail(obj,protocol,alternate): if alternate is adaptRaiseTypeException: raise TypeError("%s cannot be adapted to %s" \ % (obj,protocol)) return alternate # try to use the object's adapting mechanism adapt = getattr(obj, '__adapt__',None) if adapt: try: retval = adapt(protocol,can_wrap) if retval: return succeed(retval,obj,protocol,can_wrap) except adaptForceFailException: return fail(obj,protocol,alternate) except TypeError: pass # try to use the protocol's adapting mechanism adapt = getattr(protocol, '__prodapt__',None) if adapt: try: retval = adapt(obj,can_wrap) if retval: return succeed(retval,obj,protocol,can_wrap) except adaptForceFailException: return fail(obj,protocol,alternate) except TypeError: pass # check to see if the object is an instance try: if isinstance(obj,protocol): return obj except TypeError: pass # no-adaptation-possible case return fail(obj,protocol,alternate) # imagine binary operator syntax def isa(obj,protocol): return adapt(obj,protocol,None,0) ----------------------------------------------------------------- test.py ----------------------------------------------------------------- import adapter import types from adapter import adapt from adapter import isa from adapter import adaptForceFailException class KnightsWhoSayNi: pass class Eggs: # an unrelated class/interface def eggs(self): print "eggs!" word = "Nee-womm" class Ham: # used as an interface, no inhertance def ham(self): pass word = "Ping" class Spam: # a base class, inheritance used def spam(self): print "spam!" class EggsSpamAndHam (Spam,KnightsWhoSayNi): def ham(self): print "ham!" def __adapt__(self,protocol,can_wrap): if protocol is Ham: # implements Ham's ham, but does not have a word return self if protocol is KnightsWhoSayNi: # we are no longer the Knights who say Ni! raise adaptForceFailException if protocol is Eggs and can_wrap: # Knows how to create the eggs! return Eggs() raise TypeError("haha") class Bing (Ham): def __adapt__(self,protcol,can_wrap): raise adaptForceFailException # in this case, it is the protcol which determines # if the class is adapted class SacredWord: class HasSecredWord: def __call__(self, obj, can_wrap): if getattr(obj,'word',None): return obj __prodapt__= HasSecredWord() def test(): x = EggsSpamAndHam() adapt(x,Spam).spam() adapt(x,Eggs).eggs() adapt(x,Ham).ham() adapt(x,EggsSpamAndHam).ham() print adapt(Eggs(),SacredWord).word print adapt(Ham(),SacredWord).word pass if adapt(x,KnightsWhoSayNi,None): raise "IckyIcky" if not isa(x,Spam): raise "Spam" if isa(x,Eggs): raise "Eggs" if not isa(x,Ham): raise "Ham" if not isa(x,EggsSpamAndHam): raise "EggsAndSpam" if isa(x,KnightsWhoSayNi): raise "NightsWhoSayNi" if isa(x,SacredWord): raise "SacredWord" try: adapt(x,SacredWord) except TypeError: pass else: raise "SacredWord" try: adapt(x,KnightsWhoSayNi) except TypeError: print "Ekky-ekky-ekky-ekky-z'Bang, " \ + "zoom-Boing, z'nourrrwringmm" else: raise "NightsWhoSayNi" pass b = Bing() if not isa(b,Bing): raise "Not a Bing" if isa(b,Ham): raise "Not a Ham!" if isa(1,types.FloatType): raise "Not a float!" if isa(b,types.FloatType): raise "Not a float!" if isa(1,Ham): raise "Not a Ham!" if not isa(1,types.IntType): raise "Is an Int!" ----------------------------------------------------------------- Example Run ----------------------------------------------------------------- >>> import test >>> test.test() spam! eggs! ham! ham! Nee-womm Ping Ekky-ekky-ekky-ekky-z'Bang, zoom-Boing, z'nourrrwringmm Relationship To Paul Prescod and Tim Hochbergs Type Assertion method Paul and Tim had proposed an type checking mechanism, where the Interface is passed an object to verify. The example syntax Paul put forth recently [2] was: interface Interface def __check__(self,obj) This could be re-written to avoid the "interface" keyword as: class Interface: class Checker: def __call__(self, obj): pass #check the object __check__= Checker() As I understand it, __prodapt__ is essentially __check__, only that the function is also given the ability to substitute a wrapper for the object if can_wrap is set. Further, __prodapt__ returns an object instead of true/false, however, this seems a trivial difference. Indeed, a bulk of the idea for this proposal was built directly from Paul and Tims work. In short, the work put forth by Paul and company is great, and I dont see any problems why these two proposals couldnt work together in harmony, if not be completely complementary. Relationship to Python Interfaces [1] by Michel Pelletier The relationship to this proposal to Michels proposal could also be complementary. If approved, the first two paragraphs of the built-in adapt function could be changed as follows: # first check to see if object has the exact protocol > if type(protocol) is types.InterfaceType and \ > instance(obj,protocol): return obj if type(obj) is types.InstanceType and \ obj.__class__ is protocol: return obj if type(obj) is protocol: return obj # procedure to execute on success def succeed(retval,obj,protocol,can_wrap): > if type(protocol) is types.InterfaceType: > if not instance(retval,protocol): > raise "Bad __adapt__ or __prodapt__!" if can_wrap: return retval return obj Relationships To Microsofts Query Interface: Although this proposal may sounds similar to Microsofts QueryInterface, it differs by a number of aspects. First, there is not a special "IUnknown" interface which can be used for object identity, although this could be proposed as one of those "special" blessed interface protocol identifiers. Second, with QueryInterface, once an object supports a particular interface it must always there after support this interface; this proposal makes no such guarantee, although this may be added at a later time. Third, implementations of Microsofts QueryInterface must support a kind of equivalence relation. By reflexive they mean the querying an interface for itself must always succeed. By symmetrical they mean that if one can successfully query an interface IA for a second interface IB, then one must also be able to successfully query the interface IB for IA. And finally, by transitive they mean if one can successfully query IA for IB and one can successfully query IB for IC, then one must be able to successfully query IA for IC. Ability to support this type of equivalence relation should be encouraged, but may not be possible. Further research on this topic (by someone familiar with Microsoft COM) would be helpful in further determining how compatible this proposal is. Backwards Compatibility There should be no problem with backwards compatibility unless someone had used __adapt__ or __prodapt__, but this seems unlikely. Indeed this proposal, save an built-in adapt() function, could be tested without changes to the interpreter. Questions and Answers Q: Why was the name changed from __query__ to __adapt__ ? A: It was clear that significant QueryInterface assumptions were being laid upon the proposal, when the intent was more of an adapter. Of course, if an object does not need to be adapted then it can be used directly and this is the basic premise. Q: Why is the checking mixed with the adapter mechanism? A: Good question. They could be separated, however, there is significant overlap, if you consider the checking protocol as returning a compliant object (self) or not a compliant object (None). In this way, adapting becomes a special case of checking, via the can_wrap. This could be separated out, but the two concepts are very related so much duplicate work would be done, and the overall mechanism would feel quite a bit less unified. Q: I like/dont like the isa function/operator. A: It is separable from this proposal, it just seems like a handy short-hand for checking rather than adapting. Q: The name __prodapt__ sucks. A: Suggest a better alternative; I suppose __check__ could be used for the protocol side, however I dont want to trample on Paul Prescods proposal. Credits This proposal was created in large part by the feedback of the talented individuals on both the main mailing list and also the type signature list. Specific contributors include (sorry if I missed someone). This proposal is based largely off the suggestions from Alex Martelli and Paul Prescod with significant feedback from Robin Thomas and borrowing ideas from Marcin 'Qrczak' Kowalczyk. Other contributors (via comments) include: Michel Pelletier, Jeremy Hylton, Carlos Ribeiro, Aahz Maruch, Fredrik Lundh, Rainer Deyke, Timothy Delaney, and Huaiyu Zhu Copyright This document has been placed in the public domain. References and Footnotes [1] http://python.sourceforge.net/peps/pep-0245.html [2] http://mail.python.org/pipermail/types-sig/2001-March/001223.html [3] http://www.zope.org/Members/michel/types-sig/TreasureTrove [4] http://mail.python.org/pipermail/types-sig/2001-March/001105.html [5] http://mail.python.org/pipermail/types-sig/2001-March/001206.html [6] http://mail.python.org/pipermail/types-sig/2001-March/001223.html From fredrik at pythonware.com Fri Mar 16 12:40:23 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 16 Mar 2001 17:40:23 GMT Subject: Python style questions References: <98tb91$9t9$1@saltmine.radix.net> Message-ID: "D-Man" wrote: > Curiosly enough, print's format string is supposed to be identical to > C's printf format string. However the man page for printf says the %x > prints 0x then the number using A-F for 10-15. better check that page again; printf should add 0x only if you use the # flag. Cheers /F From aleaxit at yahoo.com Fri Mar 23 07:40:44 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 23 Mar 2001 13:40:44 +0100 Subject: PartialInterfaces ? Re: Checking the type References: Message-ID: <99fg8k01sr0@news2.newsguy.com> "Clark C. Evans" wrote in message news:mailman.985343914.18681.python-list at python.org... > > # safer > > def munge(alist): > > # first extract all bound-methods we'll need > > append = alist.append > > extend = alist.extend [snip] > This is a very cool, "protocol", a partial interface. Why, thanks. Wish I could claim originality:-), but, as I said, this (or a close analog thereof) is rather standard fare in C++ templates. > I was thinking about how this could be formalized as > a "checker/adapter"... here is very imperfect code) > > class partial_list_checker: > def __init__(self, append=0,extend=0,index=0,... > self.check_append=append > self.check_extend=extend > self.check_index =index > ... > > def check(self,alist) > try: > if self.check_append: append = alist.append > if self.check_extend: extend = alist.extend > if self.check_index: > try: alist[0] = alist[0] > except IndexError: pass > ... > return alist > except AttributeError > return None > > What do you think? Kinda slow, hunh? Rather. Maybe slightly better: class checker_of_methods: def __init__(self, *method_names_needed): self.method_names_needed = method_names_needed def check(self, anobj): return [ getattr(anobj, method) for method in self.method_names_needed ] I'd let the AttributeError propagate up to the caller of achecker.check if the object being checked does not supply a needed method -- seems simples/smoothest. And I think returning the already-bound methods is also a (very slight) optimization as well as a simplification. Of course, this doesn't handle the specific check for indexability (alist[0]=alist[0]), though I guess that could be added as a special case (maybe in a derived class of checker_of_methods specialized for sequence checking). Anyway, usage here might be, e.g.: append, extend = checker_of_methods( 'append', 'extend').check(alist) Alex From news at dorb.com Sat Mar 3 09:29:10 2001 From: news at dorb.com (Darrell) Date: Sat, 03 Mar 2001 14:29:10 GMT Subject: playing with IP's References: Message-ID: "Langa Kentane" wrote: > Greetings. > Here is what I wanna do: > Given a network number and mask ie: > 192.168.1.0/32 > I want to create a list with all the valid hosts on that range. > Problem is I don't know how to play with decimal. > > Where would I start.. any sample code? > Thanks > I don't know a lot about this, but here's a starting point. Be sure to post any improvements :) It might be handy to print out the subnet boundary's. --Darrell #!/usr/bin/env python import re def shiftOctents(octents): """ Convert dot separated IP format to a number This might exist in the socket module? """ octents=octents.split(".") octents.reverse() v=0 for x in range(len(octents)): v|= int(octents[x]) << (x*8) return v # Bytes used for local addresses in a class of IP _netWorkClassDict={'a':3, 'b':2, 'c':1} def getValues(input, netWorkClass='b'): """ Return IP converted to a number subnet address size host address size """ netWorkClass=netWorkClass.lower() ip, mask = input.split("/") mask = shiftOctents(mask) hosts = ~mask & 0xffffffffL -1 val='0x'+'ff'*_netWorkClassDict[netWorkClass] netWorkClassMask = int(val, 16) subnet=max(0, (netWorkClassMask/(hosts+2)) -1) ip= shiftOctents(ip) return ip, subnet, hosts def backToDotNotation(val): res=[] tempVal=val for x in range(4): res.append(tempVal & 0xff) tempVal = tempVal >> 8 res.reverse() return "%d.%d.%d.%d"%tuple(res) def test1(): input=["192.168.1.0/255.255.0.0","192.168.1.0/255.255.240.0", "192.168.1.0/255.255.254.0","192.168.1.0/255.255.255.252" ] expected=[(0, 65534), (14, 4094),(126, 510), (16382, 2)] netWorkClass='b' for ix in range(len(input)): i=input[ix] print "Using:", i print "Class:", netWorkClass values=getValues(i, netWorkClass) assert(values[1:]==expected[ix]) print 'Number of hosts for this subnet:', values[2] print 'Ending IP for this subnet:', backToDotNotation(values[0] | values[2]) print 'Number of subnets:', values[1] print test1() From egbert at bork.demon.nl Thu Mar 8 13:40:29 2001 From: egbert at bork.demon.nl (Egbert Bouwman) Date: Thu, 8 Mar 2001 19:40:29 +0100 Subject: Get terminal size in perl and python Message-ID: <20010308194028.A1616@bork.demon.nl> My perl correspondent uses: use Term::ReadKey; ($cols,$lines)=GetTerminalSize() What is the python equivalent ? If I don't come up with one, python looses ten points. egbert -- Egbert Bouwman - Keizersgracht 197 II - 1016 DS Amsterdam - 020 6257991 ======================================================================== From grante at visi.com Thu Mar 22 16:10:01 2001 From: grante at visi.com (Grant Edwards) Date: Thu, 22 Mar 2001 21:10:01 GMT Subject: Good Editor? References: Message-ID: In article , Bruce Sass wrote: >On Thu, 22 Mar 2001, fjs wrote: > >> Sorry folks, >> >> I use both windows and linux. So, all the recomendations have been helpful. > >I'm wondering why JED wasn't mentioned... it does a good job with >tweaking scripts, writing small programs, and the syntax >highlighting doesn't get confused as easily as with emacs. Jed is what I use under both Linux and MS-Windows. Python mode is pretty decent. -- Grant Edwards grante Yow! I have a very good at DENTAL PLAN. Thank you. visi.com From kumo at bellsouth.net Wed Mar 14 11:28:11 2001 From: kumo at bellsouth.net (David Rush) Date: 14 Mar 2001 16:28:11 +0000 Subject: Einstein's Riddle References: <3AAE9730.5A7A4249@brazee.net> <3AAF8740.907533CC@brazee.net> Message-ID: Howard Brazee writes: > The original poster must have used a Spammer tool. This thread is cross-posted > elsewhere as well, and I have seen one other coded solution, in Forth. I've seen far too many. > It would be fun to see a bunch of language solutions, first to solve this problem, > and then a more generic version to solve this class of problems. Set up a website, then. Quit spamming the world. david rush -- Einstein said that genius abhors consensus because when consensus is reached, thinking stops. Stop nodding your head. -- the Silicon Valley Tarot From max at alcyone.com Sun Mar 25 03:00:19 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 25 Mar 2001 00:00:19 -0800 Subject: Python Mega Widgets rpm spec file? References: Message-ID: <3ABDA593.86CA0E02@alcyone.com> rodrigc at mediaone.net wrote: > Grayson's book refers to Python Mega Widgets (Pmw) quite > a bit, but this does not come standard with Redhat distributions. > Has anyone made an rpm spec file for Pmw, so that it > can be installed as an rpm package? It's available here. There's nothing to compile, so it's really trivial. If you're so inclined, you could make your own rpm. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Triumph cannot help being cruel. \__/ Jose Ortega y Gasset Interstelen / http://www.interstelen.com/ A multiplayer, strategic, turn-based Web game on an interstellar scale. From claird at starbase.neosoft.com Wed Mar 21 12:03:33 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 21 Mar 2001 11:03:33 -0600 Subject: Accessing Oracle from Python remotely ? References: Message-ID: In article , gkiffney wrote: >There's http://www.zope.org/Products/DCOracle which should get you started. >There was an article by Uche Ogbuji in Linuxworld that helped me get going >with this, but it's apparently fallen off the Internet map into the bit >bucket. Using the dcoracle module (which is a bit of a pain to get going, . . . Do you mean ? -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From kare at speech.kth.se Thu Mar 15 11:43:15 2001 From: kare at speech.kth.se (Kare Sjolander) Date: Thu, 15 Mar 2001 17:43:15 +0100 Subject: ANNOUNCE: The Snack Sound Toolkit v2.0.7 Message-ID: <3AB0F123.F1E2D432@speech.kth.se> This release contains: * Several enhancements * Several important bug-fixes, e.g. related to - MP3 decoding - sound with > 2 channels * Updated demos Change log 2/6/01 (bug fix) Fixed bug in the Macintosh audio code. The sound stop command now stops sound output without any delay. 2/25/01 (bug fix) Fixed bug in the Windows audio code which limited output to two channels even though the hardware was capable of more. 3/1/01 (enhancement) The -fileformat option to the sound, read, data, append, configure, and cget commands now accept an empty string as argument indicating that no file format was specified. 3/1/01 (bug fix) A number of fixes which gives much more stable MP3 decoding. (Wilkason) 3/1/01 (enhancement) Enhanced file format detection to discriminate between raw sound files and MP3 files. 3/1/01 (bug fix) Fixed endianess problem in tests/data.test 3/5/01 (configuration improvement) Fixed configure script for FreeBSD to not use ossaudio library. 3/9/01 (bug fix) Fixed memory leak when playing -file sounds. 3/13/01 (bug fix) Fixed problem for sounds linked to disk files with more than two channels. 3/13/01 (enhancement) Precomputed waveform shapes now handle multi-channel sounds. The shape file is now stored in AIFF format with Lin8 encoding. 3/13/01 (enhancement) The wrap.tcl demo is now more intelligent in creating its temporary work directory on the Windows platform. 3/14/01 (bug fix) Bartlett analysis window corrected. (Rank) The Snack Sound Toolkit is designed to be used with a scripting language. Currently it supports Tcl/Tk and Python. Snack adds commands to play, record, and process sound and supports in-memory sound objects, file based audio, and streaming audio. It handles fileformats such as WAV, MP3, AU, AIFF, and NIST/Sphere. Snack is extensible, new commands, filters, and sound file formats can be added using the Snack C-library. An easy to build example extension is contained in the source distribution. Snack also does sound visualization, e.g. waveforms and spectrograms. The visualization objects update in real-time and can output postscript. Snack works with Tcl8.0 - Tcl8.4 and Python 1.5.2-2.0 Platforms: Linux, Solaris, HP-UX, IRIX, NetBSD, Macintosh, and Windows 95/98/NT/2K. Source and binaries can be downloaded from http://www.speech.kth.se/snack/ Regards, Kare Sjolander kare at speech.kth.se From mcalla at home.com Thu Mar 15 16:56:30 2001 From: mcalla at home.com (Mike Callahan) Date: Thu, 15 Mar 2001 21:56:30 GMT Subject: Communicating with serial port References: Message-ID: Peter, I recently finished a program using Roger's latest version of Sio and it worked well with Python 2.0. Mike Callahan "Peter Blom" wrote in message news:ndNn6.5161$t21.152593 at news3.oke.nextra.no... > I shall write a python program for downloading data from a memory card in a > measuring instrument, via a serial port. > For this purpose, I have downloaded SioModule.zip - a serial comm extension > for windows 95, upgraded to Python 1.5.1. > This does not seem to work - when importing the module 'serial.py', my > system hangs (Windows 98, Activestate Python 2.0). > Could anybody give a hint? > > Peter (a newbie) > > From jeremy at alum.mit.edu Fri Mar 16 17:33:25 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Fri, 16 Mar 2001 17:33:25 -0500 (EST) Subject: Type mismatchings and the rank newbie In-Reply-To: References: Message-ID: <15026.38069.279933.21223@w221.z064000254.bwi-md.dsl.cnc.net> >>>>> "JB" == John Brawley writes: JB> Rank newbie here, trying to do something specific. I need to JB> use a set of numbers (say, 1 to 25), and create 25 lists from JB> the numbers (1 thru 25), which lists have a character "P" and a JB> number (one of the 25). JB> The lists I want look like : P1=[x, y, z] P2=[x, y, z] P3=[x, y, z] (etcetera down to P25) [...] JB> I need to write a loop that takes each number in sequence and JB> sticks it next to the ascii "P" so that when the loop is JB> finished, I end up with a set of lists each of whose names is JB> different by one number. JB> The loop is not a problem; I just can't figure how to stick a JB> different number form the user input total, into the second JB> place of the list name ( Pn=[x, y, z] where 'n' is the number JB> stuck in there by the loop) with every iteration of the loop. JB> The docs are confusing to me (I'm not a programmer and don't JB> want to be, but there is no other way for me to do what I need JB> to to see what this program will display for me). JB> Can anyone suggest a way out of this hole? The point you're stuck at is: You have an integer, say, 12, and you want to make an assignment to the name P12. Is that right? If so, then you need some a helper object that can direct you from the number 12 to the variable P12. There is no good way to invent the variable name on the fly. (It is technically possible using exec, but this is fairly complicated and can be hard to understand.) Is it absolutely necessary to use variables names P1, P2, etc? It would be simpler to use a dictionary. P = {} P[1] = [x, y, z] P[2] = [x, y, z] If that's not possible, here is another, slightly more subtle suggestion. # These are place holders for the real values, which will be # created based on user input. P1 = [] P2 = [] ... P25 = [] Plist = [P1, P2, P3, ..., P25] # get the user input here n = get_number() Plist[n].extend([x, y, z]) # then Plist[n] => "Pn" => [x, y, z] The above code works using references to the lists. In Python, names create references to objects. Lists are mutable objects. When you call the extend method on a list, it modifies the list in place and adds the elements of its argument. >>> l = [] >>> l.extend([1]) >>> l [1] >>> l.extend([2, 3]) >>> l [1, 2, 3] Then you can bind the same object to a new name or put it in a list. >>> l2 = l >>> l2 [1, 2, 3] >>> l.append(4) >>> l [1, 2, 3, 4] >>> l2 [1, 2, 3, 4] >>> list_of_lists = [l] >>> list_of_lists [[1, 2, 3, 4]] >>> list_of_lists[0].append(5) >>> list_of_lists [[1, 2, 3, 4, 5]] >>> l [1, 2, 3, 4, 5] Hope this helps. Jeremy From farmerk at pacbell.net Tue Mar 6 04:29:39 2001 From: farmerk at pacbell.net (Keith Farmer) Date: Tue, 6 Mar 2001 01:29:39 -0800 Subject: win32, GUI AppBar class Message-ID: Has anybody implemented an AppBar class in Win32? That is, a window that docks to the edge of the screen (such as TaskBar, Launch Bar, ICQ, AIM, Office Bar, etc)? Looking through the PythonWin docs, no support seems inherent for this (dockable control bars, but not full-fledged windows). I was thinking the only choice would be calldll, but being in Python 2.0, I discovered npstruct (potentially necessary for this task) doesn't seem to be compiled for it yet. I'd be most interested in docking/auto-hide support from stock win32/python libraries -- like Tkinter and PyWin -- though I'm thinking a mixin class would be really nifty, and allow for the creation of Python-based wharfs, etc. Keith Farmer SF, CA From sheila at spamcop.net Sun Mar 18 01:08:27 2001 From: sheila at spamcop.net (Sheila King) Date: Sun, 18 Mar 2001 06:08:27 GMT Subject: reading stdinput References: Message-ID: On Sun, 18 Mar 2001 11:11:00 +0930 (CST), Michael Hall wrote in comp.lang.python in article : :How do I read standard input into a Python script? I'm trying to do the :same as 'read' in a shell script to create a variable. I've played about :with various combinations of 'sys.stdin.read()' and such but no go. Here's a really simple little script, that reads from stdin and writes the result to stdout. I just re-tested it now, to make sure it works: #!/usr/bin/env python import sys line = sys.stdin.readline() print line -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From kens at sightreader.com Fri Mar 16 12:18:25 2001 From: kens at sightreader.com (Ken Seehof) Date: Fri, 16 Mar 2001 11:18:25 -0600 Subject: Cookies References: <0Dhs6.576315$U46.17170213@news1.sttls1.wa.home.com> Message-ID: <004d01c0ae3d$1cbfbde0$04090a0a@upcast.com> Yeah, that's the closest I've come up with too, but the difficulty is making the system reliably support all browsers. Unfortunately from the point of view of a standalone application, there is no standard for cookies. Cookies are standardized from the point of view of servers and javascript, but that doesn't help me with a standalone app. The best approach so far seems to be to have the server send back a page with a 10 digit unique identifier in a large font. The python app would then ask the user to type in the number manually. Seems kinda dumb that I need the users fingers as part of my protocol. :-) - Ken ----- Original Message ----- From: "Greg Jorgensen" Newsgroups: comp.lang.python To: Sent: Thursday, March 15, 2001 11:35 PM Subject: Re: Cookies > A cookie is just a text file stored in a special place where the browser can > find it. Where exactly the cookies go depends on your OS and browser. > > Using a text file to store the key would seem the easiest solution, but > client-side Javascript can't create or write a file. > > I think you should generate unique IDs on the server, not on the client. > Here's one way to handle it: > > 1. Client browser sends form data to server. > 2. Server processes form, generates a unique ID, stores the form data keyed > by the unique ID. > 3. Server replies with a "thank you" or "database updated" page that also > writes a cookie. > 4. Python program starts up and looks for the cookie. Depending on your OS > and browser the location and name of the cookie will vary, but with a little > experimenting you can easily find the most likely locations. > 5. Python program reads the cookie. Open your cookie with a text editor to > see what's in there--it's just name: value pairs. > 6. Python program sends HTTP request to server with unique ID it got from > the cookie. > > Obviously this won't work if the client has disabled cookies. With a little > more trouble you can detect this and perhaps put the unique ID on the > response page and tell the user to save it or something. Or embed the unique > ID in the reply page and tell the user to save that page and give it a > specific name, then have your Python program open that text file and find > the unique ID in there. > > Depending on your requirements and security concerns, you can either have > your database program generate the unique ID (my preference), use the > Windows GUID functions (which are available to ASP on the server), or > implement one of the GUID functions you can easily find on the web. Many > programmers have solved this in one way or another; send email to me if you > want specific advice on generating unique IDs from your database engine. > > Good luck. > > <<< > "Ken Seehof" wrote in message > news:mailman.984707839.22839.python-list at python.org... > Short version: > > Is it possible for a stand-alone python application to read a cookie without > the help of a browser?" > > Long version: > > I have a web page W and a client side python script P. I want W to generate > a GUID (perhaps using javascript) which is then sent to a server S, where it > is to be used as a key in a database. Now I run P (on the client, and not > in a browser) and I want P to somehow find the value of the GUID, so that it > can query the database on S. > > Alternate question: > > Is there a technique common to both javascript and python that will obtain a > unique identifier for a computer (e.g. IP address). It must not be browser > specific. > > Motivation: > > I need to write a record of data from an html form, keyed by some kind of > unique client id, to the server and then be able to query that record from a > stand alone python script running on the client. The missing link is > getting the html form and the python script to agree on a value for the id; > the rest is easy. > >>> > > -- > Greg Jorgensen > PDXperts > Portland, Oregon, USA > gregj at pobox.com > > > -- > http://mail.python.org/mailman/listinfo/python-list > From bedge at troikanetworks.com Thu Mar 1 19:28:23 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Thu, 01 Mar 2001 16:28:23 -0800 Subject: define a new func on the fly? Message-ID: <3A9EE927.8744154E@troikanetworks.com> I'm trying to define a new function on the at runtime, this fails: >>> eval( "def global_func_name():\n\tpass" ) Traceback (most recent call last): File "", line 1, in ? File "", line 1 def global_func_name(): ^ SyntaxError: invalid syntax any idea how I can do this? Thanks, Bruce. From aleaxit at yahoo.com Thu Mar 15 05:26:52 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 15 Mar 2001 11:26:52 +0100 Subject: Who's minister of propaganda this week? References: <98otuq0nnf@news1.newsguy.com> Message-ID: <98q6ro2uoa@news2.newsguy.com> "Neelakantan Krishnaswami" wrote in message news:slrn9b0cc2.gsa.neelk at alum.mit.edu... > On Thu, 15 Mar 2001 00:09:30 +0100, Alex Martelli wrote: > >"Steven D. Majewski" wrote in message > >news:mailman.984595938.11127.python-list at python.org... > > [snip] > >> ( OK: not having multiple dispatch in Python means that some manual > >> dispatching is sometimes required, but usually this is burried deep > >> in some classes __coerce__ method. ) > > > > "Usually" in arithmetic, perhaps. For fancier stuff, lack of > > multimethods sometimes cramps (not that it cramps any less in C++, > > mind you), though some patterns (such as 'dynamic visitor') can help > > a bit in certain (reasonably frequent) special cases. > > What's a dynamic visitor? Is it a dictionary keyed on class? That's > what I usually do when emulating multimethods in Python. Sorry, the pattern-name is _Acyclic_ Visitor -- it's fully described by its author, Robert Martin, in the PDF at URL http://www.objectmentor.com/publications/acv.pdf for example. The 'dynamic' aspect is at its core (in the C++ version, it uses dynamic_cast systematically, for example) but not in the name (because the key _goal_ of it, vs regular Visitor, is framed as removing a very troublesome cyclic dependency). Keying a dict on class has the unfortunate side-effect of not allowing polymorphism by inheritance -- objects of classes _derived from_ the one used as the key will not match. You can preserve this basic idea by using as key, instead of the class, some ad-hoc attribute which will be inherited (if it IS acceptable to alter the class-objects of interest by adding an attribute) except where specifically overridden, an approach which can be used as a first-path (fast-path) to be followed by an isinstance loop (slow but sure) if and when the key attribute is not obtained (e.g. for types that are not classes, or, classes that can't be altered). I don't think the applicability cases of this approach to hand-simulation of multiple dispatch will overlap much with those of visitors (of any kind) or coercion approaches. Alex From phlip_cpp at my-deja.com Mon Mar 12 15:15:31 2001 From: phlip_cpp at my-deja.com (Phlip) Date: Mon, 12 Mar 2001 12:15:31 -0800 Subject: PyEval_CallObject and threads References: Message-ID: Tim Peters wrote: > [Phlip] >> My colleague came over and asked me to write this: >> >> "We got multiple C++ pthreads calling PyEval_CallObject. How threadsafe >> is the Python API? A C++ module using Boost BPL creates multiple threads, >> which then call back into Python. When two threads simultaneously call >> PyEval_CallObject we go boom." >> >> I will now go examine his serialization primitives. But if anyone has any >> better ideas... > > With very few exceptions, all calls to Python C API functions must be made > while holding the global interpreter lock. The exceptions have mostly to > do > with a handful of functions related to initialization and shutdown. See > the section "Thread State and the Global Interpreter Lock" in the Python/C > API Reference Manual for details. Further inspection reveals our architect(s) think we need to call Python script asynchronously from multiple threads. By 'lock' we assume both you and the section you cite mean 'block'. Isn't this what Stackless Python is for? -- Phlip phlip_cpp at my-deja.com ============== http://phlip.webjump.com ============== -- Proud victim of the dreaded boomerang effect -- From garabik-news at spam.melkor.dnp.fmph.uniba.sk Tue Mar 13 13:00:42 2001 From: garabik-news at spam.melkor.dnp.fmph.uniba.sk (Radovan Garabik) Date: 13 Mar 2001 18:00:42 GMT Subject: Color curses and Python 2? References: Message-ID: <984506329.356361@cdwork.cvt.stuba.sk> Jim Dennis wrote: : I can categorically guarantee that my terminal/console supports : common ncurses color (since I use it with vim, slrn, w3m, lynx, : xemacs, dialog, and the Perl Curses.pm module among others). : Heck I can even use color in shell using tput! (Please don't : suggest that I use external calls to tput in my Python code; : that's not the question here). : As I said, I haven't seen a 1.6.x package for Debian. I gather : that the 1.5.x versions don't have ncurses/color support (I : compiled my own for that). Part of the question at hand is whether : the 2.x betas were supposed to have color support. well, I am using python2 as distributed with woody and color definitely works.... -- ----------------------------------------------------------- | Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik/ | | __..--^^^--..__ garabik @ melkor.dnp.fmph.uniba.sk | ----------------------------------------------------------- Antivirus alert: file .signature infected by signature virus. Hi! I'm a signature virus! Copy me into your signature file to help me spread! From claird at starbase.neosoft.com Fri Mar 23 09:25:44 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 23 Mar 2001 08:25:44 -0600 Subject: Tkinter - Widget Colours References: Message-ID: <3CD847F90A14AEA6.B799B72D55BF6880.28EDEA4DC41BBA47@lp.airnews.net> In article , O'Rourke Clodagh-corour01 wrote: >Hi all, > >I was wondering does anyone know how the bag/fag colours can be changed after the widget is packed. . . . Or before, even: mybutton.configure(foreground = "red") -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From jmarshal at mathworks.com Tue Mar 20 14:33:27 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 20 Mar 2001 19:33:27 GMT Subject: Sequence-spreading References: <3AB7167F.2816AA21@student.liu.se> <99790u01c73@news2.newsguy.com> <99851p$ba6$2@neptun.beotel.net> Message-ID: <998ba7$5j7$1@news.mathworks.com> gzeljko wrote: > Alex Martelli wrote in message >> offsets = [ [] for i in range(pm) ] >> for i in range(len(arg)): >> offsets[i%pm].append(i) >> >> >> Alex >> > Old syntax yet works: > offsets = [[]]*pm Careful here: >>> x = [[]]*2 >>> y = [[] for i in range(2)] >>> x [[], []] >>> y [[], []] >>> x[0] is x[1] 1 >>> y[0] is y[1] 0 The first way gives you the same value at each element ("[]" is evaluated once), while the second way gives you distinct values ("[]" is evaluated for each element). From nspurrier Fri Mar 16 22:52:52 2001 From: nspurrier (at) Date: 17 Mar 2001 03:52:52 GMT Subject: md5 passwords References: Message-ID: <98un2k62shv@news1.newsguy.com> This is off the top of my head... buyer beware. The passwords may have salt added to them. I know this is done for crypt, but I'm not sure if this is done for all other hash algorithms. With crypt the salt is the first two characters (12 bits). On my OpenBSD system (which uses Blowfish) my passwords look like: $2a$06$M43SrlFfnlLoFmK3ZAtnfquh3PsM/QZNdNNAwBEse1ReOrV4IjYeMs The first 128 bits are defined as the salt -- which I think is the first 4 characters if it's encoded in base 64. If you want to send me some of your password file with the plaintext passwords, then I will take a quick look to see if I can figure out what they are doing. Yours, Noah Spurrier P.S. Do you understand salt? You create a random salt before starting. You add that to the plaintext password then run the hash. You store the salt and hash in the password file. To check a password you take the salt from the password file and add it to the plaintext password you are testing; run the hash algorithm and check against the encrypted password. This just help to prevent people from taking a huge dictionary and running the hash on each word then check to see if any match the hashes in your password file. > Can anyone explain to me how to use the md5 module to generate > passwords for the shadow password file? > > I would like to be able to be able to os.system('useradd -p > md5/crypt username') > > I can generate the required crypt hashes no problem, but can't > seem to figure out how to generate and md5 hash that looks > anything like what I see in /etc/shadow. > > -- > Stand Fast, > tjg. > > Timothy Grant tjg at exceptionalminds.com > Red Hat Certified Engineer www.exceptionalminds.com > Avalon Technology Group, Inc. <>< (503) 246-3630 > >>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<< > >>>>This machine was last rebooted: 59 days 1:59 hours ago<< > ================================== Posted via http://nodevice.com Linux Programmer's Site From emile at fenx.com Tue Mar 27 08:56:26 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 27 Mar 2001 05:56:26 -0800 Subject: Changing every other instance of in a file References: <8e41ctkk4l38jmj34070j15iotgv4is2cg@4ax.com> Message-ID: <99q6d7$2brvo$1@ID-11957.news.dfncis.de> Here's one way (although I'm interested to see how re might do this): txt = """Blablabla talktalk blabla blabla balbalblabla Blablabla talktalk blabla blabla balbalblabla Blablabla talktalk blabla blabla balbalblabla Blablabla talktalk blabla blabla balbalblabla Blablabla talktalk blabla blabla balbalblabla Blablabla talktalk blabla blabla balbalblabla Blablabla talktalk blabla blabla balbalblabla Blablabla talktalk blabla blabla balbalblabla""" parts = txt.split("") joiners = ("","") toggle = 0 result = [] for part in parts: result.append(part) result.append(joiners[toggle]) toggle = 1 - toggle newText = "".join(result[:-1]) print newText -- Emile van Sebille emile at fenx.com --------- "Lars Kl?boe" wrote in message news:8e41ctkk4l38jmj34070j15iotgv4is2cg at 4ax.com... > I have quite a few (~70000) quark tagged files I'd like to HTMLize, and > as my tool of choice has been python for every other script, I thought > I'd stick to what I know. Or thought I knew. > > The original file.txt (quark tagged) : > > Blablabla talktalk blabla blabla balbalblabla > > The resulting file.html (html) > > Blablabla talktalk blabla blabla balbalblabla > > As you can tell, every other instance of is to be changed into . > > How on earth can I do this as easy as I did in sed ? I'm stuck > mindwise, locked on a useless solution I'm too embarrased > to show you ;) > > All help is appreciated ! > > -- > Lars Kl?boe > From kens at sightreader.com Mon Mar 26 12:04:19 2001 From: kens at sightreader.com (Ken Seehof) Date: Mon, 26 Mar 2001 09:04:19 -0800 Subject: Good GUI for Python References: <002a01c0b33f$9595ade0$340210ac@winson> Message-ID: <005b01c0b616$cda12640$a325fea9@his> wxPython is the best. I use PythonWin as my IDE and wxPython as my GUI platform. I find wxPython much easier than PythonWin mostly because MFC is hard to use (even though I've been using MFC in C++ and python (win32ui) for about 10 years). Also, wxPython is portable, unlike win32ui. I agree that win32ui is a masterpiece, but it is dependent on MFC, which is not a masterpiece :-(. I am going to switch to Komodo next (which absorbs Marks expertise but without the MFC limitations). Komodo looks really nice, but I haven't gotten it to work on my system yet (probably because I have both Python 1.5.2 and 2.0 installed). I'm looking forward to the switch. I will continue to use wxPython as my GUI platform. Hi, All I surveyed 3 GUI framework for Python including wxPython, PythonWin's included win32ui and Tkinter. My development environment is Mark Hammond's PythonWin downloaded from ActiveStates. These're my issues: First, ActiveStates' Python tool cannot support Tkinter and I confirmed with their stuff. So Tkinter maybe good, but not compatible with PythonWin. Second, Mark's masterpiece win32ui and total MFC solution is excellent, but I'd wanna bind on Windows platform. Third, wxPython sounds great but not so easy as win32ui. Is there any suggestions ? Change my develop environment or is there another good gui for me ?? -- Best Regards, Winson Chang 3F, 2, 150 Lane, Sec. 5, Hsin I Rd., Taipei, Taiwan, R.O.C. Tel: +886-2-27225333 ext 376 Fax: +886-2-27222330 Email: winson at mdsserv.mds.com.tw -------------- next part -------------- An HTML attachment was scrubbed... URL: From chrisw at nipltd.com Wed Mar 28 18:14:29 2001 From: chrisw at nipltd.com (Chris Withers) Date: Thu, 29 Mar 2001 00:14:29 +0100 Subject: Setting file attributes on file creation from ZipFiles (solved) Message-ID: <3AC27055.B4AC2568@nipltd.com> I posted this question a while ago, and now that I've found the answer I thought I'd post it back ;-) Anyway, the problem was setting the modified dates on files I was creating by unzipping them from a ZipFile object. You can do this using a function as follows: from os import utime from time import time,mktime def unzip_with_date(zipefile,filename): f = open(filename,'wb') f.write(zipefile.read(filename)) f.close() utime(filename,(time(),round(mktime(zipefile.getinfo(filename).date_time + (0,0,-1))))) Maybe that could be made into a method and included in ZipFile? cheers, Chris PS: For the curious, I found out how to do this by looking at shutil.py; I love a language where the source for the libraries is included :-) From bryan at eevolved.com Sat Mar 3 10:35:16 2001 From: bryan at eevolved.com (Bryan Mongeau) Date: Sat, 03 Mar 2001 15:35:16 GMT Subject: Adding a method to an instance: solution References: Message-ID: In case anyone is wondering: import new ? def newMethod(self): ? ? ?# whatever ? f.newMethod = new.instancemethod(newMethod, f, f.__class__) Thanks to Paul Foley on this one and thank you all for the advice. Regards, -- <=====================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. Website: http://www.eevolved.com Public key: http://eevolved.com/bcm.pk <=====================================> "To say that the mind is "just molecular machines" is like saying that the Mona Lisa is "just dabs of paint". Such statements confuse the parts with the whole, and confuse matter with the pattern it embodies. We are no less human for being made of molecules." -- K. Eric Drexler From hamish_lawson at yahoo.co.uk Tue Mar 27 11:49:04 2001 From: hamish_lawson at yahoo.co.uk (=?iso-8859-1?q?Hamish=20Lawson?=) Date: Tue, 27 Mar 2001 17:49:04 +0100 (BST) Subject: Why not Tcl/Tk? Message-ID: <20010327164904.14603.qmail@web208.mail.yahoo.com> After using Tcl on a project for a year, I found its biggest flaw to be its relative lack of support for high-level data structures. While Tcl does have an associative-array structure, it is hard work to make nested structures using it. In addition I missed decent OO support. There is an add-on OO package for Tcl; but because it's not a standard part of Tcl, not many other Tcl libraries make use of it. Compare this with Python, where f.read() could be reading from any kind of object that supports the read protocol - a disk file, a pipe to a process, an in-memory file, a compressed file, a URL connection, or a user-defined object. Hamish Lawson ____________________________________________________________ Do You Yahoo!? Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk or your free @yahoo.ie address at http://mail.yahoo.ie From fredrik at pythonware.com Tue Mar 20 16:17:32 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 20 Mar 2001 21:17:32 GMT Subject: File Descriptor Modes References: Message-ID: O'Rourke Clodagh wrote: > Does anyone where I would find a summary of the different > modes it is possible to open a file descriptor in? how about the library reference, under builtin functions? http://www.python.org/doc/current/lib/built-in-funcs.html => open summary: "r" opens for reading, "w" opens for writing (zapping an existing file), and "a" opens for appending. add a "+" to open for reading and writing (use "r+" to update an existing file), and add a "b" to open in binary mode. Cheers /F From emile at fenx.com Fri Mar 16 23:26:26 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 16 Mar 2001 20:26:26 -0800 Subject: ZPT, a next-generation template technology References: <98ufbu$kkh$1@uranium.btinternet.com> <98ujtv$dcv$1@panix3.panix.com> Message-ID: <98up78$3moic$1@ID-11957.news.dfncis.de> "Aahz Maruch" wrote in message news:98ujtv$dcv$1 at panix3.panix.com... > In article , > Martien Verbruggen wrote: > >On Sat, 17 Mar 2001 01:43:50 -0000, > > Hamish Lawson wrote: > >> > >> * Zope is a leading open-source web application server and content- > >> management framework, written in Python by Digital Creations. > > > >So why did you post it to cll.perl.misc and cl.java? At least alt.php is > >slightly relevant to this, although you might piss them off as well. I > >don't know what their policy on offtopic posts is. > > > >However, cl.perl.misc gets enough offtopic crap as it is. Don't post > >future announcements here. > > Ah, the friendliness of Perl programmers that we've all come to know and > love. > -- > --- Aahz <*> (Copyright 2001 by aahz at pobox.com) > Especially now when Zope is supporting Perl... Emile van Sebille emile at fenx.com From cce at clarkevans.com Tue Mar 20 21:17:18 2001 From: cce at clarkevans.com (Clark C. Evans) Date: Tue, 20 Mar 2001 21:17:18 -0500 (EST) Subject: Yet Another PEP: Query Protocol Interface or __query__ In-Reply-To: <99917n$2jf$1@panix6.panix.com> References: <99917n$2jf$1@panix6.panix.com> Message-ID: On 20 Mar 2001, Aahz Maruch wrote: > Clark C. Evans wrote: > > > > A new built-in method, __query__ is proposed. This method has > > a single argument, an interface protocol identifier, and either > > returns an object supporting the given protocol, or throws an > > unknown exception. > > > > An interface protocol identifier is a lower-case string having > > a reverse DNS host name string: TLD '.' DOMAIN ['.' NAME ]* > > Where TLD is a top level domain such as 'com' or 'uk.co'. DOMAIN > > is a registered name in the given TLD. And one or more optional > > NAME separated by a period. NAME is a sequence of one or more > > alphabetic characters including the dash '-' character. See the > > relevant ITEF specifications for specific details. > > It's not at all clear to me why this domain thing is being suggested. A unique identifier is needed. One could use GUIDS, but I think that this would be less readable and maintainable. > Is there supposed to be some kind of lookup mechanism > associated with it? Yes. I was planning that query(obj,"org.python.example.eggs") would behind the scenes call __query__ on the object obj. This indirection allows for additional "hooks" to be added to the system via another PEP that could perform a wrapping function. See Alex's recent post. > Most importantly, how does one find out what interfaces > an object *does* support? I don't have this need -- so I didn't include it. I suppose we could ammend the proposal to have this functionality. Perhaps obj.__query__() could return a sequence (or better yet a new iterator object). What do you think? > >Example Usage > > > > >>> class EggsOnly: > > def eggs(self,str): print "eggs!" + str > > def __query__(self,protocol): > > if protocol == "org.python.example.eggs": return self > > raise "unknown: " + protocol > > > > >>> class EggsAndHam: > > def ham(self,str): print "ham!"+str > > def __query__(self,protocol): > > if protocol == "org.python.example.ham": return self > > if protocol == "org.python.example.eggs": > > return EggsOnly() > > raise "unknown" + protocol > > This seems to be implying that it is appropriate to return a brand-new > object with no association with the original object. Is that correct? Yes. The __query__ mechansim is vague in this respect, no use to have any artificial limitations. > > Does it make sense to have something like: > > class HamAndEggs: > def __query__(self, protocol): > if protocol.find("org.python.example.ham") == 0: > return self > h = HamAndEggs() > e = h.__query__("org.python.example.ham.eggs") Let me see, a string goes in, and an object comes out. Sure. Looks good to me! Clark From sean at digitome.com Fri Mar 9 16:10:56 2001 From: sean at digitome.com (Sean Mc Grath) Date: Fri, 09 Mar 2001 21:10:56 GMT Subject: XML Module problems References: Message-ID: <3aa93f65.699574094@news.iol.ie> (Tim Rowe) > >So it does! I only noticed that Pyxie (the DOS version on Sean McGrath's >book, not the rpm) broke because: > >a. It couldn't find pyexpat (though evidently xml/parsers/expat.py >manages) and > >b. When I changed pyxie to point to xml.parsers.expat, it found that the >attribute list was a dictionary, not a list. > >The version on the Pyxie site worked, though, and it's rather too >important for me at the moment for me to re-install the broken version to >investigate further! Yes. The original pyexpat used a list for attributes on the start element handler. A later version of pyexpat changed to a dictionary. The code on http://www.pyxie.org was changed to worth with both flavours of pyexpat. Sean From sdementen at hotmail.com Fri Mar 30 04:12:14 2001 From: sdementen at hotmail.com (Sébastien de Menten) Date: Fri, 30 Mar 2001 11:12:14 +0200 Subject: NumPy loop efficiency Message-ID: <3ac44e27$0$16692$73bec57d@news.be.uu.net> Hi, I was wondering if writing the following statement with NumPy arrays z,a,b and c: z = a + b + c translates into one loop like for (i in indices) z[i] = a[i]+b[i]+c[i] or two loops for (i in indices) t[i]=a[i]+b[i] z[i]=t[i]+c[i] And if a[:]=cos(a)+sin(a) creates temporary variables or assigns directly the result (like a[i]=cos(a[i])+sin(a[i]) I guess I have too many optimistic expectations... TX. Seb From tim.one at home.com Sat Mar 24 17:46:55 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 24 Mar 2001 17:46:55 -0500 Subject: New PEP: The directive statement In-Reply-To: Message-ID: [Martin von Loewis] > ... > My point is that even though you can nuke all obsolete future > statements, it might not be desirable to do so - since the module then > become silently incorrect in an older release, instead of outright > failing. Using the tool isn't required. It's a tool I would write because it's a tool *I* would use (I don't care about clinging to old releases in my own code, and indeed am quite keen to get rid of then-useless cruft ASAP). YMMV. > ... > I was asking you to predict the future: Do you think that people > will prefer to write > > if __future__.nested_scopes.getOptionalRelease() >= sys.version_info: > > instead of > > if sys.version_info < (2,1): As explained before, hardcoded version numbers can't be made to work *if* you're interested in writing code that depends on a change's MandatoryRelease (which is just a best guess under any release in which sys.version_info is less than that). > ... > I have really no problem with the format of the _Feature members; I > very much like using tuples for versioning, since it is quite elegant. > My question is whether you think that people will use those computed > version numbers instead of hard-coded ones, when comparing to > sys.version_info. I *expect* that-- just like now --they'll use hard-coded ones, until they figure out that they can't get that to work as intended. Hard-coded version numbers are always a bad idea anyway -- even if "they worked", the *reader* of if sys.version_info < (2,1): hasn't a clue in hell what the true intent of that code is. If the true intent is to key off the presence or absence of nested_scopes semantics, writing a test that *names* nested_scopes is clearly much better. I've never used a hard-coded version number in my entire Python life. Up until now, I've been happy to do things like: import tokenize if hasattr(tokenize, "NL"): # all right! I can make my parsing much faster by using NL. ... else: # bummer! It's a crufty old version of tokenize.py w/o NL. But, in the presence of *incompatible* language changes, it's not at all clear that a "just try it and see whether it works" runtime test is always possible. For example, if the incompatible change is the introduction of a new keyword (like, say, "directive" ), then code attempting to use the new keyword will likely blow up with a SyntaxError under earlier releases, and SyntaxError can't be caught at compile-time (at least not without a layer of obfuscating indirection). So being able to name the changed feature explicitly wins big on that count too. From loewis at informatik.hu-berlin.de Fri Mar 2 09:00:57 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Mar 2001 15:00:57 +0100 Subject: A counter-proposal to __future__ in PEP 236 References: Message-ID: "Fredrik Lundh" writes: > > Even though this looks like an import statement, it is not: instead, > > it changes the meaning of variable binding in the presence of nested > > functions. > > Really? I'd say it imports an alternate compiler, and activates it > for all modules that happens to contain a from __future__ state- > ment. Exactly. That makes it not to be an import statement; an import statement essentially calles __import__, and you cannot arrange it to import compilers. > > directive nested_scopes > > Note that we're not talking optional standard features here, we're > talking untested experimental stuff, on a scale too large to handle > in an ordinary prerelease cycle. I understand that. Then let's call it experimental nested_scopes or directive experimental nested_scopes > __future__ stuff may go away or change, if they turn out to be > a bad idea. If you're easily confused, you shouldn't use them at > all. The specific thing being "imported" (e.g. nested scopes) may go away or change. I read PEP 236 to mean that __future__ is here to stay. > But with your proposal, you make them look like optional features. Is the the keyword that makes them look like that? My proposal is open to picking a different keyword. > That isn't just a bad idea, it makes Python look bad too. Why is that? > Smells like hypergeneralization to me (which is a worse sin than > premature optimization). Source code encodings and experimental > compiler features are two entirely different things. They are similar as source code encoding might also be an experimental feature first. They are also similar > > In this implementation, directive is only considered as a keyword if > > it appears at the beginning of the module > > And you think from __future__ is a hack? Gimme a break. It's a transitional feature to introduce the keyword directive (or whatever it is called). At some point, directive will be a proper keyword, at which time it won't be a hack anymore. At that time, future statements will still be spelled "from __future__ import case_insensitive", and it will still be a hack. There are two unrelated issues here: smooth introduction of nested scopes, and smooth introduction of per-module semantical changes. Apparently, there is no clear way of doing that, so it should be done in a way that causes least confusion and least hackery. Regards, Martin From whisper at oz.net Thu Mar 29 15:33:51 2001 From: whisper at oz.net (Dave LeBlanc) Date: 29 Mar 2001 20:33:51 GMT Subject: CGI XML-RPC (xmlrpccgi.py) demo? References: Message-ID: <9a067f$png$1@216.39.170.247> Isn't Bobo the older name for Zope? Perhaps something named bobo is in an older zope distribution? Regards, Dave LeBlanc On Thu, 29 Mar 2001 16:07:24 +0200 (MET DST), Eugene Leitl wrote: >On Thu, 29 Mar 2001, Fredrik Lundh wrote: > >> sorry, it looks like I misread your original question -- I thought >> you were looking for a way to pass arguments (i.e. do RPC calls) >> to a server process via HTTP and CGI, not that you had to use >> a certain syntax. > >Oh, I can use XML-RPC just fine, as my (apparently quite >buzzword-compliant) company wants to give their products in future a SOAPy >flavour (they kept mishearing me saying SOAP when I was saying Zope ;). I >just thought that CGI XML-RPC would also handle parsing POST/GET >parameters -- well, it would have been too easy then. Sigh. > >I guess I'll have to parse the parameters by hand, and using XML-RPC >at a later stage of the processing pipeline. > >> under XML-RPC, you send XML-RPC requests, not FORMs. see >> http://www.xmlrpc.com for more info. > >Thanks, have been there (though got no T-shirt yet). > >You as others been very helpful. Now if somebody could tell me where I can >get Bobo for Medusa... > > From greg at cosc.canterbury.ac.nz Wed Mar 7 22:45:38 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 08 Mar 2001 16:45:38 +1300 Subject: I come to praise .join, not to bury it... References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> <3AA2F4B3.A7496E76@cosc.canterbury.ac.nz> <97vmoh061p@news2.newsguy.com> <3AA46134.D385208B@cosc.canterbury.ac.nz> <98292h0s0g@news1.newsguy.com> <3AA58BD0.3324C709@cosc.canterbury.ac.nz> <9850ge013ns@news1.newsguy.com> Message-ID: <3AA70062.C3EC318C@cosc.canterbury.ac.nz> Alex Martelli wrote: > > The joiner-dispatch DESIGN *affords* efficiency gains; I still don't see how. You have to dispatch on all the arguments eventually somehow, whether by typeswitch or something else. > And *WHAT* 'standard interface' would apply on the joiner > object, pray? The same one that applies to all the strings being joined, i.e. "make yourself into a string". Yes, yes, I KNOW you want your joiner object to be able to be not just a simple string but some esoteric entity capable of doing anything it wants to any sequence of anything at all. But I don't feel any great desire for that whatsoever. I'm quite happy with the current highly specialised special-case-the-snot-out-of-joining- these-strings meaning of 'join'. And the new design is no better at achieving *that*, as far as I can see. It's just occurred to me that there may be some natural-language ambiguity here in the use of the term "joiner". To me, it's not "the joiner" in the active sense of "the object which performs the computation of joining", but the passive sense of "the object which ends up being in between the other strings". In other words, it's the difference between "pipe joiner" being a person who carries out plumbing work, and a short piece of pipe with threads in each end. > 'Counting' technical advantages is as idiotic as 'counting' > coins as a measure of wealth Sure it is, but the point is that blindly ranking all technical considerations above all aesthetic ones is just as silly. Otherwise we might as well all switch to Perl, which I hear is faster at reading files. :-) > 'comma-separate these values' You do have a point there, sort of, but it still sounds more terse and cryptic than "separate these values with commas", and crypticness is generally not valued much in the Python culture. Also, I don't normally think of the '.' operator as corresponding to a hyphen used that way in English. The Python translation of that to my mind would be comma_separate(these_values) and not comma.separate(these_values) which to me means either "comma, separate these values" or "separate this comma with these values". The former is slightly odd because I'm not used to giving commands to punctuation symbols, and the latter is just plain... what can I say... BACKWARDS! (Yes, there's that word again.) > (Please note that the CSV acronym IS an English one Also interesting to note that it's *not* CJV. Even in English, "comma-join these values" sounds strange, to my ears, anyway. We regularly talk about commas as being separators, but hardly ever as joiners. If I were putting "-" between things, I might say it was a joiner rather than a separator. But even then I wouldn't say "hyphen-join these values", I'd say "hyphenate these values". > The string object and the string module are both in > the Python core, so moving functionality between them > can in no way be considered 'bloating'. Not bloating the core, bloating the string object. The string module may be statically linked in by default, but it could be dynamically linked, or omitted altogether, just by changing the config file. Chances are I'll never want to do that, but it's nice to know that I *could*. I couldn't cut out all the non-essential parts of the string object so easily. I like the idea of objects that concentrate on doing one job and doing it well. In the case of strings, that job is being a repository of characters, not being something that can do everything you can think of that you might possibly want to do to some characters. Yes, that's an aesthetic consideration, but I don't think you can separate technical and aesthetic considerations completely. How much weight you give to a given technical advantage (such as modularity of the core features) is an aesthetic judgement. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From loewis at informatik.hu-berlin.de Sat Mar 24 08:50:37 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 24 Mar 2001 14:50:37 +0100 Subject: PEP 245: Python interfaces References: Message-ID: Michel Pelletier writes: > I'm the author of PEP 245, a framework and syntax for interface objects in > Python. > > http://python.sourceforge.net/peps/pep-0245.html > > It has just recently been made a PEP, and I'd like to solicite some more > input from the community (you). Even though this is quite a long document, it is incomplete. This is probably not surprising since it is the first draft, but to really evaluate, I think a number of details should be added. In order of my preference: - proposal for a concrete syntax. The PEP should provide a detailed specification of the grammar changes, preferably in (A)EBNF or the Grammar/Grammar format. Currently, only a "Syntax Overview" is given; that doesn't answer all possible questions. In particular, the role of the "implements" reserved(?) word is never specified. - detailed description of the contents of the module Interface. For example, Interface.Exception.BrokenImplementation is used but not defined. For the moment, I assume that the proposal has the same definitions as the reference implementation. - a reference implementation that works as a patch to Python. This is probably not needed at the moment, but certainly prerequisite for people to completely evaluate the PEP. I like many aspects of the draft, but a few points should be corrected, IMO: - naming of the Interface package. Few standard modules are in uppercase, and I think this shouldn't be uppercase, either. Instead, I'd prefer a module "interfaces", in analogy to the types module. - packaging. I think the hierarchy is too deep, everything should be contained in the interfaces module (there is not an awful lot of stuff in it, is there?). - exceptions. I think the standard exception hierarchy should be used better, e.g. inheriting from NotImplemented (or directly using that exception) where appropriate. Also, BrokenImplementation seems a bad choice of wording; Smalltalk uses subclassResponsibility to indicate that an abstract method is not implemented. - nesting of interface assertions. Why is it necessary to support implements FooInterface, (BarInterface, (BobInterface, MyClass.__implements__)) Wouldn't it be sufficient (and more consistent with classes) to write implements (FooInterface, BarInterface, BobInterface)+MyClass.__implements__ - Access to fields. I think it is confusing that you won't write Iface.feature, e.g. in interface Iface: def feature(self): "does something" Instead of writing Iface.feature, it appears that you write Iface.getDescriptionFor("feature"). It would be better if attribute access could be used. Regards, Martin From sholden at holdenweb.com Fri Mar 9 09:36:18 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 9 Mar 2001 09:36:18 -0500 Subject: Can anyone recomend a good intoduction to C... References: <3AA5EF59.507F1D91@olsen.ch> <983958878.976344@newsmaster-04.atnet.at> <989cvj$sba$1@panix3.panix.com> <984132875.222868@newsmaster-04.atnet.at> Message-ID: "Werner Schiendl" wrote in message news:984132875.222868 at newsmaster-04.atnet.at... > What's TMTOWTDI, please? > There's another programming language whose name begins with P, whose primary philosophy is demonstrated in the well-known phrase" "There's More Than One Way to Do It" This means that it's more difficult to establish recognisable programming idioms, because for every task there are between three and seventeen ways to accomplish it, and the choice is usually made on efficiency grounds rather than those of program readability. perl's-not-a-bad-language-if-i-don't-have-to-use-it-ly y'rs - steve From bedge at troikanetworks.com Tue Mar 6 13:52:01 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Tue, 06 Mar 2001 10:52:01 -0800 Subject: Clearing history from readline module Message-ID: <3AA531D1.B9AC8CFE@troikanetworks.com> I have two contexts from my interp, regular python CLI and my cmd based interp. I want to maintain separate command line histories for each. I can do a readline.read_history_file, but that appends the current history. How can I reset the readline history data? I tried reload(readline) but that has no effect. TIA, Bruce. From mwh21 at cam.ac.uk Thu Mar 29 19:16:41 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 30 Mar 2001 01:16:41 +0100 Subject: diff lists References: Message-ID: "Tim Peters" writes: > [Michael Hudson] > > Tangentially, does anyone know of any good algorithms for "edit > > distance" between two sequences? E.g. if I have > > > > "abcdef" > > > > and want to get to > > > > "abQUACKcde" > > > > I want to get the answer back "insert 'QUACK' at position 3 and delete > > a character at position 11". > > See std library module difflib.py (new in 2.1). This packages the > SequenceMatcher class from the heart of the Tools/scripts/ndiff.py tool for > easy reuse. Ah yes; I knew about that and thought it was probably too heavy-weight, but admittedly didn't actually try it... [snip] > >>> for tag, i1, i2, j1, j2 in m.get_opcodes(): ... or look close enough to find the get_opcodes methods. I'll give it a whirl. Thanks! M. -- ARTHUR: But which is probably incapable of drinking the coffee. -- The Hitch-Hikers Guide to the Galaxy, Episode 6 From wtanksle at dolphin.openprojects.net Tue Mar 20 16:53:24 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Tue, 20 Mar 2001 21:53:24 GMT Subject: Wrong reasons to enhancing the language References: Message-ID: On Mon, 19 Mar 2001 21:33:07 -0500, Tim Peters wrote: >and-we-really-*need*-a-fifth-group-that-doesn't-agree-with-any-of-the- > others-ly y'rs - tim I'm offended by accurate, fast, or recognisable math. Can we all switch to INTERCAL and leave this Python stuff behind like a bad dream? -- -William "Billy" Tanksley From ws-news at gmx.at Tue Mar 13 04:25:39 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Tue, 13 Mar 2001 10:25:39 +0100 Subject: This math scares me References: Message-ID: <984475826.262977@newsmaster-04.atnet.at> I wonder why 17 digits are used to represent the numbers... Think I can remember the precision of double was 15 to 16 decimal digits (depends on the value) Did I miss something? regards werner Tim Peters wrote in message news:mailman.984458537.14769.python-list at python.org... > [Andrew Koenig] > > I'm curious -- Does Python now follow either the IEEE or the more > > restrictive Scheme rules for floating-point conversion? > > ... > > All aspects of Python fp are inherited from whatever the platform C compiler > and libraries happen to do. repr() conversion to string uses the platform > sprintf's %.17g format; str() conversion %.12g; both are fiddled just a > little to ensure that an exponent or a decimal point (or both) appears. > string->float is a x-platform adventure, since some platforms can't read back > all the C doubles they print (thinking of infinities and NaNs here); Python > inherits that too, whenever it happens. > > it's-all-x3j11's-fault-ly y'rs - tim > > From cribeiro at mail.inet.com.br Wed Mar 28 08:42:51 2001 From: cribeiro at mail.inet.com.br (Carlos Alberto Reis Ribeiro) Date: Wed, 28 Mar 2001 10:42:51 -0300 Subject: types.AnyType - describing interfaces with sequences of types In-Reply-To: <3ac1c5b3_1@goliath.newsfeeds.com> References: Message-ID: <5.0.2.1.0.20010328095224.021b4ec0@mail.inet.com.br> At 02:56 28/03/01 -0800, you wrote: >You get the idea. AnyType above will be eternally happy to be equivelent to >anything you compare it to. Note that you can't do 'IntType is AnyType', >that tells you actual object identity. Now, if you wanted it to only show up >as 'equivelent' to TypeTypes, and not say, strings, (e.g. "string" == >AnyType) you could do a check to make sure what its being compared to is a >TypeType..... My first instinct it was to do something like this. However, it did not work, but because of a dumb mistake of mine :-) I tried again now, and this is the resulting code: class CAnyType: def __cmp__(self, other): return (type(other) != TypeType) def __rcmp__(self, other): return (type(other) != TypeType) AnyType = CAnyType() That was my fault - I was trying to compare the class to IntType, but I need an instance for the code to work. Anyway, I felt that should be a better way to make it, maybe be inheriting from some "UserType" object. However no such object exists. I don't know if "UserType" does not exist because it not make sense, or if it does not exist simply because no one else required it before. The way it is, it's inconsistent, because: >>> type(AnyType) # should return "TypeType" Carlos Ribeiro From agavrilov at home.com Mon Mar 12 21:19:42 2001 From: agavrilov at home.com (Alexander Gavrilov) Date: Tue, 13 Mar 2001 02:19:42 GMT Subject: Extending Python: rewriting a single method in C References: Message-ID: <2tfr6.26915$zV3.1982567@news1.frmt1.sfba.home.com> "Jeff Epler" wrote in message news:slrn9apn8f.382.jepler at potty.housenet... > On 12 Mar 2001 11:13:51 +0000, Jacek Generowicz > wrote: > >I have an object-oriented numerical code written in Python. It has > >come to the stage where the speed of the code is seriously impeding > >progress. Profiling reveals (surprise, surprise) that most of the time > >is spent in only 2 methods. > > > >Is there any way of re-writing just these methods in C ? > > It's easy to write a function in C. Other posters have mentioned references > to documentation about doing this. > > However, you cannot make a builtin function be a method of a class/instance. > Instead, you could write: > > from cmodule import fast_a, fast_b > > class fastKlass(Klass): > def a(self, int1, int2): > fast_a(self, int1, int2) > def b(self, int1, int2): > fast_b(self, int1, int2) > Actually, you can write the following: class fastKlass(Klass): a = fast_a b = fast_b Whenever the program calls 'a' or 'b' methods, 'fast_a' or 'fast_b' get called instead. And you'll eliminate of 'double-calling' overhead. I didn't check it with functions from C extension module, but it works with plain Python functions. The following example works for me: def func1(self): print self.a1 def func2(self,somearg): print somearg+self.a2 class C: def __init__(self): self.a1 = 'attr1' self.a2 = 'attr2' meth1 = func1 meth2 = func2 c = C() c.meth1() c.meth2('Some string ') Alexander From edcjones at erols.com Tue Mar 20 14:18:38 2001 From: edcjones at erols.com (Edward C. Jones) Date: Tue, 20 Mar 2001 14:18:38 -0500 Subject: Small bug in PIL Message-ID: <3AB7AD0E.566C29F7@erols.com> In the PIL (Python Imaging Library) source code file "Image.py", line 937, in function "merge", the error message is incorrect. Here is the code: for im in bands[1:]: if im.mode != getmodetype(mode) or im.size != bands[0].size: raise ValueError, "wrong number of bands" Thanks, Ed Jones From fredrik at pythonware.com Wed Mar 21 12:23:44 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Mar 2001 17:23:44 GMT Subject: Regular expressions and non-standard character set References: <0XMt6.2503$4N4.321668@newsc.telia.net> Message-ID: I wrote: > are you sure? turns out I wasn't sure what I were doing... "(?L)\b" and "(?L)\B" doesn't work properly in 2.0 and 2.1b1, under non-C locales. \W and other locale-dependent operators work as expected, though. this will be fixed in 2.1b2 (out soon) and hopefully also in 2.0.1 (out when it's done). to work around this problem, use "pre" instead of "re". Sorry /F From shaleh at valinux.com Mon Mar 12 15:31:08 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Mon, 12 Mar 2001 12:31:08 -0800 (PST) Subject: continue/else functionality In-Reply-To: Message-ID: > > > for line in f.readlines(): > > datalist = string.split(line) > if datalist[0][0] == 1: > continue > elif datalist[0][0] == 0: > break > > ## Do a bunch of string manipulation here... > why do read the first line, check it, if it works, go into the loop. line = f.readline() if line[0][0] == 1: for line in f.readlines(): # do things From josh at pobox.com Sun Mar 11 07:02:49 2001 From: josh at pobox.com (Joshua Spoerri) Date: Sun, 11 Mar 2001 07:02:49 -0500 Subject: supporting asyncronous messages In-Reply-To: ; from loewis@informatik.hu-berlin.de on Wed, Mar 07, 2001 at 10:48:32AM +0100 References: Message-ID: <20010311070249.A69096@acis.mc.yu.edu> On Wed, Mar 07, 2001 at 10:48:32AM +0100, Martin von Loewis wrote: thank you for the pointer. i thought about it a little more, and for this particular application, i'd like to use tristate logic to automatically wait for only the relevant events. idea being that if an expression evaluates to "unknown", it should block, but if it evaluates to true or false it should continue. it means that you only need to worry about a single expression to control flow and wait behaviour. can python overload the logical operators, if not, are there any plans to enable it to? do you see any gotchas in this approach? thanks, josh From emile at fenx.com Sat Mar 10 08:15:11 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 10 Mar 2001 05:15:11 -0800 Subject: How to efficently build a nested dictionary References: <3AAA2042.E69A53FC@gmx.de> Message-ID: <98d9f1$1hopn$1@ID-11957.news.dfncis.de> Any particular reason not to do: ky = (dir, year, month, day) p_ttl = traffic.get(key,0) traffic[ky] = p_ttl + bytes -- Emile van Sebille emile at fenx.com ------------------- "Carsten Gaebler" wrote in message news:3AAA2042.E69A53FC at gmx.de... > Hi there! > > I wrote a script for FTP traffic accounting, i.e. for each "top level" > FTP directory it counts the bytes transferred per day. The traffic is > stored in a dictionary that has the following structure: > > traffic = {dir: {year: {month: {day: 42}}}} > > for several dirs, years, months, days, of course. > > While parsing the FTP log files I am building up the dictionary in this > way: > > if not traffic.has_key(dir): > traffic[dir] = {year: {month: {day: bytes}}} > elif not traffic[dir].has_key(year): > traffic[dir][year] = {month: {day: bytes}} > elif not traffic[dir][year].has_key(month): > traffic[dir][year][month] = {day: bytes} > elif not traffic[dir][year][month].has_key(day): > traffic[dir][year][month][day] = bytes > else: > traffic[dir][year][month][day] += bytes > > > Now, this looks a bit clumsy to me, especially if I consider > you-know-which-language-I-mean which would simply allow to write > $traffic{$year}{$month}{$day} += $bytes; > > Any ideas how to do this more elegantly? > > Regards > Carsten. From aahz at panix.com Thu Mar 15 15:18:02 2001 From: aahz at panix.com (Aahz Maruch) Date: 15 Mar 2001 12:18:02 -0800 Subject: Dynamic append in a dictionnary object ... References: <3ab11de3$0$389$446d705c@news.skynet.be> Message-ID: <98r81q$nts$1@panix3.panix.com> In article <3ab11de3$0$389$446d705c at news.skynet.be>, Furax wrote: > >I'm pretty new to Python. >I cannot figure out, reading the documentation, how I can dynamicaly add a >new pair in a dictionnary ? >>> d = {} >>> d[1] = 'foo' >>> d {1: 'foo'} >>> d['bar'] = 20 >>> d {1: 'foo', 'bar': 20} I suggest you work through the tutorial at http://www.python.org/doc/current/tut/tut.html -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "The overexamined life sure is boring." --Loyal Mini Onion From jepler at inetnebr.com Tue Mar 27 21:38:28 2001 From: jepler at inetnebr.com (Jeff Epler) Date: Wed, 28 Mar 2001 02:38:28 GMT Subject: close(), exceptions and problems References: <99i3j7$lqr$1@news.cybercity.dk> Message-ID: On 26 Mar 2001 20:43:13 -0500, David Bolen wrote: >Note that close() is often is the point at which buffered data is >flushed to a file, so there are a variety of ways in which that can >fail (I/O error, out of disk space, etc...) which will cause the >close() to fail. GNU Libc's documentation is fairly explicit about this: The normal return value from `close' is 0; a value of -1 is returned in case of failure. The following `errno' error conditions are defined for this function: `EBADF' The FILEDES argument is not a valid file descriptor. `EINTR' The `close' call was interrupted by a signal. *Note Interrupted Primitives::. Here is an example of how to handle `EINTR' properly: TEMP_FAILURE_RETRY (close (desc)); `ENOSPC' `EIO' `EDQUOT' When the file is accessed by NFS, these errors from `write' can sometimes not be detected until `close'. *Note I/O Primitives::, for details on their meaning. Strangely enough, the section 2 manpage omits this detail and documents the only errno value of close as EBADF. Jeff From pbrian at demon.net Mon Mar 19 11:29:19 2001 From: pbrian at demon.net (Paul Brian) Date: Mon, 19 Mar 2001 16:29:19 -0000 Subject: newbie - infinite loop References: <985012513.18971.0.nnrp-12.c1c3e154@news.demon.co.uk> Message-ID: <985019137.15846.0.nnrp-09.c1c3e154@news.demon.co.uk> All, Thank you for such quick responses. I shall take it as final that a for loop is expandable if the condition is mutable. I just thought I might have missed something else. And thank you all for pointing out the deliberate :-) mistake over matching and not matching "Remco Gerlich" wrote in message news:slrn9bc8et.95q.scarblac at pino.selwerd.nl... > Paul Brian wrote in comp.lang.python: > > I have solved the opriginal problem but am left with a serious question. > > > > Before I discovered the keywords in and not in, I tried to count unique > > instances of names in a file. > > > Your code belows does the opposite: if it *is* already in the list, append > it once more. And since you change the list you're currently looping over > (which is a mortal sin, etc) you get an infinite loop. > > > It's a list. It's mutable. It's not a "for condition", for just tries to get > new elements from the list until that gives an error, then the loop is > finished. If you append to the list during the loop, the new elements are > also visited. If you add or delete things in the middle of the list, > anything might happen. > > Do not taunt happy fun for loops. Do not change lists you are looping over. From quinn at riyal.ugcs.caltech.edu Thu Mar 15 04:55:43 2001 From: quinn at riyal.ugcs.caltech.edu (Quinn Dunkan) Date: 15 Mar 2001 09:55:43 GMT Subject: Process details References: Message-ID: On Mon, 12 Mar 2001 15:22:16 -0800, Timothy Grant wrote: >Hi all, > >I hope everyone is enjoying there first week back after the >events of P9. > >I need to create a list of processes and process information. I >have created a class that contains much of the information in >/proc/'pid'/status. > >It works quite well, however, it takes about four seconds to >populate a list of 90 procs. This seems a bit long. Is there a >faster way to get ahold of the information than reading /proc? You don't say what OS you're using, but from the sig I'm guessing Linux. In Linux, /proc is the official interface. /bin/ps and friends use it. Try 'cat /proc/[0-9]*/status >/dev/null'. If that takes less than four seconds, then the slowdown is likely in your code, not /proc. On this linux machine, it takes a few hundredths of a second for several hundred procs. From moshez at zadka.site.co.il Tue Mar 27 17:26:48 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Wed, 28 Mar 2001 00:26:48 +0200 Subject: Threading legality/morality In-Reply-To: <99qoje$o6q$1@troll.powertech.no> References: <99qoje$o6q$1@troll.powertech.no>, <99nnbv$phs$1@panix6.panix.com> <99qa3v$6e0$1@panix6.panix.com> Message-ID: [Aahz] > There is a misfeature in urllib such that the standard FancyURLOpener > class prompts for input if it gets an HTTP 401 (authorization needed). > You probably pressed ENTER. [Syver Enstad] > Think so yes, how can it be fixed? I am pretty well versed in python but a > pointer could be nice so I didn't use quite so much time on it. 1. No it can't be fixed. (Backwards compat.) 2. It doesn't need to be fixed -- urllib2 works much better Python 2.1 has urllib2 with documentation. Find a howto in http://www.lerner.co.il/~moshez/urllib2-howto.tex. I'll try to find time to integrate it into the Python howto project. -- "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than Python? looking for someplace else to grab power."|YODA: No...no... no. Quicker, -- Wichert Akkerman (on debian-private)| easier, more seductive. For public key, finger moshez at debian.org |http://www.{python,debian,gnu}.org From m.hadfield at niwa.cri.nz Sun Mar 4 16:10:55 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Mon, 5 Mar 2001 10:10:55 +1300 Subject: Performance when working directory is slow network drive References: <983411179.898268@clam-ext> <983480535.813990@clam-ext> <7uIn6.16286$Qb7.2659111@newsb.telia.net> Message-ID: <983740313.603627@clam-ext> "Fredrik Lundh" wrote in message news:7uIn6.16286$Qb7.2659111 at newsb.telia.net... > Mark Hadfield wrote: > > 1. Why having the current directory in the search path affects the import > > time for the os module much more than it does for other modules I tested > > (like string). Is this because os is a package? > > try running the interpreter with -vv (very verbose) might > give you additional clues: > > python -vv -c "import os" > > (look for "trying" messages) Yes. It's clear from the speed at which the output appears on the screen that the delays occur during the following operations # trying os.pyd # trying os.dll # trying os.py # trying os.pyc then later when it tries the same thing with ntpath, stat and UserDict. Thank you. --- Mark Hadfield m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield National Institute for Water and Atmospheric Research From mix77 at usa.net Fri Mar 2 03:55:17 2001 From: mix77 at usa.net (Mix) Date: Fri, 02 Mar 2001 10:55:17 +0200 Subject: CGI & Python (error) Message-ID: <3A9F5FF5.34E01148@usa.net> When accessing the script I get the error: File "getdate2.py", line 12, in ? day=form["day"].value File "/usr/lib/python1.5/cgi.py", line 907, in __getitem__ raise KeyError, key KeyError: day The script works from the command line. My problems is: the script I am trying to run is based on another one. This other script works. I can't figure out the what is causing the problem as the 2 scripts are identical in every aspect execpt for 1 variable. Both scripts are run in a page which has all the required parameters passed to it. Help. Please... I hope I'm understandable! From see.signature at bottom.of.msg Fri Mar 2 15:30:35 2001 From: see.signature at bottom.of.msg (Thomas Burns) Date: 02 Mar 2001 20:30:35 GMT Subject: Stream interfaces References: Message-ID: <97ovtb$jjk@dispatch.concentric.net> "Dave Harris" wrote in message > [...] > I expect we need more delegation. The main thing is to > separate out the formatting front-end, which needs a rich and probably > varied API, from the data-sink back-end which can use a much smaller > and more uniform API. Then we can do buffering etc by means of > pluggable adaptors, and construct pipelines like: > XmlStream -> CompressionAdaptor -> SocketStream You can get one implementation of this from the VisualWorks Freebies site at http://smalltalk.iwarp.com. The free package "Streams & Bytes" contains a generic StreamWrapper class. I got sick of creating my own streams, then realizing that there wasn't a good place to hang them. The StreamWrapper has been used in some of the other free packages. For example, the Zlib (zip-style compression, for those that don't know) package subclasses StreamWrapper to do compression and decompression on the fly via streams. There is also a ProgressReadStream that, when used in conjunction with the WidgetExtensions, can open a progress bar showing progress reading through fixed-length streams (such as file streams or internal streams). > This is roughly the approach of the Java library. As far as I know it > works reasonably well. Don't get me started. :-) This is what Java provides through the availability of the BufferedWriter and BufferedOutputStream. But in Java these (string-writing vs. byte-writing) are 2 separate hierarchies. On top of that Writer and OutputStream are abstract classes, not interfaces. So you must root from one of these hierarchies, no matter how badly they fit with your implementation. In all, I would say that providing the Buffered* classes is a good thing, but it's no great shakes and there are other significant problems magnified by typing issues. Give me Smalltalk any day. t -- Thomas Burns thomas.a.burns at usa.net VisualWorks Freebies are available at http://smalltalk.iwarp.com From lrl at ou.edu Thu Mar 29 18:00:25 2001 From: lrl at ou.edu (Luke L) Date: Thu, 29 Mar 2001 17:00:25 -0600 Subject: Python GUI with Swing References: <001e01c0b812$43f00760$340210ac@winson> Message-ID: <3AC3BE89.3F95C8DC@ou.edu> > If speed is an issue, don't use Swing. Swing is quite slow (from > experience) as it is implemented entirely in Java. If you only need > to support a single platform you can use Jython+Swing+JNI+C using JNI > to connect Java to the speed critical stuff written in C. Otherwise I > would recommend looking at other toolkits such as PyGTK and wxPython. Yeah tell me about it...lightweight components are the wrong way to go.... Awt would be a step faster, but that's still using Java of course From fredrik at pythonware.com Thu Mar 1 13:40:36 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 01 Mar 2001 18:40:36 GMT Subject: writing a C function to manipulate python lists References: Message-ID: Michael Vanier wrote: > I've been programming in python for many years but have never had to solve > this particular problem. I would like to write a short C function that will > be part of a python-callable module. The function will receive two python > lists as arguments. Currently I do this in python, but my code uses this > function very heavily and it's the major speed bottleneck in the code. The > hope is that the C function will be much faster than iterating through the > lists in python (which may not be true, but I'd like to see for myself). > > If anyone has some code lying around that does something like this, could > they pass it on to me? there's plenty of code in the Python source distribution... searching for PyList and/or PySequence should help. here's one example, based on SRE's compile function: static PyObject * myfunc(PyObject* self_, PyObject* args) { int i, n; /* accept a single list object */ PyObject* code; if (!PyArg_ParseTuple(args, "O!", &PyList_Type, &code) return NULL; /* get the size */ n = PyList_GET_SIZE(code); /* loop over the members */ for (i = 0; i < n; i++) { int v; PyObject *o = PyList_GET_ITEM(code, i); v = PyInt_AsLong(o); if (v == -1 && PyErr_Occurred()) goto oops; /* not a number */ printf("%d\n", v); } ... } to handle any kind of sequence, use the PySequence abstract API instead of the PyList API. Cheers /F From prairiesasquatch at crosswinds.net Thu Mar 15 22:36:35 2001 From: prairiesasquatch at crosswinds.net (Kevin Russell) Date: Thu, 15 Mar 2001 19:36:35 -0800 Subject: Spreadsheet-like array in Tkinter?? References: <3AB021B0.3F3DCA1F@att.net> Message-ID: <3AB18A43.5BDC8B22@crosswinds.net> An HTML attachment was scrubbed... URL: From ransen_spam_me_not at nemo.it Sat Mar 3 12:09:52 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Sat, 03 Mar 2001 17:09:52 GMT Subject: Bug in Py_Finalize() ? References: Message-ID: <3aa10f5b.459867@news.newsguy.com> On Sat, 3 Mar 2001 04:54:01 -0500, "Tim Peters" wrote: >You didn't give a complete program so it's impossible for me to say whether >your problem is fixed. I did put your loop in an extension module and >boosted the loop limit to 1000. No problem under Windows Python 2.1b1, under >either release or debug builds. That was the complete program, I had narrowed it down that far to find out what was crashing. I downloaded the Windows installer for 2.1b1 but there does not appear to be any debug libraries... -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From aleaxit at yahoo.com Sat Mar 10 17:44:14 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 10 Mar 2001 23:44:14 +0100 Subject: Can anyone recomend a good intoduction to C... References: <989mbk$24nuv$1@fido.engr.sgi.com> <98auhn0270j@news2.newsguy.com> <98dpoe12ckn@news1.newsguy.com> Message-ID: <98eamb02ug2@news1.newsguy.com> "Pearu Peterson" wrote in message news:Pine.LNX.4.21.0103102137300.7964-100000 at kev.ioc.ee... > > On Sat, 10 Mar 2001, Alex Martelli wrote: > > > "Expected" is correct; it's a social issue, NOT a technical one -- > > technically, C++ is a better choice for most Python extensions &c [snip] > I must say that earlier I had also an opinion that no matter what I would > not use C++ for extending Python --- the reasons of my opinion are > now irrelevant after I learned about Boost. Though I had a gap about 2 > years of programming in C++, interfacing a C++ library to Python using > Boost was so easy that I caught up with C++ and started to use it on Glad to see somebody seconding my opinion -- particularly somebody who was so adamantly set _against_ C++ before the Boost experience (remember how astonished you were that I even _considered_ C++ for gmpy...? It would be done by now, and well on its way to a second and richer release, if I had chosen C++ rather than C...:-). > In conclusion, extending Python with C++ libraries in connection with > Boost works very fine on Linux **if** you have plenty of memory available > in your computer for compilation. At least, that's my experience. Very good point. Yes, depending on your compiler, building template- rich C++ libraries can be a problem, if you're memory-scarce. On my old home Win98 machine, with VC++6, I get by with 64M without too many tears -- but for a newer WinME box for my girlfriend I insisted on 128M, and my own sooner-or-later Athlon/Linux box will have 256M for sure (fortunately, that IS dirt-cheap today, _if_ one doesn't aim at DDR or even Rambus...!-). Alex From shaleh at valinux.com Wed Mar 28 11:16:10 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Wed, 28 Mar 2001 08:16:10 -0800 (PST) Subject: list vs tuple In-Reply-To: Message-ID: On 28-Mar-2001 deadmeat wrote: > Whats the practical difference between a list[] and a tuple() ? > > A tuple seems to be a very basic list, so unless it's faster, what's the > point of it? > As others point out they are immutable. This can lead to self documenting code. dir_list = ('/path', '/foo/bar', '/baz/bat/files') dir_list shouldn't change and this documents it. From qrczak at knm.org.pl Sat Mar 24 09:38:24 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 24 Mar 2001 14:38:24 GMT Subject: static methods References: Message-ID: Fri, 23 Mar 2001 14:27:42 -0800, Paul Prescod pisze: > Probably because they are simply not neccessary. > > def _static(): > XXX.foo=bar > return XXX.foo > > class Class: > staticmethod = _static > ... It doesn't work. Try to call it. The fact that you are not the first person who thinks it works suggests that the current Python's solution is not ideal :-) -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From just at letterror.com Tue Mar 13 10:34:14 2001 From: just at letterror.com (Just van Rossum) Date: Tue, 13 Mar 2001 16:34:14 +0100 Subject: main in mac? References: <20010313095339.19264.00000243@ng-dh1.aol.com> <3AAE3A1A.56124135@letterror.com> Message-ID: <3AAE3DCA.8DBE482D@letterror.com> I wrote: > Hope this helped, Thank you Netscape, for posting this three times. I keep forgetting that an error doesn't neccesarily mean failure... Sorry. I think I'll go back into lurk mode. Just From dyoo at hkn.eecs.berkeley.edu Mon Mar 12 08:51:47 2001 From: dyoo at hkn.eecs.berkeley.edu (Daniel Yoo) Date: Mon, 12 Mar 2001 05:51:47 -0800 (PST) Subject: I have no idea In-Reply-To: Message-ID: > In basic you use to be able to do this: > 10 print "Hello World" > 20 goto 10 In Python, you can write an infinite loop like this: ### while 1: print 'Hello World' ### Python follows the 'structured programming' philosophy and doesn't support arbitrary goto's. If you've programmed a lot in basic, this will probably take some getting used to. From nomad*** at ***freemail.absa.co.za Wed Mar 14 09:06:54 2001 From: nomad*** at ***freemail.absa.co.za (nomad) Date: Wed, 14 Mar 2001 14:06:54 GMT Subject: [Q]: How can I get the logged in users username on Win32? Message-ID: <3aaf7ab4.3152221@news.is.co.za> Howzit, After searching through the Python Docs, I found that on Un*x I could use getpass.getuser(), but there is no equivalent for the Win32 platform. In other words, how can I get the username in Windows? As a side note, how can I enable Windows Scripting Host support for python - there is mention of python in the original WSH docs - and if I can use python scripts in WSH how would I call the built-in Wscript. TIA nomad From warren-postma at home.com Fri Mar 23 14:38:13 2001 From: warren-postma at home.com (Warren Postma) Date: Fri, 23 Mar 2001 19:38:13 GMT Subject: Python Script to dial a VPN connection, automate VPN routing table updates. Message-ID: Sorry for the nearly-off-topic nature of this post, but .... I work from home now, and there's something in Windows 2000 that's annoyingly manual: I have a permanent internet connection via @home cable modem, and I "dial" through that to create a VPN connection to the office. The problems are two: (1) Windows won't accept or save my userid, password and the domain name, so I have to enter it manually. (2) After connecting, I have two default gateways in my routing tables (ROUTE PRINT) and I need to update it so only the traffic that is destined to the office goes through that interface. The IP addresses I get given are different each time, making a batch file insufficient, so voila, a perfect use for python. So after solving #2 above in Python, I wondered, does anyone know how, in Python win32 extensions, one might dial an RAS connection, and if it's possible to do so through the win32 API somewhere or through COM? Then I could solve #1 above as well. Anyone else think this might make a nice little Python applet if I build in some more VPN/RAS stuff and maybe even Gui-fy it a bit in wxPython or tkInter. Warren Postma From lsommerer at ltec.net Fri Mar 2 23:00:40 2001 From: lsommerer at ltec.net (L Sommerer) Date: Fri, 02 Mar 2001 22:00:40 -0600 Subject: A counter-proposal to __future__ in PEP 236 References: <97ll2u02qmp@news2.newsguy.com> <3A9FBE5C.95615241@sewardweb.com> Message-ID: <3AA06C68.5D655E09@ltec.net> > > I should also point out that the "from __future__ import..." is also > > confusing to a newbie, but others have said that already. > > And that's exactly as it should be: you shouldn't use the experimental > feature(s) if you're a newbie :) Yes, but we still look at your code, and we still try to make it fit into our model (however limited it may be) of how python's syntax works. Lloyd Sommerer From claird at starbase.neosoft.com Fri Mar 23 15:42:33 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 23 Mar 2001 14:42:33 -0600 Subject: newbie question References: <73125560B5E4EF16.CC3FC0DB3FD693E3.4AF0ACCBD2EFF29B@lp.airnews.net> <99fll8$996$1@rex.ip-plus.net> Message-ID: <84EF7ECA6B21860E.2BACA551CEE41AA7.AE240BE7DBA69E93@lp.airnews.net> In article , Moshe Zadka wrote: >On 23 Mar 2001, claird at starbase.neosoft.com (Cameron Laird) wrote: > > >> That's a lot more exciting >> for them than hearing that, with a mere week or two of >> study, they can install Zope on their own. > >That's pure FUD. Zope takes time >to install, about 5 minutes to compile and 30 seconds to startup. And >using it is not necessarily harder then learning CGI. I'm only mentioning >it because "Zope is hard" seems to be a commonly uttered phrase, one that >I believed until I actually had to get a Zope server up and running. > >Hooking up Zope to Apache (say, with reverse proxying) is very easy, though >it does use some Apache configuration knowledge. This can all be learned >in a day, and anyone seriously using Apache needs to know about this >stuff. . . . There are a lot of people who are frivolously using Apache. That is, I run into a lot of people who aren't equipped to install Apache on their own, let alone Zope. They can *buy* Apache, though (more precisely, its service equivalent), and they want to know how far that'll take them, without any more "programming" or system administration on their part. What use could someone uncomfortable with Zope installation pos- sibly have with Python as a programming language? Well, it's a surprise to me, too, but often the answer is, "quite a lot." Moshe, you're right in all you write here. I've seen quite a few folks, though, for whom it's all irrelevant. They imagine themselves to have better things to do with a day than learn reverse proxying (for example). -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From bos at hack.org Sat Mar 31 07:23:04 2001 From: bos at hack.org (Rikard Bosnjakovic) Date: Sat, 31 Mar 2001 14:23:04 +0200 Subject: Couple of simple questions References: <3ac4854a.1170697@news.is.co.za> Message-ID: <3AC5CC28.3796F8B2@hack.org> nomad wrote: > Does anybody know what size python variabel types are? > Eg. how many bytes is and integer? What about a long? I have Table 3.9 in "Python Essential reference" by Beazley: Type (built-in) Size Integer 12 bytes Long Integer 12 bytes + (nbits/16 + 1)*2 bytes Float 16 bytes Complex 24 bytes List 16 bytes + 4 bytes for each item Tuple 16 bytes + 4 bytes for each item String 20 bytes + 1 byte per character Dictionary 24 bytes + 12*2^n bytes, n = log2 (nitems)+1 Class Instance 16 bytes + a dictionary object Xrange object 24 bytes -- Rikard Bosnjakovic - http://a214.ryd.student.liu.se/cv/ - ICQ: 1158217 Anyone sending unwanted advertising e-mail to my address will be charged $250 for network traffic and computing time. By extracting my address from this message or its header, you agree to these terms. From aahz at panix.com Fri Mar 9 21:48:42 2001 From: aahz at panix.com (Aahz Maruch) Date: 9 Mar 2001 18:48:42 -0800 Subject: how to make a function thread-safe ? References: <3AA94A6A.50138001@noaa.gov> <98bl7n$cn6$1@panix2.panix.com> Message-ID: <98c4ma$feo$1@panix2.panix.com> >From robinjim at earthlink.net: > > So, I have probably been making things overly complicated for myself since I > do not write functions that use global data. I assume such a function is > also thread-safe if it treats its parameter list as read-only (probably as > any "good" function should). Correct? Exactly. > If you have an opportunity to respond, please feel free to respond to the > group rather than me personally -- whichever you prefer. I generally prefer responses to public posts stay in public, so that other people can learn. -- --- Aahz (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "..., and some of you may regard all women as evil traps that exist only to tease, torture, and suck out your very soul." --DrMax From u263183593 at spawnkill.ip-mobilphone.net Wed Mar 7 01:31:55 2001 From: u263183593 at spawnkill.ip-mobilphone.net (u263183593 at spawnkill.ip-mobilphone.net) Date: Wed, 07 Mar 2001 06:31:55 GMT Subject: Retrofitting 2.1b1 "No buffer space available" fix to 2.0 Message-ID: When using multiple threads, httplib, and timeoutsocket.py from the Vaults of Parnassus under Win98SE, I get numerous "No buffer space available" IOError exceptions. This problem is fixed in the 2.1beta1 release. Is it possible to retrofit 2.0 with the fix? I'd rather not wait for 2.1 to become official. I tried to rebuild 2.0 using the 1.30 revision of socketmodule.c from sourceforge which fixes "closing sockets was not thread-safe", but I still got the same IOErrors. Does anyone know which other changes might have fixed the problem? socket.py didn't seem to have any relevant changes. -- Sent by bortg from hotmail piece from com This is a spam protected message. Please answer with reference header. Posted via http://www.usenet-replayer.com/cgi/content/new From ngps at madcap.dyndns.org Mon Mar 12 10:14:52 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 12 Mar 2001 15:14:52 GMT Subject: Packages, modules and exceptions Message-ID: <98ip5c$397$1@clematis.singnet.com.sg> Hi, In M2Crypto, I have the following (abridged) directory structure: M2Crypto/ SSL/ __init__.py Connection.py Within M2Crypto/SSL/__init__.py, I have the following: class SSLError(Exception): pass Now, various parts of M2Crypto/SSL/Connection.py wish to raise SSLError when it is appropriate to do so. For M2Crypto/SSL/Connection.py to get access to SSLError which is defined in M2Crypto/SSL/__init__.py, it (Connection.py) contains the following: SSLError = __import__('M2Crypto.SSL', globals(), locals(), 'SSLError').SSLError This works, but looks kinda funny. An equivalent(?) is: SSLError = getattr('M2Crypto.SSL', globals(), locals(), 'SSLError'), 'SSLError') Better, but still doesn't look very nice. What's the best way to do this? TIA for any input. Cheers. -- Ng Pheng Siong * http://www.post1.com/home/ngps From scarblac at pino.selwerd.nl Tue Mar 27 04:27:00 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 27 Mar 2001 09:27:00 GMT Subject: math.choice attribute error References: Message-ID: iddwb wrote in comp.lang.python: > > from the ref man math.choice says it takes a sequence object and returns a > random choice. perfect for my needs. the follow happens: > > >>> import math > >>> list = ['apple', 'orange', 'pear'] > >>> print math.choice(list) > Traceback .... > attributerror: choice > > what have I missed? You're confused, the function is in random, it's random.choice. -- Remco Gerlich From aahz at panix.com Thu Mar 15 13:18:30 2001 From: aahz at panix.com (Aahz Maruch) Date: 15 Mar 2001 10:18:30 -0800 Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> <98qv55$f5d$1@news.udel.edu> Message-ID: <98r11m$2pm$1@panix6.panix.com> In article , Grant Edwards wrote: > >If that's good enough for you, then go ahead and use FP. > >But, the people who actually write financial SW for a living seem to >think it's not good enough. You would have to talk to one of them to >find out the exact situations where FP proved insufficient. But, I >don't think anybody would have gone to the trouble of implimenting BCD >math just for the fun of it. OTOH, I guess I know people who would do >stuff like that just for fun. Don't forget, most of these arguments took place pre-754. It might be interesting to revisit the whole discussion from scratch in light of the advances in computing power etc. -- --- Aahz <*> (Copyright 2001 by aahz at pobox.com) Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "The overexamined life sure is boring." --Loyal Mini Onion From NoSpam at NoSpam.com Sun Mar 4 12:33:13 2001 From: NoSpam at NoSpam.com (Tom) Date: Sun, 04 Mar 2001 17:33:13 GMT Subject: how to get the last interactive command enetered References: Message-ID: "Martin von Loewis" wrote in message news:j4zof17qp3.fsf at informatik.hu-berlin.de... > "Tom" writes: > > > > No. Once the code is executed, the source code is dropped. All you can > > > get at is the binary code. > > > > But when I catch a 'call' trace event the code has not been executed. I > > believe that it has been parsed and compiled but not executed (till I get > > the 'return' trace event). > > Yes, it has been parsed and compiled, the result of which was a code > object (which in turn was put into a function object). After that, the > source code, and the abstract syntax tree, is discarded (actually the > source code is discarded in the process of parsing). > > The code object has a file name in it and line numbers, that's all > that's left from the source. I was afraid of that. Thanks, Tom. > Regards, > Martin From tim.one at home.com Sat Mar 24 02:35:50 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 24 Mar 2001 02:35:50 -0500 Subject: New PEP: The directive statement In-Reply-To: <5.0.2.1.0.20010323183750.009f2510@mail.inet.com.br> Message-ID: [Carlos Ribeiro] > ... > c) Please keep the proposal *simple*. > > > Man, this is turning into a nightmare... That's why PEP 236 tries to address only one thing -- the immediate problem at hand. Beyond that, you're unlikely to end up with something simple; e.g., the C compiler I use most often has 24 *kinds* of "pragma" statements, several of which come in variations, even up to the point of having "push" and "pop" flavors that maintain a bloody *stack* of "current pragmas in effect". At least "from __magicname__ import xyz" is ugly enough to discourage trying to extend it <0.4 wink>. like-the-skull-&-crossbones-on-a-jar-of-poison-ly y'rs - tim From gregj at pobox.com Sat Mar 10 15:34:19 2001 From: gregj at pobox.com (Gregory Jorgensen) Date: Sat, 10 Mar 2001 20:34:19 GMT Subject: Problems writting a wrapper around linux' ssh command References: <31rd89.lki.ln@127.0.0.1> Message-ID: ssh explicitly opens /dev/tty to read the password, so it's not looking on stdin (see the readpass.c file in your ssh sources). In a normal terminal session stdin is mapped to /dev/tty, but a child process started with popen2 will have stdin mapped to the Popen3.tochild file descriptor. Can you use one of the other secure authentication methods ssh supports? In article <31rd89.lki.ln at 127.0.0.1>, gradha at iname.com says... > >Hi. > >I am trying to write a python wrapper around ssh. The last and only problem >I have is password verification. I try to popen2.popen3 the ssh command, >but no matter what I write to the input file, the ssh command ignores it >and keeps requesting *keyboard* input. > >Is there any way to avoid this? Greg Jorgensen Deschooling Society Portland, Oregon, USA gregj at pobox.com From alf at leo.logilab.fr Thu Mar 15 05:01:08 2001 From: alf at leo.logilab.fr (Alexandre Fayolle) Date: Thu, 15 Mar 2001 10:01:08 +0000 (UTC) Subject: Regular Expressions and Python 1.5.2 References: <98q0k8$2b77$1@norfair.nerim.net> Message-ID: <98q3t4$2d6o$1@norfair.nerim.net> Alexandre Fayolle wrote: > Is this a known bug in the module re of python 1.5.2, or am I missing > something obvious? >>>> import re >>>> t = "m&n" >>>> re.sub('[^/_ -]','*',t) > '***' >>>> re.sub('[^_ -/]','*',t) > '*&*' [hits himself on the head with a dead fish] OK, I was bit tired when I wrote the code. I had forgotten that '-' has a special meaning. Obviously, '&' lies somewhere between '_' and '/'. Sorry for the noise. Alexandre Fayolle -- http://www.logilab.com Narval is the first software agent available as free software (GPL). LOGILAB, Paris (France). From wtanksle at dolphin.openprojects.net Sat Mar 31 23:02:00 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Sun, 01 Apr 2001 04:02:00 GMT Subject: PythonLabs Team Moves to ActiveState References: Message-ID: On Sat, 31 Mar 2001 19:54:59 -0500, Guido van Rossum wrote: >PythonLabs Team Moves to ActiveState I'm glad we're finally getting some stability. > Barry has already approved PEP 357, Adding Block Delimiters to Python. Okay, okay -- but these things are trivial. If we really want to solve these problems the right way, we have to behave completely like Pascal, except with curly braces. Perl has to as well. The two languages should actually be exactly identical; the difference in name can be explained as TMTOWTDI for one crowd, and The Best Way To Do it for the other. Oh, and get rid of those annoying "module" things. They're so passe'. > --Guido van Rossum (home page: http://www.python.org/~guido/) -- -William "Billy" Tanksley From phd at phd.pp.ru Wed Mar 7 04:54:03 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 7 Mar 2001 12:54:03 +0300 (MSK) Subject: GadFly and gfplus.py working with Python 2.0? In-Reply-To: Message-ID: On Wed, 7 Mar 2001, Eugene Leitl wrote: > See subject. > Aye, nay, maybe? Why not just try yourself? (Works for me, YMMV) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From crystalc at interlog.com Fri Mar 16 23:34:14 2001 From: crystalc at interlog.com (Brian Alexander) Date: Fri, 16 Mar 2001 23:34:14 -0500 Subject: ODBC for Python 2? Message-ID: <0IBs6.29099$ZT5.789151@news.total.net> Hello; Is it possible to make use of Win32 ODBC drivers from Python 2? I would like to run updates/synchronizations on a remote SQL database. Brian. From michel at digicool.com Sun Mar 11 21:05:48 2001 From: michel at digicool.com (Michel Pelletier) Date: Sun, 11 Mar 2001 18:05:48 -0800 (PST) Subject: [Python-Dev] Revive the types sig? In-Reply-To: <3AAC08DB.9D4E96B4@ActiveState.com> Message-ID: On Sun, 11 Mar 2001, Paul Prescod wrote: > Let's discuss my proposal in the types-sig. Executive summary: > > * incremental development policy > * syntax for parameter type declarations > * syntax for return type declarations > * optional runtime type checking > * goals are better runtime error reporting and method documentation I could be way over my head here, but I'll try to give you my ideas. I've read the past proposals for type declarations and their syntax, and I've also read a good bit of the types-sig archive. I feel that there is not as much benefit to extending type declarations into the language as their is to interfaces. I feel this way because I'm not sure what benefit this has over an object that describes the types you are expecting and is associated with your object (like an interface). The upshot of having an interface describe your expected parameter and return types is that the type checking can be made as compile/run-time, optional/madatory as you want without changing the language or your implementation at all. "Strong" checking could be done during testing, and no checking at all during production, and any level in between. A disadvantage of an interface is that it is a seperate, additional step over just writing code (as are any type assertions in the language, but those are "easier" inline with the implementation). But this disadvantage is also an upshot when you immagine that the interface could be developed later, and bolted onto the implementation later without changing the implementation. Also, type checking in general is good, but what about preconditions (this parameter must be an int > 5 < 10) and postconditions and other conditions one does now with assertions. Would these be more language extensions in your propsal? As I see it, interfaces satify your first point, remove the need for your second and third point, satify your fourth point, and meet the goals of your fifth. Nice to meet you at the conference, -Michel From thomas at xs4all.net Fri Mar 9 16:24:46 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 9 Mar 2001 22:24:46 +0100 Subject: news from python9!!! In-Reply-To: ; from tuttledon@hotmail.com on Thu, Mar 08, 2001 at 08:13:14PM +0000 References: Message-ID: <20010309222446.J404@xs4all.nl> On Thu, Mar 08, 2001 at 08:13:14PM +0000, Don Tuttle wrote: > "Fredrik Lundh" > > (and the subject should probably read "news from active- > > state's marketing department" ;-) > Hey, you gotta run with what you can find, seeing how all you conventioneers > where having way too much fun to drop into the newsgroup and give us an > update! > (Sorry about the award. Maybe next year.) Hey, Fredrik got a seat on the PSF Board of Directors, he should be damned happy! And now he won't be eligible for any PSF-sponsored award next year, of course . -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From shredwheat at mediaone.net Mon Mar 19 10:17:51 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Mon, 19 Mar 2001 15:17:51 GMT Subject: newbie needs help installing NumPy, reference material. References: Message-ID: > > Just trying to get numeric python installed on a win2000 machine with python > > 2.0, Idle, etc installed (but without a c compiler). I've downloaded > > http://download.sourceforge.net/numpy/NumPy1711_20.zip, but am unclear about > > whether it's the right version (there's an 18.0 version) and how to install > > it. The documentation at www.python.org was a little outdated. hi, i also have a precompiled binary of Numeric 17.3 for win32 and python2.0 this isn't the latest version of Numeric, but afaik, the latest versions only add features for python2.1 anyways, so it shouldn't make a difference for python2.0 http://pygame.seul.org/ftp/contrib/Numeric-17.3-win32-2.0.zip i've been doing all the precompiled win32 releases for the 16.x and 17.x. when 17.3 was released i also created this archive, but it was never included into the sourceforge archive. anyways, you can also use the link above for 17.1.1 fine, just letting you know about this newer version i have. as with either version, just unzip the archive into your C:\PYTHON20 directory (wherever it may be) From cyberian_bear at hotmail.com Sat Mar 17 20:08:27 2001 From: cyberian_bear at hotmail.com (cyberian bear) Date: Sat, 17 Mar 2001 20:08:27 -0500 Subject: module to do euler path and topological sorting in python Message-ID: can anyone suggest where i can find the modules which would do those two things. I have found a website which had a link to topological sorting but it says that access is forbidden. www.python.org doesn't have any matching reuslts. thanx cb From scarblac at pino.selwerd.nl Wed Mar 28 03:28:52 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 28 Mar 2001 08:28:52 GMT Subject: R: unique items in lists References: <_nZv6.2878$yU4.468236@news.infostrada.it> <3AC0E010.3CDC94FC@mentor.com> Message-ID: Bob Cannard wrote in comp.lang.python: > > The dictionary method does one dictionary action for each word, and then it > > does a dict.keys() which takes time proportional to each unique word. > > I don't know how dictionaries are implemented, but hopefully they're > a lot faster than that - one would expect a hash or tree implementation, > giving a logarithmic run time for each lookup. A linear implementation > would be an obvious cause of poor run time performance for Python > generally. Dictionaries are hashes, I'm assuming a dictionary setattr is about constant time. The "dict.keys()" at the end must be linear, since its result is linear... -- Remco Gerlich From syver at NOSPAMcyberwatcher.com Wed Mar 14 10:01:55 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Wed, 14 Mar 2001 16:01:55 +0100 Subject: Python interacting with Java Script webpage? References: Message-ID: <98o19c$o9s$1@troll.powertech.no> Use urllib or httplib, these are very simple to use and there are good examples in the docuementation. Find out what the names of the form fields are and use these in the dictionary you use to send the form data Both urllib and httplib returns a filelike object that is easy to stream out to disk, In addition urllib has got a method that writes the content to disk, urllib.urlretrieve Here is an example using urlopen: The form fields used here would be syver, christine, marius. file = urllib.urlopen('http://localhost/test/testform.asp', data=urllib.urlencode({'syver': 30, 'christine': 33, 'marius': 30})) The data parameter is where you pass in the form content. The easiest way is as shown by using a dictionary and the urllib.urlencode function that converts the dictionary into a format that you can use for query strings or form posts. an example using urlretrieve ret = urllib.urlretrieve('http://localhost/test/testform.asp', filename='form.txt', data=urllib.urlencode({'syver': 30, 'christine': 33, 'marius': 30})) as you can see it's almost equal to urlopen, but you also specify a filename that urlretrieve will write the content to. Hope this helps you and doing what you want to do. "William Dandreta" wrote and wrote > I would like to write a Python program that will be able to connect to a > webpage that runs a Java Script, post data to the form displayed, and save > the data retrieved to a file. From tm at kernelconsult.com Wed Mar 21 20:44:52 2001 From: tm at kernelconsult.com (TM) Date: Thu, 22 Mar 2001 01:44:52 GMT Subject: Please rate these Python books Message-ID: <20010322.1445209@mis.configured.host> Hi everybody, I'm wondering if the last books on Python are good. Thanks for your points of view. I'm especially thinking about : 1/Programming Python 2nd edition @ O'reilly 2/ Core Python Programming / Chun / Prentice Hall 3/ Python Essential Reference / David Beazley / New Riders Publishing Thanks again From nospam at mega-nerd.com Thu Mar 15 15:43:18 2001 From: nospam at mega-nerd.com (Erik de Castro Lopo) Date: Thu, 15 Mar 2001 20:43:18 GMT Subject: decss References: Message-ID: <3AB12769.6AF5ECDE@mega-nerd.com> Jay Collins wrote: > > Anyone every convert that perl script to python? Yep. I often get Perl code from the net. If I need to make anything more than the most rudimentary changes to it I convert it to Python first. > I was just wondering how it would look Python is FAR more readable. > /perform. The differences in speed between optimal Perl and optimal Python are negligible. Erik -- ----------------------------------------------------------------- Erik de Castro Lopo nospam at mega-nerd.com (Yes its valid) ----------------------------------------------------------------- "Two hands working can do more than a thousand clasped in prayer." -- anonymous From gerhard.nospam at bigfoot.de Thu Mar 1 01:29:06 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Thu, 01 Mar 2001 07:29:06 +0100 Subject: Python + MySQL + qt References: Message-ID: <3A9DEC32.941EFF71@bigfoot.de> Jacek Pop?awski wrote: > > I have a school project: create database and write application which will use > it (I am not sure what exactly it will do, yet), it should have graphical menu > and be user friendly. I can choose tool. I am thinking about MySQL or > Postgresql (probably MySQL) and qt/gtk+ as toolkit (probably qt). If the database is not very complex, it wouldn't matter which one you choose. If the database server should run on Windows, too, I'd use MySQL or Interbase, not Postgres. > I am much more experienced in C than in Python, but I like this language and I > think it will be next step to learn it more. > And now questions: > - is Python good choice here? what troubles will I have? Python is sure an excellent choice here. Python is very good at integrating things. Troubles? Probably lack of (good) documentation. For Python and databases, you might want to check out the database topic guide on the Python homepage. > - what libraries will I need except pygtk or pyqt? The appropriate database module for the database you choose. For MySQL, there is MySQLdb (http://dustman.net/andy/python/MySQLdb/) For PostgreSQL, there are several. I use PyGreSQL (http://www.druid.net/pygresql/). > - I am programming only in Linux, is it possible to run my application in > Windows, without any code fixes? are needed libraries available for Win? The Python database modules MySQLdb and PyGreSQL (for PostgreSQL) are available for Windows at my homepage (see below). I have a bookmark for pyGTK on win32, for the case you want to go with GTK: http://www.hans.breuer.org/ports/ I am quite a fan of wxPython. It's a very powerful library, and quite easy to program. OK, it's not Visual Basic (yet), but who wants Visual Basic, anyway ;-) Gerhard PS: Some of the modules you need might be already included in your Linux distribution. I have SuSE, and it includes most of the above mentioned Python modules. -- Sorry for the fake email, please use the real one below to reply. contact: g e r h a r d @ b i g f o o t . d e web: http://highqualdev.com From insanc at cc.gatech.edu Fri Mar 23 09:55:04 2001 From: insanc at cc.gatech.edu (Holland King) Date: 23 Mar 2001 14:55:04 GMT Subject: email address verification References: <99d5qi$95l$1@solaria.cc.gatech.edu> <99fjv8$bhf$1@solaria.cc.gatech.edu> Message-ID: <99fo48$d9h$1@solaria.cc.gatech.edu> Cameron Laird wrote: : I don't understand your description. In general, ok, we run a server that holds a lot of accounts, once an account expires then we run a script that parses the .forward file found in the home dir. the script then takes the addresses found and makes them into aliases so that hopefully the user will not lose any mail. we need to make sure that the aliases are real addresses so that at worst mail is not bounced and at best it doesn't go to a mailing list (i know i am being an optimist) : comp.mail.misc might be a more productive place to : ask these questions than c.l.p. ok thank you i will try there to, the reason i asked here is that i tried comp.linux.misc and they didn't help and i am writing it in python (i think my orignal post mention that i had found the smtp library and i was wondering if there was something similar that would work) : Are you asking about verifying e-mail addresses *on : hosts you control*? That's entirely different! no -- Joseph Holland King | "God whispers to us in our pleasures, speaks in our | conscience, but shouts in our pains: it is His | megaphone to rouse a deaf world." C. S. Lewis From amk at mira.erols.com Sun Mar 11 13:37:52 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 11 Mar 2001 18:37:52 GMT Subject: Color curses and Python 2? References: Message-ID: On 11 Mar 2001 10:44:09 GMT, Jim Dennis wrote: > I thought I'd heard that color ncurses support would be included > in 1.6. Was it? I still haven't seen a 1.6.x package Yes, it was. Perhaps the Debian version of Python is miscompiled (unlikely), or perhaps your terminal definition is set to something that doesn't support colour. --amk From gzeljko at sezampro.yu Tue Mar 20 12:44:29 2001 From: gzeljko at sezampro.yu (gzeljko) Date: Tue, 20 Mar 2001 18:44:29 +0100 Subject: Sequence-spreading References: <3AB7167F.2816AA21@student.liu.se> <99790u01c73@news2.newsguy.com> Message-ID: <99851p$ba6$2@neptun.beotel.net> Alex Martelli wrote in message > offsets = [ [] for i in range(pm) ] > for i in range(len(arg)): > offsets[i%pm].append(i) > > > Alex > Old syntax yet works: offsets = [[]]*pm ly-y'rs-gzeljko From aleaxit at yahoo.com Sun Mar 11 03:04:57 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 11 Mar 2001 09:04:57 +0100 Subject: Can anyone recomend a good intoduction to C... References: <989mbk$24nuv$1@fido.engr.sgi.com> <98auhn0270j@news2.newsguy.com> <98dpoe12ckn@news1.newsguy.com> <3AAA85C1.81FB90AA@shore.net> <98eb1f02uqq@news1.newsguy.com> <3AAAE0BB.CBCC99EC@alcyone.com> Message-ID: <98fbme0ta8@news1.newsguy.com> "Erik Max Francis" wrote in message news:3AAAE0BB.CBCC99EC at alcyone.com... > Alex Martelli wrote: > > > It's no doubt possible that gcc has significantly worsened in the > > last 5 or 6 years, but I'll confess that would really surprise me. > > No, it's actually gotten far better. The pre-egcs versions of g++ had > some really glaringly seriously problems with modern draft Standard (now > actual Standard) compliance like exceptions, templates and the like. If > you weren't using these, though, g++ was just fine (which was probably > the case for you). Yes, this was before the Standard appeared, so we were not using many of the Standard features -- templates being the only exception, as it was obvious they bought us SO much it was worth taking a lot of pain to use them. (And it was indeed a lot:-). > Note that modern version of egcs have all the > Standard language _features_ all settled out, but there are a few > Standard compliance problems in the library. These are scheduled to be > fixed in gcc 3.0. One option we considered at one point was to purchase a library somewhere (e.g., dinkumware) and use it instead of the one that came with gcc. Didn't pan out since we ended up on Windows anyway, but early tests were promising. Alex From max at alcyone.com Sun Mar 11 14:03:03 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 11 Mar 2001 11:03:03 -0800 Subject: Einstein's Riddle References: Message-ID: <3AABCBE7.94C9BB61@alcyone.com> Steve Graham wrote: > Albert Einstein wrote this riddle this century [ed. 20th century]. He > said > 98% of the world could not solve it. No, he didn't. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Weakness of attitude becomes weakness of character. \__/ Albert Einstein Interstelen / http://www.interstelen.com/ A multiplayer, strategic, turn-based Web game on an interstellar scale. From s713221 at student.gu.edu.au Thu Mar 29 00:02:07 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Thu, 29 Mar 2001 15:02:07 +1000 Subject: warrior geeks References: <3ABF72F1.98CB78F@sage.att.com> Message-ID: <3AC2C1CF.4F70AF77@student.gu.edu.au> Ken Seehof wrote: > > Me too. I'm an Aikidoist. > Me three, I'm an Aikidoka as well, Joal Heagney/AncientHart From NoSpam at NoSpam.com Wed Mar 28 23:31:44 2001 From: NoSpam at NoSpam.com (Tom) Date: Thu, 29 Mar 2001 04:31:44 GMT Subject: Boost documentation. References: Message-ID: The boost.org site has a link to the boost mailing list on Yahoo. It has a fair bit of boost.python traffic and would be a good place for your question. Tom. "Jacek Generowicz" wrote in message news:g0wv99x256.fsf at scumbag.ecs.soton.ac.uk... > Are there any sources of documentation for the Boost Python Library > besides the source examples, getting_started<1-5>.cpp ? > > How would I write a C++ function which receives a python list and > converts it into a std::vector for its own use ? > > Thanks, > > Jacek From db3l at fitlinxx.com Fri Mar 9 20:53:04 2001 From: db3l at fitlinxx.com (David Bolen) Date: 09 Mar 2001 20:53:04 -0500 Subject: Remote script execution with Python ... References: <7Ybp6.7729$r4.7336@news.indigo.ie> <98ank601u1b@news2.newsguy.com> Message-ID: "Alex Martelli" writes: > "Robert Gahan" wrote in message > news:Lpwp6.8059$r4.7712 at news.indigo.ie... > > Thanks Ben. > > > > os.popen2 is not available to windows programmers but > > Works fine for me (NT4, Python 2.0 standard build). Yes, the original post should be modified to say under Python 1.5.2, where you do need to use the win32pipe module. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From jkraska1 at san.rr.com Sat Mar 24 00:15:07 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 24 Mar 2001 05:15:07 GMT Subject: static methods References: <99h8be$om7$1@panix3.panix.com> Message-ID: <6ibobtoku1vb5m1p44k9fcd6bvdeipiprt@4ax.com> >Without debating the rationale, the standard answer is to stick the >class into a module with the same name and use module global functions >to simulate static methods. Yeah, it takes the uninitiated Python programmer a moment of pause to realize that "global" variables and functions are okay in Python. This is because every Python file is a "namespace", default. You have automatic packaging, for free. Python's packaging model succeeds at being elegant, easy to use, syntactically lightweight, and conceptually the right thing. C// From chris.gonnerman at usa.net Wed Mar 21 23:02:38 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Wed, 21 Mar 2001 22:02:38 -0600 Subject: Puzzling input problem References: <3AB9449C.A1D14738@monitor.net> Message-ID: <011801c0b284$f0abec00$a100000a@local> ----- Original Message ----- From: "Stephen R. Figgins" Subject: Puzzling input problem > I ran into a puzzling problem combining print with raw_input(). > Normally I would pass the prompt string to raw_input, but instead I > tried something like this: > > print "prompt string: ", > answer = raw_input() > print answer > > When it prints answer, it is indented one space. Why is raw_input() > putting a space in there? Is it a bug, a feature, an unintended side > effect? input() does this too. I am currently using Active Python 2.0 > build 202. Actually, raw_input isn't the culprit, exactly. The print statement's format handler doesn't know that raw_input() has modified the screen contents, so it still behaves like the cursor is just after the "prompt string: " on the screen, inserting a space as the ref guide says it will. Do it this way instead: answer = raw_input("prompt string: ") print answer and you should get what you want. From urner at alumni.princeton.edu Sat Mar 3 20:24:00 2001 From: urner at alumni.princeton.edu (Kirby Urner) Date: Sat, 03 Mar 2001 17:24:00 -0800 Subject: Missing the functional mind set References: <97rqgb$lt2$1@tyfon.itea.ntnu.no> Message-ID: "Magnus Lie Hetland" wrote: > >This should be > > >>> params = [None]*4 Yes, I seem to be constitutionally incapable of posting an error-free post. Oh well... As a certain USA ex-president might say 'I can feel my pain'. Kirby From paul at fxtech.com Sun Mar 11 16:43:16 2001 From: paul at fxtech.com (Paul Miller) Date: Sun, 11 Mar 2001 15:43:16 -0600 Subject: any interest in type-scoped static constants? References: <3AAB9578.4C8754E4@fxtech.com> Message-ID: <3AABF174.3C986EB4@fxtech.com> > Why do you need a PEP when you can implement it for any extension you > need. Just put a dictionary in the type and using type.getattr to look > stuff up in your dictionary. Correct me if I am wrong, but do you not need an *object* of the type before you can call getattr on it? In other words, I would have to do this: constant_value = Point().CONSTANT_VALUE Which would first CREATE an object of that type, then call its getattr() method where I can look at the argument. I want to avoid creating objects just to get a constant which is associated with the TYPE and not the object. From gmuller at worldonline.nl Tue Mar 6 17:10:47 2001 From: gmuller at worldonline.nl (Gerrit Muller) Date: Tue, 6 Mar 2001 23:10:47 +0100 Subject: Windows98+Idle0.6+ 32 bit color HW or SW problem? Message-ID: <983n9c$mbn$1@nereid.worldonline.nl> I recently acquired a new windows 98 computer and installed python 2.0 final plus win32all-134. I now get horizontal disturbances in the idle and other TKinter windows, when using 32 bit color mode and 1280*1024. When switching between 16 bit and 32 bit color mode the Tkinter windows are apparantly not updated, the contents of these windows becomes garbage. Microsoft applications, such as IE and outlook express do not suffer from these effects. Is there any known SW problem in Tkinter or related SW, which may cause these problems. The alternative is suspect HW (AMD Thunderbird 900 MHz, ELSA Gladiac MX). regards Gerrit From stephen_purcell at yahoo.com Thu Mar 15 05:31:34 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Thu, 15 Mar 2001 11:31:34 +0100 Subject: reversing a dictionary (newbie) In-Reply-To: <007201c0ad37$12571f80$6809a78f@dcs.shef.ac.uk>; from C.Brewster@dcs.shef.ac.uk on Thu, Mar 15, 2001 at 10:02:40AM -0000 References: <007201c0ad37$12571f80$6809a78f@dcs.shef.ac.uk> Message-ID: <20010315113134.A5112@freedom.puma-ag.com> Christopher Brewster wrote: > I have written a program to extract pairs of words from a corpus (the BNC). > It is my first Python program > Once it has processed the files I "reverse" the dictionary so that the keys > are frequencies and the values lists of word pairs of that frequency. What if two words have the same frequency? You probably want the 'reversing' process to generate a list of (frequency, word) tuples. But anyway... to reverse a dictionary, you can do: >>> dict = {'a':1, 'b':2, 'c':3} >>> reversed = {} >>> for k, v in dict.items(): ... reversed[v] = k >>> reversed {3: 'c', 2: 'b', 1: 'a'} Expect total memory usage to be triple that of 'dict' alone towards the end of the loop, because of the 'items()' call. -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From paul at fxtech.com Wed Mar 14 18:58:11 2001 From: paul at fxtech.com (Paul T. Miller) Date: Wed, 14 Mar 2001 17:58:11 -0600 Subject: Cameron Laird Quote on www.unixinsider.com -- Probably old news to y'all, but new to me. References: Message-ID: <3AB00593.D1C4BBBF@fxtech.com> > I apologize for trotting it out again, if I am repeating something earlier > discussed, but I couldn't find any direct reference to it (my nntp server > sucks, only goes back 7 days). > > All I'll add is: Well said, Cameron! I love Python. I especially love it as an embedded scripting language. But it is not going to replace graphics applications where speed is paramount. Many of these articles fail to take that into account. But then again, many problem domains do not have the interaction constraints that 3D or compositing applications have. From tim.one at home.com Sat Mar 24 00:38:50 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 24 Mar 2001 00:38:50 -0500 Subject: New PEP: The directive statement In-Reply-To: <99dtt0$l6t$1@panix3.panix.com> Message-ID: [James_Althoff] > ok, how about: > > from __readyOrNot__ import nested_scopes > > or perhaps, > > from __likeItOrNot__ import nested_scopes [Aahz Maruch] > This is in some respects excessively flippant, but that very flippancy > calls attention to it. I'm not going to push this idea, but I do think > it's worth considering. Aahz, "__future__" was intended to be flippant enough to get peoples' attention, and for some people that works (e.g., /F originally said "it makes me smile", which was half the point). But the people offended by an ounce of irreverence aren't going to be happier with a full pound. from__upyours__-ly y'rs - tim From greg at cosc.canterbury.ac.nz Wed Mar 7 20:40:24 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 08 Mar 2001 14:40:24 +1300 Subject: sorry....never mind References: Message-ID: <3AA6E308.5B63ECC6@cosc.canterbury.ac.nz> Victor Louie wrote: > > <> is obsolescent. Really? I hope it's not taken away, because that will break ALL of my code! I hate != (looks too much like C), so I always use <>. Nobody ever told me I was doing anything wrong! -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From aleaxit at yahoo.com Thu Mar 22 14:44:32 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 22 Mar 2001 20:44:32 +0100 Subject: python, perl, lisp, tcl / got a decision to make, can you give me a view point please ? and a joke for python users :) References: <3aba3076.14395287@news.vif.com> Message-ID: <99dkkd018e0@news1.newsguy.com> "Yvon Boulianne" wrote in message news:3aba3076.14395287 at news.vif.com... > Hello, i'm a bit confused with so many language ;-) > theres the story, i like to learn a programming language for 2 reasons > 1- i want to be able to make some script on my web site (i heard about > zope, don't know what it have to do with python) Zope is _written_ in Python; for the scripts, it lets you use python itself, or, now, Perl as an alternative. Anyway, Python is great for that (and many other uses). > 2- i want to learn to keep my mind trained, i'm a mystic and i want to > make this mental grow in ability ;-) Unfortunately, Python is far too good a language to serve this purpose. It's so simple you won't get much mental exercise learning it, and so powerful it will make it too easy for you to write all kinds of programs. For your purpose [2], I suggest Haskell (it starts out easy, but when you get to monads they WILL give your mind a workout -- when, and if, you emerge alive and still sane, you will have moved to a higher level of consciousness) or javascript (chaotically and ramblingly hard to learn, yet wimpy enough that using it to write significant programs is going to be serious exercise each and every time). Alex From stevewilliams at wwc.com Wed Mar 7 17:08:12 2001 From: stevewilliams at wwc.com (Steve Williams) Date: Wed, 07 Mar 2001 22:08:12 GMT Subject: I come to praise .join, not to bury it... References: <000001c0a64c$497df250$a9807018@cr706570a> Message-ID: <3AA6B157.2B62BFA5@wwc.com> D-Man wrote: > On Tue, Mar 06, 2001 at 09:46:53AM -0500, Mike C. Fletcher wrote: > > [snip] > Even with my newfound understanding, provided by the Martellibot, I > agree with this. Calling a method on an object is fine. Calling it > on a literal looks weird. Take for example something like this > > three = 1.__add__( 2 ) > > ;-) > > Continuing on into the darkness: ten = +.join(1,2,3,4) and sixfactorial = *.join(range(1,7)) Since + and * are not quoted, it's clear that 'join' is an 'arithmetic join'--polymorphism, doncha know. And howsabout RatherLargeNumber == **.join(xrange(100)) The mind boggles. From dinu at reportlab.com Fri Mar 23 06:28:47 2001 From: dinu at reportlab.com (Dinu Gherman) Date: Fri, 23 Mar 2001 11:28:47 GMT Subject: Ruby will overtake Python within four years. References: Message-ID: <3abb31fb.184742956@news.vr.in-berlin.de> On 23 Mar 2001 04:58:09 -0000, "prashant patel" wrote: >No I am not a ruby programmer not even using any scripting language other once used vbscript in ASP. Then, how comes you predict "Ruby will overtake Python within four years." in your subject line? >[...] But my inclination are towards python. Likely the right conclusion... as in four years we'll be much closer to the year 3000 than we're now, which probably means the type/ classes dichotomy will be gone, as well as Stacky Python. ;-) Dinu From not.this at seebelow.org Thu Mar 22 13:44:11 2001 From: not.this at seebelow.org (Grant Griffin) Date: 22 Mar 2001 10:44:11 -0800 Subject: New PEP: The directive statement References: Message-ID: <99dh5r013dg@drn.newsguy.com> In article , "Tim says... ... >I may like >Martin's "transitional" better for this reason -- provided that it wakes >people up enough to think about what they're reading. Alas, > > from __transitional__ import nested_scopes > >is not only ugly, it's not even funny, so would be worse than "from >__future__ ...". It works better with "directive" because it keeps it >uniformly bland. You know, if this "__future__" thing really goes through, I predict we'll eventually see something like this: from __future__ import __transitional__ or maybe even import __future__ as __transitional__ (I'm not sure if the proposed syntax will support that, though. ) Now, I like a good joke as much as the next guy , but I'm not sure software is the place for jokes. Problem is, computers seem to be inherently un-funny. For example, imagine the following from the old Star Trek series: Kirk: Computer? Computer: Working. Kirk: Why did the chicken cross the road? Computer: Specify chicken. I once worked on a system which, whenver you made a typo in entering a command, responded with, "Fat-finger typo error". That was funny for the first day or two, but it wore thin in about a week, and it became downright annoying after a month. Then, after close to a year, we finally got good at ignoring it. Similarly, whenever I use "friend" in C++, I wince a little bit. And not just for the construct itself--for its name. I don't think "friend" was ever meant as a joke, but even so, it's just a _little_ too cute. Oh, and don't get me started on Bill Gates' dancing paper clip... >if-you-can't-laugh-at-your-tools-you're-taking-them-too-seriously-ly Should we laugh at ourselves? Definitely! Should we laugh at each other? Hopefully! But should we laugh at our tools? Never! (Sorry to be such a wet blanket. :-) a-workman-is-known-by-his-tools-ly y'rs, =g2 _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From deblNonOspammy at theworld.com Tue Mar 13 23:53:09 2001 From: deblNonOspammy at theworld.com (David Lees) Date: Wed, 14 Mar 2001 04:53:09 GMT Subject: Help doing simple threading Message-ID: <3AAEF93E.F817D852@theworld.com> I am trying to learn how to use threads. I want multiple threads to be able to communicate. I thought that threads started by a common process would share globals in that module. I want thread to be able to store results in a common array. However the following returns all zeros, so clearly I am not passing anything back to the top level list 'z'. Can someone tell me how I should be passing things back from threads? Thanks in advance. David Lees --------------------------------------- import thread #Create a top level list of length n def create_len(x,n): for i in range(n): x.extend([0]) def save_stuff(k): z[k]=k*k n=10 global z z=[] create_len(z,n) for i in range(n): thread.start_new(save_stuff,(i,)) for i in range(n): print z[i] From dougfort at downright.com Mon Mar 5 06:15:03 2001 From: dougfort at downright.com (Doug Fort) Date: Mon, 5 Mar 2001 06:15:03 -0500 Subject: [Advertisment] Re: Test Your Web Apps - article at LinuxQuality References: <3AA34C6B.EC12B25B@goingware.com> Message-ID: Hey! Don't forget about http://www.stressmy.com "Michael D. Crawford" wrote in message news:3AA34C6B.EC12B25B at goingware.com... > Tonight I posted: > > Use Validators and Load Generators to Test Your Web Applications > http://linuxquality.sunsite.dk/articles/webapptesting/ > > The article promotes the idea that one should check the HTML > generated by a web application with a validator to ensure that > it conforms to W3C standards, and that you should use a load > generator to stress-test your server during development to > detect performance problems early. > > Links to some load generators and validators are given, with > tips on using them. > > I further suggest that if you generate XHTML documents rather > than HTML, you can take advantage of the many available > XML software packages to validate and process your documents. > > Comments, criticisms, corrections and suggested additions are > appreciated. > > The Linux Quality Database at http://linuxquality.sunsite.dk/ > has the dual purpose of promoting higher quality among Free > and Open Source software by publishing articles such as this, > and also the development of an easy-to-use but powerful bug > database to enable widespread public quality assurance of the > linux kernel. > > You're welcome to contribute articles on the general topics > of quality assurance and better programming practice. I'm also > looking for knowledgeable people who can help me design the schema > for the bug database. > > -- > Michael D. Crawford > GoingWare Inc. - Expert Software Development and Consulting > http://www.goingware.com > crawford at goingware.com > > Tilting at Windmills for a Better Tomorrow. From stephen_purcell at yahoo.com Tue Mar 27 11:21:47 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 27 Mar 2001 18:21:47 +0200 Subject: stripping cr/lf, lf, cr In-Reply-To: ; from root@excalibur.iks-jena.de on Tue, Mar 27, 2001 at 03:34:03PM +0000 References: Message-ID: <20010327182147.B1260@freedom.puma-ag.com> deadmeat wrote: > Is there a platform independant function that will remove appropriate EOL > characters from a string? I don't want to use strip() since it will also > remove other whitespace I want to keep. > No, but it's easy to write one: >>> import string, os >>> def strip_eol(s): ... pos = string.rfind(s, os.linesep) ... if pos == -1: return s ... if pos < len(s) - len(os.linesep): ... return s ... return s[:-len(os.linesep)] ... >>> os.linesep '\012' >>> strip_eol('a line\n') 'a line' >>> strip_eol('a line') 'a line' >>> strip_eol('a \nline') 'a \012line' >>> strip_eol('a \nline\n') 'a \012line' >>> strip_eol('a line\r\n') 'a line\015' -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Any opinions expressed herein are my own and not necessarily those of Yahoo From aleaxit at yahoo.com Tue Mar 6 12:31:51 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 6 Mar 2001 18:31:51 +0100 Subject: Can Python replace Visual Basic? Should it? References: <5DZo6.11126$hn5.1578410@news1.rdc1.mb.home.com> <98266k0p5h@news1.newsguy.com> <3q8p6.12338$hn5.1798569@news1.rdc1.mb.home.com> Message-ID: <9836u70260g@news1.newsguy.com> "Brad Bollenbach" wrote in message news:3q8p6.12338$hn5.1798569 at news1.rdc1.mb.home.com... [snip] > > Why do you focus on 'used to use'? One may perfectly well keep using > > some VB (&c) for tasks it's particularly well-suited to, while using > > Python wherever feasible (and, indeed, using both in the same project > > Certainly. And for all intents and purposes "used to use" isn't necessary, > but the question happened to be directed (as its subject suggests) at those > who _have_ replaced VB with Python. :) If only those who HAVE replaced answer, you'll get answers slanted in favour of replacing -- which may be what you're after!-) > But realistically, I just wanted to emphasize my interest in hearing answers > from those who have or currently are using VB or one of the other Win32 > visual development tools. Personally, I'm a former VB programmer now working > in Powerbuilder and am unhappy with both, again based on my dislike of IDE's > that obscure the programmer's view of what's going on. > > I could explain _why_ I don't like the 40,000 foot views of IDE's, but > that's another thread. You're definitely preaching to the choir, as far as I'm concerned, on the 'IDEs which hide things' theme. Alex From jcollin at exis.net Tue Mar 13 10:37:48 2001 From: jcollin at exis.net (Jay Collins) Date: Tue, 13 Mar 2001 10:37:48 -0500 Subject: string.find() ? In-Reply-To: References: Message-ID: Doh! I figured it out. had the arguments backward! From qrczak at knm.org.pl Sun Mar 18 09:13:47 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 18 Mar 2001 14:13:47 GMT Subject: Who's minister of propaganda this week? References: <98nu1m$12e@dispatch.concentric.net> <660ACCA1E4816F7E.C359CDF4168EF3FB.3B6B05538D619770@lp.airnews.net> <3AAFA13D.76E32C3F@divalsim.it> <98oa4o01i4v@news2.newsguy.com> <3AB0176D.8070903@yahoo.com> Message-ID: Thu, 15 Mar 2001 05:43:38 -0800, Paul Prescod pisze: > 3. Statically typed languages are absolutely not immune to type errors > for a variety of reasons: > > * Null pointer exceptions are type errors. You've passed the null > object when the code expected some other object. Not all languages have null pointers at all. (My favorites happen not to have them.) > * Almost every statically typed language also has a set of features for > working around the type system (dynamic casts). In many languages (Haskell, SML, OCaml, Clean, Mercury, Eiffel) they are almost never used. Again, not all languages are like C++ and Java where casting is essential. > * Even when the compiler thinks the "type" of your object is correct, > there are a variety of type-related errors you can make such as passing > a negative number where only positive ones are allowed, [...] Indeed. Nobody claims that static type system catch all type-related errors. But they catch most of them, and it's better to catch some than to catch none. The inability to catch all type-related errors at compile time is hardly a disadvantage of static type systems wrt. dynamic type systems, if dynamic type systems don't catch any of them at compile time. > 4. Yes, if you unit test every unit in your program, and do good > coverage testing you WILL catch ever occurrence of some code calling > foo. That's what good testing is about. And you need it, not to catch > the basic type errors but to catch the subtle semantic errors. Catching > the basic type errors comes for free. This assumes that testing procedures are perfect and cover every possible kind of data. Nobody's perfect. Tests still catch only a proper subset of what static typing + tests catch together. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From aleaxit at yahoo.com Mon Mar 12 04:01:17 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 12 Mar 2001 10:01:17 +0100 Subject: Static typing (was Re: Java guy interested in Python) References: Message-ID: <98i38q0nht@news2.newsguy.com> "Tim Peters" wrote in message news:mailman.984371806.20230.python-list at python.org... [snip] > > class int { [snip] > > Isn't this perfectly legal C++, meaning something very different from [snip] > As in the "Einstein's Riddle" thread, I was doing Rainer the favor of > assuming he was trying to say something . If I don't extend you the > same favor, then before I can answer your question I have to be assured of a > great many things, such as that e.g. this fragment isn't in the scope of > > #define char const Right -- that was supposed to be the intended-to-be-humorous-but-telling point (that one never can tell without a lot of context what 'only thing' a piece of C++ can mean, due in part but not only to the preprocessor -- a snide-but-valid implied criticism of C++ [and C]). But it does fall totally flat on re-reading. My apologies. Alex From JollyRoger at hotmail.com Sun Mar 4 21:42:08 2001 From: JollyRoger at hotmail.com (Bartok) Date: Sun, 4 Mar 2001 19:42:08 -0700 Subject: Newbie question about nested lists and constructor functions... Message-ID: I need some help with nested lists when using class constructors to initialize their contents. I found the tutorial to be of not much help in this area and have tried everything that I can think of. I understand the process as I am an experienced C++ programmer but I seem to be having some difficulty using the correct syntax. Can anyone please help? Thanks. Norm From thomas at xs4all.net Fri Mar 9 22:51:54 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sat, 10 Mar 2001 04:51:54 +0100 Subject: gah! I hate the new string syntax In-Reply-To: ; from jwbnews@scandaroon.com on Fri, Mar 09, 2001 at 06:13:20PM -0800 References: <98amlj01sp6@news2.newsguy.com> <98asrq$645$1@panix6.panix.com> Message-ID: <20010310045154.K404@xs4all.nl> On Fri, Mar 09, 2001 at 06:13:20PM -0800, John W. Baxter wrote: > And at least one of the US Clipper ships finished a New York to San > Fransicso voyage under the command of the Captain's widow. The captain > died en route. The wife was aboard as navigator (being better at the > task than the mate), and the crew made it clear that things would go > much better with her in command than with the mate in command. Sorry, I > don't have a reference handy (and the right Google search for this one > could be a bit tricky to create). Not at all: http://www.propellerclubhq.com/wpc/marys.htm Recipe: type in "clipper captain wife navigator" and click on "I'm Feeling Lucky". At least, the story is so similar that I assume it's the same one :) -- Thomas Wouters The Python Software Foundation: http://www.python.org/psf.html Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From erno-news at erno.iki.fi Tue Mar 6 09:37:28 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 06 Mar 2001 16:37:28 +0200 Subject: I come to praise .join, not to bury it... References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> <982a4f0su3@news1.newsguy.com> <1e6p6.27206$1D5.1119285@e420r-atl1.usenetserver.com> Message-ID: In article <1e6p6.27206$1D5.1119285 at e420r-atl1.usenetserver.com>, "Steve Holden" writes: | "Erno Kuusela" wrote in message | news:kuofvfjb77.fsf at lasipalatsi.fi... || it could also be argued that python uses whitespace instead || of braces because of vague aesthetic shared by lots of people. :) | Well it could be argued, but you could also look at the usability data which | (I understand) was the basis of this choice when Python was originally | designed. aha! clearly, we need a usability study on string methods. -- erno From ws-news at gmx.at Tue Mar 13 17:14:04 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Tue, 13 Mar 2001 23:14:04 +0100 Subject: This math scares me References: <3aad4062.1290021@News.CIS.DFN.DE> <20010312170356.B3513@better.net> <984486395.407379@newsmaster-04.atnet.at> <984518199.127140@newsmaster-04.atnet.at> Message-ID: <984521930.27710@newsmaster-04.atnet.at> > Bill Gates got this right in the early days, delivering two Basic > interpreters: binary floating point for speed, and decimal floating > point for money and such. (I never looked at how well his interpreters > did...I just used them.) Does this make a difference, as soon as arithmetics takes place? I think not, it will not be _exact_ results in both ways. Just storing and retrieving numbers is probably not a very common task (why convert it for nothing? maybe for reduced size compared to a string...) My work is not in financial software, but I would certainly not use floating point for this kind of problem. I think Windows supports for a 'Currency' data type with some APIs but never used them... regards werner From pfortin at pfortin.com Wed Mar 14 09:50:42 2001 From: pfortin at pfortin.com (Pierre Fortin) Date: Wed, 14 Mar 2001 09:50:42 -0500 Subject: PyQT-2.3 compile fails... References: <3AAEBCCA.4E53671@pfortin.com> <98n3if$kol$1@news1.xs4all.nl> Message-ID: <3AAF8542.B79A880@pfortin.com> Boudewijn Rempt wrote: > > Pierre Fortin wrote: > > Hi, > > > Anyone have a clue as to why others can compile PyQT-2.3; but I get errors...? > > I've also tried the CVS files... > > > I'd hate to think this is a symlink related problem: > > /usr/local/src --> /hd/b6/src > > > Thanks, > > Pierre > > > # make > > make all-recursive > > make[1]: Entering directory `/hd/b6/src/Python/PyQt-2.3' > > Making all in qt > > make[2]: Entering directory `/hd/b6/src/Python/PyQt-2.3/qt' > > /bin/sh ../libtool --mode=compile c++ -DHAVE_CONFIG_H -I. -I. -I.. > > -I/usr/local/include/python2.0 -I/usr/local/include/sip -I/usr/local/qt/include > > -I/usr/X11R6/include -fno-exceptions -O2 -c sipqtQString.cpp > > c++ -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/local/include/python2.0 > > -I/usr/local/include/sip -I/usr/local/qt/include -I/usr/X11R6/include > > -fno-exceptions -O2 -Wp,-MD,.deps/sipqtQString.pp -c -fPIC -DPIC > > sipqtQString.cpp -o sipqtQString.lo > > sip/qstring.sip: In function `int sipConvertTo_QString(PyObject *, QString **, > > int, int *)': > > sip/qstring.sip:456: no matching function for call to `QString::setUnicodeCodes > > (short unsigned int *&, int &)' > > make[2]: *** [sipqtQString.lo] Error 1 > > make[2]: Leaving directory `/hd/b6/src/Python/PyQt-2.3/qt' > > make[1]: *** [all-recursive] Error 1 > > make[1]: Leaving directory `/hd/b6/src/Python/PyQt-2.3' > > make: *** [all-recursive-am] Error 2 > > Has sip been compiled with Qt support? Do you have a Qt > 2.x? I would hope so... ./configure --help gives: --enable-qt enable Qt signal/slot support [default=yes] I picked up all the *-2.3 stuff from TrollTech before starting any compiles... sip & qt were made/installed without problem. Thanks, Pierre > -- > > Boudewijn Rempt | http://www.valdyas.org -- Linux (Up 26 days) -- Reboots are for system upgrades... not Windows X^P Last reboot reason: 02/14/01: testing startup changes for DSL From vlouie at telusplanet.net Sun Mar 25 16:46:00 2001 From: vlouie at telusplanet.net (Victor Louie) Date: Sun, 25 Mar 2001 21:46:00 GMT Subject: sorting dictionaries? Message-ID: Hi I was just wondering if anyone knows how to sort a dictionary by value...since the dictionary is and where my value is a list. Thanks in advance Victor From f8dy at yahoo.com Fri Mar 30 14:40:27 2001 From: f8dy at yahoo.com (Mark Pilgrim) Date: Fri, 30 Mar 2001 14:40:27 -0500 Subject: htmllib samples References: <3AC2F48E.4EF77C71@aon.at> Message-ID: <9a2nb4$3d8nd$1@ID-77331.news.dfncis.de> "Oliver Vecernik" wrote in message news:3AC2F48E.4EF77C71 at aon.at... > Hi, > > has anyone got some samples or point me to where to find them on how to > implement this module? http://diveintopython.org/dialect_divein.html -- -M You're smart; why haven't you learned Python yet? http://diveintopython.org/ From duncan at rcp.co.uk Thu Mar 15 05:09:05 2001 From: duncan at rcp.co.uk (Duncan Booth) Date: Thu, 15 Mar 2001 10:09:05 +0000 (UTC) Subject: [Q] Bug in Python? References: Message-ID: "Daehyok Shin" wrote in : >Recently, I met a strange behavior of Python 6.1. > Will someone please lock up that time machine! From TCHUR at doh.health.nsw.gov.au Sun Mar 11 19:23:24 2001 From: TCHUR at doh.health.nsw.gov.au (Tim CHURCHES) Date: Mon, 12 Mar 2001 11:23:24 +1100 Subject: Subclass factories? Message-ID: Is it Pythonic to use a factory function to create subclasses? The context is a system designed to be used by non-programmers. What I would like to do is to create a subclass factory function which accepts various parameters (sorry, arguments) from the end-user, does various sanity checks on these arguments, and then creates a new class which inherits from a predefined superclass and uses the arguments to overide various attributes and/or methods from the superclass, and finally to create an instance of the new class (and return that instance). In other words, allow end users to create subclasses without having to understand the class statement (remember, they are non-programmers). Or perhaps I should rephrase the question: "Is it possible to use a factory function to create instances of a class in which that instance's methods (as well as its attributes) are specialised? Such specialisation would normally be done by subclassing. Can that be wrapped in a function?" If the subclass factory approach is reasonable, what is the best way to do it? So far I been assembling the necessary statements for the new class definition into a string then exec'ing that string, but that seems rather inelegant. I'm sure there must be a better way. The overall design goal is to provide end-users with a set of functions which they can issue at the Python prompt (or in scripts) to get most things done (i.e. "most things" within the proscribed problem domain), without preventing them from using more general Python syntax (such as the class statement) if/when they progress to that. BTW, regarding the "Einstein's Riddle" thread (and not wanting in any way to promote off-topic traffic...), surely no-one owns the fish because Schrodinger's cat ate it? Tim C From phil at river-bank.demon.co.uk Thu Mar 1 06:18:35 2001 From: phil at river-bank.demon.co.uk (Phil Thompson) Date: Thu, 01 Mar 2001 11:18:35 +0000 Subject: COMMERCIAL: BlackAdder v1.0Beta2 Available Message-ID: <3A9E300B.8EA0F0C2@river-bank.demon.co.uk> The second Beta version of the BlackAdder Windows/Linux Python/Qt development environment is now available from http://www.thekompany.com/products/blackadder/. Revised screenshots are at http://www.thekompany.com/products/blackadder/screenshots/. The major changes since the previous Beta include: - The user interface has been re-designed to make it much easier to navigate and to make better use of the available screen space. - The debugger now automatically displays local and global objects of any selected frame. The objects displayed can be filtered according to their type. - Many features (particularly the Python editor) are now configurable from the Preferences dialog. These include hard/soft tabs, tab width, automatic indentation, fonts, colors, visible white space and indentation guides. - The inclusion of Qt v2.2.4. Phil From KatMouse at gmx.de Mon Mar 19 16:05:31 2001 From: KatMouse at gmx.de (Eduard Hiti) Date: Mon, 19 Mar 2001 22:05:31 +0100 Subject: How to increase PythonWin v2.0: COM browser limits? References: <994psh$so5$1@news1.xs4all.nl> Message-ID: <995sda$beu$06$1@news.t-online.com> In my experience this is a bogus error message. It could be that the problem lies elsewhere: maybe a registry corruption or a Pythonwin bug. Eduard "Twan van der Schoot" wrote in message news:994psh$so5$1 at news1.xs4all.nl... | I'm trying to use the COM Browser in Pythonwin version 2.0. But I run into | limitations of some kind. As a Python newby I dutifully scanned FAQs and | newsgroups, but alas! | | To reproduce the problem: On a heavily used NT 4.0 system with a lot of | registered COM stuff, start Pythonwin version 2.0 go to the menu entry: COM | Browser to start the COM browser and expand the "Registered Categories" | branch in the tree view. | | Pythonwin shows in the interactive window a backtrace on an exception. The | culprit raising this exception was the response: | | File "D:\Python20\win32com\client\util.py", line 53, in __GetIndex | result = self._oleobj_.Next(1) | pywintypes.com_error: (-2147024882, 'Not enough storage is available to | complete this operation.', None, None) | win32ui: Exception in OnNotify() handler | | Something suggests that the number of registered objects is too large for | the COM browser. As I've -of course- the sources available, I was wonder if | there is some parameter which I can increase to solve the problem. Or am I | running into limitations of the treeview control of MS Windows? | | TIA | | Twan van der Schoot | twanvds at NOSPAM.xs4all.nl | | From mwh21 at cam.ac.uk Fri Mar 9 07:47:01 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 09 Mar 2001 12:47:01 +0000 Subject: Can anyone recomend a good intoduction to C... References: <989mbk$24nuv$1@fido.engr.sgi.com> Message-ID: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) writes: > Language interoperability is fun. > > working-on-Haskell<->Python-binding-ly y'rs Really? I've had thoughts about doing that, but drifted away from haskell for a while. Do you have anything to show for it yet? Cheers, M. -- ARTHUR: Don't ask me how it works or I'll start to whimper. -- The Hitch-Hikers Guide to the Galaxy, Episode 11 From jeremy at alum.mit.edu Thu Mar 1 15:52:41 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Thu, 1 Mar 2001 15:52:41 -0500 (EST) Subject: A counter-counter-proposal for PEP 236: #pragma( nested_scopes) In-Reply-To: References: <0Swn6.3324$TW.17061@tor-nn1.netcom.ca> Message-ID: <15006.46745.206128.996289@w221.z064000254.bwi-md.dsl.cnc.net> >>>>> "FL" == Fredrik Lundh writes: FL> But Python isn't supposed to grow lots of pragma-style settings. FL> There shouldn't be any "other things". There Should Only Be One FL> Language. FL> We're talking about two kinds of "directives" here: [skipping #1] FL> -- Experimental compiler features, which if successful will FL> become standard in the next release. Again, "directive" FL> doesn't work, since it makes "experimental" stuff look FL> "optional". A word of clarification: __future__ isn't about experimental features. Instead it is for bleeding edge users to use a new feature in release X even though the feature won't be standard until release Y, where X < Y. If we want to do experimental stuff, we should probably do something like: from __possible_world__ import __future__ from __future__ import ... Jeremy From ws-news at gmx.at Tue Mar 6 11:27:47 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Tue, 6 Mar 2001 17:27:47 +0100 Subject: Can anyone recomend a good intoduction to C... References: Message-ID: <983896344.701456@newsmaster-04.atnet.at> Hi Laura, The only reason I can imagine at this point to go with plain C is that there are a lot more platforms that support C than do support C++. This is mainly a topic in embedded development and realtime platforms. Since you can do almost anything in C++ that can be done in C with even the same syntax I think personally it is better to get the high level concepts first and learn to use of-the-shelve components like the standard library. The standard library of C++ is in my opinion much more intuitive and easy to use for a novice programmer than all that traditional C stuff. So I think, given a good guide like the one I recommended, one will be up and running much faster. In addition, you will not get into a lot of common pitfalls common in C programming. I further think it is easier to move 'back' from C++ to C, when the need arises, than vice versa. This is simply because you are forced to use a different technique if the one you are used to does not work on that platform. Personally I started with procedural programming and moved to the object oriented technique afterwards. This is why I think it is hard to get used to objects when you are used to malloc, free, memcpy and friends. Did I miss an important point? regards Werner Laura Creighton wrote in message news:mailman.983894288.19965.python-list at python.org... > Werner Schiendl writes: > >If you have a good reason to choose C over C++, take the K&R book the others > >recommend. > > > >Otherwise you should consider going straight to C++. > >This will save you hours of headache with C memory stuff, string handling, > >and so on. > > This leaves the novice with the idea that C programmers, by and large > all became happy C++ programmers and are pleased as punch with the > new language. The reason to learn C is to eventually learn C++. > This is misleading. > > There are a very large number of people who think that C > is a terrific language; extremely good at what it does, and well worth > studying, in part to understand what it is that a language designer > does when he *gets* *it* *right*, while also believing that studying C++ is > of particular use when you want to see what happens when a language > designer *gets* *it* *wrong*. Or when forced to do so at gunpoint. > > Laura Creighton > From aleaxit at yahoo.com Thu Mar 15 08:00:14 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 15 Mar 2001 14:00:14 +0100 Subject: I come to praise .join, not to bury it... References: <97p7iq$kk2$1@nntp6.u.washington.edu> <97rka002k9@news1.newsguy.com> <3AAF7E47.294617E1@sage.att.com> Message-ID: <98qeco02hn7@news1.newsguy.com> "Garry Hodgson" wrote in message news:3AAF7E47.294617E1 at sage.att.com... > Alex Martelli wrote: > > > I have not heard ANY _technical_ arguments opposed to > > this last time the discussion went around -- nothing but > > vague aesthetic, "it should be the other way", "I find it [snip] > don't be too quick to write off Aesthetics. it's a significant > part of what attracted me to python (i'd seen enough curly braces > and semicolons to last me a lifetime). avoiding scaring off newbies > until they've had time to appreciate other virtues is not a Bad Thing. And then again, the _appearance_ that too much emphasis was being placed on syntax-sugary issues kept me *AWAY* from Python for longer than it should have -- sure, sure, I could save some punctuation, but, *WHAT DID I CARE*?! Good thing (for me) that I eventually looked beyond the pretty face, of course:-). But, appearing to care about looks more than about substance _is_ going to keep away some people (just as it is going to attract others), so, it's not a clear "win" either way, even if you just frame it as a popularity-race. Focus on *substance*, on the other hand, is going to be a win for all who _are_ involved with Python -- not just those who happen to be on the "I like it" side vs the "I like it not" one (and I've never seen any argument about _aesthetics_ [as opposed to _usability_ -- human-factors studies DO have a substantial side too:-)] that doesn't boil down to such trifles]). Alex From trentm at ActiveState.com Fri Mar 9 18:34:50 2001 From: trentm at ActiveState.com (Trent Mick) Date: Fri, 9 Mar 2001 15:34:50 -0800 Subject: IPC9 quotes wanted In-Reply-To: ; from amk@mira.erols.com on Fri, Mar 09, 2001 at 06:38:59PM +0000 References: Message-ID: <20010309153450.D4002@ActiveState.com> On Fri, Mar 09, 2001 at 06:38:59PM +0000, A.M. Kuchling wrote: > I intended to put a note on the message board about this, but > forgot... If you were at IPC9 and heard someone say something > quotable, please let me know who it was and what they said, so that it > can be added to the quotation file. Thanks! > > (I reserve the right to not add quotations, so don't feel bad if your > submitted quotation doesn't get in.) Tim Peters: You can't stop people from complaining, but you *can* control what they complain about. -- while moderating the "Overhaul Python's Numerical Model" seminar. Bruce Eckel: Perl is like vise grips. You can do anything with it but it is the wrong tool for every job. Trent -- Trent Mick TrentM at ActiveState.com From grante at visi.com Sat Mar 31 19:32:22 2001 From: grante at visi.com (Grant Edwards) Date: Sun, 01 Apr 2001 00:32:22 GMT Subject: Know of Substantial Apps Written in Python? References: Message-ID: In article , Tim Peters wrote: >[Moshe Zadka] >> ... >> Python would never fit on a floppy. > >Sure it can! Python + the entire base std library (top level >of Lib/) still fits on a floppy with ease, if you use any >common compression scheme. Just for fun, I just built a zip >file with that stuff for the Windows 2.1b2 distribution, and it >came in at just over a tad above 1Mb (so about 70% of one >floppy). I assume that Moshe meant that it will never fit on a single-floppy Linux system. Python isn't much good with no OS to run it. Ash/bash is already there as a command line shell, so there's no incremental cost in having startup scripts written in shell. A 1M incremental cost for writing them in Python would be out of the question. Other than increased maintenance costs, there's no reason you can't stick with ash/bash/sh scripts for floppy systems and Python scripts for full-up systems. -- Grant Edwards grante Yow! With this weapon at I can expose fictional visi.com characters and bring about sweeping reforms!! From andreas at andreas-jung.com Wed Mar 21 17:13:59 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Wed, 21 Mar 2001 17:13:59 -0500 Subject: os.system output References: <20010321180207.A24260@father> Message-ID: <000001c0b266$10274030$9865fea9@SUXLAP> ----- Original Message ----- From: "Kalle Svensson" > > Check out os.popen(). > > >>> dirs = os.popen("ls").read() or commands.getstatusoutput() which is actually a wrapper around os.popen() Andreas Digital Creations From s2mdalle at titan.vcu.edu Thu Mar 1 18:53:33 2001 From: s2mdalle at titan.vcu.edu (David Allen) Date: Thu, 01 Mar 2001 23:53:33 GMT Subject: Tkinter: image doesn't exist. Message-ID: <1iBn6.1691$Ry6.649664@typhoon2.ba-dsg.net> When I run this line of code: self.symbol = self.widget.create_image(x, y, image=fooimage) I get this error: File "./FooModule.py", line 87, in __init__ self.symbol = self.widget.create_image(x, y, image=fooimg) File "/usr/lib/python1.5/lib-tk/Tkinter.py", line 1223, in create_image return self._create('image', args, kw) File "/usr/lib/python1.5/lib-tk/Tkinter.py", line 1216, in _create (self._w, 'create', itemType) TclError: image "137289752" doesn't exist I've talked to several people and they though this might be because the image is getting garbage collected, but I've verified that GC is *not* the issue. I replaced fooimg with an actual PhotoImage constructor (fooimg is a PhotoImage) with valid data, and it still does the exact same thing. What kind of a crappy error message is "image doesn't exist?" How would I fix it? Any help would be greatly appreciated. -- David Allen http://opop.nols.com/ ---------------------------------------- Der Horizont vieler Menschen ist ein Kreis mit Radius Null -- und das nennen sie ihren Standpunkt. From mkc at mathdogs.com Mon Mar 26 19:42:21 2001 From: mkc at mathdogs.com (Mike Coleman) Date: 26 Mar 2001 18:42:21 -0600 Subject: fixing map(None, [1,2,3]) ? In-Reply-To: References: Message-ID: <87y9ts2gb6.fsf@mathdogs.com> "Sean 'Shaleh' Perry" writes: > On 26-Mar-2001 Mike Coleman wrote: > > Shouldn't "map(None, [1,2,3])" return "[(1,), (2,), (3,)]"? > > > > Is there any hope that this could be fixed? > > > map runs the function on each element of the list it is passed and returns an > element of a new list. Why should it magically return a list of one-tuples? The (documented) behavior of map when 'None' is given instead of a function is special. It would be very useful, too, except for the problem cited above: $ python Python 1.5.2 (#0, Apr 3 2000, 14:46:48) [GCC 2.95.2 20000313 (Debian GNU/Linux)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> map(None, [1, 2, 3], [4, 5, 6]) [(1, 4), (2, 5), (3, 6)] >>> map(None, [1, 2, 3], [4, 5, 6], [7, 8, 9]) [(1, 4, 7), (2, 5, 8), (3, 6, 9)] >>> map(None, [1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]) [(1, 4, 7, 10), (2, 5, 8, 11), (3, 6, 9, 12)] >>> map(None, [1, 2, 3]) [1, 2, 3] # shouldn't that be [(1,), (2,), (3,)]? >>> map(None) Traceback (innermost last): File "", line 1, in ? TypeError: map() requires at least two args # returning [] in this case would be nice for completeness (Certainly I could be missing something here.) --Mike -- Mike Coleman, mkc at mathdogs.com http://www.mathdogs.com -- problem solving, expert software development From hamish_lawson at yahoo.co.uk Tue Mar 27 05:38:55 2001 From: hamish_lawson at yahoo.co.uk (=?iso-8859-1?q?Hamish=20Lawson?=) Date: Tue, 27 Mar 2001 11:38:55 +0100 (BST) Subject: running code from "Scripting The Web with Python" Message-ID: <20010327103855.23536.qmail@web206.mail.yahoo.com> Eugene Leitl wrote: > I've snipped the following code from Guido's > http://www.w3j.com/6/s3.vanrossum.html presentation: > ... I can't run it due to syntax errors Wow, they really messed up the formatting on that! Below is the properly formatted version. Hamish Lawson --- import StringIO import SimpleHTTPServer BaseClass = SimpleHTTPServer.SimpleHTTPRequestHandler CounterTemplate = """

Server Statistics

This
server has been accessed %d times. """ count = 0 class MyRequestHandler(BaseClass): def do_GET(self): global count count = count + 1 BaseClass.do_GET(self) def send_head(self): if self.path == "/counter.html": return self.send_counter() else: return BaseClass.send_head(self) def send_counter(self): self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() text = CounterTemplate % count return StringIO.StringIO(text) def test(): SimpleHTTPServer.test(MyRequestHandler) test() ____________________________________________________________ Do You Yahoo!? Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk or your free @yahoo.ie address at http://mail.yahoo.ie From fredrik at pythonware.com Thu Mar 22 11:10:12 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 22 Mar 2001 16:10:12 GMT Subject: New PEP: The directive statement References: Message-ID: Martin von Loewis wrote: > Generalization is a dangerous thing: you can too easily cross the > border to over-generalization. also known as "hypergeneralization" in the Python universe: http://www.google.com/search?q=hypergeneralization Cheers /F From cribeiro at mail.inet.com.br Sat Mar 31 09:15:10 2001 From: cribeiro at mail.inet.com.br (Carlos Alberto Reis Ribeiro) Date: Sat, 31 Mar 2001 11:15:10 -0300 Subject: Know of Substantial Apps Written in Python? In-Reply-To: <3AC55CC8.44850ECF@seebelow.org> References: <3ac4e4a8_1@news4.newsfeeds.com> <3ac4ff12$1_2@news4.newsfeeds.com> Message-ID: <5.0.2.1.0.20010331111123.021eb0d0@mail.inet.com.br> At 22:27 30/03/01 -0600, Grant Griffin wrote: >Rumor has it that Google is implemented in Python. (OK, maybe not _all_ >of it. ) Not only Google, but substantial parts of Yahoo! site, including the entire yahoo mail interface (you can actually see th .py endings in many pages). Also in Python: - Infoseek/Ultraseek server (core library in C, bind to Python) - The RedHat installer - MojoNation As for Sketch, the FAQ answer your question. The main problem is that the stable version of Tk was not ported to Windows, and there are some low level stuff that wasn't ported either. Please also refer to the Software Carpentry contest. Carlos Ribeiro From moshez at zadka.site.co.il Sat Mar 24 05:16:37 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sat, 24 Mar 2001 12:16:37 +0200 Subject: How 2 get rid of console In-Reply-To: References: Message-ID: On Sat, 24 Mar 2001 05:00:43 -0500, "Bill Walker" wrote: > I'm using Tkinter to build a GUI application. How do I get rid of the > distracting dos console under the Tk window? Run it with "pythonw" and not with "python". One way to do it is to rename the script "something.pyw". Usually, it's better to say what platform you're working on instead of letting people guess (Win32?) -- "I'll be ex-DPL soon anyway so I'm |LUKE: Is Perl better than Python? looking for someplace else to grab power."|YODA: No...no... no. Quicker, -- Wichert Akkerman (on debian-private)| easier, more seductive. For public key, finger moshez at debian.org |http://www.{python,debian,gnu}.org From mlh at idi.ntnu.no Fri Mar 2 16:31:33 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Fri, 2 Mar 2001 22:31:33 +0100 Subject: Thinking Pythonically (was Re: gah! I hate the new string syntax) References: <97ohh2$polt0$1@ID-77331.news.dfncis.de> <97opsb$nhu$1@nntp6.u.washington.edu> <97oupq$qijrh$1@ID-77331.news.dfncis.de> Message-ID: <97p3mh$bkm$1@tyfon.itea.ntnu.no> "Mark Pilgrim" wrote in message news:97oupq$qijrh$1 at ID-77331.news.dfncis.de... [snip] > >>> [line for line in output if line[:4]=='Tag:'] > ['Tag: /vobs/intranet\\012', 'Tag: /vobs/project\\012'] > > Now I think: OK, I have a list of the lines I want, but I just want the > name, not the "Tag:" prefix or all the whitespace. > > >>> vobs = [line.replace('Tag:', '').strip() for line in output if > line[:4]=='Tag:'] > >>> vobs > ['/vobs/intranet', '/vobs/project'] I can't resist fiddling with little snippets of code... Why don't you use: >>> vobs = [line[4:-1] for line in output if line[:4] == 'Tag:'] Oh, well... -- Magnus Lie Hetland http://www.hetland.org "Reality is what refuses to disappear when you stop believing in it" -- Philip K. Dick From thomas at xs4all.net Fri Mar 9 16:20:34 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 9 Mar 2001 22:20:34 +0100 Subject: News from Python9!!! In-Reply-To: <20010308161415.C30277@mediasupervision.de>; from gregor@mediasupervision.de on Thu, Mar 08, 2001 at 04:14:15PM +0100 References: <20010308161415.C30277@mediasupervision.de> Message-ID: <20010309222034.I404@xs4all.nl> On Thu, Mar 08, 2001 at 04:14:15PM +0100, Gregor Hoffleit wrote: > On Thu, Mar 08, 2001 at 03:21:17AM +0000, Don Tuttle wrote: > > 4)And a bugfix release of Python 2.0 has been released. It includes PPM > > (Programmer's Package Manager ) to make finding and installing Python > > modules simple. > Shouldn't this read 'bugfix release of ActivePython 2.0' ? It should. A bugfix release of 2.0 is forthcoming (for various reasons), and Guido did more or less announce that intention at the conference, but it's not released yet. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread!