From drewpc at colorado.edu Thu Feb 1 22:36:11 2001 From: drewpc at colorado.edu (drewpc at colorado.edu) Date: Thu, 01 Feb 2001 21:36:11 GMT Subject: Python and Industry References: <20010111172342.10148.00000934@ng-ca1.aol.com> Message-ID: <95cksa$e2d$1@nnrp1.deja.com> In article <20010111172342.10148.00000934 at ng-ca1.aol.com>, crutoy at aol.com (Crutoy) wrote: > Hi , does anyone know how widly in an instries does python being used ? I > looked at the syntax of it and read some stuff on it,it's interested i just > want to know if it's worth learning it. Thanks > I work at a large networking company, and it's used all over the place. Anywhere from maintaining over a hundred DNS server configs to configuring routers to pulling accounting information off of various telco gear. I'm constantly amazed at how widely it's used. Sent via Deja.com http://www.deja.com/ From qrczak at knm.org.pl Sat Feb 3 14:44:45 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 3 Feb 2001 13:44:45 GMT Subject: python compiled to native in less than a year? References: <8pF86.6015$J%.595435@news.flash.net> <0luc6toovfccbqspkvc0dkqkuc5dck7u51@4ax.com> <3A67341D.D5022902@businesscollaborator.com> Message-ID: Fri, 19 Jan 2001 12:44:59 -0500, D-Man pisze: > BTW, I've heard several references to C# on this list, with a high > concentration on this thread. Where can I find some sort of (short) > docs that describe what C# is? (an intro or overview type of thing) http://msdn.microsoft.com/vstudio/nextgen/technology/csharpintro.asp C# is very similar to Java. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From rerla at channing.harvard.edu Thu Feb 1 19:24:43 2001 From: rerla at channing.harvard.edu (Ross Lazarus) Date: Thu, 01 Feb 2001 13:24:43 -0500 Subject: Random and whrandom References: <94p31e02135@news2.newsguy.com> Message-ID: <3A79A9EB.701D1E96@channing.harvard.edu> Nice - and I found the documentation at http://www.stecf.org/~npirzkal/python/rv/rv-ref.html Also of potential interest to fellow prng consumers who need real speed - http://www.sbc.su.se/~per/crng/ - gives about 6 million/sec from the mersenne twister cf 7600/sec from rv twister (rv running on a slower pentium). Alex Martelli wrote: > As partial atonement for the sin and heresy of "Defending > Unnecessary Complexity In The Name Of Unwarranted Generality", > I've taken advantage of Frohne's very-generous copyright > provisions to put an rv.zip containing his rv.py 1.1 (from > November 1998) up for download at http://www.fenx.com/alex/rv.zip > (it's not a particularly fast or well-connected machine, but > the only one I can place something for anonymous dowload > right now -- I hope somebody will pick it up and place it > somewhere better accessible!). > From frohne at gci.net Fri Feb 2 01:35:33 2001 From: frohne at gci.net (Ivan Frohne) Date: Thu, 1 Feb 2001 15:35:33 -0900 Subject: Random and whrandom References: <94p31e02135@news2.newsguy.com> <3A79A9EB.701D1E96@channing.harvard.edu> Message-ID: "Ross Lazarus" wrote in message news:3A79A9EB.701D1E96 at channing.harvard.edu... > Nice - and I found the documentation at > http://www.stecf.org/~npirzkal/python/rv/rv-ref.html > > Also of potential interest to fellow prng consumers who need real speed > - http://www.sbc.su.se/~per/crng/ - gives about 6 million/sec from the > mersenne twister cf 7600/sec from rv twister (rv running on a slower > pentium). You can also find the documentation for the random number module rv 1.1 at http://www.frohne.westhost.com/rv11reference.htm and a ZIP archive containing the documentation and Python module rv.py at http://www.frohne.westhost.com/rv11.zip If you're still hungry, download http://www.frohne.westhost.com/mr_random.py which is a whrandom clone, 60% faster and with a period of 10**28 (vs 10**12 for whrandom). Ivan Frohne From aleaxit at yahoo.com Fri Feb 2 10:27:08 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 2 Feb 2001 10:27:08 +0100 Subject: Random and whrandom References: <94p31e02135@news2.newsguy.com> <3A79A9EB.701D1E96@channing.harvard.edu> Message-ID: <95duhc030kb@news1.newsguy.com> "Ross Lazarus" wrote in message news:3A79A9EB.701D1E96 at channing.harvard.edu... > Nice - and I found the documentation at > http://www.stecf.org/~npirzkal/python/rv/rv-ref.html > > Also of potential interest to fellow prng consumers who need real speed > - http://www.sbc.su.se/~per/crng/ - gives about 6 million/sec from the > mersenne twister cf 7600/sec from rv twister (rv running on a slower > pentium). Mersenne Twister looks like just the ticket when what you're doing is "shuffling a sequence" (or "stirring" it, in crng terms -- or, also, using 'choose' or 'sample' to get subsets or subsequences, with or without repetition/permutation), the point being that its huge period gives you a _chance_ of selecting subsets/permutations/samples in a way that makes all possible ones roughly equally-likely (but I don't think this has ever been *proved* -- it's just that MT has some *chance*, when RNG's with shorter periods clearly don't). Speed can also become quite relevant here. Say you're shuffling a deck of 52 cards -- there are about 8.0e+67 permutations (52!), and getting one permutation requires about 50 random numbers (with the normal Knuth approach). A typical task in bridge studies is to deal out a huge variety of deals and throw away all except those meeting certain specified criteria -- and it's not unusual for those criteria to have an a priori chance of, say, one in a million, so one needs about 50 million random numbers per each significant deal produced for study (at least when such safe brute-force Montecarlo approaches are used; clever accelerations are possible but run serious risks of double-counting or subtle distortions if one is not incredibly careful in setting conditions up). This translates to about 8 seconds per significant deal with crng, versus about 2 hours per deal with rv, with the numbers you quote (actually, it WILL take, even in the best case, a couple of milliseconds at least to study and discard each deal produced, so the ratio is not all that dramatic: 2000+ seconds per produced deal with crng, vs almost 9000 with rv -- which is why one stays motivated to produce the 'clever accelerations' above mentioned, but that's another issue -- still, a 4:1 ratio *is* achievable for a brute force approach here). Alex From Pekka.Pessi at nokia.com Mon Feb 5 01:14:29 2001 From: Pekka.Pessi at nokia.com (Pekka Pessi) Date: 05 Feb 2001 02:14:29 +0200 Subject: How do I know all thrown exceptions of a function? References: <94d93h$55d$1@troll.powertech.no> <3A6B24F0.EA164698@gte.net> <94icr2$6kv$1@animus.fel.iae.nl> <3A6CDBDA.C3120F98@gte.net> <94ipci$afo$1@animus.fel.iae.nl> <3A6CFD8E.BD473DFD@gte.net> <3A6D54CB.2261D535@gte.net> <94jo9u$h45$1@nnrp1.deja.com> <94jt7e01fil@news1.newsguy.com> Message-ID: In message "Fredrik Lundh" writes: >might so be, but I still cannot make any sense of his post. He says that according to the docs, "from tkinter include *" should be used instead of "include tkinter". The latter adds lot of unnecessary text, ie. cruft, into your program. Cruft makes your code harder to read. Are we feeling a little bit obtuse on purpose today? Pekka From fredrik at effbot.org Mon Feb 5 02:03:35 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Mon, 05 Feb 2001 01:03:35 GMT Subject: How do I know all thrown exceptions of a function? References: <94d93h$55d$1@troll.powertech.no> <3A6B24F0.EA164698@gte.net> <94icr2$6kv$1@animus.fel.iae.nl> <3A6CDBDA.C3120F98@gte.net> <94ipci$afo$1@animus.fel.iae.nl> <3A6CFD8E.BD473DFD@gte.net> <3A6D54CB.2261D535@gte.net> <94jo9u$h45$1@nnrp1.deja.com> <94jt7e01fil@news1.newsguy.com> Message-ID: Pekka Pessi wrote: > >might so be, but I still cannot make any sense of his post. > > He says that according to the docs, "from tkinter include *" should > be used instead of "include tkinter". The latter adds lot of > unnecessary text, ie. cruft, into your program. Cruft makes your > code harder to read. umm. *I* wrote the part on Tkinter, and I'm pretty sure I know what I meant with the original text. still don't know what Steve meant, and frankly, I don't really care. Cheers /F From sholden at holdenweb.com Mon Feb 5 00:14:05 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 4 Feb 2001 18:14:05 -0500 Subject: How do I know all thrown exceptions of a function? References: <94d93h$55d$1@troll.powertech.no> <3A6B24F0.EA164698@gte.net> <94icr2$6kv$1@animus.fel.iae.nl> <3A6CDBDA.C3120F98@gte.net> <94ipci$afo$1@animus.fel.iae.nl> <3A6CFD8E.BD473DFD@gte.net> <3A6D54CB.2261D535@gte.net> <94jo9u$h45$1@nnrp1.deja.com> Message-ID: wrote in message news:94jo9u$h45$1 at nnrp1.deja.com... > "sandj.williams at gte.net" wrote: > > I parse that to mean 'cruft'. > > Sorry, I cannot find 'cruft' in my dictionary. Did you mean > that Python's import statement doesn't work as described, that > Tkinter hasn't been designed to support from-import, or what? > > > > > Sent via Deja.com > http://www.deja.com/ > It's defined in the jargon file. See http://www.tuxedo.org/~esr/jargon.html regards Steve From sholden at holdenweb.com Fri Feb 2 22:07:37 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 2 Feb 2001 16:07:37 -0500 Subject: How do I know all thrown exceptions of a function? References: <94d93h$55d$1@troll.powertech.no> Message-ID: "D-Man" wrote in message news:mailman.980287769.21816.python-list at python.org... > On Tue, Jan 23, 2001 at 06:48:45PM +0000, Remco Gerlich wrote: [ ... ] > > | - Obviously trying to change exceptions that aren't caused by your code > | (like KeyboardInterrupt) is of no use. > > How about ComputerExplodingError :-). > Surely the only code which would cause this would be something which naiively executed the infamous HCF opcode? Is there an HCF equivalent in the Python bytecodes? regards Steve From sandj.williams at gte.net Sat Feb 3 05:05:41 2001 From: sandj.williams at gte.net (Steve Williams) Date: Sat, 03 Feb 2001 04:05:41 GMT Subject: How do I know all thrown exceptions of a function? References: <94d93h$55d$1@troll.powertech.no> Message-ID: <3A7B850F.E7188161@gte.net> Steve Holden wrote: > "D-Man" wrote in message > news:mailman.980287769.21816.python-list at python.org... > > On Tue, Jan 23, 2001 at 06:48:45PM +0000, Remco Gerlich wrote: > [ ... ] > > > > | - Obviously trying to change exceptions that aren't caused by your code > > | (like KeyboardInterrupt) is of no use. > > > > How about ComputerExplodingError :-). > > > Surely the only code which would cause this would be something which > naiively executed the infamous HCF opcode? Is there an HCF equivalent in > the Python bytecodes? > > regards > Steve Or even the IBM 7010 opcode 'Branch on Sleepy Operator.' From jafo at tummy.com Sat Feb 3 17:46:08 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Sat, 3 Feb 2001 09:46:08 -0700 Subject: How do I know all thrown exceptions of a function? In-Reply-To: ; from sholden@holdenweb.com on Fri, Feb 02, 2001 at 04:07:37PM -0500 References: <94d93h$55d$1@troll.powertech.no> Message-ID: <20010203094608.D4938@tummy.com> On Fri, Feb 02, 2001 at 04:07:37PM -0500, Steve Holden wrote: >naiively executed the infamous HCF opcode? Is there an HCF equivalent in >the Python bytecodes? Rockwell named a modem after it. For those who don't recall, HCF is the mythical Halt and Catch Fire opcode. As ISP tech support folks will attest, the Rockwell modems might as well have... On the exceptions thrown by a function, this is one of the things I liked about Java. It required that your functions either catch all exceptions generated within it, or that they declare that they will throw certain exceptions. Unfortunately, that's kind of hard to do in Python. Sean -- It often shows a fine command of a language to say nothing. Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From dnew at san.rr.com Sun Feb 4 01:22:47 2001 From: dnew at san.rr.com (Darren New) Date: Sun, 04 Feb 2001 00:22:47 GMT Subject: How do I know all thrown exceptions of a function? References: <94d93h$55d$1@troll.powertech.no> Message-ID: <3A7CA0D7.D8A40228@san.rr.com> Sean Reifschneider wrote: > For those who don't recall, HCF is > the mythical Halt and Catch Fire opcode. It's not mythical. It's one of the undocumented opcodes in a 6502, presumedly for testing during manufacturing. When you execute the HCF opcode, the chip starts cycling all the address lines, just counting thru all 65536 patterns, until you remove power. The person who discovered it assumed it was used before the chip was bonded into the carrier. I think all this was described in Byte back when mainstream programmers cared about 6502s. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. Ignorance can be cured. Naivety cures itself. From jafo at tummy.com Sun Feb 4 05:47:38 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Sat, 3 Feb 2001 21:47:38 -0700 Subject: How do I know all thrown exceptions of a function? In-Reply-To: <3A7CA0D7.D8A40228@san.rr.com>; from dnew@san.rr.com on Sun, Feb 04, 2001 at 12:22:47AM +0000 References: <94d93h$55d$1@troll.powertech.no> <3A7CA0D7.D8A40228@san.rr.com> Message-ID: <20010203214737.A29866@tummy.com> On Sun, Feb 04, 2001 at 12:22:47AM +0000, Darren New wrote: >It's not mythical. It's one of the undocumented opcodes in a 6502, Though Rockwell was probably the closest, I don't believe anyone has correctly implemented that opcode. ;-) Sean -- I took a Meyers-Briggs personality test and came out an SMTP. -- Sean Reifschneider, 2000 Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From ullrich at math.okstate.edu Fri Feb 2 15:58:08 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Fri, 02 Feb 2001 14:58:08 GMT Subject: pyXML support for XSL tranformations?? References: <94d1tj$6sa$1@nnrp1.deja.com> <3a6aef10.3738521@nntp.sprynet.com> <3A7232DB.C576B547@ogbuji.net> <94vg3k$ed9$1@nnrp1.deja.com> <3A7442FF.E1CFDF6D@ogbuji.net> Message-ID: <3a7ac7f1.3651537@nntp.sprynet.com> On Sun, 28 Jan 2001 16:04:18 GMT, Uche Ogbuji wrote: >"David C. Ullrich" wrote: > >> Once I got it working it went right onto my I-don't-see- >> how-you-guys-can-give-this-stuff-away list, btw - hope >> you don't have the idea I've been wanting my money >> back or anything. > >No, I just wanted to have things clear on the thread because there *was* >a time when installing 4Suite was a huge pain, and I'd like all to know >we've worked very hard to make it a breeze (with some help from Greg >Ward and distutils). The install (probably a year or so ago) _was_ very easy. I may as well say what was so stupid about me: There was a spot in the instructions about unzipping to a "suitable" directory, with no definition of "suitable". Didn't take me long to figure out what was unsuitable about the directory I used. That led to copying some things over some things. I didn't replace a certain subdirectory that already existed cuz I wasn't sure whether anything was using that stuff already. The XSLT didn't work. Then I replaced python\xml\dom with the one that appeared when I unzipped your package and everything worked fine. The "uncleanliness" I was alluding to was having to modify part of an existing installation. But if I were not an idiot I would have chosen a suitable directory to begin with and I wouldn't have noticed the change. Or I would have noticed that the stuff in the directory I was reluctant to replace was _also_ an xml\dom from 4Thought - I thought for no good reason that it was a module from an entirely independent source so that replacing it would likely break something else. >> > There is no >> > reason why you can't download 4Suite-0.10.1.tar.gz, untar it, run >> > "python setup.py install", and be completely ready to go. >> >> You only think that because you're not stupid enough to find >> ways to screw it up... > >Well, we'd actually like 4Suite to be easy to install even for >non-Pythoneers. I think I just slipped through the cracks there - knew just enough to do it wrong. Not your fault. > That's because some of the features are completely >unique in XML space, and we think we can actually draw some XML users to >Python if they don't have to work too hard to get started. That's why >we put together the HOWTOs which even walk you though installing Python. > >> > But just in case, there are a 4Suite Installation HOWTOs for UNIX and >> > Windows. >> > >> > See >> > >> > http://services.4Suite.org/topics/rdf/Top/Documentation/HOWTOs > > >-- >Uche Ogbuji >Personal: uche at ogbuji.net http://uche.ogbuji.net >Work: uche.ogbuji at fourthought.com http://Fourthought.com From dave at dogwood.com Wed Feb 7 06:51:45 2001 From: dave at dogwood.com (Dave Cornejo) Date: Wed, 07 Feb 2001 05:51:45 GMT Subject: 2nd CFV: comp.soft-sys.wxwindows References: <980126365.16946@isc.org> Message-ID: <981525104.6624@isc.org> LAST CALL FOR VOTES (of 2) unmoderated group comp.soft-sys.wxwindows Newsgroups line: comp.soft-sys.wxwindows Discussions related to wxWindows framework. Votes must be received by 23:59:59 UTC, 12 Feb 2001. This vote is being conducted by a neutral third party. Questions about the proposed group should be directed to the proponent. Proponent: Vadim Zeitlin Votetaker: Dave Cornejo RATIONALE: comp.soft-sys.wxwindows This group should host the discussions about wxWindows (portable, free framework for writing GUI and console applications in C++, Python and Perl for a variety of platforms). wxWindows currently has a number of very busy mailing lists, creating a newsgroup should help people to participate in discussions about it without being overwhelmed by the number of messages. CHARTER: comp.soft-sys.wxwindows The comp.soft-sys.wxwindows newsgroup should be used for any discussions related to wxWindows framework without limitation to any language (although only C++, Python and Perl are currently supported) or platform (porting to a currently unsupported platform may be discussed here). Examples of correct postings include (but are not limited to) the following subjects: - questions related to using wxWindows - discussion of current or future wxWindows developments - bug reports and feature requests Examples of unwelcome postings: - questions about C or C++ language except when directly related to support for C++ feature or lack of thereof in wxWindows (e.g. "Should destructor of the base class be virtual?" is inappropriate while "How can I use exceptions with wxWindows?" is not). - platform-specific programming questions unrelated to wxWindows (specifically questions about Win32 API are unwelcome) - questions about using wxWindows answered in the FAQ - long (more than a few lines) patches - they should be submitted instead to the patch manager at the project Web site The newsgroup is not moderated. Posting of binaries and advertisement is not allowed. As an exception, advertisement is allowed for the announcement of products directly related to wxWindows (either written for wxWindows or using wxWindows). END CHARTER. HOW TO VOTE: Follow these instructions *exactly*! Votes are counted by computer. You should send E-MAIL (posts to a newsgroup are invalid) to: vote at dogwood.com Please do not assume that just replying to this message will work. Check the address before you mail your vote. Your mail message should contain one and only one of the following vote statements: I vote YES on comp.soft-sys.wxwindows I vote NO on comp.soft-sys.wxwindows Voter name: If your mail software does not indicate your real name (for example, AOL does not), include _exactly_ the statement above on a _separate_ line and add your name after the colon. Having your name in your signature line is NOT enough! Do NOT join the lines together or remove the words "Voter name"! You may also vote ABSTAIN (which records an empty vote) or CANCEL (which removes any earlier votes). ABSTAIN does not affect the final vote count in any way but is listed, whereas CANCEL is not. IMPORTANT VOTING PROCEDURE NOTES: Standard Guidelines for voting apply. One vote per person, one account per voter. Votes must be mailed directly from the voter to the votetaker. Anonymous, forwarded or proxy votes are not valid. Votes mailed by WWW/HTML/CGI forms are considered to be anonymous votes. Votes from non-existent email addresses are not valid. Vote counting is automated. Failure to follow these directions may mean that your vote does not get counted. If you do not receive an acknowledgment of your vote within three days contact the votetaker about the problem. It's your responsibility to make sure your vote is registered correctly. Duplicate votes are resolved in favor of the most recent valid vote. Addresses, names and votes of all voters will be published in the final voting results post. The purpose of a Usenet vote is to determine the genuine interest of persons who would read a proposed newsgroup. Soliciting votes from disinterested parties defeats this purpose. Please do not distribute this CFV. If you must, direct people to the official CFV as posted to news.announce.newgroups. Distributing pre-marked or otherwise edited copies of this CFV is generally considered to be vote fraud. When in doubt, ask the votetaker. DISTRIBUTION: In addition to the groups named in the Newsgroups: header, the CFV and the eventual RESULT posts will be mailed to these mailing lists: Mailing list name: wxwindows-devel Submission address: wxwindows-devel at lists.sourceforge.org Request address (optional): Mailing list name: wxwindows-users Submission address: wxwindows-users at lists.sourceforge.org Request address (optional): Mailing list name: wxpython-users Submission address: wxpython-users at lists.sourceforge.org Request address (optional): -- Voting question & problems: Dave Cornejo Voting address: vote at dogwood.com From dave at dogwood.com Fri Feb 23 08:31:14 2001 From: dave at dogwood.com (Dave Cornejo) Date: Fri, 23 Feb 2001 07:31:14 GMT Subject: RESULT: comp.soft-sys.wxwindows passes 164:13 References: <980126365.16946@isc.org> <981525104.6624@isc.org> Message-ID: <982913473.1281@isc.org> RESULT unmoderated group comp.soft-sys.wxwindows passes 164:13 There were 164 YES votes and 13 NO votes, for a total of 177 valid votes. There were 3 abstentions and 3 invalid ballots. For a group to pass, YES votes must be at least 2/3 of all valid (YES and NO) votes. There must also be at least 100 more YES votes than NO votes. A five day discussion period follows this announcement. If no serious allegations of voting irregularities are raised, the moderator of news.announce.newgroups will create the group shortly thereafter. Newsgroups line: comp.soft-sys.wxwindows Discussions related to wxWindows framework. Voting closed at 23:59:59 UTC, 12 Feb 2001. This vote was conducted by a neutral third party. Questions about the proposed group should be directed to the proponent. Proponent: Vadim Zeitlin Votetaker: Dave Cornejo RATIONALE: comp.soft-sys.wxwindows This group should host the discussions about wxWindows (portable, free framework for writing GUI and console applications in C++, Python and Perl for a variety of platforms). wxWindows currently has a number of very busy mailing lists, creating a newsgroup should help people to participate in discussions about it without being overwhelmed by the number of messages. CHARTER: comp.soft-sys.wxwindows The comp.soft-sys.wxwindows newsgroup should be used for any discussions related to wxWindows framework without limitation to any language (although only C++, Python and Perl are currently supported) or platform (porting to a currently unsupported platform may be discussed here). Examples of correct postings include (but are not limited to) the following subjects: - questions related to using wxWindows - discussion of current or future wxWindows developments - bug reports and feature requests Examples of unwelcome postings: - questions about C or C++ language except when directly related to support for C++ feature or lack of thereof in wxWindows (e.g. "Should destructor of the base class be virtual?" is inappropriate while "How can I use exceptions with wxWindows?" is not). - platform-specific programming questions unrelated to wxWindows (specifically questions about Win32 API are unwelcome) - questions about using wxWindows answered in the FAQ - long (more than a few lines) patches - they should be submitted instead to the patch manager at the project Web site The newsgroup is not moderated. Posting of binaries and advertisement is not allowed. As an exception, advertisement is allowed for the announcement of products directly related to wxWindows (either written for wxWindows or using wxWindows). END CHARTER. DISTRIBUTION: In addition to the groups named in the Newsgroups: header, the CFV and the eventual RESULT posts will be mailed to these mailing lists: Mailing list name: wxwindows-devel Submission address: wxwindows-devel at lists.sourceforge.org Request address (optional): Mailing list name: wxwindows-users Submission address: wxwindows-users at lists.sourceforge.org Request address (optional): Mailing list name: wxpython-users Submission address: wxpython-users at lists.sourceforge.org Request address (optional): comp.soft-sys.wxwindows Final Voter list Voted YES ------------------------------------------------------------------------------- peter#scully.com.au Peter Scully geldridg#progsoc.uts.edu.au Geoff Eldridge toivo#ucs.uwa.edu.au Toivo Pedaste Chris.Fama#uq.net.au Chris Fama praxhon#crl.be Philippe Raxhon Humphrey.Clerx#eurocontrol.be Humphrey Clerx ranma#mail.gargoyles.ch Thomas Haeberli robin#alldunn.com Robin Dunn teague#apicom.com Teague Sheridan Achim.Neumann#base-system.com Achim Neumann Alain.Culos#bigfoot.com Alain CULOS michaelteo#bigfoot.com Michael Teo pvlad#bigfoot.com P Vlad jumpo#bitex.com Angel Popov movits#BLOOMBERG.COM Mordechai Ovits biswapesh.chattopadhyay#bt.com Biswapesh Chattopadhyay grw#cabernet.com Greg Whitehead michael.kennedy#cognotec.com Michael Kennedy Onorio_Catenacci#compuware.com Onorio Catenacci dan#sol.control.com Dan L. Pierson francis.irving#creaturelabs.com Francis Irving rjh#cyberscience.com Richie Hindle carl#dgi.com Carl Godkin john#dgi.com John Skiff erlando#dnspilot.com =?iso-8859-1?Q?S=F8ren?= Erland =?iso-8859-1?Q?Vest=F8?= peter#engcorp.com Peter Hansen jfn#shell-1.enteract.com J.F.Nelson gtasker#fastpicsystems.com George Tasker emile#fcfw.fenx.com Emile van Sebille db3l#fitlinxx.com David Bolen Duane.Kaufman#med.ge.com Duane Kaufman Klaus-Guenter.Leiss#de.heidelberg.com Klaus - Guenter Leiss donod#home.com Don O'Donnell earthscibbs#home.com David Ramalho gregglsc#home.com Gregg=20 parz#home.com Parzival Herzog steve_frampton#hotmail.com Steve Frampton mtebeka#iil.intel.com Miki Tebeka lionel.allorge#lunerouge.com Lionel Allorge z3p#mailandnews.com z3p jbail#mak.com Jeff Bail tom#malcolmson.com Tom Malcolmson perry#modelspace.com Perry Miller fajuto#my-deja.com Francisco Fajuto gtalvola#nameconnector.com Geoffrey Talvola jc+usenet#port25.com Juergen Christoffel julians#redhat.com Julian Smart procyon#sensewave.com Lars Helgeland dbryson#techass.com Derry Bryson ry#teleport.com Ryan Gavin dima#testinsight.com Dima Angert kbrogers#thedigirati.com Kerry B. Rogers clstamper#theglobe.com Chris Stamper Alex.Martelli#think3.com Alex Martelli mfletch#tpresence.com Mike C. Fletcher xanthian#well.com Kent Paul Dolan Allen.Van.Sickel#usa.xerox.com Allen Van Sickel Carlo.Sans#usa.xerox.com Carlo Sans Loreene.Dixon#usa.xerox.com Loreene Dixon Marvin.Aviles#usa.xerox.com Marvin Aviles Richard.L.Clark#usa.xerox.com Richard Clark cpaul#xybion.com Carl A. Paul bwilk_97#yahoo.com Bill Wilkinson clarkcox3#yahoo.com Clark S. Cox, III jeffduska#yahoo.com Jeff Duska (Jeff#duska.com) jurus#cs.cas.cz Pavel Jurus v.slavik#volny.cz Vaclav Slavik axel#aroxis.de Axel Schlueter gerhard#bigfoot.de Gerhard Haering Gerhard.Gruber#coconet.de Gerhard Gruber Armin#exklusiv.de Armin K=F6nigsdorfer benndorf#pb.izm.fhg.de Kai Benndorf Wolfgang.Strobl#gmd.de Wolfgang Strobl amanjit.gill#gmx.de Amanjit Gill andorxor#gmx.de Stephan Tolksdorf bob.g#gmx.de Robert Gurk carsten.block#gmx.de Carsten Block Markus.Fieber#gmx.de Markus Fieber SchaeferFFM#gmx.de Oliver Schaefer Thomas_Krebs#gmx.de Thomas Krebs w_keller#gmx.de Wolfgang Keller a.larsen#identecsolutions.de Anders Larsen christof#pastors.de Christof Pastors svpeters#t-online.de Sven Peters hsauer#marnie.teuto.de Henning Sauer manfred.heumann#uni-bielefeld.de Manni Heumann Wolfram.Gloger#dent.med.uni-muenchen.de Wolfram Gloger hbachmann#vellum.de Horst Bachmann Ruediger.Maehl#web.de Ruediger Maehl bouvin#daimi.au.dk Niels Olof Bouvin dpw#CS.Arizona.EDU Don Waugaman fungus#OCF.Berkeley.EDU Hank Fung bkropf#ONLINE.EMICH.EDU Brian Kropf kjcole#gri.gallaudet.edu Kevin Cole steriana#claymore.engineer.gvsu.edu Andrew Sterian wsryu#fas.harvard.edu William Ryu jrl1#lehigh.edu John jmbowman#alum.mit.edu Jeremy Bowman amcmicha#Princeton.EDU Andrew McMichael dominicb#cvs.rochester.edu Dominic Barraclough matt#nephi.tamu.edu Matthew W. Roberts stabler#ucla.edu E Stabler jonathan.gilligan#vanderbilt.edu Jonathan M. Gilligan jeff#rufinus.cs.widener.edu J Rufinus clee#gnwy100.wuh.wustl.edu christopher lee paul.magwene#yale.edu Paul Magwene guille#iies.es Guillermo Rodriguez Garcia irm#nexo.es I.R.Maturana pedraza#datsi.fi.upm.es Jose L. Pedraza ts#UWasa.Fi Timo Salmi zeitlin#dptmaths.ens-cachan.fr Vadim Zeitlin af#eppra.polytechnique.fr Anton Frolov Gilles.Depeyrot#wanadoo.fr Gilles Depeyrot leonard.williams1#jsc.nasa.gov Leonard Williams newtons#gofree.indigo.ie Greg Newton dfrost#maths.tcd.ie Dermot Frost mau#beatles.cselt.it Maurizio Codogno mtbros#libero.it Mario Tola vtm#libero.it Lello Mele Nicola.Musatti#ObjectWay.it Nicola Musatti mbarbon#dsi.unive.it Mattia Barbon rol9999#attglobal.net Roland Schlenker greglandrum#earthlink.net Greg Landrum projectobjects#earthlink.net Earthlink rhkramer#fast.net Randy Kramer illume#gmx.net Paul C. Kunysch alexis.manning#gte.net Alexis Manning cbarker#jps.net Christopher Barker derek#leewo.net Derek M. A. Lee-Wo agold1#mediaone.net Arthur Goldhammer franke#meso.net Stefan Franke kneecap#netnet.net Neal Cappel dcfoxmail#netscape.net David Fox votefraud#pyrophore.ogoense.net UVV schaffer#optonline.net Les Schaffer randy#spoke.net Randall F. Kern skrenta#textport.net Rich Skrenta dogusanh#tr.net Hakki Dogusan rhet#turnbull.net Rhet Turnbull reed#zerohour.net Reed Hedges rcamesz#dds.nl Robert Amesz scarblac#pino.selwerd.nl Remco Gerlich joukj#hrem.stm.tudelft.nl J.Jansen a.t.hofkamp#tue.nl Albert Hofkamp p.g.m.vandermeulen#student.utwente.nl Pieter van der Meulen A.H.vandenBoogaard#wb.utwente.nl A.H. van den Boogaard faulds#es.co.nz Stuart Brodie Faulds BgPorter#acm.org Brett g Porter mbickel#asc-hq.org Martin Bickel tim.hochberg#ieee.org Timothy Hochberg richard#magicality.org Richard Palmer kedziers#mml.ch.pwr.wroc.pl Pawel Kedzierski orlov#diasoft.ru Oleg Orlov avv#quasar.ipa.nw.ru Alexander V. Voinov phd#mail2.phd.pp.ru Oleg Broytmann federico#carmen.se Federico Hernandez jonas#flintv210.sn.umu.se Jonas Rydberg zdravko.bas#iskratr.si Zdravko Bas paul.gammans#brunel.ac.uk Paul Gammans dag1000#eng.cam.ac.uk Diana Galletly jpmg#eng.cam.ac.uk Patrick Gosling biol75#york.ac.uk chris elliott jdg#diogenes.sacramento.ca.us John David Galt Voted NO ------------------------------------------------------------------------------- klaas#cs.dal.ca Michael Klaas LMcmil2586#aol.com Jeremy McMillan kimdv#best.com Kim DeVaughn stainles#bga.com Dwight Brown JEckart#mail.com John Eckart squid#panix.com Yeoh Yiu naddy#mips.inka.de Christian Weisgerber meg#Steam.Stanford.EDU meg worley rick#bcm.tmc.edu Richard H Miller dlganger#earthlink.net Devin L. Ganger mmontcha#OregonVOS.net Matthew Montchalin chriseb#ukshells.co.uk Chris Ebenezer jmulder#mighty.co.za Jeritt Mulder Abstained ------------------------------------------------------------------------------- mmrosa#bigpond.com Michal Rosa barkjr#home.com BarkerJr aahz#pobox.com Aahz Invalid ballots ------------------------------------------------------------------------------- pttlapinblanc#chez.com Stephane Junique ! Invalid email address someone#somewhere.com darren smith ! Invalid email address meow#best.com Meow Meow ! No vote statement in message To restore the email addresses above, pipe the ack list through the following command: sed -e 's/#/@/g' -- Voting question & problems: Dave Cornejo Voting address: vote at dogwood.com From doug at postsmart.net Sat Feb 3 07:00:34 2001 From: doug at postsmart.net (Doug Ball) Date: Sat, 3 Feb 2001 00:00:34 -0600 Subject: Python/C++ for graphics vs. other languages? References: <200101231452.IAA15405@starbase.neosoft.com> Message-ID: <001301c08da6$9fffc180$8a00000a@darwin.net> Cameron Laird Wrote: > Yes. Everything Mr. Wilson has written is > correct and applicable. > > I want to add a few remarks. Dylan, Common > Lisp, and OCaML are great languages. You > might have specific requirements that make > any of these ideal. Part of our confidence > in urging Python on you, though, is that even > for the situations where, say, OCaML is per- > fect, a well-crafted Python solution is likely > to lie only a small multiple away. > > "... [A] potentially large graphics intensive > program that will be speed sensitive ..." > covers a great deal of territory. We can give > more precise advice with more precise know- > ledge, of course. > . [snip] . >It's impos- > sible to know whether you're in the category > of projects where there's a significant differ- > ence, in the absence of more details. > -- > Thank you to all that have responded to my question pertaining to the suitability of programming in a combination of Python and C++ for graphical applications. Your guidance is insightful and I am very grateful. It has been pointed out that I have not provided enough information about my application to allow a proper assessment. Please forgive me, I have been unintentionally vague while I trying to be concise = ) I am working on a real-time 3d simulation of a medical procedure, to run on an Athlon 1.2 GHz machine under windows 2000. Probably using DirectX as an interface ( I don't know any OpenGL ). No force feed back or tactile simulation will be implemented. Thank you again to all who have responded, and if this information enables you to offer any further guidance I would be very grateful thanks! Doug From doug at postsmart.net Sat Feb 3 18:30:14 2001 From: doug at postsmart.net (Doug Ball) Date: Sat, 3 Feb 2001 11:30:14 -0600 Subject: Python/C++ for graphics vs. other languages? References: <200101231452.IAA15405@starbase.neosoft.com> <63bo7t4qrf0oebbj6hnni9tjjdip8hg5u8@4ax.com> Message-ID: <000501c08e06$f83a6b60$8a00000a@darwin.net> les schaffer wrote in response to a prior posting: > >I am working on a real-time 3d simulation of a medical procedure, to run on > >an Athlon 1.2 GHz machine under windows 2000. > > this sounds interesting. are you at liberty to divulge more details of > the project? Thanks for your interest! We will be working on an interactive simulation of electromyographically-guided Botulinum toxin injection. In this procedure, the practitioner places a needle into a muscle, generally guided by surface landmarks, then more specifically guided by the electrical signals produced when the muscle contracts (summated compound action potentials). Once the needle is placed, Botulinum toxin is injected, subsequently blocking the chemical signals than are responsible for controlling muscle contraction (it blocks the presynaptic vesicle from binding to the presynaptic membrane). This procedure is typically used for patients with severe muscle spasticity. The simulation user will have visual and auditory feedback from a 3D model of the patient and from the EMG-machine monitor. The user will indicate the initial location of needle placement, then will request that the patient model activates the target muscle. This action will result in a simulated signal on the EMG-monitor (with both visual and auditory components) that aids the user in further localizing the muscle, while adjusting the needle for optimal placement within the muscle. Our goal is to develop this application for physician education. Thanks again. Doug From nas at arctrix.com Thu Feb 1 11:59:55 2001 From: nas at arctrix.com (Neil Schemenauer) Date: Thu, 1 Feb 2001 02:59:55 -0800 Subject: Python vs Ruby In-Reply-To: <959mv0$qke$1@nnrp1.deja.com>; from hansboehm@my-deja.com on Wed, Jan 31, 2001 at 06:53:24PM +0000 References: <20010129111820.C15924@harmony.cs.rit.edu> <959mv0$qke$1@nnrp1.deja.com> Message-ID: <20010201025954.B24620@glacier.fnational.com> On Wed, Jan 31, 2001 at 06:53:24PM +0000, hansboehm at my-deja.com wrote: > [Neil Schemenauer] > > RC also works quite well with data caches and VM managers. Using > > the Boehm-Demers GC with Python and disabling reference counting > > slows the interpreter down by a significant amount. > > Are you sure the collector is working correctly, and not retaining > garbage for some reason? I looked at the source tree quickly, and it > appeared to me that the interpreter maintained a doubly linked list of > all Python objects? That would effectively keep the collector from > reclaiming anything. Is that list essential? That linked list is only used if the cyclic garbage collector is enabled. It has been quite a while since I played with your GC, before the linked list stuff was added to Python. > When I last looked at this 4 or 5 years ago, there were some other > issues that prevented a direct plug-in of a tracing collector. I think > some subsystems did their own free-list management. This tends to be a > pessimization with a tracing GC, especially if the objects on the free > list still point to other long-dead objects, etc. I couldn't find such > issues now, but I didn't look very hard. Those freelists are still there. I don't doubt that I could have made your GC perform better. My tests were very un-scientific and should not be given much weight. Mark and sweep GC will probably be considered for Python 3000 (at least I'm going to look at it again). > Reference counting tends to look considerably worse if you fully support > concurrency, so that you have to update reference counts with atomic > operations. Right, that is one of the big problems with "free threading" the current interpreter. Currently the interpreter is protected by one big lock. Again, this is probably something that will be considered in the Python 3000 design. Thanks for your comments. Neil From rtrocca at libero.it Thu Feb 1 20:12:05 2001 From: rtrocca at libero.it (Riccardo Trocca) Date: Thu, 01 Feb 2001 19:12:05 GMT Subject: what GUI, please advise References: <3A6F0B27.A88D11C9@crepido.com> <756399CF731B46D9.57530C0D0C9C2171.472E737DF76189F7@lp.airnews.net> <955na0$m4r2@news.qualitynet.net> Message-ID: <1eo5bx2.1jcwqo1dvno74N%rtrocca@libero.it> bashar A. Asad wrote: > > >>There seems to be several good options to choose from when > >>it comes to GUI developent with Python. > >> > >>Can someone say somthing, without killing each other with flames, what > >>GUI one should choose? > >> > >>Stupid and impossible question by the way as everything depends as > >>usual... but anyway.. Personally I've tried tkinter and pygtk. I really like pygtk, also because I can create the GUI with glade, save it in a XML file and load it on the fly. It is possible to modify the look and feel without rewriting your code. Anyway I've just started using it. Riccardo From pablo.prieto at dulcesol.es Tue Feb 13 11:42:05 2001 From: pablo.prieto at dulcesol.es (Pablo Prieto) Date: Tue, 13 Feb 2001 10:42:05 -0000 Subject: Python and postgreSQL ?? Message-ID: <009401c095a9$a54e7d10$150310ac@pablo> > You may also wish to consider the other postgresql/python interface > package, PoPy: http://popy.sourceforge.net > > I find it quite useful. Hi! I'd like to connect with PostgreSQL via Python. The program is in Windows (now), but will be executed, in few months, in Linux. I know I can use ODBC, but is there a Library or so that I can use in both OS', by meant to make the code 100% portable? I've downloaded popy, but looks like only for Linux env. Thanks in advance Yours sincerely, Pablo Prieto From stephen_purcell at yahoo.com Tue Feb 13 10:54:55 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 13 Feb 2001 10:54:55 +0100 Subject: Python and postgreSQL ?? In-Reply-To: <009401c095a9$a54e7d10$150310ac@pablo>; from pablo.prieto@dulcesol.es on Tue, Feb 13, 2001 at 10:42:05AM -0000 References: <009401c095a9$a54e7d10$150310ac@pablo> Message-ID: <20010213105455.A7121@freedom.puma-ag.com> Pablo Prieto wrote: > I'd like to connect with PostgreSQL via Python. The program is in Windows > (now), but will be executed, in few months, in Linux. I know I can use ODBC, > but is there a Library or so that I can use in both OS', by meant to make > the code 100% portable? There's a note about PyGreSQL on Windows at FAQTS.com:- http://www.faqts.com/knowledge_base/view.phtml/aid/1420/fid/278 -Steve -- Steve Purcell, Pythangelist http://pyunit.sourceforge.net/ http://pyserv.sourceforge.net/ Available for consulting and training. "Even snakes are afraid of snakes." -- Steven Wright From gerhard.nospam at bigfoot.de Wed Feb 14 11:00:34 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Wed, 14 Feb 2001 11:00:34 +0100 Subject: Python and postgreSQL ?? References: <009401c095a9$a54e7d10$150310ac@pablo> Message-ID: On Tue, 13 Feb 2001 10:54:55 +0100, Steve Purcell wrote: >Pablo Prieto wrote: >> I'd like to connect with PostgreSQL via Python. The program is in Windows >> (now), but will be executed, in few months, in Linux. I know I can use ODBC, >> but is there a Library or so that I can use in both OS', by meant to make >> the code 100% portable? > >There's a note about PyGreSQL on Windows at FAQTS.com:- > > http://www.faqts.com/knowledge_base/view.phtml/aid/1420/fid/278 PyGreSQL is the only one from the 3 Postgres Python interfaces available that I could build on Windows. The other two were too unixoid. And it's also the original, which is included in the Postgres distribution. The PyGreSQL web site at druid.net is currently only showing the default Apache docs. I hope they will be back soon. In the meantime you can still use the Windows version from my homepage (it's a superset of the source distribution with a few patches from my part). Gerhard -- mail: gerhard bigfoot de web: http://highqualdev.com From darcy at vex.net Thu Feb 15 22:40:54 2001 From: darcy at vex.net (D'Arcy J.M. Cain) Date: Thu, 15 Feb 2001 21:40:54 +0000 (UTC) Subject: Python and postgreSQL ?? References: <009401c095a9$a54e7d10$150310ac@pablo> Message-ID: <96hid6$2v4r$1@news.tht.net> Gerhard H?ring wrote: > On Tue, 13 Feb 2001 10:54:55 +0100, Steve Purcell wrote: >>Pablo Prieto wrote: >>> I'd like to connect with PostgreSQL via Python. The program is in Windows >>> (now), but will be executed, in few months, in Linux. I know I can use ODBC, >>> but is there a Library or so that I can use in both OS', by meant to make >>> the code 100% portable? >> >>There's a note about PyGreSQL on Windows at FAQTS.com:- >> >> http://www.faqts.com/knowledge_base/view.phtml/aid/1420/fid/278 That page acts funny. I eventually found the page that the link there is supposed to send you to. http://home.t-online.de/home/err666/. > PyGreSQL is the only one from the 3 Postgres Python interfaces available > that I could build on Windows. The other two were too unixoid. And it's also > the original, which is included in the Postgres distribution. The PyGreSQL > web site at druid.net is currently only showing the default Apache docs. I > hope they will be back soon. Back now. I just moved druid.net to its new home and you caught me in transition. > In the meantime you can still use the Windows version from my homepage (it's > a superset of the source distribution with a few patches from my part). Do I have all the changes? I'm sure that I could fold them in with #ifdefs at least. Didn't I already make some changes for Windows? BTW I will soon be making the source available by anonymous CVS. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.vex.net/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From greg at cosc.canterbury.ac.nz Thu Feb 1 01:32:13 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 01 Feb 2001 13:32:13 +1300 Subject: function attributes are like function objects References: Message-ID: <3A78AE8D.C9D25694@cosc.canterbury.ac.nz> Sean Reifschneider wrote: > > It didn't really > seem like they were missing so much as it seemed like they would act > more like everything else now... Everything? What about lists, dicts, tuples, file objects...? What's so special about functions that we need to be able to plonk arbitrary attributes on them, but not any other builtin types? -- 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 mlh at idi.ntnu.no Thu Feb 1 02:02:59 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Thu, 1 Feb 2001 02:02:59 +0100 Subject: function attributes are like function objects References: <3A78AE8D.C9D25694@cosc.canterbury.ac.nz> Message-ID: <95acpj$sbe$1@tyfon.itea.ntnu.no> "Greg Ewing" wrote in message news:3A78AE8D.C9D25694 at cosc.canterbury.ac.nz... > Sean Reifschneider wrote: > > > > It didn't really > > seem like they were missing so much as it seemed like they would act > > more like everything else now... > > Everything? What about lists, dicts, tuples, file > objects...? > > What's so special about functions that we need to > be able to plonk arbitrary attributes on them, but > not any other builtin types? Now *that* would be nice (if we could do that, I mean). Everything as objects... SmallTalk lurking in the background. Sounds good to me... -- Magnus Lie Hetland (magnus at hetland dot org) "Reality is what refuses to disappear when you stop believing in it" -- Philip K. Dick From katz at Glue.umd.edu Thu Feb 1 04:46:41 2001 From: katz at Glue.umd.edu (Roy Katz) Date: Wed, 31 Jan 2001 22:46:41 -0500 Subject: function attributes are like function objects In-Reply-To: <95acpj$sbe$1@tyfon.itea.ntnu.no> References: <3A78AE8D.C9D25694@cosc.canterbury.ac.nz> <95acpj$sbe$1@tyfon.itea.ntnu.no> Message-ID: Oh, good, perhaps a calll for a Py3k suggestion? idea: Perhaps replace def/class with a general 'def' which would allow the definition of - a standard class - a function - an instance method - a class method - a singleton class all through a single, consistent syntax. lists, strings, dicts, ints and other types would be subclass-able. This would solve the following current problems: - Python lacks class methods - Current Python has no support for subclassing from primitive types. I really would like that -- provided it is consistent and not occam's-razor syntax extension. I had an idea where one could write def f(x): pass def C: def f(self): pass def g(): pass # where some new syntax indicates that g is static print 'hi' # C is like a function and a class in one. and you could call f(3), C.g(), C() to call C as a function.. that'd fill those requirements... sort of. On the other hand, maybe there needs to be a distinct separation between class and function; I think right now that function attributes are a waste when the functions can use (1) global values, (2) 'call-by-reference' (er, mutable, right?) object parameters in which to hold values, or (3) be implemented as function objects, with all being viable alternatives. (1) state = 123 def f(): return state (2) class stateHolder: state = 0 def __init__(self, state): self.state = state state = stateHolder( 123 ) def f( s ) # s is a stateHolder return s.state (3) class func: state = 123 def f(self): return self.state ------- there. I prefer (3), (I'm CS-oriented :)) Roey On Thu, 1 Feb 2001, Magnus Lie Hetland wrote: > "Greg Ewing" wrote in message > news:3A78AE8D.C9D25694 at cosc.canterbury.ac.nz... > > Sean Reifschneider wrote: > > > > > > It didn't really > > > seem like they were missing so much as it seemed like they would act > > > more like everything else now... > > > > Everything? What about lists, dicts, tuples, file > > objects...? > > > > What's so special about functions that we need to > > be able to plonk arbitrary attributes on them, but > > not any other builtin types? > > Now *that* would be nice (if we could do that, I mean). > Everything as objects... SmallTalk lurking in the > background. Sounds good to me... > > -- > > Magnus Lie Hetland (magnus at hetland dot org) > > "Reality is what refuses to disappear when you stop > believing in it" -- Philip K. Dick > > > > From sholden at holdenweb.com Fri Feb 2 22:13:00 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 2 Feb 2001 16:13:00 -0500 Subject: function attributes are like function objects References: <3A78AE8D.C9D25694@cosc.canterbury.ac.nz> <95acpj$sbe$1@tyfon.itea.ntnu.no> Message-ID: "Magnus Lie Hetland" wrote in message news:95acpj$sbe$1 at tyfon.itea.ntnu.no... > "Greg Ewing" wrote in message > news:3A78AE8D.C9D25694 at cosc.canterbury.ac.nz... > > Sean Reifschneider wrote: > > > > > > It didn't really > > > seem like they were missing so much as it seemed like they would act > > > more like everything else now... > > > > Everything? What about lists, dicts, tuples, file > > objects...? > > > > What's so special about functions that we need to > > be able to plonk arbitrary attributes on them, but > > not any other builtin types? > > Now *that* would be nice (if we could do that, I mean). > Everything as objects... SmallTalk lurking in the > background. Sounds good to me... > Sounds more like Javascript lurking in the background to me. regards Steve From mwh21 at cam.ac.uk Thu Feb 1 13:26:50 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 01 Feb 2001 12:26:50 +0000 Subject: function attributes are like function objects References: <3A78AE8D.C9D25694@cosc.canterbury.ac.nz> Message-ID: Greg Ewing writes: > Sean Reifschneider wrote: > > > > It didn't really > > seem like they were missing so much as it seemed like they would act > > more like everything else now... > > Everything? What about lists, dicts, tuples, file > objects...? > > What's so special about functions that we need to > be able to plonk arbitrary attributes on them, but > not any other builtin types? The fact that people were using the one attribute they could get at (__doc__) for things far from its original purpose? 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 donn at u.washington.edu Thu Feb 1 18:05:01 2001 From: donn at u.washington.edu (Donn Cave) Date: 1 Feb 2001 17:05:01 GMT Subject: function attributes are like function objects References: <3A78AE8D.C9D25694@cosc.canterbury.ac.nz> Message-ID: <95c4vt$g0i$1@nntp6.u.washington.edu> Quoth Michael Hudson : | Greg Ewing writes: |> Everything? What about lists, dicts, tuples, file |> objects...? |> |> What's so special about functions that we need to |> be able to plonk arbitrary attributes on them, but |> not any other builtin types? | | The fact that people were using the one attribute they could get at | (__doc__) for things far from its original purpose? No, that can't be it. Programmers will abuse all kinds of language features; sometimes it is indeed in the service of good, but just as often it's utterly misguided. My curiosity is killing me. How does function attributes make Python better? Donn Cave, donn at u.washington.edu From fredrik at effbot.org Thu Feb 1 18:22:45 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Thu, 01 Feb 2001 17:22:45 GMT Subject: function attributes are like function objects References: <3A78AE8D.C9D25694@cosc.canterbury.ac.nz> Message-ID: Michael Hudson wrote: > > What's so special about functions that we need to > > be able to plonk arbitrary attributes on them, but > > not any other builtin types? > > The fact that people were using the one attribute they could get at > (__doc__) for things far from its original purpose? well, if people are too lazy to write def f(...): ... a[f] = "something" do you really think they'll find it much easier to write: def f(...): ... f.a = "something" (fwiw, I think function attributes is about the dumbest thing we've added to python lately -- face it, "because we can" isn't a very good argument when deciding what to add to the language core...) Cheers /F From bobhicks at adelphia.net Thu Feb 1 19:27:14 2001 From: bobhicks at adelphia.net (Robert L Hicks) Date: Thu, 01 Feb 2001 18:27:14 GMT Subject: function attributes are like function objects References: <3A78AE8D.C9D25694@cosc.canterbury.ac.nz> Message-ID: > From: "Fredrik Lundh" > Organization: Telia Internet > Newsgroups: comp.lang.python > Date: Thu, 01 Feb 2001 17:22:45 GMT > Subject: Re: function attributes are like function objects > > Michael Hudson wrote: >>> What's so special about functions that we need to >>> be able to plonk arbitrary attributes on them, but >>> not any other builtin types? >> >> The fact that people were using the one attribute they could get at >> (__doc__) for things far from its original purpose? > > well, if people are too lazy to write > > def f(...): > ... > a[f] = "something" > > do you really think they'll find it much easier to write: > > def f(...): > ... > f.a = "something" > > (fwiw, I think function attributes is about the dumbest > thing we've added to python lately -- face it, "because > we can" isn't a very good argument when deciding what > to add to the language core...) Was that the rational? Let's add it because we can? From tim.one at home.com Fri Feb 2 06:02:06 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 2 Feb 2001 00:02:06 -0500 Subject: function attributes are like function objects In-Reply-To: Message-ID: [/F] > well, if people are too lazy to write > > def f(...): > ... > a[f] = "something" > > do you really think they'll find it much easier to write: > > def f(...): > ... > f.a = "something" Believe it or not, I do. Bets? Don't forget methods when deciding how easy the first alternative is, and that decorating methods (not top-level functions) is the primary cause of docstring abuse. But I bet people would find the latter substantially easier even without methods complicating the first gimmick. > (fwiw, I think function attributes is about the dumbest > thing we've added to python lately I happen to like sre better myself . > -- face it, "because we can" isn't a very good argument > when deciding what to add to the language core...) Hmm. I suppose the PEP would be that much stronger had Barry thought to mention this argument : http://python.sourceforge.net/peps/pep-0232.html From dieter at handshake.de Fri Feb 2 21:48:22 2001 From: dieter at handshake.de (Dieter Maurer) Date: 02 Feb 2001 21:48:22 +0100 Subject: function attributes are like function objects References: <3A78AE8D.C9D25694@cosc.canterbury.ac.nz> Message-ID: "Fredrik Lundh" writes on Thu, 01 Feb 2001 17:22:45 GMT: > (fwiw, I think function attributes is about the dumbest > thing we've added to python lately -- face it, "because > we can" isn't a very good argument when deciding what > to add to the language core...) Zope makes quite good use of function attributes: It uses them to associate permissions, for example. It is better to have them directly attached to the function rather than maintained in a separate object, such as a dictionary. For, if the function is passed around the program, its attributes are automatically passed with it. Otherwise, the auxiliary object would need to be passed explicitly. Dieter From fredrik at effbot.org Fri Feb 2 10:30:32 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Fri, 02 Feb 2001 09:30:32 GMT Subject: function attributes are like function objects References: Message-ID: Tim Peters wrote: > [/F] > > well, if people are too lazy to write > > > > def f(...): > > ... > > a[f] = "something" > > > > do you really think they'll find it much easier to write: > > > > def f(...): > > ... > > f.a = "something" > > Believe it or not, I do. Bets? Don't forget methods when deciding how easy > the first alternative is, and that decorating methods (not top-level > functions) is the primary cause of docstring abuse. Works for methods too: class Spam: a = {} def f(...): ... a[f] = "something" You can dig it out with a one-liner (or 2-3 lines, if you want a more general version -- put it in the "code" module, where it belongs...) > > -- face it, "because we can" isn't a very good argument > > when deciding what to add to the language core...) > > Hmm. I suppose the PEP would be that much stronger had Barry thought to > mention this argument : > > http://python.sourceforge.net/peps/pep-0232.html Sure looks like "because we can" to me... Or maybe "because it's more fun to hack the core than to hack the library". (For some reason, the python-devers seem to prefer writing C/Java over Python...) On the other hand, this isn't such a big deal, especially not com- pared to some of the stuff I've seen on python-dev lately. I'm pretty sure a third-party python implementer can ignore function attributes, and nobody will ever notice... Cheers /F From tim.one at home.com Sat Feb 3 08:38:55 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Feb 2001 02:38:55 -0500 Subject: function attributes are like function objects In-Reply-To: Message-ID: [/F] > well, if people are too lazy to write > > def f(...): > ... > a[f] = "something" > > do you really think they'll find it much easier to write: > > def f(...): > ... > f.a = "something" [Tim] > Believe it or not, I do. Bets? Don't forget methods when > deciding how easy the first alternative is, and that decorating > methods (not top-level functions) is the primary cause of > docstring abuse. [/F] > Works for methods too: > > class Spam: > a = {} > def f(...): > ... > a[f] = "something" Now, now, let's be serious: > You can dig it out with a one-liner Yes, and if you *showed* that one-liner, the "easier" would be shot all to pieces. These aren't meant to be write-only attributes . > (or 2-3 lines, if you want a more general version Or, under Barry's patch, simply C.f.a > -- put it in the "code" module, where it belongs...) Na, C.f.a is too simple to hide in "code" . > ... > Sure looks like "because we can" to me... Well, my employer is famous for using the presence or absence of a docstring to determine whether a method "is publishable". It's handier and cleaner to have an attribute for that instead. You want to use a dict, and then there are multiple dicts, and then multiple "conceptual" attributes get distributed in an unhelpful way. Like the trick of hiding a function in a class, it's an alternative that's been available for years, and people simply won't do it. Heading on 50 years ago, early LISP systems had the radical idea that you could "attach" any number of key+value pairs to any symbol, via setprop, getprop, remprop functions. Python has objects instead of symbols, and dicts instead of association lists, and attr notation instead of functional, but other than those it's the same ancient idea (except still less general in Python!). Nothing bad happened to LISP as a result, and it was handy for all sorts of things. > Or maybe "because it's more fun to hack the core than to hack > the library". (For some reason, the python-devers seem to prefer > writing C/Java over Python...) And writing code rather than docs; and anything rather than volunteer to investigate a bug report. They're developers <0.6 wink>. > On the other hand, this isn't such a big deal, especially not com- > pared to some of the stuff I've seen on python-dev lately. I'm > pretty sure a third-party python implementer can ignore function > attributes, and nobody will ever notice... We would certainly notice the absence of function.__doc__, and any 3rd-party implementer realizing that first would likely take a much more uniform approach to implementing object attributes than did Guido at the start. Remember that func.__doc__ didn't exist at the start, so got backstitched in as an afterthought. One hopes that later implementers might even learn from that . hope-springs-eternal-ly y'rs - tim From geoff at homegain.com Fri Feb 2 20:31:00 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Fri, 2 Feb 2001 11:31:00 -0800 Subject: function attributes are like function objects Message-ID: <393D961EA4FCD311B03F00D0B746D65802625F21@HQSXCH01> I'm pretty new to the discussion, and definitely underinformed, but I have a question or two. Has the addition of function attributes included the addition of an introspection mechanism to allow the function access to its own attributes? In other words, can a function use its attributes to provide the moral equivalent of a static variable, or a closure? Or are function attributes pretty much accessible only to those who know the function by name? Thanks, --G. --- Geoff Gerrietts Software Engineer, HomeGain.com 510-655-0800 x4320 From barry at digicool.com Fri Feb 2 23:41:04 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Fri, 2 Feb 2001 17:41:04 -0500 Subject: function attributes are like function objects References: <393D961EA4FCD311B03F00D0B746D65802625F21@HQSXCH01> Message-ID: <14971.14208.294333.479174@anthem.wooz.org> >>>>> "GG" == Geoffrey Gerrietts writes: GG> Or are function attributes pretty much accessible only to GG> those who know the function by name? Well, if you have the function passed to you, then you don't need to know what it's called. You just access the attribute. def publish(func): try: if func.publish: print func() except AttributeError: log('Non-conforming function given to publish(): %s' % func) -Barry From fredrik at effbot.org Fri Feb 2 21:54:57 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Fri, 02 Feb 2001 20:54:57 GMT Subject: function attributes are like function objects References: Message-ID: Geoffrey Gerrietts wrote: > Has the addition of function attributes included the addition of an > introspection mechanism to allow the function access to its own > attributes? In other words, can a function use its attributes to > provide the moral equivalent of a static variable, or a closure? nope. > Or are function attributes pretty much accessible only to those > who know the function by name? exactly. on the other hand, the programmer defining a function often knows what it's called, so things like the following will work (if spam is defined in the global namespace, and as long as nobody else overloads spam with some- thing else): def spam(x): # fetch attribute via global namespace # lookup and attribute lookup print spam.x spam.x = "hello" but if that's what you want, you can of course use a global instead: def spam(x): # fetch attribute via global namespace lookup print spam_x spam_x = "hello" Cheers /F From geoff at homegain.com Sat Feb 3 00:31:22 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Fri, 2 Feb 2001 15:31:22 -0800 Subject: function attributes are like function objects Message-ID: <393D961EA4FCD311B03F00D0B746D65802625F24@HQSXCH01> Barry writes: > >>>>> "GG" == Geoffrey Gerrietts writes: > > GG> Or are function attributes pretty much accessible only to > GG> those who know the function by name? > > Well, if you have the function passed to you, then you don't need to > know what it's called. You just access the attribute. Yeah, well, right, so you don't know it by its birth name, but you still know it by the name you gave it, just like you call me GG. Not to pick nits, just that the question is about introspection, not about whether regular namespace semantics work, or whether our functions are really first-class objects. Thanks, --G. --- Geoff Gerrietts Software Engineer, HomeGain.com 510-655-0800 x4320 From barry at digicool.com Sat Feb 3 04:32:37 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Fri, 2 Feb 2001 22:32:37 -0500 Subject: function attributes are like function objects References: <393D961EA4FCD311B03F00D0B746D65802625F24@HQSXCH01> Message-ID: <14971.31701.714377.397629@anthem.wooz.org> >>>>> "GG" == Geoffrey Gerrietts writes: GG> Yeah, well, right, so you don't know it by its birth name, but GG> you still know it by the name you gave it, just like you call GG> me GG. In other words, you're accessing the object though the variable it's locally bound to (nothing special there). GG> Not to pick nits, just that the question is about GG> introspection, not about whether regular namespace semantics GG> work, or whether our functions are really first-class objects. Okay, so introspection works no differently for functions as any other object with writable attributes (e.g. classes, instances, modules). You can use getattr() to test whether a function has a particular attribute, and setattr() to set that attribute. But maybe I'm missing the point of the question? It's been a long couple of days. -Barry From aahz at panix.com Sat Feb 3 07:58:14 2001 From: aahz at panix.com (Aahz Maruch) Date: 2 Feb 2001 22:58:14 -0800 Subject: function attributes are like function objects References: <393D961EA4FCD311B03F00D0B746D65802625F24@HQSXCH01> Message-ID: <95ga66$nbj$1@panix2.panix.com> In article , Barry A. Warsaw wrote: >>>>>> "GG" == Geoffrey Gerrietts writes: > > GG> Not to pick nits, just that the question is about > GG> introspection, not about whether regular namespace semantics > GG> work, or whether our functions are really first-class objects. > >Okay, so introspection works no differently for functions as any other >object with writable attributes (e.g. classes, instances, modules). >You can use getattr() to test whether a function has a particular >attribute, and setattr() to set that attribute. I think the issue is that Geoffrey suddenly realized that there's no "self" equivalent for functions. -- --- 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 "People sometimes focus too much on the fact of communication rather than the substance of communication." --Dave Morton From geoff at homegain.com Sat Feb 3 00:57:29 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Fri, 2 Feb 2001 15:57:29 -0800 Subject: function attributes are like function objects Message-ID: <393D961EA4FCD311B03F00D0B746D65802625F26@HQSXCH01> After I sent, I realized how smarmy that last message sounds. I don't mean to imply that Barry's information was inappropriate. I can totally see how what I wrote could be read to indicate I didn't realize that function objects can be aliased and passed around and yada yada. I just want to avoid losing the point; is the function going to have access to this bit of state its carrying around, or is that reserved for outside parties? Sorry, Barry, I appreciate you trying to help. I should be more careful about my tone. Thanks, --G. --- Geoff Gerrietts Software Engineer, HomeGain.com 510-655-0800 x4320 From tim.one at home.com Sat Feb 3 09:17:21 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Feb 2001 03:17:21 -0500 Subject: function attributes are like function objects In-Reply-To: <393D961EA4FCD311B03F00D0B746D65802625F26@HQSXCH01> Message-ID: [Geoffrey Gerrietts] > ... > I just want to avoid losing the point; is the function going to have > access to this bit of state its carrying around, No. > or is that reserved for outside parties? Also no. I know you don't want to hear about namespace issues, but those *are* the issues here. As Aahz said, there is no form of "self" for function objects (or class objects, or file objects, or list objects, or ...). The only way to get to the attr is via the object, for functions as for everything else. Whether you're "in" or "out" of the function makes no difference to that. Visibility of names is the entire story in both cases. >>> def f(): ... print "f.a is", f.a >>> f.a = 42 >>> f() f.a is 42 >> But if-- for whatever reason --the name of "f" is not visible inside the body of "f", that won't work, and there's no special syntax then that can make it work. For example, run this under 2.1a2: def f(): def f(): print "inner f.a is", f.a f.a = 666 f() print "outer f.a is", f.a f.a = 42 f() Both "print" stmts see the inner redefinition of f then, so both references to "f.a" yield 666. But that's mondo perverse code! don't-punch-yourself-in-the-throat-and-you-won't-gag-ly y'rs - tim From geoff at homegain.com Sat Feb 3 09:39:21 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Sat, 3 Feb 2001 00:39:21 -0800 Subject: function attributes are like function objects Message-ID: <393D961EA4FCD311B03F00D0B746D65802625F2A@HQSXCH01> Aahz writes: > I think the issue is that Geoffrey suddenly realized that there's no > "self" equivalent for functions. Not so suddenly as maybe it seems. I wasn't aware of any mechanism that would help me out there; I just wondered whether one might be part of the package. It seemed like an obvious corollary to me; if the function is going to be carrying around this bit of state, it should probably have access to it, sorta in the way that globals() lets you at a module's __dict__. Fredrik has answered my question, though: there's nothing on the drawing board that will let me at the attributes without first having an outside handle on the object, and nothing that will give me an outside handle on it from the inside. Maybe nested scopes will help that? Maybe not. If function attributes make it easier for some folks, that's great. I thought maybe I saw a niche they might fill for me, but now I'm back to wait-and-see; I'll wait for a final release before I adopt, anyway. :) Thanks, --G. From fredrik at effbot.org Sat Feb 3 13:40:58 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Sat, 03 Feb 2001 12:40:58 GMT Subject: function attributes are like function objects References: Message-ID: Tim Peters wrote: > Yes, and if you *showed* that one-liner, the "easier" would be shot all to > pieces. These aren't meant to be write-only attributes . here's how I would solve your publishing example: ALWAYS = "ALWAYS" SOMETIMES = "SOMETIMES" # # user code class ClassicSpam: publish = {} def egg(self, x): pass publish[egg] = ALWAYS # 2.1: egg.publish = ALWAYS class NewSpam(ClassicSpam): publish = {} def bacon(self, x): pass publish[bacon] = SOMETIMES # 2.1: bacon.publish = SOMETIMES # # code for the publisher framework def getpublish(klass, name): # figure out if/when we can publish this method try: method = getattr(klass, name) return method.im_class.publish[method.im_func] # 2.1: return method.publish except (AttributeError, KeyError): return None # nope # # try it out for function in ["bacon", "egg", "spam"]: print function, getpublish(NewSpam, function) advantages: + works with pre-2.1 python + requires one dictionary per class instead of one per method + no memory penalty for classes that doesn't belong to the publishing framework disadvantages: + the 1-3 lines you need to dig out the attribute varies slightly, depending on the application > > On the other hand, this isn't such a big deal, especially not com- > > pared to some of the stuff I've seen on python-dev lately. I'm > > pretty sure a third-party python implementer can ignore function > > attributes, and nobody will ever notice... > > We would certainly notice the absence of function.__doc__, > and any 3rd-party implementer realizing that first would likely > take a much more uniform approach to implementing object >> attributes than did Guido at the start. not so sure about that -- __doc__ strings are very common, and are better stored in a separate slot to save memory (just like CPython does, of course). and I doubt many people would notice if __doc__ were made readonly... Cheers /F From tanzer at swing.co.at Sat Feb 3 14:27:07 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Sat, 03 Feb 2001 14:27:07 +0100 Subject: function attributes are like function objects In-Reply-To: Your message of "Sat, 03 Feb 2001 12:40:58 GMT." Message-ID: "Fredrik Lundh" wrote: > and I doubt many people would notice if __doc__ were made > readonly... Well, I'm not many but I certainly would notice (and complain, too). > advantages: > + works with pre-2.1 python > + requires one dictionary per class instead of one > per method - requires one dictionary per type of method attribute. Worse, it is a FORTRANique [*] instead of a pythonic solution. Instead of encapsulating all information about an object in one place, corresponding attributes of different objects are bundled up together. For a single method attribute, it doesn't matter much but if several attributes are used per method it sucks. [*] (read FORTRAN IV or FORTRAN 77) -- 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 pieter at equinox.co.za Mon Feb 5 12:15:52 2001 From: pieter at equinox.co.za (Pieter Nagel) Date: Mon, 5 Feb 2001 13:15:52 +0200 Subject: function attributes are like function objects In-Reply-To: References: Message-ID: On Sat, 3 Feb 2001, Tim Peters wrote: > Well, my employer is famous for using the presence or absence of a docstring > to determine whether a method "is publishable". We were sincerely hoping that the Python core team would teach their employers how to code Python, instead of the other way around... }:-) -- ,_ /_) /| / / i e t e r / |/ a g e l From dbrueck at edgix.com Mon Feb 5 18:04:54 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Mon, 5 Feb 2001 10:04:54 -0700 Subject: function attributes are like function objects In-Reply-To: Message-ID: > [mailto:python-list-admin at python.org]On Behalf Of Pieter Nagel > > Well, my employer is famous for using the presence or absence > of a docstring > > to determine whether a method "is publishable". > > We were sincerely hoping that the Python core team would teach their > employers how to code Python, instead of the other way around... Er, I read 'my employer' to mean Tim's boss, the BDFL himself. -Dave From fredrik at effbot.org Sat Feb 3 15:36:07 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Sat, 03 Feb 2001 14:36:07 GMT Subject: function attributes are like function objects References: Message-ID: Christian Tanzer wrote: > > and I doubt many people would notice if __doc__ were made > > readonly... > > Well, I'm not many but I certainly would notice (and complain, too). Did you read the language specification before you started abusing the __doc__ attribute? If you look under function objects, you'll notice that it says that the __doc__ attribute MAY be writable. Not that it always will be. (the real reason to have writable func_doc/func_code attributes is to allow a development environment to update functions in a running program, not so much to support doc-string hacks in user code). And if you're relying on implementation-dependent features, you only have yourself to blame... > Worse, it is a FORTRANique [*] instead of a > pythonic solution. Really? I didn't know Fortran had builtin dictionaries and hashable function objects, or that it builds class objects by executing code in a special namespace... > For a single method attribute, it doesn't matter much but if several > attributes are used per method it sucks. Yeah, right -- we all know that writing two lines instead of two lines suck... From me at nospam.net Wed Feb 7 06:23:29 2001 From: me at nospam.net (Scottie) Date: Tue, 6 Feb 2001 21:23:29 -0800 Subject: function attributes are like function objects References: Message-ID: The dictionary (a in your example) will force a reference to the function to exist, thus preventing it from being collected. An attribute evaporates with the object it is connected to. The difference provides another reason to use an attribute to perform the legerdemain rather than some (probably global) dictionary. On a separate note, can't a function acces itself through an exception's traceback frame? Something like: try: raise MyExcept except MyExcept: obtain info thru via sys.exc_info() "Christian Tanzer" wrote: > "Fredrik Lundh" wrote: > > advantages: > > + works with pre-2.1 python > > + requires one dictionary per class instead of one > > per method > - requires one dictionary per type of method attribute. - prevents funtions referenced from being garbage collected. -- Scott David Daniels Scott.Daniels at Acm.Org From fredrik at effbot.org Wed Feb 7 08:19:23 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 07 Feb 2001 07:19:23 GMT Subject: function attributes are like function objects References: Message-ID: <%F6g6.13180$AH6.1981166@newsc.telia.net> Scottie wrote: > The dictionary (a in your example) will force a reference to the function to > exist, thus preventing it from being collected. That dictionary sits inside a *class* object. That class also holds references to the function objects, as well as to the dictionary. No cycles here. > > - requires one dictionary per type of method attribute. Which is a problem only if you have more attributes than methods in your classes, of course. Not very likely. (and easy to solve with a global attribute dictionary) > - prevents funtions referenced from being garbage collected. Which is a problem only if you spend a lot of time adding and removing methods from classes. Not very likely. (and easy to solve with a weak dictionary, or by changing to a better design) Cheers /F From pieter at equinox.co.za Tue Feb 6 14:45:50 2001 From: pieter at equinox.co.za (Pieter Nagel) Date: Tue, 6 Feb 2001 15:45:50 +0200 Subject: function attributes are like function objects In-Reply-To: References: Message-ID: On Mon, 5 Feb 2001, Dave Brueck wrote: > Pieter Nagel wrote: > > Tim Peters wrote: > > > Well, my employer is famous for using the presence or absence > > of a docstring > > > to determine whether a method "is publishable". > > > > We were sincerely hoping that the Python core team would teach their > > employers how to code Python, instead of the other way around... > > Er, I read 'my employer' to mean Tim's boss, the BDFL himself. I thought that referred to the perpetrators of Zope. -- ,_ /_) /| / / i e t e r / |/ a g e l From tim.one at home.com Thu Feb 1 07:55:46 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 1 Feb 2001 01:55:46 -0500 Subject: invalid-token syntax hook (was Re: Hack request: rational numbers) In-Reply-To: <20010129102836.B1279@inetnebr.com> Message-ID: [Jeff Epler] > ... > I have no illusion that our BDFL would accept something like Mobius > into core Python, Hey, in the end he accepted xreadlines(), and you may remember his initial patch comment for that . Guido confessed to *trying* to dream up a Pythonic way to allow syntax extensions when he was designing the language, but failed. And despite what anyone may think, that's really not an invitation to discuss hygienic macros for the 50th time <0.7 wink>. life's-short-and-brutal-but-if-you're-lucky-you-die-ly y'rs - tim From tim.one at home.com Thu Feb 1 08:38:25 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 1 Feb 2001 02:38:25 -0500 Subject: simple threads kill my IDLE In-Reply-To: Message-ID: [posted & mailed] [Henning VON ROSEN] > While playing around width threads executing either interactively > or from the editmode by "f5", in many cases IDLE froze and forced > me to restart it. > > Have anyone experienced such problems? Just everyone who has tried it . Guido believes it would take a major rearchitecture to get IDLE playing nice with threads (Tk isn't really happy with threads). An entry from the "feature request" PEP at http://python.sourceforge.net/peps/pep-0042.html: """ - IDLE has deep problems running threaded programs. Re-architect. http://sourceforge.net/bugs/?func=detailbug&bug_id=121963&group_id=5470 """ > ... > 3) Just execute in DOS Windows (If there is a bug, these ugly > windows dies off, leaving me without feddback error messages! > How do I solve that?) Are you starting your program by double-clicking on its icon? Then don't do that: bring up a DOS box *first*, and type python path-to-your-program at the command prompt. When mucking with threads, I often keep an IDLE window open for editing, and a DOS box open for running the program. If you enter doskey upon opening your DOS box, you'll get command history (among other stuff -- do "doskey /?") so that reentering your last "python path-..." line is just a matter of hitting the up-arrow key. luckily-programmers-can-get-used-to-anything-ly y'rs - tim From chaluba at yahoo.com Thu Feb 22 18:11:57 2001 From: chaluba at yahoo.com (chaluba at yahoo.com) Date: Thu, 22 Feb 2001 17:11:57 -0000 Subject: win32com.client - missing methods? In-Reply-To: <94set0$ecf$1@news5.svr.pol.co.uk> Message-ID: <973h8t+prq2@eGroups.com> I ran into the same problem below, the first day I tried using win32com on NT. I eventually fixed it and the following is my account hoping it helps you or others. Setup (work): WinNT4.0SP6a + python1.52 + win32all-136 + MS Office 97 BuiltInDocumentProperties is a DocumentProperties object defined in MS Office type library. I had generated type libraries for MS Office, and DocumentProperties did not seem to have any methods. However, when I browsed with COM Browser, I was able to see its methods. Setup1 (home): Win2K + python1.52 + win32all-136 + MS Word 2000 Setup2 (home): Win2K + ActivePython 2.02 + MS Word 2000 At home I tried to access methods of BuiltInDocumentProperties and it worked under both setups. I had not generated any type libraries manually assuming they'd be auto-generated. They were not generated. Back to work, I deleted the type libraries and voila - it worked. Type libaries were not generated. I'm not sure if it's supposed to work like that but it sure confused me quite a bit (the fact that it did not work with generated type libraries). Maybe someone can comment. Ayhan --- In python-list at y..., "Kirby James" wrote: > Hi, I've written a Python program which uses the win32com interface to > obtain information from a number of Word-97 files. > The program runs fine on my Win-98 system but fails on two NT systems. > The problem line is :- > > sAuthor = myDoc.BuiltInDocumentProperties(constants.wdPropertyAuthor) > > which produces the error > > AttributeError: no __call__ method defined > > When I remove this line the other COM functions that I call work fine. On > all three systems I've run the COM Makepy utility - but I notice that > the generated files are of different sizes on the different systems (is it > safe to copy - and rename the win-98 file to NT). > > I'd appreciate any pointers > > ta, Kirby > > > Traceback (most recent call last): > File "D:\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in > RunScript > exec codeObject in __main__.__dict__ > File "D:\python\utilities\word2.py", line 178, in ? > os.path.walk('d:\\relocation', walker, 10) > File "D:\Python20\lib\ntpath.py", line 270, in walk > walk(name, func, arg) > File "D:\Python20\lib\ntpath.py", line 264, in walk > func(arg, top, names) > File "D:\python\utilities\word2.py", line 153, in walker > readWord(pathfilename) > File "D:\python\utilities\word2.py", line 64, in readWord > sAuthor = myDoc.BuiltInDocumentProperties(constants.wdPropertyAuthor) > AttributeError: no __call__ method defined > > > WORD = 'Word.Application.8' > > myWord = Dispatch(WORD) > myWord.Visible = 1 > myDoc = myWord.Documents.Open(fn) > sAuthor = myDoc.BuiltInDocumentProperties(constants.wdPropertyAuthor) > #### line 64 > sAuthor = str(sAuthor) > print ' Author = ' + sAuthor > > > > > > -- > http://mail.python.org/mailman/listinfo/python-list From NOstarfighterSPAM at freeuk.com Sat Feb 24 11:56:47 2001 From: NOstarfighterSPAM at freeuk.com (Richard Townsend) Date: Sat, 24 Feb 2001 10:56:47 -0000 Subject: Python2.0 and Pmw 0.8.4 counter problem References: <3A71D728.EE4B9F03@icestormfx.com> <3A75937B.14C8D022@icestormfx.com> Message-ID: There is a new version (0.8.5) of Pmw available at http://pmw.sourceforge.net/ it includes the fix for PmwCounter.py and a few other changes. regards, Richard "Sylvie Bruneau" wrote in message news:3A75937B.14C8D022 at icestormfx.com... > > Thank you !! Now it works well. But why the Pmw team doesn't make the > modification in their last version ? Anyway. Do you know if there are other > modifications like this one that as to be done to make sure that all the Pmw widgets > works fine ? > > Thanks again... > > > > Richard Townsend wrote: > > > > We used Python1.5 with Pmw 0.8.3 to develop an in-house application. > > For some > > > reasons, we changed to Python2.0 and we decided to use the new Pmw version > > ( > > > 0.8.4 ). In our application, we have a Pmw.Counter of integers and it > > doesn't work > > > anymore. The behaviour is strange : if we type a new integer in the > > entry field, > > > everything is fine. But using the arrows ( left or right, up or down ) > > just clean > > > the entry field, without updating its content. I try the demos in the Pmw > > > distributions and they don't work either. We installed Python1.6 with Pmw > > 0.8.3, and > > > it still doesn't work !!! I tried all the other types of counters and > > they all work > > > fine, but the integer. > > > > > > Anybody has a suggestion ? > > > > > > > I posted the same question a few months ago and got the following solution > > from Roberto Amorim > > > > > Hi, to correct it is simple. You'll have to edit PmwCounter.py. Here it > > > is: > > > > > > - Find the function called _changeNumber() (line 273) > > > - On line 279 there's the return statement for this function. Change it > > > to return str(value) (and not return str(value)[:-1]) > > > > > > That ocurred because str(long) on Python 2.0 doesn't return a number > > > with L on the end like Python 1.5.2 did. > > > > > > > regards, > > Richard Townsend > > -- > /=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/=-/ > Sylvie Bruneau ( sylvieb at icestormfx.com ) Tel: (514) 527-3963 > Software Developer, IceStorm Digital. Fax: (514) 527-5165 > 2595 Place Chasse, Montreal, Quebec, H1Y 2C3. > > Where would you have gone today if Window's hadn't crashed? > > > From tim.one at home.com Thu Feb 1 19:46:27 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 1 Feb 2001 13:46:27 -0500 Subject: c(++)python? In-Reply-To: <20010131124910.B26971@harmony.cs.rit.edu> Message-ID: [D-Man] > What is the difference between C89 and C99? ( a URL or a quick > overview is sufficient ) http://www.google.com/search?q=C89+C99 That will lead you to about 2,000 URLs and quick overviews . From fredrik at effbot.org Thu Feb 1 17:32:03 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Thu, 01 Feb 2001 16:32:03 GMT Subject: c(++)python? References: <3A71EB9C.D258C1C0@comm.mot.com> Message-ID: <7cge6.10615$AH6.1745820@newsc.telia.net> "D-Man" wrote: > What is the difference between C89 and C99? ( a URL or a quick > overview is sufficient ) http://anubis.dkuug.dk/JTC1/SC22/WG14/www/newinc9x.htm the final committee draft can be found here: http://www.lysator.liu.se/c/ Cheers /F From dsh8290 at rit.edu Fri Feb 2 01:24:29 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 1 Feb 2001 19:24:29 -0500 Subject: c(++)python? In-Reply-To: <7cge6.10615$AH6.1745820@newsc.telia.net>; from fredrik@effbot.org on Thu, Feb 01, 2001 at 04:32:03PM +0000 References: <3A71EB9C.D258C1C0@comm.mot.com> <7cge6.10615$AH6.1745820@newsc.telia.net> Message-ID: <20010201192429.A6542@harmony.cs.rit.edu> On Thu, Feb 01, 2001 at 04:32:03PM +0000, Fredrik Lundh wrote: | "D-Man" wrote: | > What is the difference between C89 and C99? ( a URL or a quick | > overview is sufficient ) | | http://anubis.dkuug.dk/JTC1/SC22/WG14/www/newinc9x.htm Thanks, exactly what I was looking for. I think I like a lot of the features in C99. (Basically my reasons for using C++ even if I wasn't going to use (hardly) any C++ features) | | the final committee draft can be found here: | http://www.lysator.liu.se/c/ | | Cheers /F | -D From Pekka.Pessi at nokia.com Mon Feb 5 02:32:34 2001 From: Pekka.Pessi at nokia.com (Pekka Pessi) Date: 05 Feb 2001 03:32:34 +0200 Subject: . Python 2.1 function attributes References: , <$5A+ZwAGjtc6EwE0@jessikat.fsnet.co.uk> <14962.62953.304511.523826@anthem.wooz.org> Message-ID: In message Roy Katz writes: >Let's add bless(). I want to change the class of an object at >runtime. How 'bout it? How about this: class sm: "State machine accepting ab*" def __init__(self): self.__class__ = a valid = 0 class a(sm): def a(self): self.__class__ = b class b(sm): def b(self): pass valid = 1 BTW, have you never looked in the source code of pickle? Pekka From n8gray at caltech.edu.is.my.email.address Thu Feb 1 09:43:07 2001 From: n8gray at caltech.edu.is.my.email.address (Nathaniel Gray) Date: Thu, 1 Feb 2001 00:43:07 -0800 Subject: "in" for dicts (was: Python 2.1 function attributes) References: <9535qg$8mu@gap.cco.caltech.edu> Message-ID: <95b7tj$ib3@gap.cco.caltech.edu> Thomas Wouters wrote: > > My main beef with the 'x in dict' idea is something Nathaniel didn't > raise, though: we all seem to think 'x in dict' is naturally 'key in dict' > -- but why ? Is it because we all know you can't *get* a value from a dict > without extracting them all, and all values could be the same ? How > obvious is that to people without a technical idea of dictionaries ? What, > exactly, is the target group for Python ? :) I think this may be what truly underlies my discomfort with 'in dict'. At some fundamental level _values_ are what we store in dictionaries, not keys. (Unless we're kludging together a Set :^) The only reason we have the keys around is to get to the values. So when I talk about something being "in" a dictionary, it's the value. I can understand, though, that from a practical standpoint the keys may be accessed and iterated over more frequently. > > [Timbot] > > We still don't have anything else for 2.1; only "a_key in dict" in a > > *boolean* context has been implemented. And, yes, we've already got > > dict.has_key(a_key) for that. And, yes, Guido just *approved* of adding > > "for a_key in dict" too, although implementing that is a puzzle given > > the current iteration protocol's use of __getitem__ (it doesn't jibe > > with what dict.__getitem__ does), and "what to do" about programs that > > go mutating the dict during iteration. Sorry if I munged up the for/if distinction. The idea's the same: To me, 'in dict' doesn't logically imply 'in dict.keys()'. I'm reassured that I'm right by the fact that, until recently Guido agreed with me. Has he ever used the time machine to go _forward_ in time? In-a-battle-between-old-Guido-and-new-Guido-who-would-win?-ly-yrs, -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From n8gray at caltech.edu.is.my.e-mail.address Fri Feb 2 11:43:13 2001 From: n8gray at caltech.edu.is.my.e-mail.address (Nathaniel Gray) Date: Fri, 02 Feb 2001 02:43:13 -0800 Subject: "in" for dicts (was: Python 2.1 function attributes) References: Message-ID: <3A7A8F41.4B59D327@caltech.edu.is.my.e-mail.address> Tim Peters wrote: > > (I sure hope we're not doing it just to save a few keystrokes every > > now and then!) > > No. I don't even believe that was mentioned. Most people seem to think > that these uses of "in" for dicts are *obvious*, and that has been > mentioned -- often. Some have also mentioned that "x in dict" will be > faster than "dict.has_key(x)", and ditto for iteration (in which latter case > it may also save an unbounded amount of additional storage). The latter has > been a FAQ for years: > > http://www.python.org/cgi-bin/faqw.py?req=show&file=faq06.012.htp Hmmm... It's always disturbing to hear a construct described as "obvious" in a feature debate. It often means "obvious in the context of the program I wrote yesterday," or "obvious if you follow my coding style." A minor shift in perspective can quickly render an "obvious" feature misleading, as T. Wouters' anecdotal evidence suggests. Interesting. I can see how "for key in dict" is faster than "for key in dict.keys()", but why is "if key in dict" faster than "if dict.has_key(key)"? > > "It's not a big dog. Perhaps if we clipped it's ears and taught it to > > meow it could pass for a cat!" > > Oh, now I'm getting confused! Is a dict the dog or the cat? Is a list the > other one? And what are the ears? Is meowing iteration? In that case > we're taking the cat out of the dungeon and removing the cruel muzzle from > its cute little kitty mouth, while giving the doghouse a fresh coat of > paint. Well why didn't you just say so in the first place? In that case I withdraw my complaint and I'll submit a foolproof "for x in dict" patch to SourceForge forthwith! ;^) > > And yes, I dislike list.pop() too. ;^) > > Really? Or did you intend to say you dislike dict.pop() (which would fit > better with the animal analogies ). Nope. I've got no beef with dict.pop() (isn't it popitem or some such?) -- it's obvious to me why that's useful. list.pop(), on the other hand, troubles me because it encourages the programmer to use a list in place of a stack. Trouble is, the list can do things the stack can't, and this opens up a mess of potential problems when the guy who maintains the code isn't the guy who wrote it. Java makes the same mess by subclassing Stack from Vector! (A Stack "is a" Vector?!) I guess I just don't understand why Python needs to open up this can of worms with "x = list.pop()" when it already has "x = list[-1]; del list[-1];". Is there some subtlety I'm missing? Performance considerations? Thread safety? Atomic Pop? (Great name for a band :^) Educate me. > > Lest I come off as too much of a grumpy Gus, I should add that I really > > like most of the new stuff in Python 2.1a1, particularly xreadlines. > > Figures -- that's the one Guido likes least. He dislikes xrange too. He > was forced into xreadlines by timing considerations (we couldn't match its > performance cleanly, not with finite effort). The only reason to like > xreadlines is speed (which is reason enough!) -- but in that case you should > like both flavors of "x in dict" too, and for the same reason. I like xreadlines because it makes the most simple idiom the same as the most efficient idiom. True, the name is unfortunate, mostly because it begs an explanation when you introduce it to a newbie. In a language like Python, though, the easy way should be the best way for ultra-common tasks, and vice-versa. With the frequency that Python programmers want to iterate over the lines of text files we ought to expect that plain old readline should be doing buffering cartwheels and breathing magical platform-dependent fire to get us those lines post-haste! :^) Yeah, I know. Submit a patch. The bloody noosphere won't homestead itself... > > I'll be first in line to upgrade when 2.1 stabilizes, even if "in dict" > > survives. > > Hey, CVS is open for business! The only way a new release stablilizes is > via people *using* it. No can do. The only reason I'm able to play with Python at all right now is because 1.52 comes preinstalled on RH. I'm doing a one-term rotation with a research group where I'm the only one who's even _heard_ of Python. It's a bit of a "don't ask, don't tell" kind of situation. Big bummer: when the end of the term comes I'll have to port all my code to C. I can already feel my productivity slipping away... Anybody know of a good C implementation of dictionaries? (Other than Python's, that is :^) -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From quinn at hork.ugcs.caltech.edu Fri Feb 2 19:53:24 2001 From: quinn at hork.ugcs.caltech.edu (Quinn Dunkan) Date: 2 Feb 2001 18:53:24 GMT Subject: "in" for dicts (was: Python 2.1 function attributes) References: <3A7A8F41.4B59D327@caltech.edu.is.my.e-mail.address> Message-ID: On Fri, 02 Feb 2001 02:43:13 -0800, Nathaniel Gray wrote: >No can do. The only reason I'm able to play with Python at all right >now is because 1.52 comes preinstalled on RH. I'm doing a one-term >rotation with a research group where I'm the only one who's even _heard_ >of Python. It's a bit of a "don't ask, don't tell" kind of situation. > >Big bummer: when the end of the term comes I'll have to port all my >code to C. I can already feel my productivity slipping away... > >Anybody know of a good C implementation of dictionaries? (Other than >Python's, that is :^) Well, two ideas: Say "I use this C library called libpython.a that provides some basic facilities. Oh, and I also use a special notation to call libpython.a procedures called 'python'---you should be able to learn the special notation quicker than the C library interface. But if you really want to learn the C interface, the special notation can be converted with a utility called 'Python2C'". Or: Port your code to eiffel. It's not quite python, but it should be an easier port than to C. Then use SmallEiffel to compile your eiffel to C. Ok, so it won't be the prettiest C in the world, but hey, it's C and that's what they want, right? Roll that baby through 'indent' and you're set! ;) From n8gray at caltech.edu.is.my.email.address Sat Feb 3 22:08:17 2001 From: n8gray at caltech.edu.is.my.email.address (Nathaniel Gray) Date: Sat, 3 Feb 2001 13:08:17 -0800 Subject: "in" for dicts (was: Python 2.1 function attributes) References: <3A7A8F41.4B59D327@caltech.edu.is.my.e-mail.address> Message-ID: <95hsar$ruv@gap.cco.caltech.edu> If the resulting code can fit in the 256 KB onboard the Khepera mobile robot, I'm there! -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Quinn Dunkan wrote: > On Fri, 02 Feb 2001 02:43:13 -0800, Nathaniel Gray > wrote: > >Anybody know of a good C implementation of dictionaries? (Other than > >Python's, that is :^) > > Well, two ideas: > > Say "I use this C library called libpython.a that provides some basic > facilities. Oh, and I also use a special notation to call libpython.a > procedures called 'python'---you should be able to learn the special > notation > quicker than the C library interface. But if you really want to learn the > C interface, the special notation can be converted with a utility called > 'Python2C'". > > Or: > > Port your code to eiffel. It's not quite python, but it should be an > easier > port than to C. Then use SmallEiffel to compile your eiffel to C. Ok, so > it won't be the prettiest C in the world, but hey, it's C and that's what > they > want, right? Roll that baby through 'indent' and you're set! > > ;) From quinn at retch.ugcs.caltech.edu Tue Feb 6 22:32:04 2001 From: quinn at retch.ugcs.caltech.edu (Quinn Dunkan) Date: 6 Feb 2001 21:32:04 GMT Subject: "in" for dicts (was: Python 2.1 function attributes) References: <3A7A8F41.4B59D327@caltech.edu.is.my.e-mail.address> <95hsar$ruv@gap.cco.caltech.edu> Message-ID: On Sat, 3 Feb 2001 13:08:17 -0800, Nathaniel Gray wrote: >If the resulting code can fit in the 256 KB onboard the Khepera mobile >robot, I'm there! I've been mentioning lua too many times lately, but this seems appropriate: lua is about 100K, the std libraries add an additional 60K. Without the stdlib, it has very few posix dependencies, so you won't need huge posix libraries linked in either. It ought to fit in about 200K, with some left for the actual bytecode. lua is very python-like (in fact, I wonder if some aspects, such as the debugging api, weren't inspired by python). Porting ought to be a breeze (unless you used lots of fancy python modules). And it would be much easier to make the case for it just being a C utility library w/ special notation :) From tim_one at email.msn.com Thu Feb 1 07:36:19 2001 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 1 Feb 2001 01:36:19 -0500 Subject: "in" for dicts (was: Python 2.1 function attributes) In-Reply-To: <20010130095928.A962@xs4all.nl> Message-ID: [Tim] > we also haven't pulled the platform-dependent tricks Perl does > to optimize char-at-a-time reading the way vendors *should* > optimize fgets() but almost never do (Tru64 Unix appears to be > the sole probable exception to date). [Thomas Wouters] > FreeBSD, actually, had insane performance in that area as well. > (getc() being just as fast as getc_unlocked(), in processes with > only a single thread active.) This one doesn't have anything to do with locking or not, it has to do with whether the inner loop is optimized to use register shadows of _iobuf members, and to use the platform's moral equivalent of the _cnt member to avoid needing to check for EOF in the inner loop. It's not "legal" to do that in user-level code, because it requires breaking into the FILE* abstraction. Vendors can do it under the covers, although apparently almost never do. The unique thing about Tru64 Unix was the report that using the fgets() method was substantially faster than using the getc_unlocked() method; that's darned hard to account for unless Tru64 optimizes the inner loop of fgets() (as Perl does). IOW, just using getc_unlocked() still leaves a pile of *potential* improvement on the floor, even on a single-thread run, but improvement you can't get at without cheating (unless the vendor libc authors were savvy enough to do it for you). If Perl while(<>) is still substantially faster on FreeBSD than Python 2.1 using the fgets() method in single-thread runs, platform failure to optimize fgets() in this way is a top contender for "why". From greg at cosc.canterbury.ac.nz Thu Feb 1 05:26:46 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 01 Feb 2001 17:26:46 +1300 Subject: "in" for dicts (was: Python 2.1 function attributes) References: Message-ID: <3A78E586.4638E05B@cosc.canterbury.ac.nz> Tim Peters wrote: > > Nobody searches phone books or Webster's > "backwards" in real life. Indeed! If I were to ask my colleague "Is the word 'bamboozle' used anywhere in a definition in Webster's dictionary?" the answer would probably be "Buggered if I know." Which leads us to what the semantics of "x in dict" should obviously be: >>> if x in dict: ... print "boo: , line 1: BuggeredIfIKnowError -- 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 tim.one at home.com Thu Feb 1 10:34:32 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 1 Feb 2001 04:34:32 -0500 Subject: . Python 2.1 function attributes In-Reply-To: <95432j014on@news2.newsguy.com> Message-ID: [Tim] >> ... >> The testimony of one person who tried a thing and found it >> lacking is more compelling than 100 virgins speculating about >> why they're certain they would despise it if only they could >> bear stooping low enough to try it . [Alex Martelli] > Actual experience with using some tool may be a _part_ of what > gives 'impressiveness' to reports that said tool is inferior, > but it's generally not a major component thereof -- e.g., the > tool may have been misunderstood, misused, etc. That's important too, though. That is, if people misunderstand or misuse, that may point to serious flaws in the docs or the design. There's just no substitute for experience. Not that that's *all* there is, but it's important. In this case, we learned that *nobody* misunderstood what it did. I suspect some people still take it way too seriously, though (like reduce, map and lambda, it's meant to be a minor convenience, not a new foundation on which to build all your file output! maybe that's a lesson we failed to learn from reduce & friends). >> telling fact that Guido rejected Barry's print>> proposal >> before giving it a test drive in his own code -- pure argument >> never had much to do with this one. > Interesting -- I don't recall hearing about this detail previously. There's a bit of it in the SourceForge patch history: http://sourceforge.net/patch/index.php?func=detailpatch&patch_id= 100970&group_id=5470 although there are many gaps in the discussion. The Python-Dev archives may or may not have more, but I've really got no interest in reliving this one. > It _does_ interestingly contradict Guido's posts at the time, > requesting _arguments_ (NOT "experiences") -- which, to me and I > guess to other respondents, implied that the requested arguments > *would* have a bit to do with something; I'm less surprised, now > that I hear this, that said arguments mattered not a whit. We need some context here. Stephen Figgins wrote a great (IMO) "outsider" summary of the brouhaha at the time: http://www.oreillynet.com/pub/a/python/2000/08/30/pythonnews.html Against the background of "a flurry of posts that accused the Python development team of creeping featurism, selling out the language to corporate interests, moving too fast, and turning a deaf ear to the Python community", Guido was trying to insist on some sanity. Don't take it personally, I don't think it was ever directed at you. But the overall debate had gone nuts. As Moshe reminded already, what Guido asked NOT to get was "votes", not "experience". A killer pure argument would have been great too. However, in his estimation he didn't get one, much as in your estimation he didn't make one. So it goes. > ... > Oh, I do realize this -- Python *will* have this wart forevermore. > That doesn't mean I intend to suffer it *silently*. No indeed, so long as it's understood that the right to speak is not also the right to be listened to -- don't you think there are more *interesting* things to do in the Python world than beat this dead horse? I do. > ... > I thought I had posted (must have been 4-5 months ago) about my > "print>>" experiments? I could well have missed that -- sorry. In the crunch to get Python 2.0 out the door, we were all pulling 20-hour days for a while, and facing the prospect of being out of work anyway (indeed, as things turned out, we finished the release on our own time). It was darned hectic. > Briefly -- I took one module that was using about 20 print > statements in two functions (and used the sys.stdout setting for > redirect when needed, from a separate wrapping function) and > recoded it using '>>blotch' on every print (with 'blotch' a > function parameter defaulting to None on the operating functions). I don't think I would have liked ">>blotch" in that context either: if I find myself using print>> in more than one or two lines in a function, I don't like it. It's simply too wordy for me then. It's the bee's knees, though, for an infrequent print to a rarely-used file, or for echo'ing the same msg to multiple files (like a log and stdout). Then it's pleasant. BTW, I see you also picked up on my dislike for sys.stderr. In the doctest context, yes, that's 100% my baby and I wrote it to please me. I don't have that luxury when working on other peoples' code, though, and if someone is already printing to sys.stderr, I'll play along for the sake of keeping their code true to *their* vision. And then print >> sys.stderr, "Hey! I got", `got`, "but expected", `want` 1 line in 250 is pure pleasure. > The small wrapper was not bad: > > from [before 'print>>']: > > def foobarRedirect(fileob, *args): > save = sys.stdout > try: return foobar(*args) > finally: sys.stdout = save > > to the simpler: > > def foobarRedirect(fileob, *args): > return foobar(*args, blotch=fileob) > > However, function foobar itself was cluttered by a more > substantial amount than the wrapper was simplified, what with > each 'print x' becoming 'print>>blotch,x' (plus the extra > blotch=None argument to both foobar and the other function, > also exposed from the module, that foobar calls). As above, I don't believe I would use print>> here either. > This has as little 'scientific' value as any other similar > experiment, of course (which is part of why I find your > 'more-impressed' somewhat unlikely) -- it's not a controlled > ergonomics experiment: We have no funding for that, so anecdotal evidence-- in the absence of a killer argument --is the best we're going to get. > in the end, the evaluation of "how readable and maintainable is > the resulting code" is about as subjective and aesthetic as one's > original appreciation of the construct. But then, actual human- > factors controlled experiments are just as scarce on the side > _supporting_ 'print>>', aren't they? There are none in either direction that I know of, and I doubt there ever will be. The realm of the subjective is where a BDFL is *most* needed! > I don't think I posted on the similar experience I did with > code previously using flob.write, but it was even worse from > my point of view. Changing the calls, typically originally > all in the form: > flob.write(format % (a,b,c)) > to print-with-redirect: > print >> flob, format % (a,b,c), > not only had no observable benefit, but actually gave a > slight problem in a case where an unwanted blank space got > inserted by two back-to-back 'print>>' (while the .write > calls, of course, did not insert it). The space-inserting gimmicks of plain "print" are best for output intended to be read by humans, and I think that's just as true of "print>>". I *suspect* (but don't know) that one reason Guido found print>> attractive is the number of msgs (over the years) directed to sys.stderr that are *missing* crucial spaces when done in the sys.stderr.write(msg) form -- and since they're "error msgs", sometimes years go by before we see that one of those is damaged. Now a space-eager printing gimmick could have been done via a function too, but Python already *had* a stmt for that purpose. From that POV, it was natural to extend it. > But then, I had even lower expectations this time -- it seems > that 'print>>' is studied to substitute for print-plus- > sys.stdout-changes, not for .write (which is what I most often > use for output). I don't think print>> is ever a good substitute for .write(), except in those cases where .write() is being used for human-readable output and the author didn't want to do the stdout redirection dance around plain "print". Else automagical space-insertion gets in the way more than it helps. Don't know whether Guido would agree, but that's my take on it. > The "lower expectations" may be important -- but I can't > brainwash myself (and wouldn't if I could) to expect the > sky and stars from a construct that strikes me so badly: > giving it "a fair chance" may thus be impossible for me. Try thinking of it as a minor convenience? I do! I could live without it; I'd rather not. > Still, we're all humans (or bots), and thus, this is no > doubt a widespread issue. I've spent an hour or so on it, > confirmed the preconceived ideas I had before I did, and > my opinions about 'print>>' are, as could be expected, > > Be that as it may, I'm still waiting to see real-life > examples, in my code *or others'*, where the use of > 'print>>' will strike me as "ah yes, clearly the one > right, obvious way to do it". A quick regexp search turns up about 135 uses in the current CVS tree. Some I don't like. Some I do. I'll mention two of the latter because I expect to hear about all the others from you . 1. The last line of Lib/test/test_largefile.py: print >>sys.stderr, name, "exists:", os.path.exists(name) A human-readable msg and the only use of sys.stderr in the module. There is no (IMO) alternative as obvious or convenient as this way of writing it. 2. Lib/warnings.py: 3 instances in 280 lines of code, again all trying to write something human-readable to sys.stderr. And I'll toss in one marginal one: Lib/smtpd.py has 12 instances of print >> DEBUGSTREAM, some, human, readable, msg That's in over 531 lines of code, and it never appears often in a single function, so it's not being overused by my lights. But I prefer using a debug *function* for this kind of thing: it's more flexible. For example, the module's default value for DEBUGSTREAM is DEBUGSTREAM = Devnull() where the author wrote a Devnull class with a do-nothing .write() method: class Devnull: def write(self, msg): pass def flush(self): pass While just a few lines of code, it's on the edge of being strained. I'd also rather see these lines as DEBUG(some, human, readable, msg) because it's the DEBUG part that's important, not the "print" part (and, indeed, the *normal* use of these lines is *not* to print!). Ack -- it's after 4AM again, and we've got a release to get out tomorrow (today? who can tell anymore ). One quickie: > ... > I guess, when he comes around to it, since he has no C background > to understand the rules for the format string; I'd better write up > something for him -- or can somebody help with an URL about %- > formatting already written up for somebody with zero C background?). I don't, but there's a very *good* writeup at: http://www-ccs.ucsd.edu/c/lib_prin.html Lots of examples, explanation, and even a railroad diagram for the syntax of a format code (which I'm afraid is more confusing than helpful!). At least the docs for 2.1 contain *a* description of each format code. The contributed patch Fred started from can be found here: http://sourceforge.net/patch/index.php?func=detailpatch& patch_id=103412&group_id=5470 good-topic-for-a-"howto"!-dense-little-languages-aren't-obvious-ly y'rs - tim From barry at digicool.com Fri Feb 2 09:24:26 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Fri, 2 Feb 2001 03:24:26 -0500 Subject: . Python 2.1 function attributes References: <95432j014on@news2.newsguy.com> Message-ID: <14970.28346.972083.948158@anthem.wooz.org> >>>>> "TP" == Tim Peters writes: TP> And I'll toss in one marginal one: Lib/smtpd.py has 12 TP> instances of And I agree, it's marginal. But I wrote that code a looong time ago[*], I think just after print>> was added, and mostly to experiment with it. If I did it again today, I probably /would/ use a debug function (much like I still use a syslog() debug function in Mailman). Tim's absolutely right, there's still a place for debug functions, but when print's behavior is what you want, I see no reason to go through the headaches and ugliness of sys.stdout redirection, or to re-implement all that behavior in a homegrown function. I do use print>> quite a bit in my mimelib package (Generator.py) because it's just so damn convenient and (to me, and I wrote it so I get to choose :) so much cleaner than either a function or wrapping in sys.stdout redirection. I really do believe either of those latter solutions would be uglier, if done correctly, compatibly, and robustly. and-email-is-(arguably)-human-readable-ly y'rs, -Barry [*] even though it was just recently checked in. From donn at u.washington.edu Thu Feb 1 20:05:42 2001 From: donn at u.washington.edu (Donn Cave) Date: 1 Feb 2001 19:05:42 GMT Subject: . Python 2.1 function attributes References: Message-ID: <95cc26$k0k$1@nntp6.u.washington.edu> Quoth "Tim Peters" : [... MASSIVE WEIGHT LOSS in ONE DAY! ...] | A quick regexp search turns up about 135 uses in the current CVS tree. Some ... To cruelly prolong the misery of this thread - I personally find "print >>" kind of distasteful in terms of the notation, but as long as we have it, we may as well enjoy it. Now that the build procedure is partly implemented in Python, I wish that a bunch of "print" commands in distutils could be "print >> sys.stderr" instead. The right way to run a build is with output redirected to a disk file, so you can review it at your leisure, and that makes stdout block buffered. The output doesn't get to the file for a long time, or at all if you have some reason to kill the process, comes out in blocks irrespective of line structure, and meanwhile all the incidental diagnostics are arriving that were issued to stderr/unit 2. Since stderr is line buffered, it's really much better to go there with diagnostic outputs, in fact that's what it's for and why it works the way it does. Likewise, the one line in test_*.py should be about every instance of print in any such file. Donn Cave, donn at u.washington.edu From tim.one at home.com Fri Feb 2 05:43:16 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 1 Feb 2001 23:43:16 -0500 Subject: . Python 2.1 function attributes In-Reply-To: <95cc26$k0k$1@nntp6.u.washington.edu> Message-ID: [Donn Cave, stderr's best buddy] > ... > Since stderr is line buffered, it's really much better to go > there with diagnostic outputs, in fact that's what it's for and > why it works the way it does. Maybe on your OS this is helpful. On mine output to stderr scrolls off the shell window irretrievably, and can't be redirected from the command line. Not much fun to see it interleaved in seemingly random order with stdout either. > Likewise, the one line in test_*.py should be about every > instance of print in any such file. Sorry, this one's wrong independent of OS. Python's std regression tests (test_*.py) work by capturing stdout and comparing it to canned "expected output" files. stderr *may* have a marginal role there, but only for exceedingly rare "what the f**k?! this isn't just wrong, it's an utterly unexpected disaster!" cases. But even those would be better directed to stdout, because the stdout comparison mechanism would point them out if they happen, and won't forget to look for them. People do forget, and, as is, when one of these stderr cases crops up, regrtest.py doesn't realize the test failed either. and-no-i-had-no-part-in-writing-regrtest.py-ly y'rs - tim From aleaxit at yahoo.com Fri Feb 2 15:24:29 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 2 Feb 2001 15:24:29 +0100 Subject: . Python 2.1 function attributes References: Message-ID: <95efv80hih@news1.newsguy.com> "Tim Peters" wrote in message news:mailman.981046930.4615.python-list at python.org... [snip] > We need some context here. Stephen Figgins wrote a great (IMO) "outsider" > summary of the brouhaha at the time: > > http://www.oreillynet.com/pub/a/python/2000/08/30/pythonnews.html [snip] > > Oh, I do realize this -- Python *will* have this wart forevermore. > > That doesn't mean I intend to suffer it *silently*. > > No indeed, so long as it's understood that the right to speak is not also > the right to be listened to -- don't you think there are more *interesting* > things to do in the Python world than beat this dead horse? I do. There is, in my opinion, a subtle and important distortion in what you call "a great outsider summary" above -- specifically in its summing things up (as of August 2000) with "This has quieted some of the complaints down. I expect them to taper off this week" and "am looking forward to seeing what controversy will rise up next as this one finally dies down". This implies that the controversy was a tempest in a teapot, just one of many, that everybody was by now resigned to what Mr. Figgins calls "a done deal". This is not the way I see the "print>>" issue. I consider it _by far_ the worst thing to ever have happened to Python (in the limited timespan in which I've been following Python; but, judging from what I've read in old mailing list archives and what I can see now in the language as it stands, then 'ever' does apply). "Those who cannot remember the past are condemned to repeat it" (this Santayana quote is often subject to many variations -- I apologize, but I don't know what the exact wording should be). If there is anything at all that I can do, which may decrease by one part in a million the probability that Python may suffer a repetition of the "print>>" disaster, it may be worth it; and, if this quote contains any germ of truth, then ensuring the remembrance is not buried may perhaps be some part of that one-in-a-million decrease in the risk of such a repetition. No, I do not believe there is any Python related endeavour, that I might be capable of, that is more IMPORTANT ("interesting" is a different issue) than whatever fraction of a part in a million I may contribute to avoiding such a repetition (if I thought there was ANY chance, no matter how tiny, to have the horrid wart REMOVED from the language, then that would be something else again -- but I don't; so, the _most_ I can hope for is to perhaps contribute to lowering the probability of a repetition). Of course I have no right to be listened to -- killfiles have not been abrogated, have they? Everybody, as usual, is _welcome_ to killfile me if they're not interested in what I have to say -- have I ever said or implied otherwise? > their code true to *their* vision. And then > > print >> sys.stderr, "Hey! I got", `got`, "but expected", `want` > > 1 line in 250 is pure pleasure. How is this "better" than sys.stderr.write("Hey! I got %r but expected %r\n" % (got, want)) ...? > *suspect* (but don't know) that one reason Guido found print>> attractive is > the number of msgs (over the years) directed to sys.stderr that are > *missing* crucial spaces when done in the sys.stderr.write(msg) form -- and > since they're "error msgs", sometimes years go by before we see that one of > those is damaged. When the msg is put together with a %-format, which seems to be the way that most comes natural to me, it's hard to think that missing spaces can be an important issue. > Now a space-eager printing gimmick could have been done via a function too, > but Python already *had* a stmt for that purpose. From that POV, it was > natural to extend it. I have no bones to pick against the print statement for its most elementary, daily use -- rough & ready debugging; no matter how refined the debuggers I have at hand, I'm enough of a dinosaur that much of my debugging is inserting and removing print's. But for that use case there is no added value in redirecting each of them separately -- if I find a sudden need to have all of the print's I currently have use OutputDebugString, or whatever, then a temporary setting of sys.stdout around the interesting parts remains preferable (which I think is part of what you were agreeing on, in the parts of your post that I snipped, above). _For a specific need to output something onto a given file_, I find absolutely nothing natural or worthwhile in "extending" a statement whose main use case is so different (impromptu tracing). An output function would have required no syntax blotch (I have just reread Guido's response and see that he does mention the analogies with sh's use of >> -- he does fail to mention that those analogies are _misleading_ ones, exactly those that seemed to trip up my son), and the objection "but for a function I have no way to say ``and don't use a linebreak''", also part of Guido's response, is unbelievable -- why not just printfun(x,y,z,newline=None) ...?! *Fortunately*, it's NOT natural in Python for a statement that already exists for a purpose to be extended, with kludgy syntax, to other similar purposes a function would serve better. For parallel iteration over lists, we didn't get some syntactically horrid kludge based on the existing for statement -- we got a usable and elegant zip function instead, good for that one AND other secondary uses too. Let's hope the "well, there IS one statement that does something a BIT like that, let's think of some C++ish abuse of a binary operator into a unary not-quite- an-operator-whatever-the-heck-IS-it to have it do that too" remains a once-a-decade occurrence in Python, rather than have it become a way of life. > I don't think print>> is ever a good substitute for .write(), except in So far, we agree, up to the "except" excluded:-). > those cases where .write() is being used for human-readable output and the > author didn't want to do the stdout redirection dance around plain "print". The redirection minuet is one thing, but I claim that write with a %-format doesn't leave me wanting for decent ways to do output. A printlike function would be better, but I don't hunger for it often, because write-plus-% does it well; if I _did_ hunger for it, it would not be terrible to write it, either (though having it as a builtin would encourage its use in small pieces of code meant to be portable). > Else automagical space-insertion gets in the way more than it helps. Don't > know whether Guido would agree, but that's my take on it. FWIW (little, of course), I agree with your take, from the 'Else' (excluded) onwards. > > The "lower expectations" may be important -- but I can't > > brainwash myself (and wouldn't if I could) to expect the > > sky and stars from a construct that strikes me so badly: > > giving it "a fair chance" may thus be impossible for me. > > Try thinking of it as a minor convenience? I do! I could live without it; > I'd rather not. "convenience" is the most-used euphemism, in today's programming, for "horrid blotch that anybody should be ashamed of", to justify complication, irregularity, rampant ad-hocitis and kludges. Thus, I have no trouble at all thinking of 'print>>' as a "convenience" (visualize Dr. Evil doing the ``quotes'' finger-gesture...). It's not "minor", IMHO, mostly because its syntax stands out like a sore thumb (and BY DESIGN, no less!) from Python's generally pretty nice picture. It DOES, as intended, recall C++, or sh -- but, in THOSE punctuation-obsessed contexts, what's a >> more or less. Anything that takes Python's syntax closer, _by design_, to that of such collections of syntactic warts as C++ or sh is a MAJOR "convenience" indeed! > A quick regexp search turns up about 135 uses in the current CVS tree. Some > I don't like. Some I do. I'll mention two of the latter because I expect > to hear about all the others from you . No need... the "likeable" ones are bad enough!-) Taking just one: > 1. The last line of Lib/test/test_largefile.py: > > print >>sys.stderr, name, "exists:", os.path.exists(name) > > A human-readable msg and the only use of sys.stderr in the module. There is > no (IMO) alternative as obvious or convenient as this way of writing it. What about: sys.stderr.write("%s exists: %s\n" % (name, os.path.exists(name)) ...? What's so horribly inconvenient or too-subtle about %-formatting? > While just a few lines of code, it's on the edge of being strained. I'd > also rather see these lines as > > DEBUG(some, human, readable, msg) > > because it's the DEBUG part that's important, not the "print" part (and, > indeed, the *normal* use of these lines is *not* to print!). I fully agree with this assessment. If a function printfun and/or a method printmethod existed to do printlike things, I think this would encourage by example the use of a function here and in similar contexts -- one might just have DEBUG=fileobject.printmethod to turn it on, and DEBUG=functionthatdoesnothing to turn it off. > > I guess, when he comes around to it, since he has no C background > > to understand the rules for the format string; I'd better write up > > something for him -- or can somebody help with an URL about %- > > formatting already written up for somebody with zero C background?). > > I don't, but there's a very *good* writeup at: > > http://www-ccs.ucsd.edu/c/lib_prin.html > > Lots of examples, explanation, and even a railroad diagram for the syntax of > a format code (which I'm afraid is more confusing than helpful!). I'm not a diagram-oriented person myself, but the rest does seem useful -- thanks! > At least the docs for 2.1 contain *a* description of each format code. The > contributed patch Fred started from can be found here: > > http://sourceforge.net/patch/index.php?func=detailpatch& > patch_id=103412&group_id=5470 Thanks again, I'll have a look. > good-topic-for-a-"howto"!-dense-little-languages-aren't-obvious-ly Good point... Alex From mbel44 at dial.pipex.net Mon Feb 5 15:15:48 2001 From: mbel44 at dial.pipex.net (Toby Dickenson) Date: Mon, 05 Feb 2001 14:15:48 +0000 Subject: . Python 2.1 function attributes References: <95efv80hih@news1.newsguy.com> Message-ID: <1jct7tg5u6j3fir09edclfm5jmf5n59eto@4ax.com> "Alex Martelli" wrote: >> I don't think print>> is ever a good substitute for .write(), except in > >So far, we agree, up to the "except" excluded:-). > >> those cases where .write() is being used for human-readable output and the >> author didn't want to do the stdout redirection dance around plain >"print". > >The redirection minuet is one thing, but I claim that write >with a %-format doesn't leave me wanting for decent ways to >do output. A printlike function would be better, but I >don't hunger for it often, because write-plus-% does it well; Not well enough, apparently, judging by the number of packages that grew out of the need for exactly this type of output. A need that wasnt satisfied by file.write("formatting"%(data)) The two that I am familiar with are the templating parts of quixote http://www.mems-exchange.org/software/python/quixote/ and DC's DTML. DTML is part of Zope - It currently currently does alot more than just formatting, but I understand that was its original (and only) goal. The real problem (IMO) with file.write("formatting"%(data)) is that the expressions that build up the data are out of line with the static content. Its harder for the programmer to visualize the bigger picture of his output, because he has to mentally interleave the dynamic and static parts. The problem is greater in functions whose only job is output formatting. The disadvantage is comparable to the difference between using an infix notation, or function notation for arithmetic. ps. Ive used both dtml and quixote templates, but largely abandonned them both in favor of print >> Toby Dickenson tdickenson at geminidataloggers.com From aleaxit at yahoo.com Mon Feb 5 17:20:45 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 5 Feb 2001 17:20:45 +0100 Subject: . Python 2.1 function attributes References: <95efv80hih@news1.newsguy.com> <1jct7tg5u6j3fir09edclfm5jmf5n59eto@4ax.com> Message-ID: <95mjsv01t2t@news1.newsguy.com> "Toby Dickenson" wrote in message news:1jct7tg5u6j3fir09edclfm5jmf5n59eto at 4ax.com... [snip] > >The redirection minuet is one thing, but I claim that write > >with a %-format doesn't leave me wanting for decent ways to > >do output. A printlike function would be better, but I > >don't hunger for it often, because write-plus-% does it well; > > Not well enough, apparently, judging by the number of packages that > grew out of the need for exactly this type of output. A need that > wasnt satisfied by file.write("formatting"%(data)) Oh, of course, there ARE plenty of human-readable-output needs that neither file.write, nor print in any form, support decently. You mention HTML-oriented templating output, which has no special need to be human-readable: there, file.write with format is _much_ superior, since more easily localized (print is a disaster in this sense -- no problem for quick&dirty debug-oriented output, but of course NOBODY is writing deliberately non-localizable applications, *ARE THEY*...?-); but 'full templating' is often more powerful, and it's simple to implement well in Python, too -- so, like everybody else, I built my own "Yet Another Python Template Utility" (YAPTU) and use that one for those (not-infrequent) text-output needs that are well satisfied via templating. _Some_ output needs require more logic than such templating can supply while remaining simple and well-usable. Hierarchical stuff that nests to arbitrary depth, for example; I know of no template solution that fully supports the unlimited-depth recursion that is typical (e.g.) of some ways to present a "bill of materials". For THAT, the recursive logic is better handled in Python (IMHO). But when the time comes to output a given 'block' of info (typically a line or small block of lines, with the code-logic determining, e.g., to what 'depth' it is to be indented), the specifics are still best handled with a formatting-line (with a dictionary on the RHS of the %, no doubt, and named fields -- we ARE talking about somewhat complicated needs after all!), and that formatting line had better be retrieved by reasonably flexible logic, else, one can wave good-bye to localization and customization (fortunately, a DB tends to be around when one is doing stuff at THIS level of complexity, so, a way is not lacking to flexibly store and recoved the needed formatting-lines!-) > The real problem (IMO) with file.write("formatting"%(data)) is that > the expressions that build up the data are out of line with the static > content. Its harder for the programmer to visualize the bigger picture > of his output, because he has to mentally interleave the dynamic and > static parts. The problem is greater in functions whose only job is > output formatting. If the ONLY job is output formatting, then there are going to be no 'expressions' to speak of -- 'data' will be a dictionary that associates names with values, and the computation will have been done elsewhere -- a very sensible way to split computation from presentation tasks, of course. But then, where is the difference between, e.g., flob.write("An a %(one)s an a %(two)s an a %(three)s!\n" % data) and print >> flob, "An a",one,"an a",two,"an a",str(three)+"!" except the sundry ways in which the second form is inferior? E.g., it's trouble to get the final '!' adjacent to the last item being output (you need to switch to str and concatenation rather than using the same approach as for all other items), localization is a bear (how do you get the pieces, how many do you get, how do you order the items...?), so is formatting to align columns to the left or right (trivial with %), the function itself needs to know the names of the items and get them into its namespace appropriately, AND flob itself may get several write calls and softspace settings and queries rather than dealing with just one nice solid write period. > The disadvantage is comparable to the difference between using an > infix notation, or function notation for arithmetic. It's true that a few more parentheses are needed for a write call, since Python syntax requires them (both around the whole %-expression, and inside the format-string when the RHS is a dictionary). But print>> requires a similar amount of commas, so it balances out; the _order_ in which the names are used is the same, and there are no "function names" vs "operators" involved, so the analogy is strained. > ps. Ive used both dtml and quixote templates, but largely abandonned > them both in favor of print >> If templates were not suitable for your needs, you no doubt did well to abandon their use. But using fileob.write rather than print>>fileob would have ensured further benefits -- see above. So, your choice need not have been the optimal one. Betraying the "one obviously correct way" philosophy is just one more way in which 'print>>' is unPythonic. There never really IS just one way, of course, nor is the right one, often, "obviously" right; but providing one more way to do yet the same thing -- particularly one whose disadvantages (difficulty in localization, column alignment, etc, etc) may not be obvious to inexperienced users -- was a step in the wrong direction. (Reflecting on how all needs might have been best served -- a futile exercise, some would say, but I'm a Santayana follower -- leads me to believe that a Print function [also supplied as a method on built-in objects -- much like xreadlines is going to be both a method of built-in objects AND a utility function to wrap user-written objects, if I understand that correctly] would have been Just Right. It would take an optional 'format=' argument, which, if present and not None, overrides the implicit ``formatting'' of "paste stuff together with spaces and a \n and the end"; one could easily prototype with a call to Print almost identical to today's print statement, then add to it a suitable format= for localization, just as one might add a suitable file= etc.). Alex From mbel44 at dial.pipex.net Tue Feb 6 15:37:13 2001 From: mbel44 at dial.pipex.net (Toby Dickenson) Date: Tue, 06 Feb 2001 14:37:13 +0000 Subject: . Python 2.1 function attributes References: <95efv80hih@news1.newsguy.com> <1jct7tg5u6j3fir09edclfm5jmf5n59eto@4ax.com> <95mjsv01t2t@news1.newsguy.com> Message-ID: "Alex Martelli" wrote: >> The real problem (IMO) with file.write("formatting"%(data)) is that >> the expressions that build up the data are out of line with the static >> content. Its harder for the programmer to visualize the bigger picture >> of his output, because he has to mentally interleave the dynamic and >> static parts. The problem is greater in functions whose only job is >> output formatting. > >If the ONLY job is output formatting, then there are going to be >no 'expressions' to speak of -- 'data' will be a dictionary that >associates names with values, and the computation will have been >done elsewhere -- a very sensible way to split computation from >presentation tasks, of course. But then, where is the difference >between, e.g., > >flob.write("An a %(one)s an a %(two)s an a %(three)s!\n" % data) > >and > >print >> flob, "An a",one,"an a",two,"an a",str(three)+"!" If your elements comes neatly packed in a dict, then yes thats true. The % operator is adept at picking named elements out of your dict. More commonly you need to pick the elements out of some other, equally simple data structure: print >> flob, "An a",things[1],"an a",things[2],"an a",things[3]+"!" print >> flob, "An a",things.pop(),"an a",things.pop(),"an a",things.pop()+"!" >It's true that a few more parentheses are needed for a write >call, since Python syntax requires them (both around the >whole %-expression, and inside the format-string when the >RHS is a dictionary). But print>> requires a similar amount >of commas, so it balances out; the _order_ in which the >names are used is the same, and there are no "function names" >vs "operators" involved, so the analogy is strained. No, the analogy is about visual locality, not names. If your data comes packaged in something other than a dict: flob.write("An a %s an a %s an a %s!\n"%(one,two,three)) Toby Dickenson tdickenson at geminidataloggers.com From greg at cosc.canterbury.ac.nz Wed Feb 7 23:08:08 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 08 Feb 2001 11:08:08 +1300 Subject: . Python 2.1 function attributes References: <95efv80hih@news1.newsguy.com> <1jct7tg5u6j3fir09edclfm5jmf5n59eto@4ax.com> Message-ID: <3A81C748.527272C@cosc.canterbury.ac.nz> Toby Dickenson wrote: > > The real problem (IMO) with file.write("formatting"%(data)) is that > the expressions that build up the data are out of line with the static > content. Its harder for the programmer to visualize the bigger picture > of his output, It seems that different people may see this differently, since I often find it easier to visualise the output when using a format string. When the output items are interleaved with string literals, I find the result is often a confusing clutter of commas and quotes, especially when there are commas in the string literals as well. Besides, with the %(name) formatting item, you can get the best of both worlds. -- 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 joconnor at cybermesa.com Thu Feb 8 00:03:55 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Wed, 07 Feb 2001 23:03:55 +0000 Subject: . Python 2.1 function attributes References: <95efv80hih@news1.newsguy.com> <1jct7tg5u6j3fir09edclfm5jmf5n59eto@4ax.com> <3A81C748.527272C@cosc.canterbury.ac.nz> Message-ID: <3A81D45B.B90C8F45@cybermesa.com> Greg Ewing wrote: > > Toby Dickenson wrote: > > > > The real problem (IMO) with file.write("formatting"%(data)) is that > > the expressions that build up the data are out of line with the static > > content. Its harder for the programmer to visualize the bigger picture > > of his output, > > It seems that different people may see this differently, > since I often find it easier to visualise the output > when using a format string. When the output items are > interleaved with string literals, I find the result > is often a confusing clutter of commas and quotes, > especially when there are commas in the string > literals as well. FWIW - I find 'printf()' style formatting string easier to write but harder to reaf -- Jay O'Connor joconnor at cybermesa.com http://www.cybermesa.com/~joconnor Python Language Discussion Forum - http://pub1.ezboard.com/fobjectorienteddevelopmentpython From donn at u.washington.edu Fri Feb 2 18:36:04 2001 From: donn at u.washington.edu (Donn Cave) Date: 2 Feb 2001 17:36:04 GMT Subject: . Python 2.1 function attributes References: Message-ID: <95er64$q36$1@nntp6.u.washington.edu> Quoth "Tim Peters" : | [Donn Cave, stderr's best buddy] | > ... | > Since stderr is line buffered, it's really much better to go | > there with diagnostic outputs, in fact that's what it's for and | > why it works the way it does. | | Maybe on your OS this is helpful. On mine output to stderr scrolls off the | shell window irretrievably, and can't be redirected from the command line. | Not much fun to see it interleaved in seemingly random order with stdout | either. That is so sad. |> Likewise, the one line in test_*.py should be about every |> instance of print in any such file. | | Sorry, this one's wrong independent of OS. Python's std regression tests | (test_*.py) work by capturing stdout and comparing it to canned "expected | output" files. stderr *may* have a marginal role there, but only for | exceedingly rare "what the f**k?! this isn't just wrong, it's an utterly | unexpected disaster!" cases. But even those would be better directed to | stdout, because the stdout comparison mechanism would point them out if they | happen, and won't forget to look for them. People do forget, and, as is, | when one of these stderr cases crops up, regrtest.py doesn't realize the | test failed either. You're right, I should have looked at the stuff before saying that. The "prints" I was really thinking of turn out to be in regrtest.py itself. Donn Cave, donn at u.washington.edu From juergen.erhard at gmx.net Wed Feb 7 01:11:07 2001 From: juergen.erhard at gmx.net (Jürgen A. Erhard) Date: Wed, 07 Feb 2001 01:11:07 +0100 Subject: Interested in a Crypto-SIG? In-Reply-To: References: <3A72C8A3.C4B4D69A@stroeder.com> <3A731F26.15461A27@stroeder.com> Message-ID: <07022001.1@wanderer.local.jae.ddns.org> >>>>> "A" == A M Kuchling writes: A> On Sat, 27 Jan 2001 20:19:02 +0100, A> Michael Str?der wrote: >>

The list is hosted inside the US, as are its archives, so >> to avoid falling afoul of the US export restrictions, it's >> recommended that postings not contain complete programs or modules. >> >> This does not attract me very much. A> Given the relaxing of US export laws last year, this text is A> really no longer necessary, and I should edit the list A> description accordingly. (Shows how much time I spend on A> crypto these days...) It's not export *laws* it's just the *regulations* of the *current* Administration. And, as we all know, the Administration just changed... I'm not expecting too much good from *that* guy. And I'd *certainly* wait with moving in crypto-related matters until those regulations had turned into real, Senate/HR-fortified, law. Sorry if I spoiled you day, 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 George Herrimann's Krazy Kat (http://www.krazy.com) "Windows NT" is an acronym for "Windows? No thanks." -- Russ McManus From michael at stroeder.com Wed Feb 7 15:44:47 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Wed, 07 Feb 2001 15:44:47 +0100 Subject: Interested in a Crypto-SIG? References: <3A72C8A3.C4B4D69A@stroeder.com> <3A731F26.15461A27@stroeder.com> Message-ID: <3A815F5F.C37B76E2@stroeder.com> "J?rgen A. Erhard" wrote: > > A> On Sat, 27 Jan 2001 20:19:02 +0100, > A> Michael Str?der wrote: > >>

The list is hosted inside the US, as are its archives, so > >> to avoid falling afoul of the US export restrictions, it's > >> recommended that postings not contain complete programs or modules. > >> > >> This does not attract me very much. > > A> Given the relaxing of US export laws last year, this text is > A> really no longer necessary, > > And I'd *certainly* > wait with moving in crypto-related matters until those regulations had > turned into real, Senate/HR-fortified, law. The solution for a python-crypto list is: http://listserv.surfnet.nl/archives/python-crypto.html Ciao, Michael. From drewpc at colorado.edu Thu Feb 1 22:44:59 2001 From: drewpc at colorado.edu (PC Drew) Date: Thu, 01 Feb 2001 21:44:59 GMT Subject: Interested in a Crypto-SIG? References: <3A72C8A3.C4B4D69A@stroeder.com> Message-ID: <95clco$ecq$1@nnrp1.deja.com> In article <3A72C8A3.C4B4D69A at stroeder.com>, Michael =?iso-8859-1?Q?Str=F6der?= wrote: > HI! > > (I know that SIG proposals should go to the META-SIG list but I > guess not many developers are subscribed to this list. Therefore I > start the discussion here.) > > I would like to propose a Crypto-SIG. The goal is to define Pythonic > class APIs for various cryptographic and related standards to enable > developers to use a unified API for implementing crypto-enabled > applications in Python independent of the underlying implementations > (basically inspired by Sun's Java crypto-related APIs). > I'm the one who proposed the idea to the meat-sig list the other day. Since then, I've joined the python-crypto list and have been having interesting discussions regarding this idea. There seems to be a genuine interest in this idea and I think that we should start drafting up an API. I'm starting to look into amkCrypto and m2crypto heavily so that I can see what things I haven't thought about. I hope to have some sort of draft in the next week. I'll coordinate this with you. Also, I think once we get started on this, it'll be easier to try and get a SIG. I too think that it'd be better to get a SIG!! Sent via Deja.com http://www.deja.com/ From schlatterbeck at tttech.com Mon Feb 5 13:28:33 2001 From: schlatterbeck at tttech.com (Ralf Schlatterbeck) Date: 5 Feb 2001 13:28:33 +0100 Subject: Python for embedded systems (was Re: What does Python do) References: <94gmeu$4fc$1@sooner.brightok.net> <94gvv5$7mo$1@sooner.brightok.net> <2F4DC6312B7FE9DA.74AB95EBEF3C09D4.1D6BDBE5660A1914@lp.airnews.net> <3A6D1E04.AABCC7DE@engcorp.com> <3A6E66EE.38FEB4F0@engcorp.com> <3A731E86.9FB8930D@fxtech.com> Message-ID: <95m69h$768$1@ttt14.tttech.com> Peter Hansen writes: > We have Python running on a 1MB Flash/1MB RAM PC/104 module. > With the compiler. Quite cool. I know from posts here that > at least one other company has achieved something similar. > I'm still pleased to find how well many of Python's advantages > translate through into the embedded world. This is, of course, > an extremely long way from a 16-bit chip with a 64K address > space, but for that there's always FORTH. :-) I replied to Peter by email and asked him: > How did you do it? Will you make this publicly available? He asked me to make his answer available in this group, here it is: Peter Hansen writes: Perhaps you would be good enough to post my reply to the forum for me, as the system on which I'm typing this has no Usenet access. Thanks. Making Python run on a PC104 system with 1MB-flash was not at all difficult. Among the few things we had to do was to strip out a large number of "unnecessary" (to us) modules, including floating point, files, long integers, all platform-specific stuff, and Unicode. We had to provide a customized thread.h for our third-party real-time kernel. Maybe the only thing that was at all difficult to figure out was how to modify marshal.c to avoid allocating a buffer in RAM and copying the code object there when a module is imported (since we are running code directly from flash, unlike many PC104 systems where the flash is only used as a file system and all code is loaded into RAM before executing). The final item to produce a useful environment was to provide a serial port implementation of sys.stdout and sys.stdin for the interactive interpreter. It is very gratifying to see the ">>> " prompt show up in Hyperterminal on a PC after all the hard work. :) Our intention was to make this publicly available, but it is not yet in any shape to do so. Furthermore, because of a change in strategy with our product, we are likely to upgrade to a more powerful processor board which will require migrating to a more typical configuration with flash file system and code running from RAM. Rather than release the coarse results of our work so far, I would be happy to respond to individuals with non-frivolous requests for specific assistance, by helping point out the areas where we've made changes and providing 'patches' or portions of our work rather than the whole thing. (Packaging up an entire work product for release, even as a free 'no warranty' type of thing, takes a lot of doing from a corporate point of view, and I'm sorry to have to say I can't spare the time do that right now.) (Once we have our final configuration polished up and at least our first product based on it released, I definitely intend to educate my upper management about why supporting the open-source community by contributing back to it is a Good Thing. It really shouldn't be a hard sell, but it has to be done in just the right way, as you may know. :-) -- Dr. Ralf Schlatterbeck mailto:schlatterbeck at tttech.com TTTech Computertechnik AG, Sch?nbrunnerstra?e 7, A-1040 Vienna, Austria Voice: +43/1/5853434-0, Fax: +43/1/5853434-90, http://www.tttech.com/ From ngps at madcap.dyndns.org Thu Feb 1 18:05:00 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 1 Feb 2001 17:05:00 GMT Subject: SSL EOF References: <980790776.835347129@news.silcom.com> <3A75DEB9.308FE746@san.rr.com> <980877001.384793985@news.silcom.com> Message-ID: <95c4vs$kss$1@violet.singnet.com.sg> According to Clarence Gardner : > Here is the relevant code. I don't know what error==6 signifies, but even > if the other side closed improperly, I don't think that's so significant as to > warrant making these sockets behave differently from non-ssl ones. > > count = SSL_read(self->ssl, PyString_AsString(buf), len); > res = SSL_get_error(self->ssl, count); > > switch (res) { > case 0: /* Good return value! */ > break; > case 6: > PyErr_SetString(SSLErrorObject, "EOF"); > Py_DECREF(buf); > return NULL; > break; > case 5: > default: > return PyErr_SetFromErrno(SSLErrorObject); > break; > For comparison, here's what M2Crypto's ssl_read() looks like: PyObject *ssl_read(SSL *ssl, int num) { PyObject *obj; void *buf; int r, err; if (!(buf = PyMem_Malloc(num))) { PyErr_SetString(PyExc_MemoryError, "ssl_read"); return NULL; } Py_BEGIN_ALLOW_THREADS r = SSL_read(ssl, buf, num); Py_END_ALLOW_THREADS switch (SSL_get_error(ssl, r)) { case SSL_ERROR_NONE: case SSL_ERROR_ZERO_RETURN: buf = PyMem_Realloc(buf, r); obj = PyString_FromStringAndSize(buf, r); break; case SSL_ERROR_WANT_WRITE: case SSL_ERROR_WANT_READ: case SSL_ERROR_WANT_X509_LOOKUP: Py_INCREF(Py_None); obj = Py_None; break; case SSL_ERROR_SSL: PyErr_SetString(_ssl_err, ERR_reason_error_string(ERR_get_error())); obj = NULL; break; case SSL_ERROR_SYSCALL: err = ERR_get_error(); if (err) PyErr_SetString(_ssl_err, ERR_reason_error_string(err)); else if (r == 0) PyErr_SetString(_ssl_err, "unexpected eof"); else if (r == -1) PyErr_SetFromErrno(_ssl_err); obj = NULL; break; } PyMem_Free(buf); return obj; } And Python code using that, from M2Crypto's https extension to Medusa: def recv(self, buffer_size): try: result = self.socket._read_nbio(buffer_size) if result is None: return '' elif result == '': self.socket.set_shutdown(SSL.SSL_SENT_SHUTDOWN|SSL.SSL_RECEIVED_SHUTDOWN) return '' else: self.server.bytes_in.increment(len(result)) return result except SSL.SSLError, why: self.socket.set_shutdown(SSL.SSL_SENT_SHUTDOWN|SSL.SSL_RECEIVED_SHUTDOWN) self.close() self.log_info('recv: closing channel %s %s' % (repr(self), why)) return '' So, in M2Crypto, ssl_read() does return a '' on eof; if the other side failed to close properly, an SSL.SSLError exception is raised with the error "unexpected eof". M2Crypto works with both Python 1.5.2 and Python 2.0. Get it here: http://www.post1.com/home/ngps/m2 Cheers. -- Ng Pheng Siong * http://www.post1.com/home/ngps From tim.one at home.com Fri Feb 2 00:28:53 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 1 Feb 2001 18:28:53 -0500 Subject: SSL EOF In-Reply-To: <95c4vs$kss$1@violet.singnet.com.sg> Message-ID: [Ng Pheng Siong] > ... > So, in M2Crypto, ssl_read() does return a '' on eof; > ... The good news is that it will in Python 2.1a2 also (to be released tomorrow). However, the more we (Jeremy, Guido, me) looked at Python's SLL support, the more questionable code we found. Alas, not being experts in this protocol, we're unlikely to fix it. So we would be grateful for a patch against CVS Python for doing this stuff more intelligently, including corresponding repairs to the httplib.py code that uses it. "case 6:"-brrrrrrrr-ingly y'rs - tim From clarence at netlojix.com Fri Feb 2 20:16:05 2001 From: clarence at netlojix.com (Clarence Gardner) Date: Fri, 2 Feb 2001 11:16:05 -0800 Subject: SSL EOF References: Message-ID: <981141471.767582214@news.silcom.com> On Thu, 01 Feb 2001, Tim Peters wrote: >[Ng Pheng Siong] >> ... >> So, in M2Crypto, ssl_read() does return a '' on eof; >> ... > >The good news is that it will in Python 2.1a2 also (to be released >tomorrow). However, the more we (Jeremy, Guido, me) looked at Python's SLL >support, the more questionable code we found. Alas, not being experts in >this protocol, we're unlikely to fix it. So we would be grateful for a >patch against CVS Python for doing this stuff more intelligently, including >corresponding repairs to the httplib.py code that uses it. > >"case 6:"-brrrrrrrr-ingly y'rs - tim Glad to hear about the EOF behavior change. To: The hypothetical person who knows about this stuff and will do it for Python From: A person who doesn't, but did anyway Yes, I implemented an SSL module for Python 1.5, and always felt guilty about not contributing it. I didn't because I implemented it without being able to find any documentation on SSL, and though it worked for my purposes, I have no idea how many holes it has. Here are some things to keep in mind when thinking of a re-do for Python: - The 2.0 stuff doesn't include a shutdown method. I had one in my implementation, but since I didn't know what I was doing, I just had it do a shutdown on the socket. It worked, but is clearly wrong. - As far as I can tell, the 2.0 stuff only allows the Python program to act as a client. Remembering my trial-and-error method of implementing server side, I can see why. :) ### I noticed that the M2Crypto code that was posted still, at the Python level, doesn't treat encrypted sockets the same as the others (e.g., returning a None result in some circumstances). I may be out of touch with the rest of the community, (or just objectively wrong), in thinking that they should... It seems to me that the application probably just cares about whether it can communicate with the other end, not which of the zillion different ways an ssl channel can go wrong. ---- Clarence Gardner Software Engineer NetLojix Communications clarence at netlojix.com From ngps at madcap.dyndns.org Sat Feb 3 04:55:05 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 3 Feb 2001 03:55:05 GMT Subject: SSL EOF References: <981141471.767582214@news.silcom.com> Message-ID: <95fvep$tqb$1@clematis.singnet.com.sg> According to Clarence Gardner : > - The 2.0 stuff doesn't include a shutdown method. I had one in > my implementation, but since I didn't know what I was doing, I > just had it do a shutdown on the socket. It worked, but is > clearly wrong. M2Crypto provides a shutdown() method for an SSL socket which calls SSL_shutdown() which DTRT. > - As far as I can tell, the 2.0 stuff only allows the Python program > to act as a client. Remembering my trial-and-error method of > implementing server side, I can see why. :) M2Crypto supports forking, threading, and async-io servers. (Sorry for the commercial. ;-) > I noticed that the M2Crypto code that was posted still, at the Python > level, doesn't treat encrypted sockets the same as the others (e.g., > returning a None result in some circumstances). None is overloaded to mean "try again" in non-blocking mode only. In blocking mode OpenSSL promises (heh) to not reach that code path. I could've invented an arbitrary object type, or return a tuple (return status, data), but they seem like too much work. So I overload None. ;-) > It seems to me that the application probably just > cares about whether it can communicate with the other end, not which of > the zillion different ways an ssl channel can go wrong. I disagree. Since you're using SSL, presumably you care about security. An unexpected shutdown on the other side is a security event, and you'll want to know about it. Cheers. -- Ng Pheng Siong * http://www.post1.com/home/ngps From ngps at madcap.dyndns.org Sat Feb 3 04:43:07 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 3 Feb 2001 03:43:07 GMT Subject: SSL EOF References: Message-ID: <95fuob$t3q$1@clematis.singnet.com.sg> According to Tim Peters : > The good news is that it will in Python 2.1a2 also (to be released > tomorrow). However, the more we (Jeremy, Guido, me) looked at Python's SLL > support, the more questionable code we found. Alas, not being experts in > this protocol, we're unlikely to fix it. So we would be grateful for a > patch against CVS Python for doing this stuff more intelligently, including > corresponding repairs to the httplib.py code that uses it. I'll see what I can do. (I recall saying that when 2.0 came out... ;-) Cheers. -- Ng Pheng Siong * http://www.post1.com/home/ngps From rvprasad at cis.ksu.edu Thu Feb 1 23:42:43 2001 From: rvprasad at cis.ksu.edu (Venkatesh Prasad Ranganath) Date: 01 Feb 2001 16:42:43 -0600 Subject: PyXML References: <3A776B59.FDEC3975@ogbuji.net> Message-ID: Hi, The example is from xml.dom.ext.reader.Sax2 import Reader from xml.dom.ext import PrettyPrint import sys i = open(sys.argv[1]) j = Reader(1).fromStream(i) i.close() PrettyPrint(j) print "++++", j.doctype.__systemId, "----" Nothing is printed between ++++ and ---- Also, shouldn't Line 61 in _xmlplus/dom/NamedNodeMap.py be return self.get(('', name)) and Line 65 in _xmlplus/xpath/XPathParserBase.py be if XPath.cvar.g_errorOccured == 1: -- Venkatesh Prasad Ranganath From greg at cosc.canterbury.ac.nz Thu Feb 1 05:19:10 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 01 Feb 2001 17:19:10 +1300 Subject: curly-brace-aphobic? References: <3A74EBD6.3C87FD15@seebelow.org> <3A757FBE.E54C5ECD@seebelow.org> <95718r018s8@drn.newsguy.com> Message-ID: <3A78E3BE.AED8CABF@cosc.canterbury.ac.nz> Grant Griffin wrote: > > However, the rule that I seem to want to apply is "All indexers are indexed > using the style of brace used to bind them." But tuples and strings aren't constructed using any kind of brackets at all: t = 1,2,3 s = "parrot" How do you propose to index those, using your rule? What's more, there are many more indexable things than the built-in ones. Extension modules can implement new indexable types, and any class can be made indexable by giving it a __getitem__ method. If you want to index every indexable thing using a unique syntax, you're going to run out of characters very quickly! It could be argued, I suppose, that sequence-like objects should be indexed with [] and mapping-like objects with {}. But is a class which has __getitem__ a sequence or a mapping? You could say that there should be two methods, such as __getitem__ for [] and __mapitem__ for {}. But that seems like needlessly multiplying entities. Why go to all that trouble to provide two different indexing notations when one is quite sufficient? -- 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 cjc26 at nospam.cornell.edu Thu Feb 1 16:00:24 2001 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Thu, 01 Feb 2001 15:00:24 GMT Subject: curly-brace-aphobic? References: <3A74EBD6.3C87FD15@seebelow.org> <3A757FBE.E54C5ECD@seebelow.org> <95718r018s8@drn.newsguy.com> <3A78E3BE.AED8CABF@cosc.canterbury.ac.nz> Message-ID: * Greg Ewing menulis: | Grant Griffin wrote: | > | > However, the rule that I seem to want to apply is "All indexers are indexed | > using the style of brace used to bind them." | | But tuples and strings aren't constructed using any | kind of brackets at all: | | t = 1,2,3 | s = "parrot" | | How do you propose to index those, using your rule? Well, >obviously<, you would do the following: >>> t 2 2 >>> s"4" r Of course, you have to be careful with tuples, because sometimes parentheses are used when creating them: >>> t2 = (4, 5, 6) >>> t2(3) 6 -- Cliff Crawford http://www.people.cornell.edu/pages/cjc26/ print "Just another Python hacker" From quinn at cruzeiro.ugcs.caltech.edu Thu Feb 1 00:40:50 2001 From: quinn at cruzeiro.ugcs.caltech.edu (Quinn Dunkan) Date: 31 Jan 2001 23:40:50 GMT Subject: curly-brace-aphobic? References: <3A74EBD6.3C87FD15@seebelow.org> <3A757FBE.E54C5ECD@seebelow.org> Message-ID: On 31 Jan 2001 00:57:48 GMT, Remco Gerlich wrote: >Well, writing "string.split" is inconsistent, shouldn't it be string[split] >or string["split"]? > >It's like indexing the module. It is actually a dict lookup internally. >They're not the same thing really since an identifier suddenly becomes a >string and so on, but it's just a connection my mind made... You'd like lua, then. Everything is a table. Modules (which are not built into the langauge, naturally) are tables. Arrays are tables indexed with numbers. foo.bar is sugar for foo['bar']. It's theoretically appealing, but sometimes causes additional complexity, when, for example, you want to know how long an array is (the convention is to have an 'n' key with the length). And tables are created with {} but indexed with [] :) From mwh21 at cam.ac.uk Thu Feb 1 13:28:50 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 01 Feb 2001 12:28:50 +0000 Subject: Unicode pb in Python 2.0 solved - no thanks to WinPython References: <95b65r$l27$1@wanadoo.fr> Message-ID: "Jurie Horneman" writes: > I would very much like to "RTFM", and believe me I tried, but there isn't > much M to FR. How could I have avoided this problem with less agony? Should > I report the bug to the authors of WinPython? Do you mean PythonWin? I would, yes. Cheers, M. -- 31. Simplicity does not precede complexity, but follows it. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From fuess at att.net Sat Feb 3 16:07:23 2001 From: fuess at att.net (David A. Fuess) Date: Sat, 03 Feb 2001 15:07:23 GMT Subject: Unicode pb in Python 2.0 solved - no thanks to WinPython References: <95b65r$l27$1@wanadoo.fr> Message-ID: Actually this is not a bug in PythonWin, although it might appear to be. What's happened is that PythonWin does not reload an already loaded module until told to do so. You do that with the save and reload icon on the toolbar (right next to the save and run icon). Dave Michael Hudson wrote: >"Jurie Horneman" writes: > >> I would very much like to "RTFM", and believe me I tried, but there isn't >> much M to FR. How could I have avoided this problem with less agony? Should >> I report the bug to the authors of WinPython? > >Do you mean PythonWin? I would, yes. > >Cheers, >M. From mwh21 at cam.ac.uk Sat Feb 3 17:51:47 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 03 Feb 2001 16:51:47 +0000 Subject: Unicode pb in Python 2.0 solved - no thanks to WinPython References: <95b65r$l27$1@wanadoo.fr> Message-ID: David A. Fuess writes: > Actually this is not a bug in PythonWin, although it might appear to > be. What's happened is that PythonWin does not reload an already > loaded module until told to do so. You do that with the save and > reload icon on the toolbar (right next to the save and run icon). As I understood the report, the problem was PythonWin ignoring SyntaxErrors encountered during startup - which sounds like a bug in PythonWin to me. Cheers, M. -- If you don't use emacs, you're a pathetic, mewling, masochistic weakling and I can't be bothered to convert you. -- Ron Echeverri From loewis at informatik.hu-berlin.de Fri Feb 2 22:20:16 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Feb 2001 22:20:16 +0100 Subject: Displaying Unicode text in Tkinter Canvas widget References: <3A75D600.60F7CD0D@mega-nerd.com> <3A769B29.77C3CE84@mega-nerd.com> Message-ID: Erik de Castro Lopo writes: > I'm sorry, I should have mentioned that I'm trying to display > the Hiragana as text in a Tkinter Canvas widget. Why does it have to be a Canvas? I'd suggest to start with a Label, or Text widget. >>> import Tkinter >>> t=Tkinter.Label(text=u"\N{HIRAGANA LETTER KA}") >>> t.pack() works fine for me (on Linux). Regards, Martin From mikael at isy.liu.se Fri Feb 2 11:50:57 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 02 Feb 2001 11:50:57 +0100 (MET) Subject: PEP-0218 (Was: RE: Sets in Python) In-Reply-To: Message-ID: Tim, Greg and others, On 31-Jan-01 Tim Peters wrote: > Note Greg Wilson's PEP for adding a set type to Python: > > http://python.sourceforge.net/peps/pep-0218.html This looks promising. I am especially glad to see that the PEP proposes the logical operations '|', '&', and '^' to implement union, intersection and symmetric difference. However, I'm not sure I like the proposed use of '-' for difference. Mathematician use '\' (so called setminus). That would have been my favourite, but we use '\' for so many things, and especially not as an arithmetic operation. The visually closest thing would be '/', which is what I have used myself. That would for instance make it possible to let -S mean {-x for x in S}. Let's just hope that there will be a UserSet class that I can subclass, for instance to implement direct sums as A+B and direct difference as A-B (interpreted as A+(-B) with -B as above), provided that '-' is not used for difference. I could also implement cartesian products as A*B. Someone else could perhaps think of a resonable way to interprete the modulo operator (%) in terms of sets... It sure does look promising. I've-said-this-before- programming-is-doing-math-ly y'rs /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 02-Feb-01 Time: 11:18:01 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From michael at stroeder.com Fri Feb 2 18:38:19 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Fri, 02 Feb 2001 18:38:19 +0100 Subject: PEP-0218 (Was: RE: Sets in Python) References: Message-ID: <3A7AF08B.DB88EC56@stroeder.com> Mikael Olofsson wrote: > > On 31-Jan-01 Tim Peters wrote: > > Note Greg Wilson's PEP for adding a set type to Python: > > > > http://python.sourceforge.net/peps/pep-0218.html > > This looks promising. I am especially glad to see that the PEP proposes > the logical operations '|', '&', and '^' to implement union, intersection > and symmetric difference. However, I'm not sure I like the proposed use > of '-' for difference. I second that. '-' could also be associated to be S^-1 (inverse set) of set S. Ciao, Michael. From mlh at idi.ntnu.no Thu Feb 1 01:56:59 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Thu, 1 Feb 2001 01:56:59 +0100 Subject: Sets in Python References: Message-ID: <95aceb$s79$1@tyfon.itea.ntnu.no> "Tim Peters" wrote in message news:mailman.980905187.10012.python-list at python.org... [...] > Note Greg Wilson's PEP for adding a set type to Python: Nice! Any chance that this may be included some time in the future? And as regards "... in dict"; It would perhaps be more natural to see a dict as a set of pairs, so that the dictionary would act similarly to dict.items()? I.e. "(key, val) in dict" would be the same as "(key, val) in dict.items()" except that it would take O(1) time...? Oh, well... If we get a set type I guess that isn't necessary. (And I would *love* to have a set type. :-))) -- Magnus Lie Hetland (magnus at hetland dot org) "Reality is what refuses to disappear when you stop believing in it" -- Philip K. Dick From l.szyster at ibm.net Thu Feb 1 16:29:47 2001 From: l.szyster at ibm.net (Laurent Szyster) Date: Thu, 01 Feb 2001 16:29:47 +0100 Subject: Sets in Python References: <956hcd$qef$1@tyfon.itea.ntnu.no> Message-ID: <3A7980EA.F16596D5@ibm.net> Magnus Lie Hetland wrote: > > I quite often use dictionaries as sets in Python... But > it doesn't really seem pretty enough to me... Some > arbitrariness (as with "while 1: ... break" I still > don't like that one...) about using what to me is a > value as a key, and assigning it some value -- like 1, > for instance... And then checking it with has_key, and > removing it with del... if you are looking for set manipulations, get the kjbuckets module and do: >>> from kjbuckets import kjSet >>> A = kjSet ([1,2,3,4,'X','Y']) >>> A.has_key ('X') 1 >>> B = kjSet ([1,2,5,'Z']) >>> A-B kjSet([3, 4, 'X', 'Y']) >>> A+B kjSet([1, 2, 3, 4, 'X', 'Y', 5, 'Z']) >>> A&B kjSet([1, 2]) The module also provides a graph class (and everything you need to write your own relational algebra, since it's been developped by the Gadfly author). Laurent Szyster From phd at phd.pp.ru Fri Feb 2 10:26:07 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 2 Feb 2001 12:26:07 +0300 (MSK) Subject: Sets in Python In-Reply-To: <3A7980EA.F16596D5@ibm.net> Message-ID: On Thu, 1 Feb 2001, Laurent Szyster wrote: > if you are looking for set manipulations, get the > kjbuckets module and do: Anyone succeed compiling kjbuckets for Python 2.0? Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From ray_drew at yahoo.co.uk Fri Feb 2 10:48:11 2001 From: ray_drew at yahoo.co.uk (Ray Drew) Date: Fri, 02 Feb 2001 09:48:11 GMT Subject: Sets in Python References: Message-ID: <3a7a8253.1394768@reading.news.pipex.net> On Fri, 2 Feb 2001 12:26:07 +0300 (MSK), Oleg Broytmann wrote: >On Thu, 1 Feb 2001, Laurent Szyster wrote: >> if you are looking for set manipulations, get the >> kjbuckets module and do: > > Anyone succeed compiling kjbuckets for Python 2.0? > >Oleg. >---- > Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru > Programmers don't die, they just GOSUB without RETURN. > > www.malcolmson.com/python From phd at phd.pp.ru Fri Feb 2 11:20:13 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 2 Feb 2001 13:20:13 +0300 (MSK) Subject: Sets in Python In-Reply-To: <3a7a8253.1394768@reading.news.pipex.net> Message-ID: On Fri, 2 Feb 2001, Ray Drew wrote: > > Anyone succeed compiling kjbuckets for Python 2.0? > > > www.malcolmson.com/python Thank you very much! It is not what I searched (I had problem on UNIX), but anyway it's nice to know someone succeed compiling it. If he did it on Windows I should build it on UNIX, I suppose :) Will try harder. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From phd at phd.pp.ru Fri Feb 2 12:44:34 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 2 Feb 2001 14:44:34 +0300 (MSK) Subject: kjbuckets for Python 2.0 (was Re: Sets in Python) In-Reply-To: Message-ID: Hello! On Fri, 2 Feb 2001, Oleg Broytmann wrote: > On Fri, 2 Feb 2001, Ray Drew wrote: > > > Anyone succeed compiling kjbuckets for Python 2.0? > > > > > www.malcolmson.com/python > > Thank you very much! It is not what I searched (I had problem on UNIX), > but anyway it's nice to know someone succeed compiling it. If he did it on > Windows I should build it on UNIX, I suppose :) Will try it harder. Ok, I managed to build kjbuckets for Python 2.0. I needed rename2.h from Python 1.5.2 :) and I was forced (by gcc, perhaps) to replace all occurence of OVERFLOW to OVERFLOWx (the replace string was choosed arbitrary - I just choosed a name to satisfy compiler). Aaron, any chance the kjbuckets module will be officially updated? Or you lost interests and the module dropped on the floor? Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From bhoel at starship.python.net Fri Feb 2 21:36:27 2001 From: bhoel at starship.python.net (Berthold Höllmann) Date: 02 Feb 2001 21:36:27 +0100 Subject: kjbuckets for Python 2.0 (was Re: Sets in Python) References: Message-ID: Oleg Broytmann writes: > Hello! > > On Fri, 2 Feb 2001, Oleg Broytmann wrote: > > On Fri, 2 Feb 2001, Ray Drew wrote: > > > > Anyone succeed compiling kjbuckets for Python 2.0? > > > > > > > www.malcolmson.com/python > > > > Thank you very much! It is not what I searched (I had problem on UNIX), > > but anyway it's nice to know someone succeed compiling it. If he did it on > > Windows I should build it on UNIX, I suppose :) Will try it harder. > > Ok, I managed to build kjbuckets for Python 2.0. I needed rename2.h from > Python 1.5.2 :) and I was forced (by gcc, perhaps) to replace all occurence > of OVERFLOW to OVERFLOWx (the replace string was choosed arbitrary - I just > choosed a name to satisfy compiler). > Aaron, any chance the kjbuckets module will be officially updated? Or > you lost interests and the module dropped on the floor? I don't know about Aaron, but I got it compiled with python 2.0 without copying rename2.h. The changes were quite straightforward, but a "diff -c" file is larger than the original (-: The simple diff is 49K, a little large for the newsgroup/mailinglist. I would put it onto starship, but I have problems with my account (what the heck was my password). So I will send the file kjbucketsmodule.c to anyone interested and without any warranty. Just drop me an email. Greetings Berthold -- bhoel at starship.python.net / http://starship.python.net/crew/bhoel/ It is unlawful to use this email address for unsolicited ads (USC Title 47 Sec.227). I will assess a US$500 charge for reviewing and deleting each unsolicited ad. From phd at phd.pp.ru Mon Feb 5 11:03:59 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Mon, 5 Feb 2001 13:03:59 +0300 (MSK) Subject: kjbuckets for Python 2.0 In-Reply-To: Message-ID: On 2 Feb 2001, Berthold H?llmann wrote: > I don't know about Aaron, but I got it compiled with python 2.0 > without copying rename2.h. The changes were quite straightforward, but > a "diff -c" file is larger than the original (-: The simple diff is > 49K, a little large for the newsgroup/mailinglist. I would put it onto > starship, but I have problems with my account (what the heck was my > password). So I will send the file kjbucketsmodule.c to anyone > interested and without any warranty. Just drop me an email. Please, send it to me, I'll test it and send furter to Aaron. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From hinsen at cnrs-orleans.fr Mon Feb 5 17:51:58 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 05 Feb 2001 17:51:58 +0100 Subject: MMTK and Scientific python for NT 4.0 References: <3A76D096.B1747887@helsinki.fi> Message-ID: Kimmo P??kk?nen writes: > If there are no such binaries, are there some instructions how to > compile them for NT? I have the free Borland 5.5 compiler, and I have According to the little I know about Windows, you must use the same compiler for compiling the Python interpreter and any extension modules. So the first step would be to recompile Python with your compiler. > ), but building MMTK extensions seems confusing, as I don't have > experience of compiling bigger projects. Any help appreciated!! I can't help with Windows, sorry. MMTK extension modules use no special tricks, except that the Setup file is preprocessed before being handed to the standard Python Makefile.pre.in mechanism. You might have to do this preprocessing manually under Windows. It involves replacing the string "@SCIENTIFIC@" by the path to the directory Scientific/Include of your ScientificPython installation, and replacing the string "@LONG@" by 1) "-D_LONG64_" if sys.maxint > 2147483647 2) an empty string otherwise With that information, Windows compilation experts should be able to tell you what you need to do. And please let me know if you succeed; I get an inquiry about Windows binaries about once per month. -- ------------------------------------------------------------------------------- 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 sholden at holdenweb.com Thu Feb 1 01:45:19 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 31 Jan 2001 19:45:19 -0500 Subject: mxDateTime for Python 2.0 for Win32 - binary PYD file References: Message-ID: "Warren Postma" wrote in message news:kEAd6.8145$Oe.37320 at tor-nn1.netcom.ca... > Okay, I think I feel stupid now. > > Warren > Please feel free to borrow my head-thwacker. But don't keep it tool long, as I'll undoubtedly need it myself the next time I get too smart for my own good. regards Steve From suzuki at acm.org Sat Feb 3 08:10:00 2001 From: suzuki at acm.org (SUZUKI Hisao) Date: Sat, 03 Feb 2001 16:10:00 +0900 Subject: Timer module? References: <3A76F442.7BB0B9A9@americasm01.nt.com> Message-ID: <95gaik$12vo$1@nwall2.odn.ne.jp> In article <3A76F442.7BB0B9A9 at americasm01.nt.com>, Rick wrote: > I wonder if there is already any timer module out there that allows me > to: > > - set a timer without blocking the current thread I have written such one :^) > - cancel the timer Yes. > - maybe also, able to tell it to recur at a given interval for so many > times; and able to change that Yes, by re-scheduling it (= a Task instance) explicitly. > - create thousands of timers with a performance penalty that grows > slower than linearly with the number of timers; preferably a performance > cost that is small and almost constant Probably yes; O(1) at best and O(n) at worst theoretically. The module is pypage/lib/timer.py, which is a part of PyPage 1.4, a handy multi-threaded Web server with JSP-like features. I wrote and posted it to a newsgroup in Japan last year: | Newsgroups: fj.sources | From: SUZUKI Hisao | Subject: PyPage 1.4 | Date: Sun, 12 Nov 2000 23:20:41 +0900 | Message-ID: <8um90n$fc9$1 at nwms2.odn.ne.jp> You can get it also via HTTP (thanks to TAKAHASHI Hideaki): http://www.zob.ne.jp/~hide-t/comp/python/pypage/pypage-1.4.tar.bz2 It is a free software WITHOUT ANY WARRANTY. Anyone may freely use, alter and redistribute it. All I ask is a brief mention of me as the original author in the source or accompanying file(s). However, the documentation is in Japanese. If you don't mind it, I introduce the module to you. First, copy two files, timer.py and jthread.py, from pypage/lib/ to the current directory. Then, execute the script: ---------------------------------------------------------------- #!/usr/bin/env python import timer def foo(msg): print msg task.when += 3 timer.schedule(task) # re-schedule the task # enable the timer timer.start() # create and schedule a task to call foo("spam") 3 seconds later task = timer.after(3, foo, "spam") raw_input('hit "Enter" to stop\n') ---------------------------------------------------------------- It will repeat "spam" until you hit Enter key. Hope this helps. -- SUZUKI Hisao >>> def fib(n): return reduce(lambda x, y: suzuki at acm.org ... (x,x[0][-1]+x[1]), [()]*n, ((0L,),1L)) From andymac at bullseye.apana.org.au Thu Feb 1 21:11:25 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Fri, 2 Feb 2001 07:11:25 +1100 (EDT) Subject: Data management products (was: How do you lock your web app data?) In-Reply-To: <95a49u11uao@news1.newsguy.com> Message-ID: On Wed, 31 Jan 2001, Alex Martelli wrote: > [To be honest, personally, I'm having a hard time > thinking up anything I'd *want* to code in Access, other VBA > platforms, Foxpro, or similar languages, rather than Python -- > but, I'm sure there are niches where such tools help a lot]. The only thing I use it for is its report writer. -- 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 claird at starbase.neosoft.com Thu Feb 1 21:27:47 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 1 Feb 2001 14:27:47 -0600 Subject: Data management products (was: How do you lock your web app data?) References: <956uqd$6st$1@newsreaderg1.core.theplanet.net> <958j810o2e@news2.newsguy.com> <95a49u11uao@news1.newsguy.com> Message-ID: <6457C4C831E9B110.6049FFDB799E041D.AA4A6C480AE5F526@lp.airnews.net> In article <95a49u11uao at news1.newsguy.com>, Alex Martelli wrote: >"Cameron Laird" wrote in message >news:D62094CDC48C0FCA.44A0CB1CEB4E1F76.B8EA27DB5535EBAD at lp.airnews.net... > [snip] >> Actually, all these Alex has mentioned have >> capabilities that'll knock the socks off vic- >> tims habituated to Access, for example. > >Just one attempt at terminology clarification...: > >Access is a possibly-handy GUI IDE front-end for cobbling together >possibly-intricated DB operations; at least if you don't mind . . . >What was in a far, distant past misnamed 'the Access database' >by Microsoft marketroids (the same misbegotten ilk who managed >for years to throw confusion around COM by misnaming everything >COM *as if* it had anything to do with various technologies who were >and are *ON TOP* of COM itself -- at first, OLE, later, Active/X), is >now fortunately again known only by its true name, 'Jet'. It's a >very old-technology, legacy engine, with no pluses I can think of >when compared to MSDE, Postgres, etc. . [other salient points] . . Do Java people use property files? I have no sense about this. I think the answer is, no. In any case, CPython has no particular need to read and write 'em, right? -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From aleaxit at yahoo.com Fri Feb 2 09:53:25 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 2 Feb 2001 09:53:25 +0100 Subject: property files (was Re: Data management products (was: How do you lock your web app data?)) References: <956uqd$6st$1@newsreaderg1.core.theplanet.net> <958j810o2e@news2.newsguy.com> <95a49u11uao@news1.newsguy.com> <6457C4C831E9B110.6049FFDB799E041D.AA4A6C480AE5F526@lp.airnews.net> Message-ID: <95dsid02v03@news1.newsguy.com> "Cameron Laird" wrote in message news:6457C4C831E9B110.6049FFDB799E041D.AA4A6C480AE5F526 at lp.airnews.net... [snip] > Do Java people use property files? I have no sense > about this. I think the answer is, no. In any case, > CPython has no particular need to read and write 'em, > right? Sorry, what do you mean by "property files" in this context [discussion of RDBMS engines]? I think I may be confused... Alex From cobrien at Radix.Net Fri Feb 2 02:26:15 2001 From: cobrien at Radix.Net (Cary O'Brien) Date: 1 Feb 2001 20:26:15 -0500 Subject: Data management products (was: How do you lock your web app data?) References: <956uqd$6st$1@newsreaderg1.core.theplanet.net> <958j810o2e@news2.newsguy.com> <95a49u11uao@news1.newsguy.com> Message-ID: <95d2bn$s7b$1@saltmine.radix.net> In article <95a49u11uao at news1.newsguy.com>, Alex Martelli wrote: >"Cameron Laird" wrote in message >news:D62094CDC48C0FCA.44A0CB1CEB4E1F76.B8EA27DB5535EBAD at lp.airnews.net... > [snip] >> Actually, all these Alex has mentioned have >> capabilities that'll knock the socks off vic- >> tims habituated to Access, for example. > >Just one attempt at terminology clarification...: > >Access is a possibly-handy GUI IDE front-end for cobbling together >possibly-intricated DB operations; at least if you don't mind [snip] > >Fortunately, Access of course works perfectly well with MSDE (or >other editions of SQL Server), Oracle, and no doubt other good >RDBMS's yet. Well... The PostgreSQL people had one heck of a time dealing with the sql that access generated. But that was a year or two ago. -- cary > Even if one IS habituated to Access (and there may >be perfectly good reasons for choosing it to develop certain DB >apps, I guess), there is no reason not to switch to a better engine >underneath the chrome (given that MSDE is freely redistributable [snip] From nielsenjf at my-deja.com Thu Feb 1 14:02:43 2001 From: nielsenjf at my-deja.com (John Nielsen) Date: Thu, 01 Feb 2001 13:02:43 GMT Subject: How do you lock your web app data? References: <956uqd$6st$1@newsreaderg1.core.theplanet.net> Message-ID: <95bmpg$g8k$1@nnrp1.deja.com> Since it will not be a heavy load app, for a windows solution, you can also look at python's win32file extension, it exposes LockFileEx which will lock files for you. How to use it is described in the help section of pythonwin: Help->Other->Win32Extensions and then look for locking. The lock, however, is process based. This means you'd need to run it in a separate process from IIS (the reason you don't want it to be a heavy-load app). Have a good day, john In article <956uqd$6st$1 at newsreaderg1.core.theplanet.net>, "Franz GEIGER" wrote: > > Hi all, > > I began to play around with cgi scripts and of course use Python for that. > And man, it is a pleasure to do that with Python! It really is a snap. After > about a day I had written an Issue Tracker, where People can add software > feature requests and bug reports. At this time I add functionality to edit > and delete the entries - until now they only could have been added. > > So an important issue enters the game: How do I lock others out, when one > edits/writes records? Please get me right: This will not be a heavy load app > nor will it be to handle requests and reports from hundreds of people. > Therefore and because I just settled out to explore cgi I decided to use > text files and pickle files for maintaining data and state, which is very > convenient. > > Of course I could take a database as backend but I wonder if there are other > possibilities to achieve that "serialization"? How do you do it? Do you > always use a database? Is it worth the effort doing it without a database? > > The server is an NT box running IIS4. Python is of version 2.0 (AvtiveState > distribution). > > Any hint is appreciated. > > Thanks in advance and best regards > Franz GEIGER > > -- nielsenjf at my-Deja.com Sent via Deja.com http://www.deja.com/ From fgeiger at datec.at Thu Feb 8 08:26:50 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Thu, 8 Feb 2001 08:26:50 +0100 Subject: How do you lock your web app data? References: <956uqd$6st$1@newsreaderg1.core.theplanet.net> Message-ID: <95thnk$vr9$1@newsreaderm1.core.theplanet.net> Thanks a lot to all who contributed. The posts were numerous, comprehensive and of great help. It's always a pleasure to be here! Best regards Franz GEIGER "Franz GEIGER" wrote in message news:956uqd$6st$1 at newsreaderg1.core.theplanet.net... > > Hi all, > > I began to play around with cgi scripts and of course use Python for that. > And man, it is a pleasure to do that with Python! It really is a snap. After > about a day I had written an Issue Tracker, where People can add software > feature requests and bug reports. At this time I add functionality to edit > and delete the entries - until now they only could have been added. > > So an important issue enters the game: How do I lock others out, when one > edits/writes records? Please get me right: This will not be a heavy load app > nor will it be to handle requests and reports from hundreds of people. > Therefore and because I just settled out to explore cgi I decided to use > text files and pickle files for maintaining data and state, which is very > convenient. > > Of course I could take a database as backend but I wonder if there are other > possibilities to achieve that "serialization"? How do you do it? Do you > always use a database? Is it worth the effort doing it without a database? > > The server is an NT box running IIS4. Python is of version 2.0 (AvtiveState > distribution). > > Any hint is appreciated. > > Thanks in advance and best regards > Franz GEIGER > > > > From m.bless at gmx.de Thu Feb 1 01:07:24 2001 From: m.bless at gmx.de (Martin Bless) Date: Thu, 01 Feb 2001 00:07:24 GMT Subject: Roadmap wanted: Python access to SPIRIT.OCX (Win9x) References: <3a7b39da.39409649@news.muenster.de> <958i3j0mk4@news2.newsguy.com> Message-ID: <3a78a445.7210135@news.muenster.de> It's past midnight - but it works!!!!!!! It was all there, and it's easy once you know what to to. makepy.py produced spirit.py, and import win32com, spirit brick = win32com.client.Dispatch('SPIRIT.SpiritCtrl.1') instantiates the object. And now I can say brick.On((0,1,3)) to get three motors going. Absolutely fascinating. IMHO, beats the proposed visual basic solutions by far. Of course I haven't understood a bit of the inner workings of makepy - the good news is, I obviously don't have to at the moment. That's real magic! I'd like to express my respect. Makepy does a marvellous job. It took me some time to discover this little hint in the generated spirit.py: # This CoClass is known by the name 'SPIRIT.SpiritCtrl.1' >Not me (another fascinating timesink being the LAST thing I >need:-) but I do understand why one would!-) Oh yes oh yes, it seems it has hit ME. Hope I can save myself ... Still very excited Martin From robertcdio at my-deja.com Fri Feb 2 20:19:20 2001 From: robertcdio at my-deja.com (robertcdio at my-deja.com) Date: Fri, 02 Feb 2001 19:19:20 GMT Subject: fork, exec no wait References: <3A774C91.40835F30@lbl.gov> <958m19$s2j@news.or.intel.com> Message-ID: <95f17d$fll$1@nnrp1.deja.com> Heres the deal: a process vfork/execs a child child does stuff1 while... parent runs stuff2 (without waiting for child to finish) *But* upon completion of child, i want the parent to switch to stuff3 simple right? well here is the problem i cant find a way for the rent to know that there little guy is done... could call wait or waitpid but both of those stall the parents process... i looked at some early versions of system(function) and thought i was on to something because i cam across the wait command embedded in a while loop with no body than i thought well perhaps the wait command doesnt actually wait at all but is stalled by the while loop so i dropped stuff2 into the body of the while loop... allas this didn't work. So i had a smoke... then i thought well if the child is done its pid goes away so i figured well thats simple i just nest a call to get the childs pid into a while loop so that the parent routinely checks for the childs expected pid. hmm the parent can't talk to the child only the child can talk to the parent... am i right wrong confused in the wrong proffecion? HELP I know i should be a writer check out the run on sentences!!! Kudos to the brilliance that aids me(and bring anti perspirant)! Sent via Deja.com http://www.deja.com/ From erno-news at erno.iki.fi Sun Feb 4 16:33:34 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 04 Feb 2001 17:33:34 +0200 Subject: fork, exec no wait References: <3A774C91.40835F30@lbl.gov> <958m19$s2j@news.or.intel.com> <95f17d$fll$1@nnrp1.deja.com> Message-ID: In article <95f17d$fll$1 at nnrp1.deja.com>, robertcdio at my-deja.com writes: | could call wait or waitpid but both of those stall the parents | process... os.waitpid(..., os.WNOHANG) -- erno From reborn at neozone.net Thu Feb 1 18:02:48 2001 From: reborn at neozone.net (??) Date: Fri, 2 Feb 2001 02:02:48 +0900 Subject: Q : About Jython & Applet (i'm begginer -_-) References: <957pjq$mg9$1@news1.kornet.net> Message-ID: <95c4r1$bv9$1@news1.kornet.net> Thank you for your regard..^ ^ > How are you using the appletviewer or explorer? To display an applet, > it must first be in an HTML file. Example: > > > > I made HTML file like that and also test as your HTML code.. but, it's same result.. I insert some code for test it in jython : if __name__ == '__main__': import pawt pawt.test(HelloApplet(), size=(500, 120)) then, I execute it like that : jython HelloApplet.py It display the result well. but, after I complie it like that : jythonc --core -d HelloApplet.py It make two java file (HelloApplet.java, HelloApplet.class) It don't work no more ... my project is that make web-based tutoring Authoring tool. If this problem doesn't solve, we have to throw away jython.. Please... give me some help.. From d98aron at dtek.chalmers.se Fri Feb 2 17:24:11 2001 From: d98aron at dtek.chalmers.se (Fredrik Aronsson) Date: 2 Feb 2001 16:24:11 GMT Subject: Q : About Jython & Applet (i'm begginer -_-) References: <957pjq$mg9$1@news1.kornet.net> <95c4r1$bv9$1@news1.kornet.net> Message-ID: <95emvb$sai$1@nyheter.chalmers.se> I used your code but compiled with jythonc -c -d -j Hello.jar HelloApplet.py and used HTML: Now it works in both netscape and appletviewer for me. [Posted and mailed] In article <95c4r1$bv9$1 at news1.kornet.net>, "??" writes: [snip] > > I made HTML file like that > > > > > > [snip] > > but, after I complie it like that : > jythonc --core -d HelloApplet.py > > It make two java file (HelloApplet.java, HelloApplet.class) didn't it make a HelloApplet$_PyInner.class also? You also need the a lot of classes from the org.python.core in the jar file, but that is taken care of by jythonc. Hope this helps /Fredrik From dale at out-think.NOSPAMco.uk Thu Feb 1 09:08:12 2001 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Thu, 01 Feb 2001 08:08:12 +0000 Subject: Python 2.1 and Unicode References: <958gnc0ksj@news2.newsguy.com> <95a49s01uao@news1.newsguy.com> Message-ID: "Alex Martelli" wrote: >"Dale Strickland-Clark" wrote in message >news:ivig7t0dvpblnqlqa348jop70dbtmd2hjo at 4ax.com... > [snip] >> Thanks, again, Alex. > >You're welcome! > >> I'm not familiar with the site configuration stuff. Could I also use this >> for identifying our own module library? >> >> Where's it documented? > >http://www.python.org/doc/current/lib/module-site.html and environs. > >Basically, strategically placing .pth files will help you "identify your >module libraries" etc. Then, sitecustomize.py, if it exists, lets you do >any last-minute site-specific tweaks -- it's imported first. > > >Alex > > > > Cheers. I'll take a look. -- Dale Strickland-Clark Out-Think Ltd Business Technology Consultants From loewis at informatik.hu-berlin.de Fri Feb 2 22:26:18 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Feb 2001 22:26:18 +0100 Subject: Python 2.1 and Unicode References: <958gnc0ksj@news2.newsguy.com> <95a49s01uao@news1.newsguy.com> Message-ID: "Alex Martelli" writes: > http://www.python.org/doc/current/lib/module-site.html and environs. > > Basically, strategically placing .pth files will help you "identify your > module libraries" etc. Then, sitecustomize.py, if it exists, lets you do > any last-minute site-specific tweaks -- it's imported first. Furthermore, starting from Python 2.1, you can have "code" in a .pth file, i.e. lines starting with import. That way, you can easily add to __builtins__ if you want without editing sitecustomize.py. Regards, Martin From loewis at informatik.hu-berlin.de Fri Feb 2 22:32:32 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Feb 2001 22:32:32 +0100 Subject: Python 2.1 and Unicode References: Message-ID: Dale Strickland-Clark writes: > However, I was disapointed not to find any improvements to the way > Unicode is handled. Did you report the problems you had as bugs? If not, why do you think it might have "improved"? > Currently we are having to use constructs such as this all over the place when dealing with values > from international databases: > > if type(val) == types.UnicodeType: > val = val.encode('Latin-1', 'ignore') > else: > val = str(val) It surely sounds wrong if you do this in many places. However, it would be equally wrong if Python would set string conversion to Latin-1 by default - what do you do if your terminal does not support Latin-1? > And it gets even more ugly when lists of values are handled. > > encode() blows if you give it an integer and str() blows if it > doesn't like the Unicode. Well, explicit is better than implicit. This fragment looks like an application-specific conversion function - so it should be one, instead of being inlined in many places. > On top of that, print needs to default to rugged handling of Unicode > and not raise an exception. That turns out to be difficult, since print uses str() for each value. What print *really* should do is to use the maximum capabilities of the terminals (i.e. loading fonts, whatever is necessary). That is even more difficult. > Inserting print statements is normally the quickest way to gather > debugging info but it becomes a big problem when dealing with > Unicode, requiring code like that above. Nah, for debugging, I think print `val` would work fine in most cases. > 1. A print command that defaults to ignoring Unicode conversion > errors - or at least has the option to do so. So how does repr() sound to you? > 2. A function, such as str() that converts *anything* to an ASCII > string - ignoring Unicode errors. Well, this is actually the question to which repr() is the answer... Regards, Martin From joseamartin at venmex.com Thu Feb 1 15:43:50 2001 From: joseamartin at venmex.com (Jose Martin) Date: Thu, 1 Feb 2001 10:43:50 -0400 Subject: Benchmarking module for Python References: <2P53OlqNc5Cg7uVAjN=rZZ5t6Jix@4ax.com> Message-ID: hI PAUL you can use the clock function, in python 2.0 this function was improved. I am using clock function to crack some passwords and works very well. good look !. Paul Moore escribi? en el mensaje de noticias 2P53OlqNc5Cg7uVAjN=rZZ5t6Jix at 4ax.com... > I'm looking for a method of benchmarking snippets of Python code, a > bit like Perl's Benchmark module. I have looked at the profile module, > but it doesn't seem to do quite what I want. > > What I'm after, given a line of code, is something that will let me > run that line a specified number of times, say 1000, and see the > average time that the line took. > > I can do something like that with profile, by wrapping my code in a > function, and profiling 'for i in xrange(1000): fn()', and then > extracting the time spent per call in fn(). But it's a bit of a long > way round to get what I want. > > Ideally, I'd like to be able to reuse the timing code from profile, > but if not, then an independent benchmark module would be OK. All I > found on Parnassus was PyBench, which tests a standard set of tasks. > > Is there any such thing, or should I start coding? > > Paul. > > PS Yes, I know that benchmarks are meaningless.... > From ngreco at softhome.net Thu Feb 1 16:29:38 2001 From: ngreco at softhome.net (Nahuel Greco) Date: Thu, 1 Feb 2001 12:29:38 -0300 Subject: PyKDE / PyQT debian packages In-Reply-To: References: Message-ID: <20010201122938.09ba6419.ngreco@softhome.net> There is debian packages of PyKDE and PyQT somewhere in the net? (some off-topic, the khtml widget supports edition of the html?, and can use it from pyqt?) Nahuel Greco From phil at river-bank.demon.co.uk Sun Feb 4 11:57:46 2001 From: phil at river-bank.demon.co.uk (phil at river-bank.demon.co.uk) Date: Sun, 04 Feb 2001 10:57:46 -0000 Subject: COMMERCIAL: BlackAdder Windows/Linux Python GUI Development Environment In-Reply-To: Message-ID: <95jcja+75br@eGroups.com> --- In python-list at y..., grey at d... (Steve Lamb) wrote: > On Wed, 31 Jan 2001 12:52:34 -0000, phil at r... > wrote: > >BlackAdder is available in two editions, the Personal Edition and the > >Business Edition. The Business Edition allows the run-time elements of > >BlackAdder (except for mxODBC) to be re-distributed with your > >applications at no extra cost. > > This is the part that gets me wondering. How pervasive are these run time > portions? I'd like to use QT as the graphical toolkit for a project I have > and that project will be GPL'd. What problems would I have in interfacing GPL > code and the personal edition upon distribution? I'm confident I could > distribute the code freely but what would that code evetually run on? The run-time elements consist of Python, and a special build of PyQt that includes Qt statically linked. With the Personal Edition you can distribute Python (because it has a different license anyway) but not the BlackAdder version of PyQt. To distribute your application (is doesn't matter if it is free or not), you have the following choices... 1. Your user has to have their own copy of the Personal Edition. 2. You buy the Business Edition which allows you to re-distribute the BlackAdder version of PyQt at no extra charge. 3. Your user has to have the free version of PyQt and Qt already installed. For UNIX this isn't a problem, for Windows they would also need a commercial Qt license which probably make it too expensive to be practical. Phil From embed at geocities.com Thu Feb 1 15:07:15 2001 From: embed at geocities.com (Warren Postma) Date: Thu, 1 Feb 2001 09:07:15 -0500 Subject: COMMERCIAL: BlackAdder Windows/Linux Python GUI Development Environment References: Message-ID: Quoth phil at river-bank.demon.co.uk: > The cunning plan continues... > > theKompany.com is pleased to announce the immediate >availability of the first Beta release of BlackAdder, a >commercial Windows/Linux IDE for Python and the Qt >GUI toolkit. Looks interesting. Besides this one (for QT) and Boa Constructor (wxPython based) are there any other RAD/IDE tools are in the works that include integrated forms builders and syntax-highlighting editor, etc? I'm trying to figure out which one to contribute to the development of. So far I'm leaning towards Boa because of the more liberal Windows licensing of wxWindows (free) compared to QT on Windows(generally not free). Warren From bobhicks at adelphia.net Thu Feb 1 15:51:39 2001 From: bobhicks at adelphia.net (Robert L Hicks) Date: Thu, 01 Feb 2001 14:51:39 GMT Subject: COMMERCIAL: BlackAdder Windows/Linux Python GUI Development Environment References: Message-ID: Why not make a pure Tkinter IDE...? > From: "Warren Postma" > Organization: AT&T Canada IES > Newsgroups: comp.lang.python > Date: Thu, 1 Feb 2001 09:07:15 -0500 > Subject: Re: COMMERCIAL: BlackAdder Windows/Linux Python GUI Development > Environment > > > Quoth phil at river-bank.demon.co.uk: >> The cunning plan continues... >> >> theKompany.com is pleased to announce the immediate >availability of the > first Beta release of BlackAdder, a >> commercial Windows/Linux IDE for Python and the Qt >> GUI toolkit. > > Looks interesting. Besides this one (for QT) and Boa Constructor (wxPython > based) are there any other RAD/IDE tools are in the works that include > integrated forms builders and syntax-highlighting editor, etc? > > I'm trying to figure out which one to contribute to the development of. So > far I'm leaning towards Boa because of the more liberal Windows licensing of > wxWindows (free) compared to QT on Windows(generally not free). > > Warren > > From fgeiger at datec.at Thu Feb 8 08:28:54 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Thu, 8 Feb 2001 08:28:54 +0100 Subject: COMMERCIAL: BlackAdder Windows/Linux Python GUI Development Environment References: Message-ID: <95thrg$vt6$1@newsreaderm1.core.theplanet.net> wxDesigner is such a tool, but is commercial: www.roebling.de Regards Franz GEIGER "Warren Postma" wrote in message news:M6ee6.8725$Oe.40269 at tor-nn1.netcom.ca... > > Quoth phil at river-bank.demon.co.uk: > > The cunning plan continues... > > > > theKompany.com is pleased to announce the immediate >availability of the > first Beta release of BlackAdder, a > >commercial Windows/Linux IDE for Python and the Qt > >GUI toolkit. > > Looks interesting. Besides this one (for QT) and Boa Constructor (wxPython > based) are there any other RAD/IDE tools are in the works that include > integrated forms builders and syntax-highlighting editor, etc? > > I'm trying to figure out which one to contribute to the development of. So > far I'm leaning towards Boa because of the more liberal Windows licensing of > wxWindows (free) compared to QT on Windows(generally not free). > > Warren > > From pieter at nagel.co.za Thu Feb 1 03:45:00 2001 From: pieter at nagel.co.za (Pieter Nagel) Date: Thu, 1 Feb 2001 04:45:00 +0200 Subject: Dynamically Defined Functions in Classes? In-Reply-To: References: Message-ID: On Wed, 31 Jan 2001, Jim Meyer wrote: > I have an application in which I wish to treat the members of a > dictionary as attributes; class Bar: def __init__(self, initial_dict): self.__dict__ = initial_dict b = Bar({'joe' : 'cool', 'frank' : 'lee', 'ron' : 'dell'}) print b.joe b.frank = 'foo' -- ,_ /_) /| / / i e t e r / |/ a g e l From wolfgang.grafen at marconi.com Thu Feb 1 10:42:45 2001 From: wolfgang.grafen at marconi.com (Wolfgang Grafen) Date: Thu, 01 Feb 2001 10:42:45 +0100 Subject: Dynamically Defined Functions in Classes? References: Message-ID: <3A792F95.E9872F6@marconi.com> Pieter Nagel wrote: > > On Wed, 31 Jan 2001, Jim Meyer wrote: > > > I have an application in which I wish to treat the members of a > > dictionary as attributes; > > class Bar: > def __init__(self, initial_dict): > self.__dict__ = initial_dict > > b = Bar({'joe' : 'cool', 'frank' : 'lee', 'ron' : 'dell'}) > print b.joe > b.frank = 'foo' > > -- > ,_ > /_) /| / > / i e t e r / |/ a g e l Good idea! Let's do a little additional stuff and you get: class Bar(UserDict): def __init__(self,dict={}): UserDict.__init__(self,dict) self.data.update(self.__dict__) self.__dict__=self.data >>> b=Bar({'a':1,'b':2) >>> b {'data': {...}, 'b': 2, 'a': 1} >>> b.b 2 >>> b.a 1 >>> b['c']=3 >>> b {'data': {...}, 'b': 2, 'c': 3, 'a': 1} >>> b.c 3 >>> b['b'] 2 Cheers, Wolfgang From timr at probo.com Fri Feb 2 05:41:34 2001 From: timr at probo.com (Tim Roberts) Date: Thu, 01 Feb 2001 20:41:34 -0800 Subject: from-import on non-module objects? References: <959jna$nfl$1@nnrp1.deja.com> Message-ID: Hamish Lawson wrote: >Have there been thoughts on having from-import used on non-module >objects in order to introduce attributes from a given object into the >current scope? Unless I misunderstood the explanation, I believe this exact thing is one of the features being included in Python 2.1. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From tim.one at home.com Sun Feb 4 11:31:38 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 4 Feb 2001 05:31:38 -0500 Subject: from-import on non-module objects? In-Reply-To: Message-ID: [Hamish Lawson] > Have there been thoughts on having from-import used on non-module > objects in order to introduce attributes from a given object into the > current scope? [Tim Roberts] > Unless I misunderstood the explanation, I believe this exact thing > is one of the features being included in Python 2.1. The description of this change is the NEWS file for 2.1a1 and 2.1a2 was incomplete; it will be clearer in the next release. Short course: in from M import x M no longer needs to be a true module object (which earlier NEWS said), but the name "M" *must* be a key in sys.modules (which info was missing). So this isn't a hack aimed at letting people do bizarre things with from-import, it's a hack aimed at letting people use "module-like objects". Python has a long tradition of loosening type restrictions over time, and this was a natural part of that tradition: if an object supports getattr, it supports the only thing the "import" part of from-import really needs. The "from" part still needs "a module name", though, but the operational definition of "a module name" is "a name that appears as a key in sys.modules". So meet those two requirements, and Python couldn't care less whether it's "a real module" anymore. Really bad idea (running under 2.1a2): >>> somelist = [1, 2, 3, 2, 1] >>> from somelist import count # blows up Traceback (most recent call last): File "", line 1, in ? from somelist import count # blows up ImportError: No module named somelist >>> import sys >>> sys.modules["somelist"] = somelist >>> from somelist import count # works, for some meaning of "works" >>> count(1), count(2), count(3), count(4) (2, 2, 1, 0) >>> Don't try that at home; you'll be shot if you do <0.9 bang>. useful-examples-left-to-your-fertile-imaginations-ly y'rs - tim From moshez at zadka.site.co.il Sun Feb 4 12:19:34 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sun, 4 Feb 2001 13:19:34 +0200 (IST) Subject: from-import on non-module objects? In-Reply-To: References: Message-ID: <20010204111934.16EE7A840@darjeeling.zadka.site.co.il> [Hamish Lawson] > Have there been thoughts on having from-import used on non-module > objects in order to introduce attributes from a given object into the > current scope? [Tim Roberts] > Unless I misunderstood the explanation, I believe this exact thing > is one of the features being included in Python 2.1. [Tim Peters] > The description of this change is the NEWS file for 2.1a1 and 2.1a2 was > incomplete; it will be clearer in the next release. > Python has a long tradition of loosening type restrictions over time, and > this was a natural part of that tradition: if an object supports getattr, > it supports the only thing the "import" part of from-import really needs. > The "from" part still needs "a module name", though, but the operational > definition of "a module name" is "a name that appears as a key in > sys.modules". So meet those two requirements, and Python couldn't care less > whether it's "a real module" anymore. Tim wrote a great explanation, and cute example, but he forgot to mention one small thing: for from M import * M, in addition to supporting getattr, must also either have an __all__ attribute which lists the names to be imported, or an __dict__ which should be a dictionary whose keys are the names which will be important. just-nitpicking-ly y'rs, Z. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 From clarence at netlojix.com Sun Feb 4 22:33:42 2001 From: clarence at netlojix.com (Clarence Gardner) Date: Sun, 4 Feb 2001 13:33:42 -0800 Subject: from-import on non-module objects? References: Message-ID: <981322698.934790726@news.silcom.com> On Sun, 04 Feb 2001, Tim Peters wrote: >if an object supports getattr, >it supports the only thing the "import" part of from-import really needs. > >Really bad idea (running under 2.1a2): > >>>> somelist = [1, 2, 3, 2, 1] >>>> from somelist import count # blows up >Traceback (most recent call last): > File "", line 1, in ? > from somelist import count # blows up >ImportError: No module named somelist >>>> import sys >>>> sys.modules["somelist"] = somelist >>>> from somelist import count # works, for some meaning of "works" >>>> count(1), count(2), count(3), count(4) >(2, 2, 1, 0) >>>> > Boy, was this confusing to someone who'd never heard of the count method of lists! But firing up the friendly interactive Python and doing a getattr([], 'count') showed it to me. Then I had to print its docstring to figure out how that result was (2,2,1,0)! Speaking of the friendly interactive Python, I saw recently that someone finally made an interactive shell for Perl. I always wondered why they hadn't done it sooner. [I'll bet it's not as good, though :)] From thomas at xs4all.net Mon Feb 5 00:14:53 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 5 Feb 2001 00:14:53 +0100 Subject: from-import on non-module objects? In-Reply-To: <981322698.934790726@news.silcom.com>; from clarence@netlojix.com on Sun, Feb 04, 2001 at 01:33:42PM -0800 References: <981322698.934790726@news.silcom.com> Message-ID: <20010205001453.H962@xs4all.nl> On Sun, Feb 04, 2001 at 01:33:42PM -0800, Clarence Gardner wrote: > Speaking of the friendly interactive Python, I saw recently that someone > finally made an interactive shell for Perl. I always wondered why they > hadn't done it sooner. [I'll bet it's not as good, though :)] Perl isn't as easy, interactively, as Python, due to the way it manages variables and code (as lazy as possible, that is :) And for the people that really wanted one, there has been the Perl debugger for a while. The way to get an interactive prompt was: 'perl -de1'. Quite recently (in 5.004 I think ?) they even added readline support in it. Not sure if that's the interactive interpreter you were talking about or not, though; my sole contribution to Perl has been the detection of a bug in the 'require' statement :) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From dan at eevolved.com Mon Feb 5 16:13:32 2001 From: dan at eevolved.com (Dan Parisien) Date: Mon, 05 Feb 2001 15:13:32 GMT Subject: from-import on non-module objects? References: Message-ID: > useful-examples-left-to-your-fertile-imaginations-ly y'rs - tim your sig is so weird :) From pj at sgi.com Thu Feb 1 00:46:59 2001 From: pj at sgi.com (Paul Jackson) Date: 31 Jan 2001 23:46:59 GMT Subject: Perl-to-Python converter/translator? References: <959jsd$njn$1@nnrp1.deja.com> <3A7879FC.EA879C9B@bigfoot.de> Message-ID: <95a85j$p1ce$1@fido.engr.sgi.com> Gerhard wrote: |> Maybe the Perl/Python phrasebook at |> http://starship.python.net/~da/jak/cookbook.html is helpful |> to you. Intra-document links don't work. Does anybody know a |> better version of this document? Try a google.com search for "perl python phrasebook" for pointers to such Perl-Python translators, and to other comparisons of Perl and Python. -- I won't rest till it's the best ... Manager, Linux System Software Paul Jackson 1.650.933.1373 From tim.one at home.com Fri Feb 2 07:57:31 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 2 Feb 2001 01:57:31 -0500 Subject: Perl-to-Python converter/translator? In-Reply-To: <959uuh01qd3@drn.newsguy.com> Message-ID: [Grant Griffin] > ... > To rigorously and correctly translate any-and-all Perl to Python > would surely take a heroic effort, but to do it at about the > 90% level can't be all that big of a job for the language > hobbyists out there (anybody know any? ); ... Sorry, Grant: simply *parsing* Perl is beyond most peoples' pain tolerance; search CPAN for an equivalent to Python's tokenize.py and report back on your successes . perhaps-you'd-make-better-progress-if-you-ran-it-through-an-fft- first-ly y'rs - tim From hamish_lawson at yahoo.co.uk Fri Feb 2 15:56:39 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: Fri, 02 Feb 2001 14:56:39 GMT Subject: Perl-to-Python converter/translator? References: <959uuh01qd3@drn.newsguy.com> Message-ID: <95ehr1$9d$1@nnrp1.deja.com> Tim Peters wrote: > Sorry, Grant: simply *parsing* Perl is beyond most peoples' pain > tolerance; search CPAN for an equivalent to Python's tokenize.py and > report back on your successes . To overcome the expected language incompatibilities between Perl 5 and the future Perl 6, the language developers are intending to provide a tool that will migrate existing Perl 5 code to Perl 6. I'm not sure of the exact details, but I understand that it will make use of the fact that Perl now has a compiler that can compile to and from some intermediate format - I presume the scheme being to use the Perl 6 compiler to reconstitute as source code the intermediate code generated by the Perl 5 compiler. Perhaps it may be possible to reconstitute this intermediate code as Python source code instead. Hamish Lawson Sent via Deja.com http://www.deja.com/ From not.this at seebelow.org Fri Feb 2 19:31:13 2001 From: not.this at seebelow.org (Grant Griffin) Date: 2 Feb 2001 10:31:13 -0800 Subject: Perl-to-Python converter/translator? References: Message-ID: <95eudh010c1@drn.newsguy.com> In article , "Tim says... > >[Grant Griffin] >> ... >> To rigorously and correctly translate any-and-all Perl to Python >> would surely take a heroic effort, but to do it at about the >> 90% level can't be all that big of a job for the language >> hobbyists out there (anybody know any? ); ... > >Sorry, Grant: simply *parsing* Perl is beyond most peoples' pain tolerance; It sure was beyond _mine_, Tim! Luckily, just about the time I realized I couldn't parse my own Perl code, I discovered Python . But this is a classic Catch-22: you switch to Python because you found yourself unable to maintain your own Perl; you want to translate your Perl to Python so you can maintain it; but there aren't any automatic translators out there because nobody _else_ can figure out how to parse Perl--which is more-or-less why you switched in the first place! Then again, haven't Great Minds already solved the parsing part of automatic translation? I mean, doesn't Perl come with its own lexer, parser, and even grammar (though last I checked, they had to doctor the parser that was automatically generated from the grammar...) Which reminds me...I really think Open Source Software is gonna become a big thing one day--just for cases like this . >search CPAN for an equivalent to Python's tokenize.py and report back on >your successes . I see what you mean. (Though to be fair, I never found tokenize.py on PYPAN either .) But did I say "translate at about the 90% level"?--I really meant translate at about the _7%_ level. If somebody came up with something that didn't really "parse" Perl but just did the simple operation of "clutter-removal" (eliminating ";", "{", "@", "my", etc. outside of strings) that would help. i'd-write-one-myself-if-perl-hadn't-taught-me-to-be-lazy --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 sheila at spamcop.net Thu Feb 1 06:15:29 2001 From: sheila at spamcop.net (Sheila King) Date: Thu, 01 Feb 2001 05:15:29 GMT Subject: Perl-to-Python converter/translator? References: <959jsd$njn$1@nnrp1.deja.com> Message-ID: <2urh7t0cmisg8ous1lfuo1s4f54c32q58e@4ax.com> On Wed, 31 Jan 2001 18:00:51 GMT, Lance Sloan wrote in comp.lang.python in article <959jsd$njn$1 at nnrp1.deja.com>: :I'm an experienced Perl programmer who has just been assigned :a project that must be done in Python. I'm looking for a :Perl-to-Python translator to help me out. I don't expect to :write the whole project in Perl and translate it, though. I'm :just looking for some automation to help me see how my old work :could be done in Python. I've translated a single Perl script (written by someone else) to Python. If it helps you at all, you can see it here: http://www.aota.net/ubb/Forum3/HTML/001491-1.html I would recommend that you read through the Python Tutorial as a start, and then look at the Library Reference. You should be able to work through the tutorial in short order, and then browse the Library Reference on an as-needed basis. The tutorial may seem simple, but it will get you jump started and won't take long.. http://www.python.org/doc/ -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From hgg9140 at cola.ca.boeing.com Thu Feb 1 15:56:07 2001 From: hgg9140 at cola.ca.boeing.com (Harry George) Date: Thu, 1 Feb 2001 14:56:07 GMT Subject: Perl-to-Python converter/translator? References: <959jsd$njn$1@nnrp1.deja.com> Message-ID: I've done some perl-->python, and found (at first) that I missed some of the perl idioms. So I did a python module to support perl-ish idioms. See "pyperl" at: http://www.seanet.com/~hgg9140/comp/index.html It lets you pretty much read the perl code and write the python code on the fly. More tedious than true converter, but do-able. I agree with other posters that after you get into python's own idioms, you won't miss perl. Lance Sloan writes: > I'm an experienced Perl programmer who has just been assigned > a project that must be done in Python. I'm looking for a > Perl-to-Python translator to help me out. I don't expect to > write the whole project in Perl and translate it, though. I'm > just looking for some automation to help me see how my old work > could be done in Python. > > I didn't find anything useful via Google or Vaults of Parnassus > searches. So, I would appreciate any pointers! > > Thanks in advance. > > -- > Lance Sloan - lsloan00 at my-deja.com > > -- > Lance Sloan - lsloan00 at my-deja.com > > > Sent via Deja.com > http://www.deja.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 Randy.L.Kemp at motorola.com Thu Feb 1 18:00:03 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Thu, 1 Feb 2001 11:00:03 -0600 Subject: Perl-to-Python converter/translator? Message-ID: <69BC4C6AE83ED311BC9400805FA7B14AF84DD6@il93exp01.css.mot.com> Have we converted another to the fray? -----Original Message----- From: Gerhard H?ring [mailto:gerhard.nospam at bigfoot.de] Sent: Wednesday, January 31, 2001 2:48 PM To: python-list at python.org Subject: Re: Perl-to-Python converter/translator? Lance Sloan wrote: > > I'm an experienced Perl programmer who has just been assigned > a project that must be done in Python. I'm looking for a > Perl-to-Python translator to help me out. I don't expect to > write the whole project in Perl and translate it, though. I'm > just looking for some automation to help me see how my old work > could be done in Python. > > I didn't find anything useful via Google or Vaults of Parnassus > searches. So, I would appreciate any pointers! Maybe the Perl/Python phrasebook at http://starship.python.net/~da/jak/cookbook.html is helpful to you. Intra-document links don't work. Does anybody know a better version of this document? 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 Fri Feb 2 22:37:02 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Feb 2001 22:37:02 +0100 Subject: Memory Leak Tools References: <3A785D25.A26822@americasm01.nt.com> Message-ID: "Lee, Rick" writes: > Any tool to help track down memory leaks? In Python 2.0, it is quite hard to find a program that produces a memory leak. In any case, just turn on debugging in the gc module - that will report all the cycles it collects. Regards, Martin From gtalvola at nameconnector.com Thu Feb 1 20:40:48 2001 From: gtalvola at nameconnector.com (Geoff Talvola) Date: Thu, 01 Feb 2001 14:40:48 -0500 Subject: executing JavaScript from Python References: <959ovu$sqd$1@nnrp1.deja.com> <63E6AD93C013B993.0AA5FD315BC99418.FEB162B59977D6FB@lp.airnews.net> Message-ID: <3A79BBC0.8F56A389@NameConnector.com> > In article <959ovu$sqd$1 at nnrp1.deja.com>, wrote: > >urllib.urlopen() can be useful for grabbing a web page and checking its > >contents. However, JavaScript generated content throws a monkey wrench > >in this technique. > > > >Has anyone cobbled together a means to invoke JavaScript from Python, > >possibly including the DOM and the substitution of output into the HTML > >file? On Windows, you can use Internet Explorer via COM: >>> import urllib >>> print urllib.urlopen('http://localhost/javascript.html').read() >>> from win32com.client.gencache import EnsureDispatch >>> ie = EnsureDispatch('InternetExplorer.Application') >>> ie.Navigate('http://localhost/javascript.html') >>> print ie.Document.documentElement.innerHTML Hello, World! >>> -- - Geoff Talvola Parlance Corporation gtalvola at NameConnector.com From gtalvola at nameconnector.com Fri Feb 2 01:14:01 2001 From: gtalvola at nameconnector.com (Geoff Talvola) Date: Thu, 01 Feb 2001 19:14:01 -0500 Subject: executing JavaScript from Python References: <959ovu$sqd$1@nnrp1.deja.com> <63E6AD93C013B993.0AA5FD315BC99418.FEB162B59977D6FB@lp.airnews.net> <3A79BBC0.8F56A389@NameConnector.com> Message-ID: <3A79FBC9.249E8E8E@NameConnector.com> (on the subject of getting web page contents _after_ the JavaScript has been executed, using Internet Explorer on Windows:) I fiddled with this a bit more, and here's a class that actually waits for IE to be done before trying to get the HTML, and which lets you refresh to make sure you're not getting a cached page. Note that this only works for GET operations -- I couldn't figure out the magic incantation to get POST to work. (Navigate has a PostData argument, but whatever I put there, it just seems to ignore.) I'm not going to spend any more time on this, but if someone can figure out how to get POST to work, I'm sure it would be appreciated... ############ import time from win32com.client.gencache import EnsureDispatch from win32com.client import constants class InternetExplorerGetter: def __init__(self): self.ie = EnsureDispatch('InternetExplorer.Application') def get(self, url): self.ie.Navigate(url) return self.waitForResult() def refresh(self): self.ie.Refresh() return self.waitForResult() def waitForResult(self): while 1: state = self.ie.ReadyState if state == constants.READYSTATE_COMPLETE: break time.sleep(0.1) return self.ie.Document.documentElement.innerHTML if __name__ == '__main__': print InternetExplorerGetter().get('http://www.python.org') ############ -- - Geoff Talvola Parlance Corporation gtalvola at NameConnector.com From hamish_lawson at yahoo.co.uk Thu Feb 8 18:06:28 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: Thu, 08 Feb 2001 17:06:28 GMT Subject: executing JavaScript from Python References: <959ovu$sqd$1@nnrp1.deja.com> <63E6AD93C013B993.0AA5FD315BC99418.FEB162B59977D6FB@lp.airnews.net> Message-ID: <95ujmb$9j$1@nnrp1.deja.com> Geoff Talvola wrote: > On Windows, you can use Internet Explorer via COM: > > >>> from win32com.client.gencache import EnsureDispatch > >>> ie = EnsureDispatch('InternetExplorer.Application') > >>> ie.Navigate('http://localhost/javascript.html') > >>> print ie.Document.documentElement.innerHTML > > > > Hello, World! > >>> I tried that out myself and got the error below. I'm using Python 2.0 with win32all build 135. Traceback (most recent call last): File "C:\temp\test2.py", line 11, in ? print ie.Document.documentElement.innerHTML File "C:\Python\win32com\client\__init__.py", line 340, in __getattr__ return apply(self._ApplyTypes_, args) File "C:\Python\win32com\client\__init__.py", line 334, in _ApplyTypes_ return self._get_good_object_(apply(self._oleobj_.InvokeTypes, (dispid, 0, wFlags, retType, argTypes) + args), user, resultCLSID) pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147467259), None) Hamish Lawson Sent via Deja.com http://www.deja.com/ From gtalvola at nameconnector.com Thu Feb 8 20:04:26 2001 From: gtalvola at nameconnector.com (Geoff Talvola) Date: Thu, 08 Feb 2001 14:04:26 -0500 Subject: executing JavaScript from Python References: <959ovu$sqd$1@nnrp1.deja.com> <63E6AD93C013B993.0AA5FD315BC99418.FEB162B59977D6FB@lp.airnews.net> <95ujmb$9j$1@nnrp1.deja.com> Message-ID: <3A82EDBA.19284CB9@NameConnector.com> Hamish Lawson wrote: > Geoff Talvola wrote: > > > On Windows, you can use Internet Explorer via COM: > > > > >>> from win32com.client.gencache import EnsureDispatch > > >>> ie = EnsureDispatch('InternetExplorer.Application') > > >>> ie.Navigate('http://localhost/javascript.html') > > >>> print ie.Document.documentElement.innerHTML > > > > > > > > Hello, World! > > >>> > > I tried that out myself and got the error below. I'm using Python 2.0 > with win32all build 135. > > Traceback (most recent call last): > File "C:\temp\test2.py", line 11, in ? > print ie.Document.documentElement.innerHTML > File "C:\Python\win32com\client\__init__.py", line 340, in __getattr__ > return apply(self._ApplyTypes_, args) > File "C:\Python\win32com\client\__init__.py", line 334, in > _ApplyTypes_ > return self._get_good_object_(apply(self._oleobj_.InvokeTypes, > (dispid, 0, wFlags, retType, argTypes) + args), user, resultCLSID) > pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, > None, None, 0, -2147467259), None) > > Hamish Lawson You have to wait until the document is done loading before you can access the innerHTML -- if you try to access innerHTML too quickly you'll get the exception. I sent out a followup message with code that does the waiting; if you can't find the message, let me know and I'll email it to you. -- - Geoff Talvola Parlance Corporation gtalvola at NameConnector.com From apederse at my-deja.com Thu Feb 8 08:17:31 2001 From: apederse at my-deja.com (apederse at my-deja.com) Date: Thu, 08 Feb 2001 07:17:31 GMT Subject: executing JavaScript from Python References: <959ovu$sqd$1@nnrp1.deja.com> Message-ID: <95th69$36k$1@nnrp1.deja.com> In article <959ovu$sqd$1 at nnrp1.deja.com>, echuck at mindspring.com wrote: > urllib.urlopen() can be useful for grabbing a web page and checking its > contents. However, JavaScript generated content throws a monkey wrench > in this technique. > > Has anyone cobbled together a means to invoke JavaScript from Python, > possibly including the DOM and the substitution of output into the HTML > file? > > -Chuck > > Sent via Deja.com > http://www.deja.com/ > How about a combination of Mozilla RHINO and JPython - just a though. /Asle Sent via Deja.com http://www.deja.com/ From MarkH at ActiveState.com Thu Feb 8 12:57:30 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 08 Feb 2001 11:57:30 GMT Subject: executing JavaScript from Python References: <959ovu$sqd$1@nnrp1.deja.com> <95th69$36k$1@nnrp1.deja.com> Message-ID: <3A8288C2.6050905@ActiveState.com> apederse at my-deja.com wrote: > How about a combination of Mozilla RHINO and > JPython - just a though. If you are happy to use Mozilla specific technology, then PyXPCOM would also be a good answer. See http://www.activestate.com/Products/Komodo/PyXPCOM/ Mark. From slaurent at sonicfoundry.com Tue Feb 13 19:13:58 2001 From: slaurent at sonicfoundry.com (Sean Laurent) Date: Tue, 13 Feb 2001 12:13:58 -0600 Subject: os.popen: writing to...? References: <959pqt$tgp$1@nnrp1.deja.com> Message-ID: On Wed, 31 Jan 2001 19:42:23 GMT, James Lockley wrote: >i now want to go to the next step and get rid of the batch files... >i need to open a pipe to a command and then write the command arguments >to it. > >as far as i could make out, this should work: > >>>> abaqus='c:\\abaqus\\5.8-14\\abaqus.exe' >>>> abq=os.popen(abaqus,'w') >>>> abq.write('post') > >but i get this: > >Traceback (innermost last): > File "", line 1, in ? >IOError: [Errno 22] Invalid argument Hrmmm. I have been encountering the exact same problem under Windows 2000. I have tried all the flavors of os.popen ... os.popen(), os.popen2(), os.popen3() and os.popen4(). I have also tried the popen2 flavors eg. popen2.popen2(), popen2.popen3(), and popen2.popen4(). None of them seem to work... >>> instream, outstream = popen2.popen2("p4 -x - edit") >>> instream >>> outstream >>> outstream.write('d:\\install\\proj\\projects.xml\n') Traceback (innermost last): File "", line 1, in ? IOError: [Errno 22] Invalid argument Does anyone have any bright ideas or suggestions? -Sean- From db3l at fitlinxx.com Tue Feb 13 22:54:44 2001 From: db3l at fitlinxx.com (David Bolen) Date: 13 Feb 2001 16:54:44 -0500 Subject: os.popen: writing to...? References: <959pqt$tgp$1@nnrp1.deja.com> Message-ID: Sean Laurent writes: > >>> instream, outstream = popen2.popen2("p4 -x - edit") > >>> instream > > >>> outstream > > >>> outstream.write('d:\\install\\proj\\projects.xml\n') > Traceback (innermost last): > File "", line 1, in ? > IOError: [Errno 22] Invalid argument > > Does anyone have any bright ideas or suggestions? One way I've been able to replicate this behavior (under NT, not 2000) is if the process I've started exits before I get around to the write(). Are you sure that "p4" is still running on your system at the point when you try to do the write? Could there be something wrong with the options you are supplying or just something about running p4 in a child process that is causing it to terminate early? Or is it possible that the child shell can't find p4 in the path or something? In such a case, you might try reading first from instream to see the pipe is closed, or if you use popen3, checking the stderr handle to see if there is an error message from your shell. -- -- 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 slaurent at sonicfoundry.com Wed Feb 21 22:57:44 2001 From: slaurent at sonicfoundry.com (Sean Laurent) Date: Wed, 21 Feb 2001 15:57:44 -0600 Subject: os.popen: writing to...? References: <959pqt$tgp$1@nnrp1.deja.com> Message-ID: <42e89t0cgbsta8i1kal9i0s0qrk0vl4jdg@4ax.com> On 13 Feb 2001 16:54:44 -0500, David Bolen wrote: >Sean Laurent writes: > >> >>> instream, outstream = popen2.popen2("p4 -x - edit") >> >>> instream >> >> >>> outstream >> >> >>> outstream.write('d:\\install\\proj\\projects.xml\n') >> Traceback (innermost last): >> File "", line 1, in ? >> IOError: [Errno 22] Invalid argument >> >> Does anyone have any bright ideas or suggestions? >Or is it possible that the child shell can't find p4 in the path or >something? In such a case, you might try reading first from instream >to see the pipe is closed, or if you use popen3, checking the stderr >handle to see if there is an error message from your shell. Well... I'm very glad you mentioned this... *laugh* I'm extremely embarassed to admit this, but you were right. The child shell could _not_ find "p4" in the path. Plain and simple. Staring me right in the face. Once I saw your suggestion to check stderr, I couldn't believe I hadn't done that. Lo and behold... file not found. *grin* The big problem was that most of my work is done from a command prompt, where the "p4" command is always in the path. Unfortunately, my testing efforts were done from PythonWin, where "p4" was _not_ in the path. *ugh* I greatly appreciate your advice... Thanks again. -Sean- From dsh8290 at rit.edu Fri Feb 2 01:35:29 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 1 Feb 2001 19:35:29 -0500 Subject: Design for slices In-Reply-To: ; from fakeaddress@nospammail.com on Thu, Feb 01, 2001 at 09:54:55AM +1100 References: <959uue$k02$1@cubacola.tninet.se> Message-ID: <20010201193529.B6542@harmony.cs.rit.edu> On Thu, Feb 01, 2001 at 09:54:55AM +1100, Ben Catanzariti wrote: | I am fairly sure this came about due to the fact you are defining a position | of a pointer, not an object ie. a letter in a string. So position x[0] means | the pointer has not moved or has a null value and will occur directly before | the first letter in a string.... | | Some one please correct me if i am wrong ... I am sure you will ;) I think you are correct, for C. In C a string can be declared as either: char[] /* array of characters */ char* /* pointer to a character */ The char* can either be a pointer to a single character, or a pointer to an array of characters. Thus the following equivalences: char[10] str1 ; char* str2 ; /* string init not shown */ str1[0] == *str2 str[n] == *(str2 + n) It also makes the following loop rather short and cute (with the NULL terminator, of course) : /* start off 1 element before the array */ char* ptr = str2-1 ; /* or str1 if you prefer */ /* advance the pointer to the end of the string */ while( *(++ptr) ) ; Along the lines of Alex' example, during my beginning Comp. Sci. courses I was given the exercise of implementing a 2d array (table). This was done in Eiffel. Following the Eiffel principles, the client would provide both the lower and upper indices. Not requiring the client to use zero-based indexing created more work in my ARRAY2 class because of the mathematical reasons already stated. -D | | "Gustaf Liljegren" wrote in message | news:959uue$k02$1 at cubacola.tninet.se... | > I'm learning Python and have a question about defining ranges/slices in | > strings. I can't find any defence for what looks like a poor design, so I | > have to ask. Why is the first character in the string x defined as x[0] | and | > not x[1]? This looks just like the typical geek thinking that I'm trying | to | > avoid with Python. | > | > Gustaf | From scarblac at pino.selwerd.nl Thu Feb 1 01:50:02 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 1 Feb 2001 00:50:02 GMT Subject: Design for slices References: <959uue$k02$1@cubacola.tninet.se> Message-ID: Gustaf Liljegren wrote in comp.lang.python: > I'm learning Python and have a question about defining ranges/slices in > strings. I can't find any defence for what looks like a poor design, so I > have to ask. Why is the first character in the string x defined as x[0] and > not x[1]? This looks just like the typical geek thinking that I'm trying to > avoid with Python. Because experience has taught generations of programmers that this is the right thing to do. For a string x of length n, the following simple equations hold: x == x[0:i]+x[i:n] for any i (even negative i) len(x[i:n]) == n-i for 0 <= i <= n x[i:i] == [] for any i This means that it's always simple to split strings. This is also the reason that a string slice x[i:j] *does not* include x[j]. It really simplifies situations that would otherwise call for "-1" and "+1" everywhere. "Off-by-one errors" have caused lots of problems in the past. The Python choice avoids these problems for the common cases. People often say that you have to think of the indexes as marks *between* the actual values. Say, you have the string "Python", then think of it as P y t h o n 0 1 2 3 4 5 6 And now it's obvious that "Python"[2:5] == "tho", a string of length 3, which is expected since 5-2 = 3. There are more reasons, but you'll come to appreciate them over time. -- Remco Gerlich From dnew at san.rr.com Thu Feb 1 05:47:58 2001 From: dnew at san.rr.com (Darren New) Date: Thu, 01 Feb 2001 04:47:58 GMT Subject: Design for slices References: <959uue$k02$1@cubacola.tninet.se> Message-ID: <3A78EA7E.F0B864B1@san.rr.com> > Why is the first character in the string x defined as x[0] and > not x[1]? Along with all the mathematical answers, there's also the answer that (most) computer languages only do one thing at a time. If you're counting and processing the elements of a string (or list, or whatever), you do it in three steps: 1) Am I done yet? 2) Process the current item. 3) Move to the next item. The first step is really "Does the number of items I processed equal the number of items in the list/string?" And before you process any, the number of items you've processed is zero. Try counting out 10 pennies from your hand to the desk, but don't say the number at the same time your hands are moving. What did you say after you moved one penny? "One." What did you say *before* you moved any pennies? -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. Ignorance can be cured. Naivety cures itself. From djmoore at uh.edu Thu Feb 1 00:39:12 2001 From: djmoore at uh.edu (DaveMoore) Date: Wed, 31 Jan 2001 17:39:12 -0600 Subject: Any practice exercises for beginner??? References: Message-ID: On Wed, 31 Jan 2001 21:36:22 GMT, "shaka" wrote: > > I was just wondering beside the tutorial if there was any practice >exercises to reinforce beginners strength in python? >I can recall that when learning Java, some Java website offered some >exercises for beginners. > First of all, check out the Useless Python Page: . Download and run the code, see what it does, then try to duplicate it. There is a link there to the Association for Computing Machinery Collegiate Programming Contest Problem Set Archive, but it's been updated: http://acm.uva.es/problemset/ (Note that contest entries must be in C/C++ or Pascal.) (Great Grotty Ghu, this thing has an automated on-line judge! I bet that's a pretty piece of code!) Here's a problem I recently had fun with: Many of the Win32 Network Resource enumeration tools return a list of dictionaries: [{'name':'comp1','comment':'room 100','type':WKSTATION}, {'name':'comp2','comment':'room 101','type':SERVER}] Try converting this to a dictionary of lists: {'comp1':['room100',WKSTATION],'comp2':['room 101',SERVER]} (Typed by hand, hope I got the punctuation right.) Now step through the dictionary, printing out the characteristics associated with each computer in a neatly-formatted table. Hm, didn't come out in order, did it? Fix that. It's interesting to do this with a large (15-20 entries), sorted list(the Win32 functions return a list sorted by computer name); if you print the result dictionary out as each entry is added, you can watch the dictionary reorganize itself as it grows. (This is as far as I got, I'm interested in the enumerated resources, and this turns out not to be the best way to do what I want. But it was an educational exercise.) If you have a lot of time to waste, er, invest, write a wrapper that solicits input to fill the source list, and then lets you search the resulting dictionary for a particular entry. Duplicates of already-existing entries should be handled gracefully. If you're really ambitious, provide a mechanism to edit and delete entries as well. OK, now re-write the interface so it uses Tk/Tcl dialogs instead of a text-based interface. -- Dave Moore == djmoore at uh.edu == I speak for me. In the wrong hands, sanity is a dangerous weapon. From mspiggie at my-deja.com Thu Feb 1 00:45:37 2001 From: mspiggie at my-deja.com (mspiggie at my-deja.com) Date: Wed, 31 Jan 2001 23:45:37 GMT Subject: Any practice exercises for beginner??? References: Message-ID: <95a82u$b6r$1@nnrp1.deja.com> You may find some interesting ideas and source code at: http://www.lowerstandard.com/python/pythonsource.html Rob Andrews In article , "shaka" wrote: > > > I was just wondering beside the tutorial if there was any practice > exercises to reinforce beginners strength in python? > I can recall that when learning Java, some Java website offered some > exercises for beginners. > > Sent via Deja.com http://www.deja.com/ From scarblac at pino.selwerd.nl Thu Feb 1 01:36:52 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 1 Feb 2001 00:36:52 GMT Subject: Any practice exercises for beginner??? References: Message-ID: shaka wrote in comp.lang.python: > I was just wondering beside the tutorial if there was any practice > exercises to reinforce beginners strength in python? > I can recall that when learning Java, some Java website offered some > exercises for beginners. I'm interested in this sort of thing. Can you tell us what the Java exercise site was? Probably a good start would be to do the same things in Python. -- Remco Gerlich From sholden at holdenweb.com Thu Feb 1 01:18:59 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 31 Jan 2001 19:18:59 -0500 Subject: redirecting output References: <3A789343.48002B2C@ic.sunysb.edu> Message-ID: "Jp Calderone" wrote in message news:3A789343.48002B2C at ic.sunysb.edu... > > > I've attached the python interpreter to a server, > essentially letting people connect to the given address > and port and pump stuff into it. What I can't figure out > is how I might go about redirecting the output from some > of the builtin functions - dir(), print, etc, to their > socket. Is this possible? > Interesting idea, with some interesting security aspects! The dir() function doesn't do any output: it just produces a list. "print", of course, isn't a statement... but you should be able to redirect its output by binding sys.stdout to the socket for the duration of the session. > Thanks in advance, > Jp > regards Steve From Bill.Scherer at VerizonWireless.com Fri Feb 2 06:46:15 2001 From: Bill.Scherer at VerizonWireless.com (Bill Scherer) Date: Fri, 02 Feb 2001 00:46:15 -0500 Subject: redirecting output References: <3A789343.48002B2C@ic.sunysb.edu> Message-ID: <3A7A49A7.CA67D2DC@VerizonWireless.com> look at the docs for the sys module. You can redirect sys.stdout (and sys.stderr and sys.stdin) to any sutable object... Jp Calderone wrote: > > I've attached the python interpreter to a server, > essentially letting people connect to the given address > and port and pump stuff into it. What I can't figure out > is how I might go about redirecting the output from some > of the builtin functions - dir(), print, etc, to their > socket. Is this possible? > > Thanks in advance, > Jp > -- > http://mail.python.org/mailman/listinfo/python-list -- William K. Scherer Sr. Member of Applications Staff - Verizon Wireless Bill.Scherer_at_VerizonWireless.com From rjroy at takingcontrol.com Thu Feb 1 01:17:09 2001 From: rjroy at takingcontrol.com (Robert Roy) Date: Thu, 01 Feb 2001 00:17:09 GMT Subject: Best way to match everything between tags References: Message-ID: <3a78a853.1151132812@news1.on.sympatico.ca> On Wed, 31 Jan 2001 23:46:17 +0100, "Henning VON ROSEN" wrote: >Hi! >I am learning regular expressions. > >What is thenatural way to match everything that is not "something" >fx i want to maipulate all the text of a html document, but none of the tags > > >This matches all the tags; > >s="textsome textmore texttext" >r = re.compile(r"<.*?>") > print r.sub("WWW",s) > >this works fine if I want to manipulate the tags, but I want to maipulate >the text between tags > >I haven't found a one-expression way. Thankful for any indications! > >/Henning von Rosen > > Some ideas: You should define groups in your re >>> s="textsome textmore texttext" Definining a group around the content >>> m = re.search(r'<[^>]*>([^<]*)<', s) >>> m.groups() ('some text',) Adding a group around the tag >>> m = re.search(r'<([^>]*)>([^<]*)<\1', s) >>> m.groups() ('body', 'some text') Uing a lookahead to find the matching tag, this will find an inner pair ie one with no more tags in it >>> m = re.search(r'<([^>]*)>([^<]*)>> m.groups() ('tag', 'more text') Example of that >>> s="textsome textmore bolded texttext" >>> m = re.search(r'<([^>]*)>([^<]*)>> m.groups() ('b', 'bolded') This will pick up outermost tag pair >>> m = re.search(r'<([^>]*)>(.*)>> m.groups() ('tag', 'more bolded text') >>> s="textsome textmore stuffbolded texttext" >>> m = re.search(r'<([^>]*)>(.*)>> m.groups() ('tag', 'more stuffbolded text') do non greedy match, this will pickup leftmost tag and leftmost close tag >>> m = re.search(r'<([^>]*)>(.*?)>> m.groups() ('tag', 'more stuff') Lots of ways to get in trouble here Bob From f8dy at my-deja.com Thu Feb 1 02:16:20 2001 From: f8dy at my-deja.com (Mark Pilgrim) Date: Thu, 01 Feb 2001 01:16:20 GMT Subject: Best way to match everything between tags References: Message-ID: <95adcs$fru$1@nnrp1.deja.com> In article , "Henning VON ROSEN" wrote: > Hi! > I am learning regular expressions. > > What is thenatural way to match everything that is not "something" > fx i want to maipulate all the text of a html document, but none of the tags Regular expressions may not be the best solution for this. Try subclassing SGMLParser and passing the document through the parser. Specific class methods will be called for each start tag, each end tag, and each block of text in between. This gives you free reign to manipulate the text-between-the-tags any way you like, and just pass the start/end tags through unaltered. See http://www.faqts.com/knowledge_base/view.phtml/aid/4200/fid/549 for a working example. The method you'd want to do your manipulation in is "handle_data". -M -- You're smart; why haven't you learned Python yet? http://diveintopython.org/ Sent via Deja.com http://www.deja.com/ From phrxy at csv.warwick.ac.uk Thu Feb 1 06:10:56 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Thu, 1 Feb 2001 05:10:56 +0000 Subject: Best way to match everything between tags In-Reply-To: <95adcs$fru$1@nnrp1.deja.com> References: <95adcs$fru$1@nnrp1.deja.com> Message-ID: On Thu, 1 Feb 2001, Mark Pilgrim wrote: > In article , > "Henning VON ROSEN" wrote: > > Hi! > > I am learning regular expressions. > > > > What is thenatural way to match everything that is not "something" > > fx i want to maipulate all the text of a html document, but none of the tags > > Regular expressions may not be the best solution for this. Try subclassing > SGMLParser and passing the document through the parser. Specific class [...] The perl FAQ has a useful discussion of this 'how do I match html-ish tags with regexps' question, IIRC (but it's a long time since I looked at anything related to perl of course). The short answer is "don't" as Mark says. John From baasad at qualitynet.net Thu Feb 1 01:07:45 2001 From: baasad at qualitynet.net (bashar A. Asad) Date: Thu, 01 Feb 2001 03:07:45 +0300 Subject: how about webware Message-ID: <95au2d$65d2@news.qualitynet.net> hello; I would like to know what do you guys think of webware as an application server. can I compare it to for example webobjects by apple ? thankx bashar From reborn at neozone.net Thu Feb 1 01:18:04 2001 From: reborn at neozone.net (¾Æ¹«) Date: Thu, 1 Feb 2001 09:18:04 +0900 Subject: How can I get the information for jpython? Message-ID: <95a9va$9rk$1@news1.kornet.net> I'm studying about jpython.. But.. inpormation is too lack for jpython.. Who do you know the site for jpython? (except www.jpython.org, www.jython.org) From Bill.Scherer at VerizonWireless.com Thu Feb 1 19:59:34 2001 From: Bill.Scherer at VerizonWireless.com (Bill Scherer) Date: Thu, 01 Feb 2001 13:59:34 -0500 Subject: How can I get the information for jpython? References: <95a9va$9rk$1@news1.kornet.net> Message-ID: <3A79B216.C589C5DC@VerizonWireless.com> Try: http://jython.sourceforge.net/ "????" wrote: > > I'm studying about jpython.. > But.. inpormation is too lack for jpython.. > Who do you know the site for jpython? > (except www.jpython.org, www.jython.org) > > -- > http://mail.python.org/mailman/listinfo/python-list -- William K. Scherer Sr. Member of Applications Staff - Verizon Wireless Bill.Scherer_at_VerizonWireless.com From amritansh at mobilian.com Thu Feb 1 01:30:06 2001 From: amritansh at mobilian.com (Amritansh Raghav) Date: Wed, 31 Jan 2001 16:30:06 -0800 Subject: overloading == Message-ID: can it be done? i looked at the operator documentation under Python Runtime Services - but didnt find anything to suggest it could be done. From quinn at hork.ugcs.caltech.edu Thu Feb 1 03:33:25 2001 From: quinn at hork.ugcs.caltech.edu (Quinn Dunkan) Date: 1 Feb 2001 02:33:25 GMT Subject: overloading == References: Message-ID: On Wed, 31 Jan 2001 16:30:06 -0800, Amritansh Raghav wrote: >can it be done? >i looked at the operator documentation under Python Runtime Services - but >didnt find anything to suggest it could be done. Yes, define __cmp__ or __rcmp__. See 3.3.1 in the language reference. From drewpc at my-deja.com Thu Feb 1 21:55:05 2001 From: drewpc at my-deja.com (drewpc at my-deja.com) Date: Thu, 01 Feb 2001 20:55:05 GMT Subject: overloading == References: Message-ID: <95cif3$bi3$1@nnrp1.deja.com> In article , quinn at hork.ugcs.caltech.edu (Quinn Dunkan) wrote: > On Wed, 31 Jan 2001 16:30:06 -0800, Amritansh Raghav > wrote: > >can it be done? > >i looked at the operator documentation under Python Runtime Services - but > >didnt find anything to suggest it could be done. > > Yes, define __cmp__ or __rcmp__. See 3.3.1 in the language reference. > if you look at the release notes for Python 2.1, they've also added the following functions: Operation Method name < __lt__ <= __le__ > __gt__ >= __ge__ == __eq__ != __ne__ (http://www.amk.ca/python/2.1/index.html#SECTION000400000000000000000) Sent via Deja.com http://www.deja.com/ From dbrueck at edgix.com Thu Feb 1 20:26:11 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Thu, 1 Feb 2001 12:26:11 -0700 Subject: overloading == In-Reply-To: Message-ID: Add a __cmp__ method to your class: def __cmp__(self, obj): # return 0, a negative, or a positive number (you can also define __rcmp__ to handle cases where the object on the left side of the conversion doesn't have a cmp method) Note that if you define __cmp__ but not a __hash__ then your objects can't act as dictionary keys (which is correct if they are mutable). -Dave > [mailto:python-list-admin at python.org]On Behalf Of Amritansh Raghav > > can it be done? > i looked at the operator documentation under Python Runtime Services - but > didnt find anything to suggest it could be done. From nas at arctrix.com Fri Feb 2 04:19:42 2001 From: nas at arctrix.com (Neil Schemenauer) Date: Thu, 1 Feb 2001 19:19:42 -0800 Subject: overloading == In-Reply-To: ; from dbrueck@edgix.com on Thu, Feb 01, 2001 at 12:26:11PM -0700 References: Message-ID: <20010201191942.A27454@glacier.fnational.com> On Thu, Feb 01, 2001 at 12:26:11PM -0700, Dave Brueck wrote: > (you can also define __rcmp__ to handle cases where the object on the left > side of the conversion doesn't have a cmp method) Its a lot more complicated that that. Python 2.1 will never call __rcmp__. Versions of Python older than 2.1 will need __rcmp__ only in some rare cases (that I can't remember at the moment). Just define __cmp__ and forget about __rcmp__. Neil From drewpc at my-deja.com Thu Feb 1 21:56:54 2001 From: drewpc at my-deja.com (drewpc at my-deja.com) Date: Thu, 01 Feb 2001 20:56:54 GMT Subject: overloading == References: Message-ID: <95ciif$bl8$1@nnrp1.deja.com> In article , "Amritansh Raghav" wrote: > can it be done? > i looked at the operator documentation under Python Runtime Services - but > didnt find anything to suggest it could be done. > > It's better in Python 2.1. Checkout the following URL: http://www.amk.ca/python/2.1/index.html#SECTION000400000000000000000 Sent via Deja.com http://www.deja.com/ From mike at skyweb.ca Thu Feb 1 03:22:47 2001 From: mike at skyweb.ca (mike) Date: Wed, 31 Jan 2001 20:22:47 -0600 Subject: serial port Message-ID: <3a78ca89_2@skyweb.ca> is there any modules for serial port communication? From news at dorb.com Thu Feb 1 04:06:51 2001 From: news at dorb.com (Darrell) Date: Thu, 01 Feb 2001 03:06:51 GMT Subject: serial port References: <3a78ca89_2@skyweb.ca> Message-ID: For windows check this out. win32comport_demo.py --Darrell "mike" wrote in message news:3a78ca89_2 at skyweb.ca... > is there any modules for serial port communication? > > From grante at visi.com Fri Feb 9 20:34:15 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 09 Feb 2001 19:34:15 GMT Subject: serial port References: <3a78ca89_2@skyweb.ca> Message-ID: In article , Darrell wrote: >> is there any modules for serial port communication? >For windows check this out. win32comport_demo.py For Posix, you can have a whack at ftp://ftp.visi.com/users/grante/python/PosixSerial.py There aren't any docs, but an example Python/GTK app that uses the above module: ftp://ftp.visi.com/users/grante/python/lcom.py -- Grant Edwards grante Yow! Did YOU find a at DIGITAL WATCH in YOUR box visi.com of VELVEETA? From peter at engcorp.com Thu Feb 1 04:56:50 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 31 Jan 2001 22:56:50 -0500 Subject: serial port References: <3a78ca89_2@skyweb.ca> Message-ID: <3A78DE82.1EE39E06@engcorp.com> mike wrote: > > is there any modules for serial port communication? Yes. No. Depends on the platform. Are you running on Windows? Linux? Elsewhere? From embed at geocities.com Mon Feb 19 22:29:40 2001 From: embed at geocities.com (Warren Postma) Date: Mon, 19 Feb 2001 16:29:40 -0500 Subject: serial port References: <3a78ca89_2@skyweb.ca> <3A78DE82.1EE39E06@engcorp.com> Message-ID: <%fgk6.99$TW.1009@tor-nn1.netcom.ca> "Peter Hansen" wrote in message news:3A78DE82.1EE39E06 at engcorp.com... > mike wrote: > > > > is there any modules for serial port communication? > > Yes. No. Depends on the platform. Are you running > on Windows? Linux? Elsewhere? This seems a darn shame. I think a single portable API should be developed. One that will enumerate the serial devices, query their speed-range abilities, and so on, so that a single source can handle unix /dev/xxx semantics, Dos/Windows style "COMx:" labels, etcetera. I have already written one for win32, which I think is quite nice, and which doesn't do anything that can't be done on all platforms. (No overlapped IO support on Win32 for instance.) Somebody better do something or else.... or else.... or else I will do it myself, gosh darn it! ;-) Warren From grante at visi.com Tue Feb 20 04:16:59 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 20 Feb 2001 03:16:59 GMT Subject: serial port References: <3a78ca89_2@skyweb.ca> Message-ID: In article <3a78ca89_2 at skyweb.ca>, mike wrote: >is there any modules for serial port communication? Yes. There is (or was) a Win32 module called Sio, but I can't seem to find it at www.python.org. There used to be a well-hidden link somewhere on that website. I wrote a Posix serial I/O class that is still waiting to be documented ftp://ftp.visi.com/users/grante/python/PosixSerial.py -- Grant Edwards grante Yow! .. or were you at driving the PONTIAC that visi.com HONKED at me in MIAMI last Tuesday? From fuess at att.net Wed Feb 21 05:59:52 2001 From: fuess at att.net (David Fuess) Date: Wed, 21 Feb 2001 04:59:52 GMT Subject: serial port References: <3a78ca89_2@skyweb.ca> Message-ID: <1mi69ts78koo7oavqh4htfs9ku5u54uqij@4ax.com> You might want to check out Roger Burnham's SioModule available at http://starship.python.net/crew/roger/. It is a complete Serial class for Python. According to Hammond's "Python Programming on Win32" p373, it is the "preferred route for serial I/O with Python" Dave On Tue, 20 Feb 2001 03:16:59 GMT, grante at visi.com (Grant Edwards) wrote: >In article <3a78ca89_2 at skyweb.ca>, mike wrote: > >>is there any modules for serial port communication? > >Yes. There is (or was) a Win32 module called Sio, but I can't seem to find >it at www.python.org. There used to be a well-hidden link somewhere on that >website. > >I wrote a Posix serial I/O class that is still waiting to be documented > > ftp://ftp.visi.com/users/grante/python/PosixSerial.py From MarkH at ActiveState.com Wed Feb 21 23:41:42 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 21 Feb 2001 22:41:42 GMT Subject: serial port References: <3a78ca89_2@skyweb.ca> <1mi69ts78koo7oavqh4htfs9ku5u54uqij@4ax.com> Message-ID: <3A94434D.6020800@ActiveState.com> David Fuess wrote: > You might want to check out Roger Burnham's SioModule available at > http://starship.python.net/crew/roger/. It is a complete Serial class > for Python. According to Hammond's "Python Programming on Win32" p373, > it is the "preferred route for serial I/O with Python" Note that the second edition is likely to point out that the win32file module has "native" serial port access available, and doesnt rely on a 3rd party DLL ;-) Mark. -- Nominate Your Favorite Programmers for the Perl and Python Active Awards! http://www.ActiveState.com/Awards/ From fuess at att.net Thu Feb 22 02:04:39 2001 From: fuess at att.net (David Fuess) Date: Thu, 22 Feb 2001 01:04:39 GMT Subject: serial port References: <3a78ca89_2@skyweb.ca> <1mi69ts78koo7oavqh4htfs9ku5u54uqij@4ax.com> <3A94434D.6020800@ActiveState.com> Message-ID: Wow, nothing like getting it from the horse's mouth, so to speak! Any chance of an update on that chapter for us owners of well worn first editions? BTW, I checked out the SioModule class further and found that it only works with Python 1.5.2. I was rather disappointed that I was unable to use it with my ActivePython 2.0! Do you have a work around Mark? Thanks for PP on Win32, keep up the great work Dave On Wed, 21 Feb 2001 22:41:42 GMT, Mark Hammond wrote: >David Fuess wrote: > >> You might want to check out Roger Burnham's SioModule available at >> http://starship.python.net/crew/roger/. It is a complete Serial class >> for Python. According to Hammond's "Python Programming on Win32" p373, >> it is the "preferred route for serial I/O with Python" > >Note that the second edition is likely to point out that the win32file module has "native" serial port access available, and doesnt rely on a 3rd party DLL ;-) > >Mark. From MarkH at ActiveState.com Thu Feb 22 07:07:16 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 22 Feb 2001 06:07:16 GMT Subject: serial port References: <3a78ca89_2@skyweb.ca> <1mi69ts78koo7oavqh4htfs9ku5u54uqij@4ax.com> <3A94434D.6020800@ActiveState.com> Message-ID: <3A94ABBF.8040509@ActiveState.com> David Fuess wrote: > Wow, nothing like getting it from the horse's mouth, so to speak! Any > chance of an update on that chapter for us owners of well worn first > editions? Not for a little while :) There is no second edition in the works ATM! Check out the win32comport_demo.py file - that is about all I would cover :) > BTW, I checked out the SioModule class further and found that it only > works with Python 1.5.2. I was rather disappointed that I was unable > to use it with my ActivePython 2.0! Do you have a work around Mark? Hrm. There is a version for Python 2.0, but I can't find it. It has been mentioned here a few times, so check google. Mark. From knotwell at ix.netcom.com Thu Feb 1 04:50:07 2001 From: knotwell at ix.netcom.com (Brad Knotwell) Date: 31 Jan 2001 19:50:07 -0800 Subject: question on threading.py Message-ID: <86k87brrio.fsf@localhost.my.domain> Hello all-- Do the _Condition methods notify and wait really need to call currentThread? Unless currentThread has some side-effect I couldn't see I think these methods don't have any reason to call them. Lines 182 and 215 of v2.0 threading.py. --Brad From loewis at informatik.hu-berlin.de Fri Feb 2 22:42:15 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Feb 2001 22:42:15 +0100 Subject: question on threading.py References: <86k87brrio.fsf@localhost.my.domain> Message-ID: Brad Knotwell writes: > Do the _Condition methods notify and wait really need to call > currentThread? Unless currentThread has some side-effect I couldn't > see I think these methods don't have any reason to call them. I agree. Want to submit a patch to sourceforge.net/projects/python? Regards, Martin From bill at janssen.org Thu Feb 1 05:24:48 2001 From: bill at janssen.org (Bill Janssen) Date: Wed, 31 Jan 2001 20:24:48 PST Subject: Palm extensions for PIL available Message-ID: <01Jan31.202456pst."3448"@watson.parc.xerox.com> Fredrik, I've completed some work on extending PIL 1.1.1 to support raw Palm image quantization and output. You can find a gzipped tar file containing a patch and a new ImagePlugin at ftp://ftp.parc.xerox.com/transient/janssen/PILpalm.tgz. The README in that file explains how to apply the support to a vanilla PIL 1.1.1 source distribution. The most interesting thing to you, I think, is the extension of the quantize method, via a new keyword, to support quantizing the colors of an image to a specified palette. That palette is specified by passing an image containing the desired palette. There were a number of ways to add this functionality; this seemed to be the approach that involved the minimal change to PIL. If you'd like to discuss any philosophical or technical issues about how I've done this, I'd be happy to do so. I'd appreciate it if this got into the next release of PIL; of course your release schedule is your own. Regards, Bill From DSHIN at nc.rr.com Thu Feb 1 06:43:33 2001 From: DSHIN at nc.rr.com (Daehyok Shin) Date: Thu, 01 Feb 2001 05:43:33 GMT Subject: [Q] ftplib: How to compare date? Message-ID: <9I6e6.7505$p8.1228772@typhoon.southeast.rr.com> I like to compare the creation dates of two files using ftplib. But, I cannot find any function to get the date of remote files. How can I do it? -- Daehyok Shin (Peter) From clgonsal at keeshah.penguinpowered.com Thu Feb 1 08:27:02 2001 From: clgonsal at keeshah.penguinpowered.com (C.Laurence Gonsalves) Date: Thu, 01 Feb 2001 07:27:02 GMT Subject: [Q] ftplib: How to compare date? References: <9I6e6.7505$p8.1228772@typhoon.southeast.rr.com> Message-ID: On Thu, 01 Feb 2001 05:43:33 GMT, Daehyok Shin wrote: >I like to compare the creation dates of two files using ftplib. >But, I cannot find any function to get the date of remote files. >How can I do it? I don't think there's any way to do this reliably. You can try and get a list of the directory, but different FTP servers will return the listing in different formats. If you only want it to work on known FTP servers, you can parse the format yourself though (string.split and time.strptime would probably come in handy at this point). Also, if you want to compare the time stamps of files on the local system with the time stamps of files on a remote FTP server, be aware that the clocks probably aren't in sync, and might not even be in the same time zone. -- C. Laurence Gonsalves "Any sufficiently advanced clgonsal at kami.com technology is indistinguishable http://cryogen.com/clgonsal/ from magic." -- Arthur C. Clarke From bsb at winnegan.de Thu Feb 1 22:49:33 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 01 Feb 2001 22:49:33 +0100 Subject: [Q] ftplib: How to compare date? In-Reply-To: <9I6e6.7505$p8.1228772@typhoon.southeast.rr.com> References: <9I6e6.7505$p8.1228772@typhoon.southeast.rr.com> Message-ID: <87ae86nkeq.fsf@winnegan.de> "Daehyok Shin" writes: > I like to compare the creation dates of two files using ftplib. > But, I cannot find any function to get the date of remote files. > How can I do it? Try this: >>> ftp=ftplib.FTP('localhost') >>> print ftp.welcome 220 ProFTPD 1.2.0pre10 Server (Debian) [keuner.winnegan.de] >>> welcome=ftp.login('me','xyzzy') >>> ftp.sendcmd('MDTM /etc/passwd') '213 20010131081337' AFAIK, ftp servers return UTC. HTH Siggy From DSHIN at nc.rr.com Fri Feb 2 07:00:43 2001 From: DSHIN at nc.rr.com (Daehyok Shin) Date: Fri, 02 Feb 2001 06:00:43 GMT Subject: [Q] ftplib: How to compare date? References: <9I6e6.7505$p8.1228772@typhoon.southeast.rr.com> Message-ID: What I want is not the local time of systems, but the creation time of files. "Siggy Brentrup" wrote in message news:mailman.981067505.10896.python-list at python.org... > "Daehyok Shin" writes: > > > I like to compare the creation dates of two files using ftplib. > > But, I cannot find any function to get the date of remote files. > > How can I do it? > > Try this: > > >>> ftp=ftplib.FTP('localhost') > >>> print ftp.welcome > 220 ProFTPD 1.2.0pre10 Server (Debian) [keuner.winnegan.de] > >>> welcome=ftp.login('me','xyzzy') > >>> ftp.sendcmd('MDTM /etc/passwd') > '213 20010131081337' > > AFAIK, ftp servers return UTC. > > HTH > Siggy > > > > From shredwheat at mediaone.net Thu Feb 1 09:02:21 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Thu, 01 Feb 2001 08:02:21 GMT Subject: "in" operator for strings Message-ID: with the back and forth going on about the "in" operator and dictionaries, i was thinking it would be nice for the "in" operator to also check for the presence of substrings in a string. for example... >>> "Waldo" in "Ralph Emerson" 0 >>> "Waldo" in "Ralph Waldo Emerson" 1 i find this much more intuitive and graceful than the current syntax i am repeatedly using... >>> "Ralph Emerson".find("Waldo") != -1 0 anyways, it may not stand a snowball's chance. but i'd hope the 'powers that be' could at least take a second to think about it and explain a yea or nea. it's just an idea that came to me. i know i would like it, but there is likely something i'm overlooking. i would think it could have a serious chance of being accepted? From hvrosen at world-online.no Thu Feb 1 10:50:17 2001 From: hvrosen at world-online.no (Henning VON ROSEN) Date: Thu, 1 Feb 2001 10:50:17 +0100 Subject: "in" operator for strings References: Message-ID: <2jae6.119$o3.4587@news.world-online.no> "Pete Shinners" skrev i melding news:hK8e6.141262$y9.26215366 at typhoon.we.rr.com... > with the back and forth going on about the "in" operator and > dictionaries, i was thinking it would be nice for the "in" > operator to also check for the presence of substrings in a > string. for example... > > > >>> "Waldo" in "Ralph Emerson" > 0 > >>> "Waldo" in "Ralph Waldo Emerson" > 1 try this: >>> "Waldo" in "Ralph Waldo Emerson".split() 1 as long as you are looking for a "word" amike via Henning > i find this much more intuitive and graceful than the current > syntax i am repeatedly using... > > >>> "Ralph Emerson".find("Waldo") != -1 > 0 > > > anyways, it may not stand a snowball's chance. but i'd hope > the 'powers that be' could at least take a second to think > about it and explain a yea or nea. > > it's just an idea that came to me. i know i would like it, but > there is likely something i'm overlooking. i would think it > could have a serious chance of being accepted? > > > From mlh at idi.ntnu.no Thu Feb 1 11:36:24 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Thu, 1 Feb 2001 11:36:24 +0100 Subject: "in" operator for strings References: <2jae6.119$o3.4587@news.world-online.no> Message-ID: <95beco$e0u$1@tyfon.itea.ntnu.no> "Henning VON ROSEN" wrote in message news:2jae6.119$o3.4587 at news.world-online.no... > > "Pete Shinners" skrev i melding [...] > > >>> "Waldo" in "Ralph Emerson" > > 0 > > >>> "Waldo" in "Ralph Waldo Emerson" > > 1 > This isn't quite logical... A string works like a sequence of characters, and sequence membership only works on single elements (in this case characters), not subsequences (in this case, substrings). So you could well say "W" in "Ralph Waldo Emerson" (giving a 1), just as in 1 in [1, 2, 3, 4, 5] But you can't do what you ask for, just like you can't write [1, 2] in [1, 2, 3, 4] > try this: > >>> "Waldo" in "Ralph Waldo Emerson".split() > 1 Probably a better idea. And for those of us who can't really get used to calling methods directly on string literals, you *could* write: "Waldo" in split("Ralph Waldo Emerson") It might be old-fashioned, but... So what :-) > > as long as you are looking for a "word" Right. > > amike via Henning Ho - Esperantisto, Cxu? -- Magnus Lie Hetland (magnus at hetland dot org) "Reality is what refuses to disappear when you stop believing in it" -- Philip K. Dick From aleaxit at yahoo.com Thu Feb 1 12:55:32 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 1 Feb 2001 12:55:32 +0100 Subject: "in" operator for strings References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> Message-ID: <95birk0r0d@news1.newsguy.com> "Magnus Lie Hetland" wrote in message news:95beco$e0u$1 at tyfon.itea.ntnu.no... [snip] > This isn't quite logical... A string works like a sequence > of characters, and sequence membership only works on > single elements (in this case characters), not subsequences > (in this case, substrings). Right, and an extension of this is basically what's being asked for (though the original poster may not have thought of this 'obvious' generalization, specialcasing string would surely not be warranted). Unfortunately, for general cases it doesn't scale well -- i.e., now: >>> print [1,2] in [6, 4, [1,2], 7] 1 >>> print [6,4] in [6, 4, [1,2], 7] 0 and having it return 1 in the second case too would be making this 'in' very ambiguous and confusing, alas. Also, of course, this would throw any parallel between "x in y" and "for x in y" out of the windows unless the latter starts looping on all *subsequences* -- eeep!-) > But you can't do what you ask for, just like you can't write > > [1, 2] in [1, 2, 3, 4] Sure you can, it's a well-formed test and returns 0 since [1,2] is not an item in the right-hand operand sequence. > > try this: > > >>> "Waldo" in "Ralph Waldo Emerson".split() > > 1 > > Probably a better idea. Only if you're looking for words, not for any substring, which is at least as frequent. > And for those of us who can't really > get used to calling methods directly on string literals, > you *could* write: > > "Waldo" in split("Ralph Waldo Emerson") > > It might be old-fashioned, but... So what :-) So it doesn't work unless you "from string import *" (horrid idea), "from string import split" (doubtful), or rewrite it using an explicit string.split (probably best, but quite verbose compared to using the split string-method -- and you still have to add an import string to your module, which is rarely needed now that we DO have string methods). For general substring-matching, a class wrapper is not too bad: class subsOf: def __init__(self, seq): self.seq = seq def __contains__(self, subseq): return self.seq.find(subseq) != -1 this only works for strings, as written, AND only to enable such idioms as if 'ald' in subsOf("Waldo"): print 'yep!' but it's not too hard to generalize it to any sequence type (at least if you're content to use elementary algorithms for __contains__!-), implement __getitem__ to allow looping on all subsequences:-), etc. Alex From cjc26 at nospam.cornell.edu Thu Feb 1 15:57:52 2001 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Thu, 01 Feb 2001 14:57:52 GMT Subject: "in" operator for strings References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> <95birk0r0d@news1.newsguy.com> Message-ID: * Alex Martelli menulis: | "Magnus Lie Hetland" wrote in message | news:95beco$e0u$1 at tyfon.itea.ntnu.no... | [snip] | > This isn't quite logical... A string works like a sequence | > of characters, and sequence membership only works on | > single elements (in this case characters), not subsequences | > (in this case, substrings). | | Right, and an extension of this is basically what's being | asked for (though the original poster may not have thought | of this 'obvious' generalization, specialcasing string would | surely not be warranted). Strings seem to be special-cased already; for example, you don't have to type >>> print ''.join(['H','e','l','l','o',',',' ','w','o','r','l','d','!']) if you don't want to . Anyway, I think having 'in' look for substrings, when used with strings, is more useful than its current behavior. Having 'in' look for a single element works well with lists and tuples, but when using strings I think it's more common to search for a substring than to search for a single character. | Unfortunately, for general cases | it doesn't scale well -- i.e., now: | | >>> print [1,2] in [6, 4, [1,2], 7] | 1 | >>> print [6,4] in [6, 4, [1,2], 7] | 0 | | and having it return 1 in the second case too would be making | this 'in' very ambiguous and confusing, alas. Right, but we will never run into this problem with strings, because its elements are always single characters. So there wouldn't be any ambiguity in extending the meaning of 'in' in this case. | Also, of course, this would throw any parallel between | "x in y" and "for x in y" out of the windows unless the | latter starts looping on all *subsequences* -- eeep!-) Again, I don't think this would be a problem if substring 'in' only worked with strings and not all sequences, because I don't think "for x in y", where y is a string, is a common construction. In fact, whenever this pops up in my code, it usually means there's a bug somewhere (i.e. I forgot to do y.split() or something like that). "for x in str" can be useful sometimes, but I think most of the time string methods (or functions from the string module, if you're old-fashioned ;) and indexing are used instead. | [snip] | | For general substring-matching, a class wrapper is not | too bad: | | class subsOf: | def __init__(self, seq): | self.seq = seq | def __contains__(self, subseq): | return self.seq.find(subseq) != -1 | | this only works for strings, as written, AND only to | enable such idioms as | | if 'ald' in subsOf("Waldo"): | print 'yep!' | | but it's not too hard to generalize it to any sequence | type (at least if you're content to use elementary | algorithms for __contains__!-), implement __getitem__ | to allow looping on all subsequences:-), etc. This is probably the best solution, since I'm sure no one will go for yet another change to the language <0.3wink>. -- Cliff Crawford http://www.people.cornell.edu/pages/cjc26/ print "Just another Python hacker" From aleaxit at yahoo.com Fri Feb 2 14:02:14 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 2 Feb 2001 14:02:14 +0100 Subject: "in" operator for strings References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> <95birk0r0d@news1.newsguy.com> Message-ID: <95eb4r0csk@news1.newsguy.com> "Cliff Crawford" wrote in message news:QPee6.1195$o91.132115 at typhoon.nyroc.rr.com... > * Alex Martelli menulis: [snip] > | of this 'obvious' generalization, specialcasing string would > | surely not be warranted). > > Strings seem to be special-cased already; for example, you don't have to > type > > >>> print ''.join(['H','e','l','l','o',',',' ','w','o','r','l','d','!']) > > if you don't want to . Literals have different syntax sugar for various kinds of sequences (tuples, lists, strings, Unicode strings -- that's it, others, such as array.array's, are built without any peculiar syntax sugar). That is vastly different from having one operator, with identical syntax, get completely different semantics for one sequence type (or two?) versus all others; THAT one is a recipe for disaster & confusion. > Anyway, I think having 'in' look for substrings, when used with strings, > is more useful than its current behavior. And maybe, since hardly anybody ever does modulo operations on complex numbers, having '%' mean something utterly different for them wrt any other kind of number would be "more useful" -- and somebody might argue that it's OK, because complex numbers "seem to be special-cased already" (horribly confusing issues of syntax sugar used for literals, with issues of uniformity of operator semantics over various kinds of numbers). And wouldn't it be "more useful" to have "foo"() look for a function NAMED foo and call it, rather than complain about a "call of non-function"? Etc, etc. This way Per^H^H^H madness lies. Building a language out of a collection of "more useful" (the usual euphemism for such unspeakable horrors is "convenient") irregularities, ad hoc "solutions", special cases, and second guessing of coder's intent... ***thanks, but NO, THANKS***. Python's *regularity and simplicity* are its key strengths. Python might perfectly well have decided that strings do not expose a sequence interface, but rather are 'atoms' (one would then explicitly call some suitable method, returning a list or tuple of the string's characters, in those relatively rare occasions where treating this as a sequence is needed). That would have some pluses, and some minuses, breaking roughly even overall IMHO. But if strings are sequences, and I see little prospect for that to change (short of the mythical "Python 3000", and I don't think such a change will in fact happen even then), then having the 'in' operator mean something utterly different for them, than it does for all other sequences, would be nothing short of a disaster (I'd _almost_ rule this out as a possibility, except that we have one historical precedent -- if somebody in the core dev't team feels strongly about it and does a patch, and the BDFL unexpectedly agrees, then a horrid, unmitigated wart CAN be added to Python; it's happened once, and now the team spirit of the core developers turns them into apologists for the wart -- oh well, on past performance we can expect about one such occurrence per decade). for relatively rare occasions where one wants the list or tuple of > Again, I don't think this would be a problem if substring 'in' only > worked with strings and not all sequences, because I don't think > "for x in y", where y is a string, is a common construction. In fact, It's quite frequent in my code (mostly with strings built by struct, or read from binary files, etc, and representing "an array of bytes" rather than "a ``veritable'' string" in some sense). If strings were atomic, I would of course turn them into buffers for such purposes (and buffers should probably be used in many places where now strings are). As strings are sequences, then I expect them to behave just like any other (non-mutable) sequence, and, in particular, to have a loose parallel between 'if x in s' and 'for x in s'. E.g., for any sequences a and b of the same type: def inboth1(a, b): return [x for x in a if x in b] def inboth2(a, b): return [x for x in b if x in a] switching the roles of a and b may affect the ordering and repetitions in the result sequence, but NOT the membership thereof -- a handy and useful axiom (which allows certain refactoring operations to be applied without needing much global context to check their correctness - one of the greatest boons of such axioms, of course). > This is probably the best solution, since I'm sure no one will go for > yet another change to the language <0.3wink>. The language keeps being changed (and there are grumblings whenever that happens, of course). A change to make strings not sequences would probably be too pervasive to consider, breaking zillions of lines of working code. A change to break the uniformity in the behavior of sequences of various types is unfortunately more conceivable, but it would be an very very bad idea if it ever happened. Alex From sholden at holdenweb.com Fri Feb 2 23:21:26 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 2 Feb 2001 17:21:26 -0500 Subject: "in" operator for strings References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> <95birk0r0d@news1.newsguy.com> <95eb4r0csk@news1.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:95eb4r0csk at news1.newsguy.com... > "Cliff Crawford" wrote in message > news:QPee6.1195$o91.132115 at typhoon.nyroc.rr.com... > > * Alex Martelli menulis: > [snip] > > | of this 'obvious' generalization, specialcasing string would > > | surely not be warranted). > > > > Strings seem to be special-cased already; for example, you don't have to > > type > > > > >>> print ''.join(['H','e','l','l','o',',',' ','w','o','r','l','d','!']) > > > > if you don't want to . > The most anomalous thing about strings from my point of view is the lack of a character dataype. So >>> lst = [1, 2, 3] >>> type(lst) >>> type(lst[1]) >>> strng = "123" >>> type(strng) >>> type(strng[1]) I wouldn't seriously argue that we _need_ a character type, but it's certainly anomalous that an element of a sequence is itself a sequence. Just the same, this kind of pragmatism is what keeps Python in the forefront of popularity (in so far as it is). [ ... ] > > This is probably the best solution, since I'm sure no one will go for > > yet another change to the language <0.3wink>. > > The language keeps being changed (and there are grumblings > whenever that happens, of course). A change to make strings > not sequences would probably be too pervasive to consider, > breaking zillions of lines of working code. A change to > break the uniformity in the behavior of sequences of various > types is unfortunately more conceivable, but it would be an > very very bad idea if it ever happened. > Python 2.0 came long enough after 1.5.2, and contained enough improvements, that most users would take whatever pain there was in converting as the price of gaining access to the new features ... all except "print >>," that is, which was and remains an abomination on the syntax of the language worthy of Bill Gates at his worst (he did write code, and I suspect that much of it was awful). Execrescence. Mother of all warts. Martelli shall not be forgotten! But now here we are, less than six months after a major release, looking at tweaks and fiddles and optimizations. It strikes me that the Python community is in danger of falling victim to the "see how much more we can stuff in without breaking backwards compatibility" syndrome. Just because a proposed change doesn't break existing code doesn't necessarily make it a good thing. Subtle changes to the semantics of the language invalidate teaching materials, for example. The situation seemd to me to be better and more rational when we expected Python 3K to be a major break from current traditions. At least this gave the twiddlers and the tweakers some hope, without putting the existing language at risk. There are undoubtledy arguments for many of the 2.1 changes, but I findsome of them unconvincing. Why not keep Python as it is now, and prodce 3K about 998 years early? There's a lot to be said for stability. wishing-i-had-a-bit-more-myself-ly y'rs - steve From chris.gonnerman at usa.net Sat Feb 3 16:57:32 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sat, 3 Feb 2001 09:57:32 -0600 Subject: Gratuitous Change (Was: Re: "in" operator for strings) References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> <95birk0r0d@news1.newsguy.com> <95eb4r0csk@news1.newsguy.com> Message-ID: <006701c08dfa$08ed8c60$a100000a@local> ----- Original Message ----- From: "Steve Holden" Subject: Re: "in" operator for strings [ hack ] > But now here we are, less than six months after a major release, looking at > tweaks and fiddles and optimizations. It strikes me that the Python > community is in danger of falling victim to the "see how much more we can > stuff in without breaking backwards compatibility" syndrome. Just because a > proposed change doesn't break existing code doesn't necessarily make it a > good thing. Subtle changes to the semantics of the language invalidate > teaching materials, for example. > > The situation seemd to me to be better and more rational when we expected > Python 3K to be a major break from current traditions. At least this gave > the twiddlers and the tweakers some hope, without putting the existing > language at risk. There are undoubtledy arguments for many of the 2.1 > changes, but I findsome of them unconvincing. Why not keep Python as it is > now, and prodce 3K about 998 years early? > > There's a lot to be said for stability. DITTO. This is my thought exactly. I don't forsee upgrading to 2.1. I still haven't gotten my main Linux workstation up to 2.0 and frankly haven't missed it much, but I am using 2.0 on my Windows 98 system. The "nested scopes" change (which as I understand it, creates namespaces for each function as it is called) is the only one I have heard about that I like, but frankly it isn't important enough to be worth putting up with all the other changes. If it ain't broken, DON'T FIX IT! From nas at arctrix.com Sat Feb 3 18:47:07 2001 From: nas at arctrix.com (Neil Schemenauer) Date: Sat, 3 Feb 2001 09:47:07 -0800 Subject: Gratuitous Change (Was: Re: "in" operator for strings) In-Reply-To: <006701c08dfa$08ed8c60$a100000a@local>; from chris.gonnerman@usa.net on Sat, Feb 03, 2001 at 09:57:32AM -0600 References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> <95birk0r0d@news1.newsguy.com> <95eb4r0csk@news1.newsguy.com> <006701c08dfa$08ed8c60$a100000a@local> Message-ID: <20010203094706.B30977@glacier.fnational.com> On Sat, Feb 03, 2001 at 09:57:32AM -0600, Chris Gonnerman wrote: > The "nested scopes" change (which as I understand it, creates > namespaces for each function as it is called) is the only one I > have heard about that I like, but frankly it isn't important > enough to be worth putting up with all the other changes. Can you give some examples of changes you have to "put up with"? The only controversial changes in 2.1a2 that I know of are nested scopes, function attributes and weak references. The nested scope changes are the only ones that affect existing code. You have to forgive me if I think your spreading FUD. Neil From chris.gonnerman at usa.net Sun Feb 4 02:11:30 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sat, 3 Feb 2001 19:11:30 -0600 Subject: Gratuitous Change (Was: Re: "in" operator for strings) References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> <95birk0r0d@news1.newsguy.com> <95eb4r0csk@news1.newsguy.com> <006701c08dfa$08ed8c60$a100000a@local> <20010203094706.B30977@glacier.fnational.com> Message-ID: <007701c08e47$696012a0$a100000a@local> ----- Original Message ----- From: "Neil Schemenauer" Subject: Re: Gratuitous Change (Was: Re: "in" operator for strings) > Can you give some examples of changes you have to "put up with"? > The only controversial changes in 2.1a2 that I know of are nested > scopes, function attributes and weak references. The nested > scope changes are the only ones that affect existing code. You > have to forgive me if I think your spreading FUD. Well, that hurts, but I guess I have it coming. FUD is my enemy, let me spread no FUD. My primary complaint is against changes to the language semantics. I am against change in a language in general when the language is already IMHO the finest I've ever worked with. You are probably right, in that these changes in 2.1 are not so bad. On the other hand, I probably won't use them. Heck, I still import string. I'm not against the changes in 2.0, although I don't use most of them; I still have servers running 1.5.2 that would be a pain to upgrade. One thing I see a lot in 2.0 code that is legal but UGLY is: nstr = ''.join((s,t,u,v)) (for instance) but I guess you can write ugly code in any language. My only real complaint is the need to rebuild ALL MY EXTENSIONS every time the version is upgraded. The build process is painless under Linux but a pain under Windows and I must live in both worlds. Even under Linux, I wind up rebuilding a LOT of software because I use a LOT of Python. Yeah, I'm rambling. The point is (yes, I have one) that I think all changes are potentially dangerous. I do respect and trust GvR though, so perhaps I'll try 2.1 when it's not alpha anymore. BTW I've lost track... is 2.1 stackless or was that just a rumor? From tim.one at home.com Sun Feb 4 04:43:24 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Feb 2001 22:43:24 -0500 Subject: Gratuitous Change (Was: Re: "in" operator for strings) In-Reply-To: <007701c08e47$696012a0$a100000a@local> Message-ID: [Chris Gonnerman] > ... > BTW I've lost track... is 2.1 stackless or was that just a rumor? Can't tell you whether it was a rumor (if it was, I had not heard it), but can tell you 2.1 is not stackless. 2.1 is registerless instead. We were getting too many complaints that making Python faster was disturbing carefully tuned Python delay loops . working-on-making-2.2-ignore-ram-and-go-straight-to-disk-ly y'rs - tim From bowman at montana.com Sat Feb 3 20:04:55 2001 From: bowman at montana.com (bowman) Date: Sat, 3 Feb 2001 12:04:55 -0700 Subject: Gratuitous Change (Was: Re: "in" operator for strings) References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> <95birk0r0d@news1.newsguy.com> <95eb4r0csk@news1.newsguy.com> <006701c08dfa$08ed8c60$a100000a@local> Message-ID: Neil Schemenauer wrote in message > > scope changes are the only ones that affect existing code. You > have to forgive me if I think your spreading FUD. language changes that affect existing code have their own way of spreading FUD. I'm not supporting a major software effort in Python at this time, just some relatively simple tools for my own use. However, I've had a few previously working tools fail or report errors since upgrading. This doesn't do a lot to encourage me to undertake a project with a projected lifetime of 10 years or so in Python. OTOH, the actual deliverable apps I am working on at present have already passed the 10 year mark since their original release, have been constantly enhanced and expanded, and ported to several platforms. They are written in C, and not a line of code has had to be changed because of underlying changes in the C language. I believe it is only in the last release of the gnu toolchain that the decision was taken to drop support of the long obsolete K&R declarations. It is this sort of stability that has made C, despite its warts and blemishes, a widely used language. Personally speaking, I am not a conservative, but there is something to be said for conservative principals when dealing with a language. A parallel would be when Java's event model changed -- altogether it was a good idea, but forced one to make the choice of using the new model, or staying with the old, knowing full well that many users were not going to upgrade their jvm's until absolutely necessary. From joconnor at cybermesa.com Sat Feb 3 20:23:14 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Sat, 03 Feb 2001 19:23:14 +0000 Subject: Gratuitous Change (Was: Re: "in" operator for strings) References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> <95birk0r0d@news1.newsguy.com> <95eb4r0csk@news1.newsguy.com> <006701c08dfa$08ed8c60$a100000a@local> Message-ID: <3A7C5AA2.A82C9B66@cybermesa.com> bowman wrote: > > Neil Schemenauer wrote in message > > > > scope changes are the only ones that affect existing code. You > > have to forgive me if I think your spreading FUD. > > language changes that affect existing code have their own way of spreading > FUD. I'm not supporting a major software effort in Python at this time, just > some relatively simple tools for my own use. However, I've had a few > previously working tools fail or report errors since upgrading. This doesn't > do a lot to encourage me to undertake a project with a projected lifetime of > 10 years or so in Python. > > OTOH, the actual deliverable apps I am working on at present have already > passed the 10 year mark since their original release, have been constantly > enhanced and expanded, and ported to several platforms. They are written in > C, and not a line of code has had to be changed because of underlying > changes in the C language. I believe it is only in the last release of the > gnu toolchain that the decision was taken to drop support of the long > obsolete K&R declarations. It is this sort of stability that has made C, > despite its warts and blemishes, a widely used language. > > Personally speaking, I am not a conservative, but there is something to be > said for conservative principals when dealing with a language. A parallel > would be when Java's event model changed -- altogether it was a good idea, > but forced one to make the choice of using the new model, or staying with > the old, knowing full well that many users were not going to upgrade their > jvm's until absolutely necessary. This is because C is a very old language and it's had time to mature and figure out what works and what doesn't. Python (and Java) is still young and maturing and people are still playing with ideas to make it work best. And that can be painful at times. -- Jay O'Connor joconnor at cybermesa.com http://www.cybermesa.com/~joconnor "God himself plays the bass strings first when He tunes the soul" From bowman at montana.com Sun Feb 4 06:40:03 2001 From: bowman at montana.com (bowman) Date: Sat, 3 Feb 2001 22:40:03 -0700 Subject: Gratuitous Change (Was: Re: "in" operator for strings) References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> <95birk0r0d@news1.newsguy.com> <95eb4r0csk@news1.newsguy.com> <006701c08dfa$08ed8c60$a100000a@local> <3A7C5AA2.A82C9B66@cybermesa.com> Message-ID: Jay O'Connor wrote in message > > This is because C is a very old language and it's had time to mature and > figure out what works and what doesn't. Python (and Java) is still > young and maturing and people are still playing with ideas to make it > work best. And that can be painful at times. agreed. Plus, C is a very simple language (not implying it is simple to use). Python, out of the box, offers a higher level of abstraction and more functionality --- and more for people to disagree on. Don't get me wrong, I use Python just for that reason. The thrill of writing yet another linked list wore off about 20 years ago. I guess I just get a little sad watching nice little languages grow up :) From mlh at idi.ntnu.no Fri Feb 2 14:03:41 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Fri, 2 Feb 2001 14:03:41 +0100 Subject: "in" operator for strings References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> <95birk0r0d@news1.newsguy.com> Message-ID: <95ebcv$bn$1@tyfon.itea.ntnu.no> "Alex Martelli" wrote in message news:95birk0r0d at news1.newsguy.com... > "Magnus Lie Hetland" wrote in message > news:95beco$e0u$1 at tyfon.itea.ntnu.no... [...] > Right, and an extension of this is basically what's being > asked for (though the original poster may not have thought > of this 'obvious' generalization, specialcasing string would > surely not be warranted). Unfortunately, for general cases > it doesn't scale well -- i.e., now: Well... Then "in" would test for both membership and subsequenceness... Quite a strong case of ambiguity if you ask me. In my opinion a really *bad* idea. (And would it only allow contiguous subsequences, or any subsequence? If we ever get built-in sets contiguity would be meningless, as would it be if we get "in" tests for dictionaries.) [...] > and having it return 1 in the second case too would be making > this 'in' very ambiguous and confusing, alas. Right. > Also, of course, this would throw any parallel between > "x in y" and "for x in y" out of the windows unless the > latter starts looping on all *subsequences* -- eeep!-) Actually, that sounds very interesting ;-) How about having a power-sequence-function (like the standard power-set function in mathematics)? Then pow(seq) or seq.pow() would return a (perhaps lazy) sequence containing all subsequences... And one could have seq.pow(contiguous=1) if one only wanted contiguous subsequences... Then one would have: >>> "Waldo" in "Ralph Waldo Emerson".pow(contiguous=1) 1 An ingenious implementation of the laziness would be needed I guess... Or maybe not. A simple string-matching algorithm would be needed for the contiguous case, and a O(n*m) exhaustive search for the non-contiguous case. (Or perhaps something better would be possible by putting the elements in a hash table... O(n+m)? Might have quite some overhead, perhaps... Oh, well) > > > But you can't do what you ask for, just like you can't write > > > > [1, 2] in [1, 2, 3, 4] > > Sure you can, it's a well-formed test and returns 0 since > [1,2] is not an item in the right-hand operand sequence. Right. That's essentially what I meant. You can't write the above to find out whether [1, 2] is a subsequence of [1, 2, 3, 4]. > > Probably a better idea. > > Only if you're looking for words, not for any substring, > which is at least as frequent. You are right. But it's a better idea than doing something that doesn't work, at least <0.8 wink> > > "Waldo" in split("Ralph Waldo Emerson") > > > > It might be old-fashioned, but... So what :-) > > So it doesn't work unless you "from string import *" (horrid > idea), "from string import split" (doubtful), or rewrite it > using an explicit string.split (probably best, Why? This would in my opinion clearly depend on the size of the script... If you don't expect another split function to appear, I think it's quite OK to use from string import split I mean -- I'm not against string methods. They're nice. I just get a bit woozy seeing them called on literals. It just gives me flashes of weird stuff like 1.plus(2) And... In my mind methods seem to be for modifying an objects state first of all. Oh, well. Here we go -- another pointless discussion. Sorry :) > For general substring-matching, a class wrapper is not > too bad: [...] > this only works for strings, as written, AND only to > enable such idioms as > > if 'ald' in subsOf("Waldo"): > print 'yep!' I should have read the entire posting before replying, I see. This is the same as my power-sequence idea I guess. > Alex -- Magnus Lie Hetland (magnus at hetland dot org) "Reality is what refuses to disappear when you stop believing in it" -- Philip K. Dick From aleaxit at yahoo.com Fri Feb 2 18:01:54 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 2 Feb 2001 18:01:54 +0100 Subject: "in" operator for strings References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> <95birk0r0d@news1.newsguy.com> <95ebcv$bn$1@tyfon.itea.ntnu.no> Message-ID: <95ep620rbt@news1.newsguy.com> "Magnus Lie Hetland" wrote in message news:95ebcv$bn$1 at tyfon.itea.ntnu.no... [snip] > > asked for (though the original poster may not have thought > > of this 'obvious' generalization, specialcasing string would > > surely not be warranted). Unfortunately, for general cases > > it doesn't scale well -- i.e., now: > > Well... Then "in" would test for both membership and > subsequenceness... Quite a strong case of ambiguity if you > ask me. In my opinion a really *bad* idea. (And would it Right. > only allow contiguous subsequences, or any subsequence? > If we ever get built-in sets contiguity would be meningless, > as would it be if we get "in" tests for dictionaries.) Dictionaries aren't sequences, nor will sets be, so the issue doesn't apply to either. Still, you're right that, *for sequences*, there are TWO definitions of subsequence that are meaningful in different context -- contiguous (aka compact) and generalized. >>> print [1,2,4] in subseqOf(range(7), contiguous=1) 0 >>> print [1,2,4] in subseqOf(range(7), contiguous=0) 1 Implementation of class subseqOf is left as an exercise to the reader:-). Actually, a very simple minded one IS simple to implement -- it's actually simpler having subseqOf be a factory function, and: def subseqOf(seq, contiguous=None): if contiguous: return contSubs(seq) else: return genrSubs(seq) class genrSubs: def __init__(self,seq): self.seq=seq def __contains__(self,subs): start = 0 for x in subs: try: where=self.seq[start:].index(x) except ValueError: return 0 start = where+1 return 1 class contSubs: def __init__(self,seq): self.seq=seq self.len=len(seq) def __contains__(self,subs): slen = len(subs) for i in range(self.len-slen): if self.seq[i:i+slen]==subs: return 1 return 0 or thereabouts (warning, untested code!). (One CAN, of course, do better than this!-). Implementing __getitem__, to enumerate all subsequences (contiguous and non) is also of some interest -- a typical combinatorics problem. Generalized subsequences are a picnic -- thanks to the natural isomorphism with binary numbers in base self.len (I've posted snippets using that to get "all combinations" pretty recently). Contiguous subsequences are more interesting -- we presumably still want to see the empty one just once, so we'll single that out as subsequence number 0 of any sequence, then get to the real business of NON-empty subs. Here, we want of course to count in a _triangular_ way -- for a sequence of len N, we'll have N subsequences that start at 0, N-1 that start at 1, ..., N-x that start at x, etc. So, given a subsequence index X, iterative computation of subseq start and length is easy (again, untested code...): if X==0: #special-case it return self.seq[0:0] X -= 1 start = 0 maxlen = N while start < N: if X < maxlen: return self.seq[start:start+X] X -= maxlen start += 1 maxlen -= 1 raise IndexError but, that's lazy -- surely some closed form exists (but there is no space in the margins of this post for me to write it down...). > > Also, of course, this would throw any parallel between > > "x in y" and "for x in y" out of the windows unless the > > latter starts looping on all *subsequences* -- eeep!-) > > Actually, that sounds very interesting ;-) > > How about having a power-sequence-function (like the standard > power-set function in mathematics)? Then pow(seq) or seq.pow() > would return a (perhaps lazy) sequence containing all > subsequences... And one could have seq.pow(contiguous=1) if > one only wanted contiguous subsequences... Then one would > have: > > >>> "Waldo" in "Ralph Waldo Emerson".pow(contiguous=1) > 1 > > An ingenious implementation of the laziness would be needed > I guess... Or maybe not. Not for the generalized case, unless you count the fact of knowing that subsets of an N-element set, and binary numbers of N bits, have a natural isomorphism, as in some way "ingenious":-). Of course one could cheat in the enumeration for the more interesting contiguous case, since the index being asked for only goes up by 1 at a time in a for loop; but finding a closed-form expression of "N-th contiguous subsequence" sounds much more fun, and it might in fact have some use (e.g., "get a random contiguous subsequence with all contiguous subsequences having equal probability" -- if you can enumerate such subsequences in closed form then that's a solved problem too). > A simple string-matching algorithm > would be needed for the contiguous case, and a O(n*m) > exhaustive search for the non-contiguous case. (Or perhaps > something better would be possible by putting the elements > in a hash table... O(n+m)? Might have quite some overhead, > perhaps... Oh, well) I suspect a modified Bayer-Moore could be very fast and effective for contiguous-subsequence checks -- sublinear just like "real" Bayer-Moore!-) For the non-contiguous case, you could have a map 'alphabet' element -> places where that element is which is just O(N). Now, you walk down the subsequence you're checking, keeping only a counter of "farthest left we could possibly be in the big sequence so far", which you successively increase to the smallest item in "places" that is larger than the current counter -- fail if you ever find an item in the subsequence that is not in the alphabet, or if the restricted 'places' is ever empty -- succeed if you get to the end. This looks a bit worse than O(M) in time, but not by much unless there is a LOT of repetitiousness in the big sequence; with bisection (binary search) over the 'places' sequences, O(M log N) appears like an easy upperbound, and maybe it can be cut down further. Of course, this only makes any sense for REALLY BIG sequences. The factory function could check for that, returning a simpleminded wrapper class for sequences up to some threshold length, and a sophisticated one for longer sequences...!-) > > > "Waldo" in split("Ralph Waldo Emerson") > > > > > > It might be old-fashioned, but... So what :-) > > > > So it doesn't work unless you "from string import *" (horrid > > idea), "from string import split" (doubtful), or rewrite it > > using an explicit string.split (probably best, > > Why? This would in my opinion clearly depend on the size of > the script... If you don't expect another split function to > appear, I think it's quite OK to use > > from string import split In a small module, maybe. Remember the status of local import statements is in doubt... they may be disallowed in Python 2.1 (hopefully they won't be, but, who knows), so it's not clear that you could do this inside a function. "doubtful" seems a fair assessment to me -- there ARE doubts, depending on context; it's not necessarily "quite OK" -- it may or may not be. Why not just use string.split and play it safe...?\ Or, just as safe, the string-method...? > I mean -- I'm not against string methods. They're nice. I > just get a bit woozy seeing them called on literals. It I think we'll all get used to that in time. > just gives me flashes of weird stuff like > > 1.plus(2) > > And... In my mind methods seem to be for modifying an > objects state first of all. Oh, well. Here we go -- another > pointless discussion. Sorry :) Why would mutators be any more worthy of syntax-sugar support than accessors? You've lost me here... Alex From mlh at idi.ntnu.no Sat Feb 3 04:21:20 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Sat, 3 Feb 2001 04:21:20 +0100 Subject: "in" operator for strings References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> <95birk0r0d@news1.newsguy.com> <95ebcv$bn$1@tyfon.itea.ntnu.no> <95ep620rbt@news1.newsguy.com> Message-ID: <95ftl4$o6b$1@tyfon.itea.ntnu.no> "Alex Martelli" wrote in message news:95ep620rbt at news1.newsguy.com... > "Magnus Lie Hetland" wrote in message > news:95ebcv$bn$1 at tyfon.itea.ntnu.no... [...] > > only allow contiguous subsequences, or any subsequence? > > If we ever get built-in sets contiguity would be meningless, > > as would it be if we get "in" tests for dictionaries.) > > Dictionaries aren't sequences, nor will sets be, so the > issue doesn't apply to either. Sure it does. It will then become the question of whether to allow the same operator do check membership and subset-ness. > Implementing __getitem__, to enumerate all > subsequences (contiguous and non) is also > of some interest -- a typical combinatorics > problem. [...] > but, that's lazy -- surely some closed form > exists (but there is no space in the margins > of this post for me to write it down...). [...] > finding a closed-form expression > of "N-th contiguous subsequence" sounds much more fun, > and it might in fact have some use (e.g., "get a random > contiguous subsequence with all contiguous subsequences > having equal probability" -- if you can enumerate such > subsequences in closed form then that's a solved problem > too). Interesting... [...] > I suspect a modified Bayer-Moore (Boyer-Moore) > could be very fast and > effective for contiguous-subsequence checks -- sublinear > just like "real" Bayer-Moore!-) I'm sure :-) What's the built-in string-matching algorithm in Python? (Not very important to me, but...) [...] > with bisection (binary search) over the > 'places' sequences, O(M log N) appears like an easy > upperbound, and maybe it can be cut down further. Well... If you could store an array of size N for each letter you could easily do it in O(1) time... But then you'd need O(M*N) time to initialize the stuff :-) If you add a requirement that the matched letters must be relatively close to each other (within a constant distance limit) you can get a speedup. (A reasonable requirement in some cases.) Actually, I know of some harwdare that does this very quickly. [...] > > I think it's quite OK to use > > > > from string import split > > In a small module, maybe. Remember the status of local > import statements is in doubt... they may be disallowed > in Python 2.1 (hopefully they won't be, but, who knows), > so it's not clear that you could do this inside a function. > "doubtful" seems a fair assessment to me -- there ARE > doubts, depending on context; it's not necessarily "quite > OK" -- it may or may not be. OK... I guess that's one way of interpreting the statement... A rather mild one, IMO :-) To me the module doesn't even have to be small. Just think about all the other function and class names you define in a module... Why should "split" specifically have to have a module prefix? If I choose to import it that may be as thought through as defining a function myself. Only if I have another function called "split" would I feel the need to add its module name. I do the same thing when importing classes in Java, for instance. When I instantiate a JFrame I find it more convenient to write mainFrame = new JFrame(); than mainFrame = new javax.swing.JFrame(); (OK... So I know you dislike the word "convenient". Well... I find it prettier too ;-) > Why not just use string.split and play it safe...?\ > > Or, just as safe, the string-method...? If in some project the other method seems unsafe, I certainly will. > > I mean -- I'm not against string methods. They're nice. I > > just get a bit woozy seeing them called on literals. It > > I think we'll all get used to that in time. I guess I'll have to. But I don't think they are all logical... For instance: " ".join(somesequence) That means 'join the elements of somesequence by " "' On the other hand, [1].extend(somesequence) means 'extend [1] by somesequence' Why not write somesequence.extend([1]) or somesequence.join(" ") (not both, of course) so that they would be consistent with each other? Oh, well. I'm sure it's just that I don't see the Greatness of it all. > Why would mutators be any more worthy of syntax-sugar > support than accessors? You've lost me here... OK. Accessors are fine, but we hardly need those in Python The " ".join([1,2,3]) doesn't seem like an accessor to me. It seems like a plain function with a weird syntax. But, hey, since this is the way it *is*, I'm the one with a problem here :-) > > Alex > -- Magnus Lie Hetland (magnus at hetland dot org) "Reality is what refuses to disappear when you stop believing in it" -- Philip K. Dick From tim.one at home.com Sat Feb 3 05:28:34 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 2 Feb 2001 23:28:34 -0500 Subject: "in" operator for strings In-Reply-To: <95ftl4$o6b$1@tyfon.itea.ntnu.no> Message-ID: [Magnus Lie Hetland] > ... > What's the built-in string-matching algorithm in Python? > (Not very important to me, but...) Brute force, using memcmp. Note that fancier algorithms that require precomputing tables of size proportional to the alphabet cardinality aren't very attractive in a Unicode world. See mxTextTools for a Boyer-Moore 8-bit string searcher. From aleaxit at yahoo.com Sat Feb 3 10:12:20 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 3 Feb 2001 10:12:20 +0100 Subject: "in" operator for strings References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> <95birk0r0d@news1.newsguy.com> <95ebcv$bn$1@tyfon.itea.ntnu.no> <95ep620rbt@news1.newsguy.com> <95ftl4$o6b$1@tyfon.itea.ntnu.no> Message-ID: <95gkgg0fo7@news1.newsguy.com> "Magnus Lie Hetland" wrote in message news:95ftl4$o6b$1 at tyfon.itea.ntnu.no... [snip] > > > only allow contiguous subsequences, or any subsequence? > > > If we ever get built-in sets contiguity would be meningless, > > > as would it be if we get "in" tests for dictionaries.) > > > > Dictionaries aren't sequences, nor will sets be, so the > > issue doesn't apply to either. > > Sure it does. It will then become the question of whether to > allow the same operator do check membership and subset-ness. Subsetness is one thing, subsequencehood another (actually two others, given contiguity may be required or not); the difference is ordering -- 'ab' is a subset but not a subsequence of 'obak'. The whole issue of subsequence is meaningless where no sequence (ordering) exists. > > with bisection (binary search) over the > > 'places' sequences, O(M log N) appears like an easy > > upperbound, and maybe it can be cut down further. > > Well... If you could store an array of size N for each > letter you could easily do it in O(1) time... But then > you'd need O(M*N) time to initialize the stuff :-) You don't know M at initialization time -- it's the size of the subsequence you're going to match (in the normal notation I've seen used), while N is the size of the big sequence in which you're looking for matches. Alphabet size is generally thought of as fixed in most published literature, though I suspect that O(N) is more realistic for generic sequences. You still can't do a match in O(1) time anyway, even with the auxiliary structure you suggest; O(M) seems the lower bound, except by precomputing ALL the possible subsequences and indexing them into some totally hypothetical O(1)-lookup-time structure (but in fact computing the hash IS still O(M), so there is no big-O advantage here). > If you add a requirement that the matched letters must > be relatively close to each other (within a constant > distance limit) you can get a speedup. (A reasonable > requirement in some cases.) Actually, I know of some > harwdare that does this very quickly. I'm curious about the algorithm and its auxiliary data structures here. The O(M) match still seems pretty elusive to me. > To me the module doesn't even have to be small. Just think > about all the other function and class names you define in > a module... Why should "split" specifically have to have > a module prefix? If I choose to import it that may be as > thought through as defining a function myself. Only if I I like the clarity that comes from use of explicit prefixes -- no wondering 'WHAT split function is this one' any more (string or re or ...?). Calling a method of an object, as in 'foo bar'.split(), is clearest -- totally local context, zero wondering-factor. Calling a prefixed function is second best. Calling a non-prefixed function sends me looking for it throughout the non-necessarily-small module -- and I won't find the '^def split' either (so I have to look at the from statements and the assignments -- sigh). > (OK... So I know you dislike the word "convenient". Well... > I find it prettier too ;-) The (modest) convenience of the code author becomes the (rather larger) IN-convenience of the maintainer. When one has spent a few years doing maintenance on large modules written by others, one's priorities tend to change -- as does one's outlook on "prettiness" when it interferes with clarity (the typical C++ scope obscurity due to implicit-this, vs. Python's clarity with explicit self, being a good example). > Why not write somesequence.extend([1]) or > somesequence.join(" ") (not both, of course) so that they would > be consistent with each other? Oh, well. I'm sure it's just > that I don't see the Greatness of it all. I've discussed the "what object should join be a method of" in a couple of lengthy postings 2 or 3 months ago -- it boils down to "where do I get the most leverage for polymorphism", and the current architecture wins hands down. extend is similar -- which object needs the polymorphism most, the one being modified or the sequence just being 'read'? And of course the answer is the same. So, the architecture DOES turn out to be fully consistent here, because exactly the same forces are being resolved! In each case, the subsequence that is just being read (for the purpose of building a string out of it, or for that of extending another object) is the argument -- all the polymorphism we need on it is that it obeys the sequence-protocol, after all. The 'joiner' (aka separator) object, and the object being modified (extended), are in each case the target of the method and get full benefit of polymorphism. > The " ".join([1,2,3]) doesn't seem like an accessor to me. > It seems like a plain function with a weird syntax. > > But, hey, since this is the way it *is*, I'm the one with > a problem here :-) And we're here to help you come to terms with it!-) What I'm doing is asking a 'joiner object' "please read this sequence of strings and join it up into one big string, will you". Function syntax does not give you polymorphism directly in Python - it can at best be syntax sugar for a method call that does do the poly thing: def myJoin(joiner, sequence): return joiner.join(sequence) which is basically what string.join now does. We do not have multimethods in Python (one generic function dispatched directly to the appropriate method), so the main Python approach to polymorphism is calling a method on an object (sometimes with weird syntax sugar, such as a+b for a.__add__(b) or maybe for b.__radd__(a), but that's another issue:-). It only remains to determine which object gets real benefit from a given case of polymorphism. Alex From mlh at idi.ntnu.no Sun Feb 4 15:55:04 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Sun, 4 Feb 2001 15:55:04 +0100 Subject: "in" operator for strings References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> <95birk0r0d@news1.newsguy.com> <95ebcv$bn$1@tyfon.itea.ntnu.no> <95ep620rbt@news1.newsguy.com> <95ftl4$o6b$1@tyfon.itea.ntnu.no> <95gkgg0fo7@news1.newsguy.com> Message-ID: <95jqlu$lcu$1@tyfon.itea.ntnu.no> "Alex Martelli" wrote in message news:95gkgg0fo7 at news1.newsguy.com... > "Magnus Lie Hetland" wrote in message > news:95ftl4$o6b$1 at tyfon.itea.ntnu.no... > [snip] > > > > only allow contiguous subsequences, or any subsequence? > > > > If we ever get built-in sets contiguity would be meningless, > > > > as would it be if we get "in" tests for dictionaries.) > > > > > > Dictionaries aren't sequences, nor will sets be, so the > > > issue doesn't apply to either. > > > > Sure it does. It will then become the question of whether to > > allow the same operator do check membership and subset-ness. > > Subsetness is one thing, subsequencehood another (actually > two others, given contiguity may be required or not); the > difference is ordering -- 'ab' is a subset but not a subsequence > of 'obak'. The whole issue of subsequence is meaningless > where no sequence (ordering) exists. Yes. I am well aware of that, and it seems that I mangled up my original sentence a bit. My *real* point (as illustrated by the examples and exmplanation of characters *in* strings etc.) was the difference between elements and subsets (or substrings, or subsequences). Order is irrelevant here, and the ambiguity is very real. The contiguity is an added problem. As I state above, in sets and dictionaries contiguity would be meaningless, and thus not part of the issue. It would seem to me that you agree on that point? (So why object? ) > I like the clarity that comes from use of explicit prefixes -- > no wondering 'WHAT split function is this one' any more > (string or re or ...?). Calling a method of an object, as in > 'foo bar'.split(), is clearest -- totally local context, zero > wondering-factor. Calling a prefixed function is second > best. Calling a non-prefixed function sends me looking for > it throughout the non-necessarily-small module -- and > I won't find the '^def split' either (so I have to look at the > from statements and the assignments -- sigh). Hm. OK. > > The " ".join([1,2,3]) doesn't seem like an accessor to me. > > It seems like a plain function with a weird syntax. > > > > But, hey, since this is the way it *is*, I'm the one with > > a problem here :-) > > And we're here to help you come to terms with it!-) And I thank you for it :) > Alex -- Magnus Lie Hetland (magnus at hetland dot org) "Reality is what refuses to disappear when you stop believing in it" -- Philip K. Dick From aleaxit at yahoo.com Mon Feb 5 14:28:56 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 5 Feb 2001 14:28:56 +0100 Subject: "in" operator for strings References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> <95birk0r0d@news1.newsguy.com> <95ebcv$bn$1@tyfon.itea.ntnu.no> <95ep620rbt@news1.newsguy.com> <95ftl4$o6b$1@tyfon.itea.ntnu.no> <95gkgg0fo7@news1.newsguy.com> <95jqlu$lcu$1@tyfon.itea.ntnu.no> Message-ID: <95m9qo01emb@news1.newsguy.com> "Magnus Lie Hetland" wrote in message news:95jqlu$lcu$1 at tyfon.itea.ntnu.no... [snip] > the issue. It would seem to me that you agree on that > point? (So why object? ) Because we ARE doing *object*-oriented design & coding here...? When you're dealing with subsets, there are no big problems, because the fact that what you're modeling is order-insensitive means it's OK to inject whatever order you like behind the cover. Call it a canonical order, if you like. The key issue is that it gives you the isomorphism between "subsets of an N-elements alphabet" and "binary numbers in base N", which I used for the non-necessarily-contiguous-subsequences case. Weed out duplicates (at insertion time or on the fly when needed), sort (ditto), and enjoy the utter simplicity we already saw for n-n-c subsequences. ("The secret of life is finding the right isomorphisms", to paraphrase the late C. Schulz -- his original quote was actually "is getting the right side-effects", but they aren't that far if you squint at them just right). Sequences WITH contiguousness constraints (and, probably even more complicated case, with *relaxed* contiguousness constraints, as you hinted at -- "elements following each other at linear distance no more than four", etc) is a far more complicated case -- as are multisets in the non-order case. Heuristics can be found (e.g., if in most cases your multisets have a multiplicity no more than 27 in each given element, you can use base-29 numbers as the primary representation of any multiset, with 28 standing in for "28 or more [rare case]", and get MOST solutions almost as fast as for sets represented as binary numbers), but the general-case is another thing (not only is it hard to look for closed-formula enumerators of such things, but proving "no closed formula exists" is a real bear too). Alex From shredwheat at mediaone.net Sat Feb 3 07:02:25 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Sat, 03 Feb 2001 06:02:25 GMT Subject: "in" operator for strings References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> <95birk0r0d@news1.newsguy.com> <95ebcv$bn$1@tyfon.itea.ntnu.no> <95ep620rbt@news1.newsguy.com> Message-ID: > Well... Then "in" would test for both membership and > subsequenceness... Quite a strong case of ambiguity if you > ask me. In my opinion a really *bad* idea. (And would it hmm, well when posting the idea this was really the only drawback against such a feature. in my mind there is no problem separating strings and lists. the two feature many similar characteristics, but at no point have i ever had the two item types confused. i was pretty sure the idea would get shutdown, but i still feel the functionality would be quite natural and useful. anyways, there's obviously much more than one or two camps of people using python, and python with or without an "in string" operator is still going to be one of my preferred languages :] From luthi at vaw.baug.ethz.ch Thu Feb 1 13:21:48 2001 From: luthi at vaw.baug.ethz.ch (luthi at vaw.baug.ethz.ch) Date: 01 Feb 2001 13:21:48 +0100 Subject: "in" operator for strings References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> Message-ID: "Magnus Lie Hetland" writes: > But you can't do what you ask for, just like you can't write > > [1, 2] in [1, 2, 3, 4] > This is exactly one of my current puzzles: How to can I compare that a set is a subset of another, larger, set efficiently? Say I have to perform such a comparison some 100000 times, it would come in very handy to write (assume all_sets is a list of 100000 sets (i.e. lists)) for set in all_sets: if [1,2,50] in set: do_something any good suggestion? Thanx! -- ============================================================ Dr. Martin L?thi Tel. +41 1 632 41 40 Glaciology Section Fax. +41 1 632 11 92 VAW ETH Zuerich CH-8092 Zuerich mail luthi at vaw.baug.ethz.ch Switzerland ============================================================ From soerense at verwaltung.uni-mainz.de Thu Feb 1 16:01:47 2001 From: soerense at verwaltung.uni-mainz.de (Ruediger Soerensen) Date: 01 Feb 2001 16:01:47 +0100 Subject: "in" operator for strings References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> Message-ID: >This is exactly one of my current puzzles: How to can I compare that a set is >a subset of another, larger, set efficiently? Say I have to perform such a >comparison some 100000 times, it would come in very handy to write > >(assume all_sets is a list of 100000 sets (i.e. lists)) > >for set in all_sets: > if [1,2,50] in set: > do_something > >any good suggestion? What about this: def inset(subset,set): for u in subset: if not u in set: return 0 return 1 print inset([1,3],[1,2,3,4]) print inset([1,8],[1,2,3,4]) -- R?diger "Black Hole" S?rensen || soerense at verwaltung.uni-mainz.de From aleaxit at yahoo.com Thu Feb 1 16:26:43 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 1 Feb 2001 16:26:43 +0100 Subject: "in" operator for strings References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> Message-ID: <95bvqt0141@news1.newsguy.com> wrote in message news:yfmwvbad25f.fsf at collet.i-did-not-set--mail-host-address--so-shoot-me... > "Magnus Lie Hetland" writes: > > > But you can't do what you ask for, just like you can't write > > > > [1, 2] in [1, 2, 3, 4] > > This is exactly one of my current puzzles: How to can I compare that a set is > a subset of another, larger, set efficiently? Say I have to perform such a Are you actually dealing with sets, and subsets, or lists, lists of lists, or maybe lists of sets? > comparison some 100000 times, it would come in very handy to write > > (assume all_sets is a list of 100000 sets (i.e. lists)) > > for set in all_sets: > if [1,2,50] in set: > do_something > > any good suggestion? If you need map your sets as lists, then you aren't going to get substantially better behavior than by: def is_subset(small_set, big_set): for item in small_set: if item not in big_set: return 0 return 1 That's gonna be SLOW -- but that depends on the representation you've chosen for sets. At the other extreme, if your sets were represented as bit-vectors (feasible iff their items are or can be efficiently mapped to small integers), then you might get VERY good performance. I've had occasion to use the GMP bit-oriented functions (which gmpy exposes) for that -- sets of integers in a reasonably compact range such as [0,1024), with each set being a '1024-bits vector' (just 128 bytes); what gmpy exposes could quite easily be wrapped up for such purposes (right now it's somewhat un-handy because, sigh, "numbers are immutable" has BIG performance implications for numbers used as bit-vectors...!). If it's unfeasible to map your sets' items to a reasonably compact range of integers, and so a bit-vector approach is out, then dictionaries are probably your best bet (although, depending on exact usage patterns, the Standard C++ Library approach of sets-as-red-black-trees will have occasional wins in the performance arena, too). Wrapping your dictionary into a class, so you can have the latter implement __contains__ etc and get nice syntax sugar, is not too hard (but nice syntax sugar is rarely the key issue when one is dealing with hundreds of thousands of sets -- survivable performance tends to be higher-priority in such cases:-). The subset-test approach doesn't change much with a dict implementation, though -- it's just that each membership test it uses is a bit faster. Alex From fredrik at effbot.org Sat Feb 3 10:06:50 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Sat, 03 Feb 2001 09:06:50 GMT Subject: "in" operator for strings References: Message-ID: Tim Peters wrote: > See mxTextTools for a Boyer-Moore 8-bit string searcher. or use re.compile/pattern.search for a Knuth-Morris-Pratt style 8-bit/16-bit string searcher... Cheers /F From m.faassen at vet.uu.nl Wed Feb 7 15:40:35 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 7 Feb 2001 14:40:35 GMT Subject: "in" operator for strings References: Message-ID: <95rmp3$k1s$2@newshost.accu.uu.nl> Pete Shinners wrote: > with the back and forth going on about the "in" operator and > dictionaries, i was thinking it would be nice for the "in" > operator to also check for the presence of substrings in a > string. for example... >>>> "Waldo" in "Ralph Emerson" > 0 >>>> "Waldo" in "Ralph Waldo Emerson" > 1 'in' already has a meaning for strings, which are sequences of characters: >>> 'f' in 'foo' 1 >>> 'b' in 'foo' 0 > i find this much more intuitive and graceful than the current > syntax i am repeatedly using... >>>> "Ralph Emerson".find("Waldo") != -1 > 0 Why I agree that this looks a bit odd, it isn't that terrible. I'll just dump my stance on 'in' here: Let's not overload 'in' more than it is now. 'in' is already overloaded; there's the for .. in.. meaning and the x in sequence meaning. Now at least these both have to do with sequences. They're not about dicts and they don't have anything to do with string matching. I think it's not a good idea to overload this meaning any further. It's okay if a custom class has an explicit override __in__, though I'd expect this class then to implement some form of the sequence interface overall. I don't think all operators have to do something sensible for everything; in the case of 'in' we obviously cannot even agree on what 'sensible' is. 'in' currently does 'something mumble mumble' with items in sequences. Not a very clear definition perhaps, but let's not muddy the waters further either. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From gbell at uclink.berkeley.edu Thu Feb 1 09:07:50 2001 From: gbell at uclink.berkeley.edu (gbell at uclink.berkeley.edu) Date: Thu, 01 Feb 2001 08:07:50 GMT Subject: IDLE & Gadfly frustration Message-ID: <95b5gk$2gi$1@nnrp1.deja.com> Two newbie questions: 1) I'm trying to write a script which creates, then makes use of, a Gadfly database to be stored in my Python20 directory. When I run the script from the (MS-DOS) command line, all is well. When I run the script using IDLE, the Gadfly data files are created in my TOOLS/IDLE directory. IDLE seems to have its own ideas about my preferred default directory. Is there any way to change this? 2) A related frustration: could someone tell me the proper syntax for specifying directory paths in Python (or perhaps I'm asking for the proper Gadfly syntax)? The Gadfly documentation says: connection.startup("mydatabase", "mydirectory") So far, I've only had luck setting the second variable to "" (perhaps because of the problem mentioned in #1). Should "mydirectory" begin with c:? Use double backward slashes? forward slashes? Many, many thanks. Gregory Bell gbell at uclink.berkeley.edu Sent via Deja.com http://www.deja.com/ From gregj at pobox.com Thu Feb 1 10:07:17 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Thu, 01 Feb 2001 09:07:17 GMT Subject: IDLE & Gadfly frustration References: <95b5gk$2gi$1@nnrp1.deja.com> Message-ID: <95b902$613$1@nnrp1.deja.com> The directory you give to gadfly must exist. You can create a new directory like this: import os os.mkdir(r"c:\mydirectory") The r"..." string literal is a raw string; this prevents Python from interpreting the backslashes as escapes. You can also do this: os.mkdir("c:\\mydirectory") To create a new database from gadfly, after you have created the folder: from gadfly import gadfly cx = gadfly() cx.startup("databasename", r"c:\mydirectory") etc. Hope this helps. -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com In article <95b5gk$2gi$1 at nnrp1.deja.com>, gbell at uclink.berkeley.edu wrote: > Two newbie questions: > > 1) I'm trying to write a script which creates, then makes use of, a > Gadfly database to be stored in my Python20 directory. When I run the > script from the (MS-DOS) command line, all is well. When I run the > script using IDLE, the Gadfly data files are created in my TOOLS/IDLE > directory. IDLE seems to have its own ideas about my preferred default > directory. Is there any way to change this? > > 2) A related frustration: could someone tell me the proper syntax for > specifying directory paths in Python (or perhaps I'm asking for the > proper Gadfly syntax)? The Gadfly documentation says: > connection.startup("mydatabase", "mydirectory") > So far, I've only had luck setting the second variable to "" (perhaps > because of the problem mentioned in #1). Should "mydirectory" begin > with c:? Use double backward slashes? forward slashes? > > Many, many thanks. > > Gregory Bell > gbell at uclink.berkeley.edu Sent via Deja.com http://www.deja.com/ From gbell at uclink.berkeley.edu Thu Feb 1 16:00:38 2001 From: gbell at uclink.berkeley.edu (gbell at uclink.berkeley.edu) Date: Thu, 01 Feb 2001 15:00:38 GMT Subject: IDLE & Gadfly frustration References: <95b5gk$2gi$1@nnrp1.deja.com> <95b902$613$1@nnrp1.deja.com> Message-ID: <95btmg$mep$1@nnrp1.deja.com> Thank you -- the raw string & os.mkdir features should help me out. But to reiterate my first question, does anyone know why running a script via the ctrl-f5 function in IDLE (as opposed to the command line) should affect the default directory where gadfly places data files? This is true when I set the "mydirectory" value (see original question) to an empty string. It seems that IDLE alters the default path. Am I right, and can I prevent this? In article <95b902$613$1 at nnrp1.deja.com>, Greg Jorgensen wrote: > The directory you give to gadfly must exist. You can create a new > directory like this: > > import os > os.mkdir(r"c:\mydirectory") > > The r"..." string literal is a raw string; this prevents Python from > interpreting the backslashes as escapes. You can also do this: > > os.mkdir("c:\\mydirectory") > > To create a new database from gadfly, after you have created the folder: > > from gadfly import gadfly > cx = gadfly() > cx.startup("databasename", r"c:\mydirectory") > > etc. > > Hope this helps. > > -- > Greg Jorgensen > Portland, Oregon, USA > gregj at pobox.com > > In article <95b5gk$2gi$1 at nnrp1.deja.com>, > gbell at uclink.berkeley.edu wrote: > > Two newbie questions: > > > > 1) I'm trying to write a script which creates, then makes use of, a > > Gadfly database to be stored in my Python20 directory. When I run the > > script from the (MS-DOS) command line, all is well. When I run the > > script using IDLE, the Gadfly data files are created in my TOOLS/IDLE > > directory. IDLE seems to have its own ideas about my preferred > default > > directory. Is there any way to change this? > > > > 2) A related frustration: could someone tell me the proper syntax for > > specifying directory paths in Python (or perhaps I'm asking for the > > proper Gadfly syntax)? The Gadfly documentation says: > > connection.startup("mydatabase", "mydirectory") > > So far, I've only had luck setting the second variable to "" (perhaps > > because of the problem mentioned in #1). Should "mydirectory" begin > > with c:? Use double backward slashes? forward slashes? > > > > Many, many thanks. > > > > Gregory Bell > > gbell at uclink.berkeley.edu > > Sent via Deja.com > http://www.deja.com/ > Sent via Deja.com http://www.deja.com/ From gregj at pobox.com Thu Feb 1 20:52:52 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Thu, 01 Feb 2001 19:52:52 GMT Subject: IDLE & Gadfly frustration References: <95b5gk$2gi$1@nnrp1.deja.com> <95b902$613$1@nnrp1.deja.com> <95btmg$mep$1@nnrp1.deja.com> Message-ID: <95ceqf$7m4$1@nnrp1.deja.com> Python uses the current working directory, as returned by os.getcwd(). The Python interpreter will uses whatever directory it was invoked from (where your DOS session is). IDLE uses the directory IDLE is in. You can use os.chdir(path) to change the current working directory. In article <95btmg$mep$1 at nnrp1.deja.com>, gbell at uclink.berkeley.edu wrote: > Thank you -- the raw string & os.mkdir features should help me out. > > But to reiterate my first question, does anyone know why running a > script via the ctrl-f5 function in IDLE (as opposed to the command > line) should affect the default directory where gadfly places data > files? This is true when I set the "mydirectory" value (see original > question) to an empty string. It seems that IDLE alters the default > path. Am I right, and can I prevent this? -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com Sent via Deja.com http://www.deja.com/ From gbell at uclink.berkeley.edu Thu Feb 1 22:44:32 2001 From: gbell at uclink.berkeley.edu (gbell at uclink.berkeley.edu) Date: Thu, 01 Feb 2001 21:44:32 GMT Subject: IDLE & Gadfly frustration References: <95b5gk$2gi$1@nnrp1.deja.com> <95b902$613$1@nnrp1.deja.com> <95btmg$mep$1@nnrp1.deja.com> <95ceqf$7m4$1@nnrp1.deja.com> Message-ID: <95clbt$ebe$1@nnrp1.deja.com> Many thanks: that should help. In article <95ceqf$7m4$1 at nnrp1.deja.com>, Greg Jorgensen wrote: > Python uses the current working directory, as returned by os.getcwd(). > The Python interpreter will uses whatever directory it was invoked from > (where your DOS session is). IDLE uses the directory IDLE is in. You > can use os.chdir(path) to change the current working directory. > > In article <95btmg$mep$1 at nnrp1.deja.com>, > gbell at uclink.berkeley.edu wrote: > > Thank you -- the raw string & os.mkdir features should help me out. > > > > But to reiterate my first question, does anyone know why running a > > script via the ctrl-f5 function in IDLE (as opposed to the command > > line) should affect the default directory where gadfly places data > > files? This is true when I set the "mydirectory" value (see original > > question) to an empty string. It seems that IDLE alters the default > > path. Am I right, and can I prevent this? > > -- > Greg Jorgensen > Portland, Oregon, USA > gregj at pobox.com > > Sent via Deja.com > http://www.deja.com/ > Sent via Deja.com http://www.deja.com/ From bobhicks at adelphia.net Thu Feb 1 15:45:33 2001 From: bobhicks at adelphia.net (Robert L Hicks) Date: Thu, 01 Feb 2001 14:45:33 GMT Subject: IDLE & Gadfly frustration References: <95b5gk$2gi$1@nnrp1.deja.com> Message-ID: In Python, the forward slash character *can* be used as a separator in file paths in both *NIX and Windows. inp = open("C:/myfiles/mydoc.txt","r") > From: gbell at uclink.berkeley.edu > Organization: Deja.com > Newsgroups: comp.lang.python > Date: Thu, 01 Feb 2001 08:07:50 GMT > Subject: IDLE & Gadfly frustration > > Two newbie questions: > > 1) I'm trying to write a script which creates, then makes use of, a > Gadfly database to be stored in my Python20 directory. When I run the > script from the (MS-DOS) command line, all is well. When I run the > script using IDLE, the Gadfly data files are created in my TOOLS/IDLE > directory. IDLE seems to have its own ideas about my preferred default > directory. Is there any way to change this? > > 2) A related frustration: could someone tell me the proper syntax for > specifying directory paths in Python (or perhaps I'm asking for the > proper Gadfly syntax)? The Gadfly documentation says: > connection.startup("mydatabase", "mydirectory") > So far, I've only had luck setting the second variable to "" (perhaps > because of the problem mentioned in #1). Should "mydirectory" begin > with c:? Use double backward slashes? forward slashes? > > Many, many thanks. > > Gregory Bell > gbell at uclink.berkeley.edu > > > Sent via Deja.com > http://www.deja.com/ From tushar at hursley.ibm.com Thu Feb 1 12:05:24 2001 From: tushar at hursley.ibm.com (Tushar Wagle) Date: Thu, 01 Feb 2001 11:05:24 +0000 Subject: xml install problem - No module named Node Message-ID: <3A7942F4.291E3D6C@hursley.ibm.com> I'm trying to use the new XML library in Python 2.0, but cannot get the examples to work. The error I get when running the iterator1.py example is: File: "iterator1.py", line 5, in ? from xml.dom.Node import Node ImportError: No module named Node which looks like a basic installation error. However, some of the other examples work, and the directories look populated. I looked in /usr/local/lib/python2.0/site-packages/_xmlplus/dom and there is no Node.py file.... I'm running RedHat 6.2, Python 2.0 and PyXML 0.6.3 (I tried the rpm and rebuilding from source with no luck either way). What's wrong? All help appreciated! :) - Tushar. From hgg9140 at cola.ca.boeing.com Thu Feb 1 15:59:17 2001 From: hgg9140 at cola.ca.boeing.com (Harry George) Date: Thu, 1 Feb 2001 14:59:17 GMT Subject: xml install problem - No module named Node References: <3A7942F4.291E3D6C@hursley.ibm.com> Message-ID: I wonder if it was a typo in the example. Seems to me it should read: from xml.dom.minidom import Node or maybe from xml.dom.minidom import * Tushar Wagle writes: > I'm trying to use the new XML library in Python 2.0, but cannot > get the examples to work. > > The error I get when running the iterator1.py example is: > > File: "iterator1.py", line 5, in ? > from xml.dom.Node import Node > ImportError: No module named Node > > which looks like a basic installation error. However, some of the other examples > > work, and the directories look populated. I looked in > /usr/local/lib/python2.0/site-packages/_xmlplus/dom and there is > no Node.py file.... > > I'm running RedHat 6.2, Python 2.0 and PyXML 0.6.3 (I tried the rpm and > rebuilding from source with no luck either way). > > What's wrong? > > All help appreciated! :) > > - Tushar. > > -- 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 kvthan at wm.edu Thu Feb 1 18:24:18 2001 From: kvthan at wm.edu (Kapil Thangavelu) Date: Thu, 01 Feb 2001 17:24:18 GMT Subject: xml install problem - No module named Node References: <3A7942F4.291E3D6C@hursley.ibm.com> Message-ID: <6Zge6.2424$ln1.197197@newsread2.prod.itd.earthlink.net> Tushar Wagle wrote: > I'm trying to use the new XML library in Python 2.0, but cannot > get the examples to work. > > The error I get when running the iterator1.py example is: > > File: "iterator1.py", line 5, in ? > from xml.dom.Node import Node > ImportError: No module named Node > > which looks like a basic installation error. However, some of the other > examples > Node is now defined in __init__.py of xml.dom try instead from xml.dom import Node kapil From tushar at hursley.ibm.com Thu Feb 1 20:04:52 2001 From: tushar at hursley.ibm.com (Tushar Wagle) Date: Thu, 01 Feb 2001 19:04:52 +0000 Subject: xml install problem - No module named Node References: <3A7942F4.291E3D6C@hursley.ibm.com> Message-ID: <3A79B353.69D5E104@hursley.ibm.com> For anyone else wondering about this, the answer's simple: > File: "iterator1.py", line 5, in ? > from xml.dom.Node import Node > ImportError: No module named Node Node is now defined in __init__ of xml.dom try instead from xml.dom import Node Many thanks to Kapil for his reply :) ..And can someone please fix the demo code!... 8) From loewis at informatik.hu-berlin.de Fri Feb 2 22:45:49 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Feb 2001 22:45:49 +0100 Subject: xml install problem - No module named Node References: <3A7942F4.291E3D6C@hursley.ibm.com> <3A79B353.69D5E104@hursley.ibm.com> Message-ID: Tushar Wagle writes: > ..And can someone please fix the demo code!... 8) Fixed. Thanks! Please report further bugs to sourceforge.net/projects/pyxml, though. Regards, Martin From robin at jessikat.fsnet.co.uk Thu Feb 1 12:22:39 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 1 Feb 2001 11:22:39 +0000 Subject: http://www.python.org/pipermail/python-dev/? Message-ID: I get a 404 at the above; has the archive moved? -- Robin Becker From mwh21 at cam.ac.uk Thu Feb 1 13:30:18 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 01 Feb 2001 12:30:18 +0000 Subject: http://www.python.org/pipermail/python-dev/? References: Message-ID: Robin Becker writes: > I get a 404 at the above; has the archive moved? Yes; it's on mail.python.org now. Except both it & www.python.org seem to be down ATM... Cheers, M. -- In case you're not a computer person, I should probably point out that "Real Soon Now" is a technical term meaning "sometime before the heat-death of the universe, maybe". -- Scott Fahlman From sbrunning at bigfoot.com Thu Feb 1 13:47:46 2001 From: sbrunning at bigfoot.com (Simon B.) Date: Thu, 01 Feb 2001 12:47:46 GMT Subject: http://www.python.org/pipermail/python-dev/? References: Message-ID: <95bltg$ff1$1@nnrp1.deja.com> In article , Robin Becker wrote: I get a 404 at , too. I suppose that it must be down. -- Simon Brunning I cheated in the finals of my metaphysics exam. I looked into the soul of the boy sitting next to me. - Woody Allen Sent via Deja.com http://www.deja.com/ From fabrice.n at home.com Thu Feb 1 13:03:58 2001 From: fabrice.n at home.com (shaka) Date: Thu, 01 Feb 2001 12:03:58 GMT Subject: Reply to Remco Gerlich Message-ID: Well I run Java on a special IDE called codewarrior, so if you go on codewarrior(metrowerk company) website, they have a tutorial on java+some assignments to do. But you have to sign up for an account. http://www.codewarrioru.com/CodeWarriorU From spbridge at my-deja.com Thu Feb 1 13:33:08 2001 From: spbridge at my-deja.com (spbridge at my-deja.com) Date: Thu, 01 Feb 2001 12:33:08 GMT Subject: Python, ASP and global.asa Message-ID: <95bl24$ese$1@nnrp1.deja.com> As a relative newcomer to Python, I have to Develop for ASP during a transition to Apache / Linux. My Problem is that Python Scripts in the global.asa always bring an "indentation error" although there is definately none there. Does anyone have any suggestions? Steve Bridge sbridge at workways-gmbh.de Sent via Deja.com http://www.deja.com/ From syver at NOSPAMcyberwatcher.com Fri Feb 2 21:41:37 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Fri, 2 Feb 2001 21:41:37 +0100 Subject: Python, ASP and global.asa References: <95bl24$ese$1@nnrp1.deja.com> Message-ID: <95f66j$h66$1@troll.powertech.no> Hi Steve, I've found a couple of solutions to your problem. It seems that IIS won't tolerate python script in global.asa if the applications scripting language isn't set to python. There are however a way to get python code to execute in global.asa without switching the default language of the application and that is to provide a script block for the default language in global.asa. example global.asa if the default scripting language for the application was Jscript If the default language was VB you'll have to have a Vb script block there instead. So to be safe you'll have to have both. There seems to be no difference in the order the script blocks appear in. wrote in message news:95bl24$ese$1 at nnrp1.deja.com... > As a relative newcomer to Python, I have to > Develop for ASP during a > transition to Apache / Linux. > My Problem is that Python Scripts in the > global.asa always bring an > "indentation error" although there is definately > none there. > Does anyone have any suggestions? > > Steve Bridge > sbridge at workways-gmbh.de > > > Sent via Deja.com > http://www.deja.com/ From jl.berliet at triade.tm.fr Thu Feb 1 14:15:17 2001 From: jl.berliet at triade.tm.fr (Jean-Louis BERLIET) Date: Thu, 1 Feb 2001 14:15:17 +0100 Subject: Quelles sociétés développent en PYTHON en FRANCE Message-ID: <95bno3$483$1@s1.read.news.oleane.net> Pour convaincre des clients de passer ? PYTHON, les arguments techniques seuls ne suffisent pas, il faut ?galement donner des exemples de projets ou de soci?t?s utilisant cette technologie. Il est toujours possible de donner des exemples am?ricains d'utilisation de PYTHON (moteur de recherche GOOGLE, site web YAHOO, infracture e-speak de HP, ...). Mais QU'EN EST-IL EN FRANCE ???? Il serait tr?s int?ressant de faire un point ! En ce qui me concerne, je peux donner un exemple tr?s r?ussi dans le monde bancaire (traitement des ch?ques en euro) ou le choix de PYTHON nous a permis d'?tre moins cher que les concurrents (temps de d?v infinimiment moins importants qu'avec des solutions de type JAVA ou C) et pour notre client de tenir les d?lais ! D'autres t?moignages ????? Jean-Louis BERLIET P.S. : si certains PYTHONISTES sont int?ress?s par une embauche sur LYON, qu'ils me contactent, les projets foisonnent (PYTHON, ZOPE, ...) ! From J.Jonkers at acriter.com Thu Feb 1 14:31:46 2001 From: J.Jonkers at acriter.com (Johan Jonkers) Date: Thu, 01 Feb 2001 14:31:46 +0100 Subject: Quelles =?iso-8859-1?Q?soci=E9t=E9s=20d=E9veloppent?= en PYTHON en FRANCE References: <95bno3$483$1@s1.read.news.oleane.net> Message-ID: <3A796542.C036DCD4@acriter.com> Making postings in a non-English language will probably result in not many people answering. Bad English is usually more understood then French. Johan -- -- Programmers don't die; they just GOSUB with no RETURN -- From fredrik at effbot.org Thu Feb 1 14:44:57 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Thu, 01 Feb 2001 13:44:57 GMT Subject: Quelles sociétés développent en PYTHON en FRANCE References: <95bno3$483$1@s1.read.news.oleane.net> <3A796542.C036DCD4@acriter.com> Message-ID: Johan Jonkers wrote: > Making postings in a non-English language will probably result in not > many people answering. Bad English is usually more understood then > French. Det beror v?l iofs p? m?lgruppen. Jag ?r n?stan helt s?ker p? att franska Python-anv?ndare faktiskt kan l?sa Jean-Louis meddelande ;-) mvh /F PS. f?r dom som kan l?sa mitt meddelande: http://groups.yahoo.com/group/python-se From martin.skott at propylon.com Thu Feb 1 17:10:51 2001 From: martin.skott at propylon.com (Martin Skott) Date: Thu, 01 Feb 2001 16:10:51 GMT Subject: Quelles sociétés développent en PYTHON en FRANCE References: <95bno3$483$1@s1.read.news.oleane.net> <3A796542.C036DCD4@acriter.com> Message-ID: <8znqo13n.fsf@propylon.com> "Fredrik Lundh" writes: > Johan Jonkers wrote: > > Making postings in a non-English language will probably result in not > > many people answering. Bad English is usually more understood then > > French. > > Det beror v?l iofs p? m?lgruppen. Jag ?r n?stan helt s?ker > p? att franska Python-anv?ndare faktiskt kan l?sa Jean-Louis > meddelande ;-) Well I feel both of you are right, but it would be a pain to read groups where you could only understand some of the messages because some elite group are discussing in some language you don't know. The question from the original poster (as far as my two years of French can help me) was basicly: We always hear about Python being used in the US (mentions Google and a few other), but what about France? There was a lot more, but this is the core of the question. I would like to extend this to Europe (or Asia or Anarctica or any other part of the world outside US). Where are people using Python? I can stat by telling that I am Danish, but working with Python in Ireland (in a job I found through this group). -- Martin Skott Software Developer Propylon - Enabling Universal Mobility http://www.propylon.com Tel: +353 096 37245 Mobile: +353 087 9680370 From moshez at zadka.site.co.il Fri Feb 2 01:32:58 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Fri, 2 Feb 2001 02:32:58 +0200 (IST) Subject: Quelles sociétés développent en PYTHON en FRANCE In-Reply-To: <8znqo13n.fsf@propylon.com> References: <8znqo13n.fsf@propylon.com>, <95bno3$483$1@s1.read.news.oleane.net> <3A796542.C036DCD4@acriter.com> Message-ID: <20010202003258.EB777A840@darjeeling.zadka.site.co.il> On Thu, 01 Feb 2001, Martin Skott wrote: > I would like to extend this to Europe (or Asia or Anarctica or any > other part of the world outside US). Where are people using Python? I'm using it in Israel -- and I'm not the only one. There are a couple of Zope-shops here too. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 From J.Jonkers at acriter.com Fri Feb 2 07:37:18 2001 From: J.Jonkers at acriter.com (Johan Jonkers) Date: Fri, 02 Feb 2001 07:37:18 +0100 Subject: Quelles =?iso-8859-1?Q?soci=E9t=E9s=20d=E9veloppent?= en PYTHON en FRANCE References: <95bno3$483$1@s1.read.news.oleane.net> <3A796542.C036DCD4@acriter.com> <8znqo13n.fsf@propylon.com> Message-ID: <3A7A559E.ACD9F54C@acriter.com> Been using Python for like 6 months now here in Holland. Martin Skott wrote: > > "Fredrik Lundh" writes: > > > Johan Jonkers wrote: > > > Making postings in a non-English language will probably result in not > > > many people answering. Bad English is usually more understood then > > > French. > > > > Det beror v?l iofs p? m?lgruppen. Jag ?r n?stan helt s?ker > > p? att franska Python-anv?ndare faktiskt kan l?sa Jean-Louis > > meddelande ;-) > > Well I feel both of you are right, but it would be a pain to read > groups where you could only understand some of the messages because > some elite group are discussing in some language you don't know. > The question from the original poster (as far as my two years of > French can help me) was basicly: > We always hear about Python being used in the US (mentions Google and > a few other), but what about France? There was a lot more, but this > is the core of the question. > I would like to extend this to Europe (or Asia or Anarctica or any > other part of the world outside US). Where are people using Python? > I can stat by telling that I am Danish, but working with Python in > Ireland (in a job I found through this group). > > -- > Martin Skott > Software Developer > Propylon - Enabling Universal Mobility > http://www.propylon.com > Tel: +353 096 37245 > Mobile: +353 087 9680370 -- -- Programmers don't die; they just GOSUB with no RETURN -- From Marc.Poinot at onera.fr Fri Feb 2 09:35:11 2001 From: Marc.Poinot at onera.fr (Marc Poinot) Date: Fri, 02 Feb 2001 09:35:11 +0100 Subject: Quelles =?iso-8859-1?Q?soci=E9t=E9s=20d=E9veloppent?= en PYTHON en FRANCE References: <95bno3$483$1@s1.read.news.oleane.net> <3A796542.C036DCD4@acriter.com> <8znqo13n.fsf@propylon.com> Message-ID: <3A7A713F.A047ECC8@onera.fr> Well... yes, we have computers too here... Then, an extension to computer is operating system (such as VMS). And we also use to put some application software on top os OS (such as Addition-v4.6). And some of the best of us have knowledge in programming (COBOL-32). I've heard about some Xinul (or Nuxil, I can't remember...), a kind of graphical computer-human interface. And finally, yes we have some Python too. But today, there's some snow on Paris, and I guess they are sleeping in a warm place of the Zoo. *** End of joke namespace: We are trying hard to organize here an European meeting for Pythoners. But it's difficult, because there is at least one major Python event in the US every 6 months... Have a look at the non-english page on Python home: http://www.python.org/doc/NonEnglish.html Marcvs [alias Mais sur le Francaise liste tu veux ecrire le Francaise avec aussi] From fernstrom at geocities.com Fri Feb 2 15:19:06 2001 From: fernstrom at geocities.com (christer fernstrom) Date: Fri, 02 Feb 2001 14:19:06 GMT Subject: Quelles sociétés développent en PYTHON en FRANCE References: <95bno3$483$1@s1.read.news.oleane.net> <3A796542.C036DCD4@acriter.com> <8znqo13n.fsf@propylon.com> Message-ID: <95efkh$u2n$1@nnrp1.deja.com> Being a swede in France I had the privilege to understand both the original question and Fredrik's comment. And to answer the question: at Xerox research (XRCE in Grenoble) we do quite a lot of prototyping work in Python. We find it hard to convince Python developers to move to Java, and ususally they're back to Python before long. christer Sent via Deja.com http://www.deja.com/ From jasonic at nomadicsltd.com Sat Feb 3 05:30:28 2001 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Fri, 2 Feb 2001 23:30:28 -0500 Subject: Quelles sociétés développent en PYTHON en FRANCE References: <95bno3$483$1@s1.read.news.oleane.net> <3A796542.C036DCD4@acriter.com> Message-ID: Johan Jonkers wrote in message news:3A796542.C036DCD4 at acriter.com... > Making postings in a non-English language will probably result in not > many people answering. Bad English is usually more understood then > French. Nonsense.. imho this is a narrow point of view. If you are French and want to find French speaking Python programmers it makes perfect sense to post here in you own language. If YOU cannot rad it, then true, you will pass over it. 'more understood' ---by whom? Only those who can read/write French will likely be suitable. The same applies for any language. Thre are so many progammers around the world, for whom English is not therir mother tongue. I am forever impressed a the additioanl obstacles which must be over come.. first to learn english then to learn computer programming. There are many smart people in the world can READ english, especially computer or science-oriented text, but perhaps cannot write or speak it well. There are others who cannot conduct a normal converstation, but can write better englsh than many native speakers. For Asians, there is an even greater set of hurdle to surmount, because writing systems and langauge roots have almost phonetic, structural, sytntactic or etymological connections whatever. For Asians going to UK or USA, it is very expensive, so mostly on the rich and priviledged can afford a extended trip whihc allows them to develop fluent language skills. Ther is a very high awareness and so local english langauge schools are big business [I don't know about Asians visiting Australia but imagine that is more and more attractive option] For example there might be many people right now in Korea or China or Japan reading this newgsgroup who do not find it easy to contribute, even though they may be proficient Python programmers. European languagse are really are very close together. Dutch, Germans and Scandanavians are famously brilliant for fluent and very correct English. This is partly linguistic, since Olde English has inherited much from them, but also cultural. France on the other hand, is notoriously proud/fearful of losing the distinction of language. Thus movies and TV are almsot all dubbed. People lose out because they do not have exposure to even hear english much. Result: catch-22 [attrappement-22] many young people find it much harder to learn, unless they are fortunate enough to travel and stay in English speaking countries, or where there is abundant english use. - Jason From loewis at informatik.hu-berlin.de Fri Feb 2 22:54:19 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Feb 2001 22:54:19 +0100 Subject: Quelles sociétés développent en PYTHON en FRANCE References: <95bno3$483$1@s1.read.news.oleane.net> Message-ID: "Jean-Louis BERLIET" writes: > Pour convaincre des clients de passer ? PYTHON, les arguments > techniques seuls ne suffisent pas, il faut ?galement donner des > exemples de projets ou de soci?t?s utilisant cette technologie. Ich finde, dass B?cher in der jeweiligen Landessprache auch sehr wichtig sind. Menschen lesen nunmal lieber "schwierige" Materie in ihrer Muttersprache, selbst wenn sie Englisch k?nnen. Gibt es eigentlich franz?sische Python-B?cher? Auf http://www.amk.ca/bookstore/non-english.html sind jedenfalls keine aufgef?hrt... Ist irgendjemand an einer ?bersetzung eines deutschen Buchs interessiert :-? Ciao, Martin From hinsen at cnrs-orleans.fr Mon Feb 5 18:05:18 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 05 Feb 2001 18:05:18 +0100 Subject: Quelles sociétés développent en PYTHON en FRANCE References: <95bno3$483$1@s1.read.news.oleane.net> Message-ID: Martin von Loewis writes: > Gibt es eigentlich franz?sische Python-B?cher? Auf Es gibt eine franzoesische Uebersetzung von "Learning Python" und von "Python Pocket Reference". Aber der Markt kann sicher mehr vertragen. Konrad. -- ------------------------------------------------------------------------------- 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 jasonic at nomadicsltd.com Sat Feb 3 05:02:25 2001 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Fri, 2 Feb 2001 23:02:25 -0500 Subject: Quelles sociétés développent en PYTHON en FRANCE References: <95bno3$483$1@s1.read.news.oleane.net> Message-ID: Jean-Louis BERLIET wrote in message news:95bno3$483$1 at s1.read.news.oleane.net... > Pour convaincre des clients de passer ? PYTHON, les arguments techniques > seuls ne suffisent pas, il faut ?galement donner des exemples de projets ou > de soci?t?s utilisant cette technologie. To convince clients to switch to Python, technical arguuments are not enough. One must also provide examples of projects or companies using this technology. > Il est toujours possible de donner des exemples am?ricains d'utilisation de > PYTHON (moteur de recherche GOOGLE, site web YAHOO, infracture e-speak de > HP, ...) It is always possible to give American examples of Python use (Google's search emgine, YAHOO web site, HP's E-Speak infrastructure) > Mais QU'EN EST-IL EN FRANCE ???? But WHERE IS IT IN FRANCE ??? > Il serait tr?s int?ressant de faire un point ! It will be very interesting to make a point ["""idiom - sorry,not sure how to translate this one correctly"""] > En ce qui me concerne, je peux donner un exemple tr?s r?ussi dans le monde > bancaire (traitement des ch?ques en euro) ou le choix de PYTHON nous a > permis d'?tre moins cher que les concurrents (temps de d?v infinimiment > moins importants qu'avec des solutions de type JAVA ou C) et pour notre > client de tenir les d?lais ! As for me, I can give an very successful example in the world of banking (handling checks in EUROS) where the choice of PYTHON allowed us to be cheaper than the competition (develoment time is infinitely less important[significant?] than with JAVA or C solutions) and to reduce dealys for clients > D'autres t?moignages ????? Any other witnesses [testimonials/stories/case studies] > Jean-Louis BERLIET > > P.S. : si certains PYTHONISTES sont int?ress?s par une embauche sur LYON, > qu'ils me contactent, les projets foisonnent (PYTHON, ZOPE, ...) ! P.S. : if any PYHONISTAS are itersted in a gig in LYON contact me. Projects are brewing (PYTHON, ZOPE, ...) hth JASON ___________________________________________________________ Jason CUNLIFFE = NOMADICS['Interactive Art and Technology'] From hinsen at cnrs-orleans.fr Mon Feb 5 18:08:00 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 05 Feb 2001 18:08:00 +0100 Subject: Quelles sociétés développent en PYTHON en FRANCE References: <95bno3$483$1@s1.read.news.oleane.net> Message-ID: "Jean-Louis BERLIET" writes: > Pour convaincre des clients de passer ? PYTHON, les arguments techniques > seuls ne suffisent pas, il faut ?galement donner des exemples de projets ou > de soci?t?s utilisant cette technologie. Bien sur, mais... > Il est toujours possible de donner des exemples am?ricains d'utilisation de > PYTHON (moteur de recherche GOOGLE, site web YAHOO, infracture e-speak de > HP, ...). > > Mais QU'EN EST-IL EN FRANCE ???? Je ne le sais pas non plus, mais je ne vois pas l'interet quand il s'agit d'argumenter pour Python. Enfin, si les americains ont des bonnes experiences, ca compte pour la France aussi, l'informatique n'est pas fondamentalement different des deux cotes de l'Atlantique. Ceci dit, par pure curiosite j'aimerais aussi connaitre la reponse! Konrad. -- ------------------------------------------------------------------------------- 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 vonehr at ira.uka.de Thu Feb 1 14:47:57 2001 From: vonehr at ira.uka.de (Markus von Ehr) Date: Thu, 01 Feb 2001 14:47:57 +0100 Subject: win32com: passing object to threads Message-ID: <3A79690D.563A7248@ira.uka.de> Hi, I play a mp3 File with MediaPlayer using COM like this: (Globals. are my global variables) Globals.ie = win32com.client.dynamic.Dispatch("InternetExplorer.Application") Globals.ie.Navigate(r'about:blank') Globals.doc = Globals.ie.Document Globals.doc.body.insertAdjacentHTML("afterBegin", """ """) Globals.mp = Globals.doc.body.children("MediaPlayer1").object Globals.mp.FileName = "MySoundFile.mp3" In another thread I want to set the New SoundFile: Globals.mp.FileName = "null.wav" and I have the error: Pythoncomerror, (-2147221008, 'CoInitialize hasn't been called', None, None) I know that I have to use the: pythoncom.CoInitialize() and pythoncom.CoUninitialize() in a way, but don't know why. Can anybody help me? Thanks a lot for any answer, Markus From aleaxit at yahoo.com Thu Feb 1 15:55:46 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 1 Feb 2001 15:55:46 +0100 Subject: win32com: passing object to threads References: <3A79690D.563A7248@ira.uka.de> Message-ID: <95btdl016u0@news1.newsguy.com> "Markus von Ehr" wrote in message news:3A79690D.563A7248 at ira.uka.de... [snip] > In another thread I want to set the New SoundFile: > > Globals.mp.FileName = "null.wav" > > and I have the error: > > Pythoncomerror, (-2147221008, 'CoInitialize hasn't been called', None, > None) > > I know that I have to use the: pythoncom.CoInitialize() and > pythoncom.CoUninitialize() in a way, but don't know why. > Can anybody help me? Each thread needs to call CoInitialize for itself -- that's the COM rule. Are you asking the "why" of this COM rule, or the "why" it gets reflected down to your Python code for all threads except the main one? Assuming you accept both of these design decisions as reasonable, the remaining meanings of "why" seem to follow: as you are doing a COM operation from this other thread, the thread needs to be COM-enabled. A thread being "COM enabled" means it having told COM explicitly exactly how it intends to operate within it -- in what "apartment", in COM parlance. This specific "explicit is better than implicit" design decision by the Microsoft COM team answers the first "why": COM refuses to guess exactly HOW a given thread might want to operate with it. As for the second "why", I don't think Python lets a package (e.g. Pythoncom) "hook" some generic function on the event "creation of an arbitrary new thread", so, even if implicitly and magically COM-enabling all threads were a good architecture (and I have my doubts), I don't see how Pythoncom might implement that architecture. Alex From MarkH at ActiveState.com Fri Feb 2 00:21:39 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 01 Feb 2001 23:21:39 GMT Subject: win32com: passing object to threads References: <3A79690D.563A7248@ira.uka.de> Message-ID: <3A79EE92.2000908@ActiveState.com> Markus von Ehr wrote: > I know that I have to use the: pythoncom.CoInitialize() and > pythoncom.CoUninitialize() in a way, but don't know > why. Can anybody help me? COM has different behaviour depending on the COM threading model. This threading model is controlled by CoInitialize/CoInitializeEx(), hence you have to understand the different behaviours and make an appropriaate choice. Just to scare you even more, if you pass objects between different "threading apartments", you have to use the scarily named pythoncom.CoMarshalInterThreadInterfaceInStream() to pass COM objects between threads. The only reasonable documentation on this for Python is "Python Programming on Win32" (by me and Andy, published by OReilly.) However, generic documentation on COM's threading models will also help. Mark. From gmunsey at adobe.com Thu Feb 1 15:46:06 2001 From: gmunsey at adobe.com (Grant Munsey) Date: Thu, 1 Feb 2001 06:46:06 -0800 Subject: Registering LOTS of C level functions Message-ID: I am covering several libraries ... each of which has a couple of thousand calls (don't ask!). I would really like some way to be able to register all of them to Python with one actual C function and an ID so that inside the C function I can generate the actual call by using a data structure that tells the actual functions address and what parameters it requires. As it stands I don't see any way to do this without an excessive amount of trickery. Looks to me like there is no way to specify an extra parameter to the low level registration process for each function ... There is the "self" parameter but that would require me to allocate a Python object for each procedure I wanted to cover. The only thing I can think of at the moment is to generate a bunch of re-direction procedures .... Tiny procedures that just get called from Python, add the ID code ... and then pass on to the "real" command handler. Anyone have any suggestions? From vonehr at ira.uka.de Thu Feb 1 16:17:42 2001 From: vonehr at ira.uka.de (Markus von Ehr) Date: Thu, 01 Feb 2001 16:17:42 +0100 Subject: Registering LOTS of C level functions References: Message-ID: <3A797E16.F89555CB@ira.uka.de> Grant Munsey wrote: > > I am covering several libraries ... each of which has a couple of thousand > calls (don't ask!). > I would really like some way to be able to register all of them to Python > with one actual > C function and an ID so that inside the C function I can generate the actual > call by using > a data structure that tells the actual functions address and what parameters > it requires. > > As it stands I don't see any way to do this without an excessive amount of > trickery. Looks > to me like there is no way to specify an extra parameter to the low level > registration process > for each function ... There is the "self" parameter but that would require > me to allocate a Python > object for each procedure I wanted to cover. > > The only thing I can think of at the moment is to generate a bunch of > re-direction procedures .... > Tiny procedures that just get called from Python, add the ID code ... and > then pass on to the > "real" command handler. > > Anyone have any suggestions? You can use the calldll module by Sam Rushing which can call both __stdcall and __cdecl functions. ftp://squirl.nightmare.com/pub/python/python-ext/ build a dictionary with your function IDs and the function addresses to call them for each lib. Markus From donn at u.washington.edu Thu Feb 1 18:39:05 2001 From: donn at u.washington.edu (Donn Cave) Date: 1 Feb 2001 17:39:05 GMT Subject: Registering LOTS of C level functions References: Message-ID: <95c6vp$gvg$1@nntp6.u.washington.edu> Quoth "Grant Munsey" : | I am covering several libraries ... each of which has a couple of | thousand calls (don't ask!). I would really like some way to be | able to register all of them to Python with one actual C function | and an ID so that inside the C function I can generate the actual | call by using a data structure that tells the actual functions | address and what parameters it requires. I do something like that for BeOS Python API modules, but I code the functions separately as usual and put the argument table data in static storage local to the function. I have only about a thousand functions, spread out over 30 odd modules, but I can't see why it wouldn't work just fine at your scale. (I didn't use a tuple parse format, cf. PyArg_ParseTuple(), because I'm dealing with C++ style function overloading.) The key point is to generate the code automatically. | The only thing I can think of at the moment is to generate a | bunch of re-direction procedures .... Tiny procedures that | just get called from Python, add the ID code ... and then | pass on to the "real" command handler. Well, of course that would work. There may not be a lot of difference, one way or the other, however you do it - it would be interesting to hear about results from trying a couple of approaches. Donn Cave, donn at u.washington.edu From danielk at aracnet.com Thu Feb 1 16:00:57 2001 From: danielk at aracnet.com (Daniel Klein) Date: Thu, 01 Feb 2001 07:00:57 -0800 Subject: popen2 questions Message-ID: The documentation for the 'popen2' module states: """ ... if bufsize is specified, it specifies the buffer size for the I/O pipes... """ however, on Windows, if I set this to anything but '-1', I get Traceback (most recent call last): File "po.py", line 2, in ? fin,fout = popen2.popen2("XTEST",128,'t') File "c:\python20\lib\popen2.py", line 120, in popen2 w, r = os.popen2(cmd, mode, bufsize) ValueError: bufsize must be -1 Is 'bufsize' supported on Windows? What does the '-1' setting change? The bottom line what I'm trying to accomplish is to squeeze any optimizations out of popen2 that I can so I thought to play with the 'bufsize' parameter. I'm running Python 2.0 on Win2k. Advanced thanks, Daniel Klein Portland,OR USA From J.Jonkers at acriter.com Fri Feb 2 07:38:26 2001 From: J.Jonkers at acriter.com (Johan Jonkers) Date: Fri, 02 Feb 2001 07:38:26 +0100 Subject: popen2 questions References: Message-ID: <3A7A55E2.53DC2CFB@acriter.com> -1 probably means that it's not supported. The data will be send directly and not buffered. Anyways, that's what it looks like to me, however I (gladly!) don't use windows :) Johan -- -- Programmers don't die; they just GOSUB with no RETURN -- From danielk at aracnet.com Fri Feb 2 14:53:55 2001 From: danielk at aracnet.com (Daniel Klein) Date: Fri, 02 Feb 2001 05:53:55 -0800 Subject: popen2 questions References: <3A7A55E2.53DC2CFB@acriter.com> Message-ID: On Fri, 02 Feb 2001 07:38:26 +0100, Johan Jonkers wrote: >-1 probably means that it's not supported. The data will be send >directly and not buffered. Anyways, that's what it looks like to me, >however I (gladly!) don't use windows :) Thanks Johan, that's what I suspected. I have to test these kinds of things on _all_ platforms that are required by my users, and that includes Windows. In this industry, it is fatal to make value judgements especially on a product as ubiquitous as Windows. Have a nice day. :^) Daniel Klein Portland, OR USA From ryu-jin at bigfoot.com Thu Feb 1 16:34:43 2001 From: ryu-jin at bigfoot.com (Ryujin) Date: Thu, 01 Feb 2001 15:34:43 GMT Subject: Standalone applications Message-ID: <95c000$8nc$1@ryu.it> Hi, Im trying to understand which is the best way to create a Standalone application in Python. I downloaded Standalone.py from http://starship.python.net/crew/gmcm/distribute.html and it works with python1.5 but the executable must stay in the same directory of the .so files. Then I tried to download Python2C and it generate from a file.py two files: __file.c adn _file.py and then I cant figure out how to compile the file.c Any suggestion??? thx alot Matte -- --------------------------------------- Memelli Matteo Could u imagine a world without Windoz? ryu-jin at bigfoot.com --------------------------------------- From loewis at informatik.hu-berlin.de Fri Feb 2 22:56:23 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Feb 2001 22:56:23 +0100 Subject: Standalone applications References: <95c000$8nc$1@ryu.it> Message-ID: "Ryujin" writes: > Any suggestion??? I personally prefer freeze. It requires a C compiler, but gives you best control and reliability. Plus it allows to create *truly* stand-alone binaries, i.e. binaries that are not even dependent on shared libraries. Regards, Martin From ryu-jin at bigfoot.com Sun Feb 4 14:11:36 2001 From: ryu-jin at bigfoot.com (Ryujin) Date: Sun, 04 Feb 2001 13:11:36 GMT Subject: Standalone applications References: <95c000$8nc$1@ryu.it> Message-ID: <95jept$251$1@ryu.it> In article , Martin von Loewis wrote: As I can read in the Freeze Readme, it is not possible to freeze and ship Tkinter application...did u find any solution to this problem? thx matte > I personally prefer freeze. It requires a C compiler, but gives you best > control and reliability. Plus it allows to create *truly* stand-alone > binaries, i.e. binaries that are not even dependent on shared libraries. > > Regards, Martin -- --------------------------------------- Memelli Matteo Could u imagine a world without Windoz? ryu-jin at bigfoot.com --------------------------------------- From loewis at informatik.hu-berlin.de Fri Feb 9 18:41:47 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 09 Feb 2001 18:41:47 +0100 Subject: Standalone applications References: <95c000$8nc$1@ryu.it> <95jept$251$1@ryu.it> Message-ID: "Ryujin" writes: > As I can read in the Freeze Readme, it is not possible to freeze and ship > Tkinter application...did u find any solution to this problem? I always used Tix' SAM (stand-alone modules) approach. That compiles Tcl and Tk's .tcl files into libraries, which can then be linked into complete binaries. I understand TclPro offers a similar mechanism. Regards, Martin From thomas.heller at ion-tof.com Fri Feb 9 19:27:02 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Fri, 9 Feb 2001 19:27:02 +0100 Subject: Standalone applications References: <95c000$8nc$1@ryu.it> <95jept$251$1@ryu.it> Message-ID: <961cpr$it636$1@ID-59885.news.dfncis.de> "Martin von Loewis" wrote in message news:p6qy9vf3g9w.fsf at informatik.hu-berlin.de... > "Ryujin" writes: > > > As I can read in the Freeze Readme, it is not possible to freeze and ship > > Tkinter application...did u find any solution to this problem? > > I always used Tix' SAM (stand-alone modules) approach. That compiles > Tcl and Tk's .tcl files into libraries, which can then be linked into > complete binaries. I understand TclPro offers a similar mechanism. Interesting. Do you have any pointers? Regards, Thomas From paulus132 at my-deja.com Tue Feb 6 16:37:57 2001 From: paulus132 at my-deja.com (paulus132 at my-deja.com) Date: Tue, 06 Feb 2001 15:37:57 GMT Subject: Standalone applications References: <95c000$8nc$1@ryu.it> Message-ID: <95p5ok$7cu$1@nnrp1.deja.com> In article , Martin von Loewis wrote: > "Ryujin" writes: > > > Any suggestion??? > > I personally prefer freeze. It requires a C compiler, but gives you > best control and reliability. Plus it allows to create *truly* > stand-alone binaries, i.e. binaries that are not even dependent on > shared libraries. > I also have some good experience with freeze, but the binaries are big (1.8M on Sun, 0.5M after strip), even for very simple *.py scripts !! Do you have some tips to reduce it ?? Paul Perrin > Regards, > Martin > Sent via Deja.com http://www.deja.com/ From dsh8290 at rit.edu Tue Feb 6 19:27:12 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 6 Feb 2001 13:27:12 -0500 Subject: Standalone applications In-Reply-To: <95p5ok$7cu$1@nnrp1.deja.com>; from paulus132@my-deja.com on Tue, Feb 06, 2001 at 03:37:57PM +0000 References: <95c000$8nc$1@ryu.it> <95p5ok$7cu$1@nnrp1.deja.com> Message-ID: <20010206132712.B1814@harmony.cs.rit.edu> On Tue, Feb 06, 2001 at 03:37:57PM +0000, paulus132 at my-deja.com wrote: | In article , | Martin von Loewis wrote: | > "Ryujin" writes: | > | > > Any suggestion??? | > | > I personally prefer freeze. It requires a C compiler, but gives you | > best control and reliability. Plus it allows to create *truly* | > stand-alone binaries, i.e. binaries that are not even dependent on | > shared libraries. | > | | I also have some good experience with freeze, but the binaries are big | (1.8M on Sun, 0.5M after strip), even for very simple *.py scripts !! | | Do you have some tips to reduce it ?? Tell the users to install the interpreter on their own. Then your package will only consist of your code and be much smaller. ;-) -D From grante at visi.com Wed Feb 7 19:55:33 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 07 Feb 2001 18:55:33 GMT Subject: Standalone applications References: <95c000$8nc$1@ryu.it> <95p5ok$7cu$1@nnrp1.deja.com> Message-ID: In article <95p5ok$7cu$1 at nnrp1.deja.com>, paulus132 at my-deja.com wrote: >I also have some good experience with freeze, but the binaries are big >(1.8M on Sun, 0.5M after strip), even for very simple *.py scripts !! > >Do you have some tips to reduce it ?? Just write more code! Eventually the 500k of overhead won't be so noticable. ;) -- Grant Edwards grante Yow! My NOSE is NUMB! at visi.com From loewis at informatik.hu-berlin.de Fri Feb 9 18:43:00 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 09 Feb 2001 18:43:00 +0100 Subject: Standalone applications References: <95c000$8nc$1@ryu.it> <95p5ok$7cu$1@nnrp1.deja.com> Message-ID: paulus132 at my-deja.com writes: > I also have some good experience with freeze, but the binaries are big > (1.8M on Sun, 0.5M after strip), even for very simple *.py scripts !! > > Do you have some tips to reduce it ?? I'd check the config.c generated by freeze. It may be that it decides to link-in builtin modules which are not needed in your application. Regards, Martin From jurgen.defurne at philips.com Wed Feb 7 08:42:51 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Wed, 7 Feb 2001 08:42:51 +0100 Subject: Standalone applications Message-ID: <0056900015717749000002L092*@MHS> Basically, what you are trying to do here is the same that Clipper did way back. THe minumum program we could get with it was 100kB. If it took the database library and the advanced stuff, we got executables between 350kB and 700 kB. What it did have, was that once most libraries were in it, the programs expanded less rapid. Does freeze compile everything to C and then to binary ? Shouldn't there be a way that you can create an executable, which consists of two parts : - the first part being code and libraries - the second part a data part, which consists of all byte codes needed Jurgen paulus132 at my-deja.com@SMTP at python.org on 06/02/2001 17:03:11 Sent by: python-list-admin at python.org To: python-list at python.org@SMTP cc: Subject: Re: Standalone applications Classification: In article , Martin von Loewis wrote: > "Ryujin" writes: > > > Any suggestion??? > > I personally prefer freeze. It requires a C compiler, but gives you > best control and reliability. Plus it allows to create *truly* > stand-alone binaries, i.e. binaries that are not even dependent on > shared libraries. > I also have some good experience with freeze, but the binaries are big (1.8M on Sun, 0.5M after strip), even for very simple *.py scripts !! Do you have some tips to reduce it ?? Paul Perrin > Regards, > Martin > Sent via Deja.com http://www.deja.com/ -- http://mail.python.org/mailman/listinfo/python-list From ngps at madcap.dyndns.org Thu Feb 1 18:06:07 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 1 Feb 2001 17:06:07 GMT Subject: [ANN] M2Crypto 0.06 snapshot #2 -- ZServerSSL Message-ID: <95c51v$3oa$1@coco.singnet.com.sg> Hi, A new snapshot of M2Crypto is now available. The major change: ZServerSSL Rides Again ------------------------ Whew! It's been a year! ZServerSSL was last released on 1 Feb 2000 for Zope 2.1.3. It has now been dusted off and re-released for Zope 2.3.0. Tested with Zope-2.3.0-win32-x86 with M2Crypto for Python1. Tested with Zope-2.3.0-src on FreeBSD with M2Crypto for both Python1 and Python2. Interoperated with Netscape, IE and Opera on Win32, and also Netscape on FreeBSD. Beware browsers with broken HTTP/1.1 - they drive ZServerSSL to 100% CPU utilisation: An example is Netscape Communicator 4.72 on my FreeBSD boxen. (Or maybe it's ZServer's HTTP/1.1 that's broken. ;-) X.509 certificate-based client authentication for HTTPS and the encrypting monitor, both features of the ZServerSSL released a year ago, to come RSN! As usual, get M2Crypto here: http://www.post1.com/home/ngps/m2 Feedback is appreciated. Cheers. -- Ng Pheng Siong * http://www.post1.com/home/ngps From victor at prodigy.net Thu Feb 1 18:18:38 2001 From: victor at prodigy.net (Victor Muslin) Date: Thu, 01 Feb 2001 17:18:38 GMT Subject: sys.exit and exceptions (newbie question) Message-ID: <3a7998cf.869169328@localhost> What is a pythonic idiom for forcing an immediate program termination? sys.exit() does not do it, because it throws a SystemExit exception, so if it is called within a try block, a generic except block is still executed. Of course it is possible to specifically catch SystemExit, as in the following example, but it is a pain. Moreover, one may want to exit in a code that plugs into somebody else's code framed by try: except: blocks. import sys try: print 'Exiting...' sys.exit(0) except SystemExit: print 'System exit...' except: print 'Oops... except' From gregj at pobox.com Thu Feb 1 20:28:43 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Thu, 01 Feb 2001 19:28:43 GMT Subject: sys.exit and exceptions (newbie question) References: <3a7998cf.869169328@localhost> Message-ID: <95cdcs$6b9$1@nnrp1.deja.com> Functions that exit without giving the caller a chance to catch the exception are a very bad idea. Exception handling is good Python practice; forcing an un-catchable exit is not. In article <3a7998cf.869169328 at localhost>, victor at prodigy.net (Victor Muslin) wrote: > What is a pythonic idiom for forcing an immediate program termination? > sys.exit() does not do it, because it throws a SystemExit exception, > so if it is called within a try block, a generic except block is still > executed. Of course it is possible to specifically catch SystemExit, > as in the following example, but it is a pain. Moreover, one may want > to exit in a code that plugs into somebody else's code framed by try: > except: blocks. > > import sys > try: > print 'Exiting...' > sys.exit(0) > except SystemExit: > print 'System exit...' > except: > print 'Oops... except' > -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com Sent via Deja.com http://www.deja.com/ From fredrik at effbot.org Thu Feb 1 20:54:07 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Thu, 01 Feb 2001 19:54:07 GMT Subject: sys.exit and exceptions (newbie question) References: <3a7998cf.869169328@localhost> Message-ID: Victor Muslin wrote: > What is a pythonic idiom for forcing an immediate program termination? not sure there is one, but if you insist, you can use: # terminate without cleaning up os._exit(errcode) or # force coredump os.abort() Cheers /F From ben.hutchings at roundpoint.com Thu Feb 1 22:41:31 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 01 Feb 2001 13:41:31 -0800 Subject: sys.exit and exceptions (newbie question) References: <3a7998cf.869169328@localhost> Message-ID: victor at prodigy.net (Victor Muslin) writes: > What is a pythonic idiom for forcing an immediate program termination? > sys.exit() does not do it, because it throws a SystemExit exception, > so if it is called within a try block, a generic except block is still > executed. I'm not sure that there is a Pythonic idiom for forcing immediate termination, since Python (a) has a pretty good exception system and (b) does not allow you to get into the sort of mess that you can do with C, where a clean exit becomes impossible. An except block that catches all exceptions should always re-raise the exceptioneal with. If it fails to re-raise KeyboardInterrupt, for example, the program won't be interruptible by the user. In the more general case, failing to re-raise exceptions can be a good way to hide bugs. You may find the os.abort() or the os._exit() function useful. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From thomas at xs4all.net Fri Feb 2 00:25:51 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 2 Feb 2001 00:25:51 +0100 Subject: sys.exit and exceptions (newbie question) In-Reply-To: <3a7998cf.869169328@localhost>; from victor@prodigy.net on Thu, Feb 01, 2001 at 05:18:38PM +0000 References: <3a7998cf.869169328@localhost> Message-ID: <20010202002551.S962@xs4all.nl> On Thu, Feb 01, 2001 at 05:18:38PM +0000, Victor Muslin wrote: > What is a pythonic idiom for forcing an immediate program termination? > sys.exit() does not do it, because it throws a SystemExit exception, > so if it is called within a try block, a generic except block is still > executed. You can use sys._exit(). This exits in a very abortive way -- right away, dropping everything it's doing, without doing any kind of cleanup. In general it's better to avoid unqualified except: clauses, and avoid code that uses it (unless, of course, they reraise the exception if they can't handle it.) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From moshez at zadka.site.co.il Fri Feb 2 14:01:29 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Fri, 2 Feb 2001 15:01:29 +0200 (IST) Subject: sys.exit and exceptions (newbie question) In-Reply-To: <20010202002551.S962@xs4all.nl> References: <20010202002551.S962@xs4all.nl>, <3a7998cf.869169328@localhost> Message-ID: <20010202130129.7059DA840@darjeeling.zadka.site.co.il> On Fri, 2 Feb 2001 00:25:51 +0100, Thomas Wouters wrote: > You can use sys._exit(). No you can't -- but you can use os._exit(). Everything else Thomas said is true... -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 From thomas at xs4all.net Fri Feb 2 15:03:00 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 2 Feb 2001 15:03:00 +0100 Subject: sys.exit and exceptions (newbie question) In-Reply-To: <20010202130129.7059DA840@darjeeling.zadka.site.co.il>; from moshez@zadka.site.co.il on Fri, Feb 02, 2001 at 03:01:29PM +0200 References: <20010202002551.S962@xs4all.nl>, <3a7998cf.869169328@localhost> <20010202002551.S962@xs4all.nl> <20010202130129.7059DA840@darjeeling.zadka.site.co.il> Message-ID: <20010202150300.V962@xs4all.nl> On Fri, Feb 02, 2001 at 03:01:29PM +0200, Moshe Zadka wrote: > On Fri, 2 Feb 2001 00:25:51 +0100, Thomas Wouters wrote: > > You can use sys._exit(). > No you can't -- but you can use os._exit(). > Everything else Thomas said is true... D'oh! I really, really need vacation. I've made *four* errors this week! And one of them was even a sysadmin error (added an emailalias in the wrong file, so it didn't work) -- that hasn't happened in years... I think I may be going senile ;P Maybe-I-should-just-move-to-management-ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From max at alcyone.com Fri Feb 2 18:46:08 2001 From: max at alcyone.com (Erik Max Francis) Date: Fri, 02 Feb 2001 09:46:08 -0800 Subject: sys.exit and exceptions (newbie question) References: <20010202002551.S962@xs4all.nl>, <3a7998cf.869169328@localhost> <20010202002551.S962@xs4all.nl> <20010202130129.7059DA840@darjeeling.zadka.site.co.il> Message-ID: <3A7AF260.250FAC03@alcyone.com> Thomas Wouters wrote: > D'oh! I really, really need vacation. I've made *four* errors this > week! And > one of them was even a sysadmin error (added an emailalias in the > wrong > file, so it didn't work) -- that hasn't happened in years... I think I > may > be going senile ;P So you don't feel so bad, I remembered it as being sys._exit too. :-) -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Conversation is the enemy of good wine and food. \__/ Alfred Hitchcock Kepler's laws / http://www.alcyone.com/max/physics/kepler/ A proof of Kepler's laws. From fredrik at effbot.org Fri Feb 2 09:10:25 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Fri, 02 Feb 2001 08:10:25 GMT Subject: sys.exit and exceptions (newbie question) References: <3a7998cf.869169328@localhost> Message-ID: Thomas Wouters wrote: > You can use sys._exit(). This exits in a very abortive way -- right away, > dropping everything it's doing, without doing any kind of cleanup. only if you're not catching AttributeError, that is ;-) >>> import sys >>> sys._exit() Traceback (most recent call last): File "", line 1, in ? AttributeError: _exit (it's "os._exit(code)", not "sys._exit()") Cheers /F From mj at muc.das-werk.de Thu Feb 1 18:50:33 2001 From: mj at muc.das-werk.de (Michael Jonas) Date: Thu, 1 Feb 2001 18:50:33 +0100 Subject: Win32 CreateProcess with In/out Redirection and a Way to kill the job? Message-ID: Seems like I need people with win32 geek factor.... What I want: I'd like to code a extension module with a function popen3 (same as in os) and a function is_alive() and terminate(). What I allready have: a module which has an popen3 method which does exactly the same like the posixmodule popen3 except that I extracted it to get hold of the process Handle (from the normally inaccessible dict). The redirection works fine, I can check if the job is still alive with my new is_alive(). But I'm really struggling to terminate the job. Where my proble is: The CreateProcess in the popen3 not only starts the job specified, it first starts a cmd.exe which then starts the job. Ergo: the process handle I save is the handle of the console app. The started app does not care at all if I do a TerminateProcess on the console. The cmd.exe dies and the started job stays alive. I tried to find a way to get hold of the Window Handle of the console, but did not find a way. (The doughter process seems to die if I close the Console Window. So I thought I could send a WM_Close to the Window....) Nothing really worked till here... Any idea how to implement something like this on Win32?!? Thanks Michel PS. Please cc the mail also to mj at muc.das-werk.de, cause I'm having trouble getting the mail from the list. ----------------------------------------- Michael Jonas Head of R&D Das Werk Digitale Bildverarbeitungs GmbH mail: mj at muc.das-werk.de phone: +49(89)368148-700 fax: +49(89)368148-111 ----------------------------------------- From MarkH at ActiveState.com Fri Feb 2 00:23:31 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 01 Feb 2001 23:23:31 GMT Subject: Win32 CreateProcess with In/out Redirection and a Way to kill the job? References: Message-ID: <3A79EF02.6040104@ActiveState.com> Michael Jonas wrote: > Any idea how to implement something like this on Win32?!? Try _not_ using "cmd.exe" as an intermediate shim. You should be able to execute the process directory. popen does it this way for maximum compatibility. Mark. From vasvir at iit.demokritos.gr Sat Feb 3 15:13:24 2001 From: vasvir at iit.demokritos.gr (Vassilis Virvilis) Date: Sat, 03 Feb 2001 16:13:24 +0200 Subject: Win32 CreateProcess with In/out Redirection and a Way to kill the job? References: Message-ID: <3A7C1204.A226B21E@iit.demokritos.gr> Michael Jonas wrote: > > Seems like I need people with win32 geek factor.... > > What I want: > I'd like to code a extension module with a function popen3 (same as in os) > and a function is_alive() and terminate(). > > What I allready have: > a module which has an popen3 method which does exactly the same like the > posixmodule popen3 except that I extracted it to get hold of the process > Handle (from the normally inaccessible dict). The redirection works fine, I > can check if the job is still alive with my new is_alive(). But I'm > really struggling to terminate the job. > > Where my proble is: > The CreateProcess in the popen3 not only starts the job specified, it first > starts a cmd.exe which then starts the job. Ergo: the process handle I save > is the handle of the console app. The started app does not care at all if I > do a TerminateProcess on the console. The cmd.exe dies and the started job > stays alive. I tried to find a way to get hold of the Window Handle of the > console, but did not find a way. (The doughter process seems to die if I > close the Console Window. So I thought I could send a WM_Close to the > Window....) Nothing really worked till here... > > Any idea how to implement something like this on Win32?!? > > Thanks Michel > > PS. Please cc the mail also to mj at muc.das-werk.de, cause I'm having trouble > getting the mail from the list. I don't know how exactly the popen* functions are implemented but I think it's better to use CreateProcess/DuplicateHandle to mimic the popen* behavior in windows and fork/dup in UNIX. PS In UNIX a libc popen invocation fires a shell also (bin/sh). .Bill From tmealy at my-deja.com Thu Feb 1 18:57:03 2001 From: tmealy at my-deja.com (tmealy at my-deja.com) Date: Thu, 01 Feb 2001 17:57:03 GMT Subject: Confused re: popen() Message-ID: <95c81a$vf$1@nnrp1.deja.com> I am having one heck of a time figuring out how to run a dos program interactively. I want to: 1. Issue a "CVS login" command, which when run in a dos responds with a password prompt. 2. Enter the password. 3. Issue a "CVS update" command. Can anyone give me an example of how to do this? Or is there a package out there that can hand CVS? I am running ActivePython 2 on a Win2000 box. Sent via Deja.com http://www.deja.com/ From trace at reinventnow.com Thu Feb 1 19:52:23 2001 From: trace at reinventnow.com (trace s. ruggles) Date: Thu, 01 Feb 2001 12:52:23 -0600 Subject: (MySQLdb and FreeBSD) on a VPS? Message-ID: Hi all, Has anyone had any luck installing MySQLdb while running under FreeBSD on a VPS (virtual private server)? (specifically, FreeBSD version 4.1) The distutils.py module can't seem to find the right directories to do the install because of the oddities of the VPS. It's looking for directories like "/usr/local/lib/..." while it should be looking for "/usr/home/axiomfire/usr/local/lib/..." (the "/usr/home/aximofir" is my specific directory on the VPS). I've tried to go in and muck around with the default directory settings in the sysconfig.py module within distutils, but I just seem to be making things worse... Thanks, Trace -- Trace S. Ruggles => 512/845.9354 => tracer at axiomfire.com "Ignite your marketing with interactive precision." AxiomFire, Inc. => http://www.axiomfire.com From h4rv3st.m00n at gmx.net Thu Feb 1 20:00:50 2001 From: h4rv3st.m00n at gmx.net (Harvest T. Moon) Date: Thu, 1 Feb 2001 20:00:50 +0100 Subject: Q: elements in a list [newbie] Message-ID: <95cbfs$gu0iq$1@ID-22517.news.dfncis.de> i hope this is not some kind of 'very stupid' question, how can i find out how many elements are in a list? (generated by file.readlines()) Harvest T. Moon From aahz at panix.com Thu Feb 1 20:14:28 2001 From: aahz at panix.com (Aahz Maruch) Date: 1 Feb 2001 11:14:28 -0800 Subject: Q: elements in a list [newbie] References: <95cbfs$gu0iq$1@ID-22517.news.dfncis.de> Message-ID: <95ccik$t4o$1@panix2.panix.com> In article <95cbfs$gu0iq$1 at ID-22517.news.dfncis.de>, Harvest T. Moon wrote: > >i hope this is not some kind of 'very stupid' question, how can i find out >how many elements are in a list? >(generated by file.readlines()) len() See the section on built-in functions in the Python docs. -- --- 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 "People sometimes focus too much on the fact of communication rather than the substance of communication." --Dave Morton From gregj at pobox.com Thu Feb 1 20:23:05 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Thu, 01 Feb 2001 19:23:05 GMT Subject: Q: elements in a list [newbie] References: <95cbfs$gu0iq$1@ID-22517.news.dfncis.de> Message-ID: <95cd2b$5uk$1@nnrp1.deja.com> len(list) In article <95cbfs$gu0iq$1 at ID-22517.news.dfncis.de>, "Harvest T. Moon" wrote: > i hope this is not some kind of 'very stupid' question, how can i find out > how many elements are in a list? > (generated by file.readlines()) > > Harvest T. Moon > > -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com Sent via Deja.com http://www.deja.com/ From Bill.Scherer at VerizonWireless.com Thu Feb 1 23:57:58 2001 From: Bill.Scherer at VerizonWireless.com (Bill Scherer) Date: Thu, 01 Feb 2001 17:57:58 -0500 Subject: Q: elements in a list [newbie] References: <95cbfs$gu0iq$1@ID-22517.news.dfncis.de> Message-ID: <3A79E9F6.C70518B6@VerizonWireless.com> len, as in: l = file.readlines() length = len(l) "Harvest T. Moon" wrote: > > i hope this is not some kind of 'very stupid' question, how can i find out > how many elements are in a list? > (generated by file.readlines()) > > Harvest T. Moon > > -- > http://mail.python.org/mailman/listinfo/python-list -- William K. Scherer Sr. Member of Applications Staff - Verizon Wireless Bill.Scherer_at_VerizonWireless.com From chris.gonnerman at usa.net Fri Feb 2 05:54:55 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Thu, 1 Feb 2001 22:54:55 -0600 Subject: elements in a list [newbie] References: <95cbfs$gu0iq$1@ID-22517.news.dfncis.de> Message-ID: <018301c08cd4$97b74660$a100000a@local> ----- Original Message ----- From: "Harvest T. Moon" Subject: Q: elements in a list [newbie] > i hope this is not some kind of 'very stupid' question, how can i find out > how many elements are in a list? > (generated by file.readlines()) f = file.readlines() l = len(f) Thar ya go. From binnc at my-deja.com Thu Feb 1 20:02:01 2001 From: binnc at my-deja.com (binnc at my-deja.com) Date: Thu, 01 Feb 2001 19:02:01 GMT Subject: Subroutine Equivalent in Python (newbie Q) Message-ID: <95cbr2$4o2$1@nnrp1.deja.com> Hello, Another question from someone totally new to Python. Is there an equivalent in Python to a sub- routine, (e.g. gosub and return). I want to create a modular program with sub-routines to perform distinct tasks wihin the program for organizational and debugging purposes, etc. Is the only (or best) way to do this is with modules? A function works but the values obtained within the function do not appear to be valid outside of that function. I guess I am looking for the best approach to create the subroutines for execution from the main flow of the program. Thanks for any assistance! Sent via Deja.com http://www.deja.com/ From aahz at panix.com Thu Feb 1 20:16:26 2001 From: aahz at panix.com (Aahz Maruch) Date: 1 Feb 2001 11:16:26 -0800 Subject: Subroutine Equivalent in Python (newbie Q) References: <95cbr2$4o2$1@nnrp1.deja.com> Message-ID: <95ccma$7d$1@panix2.panix.com> In article <95cbr2$4o2$1 at nnrp1.deja.com>, wrote: > >Another question from someone totally new to >Python. Is there an equivalent in Python to a sub- >routine, (e.g. gosub and return). I suggest you read the Python tutorial; it will answer that question and many others. See http://www.python.org/doc/current/tut/tut.html -- --- 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 "People sometimes focus too much on the fact of communication rather than the substance of communication." --Dave Morton From gregj at pobox.com Thu Feb 1 20:24:55 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Thu, 01 Feb 2001 19:24:55 GMT Subject: Subroutine Equivalent in Python (newbie Q) References: <95cbr2$4o2$1@nnrp1.deja.com> Message-ID: <95cd5q$66u$1@nnrp1.deja.com> Python has functions, modules, and packages, which support modular programming at various levels. Python also has classes, which support object-oriented programming. I strongly urge you to read the excellent Python tutorial at www.python.org. In article <95cbr2$4o2$1 at nnrp1.deja.com>, binnc at my-deja.com wrote: > Hello, > > Another question from someone totally new to > Python. Is there an equivalent in Python to a sub- > routine, (e.g. gosub and return). I want to > create a modular program with sub-routines to > perform distinct tasks wihin the program for > organizational and debugging purposes, etc. Is > the only (or best) way to do this is with > modules? A function works but the values > obtained within the function do not appear to be > valid outside of that function. I guess I am > looking for the best approach to create the > subroutines for execution from the main flow of > the program. > > Thanks for any assistance! > > Sent via Deja.com > http://www.deja.com/ > -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com Sent via Deja.com http://www.deja.com/ From cfelling at iae.nl Fri Feb 2 05:44:26 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 2 Feb 2001 05:44:26 +0100 Subject: Subroutine Equivalent in Python (newbie Q) References: <95cbr2$4o2$1@nnrp1.deja.com> Message-ID: <95ddva$mq1$1@animus.fel.iae.nl> binnc at my-deja.com wrote: > Hello, > Another question from someone totally new to > Python. Is there an equivalent in Python to a sub- > routine, (e.g. gosub and return). I want to > create a modular program with sub-routines to > perform distinct tasks wihin the program for > organizational and debugging purposes, etc. Is > the only (or best) way to do this is with > modules? A function works but the values > obtained within the function do not appear to be > valid outside of that function. I guess I am Ai, I fear your BASIC-abuse is shining through here:) IIRQ from the one week I had to work with BASIC, it offered the most basic form of subroutine calls possible, no context saving, no new var scope, only a return to were you came from. So basicly there was but one scope in such a program, comparable to the global scope of Python. In almost any other programming language I know of a subroutine creates a new namespace/scope. The joy of this is that it prevents nasty, hard to find nameclashes; ie in sub A you choose i for a local var, you go off to sub B, sub C etc, and somewhere in that line som other sub also choose to use i as a local var, but helas it isn't a local var, so the program logic of sub A might break in unpredictable ways. > looking for the best approach to create the > subroutines for execution from the main flow of > the program. There are several tools available to lumb code together to perform reoccuring tasks. The most basic one is the function, like: >>> def fun(args): >>> return result In its pure form it performs some calculation on its args and returns a result. But Python is not a pure functional language:) so other things are possible here to, like: >>> a = "spam" >>> def more_fun(args): >>> print a, args # a is automatically looked up in the outer scope ... >>> more_fun("and spam") spam and spam And for yet some more trickery: >>> a = "spam, spam" >>> def more_fun(args): >>> global a # this is needed to be able to assign to the global a >>> a = a + ', ' + args ... >>> more_fun("spam and spam") >>> print a spam, spam, spam and spam >>> more_fun("spam and spam") >>> print a spam, spam, spam and spam, spam and spam The trick is here that the global keyword tells Python to look a up in the global scope and not in the local function scope. But global scope get's hairy quickly, and func within func still only know of two scopes, their own and the module-global scope. There are better ways of doing things, like: >>> class C: >>> a = 'spam' >>> def __init__(self, s='more spam'): >>> self.s = self.a + 'and ' + s >>> def prt(self): >>> print self.s ... >>> c = C() >>> cc = C('spam and eggs') >>> c.prt() spam and more spam >>> cc.prt() spam and spam and eggs >>> cc.s = 'no more spam' >>> cc.prt() no more spam >>> c.prt() spam and more spam So a class is ideally suited to lumb together some code (several funcs in a single class) and some data to go along with that code. Read all about it in the FIne Manuals -- groetjes, carel From rtrocca at libero.it Thu Feb 1 20:12:02 2001 From: rtrocca at libero.it (Riccardo Trocca) Date: Thu, 01 Feb 2001 19:12:02 GMT Subject: wxPython on LinuxPPC Message-ID: <1eo5bsr.3fhlxt1f6ehcaN%rtrocca@libero.it> Hello, I've been trying to make wxPython compile on LinuxPPC, but I've failed (evenif wxWindow compiled well). Has somebody done it? I've been using python 2.0 compiled by myself. Riccardo From robin at alldunn.com Fri Feb 2 04:54:12 2001 From: robin at alldunn.com (Robin Dunn) Date: Thu, 1 Feb 2001 19:54:12 -0800 Subject: wxPython on LinuxPPC References: <1eo5bsr.3fhlxt1f6ehcaN%rtrocca@libero.it> Message-ID: "Riccardo Trocca" wrote in message news:1eo5bsr.3fhlxt1f6ehcaN%rtrocca at libero.it... > Hello, I've been trying to make wxPython compile on LinuxPPC, but I've > failed (evenif wxWindow compiled well). > Has somebody done it? > I've been using python 2.0 compiled by myself. > I don't have any details, but I know it's been done by at least a couple people. -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From bernhard at abnoba.intevation.de Mon Feb 5 14:48:27 2001 From: bernhard at abnoba.intevation.de (Bernhard Reiter) Date: 5 Feb 2001 13:48:27 GMT Subject: wxPython on LinuxPPC References: <1eo5bsr.3fhlxt1f6ehcaN%rtrocca@libero.it> Message-ID: <95mavb$lsj$2@newsserver.rrzn.uni-hannover.de> In article <1eo5bsr.3fhlxt1f6ehcaN%rtrocca at libero.it>, rtrocca at libero.it (Riccardo Trocca) writes: > Hello, I've been trying to make wxPython compile on LinuxPPC, but I've > failed (evenif wxWindow compiled well). > Has somebody done it? Yes. It works fine here, there were no problems. Make sure that you have exactly the same version of wxGTK and wxPython. Bernhard > I've been using python 2.0 compiled by myself. -- 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 ccosse at psl.nmsu.edu Thu Feb 1 20:54:49 2001 From: ccosse at psl.nmsu.edu (charles cosse) Date: Thu, 01 Feb 2001 12:54:49 -0700 Subject: how to run script in windows via C system call w/o popup dos shell Message-ID: <3A79BF08.5C4018C7@psl.nmsu.edu> Hello, just spent too much time trying to get NT not to pop up a window everytime my C function made a "system" call to run a python script. I think the solution is merely to rename the script ".pyw" rather than ".py". This info was found in David Beasley's (excellent) book: Python Essential Reference, p. 85. It sure beats creating a new "NT Service" -- which is what i thought was gonna have to do. Hope this helps someone, someday. Charlie From bobhicks at adelphia.net Thu Feb 1 21:08:11 2001 From: bobhicks at adelphia.net (Robert L Hicks) Date: Thu, 01 Feb 2001 20:08:11 GMT Subject: MacPython Message-ID: Is there a MacPython tutorial anywhere? From shwang5 at students.uiuc.edu Thu Feb 1 21:27:49 2001 From: shwang5 at students.uiuc.edu (seung-won hwang) Date: Thu, 1 Feb 2001 14:27:49 -0600 Subject: Python CGI programming Message-ID: Hello, I tried a python CGI programming example in 'learning python' and the msg as follows says that the address is incorrect though I specified the address of .py file correctly. Any help would be greatly appreciated. Thanks! (I attached my .html file just in case, after the error mesg) --- The page cannot be displayed The page you are looking for cannot be displayed because the address is incorrect. -------------------------------------------------------------------------------- Please try the following: If you typed the page address in the Address bar, check that it is entered correctly. Open the www-sal.cs.uiuc.edu home page and then look for links to the information you want. Click Search to look for information on the Internet. HTTP 405 - Resource not allowed Internet Explorer --
    Please fill out the entire form:
Name:
Email Address:
Mailing Address:
Type of Message: comment  complaint
Enter the text in here:
From shwang5 at students.uiuc.edu Thu Feb 1 22:26:05 2001 From: shwang5 at students.uiuc.edu (seung-won hwang) Date: Thu, 1 Feb 2001 15:26:05 -0600 Subject: Python CGI programming In-Reply-To: References: Message-ID: FYI, when I type the following example, web browser just shows the source code..not the test string... How can I fix this? #!/usr/bin/python # Tell the browser how to render the text print "Content-Type: text/plain\n\n" print "Hello, Python!" # print a test string From gerhard.nospam at bigfoot.de Thu Feb 1 23:36:57 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Thu, 01 Feb 2001 23:36:57 +0100 Subject: Python CGI programming References: Message-ID: <3A79E509.31F99F12@bigfoot.de> Your Python code is ok. Assuming the Python interpreter really is at /usr/bin/python. If not, you must adjust the first line of the script to point to the location of the python interpreter. Another common place would be /usr/local/bin/python. First you should find out if the webserver supports user CGI scripts at all. If it does, these must normally be put in a directory named cgi-bin, like ~/home_html/cgi-bin. The script must also have the executable bit set (assuming you are on Unix, of course). chmod +x feedback.py sets the executable bit of your script. Gerhard seung-won hwang wrote: > > FYI, when I type the following example, web browser just shows > the source code..not the test string... How can I fix this? > > #!/usr/bin/python > > # Tell the browser how to render the text > print "Content-Type: text/plain\n\n" > > print "Hello, Python!" # print a test string -- 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 joconnor at cybermesa.com Fri Feb 2 00:49:21 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Thu, 01 Feb 2001 23:49:21 +0000 Subject: Python CGI programming References: Message-ID: <3A79F601.424B7F3F@cybermesa.com> seung-won hwang wrote: > > FYI, when I type the following example, web browser just shows > the source code..not the test string... How can I fix this? > > #!/usr/bin/python > > # Tell the browser how to render the text > print "Content-Type: text/plain\n\n" > > print "Hello, Python!" # print a test string Make sure that a) the script is in the cgi-bin directory for the web server. If it's not, the server will display the file rather than execute it b) the script has execute permission set (although I think this raises a 500 error instead) Take care, -- Jay O'Connor joconnor at cybermesa.com http://www.cybermesa.com/~joconnor "God himself plays the bass strings first when He tunes the soul" From jcm at bigskytel.com Fri Feb 2 02:39:55 2001 From: jcm at bigskytel.com (David Porter) Date: Thu, 1 Feb 2001 18:39:55 -0700 Subject: Python CGI programming In-Reply-To: ; from shwang5@students.uiuc.edu on Thu, Feb 01, 2001 at 03:26:05PM -0600 References: Message-ID: <20010201183955.A7746@bigskytel.com> * seung-won hwang : > > FYI, when I type the following example, web browser just shows > the source code..not the test string... How can I fix this? Make the file executable and put it in your web server's CGI bin, or some other place where the web server will execute programs. David From chris.gonnerman at usa.net Fri Feb 2 06:01:39 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Thu, 1 Feb 2001 23:01:39 -0600 Subject: Python CGI programming References: Message-ID: <019901c08cd5$3baba040$a100000a@local> ----- Original Message ----- From: "seung-won hwang" Subject: Re: Python CGI programming > FYI, when I type the following example, web browser just shows > the source code..not the test string... How can I fix this? > > #!/usr/bin/python > > # Tell the browser how to render the text > print "Content-Type: text/plain\n\n" > > print "Hello, Python!" # print a test string The webserver does not recognize your script as a cgi script. Depending on the webserver, you may be required to put the script in a special subdirectory (cgi-bin or scripts for instance), make registry or config file changes on the server (unlikely to be allowed if you don't own the server yourself), etc. The 405 error you are getting is because METHOD=POST is not allowed for non-cgi documents by your webserver, and as I said, it doesn't know it is a cgi script. Can you tell us anything else about your problem? (What host OS/webserver, do you have root or administrative access, etc.)? From burkhard.kayser at freenet.de Thu Feb 1 21:37:29 2001 From: burkhard.kayser at freenet.de (Burkhard Kayser) Date: Thu, 1 Feb 2001 21:37:29 +0100 Subject: A Telnet question Message-ID: <95chjn$18n$02$1@news.t-online.com> Hi, I'm a newbie in python. My first application is based on telnetlib and I've a problem with unreachable hosts. When I try to connect to a host, wich is currently not reachable, socket.connect(), wich is invoked by telnet.open(), times out after some minutes. How can I change this timeout to some seconds ? I tried it under SuSE 7.0. Has onyone an idea ? Thanks From Bill.Scherer at VerizonWireless.com Fri Feb 2 01:27:04 2001 From: Bill.Scherer at VerizonWireless.com (Bill Scherer) Date: Thu, 01 Feb 2001 19:27:04 -0500 Subject: A Telnet question References: <95chjn$18n$02$1@news.t-online.com> Message-ID: <3A79FED8.F6A3C43C@VerizonWireless.com> Get timeoutsocket from: http://www.timo-tasi.org/python/timeoutsocket.py Burkhard Kayser wrote: > > Hi, > > I'm a newbie in python. My first application is based on telnetlib and I've > a problem with unreachable hosts. > > When I try to connect to a host, wich is currently not reachable, > socket.connect(), wich is invoked by telnet.open(), times out after some > minutes. How can I change this timeout to some seconds ? > I tried it under SuSE 7.0. > > Has onyone an idea ? > > Thanks > > -- > http://mail.python.org/mailman/listinfo/python-list -- William K. Scherer Sr. Member of Applications Staff - Verizon Wireless Bill.Scherer_at_VerizonWireless.com From gregj at pobox.com Fri Feb 2 01:54:34 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Fri, 02 Feb 2001 00:54:34 GMT Subject: A Telnet question References: <95chjn$18n$02$1@news.t-online.com> Message-ID: <95d0g7$oql$1@nnrp1.deja.com> timeout_socket is in the Vaults of Parnassus, here: http://www.vex.net/parnassus/apyllo.py/126307487.528281449 and here: http://www.cs.usyd.edu.au/~piers/python/ Other implementations have been discussed in this forum; search for "socket timeout" to find them. In article <95chjn$18n$02$1 at news.t-online.com>, "Burkhard Kayser" wrote: > Hi, > > I'm a newbie in python. My first application is based on telnetlib and I've > a problem with unreachable hosts. > > When I try to connect to a host, wich is currently not reachable, > socket.connect(), wich is invoked by telnet.open(), times out after some > minutes. How can I change this timeout to some seconds ? > I tried it under SuSE 7.0. -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com Sent via Deja.com http://www.deja.com/ From gerhard.nospam at bigfoot.de Fri Feb 2 02:15:10 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Fri, 02 Feb 2001 02:15:10 +0100 Subject: A Telnet question References: <95chjn$18n$02$1@news.t-online.com> Message-ID: <3A7A0A1E.D5C7FDCA@bigfoot.de> Burkhard Kayser wrote: > > Hi, > > I'm a newbie in python. My first application is based on telnetlib and I've > a problem with unreachable hosts. > > When I try to connect to a host, wich is currently not reachable, > socket.connect(), wich is invoked by telnet.open(), times out after some > minutes. How can I change this timeout to some seconds ? > I tried it under SuSE 7.0. Sounds like a typical application for the timeoutsocket module, available at http://www.timo-tasi.org/python/timeoutsocket.py , which I downloaded, but never used myself ;-) It's a wrapper around the standard Python socket module with the additional possibility of setting a timeout. So it might be just what you need. 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 joconnor at cybermesa.com Thu Feb 1 22:18:03 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Thu, 01 Feb 2001 21:18:03 +0000 Subject: Python/C++ interface Message-ID: <3A79D28B.1BEB46A0@cybermesa.com> All, I was doing some testing with the Python->C++ interface and ran into something odd. The example shows calling a C function from python with import spam spam.system ("ls -l") and on the C++ side... the signature reads PyObject* spam_system(PyObject *self, PyObject * args) { ... } Now. On the C++ side, args is considered, and parsed, as a Tuple. However, what I found was that a Tuple was not being passed, just a String. The only time a Tuple was passed was if there was more than one argument. The whole argument list would be converted to a Tuple, then. Is this an error in the documentation? Or has the passing method changed between 1.5.x and 2.0 (I'm using 2.0) and the documentation is just out of date? Also, is there a good way of printing the name of the type of a PyObject? Thanks -- Jay O'Connor joconnor at cybermesa.com http://www.cybermesa.com/~joconnor "God himself plays the bass strings first when He tunes the soul" From mwh21 at cam.ac.uk Thu Feb 1 22:23:43 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 01 Feb 2001 21:23:43 +0000 Subject: Python/C++ interface References: <3A79D28B.1BEB46A0@cybermesa.com> Message-ID: Jay O'Connor writes: > Now. On the C++ side, args is considered, and parsed, as a Tuple. > However, what I found was that a Tuple was not being passed, just a > String. The only time a Tuple was passed was if there was more than one > argument. The whole argument list would be converted to a Tuple, then. You missed a METH_VARARGS somewhere. > Is this an error in the documentation? Or has the passing method > changed between 1.5.x and 2.0 (I'm using 2.0) and the documentation is > just out of date? > > Also, is there a good way of printing the name of the type of a > PyObject? Something very like printf(ob->ob_type->tp_name). Or print type(object).name in Python. 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 joconnor at cybermesa.com Thu Feb 1 22:28:23 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Thu, 01 Feb 2001 21:28:23 +0000 Subject: Python/C++ interface References: <3A79D28B.1BEB46A0@cybermesa.com> Message-ID: <3A79D4F7.CF63C817@cybermesa.com> Michael Hudson wrote: > You missed a METH_VARARGS somewhere. Ah, yes...I see it now...in my static declaration of the exported method list > > Also, is there a good way of printing the name of the type of a > > PyObject? > > Something very like printf(ob->ob_type->tp_name). Doh! I was so close to that a few times :) Thanks -- Jay O'Connor joconnor at cybermesa.com http://www.cybermesa.com/~joconnor "God himself plays the bass strings first when He tunes the soul" From loewis at informatik.hu-berlin.de Fri Feb 2 22:59:35 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Feb 2001 22:59:35 +0100 Subject: Python/C++ interface References: <3A79D28B.1BEB46A0@cybermesa.com> <3A79D4F7.CF63C817@cybermesa.com> Message-ID: Jay O'Connor writes: > > Something very like printf(ob->ob_type->tp_name). > > > Doh! I was so close to that a few times :) Or, call _PyObject_Dump(ob). Works nicely from gdb as well (I wish Misc/gdbinit had been around much longer - I only learned about _PyObject_Dump from that, either). Regards, Martin From idfx at my-deja.com Fri Feb 9 20:29:14 2001 From: idfx at my-deja.com (idfx) Date: Fri, 09 Feb 2001 19:29:14 GMT Subject: Python/C++ interface References: <3A79D28B.1BEB46A0@cybermesa.com> Message-ID: <961gdt$fm4$1@nnrp1.deja.com> In article <3A79D28B.1BEB46A0 at cybermesa.com>, Jay O'Connor wrote: > All, > > I was doing some testing with the Python->C++ interface and ran into > something odd. > > The example shows calling a C function from python with > > import spam > spam.system ("ls -l") > > and on the C++ side... the signature reads > PyObject* spam_system(PyObject *self, PyObject * args) { > ... > } > > Now. On the C++ side, args is considered, and parsed, as a Tuple. > However, what I found was that a Tuple was not being passed, just a > String. The only time a Tuple was passed was if there was more than one > argument. The whole argument list would be converted to a Tuple, then. > > Is this an error in the documentation? Or has the passing method > changed between 1.5.x and 2.0 (I'm using 2.0) and the documentation is > just out of date? > > Also, is there a good way of printing the name of the type of a > PyObject? I may be wrong, or over-simplifying, but I think you've gotten confused by the terms, understandably. Yes, args is read into a tuple, always, but if there's only one argument, then it becomes a tuple of length 1. ie: tpl = ("yourstring",) that way, you can refer to as many arguments as there are, ( numargs=len(tpl) ) instead of worrying about special cases for 1 or 0 arguments. Your args is still a string, it's just that it's a string that happens to be an element of a tuple. OTOH, I may be totally mis-reading your problem. The other possibility is that, for a system call, (e.g. 'ls -l'), C++ makes a string of the argument(s) to preserve the command you are passing to the system, which should be a string anyway, or so I'm told. As for the printing of type names, this is something I had trouble with, too. Eventually, I came up with this, although I'm sure there are more elegant ways to address the problem: def printype( obj ): naym = `type(obj)` # string it, i = naym.find("'") naym = naym[(i+1):] # trim it, i = naym.find("'") naym = naym[:i] return naym # return it! (as a string) Hey, what can I say? It works. Usually. ; ) Hope that helps. -- yrs, in_sanity, idfx Sent via Deja.com http://www.deja.com/ From drewpc at colorado.edu Thu Feb 1 22:31:13 2001 From: drewpc at colorado.edu (drewpc at colorado.edu) Date: Thu, 01 Feb 2001 21:31:13 GMT Subject: interfaces? Message-ID: <95ckj2$dlc$1@nnrp1.deja.com> Let me preface this posting by saying that I'm not a fan of Java. A lot of people may argue with me, but that's not the point. The point is that I think that, one of the only useful features of Java is the idea of an interface. If you know what a Java interface is, skip this paragraph. For those of you that don't know, here's how I understand it. Imagine you're writing an API for a database. You want every database module (MySQL, PostgreSQL, Oracle, etc) to implement the connect(), query(), insert(), update(), and drop() methods. What if you could create a pseudo class that all of your database modules would "implement". Meaning that the pseudo class would define the methods (and variables too, I think) connect(), query(), insert(), update(), and drop() methods. It wouldn't implement them at all, but just define them. Then, inside each module you'd "implement" (which would be a little different then "inherit") the interface that you defined above. All that means is that the compiler (or interpreter) checks to make sure the the class that implements the interface does in fact use the functions that were defined in the interface. Now, my question. Is this something that people would be interested in seeing in Python? If so, then I think I'll write up a PEP (Python Enhancement Proposal, http://python.sourceforge.net/peps/) about this. Comments? Cheap shots? One-liners? Sent via Deja.com http://www.deja.com/ From cjc26 at nospam.cornell.edu Fri Feb 2 03:18:07 2001 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Fri, 02 Feb 2001 02:18:07 GMT Subject: interfaces? References: <95ckj2$dlc$1@nnrp1.deja.com> Message-ID: * drewpc at colorado.edu menulis: | | Now, my question. Is this something that people would be interested in | seeing in Python? If so, then I think I'll write up a PEP (Python | Enhancement Proposal, http://python.sourceforge.net/peps/) about this. | Comments? Cheap shots? One-liners? Well, the usual way to indicate that a class implements, say, the file interface, is to write a comment saying "this class implements the file interface". ;) You probably don't need anything more complicated than that, since Python is dynamically typed, blah blah, etc. (where "blah blah, etc." is meant to sum up the many discussions on c.l.py about this very topic ;) If you were really paranoid, you could always do something like this: def func(f): if not hasattr(f, "readlines"): raise NeedFileObjectError for line in f.readlines(): # rest of function goes here try: func(suspectedFileObject) except NeedFileObjectError: print >>sys.stderr, "You must use a file object!" Of course, most people would just leave out the hasattr() check, and let func() raise an AttributeError if it's passed something which doesn't act like a file object. and-we-don't-need-to-declare-which-exceptions-our-functions-raise- either--ly y'rs, Cliff -- Cliff Crawford http://www.people.cornell.edu/pages/cjc26/ print "Just another Python hacker" From aleaxit at yahoo.com Fri Feb 2 09:50:33 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 2 Feb 2001 09:50:33 +0100 Subject: interfaces? References: <95ckj2$dlc$1@nnrp1.deja.com> Message-ID: <95dscp02us3@news1.newsguy.com> wrote in message news:95ckj2$dlc$1 at nnrp1.deja.com... > Let me preface this posting by saying that I'm not a fan of Java. A lot > of people may argue with me, but that's not the point. The point is > that I think that, one of the only useful features of Java is the idea > of an interface. It's a good idea, but COM did it better, before Java ever existed:-). E.g., one think I love about COM interfaces vs Java's: a COM object is *informed* when one of its interfaces is requested of it -- it gets to 'intercept' the interface-request, if you will, and thus can do whatever work it may need to prepare itself for "actually HAVING" the interface it advertises -- acquire resources, etc; explicitness of navigation between interfaces is just lovely -- as usual, "explicit is better than implicit". In Java, like in C++, the native protocol for "navigating between the interfaces of a given object" is a cast (dynamic_cast, in C++), and the object doesn't even get _informed_ that somebody's trying to cast it in a such-and-such way. So, when you need 'hooks' upon interface navigation, you can't have them within the native protocol -- you must redundantly check at each method-entry, or use other non-native protocols whereby your "secondary interfaces" are requested by some method-call. It's a bit better in Python, since __getattr__ does provide a natural place to hang a hook for interface-navigation -- whenever a method in interface X is requested, and you don't yet have it in your dict, your __getattr__ get called, and you can diagnose the situation, do whatever you require to prepare to actually support interface X, and add X's methods to your __dict__ (or switch your runtime class to add some X implementation to its bases, etc) so your __getattr__ won't be bothered again about them. Still, it's somewhat dark magic in Python, while it's clear as crystal in COM (if you understand COM's semantics rules about identity &tc; Don Box's great "Essential COM" is highly recommended to foster such understanding!-). Anyway, "interfaces are a good concept" is a widely shared opinion, among Pythonistas as well as among others -- including users of other languages that don't model interfaces *explicitly*, but still let you use them one way or another. You could say of Python (and Smalltalk, etc) that interfaces are there, just not 'bundled' -- each method-cum-signature (that you can conceptually group into an interface) is on its own. You could say of C++ (and Eiffel, etc) that interfaces are there, just not named as such -- you can model them, if you wish, by using special-cases of classes (with multiple inheritance), and good C++/Eiffel designers do that a LOT -- see, e.g., John Lakos' great book "Large Scale C++ Software Design" (Addison-Wesley, 1996) -- what you and I and COM and Java call "interfaces", Lakos calls "protocol classes", but, terminology apart, the concept IS very much there, and it's developed solidly and convincingly in the context of a splendid discussion of the issues of large-scale software design (dependency management, &c). (I can't mention Lakos without a nod to Robert Martin, who writes about very similar concerns -- interfaces, components, dependency managements -- in VERY clear ways, having a gift for wrapping up the wisdom he imparts into easily digestible little morsels -- if you can stomach reading a little bit of C++ code, about all of his articles at http://www.objectmentor.com/publications/articlesByAuthor.html are great reading, IMHO; Lakos' book is more organic and thorough, but by that same token it requires a substantial investment of time and energy to study it in depth and digest it as it deserves to be -- Martin's articles, focusing on one concern at a time, may prove much more palatable fare for most of us over-worked, chronically short of time, short-attention-span, any-unbillable-minute-had- BETTER-give-great-returns, typical software professionals). Anyway, back to Python -- see http://www.prescod.net/pytypes/, and http://www.zope.org/Wikis/Interfaces/FrontPage, for some of the previous thoughts on interfaces in Pyhon. Alex From tshumway at transafari.com Fri Feb 2 15:28:53 2001 From: tshumway at transafari.com (Terrel Shumway) Date: Fri, 02 Feb 2001 06:28:53 -0800 Subject: interfaces? References: <95ckj2$dlc$1@nnrp1.deja.com> Message-ID: <3A7AC425.33EBD58F@transafari.com> drewpc at colorado.edu wrote: > that I think that, one of the only useful features of Java is the idea > of an interface. > Interfaces are good, but they are only a first step. In Java, you can declare an interface, and you can claim that a class implements that interface, but that is all the support that the language provides. The question is: as a client, do you believe that claim, just because it has the right method signatures? The most effective way I have seen to know this is to test it. See http://junit.org/ and http://pyunit.sourceforge.net/ for starting points. BTW: Unit testing even works for assembly language. :-) if-it-is-worth-implementing-it-is-worth-testing-ly yours, Terrel From m.faassen at vet.uu.nl Sun Feb 4 02:21:06 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Feb 2001 01:21:06 GMT Subject: interfaces? References: <95ckj2$dlc$1@nnrp1.deja.com> Message-ID: <95iaq2$gbm$1@newshost.accu.uu.nl> drewpc at colorado.edu wrote: > Let me preface this posting by saying that I'm not a fan of Java. A lot > of people may argue with me, but that's not the point. The point is > that I think that, one of the only useful features of Java is the idea > of an interface. [snip] > Now, my question. Is this something that people would be interested in > seeing in Python? If so, then I think I'll write up a PEP (Python > Enhancement Proposal, http://python.sourceforge.net/peps/) about this. > Comments? Cheap shots? One-liners? One-liner: http://www.zope.org/Members/michel/InterfacesPEP/PEP.txt Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From ctavares at develop.com Sun Feb 4 11:38:24 2001 From: ctavares at develop.com (Chris Tavares) Date: Sun, 04 Feb 2001 10:38:24 GMT Subject: interfaces? References: <95ckj2$dlc$1@nnrp1.deja.com> Message-ID: wrote in message news:95ckj2$dlc$1 at nnrp1.deja.com... > Let me preface this posting by saying that I'm not a fan of Java. A lot > of people may argue with me, but that's not the point. The point is > that I think that, one of the only useful features of Java is the idea > of an interface. > [... snip ...] I think that the Smalltalk approach to interfaces would be more appropriate for Python than the Java one - dynamic vs. static and all. The equivalent code in Python would be: class IDontDoAnything: def UselessMethod(self): return self.SubclassResponsibility() And then you don't define SubclassResponsibility. That way, when you try and call UselessMethod on a class that doesn't implement it, you'll get an attribute error. Static verification doesn't really belong in Python to my mind. I *like* just being able to only implement the part of the protocol that I need. -Chris From syver at NOSPAMcyberwatcher.com Sun Feb 4 21:50:07 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Sun, 4 Feb 2001 21:50:07 +0100 Subject: interfaces? References: <95ckj2$dlc$1@nnrp1.deja.com> Message-ID: <95kfeg$fpt$1@troll.powertech.no> "Chris Tavares" wrote > I think that the Smalltalk approach to interfaces would be more appropriate > for Python than the Java one - dynamic vs. static and all. > > The equivalent code in Python would be: > > class IDontDoAnything: > def UselessMethod(self): > return self.SubclassResponsibility() Wouldn't you rather do it like this in Python: class IDontDoAnything: def UselessMethod(self): raise NotImplementedError() From fernstrom at geocities.com Thu Feb 1 22:58:04 2001 From: fernstrom at geocities.com (fernstrom at geocities.com) Date: Thu, 01 Feb 2001 21:58:04 GMT Subject: Programmatic control of scroll position in PmwScrolledFrame Message-ID: <95cm56$f9i$1@nnrp1.deja.com> I would like to set the scrolling in a PmwScrolledFrame programatically (in order to retain the same scroll position every time the same information is displayed in the frame). I have tried two ways: - by using get() and set() in the scrollbar of the scrolledframe object. get() returns plausible values, but set() has no effect - by using the private function in PmwScrolledFrame. _yview(), with first parameter set to 'moveto'. Doesn't work either. Does anybody have a clue? christer Sent via Deja.com http://www.deja.com/ From btheld2 at my-deja.com Thu Feb 1 23:42:31 2001 From: btheld2 at my-deja.com (btheld2 at my-deja.com) Date: Thu, 01 Feb 2001 22:42:31 GMT Subject: Using WITH_FREE_THREAD to avoid PyEval_AcquireThread error Message-ID: <95cool$hr5$1@nnrp1.deja.com> I am having some problems with a PyEval_AcquireThread error. I have an extension DLL (created using SWIG). A Python callback function in this dll is calling a COM function. This COM function is creating a new Document in my MDI MFC Application. When this occurs I get an PyEval_AcquireThread error (Null thread?). After digging through the code, it appears that a pre-processor directive (WITH_FREE_THREAD) may solve this problem. I just tried defining this and rebuilding python, but the system cannot find threadstate.h. So, Is this a solution? If not, what is? If so, where is the threadstate.h file? Ben Sent via Deja.com http://www.deja.com/ From RoD at qnet20.com Thu Feb 1 23:24:00 2001 From: RoD at qnet20.com (Rod) Date: Thu, 1 Feb 2001 23:24:00 Subject: Diamond x Jungle Carpet Python Message-ID: <20010202072423.184C9F4EA@mail.python.org> I have several Diamond x Jungle Capret Pythons for SALE. Make me an offer.... Go to: www.qnet20.com From peter at engcorp.com Fri Feb 2 14:31:51 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 02 Feb 2001 08:31:51 -0500 Subject: Diamond x Jungle Carpet Python References: Message-ID: <3A7AB6C7.386D14D@engcorp.com> Rod wrote: > > I have several Diamond x Jungle Capret Pythons for SALE. > > Make me an offer.... > > Go to: www.qnet20.com Which platform? Version 1.5.2 or earlier? Doesn't ActiveState already make these available as a free download provided you don't need to redistribute them? Jeez, why don't people ever provide enough detail in their posts?! :-) From jhauser at ifm.uni-kiel.de Fri Feb 2 14:43:23 2001 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 02 Feb 2001 14:43:23 +0100 Subject: Diamond x Jungle Carpet Python References: <3A7AB6C7.386D14D@engcorp.com> Message-ID: <877l399p50.fsf@lisboa.ifm.uni-kiel.de> Peter Hansen writes: > Rod wrote: > > > > I have several Diamond x Jungle Capret Pythons for SALE. > > > > Make me an offer.... > > > > Go to: www.qnet20.com > > Which platform? Version 1.5.2 or earlier? Doesn't > ActiveState already make these available as a free > download provided you don't need to redistribute them? > > Jeez, why don't people ever provide enough detail in > their posts?! > > :-) What? You do not take this serious? I have just ordered two of them for the sides of my home entrance. And Rod has given me a written guarantee that these babies will not move and only roll their eyes, as long as the the outside temperature is below zero degree (hope he meant celsius). So I think I'm safe for the winter :-) __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 dougfort at downright.com Fri Feb 2 02:28:49 2001 From: dougfort at downright.com (Doug Fort) Date: Thu, 1 Feb 2001 20:28:49 -0500 Subject: httplib: response.read() vs response.read(size) Message-ID: We're developing a website load testing application (http://www.stressmy.com). We give httplib a pretty good workout. And generally get excellent results. Recently, we ran into a pair of unrelated sites that use some form of graphics server (Netscape-Enterprise/4.1). There, our simulated users hung up waiting for a read on the socket in the httplib.HTTPResponse.read(). The code looks like this (with a lot of deletions) self._client = httplib.HTTPConnection("", None) ... response = self._client.getresponse() ... self._data = response.read() I was able to work around this with the following: if response.length: self._data = response.read(response.length) else: self._data = response.read() My question is: should this be moved up into httplib.HTTPResponse.read()? I'm posting this here, instead of sending a bug or a diff to SourceForge because I really don't understand the new HTTP 1.1 state machine in httplib, and I don't want to aggravate the developers with bogus bugs or dumb patches while they're working on 2.1. -- Doug Fort Senior Meat Manager Downright Software LLC http://www.dougfort.net From jobs at sliceware.com Fri Feb 2 02:51:45 2001 From: jobs at sliceware.com (Adam Feuer) Date: Fri, 02 Feb 2001 01:51:45 GMT Subject: Python/Zope Software Architect/Developer wanted Message-ID: VSA Manager Software Architect/Lead Developer Software Architect/Developer Sliceware, Inc. http://www.sliceware.com/ Sliceware has an open position for a Software Architect/Developer located in Portland, Oregon. You will be responsible for the design and implementation of one of Sliceware's core software products, the server end of an Internet-based client-server system. The server will be implemented in Zope. You will work with our Chief Architect, the lead architect of the client end project, and other team members. Must Have Experience: * Previous work as a Software Architect * Good communication skills * Shipping software to end-users (As opposed to building websites or web-applications that don't ship to users.) * Object-oriented development (Python, Java, C++, Smalltalk, etc.) * Scalable, multi-tier web applications * Enterprise Databases (Oracle, Sybase, PostgreSQL, MySQL, etc.) * Distributed computing * Open Source software and development methodologies * Unix, Linux * XML * W. Richard Stevens :-) * BS - Computer Science (or equivalent) Nice To Have Experience: * Python * Zope * XML-RPC or SOAP * Project Management * Public Key Infrastructure, X.509 Certificates, SSL and TLS * LDAP/Directory programming * SNMP * CIM About Sliceware, Inc.: Sliceware Inc. develops, markets and sells software for office networks and software tools to administer them remotely. Please send your resume to jobs at sliceware.com Contact: Adam Feuer jobs at sliceware.com 503-977-2800 6932 SW Macadam Ave. Suite C Portland OR 97219 From g_will at cyberus.ca Fri Feb 2 07:18:05 2001 From: g_will at cyberus.ca (Gordon Williams) Date: Fri, 2 Feb 2001 01:18:05 -0500 Subject: Four problems with Gordon McMillan's Installer Message-ID: <95djga$2a9s$1@news2.ottawa.cyberus.ca> Hi All, I'm having big problems with Gordon McMillan installer (3i) to make a standalone package. I'm trying to put together a package using wxPython 2.2.2, Python 2. under W95. I have used earlier versions of the installer, but this is the first time for 3i. Here is what is happening: 1) Minor problem is that "wxPython.wxc.pyd" is in the standalone directory but it should be named "wxc.pyd". 2) wx22_2.dll is not found so I am putting it in under "misc". This is the notice that I am getting (whatever found and not found means): analyzing multiarray found python20.dll found MSVCRT.dll found KERNEL32.dll analyzing wxPython.wxc found wx22_2.dll lib not found: wx22_2.dll found python20.dll found MSVCRT.dll analyzing _numpy found python20.dll found MSVCRT.dll found KERNEL32.dll 3) I'm getting notices about fixcase for all the files that it is recompiling. The names before and after are the same!! Creating BS_Main06B.pyz name before fixcase e:\program files\python\lib\threading.py name after fixcase e:\program files\python\lib\threading.py 4) This is the major problem. It is not finding the standard time module. I am importing time into a number of modules and it cant find it all the time. If I move the import statement up or down a few lines it sometimes fixes the problem, only to appear in another module. Here is what I am getting during a run of the standalone. I cant see anything in the .log file or the screen output during the build process. File "e:\program files\python\lib\imputil.py", line 252, in _import_one module = self._process_result(result, fqname) File "e:\program files\python\lib\imputil.py", line 281, in _process_result exec code in module.__dict__ File "e:\program files\python\junk_files\Main_thread.py", line 1, in ? import threading, time, Registers, DataSep File "e:\program files\python\lib\imputil.py", line 88, in _import_hook top_module = self._import_top_module(parts[0]) File "e:\program files\python\lib\imputil.py", line 170, in _import_top_module module = item.import_top(name) File "e:\program files\python\lib\imputil.py", line 197, in import_top return self._import_one(None, name, name) File "e:\program files\python\lib\imputil.py", line 252, in _import_one module = self._process_result(result, fqname) File "e:\program files\python\lib\imputil.py", line 281, in _process_result exec code in module.__dict__ File "e:\program files\python\lib\threading.py", line 4, in ? import time File "e:\program files\python\lib\imputil.py", line 91, in _import_hook raise ImportError, 'No module named ' + fqname ImportError: No module named time I have a web bookmark to Gordon's installer pages that are out of date as they lead me to version 3f with no indication that there is a new installer 3i available. Maybe these old pages could be deleted so others are not also mislead. Needless to say I'm going crazy. Any help or ideas would be appreciated. Gordon Williams From thomas.heller at ion-tof.com Fri Feb 2 10:36:07 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Fri, 2 Feb 2001 10:36:07 +0100 Subject: Four problems with Gordon McMillan's Installer References: <95djga$2a9s$1@news2.ottawa.cyberus.ca> Message-ID: <95dv28$guuo7$1@ID-59885.news.dfncis.de> You should probably try out py2exe, which is still beta, but moving fast. It has been used to create wxPython programs easily. http://starship.python.net/crew/theller/py2exe If you insist using Gordon's installer, search c.l.p. Solutions to your problems have been posted AFAIK. Regards, Thomas From g_will at cyberus.ca Fri Feb 2 16:45:10 2001 From: g_will at cyberus.ca (Gordon Williams) Date: Fri, 2 Feb 2001 10:45:10 -0500 Subject: Four problems with Gordon McMillan's Installer References: <95djga$2a9s$1@news2.ottawa.cyberus.ca> <95dv28$guuo7$1@ID-59885.news.dfncis.de> Message-ID: <95eklf$o50$1@news2.ottawa.cyberus.ca> Yes, I used your program a couple of days ago when it was hot off the press. It worked nicely and very smoothly. The problem that I had with it was that you pack all the source .pyc files into an easily expandable zip file. These can be easily extracted and decompiled back to .py for all the world to see. I dont want people messing with the source so I was looking for something that was not quite as easy to hack. Maybe there is something that can be done with your program to at least hide the python files inside the zip file to provide at least some level of security? I dont know how others handle this for commercial apps. Regards, Gordon Williams "Thomas Heller" wrote in message news:95dv28$guuo7$1 at ID-59885.news.dfncis.de... > You should probably try out py2exe, which is still beta, but moving fast. > It has been used to create wxPython programs easily. > > http://starship.python.net/crew/theller/py2exe > > From thomas.heller at ion-tof.com Fri Feb 2 16:57:54 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Fri, 2 Feb 2001 16:57:54 +0100 Subject: Four problems with Gordon McMillan's Installer References: <95djga$2a9s$1@news2.ottawa.cyberus.ca> <95dv28$guuo7$1@ID-59885.news.dfncis.de> <95eklf$o50$1@news2.ottawa.cyberus.ca> Message-ID: <95ele5$gqs15$1@ID-59885.news.dfncis.de> > Yes, I used your program a couple of days ago when it was hot off the press. > It worked nicely and very smoothly. Glad to hear this! The problem that I had with it was that > you pack all the source .pyc files into an easily expandable zip file. > These can be easily extracted and decompiled back to .py for all the world > to see. I dont want people messing with the source so I was looking for > something that was not quite as easy to hack. > > Maybe there is something that can be done with your program to at least hide > the python files inside the zip file to provide at least some level of > security? I dont know how others handle this for commercial apps. Well, this is on the to-do list for later. I want to do this in two stages: - first, use a notstandard zip-header so that winzip does not recognize it - second, maybe crypt the .pyc files in the archive somehow and decrypt them in the exe. Do you think this would be apppropriate? I have no idea yet for the .pyd files. Thomas From dbrueck at edgix.com Fri Feb 2 18:24:26 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Fri, 2 Feb 2001 10:24:26 -0700 Subject: Four problems with Gordon McMillan's Installer In-Reply-To: <95ele5$gqs15$1@ID-59885.news.dfncis.de> Message-ID: > > Maybe there is something that can be done with your program to > at least hide > > the python files inside the zip file to provide at least some level of > > security? I dont know how others handle this for commercial apps. > Well, this is on the to-do list for later. > I want to do this in two stages: > - first, use a notstandard zip-header so that winzip does > not recognize it > - second, maybe crypt the .pyc files in the archive somehow > and decrypt them in the exe. > > Do you think this would be apppropriate? Yes, that sounds like a good idea... you can use the imp/ihooks (is ihooks obsolete?) modules to hook into the normal module importer and decrypt them on the fly. For the zipfile you could still use a normal format but save it to disk in a munged-up format (something simple like the rotor module would keep most people out anyway) and then unmunge before reading it. -Dave P.S. - I just tried the latest version of py2exe on a wxPython program and it worked _flawlessly_ and took little time to set up and get going. Very cool... From loewis at informatik.hu-berlin.de Fri Feb 2 23:02:16 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Feb 2001 23:02:16 +0100 Subject: Four problems with Gordon McMillan's Installer References: <95djga$2a9s$1@news2.ottawa.cyberus.ca> <95dv28$guuo7$1@ID-59885.news.dfncis.de> <95eklf$o50$1@news2.ottawa.cyberus.ca> Message-ID: "Gordon Williams" writes: > I dont want people messing with the source so I was looking for > something that was not quite as easy to hack. In that case, I recommend freezing. It also allows to integrate all DLLs (provided you have or can produce static libraries for them). Regards, Martin From fgeiger at datec.at Sun Feb 4 10:37:43 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Sun, 4 Feb 2001 10:37:43 +0100 Subject: Four problems with Gordon McMillan's Installer References: <95djga$2a9s$1@news2.ottawa.cyberus.ca> <95dv28$guuo7$1@ID-59885.news.dfncis.de> Message-ID: <95j7si$24f$1@newsreaderm1.core.theplanet.net> Had similar problems. Tried your py2exe and it worked - cool! Regards Franz GEIGER "Thomas Heller" wrote in message news:95dv28$guuo7$1 at ID-59885.news.dfncis.de... > You should probably try out py2exe, which is still beta, but moving fast. > It has been used to create wxPython programs easily. > > http://starship.python.net/crew/theller/py2exe > > If you insist using Gordon's installer, search c.l.p. Solutions > to your problems have been posted AFAIK. > > Regards, > > Thomas > > From robin at alldunn.com Fri Feb 2 17:56:22 2001 From: robin at alldunn.com (Robin Dunn) Date: Fri, 2 Feb 2001 08:56:22 -0800 Subject: Four problems with Gordon McMillan's Installer References: <95djga$2a9s$1@news2.ottawa.cyberus.ca> Message-ID: > > 4) This is the major problem. It is not finding the standard time module. > I am importing time into a number of modules and it cant find it all the > time. In the Installer sources in support/archive_rt.py after "import imputil" add this line: sys.path.append(imputil.BuiltinImporter()) -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From Dan.Rolander at marriott.com Fri Feb 2 18:41:01 2001 From: Dan.Rolander at marriott.com (Rolander, Dan) Date: Fri, 2 Feb 2001 12:41:01 -0500 Subject: Four problems with Gordon McMillan's Installer Message-ID: <6176E3D8E36FD111B58900805FA7E0F80CCF6360@mcnc-mdm1-ex01> Gordon (Williams): I am using Installer with wxPython 2.2.2, and Python 2.0 under Win2K. I had some initial problems but everything is fine now. Here are my comments: 1) Yes, the problem with wxPython.wxc.pyd is known. Apparently this started happening with Python 2.0. You'll see this often-- files will be named with the full package path name. As far as I know the only workaround is to rename them after the build. 2) Yes, I also include wx22_2.dll on the misc line, like this-- misc= MYSTANDALONE, wxPython.wx22_2 3) I see the fixcase messages also but they don't seem to affect anything. 4) I have an application that is using wxPython and the time module and I haven't had a problem with it. BUT... I do have a couple of updated files from Gordon McMillan that are newer than the 3i distribution and did fix A LOT of problems I was having before. He's advised they will be part of the 3j distribution whenever that is released. I'm attaching them. I recommend you replace your existing versions with these. 5) Yes, Gordon's starship pages are out of date and I don't know why they are still there. Be sure to use http://www.mcmillan-inc.com instead. I hope this helps, Dan -------------- MEInc\dist\bindepend.py ---------------- # copyright 1999 McMillan Enterprises, Inc. # license: use as you please. No warranty. # # use dumpbin.exe (if present) to find the binary # dependencies of an extension module. # if dumpbin not available, pick apart the PE hdr of the binary # while this appears to work well, it is complex and subject to # problems with changes to PE hdrs (ie, this works only on 32 bit Intel # Windows format binaries) # # Note also that you should check the results to make sure that the # dlls are redistributable. I've listed most of the common MS dlls # under "excludes" below; add to this list as necessary (or use the # "excludes" option in the INSTALL section of the config file). import os import time import string import sys import tempfile import finder seen = {} excludes = {'KERNEL32.DLL':1, 'ADVAPI.DLL':1, 'MSVCRT.DLL':1, 'ADVAPI32.DLL':1, 'COMCTL32.DLL':1, 'CRTDLL.DLL':1, 'GDI32.DLL':1, 'MFC42.DLL':1, 'NTDLL.DLL':1, 'OLE32.DLL':1, 'OLEAUT32.DLL':1, 'RPCRT4.DLL':1, 'SHELL32.DLL':1, 'USER32.DLL':1, 'WINSPOOL.DRV':1, 'WS2HELP.DLL':1, 'WS2_32.DLL':1, 'WSOCK32.DLL':1, 'WINMM.DLL':1, 'COMDLG32.DLL':1, 'ZLIB.DLL':1, 'ODBC32.DLL':1, 'VERSION.DLL':1} def getfullnameof(mod, xtrapath = None): """Return the full path name of MOD. MOD is the basename of a dll or pyd. XTRAPATH is a path or list of paths to search first. Return the full path name of MOD. Will search the full Windows search path, as well as sys.path""" epath = finder.getpath() if mod[-4:] in ('.pyd', '.PYD'): epath = epath + sys.path if xtrapath is not None: if type(xtrapath) == type(''): epath.insert(0, xtrapath) else: epath = xtrapath + epath for p in epath: npth = os.path.join(p, mod) if os.path.exists(npth): return npth return '' def getImports1(pth): """Find the binary dependencies of PTH. This implementation (not used right now) uses the MSVC utility dumpbin""" rslt = [] tmpf = tempfile.mktemp() os.system('dumpbin /IMPORTS "%s" >%s' %(pth, tmpf)) time.sleep(0.1) txt = open(tmpf,'r').readlines() os.remove(tmpf) i = 0 while i < len(txt): tokens = string.split(txt[i]) if len(tokens) == 1 and string.find(tokens[0], '.') > 0: rslt.append(string.strip(tokens[0])) i = i + 1 return rslt def getImports2(pth): """Find the binary dependencies of PTH. This implementation walks through the PE header""" import struct rslt = [] try: f = open(pth, 'rb').read() pehdrd = struct.unpack('l', f[60:64])[0] magic = struct.unpack('l', f[pehdrd:pehdrd+4])[0] numsecs = struct.unpack('h', f[pehdrd+6:pehdrd+8])[0] numdirs = struct.unpack('l', f[pehdrd+116:pehdrd+120])[0] idata = '' if magic == 17744: importsec, sz = struct.unpack('2l', f[pehdrd+128:pehdrd+136]) secttbl = pehdrd + 120 + 8*numdirs secttblfmt = '8s7l2h' seclist = [] for i in range(numsecs): seclist.append(struct.unpack(secttblfmt, f[secttbl+i*40:secttbl+(i+1)*40])) #nm, vsz, va, rsz, praw, preloc, plnnums, qrelocs, qlnnums, flags \ # = seclist[-1] for i in range(len(seclist)-1): if seclist[i][2] <= importsec < seclist[i+1][2]: break vbase = seclist[i][2] raw = seclist[i][4] idatastart = raw + importsec - vbase idata = f[idatastart:idatastart+seclist[i][1]] i = 0 while 1: vsa = struct.unpack('5l', idata[i*20:i*20+20])[3] if vsa == 0: break sa = raw + vsa - vbase end = string.find(f, '\000', sa) nm = f[sa:end] if nm: rslt.append(nm) i = i + 1 except IOError: print "bindepend cannot analyze %s - file not found!" % pth except struct.error: print "bindepend cannot analyze %s - error walking thru pehdr" % pth return rslt def Dependencies(lTOC): """Expand LTOC to include all the closure of binary dependencies. LTOC is a logical table of contents, ie, a seq of tuples (name, path). Return LTOC expanded by all the binary dependencies of the entries in LTOC, except those listed in the module global EXCLUDES""" for (nm, pth) in lTOC: fullnm = string.upper(os.path.basename(pth)) if seen.get(string.upper(nm),0): continue print "analyzing", nm seen[string.upper(nm)] = 1 dlls = getImports(pth) for lib in dlls: print " found", lib if excludes.get(string.upper(lib),0): continue if seen.get(string.upper(lib),0): continue npth = getfullnameof(lib) if npth: lTOC.append((lib, npth)) else: print " lib not found:", lib, "dependency of", return lTOC ##if getfullnameof('dumpbin.exe') == '': ## def getImports(pth): ## return getImports2(pth) ##else: ## def getImports(pth): ## return getImports1(pth) def getImports(pth): """Forwards to either getImports1 or getImports2 """ return getImports2(pth) -------------- support\archive_rt.py ---------------- # # Gordon McMillan (as inspired and influenced by Greg Stein) # # subclasses may not need marshal or struct, but since they're # builtin, importing is safe. # # While an Archive is really an abstraction for any "filesystem # within a file", it is tuned for use with imputil.FuncImporter. # This assumes it contains python code objects, indexed by the # the internal name (ie, no '.py'). # See carchive.py for a more general archive (contains anything) # that can be understood by a C program. #archive_rt is a stripped down version of MEInc.Dist.archive. #It has had all building logic removed. #It's purpose is to bootstrap the Python installation. _verbose = 0 _listdir = None import marshal import struct import imp import sys import imputil _c_suffixes = filter(lambda x: x[2] == imp.C_EXTENSION, imp.get_suffixes()) for nm in ('nt', 'posix', 'dos', 'os2', 'mac'): if nm in sys.builtin_module_names: mod = __import__(nm) _listdir = mod.listdir class Archive(imputil.Importer): """ A base class for a repository of python code objects. The extract method is used by imputil.ArchiveImporter to get code objects by name (fully qualified name), so an enduser "import a.b" would become extract('a.__init__') extract('a.b') """ MAGIC = 'PYL\0' HDRLEN = 12 # default is MAGIC followed by python's magic, int pos of toc TOCPOS = 8 TRLLEN = 0 # default - no trailer TOCTMPLT = {} # os = None _bincache = None def __init__(self, path=None, start=0): "Initialize an Archive. If path is omitted, it will be an empty Archive." self.toc = None self.path = path self.start = start import imp self.pymagic = imp.get_magic() if path is not None: self.lib = open(self.path, 'rb') self.checkmagic() self.loadtoc() if Archive._bincache is None: Archive._bincache = {} for fnm in _listdir(sys.path[0]): for ext, mode, typ in _c_suffixes: sz = len(ext) if fnm[-sz:] == ext: Archive._bincache[fnm[:-sz]] = sys.path[0] + '/' + fnm, (ext, mode, typ) if _verbose: print "Archive caching", fnm[:-sz] ####### Sub-methods of __init__ - override as needed ############# def checkmagic(self): """ Overridable. Check to see if the file object self.lib actually has a file we understand. """ self.lib.seek(self.start) #default - magic is at start of file if self.lib.read(len(self.MAGIC)) != self.MAGIC: raise RuntimeError, "%s is not a valid %s archive file" \ % (self.path, self.__class__.__name__) if self.lib.read(len(self.pymagic)) != self.pymagic: raise RuntimeError, "%s has version mismatch to dll" % (self.path) def loadtoc(self): """ Overridable. Default: After magic comes an int (4 byte native) giving the position of the TOC within self.lib. Default: The TOC is a marshal-able string. """ self.lib.seek(self.start + self.TOCPOS) (offset,) = struct.unpack('=i', self.lib.read(4)) self.lib.seek(self.start + offset) self.toc = marshal.load(self.lib) ######## This is what is called by FuncImporter ####### ## Since an Archive is flat, we ignore parent and modname. def get_code(self, parent, modname, fqname): if _verbose: print "get_code(%s, %s, %s, %s)" % (self, parent, modname, fqname) rslt = self.extract(fqname) # None if not found, (ispkg, code) otherwise if rslt is None: if parent: importer = getattr(parent, "__importer__", None) if importer: func = getattr(importer, "func", None) if func == self.get_code: file, desc = Archive._bincache.get(fqname, (None, None)) if file: try: fp = open(file, desc[1]) except IOError: pass else: module = imp.load_module(fqname, fp, file, desc) if _verbose: print "#found", file return 0, module, {'__file__':file} if _verbose: print "#not found" return None ispkg, code = rslt if ispkg: return ispkg, code, {'__path__' : [fqname]} return ispkg, code, {} ####### Core method - Override as needed ######### def extract(self, name): """ Get the object corresponding to name, or None. For use with imputil ArchiveImporter, object is a python code object. 'name' is the name as specified in an 'import name'. 'import a.b' will become: extract('a') (return None because 'a' is not a code object) extract('a.__init__') (return a code object) extract('a.b') (return a code object) Default implementation: self.toc is a dict self.toc[name] is pos self.lib has the code object marshal-ed at pos """ ispkg, pos = self.toc.get(name, (0,None)) if pos is None: return None self.lib.seek(self.start + pos) return ispkg, marshal.load(self.lib) ######################################################################## # Informational methods def contents(self): """Return a list of the contents Default implementation assumes self.toc is a dict like object. Not required by ArchiveImporter. """ return self.toc.keys() ######################################################################## # Building ####### Top level method - shouldn't need overriding ####### ## def build(self, path, lTOC): ## """Create an archive file of name 'path'. ## lTOC is a 'logical TOC' - a list of (name, path, ...) ## where name is the internal name, eg 'a' ## and path is a file to get the object from, eg './a.pyc'. ## """ ## self.path = path ## self.lib = open(path, 'wb') ## #reserve space for the header ## if self.HDRLEN: ## self.lib.write('\0'*self.HDRLEN) ## ## #create an empty toc ## ## if type(self.TOCTMPLT) == type({}): ## self.toc = {} ## else: # assume callable ## self.toc = self.TOCTMPLT() ## ## for tocentry in lTOC: ## self.add(tocentry) # the guts of the archive ## ## tocpos = self.lib.tell() ## self.save_toc(tocpos) ## if self.TRLLEN: ## self.save_trailer(tocpos) ## if self.HDRLEN: ## self.update_headers(tocpos) ## self.lib.close() ## ## ## ####### manages keeping the internal TOC and the guts in sync ####### ## def add(self, entry): ## """Override this to influence the mechanics of the Archive. ## Assumes entry is a seq beginning with (nm, pth, ...) where ## nm is the key by which we'll be asked for the object. ## pth is the name of where we find the object. Overrides of ## get_obj_from can make use of further elements in entry. ## """ ## if self.os is None: ## import os ## self.os = os ## nm = entry[0] ## pth = entry[1] ## ispkg = self.os.path.splitext(self.os.path.basename(pth))[0] == '__init__' ## self.toc[nm] = (ispkg, self.lib.tell()) ## f = open(entry[1], 'rb') ## f.seek(8) #skip magic and timestamp ## self.lib.write(f.read()) ## ## def save_toc(self, tocpos): ## """Default - toc is a dict ## Gets marshaled to self.lib ## """ ## marshal.dump(self.toc, self.lib) ## ## def save_trailer(self, tocpos): ## """Default - not used""" ## pass ## ## def update_headers(self, tocpos): ## """Default - MAGIC + Python's magic + tocpos""" ## self.lib.seek(self.start) ## self.lib.write(self.MAGIC) ## self.lib.write(self.pymagic) ## self.lib.write(struct.pack('=i', tocpos)) ############################################################## # # ZlibArchive - an archive with compressed entries # class ZlibArchive(Archive): MAGIC = 'PYZ\0' TOCPOS = 8 HDRLEN = 12 TRLLEN = 0 TOCTMPLT = {} LEVEL = 9 def __init__(self, path=None, offset=0): Archive.__init__(self, path, offset) # dynamic import so not imported if not needed global zlib import zlib def extract(self, name): (ispkg, pos, lngth) = self.toc.get(name, (0, None, 0)) if pos is None: return None self.lib.seek(self.start + pos) return ispkg, marshal.loads(zlib.decompress(self.lib.read(lngth))) ## def add(self, entry): ## if self.os is None: ## import os ## self.os = os ## nm = entry[0] ## pth = entry[1] ## ispkg = self.os.path.splitext(self.os.path.basename(pth))[0] == '__init__' ## f = open(pth, 'rb') ## f.seek(8) #skip magic and timestamp ## obj = zlib.compress(f.read(), self.LEVEL) ## self.toc[nm] = (ispkg, self.lib.tell(), len(obj)) ## self.lib.write(obj) ## if type(__import__) == type(open): imputil.ImportManager().install() sys.path.append(imputil.BuiltinImporter()) From thomas.heller at ion-tof.com Fri Feb 2 19:11:59 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Fri, 2 Feb 2001 19:11:59 +0100 Subject: Four problems with Gordon McMillan's Installer References: Message-ID: <95et9h$ge831$1@ID-59885.news.dfncis.de> "Dave Brueck" wrote in message news:mailman.981135004.31623.python-list at python.org... > > > Maybe there is something that can be done with your program to > > at least hide > > > the python files inside the zip file to provide at least some level of > > > security? I dont know how others handle this for commercial apps. > > Well, this is on the to-do list for later. > > I want to do this in two stages: > > - first, use a notstandard zip-header so that winzip does > > not recognize it > > - second, maybe crypt the .pyc files in the archive somehow > > and decrypt them in the exe. > > > > Do you think this would be apppropriate? > > Yes, that sounds like a good idea... you can use the imp/ihooks (is ihooks > obsolete?) modules to hook into the normal module importer and decrypt them > on the fly. This is what I had planned. > For the zipfile you could still use a normal format but save it > to disk in a munged-up format (something simple like the rotor module would > keep most people out anyway) and then unmunge before reading it. > > -Dave > > P.S. - I just tried the latest version of py2exe on a wxPython program and > it worked _flawlessly_ and took little time to set up and get going. Very > cool... > > Thanks for trying it, Thomas From lisowski.tomasz at sssa.NOSPAM.com.pl Fri Feb 2 08:17:03 2001 From: lisowski.tomasz at sssa.NOSPAM.com.pl (Tomasz Lisowski) Date: Fri, 2 Feb 2001 08:17:03 +0100 Subject: Q: import statement within a function Message-ID: <95dmp6$n4s$1@news.tpi.pl> This is perhaps rather a basic question, but ... I have seen often import statements included within a function's body, not in the global scope, as it is most common. Approach 1: ------------- def fun(s): ... import string words=string.split(s) as compared to: Approach 2: ------------- import string def fun(s): ... words=string.split(s) What are the advantages of the first approach over the second. Won't Python do the importing job many times, each time the function fun() is called? Regards, Tomasz Lisowski From fredrik at effbot.org Fri Feb 2 09:10:37 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Fri, 02 Feb 2001 08:10:37 GMT Subject: import statement within a function References: <95dmp6$n4s$1@news.tpi.pl> Message-ID: <1Yte6.11069$AH6.1772843@newsc.telia.net> Tomasz Lisowski wrote: > I have seen often import statements included within a function's body, not > in the global scope, as it is most common. > ... > What are the advantages of the first approach over the second. Won't Python > do the importing job many times, each time the function fun() is called? Depends on what you mean with "importing job" -- Python caches imported modules in sys.modules. The "real" import is only done the first time you need a module. also see: http://effbot.org/guides/import-confusion.htm and the language reference. Cheers /F From lisowski.tomasz at sssa.NOSPAM.com.pl Fri Feb 2 09:33:51 2001 From: lisowski.tomasz at sssa.NOSPAM.com.pl (Tomasz Lisowski) Date: Fri, 2 Feb 2001 09:33:51 +0100 Subject: import statement within a function References: <95dmp6$n4s$1@news.tpi.pl> <1Yte6.11069$AH6.1772843@newsc.telia.net> Message-ID: <95dr93$dcs$1@news.tpi.pl> U?ytkownik "Fredrik Lundh" napisa? w wiadomo?ci news:1Yte6.11069$AH6.1772843 at newsc.telia.net... > Tomasz Lisowski wrote: > > I have seen often import statements included within a function's body, not > > in the global scope, as it is most common. > > ... > > What are the advantages of the first approach over the second. Won't Python > > do the importing job many times, each time the function fun() is called? > > Depends on what you mean with "importing job" -- Python > caches imported modules in sys.modules. The "real" import > is only done the first time you need a module. > > also see: > http://effbot.org/guides/import-confusion.htm > and the language reference. OK, I have read your mini-guide, and the language reference, and now I see, that the penalty for executing import statement after it has been imported for the first time is minimal. What are then advantages of importing a module WITHIN a function. Why not place this statement in the global scope? If a module is imported within a function, the module's name is added to the CURRENT namespace, right. It means that other functions in the module have no access to this module, even if it is listed in sys.modules. IMHO, this is rather a drawback of this approach. Let me ask once more: what are the advantages? Tomasz Lisowski From fredrik at effbot.org Fri Feb 2 10:40:39 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Fri, 02 Feb 2001 09:40:39 GMT Subject: import statement within a function References: <95dmp6$n4s$1@news.tpi.pl> <1Yte6.11069$AH6.1772843@newsc.telia.net> <95dr93$dcs$1@news.tpi.pl> Message-ID: Tomasz Lisowski wrote: > OK, I have read your mini-guide, and the language reference, and now I see, > that the penalty for executing import statement after it has been imported > for the first time is minimal. What are then advantages of importing a > module WITHIN a function. - lazy importing: if you place it within a function, the module is only imported if your program really needs it. - import dependencies (see the recursive import section in the mini-guide). if you use from-import on the module level, you can end up in situations where the things you import doesn't yet exist. - performance: local lookup is faster than global lookup. - readability: it can be easier to grok your code if you import things (i.e. define names) near the place you're using them. (etc) Cheers /F From lisowski.tomasz at sssa.NOSPAM.com.pl Fri Feb 2 13:34:15 2001 From: lisowski.tomasz at sssa.NOSPAM.com.pl (Tomasz Lisowski) Date: Fri, 2 Feb 2001 13:34:15 +0100 Subject: import statement within a function References: <95dmp6$n4s$1@news.tpi.pl> <1Yte6.11069$AH6.1772843@newsc.telia.net> <95dr93$dcs$1@news.tpi.pl> Message-ID: <95e9c2$rmm$1@news.tpi.pl> U?ytkownik "Fredrik Lundh" napisa? w wiadomo?ci news:rgve6.11079$AH6.1774088 at newsc.telia.net... > Tomasz Lisowski wrote: > > OK, I have read your mini-guide, and the language reference, and now I see, > > that the penalty for executing import statement after it has been imported > > for the first time is minimal. What are then advantages of importing a > > module WITHIN a function. > > - lazy importing: if you place it within a function, the module > is only imported if your program really needs it. > > - import dependencies (see the recursive import section in the > mini-guide). if you use from-import on the module level, you > can end up in situations where the things you import doesn't > yet exist. > > - performance: local lookup is faster than global lookup. Yes, that's really a good point! > - readability: it can be easier to grok your code if you import > things (i.e. define names) near the place you're using them. Thanks, Frederik, that is really a good explanation! BTW, I really appreciate your "Introduction to Tkinter". I am using it alot. Tomasz From peter at engcorp.com Fri Feb 2 14:29:56 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 02 Feb 2001 08:29:56 -0500 Subject: import statement within a function References: <95dmp6$n4s$1@news.tpi.pl> <1Yte6.11069$AH6.1772843@newsc.telia.net> <95dr93$dcs$1@news.tpi.pl> <95e9c2$rmm$1@news.tpi.pl> Message-ID: <3A7AB654.D6C16746@engcorp.com> Tomasz Lisowski wrote: > > "Fredrik Lundh" : > > Tomasz Lisowski wrote: > > > for the first time is minimal. What are then advantages of importing a > > > module WITHIN a function. > > > > - lazy importing: if you place it within a function, the module > > is only imported if your program really needs it. > > > > - import dependencies (see the recursive import section in the > > mini-guide). if you use from-import on the module level, you > > can end up in situations where the things you import doesn't > > yet exist. > > > > - performance: local lookup is faster than global lookup. > > Yes, that's really a good point! > > > - readability: it can be easier to grok your code if you import > > things (i.e. define names) near the place you're using them. > > Thanks, Frederik, that is really a good explanation! BTW, I really > appreciate your "Introduction to Tkinter". I am using it alot. The one you highlight, "performance", should probably be considered the _least_ important of the points Fredrik raised. The last one, which implies improved maintainability, is far more important (IMHO), and that alone is a good reason to put import within a function instead of 'without' (provided the imported module is not needed throughout the importing module of course). From lisowski.tomasz at sssa.NOSPAM.com.pl Sat Feb 3 08:43:47 2001 From: lisowski.tomasz at sssa.NOSPAM.com.pl (Tomasz Lisowski) Date: Sat, 3 Feb 2001 08:43:47 +0100 Subject: import statement within a function References: <95dmp6$n4s$1@news.tpi.pl> <1Yte6.11069$AH6.1772843@newsc.telia.net> <95dr93$dcs$1@news.tpi.pl> <95e9c2$rmm$1@news.tpi.pl> <3A7AB654.D6C16746@engcorp.com> Message-ID: <95gcn6$imb$1@news.tpi.pl> Uzytkownik "Peter Hansen" napisal w wiadomosci news:3A7AB654.D6C16746 at engcorp.com... <.> > > > - lazy importing: if you place it within a function, the module > > > is only imported if your program really needs it. > > > > > > - import dependencies (see the recursive import section in the > > > mini-guide). if you use from-import on the module level, you > > > can end up in situations where the things you import doesn't > > > yet exist. > > > > > > - performance: local lookup is faster than global lookup. > > > > Yes, that's really a good point! > > > > > - readability: it can be easier to grok your code if you import > > > things (i.e. define names) near the place you're using them. > > > > Thanks, Frederik, that is really a good explanation! BTW, I really > > appreciate your "Introduction to Tkinter". I am using it alot. > > The one you highlight, "performance", should probably be > considered the _least_ important of the points Fredrik raised. That depends, on what the given function does, and how often it is called, of course. > The last one, which implies improved maintainability, is > far more important (IMHO), and that alone is a good reason > to put import within a function instead of 'without' > (provided the imported module is not needed throughout > the importing module of course). I dare to disagree with you, as I find it very convenient to find all import statements at the beginning of the source file, without having to scan the file, if there are any other modules, that I have requested. Perhaps my opinion is influenced by my Delphi programming habits, where I could find all modules imported in the 'uses' clause, easily locateable in the source file. Moreover, it is a matter of taste, whether I put the import statement at the beginning of the file, even if the given module is imported only by one function, since this function will be eventually called (there was surely a reason for writing it, wasn't it?). Therefore I have asked Frederik about REAL advantages, that could persuade me to put import statements within a function. Performance, IMHO, is one of them. Tomasz Lisowski From peter at engcorp.com Sat Feb 3 15:34:16 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 03 Feb 2001 09:34:16 -0500 Subject: import statement within a function References: <95dmp6$n4s$1@news.tpi.pl> <1Yte6.11069$AH6.1772843@newsc.telia.net> <95dr93$dcs$1@news.tpi.pl> <95e9c2$rmm$1@news.tpi.pl> <3A7AB654.D6C16746@engcorp.com> <95gcn6$imb$1@news.tpi.pl> Message-ID: <3A7C16E8.1805AF24@engcorp.com> Tomasz Lisowski wrote: > > "Peter Hansen" : > > The one you highlight, "performance", should probably be > > considered the _least_ important of the points Fredrik raised. > > That depends, on what the given function does, and how often it is called, > of course. > > > The last one, which implies improved maintainability, is > > far more important (IMHO) ... > > Moreover, it is a matter of taste, whether I put the import statement at the > beginning of the file, even if the given module is imported only by one > function, since this function will be eventually called (there was surely a > reason for writing it, wasn't it?). Therefore I have asked Frederik about > REAL advantages, that could persuade me to put import statements within a > function. Performance, IMHO, is one of them. We're definitely talking from different backgrounds, but there's room for that. In my world, performance is NEVER an issue ahead of time, but getting things to work is. Performance becomes an issue only when it is insufficient for the purpose, and in that case it would be good to know that by putting the import inside a "hot spot" function, its performance may be improved. After profiling and seeing unacceptable performance. On the other hand, for me maintainability is ALWAYS an issue ahead of time and throughout the life of the code. To make the code more maintainable, it may be necessary to comment why a module is imported (if it is imported at the top far away from the function using it). By placing the import within the single function which uses it, the code becomes effectively self-documenting and needs no additional comment regarding the module. I can always 'grep' the code to find all import statements, if that is necessary (which it rarely is, for me). So to me this is very much a REAL advantage, but I can see you have a different (and perfectly valid, for you) perspective. :) From danielk at aracnet.com Fri Feb 2 15:00:01 2001 From: danielk at aracnet.com (Daniel Klein) Date: Fri, 02 Feb 2001 06:00:01 -0800 Subject: import statement within a function References: <95dmp6$n4s$1@news.tpi.pl> <1Yte6.11069$AH6.1772843@newsc.telia.net> <95dr93$dcs$1@news.tpi.pl> <95e9c2$rmm$1@news.tpi.pl> Message-ID: On Fri, 2 Feb 2001 13:34:15 +0100, "Tomasz Lisowski" wrote: >> > OK, I have read your mini-guide, and the language reference, and now I Where can I find this 'mini-guide'. I already have the 'The Standard Python Library' and of course the language reference. Thanks, Daniel Klein From fredrik at effbot.org Fri Feb 2 15:51:42 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Fri, 02 Feb 2001 14:51:42 GMT Subject: import statement within a function References: <95dmp6$n4s$1@news.tpi.pl> <1Yte6.11069$AH6.1772843@newsc.telia.net> <95dr93$dcs$1@news.tpi.pl> <95e9c2$rmm$1@news.tpi.pl> Message-ID: <2Qze6.11108$AH6.1780895@newsc.telia.net> Daniel Klein wrote: > Where can I find this 'mini-guide'. I already have the 'The Standard Python > Library' and of course the language reference. http://effbot.org/guides Cheers /F From mmueller at dgfz.de Fri Feb 2 08:56:08 2001 From: mmueller at dgfz.de (Mike Müller) Date: Fri, 2 Feb 2001 08:56:08 +0100 Subject: Naming conventions for path? Message-ID: <95dope$o4k@micky.ibh-dd.de> Setting up my first bigger Python program I find myself al little bit confused with the use of path. That is, using path as a variable I don?t exactly know what I am referring to when joining and spliting path names. I would like to use self explaining variable names for those path parts. Lets look an example: .../dir1/dir2/filename.ext -----------++++++.*** The whole thing is usually referred to as path. But also the part underlined with ---- can be addressed with path. Alternatively the whole thing can be named filename (or any thing else if want to but I talk about conventions). +++.*** can also be filename furthermore +++ filenameRoot ? and *** fileExtension ? also ---- directory or dir ? Are there any conventions in Python (or any other language) that are more or less widely used? Or should I come up with my own naming scheme and just stay consistent throughout may project(s)? Thanks for advise. Mike From zope at thewebsons.com Fri Feb 2 09:41:18 2001 From: zope at thewebsons.com (Ben Ocean) Date: Fri, 02 Feb 2001 00:41:18 -0800 Subject: Chokes on GETPPID Message-ID: <5.0.2.1.0.20010202003611.009e95d0@thewebsons.com> Hi; I'm trying to install Zope and it chokes in this block: >>> if not READ_ONLY: pf = open(PID_FILE, 'w') pid=str(os.getpid()) try: pid=str(os.getppid())+' '+pid except: pass pf.write(pid) pf.close() <<< It specifically identified the *try* statement as the choke-point. How do I trouble-shoot this? TIA, BenO From fredrik at effbot.org Fri Feb 2 10:59:45 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Fri, 02 Feb 2001 09:59:45 GMT Subject: Chokes on GETPPID References: Message-ID: Ben Ocean wrote: > I'm trying to install Zope and it chokes in this block: > >>> > if not READ_ONLY: > pf = open(PID_FILE, 'w') > pid=str(os.getpid()) > try: pid=str(os.getppid())+' '+pid > except: pass > pf.write(pid) > pf.close() > <<< > It specifically identified the *try* statement as the choke-point. > How do I trouble-shoot this? I assume "choke" means that it stopped and printed a traceback message? how about posting that traceback? From zope at thewebsons.com Fri Feb 2 15:18:11 2001 From: zope at thewebsons.com (Ben Ocean) Date: Fri, 02 Feb 2001 06:18:11 -0800 Subject: Chokes on GETPPID In-Reply-To: References: Message-ID: <5.0.2.1.0.20010202061728.00a4fab0@thewebsons.com> At 09:59 AM 2/2/2001 +0000, you wrote: >Ben Ocean wrote: > > I'm trying to install Zope and it chokes in this block: > > >>> > > if not READ_ONLY: > > pf = open(PID_FILE, 'w') > > pid=str(os.getpid()) > > try: pid=str(os.getppid())+' '+pid > > except: pass > > pf.write(pid) > > pf.close() > > <<< > > It specifically identified the *try* statement as the choke-point. > > How do I trouble-shoot this? > >I assume "choke" means that it stopped and printed a >traceback message? how about posting that traceback? ...with traceback... >>> Traceback (innermost last): File "/apache/Zope-2.2.4-linux2-x86/z2.py", line 710, in ? pf = open(PID_FILE, 'w') IOError: [Errno 13] Permission denied: '/apache/Zope-2.2.4-linux2-x86/var/Z2.pid '<<< > > > >-- >http://mail.python.org/mailman/listinfo/python-list From fredrik at effbot.org Fri Feb 2 15:49:43 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Fri, 02 Feb 2001 14:49:43 GMT Subject: Chokes on GETPPID References: Message-ID: Ben Ocean wrote: > > > >>> > > > if not READ_ONLY: > > > pf = open(PID_FILE, 'w') > > > pid=str(os.getpid()) > > > try: pid=str(os.getppid())+' '+pid > > > except: pass > > > pf.write(pid) > > > pf.close() > > > <<< > > > It specifically identified the *try* statement as the choke-point. > > > How do I trouble-shoot this? > > > >I assume "choke" means that it stopped and printed a > >traceback message? how about posting that traceback? > > ...with traceback... > >>> > Traceback (innermost last): > File "/apache/Zope-2.2.4-linux2-x86/z2.py", line 710, in ? > pf = open(PID_FILE, 'w') > IOError: [Errno 13] Permission denied: > '/apache/Zope-2.2.4-linux2-x86/var/Z2.pid > '<<< I'd say it specifically identified the *open* statement as the choke-point... Do you have write privileges in that directory? If the file already exists, is it writable? Cheers /F From robin at jessikat.fsnet.co.uk Fri Feb 2 11:33:55 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 2 Feb 2001 10:33:55 +0000 Subject: nested scopes Message-ID: Is it really true that J Hylton's nested scopes will cause code like def bingo(): from string import * .... to be declared bad? I'm already against nested scopes, but requiring this to be wrong seems awful. We seem to be replacing a simple 2-level system by a more complex one & restrictions. -- Robin Becker From mwh21 at cam.ac.uk Fri Feb 2 13:57:52 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 02 Feb 2001 12:57:52 +0000 Subject: nested scopes References: Message-ID: Robin Becker writes: > Is it really true that J Hylton's nested scopes will cause code like > > def bingo(): > from string import * > .... > > to be declared bad? I'm not sure about how hard a requirement it is. It is illegal in current CVS and probably will be in 2.1a2. Subsequent enormous howls of protest might result in a more gentle solution. We shall see. Cheers, M. -- I have a cat, so I know that when she digs her very sharp claws into my chest or stomach it's really a sign of affection, but I don't see any reason for programming languages to show affection with pain. -- Erik Naggum, comp.lang.lisp From robin at jessikat.fsnet.co.uk Fri Feb 2 14:15:42 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 2 Feb 2001 13:15:42 +0000 Subject: nested scopes References: Message-ID: In article , Michael Hudson writes >Robin Becker writes: > >> Is it really true that J Hylton's nested scopes will cause code like >> >> def bingo(): >> from string import * >> .... >> >> to be declared bad? > >I'm not sure about how hard a requirement it is. It is illegal in >current CVS and probably will be in 2.1a2. Subsequent enormous howls >of protest might result in a more gentle solution. We shall see. > >Cheers, >M. > HOWL HOWL HOWL, gratuitous changes for no very obvious benefit and mysterious side effects are bad mumble, howl, whine. -- Robin Becker From phrxy at csv.warwick.ac.uk Fri Feb 2 16:52:45 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Fri, 2 Feb 2001 15:52:45 +0000 Subject: nested scopes In-Reply-To: References: Message-ID: On Fri, 2 Feb 2001, Robin Becker wrote: > Is it really true that J Hylton's nested scopes will cause code like > > def bingo(): > from string import * > .... > > to be declared bad? I'm already against nested scopes, but requiring > this to be wrong seems awful. We seem to be replacing a simple 2-level > system by a more complex one & restrictions. [...] Are nested scopes actually going to end up in Python proper, then? As opposed to remaining as an optional patch? And why should the above become bad rather than just import into the appropriate namespace? John From robin at jessikat.fsnet.co.uk Fri Feb 2 17:05:58 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 2 Feb 2001 16:05:58 +0000 Subject: nested scopes References: Message-ID: <55q$5KAmrte6EwVo@jessikat.fsnet.co.uk> In article , John J. Lee writes >On Fri, 2 Feb 2001, Robin Becker wrote: > >> Is it really true that J Hylton's nested scopes will cause code like >> >> def bingo(): >> from string import * >> .... >> >> to be declared bad? I'm already against nested scopes, but requiring >> this to be wrong seems awful. We seem to be replacing a simple 2-level >> system by a more complex one & restrictions. >[...] > >Are nested scopes actually going to end up in Python proper, then? As >opposed to remaining as an optional patch? > don't know about that, apparently 2.1a has it >And why should the above become bad rather than just import into the >appropriate namespace? > ... I have a feeling that in order to make nested scopes workable/acceptable the byte compiler is being hacked and this has had some unfortunate side effects. It took me a while to get used to the two level (or three if you split builtins from globals) scoping rule, but I don't miss Algol style nesting a lot and I find the explicit lambda stuff a help rather than a hindrance. I would drop this real soon if I could. -- Robin Becker From thomas at xs4all.net Fri Feb 2 19:46:09 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 2 Feb 2001 19:46:09 +0100 Subject: nested scopes In-Reply-To: <55q$5KAmrte6EwVo@jessikat.fsnet.co.uk>; from robin@jessikat.fsnet.co.uk on Fri, Feb 02, 2001 at 04:05:58PM +0000 References: <55q$5KAmrte6EwVo@jessikat.fsnet.co.uk> Message-ID: <20010202194609.W962@xs4all.nl> On Fri, Feb 02, 2001 at 04:05:58PM +0000, Robin Becker wrote: > In article ac.uk>, John J. Lee writes > >On Fri, 2 Feb 2001, Robin Becker wrote: > > > >> Is it really true that J Hylton's nested scopes will cause code like > >> > >> def bingo(): > >> from string import * > >> .... > >> > >> to be declared bad? I'm already against nested scopes, but requiring > >> this to be wrong seems awful. We seem to be replacing a simple 2-level > >> system by a more complex one & restrictions. > >[...] > > > >Are nested scopes actually going to end up in Python proper, then? As > >opposed to remaining as an optional patch? > don't know about that, apparently 2.1a has it It won't be optional, it'll be part of Python. I guess that if there is a *really* *really* *really* lot of code out there that will break, it could be withheld until Python 2.2, and the practice of 'from foo import *' in function/class scopes be made to issue a warning in Python 2.1, but frankly I doubt there'll be that much code breakage. At least it's not a *silent* breakage ! It's a compiler error, so the first run of a script under the new Python will detect it. It's not like it's a new kind of exception being raised. > >And why should the above become bad rather than just import into the > >appropriate namespace? > > > ... > I have a feeling that in order to make nested scopes workable/acceptable > the byte compiler is being hacked and this has had some unfortunate side > effects. Now, now, 'hacked' is a bit strong. Jeremy did a fairly extensive rewrite of the compiler, complete and decent enough not to be called a 'hack' for sure. Besides, developers never 'hack', they 'extend' :-) The problem with 'from foo import *' in a function or class scope, though, is that it makes it impossible for the compiler to see what names will be defined in that scope, and hence what names a nested scope uses will resolve to that. I don't like it at all, either. In fact, I was the first to whine about it, incessantly, on python-dev. I think I have to buy Jeremy a beer (or whatever's his poison) on the Python conference to make up ;) The situation does lend itself to a workaround (a *true* hack, mind you:) but I haven't looked into implementing it, yet. (Jeremy might be doing that, but I'm not sure): The compiler could try and live with 'from foo import *' as long as the function doesn't define a scope nested in that function. Unfortunately, this isn't going to fix every instance of the problem: a single lambda statement inside the function will make the import illegal again. Disabling nested-scoping in the presense of 'from foo import *' might be technically possible, but would create enormous amounts of confusion, I'm sure. And lastly, I'd like to point out (as Jeremy does :) that the reference manual already states that 'from foo import *' in anything but a module scope is illegal. Even if the nested scopes patch was withdrawn from Python 2.1, 'from foo import *' in local scopes *will* generate a warning (warnings are also new in 2.1) so your best bet, either way, is sanitizing your code. (Don't get me wrong: I seriously think 'from foo import *' is overused. The language reference makes it pretty clear what it was intended for, and I think even the common 'from Tkinter import *' is wrong use -- but I don't like code breakage, regardless.) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From aahz at panix.com Fri Feb 2 20:08:07 2001 From: aahz at panix.com (Aahz Maruch) Date: 2 Feb 2001 11:08:07 -0800 Subject: nested scopes References: <55q$5KAmrte6EwVo@jessikat.fsnet.co.uk> Message-ID: <95f0in$907$1@panix3.panix.com> In article , Thomas Wouters wrote: > >(Don't get me wrong: I seriously think 'from foo import *' is overused. The >language reference makes it pretty clear what it was intended for, and I >think even the common 'from Tkinter import *' is wrong use -- but I don't >like code breakage, regardless.) Yup. I even have one slide in my upcoming Thread Tutorial at IPC9 devoted to editorializing about import. -- --- 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 "People sometimes focus too much on the fact of communication rather than the substance of communication." --Dave Morton From robin at jessikat.fsnet.co.uk Fri Feb 2 20:51:41 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 2 Feb 2001 19:51:41 +0000 Subject: nested scopes References: <55q$5KAmrte6EwVo@jessikat.fsnet.co.uk> Message-ID: In article , Thomas Wouters writes ..... >Now, now, 'hacked' is a bit strong. Jeremy did a fairly extensive rewrite of >the compiler, complete and decent enough not to be called a 'hack' for sure. >Besides, developers never 'hack', they 'extend' :-) The problem with 'from >foo import *' in a function or class scope, though, is that it makes it >impossible for the compiler to see what names will be defined in that scope, >and hence what names a nested scope uses will resolve to that. I don't like >it at all, either. In fact, I was the first to whine about it, incessantly, >on python-dev. I think I have to buy Jeremy a beer (or whatever's his >poison) on the Python conference to make up ;) > I really don't understand why this short cut should be considered such an abomination. Not using it leads to bad maintenance problems ie I either flood my module with names by importing right at the top or I am forced to explicitly import in the target scope. Any name changes in the origin module must then be pursued over the whole world. As for the compiler statically determining what's in scope I thought the whole point of python was that it was dynamic and did late binding. I can't figure out how any compiler is going to figure out that def outer(name): exec name + '=1' def inner(): return g return inner() can work if I call outer('g') so this must only be static scoping; if it's static why should dynamic events like imports be clashing with it. I suppose there's some attempt at code optimisation being pursued. Optimality is the enemy of stability. -- Robin Becker From jeremy at alum.mit.edu Sat Feb 3 00:07:10 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Fri, 02 Feb 2001 23:07:10 GMT Subject: nested scopes References: <55q$5KAmrte6EwVo@jessikat.fsnet.co.uk> Message-ID: <95fein$shj$1@nnrp1.deja.com> In article , Robin Becker wrote: [reflecting on the virtues of 'from ... import *':] > I really don't understand why this short cut should be considered such > an abomination. Not using it leads to bad maintenance problems ie I > either flood my module with names by importing right at the top or I > am forced to explicitly import in the target scope. Any name changes > in the origin module must then be pursued over the whole world. I don't understand your complaint. The first part I follow: You don't want to import names into the module scope. Then you say that explicit imports will cause you to pursue changes over the whole world. I don't get that. If you have a function that does "from mymodule import *", you presumably use some names defined in mymodule like eggs or spam. If you change mymodule so that eggs is replaced with beans, you've got to track down any client of mymodule and update it. If you used "from mymodule import eggs", then you could search for all import lines that mention mymodule and eggs and find all the cases. (This is pursuing it over the whole world, but it's what you get when you change the interface of a module.) If you used "from mymodule import *", you'll need to search for all scopes that import mymodule and then see if they also use the name eggs. It's much harder to find all the cases, because you aren't being explicit about which names you're using from mymodule. On the third hand, if you change the name foo in mymodule to bar, but foo was not used, then it's immaterial whether you used import * or an explicit import. Unless I'm missing something, your maintenance problems are reduced by never using import *. > As for the compiler statically determining what's in scope I thought > the whole point of python was that it was dynamic and did late > binding. I think that's a bit of an exageration :-). I don't think there's a "whole point" to Python. > I can't figure out how any compiler is going to figure out > that > > def outer(name): > exec name + '=1' > def inner(): > return g > return inner() > > can work if I call outer('g') so this must only be static scoping; if > it's static why should dynamic events like imports be clashing with > it. I suppose there's some attempt at code optimisation being pursued. Interesting point you raise. The compiler is supposed to flag this as an error, just like import * and for exactly the same reason. Dynamic name binding via exec or import * are at odds with static scoping -- and you shouldn't try to mix the two. I'll have to fix this in the next release. -- -- Jeremy Hylton, Sent via Deja.com http://www.deja.com/ From robin at jessikat.fsnet.co.uk Sat Feb 3 01:46:55 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 3 Feb 2001 00:46:55 +0000 Subject: nested scopes References: <55q$5KAmrte6EwVo@jessikat.fsnet.co.uk> <95fein$shj$1@nnrp1.deja.com> Message-ID: In article <95fein$shj$1 at nnrp1.deja.com>, Jeremy Hylton writes ... probaly correct analysis of maintainance elided. The only difference on a name change would be the import as well as the actual reference. >I think that's a bit of an exageration :-). I don't think there's a >"whole point" to Python. > >> I can't figure out how any compiler is going to figure out >> that >> >> def outer(name): >> exec name + '=1' >> def inner(): >> return g >> return inner() >> >> can work if I call outer('g') so this must only be static scoping; if >> it's static why should dynamic events like imports be clashing with >> it. I suppose there's some attempt at code optimisation being pursued. > >Interesting point you raise. The compiler is supposed to flag this as >an error, just like import * and for exactly the same reason. Dynamic >name binding via exec or import * are at odds with static scoping -- and >you shouldn't try to mix the two. I'll have to fix this in the next >release. The implication of this is that we're forbidden to use exec if it clashes with a statically scoped name or am I still being stupid? Python is a joy to use because it lacks such pedantic restrictions. >-- >-- Jeremy Hylton, > > >Sent via Deja.com >http://www.deja.com/ -- Robin Becker From tim.one at home.com Sat Feb 3 07:30:12 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Feb 2001 01:30:12 -0500 Subject: nested scopes In-Reply-To: Message-ID: [Robin Becker] > ... > As for the compiler statically determining what's in scope I > thought the whole point of python was that it was dynamic and > did late binding. Na, the whole point of Python was to make Guido filthy rich. It was actually a bet between him and Bill Gates, and, despite what Microsoft may tell you, the final outcome is still uncertain . WRT scopes, the determination of which names are local is entirely done at compile-time. That wasn't always true, but has been true since version 0.9.9, and was the single biggest speedup in Python's history. The determination of which names are local is still done at compile-time in the presence of "import *" and "exec", but then the results can't be trusted, and the compiler generates different code that does all sorts of crap under the covers to give "the expected" results -- most of the time. I doubt that crap will get extended to live nice with deeply nested scopes, though. > ... > Optimality is the enemy of stability. in-america-they-tell-us-it's-drugs-ly y'rs - tim From robin at jessikat.fsnet.co.uk Sat Feb 3 12:25:23 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 3 Feb 2001 11:25:23 +0000 Subject: nested scopes References: Message-ID: <467PpKAjq+e6EwFJ@jessikat.fsnet.co.uk> In article , Tim Peters writes >[Robin Becker] .... >WRT scopes, the determination of which names are local is entirely done at >compile-time. That wasn't always true, but has been true since version >0.9.9, and was the single biggest speedup in Python's history. The >determination of which names are local is still done at compile-time in the >presence of "import *" and "exec", but then the results can't be trusted, >and the compiler generates different code that does all sorts of crap under >the covers to give "the expected" results -- most of the time. I doubt that >crap will get extended to live nice with deeply nested scopes, though. > >> ... >> Optimality is the enemy of stability. > >in-america-they-tell-us-it's-drugs-ly y'rs - tim > > as I suspected this is about optimality; speed vs clarity/simplicity is the argument here. I guess that the nested scopes stuff has just brought it to the fore. Luckily we're not forced to use nested scopes in python, pascal experience makes me despise them because of all that paging up and down to find the defining declaration. -- Robin Becker From tim.one at home.com Sat Feb 3 20:57:51 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Feb 2001 14:57:51 -0500 Subject: nested scopes In-Reply-To: <467PpKAjq+e6EwFJ@jessikat.fsnet.co.uk> Message-ID: [Robin Becker] > as I suspected this is about optimality; Since the local vrbl optimization happened 7 years ago, it really is too late to cry "foul!" on that one . BTW, the *rules* for when a name is local did *not* change then; they simply got exploited; and Python actually got more predictable because of it (although only in obscure endcases, none of which I saw that weren't contrived). > speed vs clarity/simplicity is the argument here. Sorry, but there isn't, and never was, great clarity about what "import *" and "exec" do in all cases; that's why the Reference Manual hedged about them even before the local vrbl optimization was conceived. You have always had to be a bona fide expert in Python's internals to predict their behavior in cases where interaction with the namespaces is anything less than bloody straightforward. That was true before the local vrbl optimization too. > I guess that the nested scopes stuff has just brought it to the fore. It's still in the background for me . > Luckily we're not forced to use nested scopes in python, pascal > experience makes me despise them because of all that paging up > and down to find the defining declaration. I'll repeat something I've said dozens of times over the years in the ongoing scope debate: it's going to be much harder in Python, because there aren't any "defining declarations" in Python. You have to search up and search down, looking at all assignments, all imports, all "for" loops (whether or not nested in listcomps) ... everywhere a binding occurs. Python's "2-level" scheme was a deliberate counterpoint to the abuses of deep lexical nesting in Pascal programs of the time (according to Guido), and it's something I've grown to like a lot. But newbies eternally stumble over that functions nest textually but not lexically in Python, and this will make life simpler for them. People mucking with excruciatingly subtle "exec" and "import" tricks arguably deserved to be shot anyway . not-that-a-plain-"import-*"-at-function-scope-is-excruciatingly- subtle-ly y'rs - tim From fredrik at effbot.org Sat Feb 3 21:55:12 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Sat, 03 Feb 2001 20:55:12 GMT Subject: nested scopes References: Message-ID: Tim Peters wrote: > Python's "2-level" scheme was a deliberate counterpoint to the abuses of > deep lexical nesting in Pascal programs of the time (according to Guido), > and it's something I've grown to like a lot. But newbies eternally stumble > over that functions nest textually but not lexically in Python, and this > will make life simpler for them. I'm beginning to suspect that a new "sorry, you can no longer nest def statements" might have been an easier sell... Cheers /F From aahz at panix.com Sat Feb 3 22:00:12 2001 From: aahz at panix.com (Aahz Maruch) Date: 3 Feb 2001 13:00:12 -0800 Subject: nested scopes References: Message-ID: <95hrgs$3hu$1@panix6.panix.com> In article , Fredrik Lundh wrote: >Tim Peters wrote: >> >> Python's "2-level" scheme was a deliberate counterpoint to the abuses of >> deep lexical nesting in Pascal programs of the time (according to Guido), >> and it's something I've grown to like a lot. But newbies eternally stumble >> over that functions nest textually but not lexically in Python, and this >> will make life simpler for them. > >I'm beginning to suspect that a new "sorry, you can no longer >nest def statements" might have been an easier sell... Taking that seriously, that would cause problems for classes. Not to mention the lambda issue, which I personally would be just as happy to see go bye-bye. -- --- 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 "People sometimes focus too much on the fact of communication rather than the substance of communication." --Dave Morton From tim.one at home.com Sun Feb 4 05:53:47 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Feb 2001 23:53:47 -0500 Subject: nested scopes In-Reply-To: <95hrgs$3hu$1@panix6.panix.com> Message-ID: [/F] > I'm beginning to suspect that a new "sorry, you can no longer > nest def statements" might have been an easier sell... Not a chance. You can't stop people from complaining, you can only influence *what* they complain about. If Python never ever changed anything again, there would be howls of protest against that too. It's much easier to bear complaints about enforcing something the Reference Manual always said you shouldn't do (while it's far from certain things will stay this way for the beta release, if they do then "sorry, but tough luck" is a defensible response). [Aahz, Copyright 2001 by aahz at pobox.com, reproduced without permission] > Taking that seriously, that would cause problems for classes. /F meant "a def block can no longer contain a def block". It's curious how few have ever complained that a def inside a class doesn't have automagic access to the class locals. But do the same thing wrt a def in a def, and it's like Guido is trying to use the time machine to go back and kill John McCarthy's mother before he was born . > Not to mention the lambda issue, which I personally would be just > as happy to see go bye-bye. Well, it *has*, but in the way people expect: >>> def f(n): ... return lambda i: i + n ... >>> f(3)(4) 7 >>> No more "n=n" abuse needed. Politically impossible to remove lambda at this stage anyway. lambda is the print>> of Pytnon functions . From clee at thalamus.wustl.edu Sat Feb 3 23:35:31 2001 From: clee at thalamus.wustl.edu (clee at thalamus.wustl.edu) Date: Sat, 03 Feb 2001 22:35:31 GMT Subject: nested scopes References: <467PpKAjq+e6EwFJ@jessikat.fsnet.co.uk> Message-ID: <95i13k$pfg$1@nnrp1.deja.com> In article , "Tim Peters" wrote: > Python's "2-level" scheme was a deliberate counterpoint to the abuses of > deep lexical nesting in Pascal programs of the time (according to Guido), > and it's something I've grown to like a lot. But newbies eternally stumble > over that functions nest textually but not lexically in Python, and this > will make life simpler for them. Out of curiosity, were explicit declarations for whether scopes nest ever considered? Something like: def f(): A = 1 closure: # all functions declared in this block can access f's # variables def g(): A = 2 Alternative names for closure might be be "bindlocals" or something. I guess this doesn't minimize a beginner's surprise, but it would prevent code breakage. -chris Sent via Deja.com http://www.deja.com/ From robin at jessikat.fsnet.co.uk Sun Feb 4 00:59:59 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 3 Feb 2001 23:59:59 +0000 Subject: nested scopes References: <467PpKAjq+e6EwFJ@jessikat.fsnet.co.uk> Message-ID: <$NN+ELA$tJf6Ewfn@jessikat.fsnet.co.uk> In article , Tim Peters writes >[Robin Becker] >> as I suspected this is about optimality; > >Since the local vrbl optimization happened 7 years ago, it really is too >late to cry "foul!" on that one . BTW, the *rules* for when a name is >local did *not* change then; they simply got exploited; and Python actually >got more predictable because of it (although only in obscure endcases, none >of which I saw that weren't contrived). > ... it's never too late to cry foul -- Robin Becker From root at rainerdeyke.com Sat Feb 3 18:24:51 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sat, 03 Feb 2001 17:24:51 GMT Subject: nested scopes References: Message-ID: "Tim Peters" wrote in message news:mailman.981181863.15223.python-list at python.org... > WRT scopes, the determination of which names are local is entirely done at > compile-time. That wasn't always true, but has been true since version > 0.9.9, and was the single biggest speedup in Python's history. The > determination of which names are local is still done at compile-time in the > presence of "import *" and "exec", but then the results can't be trusted, > and the compiler generates different code that does all sorts of crap under > the covers to give "the expected" results -- most of the time. I doubt that > crap will get extended to live nice with deeply nested scopes, though. "Most of the time" is significant here. There are at least two inconsistencies in functions with 'import *' as of 2.0. Can you say "source of subtle bugs"? -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From tim.one at home.com Sat Feb 3 20:57:50 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Feb 2001 14:57:50 -0500 Subject: nested scopes In-Reply-To: Message-ID: [Tim] > ... > The determination of which names are local is still done at > compile-time in the presence of "import *" and "exec", but then > the results can't be trusted, and the compiler generates > different code that does all sorts of crap under the covers to > give "the expected" results -- most of the time. .... [Rainer Deyke] > "Most of the time" is significant here. I used to lose about 100 hairs a day. Now I think it's closer to 101. Much more significant to me . > There are at least two inconsistencies in functions with 'import *' > as of 2.0. Can you say "source of subtle bugs"? In this case, no. Yes, "import *" is a notorious source of subtle bugs, but all of them reported in real life are due to its advertised behavior (like "hey, 'open()' is broken!", "works for me", "no, it's broken", "what did you change?", "nothing!", "did it used to work?", "well, yes, but then it broke for no reason at all!", "and you changed nothing", "well, nothing relevant -- it just broke!", "so you did change something -- what (exactly) did you change?", "I added a global counter, so maybe the compiler generates bad code now ... and, OK, sure, I added 'from os import *'", ... and that one is so frequent the replybots automatically respond "from os import *" whenever somebody complains "hey, 'open()' is broken!" now). I posted some cases after the 0.9.9 release that showed endcase differences in "import *" and "exec" semantics due to the then-new local variable optimization. All of them were contrived. Guido didn't care; neither did I. In the approximately seven years since then, to the best of my knowledge no bug report on "import *" has ever been filed, and perhaps two were filed on "exec" but in non-contrived cases that were clearly broken. Nevertheless, if you fear the import* "bugs" *you* contrived, SourceForge is open 24 hours a day for patches . never-use-import-*-myself-except-in-an-interactive-shell-ly y'rs - tim From scarblac at pino.selwerd.nl Sun Feb 4 15:50:31 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 4 Feb 2001 14:50:31 GMT Subject: nested scopes References: <55q$5KAmrte6EwVo@jessikat.fsnet.co.uk> Message-ID: Thomas Wouters wrote in comp.lang.python: > It won't be optional, it'll be part of Python. I guess that if there is > a *really* *really* *really* lot of code out there that will break, it could > be withheld until Python 2.2, and the practice of 'from foo import *' in > function/class scopes be made to issue a warning in Python 2.1, but frankly > I doubt there'll be that much code breakage. At least it's not a *silent* > breakage ! It's a compiler error, so the first run of a script under the new > Python will detect it. It's not like it's a new kind of exception being > raised. Argh. I use this quite a lot. To simulate enums, I have a module that defines a lot of constants, and these are used in lots of little functions all over the place, but I wouldn't want those constants in every module's global namespace. So I use from import *... I'm not even sure if I can switch to importing them at the start of the module because there might be name clashes. So because of the Pascal fans, we can't use import * anymore, and always have to type full module names? I'm starting to agree with the people who say that it's all going downhill... This sort of thing was meant for Python 3000! For a reason!! -- Remco Gerlich From scarblac at pino.selwerd.nl Sun Feb 4 16:34:46 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 4 Feb 2001 15:34:46 GMT Subject: nested scopes References: <55q$5KAmrte6EwVo@jessikat.fsnet.co.uk> Message-ID: Remco Gerlich wrote in comp.lang.python: > So because of the Pascal fans, we can't use import * anymore, and always > have to type full module names? I'm starting to agree with the people who > say that it's all going downhill... This sort of thing was meant for > Python 3000! For a reason!! Actually, I was reading some things in the PEP wrong, about masking local variables and so on. It's ok now, I can do without the from import thing, I've tried alpha 2 out, and most things I tried worked exactly how I hoped and not how I feared, so now I like the patch :-). -- Remco Gerlich From tim.one at home.com Sat Feb 3 05:19:19 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 2 Feb 2001 23:19:19 -0500 Subject: nested scopes In-Reply-To: Message-ID: >> def bingo(): >> from string import * > > .... [John J. Lee] > Are nested scopes actually going to end up in Python proper, > then? As opposed to remaining as an optional patch? They're *in* 2.1a2, released earlier today. > And why should the above become bad rather than just import > into the appropriate namespace? Whether a name is local to a given scope is, in Python, determined by whether the name is *bound* somewhere in that scope. "import *" counts as a binding, but the compiler has no idea which names are being bound. So when compiling code for a nested function N, referencing a non-local name (one that is not bound to within N's body) X, the compiler has no idea which scope X belongs to if an "import *" (or "exec" stmt) appears in an enclosing function E. Any name whatsoever *may* become local in E then, but it's impossible to know anything about that at compile-time. If you still think it's easy, submit a patch . invitation-or-threat-is-in-the-eye-of-the-beholder-ly y'rs - tim From loewis at informatik.hu-berlin.de Fri Feb 2 23:14:04 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Feb 2001 23:14:04 +0100 Subject: nested scopes References: Message-ID: Robin Becker writes: > Is it really true that J Hylton's nested scopes will cause code like > > def bingo(): > from string import * > .... > > to be declared bad? That code has been bad for a long time. See http://www.python.org/doc/current/ref/import.html which says # The from form with "*" may only occur in a module scope. It is only now that this restriction is enforced by CPython; again, the code was incorrect for a long time (see http://www.python.org/doc/1.4/ref/ref6.html#REF17806 to get my point; it was also in the 1.1 version of the language reference). Regards, Martin From robin at jessikat.fsnet.co.uk Sat Feb 3 01:47:55 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 3 Feb 2001 00:47:55 +0000 Subject: nested scopes References: Message-ID: In article , Martin von Loewis writes >Robin Becker writes: > >> Is it really true that J Hylton's nested scopes will cause code like >> >> def bingo(): >> from string import * >> .... >> >> to be declared bad? > >That code has been bad for a long time. See > >http://www.python.org/doc/current/ref/import.html > >which says > ># The from form with "*" may only occur in a module scope. > >It is only now that this restriction is enforced by CPython; again, >the code was incorrect for a long time (see > >http://www.python.org/doc/1.4/ref/ref6.html#REF17806 > >to get my point; it was also in the 1.1 version of the language >reference). > >Regards, >Martin imho it's the restriction which is bad. It's just a bunch of imports and assignments. -- Robin Becker From mwh21 at cam.ac.uk Tue Feb 6 16:55:53 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 06 Feb 2001 15:55:53 +0000 Subject: nested scopes References: Message-ID: Martin von Loewis writes: > Robin Becker writes: > > > Is it really true that J Hylton's nested scopes will cause code like > > > > def bingo(): > > from string import * > > .... > > > > to be declared bad? > > That code has been bad for a long time. See > > http://www.python.org/doc/current/ref/import.html > > which says > > # The from form with "*" may only occur in a module scope. > > It is only now that this restriction is enforced by CPython; again, > the code was incorrect for a long time (see > > http://www.python.org/doc/1.4/ref/ref6.html#REF17806 > > to get my point; it was also in the 1.1 version of the language > reference). I've been meaning to say this for a few days, but finally I get round to saying that this particular argument bothers me; Python isn't a language you program with a reference manual open at all times (unlike, say, C++) - and this IMHO is a good thing. This particular change probably isn't too stressful, but I slightly fear more onerous restrictions might be lurking in the ref manual to be whipped out when we next get comfortable with the language. Cheers, M. -- (Of course SML does have its weaknesses, but by comparison, a discussion of C++'s strengths and flaws always sounds like an argument about whether one should face north or east when one is sacrificing one's goat to the rain god.) -- Thant Tessman From loewis at informatik.hu-berlin.de Fri Feb 9 18:46:34 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 09 Feb 2001 18:46:34 +0100 Subject: nested scopes References: Message-ID: Michael Hudson writes: > I've been meaning to say this for a few days, but finally I get round > to saying that this particular argument bothers me; Python isn't a > language you program with a reference manual open at all times > (unlike, say, C++) - and this IMHO is a good thing. This particular > change probably isn't too stressful, but I slightly fear more onerous > restrictions might be lurking in the ref manual to be whipped out when > we next get comfortable with the language. It certainly must be decided on a case-by-case bases, evaluating the impacts in each case. If (like in this case), the ruled-out code uses what many consider bad style, and if the code contradicts with a new desirable feature, then it seems acceptable to break that code. If code is broken, there should be clear instructions for people affected how to modify their code. In other cases, it may be better to remove the restriction from the documentation. Regards, Martin From jeremy at alum.mit.edu Fri Feb 2 23:48:24 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Fri, 02 Feb 2001 22:48:24 GMT Subject: nested scopes References: Message-ID: <95fdfk$rfc$1@nnrp1.deja.com> In article , Robin Becker wrote: > Is it really true that J Hylton's nested scopes will cause code like > > def bingo(): > from string import * > .... > > to be declared bad? I'm already against nested scopes, but requiring > this to be wrong seems awful. We seem to be replacing a simple 2-level > system by a more complex one & restrictions. This code will not work in 2.1 alpha 2. It will raise a SyntaxError exception. I expect the restriction to be eased somewhat for 2.1b1, so that it will be allowed as long as the function doesn't contain other function definitions. This is partly the result of the nested scopes change, and partly the result of some confusion about the reference manual. I'll explain the real problem first. def f(): from string import strip def g(s): return strip(s) return g In 2.1a2, the name strip in g() will use the binding for strip in f(). The resolution of names is determined at compile time. If f() didn't have a binding for strip, then the use in g() would check in globals and builtins. I think this is straightforward. The 'from ... import *' form is a problem, because the compiler can't tell what names will be present in a function scope at compile time. def f(): from string import * def g(s): return strip(s) return g The compiler has know way to know whether 'from string import *' will create a binding for strip in f(). It could ignore the possibility that a binding would be created at runtime and treat strip as a global, but that would be a confusing special case. Instead, the compiler flags it as an error and forces the programmer to be explicit about the binding. While I was working on nested scopes, I noticed that the 2.0 reference manual says that "from ... import *" is illegal anywhere except at the module level (and noted that the compiler did not enforce this rule). Since I was modifying the compiler anyway, I decided to enforce this rule. It meant I didn't have to work about the case I just described above, because any use of 'from ... import *' would be illegal. No one seems to remember why the reference manual outlawed this form of import. (It also outlawed assigning to a name declared global, e.g. "def f(): global time; import time" and we're not sure about that either.) This form seems to be used often enough that we should allow it when there is no ambiguity. I plan to fix the compiler for the next release so that it only complains when 'from ... import *' is used in the presence of nested scopes. As Thomas noted in another message, use of a lambda statement counts as "in the presence of nested scopes." -- -- Jeremy Hylton, Sent via Deja.com http://www.deja.com/ From geoff at homegain.com Sat Feb 3 03:38:54 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Fri, 2 Feb 2001 18:38:54 -0800 Subject: nested scopes Message-ID: <393D961EA4FCD311B03F00D0B746D65802625F27@HQSXCH01> Jeremy writes: > I don't understand your complaint. The first part I follow: You don't > want to import names into the module scope. Then you say > that explicit > imports will cause you to pursue changes over the whole > world. I don't > get that. I think that part of your confusion might be based on your conception of what a module is for. The premise upon which you base your argument is that you will not be using the names you acquire in a dynamic way. For example, if I have a large file, or a large collection of files, all of which contain a large number of variable definitions, I can suck those up into a function and use dir() to grab the list and do things with them. Harder now, without polluting your global namespace, but you can presumably load all the names into a local dictionary, assuming __import__ will not restrict us. An alternative situation where this might be used is in fact highlighted by the very case that the limitation allowed 2.1 to ignore; if we are trying to exploit the dynamism of the language by executing one piece of code while changing out the names it imports from underneath it. While I can't say I don't find nested scopes interesting, I confess that I find them just as troublesome, and I'm really kinda sad to see dynamic features yanked from the language (even if they're unintentional features) just so we can have nested scoping. --- Geoff Gerrietts From tim.one at home.com Sat Feb 3 05:11:50 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 2 Feb 2001 23:11:50 -0500 Subject: nested scopes In-Reply-To: Message-ID: [Robin Becker] > Is it really true that J Hylton's nested scopes will cause code like > > def bingo(): > from string import * > .... > > to be declared bad? As has been pointed out, the "*" form of import has always been documented as unsupported at any but module scope. Sometimes Guido wishes people would read the manuals he worked so hard to write . But as the 2.1a2 NEWS file says, In a future release, the compiler may allow this form when there is no possibility of ambiguity. I guess this depends on how loudly people scream. Before screaming too loudly, though, realize that in 2.0 and before, the mere presence of "import *" in a function forces the compiler to generate worse (slower) code for the entire function body, since it no longer has any idea which names are local, and so has to treat all names as if they "might be" local. "exec" stmts have the same effect on the scope in which they appear. > I'm already against nested scopes, but requiring this to be wrong > seems awful. Was already wrong, and it's unclear how making your code clearer and faster is "awful". > We seem to be replacing a simple 2-level system by a more complex > one & restrictions. Exactly right, except that it has been a 3-level system (which Guido called a 2-level system in a successful attempt to make people think it's simpler than it is ). I don't think I know of any other language trying to mix arbitrarily deeply nested scopes with lack of declarations. The schemes for "import *" and "exec" were hanging by a thread before; it's doubtful they'll ever work well with deep nesting. I may have missed one, but I counted three checkins to repair nested use of "import *" in the CVS tree for the 2.1a2 release. That's not much out of aobut ~6Mb of Python source code. "from Tkinter import *" is the leader for worst offender. 2/3 of the offending lines were written by Guido, 1/3 by Barry. so-i-suppose-guido-is-twice-as-outraged-ly y'rs - tim From loewis at informatik.hu-berlin.de Sat Feb 3 12:17:17 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 03 Feb 2001 12:17:17 +0100 Subject: nested scopes References: Message-ID: Geoffrey Gerrietts writes: > I think that part of your confusion might be based on your conception > of what a module is for. The premise upon which you base your argument > is that you will not be using the names you acquire in a dynamic way. I think this is a fair assumption. You give a counter-example; unfortunately, I cannot understand that example: > For example, if I have a large file, or a large collection of files, > all of which contain a large number of variable definitions, I can > suck those up into a function and use dir() to grab the list and do > things with them. How do you exactly do this? If you have a list of module names, it appears that you will need to do def foo(module_names): for m in module_names: exec "from %s import *" % m return dir() or something like that. That continues to work in the current CVS Python, since the check for import is a static check, not a dynamic one. Or did you have a different algorithm in mind which would stop working? In any case, it might be better to rewrite this function as def foo(module_names): result = [] module = {} for m in module_names: exec "from %s import *" % m in module result += dir(module[m]) return result Even better might be def foo(module_names): result = {} for m in module_names: exec "from %s import *" % m in result return dir(x) With that, you execute the import neither in local nor in global namespace; you do so in a "fresh" namespace. > While I can't say I don't find nested scopes interesting, I confess > that I find them just as troublesome, and I'm really kinda sad to > see dynamic features yanked from the language (even if they're > unintentional features) just so we can have nested scoping. I can't see any dynamic features being yanked - I can see that of the many ways to do a certain dynamic thing, one way is removed. There's Only One Way To Do It, anyway. Regards, Martin From root at rainerdeyke.com Sat Feb 3 18:24:51 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sat, 03 Feb 2001 17:24:51 GMT Subject: nested scopes References: Message-ID: "Martin von Loewis" wrote in message news:p6qhf2crp6q.fsf at informatik.hu-berlin.de... > def foo(module_names): > for m in module_names: > exec "from %s import *" % m > return dir() Yuck. def foo(*names): dict = {} for name in names: dict.update(__import__(name).__dict__) return dict Note the absensce of local variables 'm' and 'module_names' in the returned dictionary. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From loewis at informatik.hu-berlin.de Fri Feb 9 18:48:14 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 09 Feb 2001 18:48:14 +0100 Subject: nested scopes References: Message-ID: "Rainer Deyke" writes: > "Martin von Loewis" wrote in message > news:p6qhf2crp6q.fsf at informatik.hu-berlin.de... > > def foo(module_names): > > for m in module_names: > > exec "from %s import *" % m > > return dir() > > Yuck. > > def foo(*names): > dict = {} > for name in names: > dict.update(__import__(name).__dict__) > return dict > > Note the absensce of local variables 'm' and 'module_names' in the returned > dictionary. OTOH, note the presence of names starting with an underscore in the returned dictionary. Regards, Martin From n8gray at caltech.edu.is.my.email.address Mon Feb 5 11:01:58 2001 From: n8gray at caltech.edu.is.my.email.address (Nathaniel Gray) Date: Mon, 5 Feb 2001 02:01:58 -0800 Subject: nested scopes References: Message-ID: <95lu1i$ebs@gap.cco.caltech.edu> Tim Peters wrote: > Whether a name is local to a given scope is, in Python, determined by > whether the name is *bound* somewhere in that scope. "import *" counts as > a > binding, but the compiler has no idea which names are being bound. So > when compiling code for a nested function N, referencing a non-local name > (one that is not bound to within N's body) X, the compiler has no idea > which scope X belongs to if an "import *" (or "exec" stmt) appears in an > enclosing > function E. Any name whatsoever *may* become local in E then, but it's > impossible to know anything about that at compile-time. Interesting issue. What if the following was allowed: >>> from tim_bot_module import tb* telling the compiler that only names beginning with "tb" are imported. This way you could still design libraries to use from ... import ..* without totally throwing efficiency out the window. I know import * is considered harmful, but occasionally (think tkinter) it's a useful construct, assuming the library is designed to prevent name conflicts. Just a thought, -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From dsh8290 at rit.edu Mon Feb 5 18:42:42 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 5 Feb 2001 12:42:42 -0500 Subject: nested scopes In-Reply-To: <95lu1i$ebs@gap.cco.caltech.edu>; from n8gray@caltech.edu.is.my.email.address on Mon, Feb 05, 2001 at 02:01:58AM -0800 References: <95lu1i$ebs@gap.cco.caltech.edu> Message-ID: <20010205124241.A27402@harmony.cs.rit.edu> On Mon, Feb 05, 2001 at 02:01:58AM -0800, Nathaniel Gray wrote: | Tim Peters wrote: | | > Whether a name is local to a given scope is, in Python, determined by | > whether the name is *bound* somewhere in that scope. "import *" counts as | > a | > binding, but the compiler has no idea which names are being bound. So | > when compiling code for a nested function N, referencing a non-local name | > (one that is not bound to within N's body) X, the compiler has no idea | > which scope X belongs to if an "import *" (or "exec" stmt) appears in an | > enclosing | > function E. Any name whatsoever *may* become local in E then, but it's | > impossible to know anything about that at compile-time. | | Interesting issue. What if the following was allowed: | >>> from tim_bot_module import tb* | Hmm, wouldn't it be better to use : >>> import tim_bot_module as tb >>> tb.name_you_want_to_use ? IMO prefixing names with strings like "tb" is for namespace-less languages like C. Since python has namespaces, why not use them? What I wonder about is whether names defined in a try block or a for block will still exist outside the block. Take this Java code for example: String s ; try { s = some_func_that_might_throw() ; } catch ( ThrownException ex ) { s = "Some other value" ; } So you look at it and whether the function throws an exception or not, s has been initialized appropriately. javac won't compile this since "s might not be initialized". In Python, it is much nicer : try : s = some_func_that_might_throw() except ThrownException : s = "Some other value" and everything works as expected. If the exception was thrown, s will have the one value, if not it will have the other. Will the new nested scopes require me to write: s = None # make the name exist in this scope first try : ... ? I think it is acceptable if variables like loop counters and temps inside a loop don't exist in the function's namespace. ie: for i in range( 10 ) : pass print i # this gives NameError but : i = 1 for i in range( 10 ) : pass print i # prints '9' since the name i already existed and was rebound What I wonder about is how important/useful nested scopes really are. When I first learned python, I had an Eiffel/C++/C background with maybe a little Java. Each of those has nested lexical scopes. I thought python was weird and lacking. I have since learned that python is quite natural and doesn't require various ugly idioms (declaring the variable at the top) to make the assignment in the nested scope persist outside the loop/if/whatever. Last quarter I took a class called "Programming Language Concepts" that discussed the design of programming languages. It was the first time I had heard of dynamic scoping. (Actually, I think I saw it mentioned in a lisp context, but I didn't know what it meant) The professor didn't know of any situations where it would be advantageous, and I couldn't contrive any either. I was kind of surprised when I heard python described as "dynamically scoped" because its scoping was really quite natural for me. The [23]-level scoping makes the dynamic scoping almost static and I don't see that as a weakness. I really don't know, at this moment, whether adding nested static scopes will strengthen or weaken the language. just-a-few-thoughts-ly y'rs -D From dnew at san.rr.com Mon Feb 5 19:39:07 2001 From: dnew at san.rr.com (Darren New) Date: Mon, 05 Feb 2001 18:39:07 GMT Subject: nested scopes References: <95lu1i$ebs@gap.cco.caltech.edu> Message-ID: <3A7EF349.407C71E1@san.rr.com> D-Man wrote: > professor didn't know of any situations where it would be > advantageous, and I couldn't contrive any either. I was kind of > surprised when I heard python described as "dynamically scoped" > because its scoping was really quite natural for me. That's because your prof doesn't know what "dynamic scoping" is. def alpha(): a = 5 gamma() beta() gamma() def beta(): a = 17 gamma() def gamma(): print a alpha() With dynamic scoping, this would print "5" then "17" then "5" again, as "gamma" would basically walk up the run-time call stack looking for the most recent "a" to print. (Note that "a" is supposed to be local everywhere, not a global.) Obviously, this is *not* how Python works. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. Ignorance can be cured. Naivety cures itself. From dsh8290 at rit.edu Tue Feb 6 15:38:09 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 6 Feb 2001 09:38:09 -0500 Subject: nested scopes In-Reply-To: <3A7EF349.407C71E1@san.rr.com>; from dnew@san.rr.com on Mon, Feb 05, 2001 at 06:39:07PM +0000 References: <95lu1i$ebs@gap.cco.caltech.edu> <3A7EF349.407C71E1@san.rr.com> Message-ID: <20010206093809.A1360@harmony.cs.rit.edu> On Mon, Feb 05, 2001 at 06:39:07PM +0000, Darren New wrote: | D-Man wrote: | > professor didn't know of any situations where it would be | > advantageous, and I couldn't contrive any either. I was kind of | > surprised when I heard python described as "dynamically scoped" | > because its scoping was really quite natural for me. | | That's because your prof doesn't know what "dynamic scoping" is. Maybe not, it seemed very confusing. I still have the book, though I haven't read it much (maybe I should ...) Do you know of any situations where it would be advantageous to have dynamic scoping instead of static scoping? (Note that I'm not asking for situations where dynamic scoping exists, but where it would be better) | | | def alpha(): | a = 5 | gamma() | beta() | gamma() | | def beta(): | a = 17 | gamma() | | def gamma(): | print a | | alpha() | | With dynamic scoping, this would print "5" then "17" then "5" again, as | "gamma" would basically walk up the run-time call stack looking for the most | recent "a" to print. (Note that "a" is supposed to be local everywhere, not Yeah, this is what I thought dynamic scoping would do. | a global.) Obviously, this is *not* how Python works. Right, in Python, gamma() would complain that it can't find 'a'. This is why I said that python's scope rules are really not hard to understand. -D From dnew at san.rr.com Tue Feb 6 19:19:16 2001 From: dnew at san.rr.com (Darren New) Date: Tue, 06 Feb 2001 18:19:16 GMT Subject: nested scopes References: <95lu1i$ebs@gap.cco.caltech.edu> <3A7EF349.407C71E1@san.rr.com> Message-ID: <3A804026.AD3D1540@san.rr.com> D-Man wrote: > Do you know of any situations where it would be advantageous to have > dynamic scoping instead of static scoping? (Note that I'm not asking > for situations where dynamic scoping exists, but where it would be > better) My understanding is that it was more an artifact of the implementation of LISP than it was a desirous effect. It might be better if you're trying to form closures or do funky macro stuff or something, but I'm not sure. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. Ignorance can be cured. Naivety cures itself. From mwh21 at cam.ac.uk Tue Feb 6 19:43:28 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 06 Feb 2001 18:43:28 +0000 Subject: nested scopes References: <95lu1i$ebs@gap.cco.caltech.edu> <3A7EF349.407C71E1@san.rr.com> <3A804026.AD3D1540@san.rr.com> Message-ID: Darren New writes: > D-Man wrote: > > Do you know of any situations where it would be advantageous to have > > dynamic scoping instead of static scoping? (Note that I'm not asking > > for situations where dynamic scoping exists, but where it would be > > better) > > My understanding is that it was more an artifact of the implementation of > LISP than it was a desirous effect. It might be better if you're trying to > form closures or do funky macro stuff or something, but I'm not sure. It's good when you're calling a function (call it A) that calls another function (call this one B) that has parameterizable behaviour, because A doesn't have to put all of B's parameters in its argument list - you get B to read these paramters from special (ie. dynamically scoped) variables and bind them around your call to A. Can't think of a real good example now, I'm afraid. The Common Lisp printer uses special variables extensively. I'm not sure this could be made to work in Python, not least because it has a rather different notion of binding to Python. Cheers, M. -- Roll on a game of competetive offence-taking. -- Dan Sheppard, ucam.chat From root at rainerdeyke.com Tue Feb 6 21:10:03 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 06 Feb 2001 20:10:03 GMT Subject: nested scopes References: <95lu1i$ebs@gap.cco.caltech.edu> <3A7EF349.407C71E1@san.rr.com> <3A804026.AD3D1540@san.rr.com> Message-ID: "Michael Hudson" wrote in message news:m3r91b3b5b.fsf at atrus.jesus.cam.ac.uk... > It's good when you're calling a function (call it A) that calls > another function (call this one B) that has parameterizable behaviour, > because A doesn't have to put all of B's parameters in its argument > list - you get B to read these paramters from special (ie. dynamically > scoped) variables and bind them around your call to A. Can't think of > a real good example now, I'm afraid. The Common Lisp printer uses > special variables extensively. Some Python functions (including 'globals' and 'locals') have behavior similar to that of dynamic scoping. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From mwh21 at cam.ac.uk Tue Feb 6 21:35:09 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 06 Feb 2001 20:35:09 +0000 Subject: nested scopes References: <95lu1i$ebs@gap.cco.caltech.edu> <3A7EF349.407C71E1@san.rr.com> <3A804026.AD3D1540@san.rr.com> Message-ID: "Rainer Deyke" writes: > "Michael Hudson" wrote in message > news:m3r91b3b5b.fsf at atrus.jesus.cam.ac.uk... > > It's good when you're calling a function (call it A) that calls > > another function (call this one B) that has parameterizable behaviour, > > because A doesn't have to put all of B's parameters in its argument > > list - you get B to read these paramters from special (ie. dynamically > > scoped) variables and bind them around your call to A. Can't think of > > a real good example now, I'm afraid. The Common Lisp printer uses > > special variables extensively. > > Some Python functions (including 'globals' and 'locals') have behavior > similar to that of dynamic scoping. How so? Note I'm using "dynamic scope" in a pretty technical sense here - "indefinite scope and dynamic extent". Python variables have definite scope and dynamic extent (although the objects they point to have indefinite extent). Here's a reference: http://ringer.cs.utsa.edu/research/AI/cltl/clm/node43.html Cheers, M. -- ARTHUR: Why should he want to know where his towel is? FORD: Everybody should know where his towel is. ARTHUR: I think your head's come undone. -- The Hitch-Hikers Guide to the Galaxy, Episode 7 From root at rainerdeyke.com Tue Feb 6 22:45:39 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 06 Feb 2001 21:45:39 GMT Subject: nested scopes References: <95lu1i$ebs@gap.cco.caltech.edu> <3A7EF349.407C71E1@san.rr.com> <3A804026.AD3D1540@san.rr.com> Message-ID: <7g_f6.182817$ge4.63254223@news2.rdc2.tx.home.com> "Michael Hudson" wrote in message news:m3lmrj35z6.fsf at atrus.jesus.cam.ac.uk... > "Rainer Deyke" writes: > > Some Python functions (including 'globals' and 'locals') have behavior > > similar to that of dynamic scoping. > > How so? Note I'm using "dynamic scope" in a pretty technical sense > here - "indefinite scope and dynamic extent". Python variables have > definite scope and dynamic extent (although the objects they point to > have indefinite extent). I am referring to the fact that these functions access the namespace of the calling function. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From mwh21 at cam.ac.uk Tue Feb 6 22:59:03 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 06 Feb 2001 21:59:03 +0000 Subject: nested scopes References: <95lu1i$ebs@gap.cco.caltech.edu> <3A7EF349.407C71E1@san.rr.com> <3A804026.AD3D1540@san.rr.com> <7g_f6.182817$ge4.63254223@news2.rdc2.tx.home.com> Message-ID: "Rainer Deyke" writes: > "Michael Hudson" wrote in message > news:m3lmrj35z6.fsf at atrus.jesus.cam.ac.uk... > > "Rainer Deyke" writes: > > > Some Python functions (including 'globals' and 'locals') have behavior > > > similar to that of dynamic scoping. > > > > How so? Note I'm using "dynamic scope" in a pretty technical sense > > here - "indefinite scope and dynamic extent". Python variables have > > definite scope and dynamic extent (although the objects they point to > > have indefinite extent). > > I am referring to the fact that these functions access the namespace of the > calling function. Oh, I see (I think). I wouldn't have said that was an instructive example myself. Cheers, M. -- All parts should go together without forcing. You must remember that the parts you are reassembling were disassembled by you. Therefore, if you can't get them together again, there must be a reason. By all means, do not use a hammer. -- IBM maintenance manual, 1925 From ben.hutchings at roundpoint.com Tue Feb 6 21:36:43 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 06 Feb 2001 12:36:43 -0800 Subject: nested scopes References: <95lu1i$ebs@gap.cco.caltech.edu> <3A7EF349.407C71E1@san.rr.com> <3A804026.AD3D1540@san.rr.com> Message-ID: Michael Hudson writes: [about dynamic scoping] > It's good when you're calling a function (call it A) that calls > another function (call this one B) that has parameterizable behaviour, > because A doesn't have to put all of B's parameters in its argument > list - you get B to read these paramters from special (ie. dynamically > scoped) variables and bind them around your call to A. Can't think of > a real good example now, I'm afraid. The Common Lisp printer uses > special variables extensively. If you consider Unix processes as functions, then a process's environment is its dynamic scope. There are many interesting uses for environmental variables. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From johann at physics.berkeley.edu Tue Feb 6 22:08:40 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 06 Feb 2001 13:08:40 -0800 Subject: nested scopes References: <95lu1i$ebs@gap.cco.caltech.edu> <3A7EF349.407C71E1@san.rr.com> Message-ID: D-Man writes: > Do you know of any situations where it would be advantageous to have > dynamic scoping instead of static scoping? (Note that I'm not asking > for situations where dynamic scoping exists, but where it would be > better) Well, it's very useful for output. You can write all of your functions to output to the standard output stream, and then redirect that output stream with something like: ;; ;; Pseudo-lisp. All of my function names are wrong, but I'm lazy. ;; (let ((*standard-output-stream* (open-output-file "file.dat"))) (generate-big-report)) That way, output will be redirected while you're inside generate-big-report, but will automatically be switched back. In python, a similar thing would be try: temp = sys.stdout # redirect output. file = open('file.dat', 'w') sys.stdout = file generate_big_report() finally: file.close() sys.stdout = temp # make sure that you fix it. -- Johann Hibschman johann at physics.berkeley.edu From jhylton at my-deja.com Mon Feb 5 19:57:56 2001 From: jhylton at my-deja.com (Jeremy Hylton) Date: Mon, 05 Feb 2001 18:57:56 GMT Subject: nested scopes References: <95lu1i$ebs@gap.cco.caltech.edu> Message-ID: <95mt3e$9pe$1@nnrp1.deja.com> In article , D-Man wrote: > What I wonder about is whether names defined in a try block or a for > block will still exist outside the block. > > Take this Java code for example: > > String s ; > try > { > s = some_func_that_might_throw() ; > } > catch ( ThrownException ex ) > { > s = "Some other value" ; > } > > So you look at it and whether the function throws an exception or not, > s has been initialized appropriately. javac won't compile this since > "s might not be initialized". > > In Python, it is much nicer : > > try : > s = some_func_that_might_throw() > except ThrownException : > s = "Some other value" > > and everything works as expected. If the exception was thrown, s will > have the one value, if not it will have the other. > > Will the new nested scopes require me to write: > > s = None # make the name exist in this scope first > try : > ... > > ? No. Nested scopes don't require you to do anything different unless you actually use nested scopes. In places where Java would raise a compile-time error because it can't tell if a name will be used unitialized, Python will not complain at comile time. Instead, it will raise a NameError if an error occurs at run time. I won't offer any opinions about which is better. > I think it is acceptable if variables like loop counters and temps > inside a loop don't exist in the function's namespace. ie: Regardless of whether you find it acceptable, the language doesn't work that way. > Last quarter I took a class called "Programming Language Concepts" > that discussed the design of programming languages. It was the first > time I had heard of dynamic scoping. (Actually, I think I saw it > mentioned in a lisp context, but I didn't know what it meant) The > professor didn't know of any situations where it would be > advantageous, and I couldn't contrive any either. I was kind of > surprised when I heard python described as "dynamically scoped" > because its scoping was really quite natural for me. The [23]-level > scoping makes the dynamic scoping almost static and I don't see that > as a weakness. Python's scoping rules aren't dynamic, never have been. (At least not as long as I've been using the language.) It used to be that scopes didn't nest, but that doesn't make scoping dynamic. > > I really don't know, at this moment, whether adding nested static > scopes will strengthen or weaken the language. PEP 227 has a brief discussion of some benefits, among them that lambdas are easier to use. http://python.sourceforge.net/peps/ -- -- Jeremy Hylton, Sent via Deja.com http://www.deja.com/ From dsh8290 at rit.edu Tue Feb 6 15:44:53 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 6 Feb 2001 09:44:53 -0500 Subject: nested scopes In-Reply-To: <95mt3e$9pe$1@nnrp1.deja.com>; from jhylton@my-deja.com on Mon, Feb 05, 2001 at 06:57:56PM +0000 References: <95lu1i$ebs@gap.cco.caltech.edu> <95mt3e$9pe$1@nnrp1.deja.com> Message-ID: <20010206094453.B1360@harmony.cs.rit.edu> On Mon, Feb 05, 2001 at 06:57:56PM +0000, Jeremy Hylton wrote: | In article , | D-Man wrote: [snip] | | No. Nested scopes don't require you to do anything different unless you | actually use nested scopes. In places where Java would raise a | compile-time error because it can't tell if a name will be used | unitialized, Python will not complain at comile time. Instead, it will | raise a NameError if an error occurs at run time. I won't offer any | opinions about which is better. Hmm, ok. I think I need to learn more details of how this nested scope change affects the rules/semantics of python. | | > I think it is acceptable if variables like loop counters and temps | > inside a loop don't exist in the function's namespace. ie: | | Regardless of whether you find it acceptable, the language doesn't work | that way. I just thought that that might have been something the nested scopes would have changed. I was letting you know I won't complain if that change happens, though I'm not requesting it either :-). I think that maybe my experience with C/C++/Java isn't helping me here. Those languages have nested scopes and variables declared in such a scope disappear outside that scope. This makes sense. I guess the difference is that a loop/if/try block defines a scope in C/C++/Java but doesn't in Python. This is probably where I got confused. | | > Last quarter I took a class called "Programming Language Concepts" | > that discussed the design of programming languages. It was the first | > time I had heard of dynamic scoping. (Actually, I think I saw it | > mentioned in a lisp context, but I didn't know what it meant) The | > professor didn't know of any situations where it would be | > advantageous, and I couldn't contrive any either. I was kind of | > surprised when I heard python described as "dynamically scoped" | > because its scoping was really quite natural for me. The [23]-level | > scoping makes the dynamic scoping almost static and I don't see that | > as a weakness. | | Python's scoping rules aren't dynamic, never have been. (At least not | as long as I've been using the language.) It used to be that scopes | didn't nest, but that doesn't make scoping dynamic. I thought I heard someone say that python's scoping rules are (prior to 2.1a1, that is) dynamic. | | > | > I really don't know, at this moment, whether adding nested static | > scopes will strengthen or weaken the language. | | PEP 227 has a brief discussion of some benefits, among them that lambdas | are easier to use. http://python.sourceforge.net/peps/ I think I ought to read that in more detail, and probably read up on the accepted definitions of some terms. Thanks for the reply. -D From n8gray at caltech.edu.is.my.email.address Tue Feb 6 09:00:47 2001 From: n8gray at caltech.edu.is.my.email.address (Nathaniel Gray) Date: Tue, 6 Feb 2001 00:00:47 -0800 Subject: nested scopes References: <95lu1i$ebs@gap.cco.caltech.edu> Message-ID: <95obae$oc2@gap.cco.caltech.edu> D-Man wrote: > On Mon, Feb 05, 2001 at 02:01:58AM -0800, Nathaniel Gray wrote: > | > | Interesting issue. What if the following was allowed: > | >>> from tim_bot_module import tb* > | > > Hmm, wouldn't it be better to use : > > >>> import tim_bot_module as tb > >>> tb.name_you_want_to_use > > ? > > IMO prefixing names with strings like "tb" is for namespace-less > languages like C. Since python has namespaces, why not use them? > Yes, that would be the preferred method, but there are modules (TKInter, Numpy, wxPython) that are designed to be used with the "import *" idiom. This proposal would just allow you to use those modules without sacrificing efficiency. I agree, though, that "import .. as .." goes a long way towards making "import *" unnecessary. -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From n8gray at caltech.edu.is.my.email.address Tue Feb 6 09:00:47 2001 From: n8gray at caltech.edu.is.my.email.address (Nathaniel Gray) Date: Tue, 6 Feb 2001 00:00:47 -0800 Subject: nested scopes References: <95lu1i$ebs@gap.cco.caltech.edu> Message-ID: <95obd1$ocb@gap.cco.caltech.edu> D-Man wrote: > On Mon, Feb 05, 2001 at 02:01:58AM -0800, Nathaniel Gray wrote: > | > | Interesting issue. What if the following was allowed: > | >>> from tim_bot_module import tb* > | > > Hmm, wouldn't it be better to use : > > >>> import tim_bot_module as tb > >>> tb.name_you_want_to_use > > ? > > IMO prefixing names with strings like "tb" is for namespace-less > languages like C. Since python has namespaces, why not use them? > Yes, that would be the preferred method, but there are modules (TKInter, Numpy, wxPython) that are designed to be used with the "import *" idiom. This proposal would just allow you to use those modules without sacrificing efficiency. I agree, though, that "import .. as .." goes a long way towards making "import *" unnecessary. -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From moshez at zadka.site.co.il Tue Feb 6 13:48:16 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Tue, 6 Feb 2001 14:48:16 +0200 (IST) Subject: nested scopes In-Reply-To: <95lu1i$ebs@gap.cco.caltech.edu> References: <95lu1i$ebs@gap.cco.caltech.edu>, Message-ID: <20010206124816.A2EA5A840@darjeeling.zadka.site.co.il> On Mon, 5 Feb 2001, Nathaniel Gray wrote: > Interesting issue. What if the following was allowed: > >>> from tim_bot_module import tb* Why wouldn't import tim_bot_module as tb And losing the "tb" prefix in tim_bot_module work? -- For public key: finger moshez at debian.org | gpg --import Debian - All the power, without the silly hat. Fingerprint: 4BD1 7705 EEC0 260A 7F21 4817 C7FC A636 46D0 1BD6 From jschmitt at vmlabs.com Tue Feb 6 07:42:29 2001 From: jschmitt at vmlabs.com (John Schmitt) Date: Mon, 5 Feb 2001 22:42:29 -0800 Subject: nested scopes Message-ID: <008F0A63472BD311AF9800104BCD102561CB4B@minirex.vmlabs.com> > -----Original Message----- > From: Nathaniel Gray [mailto:n8gray at caltech.edu.is.my.email.address] > Sent: Monday, February 05, 2001 2:02 AM > To: python-list at python.org > Subject: RE: nested scopes [snip] > telling the compiler that only names beginning with "tb" are > imported. > This way you could still design libraries to use from ... import ..* > without totally throwing efficiency out the window. I know > import * is > considered harmful, but occasionally (think tkinter) it's a useful > construct, assuming the library is designed to prevent name conflicts. [snip] When I first picked up Python, I typed in a couple of examples from Grayson's book. I would always say: import Tkinter tk = Tkinter root = tk.Tk() # etc I tacked on a 'tk.' in front of tk calls. I wanted to know which function came from tk and which came from the standard python library etc. For what it's worth, I'd like to say that I'm happy that from ... import..* is discouraged and if it disappeard from the language completely, I wouldn't miss it. Only slightly related is the fact anything that looks like Pascal's 'with' would be completely wasted on me. :-) I'd rather prepend class name. Explicit is better than implicit, right? John From greg at cosc.canterbury.ac.nz Fri Feb 9 01:24:10 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 09 Feb 2001 13:24:10 +1300 Subject: nested scopes References: Message-ID: <3A8338AA.D713D628@cosc.canterbury.ac.nz> Tim Peters wrote: > > It's curious how > few have ever complained that a def inside a class doesn't have automagic > access to the class locals. But they *do* complain about having to make explicit references to 'self', which is the analogous thing there. -- 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 jmarshal at mathworks.com Fri Feb 9 08:12:45 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 9 Feb 2001 07:12:45 GMT Subject: nested scopes References: <3A8338AA.D713D628@cosc.canterbury.ac.nz> Message-ID: <96059d$din$1@news.mathworks.com> Greg Ewing wrote: > Tim Peters wrote: >> >> It's curious how >> few have ever complained that a def inside a class doesn't have automagic >> access to the class locals. > But they *do* complain about having to make explicit > references to 'self', which is the analogous thing there. Still this is a different issue than lexical scoping. Consider: class T: def m(self): print self.x T.x = 'foo' T().m() Here, T().m() prints "foo". Lexically, x is not defined in m's scope. I believe it was a good decision to require going through self to access class/object fields. This is very different than something like: def f(): x = 1 def g(): print x g() where x is lexically in g's scope. From aahz at panix.com Fri Feb 9 16:40:21 2001 From: aahz at panix.com (Aahz Maruch) Date: 9 Feb 2001 07:40:21 -0800 Subject: nested scopes References: <3A8338AA.D713D628@cosc.canterbury.ac.nz> <96059d$din$1@news.mathworks.com> Message-ID: <961315$l60$1@panix2.panix.com> In article <96059d$din$1 at news.mathworks.com>, Joshua Marshall wrote: > >Still this is a different issue than lexical scoping. Consider: > > class T: > def m(self): > print self.x > > T.x = 'foo' > > T().m() > >Here, T().m() prints "foo". Lexically, x is not defined in m's scope. >I believe it was a good decision to require going through self to >access class/object fields. Note that you don't necessarily want to go through self to access class fields. Here you're relying on the search through the class hierarchy to access T.x with self.x. (I'm pretty sure you know this, but I don't want any newcomers getting confused.) -- --- 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 "Actually, I've found that Usenet has helped a lot with my terror of social stupidity. Seeing people I really like and respect behave like idiots in public has been very beneficial." --Rachael Lininger From jeremy at alum.mit.edu Fri Feb 9 18:55:12 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Fri, 09 Feb 2001 17:55:12 GMT Subject: nested scopes References: <3A8338AA.D713D628@cosc.canterbury.ac.nz> <96059d$din$1@news.mathworks.com> Message-ID: <961atr$a9v$1@nnrp1.deja.com> In article <96059d$din$1 at news.mathworks.com>, Joshua Marshall wrote: > > But they *do* complain about having to make explicit > > references to 'self', which is the analogous thing there. > > Still this is a different issue than lexical scoping. Consider: > > class T: > def m(self): > print self.x > > T.x = 'foo' > > T().m() > > Here, T().m() prints "foo". Lexically, x is not defined in m's scope. > I believe it was a good decision to require going through self to > access class/object fields. This is very different than something > like: > > def f(): > x = 1 > def g(): > print x > g() > > where x is lexically in g's scope. > I agree that these examples are very different. In the first, the variable name is self and x is an attribute. In the second, x is itself a variable. Python has very different rules for name lookup and attribute lookup. The few complaints I have seen about nested scopes on this list all describe dynamic behavior that is probably better done with objects and attributes. While nested scopes are useful, many of the uses people put them to in other languages are probably best done with instances in Python. -- -- Jeremy Hylton, Sent via Deja.com http://www.deja.com/ From paolo.salvan.amniup at libero.it Fri Feb 2 11:50:39 2001 From: paolo.salvan.amniup at libero.it (paolo.salvan.amniup at libero.it) Date: Fri, 02 Feb 2001 10:50:39 GMT Subject: wish: "struct" module extension proposal Message-ID: <95e3dt$kq0$1@nnrp1.deja.com> I'm using the "struct" module to pack/unpack binary data... I often pack strings rappresenting raw binary data putting a 4-bytes integer indicating the string length, followed by the string data...(it's likes the Pascal string coding schema, but with 4-bytes prefix instead of the 1 byte prefix) I think it would be generally useful if the struct format string was extended to directly support this packing schema...what you think? Paolo Sent via Deja.com http://www.deja.com/ From spam at spam.com Fri Feb 2 23:16:56 2001 From: spam at spam.com (Penfold) Date: Fri, 2 Feb 2001 22:16:56 -0000 Subject: "struct" module extension proposal References: <95e3dt$kq0$1@nnrp1.deja.com> Message-ID: I often pack strings in reverse using an 8 byte number at the end of the string to tell the user how long it was I too think that the struct module needs extending to directly support my arbitrrary packing structure. What do you think ? Des :-) wrote in message news:95e3dt$kq0$1 at nnrp1.deja.com... > I'm using the "struct" module to pack/unpack binary data... > > I often pack strings rappresenting raw binary data putting a 4-bytes > integer indicating the string length, followed by the string > data...(it's likes the Pascal string coding schema, but with 4-bytes > prefix instead of the 1 byte prefix) > > I think it would be generally useful if the struct format string was > extended to directly support this packing schema...what you think? > > Paolo > > > Sent via Deja.com > http://www.deja.com/ From kirschh at lionbioscience.com Fri Feb 2 14:08:20 2001 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 02 Feb 2001 14:08:20 +0100 Subject: execfile('bla.py'), can bla.py know its full path Message-ID: When a script is called by execfile, can it find out the full absolute path name by which it was called? Harald Kirsch -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?" LION Bioscience | +49 6221 4038 172 | -- Paul Erd?s From jcm at bigskytel.com Fri Feb 2 14:36:55 2001 From: jcm at bigskytel.com (David Porter) Date: Fri, 2 Feb 2001 06:36:55 -0700 Subject: execfile('bla.py'), can bla.py know its full path In-Reply-To: ; from kirschh@lionbioscience.com on Fri, Feb 02, 2001 at 02:08:20PM +0100 References: Message-ID: <20010202063655.A12537@bigskytel.com> * Harald Kirsch : > When a script is called by execfile, can it find out the full absolute > path name by which it was called? You could tell it by passing a variable to it containing the value: execfile('/home/dap/bla.py', {'path': '/home/dap/bla.py'}) David From tshumway at transafari.com Fri Feb 2 14:42:32 2001 From: tshumway at transafari.com (Terrel Shumway) Date: Fri, 02 Feb 2001 05:42:32 -0800 Subject: How can I get Memory/CPU stats for the python VM? Message-ID: <3A7AB948.DEA24C31@transafari.com> I am running Python 2.0 on a Linux box that has an protected /proc/. How can I find out how big the python process is and how much CPU time it is taking? The profile module is not enough: 1) I need to get info from a deployed process (non-debug) 2) It doesn't give memory stats Rebuilding the python interpreter or an extension module *is* feasible. TIA, -- Terrel From loewis at informatik.hu-berlin.de Fri Feb 2 23:25:15 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Feb 2001 23:25:15 +0100 Subject: How can I get Memory/CPU stats for the python VM? References: <3A7AB948.DEA24C31@transafari.com> Message-ID: Terrel Shumway writes: > I am running Python 2.0 on a Linux box that has an protected /proc/. > > How can I find out how big the python process is and how much CPU time > it is taking? time python foo.py gives you the execution time. > The profile module is not enough: > 1) I need to get info from a deployed process (non-debug) > 2) It doesn't give memory stats > > Rebuilding the python interpreter or an extension module *is* > feasible. With the gc module, you can get the number of living objects. With the resource module, you can get shared and unshared memory sizes etc, if your operating system supports that. Unfortunately, Linux reports zeroes in many of these fields. Reading /proc/self/maps or /proc/self/stat* will provide the proper detail on Linux - you only need to find the kernel documentation to interpret these numbers :-) Hint: /usr/src/linux/fs/proc/array.c has the code that generates these lists. Regards, Martin From robin at jessikat.fsnet.co.uk Fri Feb 2 15:49:50 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 2 Feb 2001 14:49:50 +0000 Subject: zope.org? Message-ID: <24QsZIAOkse6Ewl$@jessikat.fsnet.co.uk> Anyone know what's up with zope.org, seems off line and a lot of problems with the mailing lists. -- Robin Becker From mikael at isy.liu.se Fri Feb 2 16:06:16 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 02 Feb 2001 16:06:16 +0100 (MET) Subject: zope.org? In-Reply-To: <24QsZIAOkse6Ewl$@jessikat.fsnet.co.uk> Message-ID: On 02-Feb-01 Robin Becker wrote: > Anyone know what's up with zope.org, seems off line and a lot of > problems with the mailing lists. Well, I don't know about the mailing lists, but the web service seems to be up. Accessing www.zope.org causes me no problems. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 02-Feb-01 Time: 16:05:07 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From chrisw at nipltd.com Fri Feb 2 16:50:57 2001 From: chrisw at nipltd.com (Chris Withers) Date: Fri, 02 Feb 2001 15:50:57 +0000 Subject: zope.org? References: Message-ID: <3A7AD761.BB2A884D@nipltd.com> Mikael Olofsson wrote: > > On 02-Feb-01 Robin Becker wrote: > > Anyone know what's up with zope.org, seems off line and a lot of > > problems with the mailing lists. > > Well, I don't know about the mailing lists, but the web service seems > to be up. Accessing www.zope.org causes me no problems. zope.org came up about 1/2 hour ago. The lists are still down, for over a day now :-( *sigh* Some kindof BIND problem and disk failure, apparently... cheers, Chris From binnc at my-deja.com Fri Feb 2 16:08:31 2001 From: binnc at my-deja.com (binnc at my-deja.com) Date: Fri, 02 Feb 2001 15:08:31 GMT Subject: String as a Variable? Message-ID: <95eih7$si$1@nnrp1.deja.com> Another newbie question... Is there a way to have a string represent a variable. For eaxample, I have a the following: serial_number = '3' print 'ip_address_serial_' + serial_number ip_address_serial_3 Now I want to use the string ip_address_serial_3 to pull the value assigned to the variable of the same name. How can I represent the string as a variable? Thanks in advance! Sent via Deja.com http://www.deja.com/ From DSHIN at nc.rr.com Fri Feb 2 16:31:03 2001 From: DSHIN at nc.rr.com (Daehyok Shin) Date: Fri, 02 Feb 2001 15:31:03 GMT Subject: String as a Variable? References: <95eih7$si$1@nnrp1.deja.com> Message-ID: Use __dict__. For example, in a class, str='ip_address_serial' self.__dict__[str]=str print self.ip_address_serial wrote in message news:95eih7$si$1 at nnrp1.deja.com... > Another newbie question... > > Is there a way to have a string represent a variable. > > For eaxample, I have a the following: > > > > serial_number = '3' > print 'ip_address_serial_' + serial_number > ip_address_serial_3 > > Now I want to use the string ip_address_serial_3 to pull > the value assigned to the variable of the same name. > > How can I represent the string as a variable? > > Thanks in advance! > > > Sent via Deja.com > http://www.deja.com/ From fredrik at effbot.org Fri Feb 2 16:32:52 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Fri, 02 Feb 2001 15:32:52 GMT Subject: String as a Variable? References: <95eih7$si$1@nnrp1.deja.com> Message-ID: binnc at my-deja.com wrote: > Is there a way to have a string represent a variable. yes, but Python's not Tcl, and there are better ways to do it. start here: http://www.python.org/doc/current/tut/node7.html => 5.4 Dictionaries Cheers /F From phd at phd.pp.ru Fri Feb 2 16:57:01 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 2 Feb 2001 18:57:01 +0300 (MSK) Subject: String as a Variable? In-Reply-To: <95eih7$si$1@nnrp1.deja.com> Message-ID: On Fri, 2 Feb 2001 binnc at my-deja.com wrote: > Is there a way to have a string represent a variable. Although there are ways to do it, the recommnded way is to awoid it at all. Better, collect all neccessary variables in a dictionary: x = mydict["ip_addr_" + value] Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From mikael at isy.liu.se Fri Feb 2 17:05:04 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 02 Feb 2001 17:05:04 +0100 (MET) Subject: String as a Variable? In-Reply-To: <95eih7$si$1@nnrp1.deja.com> Message-ID: On 02-Feb-01 binnc at my-deja.com wrote: > Now I want to use the string ip_address_serial_3 to pull > the value assigned to the variable of the same name. >>> exec('a=0') >>> a 0 HTH /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 02-Feb-01 Time: 17:04:09 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From aleaxit at yahoo.com Fri Feb 2 17:05:39 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 2 Feb 2001 17:05:39 +0100 Subject: String as a Variable? References: <95eih7$si$1@nnrp1.deja.com> Message-ID: <95elsm0nuj@news1.newsguy.com> wrote in message news:95eih7$si$1 at nnrp1.deja.com... > Another newbie question... > > Is there a way to have a string represent a variable. Yes, there are quite a few. It's an *exceedingly* rare occurrence that using any of those ways is actually the best approach to anything, though; you would most likely be best advised to refactor your code to work otherwise. > For eaxample, I have a the following: > > > > serial_number = '3' > print 'ip_address_serial_' + serial_number > ip_address_serial_3 > > Now I want to use the string ip_address_serial_3 to pull > the value assigned to the variable of the same name. The built-in function vars() returns a mapping that represents the variable-to-value correspondence at this time. Indexing that mapping with a string will return the value currently corresponding to the variable whose name is that string -- if no such variable exists, of course, a KeyError will be raised. I.e., print vars()['ip_address_serial_' + serial_number] will print the value you require. But it's a bad ideas to use variables in this way. Why not have ip_addresses be a dictionary, and index it with '3' directly? This is much more direct, explicit, simple, and well-performing, than hiding the 'pieces' of a mapping as part of the vars-dictionary -- which is what you're doing when you use variables (rather than dictionary entries) to refer to values, but then want to access them by string-index. Further, vars() and friends do not, in general, let you RE-BIND variables to new values -- only access the value a variable is currently bound to. You can bypass these issues with the exec statement (and, as you're at it, you might use the eval function to fetch your variables -- it's overkill, though). But, MUCH better, you can bypass them by using a dictionary when a dictionary is what you really want. Alex From bogus@does.not.exist.com Sat Feb 3 21:34:41 2001 From: bogus@does.not.exist.com (Jonathan Polley) Date: Sat, 03 Feb 2001 14:34:41 -0600 Subject: String as a Variable? References: <95eih7$si$1@nnrp1.deja.com> Message-ID: <3A7C6B61.641D75E0@collins.rockwell.com> I actually use the exec() and eval() functions. If I need to assign to the string/variable, I will use exec(): My_Variable = "This_Thing" My_Expression = "= 15.75" exec (My_Variable + My_Expression) To read the variable, use eval(): print eval (My_Variable) Jon p.s. While it may not be an accpeted practice to do this, I have found it quite useful. At work, we are able to quickly develop automated tests that will do bounds checking on various python classes and methods. binnc at my-deja.com wrote: > Another newbie question... > > Is there a way to have a string represent a variable. > > For eaxample, I have a the following: > > > > serial_number = '3' > print 'ip_address_serial_' + serial_number > ip_address_serial_3 > > Now I want to use the string ip_address_serial_3 to pull > the value assigned to the variable of the same name. > > How can I represent the string as a variable? > > Thanks in advance! > > Sent via Deja.com > http://www.deja.com/ From dan at eevolved.com Fri Feb 2 18:15:57 2001 From: dan at eevolved.com (Dan Parisien) Date: Fri, 02 Feb 2001 17:15:57 GMT Subject: expanding a list and dict to a *args and **dict Message-ID: Is it possible to 'expand' a list or dictionary into its components to call a function expecting many parameters? I want to be able to call a function without accessing each individual element manually (list[0], list[1], list[2]) I'm sending random parameters over a network (*args and **dict). When I unpickle them on the other side, I get a python list and dictionary. I then call an arbitrary function (actually a reference to a function that was bound at runtime a la self.randomfunction = obj.specificfunction ) That function is not expecting a list and a dictionary, instead it is expecting specific parameters(that i don't know at runtime) and I want to take the list and turn it into a bunch of parameters like list[0], list[1], list[2] (but as stated above, I can't do that) Ha. I hope someone understood me :) Dan From mwh21 at cam.ac.uk Fri Feb 2 18:21:55 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 02 Feb 2001 17:21:55 +0000 Subject: expanding a list and dict to a *args and **dict References: Message-ID: Dan Parisien writes: > Is it possible to 'expand' a list or dictionary into its components to call > a function expecting many parameters? > > I want to be able to call a function without accessing each individual > element manually (list[0], list[1], list[2]) > > I'm sending random parameters over a network (*args and **dict). When I > unpickle them on the other side, I get a python list and dictionary. I then > call an arbitrary function (actually a reference to a function that was > bound at runtime a la > self.randomfunction = obj.specificfunction > ) > > That function is not expecting a list and a dictionary, instead it is > expecting specific parameters(that i don't know at runtime) and I want to > take the list and turn it into a bunch of parameters like list[0], list[1], > list[2] (but as stated above, I can't do that) > > Ha. I hope someone understood me :) Only a bit, but do you know about apply (a builtin function) and/or this sort of thing: >>> def f(a,b,c): ... print a,b,c ... >>> f(*(1,2),**{'c':3}) 1 2 3 I *think* that's what your asking for... Cheers, M. -- I have gathered a posie of other men's flowers, and nothing but the thread that binds them is my own. -- Montaigne From phd at phd.pp.ru Fri Feb 2 18:39:33 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 2 Feb 2001 20:39:33 +0300 (MSK) Subject: expanding a list and dict to a *args and **dict In-Reply-To: Message-ID: On Fri, 2 Feb 2001, Dan Parisien wrote: > Is it possible to 'expand' a list or dictionary into its components to call > a function expecting many parameters? Use builtin function "apply"! Read docs... Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From tiddlerdeja at my-deja.com Fri Feb 2 18:35:56 2001 From: tiddlerdeja at my-deja.com (tiddlerdeja at my-deja.com) Date: Fri, 02 Feb 2001 17:35:56 GMT Subject: jython 2 java class - help????? Message-ID: <95er5s$9od$1@nnrp1.deja.com> Can anyone tell me if they have had much success with this? I can follow the Graph.py demo and I get this to work. With this demo you get a PythonGraph.java file to javac. When I attempt this for MyEg.py, I get the MyEg.class files, but I don't get the PythonMyEg.java file to compile. My exmaple does derive from java.lang.Object, it does work from jythjon.bat and has a if __main...... thingy. I also want to be able to create a jar that I can deply on another VM that does not have jython-2.0 installed. Any help appreciated. Sent via Deja.com http://www.deja.com/ From dsh8290 at rit.edu Fri Feb 2 19:24:07 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 2 Feb 2001 13:24:07 -0500 Subject: jython 2 java class - help????? In-Reply-To: <95er5s$9od$1@nnrp1.deja.com>; from tiddlerdeja@my-deja.com on Fri, Feb 02, 2001 at 05:35:56PM +0000 References: <95er5s$9od$1@nnrp1.deja.com> Message-ID: <20010202132407.B8584@harmony.cs.rit.edu> (these things are probably better for the jython list) $ jythonc --all --jar MyEg.jar MyEg.py Will create a jar file MyEg.jar that will contain all the .class files you need (from your .py source and the jython.jar file). By default jythonc does its work in a directory ./jpywork . This is where the .java and .class files are output. If you specify a jar file, jythonc will take the .class files it output to ./jpywork and put them in the jar. HTH, -D On Fri, Feb 02, 2001 at 05:35:56PM +0000, tiddlerdeja at my-deja.com wrote: | Can anyone tell me if they have had much success with this? | | I can follow the Graph.py demo and I get this to work. With this demo | you get a PythonGraph.java file to javac. | | When I attempt this for MyEg.py, I get the MyEg.class files, but I | don't get the PythonMyEg.java file to compile. | | My exmaple does derive from java.lang.Object, it does work from | jythjon.bat and has a if __main...... thingy. | | I also want to be able to create a jar that I can deply on another VM | that does not have jython-2.0 installed. | | Any help appreciated. | From reborn at neozone.net Fri Feb 2 23:28:22 2001 From: reborn at neozone.net (syKim) Date: Sat, 3 Feb 2001 07:28:22 +0900 Subject: jython 2 java class - help????? References: <95er5s$9od$1@nnrp1.deja.com> Message-ID: <95fc9d$kad$1@news1.kornet.net> If you just want run & test in jython.. now, you could try like that : (attach bottom of your code) if __name__ == '__main__' import pawt pawt.test(yourclassname(),size=(number,number)) # yourclassname, number - anything you want you can get the result like that jython filename.py In webrower, I'm discussing yet.. From tiddlerdeja at my-deja.com Mon Feb 5 12:32:59 2001 From: tiddlerdeja at my-deja.com (tiddlerdeja at my-deja.com) Date: Mon, 05 Feb 2001 11:32:59 GMT Subject: jython 2 java class - help????? References: <95er5s$9od$1@nnrp1.deja.com> Message-ID: <95m31b$hfi$1@nnrp1.deja.com> Thanks for that, I'll give it a go, but I think I'll run into my original problems. I did have a look for a jython group to post to, but didn't find one. Would you be able to tell me what it is? Thanks again. In article , D-Man wrote: > > (these things are probably better for the jython list) > > $ jythonc --all --jar MyEg.jar MyEg.py > > Will create a jar file MyEg.jar that will contain all the .class files > you need (from your .py source and the jython.jar file). > > By default jythonc does its work in a directory ./jpywork . This is > where the .java and .class files are output. If you specify a jar > file, jythonc will take the .class files it output to ./jpywork and > put them in the jar. > > HTH, > -D > > On Fri, Feb 02, 2001 at 05:35:56PM +0000, tiddlerdeja at my-deja.com wrote: > | Can anyone tell me if they have had much success with this? > | > | I can follow the Graph.py demo and I get this to work. With this demo > | you get a PythonGraph.java file to javac. > | > | When I attempt this for MyEg.py, I get the MyEg.class files, but I > | don't get the PythonMyEg.java file to compile. > | > | My exmaple does derive from java.lang.Object, it does work from > | jythjon.bat and has a if __main...... thingy. > | > | I also want to be able to create a jar that I can deply on another VM > | that does not have jython-2.0 installed. > | > | Any help appreciated. > | > > Sent via Deja.com http://www.deja.com/ From dsh8290 at rit.edu Mon Feb 5 16:49:50 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 5 Feb 2001 10:49:50 -0500 Subject: jython 2 java class - help????? In-Reply-To: <95m31b$hfi$1@nnrp1.deja.com>; from tiddlerdeja@my-deja.com on Mon, Feb 05, 2001 at 11:32:59AM +0000 References: <95er5s$9od$1@nnrp1.deja.com> <95m31b$hfi$1@nnrp1.deja.com> Message-ID: <20010205104950.A27254@harmony.cs.rit.edu> On Mon, Feb 05, 2001 at 11:32:59AM +0000, tiddlerdeja at my-deja.com wrote: | Thanks for that, I'll give it a go, but I think I'll run into my | original problems. | | I did have a look for a jython group to post to, but didn't find one. | Would you be able to tell me what it is? It is mentioned on the web site, jython.sourceforge.net. jython-users at lists.sourceforge.net -D From echuck at mindspring.com Fri Feb 2 19:53:27 2001 From: echuck at mindspring.com (Chuck Esterbrook) Date: Fri, 02 Feb 2001 13:53:27 -0500 Subject: Comparison oddities Message-ID: <5.0.2.1.0.20010202134528.05141ad0@mail.mindspring.com> It appears that tuples and strings are "greater than" lists. >python ActivePython 2.0, build 202 (ActiveState Tool Corp.) based on Python 2.0 (#8, Oct 19 2000, 11:30:05) [MSC 32 bit (Intel)] on win32 >>> a = (1, 1) >>> b = [1, 1] >>> a < b 0 >>> a > b 1 >>> a==b 0 >>> a = '1' >>> a < b 0 >>> a > b 1 Does this seem a little odd to anyone? Since tuples and lists are both "sequences of anything", you would hope that they would compare in "the natural fashion". Since comparing a string and a list doesn't make sense, would an exception be more appropriate? And yes, I know the manual says "Otherwise, objects of different types *always* compare unequal, and are ordered consistently but arbitrarily. ... In the future, the comparison rules for objects of different types are likely to change." My question is more of a design question. -Chuck From aahz at panix.com Fri Feb 2 20:10:46 2001 From: aahz at panix.com (Aahz Maruch) Date: 2 Feb 2001 11:10:46 -0800 Subject: Comparison oddities References: Message-ID: <95f0nm$9am$1@panix3.panix.com> In article , Chuck Esterbrook wrote: > >It appears that tuples and strings are "greater than" lists. >Does this seem a little odd to anyone? > >Since tuples and lists are both "sequences of anything", you would hope >that they would compare in "the natural fashion". > >Since comparing a string and a list doesn't make sense, would an exception >be more appropriate? > >And yes, I know the manual says "Otherwise, objects of different types >*always* compare unequal, and are ordered consistently but arbitrarily. ... >In the future, the comparison rules for objects of different types are >likely to change." > >My question is more of a design question. I'm only going to answer your second question: this ordering is required by the fact that lists are *not* homogenous. A list can contain any other Python type, including lists, strings, dicts, and numbers. list.sort() is required to work well in all of this. -- --- 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 "People sometimes focus too much on the fact of communication rather than the substance of communication." --Dave Morton From jmg at ecs.soton.ac.uk Fri Feb 2 20:38:17 2001 From: jmg at ecs.soton.ac.uk (Jacek Generowicz) Date: 02 Feb 2001 19:38:17 +0000 Subject: Command line editing in python shell Message-ID: I have compiled python 2.0 on a Mandrake 7.2 installation. Command line editing is impossible: The up-arrow prints ^[[A and so on. I guess that some libraries are not being found, as I have previously compiled python 2.0 on a RedHat 6.2 installation and everything worked fine. Any ideas how I can fix this one ? Thanks, Jacek From thomas at xs4all.net Fri Feb 2 21:14:33 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 2 Feb 2001 21:14:33 +0100 Subject: Command line editing in python shell In-Reply-To: ; from jmg@ecs.soton.ac.uk on Fri, Feb 02, 2001 at 07:38:17PM +0000 References: Message-ID: <20010202211433.X962@xs4all.nl> On Fri, Feb 02, 2001 at 07:38:17PM +0000, Jacek Generowicz wrote: > I have compiled python 2.0 on a Mandrake 7.2 installation. Command > line editing is impossible: The up-arrow prints ^[[A and so on. > > I guess that some libraries are not being found, as I have previously > compiled python 2.0 on a RedHat 6.2 installation and everything worked > fine. > Any ideas how I can fix this one ? You have to compile in the 'readline' module. In Python 2.0 that means editing 'Modules/Setup' and uncommenting the line that mentions readline. You'll probably also want to uncomment some other lines. If that doesn't work, you might lack the headerfiles for readline, or they might be in an odd location. If you don't have them installed, you have to find an RPM that provides them (probably readline-devel..rpm.) If they are in an odd location, you have to tweak the -I and -L arguments behind readline. This will almost all be unnecessary in Python 2.1, where the modules are autodetected using Python's distutils. It's less easy to supply your own location, but it will hardly be necessary, in most cases. In Python 2.1, a single 'make' after 'configure' will build everything for you :) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From jmg at ecs.soton.ac.uk Mon Feb 5 11:50:29 2001 From: jmg at ecs.soton.ac.uk (Jacek Generowicz) Date: 05 Feb 2001 10:50:29 +0000 Subject: Command line editing in python shell References: Message-ID: Thomas Wouters writes: > On Fri, Feb 02, 2001 at 07:38:17PM +0000, Jacek Generowicz wrote: > > I have compiled python 2.0 on a Mandrake 7.2 installation. Command > > line editing is impossible: The up-arrow prints ^[[A and so on. > > > > I guess that some libraries are not being found, as I have previously > > compiled python 2.0 on a RedHat 6.2 installation and everything worked > > fine. > > Any ideas how I can fix this one ? > > You have to compile in the 'readline' module. In Python 2.0 that means > editing 'Modules/Setup' and uncommenting the line that mentions readline. This solved the problem. (After obtaining and compiling the library) > If that doesn't work, you might lack the headerfiles for readline, or they > might be in an odd location. If you don't have them installed, you have to > find an RPM that provides them (probably readline-devel..rpm.) I used readline-4.1-9mdk-src.rpm which I obtained from rpmfind.net. I applied the makefile patch that comes in the package before compiling. Thanks, Jacek From geoff at homegain.com Fri Feb 2 20:38:52 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Fri, 2 Feb 2001 11:38:52 -0800 Subject: fetching class by name Message-ID: <393D961EA4FCD311B03F00D0B746D65802625F22@HQSXCH01> I think I know the answer to this question before I ask it, but I feel like I need to ask anyway. Is there an easier way to retrieve a class object by name than doing a manual lookup through the __dict__ of every module in sys.modules? I think maybe I'm just spoiled by the way objective c gives you a cute little utility function to do this for you. Still, looking it up manually seems extraordinarily costly. Thanks, --G. --- Geoff Gerrietts Software Engineer, HomeGain.com 510-655-0800 x4320 From loewis at informatik.hu-berlin.de Fri Feb 2 23:31:10 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Feb 2001 23:31:10 +0100 Subject: fetching class by name References: Message-ID: Geoffrey Gerrietts writes: > Is there an easier way to retrieve a class object by name than > doing a manual lookup through the __dict__ of every module in > sys.modules? Depends on what you know about the class. If you *only* know the name, there is probably no other way. Hint: if all you need is a class with that name, how about >>> import new >>> new.classobj("thename",(),{}) > I think maybe I'm just spoiled by the way objective c gives you a > cute little utility function to do this for you. Still, looking > it up manually seems extraordinarily costly. More explicitly: there might be more than one class with that name, the class might be known under a different name, or it might not be bound to a variable altogether: >>> class Foo:pass ... >>> foo=Foo() >>> del Foo >>> foo.__class__ Classes are objects like any other: some are referred-to by global variables, others are not. Regards, Martin From marchign at science.unitn.it Wed Feb 7 13:57:40 2001 From: marchign at science.unitn.it (Davide Marchignoli) Date: Wed, 07 Feb 2001 13:57:40 +0100 Subject: fetching class by name In-Reply-To: References: Message-ID: In comp.lang.python, you wrote: > >I think I know the answer to this question before I ask it, but I >feel like I need to ask anyway. > >Is there an easier way to retrieve a class object by name than >doing a manual lookup through the __dict__ of every module in >sys.modules? > >I think maybe I'm just spoiled by the way objective c gives you a >cute little utility function to do this for you. Still, looking >it up manually seems extraordinarily costly. > >Thanks, >--G. > maybe eval suits your needs: >>> class C : pass ... >>> x = eval('C') >>> x Bye, -- Davide From greg at cosc.canterbury.ac.nz Wed Feb 14 01:18:10 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 14 Feb 2001 13:18:10 +1300 Subject: fetching class by name References: Message-ID: <3A89CEC2.DB75C7CE@cosc.canterbury.ac.nz> Someone whose attribution has been lost said: > >I think maybe I'm just spoiled by the way objective c gives you a > >cute little utility function to do this for you. Still, looking > >it up manually seems extraordinarily costly. All the class names live in a single namespace in Objective C. In Python the situation is more complicated. If you have no idea which module the class is defined in, then you've no choice but to go searching. On the other hand, if you know both the module name and the class name, then you can go straight to it: import sys c = getattr(sys.modules[module_name], class_name) -- 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 geoff at homegain.com Sat Feb 3 00:48:01 2001 From: geoff at homegain.com (Geoffrey Gerrietts) Date: Fri, 2 Feb 2001 15:48:01 -0800 Subject: fetching class by name Message-ID: <393D961EA4FCD311B03F00D0B746D65802625F25@HQSXCH01> Martin von Loewis wrote: > > More explicitly: there might be more than one class with that name, > the class might be known under a different name, or it might not be > bound to a variable altogether: All excellent points, the last of which is most surprising of the three (I wouldn't have thought of that case if you hadn't pointed it out), and most alarming. Definitely the point that politely suggests an alternate implementation for the case I'm looking at. Sometimes hard to chase away idioms of the past.... Thanks very much, --G. --- Geoff Gerrietts Software Engineer, HomeGain.com 510-655-0800 x4320 From fluxent at yahoo.com Fri Feb 2 21:26:28 2001 From: fluxent at yahoo.com (Bill Seitz) Date: Fri, 02 Feb 2001 20:26:28 GMT Subject: ADO/ODBC call via Python/IIS Message-ID: <95f558$jgl$1@nnrp1.deja.com> Architecture: ASP page using <%@ LANGUAGE = Python%>, calling Python class which calls ADO to pass SQL command via ODBC driver to MsSQL db. (Everything running on Win2K.) MsSQL configured to authenticate against ActiveDirectory only. Sysadmin created userID 'pyasp'. I created MsSQL login and assigned user rights in the appropriate db. I created an ODBC source named 'pyasp', assigned the current db as the default. Here is the class that does the work (in file 'aAdoBiz.py') class aConnect: def __init__(self): import win32com.client adoConn = win32com.client.Dispatch('ADODB.Connection') adoConn.Open('pyasp') (adoRS, success) = adoConn.Execute('Select * from RateUnits') adoRS.MoveFirst() adoRS.MoveNext() self.fieldName = adoRS.Fields("Name").Value When I call this code interactively, I get the right result: >>> import aAdoBiz >>> z=aAdoBiz.aConnect() >>> z.fieldName.encode() 'Days ' But then I have the same idea implemented in an ASP page: <% import aAdoBiz x = aAdoBiz.aConnect() out = x.fieldName.encode() %> <%= out %> (A very similar ASP page, calling a simple stub class with no ODBC activity, works fine.) When I call this ASP page, I get an error to the browser... HTTP 500.100 - Internal Server Error - ASP error Error Type: Python ActiveX Scripting Engine (0x80020009) Traceback (innermost last): File " "Scott Hathaway" a ?crit dans le message news: nTDh6.66287$bb.1038987 at news1.rdc1.tx.home.com... > I am using mxODBC to access db's with no problem, but I have a question. If > I use a sql call as follows: > > select username from users; > > Then, I make a call as follows: > > data = c.fetchall() > > Then, to access the first value of the first (and only) field, I have to > use: > > theValue = data[0][0] > > This is ugly. Is there a way to do something like: > > theValue = data[0]['firstname'] > > Or anything more easy to discern for code readability? > > Thanks, > Scott > > From sholden at holdenweb.com Mon Feb 12 13:45:07 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 12 Feb 2001 07:45:07 -0500 Subject: mxODBC question References: Message-ID: "Scott Hathaway" wrote in message news:nTDh6.66287$bb.1038987 at news1.rdc1.tx.home.com... > I am using mxODBC to access db's with no problem, but I have a question. If > I use a sql call as follows: > > select username from users; > > Then, I make a call as follows: > > data = c.fetchall() > > Then, to access the first value of the first (and only) field, I have to > use: > > theValue = data[0][0] > > This is ugly. Is there a way to do something like: > > theValue = data[0]['firstname'] > > Or anything more easy to discern for code readability? > > Thanks, > Scott > The best tool I've come across for this is at http://www.lyra.org/greg/python/dtuple.py It has worked in a number of such contexts for me, allowing access by attribute name or index, with a well-thought-out set of methods.. regards Steve From slhath at home.com Wed Feb 14 00:15:05 2001 From: slhath at home.com (Scott Hathaway) Date: Tue, 13 Feb 2001 23:15:05 GMT Subject: mxODBC question References: Message-ID: Thanks for all the feedback! Scott "Scott Hathaway" wrote in message news:nTDh6.66287$bb.1038987 at news1.rdc1.tx.home.com... > I am using mxODBC to access db's with no problem, but I have a question. If > I use a sql call as follows: > > select username from users; > > Then, I make a call as follows: > > data = c.fetchall() > > Then, to access the first value of the first (and only) field, I have to > use: > > theValue = data[0][0] > > This is ugly. Is there a way to do something like: > > theValue = data[0]['firstname'] > > Or anything more easy to discern for code readability? > > Thanks, > Scott > > From dan at eevolved.com Mon Feb 12 00:12:23 2001 From: dan at eevolved.com (Dan Parisien) Date: Sun, 11 Feb 2001 23:12:23 GMT Subject: why does this happen? Message-ID: key = 0 dict = {0:''} key = dict[key] = "__0" print key >>> __0 print dict >>> {9: '', '__9': '__9'} It doesn't do it from right to left like in c? Obviously not. Does anyone know why? thank you, Dan From dan at eevolved.com Mon Feb 12 00:22:49 2001 From: dan at eevolved.com (Dan Parisien) Date: Sun, 11 Feb 2001 23:22:49 GMT Subject: why does this happen? (messed up previous post) References: Message-ID: Dan Parisien wrote: > key = 0 > dict = {0:''} > key = dict[key] = "__0" > print key > >>> __0 > print dict > >>> {9: '', '__9': '__9'} > > It doesn't do it from right to left like in c? Obviously not. Does anyone > know why? > > thank you, > Dan > > haha. I wrote the example, _then_ copied and pasted from a terminal. serves me right. Sorry for the confusion. key = "key" dict = {"key":None} key = dict[key] = "newval" print key >>> newval print dict >>> {"key":None, "newval":"newval"} I was expecting print dict >>>{"key":"newval"} I'm using Python 2.0.1 thank you, Dan From scarblac at pino.selwerd.nl Mon Feb 12 09:43:43 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 12 Feb 2001 08:43:43 GMT Subject: why does this happen? (messed up previous post) References: Message-ID: Dan Parisien wrote in comp.lang.python: > key = "key" > dict = {"key":None} > key = dict[key] = "newval" > > print key > >>> newval > print dict > >>> {"key":None, "newval":"newval"} > > I was expecting > print dict > >>>{"key":"newval"} In C, = is an expression. a = b = c therefore means a = (b = c). In Python, = is a statement, and a = b = c is simply a shorthand for a = c; b = c. And that obviously happens left to right. This is also the reason why in Python "a = (b = c)" is illegal. I'd consider 'key = dict[key] = "newval"' to be deliberately confusing. Once you're depending on the order of that sort of thing, your code is hard to read. I had no idea what to expect when I read it, really. Use the multiple = when you are setting several similar variables to the same value, length = width = height = 1, but don't try to make the meaning of one of them depend on the value of another... -- Remco Gerlich From gregj at pobox.com Mon Feb 12 01:00:49 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Mon, 12 Feb 2001 00:00:49 GMT Subject: why does this happen? References: Message-ID: <96793e$rd6$1@nnrp1.deja.com> In article , dan at eevolved.com wrote: > key = 0 > dict = {0:''} > key = dict[key] = "__0" > print key > >>> __0 > print dict > >>> {9: '', '__9': '__9'} ** I think you meant {0: '', '__0': '__0'} > > It doesn't do it from right to left like in c? Obviously not. Does anyone > know why? In C assignment is an expression: the value of the expression a=1 is 1. In Python, assignment is not an expression: print a=1 is an error. Python allows assignment to several variables "simultaneously" (that's what the Python Tutorial says) with the form a = b = 1. I don't see anything in the Language Reference that says what order the assignments are actually carried out, but from your experiment and my own it looks like a = b = 1 is equivalent to: a = 1 b = 1 In other words, the rightmost expression is assigned to each lvalue in left-to-right order. But unless the order of assignment is explicitly specified in the language spec you should not rely on it. Perhaps a clearer example is: >>> i = 0 >>> t = [0,0] >>> i = t[i] = 1 >>> i 1 >>> t [0,1] -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com Sent via Deja.com http://www.deja.com/ From dan at eevolved.com Mon Feb 12 01:14:24 2001 From: dan at eevolved.com (Dan Parisien) Date: Mon, 12 Feb 2001 00:14:24 GMT Subject: why does this happen? References: <96793e$rd6$1@nnrp1.deja.com> Message-ID: > Greg Jorgensen > Portland, Oregon, USA > gregj at pobox.com thank you very much :) Dan From cfelling at iae.nl Mon Feb 12 02:22:05 2001 From: cfelling at iae.nl (Carel Fellinger) Date: Mon, 12 Feb 2001 01:22:05 GMT Subject: why does this happen? References: <96793e$rd6$1@nnrp1.deja.com> Message-ID: <967dus$iic$1@animus.fel.iae.nl> > In C assignment is an expression: the value of the expression a=1 is 1. > In Python, assignment is not an expression: print a=1 is an error. > Python allows assignment to several variables "simultaneously" (that's > what the Python Tutorial says) with the form a = b = 1. I don't see > anything in the Language Reference that says what order the assignments > are actually carried out, but from your experiment and my own it looks >From the Python Language Reference 1.5.2: next up previous Python Reference Manual contents index Next: 6.4 The pass statement Up: 6. Simple statements Previous: 6.2 Assert statements _________________________________________________________________ 6.3 Assignment statements Assignment statements are used to (re)bind names to values and to modify attributes or items of mutable objects: assignment_stmt: (target_list "=")+ expression_list target_list: target ("," target)* [","] target: identifier | "(" target_list ")" | "[" target_list "]" | attributeref | subscription | slicing (See section 5.3 for the syntax definitions for the last three symbols.) An assignment statement evaluates the expression list (remember that this can be a single expression or a comma-separated list, the latter yielding a tuple) and assigns the single resulting object to each of the target lists, from left to right. So it is, from left to right:) -- groetjes, carel From pretomal at yahoo.com Mon Feb 12 00:41:56 2001 From: pretomal at yahoo.com (pretomal at yahoo.com) Date: Sun, 11 Feb 2001 23:41:56 GMT Subject: TclError: while using Tkinter() Message-ID: <967802$qgq$1@nnrp1.deja.com> Win98, ActivePython 2.0 I'm new to Python, and cannot get Tkinter to work. Tk/Tcl8.32 is installed, and I had to copy tcl83.dll and tk83.dll to my \windows\system\ dir. to get Tkinter to load, but now I get the following error while trying to call "Tkinter.Tk()" : File "c:\python20\lib\lib-tk\Tkinter.py", line 1482, in __init__ self.tk = _tkinter.create(screenName, baseName, className) TclError: invalid command name "tcl_findLibrary" By searching comp.lang.tcl I'm led to believe that Tk.Init() is being called before Tcl.Init(), but I'm clueless as how to solve that. Any help is appreciated. Pretomal Sent via Deja.com http://www.deja.com/ From rvprasad at cis.ksu.edu Mon Feb 12 02:46:34 2001 From: rvprasad at cis.ksu.edu (Venkatesh Prasad Ranganath) Date: 11 Feb 2001 19:46:34 -0600 Subject: DOM creation Message-ID: Hi, I have a question on how DOM for a XML document conforming to DOM 2 should be constructed? Now if there are no namespaces specified in the document then should attributes be added to DOM using setAttributeNS('', Name, Value) or setAttribute(Name, Value)? The problem I am facing is when reading in a XML document with no explicit namespace specified in it through PyXML the attributes are added to the DOM using setAttributeNS with an empty NameSpace. So, I wanted to clarify if this is a problem with PyXML or is this how other DOM Constructors work. waiting for reply, -- Venkatesh Prasad Ranganath From alf at leo.logilab.fr Mon Feb 12 15:50:53 2001 From: alf at leo.logilab.fr (Alexandre Fayolle) Date: Mon, 12 Feb 2001 14:50:53 +0000 (UTC) Subject: DOM creation References: Message-ID: <968t8d$23mg$1@norfair.nerim.net> In comp.lang.python Venkatesh Prasad Ranganath wrote: > Now if there are no namespaces specified in the document then should attributes > be added to DOM using > setAttributeNS('', Name, Value) > or > setAttribute(Name, Value)? Use the first one, definitely. Event better, define a symbolic constant that you'll call, for example EMPTY_NS, and set it to '' for now. There has been some discussion about what should be the prefix of empty namespace on xml-sig ('' or None), and it is likely that it will change from empty string to None soon (someone corrects me if I'm wrong, please.) > The problem I am facing is when reading in a XML document with no explicit > namespace specified in it through PyXML the attributes are added to the DOM > using setAttributeNS with an empty NameSpace. So, I wanted to clarify if this > is a problem with PyXML or is this how other DOM Constructors work. This is what the DOM L2 spec says. It also says that you should not mix the ns aware and non-ns aware APIs provided in DOM L2. So this means that you shoud use Document.createElementNS(EMPTY_NS,name) instead of Document.createElement(name) to create new element nodes. I hope this helps. Alexandre Fayolle -- http://www.logilab.com Narval is the first software agent available as free software (GPL). LOGILAB, Paris (France). From uche at ogbuji.net Wed Feb 14 15:12:30 2001 From: uche at ogbuji.net (Uche Ogbuji) Date: Wed, 14 Feb 2001 14:12:30 GMT Subject: DOM creation References: Message-ID: <3A8A9254.C4F9FDC@ogbuji.net> Venkatesh Prasad Ranganath wrote: > I have a question on how DOM for a XML document conforming to DOM 2 should be > constructed? > > Now if there are no namespaces specified in the document then should attributes > be added to DOM using > setAttributeNS('', Name, Value) > or > setAttribute(Name, Value)? > > The problem I am facing is when reading in a XML document with no explicit > namespace specified in it through PyXML the attributes are added to the DOM > using setAttributeNS with an empty NameSpace. So, I wanted to clarify if this > is a problem with PyXML or is this how other DOM Constructors work. This is correct behavior. Of course, if you use the xml.dom.ext.reader.Sax reader, you get a tree with no namespace specifiers at all, which is also correct. If you plan to migrate to namespaces in future, or to mix namespace with non-namespace behavior, I'd suggest sticking to the PyExpat and Sax2 readers and using the DOm Level 2 methods (with appended "NS"). > waiting for reply, This reminds me. I'm not sure I sent a reply to your last enquiry. I had a few questions, such as which Reader you were trying to use (It looked as if you didn't paste all of your example code in). However, I'd suggest trying the latest 4Suite 0.10.2 beta that was announced (since I noticed you're using XPath), and see if you still have those problems. If so, pleace copy follow-ups to xml-sig at python.org, which I check more regularly than this newsgroup. Thanks. -- Uche Ogbuji Personal: uche at ogbuji.net http://uche.ogbuji.net Work: uche.ogbuji at fourthought.com http://Fourthought.com From rvprasad at cis.ksu.edu Wed Feb 14 22:00:25 2001 From: rvprasad at cis.ksu.edu (Venkatesh Prasad Ranganath) Date: 14 Feb 2001 15:00:25 -0600 Subject: DOM creation References: <3A8A9254.C4F9FDC@ogbuji.net> Message-ID: >>>>> "Uche" == Uche Ogbuji writes: Uche> Venkatesh Prasad Ranganath wrote: >> I have a question on how DOM for a XML document conforming to DOM 2 >> should be constructed? >> >> Now if there are no namespaces specified in the document then should >> attributes be added to DOM using setAttributeNS('', Name, Value) or >> setAttribute(Name, Value)? >> >> The problem I am facing is when reading in a XML document with no >> explicit namespace specified in it through PyXML the attributes are added >> to the DOM using setAttributeNS with an empty NameSpace. So, I wanted to >> clarify if this is a problem with PyXML or is this how other DOM >> Constructors work. Uche> This is correct behavior. Of course, if you use the Uche> xml.dom.ext.reader.Sax reader, you get a tree with no namespace Uche> specifiers at all, which is also correct. Uche> If you plan to migrate to namespaces in future, or to mix namespace Uche> with non-namespace behavior, I'd suggest sticking to the PyExpat and Uche> Sax2 readers and using the DOm Level 2 methods (with appended "NS"). If this is the case then should or shouldn't set/getAttribute() in DOM2 "intelligently" assume empty namespace ('')? Also, is there any specification on construction of DOM for XML documents? Or does the DOM specs available at W3C describe the construction process? If so, can somebody tell me in which section? >> waiting for reply, Uche> This reminds me. I'm not sure I sent a reply to your last enquiry. Uche> I had a few questions, such as which Reader you were trying to use (It Uche> looked as if you didn't paste all of your example code in). Uche> However, I'd suggest trying the latest 4Suite 0.10.2 beta that was Uche> announced (since I noticed you're using XPath), and see if you still Uche> have those problems. If so, pleace copy follow-ups to Uche> xml-sig at python.org, which I check more regularly than this newsgroup. I guess it works fine on with 0.10.2b. Thankx -- Venkatesh Prasad Ranganath From dsavitsk at e-coli.net Mon Feb 12 03:04:14 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Sun, 11 Feb 2001 20:04:14 -0600 Subject: Python on FreeBSD Message-ID: <3A87449E.47AACA64@e-coli.net> greetings; i am having some trouble wih python on FreeBSD. I installed python 2.0 from the package collection. Then when i installed idle from the ports collection, it said that python 1.5.2 was a dependency and installed that too. That's not the problem (i don't think anyway). The problem is that when i tried to make install mod_python it couldn't find a checksum for python15 (which as far as i know installed fine as idle works fine). is it safe to force the build w/o a checksum? or is it better to CVSup and try to make install again? or will that do anything different? os is FreeBSD 4.2. i downloaded and burned the iso, so packages are installed from cdrom, but i install ports via ftp. any help, suggestions, places to look would be welcome as i am new to the unix world. doug From chris at voodooland.net Mon Feb 12 04:43:13 2001 From: chris at voodooland.net (Chris Watson) Date: Sun, 11 Feb 2001 21:43:13 -0600 (CST) Subject: Python on FreeBSD In-Reply-To: <3A87449E.47AACA64@e-coli.net> Message-ID: > greetings; > > > That's not the problem (i don't think anyway). The problem is that when > i tried to make install mod_python it couldn't find a checksum for > python15 (which as far as i know installed fine as idle works fine). is > it safe to force the build w/o a checksum? or is it better to CVSup and > try to make install again? or will that do anything different? You need to update your ports tree with cvsup. The md5 checksum on mod_python changed. And no it isnt going to hurt anything to over ride it and install it with a mismatched checksum. Not a big deal at all :-) -- ============================================================================= -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?" ============================================================================= GNU = Gnu's Non-portable & Unstable irc.openprojects.net #FreeBSD -Join the revolution! ICQ: 20016186 From gryphon01 at my-deja.com Mon Feb 12 05:16:39 2001 From: gryphon01 at my-deja.com (gryphon01 at my-deja.com) Date: Mon, 12 Feb 2001 04:16:39 GMT Subject: test_pyexpat failed Message-ID: <967o32$75r$1@nnrp1.deja.com> I an trying to build Python 2.0 with expat 1.2. The compile doesn't complain but test_pyexpat says: test test_pyexpat failed -- Writing: "('xml=http://www.w3.org/XML/1998/namespace\\014external_entity', None, 'entity.file', None)", expected: "('http://www.python.org/namespace=http://www.w3.org/XML/1998/namespace\\014e xternal_entity'" What is going on here? I must be doing something wrong. Thanks - Clint Sent via Deja.com http://www.deja.com/ From marc.vollmer at mahr.de Mon Feb 12 07:45:24 2001 From: marc.vollmer at mahr.de (Marc Vollmer) Date: Mon, 12 Feb 2001 07:45:24 +0100 Subject: Newbie: Adress of Pointer from C Message-ID: <9681bl$k4960$1@ID-59219.news.dfncis.de> Hi, I have an SocketServer (TCP/IP) as an C++ program and my SocketClient is a Python-script. Now I want to transfer the address of a pointer to Python, but I don't think how I can read the address and can read-out the pointer datas in the python script. System: Python 2.0 OS: WinNT Thanks and bye Marc From stephen_purcell at yahoo.com Mon Feb 12 08:49:15 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Mon, 12 Feb 2001 08:49:15 +0100 Subject: Newbie: Adress of Pointer from C In-Reply-To: <9681bl$k4960$1@ID-59219.news.dfncis.de>; from marc.vollmer@mahr.de on Mon, Feb 12, 2001 at 07:45:24AM +0100 References: <9681bl$k4960$1@ID-59219.news.dfncis.de> Message-ID: <20010212084915.D24337@freedom.puma-ag.com> Marc Vollmer wrote: > > I have an SocketServer (TCP/IP) as an C++ program and my SocketClient is a > Python-script. Now I want to transfer the address of a pointer to Python, > but I don't think how I can read the address and can read-out the pointer > datas in the python script. Eek! Don't expect Python to help you look at what the pointer is pointing at. (Isn't it pointing at something in the server process anyway?). What you can probably do is read the pointer value from the server across the socket, but I can't think how that would help you later. -Steve -- Steve Purcell, Pythangelist PythonTesting = urlopen('http://pyunit.sourceforge.net/') PythonServlets = urlopen('http://pyserv.sourceforge.net/') Available for consulting and training. "Even snakes are afraid of snakes." -- Steven Wright From marc.vollmer at mahr.de Mon Feb 12 08:48:28 2001 From: marc.vollmer at mahr.de (Marc Vollmer) Date: Mon, 12 Feb 2001 08:48:28 +0100 Subject: Newbie: Windows DLL Access Message-ID: <9684p5$jktge$1@ID-59219.news.dfncis.de> I try to use a Visual C++ library (.lib or .dll) , but python give me this error: import medvc50f ImportError: dynamic module does not define init function (initmedvc50f) How I can use DLL od LIBS in python? Or where is a description? Thanks Marc From stephen_purcell at yahoo.com Mon Feb 12 10:06:54 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Mon, 12 Feb 2001 10:06:54 +0100 Subject: Newbie: Windows DLL Access In-Reply-To: <9684p5$jktge$1@ID-59219.news.dfncis.de>; from marc.vollmer@mahr.de on Mon, Feb 12, 2001 at 08:48:28AM +0100 References: <9684p5$jktge$1@ID-59219.news.dfncis.de> Message-ID: <20010212100654.B25640@freedom.puma-ag.com> Marc Vollmer wrote: > I try to use a Visual C++ library (.lib or .dll) , but python give me this > error: > > import medvc50f > ImportError: dynamic module does not define init function (initmedvc50f) > > How I can use DLL od LIBS in python? Or where is a description? Check out 'calldll'; http://www.nightmare.com/software.html -Steve -- Steve Purcell, Pythangelist PythonTesting = urlopen('http://pyunit.sourceforge.net/') PythonServlets = urlopen('http://pyserv.sourceforge.net/') Available for consulting and training. "Even snakes are afraid of snakes." -- Steven Wright From ransen_spam_me_not at nemo.it Mon Feb 12 09:03:05 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Mon, 12 Feb 2001 08:03:05 GMT Subject: Embedding Python on the Mac Message-ID: <3a8797bb.2899561@news.newsguy.com> I'm new to python and new to the mac... ...I've heard from various contacts that embedding python in a Windows app is reasonably easy, but has anyone experience of doing it for the Mac? -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From rtrocca at libero.it Tue Feb 13 09:06:48 2001 From: rtrocca at libero.it (Riccardo Trocca) Date: Tue, 13 Feb 2001 08:06:48 GMT Subject: Embedding Python on the Mac References: <3a8797bb.2899561@news.newsguy.com> Message-ID: <1eoqke6.gkpx5c1ydxrokN%rtrocca@libero.it> Not so easy to be sincere. I mean: it is not so difficult if you are using C. It is uch more difficult in C++. Anyway I didn't spend too much time on that. It is better to ask the same question on the MacPython-SIG. The MacPython distribution comes with some example (working) that show how to do that. Owen F. Ransen wrote: > I'm new to python and new to the mac... > ...I've heard from various contacts that embedding > python in a Windows app is reasonably easy, but > has anyone experience of doing it for the Mac? > > > -- > Owen F. Ransen > http://www.ransen.com/ > Home of Gliftic & Repligator Image Generators From ransen_spam_me_not at nemo.it Wed Feb 14 07:30:25 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Wed, 14 Feb 2001 06:30:25 GMT Subject: Embedding Python on the Mac References: <3a8797bb.2899561@news.newsguy.com> <1eoqke6.gkpx5c1ydxrokN%rtrocca@libero.it> Message-ID: <3a8b6d8a.2151036@news.newsguy.com> On Tue, 13 Feb 2001 08:06:48 GMT, rtrocca at libero.it (Riccardo Trocca) wrote: >Not so easy to be sincere. >I mean: it is not so difficult if you are using C. It is uch more >difficult in C++. Anyway I didn't spend too much time on that. It is >better to ask the same question on the MacPython-SIG. >The MacPython distribution comes with some example (working) that show >how to do that. Thanks for the feedback - sei Italiano? Chiedo perche abito vicino a Milano... -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From rtrocca at libero.it Thu Feb 15 08:26:26 2001 From: rtrocca at libero.it (Riccardo Trocca) Date: Thu, 15 Feb 2001 07:26:26 GMT Subject: Embedding Python on the Mac References: <3a8797bb.2899561@news.newsguy.com> <1eoqke6.gkpx5c1ydxrokN%rtrocca@libero.it> <3a8b6d8a.2151036@news.newsguy.com> Message-ID: <1eou9il.92hl7f16x7746N%rtrocca@libero.it> Si si, sono Italiano, studio a genova. Se hai bisogno di qualche aiuto con MacPython e filmati/immagini (vista la tua signature) fatti sentire. Owen F. Ransen wrote: > On Tue, 13 Feb 2001 08:06:48 GMT, rtrocca at libero.it (Riccardo Trocca) > wrote: > > >Not so easy to be sincere. > >I mean: it is not so difficult if you are using C. It is uch more > >difficult in C++. Anyway I didn't spend too much time on that. It is > >better to ask the same question on the MacPython-SIG. > >The MacPython distribution comes with some example (working) that show > >how to do that. > > Thanks for the feedback - sei Italiano? Chiedo perche > abito vicino a Milano... > > > -- > Owen F. Ransen > http://www.ransen.com/ > Home of Gliftic & Repligator Image Generators From fredrik at pythonware.com Mon Feb 12 10:22:00 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 12 Feb 2001 10:22:00 +0100 Subject: ANN: SRE 2.1a2 (separate distribution) Message-ID: <054201c094d5$41b3a110$0900a8c0@SPIFF> in case you don't want to upgrade Python right now: Secret Labs' Regular Expression Engine (SRE) is the new regular expression engine shipped with Python 1.6 and 2.0. The latest SRE version (from Python 2.1a2) is now available separately: http://www.pythonware.com/products/sre Changes from the 2.0 include a couple of bug fixes, and improved portability: this version also works under Python 1.5.2. The distribution includes library source code, and prebuilt Windows binaries for Python 1.5.2 and 2.0. enjoy, the pythonware team "Secret Labs -- makers of fine pythonware since 1997." From vbg-news at bitjungle.com Mon Feb 12 11:31:37 2001 From: vbg-news at bitjungle.com (Vidar Gundersen) Date: Mon, 12 Feb 2001 10:31:37 GMT Subject: __file__ with pythonw Message-ID: how can i get a string with the path to the current python script? (should work both with .py and .pyw) problem using __file__: the statement below works as expected with python.exe, but fails with pythonw.exe because: -- variable __file__ does not exist (?) -- sys.path[0] is empty how come? is it a bug? system info: python 2.0, windows 95 try: filepath = os.path.split(__file__)[0] except: filepath = sys.path[0] -- Vidar Bronken Gundersen From gavin at madzag.com Mon Feb 12 12:07:49 2001 From: gavin at madzag.com (Gavin Tomlins) Date: Mon, 12 Feb 2001 11:07:49 GMT Subject: Permissions or mutable objects... Read only file contents template to write only? Message-ID: <9uPh6.16771$o85.85546@news-server.bigpond.net.au> Greetings I'm currently faced with a problem regarding permissions. I'm trying to read in x# of template files to construct an output file. eg. templateHdr.txt templateFooter.txt outputResult.txt I attempt to read in the files then redirect the inputted template to the output file ergo, cTemplateHdr = "templateHdr.txt" cTemplateFooter = "templateFooter.txt" cOutput = "outputResult.txt" #open files for various operations fileHdr = open(cTemplateHdr, "r") fileFooter = open(cTemplateFooter, "r') fileOutput = open(cOutput, "w") cTempStr = "" cTempStr = fileHdr.readlines() fileOutput.write(cTempStr) at this point I am presented with a type error indicating that I'm trying to write a 'read buffer'. What is the process for rectifying this problem. Any assistance, reference would be greatly appreciated. I've searched the Python documentation but was unable to find appropriate documentation. If possible, could people cite the reference for my understanding. I can only put it down to lack of comprehension or poor choice of search criteria on my behalf. Regards Gavin gavin at madzag.com From ivnowa at hvision.nl Mon Feb 12 13:56:43 2001 From: ivnowa at hvision.nl (Hans Nowak) Date: Mon, 12 Feb 2001 12:56:43 GMT Subject: Permissions or mutable objects... Read only file contents template to write only? References: <9uPh6.16771$o85.85546@news-server.bigpond.net.au> Message-ID: <3A87DBA4.710B@hvision.nl> Gavin Tomlins wrote: > #open files for various operations > fileHdr = open(cTemplateHdr, "r") > fileFooter = open(cTemplateFooter, "r') > fileOutput = open(cOutput, "w") > > cTempStr = "" > cTempStr = fileHdr.readlines() > > fileOutput.write(cTempStr) > > at this point I am presented with a type error indicating that I'm trying to > write a 'read buffer'. fileHdr.readlines() returns a list. So, you are trying to write a list of strings to fileOutput, while the .write method wants a string. You can loop over the list, writing it line by line: for line in cTempStr: fileOutput.write(line) or use the .writelines method: fileOutput.writelines(cTempStr) Maybe you wanted to read only one line from the input file; in that case you can use the .readline method. > What is the process for rectifying this problem. Any assistance, reference > would be greatly appreciated. I've searched the Python documentation but was > unable to find appropriate documentation. If possible, could people cite the > reference for my understanding. I can only put it down to lack of comprehension > or poor choice of search criteria on my behalf. See the Python library reference, 2.1.7.9. HTH, From walterm at cmat.edu.uy Mon Feb 12 14:49:07 2001 From: walterm at cmat.edu.uy (Walter Moreira) Date: Mon, 12 Feb 2001 10:49:07 -0300 Subject: root permissions Message-ID: <20010212104907.A10918@cmat.edu.uy> Hello Python people. Hope this question not to be too off topic. Inside a Python script I must read a file owned by root with permissions 600. But I want the script can be executed by a normal user. What can I do? I am using sudo but this implies that the users must be listed in /etc/sudoers and they get all the privileges. Is there an elegant solution? Thanks. -- Walter -- -------------- Walter Moreira # Centro de Matematica # Universidad de la Republica walterm at cmat.edu.uy http://www.cmat.edu.uy/~walterm Uruguay /OD\_ | "Agent Smith: Never send a human to do a O o . |_o_o_) | machine's job." -- From ``The Matrix'' From cfelling at iae.nl Tue Feb 13 00:13:26 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 13 Feb 2001 00:13:26 +0100 Subject: root permissions References: Message-ID: <969qmm$8pd$1@animus.fel.iae.nl> Walter Moreira wrote: > Hello Python people. > Hope this question not to be too off topic. > Inside a Python script I must read a file owned by root with permissions > 600. But I want the script can be executed by a normal user. What can I do? > I am using sudo but this implies that the users must be listed in /etc/sudoers > and they get all the privileges. Is there an elegant solution? There are basicly three ways to deal with this: 1) restrict sudo acces to your program only 2) wrap your program in a real executable and suid-it (example in the Python source: Misc/setuid-prog.c) 3) make a small suid-ed c program to access that root-owned file and nothing else, and call that program from within your Python script 1 and 2 share the same huge disadvantage of your program being run as root! Be very carefull in your programming, drop root privelige as soon as possible, think twice and then refrain from it all to gether. -- groetjes, carel From erno-news at erno.iki.fi Tue Feb 13 01:51:26 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 13 Feb 2001 02:51:26 +0200 Subject: root permissions References: Message-ID: In article , Walter Moreira writes: | I am using sudo but this implies that the users must be listed in | /etc/sudoers and they get all the privileges. Is there an elegant | solution? it is possible to configure sudo so that some users can only execute some commands. -- erno From un4e at rzstud1.rz.uni-karlsruhe.de Mon Feb 12 15:35:40 2001 From: un4e at rzstud1.rz.uni-karlsruhe.de (Bjoern Giesler) Date: 12 Feb 2001 14:35:40 GMT Subject: PGP wrapper? Message-ID: <968sbs$9of$1@news.rz.uni-karlsruhe.de> Hi, I'm looking for a PGP wrapper written in Python that supports key generation. Unfortunately, the -kg command in PGP requires a lot of interaction; I've tried to wrap it and despaired... Does anyone have such a beast? Or is anyone aware of a library version of PGP, so that I might call the key-generation process directly? Thanks in advance, --Bj?rn From matthias.horst at ruhr-uni-bochum.de Mon Feb 12 15:50:12 2001 From: matthias.horst at ruhr-uni-bochum.de (matthias.horst at ruhr-uni-bochum.de) Date: Mon, 12 Feb 2001 14:50:12 GMT Subject: Python COM Object Return Values in Delphi Message-ID: <968t70$304$1@nnrp1.deja.com> God's blessing for anybody who can help me with the following problem: I have written a Com server object in Python 2.0 similar to that (this is not the problem) class testClass: _public_methods_ = ['daddel'] _reg_progid_ = "somthing" _reg_clsid_ = "{....}" def daddel(self): return ("hello",1) if __name__=='__main__': import win32com.server.register win32com.server.register.UseCommandLine(testClass) Does anybody know how I can access the return value of method daddel? For a simple string or integer it's clear : procedure callIt; var obj:variant; dummy:string; begin obj=createOleObject("putInHereTheName") dummy=obj.callHereTheMethod; end; But for a complex tupple...?!?!? Thanks in advance. Sent via Deja.com http://www.deja.com/ From embed at geocities.com Mon Feb 12 16:03:07 2001 From: embed at geocities.com (Warren Postma) Date: Mon, 12 Feb 2001 10:03:07 -0500 Subject: Signals between threads Message-ID: I am limited by my embedded platform to a single process, with multiple threads. I have implemented a time.sleep() modification that makes it interruptable (I use WaitForSingleObject( hInterruptSleepEvent,ms ) != WAIT_TIMEOUT) in timemodule.c. Now I'm considering some improvements to the thread-by-thread signalling code in my personal python 1.5.2 variant: import thread,time def myfunc(): print "starting" try: time.sleep(999999) except: print "time.sleep blew up. must have been sent an exception" print "stopping" thrd = thread.start_new_thread( myfunc, () ) # currently thrd would be None. time.sleep(1.0) thrd.raise_exception(KeyboardInterrupt) # the wishfull-thinking bit. time.sleep(1.0) This is very much a practical effort to get real work done, but also in the long term I'm intereseted in contributing threading improvements to the 2.xx codebase. In particular, the ability of one thread to send a signal (raise an exception in another thread), and for the built-in thread module to return a an object that can be used for this purpose. (Currently thread.start_new_thread returns None. I consider that to be Horrid Behaviour, and the module threading.py to be a nice-API, but which should be implemented in Python itself.) I agree with posters who said that interruptable and "killable" threads are a bad, or dangerous, idea. I think the ability to inject an exception into another thread could easily be abused, however I also think it needs to be there, for when it's essential to getting a job done. Is anyone else in a similar bind? What are you considering? Warren Postma From parz at home.com Mon Feb 12 21:57:01 2001 From: parz at home.com (Parzival Herzog) Date: Mon, 12 Feb 2001 20:57:01 GMT Subject: Signals between threads References: Message-ID: "Warren Postma" wrote in message news:UXSh6.2933$D3.13081 at tor-nn1.netcom.ca... > In particular, the ability of one thread to send a signal (raise an > exception in another thread), and for the built-in thread module to return a > an object that can be used for this purpose. (Currently > thread.start_new_thread returns None. I consider that to be Horrid > Behaviour, and the module threading.py to be a nice-API, but which should be > implemented in Python itself.) > > I agree with posters who said that interruptable and "killable" threads are > a bad, or dangerous, idea. I think the ability to inject an exception > into another thread could easily be abused, however I also think it needs to > be there, for when it's essential to getting a job done. Absolutely: This is the single greatest defect in Python threads. You have to have a way to signal threads independent of whether they are blocked. In Modula-3, an exception, defined in the threading interface: "Thread.Alerted" is used to accomplish this. This makes Modula-3 threads practical to use. Python requires that threads poll for exceptional conditions, e.g "while self.keepRunning:" without providing a guaranteed way to ensure that the polling loop will actually run (i.e the thread could be blocked for abitrary amounts of time in i/O, or in consume arbitrary amounts of time in computation before returning to the polling loop. These requirements arise in real applications that need to be robust and reliable in an unreliable environment. So yes, lets have a "thread.alerted" exception! - Parzival From Pieter_Claerhout at CreoScitex.com Mon Feb 12 16:04:27 2001 From: Pieter_Claerhout at CreoScitex.com (Pieter Claerhout) Date: Mon, 12 Feb 2001 16:04:27 +0100 Subject: Command prompts on a Windows station Message-ID: <2B1262E83448D211AE4B00A0C9D61B030130191A@msgeuro1.177.115.149.IN-ADDR.ARPA> Hello all, is there a way in Python to catch that a command prompt was closed by clicking on the close button in the title bar? I have a script that is launching several other scripts, and I would like to kill those processes again once the main script is closed again. I can catch this when he is pressing CTRL+BREAK, but I can seem to catch is when the window is closed using the close button? Any ideas? I remember that an email about this was going around, but I can't seem to find it back... Thanks, Pieter From timr at probo.com Wed Feb 14 07:56:30 2001 From: timr at probo.com (Tim Roberts) Date: Tue, 13 Feb 2001 22:56:30 -0800 Subject: Command prompts on a Windows station References: Message-ID: Pieter Claerhout wrote: > >is there a way in Python to catch that a command prompt was closed by >clicking on the close button in the title bar? Not as far as I know. Clicking the 'close' button is a drastic termination; it is a signal to the application that displays DOS windows (WINOLDAP), which closes the VM without any further notice to the programs running in the VM. That's why, ordinarily, you get a "warning, is this really what you want to do?" dialog when you close it that way. If you were a clever sort, you might be able to do some magic with the Win32 API. You could use FindWindow to locate the window, subclass the window with your own WndProc, and watch for WM_CLOSE messages. However, that's not very Python-like. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From bragib at my-deja.com Mon Feb 12 16:59:25 2001 From: bragib at my-deja.com (bragib at my-deja.com) Date: Mon, 12 Feb 2001 15:59:25 GMT Subject: How to end process started in os.popen? Message-ID: <96918n$6sn$1@nnrp1.deja.com> I am running a csh script and getting the output through a pipe using os.popen() on Unix. I would like to be able to kill the running of the csh script if a certain event occurs. Just closing the pipe won't stop the csh script. Bragi Sent via Deja.com http://www.deja.com/ From erno-news at erno.iki.fi Mon Feb 12 17:51:03 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 12 Feb 2001 18:51:03 +0200 Subject: How to end process started in os.popen? References: <96918n$6sn$1@nnrp1.deja.com> Message-ID: In article <96918n$6sn$1 at nnrp1.deja.com>, bragib at my-deja.com writes: | I am running a csh script and getting the output through a pipe using | os.popen() on Unix. I would like to be able to kill the running of the | csh script if a certain event occurs. | Just closing the pipe won't stop the csh script. you could have the csh script write its pid to a file somewhere, and use that. or you could roll your own popen with fork, pipe and exec that returned the pid too. -- erno From roymath at my-deja.com Mon Feb 12 17:09:46 2001 From: roymath at my-deja.com (roymath at my-deja.com) Date: Mon, 12 Feb 2001 16:09:46 GMT Subject: Help: Non-capturing RE fails? Message-ID: <9691s1$7f7$1@nnrp1.deja.com> Hi folks, I don't know if it is my understanding of non-capturing REs thats flawed, or there is a bug in CPython 2.0. Anyhow, the following test indicates what I think is the problem: Please email me as well at roymath at yahoo.com, as I dont always have access to dejanews. Thanks, Roy. # ---------------------------------------------------------------------- import re str = r' - <> @<> <> - ' desiredResult = r" - ba @<> c - " # The following fails. produces: " -ba @<>c - " (Note. whitespace is eaten up). # Use non-capturing RE. r = re.compile(r'(?:[^@])<<(.*?)>>') print re.sub(r, r"\1", str) # The following succeeds. produces: " - ba @<> c - " # Use a named group instead of non-capturing RE def mysub(x): # print x.groups() return x.group('ws') + x.group('pat') r = re.compile(r'(?P[^@])<<(?P.*?)>>') print re.sub(r, mysub, str) # ------------------------------------------------------------------------ Sent via Deja.com http://www.deja.com/ From roymath at yahoo.com Mon Feb 12 17:12:56 2001 From: roymath at yahoo.com (roymath at yahoo.com) Date: Mon, 12 Feb 2001 16:12:56 GMT Subject: Help: non-capturing group RE fails Message-ID: <96921u$7j8$1@nnrp1.deja.com> Hi folks, I don't know if it is my understanding of non-capturing REs thats flawed, or there is a bug in CPython 2.0. Anyhow, the following test indicates what I think is the problem: Please email me as well at roymath at yahoo.com, as I dont always have access to dejanews. Thanks, Roy. # ---------------------------------------------------------------------- import re str = r' - <> @<> <> - ' desiredResult = r" - ba @<> c - " # The following fails. produces: " -ba @<>c - " (Note. whitespace is eaten up). # Use non-capturing RE. r = re.compile(r'(?:[^@])<<(.*?)>>') print re.sub(r, r"\1", str) # The following succeeds. produces: " - ba @<> c - " # Use a named group instead of non-capturing RE def mysub(x): # print x.groups() return x.group('ws') + x.group('pat') r = re.compile(r'(?P[^@])<<(?P.*?)>>') print re.sub(r, mysub, str) # ------------------------------------------------------------------------ Sent via Deja.com http://www.deja.com/ From robin.thomas at starmedia.net Mon Feb 12 17:57:04 2001 From: robin.thomas at starmedia.net (Robin Thomas) Date: Mon, 12 Feb 2001 11:57:04 -0500 Subject: Help: non-capturing group RE fails In-Reply-To: <96921u$7j8$1@nnrp1.deja.com> Message-ID: <4.3.1.2.20010212115249.00d2b100@exchange.starmedia.net> At 04:12 PM 2/12/01 +0000, roymath at yahoo.com wrote: ># ---------------------------------------------------------------------- >import re > >str = r' - <> @<> <> - ' >desiredResult = r" - ba @<> c - " > ># The following fails. produces: " -ba @<>c - " (Note. whitespace is >eaten up). ># Use non-capturing RE. >r = re.compile(r'(?:[^@])<<(.*?)>>') (?:[^@]) is not a "group" that can be referenced. It is an "assertion", or "lookahead assertion", that is part of the match but does not get a group reference. That's why it is consumed along with the other ungrouped parts of the match, like << and >>. r'([^@])<<(.*?)>>' is the quickest fix, along with >print re.sub(r, r"\1", str) print re.sub(r, r"\1\2", str) completes the quick fix. ># The following succeeds. produces: " - ba @<> c - " ># Use a named group instead of non-capturing RE > >def mysub(x): > # print x.groups() > return x.group('ws') + x.group('pat') > >r = re.compile(r'(?P[^@])<<(?P.*?)>>') >print re.sub(r, mysub, str) Here, (?P[^@]) really is a group definition, not merely a lookahead assertion. That's why it behaves differently. The fact that you've named the groups instead of using the implicit group numbering isn't material. -- Robin Thomas Director, Platform Engineering StarMedia Network, Inc. robin.thomas at starmedia.net From robin.thomas at starmedia.net Mon Feb 12 20:00:08 2001 From: robin.thomas at starmedia.net (Robin Thomas) Date: Mon, 12 Feb 2001 14:00:08 -0500 Subject: Help: non-capturing group RE fails In-Reply-To: <20010212173431.6556.qmail@web10004.mail.yahoo.com> References: <4.3.1.2.20010212115249.00d2b100@exchange.starmedia.net> Message-ID: <4.3.1.2.20010212124918.00d2f2c0@exchange.starmedia.net> At 09:34 AM 2/12/01 -0800, Roy Mathew wrote: >Robin, > >Thanks for your clear explanation; I had assumed that "non-capturing" meant >"non-consuming" as well. I am still puzzled however, over the >following behavior (slightly modified from before). ie: why does >the "?=" which is a +ve lookahead assertion not produce the result >we are looking for: Damn, I'm sorry. I failed to notice that you want *nothing* touched in @<>. Anything not in a group will not be put in your replacement string, because there's no way to reference it. Things aren't "consumed", they're just considered part of the match, and the entire mathc substring is replaced with your replacement string. "consumed" refers to anything that is not a lookahead or zero-width assertion. ?= does not consume any of the string. So ?=[^@] says, "check the next character. As long as it's not '@', this re could still match. Continue matching at the same character I just checked!" So the next part of the re will start matching at the same character. That's why you get the weird behavior. A negative lookbehind behaves differently. It will exclude the lookbehind's contents from the match, and do what you want: # new code, works in 1.6 and up import re str = r' - <> @<> <> - ' r = re.compile(r'(?>') print r.sub(r"\1", str) -- Robin Thomas Director, Platform Engineering StarMedia Network, Inc. robin.thomas at starmedia.net From zope at thewebsons.com Mon Feb 12 17:31:14 2001 From: zope at thewebsons.com (Ben Ocean) Date: Mon, 12 Feb 2001 08:31:14 -0800 Subject: How Best Get These Components? Message-ID: <5.0.2.1.0.20010212082638.009f3320@thewebsons.com> Hi; I ran into some strange problems when I re-located my Apache box. Because of that, I (stupidly) ended up ripping out all things python and trying to re-install it. Well, python appears to work now, but I still appear to be missing a bunch of components. Then again, maybe I'm not: if python can't work with the components listed below, then perhaps I have a dead installation and a good one, too. (As an example, Zope works just fine.) What's the easiest way to test for if I really do need these tools? If I *do* need them, how should I go about installing them? TIA, BenO the list... missing /usr/lib/python1.5/site-packages/_appletmodule.so missing /usr/lib/python1.5/site-packages/_cappletmodule.so missing /usr/lib/python1.5/site-packages/_gnomemodule.so missing /usr/lib/python1.5/site-packages/_gnomeuimodule.so missing /usr/lib/python1.5/site-packages/_gtkxmhtmlmodule.so missing /usr/lib/python1.5/site-packages/_zvtmodule.so missing /usr/lib/python1.5/site-packages/gettext.py missing /usr/lib/python1.5/site-packages/gettext.pyc missing /usr/lib/python1.5/site-packages/gettext.pyo missing /usr/lib/python1.5/site-packages/gnome/__init__.py missing /usr/lib/python1.5/site-packages/gnome/__init__.pyc missing /usr/lib/python1.5/site-packages/gnome/__init__.pyo missing /usr/lib/python1.5/site-packages/gnome/affine.py missing /usr/lib/python1.5/site-packages/gnome/affine.pyc missing /usr/lib/python1.5/site-packages/gnome/affine.pyo missing /usr/lib/python1.5/site-packages/gnome/applet.py missing /usr/lib/python1.5/site-packages/gnome/applet.pyc missing /usr/lib/python1.5/site-packages/gnome/applet.pyo missing /usr/lib/python1.5/site-packages/gnome/capplet.py missing /usr/lib/python1.5/site-packages/gnome/capplet.pyc missing /usr/lib/python1.5/site-packages/gnome/capplet.pyo missing /usr/lib/python1.5/site-packages/gnome/config.py missing /usr/lib/python1.5/site-packages/gnome/config.pyc missing /usr/lib/python1.5/site-packages/gnome/config.pyo missing /usr/lib/python1.5/site-packages/gnome/file.py missing /usr/lib/python1.5/site-packages/gnome/file.pyc missing /usr/lib/python1.5/site-packages/gnome/file.pyo missing /usr/lib/python1.5/site-packages/gnome/help.py missing /usr/lib/python1.5/site-packages/gnome/help.pyc missing /usr/lib/python1.5/site-packages/gnome/help.pyo missing /usr/lib/python1.5/site-packages/gnome/history.py missing /usr/lib/python1.5/site-packages/gnome/history.pyc missing /usr/lib/python1.5/site-packages/gnome/history.pyo missing /usr/lib/python1.5/site-packages/gnome/metadata.py missing /usr/lib/python1.5/site-packages/gnome/metadata.pyc missing /usr/lib/python1.5/site-packages/gnome/metadata.pyo missing /usr/lib/python1.5/site-packages/gnome/mime.py missing /usr/lib/python1.5/site-packages/gnome/mime.pyc missing /usr/lib/python1.5/site-packages/gnome/mime.pyo missing /usr/lib/python1.5/site-packages/gnome/score.py missing /usr/lib/python1.5/site-packages/gnome/score.pyc missing /usr/lib/python1.5/site-packages/gnome/score.pyo missing /usr/lib/python1.5/site-packages/gnome/triggers.py missing /usr/lib/python1.5/site-packages/gnome/triggers.pyc missing /usr/lib/python1.5/site-packages/gnome/triggers.pyo missing /usr/lib/python1.5/site-packages/gnome/ui.py missing /usr/lib/python1.5/site-packages/gnome/ui.pyc missing /usr/lib/python1.5/site-packages/gnome/ui.pyo missing /usr/lib/python1.5/site-packages/gnome/uiconsts.py missing /usr/lib/python1.5/site-packages/gnome/uiconsts.pyc missing /usr/lib/python1.5/site-packages/gnome/uiconsts.pyo missing /usr/lib/python1.5/site-packages/gnome/url.py missing /usr/lib/python1.5/site-packages/gnome/url.pyc missing /usr/lib/python1.5/site-packages/gnome/url.pyo missing /usr/lib/python1.5/site-packages/gnome/xmhtml.py missing /usr/lib/python1.5/site-packages/gnome/xmhtml.pyc missing /usr/lib/python1.5/site-packages/gnome/xmhtml.pyo missing /usr/lib/python1.5/site-packages/gnome/zvt.py missing /usr/lib/python1.5/site-packages/gnome/zvt.pyc missing /usr/lib/python1.5/site-packages/gnome/zvt.pyo missing /usr/lib/python1.5/site-packages/GDK.py missing /usr/lib/python1.5/site-packages/GDK.pyc missing /usr/lib/python1.5/site-packages/GDK.pyo missing /usr/lib/python1.5/site-packages/GTK.py missing /usr/lib/python1.5/site-packages/GTK.pyc missing /usr/lib/python1.5/site-packages/GTK.pyo missing /usr/lib/python1.5/site-packages/GdkImlib.py missing /usr/lib/python1.5/site-packages/GdkImlib.pyc missing /usr/lib/python1.5/site-packages/GdkImlib.pyo missing /usr/lib/python1.5/site-packages/GtkExtra.py missing /usr/lib/python1.5/site-packages/GtkExtra.pyc missing /usr/lib/python1.5/site-packages/GtkExtra.pyo missing /usr/lib/python1.5/site-packages/Gtkinter.py missing /usr/lib/python1.5/site-packages/Gtkinter.pyc missing /usr/lib/python1.5/site-packages/Gtkinter.pyo missing /usr/lib/python1.5/site-packages/_gdkimlibmodule.so missing /usr/lib/python1.5/site-packages/_gtkmodule.so missing /usr/lib/python1.5/site-packages/gtk.py missing /usr/lib/python1.5/site-packages/gtk.pyc missing /usr/lib/python1.5/site-packages/gtk.pyo missing /usr/lib/python1.5/site-packages/pyglade/__init__.py missing /usr/lib/python1.5/site-packages/pyglade/__init__.pyc missing /usr/lib/python1.5/site-packages/pyglade/__init__.pyo missing /usr/lib/python1.5/site-packages/pyglade/build.py missing /usr/lib/python1.5/site-packages/pyglade/build.pyc missing /usr/lib/python1.5/site-packages/pyglade/build.pyo missing /usr/lib/python1.5/site-packages/pyglade/style.py missing /usr/lib/python1.5/site-packages/pyglade/style.pyc missing /usr/lib/python1.5/site-packages/pyglade/style.pyo missing /usr/lib/python1.5/site-packages/pyglade/xmlparse.py missing /usr/lib/python1.5/site-packages/pyglade/xmlparse.pyc missing /usr/lib/python1.5/site-packages/pyglade/xmlparse.pyo /usr/lib/python1.5/site-packages/rpmmodule.so missing /usr/lib/python1.5/lib-dynload/_tkinter.so missing /usr/lib/python1.5/lib-tk missing /usr/lib/python1.5/lib-tk/Canvas.py missing /usr/lib/python1.5/lib-tk/Canvas.pyc missing /usr/lib/python1.5/lib-tk/Canvas.pyo missing /usr/lib/python1.5/lib-tk/Dialog.py missing /usr/lib/python1.5/lib-tk/Dialog.pyc missing /usr/lib/python1.5/lib-tk/Dialog.pyo missing /usr/lib/python1.5/lib-tk/FileDialog.py missing /usr/lib/python1.5/lib-tk/FileDialog.pyc missing /usr/lib/python1.5/lib-tk/FileDialog.pyo missing /usr/lib/python1.5/lib-tk/FixTk.py missing /usr/lib/python1.5/lib-tk/FixTk.pyc missing /usr/lib/python1.5/lib-tk/FixTk.pyo missing /usr/lib/python1.5/lib-tk/ScrolledText.py missing /usr/lib/python1.5/lib-tk/ScrolledText.pyc missing /usr/lib/python1.5/lib-tk/ScrolledText.pyo missing /usr/lib/python1.5/lib-tk/SimpleDialog.py missing /usr/lib/python1.5/lib-tk/SimpleDialog.pyc missing /usr/lib/python1.5/lib-tk/SimpleDialog.pyo missing /usr/lib/python1.5/lib-tk/Tkconstants.py missing /usr/lib/python1.5/lib-tk/Tkconstants.pyc missing /usr/lib/python1.5/lib-tk/Tkconstants.pyo missing /usr/lib/python1.5/lib-tk/Tkdnd.py missing /usr/lib/python1.5/lib-tk/Tkdnd.pyc missing /usr/lib/python1.5/lib-tk/Tkdnd.pyo missing /usr/lib/python1.5/lib-tk/Tkinter.py missing /usr/lib/python1.5/lib-tk/Tkinter.pyc missing /usr/lib/python1.5/lib-tk/Tkinter.pyo missing /usr/lib/python1.5/lib-tk/tkColorChooser.py missing /usr/lib/python1.5/lib-tk/tkColorChooser.pyc missing /usr/lib/python1.5/lib-tk/tkColorChooser.pyo missing /usr/lib/python1.5/lib-tk/tkCommonDialog.py missing /usr/lib/python1.5/lib-tk/tkCommonDialog.pyc missing /usr/lib/python1.5/lib-tk/tkCommonDialog.pyo missing /usr/lib/python1.5/lib-tk/tkFileDialog.py missing /usr/lib/python1.5/lib-tk/tkFileDialog.pyc missing /usr/lib/python1.5/lib-tk/tkFileDialog.pyo missing /usr/lib/python1.5/lib-tk/tkFont.py missing /usr/lib/python1.5/lib-tk/tkFont.pyc missing /usr/lib/python1.5/lib-tk/tkFont.pyo missing /usr/lib/python1.5/lib-tk/tkMessageBox.py missing /usr/lib/python1.5/lib-tk/tkMessageBox.pyc missing /usr/lib/python1.5/lib-tk/tkMessageBox.pyo missing /usr/lib/python1.5/lib-tk/tkSimpleDialog.py missing /usr/lib/python1.5/lib-tk/tkSimpleDialog.pyc missing /usr/lib/python1.5/lib-tk/tkSimpleDialog.pyo From dsh8290 at rit.edu Mon Feb 12 21:00:16 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 12 Feb 2001 15:00:16 -0500 Subject: How Best Get These Components? In-Reply-To: <5.0.2.1.0.20010212082638.009f3320@thewebsons.com>; from zope@thewebsons.com on Mon, Feb 12, 2001 at 08:31:14AM -0800 References: <5.0.2.1.0.20010212082638.009f3320@thewebsons.com> Message-ID: <20010212150016.B5667@harmony.cs.rit.edu> Whether or not you need them depends on what you want to do. On Mon, Feb 12, 2001 at 08:31:14AM -0800, Ben Ocean wrote: | Hi; | I ran into some strange problems when I re-located my Apache box. Because | of that, I (stupidly) ended up ripping out all things python and trying to | re-install it. Well, python appears to work now, but I still appear to be | missing a bunch of components. Then again, maybe I'm not: if python can't | work with the components listed below, then perhaps I have a dead | installation and a good one, too. (As an example, Zope works just fine.) | What's the easiest way to test for if I really do need these tools? If I | *do* need them, how should I go about installing them? | TIA, | BenO | | the list... | These are the GTK/GNOME bindings. There should be a link to James' site (the maintainer) from gtk.org and gnome.org. You only need them if you want to use programs that use gtk or gnome (for the user interface). | missing /usr/lib/python1.5/site-packages/_appletmodule.so | missing /usr/lib/python1.5/site-packages/_cappletmodule.so | missing /usr/lib/python1.5/site-packages/_gnomemodule.so | missing /usr/lib/python1.5/site-packages/_gnomeuimodule.so | missing /usr/lib/python1.5/site-packages/_gtkxmhtmlmodule.so | missing /usr/lib/python1.5/site-packages/gnome/__init__.py | missing /usr/lib/python1.5/site-packages/gnome/__init__.pyc | missing /usr/lib/python1.5/site-packages/gnome/__init__.pyo | missing /usr/lib/python1.5/site-packages/gnome/affine.py | missing /usr/lib/python1.5/site-packages/gnome/affine.pyc | missing /usr/lib/python1.5/site-packages/gnome/affine.pyo | missing /usr/lib/python1.5/site-packages/gnome/applet.py | missing /usr/lib/python1.5/site-packages/gnome/applet.pyc | missing /usr/lib/python1.5/site-packages/gnome/applet.pyo | missing /usr/lib/python1.5/site-packages/gnome/capplet.py | missing /usr/lib/python1.5/site-packages/gnome/capplet.pyc | missing /usr/lib/python1.5/site-packages/gnome/capplet.pyo | missing /usr/lib/python1.5/site-packages/gnome/config.py | missing /usr/lib/python1.5/site-packages/gnome/config.pyc | missing /usr/lib/python1.5/site-packages/gnome/config.pyo | missing /usr/lib/python1.5/site-packages/gnome/file.py | missing /usr/lib/python1.5/site-packages/gnome/file.pyc | missing /usr/lib/python1.5/site-packages/gnome/file.pyo | missing /usr/lib/python1.5/site-packages/gnome/help.py | missing /usr/lib/python1.5/site-packages/gnome/help.pyc | missing /usr/lib/python1.5/site-packages/gnome/help.pyo | missing /usr/lib/python1.5/site-packages/gnome/history.py | missing /usr/lib/python1.5/site-packages/gnome/history.pyc | missing /usr/lib/python1.5/site-packages/gnome/history.pyo | missing /usr/lib/python1.5/site-packages/gnome/metadata.py | missing /usr/lib/python1.5/site-packages/gnome/metadata.pyc | missing /usr/lib/python1.5/site-packages/gnome/metadata.pyo | missing /usr/lib/python1.5/site-packages/gnome/mime.py | missing /usr/lib/python1.5/site-packages/gnome/mime.pyc | missing /usr/lib/python1.5/site-packages/gnome/mime.pyo | missing /usr/lib/python1.5/site-packages/gnome/score.py | missing /usr/lib/python1.5/site-packages/gnome/score.pyc | missing /usr/lib/python1.5/site-packages/gnome/score.pyo | missing /usr/lib/python1.5/site-packages/gnome/triggers.py | missing /usr/lib/python1.5/site-packages/gnome/triggers.pyc | missing /usr/lib/python1.5/site-packages/gnome/triggers.pyo | missing /usr/lib/python1.5/site-packages/gnome/ui.py | missing /usr/lib/python1.5/site-packages/gnome/ui.pyc | missing /usr/lib/python1.5/site-packages/gnome/ui.pyo | missing /usr/lib/python1.5/site-packages/gnome/uiconsts.py | missing /usr/lib/python1.5/site-packages/gnome/uiconsts.pyc | missing /usr/lib/python1.5/site-packages/gnome/uiconsts.pyo | missing /usr/lib/python1.5/site-packages/gnome/url.py | missing /usr/lib/python1.5/site-packages/gnome/url.pyc | missing /usr/lib/python1.5/site-packages/gnome/url.pyo | missing /usr/lib/python1.5/site-packages/gnome/xmhtml.py | missing /usr/lib/python1.5/site-packages/gnome/xmhtml.pyc | missing /usr/lib/python1.5/site-packages/gnome/xmhtml.pyo | missing /usr/lib/python1.5/site-packages/gnome/zvt.py | missing /usr/lib/python1.5/site-packages/gnome/zvt.pyc | missing /usr/lib/python1.5/site-packages/gnome/zvt.pyo | missing /usr/lib/python1.5/site-packages/GDK.py | missing /usr/lib/python1.5/site-packages/GDK.pyc | missing /usr/lib/python1.5/site-packages/GDK.pyo | missing /usr/lib/python1.5/site-packages/GTK.py | missing /usr/lib/python1.5/site-packages/GTK.pyc | missing /usr/lib/python1.5/site-packages/GTK.pyo | missing /usr/lib/python1.5/site-packages/GdkImlib.py | missing /usr/lib/python1.5/site-packages/GdkImlib.pyc | missing /usr/lib/python1.5/site-packages/GdkImlib.pyo | missing /usr/lib/python1.5/site-packages/GtkExtra.py | missing /usr/lib/python1.5/site-packages/GtkExtra.pyc | missing /usr/lib/python1.5/site-packages/GtkExtra.pyo | missing /usr/lib/python1.5/site-packages/Gtkinter.py | missing /usr/lib/python1.5/site-packages/Gtkinter.pyc | missing /usr/lib/python1.5/site-packages/Gtkinter.pyo | missing /usr/lib/python1.5/site-packages/_gdkimlibmodule.so | missing /usr/lib/python1.5/site-packages/_gtkmodule.so | missing /usr/lib/python1.5/site-packages/gtk.py | missing /usr/lib/python1.5/site-packages/gtk.pyc | missing /usr/lib/python1.5/site-packages/gtk.pyo | missing /usr/lib/python1.5/site-packages/pyglade/__init__.py | missing /usr/lib/python1.5/site-packages/pyglade/__init__.pyc | missing /usr/lib/python1.5/site-packages/pyglade/__init__.pyo | missing /usr/lib/python1.5/site-packages/pyglade/build.py | missing /usr/lib/python1.5/site-packages/pyglade/build.pyc | missing /usr/lib/python1.5/site-packages/pyglade/build.pyo | missing /usr/lib/python1.5/site-packages/pyglade/style.py | missing /usr/lib/python1.5/site-packages/pyglade/style.pyc | missing /usr/lib/python1.5/site-packages/pyglade/style.pyo | missing /usr/lib/python1.5/site-packages/pyglade/xmlparse.py | missing /usr/lib/python1.5/site-packages/pyglade/xmlparse.pyc | missing /usr/lib/python1.5/site-packages/pyglade/xmlparse.pyo Looks like this is the Tkinter bindings. I don't know where to get them. It should have been included in the standard dist. I don't know what to do (since you built your own, right?) These are only necessary if you want to run programs using Tkinter for the UI. | missing /usr/lib/python1.5/lib-dynload/_tkinter.so | missing /usr/lib/python1.5/lib-tk | missing /usr/lib/python1.5/lib-tk/Canvas.py | missing /usr/lib/python1.5/lib-tk/Canvas.pyc | missing /usr/lib/python1.5/lib-tk/Canvas.pyo | missing /usr/lib/python1.5/lib-tk/Dialog.py | missing /usr/lib/python1.5/lib-tk/Dialog.pyc | missing /usr/lib/python1.5/lib-tk/Dialog.pyo | missing /usr/lib/python1.5/lib-tk/FileDialog.py | missing /usr/lib/python1.5/lib-tk/FileDialog.pyc | missing /usr/lib/python1.5/lib-tk/FileDialog.pyo | missing /usr/lib/python1.5/lib-tk/FixTk.py | missing /usr/lib/python1.5/lib-tk/FixTk.pyc | missing /usr/lib/python1.5/lib-tk/FixTk.pyo | missing /usr/lib/python1.5/lib-tk/ScrolledText.py | missing /usr/lib/python1.5/lib-tk/ScrolledText.pyc | missing /usr/lib/python1.5/lib-tk/ScrolledText.pyo | missing /usr/lib/python1.5/lib-tk/SimpleDialog.py | missing /usr/lib/python1.5/lib-tk/SimpleDialog.pyc | missing /usr/lib/python1.5/lib-tk/SimpleDialog.pyo | missing /usr/lib/python1.5/lib-tk/Tkconstants.py | missing /usr/lib/python1.5/lib-tk/Tkconstants.pyc | missing /usr/lib/python1.5/lib-tk/Tkconstants.pyo | missing /usr/lib/python1.5/lib-tk/Tkdnd.py | missing /usr/lib/python1.5/lib-tk/Tkdnd.pyc | missing /usr/lib/python1.5/lib-tk/Tkdnd.pyo | missing /usr/lib/python1.5/lib-tk/Tkinter.py | missing /usr/lib/python1.5/lib-tk/Tkinter.pyc | missing /usr/lib/python1.5/lib-tk/Tkinter.pyo | missing /usr/lib/python1.5/lib-tk/tkColorChooser.py | missing /usr/lib/python1.5/lib-tk/tkColorChooser.pyc | missing /usr/lib/python1.5/lib-tk/tkColorChooser.pyo | missing /usr/lib/python1.5/lib-tk/tkCommonDialog.py | missing /usr/lib/python1.5/lib-tk/tkCommonDialog.pyc | missing /usr/lib/python1.5/lib-tk/tkCommonDialog.pyo | missing /usr/lib/python1.5/lib-tk/tkFileDialog.py | missing /usr/lib/python1.5/lib-tk/tkFileDialog.pyc | missing /usr/lib/python1.5/lib-tk/tkFileDialog.pyo | missing /usr/lib/python1.5/lib-tk/tkFont.py | missing /usr/lib/python1.5/lib-tk/tkFont.pyc | missing /usr/lib/python1.5/lib-tk/tkFont.pyo | missing /usr/lib/python1.5/lib-tk/tkMessageBox.py | missing /usr/lib/python1.5/lib-tk/tkMessageBox.pyc | missing /usr/lib/python1.5/lib-tk/tkMessageBox.pyo | missing /usr/lib/python1.5/lib-tk/tkSimpleDialog.py | missing /usr/lib/python1.5/lib-tk/tkSimpleDialog.pyc | missing /usr/lib/python1.5/lib-tk/tkSimpleDialog.pyo Not sure where these come from, but gettext is the GNU library for internationalizing programs. These are only necessary if you want to run programs that use gettext for internationalization. | missing /usr/lib/python1.5/site-packages/_zvtmodule.so | missing /usr/lib/python1.5/site-packages/gettext.py | missing /usr/lib/python1.5/site-packages/gettext.pyc | missing /usr/lib/python1.5/site-packages/gettext.pyo If you don't want to run programs that need these modules, then you don't need to install them. If you do (say, netcfg or printtool -- both need Tkinter) then they will crash with a Import Failed, No Such Module type of message. You have a RH system right? You should just be able to install the rpms. Of course, since you compiled python from source, rpm will complain that you are missing python. Just use --nodeps when you install. Also realize that you will "forever" have such issues since part of your system is rpm-based and part is hand installed from tarballs. HTH, -D From gvwilson at interlog.com Mon Feb 12 17:53:59 2001 From: gvwilson at interlog.com (Greg Wilson) Date: 12 Feb 2001 11:53:59 -0500 Subject: Python Conference BOF Mailing lists Message-ID: <9694f7$q5e@shell1.interlog.com> Two mailing lists have been set up to discuss admin issues for the BOFs on iterators and sets: Iterator-BOF at python9.org (March 6) Set-BOF at python9.org (March 7) If you are planning to attend, please send mail to the list, so that we can plan room allocation, make sure we get served quickly for lunch so that we can get discussion started early, etc. Greg From paul.moore at uk.origin-it.com Mon Feb 12 18:03:55 2001 From: paul.moore at uk.origin-it.com (Paul Moore) Date: Mon, 12 Feb 2001 18:03:55 +0100 Subject: How do I use a pyc file created with an older version of Python? Message-ID: Hi, This is probably a silly question, but I have an old pyc file generated under Python 1.5.? (I think), and I now use Python 2.0. I don't have the source easily accessible, unortunately, and I don't really want to install Python 1.5 as well, just for this one bit of code. Is it possible to convert a pyc from an older version of Python to a newer one, without the source? It seems like it should be possible, as a pyc is (I believe) just a magic number plus a marshalled code object. Assuming the code itself is compatible, could I just "fix" the magic number? Or would I need to "upgrade" the marshalled code somehow? Or is this not possible, and I just have to get the source back...? Thanks, Paul From mwh21 at cam.ac.uk Mon Feb 12 18:27:39 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 12 Feb 2001 17:27:39 +0000 Subject: How do I use a pyc file created with an older version of Python? References: Message-ID: Paul Moore writes: > Is it possible to convert a pyc from an older version of Python to a > newer one, without the source? It seems like it should be possible, > as a pyc is (I believe) just a magic number plus a marshalled code > object. Assuming the code itself is compatible, could I just "fix" > the magic number? The reason the magic number is different is because the code is not compatible. > Or would I need to "upgrade" the marshalled code somehow? Or is this > not possible, and I just have to get the source back...? Getting the source back is your only real hope. I suppose it would be possible to write a 1.5.2 -> 2.0 bytecode translator (the differences aren't all that great), but it doesn't seem worth the effort (to me, at least). There's also decompyle (google for it) that may, or may not, be able to translate your .pyc into a .py. Cheers, M. -- You owe The Oracle a TV with an 'intelligence' control - I've tried 'brightness' but that didn't work. -- Internet Oracularity #1192-01 From stephen_purcell at yahoo.com Mon Feb 12 18:38:08 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Mon, 12 Feb 2001 18:38:08 +0100 Subject: How do I use a pyc file created with an older version of Python? In-Reply-To: ; from paul.moore@uk.origin-it.com on Mon, Feb 12, 2001 at 06:03:55PM +0100 References: Message-ID: <20010212183808.A1750@freedom.puma-ag.com> Paul Moore wrote: > Is it possible to convert a pyc from an older version of Python to a > newer one, without the source? It seems like it should be possible, as > a pyc is (I believe) just a magic number plus a marshalled code > object. Bad luck. The marshalled code objects aren't compatible from 1.5.2 to 2.0. -Steve -- Steve Purcell, Pythangelist http://pyunit.sourceforge.net/ http://pyserv.sourceforge.net/ Available for consulting and training. "Even snakes are afraid of snakes." -- Steven Wright From thomas at xs4all.net Wed Feb 14 16:35:59 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 14 Feb 2001 16:35:59 +0100 Subject: How do I use a pyc file created with an older version of Python? In-Reply-To: ; from paul.moore@uk.origin-it.com on Mon, Feb 12, 2001 at 06:03:55PM +0100 References: Message-ID: <20010214163559.I4924@xs4all.nl> On Mon, Feb 12, 2001 at 06:03:55PM +0100, Paul Moore wrote: > This is probably a silly question, but I have an old pyc file > generated under Python 1.5.? (I think), and I now use Python 2.0. I > don't have the source easily accessible, unortunately, and I don't > really want to install Python 1.5 as well, just for this one bit of > code. You'll have to do one of the latter two, unfortunately. > Is it possible to convert a pyc from an older version of Python to a > newer one, without the source? It seems like it should be possible, as > a pyc is (I believe) just a magic number plus a marshalled code > object. Assuming the code itself is compatible, could I just "fix" the > magic number? Or would I need to "upgrade" the marshalled code > somehow? Or is this not possible, and I just have to get the source > back...? A .pyc file is indeed 'just' a magic number and a marshalled code object. However, the magic number is there for a reason: the actual bytecode contained in the marshalled object *changed meaning*. For instance, in the 1.5.2 -> 2.0 change, the 'IMPORT_FROM' bytecode was split into 'IMPORT_FROM' and 'IMPORT_STAR'. 'IMPORT_FROM' no longer handles the special case of the "*" name, and if you try to run Python 1.5 (or older) bytecode that uses 'IMPORT_FROM' with a name of "*", you'll probably get a system error. Or worse, it doesn't raise an error, but it doesn't import any of the desired names either :) There are more problems, though (before you think you're safe because the code doesn't do 'from foo import *' :) between 1.5 and 2.0, the UNPACK_TUPLE, UNPACK_LIST, UNPACK_ARG and UNPACK_VARARG opcodes were merged into a single UNPACK_SEQUENCE opcode. UNPACK_TUPLE will still work, since it has the same number and functionality as the 'new' UNPACK_SEQUENCE opcode, but the other ones will raise a system error. Except for UNPACK_VARARG, which is now DUP_TOPX, and would cause a lot of confusion :-) Several other opcodes were removed as well. So, bottom line, you're out of luck. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From scarpenter at innerx.net Mon Feb 12 18:26:45 2001 From: scarpenter at innerx.net (scarpenter at innerx.net) Date: Mon, 12 Feb 2001 12:26:45 -0500 Subject: New Online Auction Site for Brand Name Tools, Hardware, Home Improvement Products Message-ID: An HTML attachment was scrubbed... URL: From tjg at exceptionalminds.com Mon Feb 12 19:03:37 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Mon, 12 Feb 2001 10:03:37 -0800 Subject: I don't think I understand popen2() behaviour Message-ID: <20010212100337.Y17173@trufflehunter.avalongroup.net> Hi, I need some enlightenment. For the first time ever, I'm playing with pipes in python and I must be missing something. I'll paste in a couple of examples to see if I can explain myself. >>> import os >>> x = os.popen('tail -f /var/log/messages') >>> tail: /var/log/messages: Permission denied tail: no files remaining >>> OK, so I'd expect that behaviour, as I'm logged in as me, not root. Now, my understanding of popen2() is that it gives me a file handle to both stdin and stderr, so since I don't want those error messages popping up on the screen I tried the following >>> import popen2 >>> x,y = popen2.popen2('tail -f /var/log/messages') >>> tail: /var/log/messages: Permission denied tail: no files remaining >>> Now that was unexpected, as I would have thought that the error messages should have been hidden away in my file object y, and that I wouldn't see them until I did a y.readlines() or something. However, when I try to access y, I get the following: >>> y.readlines() Traceback (innermost last): File "", line 1, in ? IOError: [Errno 9] Bad file descriptor >>> So, obviously I don't understand something, but I'm not even sure what it is I don't understand yet! Thanks for your assistance. -- 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: 26 days 22:08 hours ago<< From bsb at winnegan.de Mon Feb 12 19:48:35 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 12 Feb 2001 19:48:35 +0100 Subject: I don't think I understand popen2() behaviour In-Reply-To: <20010212100337.Y17173@trufflehunter.avalongroup.net> References: <20010212100337.Y17173@trufflehunter.avalongroup.net> Message-ID: <87wvavd9fg.fsf@winnegan.de> Timothy Grant writes: > Hi, > I need some enlightenment. For the first time ever, I'm playing with > pipes in python and I must be missing something. I'll paste in a > couple of examples to see if I can explain myself. > >>> import os > >>> x = os.popen('tail -f /var/log/messages') > >>> tail: /var/log/messages: Permission denied > tail: no files remaining > > >>> > OK, so I'd expect that behaviour, as I'm logged in as me, not root. > Now, my understanding of popen2() is that it gives me a file handle > to both stdin and stderr, so since I don't want those error messages > popping up on the screen I tried the following > >>> import popen2 > >>> x,y = popen2.popen2('tail -f /var/log/messages') > >>> tail: /var/log/messages: Permission denied > tail: no files remaining > > >>> > Now that was unexpected, as I would have thought that the error > messages should have been hidden away in my file object y, and that > I wouldn't see them until I did a y.readlines() or something. popen2 connects the command's stdin and stdout, but not to stderr. > However, when I try to access y, I get the following: > >>> y.readlines() > Traceback (innermost last): > File "", line 1, in ? > IOError: [Errno 9] Bad file descriptor > >>> >>> y shows that you are reading from a file open for output, hence the IOError. > So, obviously I don't understand something, but I'm not even sure > what it is I don't understand yet! Try the following: >>> cld = popen2.Popen3('tail -f /var/log/messages', 1) For details cf. http://www.python.org/doc/current/lib/popen3-objects.html HIH Siggy From tjg at exceptionalminds.com Mon Feb 12 20:09:48 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Mon, 12 Feb 2001 11:09:48 -0800 Subject: I don't think I understand popen2() behaviour In-Reply-To: <87wvavd9fg.fsf@winnegan.de>; from bsb@winnegan.de on Mon, Feb 12, 2001 at 07:48:35PM +0100 References: <20010212100337.Y17173@trufflehunter.avalongroup.net> <87wvavd9fg.fsf@winnegan.de> Message-ID: <20010212110947.Z17173@trufflehunter.avalongroup.net> On Mon, Feb 12, 2001 at 07:48:35PM +0100, Siggy Brentrup wrote: > > I wouldn't see them until I did a y.readlines() or something. > > popen2 connects the command's stdin and stdout, but not to stderr. > > > > So, obviously I don't understand something, but I'm not even sure > > what it is I don't understand yet! > > Try the following: > > >>> cld = popen2.Popen3('tail -f /var/log/messages', 1) > > For details cf. > http://www.python.org/doc/current/lib/popen3-objects.html > Hmm, another case of my brain interpreting what I read in light of what my brain wanted me to read. Thanks for the pointer. I'll try and pay closer attention next time. -- 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: 26 days 23:20 hours ago<< From stephen_purcell at yahoo.com Mon Feb 12 19:54:15 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Mon, 12 Feb 2001 19:54:15 +0100 Subject: I don't think I understand popen2() behaviour In-Reply-To: <20010212100337.Y17173@trufflehunter.avalongroup.net>; from tjg@exceptionalminds.com on Mon, Feb 12, 2001 at 10:03:37AM -0800 References: <20010212100337.Y17173@trufflehunter.avalongroup.net> Message-ID: <20010212195415.A3546@freedom.puma-ag.com> Timothy Grant wrote: > >>> import popen2 > >>> x,y = popen2.popen2('tail -f /var/log/messages') > >>> tail: /var/log/messages: Permission denied > tail: no files remaining > > >>> > > Now that was unexpected, as I would have thought that the error messages > should have been hidden away in my file object y, popen2 gives you (stdin, stdout) for the child process. You probably want 'popen3' instead if you want to grab stderr. -Steve -- Steve Purcell, Pythangelist http://pyunit.sourceforge.net/ http://pyserv.sourceforge.net/ Available for consulting and training. "Even snakes are afraid of snakes." -- Steven Wright From stephen_purcell at yahoo.com Mon Feb 12 19:55:48 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Mon, 12 Feb 2001 19:55:48 +0100 Subject: I don't think I understand popen2() behaviour In-Reply-To: <20010212195415.A3546@freedom.puma-ag.com>; from stephen_purcell@yahoo.com on Mon, Feb 12, 2001 at 07:54:15PM +0100 References: <20010212100337.Y17173@trufflehunter.avalongroup.net> <20010212195415.A3546@freedom.puma-ag.com> Message-ID: <20010212195548.B3546@freedom.puma-ag.com> Steve Purcell wrote: > > popen2 gives you (stdin, stdout) for the child process. Sorry, that should read (stdout, stdin). Cribbed from http://www.python.org/doc/lib/module-popen2.html -Steve From stevena at neosynapse.net Mon Feb 12 19:53:02 2001 From: stevena at neosynapse.net (Steven D. Arnold) Date: Mon, 12 Feb 2001 13:53:02 -0500 Subject: ANN: Pure-Python Encryption Tools Message-ID: <5.0.2.1.2.20010212133300.03a64ae0@phear.dementian.com> Neosynapse Consulting Group announces the release of pure-Python encryption tools. These modules may be used as building blocks for programs that need cryptographic services. The modules are released as open-source software under the Neosynapse Artistic License. So far, we have an implementation of IDEA and a module for handling modular arithmetic. Coming soon, look for modules to handle problems relating to prime numbers, a Blowfish module and an RSA public-key cryptography module. Interested people are welcomed to participate in the development of these open-source modules. The software may be downloaded at: http://www.neosynapse.net/free_encrypt.htm -- Steven D. Arnold President, Neosynapse Consulting Group stevena at neosynapse.net http://www.neosynapse.net From glennj at pcard31e.ca.nortel.com Tue Feb 13 21:36:14 2001 From: glennj at pcard31e.ca.nortel.com (Glenn W Jackman) Date: 13 Feb 2001 20:36:14 GMT Subject: ANN: Pure-Python Encryption Tools References: Message-ID: <96c5ru$s1f$1@bcarh8ab.ca.nortel.com> Steven D. Arnold wrote: >Neosynapse Consulting Group announces the release of pure-Python encryption >tools. These modules may be used as building blocks for programs that need >cryptographic services. The modules are released as open-source software >under the Neosynapse Artistic License. > >So far, we have an implementation of IDEA and a module for handling modular >arithmetic. Coming soon, look for modules to handle problems relating to >prime numbers, a Blowfish module and an RSA public-key cryptography module. > >Interested people are welcomed to participate in the development of these >open-source modules. The software may be downloaded at: > > http://www.neosynapse.net/free_encrypt.htm Is this url active? File Not Found requested URL /free_encrypt.htm was not found on this server. -- Glenn From emile at fenx.com Tue Feb 13 22:43:14 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 13 Feb 2001 13:43:14 -0800 Subject: ANN: Pure-Python Encryption Tools References: <96c5ru$s1f$1@bcarh8ab.ca.nortel.com> Message-ID: <96c9s8$kpchj$1@ID-11957.news.dfncis.de> > >Interested people are welcomed to participate in the development of these > >open-source modules. The software may be downloaded at: > > > > http://www.neosynapse.net/free_encrypt.htm > > Is this url active? > File Not Found > requested URL /free_encrypt.htm was not found on this server. > > -- > Glenn I got right through. -- Emile van Sebille emile at fenx.com ------------------- From fdrake at acm.org Mon Feb 12 19:53:08 2001 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Mon, 12 Feb 2001 13:53:08 -0500 (EST) Subject: Fwd: test_pyexpat failed (gryphon01@my-deja.com) In-Reply-To: <14983.63939.371712.913299@w221.z064000254.bwi-md.dsl.cnc.net> References: <14983.63939.371712.913299@w221.z064000254.bwi-md.dsl.cnc.net> Message-ID: <14984.12564.945348.622604@cj42289-a.reston1.va.home.com> [Jeremy Hylton forwarded this message to me.] > From: gryphon01 at my-deja.com > To: python-list at python.org > Subject: test_pyexpat failed > Date: Mon, 12 Feb 2001 04:16:39 GMT > > I an trying to build Python 2.0 with expat 1.2. The compile doesn't complain > but test_pyexpat says: test test_pyexpat failed -- Writing: > "('xml=http://www.w3.org/XML/1998/namespace\\014external_entity', None, > 'entity.file', None)", expected: > "('http://www.python.org/namespace=http://www.w3.org/XML/1998/namespace\\014e > xternal_entity'" You're not doing anything wrong; the test suite exposes some internal data that expat passes through Python to allow the .ExternalEntityParserCreate() method to pick up context information. The format of the context information can and has changed over the life of Expat, but should not be exposed to begin with. The current version of the test (in the alphas for 2.1) does not expose this implementation detail. You should be able to pick up the files Lib/test/test_pyexpat.py and Lib/test/output/test_pyexpat from the Python CVS and use them instead. I'll add an entry to the Python 2.0 FAQ. -Fred -- Fred L. Drake, Jr. PythonLabs at Digital Creations From timo at lightdog.com Wed Feb 14 14:49:23 2001 From: timo at lightdog.com (timo at lightdog.com) Date: Wed, 14 Feb 2001 08:49:23 -0500 Subject: International/Localized Python GUI apps In-Reply-To: <14984.12564.945348.622604@cj42289-a.reston1.va.home.com> References: <14983.63939.371712.913299@w221.z064000254.bwi-md.dsl.cnc.net> Message-ID: <3A8A4693.16262.33F62C@localhost> I (desparately) want to be using python for our GUI apps here, but we're currently using M$ Visual C++. I'm not very happy with it, MFC in particular. It's a horrible set of wrappers on an unhappy api. Still, we have some opportunity. I need to be able to do UIs that are easily internationalizable, and I need to do a lot of work in grids. I've looked at WxPython, but it doesn't seem to do wide characters and/or unicode. I really need multilingual support, some of those languages being asian ones. Is there a way for me to propose python and tkinter or something for this work? I really need grid controls, and i really need foreign language support. If I have these, and can make an argument for it being easier than MFC/VC++, then I have a really good chance of getting it pushed through here. Any help? Tim From boud at valdyas.org Wed Feb 14 21:33:46 2001 From: boud at valdyas.org (Boudewijn Rempt) Date: Wed, 14 Feb 2001 21:33:46 +0100 Subject: International/Localized Python GUI apps References: <14983.63939.371712.913299@w221.z064000254.bwi-md.dsl.cnc.net> Message-ID: <3a8aebcb$0$36171$1a0eedbc@dreader2.news.xs4all.nl> timo at lightdog.com wrote: > I (desparately) want to be using python for our GUI apps here, but > we're currently using M$ Visual C++. I'm not very happy with it, > MFC in particular. It's a horrible set of wrappers on an unhappy api. > > Still, we have some opportunity. I need to be able to do UIs that are > easily internationalizable, and I need to do a lot of work in grids. I've > looked at WxPython, but it doesn't seem to do wide characters > and/or unicode. I really need multilingual support, some of those > languages being asian ones. > > Is there a way for me to propose python and tkinter or something > for this work? I really need grid controls, and i really need foreign > language support. If I have these, and can make an argument for it > being easier than MFC/VC++, then I have a really good chance of > getting it pushed through here. > If you really need Asian character set support, and _good_ support, you should try PyQt. I've just released an application that uses it - you can see a screenshot at http://www.valdyas.org/linguistics/screenshots.html. If you need good BiDi, you might have to wait for version 3.0 of Qt. PyQt also offers a strong Table control, grid layouts and a good canvas. And, of course, it's very, very easy to work with. It's not free for Windows, but that should make it _easier_ to get it into a a shop using Visual C++ ;-). Boudewijn Rempt From loewis at informatik.hu-berlin.de Tue Feb 20 10:58:12 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 20 Feb 2001 10:58:12 +0100 Subject: International/Localized Python GUI apps References: <14983.63939.371712.913299@w221.z064000254.bwi-md.dsl.cnc.net> Message-ID: timo at lightdog.com writes: > Still, we have some opportunity. I need to be able to do UIs that are > easily internationalizable, and I need to do a lot of work in grids. I've > looked at WxPython, but it doesn't seem to do wide characters > and/or unicode. I really need multilingual support, some of those > languages being asian ones. For the internationalization, I recommend to use the gettext module of Python 2.0. Regards, Martin From corour01 at motorola.com Mon Feb 12 20:11:31 2001 From: corour01 at motorola.com (O'Rourke Clodagh-corour01) Date: Mon, 12 Feb 2001 19:11:31 -0000 Subject: Embedding UNIX Commands Message-ID: <13EE655665F4D311AB4D0008C789498A01EE2C3C@zei02exm02.cork.cig.mot.com> Hi All, I'm wondering could anyone advise me on what is the best way to embed unix commands such as setenv and whoami in a Python/Tkinter application. Would it be to put them into a C module or can it be done directly in python? Thanks, Clodagh O' Rourke. From dsh8290 at rit.edu Mon Feb 12 21:07:49 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 12 Feb 2001 15:07:49 -0500 Subject: Embedding UNIX Commands In-Reply-To: <13EE655665F4D311AB4D0008C789498A01EE2C3C@zei02exm02.cork.cig.mot.com>; from corour01@motorola.com on Mon, Feb 12, 2001 at 07:11:31PM +0000 References: <13EE655665F4D311AB4D0008C789498A01EE2C3C@zei02exm02.cork.cig.mot.com> Message-ID: <20010212150748.C5667@harmony.cs.rit.edu> You can use the system function : import os os.system( "whoami" ) I don't think you can use setenv -- that is a csh thing, and system() won't even start up a shell (AFAIK). Even if it did, it wouldn't do you any good since that shell would terminate and its environment would be meaningless. (Also, on Linux systems bash is the default shell) It would probably be better if you described what you want to accomplish with these commands and then people can come up with a different way that wouldn't rely on the underlying system (and PATH). If you simply want to change the environment of your python process you can : import sys sys.env[ "VAR" ] = "value" (also possibly the sys.setenv() function, try dir( sys ) , and print sys.setenv.__doc__ ) HTH, -D On Mon, Feb 12, 2001 at 07:11:31PM +0000, O'Rourke Clodagh-corour01 wrote: | Hi All, | I'm wondering could anyone advise me on what is the best way to embed unix commands such as setenv and whoami in a Python/Tkinter application. Would it be to put them into a C module or can it be done directly in python? | | Thanks, | Clodagh O' Rourke. | From kalle at gnupung.net Tue Feb 13 01:42:58 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Tue, 13 Feb 2001 01:42:58 +0100 Subject: Embedding UNIX Commands In-Reply-To: <20010212150748.C5667@harmony.cs.rit.edu>; from dsh8290@rit.edu on Mon, Feb 12, 2001 at 03:07:49PM -0500 References: <13EE655665F4D311AB4D0008C789498A01EE2C3C@zei02exm02.cork.cig.mot.com> <20010212150748.C5667@harmony.cs.rit.edu> Message-ID: <20010213014258.A17495@apone.network.loc> Sez D-Man: > If you simply want to change the environment of your python process > you can : > > import sys > sys.env[ "VAR" ] = "value" > > > (also possibly the sys.setenv() function, try dir( sys ) , and print > sys.setenv.__doc__ ) That should be import os os.environ["VAR"] = "value" os.putenv() dir(os) and print os.putenv.__doc__ I believe. At least with Python 2.x. Check http://www.python.org/doc/current/lib/os-procinfo.html for more info. Otherwise, I agree with the previous speaker... 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 erno-news at erno.iki.fi Tue Feb 13 01:33:45 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 13 Feb 2001 02:33:45 +0200 Subject: Embedding UNIX Commands References: <13EE655665F4D311AB4D0008C789498A01EE2C3C@zei02exm02.cork.cig.mot.com> Message-ID: In article , D-Man writes: | I don't think you can use setenv -- that is a csh thing, and system() | won't even start up a shell (AFAIK). Even if it did, it wouldn't do | you any good since that shell would terminate and its environment | would be meaningless. (Also, on Linux systems bash is the default | shell) actually, system() (and popen()) pass the command line to /bin/sh under unix. | It would probably be better if you described what you want to | accomplish with these commands and then people can come up with a | different way that wouldn't rely on the underlying system (and PATH). | If you simply want to change the environment of your python process | you can : | import sys | sys.env[ "VAR" ] = "value" | (also possibly the sys.setenv() function, try dir( sys ) , and print | sys.setenv.__doc__ ) those should be os.environ and os.putenv instead of sys.env and sys.setenv. -- erno From bill at libc.org Mon Feb 12 21:00:55 2001 From: bill at libc.org (Bill Anderson) Date: Tue, 13 Feb 2001 03:00:55 +0700 Subject: Embedding UNIX Commands References: <13EE655665F4D311AB4D0008C789498A01EE2C3C@zei02exm02.cork.cig.mot.com> Message-ID: In article , "Erno Kuusela" wrote: > In article , D-Man > writes: > > | I don't think you can use setenv -- that is a csh thing, and system() > | won't even start up a shell (AFAIK). Even if it did, it wouldn't do > | you any good since that shell would terminate and its environment > | would be meaningless. (Also, on Linux systems bash is the default > | shell) > > actually, system() (and popen()) pass the command line to /bin/sh under > unix. Which _is_ bash (on most Linux Dists): ucntcme at locutus in /home/ucntcme $ ll /bin/sh lrwxrwxrwx 1 root root 4 Jan 13 19:58 /bin/sh -> bash* From chris at voodooland.net Wed Feb 14 01:28:17 2001 From: chris at voodooland.net (Chris Watson) Date: Tue, 13 Feb 2001 18:28:17 -0600 (CST) Subject: Embedding UNIX Commands In-Reply-To: Message-ID: > Which _is_ bash (on most Linux Dists): > ucntcme at locutus in /home/ucntcme > $ ll /bin/sh lrwxrwxrwx 1 root root 4 Jan 13 19:58 /bin/sh -> bash* Non portable. Non standard. Big surprise. Please dont inject code out their that uses bash when you really mean to use sh. It wont work on other unix without bash. -- ============================================================================= -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?" ============================================================================= GNU = Gnu's Non-portable & Unstable irc.openprojects.net #FreeBSD -Join the revolution! ICQ: 20016186 From csrabak at uol.com.br Tue Feb 13 01:56:07 2001 From: csrabak at uol.com.br (Cesar Rabak) Date: Mon, 12 Feb 2001 21:56:07 -0300 Subject: Embedding UNIX Commands References: <13EE655665F4D311AB4D0008C789498A01EE2C3C@zei02exm02.cork.cig.mot.com> Message-ID: <3A888627.4EB23450@uol.com.br> D-Man wrote: > > You can use the system function : > > import os > os.system( "whoami" ) > > I don't think you can use setenv -- that is a csh thing, and system() > won't even start up a shell (AFAIK). Even if it did, it wouldn't do > you any good since that shell would terminate and its environment > would be meaningless. (Also, on Linux systems bash is the default > shell) setenv is also a non standard (albeit very commonplace) function which is available in several C libraries. Perhaps Python can call it if it was compiled with a library that has it? From bpederson at geocities.com Mon Feb 12 21:17:27 2001 From: bpederson at geocities.com (Barry Pederson) Date: Mon, 12 Feb 2001 14:17:27 -0600 Subject: QuakeWorld Python 1.0 Message-ID: <3A8844D7.1CE2CC58@geocities.com> QWPython (http://qwpython.sourceforge.net) is a Python-powered QuakeWorld dedicated server. The core engine has been wrapped up as a Python module and altered to call back to Python to execute Quake game logic. A QuakeC -> Python translator is also included, along with pre-translated versions of Deathmatch and Capture the Flag. Version 1.0 includes sourcecode which builds and runs on both Windows and Unix platforms, and Win32 binaries. Barry From chris.gonnerman at usa.net Tue Feb 13 03:18:03 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Mon, 12 Feb 2001 20:18:03 -0600 Subject: QuakeWorld Python 1.0 References: <3A8844D7.1CE2CC58@geocities.com> Message-ID: <011e01c09563$837ecc80$a100000a@local> ----- Original Message ----- From: "Barry Pederson" Subject: QuakeWorld Python 1.0 > Version 1.0 includes sourcecode which builds and runs on both Windows > and Unix platforms, and Win32 binaries. Where ARE the Win32 binaries? I downloaded the Win32 package but got no binaries (no .exe or .dll files). From bpederson at geocities.com Tue Feb 13 04:50:43 2001 From: bpederson at geocities.com (Barry Pederson) Date: Mon, 12 Feb 2001 21:50:43 -0600 Subject: QuakeWorld Python 1.0 References: <3A8844D7.1CE2CC58@geocities.com> Message-ID: <3A88AF13.7B0B5275@geocities.com> Chris Gonnerman wrote: > > ----- Original Message ----- > From: "Barry Pederson" > Subject: QuakeWorld Python 1.0 > > Version 1.0 includes sourcecode which builds and runs on both Windows > > and Unix platforms, and Win32 binaries. > > Where ARE the Win32 binaries? I downloaded the Win32 package but got no > binaries > (no .exe or .dll files). Under Windows, Python uses .pyd instead of .dll for native-code extensions. In the QWPython Win32 distribution, qwpython\qwsv.pyd is what you're looking for. To actually run a game, you run the ctf.py or deathmatch.py scripts, which take care of loading the native-code module, along with the pythonized game code (which should be covered in the README.html file) Barry From jepler at inetnebr.com Tue Feb 13 14:50:43 2001 From: jepler at inetnebr.com (Jeff Epler) Date: Tue, 13 Feb 2001 13:50:43 GMT Subject: QuakeWorld Python 1.0 References: <3A8844D7.1CE2CC58@geocities.com> Message-ID: On Mon, 12 Feb 2001 14:17:27 -0600, Barry Pederson wrote: >QWPython (http://qwpython.sourceforge.net) is a Python-powered >QuakeWorld dedicated server. This is very cool. I've been wishing that something like this would happen for quite awhile. (In fact, I tried my hand at a pure-Python Quake server once, long before the source was available---Like most of my big projects seem to do, it ultimately went nowhere) Jeff From shredwheat at mediaone.net Wed Feb 14 07:11:50 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Wed, 14 Feb 2001 06:11:50 GMT Subject: QuakeWorld Python 1.0 References: <3A8844D7.1CE2CC58@geocities.com> Message-ID: > This is very cool. I've been wishing that something like this would happen > for quite awhile. (In fact, I tried my hand at a pure-Python Quake server > once, long before the source was available---Like most of my big projects > seem to do, it ultimately went nowhere) this is neat, i spent some time looking at it this afternoon. the origin worlds online game in development is using a very similar approach. the server is using python for all the game logic From hamish_lawson at yahoo.co.uk Mon Feb 12 21:18:00 2001 From: hamish_lawson at yahoo.co.uk (=?iso-8859-1?q?Hamish=20Lawson?=) Date: Mon, 12 Feb 2001 20:18:00 +0000 (GMT) Subject: Help: non-capturing group RE fails Message-ID: <20010212201800.11411.qmail@web215.mail.yahoo.com> Robin Thomas wrote: > (?:[^@]) is not a "group" that can be referenced. It is an > "assertion", or "lookahead assertion", that is part of the match but > does not get a group I don't mean to pick holes in Robin's explanation, but I believe the terminology used above isn't quite correct regarding assertions. I point this out just so that Roy doesn't get confused when reading reference material on REs - the concepts can be tricky enough! Robin is correct in saying that (?:) can't be referenced since it's not memorised; it's what's called a non-capturing group. However it does consume the string, in that it causes the RE engine's 'pointer' to be advanced through the string, and hence by definition isn't an assertion. An assertion specifies a condition that must be fulfilled, but doesn't causing the string to be consumed (i.e. doesn't advance the pointer). (But to be fair to Robin, he makes the difference between consuming and capturing clearer in another post.) The term 'capturing' relates to whether the content is memorised for later reference (whether by index or by name); 'consuming' to whether it causes the pointer to be advanced. Consider the code below. r = re.compile("a(?:bd)+(?=c)(..)") s = "HKabdbdGKMDabdbdbdcWFGT" m = r.search(s) print m.group(1) This prints out 'cW'. I want the '+' to apply to the pair 'bd' rather than just 'd', but since I don't care about referring to the 'bd' pairs that are matched, I use a non-capturing group '(?:bd)' rather than a capturing group (bd); this means that the later '(..)' group in the pattern will be the first referrable group. The '(?=c)' in the pattern is a look-ahead assertion that specifies that the 'bd' pairs must be followed by 'c'. But because it is an assertion, it doesn't cause the string to be consumed. Hence the 'c' is still available to be consumed by the '(..)' expression. 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 andreas.dietrich at news.online.de Mon Feb 12 21:27:10 2001 From: andreas.dietrich at news.online.de (Andreas Dietrich) Date: Mon, 12 Feb 2001 21:27:10 +0100 Subject: How do I modify my callers local variables? Message-ID: Hallo, Pythoneers! I tried to simplify keyword parsing and wrote the following routine: def parse_keywords(defaults,kw): import sys try: raise None except: frame = sys.exc_info()[2].tb_frame.f_back locals_dict=frame.f_locals for i in defaults.keys(): try: locals_dict[i]=kw[i] except KeyError: try: locals_dict[i]=defaults[i] except KeyError: #We should not be here print 'Moo. Moo' return def test(**kw): parse_keywords({'a':1,'b':2,'c':3},kw) #didn't work print a,b,c test() Unfortunately it doesn't work. Is there a way to do it? I'm tired of the repetitious code involved in keyword parsing. I'd really appreciate any insights into this matter. Thank you. Andreas -- "We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare. Now, thanks to the Internet, we know this is not true." -- Robert Wilensky From jeremy at alum.mit.edu Mon Feb 12 23:05:41 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Mon, 12 Feb 2001 17:05:41 -0500 (EST) Subject: How do I modify my callers local variables? In-Reply-To: References: Message-ID: <14984.24117.294067.705291@w221.z064000254.bwi-md.dsl.cnc.net> >>>>> "AD" == Andreas Dietrich writes: AD> def parse_keywords(defaults,kw): AD> import sys try: AD> raise None AD> except: AD> frame = sys.exc_info()[2].tb_frame.f_back AD> locals_dict=frame.f_locals AD> for i in defaults.keys(): AD> try: AD> locals_dict[i]=kw[i] AD> except KeyError: AD> try: AD> locals_dict[i]=defaults[i] AD> except KeyError: AD> #We should not be here AD> print 'Moo. Moo' AD> return AD> def test(**kw): AD> parse_keywords({'a':1,'b':2,'c':3},kw) AD> #didn't work AD> print a,b,c AD> test() AD> Unfortunately it doesn't work. Is there a way to do it? I'm AD> tired of the repetitious code involved in keyword parsing. There is no way to do it. If there were, it would be tempting to disable it <0.5 wink>. AD> I'd really appreciate any insights into this matter. When test() is compiled, the compiler determines that a, b, and c are all global variables. The body of test() does not contains assignments or other name binding operations. If you want to have default arguments for local variables, I suggest using ... default arguments! def test(a=1, b=2, c=3): print a, b, c Jeremy From andreas.dietrich at news.online.de Mon Feb 12 23:48:08 2001 From: andreas.dietrich at news.online.de (Andreas Dietrich) Date: Mon, 12 Feb 2001 23:48:08 +0100 Subject: How do I modify my callers local variables? References: Message-ID: <87p969.t89.ln@news.onlinehome.de> On Mon, 12 Feb 2001 21:27:10 +0100, I wrote: >def test(**kw): > parse_keywords({'a':1,'b':2,'c':3},kw) > #didn't work > print a,b,c > >test() I?hate to post a followup to my own posting, but I forgot to point out the _real_ problem. It doesn't work even if I replace test() with def test(**kw): a=b=c=0 parse_keywords({'a':1,'b':2,'c':3},kw) #didn't work print a,b,c I'm aware of the fact that python considers variables as global that are not assigned to (Could I modify _that_ from parse_keywords ? If not, this not a showstopper. ) Andreas -- "We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare. Now, thanks to the Internet, we know this is not true." -- Robert Wilensky From tjreedy at udel.edu Tue Feb 13 03:57:50 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 12 Feb 2001 21:57:50 -0500 Subject: How do I modify my callers local variables? References: Message-ID: <96a7jt$6no$1@news.udel.edu> > def parse_keywords(defaults,kw): > import sys > try: > raise None > except: > frame = sys.exc_info()[2].tb_frame.f_back > locals_dict=frame.f_locals This only gives you a PyDict copy of the function locals, which happen to be internally implemented as an indexed C array. > for i in defaults.keys(): > try: > locals_dict[i]=kw[i] > except KeyError: > try: > locals_dict[i]=defaults[i] Modifying your PyDict copy has no effect on the internal C array that the function actually uses. Thus this assignment in useless in terms of what you hope to accomplish. > ... > I'd really appreciate any insights into this matter. I hope this helps. Terry J. Reedy From sandj.williams at gte.net Mon Feb 12 21:42:16 2001 From: sandj.williams at gte.net (Steve Williams) Date: Mon, 12 Feb 2001 20:42:16 GMT Subject: Google buys Deja Message-ID: <3A884C33.B253C411@gte.net> http://www.theregister.co.uk/content/6/16836.html From bs1535 at sbc.com Mon Feb 12 22:17:05 2001 From: bs1535 at sbc.com (SNYDER, BARRON F. (AIT)) Date: Mon, 12 Feb 2001 16:17:05 -0500 Subject: Can a Tkinter Scrollbar scroll 2 widgets at the same time? Message-ID: <35BD410BA148D411A7ED00508BCFFBDA05CB2824@msgil65170u05.nbk2305.il.ameritech.com> Since Tkinter doesn't have a table widget, I'm using a ScrolledListBox and a ScrolledFrame (to hold the column headings as Buttons). I would like the scrollbar from the ScrolledListBox to scroll both ScrolledListBox and ScrolledFrame at the same time. Is this possible? If not, can a separate Scrollbar scroll more than one widget (can I scroll, say, 2 listboxes with one scrollbar?)? Thanks, Barron From sholden at holdenweb.com Mon Feb 12 22:49:46 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 12 Feb 2001 16:49:46 -0500 Subject: Can a Tkinter Scrollbar scroll 2 widgets at the same time? References: Message-ID: "SNYDER, BARRON F. (AIT)" wrote in message news:mailman.982012694.3832.python-list at python.org... > > Since Tkinter doesn't have a table widget, I'm using a ScrolledListBox and a > ScrolledFrame (to hold the column headings as Buttons). I would like the > scrollbar from the ScrolledListBox to scroll both ScrolledListBox and > ScrolledFrame at the same time. Is this possible? > > If not, can a separate Scrollbar scroll more than one widget (can I scroll, > say, 2 listboxes with one scrollbar?)? > > Thanks, > Barron > Traditionally you do this by registering the set() method of the scroll bar as the yscrollcommand of each of the listboxes, and registering a callback for the scroll bar which adjusts the positions of each listbox. Here's an extract from the __init__() method of a mail searchwindow, which shows you how this works in practice: self.msgScrollBar.config(command=self.scrollMsg) self.msgDateList = Listbox(self.msgFrame, borderwidth=1, bg='white', yscrollcommand=self.msgScrollBar.set, exportselection=0) self.msgDateList.bind("", self.showMessage) self.msgSenderList = Listbox(self.msgFrame, borderwidth=1, bg='white', yscrollcommand=self.msgScrollBar.set, exportselection=0) self.msgSubjectList = Listbox(self.msgFrame, borderwidth=1, bg='white', yscrollcommand=self.msgScrollBar.set, exportselection=0) And here's the code of the scrollMsg callback from msgScrollBar events: def scrollMsg(self, *args): apply(self.msgDateList.yview, args) apply(self.msgSenderList.yview, args) apply(self.msgSubjectList.yview, args) This does have limitations, though, since any changes to the scrolling lists made by keyboard aren't reflected in the others. regards Steve PS: Can anyone explain how I might implement a columnar scrolling list, allowing different text elements to align vertically inside each row of a scrolling list -- without using a fixed-pitch font? This would solve an interface problem for me. From ken at lt.com Mon Feb 12 22:50:35 2001 From: ken at lt.com (Kenneth Loafman) Date: Mon, 12 Feb 2001 15:50:35 -0600 Subject: How do I change a process name or even a thread name in python! References: <3a884bc2@si-nic.hrz.uni-siegen.de> Message-ID: <3A885AAB.863BC0B8@lt.com> C manages because the executable is the same as the program. A script is different. The interpreter name (python, sh, bash, etc.) will appear as the name if you run it like '$ python foo.py'. Same applies to '$ sh script'. Try putting a '#! /usr/bin/python' as the first line, then running it as '$ ./foo.py'. Under Linux/UNIX, that picks up the right name and arguments for ps aux. If you have to run it as 'python foo.py ...', I have no idea. ...Ken Fionn Behrens wrote: > > I am sick of seeing 10x"python" in top, without being able to say which is > which. > > I mean the name of the process as it appears in "ps" or "top". Obviously, > changing argv[0] like in C does not do the trick (which would not be of > much use for distinguishable threads anyway) > > Any suggestions? > > Regards, > Fionn > -- > http://mail.python.org/mailman/listinfo/python-list From kalle at gnupung.net Tue Feb 13 00:02:20 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Tue, 13 Feb 2001 00:02:20 +0100 Subject: How do I change a process name or even a thread name in python! In-Reply-To: <3A885AAB.863BC0B8@lt.com>; from ken@lt.com on Mon, Feb 12, 2001 at 03:50:35PM -0600 References: <3a884bc2@si-nic.hrz.uni-siegen.de> <3A885AAB.863BC0B8@lt.com> Message-ID: <20010213000220.A13868@apone.network.loc> [reformatted included text] Sez Kenneth Loafman: > Fionn Behrens wrote: > > > > I am sick of seeing 10x"python" in top, without being able to say which is > > which. > > Try putting a '#! /usr/bin/python' as the first line, then running it as > '$ ./foo.py'. Under Linux/UNIX, that picks up the right name and > arguments for ps aux. As long as the magic line isn't #!/usr/bin/env python 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 donn at u.washington.edu Tue Feb 13 01:37:39 2001 From: donn at u.washington.edu (Donn Cave) Date: 13 Feb 2001 00:37:39 GMT Subject: How do I change a process name or even a thread name in python! References: <3a884bc2@si-nic.hrz.uni-siegen.de> Message-ID: <969vkj$sak$1@nntp6.u.washington.edu> Quoth Kenneth Loafman : | C manages because the executable is the same as the program. A script | is different. The interpreter name (python, sh, bash, etc.) will appear | as the name if you run it like '$ python foo.py'. Same applies to '$ sh | script'. | | Try putting a '#! /usr/bin/python' as the first line, then running it as | '$ ./foo.py'. Under Linux/UNIX, that picks up the right name and | arguments for ps aux. It does? I don't think so! $ ./iam & [1] 28372 $ ps wwaux | fgrep iam donn 28372 0.8 0.4 2768 1140 pts/1 S 16:31 0:00 /usr/local/bin/python ./iam Donn Cave, donn at u.washington.edu From erno-news at erno.iki.fi Tue Feb 13 04:49:10 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 13 Feb 2001 05:49:10 +0200 Subject: How do I change a process name or even a thread name in python! References: <3a884bc2@si-nic.hrz.uni-siegen.de> <969vkj$sak$1@nntp6.u.washington.edu> Message-ID: In article <969vkj$sak$1 at nntp6.u.washington.edu>, Donn Cave writes: | Quoth Kenneth Loafman : || Try putting a '#! /usr/bin/python' as the first line, then running it as || '$ ./foo.py'. Under Linux/UNIX, that picks up the right name and || arguments for ps aux. | It does? I don't think so! | $ ./iam & | [1] 28372 | $ ps wwaux | fgrep iam | donn 28372 0.8 0.4 2768 1140 pts/1 S 16:31 0:00 /usr/local/bin/python ./iam clearly, python needs setproctitle() in the posix module. -- erno From phd at phd.pp.ru Tue Feb 13 10:32:50 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 13 Feb 2001 12:32:50 +0300 (MSK) Subject: How do I change a process name or even a thread name in python! In-Reply-To: Message-ID: On 13 Feb 2001, Erno Kuusela wrote: > clearly, python needs setproctitle() in the posix module. For a long long while I longing to write one, but always short on time! Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From sdm7g at virginia.edu Wed Feb 14 01:16:53 2001 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Tue, 13 Feb 2001 19:16:53 -0500 (EST) Subject: setproctitle [was: How do I change a process name or even a thread name in python!] In-Reply-To: Message-ID: On Tue, 13 Feb 2001, Oleg Broytmann wrote: > On 13 Feb 2001, Erno Kuusela wrote: > > clearly, python needs setproctitle() in the posix module. > > For a long long while I longing to write one, but always short on time! > Because of the posix_1str wrapper in posixmodule, it ought to be pretty trivial ... something like: - #ifdef HAVE_SETPROCTITLE - - static char posix_setproctitle__doc__[] = - "setproctitle(path) -> None\n\ - Set the process title."; - - static PyObject * - posix_setproctitle(PyObject *self, PyObject *args) - { - return posix_1str(args, "s:setproctitle", setproctitle); - } - - #endif HAVE_SETPROCTITLE I was about to try this, but I discovered that althought there's a man page to setproctitle(3) in macosx/darwin, they inadvertently left that function out of the public beta. ( Well -- more precisely, I'm told the code is there, but it's not in the library. ) The actual args to (C) setproctitle is a format string and optional args, but it makes more sense to do any string formatting in Python, and just pass that string. A nicer implementation would allow no arg to reset to the default proctitle. -- Steve Majewski From donn at u.washington.edu Wed Feb 14 02:00:10 2001 From: donn at u.washington.edu (Donn Cave) Date: 14 Feb 2001 01:00:10 GMT Subject: setproctitle [was: How do I change a process name or even a thread name in python!] References: Message-ID: <96claq$gro$1@nntp6.u.washington.edu> Quoth "Steven D. Majewski" : | On Tue, 13 Feb 2001, Oleg Broytmann wrote: |> On 13 Feb 2001, Erno Kuusela wrote: |>> clearly, python needs setproctitle() in the posix module. |> |> For a long long while I longing to write one, but always short on time! | Because of the posix_1str wrapper in posixmodule, it ought to be pretty | trivial ... something like: | | - #ifdef HAVE_SETPROCTITLE | - | - static char posix_setproctitle__doc__[] = | - "setproctitle(path) -> None\n\ | - Set the process title."; | - | - static PyObject * | - posix_setproctitle(PyObject *self, PyObject *args) | - { | - return posix_1str(args, "s:setproctitle", setproctitle); | - } | - | - #endif HAVE_SETPROCTITLE | | | I was about to try this, but I discovered that althought there's | a man page to setproctitle(3) in macosx/darwin, they inadvertently | left that function out of the public beta. ( Well -- more precisely, | I'm told the code is there, but it's not in the library. ) | | The actual args to (C) setproctitle is a format string and optional | args, but it makes more sense to do any string formatting in Python, | and just pass that string. | | A nicer implementation would allow no arg to reset to the default | proctitle. It looks to me like the only platforms that have setproctitle() at this point are NetBSD, FreeBSD, OpenBSD and BSDI. Most of the rest of the UNIX world does have some way to overwrite the command line as seen from "ps", but not all very pretty. Donn Cave, donn at u.washington.edu From sdm7g at virginia.edu Wed Feb 14 04:15:42 2001 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Tue, 13 Feb 2001 22:15:42 -0500 (EST) Subject: setproctitle [was: How do I change a process name or even a thread name in python!] In-Reply-To: <96claq$gro$1@nntp6.u.washington.edu> Message-ID: On 14 Feb 2001, Donn Cave wrote: > > It looks to me like the only platforms that have setproctitle() > at this point are NetBSD, FreeBSD, OpenBSD and BSDI. Most of the > rest of the UNIX world does have some way to overwrite the command > line as seen from "ps", but not all very pretty. > Maybe there's a evil curse on the function, Donn. The man page for it on macosx seems to die in midsentence, as if the author was struck dead for trying to tell us it's bizarre history. SEE ALSO ps(1), w(1), printf(3) HISTORY The setproctitle() function first appeared in BSD Experimental April 13, 1994 1 In fact, not dissimilar from how the Python Underground has been known to From jepler at inetnebr.com Wed Feb 14 15:14:30 2001 From: jepler at inetnebr.com (Jeff Epler) Date: Wed, 14 Feb 2001 14:14:30 GMT Subject: setproctitle [was: How do I change a process name or even a thread name in python!] References: Message-ID: On Tue, 13 Feb 2001 19:16:53 -0500 (EST), Steven D. Majewski wrote: >The actual args to (C) setproctitle is a format string and optional >args, but it makes more sense to do any string formatting in Python, >and just pass that string. Actually, this is unsafe, and has been the cause of a number of bugs recently exposed on Bugtraq. Imagine that you are writing an ftp server which uses 'setproctitle' to change its process name to give information including the e-mail address an anonymous user gave when he logged in. The user might pass a string like "%x%x%x%x", which will be treated as printf-style specifiers by setproctitle. So, rather than setproctitle(new_title); you must setproctitle("%s", new_title); to be safe. See bugtraq or search for "setproctitle format vulnerability" for more details on this potential security risk. One URL: http://www.hert.org/papers/format.html Unfortunately, that means the convenience function in the posix module can't be used. Jeff jepler at inetnebr.com From phd at phd.pp.ru Wed Feb 14 10:20:47 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 14 Feb 2001 12:20:47 +0300 (MSK) Subject: setproctitle [was: How do I change a process name or even a thread name in python!] In-Reply-To: Message-ID: On Tue, 13 Feb 2001, Steven D. Majewski wrote: > - return posix_1str(args, "s:setproctitle", setproctitle); setproctitle is available in libc only in *BSD. Other unicies require different tricks. Have you ever looked at sendmail source code? You'll find there many surprises. The problem is their license. May be I'll steal the code from Postgres (which has similar, but different implementation, covered under BSD license). Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From chris.gonnerman at usa.net Wed Feb 14 14:49:49 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Wed, 14 Feb 2001 07:49:49 -0600 Subject: setproctitle [was: How do I change a process name or even athread name in python!] References: Message-ID: <000201c096d7$a8d76f80$a100000a@local> ----- Original Message ----- From: "Oleg Broytmann" Subject: Re: setproctitle [was: How do I change a process name or even athread name in python!] > setproctitle is available in libc only in *BSD. Other unicies require > different tricks. Have you ever looked at sendmail source code? You'll find > there many surprises. The problem is their license. > May be I'll steal the code from Postgres (which has similar, but > different implementation, covered under BSD license). I looked at several implementations of setproctitle... they all seem to need to be initialized at program startup with the argc, argv and envp values from the call to main(). I'm not sure how to do this in a module for Python without changing the main interpreter (but I haven't looked at the interpreter source yet...) From ken at lt.com Tue Feb 13 14:48:58 2001 From: ken at lt.com (Kenneth Loafman) Date: Tue, 13 Feb 2001 07:48:58 -0600 Subject: How do I change a process name or even a thread name in python! References: <3a884bc2@si-nic.hrz.uni-siegen.de> <969vkj$sak$1@nntp6.u.washington.edu> Message-ID: <3A893B4A.9ECCB53C@lt.com> Donn Cave wrote: > > Quoth Kenneth Loafman : > | C manages because the executable is the same as the program. A script > | is different. The interpreter name (python, sh, bash, etc.) will appear > | as the name if you run it like '$ python foo.py'. Same applies to '$ sh > | script'. > | > | Try putting a '#! /usr/bin/python' as the first line, then running it as > | '$ ./foo.py'. Under Linux/UNIX, that picks up the right name and > | arguments for ps aux. > > It does? I don't think so! > > $ ./iam & > [1] 28372 > $ ps wwaux | fgrep iam > donn 28372 0.8 0.4 2768 1140 pts/1 S 16:31 0:00 /usr/local/bin/python ./iam You're right. My top shows it as foo.py, but ps does not. I may have been confusing the behavior with Solaris. Its been a while since I touched a Sun box though. ...Ken From danw at rtp.ericsson.se Mon Feb 12 23:10:44 2001 From: danw at rtp.ericsson.se (Daniel Wickstrom) Date: 12 Feb 2001 17:10:44 -0500 Subject: Calling static methods in Jython Message-ID: <5cn1brbli3.fsf@rtp.ericsson.se> I've already posted this on the jython-users list, but I haven't received a response. I want to use Jython with some existing java classes that contain static methods. How does one call java static methods from Jython? -Dan From rgruet at intraware.com Mon Feb 12 23:25:59 2001 From: rgruet at intraware.com (Richard Gruet) Date: Mon, 12 Feb 2001 22:25:59 GMT Subject: Calling static methods in Jython References: <5cn1brbli3.fsf@rtp.ericsson.se> Message-ID: <3A8862F6.6CC23EE7@intraware.com> If the Java class is C and the static method M, simply do from Python: C.M(args...) Daniel Wickstrom wrote: > I've already posted this on the jython-users list, but I haven't > received a response. > > I want to use Jython with some existing java classes that contain > static methods. How does one call java static methods from Jython? > > -Dan -------------- next part -------------- A non-text attachment was scrubbed... Name: rgruet.vcf Type: text/x-vcard Size: 370 bytes Desc: Card for Richard Gruet URL: From stephen_purcell at yahoo.com Tue Feb 13 09:54:12 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 13 Feb 2001 09:54:12 +0100 Subject: Calling static methods in Jython In-Reply-To: <5cn1brbli3.fsf@rtp.ericsson.se>; from danw@rtp.ericsson.se on Mon, Feb 12, 2001 at 05:10:44PM -0500 References: <5cn1brbli3.fsf@rtp.ericsson.se> Message-ID: <20010213095412.E5558@freedom.puma-ag.com> Daniel Wickstrom wrote: > > I've already posted this on the jython-users list, but I haven't > received a response. > > I want to use Jython with some existing java classes that contain > static methods. How does one call java static methods from Jython? Just as you would do it in Java: Jython 2.0 on java1.2.2 (JIT: javacomp) Type "copyright", "credits" or "license" for more information. >>> import java.text.DateFormat >>> df = java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM) >>> df java.text.SimpleDateFormat at ce9bf0a5 -Steve -- Steve Purcell, Pythangelist http://pyunit.sourceforge.net/ http://pyserv.sourceforge.net/ Available for consulting and training. "Even snakes are afraid of snakes." -- Steven Wright From rgruet at intraware.com Mon Feb 12 23:13:43 2001 From: rgruet at intraware.com (Richard Gruet) Date: Mon, 12 Feb 2001 22:13:43 GMT Subject: sluggish startup with 2.0 Message-ID: <3A886015.53BF722E@intraware.com> Hey Pythoners, Apologies if that question has already been raised. Startup/launch time seems far longer in Python 2.0 than it was in 1.5.2. Is it normal or is it specific to my configuration ? I use ActivePython build 202 on Windows NT 4 SP6. Thanks -------------- next part -------------- A non-text attachment was scrubbed... Name: rgruet.vcf Type: text/x-vcard Size: 370 bytes Desc: Card for Richard Gruet URL: From rgruet at intraware.com Tue Feb 13 18:07:40 2001 From: rgruet at intraware.com (Richard Gruet) Date: Tue, 13 Feb 2001 17:07:40 GMT Subject: sluggish startup with 2.0 References: <3A886015.53BF722E@intraware.com> Message-ID: <3A8969DA.2FF1D856@intraware.com> I answer to my own question. In fact, Python 2.0 sluggishness on startup was due to some misconfiguration in the Windows shell associations on my PC. Now it's fixed. Richard Gruet wrote: > Hey Pythoners, > > Apologies if that question has already been raised. > Startup/launch time seems far longer in Python 2.0 than it was in 1.5.2. > > Is it normal or is it specific to my configuration ? I use ActivePython > build 202 on Windows NT 4 SP6. > > Thanks -------------- next part -------------- A non-text attachment was scrubbed... Name: rgruet.vcf Type: text/x-vcard Size: 370 bytes Desc: Card for Richard Gruet URL: From nickb at earth.ox.ac.uk Mon Feb 12 23:56:24 2001 From: nickb at earth.ox.ac.uk (Nick Belshaw) Date: Mon, 12 Feb 2001 22:56:24 +0000 Subject: help: silent failure on socket termination? Message-ID: <3A886A17.B04EE140@earth.ox.ac.uk> I was wondering if this is a problem which can be fixed? It is very upleasant and I have not found any references to similar. I am running Python1.5.2 on Redhat 6.2 Using the ayncore/asynchat modules to support customized communications between client and server code-modules on the same or different machines I am suffering an occasional silent failure of my server module when terminating the Client during conditions when the client-server link is busy. 9 times out of 10 there is no problem and the socket connection terminates correctly but the other time the server code simply exits without any error message!!!???? No core dump, error messages or anything anywhere.....the program simply exits.... I didn't know such a thing could happen !!!!!!! I am presuming the failure is inside the socket module since the asyncore.py routines seems to log/flag all eventualities and so can not be seeing the problem. Posting code here would really be impossible - too much is going on :-( My question is therefore, are there any known problems with socket.py or am I looking at a problem specific to my configuration such as a marginal Network card or similar? Unfortunately the problem only appeared on 'upgrading' from a Redhat6.0 configuration which was running very stably for several years.....so hardware seems unlikely. any suggestions would be greatly appreciated. Nick/Oxford From amyk at foretec.com Tue Feb 13 00:43:10 2001 From: amyk at foretec.com (Amy Katherine) Date: Mon, 12 Feb 2001 18:43:10 -0500 Subject: ***Python 9 New Updates and Activities*** Message-ID: <4.2.2.20010212184223.00b5aed0@colossus.foretec.com> Greetings! The Python 9 conference agenda is now available on-line at http://www1.python9.org/p9-agenda.html. Python 9 will offer two lunchtime "Birds of a Feather" (BOF) meetings, one on Tuesday, March 6 and one on Wednesday, March 7. The topic for the Tuesday meeting is "Adding Iterators to Python", and the topic for the Wednesday meeting is "Adding Sets to Python". To sign up for one or both of these BOFs, please send an email note to: Iterator-BOF at python9.org and/or Set-BOF at python9.org. On each day, tables will be reserved for BOF participants at lunchtime, and lunch will be served promptly at 12 Noon. Following lunch, BOF participants will adjourn to a meeting room for the remainder of the lunch break. The location of the meeting room will be posted on the bulletin board in the registration area. On-line registration for Python 9 closes on Sunday, February 25, 2001. To register, please go to http://www1.python9.org/p9-reginfo.html. Rooms at the Hilton Long Beach are no longer available at the special group rate of $134 per night. However, rooms for Python 9 attendees are now available at the Holiday Inn Downtown Long Beach and the Westin Long Beach hotels at favorable rates. For more information, please go to http://www1.python9.org/p9-hotelinfo.html. ActiveState (www.ActiveState.com) is pleased to launch its first annual Programmer's Choice award for the Python programmer who's actively contributing to the community. Nominate your favorite programmer by February 20, 2001 by going to http://www.ActiveState.com/Awards. The winner will be announced at the Python 9 conference. __________________________________________________________ Sponsors: Platinum Sponsor: ActiveState (www.ActiveState.com) Gold Sponsor: Digital Creations (www.digicool.com) Silver Sponsor: O'Reilly & Associates (www.oreilly.com) Exhibitors: ActiveState (www.ActiveState.com) Digital Creations (www.digicool.com) Archaeopteryx (www.archaeopteryx.com) Perforce Software (www.perforce.com) Irvine Sci-Tech Books (www.scitechbooks.com) -------------- next part -------------- An HTML attachment was scrubbed... URL: From qiang.li at aya.yale.edu Tue Feb 13 00:43:15 2001 From: qiang.li at aya.yale.edu (qiang) Date: Mon, 12 Feb 2001 15:43:15 -0800 Subject: problem with import cephes under windowsNT Message-ID: <982021397.659463@emperor.labs.agilent.com> Hi, I am a newbie. I tried to import cephes module under windowsNT but kept getting error messages saying "ImportError: DLL load failed: The specified module could not be found." I have tried to place cephes.pyd in various paths including c:\python20\dlls and c:\python20 with no success. Perhaps someone can point out the problem? Thanks a lot! From MarkH at ActiveState.com Tue Feb 13 08:34:11 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 13 Feb 2001 07:34:11 GMT Subject: problem with import cephes under windowsNT References: <982021397.659463@emperor.labs.agilent.com> Message-ID: <3A88E292.9020103@ActiveState.com> qiang wrote: > I am a newbie. I tried to import cephes module under windowsNT but kept > getting error messages saying > "ImportError: DLL load failed: The specified module could not be found." > I have tried to place cephes.pyd in various paths including > c:\python20\dlls and c:\python20 with no success. > Perhaps someone can point out the problem? This generally means that cephes.pyd is dependent on _another_ DLL, and that DLL can't be found. If you have msvc, run "dumpbin /imports cephes.pyd | grep -i dll" and you will get a reasonable list... There are also freeware programs around that can tell you dependencies in a much nicer way, but I don't use one. Mark. From luckow at netvision.com.br Tue Feb 13 01:34:28 2001 From: luckow at netvision.com.br (Luckow) Date: Mon, 12 Feb 2001 21:34:28 -0300 Subject: Can I create HTML mails in Python,?? How?? Message-ID: <003d01c09554$f23190e0$675ed7c8@decio> At the web site that I work I only get to send mails with the follow command. os.popen("echo 'Message of the mail' | su myself -c mail 'Subject of mail' pedro at provedor.com.br") However I find an commmand that I can create email in HTML. f = os.popen ( "/usr/sbin/sendmail", "w" ) f.write ( """\ From: pedro at terra.com.br To: joao at uol.com.br Subject: some subject body os de messagem """ ) this comand allow me to create since an simple text mail until an HTML email, but this command not run in my FreeBSD (with SendMail). The browser show an I/O Error. Or some body have some source-code with this that I want. SOME BODY CAN HELP-ME please. tanks for all. D?cio H. Luckow (sorry my bad english) -------------- next part -------------- An HTML attachment was scrubbed... URL: From sandipan at vsnl.com Tue Feb 13 03:45:02 2001 From: sandipan at vsnl.com (Sandipan Gangopadhyay) Date: Tue, 13 Feb 2001 08:15:02 +0530 Subject: Can I create HTML mails in Python,?? How?? References: <003d01c09554$f23190e0$675ed7c8@decio> Message-ID: <00d601c09566$f7ad33a0$020000c3@node02> You can use smtplib or os.popen (like you have written) for sending the mail, but need to use MimeWriter or such module to build a MIME email. And put the HTML document in the MIME body appropriately. Regards, Sandipan ----- Original Message ----- From: Luckow To: python-list at python.org Sent: Tuesday, February 13, 2001 6:04 AM Subject: Can I create HTML mails in Python,?? How?? At the web site that I work I only get to send mails with the follow command. os.popen("echo 'Message of the mail' | su myself -c mail 'Subject of mail' pedro at provedor.com.br") However I find an commmand that I can create email in HTML. f = os.popen ( "/usr/sbin/sendmail", "w" ) f.write ( """\ From: pedro at terra.com.br To: joao at uol.com.br Subject: some subject body os de messagem """ ) this comand allow me to create since an simple text mail until an HTML email, but this command not run in my FreeBSD (with SendMail). The browser show an I/O Error. Or some body have some source-code with this that I want. SOME BODY CAN HELP-ME please. tanks for all. D?cio H. Luckow (sorry my bad english) -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjg at exceptionalminds.com Tue Feb 13 05:57:46 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Mon, 12 Feb 2001 20:57:46 -0800 Subject: killing a task started with popen() Message-ID: <20010212205746.A19651@trufflehunter.avalongroup.net> Hi again. I'm using the following code x = os.popen('tail -fn1 /var/log/messages') works beautifully. however, x.close() doesn't work. I understand why, but I don't know what to do about it. So, what method would be best to terminate the process I started? I guess I should just let it run until the parent exits, but that seems kind of klunky. -- 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: 27 days 9:02 hours ago<< From wcanopy at covad.net Tue Feb 13 07:51:34 2001 From: wcanopy at covad.net (Wiwih Gunadi) Date: Tue, 13 Feb 2001 00:51:34 -0600 Subject: Setting boolean COM properties Message-ID: <96ak75$ru$1@newstest.laserlink.net> Hi, Does anybody know how to set a boolean COM object property? In his book, Mark indicated two objects PyTrue and PyFalse but he didn't tell how to get these objects. Searching the internet yields dissapointing results leading me to believe that these objects are obsolete or nobody ever use'em. Pls help, -w-- From MarkH at ActiveState.com Tue Feb 13 08:37:11 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 13 Feb 2001 07:37:11 GMT Subject: Setting boolean COM properties References: <96ak75$ru$1@newstest.laserlink.net> Message-ID: <3A88E346.2080106@ActiveState.com> Wiwih Gunadi wrote: > Does anybody know how to set a boolean COM object property? > In his book, Mark indicated two objects PyTrue and PyFalse but he didn't > tell how to get these objects. > > Searching the internet yields dissapointing results leading me to believe > that these objects are obsolete or nobody ever use'em. You can just use integers 1 and 0, and they should work fine. PyTrue and PyFalse are hidden objects. You can get at them via: true = 1==1 false = 1==0 Due to a quirk in Python, these variables will then look like ints, but are really the PyTrue and PyFalse objects, as shown here: >>> true = 1==1 >>> true 1 >>> true == 1 1 >>> true is 1 0 >>> HTH, Mark. From max at alcyone.com Tue Feb 13 08:36:17 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 12 Feb 2001 23:36:17 -0800 Subject: Setting boolean COM properties References: <96ak75$ru$1@newstest.laserlink.net> <3A88E346.2080106@ActiveState.com> Message-ID: <3A88E3F1.587F70EF@alcyone.com> Mark Hammond wrote: > Due to a quirk in Python, these variables will then look like ints, > but > are really the PyTrue and PyFalse objects, as shown here: Which brings up a fairly obvious question: Especially given that there are hidden true and false objects in the Python core, how come there isn't a distinct Boolean type in Python, with values true and false? There's nothing on this in the FAQ. This is one of the few things I really wish was in Python, for cleanliness sake. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ There are no dull subjects. There are only dull writers. \__/ H.L. Mencken Alcyone Systems / http://www.alcyone.com/ Alcyone Systems, San Jose, California. From wcanopy at covad.net Wed Feb 14 01:14:46 2001 From: wcanopy at covad.net (Wiwih Gunadi) Date: Tue, 13 Feb 2001 18:14:46 -0600 Subject: Setting boolean COM properties References: <96ak75$ru$1@newstest.laserlink.net> <3A88E346.2080106@ActiveState.com> Message-ID: <96chau$54l$1@newstest.laserlink.net> I see, in that case, the problem lies with the COM object property, specifically: Word.Application.ActiveDocument.Footnotes.Item(1).Range.TextRetrievalMode.In cludeFieldCodes In the msdn documentation, this property is read-write, but no matter what I assign to it, it won't change value. Anybody has different experience with this? -Will-- "Mark Hammond" wrote in message news:3A88E346.2080106 at ActiveState.com...> Wiwih Gunadi wrote: > > > > Does anybody know how to set a boolean COM object property? > > In his book, Mark indicated two objects PyTrue and PyFalse but he didn't > > tell how to get these objects. > > > > Searching the internet yields dissapointing results leading me to believe > > that these objects are obsolete or nobody ever use'em. > > You can just use integers 1 and 0, and they should work fine. > > PyTrue and PyFalse are hidden objects. You can get at them via: > > true = 1==1 > false = 1==0 > > Due to a quirk in Python, these variables will then look like ints, but > are really the PyTrue and PyFalse objects, as shown here: > > >>> true = 1==1 > >>> true > 1 > >>> true == 1 > 1 > >>> true is 1 > 0 > >>> > > HTH, > > Mark. > From dhjung7 at orgio.net Tue Feb 13 08:52:54 2001 From: dhjung7 at orgio.net (iact21) Date: Tue, 13 Feb 2001 16:52:54 +0900 Subject: How can I use "tkFileDialog.askopenfilename()" Message-ID: <96ap4f$5qp$1@b5nntp2.channeli.net> >> import tkSimpleDialg, Tkinter >> root = Tk() >> fn = tkFileDialog,askopenfilename() error... Traceback (innermost last): File "", line 1, in ? NameError: tkFileDialog Please..help..me...!!! From b012414 at mail.dvz.fh-koeln.de Tue Feb 13 12:40:28 2001 From: b012414 at mail.dvz.fh-koeln.de (Stephan Effelsberg) Date: Tue, 13 Feb 2001 12:40:28 +0100 Subject: How can I use "tkFileDialog.askopenfilename()" References: <96ap4f$5qp$1@b5nntp2.channeli.net> Message-ID: <3A891D2B.D1E3717B@mail.dvz.fh-koeln.de> iact21 schrieb: > >> import tkSimpleDialg, Tkinter It seems that you want tkFileDialog, not tkSimpleDialog. > >> root = Tk() > >> fn = tkFileDialog,askopenfilename() Also take care of typos, dot instead of comma. > error... > Traceback (innermost last): > File "", line 1, in ? > NameError: tkFileDialog See your import line ... > Please..help..me...!!! import tkFileDialog # no own root window needed fn = tkFileDialog.askopenfilename() From Michael.Husmann at teleatlas.com Tue Feb 13 10:17:20 2001 From: Michael.Husmann at teleatlas.com (Michael Husmann) Date: Tue, 13 Feb 2001 10:17:20 +0100 Subject: How to pickle a C struct? Message-ID: <3A88FBA0.939243C5@teleatlas.com> I have SWIG(ed) a C library with lots of structs and wanted to use the shelve module to store some data on harddisk. Those data contains a simple C struct. I have read that I have to add the two functions __getstate__() and __setstate__() in addmethods for storing and retrieving. Is there someone who has done so to give me an example. Michael From djc at object-craft.com.au Wed Feb 14 02:05:28 2001 From: djc at object-craft.com.au (Dave Cole) Date: 14 Feb 2001 12:05:28 +1100 Subject: How to pickle a C struct? References: <3A88FBA0.939243C5@teleatlas.com> Message-ID: >>>>> "Michael" == Michael Husmann writes: Michael> I have SWIG(ed) a C library with lots of structs and wanted Michael> to use the shelve module to store some data on harddisk. Michael> Those data contains a simple C struct. I have read that I Michael> have to add the two functions __getstate__() and Michael> __setstate__() in addmethods for storing and retrieving. Michael> Is there someone who has done so to give me an example. I thought you had to do that too. You need to use the copy_reg module. Here is some code from my Sybase module which allows you to pickle the numeric type I implemented. There is probably more code here than you need, but I would prefer to err on the side of caution. - Dave - - from numeric.c - - - - - - - - - - - - - - - - - - - - - - - - - - - - /* Implement the Sybase.numeric() method */ PyObject *NumericType_new(PyObject *module, PyObject *args) { NumericObj *self; int precision, scale; PyObject *obj; self = PyObject_NEW(NumericObj, &NumericType); if (self == NULL) return NULL; precision = -1; scale = -1; if (PyArg_ParseTuple(args, "O|ii", &obj, &precision, &scale)) { NumericObj *num = NULL; if (PyInt_Check(obj)) num = Numeric_FromInt(obj, precision, scale); else if (PyLong_Check(obj)) num = Numeric_FromLong(obj, precision, scale); else if (PyFloat_Check(obj)) num = Numeric_FromFloat(obj, precision, scale); else if (PyString_Check(obj)) num = Numeric_FromString(obj, precision, scale); else if (Numeric_Check(obj)) num = Numeric_FromNumeric(obj, precision, scale); else raise_exception_string(DataError, "could not convert to Numeric"); if (num) return (PyObject*)num; } Py_DECREF(self); return NULL; } /* Used in unpickler */ static PyObject *numeric_constructor = NULL; /* Register the numeric type with the copy_reg module. This allows * Python to (un)pickle numeric objects. The equivalent Python code * is this: * * def pickle_numeric(n): * return numeric, (str(n), n.precision, n.scale) * * copy_reg.pickle(type(numeric(1)), pickle_numeric, numeric) */ /* Numeric pickling function */ PyObject *pickle_numeric(PyObject *module, PyObject *args) { NumericObj *obj = NULL; PyObject *values = NULL, *tuple = NULL; char text[NUMERIC_LEN]; if (!PyArg_ParseTuple(args, "O!", &NumericType, &obj)) goto error; numeric_as_string(obj, text); if ((values = Py_BuildValue("(sii)", text, obj->num.precision, obj->num.scale)) == NULL) goto error; tuple = Py_BuildValue("(OO)", numeric_constructor, values); error: Py_XDECREF(values); return tuple; } /* Register Numeric type pickler */ void copy_reg_numeric(PyObject *dict) { PyObject *module = NULL, *pickle_func = NULL, *pickler = NULL, *obj = NULL; module = PyImport_ImportModule("copy_reg"); if (module == NULL) goto error; if ((pickle_func = PyObject_GetAttrString(module, "pickle")) == NULL) goto error; if ((numeric_constructor = PyDict_GetItemString(dict, "numeric")) == NULL) goto error; if ((pickler = PyDict_GetItemString(dict, "pickle_numeric")) == NULL) goto error; Py_XINCREF(numeric_constructor); obj = PyObject_CallFunction(pickle_func, "OOO", &NumericType, pickler, numeric_constructor); error: Py_XDECREF(obj); Py_XDECREF(pickler); Py_XDECREF(pickle_func); Py_XDECREF(module); } - - from Sybase.c - - - - - - - - - - - - - - - - - - - - - - - - - - - - static struct PyMethodDef Sybase_methods[] = { { "connect", (PyCFunction)ConnectType_new, METH_VARARGS | METH_KEYWORDS }, { "numeric", (PyCFunction)NumericType_new, METH_VARARGS }, { "pickle_numeric", (PyCFunction)pickle_numeric, METH_VARARGS }, { NULL, NULL } }; void initSybase(void) { PyObject *module; PyObject *dict; module = Py_InitModule(module_name, Sybase_methods); dict = PyModule_GetDict(module); : : copy_reg_numeric(dict); } -- http://www.object-craft.com.au From niessink at serc.nl Tue Feb 13 11:17:54 2001 From: niessink at serc.nl (Frank Niessink) Date: 13 Feb 2001 10:17:54 GMT Subject: How to import from filename with dots in it? Message-ID: <96b1ki$j26$1@newshost.accu.uu.nl> Hi all, I want to import from a file called 'foo-0.1.py'. Is this at all possible? Maybe using __import__? Thanks, Frank -- The Hitch Hiker's Guide to the Galaxy has this to say on the subject of flying. There is an art, it says, or rather a knack to flying. The knack lies in learning how to throw yourself at the ground and miss. Pick a nice day, it suggests, and try it. -- Douglas Adams, 'Life, the Universe, and Everything' From niessink at serc.nl Tue Feb 13 12:30:07 2001 From: niessink at serc.nl (Frank Niessink) Date: 13 Feb 2001 11:30:07 GMT Subject: How to import from filename with dots in it? References: <96b1ki$j26$1@newshost.accu.uu.nl> Message-ID: <96b5rv$his$1@newshost.accu.uu.nl> Frank Niessink wrote: > > I want to import from a file called 'foo-0.1.py'. Is this at all possible? > Maybe using __import__? After some experimenting I found a solution: >>> import imp >>> location = imp.find_module('foo-0.1') >>> foo_0_1 = imp.load_module('dummy', *location) The first argument to load_module does not seem to matter? Cheers, Frank -- "An SEP," he said, "is something that we can't see, or don't see, or our brain doesn't let us see, because we think that it's somebody else's problem. That's what SEP means. Somebody Else's Problem. The brain just edits it out, it's like a blind spot." -- Douglas Adams, 'Life, the Universe, and Everything' From jfontain at winealley.com Tue Feb 13 12:51:50 2001 From: jfontain at winealley.com (Jean-Luc Fontaine) Date: Tue, 13 Feb 2001 12:51:50 +0100 Subject: how to get the output of embedded python? Message-ID: <96b6o6$a6e$1@s1.read.news.oleane.net> I am trying to write a tclpython extension so that modules for my system monitoring application (moodss at http://jfontain.free.fr/moodss11.htm) can also be written in python, on top of tcl and perl. It has been quite simple to write the tclperl extension, since perl allows retrieving the result in string form of any script, using the internal eval facilities. With python, according to my research on the subject (which may be wrong since I am new in python), there does not seem to be any simple way to gather the output of a script passed for example to PyRun_SimpleString. I also looked at the huge piece of code that handles the interactive part of python so that typing 1+1 at the prompt prints 2. Did I miss something in the C API and is there an implementation of say: char *PyEval(char *script) somewhere? Additionally, I would also need the above functionality on a per interpreter basis (I need to be able to use several interpreters concurrently). My apologies if the questions above seem trivial. -- Jean-Luc Fontaine mailto:jfontain at winealley.com http://www.winealley.com From db3l at fitlinxx.com Tue Feb 13 19:28:33 2001 From: db3l at fitlinxx.com (David Bolen) Date: 13 Feb 2001 13:28:33 -0500 Subject: how to get the output of embedded python? References: <96b6o6$a6e$1@s1.read.news.oleane.net> Message-ID: Jean-Luc Fontaine writes: > With python, according to my research on the subject (which may be wrong > since I am new in python), there does not seem to be any simple way to > gather the output of a script passed for example to PyRun_SimpleString. I > also looked at the huge piece of code that handles the interactive part of > python so that typing 1+1 at the prompt prints 2. You may need to be a little more clear on what you mean by "output" - is it anything the script generates, or are you looking for information that is otherwise sent to sys.stdout? The former may be impossible, given that scripts may write files or do various operations. The latter isn't too bad, since you can just redirect sys.stdout before executing the code, unless you need a highly secure or guaranteed environment. I took a fairly low tech approach in one of my embedded applications. First, I just implemented some functions that expected to be called with any data being generated by the script. In my case the application was a simulator and script output was just placed into a main scrolling log window (highlighted if it was to stderr). Then, after instantiating an interpreter (and you could do this for multiple interpreters although you'd need to separate their output in your embedded processing function), I first forced the execution of an initialization script that rebound sys.stdout/stderr to my code, e.g.: import sys class StdoutCatcher: def write(self, stuff): ecna.stdout(stuff) class StderrCatcher: def write(self, stuff): ecna.stderr(stuff) sys.stdout = StdoutCatcher() sys.stderr = StderrCatcher() (in the above, the "ecna." functions are those already registered by the embedding application) And after that, any scripts that I executed within that same interpreter would send output normally destined for sys.stdout/stderr to my internal function which could do whatever it wanted with it. In your case, you could just accumulate it until some other part of your application requested it. Note that this doesn't preclude the script being run from trying to reset sys.stdout, and it does involve an extra "init" script (hidden though it was from the main script). You could be a bit more self-contained by actually implementing the catcher classes directly in your embedding application, but for simply embedding typical scripts that you want to trap the output of, this should work well. -- -- 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 jfontain at winealley.com Wed Feb 14 11:06:53 2001 From: jfontain at winealley.com (Jean-Luc Fontaine) Date: Wed, 14 Feb 2001 11:06:53 +0100 Subject: how to get the output of embedded python? References: <96b6o6$a6e$1@s1.read.news.oleane.net> Message-ID: <96dkvb$eb8$1@s1.read.news.oleane.net> David Bolen wrote: > Jean-Luc Fontaine writes: > > > With python, according to my research on the subject (which may be wrong > > since I am new in python), there does not seem to be any simple way to > > gather the output of a script passed for example to PyRun_SimpleString. > > I also looked at the huge piece of code that handles the interactive > > part of python so that typing 1+1 at the prompt prints 2. > > You may need to be a little more clear on what you mean by "output" - > is it anything the script generates, Yes. That is whatever output you would see when in interactive mode, if that makes any sense... > or are you looking for > information that is otherwise sent to sys.stdout? The former may be > impossible, given that scripts may write files or do various > operations. That does not seem to matter in other scripting languages, such as Tcl or Perl: calling an internal eval C function with a script as argument returns the result of the script (not what comes out on stdout or stderr), which may be empty. For example, if I define a function foo that returns a string, invoking eval("foo()") in C would return that string. Is not that the behavior of python in interactive mode, for example? -- Jean-Luc Fontaine mailto:jfontain at winealley.com http://www.winealley.com From db3l at fitlinxx.com Thu Feb 15 02:16:04 2001 From: db3l at fitlinxx.com (David Bolen) Date: 14 Feb 2001 20:16:04 -0500 Subject: how to get the output of embedded python? References: <96b6o6$a6e$1@s1.read.news.oleane.net> <96dkvb$eb8$1@s1.read.news.oleane.net> Message-ID: Jean-Luc Fontaine writes: > Yes. That is whatever output you would see when in interactive mode, if > that makes any sense... Oh, I think I understand better. You don't actually want to trap any output generated during the execution of the code - you just want to deal with the result of the expression you may be evaluating. > That does not seem to matter in other scripting languages, such as Tcl or > Perl: calling an internal eval C function with a script as argument returns > the result of the script (not what comes out on stdout or stderr), which > may be empty. > > For example, if I define a function foo that returns a string, invoking > eval("foo()") in C would return that string. Is not that the behavior of > python in interactive mode, for example? On an expression by expression basis, yes, each expression has a result object (but not statements such as "print" for example). You should be able to handle the same thing from your controlling code by dipping a little lower than the "Simple" high level functions. By using either PyRun_File or PyRun_String you can evaluate Python code, and the result of the function is the resulting Python object (a PyObject *). Use PyEval_GetGlobals and PyEval_GetLocals for the dictionaries to supply to the execution. Once you have the resulting object pointer you can do anything you want with it (using any of the Python functions available for extending/embedding applications), including converting it into a string representation if you like. Note that the result does not itself have to be a string object, since a Python expression can result in any Python object. Check out the abstract and concrete objects layer in the C/API reference or the Python source for all sorts of functions. But if you know you want a string representation, you should be able to use something like PyObject_Str to return a new Python object with a string representation of the result object. Then, if you just want a char*, use PyString_AsString. -- -- 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 jfontain at winealley.com Thu Feb 15 14:56:45 2001 From: jfontain at winealley.com (Jean-Luc Fontaine) Date: Thu, 15 Feb 2001 14:56:45 +0100 Subject: how to get the output of embedded python? References: <96b6o6$a6e$1@s1.read.news.oleane.net> <96dkvb$eb8$1@s1.read.news.oleane.net> Message-ID: <96gmq7$p9r$1@s1.read.news.oleane.net> David Bolen wrote: > Jean-Luc Fontaine writes: > > > Yes. That is whatever output you would see when in interactive mode, if > > that makes any sense... > > Oh, I think I understand better. You don't actually want to trap any > output generated during the execution of the code - you just want to > deal with the result of the expression you may be evaluating. > > > That does not seem to matter in other scripting languages, such as Tcl > > or Perl: calling an internal eval C function with a script as argument > > returns the result of the script (not what comes out on stdout or > > stderr), which may be empty. > > > > For example, if I define a function foo that returns a string, invoking > > eval("foo()") in C would return that string. Is not that the behavior of > > python in interactive mode, for example? > > On an expression by expression basis, yes, each expression has a > result object (but not statements such as "print" for example). > > You should be able to handle the same thing from your controlling code > by dipping a little lower than the "Simple" high level functions. By > using either PyRun_File or PyRun_String you can evaluate Python code, > and the result of the function is the resulting Python object (a > PyObject *). Use PyEval_GetGlobals and PyEval_GetLocals for the > dictionaries to supply to the execution. > > Once you have the resulting object pointer you can do anything you > want with it (using any of the Python functions available for > extending/embedding applications), including converting it into a > string representation if you like. Note that the result does not > itself have to be a string object, since a Python expression can > result in any Python object. Check out the abstract and concrete > objects layer in the C/API reference or the Python source for all > sorts of functions. > > But if you know you want a string representation, you should be able > to use something like PyObject_Str to return a new Python object with > a string representation of the result object. Then, if you just want > a char*, use PyString_AsString. > > -- Thank you so very much for all this information: that is what I needed to get started. -- Jean-Luc Fontaine mailto:jfontain at winealley.com http://www.winealley.com From jh at web.de Thu Feb 15 23:00:29 2001 From: jh at web.de (Jürgen Hermann) Date: Thu, 15 Feb 2001 23:00:29 +0100 Subject: how to get the output of embedded python? References: <96b6o6$a6e$1@s1.read.news.oleane.net> Message-ID: <96hjhn$hni$05$1@news.t-online.com> "Jean-Luc Fontaine" schrieb im Newsbeitrag news:96b6o6$a6e$1 at s1.read.news.oleane.net... > Did I miss something in the C API and is there an implementation of say: > > char *PyEval(char *script) > > somewhere? BTW, the easiest way to handle it is to create a cStringIO object, PySys_SetItem() that as your stdout and then start your script. After it did run, you can getvalue() the output. This is much easier than writing your own file-like C extension. From boswell at caltech.edu Tue Feb 13 13:24:30 2001 From: boswell at caltech.edu (Dustin Boswell) Date: Tue, 13 Feb 2001 04:24:30 -0800 Subject: https support in Python? Message-ID: <3A89277E.68C09AB1@caltech.edu> I noticed that although python 1.6 and up are claimed to support code like: urllib.urlopen("https://secure-server.com") the Modules/Setup file (in the source distribution for Python) has the SSL part commented out since it "breaks" the Python build. It sure does. ;-) I've tried downloading and installing various openssl, ssleay, and other packages but it always complains one way or another during build. And it seems that there are a lot of hacks, but no official Python releases. My question is, what is the "standard" way (what packages, etc...) to get my python interpreter built so I can do urlopen("https://")? Any links to good packages (third party ok) would be great help. P.S. I'm running Redhat 6.2 Thanks in advance. From olafb+usenet at pvv.org Tue Feb 13 14:11:18 2001 From: olafb+usenet at pvv.org (Olaf Trygve Berglihn) Date: 13 Feb 2001 14:11:18 +0100 Subject: https support in Python? References: <3A89277E.68C09AB1@caltech.edu> Message-ID: Dustin Boswell writes: > I noticed that although python 1.6 and up are claimed to support code > like: > urllib.urlopen("https://secure-server.com") > the Modules/Setup file (in the source distribution for Python) has the > SSL > part commented out since it "breaks" the Python build. It sure does. > ;-) > > I've tried downloading and installing various openssl, ssleay, and other > packages > but it always complains one way or another during build. And it seems > that > there are a lot of hacks, but no official Python releases. > My question is, what is the "standard" way (what packages, etc...) to > get my > python interpreter built so I can do urlopen("https://")? > > Any links to good packages (third party ok) would be great help. You can try my (unofficial) build of python 2.0 found at: Try rebuilding the srpm on your redhat. The binary rpms were build on a Trustix Secure Linux v1.2 and link against openssl-0.9.6. I guess rh-6.2 uses openssl-0.9.5a. It should work with the older openssl. The Tkinter module is left out in this build. Olaf -- Olaf Trygve Berglihn From gustafl at algonet.se Tue Feb 13 13:35:31 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: Tue, 13 Feb 2001 13:35:31 +0100 Subject: Delete a certain line from a file Message-ID: <96b9n0$amd$1@cubacola.tninet.se> Excuse another newbie question. My script is reading a textfile with a list of words (separated with newlines), and now I need something to delete a certain record when I encounter it in a loop. Something like: for line in f.readlines(): if line == "somethingbad": # delete the whole line with newline break I have successfully done this by adding each line to a list and then used list.remove("somethingbad"), but there's another way without having to put the whole file in a list, isn't it? Regards, Gustaf Liljegren From stephen_purcell at yahoo.com Tue Feb 13 15:39:06 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 13 Feb 2001 15:39:06 +0100 Subject: Delete a certain line from a file In-Reply-To: <96b9n0$amd$1@cubacola.tninet.se>; from gustafl@algonet.se on Tue, Feb 13, 2001 at 01:35:31PM +0100 References: <96b9n0$amd$1@cubacola.tninet.se> Message-ID: <20010213153906.A759@freedom.puma-ag.com> Gustaf Liljegren wrote: > Excuse another newbie question. My script is reading a textfile with a list > of words (separated with newlines), and now I need something to delete a > certain record when I encounter it in a loop. Something like: > > for line in f.readlines(): > if line == "somethingbad": > # delete the whole line with newline > break Note that 'readlines' always reads the whole file into memory anyway... > > I have successfully done this by adding each line to a list and then used > list.remove("somethingbad"), but there's another way without having to put > the whole file in a list, isn't it? Yes, filter the file into another file then rename it: infile = open(inputfilename,'r') outputfile = open(outputfilename, 'w') while 1: line = infile.readline() if not line: break if line != "somethingbad": outfile.write(line) infile.close() outfile.close() os.rename(outputfilename, inputfilename) -Steve -- Steve Purcell, Pythangelist http://pyunit.sourceforge.net/ http://pyserv.sourceforge.net/ Available for consulting and training. "Even snakes are afraid of snakes." -- Steven Wright From cfelling at iae.nl Tue Feb 13 15:41:35 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 13 Feb 2001 15:41:35 +0100 Subject: Delete a certain line from a file References: <96b9n0$amd$1@cubacola.tninet.se> Message-ID: <96bh2v$26t$1@animus.fel.iae.nl> Gustaf Liljegren wrote: > Excuse another newbie question. My script is reading a textfile with a list > of words (separated with newlines), and now I need something to delete a > certain record when I encounter it in a loop. Something like: > for line in f.readlines(): > if line == "somethingbad": > # delete the whole line with newline > break use the marvelous fileinput module like in: import fileinput for line in fileinput.input('yourfile', inplace=1): if line != "somethingbad": print line, The keyword argument "inplace=1", tells fileinput.input to handle this file special: make a copy, read from that copy and redirect stdout to a new version of that file, effectively allowing you to change that file `in place'. Notice the trailing "," in the print line, this tells print not to add (yet an other) end-of-line character. > I have successfully done this by adding each line to a list and then used > list.remove("somethingbad"), but there's another way without having to put > the whole file in a list, isn't it? see above:), your approach seems correct though, though could be spedup a little: data = filter(lambda x: x != "somethingbad", f.readlines()) or: data = [] for line in f.readlines() if line != "somethingbad" data.append(line) -- groetjes, carel From csrabak at uol.com.br Tue Feb 13 15:56:45 2001 From: csrabak at uol.com.br (Cesar Rabak) Date: Tue, 13 Feb 2001 11:56:45 -0300 Subject: Delete a certain line from a file References: <96b9n0$amd$1@cubacola.tninet.se> Message-ID: <3A894B2D.8D48EAFF@uol.com.br> Gustaf Liljegren wrote: > > Excuse another newbie question. My script is reading a textfile with a list > of words (separated with newlines), and now I need something to delete a > certain record when I encounter it in a loop. Something like: > > for line in f.readlines(): > if line == "somethingbad": > # delete the whole line with newline > break > > I have successfully done this by adding each line to a list and then used > list.remove("somethingbad"), but there's another way without having to put > the whole file in a list, isn't it? Unfortunately no ;-) If you feel you'll need this kind of functionality more often than not, you should consider changing from a textfile to a database. HTH Cesar From mike.mellor at tbe.com Tue Feb 13 13:49:32 2001 From: mike.mellor at tbe.com (mike.mellor at tbe.com) Date: Tue, 13 Feb 2001 12:49:32 -0000 Subject: Passing Values Message-ID: <96bags+tjse@eGroups.com> I am working on an RPN calculator program, using a four level stack. I initialize it as: stack = [0.0,0.0,0.0,0.0] I am noticing problems with the following two functions (xStack and yStack are Entry widgets). clearer is supposed to clear the values of the stack, and RollDown is supposed to "roll the stack" down. def clearer(event): yStack.delete(0,END) xStack.delete(0,END) stack = [0.0, 0.0, 0.0, 0.0] print 'Clear ' + str(stack) for i in range(4): print 'Stack ' + `i` + ' ' + str(stack[i]) def RollDown(event): stack[0] = stack[1] stack[1] = stack[2] stack[2] = stack[3] try: stack[3] = float(xStack.get()) except ValueError: stack[3] = 0.0 xStack.delete(0,END) xStack.insert(0,stack[0]) yStack.delete(0,END) yStack.insert(0,str(stack[1])) print 'Roll down ' + str(stack) for i in range(4): print 'Stack ' + `i` + ' ' + str(stack[i]) The console reports that the stack is cleared, but when I roll the stack down, old values pop in. Do I need to use a deepcopy to pass the values from one stack location to the next (stack[0] = deepcopy (stack[1])) or is there a better way to do this? Thanks. Mike From scarblac at pino.selwerd.nl Wed Feb 14 00:06:50 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 13 Feb 2001 23:06:50 GMT Subject: Passing Values References: Message-ID: mike.mellor at tbe.com wrote in comp.lang.python: > I am working on an RPN calculator program, using a four level stack. > I initialize it as: > > stack = [0.0,0.0,0.0,0.0] > > I am noticing problems with the following two functions (xStack and > yStack are Entry widgets). clearer is supposed to clear the values > of the stack, and RollDown is supposed to "roll the stack" down. > > def clearer(event): > yStack.delete(0,END) > xStack.delete(0,END) > stack = [0.0, 0.0, 0.0, 0.0] > print 'Clear ' + str(stack) > for i in range(4): > print 'Stack ' + `i` + ' ' + str(stack[i]) The stack you use here is a local variable. It has no effect on the global variable also named stack. Solution: put 'global stack' as the first line of the function. > def RollDown(event): > stack[0] = stack[1] > stack[1] = stack[2] > stack[2] = stack[3] > try: > stack[3] = float(xStack.get()) > except ValueError: > stack[3] = 0.0 > xStack.delete(0,END) > xStack.insert(0,stack[0]) > yStack.delete(0,END) > yStack.insert(0,str(stack[1])) > print 'Roll down ' + str(stack) > for i in range(4): > print 'Stack ' + `i` + ' ' + str(stack[i]) Here, you never directly assign to stack, so Python assumes you meant the global. This function uses the global stack. > The console reports that the stack is cleared, but when I roll the > stack down, old values pop in. Do I need to use a deepcopy to pass > the values from one stack location to the next (stack[0] = deepcopy > (stack[1])) or is there a better way to do this? Instead of stack[0]=stack[1]; stack[1]=stack[2]; stack[2]=etc, you simply want to do 'del stack[0]'. Then add the new element with stack.append(0.0). -- Remco Gerlich From danielk at aracnet.com Tue Feb 13 16:32:23 2001 From: danielk at aracnet.com (Daniel Klein) Date: Tue, 13 Feb 2001 07:32:23 -0800 Subject: spawnv question Message-ID: Here is a snippet of code I'm using with the 'spawnv' command: import os args = ('http://www.python.org', 'http://www.python.org') # This works os.spawnv(os.P_NOWAIT, 'c:\progra~1\intern~1\iexplore', args) print "done" The Python Reference for the 'spawnv' command says: "Execute the program path in a new process, passing the arguments specified in args as command-line parameters. args may be a list or a tuple." My question is, why do I have to specify the url argument twice in the 'args' variable. It doesn't seem to work properly if I specify it as a 1-element tuple, ie... args = ('http://www.python.org',) # This doesn't work Thanks, Daniel Klein From fredrik at pythonware.com Tue Feb 13 16:48:32 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 13 Feb 2001 15:48:32 GMT Subject: spawnv question References: Message-ID: Daniel Klein wrote: > Here is a snippet of code I'm using with the 'spawnv' command: > > import os > args = ('http://www.python.org', 'http://www.python.org') # This works > os.spawnv(os.P_NOWAIT, 'c:\progra~1\intern~1\iexplore', args) > print "done" > > The Python Reference for the 'spawnv' command says: > > "Execute the program path in a new process, passing the arguments specified in > args as command-line parameters. args may be a list or a tuple." > > My question is, why do I have to specify the url argument twice in the 'args' > variable. because internet explorer, like any other program, expects to find its first argument in argv[1], not argv[0]. by convention (and sometimes necessity), the first argument should be the name of the program's executable. try this: os.spawnv(mode, program, (program,) + tuple(args)) under unix, (program,) should be (os.path.basename(program),) instead. Cheers /F From dbrueck at edgix.com Tue Feb 13 16:50:12 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Tue, 13 Feb 2001 08:50:12 -0700 Subject: spawnv question In-Reply-To: Message-ID: argv[0] is reserved for the program name. > -----Original Message----- > From: python-list-admin at python.org > [mailto:python-list-admin at python.org]On Behalf Of Daniel Klein > Sent: Tuesday, February 13, 2001 8:32 AM > To: python-list at python.org > Subject: spawnv question > > > Here is a snippet of code I'm using with the 'spawnv' command: > > import os > args = ('http://www.python.org', 'http://www.python.org') # This works > os.spawnv(os.P_NOWAIT, 'c:\progra~1\intern~1\iexplore', args) > print "done" > > The Python Reference for the 'spawnv' command says: > > "Execute the program path in a new process, passing the > arguments specified in > args as command-line parameters. args may be a list or a tuple." > > My question is, why do I have to specify the url argument twice > in the 'args' > variable. It doesn't seem to work properly if I specify it as a 1-element > tuple, ie... > > args = ('http://www.python.org',) # This doesn't work > > Thanks, > Daniel Klein > > -- > http://mail.python.org/mailman/listinfo/python-list From cerutti at together.net Tue Feb 13 17:24:44 2001 From: cerutti at together.net (Neil Cerutti) Date: 13 Feb 2001 16:24:44 GMT Subject: spawnv question References: Message-ID: Dave Brueck posted: >argv[0] is reserved for the program name. Python gives you the ability to call programs while supplying an erroneous program names to them. This is very useful, and it makes perfect sense if you know various C libraries. After all, spawning external programs should only be attempted by experienced programmers. -- Neil Cerutti From erno-news at erno.iki.fi Wed Feb 14 09:16:12 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 14 Feb 2001 10:16:12 +0200 Subject: spawnv question References: Message-ID: In article , cerutti at together.net (Neil Cerutti) writes: | Dave Brueck posted: || argv[0] is reserved for the program name. | Python gives you the ability to call programs while supplying an | erroneous program names to them. This is very useful, and it | makes perfect sense if you know various C libraries. After all, | spawning external programs should only be attempted by | experienced programmers. there is no way to tell what is an erroneous program name to you (short of popping up a dialog box and asking) :) -- erno From jurgen.defurne at philips.com Wed Feb 14 08:26:52 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Wed, 14 Feb 2001 08:26:52 +0100 Subject: spawnv question Message-ID: <0056900015894399000002L092*@MHS> To know why, you should consult the MS documentation about the spawn calls. Their standard is to use as first argument in the argumentlist the name of the program that you called. The Python documentation is very unclear about the spawn calls. What is not mentioned also is that both spawnv(e) and spawnl(e) are available in Python 2.0. Jurgen danielk at aracnet.com@SMTP at python.org on 13/02/2001 16:53:38 Sent by: python-list-admin at python.org To: python-list at python.org@SMTP cc: Subject: spawnv question Classification: Here is a snippet of code I'm using with the 'spawnv' command: import os args = ('http://www.python.org', 'http://www.python.org') # This works os.spawnv(os.P_NOWAIT, 'c:\progra~1\intern~1\iexplore', args) print "done" The Python Reference for the 'spawnv' command says: "Execute the program path in a new process, passing the arguments specified in args as command-line parameters. args may be a list or a tuple." My question is, why do I have to specify the url argument twice in the 'args' variable. It doesn't seem to work properly if I specify it as a 1-element tuple, ie... args = ('http://www.python.org',) # This doesn't work Thanks, Daniel Klein -- http://mail.python.org/mailman/listinfo/python-list From hamish_lawson at yahoo.co.uk Tue Feb 13 16:44:08 2001 From: hamish_lawson at yahoo.co.uk (=?iso-8859-1?q?Hamish=20Lawson?=) Date: Tue, 13 Feb 2001 15:44:08 +0000 (GMT) Subject: MySQL + SQL Statements + Quote escaping Message-ID: <20010213154408.14748.qmail@web214.mail.yahoo.com> Christian Theune wrote: i just tuned into python and it's really cool. I like it. Before I came to python i used to write scripts in php. There was a function called "addslashes" it escaped quotes and slashes to make strings sql-safe. Database modules that conform to the DB-API specfication, such as MySQLdb, provide a placeholder mechanism that will take care of the quoting automatically. For example: cursor.execute( "select * from customers where surname = %s and age < %s", ("O'Hara", 40) ) The %s placeholders are replaced by correctly quoted values. There are two advantages to this approach. Firstly, database engines differ in how they escape quotes. Many, such as MySQLdb, prefix them with a backslash, but other DB engines escape quotes by doubling them (thus 'O''Reilly'). Using the placeholder mechanism lets the particular database module deal with that for you. The second advantage is that the execute() method can optimise its performance when the same operation is repeatedly executed but with different bound values for the placeholders. But if you build the query string yourself on each iteration, then the execute() method will have to parse it each time for correctness, thus losing the opportunity for optimisation. 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 ct at gocept.com Tue Feb 13 23:01:17 2001 From: ct at gocept.com (Christian Theune) Date: Tue, 13 Feb 2001 23:01:17 +0100 Subject: MySQL + SQL Statements + Quote escaping References: Message-ID: <3A89AEAD.70003@gocept.com> thanks to all of you, who answered. I think the most reliable and effictive solution was brought up from Hamish Lawson. have a nice day Christian Theune From ben.held at staarinc.com Tue Feb 13 16:45:51 2001 From: ben.held at staarinc.com (Ben Held) Date: Tue, 13 Feb 2001 09:45:51 -0600 Subject: returning local character string from python extension dll Message-ID: <3a8956ec$0$46002$272ea4a1@news.execpc.com> I am building a python extension dll using C++ and SWIG. I need to return a character string from a class member function. The problem is the that the string is not a member of the class, but it is a local string: char* CFoo::GetName() { char pc[] = "blah"; ......... return pc; } I want to be able to call "print pFoo.GetName()" in python and have "blah" printed. If I define my function just as above, I get garbage printed since the data is local and destroyed when the function exits. I know I can return a PyObject* using PyString_FromString, but then print on that object doesn't show the string like I need. Ideas? Ben ben.held at staarinc.com From vonehr at ira.uka.de Tue Feb 13 17:55:56 2001 From: vonehr at ira.uka.de (Markus von Ehr) Date: Tue, 13 Feb 2001 17:55:56 +0100 Subject: tkinter: Message-ID: <3A89671C.58AC2833@ira.uka.de> Hi, I have a class that creates a toplevel window and want to destroy the toplevel from a thread within this class. I get an error in python.exe, does anybody know why and how I can destroy the toplevel in this thread? class MyWindow: def __init__(self, root, duration): self.duration = int(duration * 10 + 0.5) self.toplevel = Toplevel(root) thread.start_new_thread(self.my_thread, (10,)) def my_thread(self, start): time.sleep(self.duration) self.toplevel.grab_release() self.root.focus_set() self.root.focus_set() self.toplevel.destroy() Thanks for any answer, Markus From u504516601 at spawnkill.ip-mobilphone.net Tue Feb 13 17:58:38 2001 From: u504516601 at spawnkill.ip-mobilphone.net (u504516601 at spawnkill.ip-mobilphone.net) Date: Tue, 13 Feb 2001 16:58:38 GMT Subject: pattern for processing HTML form with multiple rows? Message-ID: Architecture: Python, ASP, MsSQL Want to have a form for inserting records into a database. Would like to offer a grid so that user can enter multiple records at one time. Assume data validation provided through pulldowns for key fields. What's the "best" approach for looping over the fields and performing the inserts? -- Sent by fluxent from yahoo piece of com This is a spam protected message. Please answer with reference header. Posted via http://www.usenet-replayer.com/cgi/content/new From gregj at pobox.com Sun Feb 18 03:15:56 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Sun, 18 Feb 2001 02:15:56 GMT Subject: pattern for processing HTML form with multiple rows? References: Message-ID: <3a8f2fd9.161195146@news.potlnd1.or.home.com> On Tue, 13 Feb 2001 16:58:38 GMT, u504516601 at spawnkill.ip-mobilphone.net wrote: >Architecture: Python, ASP, MsSQL > >Want to have a form for inserting records into a database. >Would like to offer a grid so that user can enter multiple >records at one time. Assume data validation provided through >pulldowns for key fields. > >What's the "best" approach for looping over the fields >and performing the inserts? You can set up your HTML form "grid" a couple of ways. One way is to give the fields in each grid row different names. Another way is to reuse the form field names. Example 1:
...
In your Python CGI program: import cgi form = cgi.FieldStorage() numrows = form["numrows"] # passed from form for r in range(1,numrows+1): # for each row... f1 = form["r" + str(r) + "f1"].value # get field f1 f2 = form["r" + str(r) + "f2"].value # get field f2 # do something with fields f1 & f2 # note that the fields may be empty Example 2:
...
Note that the fields have the same name in each row. The Python code is: import cgi form = cgi.FieldStorage() rows = len(form["f1"]) # f1, f2 are lists, one entry per row for i in range(rows): f1 = form["f1"][i].value f2 = form["f2"][i].value # do something with fields f1 & f2 # note that the fields may be empty I can't say which method may work best for you. You can only go so far simulating a grid-type data entry widget in HTML. The main point to remember is that if an HTML form has more than one field with the same name, the values are sent to the receiving CGI program in a comma-separated list. Greg Jorgensen Deschooling Society Portland, Oregon USA From chrisa at ASPATECH.COM.BR Tue Feb 13 19:29:00 2001 From: chrisa at ASPATECH.COM.BR (Chris Richard Adams) Date: Tue, 13 Feb 2001 15:29:00 -0300 Subject: while loop with f.readline() Message-ID: I'm trying to create a loop that reads through a simple file with strings on each line. f=open('/tmp/xferlog', 'r') while f.readline(): line = f.readline() print line Problem 1: Although I know there are five lines in the file - it only prints the 3rd and 4th line. Is my usage above correct for this - I'd expect to see all lines. Problem 2: How do define the range of the while loop: for example if I place f.close() in the list of items wto go through in the loop: f=open('/tmp/xferlog', 'r') while f.readline(): line = f.readline() print line f.close() How do i code the loop to know that it should be executed after the loop...not after each iteration??? Thanks! From dsh8290 at rit.edu Tue Feb 13 18:39:08 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 13 Feb 2001 12:39:08 -0500 Subject: while loop with f.readline() In-Reply-To: ; from chrisa@aspatech.com.br on Tue, Feb 13, 2001 at 03:29:00PM -0300 References: Message-ID: <20010213123908.B11342@harmony.cs.rit.edu> On Tue, Feb 13, 2001 at 03:29:00PM -0300, Chris Richard Adams wrote: | I'm trying to create a loop that reads through a simple file with | strings on each line. | | f=open('/tmp/xferlog', 'r') | while f.readline(): This reads line 1 , 3, 5 | line = f.readline() this reads lines 2 , 4 | print line this prints the lines stored in 'line', lines 2, 4 | | Problem 1: Although I know there are five lines in the file - it only | prints the 3rd and 4th line. Is my usage above correct for this - I'd | expect to see all lines. | | Problem 2: How do define the range of the while loop: for example if I | place f.close() in the list of items wto go through in the loop: | | | f=open('/tmp/xferlog', 'r') | while f.readline(): | line = f.readline() | print line | f.close() | | How do i code the loop to know that it should be executed after the | loop...not after each iteration??? | | Thanks! | f = open( '/tmp/xferlog' , 'r' ) for line in f.readlines() : print line f.close() # not indented, this happens after the loop If you are using Python 2.1 or greater you can use the f.xreadlines() function which won't read the entire file at once. Alternatively : f = open( '/tmp/xferlog' , 'r' ) while 1 : line = f.readline() if not line : break # stop the loop if no line was read print line f.close() # after the loop, not in it or f = open( '/tmp/xferlog' , 'r' ) line = f.readline() while line : print line line = f.readline() f.close() I prefer the for loop the best, and will be great when 2.1 is released (with the xreadlines function). HTH, -D From stephen_purcell at yahoo.com Tue Feb 13 18:39:18 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 13 Feb 2001 18:39:18 +0100 Subject: while loop with f.readline() In-Reply-To: ; from chrisa@ASPATECH.COM.BR on Tue, Feb 13, 2001 at 03:29:00PM -0300 References: Message-ID: <20010213183918.A4918@freedom.puma-ag.com> Chris Richard Adams wrote: > I'm trying to create a loop that reads through a simple file with > strings on each line. > > f=open('/tmp/xferlog', 'r') > while f.readline(): > line = f.readline() > print line In the code above, the line returned from 'f.readline()' in the 'while' condition is simply thrown away, so only every second line is printed. You probably mean: while 1: line = f.readline() if not line: break print line It may look a bit strange, but it's a Python idiom and is the best way to do this kind of input loop. > f=open('/tmp/xferlog', 'r') > while f.readline(): > line = f.readline() > print line > f.close() > > How do i code the loop to know that it should be executed after the > loop...not after each iteration??? Put the 'close' call in the appropriate block -- the blocks are contiguous areas of equal indentation. You don't want the 'close' call in the block internal to the loop, or it will be executed each time through the loop. You want: while 1: line = f.readline() if not line: break print line f.close() -Steve -- Steve Purcell, Pythangelist http://pyunit.sourceforge.net/ http://pyserv.sourceforge.net/ Available for consulting and training. "Even snakes are afraid of snakes." -- Steven Wright From chris.gonnerman at usa.net Wed Feb 14 02:06:25 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Tue, 13 Feb 2001 19:06:25 -0600 Subject: while loop with f.readline() References: Message-ID: <00b801c09622$623886a0$a100000a@local> ----- Original Message ----- From: "Chris Richard Adams" Subject: while loop with f.readline() > >I'm trying to create a loop that reads through a simple file with >strings on each line. > >f=open('/tmp/xferlog', 'r') >while f.readline(): > line = f.readline() > print line I have always been a fan of the FileReader class: class FileReader: def __init__(self, file): self.file = file def next(self): self.line = self.file.readline() return self.line if __name__ == '__main__': f = FileReader(open("c:/autoexec.bat")) while f.next(): print f.line, From zdweeb at hotmail.com Wed Feb 14 02:32:53 2001 From: zdweeb at hotmail.com (William Voll) Date: Wed, 14 Feb 2001 01:32:53 GMT Subject: while loop with f.readline() References: Message-ID: in article mailman.982085180.24537.python-list at python.org, Chris Richard Adams at chrisa at ASPATECH.COM.BR wrote on 2/13/01 1:29 PM: > I'm trying to create a loop that reads through a simple file with > strings on each line. > > f=open('/tmp/xferlog', 'r') > while f.readline(): > line = f.readline() > print line > > Problem 1: Although I know there are five lines in the file - it only > prints the 3rd and 4th line. Is my usage above correct for this - I'd > expect to see all lines. > > Problem 2: How do define the range of the while loop: for example if I > place f.close() in the list of items wto go through in the loop: > > > f=open('/tmp/xferlog', 'r') > while f.readline(): > line = f.readline() > print line > f.close() > > How do i code the loop to know that it should be executed after the > loop...not after each iteration??? > > Thanks! > This should get the job done. f=open('/tmp/xferlogt','r').readlines() for l in f: print l --zdweeb From phlip_cpp at my-deja.com Wed Feb 14 06:15:14 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 14 Feb 2001 05:15:14 GMT Subject: while loop with f.readline() References: Message-ID: <96d492$88c@dispatch.concentric.net> Proclaimed Chris Gonnerman from the mountaintops: > I have always been a fan of the FileReader class: > > class FileReader: > def __init__(self, file): > self.file = file > def next(self): > self.line = self.file.readline() > return self.line > > if __name__ == '__main__': > > f = FileReader(open("c:/autoexec.bat")) > > while f.next(): > print f.line, Came to the thread late can't read all posts don't know if this was covered so sue me but... ...what's wrong with this? for z in f.readlines(): print z That's how I done it since I was a chile'. -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- http://www.deja.com/my/pb.xp?member_name=phlip_cpp -- From jepler at inetnebr.com Wed Feb 14 15:17:22 2001 From: jepler at inetnebr.com (Jeff Epler) Date: Wed, 14 Feb 2001 14:17:22 GMT Subject: while loop with f.readline() References: <96d492$88c@dispatch.concentric.net> Message-ID: On 14 Feb 2001 05:15:14 GMT, Phlip wrote: >Came to the thread late can't read all posts don't know if this was covered >so sue me but... > >...what's wrong with this? > > for z in f.readlines(): > print z > >That's how I done it since I was a chile'. If the contents of f are larger than memory, this won't work. If the contents of f are large compared to memory, then it won't work very well. This is one reason that 2.1 will include "xreadlines", which will work just like the above: for z in f.xreadlines(): print z but will never hold the entire file in memory. Jeff From fredrik at pythonware.com Thu Feb 15 08:11:46 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 15 Feb 2001 07:11:46 GMT Subject: while loop with f.readline() References: <96d492$88c@dispatch.concentric.net> Message-ID: Jeff Epler wrote: > This is one reason that 2.1 will include "xreadlines", which will work > just like the above: > for z in f.xreadlines(): > print z > but will never hold the entire file in memory. never? not even if it's a single byte? ;-) Cheers /F From jepler at inetnebr.com Thu Feb 15 14:22:39 2001 From: jepler at inetnebr.com (Jeff Epler) Date: Thu, 15 Feb 2001 13:22:39 GMT Subject: while loop with f.readline() References: <96d492$88c@dispatch.concentric.net> Message-ID: >Jeff Epler wrote: >> [xreadlines] never hold the entire file in memory. > On Thu, 15 Feb 2001 07:11:46 GMT, Fredrik Lundh wrote: >never? not even if it's a single byte? ;-) I thought about making a qualification like this, but decided nobody would feel the need to be such a smart-arse. I'd say, "xreadlines will never hold more than a few KB of the file in memory", but that's wrong if you have a file with a multi-megabyte line. So, as you can see, I'm at a loss to describe just what xreadlines does, but I'm sure it's a really wonderful thing. Jeff From jafo-pythonlist at tummy.com Fri Feb 16 01:04:19 2001 From: jafo-pythonlist at tummy.com (Sean Reifschneider) Date: Thu, 15 Feb 2001 17:04:19 -0700 Subject: while loop with f.readline() In-Reply-To: ; from jepler@inetnebr.com on Thu, Feb 15, 2001 at 01:22:39PM +0000 References: <96d492$88c@dispatch.concentric.net> Message-ID: <20010215170419.L23577@tummy.com> On Thu, Feb 15, 2001 at 01:22:39PM +0000, Jeff Epler wrote: >I'd say, "xreadlines will never hold more than a few KB of the file >in memory", but that's wrong if you have a file with a multi-megabyte line. Say "xreadlines()" will never hold more than a single line of the file in memory. Note the implications if you feed it a file with multi-megabyte line(s). Sean -- I find that a great part of the information I have was acquired by looking up something and finding something else on the way. -- Franklin P. Adams Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From jepler at inetnebr.com Fri Feb 16 01:44:03 2001 From: jepler at inetnebr.com (Jeff Epler) Date: Thu, 15 Feb 2001 18:44:03 -0600 Subject: while loop with f.readline() In-Reply-To: <20010215170419.L23577@tummy.com> References: <96d492$88c@dispatch.concentric.net> <20010215170419.L23577@tummy.com> Message-ID: <20010215184403.A8822@potty.housenet> On Thu, Feb 15, 2001 at 05:04:19PM -0700, Sean Reifschneider wrote: > On Thu, Feb 15, 2001 at 01:22:39PM +0000, Jeff Epler wrote: > >I'd say, "xreadlines will never hold more than a few KB of the file > >in memory", but that's wrong if you have a file with a multi-megabyte line. > > Say "xreadlines()" will never hold more than a single line of the file in > memory. Note the implications if you feed it a file with multi-megabyte > line(s). Well, the full explanation is that it uses 'readlines(sizehint)' internally, and it never holds more than one chunk as returned by readlines(). So for line in file.xreadlines(): pass has the memory behavior of while 1: lines = file.readlines(sizehint) if not lines: break for line in lines: pass but the flow control of for line in file.readlines(): pass Jeff PS I don't recall what value of sizehint is used in 2.1, it was changed when the patch was integreated, after some benchmarking on python-dev From db3l at fitlinxx.com Sat Feb 17 00:33:12 2001 From: db3l at fitlinxx.com (David Bolen) Date: 16 Feb 2001 18:33:12 -0500 Subject: while loop with f.readline() References: <96d492$88c@dispatch.concentric.net> <20010215170419.L23577@tummy.com> Message-ID: Jeff Epler writes: > PS I don't recall what value of sizehint is used in 2.1, it was changed > when the patch was integreated, after some benchmarking on python-dev It looks like 8K in my recently updated copy from CVS. -- -- 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 piet at cs.uu.nl Thu Feb 22 15:59:26 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 22 Feb 2001 15:59:26 +0100 Subject: while loop with f.readline() References: <96d492$88c@dispatch.concentric.net> Message-ID: >>>>> Sean Reifschneider (SR) writes: SR> On Thu, Feb 15, 2001 at 01:22:39PM +0000, Jeff Epler wrote: >> I'd say, "xreadlines will never hold more than a few KB of the file >> in memory", but that's wrong if you have a file with a multi-megabyte line. SR> Say "xreadlines()" will never hold more than a single line of the file in SR> memory. Note the implications if you feed it a file with multi-megabyte SR> line(s). If you really want to be smart-assed you should note that that isn't entirely true: there will probably also be some buffer, which may contain more than one line. :=( -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From phlip_cpp at my-deja.com Wed Feb 14 15:10:34 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 14 Feb 2001 14:10:34 GMT Subject: while loop with f.readline() References: Message-ID: <96e3kq$3g5@dispatch.concentric.net> Proclaimed Chris Gonnerman from the mountaintops: > I have always been a fan of the FileReader class: > > class FileReader: > def __init__(self, file): > self.file = file > def next(self): > self.line = self.file.readline() > return self.line > > if __name__ == '__main__': > > f = FileReader(open("c:/autoexec.bat")) > > while f.next(): > print f.line, Came to the thread late can't read all posts don't know if this was covered so sue me but... ...what's wrong with this? for z in f.readlines(): print z That's how I done it since I was a chile'. -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- http://www.deja.com/my/pb.xp?member_name=phlip_cpp -- From db3l at fitlinxx.com Wed Feb 14 20:18:03 2001 From: db3l at fitlinxx.com (David Bolen) Date: 14 Feb 2001 14:18:03 -0500 Subject: while loop with f.readline() References: <96e3kq$3g5@dispatch.concentric.net> Message-ID: Phlip writes: > Came to the thread late can't read all posts don't know if this was covered > so sue me but... > > ...what's wrong with this? > > for z in f.readlines(): > print z > > That's how I done it since I was a chile'. Nothing "wrong" - but realize that doing it that way will read the entire file into memory (into the list object returned by readlines()) and then iterate over that object. Probably not be the best idea if you're looking at large files, but certainly doable for small to middling stuff. -- -- 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 mmiller3 at iupui.edu Thu Feb 15 18:49:11 2001 From: mmiller3 at iupui.edu (Michael A. Miller) Date: 15 Feb 2001 12:49:11 -0500 Subject: while loop with f.readline() References: Message-ID: <874rxv4z1k.fsf@lumen.med.iupui.edu> > From: "Chris Richard Adams" > I'm trying to create a loop that reads through a simple > file with strings on each line. Take a look at the fileinput module: import fileinput for line in fileinput.input('filename'): process(line) From ssthapa at classes.cs.uchicago.edu Tue Feb 13 20:14:26 2001 From: ssthapa at classes.cs.uchicago.edu (ssthapa at classes.cs.uchicago.edu) Date: Tue, 13 Feb 2001 19:14:26 GMT Subject: Siphon -- CPAN functionality for python Message-ID: I've registered the project with sourceforge but it won't be available until the project is approved which should take about a day or two. In the meantime, if anyone would like a early look, I'll be happy to email you a copy. Right now, there are a lot of stub functions where things are supposed to be but the core functionality should be there and you'll be able to see how the code fits together. -- ---------------------------------------------------------------------------- | 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 ljohnson at resgen.com Wed Feb 14 15:45:26 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Wed, 14 Feb 2001 08:45:26 -0600 Subject: Siphon -- CPAN functionality for python References: Message-ID: Suchandra, How do this project's goals coordinate with those of the Catalog SIG? http://www.python.org/sigs/catalog-sig/ Lyle wrote in message news:slrn98j244.234.ssthapa at ntcs-ip45.uchicago.edu... > I've registered the project with sourceforge but it won't be available > until the project is approved which should take about a day or two. In the > meantime, if anyone would like a early look, I'll be happy to email you > a copy. Right now, there are a lot of stub functions where things are > supposed to be but the core functionality should be there and you'll be > able to see how the code fits together. > > -- > -------------------------------------------------------------------------- -- > | > 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 chrisa at ASPATECH.COM.BR Tue Feb 13 20:20:50 2001 From: chrisa at ASPATECH.COM.BR (Chris Richard Adams) Date: Tue, 13 Feb 2001 16:20:50 -0300 Subject: Python & XML Message-ID: Hi all.. I have a tab seperated file that I would like to parse and store in XML format. file example: line1: 12:00:00 bob nassl.pdf 123.123.123.123 would like to create an xml file from this text file in the form bob nassl.pdf 123.123.123.123 Could someone advise me on how I might do this with Python...for example is there a utility to create XML doc like this. From paulp at ActiveState.com Tue Feb 13 19:44:11 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Tue, 13 Feb 2001 10:44:11 -0800 Subject: Python & XML References: Message-ID: <3A89807B.E49CF349@ActiveState.com> Chris Richard Adams wrote: > > Hi all.. > > > > I have a tab seperated file that I would like to parse and store in XML > > format. > > file example: > > line1: 12:00:00 bob nassl.pdf 123.123.123.123 > > would like to create an xml file from this text file in the form > > > > > > bob > > nassl.pdf > > 123.123.123.123 > > I would suggest something like this: time, name, file, ip = line.split("\t") print """ %s %s %s """ % (date, name, file, ip) I would discourage you from spending much effort looking for XML-specific ways to do things that you probably already know how to do. Reading an XML file is hard and should usually be done through a specialized module. Writing XML is easy so you often don't need a module. Paul Prescod From alet at unice.fr Wed Feb 14 11:07:44 2001 From: alet at unice.fr (Jerome Alet) Date: Wed, 14 Feb 2001 11:07:44 +0100 Subject: Python & XML References: Message-ID: <3A8A58F0.A3F32D81@unice.fr> Chris Richard Adams wrote: > I have a tab seperated file that I would like to parse and store in XML > format. > > line1: 12:00:00 bob nassl.pdf 123.123.123.123 > > would like to create an xml file from this text file in the form > > > > bob > nassl.pdf > 123.123.123.123 > I suggest you to download my GPLed jaxml module from: http://cortex.unice.fr/~jerome/jaxml-2.00beta1.tar.gz then: --- CUT --- import jaxml yourfile = open("inputfile.txt") doc = jaxml.XML_document() for line in yourfile.readlines() : time, name, file, ip = line.split("\t") # same as Paul doc._push() doc.upload().time(time).user(name).file(file).ip(ip) doc._pop() doc._output("outputfile.xml") # or: print doc --- CUT --- will produce exactly what you want, and is able of much more, without boring you with the indentation and closing tags if you want to have a human readable XML document: formatting is done automagically. This module also includes templating facilities and other goodies. You won't find something easier to use ! (or else just tell me) don't be afraid of the "beta1", it should be read as "final" ;-) Comments are very welcome. -- Jerome Alet - alet at unice.fr - http://cortex.unice.fr/~jerome Fac de Medecine de Nice http://wwwmed.unice.fr Tel: (+33) 4 93 37 76 30 Fax: (+33) 4 93 53 15 15 28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE From alet at unice.fr Wed Feb 14 11:10:22 2001 From: alet at unice.fr (Jerome Alet) Date: Wed, 14 Feb 2001 11:10:22 +0100 Subject: Python & XML References: <3A8A58F0.A3F32D81@unice.fr> Message-ID: <3A8A598E.7168AB0A@unice.fr> Jerome Alet wrote: > I suggest you to download my GPLed jaxml module from: > > http://cortex.unice.fr/~jerome/jaxml-2.00beta1.tar.gz Sorry, this url works, but the correct url is: http://cortex.unice.fr/~jerome/jaxml/jaxml-2.00beta1.tar.gz or: http://cortex.unice.fr/~jerome/jaxml/ if you want to read the README and NEWS (ChangeLog) files. -- Jerome Alet - alet at unice.fr - http://cortex.unice.fr/~jerome Fac de Medecine de Nice http://wwwmed.unice.fr Tel: (+33) 4 93 37 76 30 Fax: (+33) 4 93 53 15 15 28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE From pfenn at mmm.com Tue Feb 13 20:33:02 2001 From: pfenn at mmm.com (pfenn at mmm.com) Date: Tue, 13 Feb 2001 13:33:02 -0600 Subject: Controling types in PythonCOM Message-ID: Hello, I'm working with an ill behaved type library, where the ODL for a function specifies a variant integer, but by mucking around in Visual C++, I've determined that the function really needs a VT_I2. It appears that PythonCOM is attempting to pass a VT_I4 which causes an exception. I am using the makepy generated interface, and to make sure I'm doing this right, I'll show my code: from win32com.client import Dispatch xrf = Dispatch('XRaw.Xraw.1') # Invoked non-dynamically, right? This is the makepy generated interface for the problem function. I tried changing that first (12,17) to a (2,0) after looking at some functions that did have shorts for parameters but that didn't help. # The method GetChromatogram is actually a property, but must be used as a method to correctly pass the arguments def GetChromatogram(self, FilterIndex=defaultNamedOptArg, TraceSelector=defaultNamedOptArg, TimeRange=defaultNamedOptArg, Delay=defaultNamedOptArg): """property Chromatogram""" return self._ApplyTypes_(0x1e, 2, (12, 0), ((12, 17), (12, 17), (12, 17), (12, 17)), 'GetChromatogram', None,FilterIndex, TraceSelector, TimeRange, Delay) In case I'm interpreting my investigations incorrectly, here's the error I get in Python when I call this function: Traceback (most recent call last): File "C:\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript exec codeObject in __main__.__dict__ File "C:\Python20\xcalibur.py", line 146, in ? chro3 = df.MIC(1) File "C:\Python20\xcalibur.py", line 131, in MIC chrom = self.msdet.GetChromatogram(FilterIndex=mode) File "c: \python20\win32com\gen_py\2DDE1FB3-A60F-11D2-BD82-0060978EEB9Cx0x1x0.py", line 1415, in GetChromatogram return self._ApplyTypes_(0x1e, 2, (12, 0), ((12, 17), (12, 17), (12, 17), (12, 17)), 'GetChromatogram', None,FilterIndex, TraceSelector, TimeRange, Delay) File "C:\Python20\win32com\client\__init__.py", line 334, in _ApplyTypes_ return self._get_good_object_(apply(self._oleobj_.InvokeTypes, (dispid, 0, wFlags, retType, argTypes) + args), user, resultCLSID) com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147473646), None) If I wrap the type library with ATL in Visual C++, the following line generates a run time error: IXChromatogramPtr pChrom = pMSDetector->GetChromatogram((long) 1,vtMissing,vtMissing,vtMissing); but changing the type cast to (short) causes no error to occur. Thanks ahead of time, Tom From MarkH at ActiveState.com Wed Feb 14 00:05:15 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 13 Feb 2001 23:05:15 GMT Subject: Controling types in PythonCOM References: Message-ID: <3A89BCC9.2000807@ActiveState.com> pfenn at mmm.com wrote: > I'm working with an ill behaved type library, where the ODL for a function > specifies a variant integer, but by mucking around in Visual C++, I've > determined that the function really needs a VT_I2. It appears that > PythonCOM is attempting to pass a VT_I4 which causes an exception. I am > using the makepy generated interface, and to make sure I'm doing this > right, I'll show my code: Well that object sucks :) It should be capable of pulling an int out of any of the variant integer types. > from win32com.client import Dispatch > xrf = Dispatch('XRaw.Xraw.1') # Invoked non-dynamically, right? Assuming you have makepy pre-generated, yes. > This is the makepy generated interface for the problem function. I tried > changing that first (12,17) to a (2,0) after looking at some functions that > did have shorts for parameters but that didn't help. The 12 means VT_VARIANT. The 17 is PARAMFLAG_FOPT | PARAMFLAG_FIN So you probably should change it to (2,1) - ie (VT_I2, PARAMFLAG_FIN). You can't specificy FTOPT with a non variant arg. By passing (2,0) you _may_ have ended up with a byref int (as some code that sees no flags (ie, 0) gets conservative.) > com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, > -2147473646), None) This is certainly the COM object itself raising the error, not Python. Mark. -- Nominate Your Favorite Programmers for the Perl and Python Active Awards! http://www.ActiveState.com/Awards/ From bill.xu at newlix.com Tue Feb 13 20:40:33 2001 From: bill.xu at newlix.com (Bill Xu) Date: Tue, 13 Feb 2001 19:40:33 GMT Subject: What is wrong in my pulldom.startElement()? Message-ID: Hi, Gang: Will u please tell me how to use the pulldom.startElement() in the Python XML DOM? Following is my simple test program and result. Will u please tell me how to correct this bug? "AttributeError: 'None' object has no attribute 'createElement'"; Thanks in advance! Bill ===================================================== #!/usr/bin/python # import os, sys, string, StringIO import xml.dom from xml.dom import minidom from xml.dom.pulldom import PullDOM import traceback # Save the new message def test_meth(): print "Am i here" builder = PullDOM() builder.startElement("SET", {"PATH" : "a path"}) builder.endElement("SET") print "Am i here" confirm(builder) #result = self.Print(builder) def confirm(test, testname = "Test"): if test: print "Passed " + testname else: print "Failed " + testname raise Exception print "? am i herer" test_meth() ======================================================= Output: ? am i herer Am i here Traceback (innermost last): File "./testdom.py", line 34, in ? test_meth() File "./testdom.py", line 20, in test_meth builder.startElement("SET", {"PATH" : "a path"}) File "/usr/lib/python1.5/site-packages/xml/dom/pulldom.py", line 85, in startElement node = self.document.createElement(name) AttributeError: 'None' object has no attribute 'createElement' From loewis at informatik.hu-berlin.de Mon Feb 19 19:48:24 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 19 Feb 2001 19:48:24 +0100 Subject: What is wrong in my pulldom.startElement()? References: Message-ID: "Bill Xu" writes: > Will u please tell me how to use the pulldom.startElement() in the Python > XML DOM? > Following is my simple test program and result. > Will u please tell me how to correct this bug? > "AttributeError: 'None' object has no attribute 'createElement'"; I think you are using startElement itself quite correctly. However, you have to emulate exactly a SAX parser, i.e. first you need to invoke startDocument. Please note that pulldom is undocumented. I don't know what you are attempting to do, but using pulldom is most likely the wrong way. Regards, Martin From afonso at mac.com Tue Feb 13 21:06:51 2001 From: afonso at mac.com (Afonso Salcedo) Date: Tue, 13 Feb 2001 20:06:51 +0000 Subject: Help: NumTut and Macs... Message-ID: I'm having tons of trouble running the NumTut package that comes with the MacPython distribution. Every time I try even the simplest test sample: >>> from NumTut import * >>> view(greece) Everything hangs... I can't seem to understand what exactly is going on. As the view() would be useful to my work, is there any suggestion on what I should do? Thanks, Joe From rtrocca at libero.it Thu Feb 15 08:26:28 2001 From: rtrocca at libero.it (Riccardo Trocca) Date: Thu, 15 Feb 2001 07:26:28 GMT Subject: Help: NumTut and Macs... References: Message-ID: <1eouamj.1tldmrir6uaw0N%rtrocca@libero.it> Personal Experience: view does not work with macPython. I developed a solution for personal use that allows the user to visualize an 2d NumPy array as a GrayScale Image or a RGB Image in an IDE window. If interested I can send you the code. Riccardo Afonso Salcedo wrote: > I'm having tons of trouble running the NumTut package that comes with the > MacPython distribution. > > Every time I try even the simplest test sample: > > >>> from NumTut import * > >>> view(greece) > > Everything hangs... > > I can't seem to understand what exactly is going on. As the view() would be > useful to my work, is there any suggestion on what I should do? > > Thanks, > Joe From chrisa at ASPATECH.COM.BR Tue Feb 13 21:23:31 2001 From: chrisa at ASPATECH.COM.BR (Chris Richard Adams) Date: Tue, 13 Feb 2001 17:23:31 -0300 Subject: Parsing a line with Python Message-ID: Can anyone suggest a technique where I could parse through a line in a file and select individual strings? For example, I could process this email and put string in a list or temp storage. Thanks..in advance From tjreedy at udel.edu Tue Feb 13 21:29:59 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 13 Feb 2001 15:29:59 -0500 Subject: Parsing a line with Python References: Message-ID: <96c578$32k$1@news.udel.edu> "Chris Richard Adams" wrote in message news:mailman.982092035.18085.python-list at python.org... Can anyone suggest a technique where I could parse through a line in a file and select individual strings? For example, I could process this email and put string in a list or temp storage. Strings have match(), find(), and split() methods. There is also the re (relational expression) module for more complicated searches. From lreilly at cs.strath.ac.uk Tue Feb 13 21:36:40 2001 From: lreilly at cs.strath.ac.uk (Lee Reilly CS1997) Date: Tue, 13 Feb 2001 20:36:40 +0000 Subject: breasking out of a while loop (in an if statement) Message-ID: <3A899AD8.B4182CA4@cs.strath.ac.uk> Hi, I wonder if anyone could be kind enough to point out what I am doing wrong here (please see code below). The problem arises in the last 5 lines of code. 'result' is a database query result (type string). If it's empty then it has size==2 and if not then it's >=3. If it is empty then I have placed a return value after it. However, if it is not then I would like it to go back around the while loop. The code *looks* okay... -=---=-=--=-==-=-=-=-== while (j!=0): if (radiobutton=='comma'): tempString = string.split(text[i-1], ",") else: tempString = string.split(text[i-1], "\t") matric = string.rstrip(string.lstrip(tempString[0])) SQL = "select * from STUDENTS where matric= '" + matric + "'" result=db_conn.query(SQL) result = len(result) if (result>=3): return "Student with matric value " + matric + " already exists in the database" # break else: j=j-1 -=---=-=--=-==-=-=-=-== => Error Type: IndexError => Error Value: list index out of range I'm using Python with Zope BTW. Can anyone see my problem? Any help would be greatly appreciated ;-) - Best regards, Lee Reilly From hgg9140 at seanet.com Wed Feb 14 01:43:17 2001 From: hgg9140 at seanet.com (Harry George) Date: 13 Feb 2001 16:43:17 -0800 Subject: breasking out of a while loop (in an if statement) References: <3A899AD8.B4182CA4@cs.strath.ac.uk> Message-ID: You don't indicate how "text" is initialized, nor why you are using "i" to index it and "j" as your loop counter. Probably something funny there, because the "index out of range" is either those accesses or the resulting tempString array access. As for the loop itself, "j>0" might be safer than "j!=0", because you might come in with a negative number. Next, I'd print out the result value to see what it *really* is -- there may be conditions where it doesn't act the way you expect. Lee Reilly CS1997 writes: > Hi, I wonder if anyone could be kind enough to point out what I am doing > wrong here (please see code below). > > The problem arises in the last 5 lines of code. 'result' is a database > query result (type string). If it's empty then it has size==2 and if not > then it's >=3. If it is empty then I have placed a return value after > it. However, if it is not then I would like it to go back around the > while loop. The code *looks* okay... > > -=---=-=--=-==-=-=-=-== > while (j!=0): > if (radiobutton=='comma'): > tempString = string.split(text[i-1], ",") > else: > tempString = string.split(text[i-1], "\t") > > matric = string.rstrip(string.lstrip(tempString[0])) > SQL = "select * from STUDENTS where matric= '" + matric + "'" > result=db_conn.query(SQL) > result = len(result) > if (result>=3): > return "Student with matric value " + matric + " already exists > in the database" > # break > else: > j=j-1 > -=---=-=--=-==-=-=-=-== > > => Error Type: IndexError > => Error Value: list index out of range > > I'm using Python with Zope BTW. > > Can anyone see my problem? Any help would be greatly appreciated ;-) > > - Best regards, > Lee Reilly -- Harry George hgg9140 at seanet.com From db3l at fitlinxx.com Wed Feb 14 02:18:45 2001 From: db3l at fitlinxx.com (David Bolen) Date: 13 Feb 2001 20:18:45 -0500 Subject: breasking out of a while loop (in an if statement) References: <3A899AD8.B4182CA4@cs.strath.ac.uk> Message-ID: Lee Reilly CS1997 writes: > Hi, I wonder if anyone could be kind enough to point out what I am doing > wrong here (please see code below). (...) > -=---=-=--=-==-=-=-=-== > while (j!=0): > if (radiobutton=='comma'): > tempString = string.split(text[i-1], ",") > else: > tempString = string.split(text[i-1], "\t") > > matric = string.rstrip(string.lstrip(tempString[0])) > SQL = "select * from STUDENTS where matric= '" + matric + "'" > result=db_conn.query(SQL) > result = len(result) > if (result>=3): > return "Student with matric value " + matric + " already exists > in the database" > # break > else: > j=j-1 > -=---=-=--=-==-=-=-=-== > > => Error Type: IndexError > => Error Value: list index out of range > > I'm using Python with Zope BTW. > > Can anyone see my problem? Any help would be greatly appreciated ;-) It would help to have the full traceback since that would highlight the line where the actual error is occuring. Also, it looks like this code depends on surrounding code (e.g., where is "i" or "text" set?), so having more detail about that surrounding code might help. But given the error, and assuming that the error is actually within this specific code, then it would seem to me to either be arising from your reference to "text[i-1]" or "tempString[0]". In the former case, you should verify that "text" has the contents you expect and that it has enough entries in any pass through the loop as indexed by "i-1". I think the latter case is safe, since from what I can see, using string.split with a dividing character will always at least produce a single entry in the list, although it may be an empty string. But you might want to verify it in this actual code as well, since at least in Python 1.5.2, string.split does return an empty list (e.g., if I split an empty string on the default separator) in some cases, which could then yield the IndexError when you try to access element 0. -- -- 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 bshapiro at funnygarbage.com Tue Feb 13 22:03:04 2001 From: bshapiro at funnygarbage.com (Ben Shapiro) Date: Tue, 13 Feb 2001 16:03:04 -0500 Subject: Please Help: COM Events Message-ID: <96c7de$mb9$1@bob.news.rcn.net> Hi all I am having a problem with COM events. I am using the JabberCOM library. This library contains a bunch of classes such as JabberSession and JabberMsg. I create the object with: JabberCtl = win32com.client.DispatchWithEvents('JabberCOM.JabberSession',JabberEvts) the JabberEvts class is registered to handle events for this object.... The problem is this.... in the JabberEvts Class i have the following method that gets triggered every time a message arrives: def OnMessage(self, Msg, Tag): print "I made it this far ---" #---this works print Msg.MsgType #--- never executes In this method, Msg is an object of type JabberMsg when i do a print Msg, python reports that it is an IDispatch Seems to me that when the event handler is called, the argument passed in loses it's type as a JabberMsg and becomes a generic Dispatch object so i can't call properties or methods on it.. Is there any way to cast the argument back to a JabberMsg object? thx for any help Ben From MarkH at ActiveState.com Wed Feb 14 00:07:29 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 13 Feb 2001 23:07:29 GMT Subject: Please Help: COM Events References: <96c7de$mb9$1@bob.news.rcn.net> Message-ID: <3A89BD4F.3040708@ActiveState.com> Ben Shapiro wrote: > Seems to me that when the event handler is called, the argument passed in > loses it's type as a JabberMsg and becomes a generic Dispatch object > so i can't call properties or methods on it.. Is there any way to cast the > argument back to a JabberMsg object? You should be able to say: Msg = win32com.client.Dispatch(Msg) However, event handlers are supposed to do this for you automatically. Hrm. No time to investigate ATM - I am busy adding support for vtable implemented interfaces to win32com ;-) Mark. -- Nominate Your Favorite Programmers for the Perl and Python Active Awards! http://www.ActiveState.com/Awards/ From urner at alumni.princeton.edu Tue Feb 13 22:04:51 2001 From: urner at alumni.princeton.edu (Kirby Urner) Date: Tue, 13 Feb 2001 13:04:51 -0800 Subject: math through programming Message-ID: [ below is my most recent post to math-learn, clearly a response to something earlier -- but with enough standalone content to give the idea. Earlier posts in the same thread include Python source code for computing Pascal's Triangle and comparing the results with balls randomly falling, pachinko-style, through a triangulated grid of pins (some of you may have seen the well-known science museum demo showing the bell curved result). Thanks again to Tim Peters for cluing me re 'Concrete Mathematics' which I went out and grabbed some months ago (if edu-sig had a search feature, I'd go find where he first posted about it, as an easier intro than Knuth's "telegraphic" 'Art of Computer Programming' -- and indeed, that's how this text evolved, from notes around the mathematical preliminaries leading into Knuth's magnum opus). I'm cross-posting this here as a snap-shot of my ongoing effort to combine the math learning process with a strong programming element, to create a hybrid more adapted to life in the 21st century. The mass-education juggernaut has too much inertia to steer in this new direction any time soon, but there's always the hope that more alert passengers will jump overboard and swim for their lives :-D (good to have this alternative more seaworthy craft in the vicinity, given the more conventional curriculum simply isn't). complete thread: http://www.mathforum.com/epigone/math-learn/snoipumkhee Kirby ] Subject: [math-learn] Re: Intro to Probability Author: pdx4d at teleport.com Date: Tue, 13 Feb 2001 16:33:03 -0000 > So the short way to write (n-k+1)! is just n!/(n-k)! as ^^^^^^^^^^^^^^^^^^^^^^^^^^ > that cancels all terms except n(n-1)(n-2)..(n-k+1). Right, a typo, thanks to a close reader for catching that. What I wanted to express with (n-k+1)! were the k terms in n(n-1)...(n-k+1), but of course these aren't equivalent. What I need is notation to expressing a "falling factorial" running for k terms, and, indeed, such notation is offered in 'Concrete Mathematics' by Graham Knuth and Patashnik (Addison-Wesley, 1994), pp 47-48. The notation can't easily be written in ascii unfortunately, but "n to the m falling" is written [n to the m-underbar]. With "n to the m rising" = [n to the m_overbar]. "These functions are also called 'falling factorial powers' and 'rising factorial powers', since they are closely related to the factorial function n! = n(n-1)...(1). In fact n! = [n to the n-underbar] = [1 to the n- overbar]." So anyway, what I should have written was [n to the k-underbar]. This book 'Concrete Mathematics' I've mentioned before on math-teach, as exemplary of what I'm aiming for at the college level with my K-12 curriculum writing. It's used for computer science students a lot, but it's also just a fine introduction to a lot of concrete (not too abstract) mathematics, including discrete probability, binomial coefficients and elementary number theory. I'm also trying to boost geometry content, by moving 'Beyond Flatland' (off the plane) -- which links to a 'Beyond Calculators' push as well (as I haven't seen many rotating polyhedra on calculator screens -- though maybe these have appeared in Japan by this time, a market typically ahead of the USA's in the calculator department). As I wrote to a math educator recently by email: You may remember from emails past that I'm one of those looking for ways to incorporate more of Bucky Fuller's contributions into early math ed. I also push a "math through programming" approach, and converge it with the Fuller-informed spatial geometry. "Beyond Flatland" and "Beyond Calculators" summarize my two pronged strategy to revamp math ed pedagogy. I've just put up a new essay, well-illustrated, which looks at the "Beyond Flatland" approach: http://www.inetarena.com/~pdx4d/ocn/overview.html And here's a review of my "Beyond Calculators" initiative: http://www.oreillynet.com/pub/a/python/2000/10/04/pythonnews.html Kirby From sandysj at asme.org Wed Feb 14 17:48:20 2001 From: sandysj at asme.org (Jeff Sandys) Date: Wed, 14 Feb 2001 16:48:20 GMT Subject: math through programming References: Message-ID: <3A8AB6D4.3216FC3E@asme.org> I am cross posting this to comp.lang.logo to expose the Logo community to python and "Computer Programming for Everyone" (CP4E). My view of Logo is a mathematical playground. I still believe that it is a better language for young students (I like working with 9 year old and above), and it embraces different learning styles with a cleaner and more forgiving syntax. The advantage of python is object programming, which some Logo languages have, and a skill that can be used later. While the learning processes developed with Logo translate to other programming languages and to thinking in general, I have never seen any commercial applications or job openings for Logo. What python is missing is a course outline that is age appropriate and accommodates different learning styles. I am eager to try python on some middle school students in an after school programming club, but without a plan I will stick to tried and proven Logo. Thanks, Jeff Sandys Kirby Urner wrote: > > [ > > below is my most recent post to math-learn, clearly a > response to something earlier -- but with enough standalone > content to give the idea. > > Earlier posts in the same thread include Python source > code for computing Pascal's Triangle and comparing the > results with balls randomly falling, pachinko-style, > through a triangulated grid of pins (some of you may have > seen the well-known science museum demo showing the bell > curved result). > > Thanks again to Tim Peters for cluing me re 'Concrete > Mathematics' which I went out and grabbed some months ago > (if edu-sig had a search feature, I'd go find where he > first posted about it, as an easier intro than Knuth's > "telegraphic" 'Art of Computer Programming' -- and indeed, > that's how this text evolved, from notes around the > mathematical preliminaries leading into Knuth's magnum > opus). > > I'm cross-posting this here as a snap-shot of my ongoing > effort to combine the math learning process with a > strong programming element, to create a hybrid more > adapted to life in the 21st century. The mass-education > juggernaut has too much inertia to steer in this new > direction any time soon, but there's always the hope > that more alert passengers will jump overboard and swim > for their lives :-D (good to have this alternative more > seaworthy craft in the vicinity, given the more > conventional curriculum simply isn't). > > complete thread: > http://www.mathforum.com/epigone/math-learn/snoipumkhee > > Kirby > > ] > > Subject: [math-learn] Re: Intro to Probability > Author: pdx4d at teleport.com > Date: Tue, 13 Feb 2001 16:33:03 -0000 > > > So the short way to write (n-k+1)! is just n!/(n-k)! as > ^^^^^^^^^^^^^^^^^^^^^^^^^^ > > > that cancels all terms except n(n-1)(n-2)..(n-k+1). > > Right, a typo, thanks to a close reader for catching that. What I > wanted to express with (n-k+1)! were the k terms in n(n-1)...(n-k+1), > but of course these aren't equivalent. What I need is notation to > expressing a "falling factorial" running for k terms, and, indeed, > such notation is offered in 'Concrete Mathematics' by Graham Knuth > and Patashnik (Addison-Wesley, 1994), pp 47-48. > > The notation can't easily be written in ascii unfortunately, but > "n to the m falling" is written [n to the m-underbar]. With "n to > the m rising" = [n to the m_overbar]. "These functions are also > called 'falling factorial powers' and 'rising factorial powers', > since they are closely related to the factorial function n! = > n(n-1)...(1). In fact n! = [n to the n-underbar] = [1 to the n- > overbar]." > > So anyway, what I should have written was [n to the k-underbar]. > > This book 'Concrete Mathematics' I've mentioned before on math-teach, > as exemplary of what I'm aiming for at the college level with my > K-12 curriculum writing. It's used for computer science students > a lot, but it's also just a fine introduction to a lot of concrete > (not too abstract) mathematics, including discrete probability, > binomial coefficients and elementary number theory. > > I'm also trying to boost geometry content, by moving 'Beyond > Flatland' (off the plane) -- which links to a 'Beyond Calculators' > push as well (as I haven't seen many rotating polyhedra on > calculator screens -- though maybe these have appeared in Japan > by this time, a market typically ahead of the USA's in the > calculator department). > > As I wrote to a math educator recently by email: > > You may remember from emails past that I'm one of those > looking for ways to incorporate more of Bucky Fuller's > contributions into early math ed. I also push a "math > through programming" approach, and converge it with the > Fuller-informed spatial geometry. "Beyond Flatland" and > "Beyond Calculators" summarize my two pronged strategy > to revamp math ed pedagogy. > > I've just put up a new essay, well-illustrated, which > looks at the "Beyond Flatland" approach: > http://www.inetarena.com/~pdx4d/ocn/overview.html > > And here's a review of my "Beyond Calculators" initiative: > http://www.oreillynet.com/pub/a/python/2000/10/04/pythonnews.html > > Kirby From jsteve17 at tampabay.rr.com Tue Feb 13 22:32:15 2001 From: jsteve17 at tampabay.rr.com (Jeff Stephens) Date: Tue, 13 Feb 2001 21:32:15 GMT Subject: Changing Fonts in IDLE-0.5 Message-ID: <3A89A78F.C4C6B70A@tampabay.rr.com> I am just starting out with Python and was trying to use idle, but the fonts are so small it's giving me a headache. I followed the instructions in the help menu and tried editing the 'EditorWindow.py' file to no avail. I commented out the first line and uncommented the second as recommended: no change. I tried changing the sizes of both fonts to 10, 12: no change. The only thing I can figure is that idle is using some default that is not reflected by either of these lines. Can someone help before I go blind. Thanks. Regards, Jeff Stephens From DanielK at jBASE.com Tue Feb 13 23:39:51 2001 From: DanielK at jBASE.com (Daniel Klein) Date: Tue, 13 Feb 2001 14:39:51 -0800 Subject: Changing Fonts in IDLE-0.5 References: <3A89A78F.C4C6B70A@tampabay.rr.com> Message-ID: <%Oii6.238$Vf.9579@typhoon.aracnet.com> Jeff, You got me curious about this so after a minute of digging, I found two files, 'config-unix.txt' and 'config-win.txt' in the '/python20/tools/idle' (or C:\python20\tools\idle) directory. It is in these files (depending on your platform) where the font size can be changed. Hope this helps, Daniel Klein Portland OR USA "Jeff Stephens" wrote in message news:3A89A78F.C4C6B70A at tampabay.rr.com... > I am just starting out with Python and was trying to use idle, but the > fonts > are so small it's giving me a headache. I followed the instructions in > the > help menu and tried editing the 'EditorWindow.py' file to no avail. I > commented > out the first line and uncommented the second as recommended: no change. > I tried > changing the sizes of both fonts to 10, 12: no change. The only thing I > can figure is > that idle is using some default that is not reflected by either of these > lines. Can someone > help before I go blind. Thanks. > > Regards, > Jeff Stephens > From jsteve17 at tampabay.rr.com Wed Feb 14 02:51:57 2001 From: jsteve17 at tampabay.rr.com (Jeff Stephens) Date: Wed, 14 Feb 2001 01:51:57 GMT Subject: Changing Fonts in IDLE-0.5 References: <3A89A78F.C4C6B70A@tampabay.rr.com> <%Oii6.238$Vf.9579@typhoon.aracnet.com> Message-ID: <3A89E46C.A081293F@tampabay.rr.com> Daniel Klein wrote: > Jeff, > > You got me curious about this so after a minute of digging, I found two > files, 'config-unix.txt' and 'config-win.txt' in the '/python20/tools/idle' > (or C:\python20\tools\idle) directory. It is in these files (depending on > your platform) where the font size can be changed. > > Hope this helps, > > Daniel Klein > Portland OR USA > I'm running on Linux, specifically, Redhat 6.2. I don't have either of these files. Here are the files in my idle-0.5 directory: AutoExpand.py IdleHistory.pyc Separator.py AutoExpand.pyc IdlePrefs.py StackViewer.py AutoIndent.py IdlePrefs.pyc TODO.txt AutoIndent.pyc MultiScrolledLists.py ToolTip.py Bindings.py MultiStatusBar.py TreeWidget.py Bindings.pyc MultiStatusBar.pyc UndoDelegator.py CallTipWindow.py NEWS.txt UndoDelegator.pyc CallTips.py ObjectBrowser.py WidgetRedirector.py CallTips.pyc OldStackViewer.py WidgetRedirector.pyc ChangeLog OutputWindow.py WindowList.py ClassBrowser.py OutputWindow.pyc WindowList.pyc ColorDelegator.py PathBrowser.py ZoomHeight.py ColorDelegator.pyc Percolator.py ZoomHeight.pyc Debugger.py Percolator.pyc __init__.py Delegator.py PyParse.py eventparse.py Delegator.pyc PyParse.pyc extend.py EditorWindow.py PyShell.py extend.pyc EditorWindow.pyc PyShell.pyc extend.txt FileList.py README.txt help.txt FileList.pyc ReplaceDialog.py idle.bat FormatParagraph.py ScriptBinding.py idle.py FormatParagraph.pyc ScriptBinding.pyc idle.pyw FrameViewer.py ScrolledList.py idlever.py GrepDialog.py SearchBinding.py idlever.pyc IOBinding.py SearchBinding.pyc keydefs.py IOBinding.pyc SearchDialog.py keydefs.pyc Icons SearchDialogBase.py pyclbr.py IdleHistory.py SearchEngine.py testcode.py Any other ideas? > > "Jeff Stephens" wrote in message > news:3A89A78F.C4C6B70A at tampabay.rr.com... > > I am just starting out with Python and was trying to use idle, but the > > fonts > > are so small it's giving me a headache. I followed the instructions in > > the > > help menu and tried editing the 'EditorWindow.py' file to no avail. I > > commented > > out the first line and uncommented the second as recommended: no change. > > I tried > > changing the sizes of both fonts to 10, 12: no change. The only thing I > > can figure is > > that idle is using some default that is not reflected by either of these > > lines. Can someone > > help before I go blind. Thanks. > > > > Regards, > > Jeff Stephens > > From dan at eevolved.com Wed Feb 14 03:48:42 2001 From: dan at eevolved.com (Dan Parisien) Date: Wed, 14 Feb 2001 02:48:42 GMT Subject: Changing Fonts in IDLE-0.5 References: <3A89A78F.C4C6B70A@tampabay.rr.com> <%Oii6.238$Vf.9579@typhoon.aracnet.com> <3A89E46C.A081293F@tampabay.rr.com> Message-ID: try doing # grep "font" * inside your idle/ directory Dan From jsteve17 at tampabay.rr.com Wed Feb 14 04:17:27 2001 From: jsteve17 at tampabay.rr.com (Jeff Stephens) Date: Wed, 14 Feb 2001 03:17:27 GMT Subject: Changing Fonts in IDLE-0.5 References: <3A89A78F.C4C6B70A@tampabay.rr.com> <%Oii6.238$Vf.9579@typhoon.aracnet.com> <3A89E46C.A081293F@tampabay.rr.com> Message-ID: <3A89F875.BD37A431@tampabay.rr.com> Dan Parisien wrote: > try doing > > # grep "font" * > > inside your idle/ directory > > Dan Already did. The only entries for font are in EditorWindow.py and EditorWindow.pyc. The latter file can't be viewed in an editor. I suspect it's some sort of compiled version of the .py file. From dan at eevolved.com Wed Feb 14 06:41:11 2001 From: dan at eevolved.com (Dan Parisien) Date: Wed, 14 Feb 2001 05:41:11 GMT Subject: Changing Fonts in IDLE-0.5 References: <3A89A78F.C4C6B70A@tampabay.rr.com> <%Oii6.238$Vf.9579@typhoon.aracnet.com> <3A89E46C.A081293F@tampabay.rr.com> <3A89F875.BD37A431@tampabay.rr.com> Message-ID: Jeff Stephens wrote: > Already did. The only entries for font are in EditorWindow.py and > EditorWindow.pyc. The latter file can't be viewed in > an editor. I suspect it's some sort of compiled version of the .py > file. > Yep. It's the byte-compiled python source (it's faster for python to load). A mad-hack you could pull is changing line 152: text['font'] = edconf.get('font-name'), edconf.get('font-size') with text['font'] = "courier", "12" I hope it works :) Dan From martin.franklin at westerngeco.com Wed Feb 14 09:33:09 2001 From: martin.franklin at westerngeco.com (Martin Franklin) Date: Wed, 14 Feb 2001 08:33:09 +0000 Subject: Changing Fonts in IDLE-0.5 References: <3A89A78F.C4C6B70A@tampabay.rr.com> <%Oii6.238$Vf.9579@typhoon.aracnet.com> <3A89E46C.A081293F@tampabay.rr.com> <3A89F875.BD37A431@tampabay.rr.com> Message-ID: <3A8A42C5.A4A0A56C@westerngeco.com> With idle 0.5 you should take a look around line 141 in EditorWindow.py change this..... if sys.platform[:3] == 'win': text['font'] = ("lucida console", 8) to just this..... text['font'] = ("Courier ", 24) 24 may be a little too big but you get the idea. You should consider upgrading to python 2.0 and idle 0.6 Martin. Dan Parisien wrote: > > Jeff Stephens wrote: > > Already did. The only entries for font are in EditorWindow.py and > > EditorWindow.pyc. The latter file can't be viewed in > > an editor. I suspect it's some sort of compiled version of the .py > > file. > > > Yep. It's the byte-compiled python source (it's faster for python to load). > > A mad-hack you could pull is changing line 152: > > text['font'] = edconf.get('font-name'), edconf.get('font-size') > > with > > text['font'] = "courier", "12" > > I hope it works :) > > Dan > -- > http://mail.python.org/mailman/listinfo/python-list From jsteve17 at tampabay.rr.com Wed Feb 14 19:20:54 2001 From: jsteve17 at tampabay.rr.com (Jeff Stephens) Date: Wed, 14 Feb 2001 18:20:54 GMT Subject: Changing Fonts in IDLE-0.5 References: <3A89A78F.C4C6B70A@tampabay.rr.com> <%Oii6.238$Vf.9579@typhoon.aracnet.com> <3A89E46C.A081293F@tampabay.rr.com> <3A89F875.BD37A431@tampabay.rr.com> Message-ID: <3A8ACC32.5CE1C9B4@tampabay.rr.com> Martin Franklin wrote: > With idle 0.5 you should take a look around line 141 in > EditorWindow.py > > change this..... > > if sys.platform[:3] == 'win': > text['font'] = ("lucida console", 8) > > to just this..... > > text['font'] = ("Courier ", 24) > > 24 may be a little too big but you get the idea. > > You should consider upgrading to python 2.0 and idle 0.6 > > Martin. > Well, this seems to be trying to work, except that I think that the syntax for selecting the font must be off. Here is the error I get after commenting out the "if sys.platform...." statement: Traceback (innermost last): File "./idle.py", line 2, in ? import PyShell File "./PyShell.py", line 15, in ? from EditorWindow import EditorWindow, fixwordbreaks File "./EditorWindow.py", line 142 text['font'] = ("times adobe", 14) ^ SyntaxError: invalid syntax Maybe I should try Python 2.0. > > Dan Parisien wrote: > > > > Jeff Stephens wrote: > > > Already did. The only entries for font are in EditorWindow.py and > > > EditorWindow.pyc. The latter file can't be viewed in > > > an editor. I suspect it's some sort of compiled version of the .py > > > file. > > > > > Yep. It's the byte-compiled python source (it's faster for python to load). > > > > A mad-hack you could pull is changing line 152: > > > > text['font'] = edconf.get('font-name'), edconf.get('font-size') > > > > with > > > > text['font'] = "courier", "12" > > > > I hope it works :) > > > > Dan > > -- > > http://mail.python.org/mailman/listinfo/python-list From db3l at fitlinxx.com Wed Feb 14 21:45:32 2001 From: db3l at fitlinxx.com (David Bolen) Date: 14 Feb 2001 15:45:32 -0500 Subject: Changing Fonts in IDLE-0.5 References: <3A89A78F.C4C6B70A@tampabay.rr.com> <%Oii6.238$Vf.9579@typhoon.aracnet.com> <3A89E46C.A081293F@tampabay.rr.com> <3A89F875.BD37A431@tampabay.rr.com> <3A8ACC32.5CE1C9B4@tampabay.rr.com> Message-ID: Jeff Stephens writes: > Well, this seems to be trying to work, except that I think that the > syntax for selecting the font must be off. Here is the error I get > after commenting out the "if sys.platform...." statement: > > Traceback (innermost last): > File "./idle.py", line 2, in ? > import PyShell > File "./PyShell.py", line 15, in ? > from EditorWindow import EditorWindow, fixwordbreaks > File "./EditorWindow.py", line 142 > text['font'] = ("times adobe", 14) > ^ > SyntaxError: invalid syntax You might want to include a snippet of what the file actually looks like after your changes, including a few of the surrounding lines - there may be an indentation problem depending on what precisely you commented out. Make sure that your new line is at the same indentation level as the surrounding lines (and to be safe only use spaces, don't try to mix in tabs). -- -- 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 greg at cosc.canterbury.ac.nz Fri Feb 16 03:46:33 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 16 Feb 2001 15:46:33 +1300 Subject: Changing Fonts in IDLE-0.5 References: <3A89A78F.C4C6B70A@tampabay.rr.com> <%Oii6.238$Vf.9579@typhoon.aracnet.com> <3A89E46C.A081293F@tampabay.rr.com> <3A89F875.BD37A431@tampabay.rr.com> <3A8ACC32.5CE1C9B4@tampabay.rr.com> Message-ID: <3A8C9489.6A25D804@cosc.canterbury.ac.nz> Jeff Stephens wrote: > > File "./EditorWindow.py", line 142 > text['font'] = ("times adobe", 14) > ^ > SyntaxError: invalid syntax Looks like an indentation problem. Make sure you indent the line exactly the same way as it was previously. You sound like you're new to Python, so you need to be aware that indentation is syntactically significant in Python. -- 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 pod at merlin.net.au Wed Feb 14 12:40:26 2001 From: pod at merlin.net.au (PoD) Date: Wed, 14 Feb 2001 22:10:26 +1030 Subject: Changing Fonts in IDLE-0.5 References: <3A89A78F.C4C6B70A@tampabay.rr.com> <%Oii6.238$Vf.9579@typhoon.aracnet.com> <3A89E46C.A081293F@tampabay.rr.com> Message-ID: <3A8A6EAA.9E749052@merlin.net.au> Jeff Stephens wrote: > > Daniel Klein wrote: > > > Jeff, > > > > You got me curious about this so after a minute of digging, I found two > > files, 'config-unix.txt' and 'config-win.txt' in the '/python20/tools/idle' > > (or C:\python20\tools\idle) directory. It is in these files (depending on > > your platform) where the font size can be changed. > > > > Hope this helps, > > > > Daniel Klein > > Portland OR USA > > > > I'm running on Linux, specifically, Redhat 6.2. I don't have either of these > files. Here are the > files in my idle-0.5 directory: > Here are the config files from my idle directory from Python-2.0, you never know, they may work. -------------- next part -------------- # IDLE reads several config files to determine user preferences. This # file is the default config file. When IDLE starts, it will look in # the following four files in order: # config.txt the default config file # config-[win/unix/mac].txt the generic platform config file # config-[sys.platform].txt the specific platform config file # ~/.idle the user config file # XXX what about Windows? # # The last definition of each option is used. For example, you can # override the default window size (80x24) by defining width and # height options in the EditorWindow section of your ~/.idle file # # IDLE extensions can be enabled and disabled by adding them to one of # the config files. To enable an extension, create a section with the # same name as the extension, e.g. the [ParenMatch] section below. To # disable an extension, either remove the section or add the 'enable' # option with the value 0. [EditorWindow] width= 80 height= 24 # fonts defined in config-[win/unix].txt [Colors] normal-foreground= black normal-background= white # These color types are not explicitly defined= sync, todo, stdin keyword-foreground= #ff7700 comment-foreground= #dd0000 string-foreground= #00aa00 definition-foreground= #0000ff hilite-foreground= #000068 hilite-background= #006868 break-foreground= #ff7777 hit-foreground= #ffffff hit-background= #000000 stdout-foreground= blue stderr-foreground= red console-foreground= #770000 error-background= #ff7777 cursor-background= black [SearchBinding] [AutoIndent] [AutoExpand] [FormatParagraph] [ZoomHeight] [ScriptBinding] [CallTips] [ParenMatch] enable= 0 style= expression flash-delay= 500 bell= 1 hilite-foreground= black hilite-background= #43cd80 -------------- next part -------------- [EditorWindow] font-name= courier font-size= 12 From DanielK at jBASE.com Wed Feb 14 00:07:06 2001 From: DanielK at jBASE.com (Daniel Klein) Date: Tue, 13 Feb 2001 15:07:06 -0800 Subject: SocketServer inconsistencies Message-ID: I am attempting to write some socket code which must be platform indepent and the following behavior indicates that I can't use the SocketServer module as I had hoped to do. On Linux using Python 1.5.2, 'import SocketServer' correctly imports into the global namespace. On Windows, using Python 2.0, the same command returns >>> import SocketServer Traceback (innermost last): File "", line 1, in ? import SocketServer NameError: Case mismatch for module name SocketServer (filename C:\DanielK\python\socketserver.py) ...however when I try 'import socketserver' (note the case of the command), it actually _starts_ the server, ie >>> import socketserver Waiting for a connection... I know I'm using different version on the different platforms but could someone please advise how to use the SocketServer module on Windows please? Has the implementation changed from 1.5.2 to 2.0? Please forgive my naivety if the answer is obvious but this is a serious problem for me. If I can't use the SocketServer module on Windows, I have to go back to the drawing board and see what I would need to do to use the lower level 'socket' module (which will require a great deal more work, especially since I am new to network programming). :^( Thanks for listening, and hopefully for an answer, Daniel Klein From spam at spam.com Wed Feb 14 01:00:26 2001 From: spam at spam.com (Penfold) Date: Wed, 14 Feb 2001 00:00:26 -0000 Subject: SocketServer inconsistencies References: Message-ID: There is no *inconsistency* between the platforms. It seems to me that you've taken the somewhat dubious step of naming the test script that you are using "socketserver.py", or at least one of *your* modules is named that ... note your error > NameError: Case mismatch for module name SocketServer > (filename C:\DanielK\python\socketserver.py) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ When you import modules, python searches for them on its path (sys.path, $PYTHONPATH etc). It looks in the directory of the script it is running before looking in the library. Now on linux this is fine ... it looks in the scripts directory for SocketServer and never finds it (as it is called socketserver which is a different name on *nix). On windows however it strikes a problem. To Windows, there is no case sensitivity in filenames, so to all intents and purposes it cant tell the difference between SocketServer --- so it imports *your* module (not the library one). But then its smart enought to figure out that its not quite making sense ... Now if you import socketserver it of course just runs any code in *your* socketserver program so its your own fault if thats gone and done something ! [learn about the __name__ == '__main__': pydiom] So ... solution, call your modules something better than socketserver ... on windows choosing a module name the same as library module when case is ignored is just asking for problems. On linux of course you would have had a similar problem if you had called your module SocketServer.py [would you call one of your own modules sys.py or os.py or string.py ?? i hope not ;-)] Have a nice day D "Daniel Klein" wrote in message news:ycji6.241$Vf.9600 at typhoon.aracnet.com... > I am attempting to write some socket code which must be platform indepent > and the following behavior indicates that I can't use the SocketServer > module as I had hoped to do. > > On Linux using Python 1.5.2, 'import SocketServer' correctly imports into > the global namespace. On Windows, using Python 2.0, the same command returns > > >>> import SocketServer > Traceback (innermost last): > File "", line 1, in ? > import SocketServer > NameError: Case mismatch for module name SocketServer > (filename C:\DanielK\python\socketserver.py) > > ...however when I try 'import socketserver' (note the case of the command), > it actually _starts_ the server, ie > > >>> import socketserver > Waiting for a connection... > > I know I'm using different version on the different platforms but could > someone please advise how to use the SocketServer module on Windows please? > Has the implementation changed from 1.5.2 to 2.0? > > Please forgive my naivety if the answer is obvious but this is a serious > problem for me. If I can't use the SocketServer module on Windows, I have to > go back to the drawing board and see what I would need to do to use the > lower level 'socket' module (which will require a great deal more work, > especially since I am new to network programming). :^( > > Thanks for listening, and hopefully for an answer, > > Daniel Klein > > > From DanielK at jBASE.com Wed Feb 14 01:18:45 2001 From: DanielK at jBASE.com (Daniel Klein) Date: Tue, 13 Feb 2001 16:18:45 -0800 Subject: SocketServer inconsistencies References: Message-ID: Big slap on forehead!!!! :^( This is one lesson I will NEVER forget. Thanks to you and /F I am now a happy parrot instead of a dead one. :^) Dan "I shot an error into the air. It's still going everywhere." "Penfold" wrote in message news:t8jisec2vrr24 at corp.supernews.com... > There is no *inconsistency* between the platforms. It seems to me that > you've taken the somewhat dubious step > of naming the test script that you are using "socketserver.py", or at least > one of *your* modules is named that ... > note your error > > > NameError: Case mismatch for module name SocketServer > > (filename C:\DanielK\python\socketserver.py) > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > When you import modules, python searches for them on its path (sys.path, > $PYTHONPATH etc). It looks in the directory of the script it is running > before looking in the library. Now on linux this is fine ... it looks in > the scripts directory for SocketServer and never finds it (as it is called > socketserver which is a different name on *nix). On windows however it > strikes a problem. To Windows, there is no case sensitivity in filenames, > so to all intents and purposes it cant tell the difference between > SocketServer --- so it imports *your* module (not the library one). But > then its smart enought to figure out that its not quite making sense ... Now > if you import socketserver it of course just runs any code in *your* > socketserver program so its your own fault if thats gone and done something > ! [learn about the __name__ == '__main__': pydiom] > > So ... solution, call your modules something better than socketserver ... on > windows choosing a module name the same as library module when case is > ignored is just asking for problems. On linux of course you would have had > a similar problem if you had called your module SocketServer.py [would you > call one of your own modules sys.py or os.py or string.py ?? i hope not ;-)] > > Have a nice day > > D > "Daniel Klein" wrote in message > news:ycji6.241$Vf.9600 at typhoon.aracnet.com... > > I am attempting to write some socket code which must be platform indepent > > and the following behavior indicates that I can't use the SocketServer > > module as I had hoped to do. > > > > On Linux using Python 1.5.2, 'import SocketServer' correctly imports into > > the global namespace. On Windows, using Python 2.0, the same command > returns > > > > >>> import SocketServer > > Traceback (innermost last): > > File "", line 1, in ? > > import SocketServer > > NameError: Case mismatch for module name SocketServer > > (filename C:\DanielK\python\socketserver.py) > > > > ...however when I try 'import socketserver' (note the case of the > command), > > it actually _starts_ the server, ie > > > > >>> import socketserver > > Waiting for a connection... > > > > I know I'm using different version on the different platforms but could > > someone please advise how to use the SocketServer module on Windows > please? > > Has the implementation changed from 1.5.2 to 2.0? > > > > Please forgive my naivety if the answer is obvious but this is a serious > > problem for me. If I can't use the SocketServer module on Windows, I have > to > > go back to the drawing board and see what I would need to do to use the > > lower level 'socket' module (which will require a great deal more work, > > especially since I am new to network programming). :^( > > > > Thanks for listening, and hopefully for an answer, > > > > Daniel Klein > > > > > > > > From fredrik at pythonware.com Wed Feb 14 01:02:26 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 14 Feb 2001 00:02:26 GMT Subject: SocketServer inconsistencies References: Message-ID: Daniel Klein wrote: > On Windows, using Python 2.0, the same command returns > > >>> import SocketServer > Traceback (innermost last): > File "", line 1, in ? > import SocketServer > NameError: Case mismatch for module name SocketServer > (filename C:\DanielK\python\socketserver.py) did you call your test program "socketserver.py" ? that's a bad idea, when using a case-insensitive file system... Cheers /F From jepler at inetnebr.com Wed Feb 14 04:55:06 2001 From: jepler at inetnebr.com (Jeff Epler) Date: Wed, 14 Feb 2001 03:55:06 GMT Subject: SocketServer inconsistencies References: Message-ID: On Tue, 13 Feb 2001 15:07:06 -0800, Daniel Klein wrote: >I am attempting to write some socket code which must be platform indepent >and the following behavior indicates that I can't use the SocketServer >module as I had hoped to do. This error may mean that your Python installation is damaged, and/or that Windows is brain damaged. Google for "PYTHONCASEOK" and you'll find a solution to your problem. As far as I know, the SocketServer module ought to work on Windows, the problem is due to the case of the filename (socketserver.py vs SocketServer.py) and the fact that the VFAT/FAT32 filesystem is case-preserving but case-sensitive. If you perform the suggested web search, you can read more about it than you care to see. Jeff From latlong at css2.com Wed Feb 14 00:50:27 2001 From: latlong at css2.com (LatLong) Date: Tue, 13 Feb 2001 23:50:27 GMT Subject: ANN: Latitude longitude database Message-ID: <7Lji6.4747$hN2.880712@news3.cableinet.net> Latitude longitude database of over 2.8 million locations worldwide. Download from: http://www.css2.com/latlong.htm Ideal for sales and marketing applications and travel related websites. Includes sample code. From maderacv at pacbell.net Wed Feb 14 01:28:34 2001 From: maderacv at pacbell.net (Louie Fimbrez) Date: Wed, 14 Feb 2001 00:28:34 GMT Subject: Introduction to Spanish Multimedia Website Message-ID: Madera CineVideo with 15 years of experience would like to announce the opening of its new Website http://www.spanishmultimedia.com, one of the largest distributors of Spanish Educational Videos from Math, to History, Language Arts and Parenting. In Entertainment we offer something for the whole family, a wide selection of both the old classics and the new releases. Checkout our Website and let us know how you like it. All comments are greatly appreciated. mailto:maderacv at pacbell.net. From steve.waterbury at gsfc.nasa.gov Wed Feb 14 02:31:26 2001 From: steve.waterbury at gsfc.nasa.gov (Steve Waterbury) Date: Tue, 13 Feb 2001 20:31:26 -0500 Subject: Introduction to Spanish Multimedia Website References: Message-ID: <3A89DFEE.C207A651@gsfc.nasa.gov> python-list-request at python.org wrote: > Subject: Introduction to Spanish Multimedia Website Well we weren't expecting the Introduction to the Spanish Multimedia Website!! :^) oo _\o \/\ \ / ____________________________________________ oo _________________ "Sometimes you're the windshield; sometimes you're the bug." - Knopfler From dan at eevolved.com Wed Feb 14 03:11:11 2001 From: dan at eevolved.com (Dan Parisien) Date: Wed, 14 Feb 2001 02:11:11 GMT Subject: Introduction to Spanish Multimedia Website References: Message-ID: <3Pli6.115170$Pm2.2181515@news20.bellglobal.com> Steve Waterbury wrote: > python-list-request at python.org wrote: > > > Subject: Introduction to Spanish Multimedia Website > > Well we weren't expecting the Introduction to the Spanish > Multimedia Website!! hahahahaha good one :) Dan From m.wilson at bibliocraft.com Wed Feb 14 04:39:43 2001 From: m.wilson at bibliocraft.com (Mark Wilson) Date: Wed, 14 Feb 2001 03:39:43 -0000 Subject: Introduction to Spanish Multimedia Website Message-ID: <021e01c09637$c7c63fc0$2c824ac3@mwdell1> >> Subject: Introduction to Spanish Multimedia Website > >Well we weren't expecting the Introduction to the Spanish >Multimedia Website!! _Nobody_ _expects_ the Introduction to the Spanish Multimedia Website!! :-> From sholden at holdenweb.com Wed Feb 14 13:38:07 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 14 Feb 2001 07:38:07 -0500 Subject: Introduction to Spanish Multimedia Website References: Message-ID: "Mark Wilson" wrote in message news:mailman.982122194.11337.python-list at python.org... > >> Subject: Introduction to Spanish Multimedia Website > > > >Well we weren't expecting the Introduction to the Spanish > >Multimedia Website!! > > _Nobody_ _expects_ the Introduction to the Spanish > Multimedia Website!! > > :-> > There are two reasons for this. First, it's Spanish. Second, it's Multimedia. Third, it's a Website. There are _three_ reasons for this ... rgeards Steve From sdm7g at virginia.edu Wed Feb 14 01:34:37 2001 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Tue, 13 Feb 2001 19:34:37 -0500 (EST) Subject: Seen on comp.lang.scheme... computer languages in comp.sci.curriculum Message-ID: FYI: Forwarded from comp.lang.scheme -------------------- Dear Colleagues -- ACM's and IEEE's joint task on curriculum development has released its "ironman draft" proposal for a new core curriculum in computer science. The draft allocates six hours to the area of programming languages, relegating it to third-class status. I have written a letter of protest and ask for your support. Please visit my Web site where I have posted the letter and where you can find some additional information on the topic: http://www.cs.rice.edu/~matthias/cc2001.html Regards -- Matthias Felleisen From dan at eevolved.com Wed Feb 14 03:32:48 2001 From: dan at eevolved.com (Dan Parisien) Date: Wed, 14 Feb 2001 02:32:48 GMT Subject: crazy lambdas Message-ID: I want to do this class Event: def __init__(self): self.callbacks = [] def trigger(self): for i in self.callbacks: i() e = Event() person = "me" dict = {person:1} e.callbacks.append(lambda d=dict, p=person: del d[p]) # .... later e.trigger() #deletes --- those who use lambdas alot will notice my mistake. I, however, do not know what I am doing wrong. I think it has something to do with the fact 'del d[p]' doesn't have a value... Is it possible to do what I want (make a custom one-time-use function that is called much later and deletes a key from a dictionary)? thanks, Dan From johann at physics.berkeley.edu Wed Feb 14 04:23:02 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 13 Feb 2001 19:23:02 -0800 Subject: crazy lambdas References: Message-ID: Dan Parisien writes: > those who use lambdas alot will notice my mistake. I, however, do not know > what I am doing wrong. I think it has something to do with the fact 'del > d[p]' doesn't have a value... Yep. "del d[p]" is a statement, not an expression. Take a look at the built-in function delattr. That should do what you want. --J -- Johann Hibschman johann at physics.berkeley.edu From sdm7g at virginia.edu Wed Feb 14 04:32:13 2001 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Tue, 13 Feb 2001 22:32:13 -0500 (EST) Subject: crazy lambdas In-Reply-To: Message-ID: On Wed, 14 Feb 2001, Dan Parisien wrote: > I want to do this > > e.callbacks.append(lambda d=dict, p=person: del d[p]) > > # .... later > > e.trigger() #deletes > --- > those who use lambdas alot will notice my mistake. I, however, do not know > what I am doing wrong. I think it has something to do with the fact 'del > d[p]' doesn't have a value... No -- the problem is that 'lambda' expressions take an expression and 'del' is a statement in the python grammar. You'll get the same error if you try: 'lambda x: import sys' -- The problem is 'del' , not 'd[p]' . > Is it possible to do what I want (make a custom one-time-use function that > is called much later and deletes a key from a dictionary)? I think the more pythonic way to do this would be to subclass UserDict and make a method that deletes the keys. ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- "All operating systems want to be unix, All programming languages want to be lisp." From scarblac at pino.selwerd.nl Wed Feb 14 11:22:26 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 14 Feb 2001 10:22:26 GMT Subject: crazy lambdas References: Message-ID: Dan Parisien wrote in comp.lang.python: > e.callbacks.append(lambda d=dict, p=person: del d[p]) > > # .... later > > e.trigger() #deletes > --- > those who use lambdas alot will notice my mistake. I, however, do not know > what I am doing wrong. I think it has something to do with the fact 'del > d[p]' doesn't have a value... The problem is that it is a statement, not a function. Note that you don't use parentheses after del either, just like with print, import, exec, etc. Assignment isn't a function either. > Is it possible to do what I want (make a custom one-time-use function that > is called much later and deletes a key from a dictionary)? Make the function with a normal def. Make another function that creates those functions so you don't have to do it all the time... def make_deleter(dict, person): def deleter(dict=dict, person=person): del dict[person] return deleter e.callbacks.append(make_deleter(dict, person)) -- Remco Gerlich From hgg9140 at seanet.com Wed Feb 14 04:21:41 2001 From: hgg9140 at seanet.com (Harry George) Date: 13 Feb 2001 19:21:41 -0800 Subject: XML Schema? Message-ID: Anyone have a python XML Schema parser/validator? I thought I saw comments that it wasn't being done yet as part of xml-sig. Of course, we don't actually need an XML Schema validator inpython (java or C++ renditions would do fine), but there is a social cachet to it, so maybe worth the effort. Assuming it is an open task, here is an approach. Anyone see holes in this, besides it being a humongous task? 1. Get the specs from OASIS-->W3C. 2. Get test cases (for schemas and for instances) There are a few cases at xml-conf, but I think a lot more will be needed. So I'll need to generate them, and that suggests a case generator, plus of course a test driver. I have the testcase generator and driver done. 3. XML Schema is basically a regular expression problem, with nodes as the "characters". So we can use classical lexer algorithms: regexpr --> NFA --> DFA. The hassles may be at the leaf nodes, where XML Schema has lots of special cases. I don't knbow if there are non-re constraints in the specs, but if so I'd apply them after the initial pass. 4. Given that state machine, run schemas through the parser until it can build machines from valid schemas and detect invalid ones. 5. Given a sound state machine, run instance test cases through the package until it is passing valid instances and detecting invalid ones. 6. This would probably be an iterative enhancement exercise, once the state machine engine was in place. I have a lex-workalike I wrote in Modula-2, which I'll use as the start point. Probably could use a SAX input approach ("next node" instead of "next char"), maybe with 1 lookahead. -- Harry George hgg9140 at seanet.com From adaminthedomaindevtty.net Wed Feb 14 08:00:31 2001 From: adaminthedomaindevtty.net (Adam Logghe) Date: Tue, 13 Feb 2001 23:00:31 -0800 Subject: XML Schema? References: Message-ID: <3a8a2b13$1_1@news.nwlink.com> I haven't seen a Python schema validator yet. I would think that if anyone would know it would be the XML-SIG mailing list and the 4suite.org people. 4suite has the most complete standard XML toolset in Python I've seen yet, I've been VERY pleased. I suspect that Schema is not far enough along yet for serious implementation?? Adam adam in the domain devtty.net "Harry George" wrote in message news:m3ofw62blm.fsf at wilma.localdomain... > Anyone have a python XML Schema parser/validator? I thought I saw > comments that it wasn't being done yet as part of xml-sig. Of course, > we don't actually need an XML Schema validator inpython (java or C++ > renditions would do fine), but there is a social cachet to it, so > maybe worth the effort. > > Assuming it is an open task, here is an approach. Anyone see holes in > this, besides it being a humongous task? > > 1. Get the specs from OASIS-->W3C. > > 2. Get test cases (for schemas and for instances) There are a few > cases at xml-conf, but I think a lot more will be needed. So I'll > need to generate them, and that suggests a case generator, plus of > course a test driver. I have the testcase generator and driver > done. > > 3. XML Schema is basically a regular expression problem, with nodes as > the "characters". So we can use classical lexer algorithms: > regexpr --> NFA --> DFA. The hassles may be at the leaf nodes, > where XML Schema has lots of special cases. I don't knbow if there > are non-re constraints in the specs, but if so I'd apply them after > the initial pass. > > 4. Given that state machine, run schemas through the parser until it can > build machines from valid schemas and detect invalid ones. > > 5. Given a sound state machine, run instance test cases through the > package until it is passing valid instances and detecting invalid > ones. > > 6. This would probably be an iterative enhancement exercise, once the > state machine engine was in place. > > I have a lex-workalike I wrote in Modula-2, which I'll use as the > start point. Probably could use a SAX input approach ("next node" > instead of "next char"), maybe with 1 lookahead. > > > > -- > Harry George > hgg9140 at seanet.com From uche at ogbuji.net Tue Feb 20 01:53:54 2001 From: uche at ogbuji.net (Uche Ogbuji) Date: Tue, 20 Feb 2001 00:53:54 GMT Subject: XML Schema? References: <3a8a2b13$1_1@news.nwlink.com> Message-ID: <3A91C021.C6C3B9BA@ogbuji.net> Adam Logghe wrote: > > I haven't seen a Python schema validator yet. > > I would think that if anyone would know it would be the XML-SIG mailing list > and the 4suite.org people. > > 4suite has the most complete standard XML toolset in Python I've seen yet, > I've been VERY pleased. > > I suspect that Schema is not far enough along yet for serious > implementation?? We've just ben talking about this on XML-SIG. The main problem seems to be that it's pretty hard to find someone who likes XML Schemas enough to begin implementing it. I personally dislike the spec. I prefer Schematron, TREX, RELAX, HOOK, etc. However, given the number of other specs beginning to depend on XSchema, I don't suppose we'll have much choice. Probably post 4Suite 1.0. For now Henry Thomson's XSV package is the only option for Pythoneers looking for XSchemas. (No wonder he's an XSchema fan: he's on the working group). Thanks for the kind words about 4Suite, though. Don't miss the 0.10.2 release we just put out. *Many* bug-fixes. -- Uche Ogbuji Personal: uche at ogbuji.net http://uche.ogbuji.net Work: uche.ogbuji at fourthought.com http://Fourthought.com From uche at ogbuji.net Wed Feb 14 15:00:40 2001 From: uche at ogbuji.net (Uche Ogbuji) Date: Wed, 14 Feb 2001 14:00:40 GMT Subject: XML Schema? References: Message-ID: <3A8A8F8E.C1D27F0B@ogbuji.net> Harry George wrote: > > Anyone have a python XML Schema parser/validator? I thought I saw > comments that it wasn't being done yet as part of xml-sig. Of course, > we don't actually need an XML Schema validator inpython (java or C++ > renditions would do fine), but there is a social cachet to it, so > maybe worth the effort. I'm not personally a fan of XML Schemas, but I think this would be a very worth-while project. You'd probably get plenty of help as well. > Assuming it is an open task, here is an approach. Anyone see holes in > this, besides it being a humongous task? > > 1. Get the specs from OASIS-->W3C. > > 2. Get test cases (for schemas and for instances) There are a few > cases at xml-conf, but I think a lot more will be needed. So I'll > need to generate them, and that suggests a case generator, plus of > course a test driver. I have the testcase generator and driver > done. > > 3. XML Schema is basically a regular expression problem, with nodes as > the "characters". Hmm. I wouldn't go this far. The most basic parts of the content model are so, but the entire data-type system and parts of the content model need a different approach than regular grammar. > So we can use classical lexer algorithms: > regexpr --> NFA --> DFA. The hassles may be at the leaf nodes, > where XML Schema has lots of special cases. I don't knbow if there > are non-re constraints in the specs, but if so I'd apply them after > the initial pass. Interesting approach. > 4. Given that state machine, run schemas through the parser until it can > build machines from valid schemas and detect invalid ones. > > 5. Given a sound state machine, run instance test cases through the > package until it is passing valid instances and detecting invalid > ones. > > 6. This would probably be an iterative enhancement exercise, once the > state machine engine was in place. > > I have a lex-workalike I wrote in Modula-2, which I'll use as the > start point. Probably could use a SAX input approach ("next node" > instead of "next char"), maybe with 1 lookahead. Just to note: LT-XML supposedly has a Python interface and an XSchemas validator. I still think your effort would be worth-while, especially given your fresh approach. http://www.ltg.ed.ac.uk/software/xml/ -- Uche Ogbuji Personal: uche at ogbuji.net http://uche.ogbuji.net Work: uche.ogbuji at fourthought.com http://Fourthought.com From hgg9140 at cola.ca.boeing.com Wed Feb 14 18:58:53 2001 From: hgg9140 at cola.ca.boeing.com (Harry George) Date: Wed, 14 Feb 2001 17:58:53 GMT Subject: XML Schema? References: <3A8A8F8E.C1D27F0B@ogbuji.net> Message-ID: Thanks for the pointer. I didn't find LTXML in my initial literature search. Given that it exists, I don't see much reason to continue on my effort. Maybe the xml-conf site could use the testcase generator. Another possibility I considered was to do a python binding to the apache Xerces "C++". Do you know if anyone has done that? That would hook into IBM's significant C++/Java XML-oriented releases. I'm not a fan of Schema either, but it sure is being hyped to the local decision makers -- so I need a python treatment. The whole XML world has migrated from "It is deliberately simple so all languages can play" to "Let's complexify it so those pesky GPL guys can't keep up." Uche Ogbuji writes: > Harry George wrote: > > > > Anyone have a python XML Schema parser/validator? I thought I saw > > comments that it wasn't being done yet as part of xml-sig. Of course, > > we don't actually need an XML Schema validator inpython (java or C++ > > renditions would do fine), but there is a social cachet to it, so > > maybe worth the effort. > > I'm not personally a fan of XML Schemas, but I think this would be a > very worth-while project. You'd probably get plenty of help as well. > > > Assuming it is an open task, here is an approach. Anyone see holes in > > this, besides it being a humongous task? > > > > 1. Get the specs from OASIS-->W3C. > > > > 2. Get test cases (for schemas and for instances) There are a few > > cases at xml-conf, but I think a lot more will be needed. So I'll > > need to generate them, and that suggests a case generator, plus of > > course a test driver. I have the testcase generator and driver > > done. > > > > 3. XML Schema is basically a regular expression problem, with nodes as > > the "characters". > > Hmm. I wouldn't go this far. The most basic parts of the content model > are so, but the entire data-type system and parts of the content model > need a different approach than regular grammar. > > > So we can use classical lexer algorithms: > > regexpr --> NFA --> DFA. The hassles may be at the leaf nodes, > > where XML Schema has lots of special cases. I don't knbow if there > > are non-re constraints in the specs, but if so I'd apply them after > > the initial pass. > > Interesting approach. > > > 4. Given that state machine, run schemas through the parser until it can > > build machines from valid schemas and detect invalid ones. > > > > 5. Given a sound state machine, run instance test cases through the > > package until it is passing valid instances and detecting invalid > > ones. > > > > 6. This would probably be an iterative enhancement exercise, once the > > state machine engine was in place. > > > > I have a lex-workalike I wrote in Modula-2, which I'll use as the > > start point. Probably could use a SAX input approach ("next node" > > instead of "next char"), maybe with 1 lookahead. > > Just to note: LT-XML supposedly has a Python interface and an XSchemas > validator. I still think your effort would be worth-while, especially > given your fresh approach. > > http://www.ltg.ed.ac.uk/software/xml/ > > > -- > Uche Ogbuji > Personal: uche at ogbuji.net http://uche.ogbuji.net > Work: uche.ogbuji at fourthought.com http://Fourthought.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 rtexier at elikya.com Thu Feb 15 12:24:38 2001 From: rtexier at elikya.com (Romuald Texier) Date: Thu, 15 Feb 2001 11:24:38 +0000 Subject: XML Schema? References: <3A8A8F8E.C1D27F0B@ogbuji.net> Message-ID: <96gap7$6qj$1@news.irisa.fr> Did you take a look at http://4suite.org/ ? Regards. Romuald Texier. Harry George wrote: > Thanks for the pointer. I didn't find LTXML in my initial literature > search. Given that it exists, I don't see much reason to continue on > my effort. Maybe the xml-conf site could use the testcase generator. > > Another possibility I considered was to do a python binding to the > apache Xerces "C++". Do you know if anyone has done that? That would > hook into IBM's significant C++/Java XML-oriented releases. > > I'm not a fan of Schema either, but it sure is being hyped to the > local decision makers -- so I need a python treatment. The whole XML > world has migrated from "It is deliberately simple so all languages can > play" to "Let's complexify it so those pesky GPL guys can't keep up." > > Uche Ogbuji writes: > > > Harry George wrote: > > > > > > Anyone have a python XML Schema parser/validator? I thought I saw > > > comments that it wasn't being done yet as part of xml-sig. Of course, > > > we don't actually need an XML Schema validator inpython (java or C++ > > > renditions would do fine), but there is a social cachet to it, so > > > maybe worth the effort. > > > > I'm not personally a fan of XML Schemas, but I think this would be a > > very worth-while project. You'd probably get plenty of help as well. > > > > > Assuming it is an open task, here is an approach. Anyone see holes in > > > this, besides it being a humongous task? > > > > > > 1. Get the specs from OASIS-->W3C. > > > > > > 2. Get test cases (for schemas and for instances) There are a few > > > cases at xml-conf, but I think a lot more will be needed. So I'll > > > need to generate them, and that suggests a case generator, plus of > > > course a test driver. I have the testcase generator and driver > > > done. > > > > > > 3. XML Schema is basically a regular expression problem, with nodes as > > > the "characters". > > > > Hmm. I wouldn't go this far. The most basic parts of the content model > > are so, but the entire data-type system and parts of the content model > > need a different approach than regular grammar. > > > > > So we can use classical lexer algorithms: > > > regexpr --> NFA --> DFA. The hassles may be at the leaf nodes, > > > where XML Schema has lots of special cases. I don't knbow if there > > > are non-re constraints in the specs, but if so I'd apply them after > > > the initial pass. > > > > Interesting approach. > > > > > 4. Given that state machine, run schemas through the parser until it > > > can > > > build machines from valid schemas and detect invalid ones. > > > > > > 5. Given a sound state machine, run instance test cases through the > > > package until it is passing valid instances and detecting invalid > > > ones. > > > > > > 6. This would probably be an iterative enhancement exercise, once the > > > state machine engine was in place. > > > > > > I have a lex-workalike I wrote in Modula-2, which I'll use as the > > > start point. Probably could use a SAX input approach ("next node" > > > instead of "next char"), maybe with 1 lookahead. > > > > Just to note: LT-XML supposedly has a Python interface and an XSchemas > > validator. I still think your effort would be worth-while, especially > > given your fresh approach. > > > > http://www.ltg.ed.ac.uk/software/xml/ > > > > > > -- > > Uche Ogbuji > > Personal: uche at ogbuji.net http://uche.ogbuji.net > > Work: uche.ogbuji at fourthought.com http://Fourthought.com > -- Romuald Texier From loewis at informatik.hu-berlin.de Mon Feb 19 19:52:02 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 19 Feb 2001 19:52:02 +0100 Subject: XML Schema? References: <3A8A8F8E.C1D27F0B@ogbuji.net> Message-ID: Harry George writes: > Another possibility I considered was to do a python binding to the > apache Xerces "C++". Do you know if anyone has done that? People have considered that, but nobody has done it, AFAICT. Note that you could chose to expose either SAX or DOM or both. > That would hook into IBM's significant C++/Java XML-oriented > releases. I guess Xerces C++ would not hook very much into Java releases... It's also open for debate what you'd gain from using that XML parser, compared to, say, Expat. Regards, Martin From hgg9140 at cola.ca.boeing.com Mon Feb 19 21:28:41 2001 From: hgg9140 at cola.ca.boeing.com (Harry George) Date: Mon, 19 Feb 2001 20:28:41 GMT Subject: XML Schema? References: <3A8A8F8E.C1D27F0B@ogbuji.net> Message-ID: Martin von Loewis writes: > Harry George writes: > > That would hook into IBM's significant C++/Java XML-oriented > > releases. > > I guess Xerces C++ would not hook very much into Java releases... > What I meant was that IBM is pouring money into XML, using C++ and Java as the proof-of-concept languages. It would be easy for python to fall off the leading edge if they got too far out there. Binding directly to the C++ library keeps that connection. Not that I approve of all this churning of standards. XML was meant to be simple -- and it was until business people figured out they could get lockin with complex standards. > It's also open for debate what you'd gain from using that XML parser, > compared to, say, Expat. > Expat has XML Schema and UDDI? > Regards, > Martin -- 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 loewis at informatik.hu-berlin.de Tue Feb 20 14:02:21 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 20 Feb 2001 14:02:21 +0100 Subject: XML Schema? References: <3A8A8F8E.C1D27F0B@ogbuji.net> Message-ID: Harry George writes: > > It's also open for debate what you'd gain from using that XML parser, > > compared to, say, Expat. > > > > Expat has XML Schema and UDDI? As Paul points out: Xerces C++ does not have schema support, either. Not sure how UDDI fits into the parsing business, though. Regards, Martin From hgg9140 at cola.ca.boeing.com Tue Feb 20 15:47:23 2001 From: hgg9140 at cola.ca.boeing.com (Harry George) Date: Tue, 20 Feb 2001 14:47:23 GMT Subject: XML Schema? References: <3A8A8F8E.C1D27F0B@ogbuji.net> Message-ID: My concern was not about parsers per se, but a general body of work rapidly developing and moving to either legal or defacto standard status. If that work is focused on one or a few languages, then other languages have some difficulty staying in the game. So I'm looking for a low cost way to keep up. One way is to bind to libraries generated by others -- that's easier done against C/C++ libraries. Another is to do idiomatic code conversion -- that's probably easier done from Java to Python. Martin von Loewis writes: > Harry George writes: > > > > It's also open for debate what you'd gain from using that XML parser, > > > compared to, say, Expat. > > > > > > > Expat has XML Schema and UDDI? > > As Paul points out: Xerces C++ does not have schema support, > either. Not sure how UDDI fits into the parsing business, though. > > Regards, > Martin -- 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 aleaxit at yahoo.com Tue Feb 20 17:38:30 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 20 Feb 2001 17:38:30 +0100 Subject: XML Schema? References: <3A8A8F8E.C1D27F0B@ogbuji.net> Message-ID: <96u6i001hfc@news2.newsguy.com> "Harry George" wrote in message news:xqxg0h94dj8.fsf at cola.ca.boeing.com... > My concern was not about parsers per se, but a general body of work > rapidly developing and moving to either legal or defacto standard > status. If that work is focused on one or a few languages, then other > languages have some difficulty staying in the game. ...unless the "other languages" are particularly apt at "fitting into diverse ecological niches" -- Python does that well:-). > So I'm looking for a low cost way to keep up. One way is to bind to > libraries generated by others -- that's easier done against C/C++ > libraries. Easier than what...? Definitely not easier than Java/Python integration (with Jython), so I must be misreading you...? > Another is to do idiomatic code conversion -- that's > probably easier done from Java to Python. Among the easiest things in the world (definitely easier than stealing candy from a baby, even not considering the moral implications of this latter act) is using Java classes from the Jython version of Python. If, as I originally read your message, such use is what you desire, then I don't understand your concern. If, OTOH, XML use from Python is actually your main thrust, I'd stay with 4Suite. But that's a personal choice -- there's just SO much current/modern/leading-edge stuff out there for Java, that Jython may be the best choice for cross-platform work, just as Python + win32com probably is for Windows-only work for similar reasons. Anyway, my key point is that the ease of "extending and embedding" Jython with Java is *astounding* -- a completely different order of magnitude from 'extending and embedding' CPython with C or C++. You don't have to write ONE LINE of Java code in the knowledge that it will ever be used from Python -- you can do all that's needed on the Python side of things. .NET may give us all that and more besides one (perhaps not-too-far-off) day, but Java and Jython give a LOT today, within the JVM's limitations (speed, possible security issues, etc) which you'd have from Java itself as well to some extent. Alex From hgg9140 at seanet.com Wed Feb 21 01:15:38 2001 From: hgg9140 at seanet.com (Harry George) Date: 20 Feb 2001 16:15:38 -0800 Subject: XML Schema? References: <3A8A8F8E.C1D27F0B@ogbuji.net> <96u6i001hfc@news2.newsguy.com> Message-ID: "Alex Martelli" writes: > "Harry George" wrote in message > news:xqxg0h94dj8.fsf at cola.ca.boeing.com... > > My concern was not about parsers per se, but a general body of work > > rapidly developing and moving to either legal or defacto standard > > status. If that work is focused on one or a few languages, then other > > languages have some difficulty staying in the game. > > ...unless the "other languages" are particularly apt at "fitting into > diverse ecological niches" -- Python does that well:-). Yes, python is extrodinary in that niche. But we wouldn't be having this discusison if it were on top of all the modules that Java is covering. > > > So I'm looking for a low cost way to keep up. One way is to bind to > > libraries generated by others -- that's easier done against C/C++ > > libraries. > > Easier than what...? Definitely not easier than Java/Python > integration (with Jython), so I must be misreading you...? > Jython is great -- if you want to use Java. Personally, I don't want to lock in to that world. So I was looking for ways to escape the java mindset, not support it. > > Another is to do idiomatic code conversion -- that's > > probably easier done from Java to Python. > > Among the easiest things in the world (definitely easier than > stealing candy from a baby, even not considering the moral > implications of this latter act) is using Java classes from > the Jython version of Python. If, as I originally read your > message, such use is what you desire, then I don't understand > your concern. Again, I don't want to use or directly link to java. I want to link to other libraries. > > If, OTOH, XML use from Python is actually your main thrust, > I'd stay with 4Suite. But that's a personal choice -- there's > just SO much current/modern/leading-edge stuff out there for > Java, that Jython may be the best choice for cross-platform > work, just as Python + win32com probably is for Windows-only > work for similar reasons. > I already use 4Suite. As noted elsewhere, it doesn't do XSchema, which is why I started this thread. > Anyway, my key point is that the ease of "extending and > embedding" Jython with Java is *astounding* -- a completely > different order of magnitude from 'extending and embedding' > CPython with C or C++. You don't have to write ONE LINE of > Java code in the knowledge that it will ever be used from > Python -- you can do all that's needed on the Python side > of things. .NET may give us all that and more besides one > (perhaps not-too-far-off) day, but Java and Jython give a > LOT today, within the JVM's limitations (speed, possible > security issues, etc) which you'd have from Java itself as > well to some extent. > I may have to eventually use .NET at work, but it will be a cold day in Tuxland before I use it at home... > > Alex > > > > -- Harry George hgg9140 at seanet.com From aleaxit at yahoo.com Wed Feb 21 10:18:36 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 21 Feb 2001 10:18:36 +0100 Subject: XML Schema? References: <3A8A8F8E.C1D27F0B@ogbuji.net> <96u6i001hfc@news2.newsguy.com> Message-ID: <97015e02mpi@news1.newsguy.com> "Harry George" wrote in message news:m34rxoao2d.fsf at wilma.localdomain... [snip] > > > status. If that work is focused on one or a few languages, then other > > > languages have some difficulty staying in the game. > > > > ...unless the "other languages" are particularly apt at "fitting into > > diverse ecological niches" -- Python does that well:-). > > Yes, python is extrodinary in that niche. But we wouldn't be having > this discusison if it were on top of all the modules that Java is > covering. But it *IS* -- just use Jython, hey presto, you're there. > > > So I'm looking for a low cost way to keep up. One way is to bind to > > > libraries generated by others -- that's easier done against C/C++ > > > libraries. > > > > Easier than what...? Definitely not easier than Java/Python > > integration (with Jython), so I must be misreading you...? > > Jython is great -- if you want to use Java. This is like saying that "CPython is great -- if you want to use C". A total non-sequitur! If you want to use C, use C; if you want to use Java, use Java; Python is great if you want to AVOID using C, or Java, as much as feasible, while still extracting benefits from existing libraries that are written in/for those languages. The correct statements may thus be more like: J) Jython is great if you want to use libraries written in/for Java (while eschewing use of Java itself as much as possible) just like: C) CPython is great if you want to use libraries written in/for C/C++ (while eschewing use of C or C++ as much as possible) The fact is that, while both statements (C) and (J) are true, (J) is *far TRUER* -- reusing ANY library written in/for Java (while eschewing use of Java itself) is a _snap_ with Jython, while the analogous situation in case (C) often requires *SOME* amount of C-level work to "wrap" the library specifically for Python use. > Personally, I don't want > to lock in to that world. So I was looking for ways to escape the > java mindset, not support it. The Java mindset seems to me to be "one language to bind them all", etc. Using a language that is definitely NOT Java thus escapes "the java mindset" (as I see it) quite effectively, and Jython is that "language that is definitely NOT Java". Jython runs only within the *JVM*, of course -- *THAT* is the unavoidable pre-req for reusing libraries that also run only within the JVM. If/when a fully-JVM-specs-compatible JIT or AOT (ahead-of-time) compiler for JVM-bytecode emerges, then the libraries in question will be freed from running "within" the JVM, and so, of course, will Jython be (without any special effort on the part of anybody EXCEPT the authors of the hypothetical JVM-bytecode-to-something-else compilers:-). > Again, I don't want to use or directly link to java. I want to link > to other libraries. You can wrap C-coded or C++-coded libraries with lots of existing tools such as SWIG, although much manual work is typically needed. But that buys you nothing squat, when "that work is focused on one .. language", given that said language, in practice, *IS* Java. With Jython, you will NOT "use or directly link to" *Java* -- you WILL use the bytecodes of the JVM, rather than those of the dedicated Python VM that's bundled with CPython, and that's all. > I already use 4Suite. As noted elsewhere, it doesn't do XSchema, > which is why I started this thread. But neither does the C++ version of Xerces, etc, so, why DO you at all care about 'linking' to it?! The (perhaps-sad) current reality is that much research and development effort regarding bleeding-edge tools is going to build libraries that will only run within the JVM; the silver lining in this situation is that Jython rescues you from having to use Java as the entry-ticket to that world of rich, bleeding-edge libraries (you do have to be able to *read* "just enough Java to get by", just like, to use COM Automation effectively, you have to be able to read just enough VB to get by, and for a similar reason -- the _docs and examples_ you will find around will be totally slanted to Java/VB respectively; fortunately, Java and VB, as used in docs and examples, tend to be somewhat readable -- it's NOT as bad as if the examples and docs were slanted to C++ or Perl!-). If you don't NEED to use certain available-for-JVM-only bleeding-edge libraries, then CPython appears to me to be as well-placed as any other language to use other, non-JVM libraries. 4Suite appears to offer, roughly, about as much XML functionality, or more, than any other XML suite of tools that is not JVM-connected. Easy alternatives include using COM, which is about as effortless with CPython (and win32all) as using for-JVM tools with Jython; if a for-JVM-only tool IS compatible with Microsoft's JVM, you can probably take advantage of the latter's ability to expose any Java class as a COM/Automation object to use it that way (I haven't tried that, and it does not seem very strategic, given that MS's JVM is not state-of-the- art any more, and is slowly or not-so-slowly dying). Near-future possibilities will include XPCOM (a COM work- alike that was developed within Mozilla and is now well usable from CPython, thanks to ActiveState's efforts; it remains to be seen how many bleeding-edge components &c will in fact be available for it!) and .NET, of which you say...: > I may have to eventually use .NET at work, but it will be a cold > day in Tuxland before I use it at home... ...even if/when it becomes available for, say, Linux as well as Windows platform, and bleeding-edge tools you need are only available for it? Why? Judging from this assertion, and your total reluctance to use the JVM (which you appear to be expressing as a reluctance to use *Java*, which would in fact be well justified, AND a completely different thing), you would appear to be allergic to bytecode-based execution environments. In which case, it's hard to understand why you use Python, since, in any of its forms (CPython with the special-purpose VM, Jython with JVM, Python.NET with MSIL...), it *DOES* rely on just such bytecode ideas!-) Alex From loewis at informatik.hu-berlin.de Tue Feb 20 19:08:48 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 20 Feb 2001 19:08:48 +0100 Subject: XML Schema? References: <3A8A8F8E.C1D27F0B@ogbuji.net> Message-ID: Harry George writes: > So I'm looking for a low cost way to keep up. One way is to bind to > libraries generated by others -- that's easier done against C/C++ > libraries. Another is to do idiomatic code conversion -- that's > probably easier done from Java to Python. Integrating C libraries always was one of the major strengths of Python. I'm sure that somebody will integrate any library which would be useful to enough people - I just doubt that Xerces is such a library. Python is particularly good at integrating things that come from different origins. So if it turns out that IBM UDDI support is great, then somebody will wrap it. You could still ignore the SAX part if you think it sucks; I'd personally favour the small Expat library over a heavy C++ parser any time. Regards, Martin From paulp at ActiveState.com Mon Feb 19 21:28:28 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Mon, 19 Feb 2001 12:28:28 -0800 Subject: XML Schema? References: <3A8A8F8E.C1D27F0B@ogbuji.net> Message-ID: <3A9181EC.D8DE0125@ActiveState.com> Harry George wrote: > > ... > Another possibility I considered was to do a python binding to the > apache Xerces "C++". Do you know if anyone has done that? That would > hook into IBM's significant C++/Java XML-oriented releases. Xereces C++ does not have a schema engine yet. > I'm not a fan of Schema either, but it sure is being hyped to the > local decision makers -- so I need a python treatment. The whole XML > world has migrated from "It is deliberately simple so all languages can > play" to "Let's complexify it so those pesky GPL guys can't keep up." That's one cynical reading of the situation. I think it is more a case of getting more competing interests into a room than we had in the early days. You need a much more disciplined moderator/editor in that situation than you do when nobody cares. -- Vote for Your Favorite Python & Perl Programming Accomplishments in the first Active Awards! http://www.ActiveState.com/Awards From gReGlAnDrUm at earthlink.net Wed Feb 14 04:27:39 2001 From: gReGlAnDrUm at earthlink.net (greg Landrum) Date: Tue, 13 Feb 2001 19:27:39 -0800 Subject: Python20 and .pth files Message-ID: <3A89FB2B.C1CA8A5E@earthlink.net> This is the second time I've been bitten by this problem in two days, so I figured that I'd post about it and see what the community consensus is. If the community consensus is that I'm an idiot, I'll live with that. :-) My system: I'm running python20 on Win2K (using ActivePython, if that makes any difference). I didn't muck about with any of the installation settings, so python lives in c:/python20 Short form of the problem: It appears that some "advanced" python applications ignore .pth files at times. Specific instances of this happening: Numeric Python likes to be installed in c:/python20. It creates a Numeric subdirectory and puts a Numeric.pth file in c:/python20. Most of the time this is just fine. However... one of the applications I'm working on creates Python COM servers which import Numeric. These work fine when I call them from Python applications (so none of my unit tests broke when I upgraded to 2.0, so I never noticed the problem). However, when I create one of these COM objects from within VB, I get an ImportError for Numeric. After much shrieking and pulling of my hair (I'm giving a demo of these objects on Friday, so I was not pleased to discover that they were mysteriously broken), I worked out a solution: add c:/Python20/Numeric to my PYTHONPATH environment variable. Now everything is happy. I had noticed similar problems when I tried to use my mod_python based web stuff, these are also fixed by ensuring that c:/python20/Numeric is in sys.path. The Question: Was it an accident that everything just worked before or has something changed? I know old versions of Numeric used to have an installer that may or may not have set registry keys to help out with this problem. Are .pth files being deprecated so that we (the users) should start badgering developers who still ship modules requiring them? I'm now looking forward to the first time I try to use PIL in one of these cases and discover that it doesn't work either. Luckily this time I'll know how to work around the problem. -greg From MarkH at ActiveState.com Wed Feb 14 23:12:35 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 14 Feb 2001 22:12:35 GMT Subject: Python20 and .pth files References: <3A89FB2B.C1CA8A5E@earthlink.net> Message-ID: <3A8B01F3.1000605@ActiveState.com> greg Landrum wrote: > However... one of the applications I'm working on creates Python COM > servers which import Numeric. These work fine when I call them from Python > applications (so none of my unit tests broke when I upgraded to 2.0, so I > never noticed the problem). However, when I create one of these COM > objects from within VB, I get an ImportError for Numeric. After much > shrieking and pulling of my hair (I'm giving a demo of these objects on > Friday, so I was not pleased to discover that they were mysteriously > broken), I worked out a solution: add c:/Python20/Numeric to my PYTHONPATH > environment variable. Now everything is happy. I believe this is a problem in certain embedding situations. Specifically, I believe it is because Python does not know its "home", so doesnt know where to load the .pth files from. > The Question: > Was it an accident that everything just worked before or has something > changed? I know old versions of Numeric used to have an installer that may > or may not have set registry keys to help out with this problem. > Are .pth files being deprecated so that we (the users) should start > badgering developers who still ship modules requiring them? I dont believe this would ever have worked. As you suggest, it is quite possible that only new versions of Numeric have .pth files. This is on my "to-do" list - having Python know its correct home in embedded situations would solve a few other problems too. Mark. -- Nominate Your Favorite Programmers for the Perl and Python Active Awards! http://www.ActiveState.com/Awards/ From thomas.heller at ion-tof.com Thu Feb 15 08:43:22 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 15 Feb 2001 08:43:22 +0100 Subject: Python20 and .pth files References: <3A89FB2B.C1CA8A5E@earthlink.net> <3A8B01F3.1000605@ActiveState.com> Message-ID: <96g1ar$kuoss$1@ID-59885.news.dfncis.de> "Mark Hammond" wrote in message news:3A8B01F3.1000605 at ActiveState.com... > greg Landrum wrote: > > > > However... one of the applications I'm working on creates Python COM > > servers which import Numeric. These work fine when I call them from Python > > applications (so none of my unit tests broke when I upgraded to 2.0, so I > > never noticed the problem). However, when I create one of these COM > > objects from within VB, I get an ImportError for Numeric. After much > > shrieking and pulling of my hair (I'm giving a demo of these objects on > > Friday, so I was not pleased to discover that they were mysteriously > > broken), I worked out a solution: add c:/Python20/Numeric to my PYTHONPATH > > environment variable. Now everything is happy. > > I believe this is a problem in certain embedding situations. Specifically, I believe it is because Python does not know its "home", so doesnt know where to load the .pth files from. Are you sure site.py is imported at all? There PYTHONPATH is extended by the contents of the .pth files. > > > The Question: > > Was it an accident that everything just worked before or has something > > changed? I know old versions of Numeric used to have an installer that may > > or may not have set registry keys to help out with this problem. > > Are .pth files being deprecated so that we (the users) should start > > badgering developers who still ship modules requiring them? > > I dont believe this would ever have worked. As you suggest, it is quite possible that only new versions of Numeric have .pth files. > New versions have a .pth file (since they are distributed via distutils), old versions used registry settings. > This is on my "to-do" list - having Python know its correct home in embedded situations would solve a few other problems too. > This is a bug in getpathp.c, see http://sourceforge.net/bugs/?func=detailbug&bug_id=131064&group_id=5470 > Mark. > Mark, please look at the bug. Otherwise you are forcing my to submit a patch ;-) Thomas From rogersd at bigfoot.com Wed Feb 14 05:31:58 2001 From: rogersd at bigfoot.com (Dave Rogers) Date: Tue, 13 Feb 2001 23:31:58 -0500 Subject: Python/ASP Docs/Questions Message-ID: <3A8A0A3E.A1EF40E9@bigfoot.com> I'm a newcomer to this group, but I'm working on a fairly large and exciting web site using Win2K/Python/ASP (win32 135/Python2.0) I cannot find any docs regarding the COM Scripting object that it uses. Can anyone (Mark?) refer me to proper docs for it? - I've checked ActiveState and the net in general with no luck. My two main problems are: 1) I would like for the COM Scripting object to not cache modules for me as I develop my code. I see the following conceivable solutions: a) There is some COM method I can call that will turn it off b) There is some process I can kill or restart (I tried WWW Publishing service) that will knock everything out of memory c) I can do manual reloads everywhere which are not desirable because I have some open source code that does "from foo import foo" where I cannot reload (foo) and I don't want to mess with the open source code because then I mess up the open source project d) Reboot the PC 2) I want to set cookies easily using Response. I would like to go Response.Cookies('name') = 'bob' (for a simple cookie), but instead I am forced to go import Cookie c = Cookie.Cookie() ... Response.AddHeader("Set-Cookie", c[12:]) (or something similar to that) I know Cookies is a collection - I seem to have this problem setting ASP Object values in general as I have to go Session.SetValue to set session variables. I really appreciate any help people can give me - these seem like fairly common issues, yet beyond the newbie level. P.S. One of the neatest things I've seen is Chuck Esterbrook's MiddleKit which was just released under Webware (http://webware.sourceforge.net). What it does is allow you to map your python objects to a database for design and run time access. What this means is that you can relate your objects in a 1 to 1 or 1 to many relationship and the MiddleKit will service all of your SQL needs - you do NOT write SQL or use recordsets. Once you acquire one or more objects from the database, you can follow their object references to other database objects. In fact I have abandoned ADO in favor of this middle layer which resides in between the database and my web site. I probably didn't do it justice but you'll just have to check it out. Thanks, -- Dave Rogers From kelly.kranabetter at gems6.gov.bc.ca Wed Feb 14 20:07:55 2001 From: kelly.kranabetter at gems6.gov.bc.ca (KellyK) Date: Wed, 14 Feb 2001 19:07:55 GMT Subject: Python/ASP Docs/Questions References: <3A8A0A3E.A1EF40E9@bigfoot.com> Message-ID: <3a8ad64e.222776145@nntp.gov.bc.ca> On Tue, 13 Feb 2001 23:31:58 -0500, Dave Rogers wrote: >1) I would like for the COM Scripting object to not cache modules for me as I develop my code. I see the following conceivable solutions: I had this same problem. I ended up making one ASP script that did a series of reload()'s so when I wanted to reload the modules I was working on I would view that one page. It had the advantage of having all the reloads in one place instead of sprinkled throughout many pages. From syver at NOSPAMcyberwatcher.com Thu Feb 15 13:51:20 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Thu, 15 Feb 2001 13:51:20 +0100 Subject: Python/ASP Docs/Questions References: <3A8A0A3E.A1EF40E9@bigfoot.com> Message-ID: <8V3k6.2528$X_2.64439@news1.oke.nextra.no> "Dave Rogers" wrote in message > My two main problems are: > b) There is some process I can kill or restart (I tried WWW Publishing service) that will knock everything out of memory net stop w3svc works fine on my box (and then start of course) You can also push the unload button in the application properties. > 2) I want to set cookies easily using Response. I would like to go Response.Cookies('name') = 'bob' (for a simple cookie), but instead I am forced to go Here is an example of using the cookies collection: Response.Cookies[name] = value # the root for this application Response.Cookies(name).path = "/v2/" + path + "/" import time ctime = time.mktime([2033, 11, 8, 12, 4, 14, 2, 313, 0]) Response.Cookies(name).Expires = cwutils.MakeComTime(ctime) > P.S. One of the neatest things I've seen is Chuck Esterbrook's MiddleKit which was just released under Webware (http://webware.sourceforge.net). What it does is allow you to map your python objects to a database for design and run time access. What this means is that you can relate your objects in a 1 to 1 or 1 to many relationship and the MiddleKit will service all of your SQL needs - you do NOT write SQL or use recordsets. Once you acquire one or more objects from the database, you can follow their object references to other database objects. In fact I have abandoned ADO in favor of this middle layer which resides in between the database and my web site. I probably didn't do it justice but you'll just have to check it out. > > Thanks, > -- > Dave Rogers > From graham at nospam.microtonal.co.uk Thu Feb 15 21:16:00 2001 From: graham at nospam.microtonal.co.uk (Graham Breed) Date: Thu, 15 Feb 2001 20:16 +0000 (GMT Standard Time) Subject: Python/ASP Docs/Questions References: <3A8A0A3E.A1EF40E9@bigfoot.com> Message-ID: In article <3A8A0A3E.A1EF40E9 at bigfoot.com>, rogersd at bigfoot.com (Dave Rogers) wrote: > 2) I want to set cookies easily using Response. I would like to go > Response.Cookies('name') = 'bob' (for a simple cookie), but instead I > am forced to go > > import Cookie > c = Cookie.Cookie() > ... > Response.AddHeader("Set-Cookie", c[12:]) > (or something similar to that) Here's an example that sets a cookie iff it isn't already set. cookieName = 'example cookie' cookie = str(Request.Cookies(cookieName)) # needs to be converted to a string to evaluate as false if not cookie: Response.Cookies[cookieName]='cookie read' c = Response.Cookies(cookieName) c.expires = pywintypes.Time(time.time()+600) > I know Cookies is a collection - I seem to have this problem setting > ASP Object values in general as I have to go Session.SetValue to set > session variables. Yes, it's because Python doesn't allow you to assign to the result of a function. Not that it's a problem with session variables, because they're evil anyway. Graham From gReGlAnDrUm at earthlink.net Wed Feb 14 06:09:37 2001 From: gReGlAnDrUm at earthlink.net (greg Landrum) Date: Tue, 13 Feb 2001 21:09:37 -0800 Subject: A PythonCOM tidbit Message-ID: <3A8A1311.7088EDB8@earthlink.net> This is probably abundantly clear to everyone who actually thinks hard about pythonCOM, but I just ran into problems with it, so I figure I'll point it out... I was feeling particularly uncreative whilst creating the names of my source files for COM servers. So I had two different COM servers Foo.Obj and Bar.Obj implemented in files called COMServer.py (yeah, yeah, I was *asking* for it) which lived in different directories (Foo and Bar). These were both registered and worked just fine. Until I tried to use them in succession on Excel. Then I started getting AttributeErrors. I'd create an instance of Foo.Obj, work with it for a bit, then try and create an instance of Bar.Obj. BAM! AttributeError for BarServer (the class defining Bar.Obj). Or I could work with Bar.Obj for a while and then try creating a Foo.Obj. Instant AttributeError for FooServer (the class defining Foo.Obj). After spending a while trying to figure out what the heck was going on, frantically flipping through PPW32 (once again: kudos to Mark and Andy for this fantastic tome), and generally getting all worked up, it hit me... when I first create a Foo.Obj, pythoncom is importing a module called COMServer from directory Foo. Later, when I try to create Bar.Obj, pythoncom tries to import COMServer, but it must see that a module called COMServer is already loaded, so it doesn't load the new one. The solution to this problem is, of course, to not use names quite so stupid as COMServer. -greg From shredwheat at mediaone.net Wed Feb 14 07:09:55 2001 From: shredwheat at mediaone.net (Pete Shinners) Date: Wed, 14 Feb 2001 06:09:55 GMT Subject: ANN: pygame-0.9 Message-ID: Pygame, Python Game Development. (A wrapper for the SDL and SDL daughter libraries) Pygame 0.9 released on Feb 12th, 2001 Pygame homepage: http://pygame.seul.org SDL homepage: http://www.libsdl.org Maintainer: Pete Shinners (pete at shinners.org) Pygame is a set of python modules written to help create games in Python. The package is wrapped around SDL and several of the SDL daughter libraries. SDL is a cross-platform media library created by Loki Games. SDL is currently used for many commercial and opensource game projects. This pygame binding takes SDL's C interface and turns it into a more pythonic library with objects, exceptions, and some python utility modules. This version 0.9, solidifies the package, as well as adding new features like line drawing, defineable cursors, and shared image data. At this point the library api has settled into a solid state. The coming plans call for a move to 1.0 within a couple of weeks. Now is a great time to examine the project and send in feedback. A tally list of pygame features (note, many are also SDL features); Cross platform, with multiple backends (x11, fbcon, svgalib, etc) Fullscreen or windowed accelerated graphics Image loading from popular formats; jpg, bmp, gif, png, etc Access image pixel data as Numeric Python arrays Blitting with colorkey and alpha support Multiple mixing sound channels Streaming music data; mp3, mod, wav, etc CDROM support with audio playback Joystick support Truetype font rendering, with antialiasing Multithreaded support The pygame package also comes with complete documentation, tutorials, and many playable examples. The pygame mailing list has an active list of users, which makes getting started much more accessable. Currently installable from source, RPM, or Windows Installer. Pygame is distributed under the LGPL licese, which is the same license used by many its dependencies. There are several types of distributions for download; RPM, Precompiled Win32, and Source. From jschmitt at vmlabs.com Wed Feb 14 07:13:14 2001 From: jschmitt at vmlabs.com (John Schmitt) Date: Tue, 13 Feb 2001 22:13:14 -0800 Subject: passing object methods to os.path.walk ? Message-ID: <008F0A63472BD311AF9800104BCD102561CC85@minirex.vmlabs.com> I did something like this: class foo: def __init__(self): os.path.walk( self.stuff, self.slurp, self.otherstuff ) def slurp(self): #some code here and I got a 'TypeError: too many arguments; expected 3, got 4' message from ntpath.py line 264 which reads func( arg, top, names ) I fixed this by moving the slurp() function out of class foo and made it a function outside of any class. I don't get what's going on here. Is there an entry in TFM for this? BTW, Python 2.0 on Win2000 John From porter at et.byu.edu Wed Feb 14 07:15:20 2001 From: porter at et.byu.edu (C. Porter Bassett) Date: Tue, 13 Feb 2001 23:15:20 -0700 (MST) Subject: Python profiler In-Reply-To: <008F0A63472BD311AF9800104BCD102561CC85@minirex.vmlabs.com> Message-ID: In the profiler module, function sort_stats, what exactly is the difference between "time" and "cumulative" as arguments? I looked in the docs, but it didn't explain it very well. From fredrik at pythonware.com Wed Feb 14 12:07:33 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 14 Feb 2001 11:07:33 GMT Subject: passing object methods to os.path.walk ? References: Message-ID: John Schmitt wrote: > I did something like this: > > class foo: > def __init__(self): > os.path.walk( self.stuff, self.slurp, self.otherstuff ) > def slurp(self): > #some code here does "something like" mean: def slurp(arg, top, names): # correct if slurp is a function, wrong if it's a method or def slurp(self, arg, top, names): # wrong if slurp is a function, correct if it's a method > and I got a 'TypeError: too many arguments; expected 3, got 4' message from > ntpath.py line 264 which reads > > func( arg, top, names ) os.path.walk calls the callback with three arguments. If you use a bound instance method as callback, Python inserts the instance (self) first in the argument list. Cheers /F From chris at collegewafer.com Wed Feb 14 10:18:16 2001 From: chris at collegewafer.com (Chris Baker) Date: Wed, 14 Feb 2001 04:18:16 -0500 Subject: Hi, Need 6"-8" Wafer Special! Si, SOI, ZnO, MEMS & More! Message-ID: <200102140918.DAA22252@ionet.net> Hi, Let CollegeWafer.com take care of your wafer needs! Save time and $$$ It's a FREE service to you! Visit http://www.collegewafer.com or call 800-713-9375, Fax 888-832-0340 or email chris at collegewafer.com We have AIN, Fused Silica, Pyrex, GaN, SiC, ZnO of course Si, SOI, Ultra-Thin Si, Ge, InP, ZnSe, ZnO, ZnS, GaP, Infrared and so much more, including: Custom orders for Prime wafers, Test wafers, or Coin Roll wafers. 5" N<100> 5-10 ohm-cm. 24-25.9mils 5" N <100> 10-20 ohm-cm. 24-26mils 5" P<100> 5-10 ohm-cm. 24-25.9mils 5" P<100> 10-20 ohm-cm. 24-25.9mils 6" N<100> 1-5 ohm-cm. 25-27.9mils 6" N<100> 10-20 ohm-cm. 585-725?m 6" N<100> 10-20 ohm-cm. >650?m 6" N<100> 20-30 ohm-cm. 625-725?m 6" N<100> 20-30 ohm-cm. 25-27.5mils 6" P<100> 1-10 ohm-cm. 625-725?m 6" P<100> 10-20 ohm-cm. 625-725?m 6" P<100> 2-15 ohm-cm. 625-725?m 6" P<100> >30 ohm-cm. 25-27.5mils 8" P<100> 1-10 ohm-cm. 675-775?m 8" P<100> 10-20 ohm-cm. 675-775?m 8" P<100> 10-20 ohm-cm. 700-750?m 8" P<100> 10-20 ohm-cm. 700-750?m 12" P <100> 1-100 ohm-cm.750-800?m Polishing and Reclaim: We can polish test and prime wafers at better than SEMI standard specifications. Need Wafer inspection services? Test your wafers for type, resistivity, thickness, TIR, STIR, TTV, FPD and cleanliness analysis. How about: Cleaning, Lapping, Etching, Edge round, graphic printouts (2D & 3D), Certificate of Conformance, Certificate of Analysis, Polishing, Reclaim Services, Laser-cutting and Oxide Services Ask about In-House Oxide Services: Thermally grown oxide for 2"-8" wafers ranging in thickness from 500-100,000 Angstroms. http://www.collegewafer.com/contact_us/Remove/remove.html 11ada22 From latlong at css2.com Wed Feb 14 10:34:31 2001 From: latlong at css2.com (LatLong) Date: Wed, 14 Feb 2001 09:34:31 GMT Subject: ANN: Latitude longitude database Message-ID: Latitude longitude database of over 2.8 million locations worldwide. Download from: http://www.css2.com/latlong.htm Ideal for sales and marketing applications and travel related websites. Includes sample code. From un4e at rzstud1.rz.uni-karlsruhe.de Wed Feb 14 10:51:07 2001 From: un4e at rzstud1.rz.uni-karlsruhe.de (Bjoern Giesler) Date: 14 Feb 2001 09:51:07 GMT Subject: Getting an instance's class name? Message-ID: <96dkeb$fcj$1@news.rz.uni-karlsruhe.de> Hi, can anyone tell me how to obtain the name(s) of the class(es) that constitute an instance's type? Thanks in advance, --Bj?rn From smigowsky at dspace.de Wed Feb 14 11:08:41 2001 From: smigowsky at dspace.de (Stefan Migowsky) Date: Wed, 14 Feb 2001 11:08:41 +0100 Subject: AW: Getting an instance's class name? Message-ID: <84257D042AA7D411B3F700D0B7DB9B7C13A93B@newsintern.dspace.de> Hi, try >>> class A: ... pass ... >>> C = A() >>> C.__class__ >>> C.__class__.__name__ 'A' >>> Stefan -----Urspr?ngliche Nachricht----- Von: Bjoern Giesler [mailto:un4e at rzstud1.rz.uni-karlsruhe.de] Gesendet: Mittwoch, 14. Februar 2001 10:51 An: python-list at python.org Betreff: Getting an instance's class name? Hi, can anyone tell me how to obtain the name(s) of the class(es) that constitute an instance's type? Thanks in advance, --Bj?rn -- http://mail.python.org/mailman/listinfo/python-list From stephen_purcell at yahoo.com Wed Feb 14 11:31:29 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Wed, 14 Feb 2001 11:31:29 +0100 Subject: Getting an instance's class name? References: <96dkeb$fcj$1@news.rz.uni-karlsruhe.de> Message-ID: <20010214113129.A9420@freedom.puma-ag.com> Bjoern Giesler wrote: > can anyone tell me how to obtain the name(s) of the class(es) that > constitute an instance's type? > With the '__class__' attribute of the instance, and the '__name__' attribute of the class: >>> p = Exception() >>> p.__class__.__name__ 'Exception' >>> Note that you'll get an attribute error for objects that are not class instances. For non-class instances, a handy way to get the type name is: >>> p = 1 >>> type(p).__name__ 'int' >>> -Steve -- Steve Purcell, Pythangelist http://pyunit.sourceforge.net/ http://pyserv.sourceforge.net/ Available for consulting and training. "Even snakes are afraid of snakes." -- Steven Wright From un4e at rzstud1.rz.uni-karlsruhe.de Wed Feb 14 15:50:21 2001 From: un4e at rzstud1.rz.uni-karlsruhe.de (Bjoern Giesler) Date: 14 Feb 2001 14:50:21 GMT Subject: Getting an instance's class name? References: <96dkeb$fcj$1@news.rz.uni-karlsruhe.de> Message-ID: <96e5vd$d98$1@news.rz.uni-karlsruhe.de> Hi, thanks to all... sorry, that wasn't too smart of me :-) Regards, --Bj?rn From alberik at gmx.de Wed Feb 14 11:08:19 2001 From: alberik at gmx.de (Thomas Off) Date: Wed, 14 Feb 2001 11:08:19 +0100 Subject: PHP und remote files Message-ID: <96dlf3$kms4b$1@ID-66991.news.dfncis.de> Wie kann ich remote files, in denen wiederum PHP-Code steckt in meine PHP-Files einbinden, so dass der Code aus dem remote file auch verarbeitet wird? MfG Thomas Off From alberik at gmx.de Wed Feb 14 11:10:29 2001 From: alberik at gmx.de (Thomas Off) Date: Wed, 14 Feb 2001 11:10:29 +0100 Subject: PHP und remote files References: <96dlf3$kms4b$1@ID-66991.news.dfncis.de> Message-ID: <96dljn$kbuk0$1@ID-66991.news.dfncis.de> Sorry, falsche Newsgroup! Thomas Off Thomas Off schrieb in im Newsbeitrag: 96dlf3$kms4b$1 at ID-66991.news.dfncis.de... > Wie kann ich remote files, in denen wiederum PHP-Code steckt in meine > PHP-Files einbinden, so dass der Code aus dem remote file auch verarbeitet > wird? > > MfG Thomas Off > > From mix77 at usa.net Wed Feb 14 11:58:40 2001 From: mix77 at usa.net (Mix) Date: Wed, 14 Feb 2001 12:58:40 +0200 Subject: Image Manipulation Message-ID: <3A8A64E0.EF55A2CA@usa.net> How does one rotate an image (like gif,jpg,etc) using Python (cgi). Also, how can one resize an image? What I am trying to do is load an image in a browser (Netscape, say) and the allow the user to rotate and resize the image to fit in a window so as print it. From rtrocca at libero.it Thu Feb 15 08:26:26 2001 From: rtrocca at libero.it (Riccardo Trocca) Date: Thu, 15 Feb 2001 07:26:26 GMT Subject: Image Manipulation References: <3A8A64E0.EF55A2CA@usa.net> Message-ID: <1eou9rm.1l3ednv1uee4e8N%rtrocca@libero.it> Try using PIL from pythonware. URL should be www.pythonware.com Mix wrote: > How does one rotate an image (like gif,jpg,etc) using Python (cgi). > Also, > how can one resize an image? What I am trying to do is load an image > in a browser (Netscape, say) and the allow the user to rotate and resize > > the image to fit in a window so as print it. From bk at xk7.com Wed Feb 14 12:12:20 2001 From: bk at xk7.com (Burkhard Kloss) Date: Wed, 14 Feb 2001 11:12:20 -0000 Subject: Type Hierarchies Message-ID: <982149142.9745@master.nyc.kbcfp.com> Is there a way to check whether an object is a sequence? I'm not interested in the specific type, just that it qualifies as a sequence, so it could be built-in or user defined sequence. The language spec talks about type hierarchies, but if there's any way to access that concept in code I must have missed it. Obviously I can try a call, and catch the exception: def is_seq(a): try: len(a) return 1 except: return 0 which works: assert is_seq( [] ) assert is_seq( () ) assert is_seq( "" ) assert not is_seq( 1 ) but isn't very elegant. It's probably also not very fast... Am I missing something obvious here? Are there better ways? Thanks, Burkhard From stephen_purcell at yahoo.com Wed Feb 14 12:40:02 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Wed, 14 Feb 2001 12:40:02 +0100 Subject: Type Hierarchies In-Reply-To: <982149142.9745@master.nyc.kbcfp.com>; from bk@xk7.com on Wed, Feb 14, 2001 at 11:12:20AM -0000 References: <982149142.9745@master.nyc.kbcfp.com> Message-ID: <20010214124002.A13418@freedom.puma-ag.com> Burkhard Kloss wrote: > Is there a way to check whether an object is a sequence? I'm not interested > in the specific type, just that it qualifies as a sequence, so it could be > built-in or user defined sequence. The language spec talks about type > hierarchies, but if there's any way to access that concept in code I must > have missed it. There's no real way to do this. As I spotted at the end of one of Tim Peters' posts on this topic, "in-Python-what-you-want-to-do-with-an-object-is-more-important-than- what-you-call-it" > Obviously I can try a call, and catch the exception: > > def is_seq(a): > try: > len(a) > return 1 > except: > return 0 This kind of thing is probably the best that you can hope for. The most pythonic way (shocking though it may sound to some) is to throw the object you hope is a sequence into the function that will use it, and test that in ordinary use of your system the function always works correctly. -Steve -- Steve Purcell, Pythangelist http://pyunit.sourceforge.net/ http://pyserv.sourceforge.net/ Available for consulting and training. "Even snakes are afraid of snakes." -- Steven Wright From erno-news at erno.iki.fi Wed Feb 14 13:13:06 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 14 Feb 2001 14:13:06 +0200 Subject: Type Hierarchies References: <982149142.9745@master.nyc.kbcfp.com> Message-ID: In article <982149142.9745 at master.nyc.kbcfp.com>, "Burkhard Kloss" writes: | def is_seq(a): | try: | len(a) | return 1 | except: | return 0 len() also works on mappings. -- erno From sholden at holdenweb.com Wed Feb 14 13:30:00 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 14 Feb 2001 07:30:00 -0500 Subject: Type Hierarchies References: <982149142.9745@master.nyc.kbcfp.com> Message-ID: <6Xui6.9193$GA5.125501@e420r-atl1.usenetserver.com> "Burkhard Kloss" wrote in message news:982149142.9745 at master.nyc.kbcfp.com... > Is there a way to check whether an object is a sequence? I'm not interested > in the specific type, just that it qualifies as a sequence, so it could be > built-in or user defined sequence. The language spec talks about type > hierarchies, but if there's any way to access that concept in code I must > have missed it. > > Obviously I can try a call, and catch the exception: > > def is_seq(a): > try: > len(a) > return 1 > except: > return 0 > > which works: > > assert is_seq( [] ) > assert is_seq( () ) > assert is_seq( "" ) > assert not is_seq( 1 ) > > but isn't very elegant. It's probably also not very fast... > > Am I missing something obvious here? Are there better ways? > > Thanks, > > Burkhard > Well, this might cause you to think again: >>> tbl = {1:'one', 2:'two'} >>> len(tbl) 2 Sorry. regards Steve From teep at inet.co.th Wed Feb 14 14:02:46 2001 From: teep at inet.co.th (Prateep Siamwalla) Date: Wed, 14 Feb 2001 20:02:46 +0700 Subject: Type Hierarchies References: <982149142.9745@master.nyc.kbcfp.com> Message-ID: <96dvfs$rbq$1@news.inet.co.th> Hi, after browsing through D.Beazley's Python Essential Reference (p 20), I believe this is what you are looking for ... (apologies if I'm way off) import types def am_i_a_sequence(ob): return type(ob) in [types.StringType,types.ListType,types.TupleType,types.XRangeType] hope this helps, ['t','e','e','p'] Burkhard Kloss wrote in message news:982149142.9745 at master.nyc.kbcfp.com... > Is there a way to check whether an object is a sequence? I'm not interested > in the specific type, just that it qualifies as a sequence, so it could be > built-in or user defined sequence. The language spec talks about type > hierarchies, but if there's any way to access that concept in code I must > have missed it. > > Obviously I can try a call, and catch the exception: > > def is_seq(a): > try: > len(a) > return 1 > except: > return 0 > > which works: > > assert is_seq( [] ) > assert is_seq( () ) > assert is_seq( "" ) > assert not is_seq( 1 ) > > but isn't very elegant. It's probably also not very fast... > > Am I missing something obvious here? Are there better ways? > > Thanks, > > Burkhard > > > > From bk at xk7.com Wed Feb 14 16:35:51 2001 From: bk at xk7.com (Burkhard Kloss) Date: Wed, 14 Feb 2001 15:35:51 -0000 Subject: Type Hierarchies References: <982149142.9745@master.nyc.kbcfp.com> <96dvfs$rbq$1@news.inet.co.th> Message-ID: <982164952.565065@master.nyc.kbcfp.com> Thanks to all the people who reminded me that len() also works on mappings ... > def am_i_a_sequence(ob): > return type(ob) in > [types.StringType,types.ListType,types.TupleType,types.XRangeType] Yes, this works great for the built-in types - but not for user defined types, which is specifically what I'm after. > ['t','e','e','p'] :) I guess concretely, the problem I'm trying to solve is iterating over a sequence which may contain sequences or items, e.g. [1, [2,3], 4, 5, [6,7,8,9]] and I was hoping to write something along the lines of for item in sequence: if is_sequence (item): for it in sequence: process (it) else: process (item) Which IMHO looks marginally cleaner than for item in sequence: try: for it in sequence: process (it) except: process (item) Although I guess what I should really do is for item in flatten(sequence): process (item) Hmmm.... now how do I effectively flatten a sequence ? From cjc26 at nospam.cornell.edu Wed Feb 14 21:26:55 2001 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Wed, 14 Feb 2001 20:26:55 GMT Subject: Type Hierarchies References: <982149142.9745@master.nyc.kbcfp.com> <96dvfs$rbq$1@news.inet.co.th> <982164952.565065@master.nyc.kbcfp.com> Message-ID: * Burkhard Kloss menulis: | | I guess concretely, the problem I'm trying to solve is iterating over a | sequence which may contain sequences or items, e.g. | | [1, [2,3], 4, 5, [6,7,8,9]] | | and I was hoping to write something along the lines of | | for item in sequence: | if is_sequence (item): | for it in sequence: | process (it) | else: | process (item) Well, 'for' uses the __getitem__ method to iterate through the items of its sequence, so what you could do is check if the object has a __getitem__ method: for item in sequence: if hasattr(item, "__getitem__"): for it in item: process(it) else: process(item) You'll run into problems though if the object implements a __getitem__ which doesn't ever throw an IndexError, because then the loop will go on forever. Also, I just tried this out on built-in sequences (lists and tuples), and apparently they don't have __getitem__()...? | Which IMHO looks marginally cleaner than | | for item in sequence: | try: | for it in sequence: | process (it) | except: | process (item) This is kind of unsafe, because the "except:" will catch any exception, not just TypeError (which is what gets raised when you try to iterate over a non-sequence). -- Cliff Crawford http://www.people.cornell.edu/pages/cjc26/ "huh? Are you all there? You missing some key parts up there? Becoming a English major or an minor? Do you need a annual report? Are you slow today, eh? Did someone sever you parietal lobe?" - Mark From me at nospam.net Thu Feb 15 07:13:34 2001 From: me at nospam.net (Scottie) Date: Wed, 14 Feb 2001 22:13:34 -0800 Subject: Type Hierarchies References: <982149142.9745@master.nyc.kbcfp.com> <96dvfs$rbq$1@news.inet.co.th> <982164952.565065@master.nyc.kbcfp.com> Message-ID: Well, I'd suggest you think of what you mean by "flatten". It has the same problem that something like "deepCopy" does: who knows when you cross the boundary between interface and implementation. If you have a list of numbers, and it turns out that my implementation of rationals responds to "len," do you intend to iterate ove the interior of my implementation? How about a new version of "long" which allows access to the individual 16-bit elements of its representation? I guess what I am saying is that "recurse through sequences and sequence-like objects may be a surprisingly ill-defined operation. -Scott David Daniels Scott.Daniels at Acm.Org "Burkhard Kloss" wrote in message news:982164952.565065 at master.nyc.kbcfp.com... > Thanks to all the people who reminded me that len() also works on mappings > ... > > > def am_i_a_sequence(ob): > > return type(ob) in > > [types.StringType,types.ListType,types.TupleType,types.XRangeType] > > Yes, this works great for the built-in types - but not for user defined > types, which is specifically what I'm after. > > > ['t','e','e','p'] > :) > > I guess concretely, the problem I'm trying to solve is iterating over a > sequence which may contain sequences or items, e.g. > > [1, [2,3], 4, 5, [6,7,8,9]] > > and I was hoping to write something along the lines of > > for item in sequence: > if is_sequence (item): > for it in sequence: > process (it) > else: > process (item) > > Which IMHO looks marginally cleaner than > > for item in sequence: > try: > for it in sequence: > process (it) > except: > process (item) > > Although I guess what I should really do is > > for item in flatten(sequence): > process (item) > > Hmmm.... now how do I effectively flatten a sequence ? > > From bk at xk7.com Thu Feb 15 19:53:58 2001 From: bk at xk7.com (Burkhard Kloss) Date: Thu, 15 Feb 2001 18:53:58 -0000 Subject: Type Hierarchies References: <982149142.9745@master.nyc.kbcfp.com> <96dvfs$rbq$1@news.inet.co.th> <982164952.565065@master.nyc.kbcfp.com> Message-ID: <982263239.671435@master.nyc.kbcfp.com> > I guess what I am saying is that "recurse through sequences and > sequence-like objects may be a surprisingly ill-defined operation. In general, yes - but thankfully in my particular application context its is well defined. Thanks for pointingit out though. From porter at et.byu.edu Mon Feb 26 05:29:56 2001 From: porter at et.byu.edu (C. Porter Bassett) Date: Sun, 25 Feb 2001 21:29:56 -0700 (MST) Subject: Recursive Directory Contents In-Reply-To: References: <982149142.9745@master.nyc.kbcfp.com> <96dvfs$rbq$1@news.inet.co.th> <982164952.565065@master.nyc.kbcfp.com> Message-ID: Is there a common module out there that will recursively record the contents of a directory? I want to use it to do tests to see what files have been modified since last check. From brian at sweetapp.com Mon Feb 26 06:44:34 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Sun, 25 Feb 2001 21:44:34 -0800 Subject: Recursive Directory Contents In-Reply-To: Message-ID: Try looking at the "walk" function in "os.path". -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of C. Porter Bassett Sent: Sunday, February 25, 2001 8:30 PM To: python-list at python.org Cc: python-list at python.org Subject: Recursive Directory Contents Is there a common module out there that will recursively record the contents of a directory? I want to use it to do tests to see what files have been modified since last check. -- http://mail.python.org/mailman/listinfo/python-list From f8dy at yahoo.com Mon Feb 26 17:24:48 2001 From: f8dy at yahoo.com (Mark Pilgrim) Date: Mon, 26 Feb 2001 11:24:48 -0500 Subject: Recursive Directory Contents References: <982149142.9745@master.nyc.kbcfp.com> <96dvfs$rbq$1@news.inet.co.th> <982164952.565065@master.nyc.kbcfp.com> Message-ID: <97dvtb$ovqli$1@ID-77331.news.dfncis.de> The os.path module has a wonderful method called "walk", which takes a root directory, a function, and an arbitrary argument. It recursively walks through the root directory, calling the function with 3 parameters: , , . For example, this script will find all the files anywhere within the "/music" directory that have been modified since Feb 15, 2001, store them (with fully qualified paths) in modifiedFilesWithPaths, and then print them. ----- import os import time def mtimeChecker(arg, dirname, fileList): (mtime, modifiedList) = arg for f in [os.path.join(dirname, file) for file in fileList]: if os.path.getmtime(f) > mtime: modifiedList.append(f) modifiedFilesWithPaths = [] os.path.walk('/music', mtimeChecker, \ (time.mktime((2001, 2, 15, 0, 0, 0, 0, 0, 0)), \ modifiedFilesWithPaths)) for f in modifiedFilesWithPaths: print f ----- -M You're smart; why haven't you learned Python yet? http://diveintopython.org/ "C. Porter Bassett" wrote in message news:mailman.983161805.496.python-list at python.org... > Is there a common module out there that will recursively record the > contents of a directory? I want to use it to do tests to see what files > have been modified since last check. > > > > From andrew at andrewcooke.free-online.co.uk Wed Feb 14 15:32:37 2001 From: andrew at andrewcooke.free-online.co.uk (Andrew Cooke) Date: Wed, 14 Feb 2001 14:32:37 +0000 Subject: Type Hierarchies References: <982149142.9745@master.nyc.kbcfp.com> Message-ID: <3A8A9705.7F10944B@andrewcooke.free-online.co.uk> Often you can avoid testing types by making sure that all types that you use implement whatever you require. Rather than, for example, testing for the type of something so that you can infer whether or not to use len, it might be easier to include something that implements __len__ somewhere in the superclasses fo whatever you are manipulating. DOn't forget that Python has multiple inheritance, so this isn't hard (a lot easier than Java!). I don't know if it helps in your case, but it's a pretty standard way to avoid tests with OO languages. Sorry if I'm saying the obvious. Andrew Burkhard Kloss wrote: > > Is there a way to check whether an object is a sequence? I'm not interested > in the specific type, just that it qualifies as a sequence, so it could be > built-in or user defined sequence. The language spec talks about type > hierarchies, but if there's any way to access that concept in code I must > have missed it. > > Obviously I can try a call, and catch the exception: > > def is_seq(a): > try: > len(a) > return 1 > except: > return 0 > > which works: > > assert is_seq( [] ) > assert is_seq( () ) > assert is_seq( "" ) > assert not is_seq( 1 ) > > but isn't very elegant. It's probably also not very fast... > > Am I missing something obvious here? Are there better ways? > > Thanks, > > Burkhard From bk at xk7.com Wed Feb 14 12:20:16 2001 From: bk at xk7.com (Burkhard Kloss) Date: Wed, 14 Feb 2001 11:20:16 -0000 Subject: overloading on type? Message-ID: <982149618.95754@master.nyc.kbcfp.com> One design problem I run across frequently in Python is how to nicely deal with different types of arguments. For example, writing a date class you'd often have overloaded constructors in a statically typed language like C++: class date { public: date (const date &); date (const string &); date (long); in python, I catch myself writing things along the lines of class date: def __init__ (self, arg): if type(arg) == types.InstanceType: .... elif type(arg) == types.IntType: ... which works, but just seems so *wrong*. Maybe I'm just having a conceptual block here as a result of my upbringing (I'm a longtime and unrepentant C++ user and lover), but surely in a language as nice as python there must be a better way to do this? :) Overloading obviously doesn't fit into the conceptual framework of the language. Thoughts, anyone? Burkhard From stephen_purcell at yahoo.com Wed Feb 14 12:47:10 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Wed, 14 Feb 2001 12:47:10 +0100 Subject: overloading on type? In-Reply-To: <982149618.95754@master.nyc.kbcfp.com>; from bk@xk7.com on Wed, Feb 14, 2001 at 11:20:16AM -0000 References: <982149618.95754@master.nyc.kbcfp.com> Message-ID: <20010214124710.B13418@freedom.puma-ag.com> Burkhard Kloss wrote: > in python, I catch myself writing things along the lines of > > class date: > def __init__ (self, arg): > if type(arg) == types.InstanceType: > .... > elif type(arg) == types.IntType: > ... > > which works, but just seems so *wrong*. There are cases where this sort of type check is the best way to make a clear API. A solution might be: class Date: def __init__(self, millis): # construct with int or long self.millis = millis def parse_date(str): millis = ... return Date(millis) This is quite common in the standard libraries. There are many module-level functions that 'return an object of type ...', and the mechanism for constructing such objects directly is deliberately obscured. Modules form a convenient namespace for factory methods. -Steve -- Steve Purcell, Pythangelist http://pyunit.sourceforge.net/ http://pyserv.sourceforge.net/ Available for consulting and training. "Even snakes are afraid of snakes." -- Steven Wright From oconnor at bioreason.com Wed Feb 14 16:53:58 2001 From: oconnor at bioreason.com (Jay O'COnnor) Date: Wed, 14 Feb 2001 08:53:58 -0700 Subject: overloading on type? References: <982149618.95754@master.nyc.kbcfp.com> Message-ID: <3A8AAA14.EF207BA7@bioreason.com> Burkhard Kloss wrote: > One design problem I run across frequently in Python is how to nicely deal > with different types of arguments. For example, writing a date class you'd > often have overloaded constructors in a statically typed language like C++: > > class date > { > public: > date (const date &); > date (const string &); > date (long); > > in python, I catch myself writing things along the lines of > > class date: > def __init__ (self, arg): > if type(arg) == types.InstanceType: > .... > elif type(arg) == types.IntType: > ... > > which works, but just seems so *wrong*. > > Maybe I'm just having a conceptual block here as a result of my upbringing > (I'm a longtime and unrepentant C++ user and lover), but surely in a > language as nice as python there must be a better way to do this? :) > Overloading obviously doesn't fit into the conceptual framework of the > language. One approach you can use is called "Double Dispatch". This will allow you to resolve to a specific method from a general method based on the type of the argument; even in dynamically bound languages susch as Python and Smalltalk. The approach is to get the argument invovled in the decision as well. Your receiver object calls back to the argument object telling it to do something with itself. The argument object, in turn, calls back to the first object with a specific message based on it's own type (which it already knows) Here's an example using a simple DrawingContext and Shape hierarchy #!/usr/bin/python #covarient.py class DrawingContext: def drawShape (self, aShape): aShape.drawOn(self) def drawCircle (self, aCircle): print "Drawing circle at " + aCircle.printLocation() def drawSquare (self, aSquare): print "Drawing square at " + aSquare.printLocation() class Shape: def __init__(self, x=0, y=0): self.x = x self.y = y def printLocation (self): return "X = " + `self.x` + " Y= " + `self.y` def drawOn(self, aDrawingContext): #Abstract method pass class Circle(Shape): def __init__ (self, x=0, y=0, radius=0): Shape.__init__(self, x,y) self.radius = radius def printLocation (self): return Shape.printLocation(self) + " Radius = " + `self.radius` def drawOn (self, aDrawingContext): aDrawingContext.drawCircle(self) class Square(Shape): def __init__ (self, x=0, y=0, sideLength=0): Shape.__init__(self, x,y) self.sideLength = sideLength def printLocation (self): return Shape.printLocation(self) + " Side Length = " + `self.sideLength` def drawOn (self, aDrawingContext): aDrawingContext.drawSquare(self) # Test script starts here dc = DrawingContext() circle = Circle (x=100,y=200,radius=5) square = Square (x=10,y=150, sideLength=10) dc.drawShape( circle) dc.drawShape (square) and here's the output [jay at altaica misc_junk]$ ./covarient.py Drawing circle at X = 100 Y= 200 Radius = 5 Drawing square at X = 10 Y= 150 Side Length = 10 (Note: it's called covarient.py because I took it from some sample code I posted in another message forum about covarients in Java) The way it works is that the DrawingContext object must draw the shape, but it draws it in a different manner based on what kind of shape it is. So it tells the given shape to draw on itself (the canvas) The shape then calls back to the DrawingContext with the message for the specific drawing operation (drawCircle(), etc) This works very well at resolving from an abstract interface to a specific operation based on the tyhpes of both objects. It does, however, require that you be able to add code to both partners of the operation. If this is not possible, I usually use an approach of building a Dictionary where the keys are the type and the values are the methods to call. I thjink this looks a little cleaner than having an 'if' conditional. import types class Date: def __init__(self, fromObject) initializer =initOperations[type(fromObject)] initializer (self, fromObject) def initializeFromInt(self, anInt): pass def initializeFromInstance (self, anInstance): pass initOperations = { types.IntType:Date.initializeFromInt, types.InstanceType: Date.initializeFromInstance} Note: I haven't tested that, but you get the idea. I consider this second approach a not very good one and only appropriate if I need to make such a decisision either using primitive types or third party objects that I can't add the douple dispatch support to Take care, Jay O'Connor joconor at cybermesa.com Python Language Discussion Forum - http://pub1.ezboard.com/fobjectorienteddevelopmentpython From froydnj at rose-hulman.edu Thu Feb 15 06:20:46 2001 From: froydnj at rose-hulman.edu (Nathan Froyd) Date: 15 Feb 2001 05:20:46 GMT Subject: overloading on type? References: <982149618.95754@master.nyc.kbcfp.com> Message-ID: In article <982149618.95754 at master.nyc.kbcfp.com>, Burkhard Kloss wrote: >Maybe I'm just having a conceptual block here as a result of my upbringing >(I'm a longtime and unrepentant C++ user and lover), but surely in a >language as nice as python there must be a better way to do this? :) >Overloading obviously doesn't fit into the conceptual framework of the >language. You might try Multimethod.py: http://www.sff.net/people/neelk/open-source/ It might not do *exactly* what you want (I don't know if you can specialize on built-in datatypes and I don't know what the speed is like), but it's probably a good starting point. -- froydnj at rose-hulman.edu | http://www.rose-hulman.edu/~froydnj/ Yes, God had a deadline. So He wrote it all in Lisp. From neelk at alum.mit.edu Fri Feb 16 17:11:03 2001 From: neelk at alum.mit.edu (Neelakantan Krishnaswami) Date: 16 Feb 2001 16:11:03 GMT Subject: overloading on type? References: <982149618.95754@master.nyc.kbcfp.com> Message-ID: On 15 Feb 2001 05:20:46 GMT, Nathan Froyd wrote: >In article <982149618.95754 at master.nyc.kbcfp.com>, Burkhard Kloss wrote: >>Maybe I'm just having a conceptual block here as a result of my upbringing >>(I'm a longtime and unrepentant C++ user and lover), but surely in a >>language as nice as python there must be a better way to do this? :) >>Overloading obviously doesn't fit into the conceptual framework of the >>language. > >You might try Multimethod.py: > >http://www.sff.net/people/neelk/open-source/ > > It might not do *exactly* what you want (I don't know if you can > specialize on built-in datatypes and I don't know what the speed is > like), but it's probably a good starting point. Yes, you can specialize on C types. Unlike C++ overloading, this does real multiple dispatch -- the overloading is resolved based on the *runtime* class of the methods, not the static type. Thes performance overhead is about what you'd expect from wrapping something with a __call__ method. Neel From gregm at iname.com Wed Feb 14 12:54:18 2001 From: gregm at iname.com (Greg McFarlane) Date: Wed, 14 Feb 2001 22:54:18 +1100 Subject: ANNOUNCE: Pmw megawidgets 0.8.5 Message-ID: Pmw megawidgets Pmw.0.8.5 * Python 2.0 release * Pmw moved to SourceForge Pmw new home: http://pmw.sourceforge.net/ Pmw maintainer: Greg McFarlane A new release of Pmw is out. This is mainly a bug fix release for python 2.0, fixing a problem with Pmw.Counter caused by a change in the ascii representation of a long (no 'L'). Also, the home for Pmw development has moved to SourceForge. The Pmw sources and documentation are under CVS control and releases can be downloaded from there. I would like to thank Graham Dumpleton for allowing Pmw to be hosted at his web site for so long. I hope SourceForge will match the stability of Pmw's old site. Other changes in this release are: - Minor fixes to tests for Tk 8.3. - Fixed bug in Pmw.ScrolledFrame when given invalid flex options. - Added pmw2 font scheme, since the font used for balloon text with pmw1 is too small on Linux. - Removed syntax coloring from code window in demos. It did not look good and the pattern matching was not always correct. - Changed font size used for demos to 12 for Unix, since 14 looked too big under Linux. For more information on Pmw, see the (new) home page at http://pmw.sourceforge.net/ You can fetch the entire distribution from http://download.sourceforge.net/pmw/Pmw.0.8.5.tar.gz If you have any comments, enhancements or new contributions, please contact me (gregm at iname.com). ===================================================================== What is Pmw? Pmw is a GUI toolkit for building high-level compound widgets in Python using the Tkinter module. These compound widgets, called 'megawidgets', are constructed using other Tkinter widgets or Pmw megawidgets as component parts. It promotes consistent look and feel within and between graphical applications, is highly configurable and is easy to use. Pmw consists of: - A few base classes, providing a foundation for building megawidgets. - A library of flexible and extensible megawidgets built on the base classes, such as buttonboxes, notebooks, comboboxes, selection widgets, paned widgets, scrolled widgets and dialog windows. - A lazy importer/dynamic loader which is automatically invoked when Pmw is first imported. This gives unified access to all Pmw classes and functions through the Pmw. prefix. It also speeds up module loading time by only importing Pmw sub-modules when needed. - Reference documentation, consisting of complete listings of megawidget options, methods and components. Full descriptions are also available for all the base classes and several other megawidget classes. Descriptions of the other megawidgets will be released soon. - A test framework and tests for Pmw megawidgets. - A slick demonstration of the megawidgets. - An interface to the BLT busy, graph and vector commands. The interface to Pmw megawidgets is similar to basic Tk widgets, so it is easy for developers to include both megawidgets and basic Tk widgets in their graphical applications. In addition, Pmw megawidgets may themselves be extended, using either inheritance or composition. The use of the Pmw megawidgets replaces common widget combinations with higher level abstractions. This simplifies code, making it more readable and maintainable. The ability to extend Pmw megawidgets enables developers to create new megawidgets based on previous work. -- Greg McFarlane Really Good Software Pty Ltd Sydney Australia gregm at iname.com From rytrom at zoote.com Wed Feb 14 13:13:22 2001 From: rytrom at zoote.com (Roman Rytov) Date: Wed, 14 Feb 2001 14:13:22 +0200 Subject: Difference btw JPython and Jython? Message-ID: Is there any difference btw them or it has as much common things as Java and JavaScript:-)) From sholden at holdenweb.com Wed Feb 14 14:12:47 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 14 Feb 2001 08:12:47 -0500 Subject: Difference btw JPython and Jython? References: Message-ID: "Roman Rytov" wrote in message news:newscache$j4yq8g$kca$1 at lnews.actcom.co.il... > Is there any difference btw them or it has as much common things as Java and > JavaScript:-)) > Jython is the name for the current implementation of what used to be JPython. This latter name is trademarked by CNRI, Guido's former employer. regards Steve From hamish_lawson at yahoo.co.uk Wed Feb 14 13:44:59 2001 From: hamish_lawson at yahoo.co.uk (=?iso-8859-1?q?Hamish=20Lawson?=) Date: Wed, 14 Feb 2001 12:44:59 +0000 (GMT) Subject: Suggestion: Python tools book Message-ID: <20010214124459.18461.qmail@web217.mail.yahoo.com> I'd welcome a book that covered the more popular third-party toolkits for Python, plus those toolkits (*) in the standard library that could use more coverage than given in the library reference. Perhaps the various toolkit authors could contribute a respective chapter. Does the community think this kind of book is needed, and what toolkits should be included? Here's my stab at a list of candidates: wxPython DB-API Python Imaging Library Numerical Python mxDateTime mod_python / mod_snake HTMLgen mxTextTools ReportLab PyXML* TkInter* Hamish Lawson ===== Hamish Lawson hamish_lawson at yahoo.co.uk ____________________________________________________________ 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 sandipan at vsnl.com Wed Feb 14 14:17:32 2001 From: sandipan at vsnl.com (Sandipan Gangopadhyay) Date: Wed, 14 Feb 2001 18:47:32 +0530 Subject: Suggestion: Python tools book References: <20010214124459.18461.qmail@web217.mail.yahoo.com> Message-ID: <005101c09688$7dd1e440$020000c3@node02> Hear, hear ! Also: SSL socket stuff freeze/packaging Sandipan ----- Original Message ----- From: "Hamish Lawson" To: Sent: Wednesday, February 14, 2001 6:14 PM Subject: Suggestion: Python tools book > I'd welcome a book that covered the more popular third-party toolkits > for Python, plus those toolkits (*) in the standard library that could > use more coverage than given in the library reference. Perhaps the > various toolkit authors could contribute a respective chapter. Does the > community think this kind of book is needed, and what toolkits should > be included? Here's my stab at a list of candidates: > > wxPython > DB-API > Python Imaging Library > Numerical Python > mxDateTime > mod_python / mod_snake > HTMLgen > mxTextTools > ReportLab > PyXML* > TkInter* > > Hamish Lawson > > > ===== > Hamish Lawson hamish_lawson at yahoo.co.uk > > ____________________________________________________________ > 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 > > -- > http://mail.python.org/mailman/listinfo/python-list > From ljohnson at resgen.com Wed Feb 14 15:53:36 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Wed, 14 Feb 2001 08:53:36 -0600 Subject: Suggestion: Python tools book References: Message-ID: Hamish, There's a new book out from SAMS called "Python Developer's Handbook", by Andre Lessa. It appears to cover a lot of these topics that you mentioned and so you might want to check it out. I personally have not read this one and so this isn't an endorsement of the book! Lyle "Hamish Lawson" wrote in message news:mailman.982154801.10484.python-list at python.org... > I'd welcome a book that covered the more popular third-party toolkits > for Python, plus those toolkits (*) in the standard library that could > use more coverage than given in the library reference. Perhaps the > various toolkit authors could contribute a respective chapter. Does the > community think this kind of book is needed, and what toolkits should > be included? Here's my stab at a list of candidates: > > wxPython > DB-API > Python Imaging Library > Numerical Python > mxDateTime > mod_python / mod_snake > HTMLgen > mxTextTools > ReportLab > PyXML* > TkInter* > > Hamish Lawson > > > ===== > Hamish Lawson hamish_lawson at yahoo.co.uk > > ____________________________________________________________ > 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 pj at sgi.com Wed Feb 14 21:01:46 2001 From: pj at sgi.com (Paul Jackson) Date: 14 Feb 2001 20:01:46 GMT Subject: Suggestion: Python tools book References: Message-ID: <96eo7a$43422$1@fido.engr.sgi.com> |> There's a new book out from SAMS called "Python Developer's Handbook", by |> Andre Lessa. It appears to cover a lot of these topics that you mentioned Read the reviews of this book on amazon.com before buying it. I for one found the book rather lightweight (well, heavy by the pound, light by the technical depth), and ended up returning my copy. Some of the Amazon reviews are more positive than mine, but all the reviews seem to agree on what are the strengths and weaknesses of this book, so you should get a good idea of whether it fits your needs. -- I won't rest till it's the best ... Manager, Linux System Software Paul Jackson 1.650.933.1373 From rickylee at americasm01.nt.com Wed Feb 14 14:30:19 2001 From: rickylee at americasm01.nt.com (Lee, Rick) Date: Wed, 14 Feb 2001 08:30:19 -0500 Subject: StringType add operation seems every inefficient Message-ID: <3A8A886B.BB7329F6@americasm01.nt.com> If I do something like this: s = '' for i in listOfStrings: s = s + i Once listOfStrings is say 10000 members of 100 bytes, it takes forever (ie. minutes) for the "for" loop to finish. This is running on a 700MHz WinNT machine, Python 2.0 Contrast with: s = '' blocks = [] for i in listOfStrings: s = s + i if len(s) > 4000 blocks.append(s); s = '' This takes a blink of the eye to finish, so it is faster than the first piece of code by between 100 and 1000 times. Is this relative inefficiency in the string add operation expected? I eventually have to produce a big long string of approx. 10MB. What is the fastest way to do it without having to write C-extensions? - Rick Lee From jeremy at alum.mit.edu Tue Feb 13 16:00:14 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Tue, 13 Feb 2001 10:00:14 -0500 (EST) Subject: StringType add operation seems every inefficient In-Reply-To: <3A8A886B.BB7329F6@americasm01.nt.com> References: <3A8A886B.BB7329F6@americasm01.nt.com> Message-ID: <14985.19454.873485.617135@w221.z064000254.bwi-md.dsl.cnc.net> >>>>> "RL" == Lee, Rick writes: RL> If I do something like this: RL> s = '' RL> for i in listOfStrings: RL> s = s + i RL> Once listOfStrings is say 10000 members of 100 bytes, it takes RL> forever (ie. minutes) for the "for" loop to finish. This is RL> running on a 700MHz WinNT machine, Python 2.0 RL> Contrast with: RL> s = '' RL> blocks = [] RL> for i in listOfStrings: RL> s = s + i if len(s) > 4000 RL> blocks.append(s); s = '' RL> This takes a blink of the eye to finish, so it is faster than RL> the first piece of code by between 100 and 1000 times. RL> Is this relative inefficiency in the string add operation RL> expected? It is expected, because the string add version is doing something quite different than accumulator version. The 's = s + i' line is making a new string for each iteration of the loop. To make the new string, the interpreter allocates a new string object and copies the contents of s and i into it. It may help you to see what is happening if you unroll the loop by hand: s0 = '' s1 = s0 + listOfStrings[0] s2 = s1 + listOfStrings[1] # ~= s0 + listOfStrings[0] + listOfStrings[1] s3 = s2 + listOfStrings[2] # ~= s0 + listOfStrings[0] + listOfStrings[1] + listOfStrings[2] In the end, that's O(N) string allocations and O(N**2) string copies, where N is the length of listOfStrings. RL> I eventually have to produce a big long string of approx. 10MB. RL> What is the fastest way to do it without having to write RL> C-extensions? The second technique you show -- using a list to accumulate the individual strings -- is a standard Python idiom. At the end, you do "".join(blocks) or somesuch to produce a single string. This approach does exactly one copy for each constituent string. I believe someone also suggested using cStringIO, which is probably just as fast. Jeremy From jhauser at ifm.uni-kiel.de Wed Feb 14 14:46:11 2001 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 14 Feb 2001 14:46:11 +0100 Subject: StringType add operation seems every inefficient References: <3A8A886B.BB7329F6@americasm01.nt.com> Message-ID: <873ddh1ios.fsf@lisboa.ifm.uni-kiel.de> "Lee, Rick" writes: > If I do something like this: > > s = '' > for i in listOfStrings: > s = s + i > This always generates a new string object, so there is a lot of memory copies involved. > Once listOfStrings is say 10000 members of 100 bytes, it takes forever > (ie. minutes) for the "for" loop to finish. This is running on a 700MHz > WinNT machine, Python 2.0 > > Contrast with: > > s = '' > blocks = [] > for i in listOfStrings: > s = s + i > if len(s) > 4000 > blocks.append(s); s = '' > if you have the string parts already in a list and then do a string.join(listOfStrings) this should be much faster. (In Python2.0 this should be ''.join(list)) 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 fuess at att.net Wed Feb 14 14:48:31 2001 From: fuess at att.net (David Fuess) Date: Wed, 14 Feb 2001 13:48:31 GMT Subject: StringType add operation seems every inefficient References: <3A8A886B.BB7329F6@americasm01.nt.com> Message-ID: Don't really know if it was expected, but the presence of the StringIO module in both Python and "C" versions indicates that it was. For really fast performance in string concatenation, use cStringIO, for a somewhat slower but more feature rich implementation use StringIO. Dave On Wed, 14 Feb 2001 08:30:19 -0500, "Lee, Rick" wrote: >If I do something like this: > >s = '' >for i in listOfStrings: > s = s + i > >Once listOfStrings is say 10000 members of 100 bytes, it takes forever >(ie. minutes) for the "for" loop to finish. This is running on a 700MHz >WinNT machine, Python 2.0 > >Contrast with: > >s = '' >blocks = [] >for i in listOfStrings: > s = s + i > if len(s) > 4000 > blocks.append(s); s = '' > >This takes a blink of the eye to finish, so it is faster than the first >piece of code by between 100 and 1000 times. > >Is this relative inefficiency in the string add operation expected? > >I eventually have to produce a big long string of approx. 10MB. What is >the fastest way to do it without having to write C-extensions? > >- Rick Lee > > > > From rwklee at home.com Wed Feb 14 23:29:26 2001 From: rwklee at home.com (Rick Lee) Date: Wed, 14 Feb 2001 22:29:26 GMT Subject: StringType add operation seems every inefficient References: <3A8A886B.BB7329F6@americasm01.nt.com> Message-ID: <3A8B06C6.281511E3@home.com> Thank you all for your suggestions. I will try out both join() and cStringIO. "Lee, Rick" wrote: > If I do something like this: > > s = '' > for i in listOfStrings: > s = s + i > > Once listOfStrings is say 10000 members of 100 bytes, it takes forever > (ie. minutes) for the "for" loop to finish. This is running on a 700MHz > WinNT machine, Python 2.0 > > Contrast with: > > s = '' > blocks = [] > for i in listOfStrings: > s = s + i > if len(s) > 4000 > blocks.append(s); s = '' > > This takes a blink of the eye to finish, so it is faster than the first > piece of code by between 100 and 1000 times. > > Is this relative inefficiency in the string add operation expected? > > I eventually have to produce a big long string of approx. 10MB. What is > the fastest way to do it without having to write C-extensions? > > - Rick Lee From rytrom at zootec.com Wed Feb 14 15:26:14 2001 From: rytrom at zootec.com (Roman Rytov) Date: Wed, 14 Feb 2001 16:26:14 +0200 Subject: Developer's tools? Message-ID: Is there any recommended enviroment for developing in Jython or Python that allows tracing, debuging and doing all regular programmer's stuff? From fredrik at pythonware.com Wed Feb 14 16:43:20 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 14 Feb 2001 15:43:20 GMT Subject: Developer's tools? References: Message-ID: Roman Rytov wrote: > Is there any recommended enviroment for developing in Jython or Python that > allows tracing, debuging and doing all regular programmer's stuff? start here: http://www.faqts.com/knowledge_base/view.phtml/aid/6433/fid/199 Cheers /F From trentm at ActiveState.com Wed Feb 14 20:12:22 2001 From: trentm at ActiveState.com (Trent Mick) Date: Wed, 14 Feb 2001 11:12:22 -0800 Subject: Developer's tools? In-Reply-To: ; from fredrik@pythonware.com on Wed, Feb 14, 2001 at 03:43:20PM +0000 References: Message-ID: <20010214111222.J19947@ActiveState.com> On Wed, Feb 14, 2001 at 03:43:20PM +0000, Fredrik Lundh wrote: > Roman Rytov wrote: > > Is there any recommended enviroment for developing in Jython or Python that > > allows tracing, debuging and doing all regular programmer's stuff? > > start here: > http://www.faqts.com/knowledge_base/view.phtml/aid/6433/fid/199 > You can also add Komodo to that list. This is a cross-platform scripting language IDE based on Mozilla: http://www.activestate.com/Products/Komodo/index.html Cheers, Trent -- Trent Mick TrentM at ActiveState.com From bill.xu at newlix.com Wed Feb 14 15:43:02 2001 From: bill.xu at newlix.com (Bill Xu) Date: Wed, 14 Feb 2001 14:43:02 GMT Subject: Anybody know about pulldom in PyXML? Message-ID: Hi, Gang: Will u please tell me how to use the pulldom.startElement() in the Python XML DOM (PyXml 0.6.3, Python 1.5, Redhat Linux 6.2) ? Following is my simple test program and result. Will u please tell me how to correct this bug? "AttributeError: 'None' object has no attribute 'createElement'"; Thanks in advance! Bill ===================================================== #!/usr/bin/python # import os, sys, string, StringIO import xml.dom from xml.dom import minidom from xml.dom.pulldom import PullDOM import traceback # Save the new message def test_meth(): print "Am i here" builder = PullDOM() builder.startElement("SET", {"PATH" : "a path"}) builder.endElement("SET") print "Am i here" confirm(builder) #result = self.Print(builder) def confirm(test, testname = "Test"): if test: print "Passed " + testname else: print "Failed " + testname raise Exception print "? am i herer" test_meth() ======================================================= Output: ? am i herer Am i here Traceback (innermost last): File "./testdom.py", line 34, in ? test_meth() File "./testdom.py", line 20, in test_meth builder.startElement("SET", {"PATH" : "a path"}) File "/usr/lib/python1.5/site-packages/xml/dom/pulldom.py", line 85, in startElement node = self.document.createElement(name) AttributeError: 'None' object has no attribute 'createElement' From dan.rolander at marriott.com Wed Feb 14 15:56:34 2001 From: dan.rolander at marriott.com (Dan Rolander) Date: Wed, 14 Feb 2001 09:56:34 -0500 Subject: Help! Problems with win32wnet.WNetAddConnection2 Message-ID: <004801c09696$53636ea0$11260340@yin> I am using the following function to break any existing connections between a local drive and a network share and create a new one. It works just fine on Windows 2000, but on Windows 98 both WNetCancelConnection2 and WNetAddConnection2 return the following pywintypes.api_error: 'The network request is not supported.' This should work on Windows 98 shouldn't it? What am I doing wrong? def map(drive, unc, username=None, password=None, persistent='no'): if persistent == 'yes': flags = win32netcon.CONNECT_UPDATE_PROFILE else: flags = 0 drive_type = win32file.GetDriveType(drive) if drive_type == win32con.DRIVE_REMOTE: win32wnet.WNetCancelConnection2(drive, flags, 1) win32wnet.WNetAddConnection2( win32netcon.RESOURCETYPE_DISK, drive, unc, None, username, password, flags ) From aahz at panix.com Wed Feb 14 16:15:47 2001 From: aahz at panix.com (Aahz Maruch) Date: 14 Feb 2001 07:15:47 -0800 Subject: Google? Message-ID: <96e7f3$b75$1@panix6.panix.com> Anybody here work for Google (or know somebody who does)? I'm thinking of applying for a job there, but I'd like to know something about the working conditions. -- --- 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 'Gender' isn't a definition, it's a heuristic. --Aahz From olk at olk.co.kr Wed Feb 14 16:21:37 2001 From: olk at olk.co.kr (Online Korea) Date: Thu, 15 Feb 2001 00:21:37 +0900 Subject: =?ks_c_5601-1987?B?cHl0aG9uLWxpc3S01CC+yLPnx8+8vL/kPyA=?= Message-ID: <3W-POP3-ADBDUfdfdhN00000d39@3w-pop3-ad.korea.com> An HTML attachment was scrubbed... URL: From zope at thewebsons.com Wed Feb 14 16:36:57 2001 From: zope at thewebsons.com (Ben Ocean) Date: Wed, 14 Feb 2001 07:36:57 -0800 Subject: Link Exchange Robot Message-ID: <5.0.2.1.0.20010214073626.00a05280@thewebsons.com> Hi; There's a great little proggie I use to scout out potential link exchange partners for my clients called Zeus. I have no financial interest in Zeus. *However*, there are some facilities in this proggie I don't care for: facilities designed to slow one down (and presumably keep the company from being known as a developer of devices for spammers, not that I advocate spamming). I also have a Linux box with a T-1 line that could kick serious butt, and this (of course) is built for Windoze. That, plus the fact that I now find I need a whole bunch of these robots and I'd like to legally skate on the licencing fee :) Which (finally) brings me to my question: Does anyone know of an open source program that does the same thing? TIA, BenO From bshapiro at funnygarbage.com Wed Feb 14 17:03:44 2001 From: bshapiro at funnygarbage.com (Ben Shapiro) Date: Wed, 14 Feb 2001 11:03:44 -0500 Subject: COM 'Catastrophic failure' ???? Message-ID: <96ea87$b2d$1@bob.news.rcn.net> Anyone know what could be causing the 'Catastrophic failure'?? I am using an OCX as the media control thx for your help C:\code\3LP\PyFileunder>mediaplayer.py Traceback (most recent call last): File "C:\code\3LP\PyFileunder\MediaPlayer.py", line 39, in ? t = MediaPlayer() File "C:\code\3LP\PyFileunder\MediaPlayer.py", line 22, in __init__ p = w.Open("c:\\code\\3LP\\pyfileunder\\music\\test.mp3") File "c:\python20\win32com\gen_py\2DF09BC5-B050-11D2-81C1-00C0DFEAA961x0x1x0.py", line 75, in Open return self._oleobj_.InvokeTypes(0x33, LCID, 1, (3, 0), ((8, 0),),URL) pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None) From MarkH at ActiveState.com Wed Feb 14 23:17:21 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 14 Feb 2001 22:17:21 GMT Subject: COM 'Catastrophic failure' ???? References: <96ea87$b2d$1@bob.news.rcn.net> Message-ID: <3A8B0312.1080906@ActiveState.com> Ben Shapiro wrote: > Anyone know what could be causing the 'Catastrophic failure'?? > I am using an OCX as the media control > > thx for your help > > C:\code\3LP\PyFileunder>mediaplayer.py > Traceback (most recent call last): > File "C:\code\3LP\PyFileunder\MediaPlayer.py", line 39, in ? > t = MediaPlayer() > File "C:\code\3LP\PyFileunder\MediaPlayer.py", line 22, in __init__ > p = w.Open("c:\\code\\3LP\\pyfileunder\\music\\test.mp3") > File > "c:\python20\win32com\gen_py\2DF09BC5-B050-11D2-81C1-00C0DFEAA961x0x1x0.py", > line 75, in Open > return self._oleobj_.InvokeTypes(0x33, LCID, 1, (3, 0), ((8, 0),),URL) > pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None) I would guess that the media player wants a real OCX container. win32com doesnt support that. Pythonwin does tho - see the pywin\demos\ocx samples and see if that helps it work. Mark. -- Nominate Your Favorite Programmers for the Perl and Python Active Awards! http://www.ActiveState.com/Awards/ From lutz at rmi.net Wed Feb 14 17:07:00 2001 From: lutz at rmi.net (Mark Lutz) Date: Wed, 14 Feb 2001 09:07:00 -0700 Subject: Python training next week, Denver Message-ID: <008601c096a0$2ff51ae0$dc73fea9@vaio> There are still some seats available in the upcoming Kaivo Python training session described here: http://www.kaivo.com Kaivo classes are open to the public, and accept individual and group enrollments. --Mark Lutz (http://www.rmi.net/~lutz) From phd at phd.russ.ru Wed Feb 14 17:20:33 2001 From: phd at phd.russ.ru (Oleg Broytmann) Date: 14 Feb 2001 10:20:33 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Feb 14) Message-ID: <63B38717DB69B0D6.7FB13CCE0B8ED7BA.330DC4E9A51B2B9B@lp.airnews.net> Google.com buys Deja archives. All links change! http://groups.google.com/groups?q=group:comp.lang.python&start=30&hl=en&lr=&safe=off&rnum=35&seld=926663091&ic=1 Suchandra Thapa starts a long thread on creating a CPAN-like service for Python http://groups.google.com/groups?hl=en&lr=&safe=off&th=6202938a19f67d9b&thn=CPAN+functionality+for+python&ic=1&seekd=927216290 Steven D. Arnold announces the release of pure-Python encryption tools http://groups.google.com/groups?q=group:comp.lang.python&start=20&hl=en&lr=&safe=off&rnum=30&seld=926624071&ic=1 Barry Pederson releases a Python-powered QuakeWorld dedicated server http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=c01ded3a01dfc324&thn=QuakeWorld+Python+1.0&seekd=926538529 In a thread dedicated to boolean COM properties Mark Hammond explains PyTrue and PyFalse http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=1cd0ed3943dead44&thn=Setting+boolean+COM+properties&seekd=926499672 ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://deja.com/group/comp.lang.python.announce Andrew Kuchling writes marvelous summaries twice a month of the action on the python-dev mailing list, where the future of Python is truly determined http://www.amk.ca/python/dev The Vaults of Parnassus ambitiously collect Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Consortium emerges as an independent nexus of activity http://www.python.org/consortium Cetus does much of the same http://www.cetus-links.de/oo_python.html Python FAQTS http://python.faqts.com/ Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing trick of the trade: http://www.dejanews.com/dnquery.xp?QRY=&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=threaded&showsort=date&maxhits=100&groups=comp.lang.python Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://www.dejanews.com/dnquery.xp?QRY=~g%20comp.lang.python%20Python-URL%21 Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m Wed Feb 14 17:41:01 2001 From: k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m (Keith Ray) Date: Wed, 14 Feb 2001 16:41:01 GMT Subject: python interpreter in smalltalk References: <9579gr$g0jjg$1@ID-65212.news.dfncis.de> <95abs4$g1nic$1@ID-65212.news.dfncis.de> <95coka$hp3$1@nnrp1.deja.com> <7MGJOov0nvx+VW3xYgkmsmMz2tDQ@4ax.com> Message-ID: In article <7MGJOov0nvx+VW3xYgkmsmMz2tDQ at 4ax.com>, sma at 3plus4.de wrote: > On Sat, 03 Feb 2001 02:57:36 GMT, Keith Ray > wrote: > > >Has anyone tried to write a Python interpreter in Smalltalk? > > I tried this, although using Squeak Smalltalk not Dolphin Smalltalk. > I never finished the project but there's a partially working parser > which I could share. > > bye > -- > Stefan Matthias Aust____Truth until Paradox!____________________ > Jobs? ==> jobs at baltic-online.de www.baltic-online.de I have the desire to see Python running inside Squeak . I was planning to start porting from the Jython sources, since those are already in an object oriented language (Java). If you could, please email your parser to me and it will help me learn how Squeak could host a Python language. C. Keith Ray remove spaces to get my email address c k e i t h r a y @ h o m e . c o m -- From marten at phoenix-edv.netzservice.de Thu Feb 15 08:55:24 2001 From: marten at phoenix-edv.netzservice.de (Marten Feldtmann) Date: Thu, 15 Feb 2001 08:55:24 +0100 Subject: python interpreter in smalltalk References: <9579gr$g0jjg$1@ID-65212.news.dfncis.de> <95abs4$g1nic$1@ID-65212.news.dfncis.de> <95coka$hp3$1@nnrp1.deja.com> <7MGJOov0nvx+VW3xYgkmsmMz2tDQ@4ax.com> Message-ID: <3A8B8B6C.A19DC08D@phoenix-edv.netzservice.de> Keith Ray schrieb: > > In article <7MGJOov0nvx+VW3xYgkmsmMz2tDQ at 4ax.com>, sma at 3plus4.de wrote: > > > On Sat, 03 Feb 2001 02:57:36 GMT, Keith Ray > > wrote: > > > > >Has anyone tried to write a Python interpreter in Smalltalk? > > > > I tried this, although using Squeak Smalltalk not Dolphin Smalltalk. > > I never finished the project but there's a partially working parser > > which I could share. > > > > bye > > -- > > Stefan Matthias Aust____Truth until Paradox!____________________ > > Jobs? ==> jobs at baltic-online.de www.baltic-online.de > > I have the desire to see Python running inside Squeak > . > Why not call Python via it's C interface ? Marten From k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m Thu Feb 15 18:37:56 2001 From: k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m (Keith Ray) Date: Thu, 15 Feb 2001 17:37:56 GMT Subject: python interpreter in smalltalk References: <9579gr$g0jjg$1@ID-65212.news.dfncis.de> <95abs4$g1nic$1@ID-65212.news.dfncis.de> <95coka$hp3$1@nnrp1.deja.com> <7MGJOov0nvx+VW3xYgkmsmMz2tDQ@4ax.com> <3A8B8B6C.A19DC08D@phoenix-edv.netzservice.de> Message-ID: In article <3A8B8B6C.A19DC08D at phoenix-edv.netzservice.de>, Marten Feldtmann wrote: > Keith Ray schrieb: > > > > In article <7MGJOov0nvx+VW3xYgkmsmMz2tDQ at 4ax.com>, sma at 3plus4.de wrote: > > > > > On Sat, 03 Feb 2001 02:57:36 GMT, Keith Ray > > > wrote: > > > > > > >Has anyone tried to write a Python interpreter in Smalltalk? > > > > > > I tried this, although using Squeak Smalltalk not Dolphin Smalltalk. > > > I never finished the project but there's a partially working parser > > > which I could share. > > > > > > bye > > > -- > > > Stefan Matthias Aust____Truth until Paradox!____________________ > > > Jobs? ==> jobs at baltic-online.de www.baltic-online.de > > > > I have the desire to see Python running inside Squeak > > . > > > > Why not call Python via it's C interface ? Because that wouldn't allow writing Python subclasses of Smalltalk classes and vice versa. Both Python and Squeak use bytecodes, and run in a kind of VM. Squeak can call out to C code, but C code can't call into Squeak -- the hooks are not there (yet). Squeak happens to be implemented "in itself" -- that is, its virtual machine was written and debugged in a subset of normal Smalltalk (I think they call it 'Slang'). Then a translator (also written in Smalltalk) converts the Slang code into C code, which is compiled and becomes the real virtual machine. The original Slang-based virtual machine can also be executed in Squeak -- so you have an "emulated" virtual machine running (very slowly) inside a real virtual machine. If Squeak can be made to handle multiple sets of byte-codes types, then it could transparently handle Python, Java, and Smalltalk in its "universal VM". Or the JPython route -- implement Python within the host language/vm... Jython allows interoperating with Java the way I want Python to interoperate with Squeak Smalltalk. Squeak can reconstuct the source code of a method from the byte-code (does not include comments and probably not the local variable names), it is possible that a combined Squeak/Python vm could let you choose to view a method in Smalltalk syntax or in Python syntax. Squeak has been ported to many platforms, including some that don't have an operating system (ported to the "bare metal"). It has really good MacOS support (my preferred platform). -- From k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m Fri Feb 16 03:32:23 2001 From: k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m (Keith Ray) Date: Fri, 16 Feb 2001 02:32:23 GMT Subject: python interpreter in smalltalk References: <9579gr$g0jjg$1@ID-65212.news.dfncis.de> <95abs4$g1nic$1@ID-65212.news.dfncis.de> <95coka$hp3$1@nnrp1.deja.com> <7MGJOov0nvx+VW3xYgkmsmMz2tDQ@4ax.com> <3A8C189F.B3040253@canis.uiuc.edu> Message-ID: In article <3A8C189F.B3040253 at canis.uiuc.edu>, Les Tyrrell wrote: > You might consider an approach similar to that used in > Frost ( http://oasis.canis.uiuc.edu:8080/Frost ) where > bytecodes for Java are translated to Smalltalk bytecodes. > Frost also parses Java source code, but when it does it > goes straight to VisualWorks bytecodes. > > One of the things I'd like to consider for Frost would be > accomodating languages other than Java, especially languages > like Python or Ruby. Not because I want to do Java, Python, > or Ruby development, but because I do NOT want to do Java, > Python, or Ruby development, but also do not want to have to > manually re-implement any useful code written in those languages > in Smalltalk. > > It's also the sort of thing that hopefully puts positive pressures > on the VM designers, perhaps along the lines mentioned in the > "Universal VM" thread. > > - les Thanks for the URL... and it's open source! -- From sma at 3plus4.de Sun Feb 18 09:33:11 2001 From: sma at 3plus4.de (Stefan Matthias Aust) Date: Sun, 18 Feb 2001 09:33:11 +0100 Subject: python interpreter in smalltalk References: <9579gr$g0jjg$1@ID-65212.news.dfncis.de> <95abs4$g1nic$1@ID-65212.news.dfncis.de> <95coka$hp3$1@nnrp1.deja.com> <7MGJOov0nvx+VW3xYgkmsmMz2tDQ@4ax.com> Message-ID: On Wed, 14 Feb 2001 16:41:01 GMT, Keith Ray wrote: >> I tried this, although using Squeak Smalltalk not Dolphin Smalltalk. >> I never finished the project but there's a partially working parser >> which I could share. >> >> bye >> -- >> Stefan Matthias Aust____Truth until Paradox!____________________ >> Jobs? ==> jobs at baltic-online.de www.baltic-online.de > >I have the desire to see Python running inside Squeak >. Keith, I've up my sources for an unfinished python parser to www.3plus4.de/squeak. Feel free to use is a foundation for a real Python system. I think, this wouldn't be that difficult. When I started, I mostly ignored the runtime system but reading the Python specification I did find anything which couldn't implemented in Smalltalk. bye -- Stefan Matthias Aust____Truth until Paradox!____________________ Jobs? ==> jobs at baltic-online.de www.baltic-online.de From k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m Mon Feb 19 03:10:47 2001 From: k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m (Keith Ray) Date: Mon, 19 Feb 2001 02:10:47 GMT Subject: python interpreter in smalltalk References: <9579gr$g0jjg$1@ID-65212.news.dfncis.de> <95abs4$g1nic$1@ID-65212.news.dfncis.de> <95coka$hp3$1@nnrp1.deja.com> <7MGJOov0nvx+VW3xYgkmsmMz2tDQ@4ax.com> Message-ID: In article , sma at 3plus4.de wrote: > On Wed, 14 Feb 2001 16:41:01 GMT, Keith Ray > wrote: > > >> I tried this, although using Squeak Smalltalk not Dolphin Smalltalk. > >> I never finished the project but there's a partially working parser > >> which I could share. > >> > >> bye > >> -- > >> Stefan Matthias Aust____Truth until Paradox!____________________ > >> Jobs? ==> jobs at baltic-online.de www.baltic-online.de > > > >I have the desire to see Python running inside Squeak > >. > > Keith, > > I've up my sources for an unfinished python parser to > www.3plus4.de/squeak. Feel free to use is a foundation for a real > Python system. I think, this wouldn't be that difficult. When I > started, I mostly ignored the runtime system but reading the Python > specification I did find anything which couldn't implemented in > Smalltalk. > > bye > -- > Stefan Matthias Aust____Truth until Paradox!____________________ > Jobs? ==> jobs at baltic-online.de www.baltic-online.de Thanks! ( By the way the link named "Python" shows up as the invalid link "". ) -- From LauraL Wed Feb 14 17:44:43 2001 From: LauraL (LauraL) Date: 14 Feb 2001 16:44:43 GMT Subject: Suggestion: Python tools book References: Message-ID: <96eclr01m74@news2.newsguy.com> Hi, You will find a lot of these tools covered in the new (2nd) edition of Programming Python, due out early March. We are also in the planning stages on a Cookbook that will hit on these topics. Laura LLewin at oreilly.com > Hear, hear ! > > Also: > SSL socket stuff > freeze/packaging > > Sandipan > > ----- Original Message ----- > From: "Hamish Lawson" > To: > Sent: Wednesday, February 14, 2001 6:14 PM > Subject: Suggestion: Python tools book > > > > I'd welcome a book that covered the more popular third-party toolkits > > for Python, plus those toolkits (*) in the standard library that could > > use more coverage than given in the library reference. Perhaps the > > various toolkit authors could contribute a respective chapter. Does the > > community think this kind of book is needed, and what toolkits should > > be included? Here's my stab at a list of candidates: > > > > wxPython > > DB-API > > Python Imaging Library > > Numerical Python > > mxDateTime > > mod_python / mod_snake > > HTMLgen > > mxTextTools > > ReportLab > > PyXML* > > TkInter* > > > > Hamish Lawson > > > > > > ===== > > Hamish Lawson hamish_lawson at yahoo.co.uk ================================== Posted via http://nodevice.com Linux Programmer's Site From dvoitenko at qode.com Wed Feb 14 17:51:18 2001 From: dvoitenko at qode.com (Voitenko, Denis) Date: Wed, 14 Feb 2001 11:51:18 -0500 Subject: Working with DNS via Python Message-ID: <0FF17853157CD31197E100902784B34B7A1F2E@FILESERVER1> Could someone point me to some functions or material that'd explain how to work with DNS functions (nslookup, etc) via Python? I'd be interested in sumulating something like this: Default Server: localhost Address: 127.0.0.1 > set q=mx > sony.com Server: localhost Address: 127.0.0.1 Non-authoritative answer: sony.com preference = 10, mail exchanger = mail5.fw-bc.sony.com sony.com preference = 10, mail exchanger = mail4.fw-sj.sony.com sony.com preference = 10, mail exchanger = mail4.fw-bc.sony.com Denis -------------- next part -------------- An HTML attachment was scrubbed... URL: From phd at phd.pp.ru Wed Feb 14 17:58:29 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 14 Feb 2001 19:58:29 +0300 (MSK) Subject: Working with DNS via Python In-Reply-To: <0FF17853157CD31197E100902784B34B7A1F2E@FILESERVER1> Message-ID: On Wed, 14 Feb 2001, Voitenko, Denis wrote: > Could someone point me to some functions or material that'd explain how to > work with DNS functions (nslookup, etc) via Python? The first and most strightforward idea - just use os.popen and run nslookup! :) Also there is dnslib - it is not in standard library, it is in Demo/dns subdirectory in source distribution. Also there is adns (asynchronous dns lib in C); Andy Dustman wrote python wrapper for it. (Russian? Why not to ask question on Russian Python list?) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From dvoitenko at qode.com Wed Feb 14 18:13:46 2001 From: dvoitenko at qode.com (Voitenko, Denis) Date: Wed, 14 Feb 2001 12:13:46 -0500 Subject: Working with DNS via Python Message-ID: <0FF17853157CD31197E100902784B34B7A1F30@FILESERVER1> >> work with DNS functions (nslookup, etc) via Python? >The first and most strightforward idea - just use os.popen and run nslookup! :) If I wanted to do that I'd use Bash. >Also there is dnslib - it is not in standard library, it is in Demo/dns subdirectory in source distribution. Is it documented anywhere? >Also there is adns (asynchronous dns lib in C); Andy Dustman wrote python wrapper for it. Where do I get it? >(Russian? Why not to ask question on Russian Python list?) If I do, only Russians will be able to use my findings. Kinda makes it unfair, eh? -------------- next part -------------- An HTML attachment was scrubbed... URL: From phd at phd.pp.ru Wed Feb 14 18:14:57 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 14 Feb 2001 20:14:57 +0300 (MSK) Subject: Working with DNS via Python In-Reply-To: <0FF17853157CD31197E100902784B34B7A1F30@FILESERVER1> Message-ID: On Wed, 14 Feb 2001, Voitenko, Denis wrote: > >Also there is dnslib - it is not in standard library, it is in Demo/dns > subdirectory in source distribution. > > Is it documented anywhere? No. > >Also there is adns (asynchronous dns lib in C); Andy Dustman wrote > python wrapper for it. > > Where do I get it? http://dustman.net/andy/python/ > >(Russian? Why not to ask question on Russian Python list?) > > If I do, only Russians will be able to use my findings. Kinda makes it > unfair, eh? Absoluteley no. And this makes converstaion easy for people who don't know English well. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From cg at schlund.de Wed Feb 14 18:34:17 2001 From: cg at schlund.de (Carsten Gaebler) Date: Wed, 14 Feb 2001 18:34:17 +0100 Subject: Working with DNS via Python References: Message-ID: <3A8AC199.50A4B5BB@schlund.de> > > Could someone point me to some functions or material that'd explain how > to work with DNS functions (nslookup, etc) via Python? > I was looking for such functions today, too, and found this on Parnassus: http://www.interlink.com.au/anthony/python/dns.tar.gz It works. There is a bug in Lib.py: index.append() takes a 2-tuple argument, not two single arguments. cg. From phd at phd.pp.ru Wed Feb 14 18:46:12 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 14 Feb 2001 20:46:12 +0300 (MSK) Subject: Working with DNS via Python In-Reply-To: <3A8AC199.50A4B5BB@schlund.de> Message-ID: On Wed, 14 Feb 2001, Carsten Gaebler wrote: > It works. There is a bug in Lib.py: index.append() takes a 2-tuple > argument, not two single arguments. It is not a bug - it's a change from 1.5.2 to 1.6. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From michael at stroeder.com Thu Feb 15 07:26:07 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Thu, 15 Feb 2001 07:26:07 +0100 Subject: Working with DNS via Python References: <3A8AC199.50A4B5BB@schlund.de> Message-ID: <3A8B767F.BE8236EB@stroeder.com> Carsten Gaebler wrote: > > > Could someone point me to some functions or material that'd explain how > > to work with DNS functions (nslookup, etc) via Python? > > I was looking for such functions today, too, and found this on Parnassus: > > http://www.interlink.com.au/anthony/python/dns.tar.gz Note: I patched this to work under Python 1.6+ and I've added support for SRV RR's. I would like to see something like this in the standard lib. It seems to be well designed. Even I understood very quickly how to add a new RR type. ;-) Ciao, Michael. From rozen at rgelpc254.rgv.hp.com Wed Feb 14 18:17:19 2001 From: rozen at rgelpc254.rgv.hp.com (Don Rozenberg) Date: 14 Feb 2001 09:17:19 -0800 Subject: [ANN] PAGE 0.1 - A drag and drop GUI generator for Message-ID: <80lhf1xchgg.fsf@rgelpc254.rgv.hp.com> PAGE is a tool which helps to create GUI for Python programs. It uses Tk and Tix widgets. PAGE is not an end-all, be-all tool, but rather one that attempts to ease the burden on the Python programmer. It is aimed at the user who will put up with a less-than-general GUI capability in order to get an easily generated GUI. It does not build an entire application but rather is aimed at building a single GUI window. PAGE is built on version 1.2.2 of Visual Tcl, version 8.1.1 of Tix, and Tcl/Tk version 8.3.2. It works with Python 2.0. This is an early version which run on Linux and Windows/NT. It supports many Tk widgets and a subset of the Tix widget set. The user will have to acquire and install Tix 8.1.1 and tcl8.3.2 to use this program. It is released under the GPL. The PAGE web site is http://www.geocities.com/page_python -- Don Rozenberg rozen at rgv.hp.com 408-343-6266 From franze at cs.unibo.it Wed Feb 14 18:32:25 2001 From: franze at cs.unibo.it (Francesco Franze) Date: 14 Feb 2001 17:32:25 GMT Subject: linking with python20.dll Message-ID: <96eff9$o5d$1@le.cs.unibo.it> i tried to link a new extension module for activepython (2.0) it seems some symbols (like _Py_NoneStruct) are missing in python20.lib i rebuilt the lib file and added the apparently missing symbols the dll now is created (with cygnus gcc or ms visual studio c++) linking with python15 generates a lib conflict... any idea? f. From dsh8290 at rit.edu Wed Feb 14 19:29:55 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 14 Feb 2001 13:29:55 -0500 Subject: pth information Message-ID: <20010214132954.A17229@harmony.cs.rit.edu> I was searching through the documentation on python.org, but couldn't find anything describing the usage and syntax for .pth files. All I managed to find was a brief mention of their existence in some extension modules in section 3.23 of the Library Reference. Could someone point me in the right direction? (Or explain here if you feel inclined to do so) Thanks, -D From phd at phd.pp.ru Wed Feb 14 19:38:30 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 14 Feb 2001 21:38:30 +0300 (MSK) Subject: pth information In-Reply-To: <20010214132954.A17229@harmony.cs.rit.edu> Message-ID: On Wed, 14 Feb 2001, D-Man wrote: > I was searching through the documentation on python.org, but couldn't > find anything describing the usage and syntax for .pth files. All I http://www.python.org/doc/essays/packages.html Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From dsh8290 at rit.edu Wed Feb 14 21:43:36 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 14 Feb 2001 15:43:36 -0500 Subject: pth information In-Reply-To: ; from phd@phd.pp.ru on Wed, Feb 14, 2001 at 09:38:30PM +0300 References: <20010214132954.A17229@harmony.cs.rit.edu> Message-ID: <20010214154336.A17557@harmony.cs.rit.edu> On Wed, Feb 14, 2001 at 09:38:30PM +0300, Oleg Broytmann wrote: | On Wed, 14 Feb 2001, D-Man wrote: | > I was searching through the documentation on python.org, but couldn't | > find anything describing the usage and syntax for .pth files. All I | | http://www.python.org/doc/essays/packages.html Thanks! -D | Programmers don't die, they just GOSUB without RETURN. BTW, I think this is kind of cute. From dsh8290 at rit.edu Wed Feb 14 22:20:46 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 14 Feb 2001 16:20:46 -0500 Subject: pth information In-Reply-To: ; from phd@phd.pp.ru on Wed, Feb 14, 2001 at 09:38:30PM +0300 References: <20010214132954.A17229@harmony.cs.rit.edu> Message-ID: <20010214162046.A17719@harmony.cs.rit.edu> On Wed, Feb 14, 2001 at 09:38:30PM +0300, Oleg Broytmann wrote: | On Wed, 14 Feb 2001, D-Man wrote: | > I was searching through the documentation on python.org, but couldn't | > find anything describing the usage and syntax for .pth files. All I | | http://www.python.org/doc/essays/packages.html This did a good job of explaining how packages are supposed to work and how packages differ and interact with modules. It also explained what .pth files are for and that .pth files shouldn't be used unless absolutely necessary. Ok, but I still want to know what such a file should look like. For example, on one of my systems, I have Win2k, Python 2.0, and wxPython 2.2.5. Python is installed in d:\apps\python20 wxPython is in d:\lib\python_modules\wxPython. Right now I have d:\lib\python_modules in my PYTHONPATH environment variable. If I want to use a wxPython.pth file instead, how would I do that? Should it go in d:\apps\python20\lib? What should it contain? Simply the path to d:\lib\python_modules\wxPython on a line by itself? Thanks, -D From tuttledon at hotmail.com Wed Feb 14 23:02:50 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Wed, 14 Feb 2001 22:02:50 GMT Subject: pth information References: <20010214132954.A17229@harmony.cs.rit.edu> Message-ID: "D-Man" wrote in message news:mailman.982185680.5800.python-list at python.org... > > Ok, but I still want to know what such a file should look like. For > example, on one of my systems, I have Win2k, Python 2.0, and wxPython > 2.2.5. Python is installed in d:\apps\python20 wxPython is in > d:\lib\python_modules\wxPython. Right now I have > d:\lib\python_modules in my PYTHONPATH environment variable. If I > want to use a wxPython.pth file instead, how would I do that? Should > it go in d:\apps\python20\lib? What should it contain? Simply the > path to d:\lib\python_modules\wxPython on a line by itself? I was wondering about this just a couple of days ago. From what I could find out the .pth should contain a one line path to the folder where the module resides. In your case the "wxPython.pth" would contain this line: d:\lib\python_modules\wxPython If you had installed it in the \Python20 folder, all you would need is the folder name (path relative to \Python20): wxPython.pth wxPython Question: Where does Python look first? The PythonPath or for a .pth file? Hope this helps, Don From paul.moore at uk.origin-it.com Thu Feb 15 15:33:13 2001 From: paul.moore at uk.origin-it.com (Paul Moore) Date: Thu, 15 Feb 2001 15:33:13 +0100 Subject: pth information References: <20010214132954.A17229@harmony.cs.rit.edu> Message-ID: On Wed, 14 Feb 2001 23:02:50 +0100, "Don Tuttle" wrote: >Question: Where does Python look first? The PythonPath or for a .pth file? The standard module site.py is loaded first. You can read the source of this for the definitive answer, but basically, site.py searches the sirectory sys.prefix (and maybe sys.exec_prefix) for files whose names end in ".pth". All such files are read, and each line is treated as the name of a directory (relative to the directory containing the .pth file, if it isn't an absolute name already) to be added at the end of sys.path. All this happens at startup, and from then on, sys.path is just used as normal. Hope this helps, Paul. From cerutti at together.net Thu Feb 15 16:48:06 2001 From: cerutti at together.net (Neil Cerutti) Date: 15 Feb 2001 15:48:06 GMT Subject: pth information References: <20010214132954.A17229@harmony.cs.rit.edu> Message-ID: D-Man posted: >On Wed, Feb 14, 2001 at 09:38:30PM +0300, Oleg Broytmann wrote: >| On Wed, 14 Feb 2001, D-Man wrote: >| > I was searching through the documentation on python.org, but >couldn't | > find anything describing the usage and syntax for >.pth files. All I >| >| http://www.python.org/doc/essays/packages.html > >This did a good job of explaining how packages are supposed to >work and how packages differ and interact with modules. It also >explained what .pth files are for and that .pth files shouldn't >be used unless absolutely necessary. > >Ok, but I still want to know what such a file should look like. >For example, on one of my systems, I have Win2k, Python 2.0, and >wxPython 2.2.5. Python is installed in d:\apps\python20 >wxPython is in d:\lib\python_modules\wxPython. Right now I have >d:\lib\python_modules in my PYTHONPATH environment variable. If >I want to use a wxPython.pth file instead, how would I do that? >Should it go in d:\apps\python20\lib? What should it contain? >Simply the path to d:\lib\python_modules\wxPython on a line by >itself? On Windows, I gather that it should be a one-line text file: lib/python_modules/wxPython The path should be relative to your Python installation directory in Windows. -- Neil Cerutti From fluxent at yahoo.com Wed Feb 14 19:30:03 2001 From: fluxent at yahoo.com (fluxent at yahoo.com) Date: Wed, 14 Feb 2001 18:30:03 -0000 Subject: tweaking ADO RecordSet tuple? Message-ID: <96eirb+ast4@eGroups.com> context/architecture: Python, ASP, MsSQL. Sending query to MsSQL, getting back RecordSet, outputting HTML table. Am I correct in understanding that to work with a RecordSet in a "normal" (to me) manner, I need to: - transpose it, since GetRows returns columns, not rows - convert from unicode and dateobjects to useful stuff Is there some code sitting someplace that people are usually using for this purpose? Or are so few people using ADO that it hasn't bubbled up? From KatMouse at gmx.de Wed Feb 14 20:59:16 2001 From: KatMouse at gmx.de (Eduard Hiti) Date: Wed, 14 Feb 2001 20:59:16 +0100 Subject: tweaking ADO RecordSet tuple? References: Message-ID: <96eo4a$h2r$02$1@news.t-online.com> I'm using ADO with Python just fine. COM Unicode usage was always handled very well by win32com. Date values can be converted to 'time' module format simply by using int(): import pywintypes, time t = pywintypes.Time(time.time()) # this is the COM date type in Python time.strftime("%Y-%m-%d %H:%M:%S", time.localtime( int(t) ) ) This seems to be a little messy, since time.time() returns a float, so conversion with int() will lose information. What is worse, using float() will return wrong values. pywintypes.Time has a 'Format' method, too: t.Format("%m%d%Y") which will return a string representation of the date. I heard that the mxDateTime module has excellent support for COM date types, but I didn't need it, so can't comment on that module. Greetings, Eduard ----- Original Message ----- From: Newsgroups: comp.lang.python To: Sent: Wednesday, February 14, 2001 7:30 PM Subject: tweaking ADO RecordSet tuple? | context/architecture: Python, ASP, MsSQL. Sending query to MsSQL, | getting back RecordSet, outputting HTML table. | | Am I correct in understanding that to work with a RecordSet in | a "normal" (to me) manner, I need to: | - transpose it, since GetRows returns columns, not rows | - convert from unicode and dateobjects to useful stuff | | Is there some code sitting someplace that people are usually using | for this purpose? Or are so few people using ADO that it hasn't | bubbled up? | | | From fuess at att.net Thu Feb 15 04:23:27 2001 From: fuess at att.net (David Fuess) Date: Thu, 15 Feb 2001 03:23:27 GMT Subject: tweaking ADO RecordSet tuple? References: <96eo4a$h2r$02$1@news.t-online.com> Message-ID: On Wed, 14 Feb 2001 20:59:16 +0100, "Eduard Hiti" wrote: General comment: With COM and ADO the number of variable types and situations you encounter are so wide and varied that each one seems to be a special case. I have managed to control the beast by restricting the variable types created in my databases. But we don't always have that luxury ... >I'm using ADO with Python just fine. >COM Unicode usage was always handled very well by win32com. But you may still want to convert them to latin1 if you intend to perform string operations on the data items. Many string functions fail when you feed them certain unicode characters (like u-umlaut). > >Date values can be converted to 'time' module format simply by using int(): > > import pywintypes, time > > t = pywintypes.Time(time.time()) # this is the COM date type in >Python > time.strftime("%Y-%m-%d %H:%M:%S", time.localtime( int(t) ) ) > I've had a lot of trouble with this because the datum may be different between the database server and the UNIX time functions. On SQL Server 7 the datum is 1/1/1900. Instead I use the .Format() function of the database time object to format the time into a string. It takes the same arguments as strftime. (This is the method duscussed next :-) ) >This seems to be a little messy, since time.time() returns a float, so >conversion with int() will lose information. What is worse, using float() >will return wrong values. > >pywintypes.Time has a 'Format' method, too: > > t.Format("%m%d%Y") > >which will return a string representation of the date. > >I heard that the mxDateTime module has excellent support for COM date types, >but I didn't need it, so can't comment on that module. > >Greetings, > > Eduard > > >----- Original Message ----- >From: >Newsgroups: comp.lang.python >To: >Sent: Wednesday, February 14, 2001 7:30 PM >Subject: tweaking ADO RecordSet tuple? > > >| context/architecture: Python, ASP, MsSQL. Sending query to MsSQL, >| getting back RecordSet, outputting HTML table. >| >| Am I correct in understanding that to work with a RecordSet in >| a "normal" (to me) manner, I need to: >| - transpose it, since GetRows returns columns, not rows >| - convert from unicode and dateobjects to useful stuff >| >| Is there some code sitting someplace that people are usually using >| for this purpose? Or are so few people using ADO that it hasn't >| bubbled up? >| >| >| > > From marco at atmosp.physics.utoronto.ca Wed Feb 14 19:48:24 2001 From: marco at atmosp.physics.utoronto.ca (marco at atmosp.physics.utoronto.ca) Date: 14 Feb 2001 18:48:24 GMT Subject: I don't understand popen2 :( Message-ID: <96ejto$4q3$1@news.netmar.com> Hello All, I'm a python newbie, happy so far, but somewhat bewildered :( My problem is with popen2.popen3. It sometimes gets stuck when reading the process std_out/err. Here is an example: >>> (po, pi, pe) = popen2.popen3('ssh computer "ls"') >>> po_out = po.read() >>> pe_err = pe.read() >>> pe_err '' >>> po_out [Directory listing OK] Alternatively (notice the read order): >>> (po, pi, pe) = popen2.popen3('ssh computer "ls"') >>> pe_err = pe.read() >>> po_out = po.read() >>> pe_err '' >>> po_out [Directory listing OK] Fine. Now I try something slightly different: >>> (po, pi, pe) = popen2.popen3('ssh computer "find /home/marco"') >>> po_out = po.read() >>> pe_err = pe.read() >>> pe_err '' >>> po_out [snip find results] which is fine, BUT if I do: >>> (po, pi, pe) = popen2.popen3('ssh computer "find /home/marco"') >>> pe_err = pe.read() [freezes!! I then Ctrl-C] Traceback (innermost last): File "", line 1, in ? KeyboardInterrupt >>> po_out = po.read() >>> po_out [snip find results] So, in this last case if I pe.read() first my script freezes, and I have to Ctrl-C. Sure, I could always po.read() first, but my biggest problem is that sometimes it's the other way around! That is, performing po.read() first causes a freeze! Unfortunately, I cannot reliably reproduce this last behaviour, but here is the result from a script I had to Ctrl-C: prompt> ./myprog.py [frozen -- Ctrl-C] Traceback (innermost last): File "./myprog.py", line 1245, in ? get_files() File "./myprog.py", line 1102, in get_files po_out = po.read() KeyboardInterrupt line # 1101 (po, pi, pe) = popen2.popen3(scp_from_remote_IP) 1102 po_out = po.read() 1103 pe_err = pe.read() Sadly, the scp operation *does* seem to work most of the time, why does it sometimes get stuck? Thoughts? Ideas? I'm using: Python 1.5.2 (#1, Feb 1 2000, 16:32:16) [GCC egcs-2.91.66 19990314/Linux (egcs- on linux-i386)] Thanks for any help! (Oh, and please CC me a reply if possible -- Deja's undergoing transition pains to Google right now) ----- 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 spam at spam.com Wed Feb 14 23:10:03 2001 From: spam at spam.com (Penfold) Date: Wed, 14 Feb 2001 22:10:03 -0000 Subject: I don't understand popen2 :( References: <96ejto$4q3$1@news.netmar.com> Message-ID: This is simply the usual nightmare of dealing with pipes between processes. The problem is simple ... both the po_out.read() and pe_err.read() are *blocking* reads ... further more since you used read and not read(100) eg, they will block until they can read to the end of file (ie the whole output of the command). In your case when you do a po_read first it works since the comand has produced all its output, you read it, then it dies and you read the error stream, all well and cool. In the latter case, you try and read the error stream first ... but your child process refuses to die until its output pipe has been read ... hence it idles doing nothing and you idle since you've just entered a blocking read on the error pipe == deadlock. Bummer :-) Or something like that. Solution ... I tend to alter the pipes to no longer be blocking ... I'm not sure what other people do in these cases. You can use fctl to do this but I forget the flags you want, something like NDELAY and O_NOBLOCK ... I have none of my sample code to hand. Look at man fcntl. Alternatively, just read the pipes in a sensible order :-) D. wrote in message news:96ejto$4q3$1 at news.netmar.com... > > Hello All, > > I'm a python newbie, happy so far, but somewhat bewildered :( > > My problem is with popen2.popen3. It sometimes gets stuck when > reading the process std_out/err. Here is an example: > > >>> (po, pi, pe) = popen2.popen3('ssh computer "ls"') > >>> po_out = po.read() > >>> pe_err = pe.read() > >>> pe_err > '' > >>> po_out > [Directory listing OK] > > Alternatively (notice the read order): > > >>> (po, pi, pe) = popen2.popen3('ssh computer "ls"') > >>> pe_err = pe.read() > >>> po_out = po.read() > >>> pe_err > '' > >>> po_out > [Directory listing OK] > > Fine. Now I try something slightly different: > > >>> (po, pi, pe) = popen2.popen3('ssh computer "find /home/marco"') > >>> po_out = po.read() > >>> pe_err = pe.read() > >>> pe_err > '' > >>> po_out > [snip find results] > > which is fine, BUT if I do: > > >>> (po, pi, pe) = popen2.popen3('ssh computer "find /home/marco"') > >>> pe_err = pe.read() > > [freezes!! I then Ctrl-C] > > Traceback (innermost last): > File "", line 1, in ? > KeyboardInterrupt > > >>> po_out = po.read() > >>> po_out > [snip find results] > > So, in this last case if I pe.read() first > my script freezes, and I have to Ctrl-C. Sure, I > could always po.read() first, but my biggest problem > is that sometimes it's the other way around! That is, > performing po.read() first causes a freeze! Unfortunately, > I cannot reliably reproduce this last behaviour, but here > is the result from a script I had to Ctrl-C: > > prompt> ./myprog.py > > [frozen -- Ctrl-C] > > Traceback (innermost last): > File "./myprog.py", line 1245, in ? > get_files() > File "./myprog.py", line 1102, in get_files > po_out = po.read() > KeyboardInterrupt > > line # > 1101 (po, pi, pe) = popen2.popen3(scp_from_remote_IP) > 1102 po_out = po.read() > 1103 pe_err = pe.read() > > Sadly, the scp operation *does* seem to work most of the time, > why does it sometimes get stuck? Thoughts? Ideas? > > I'm using: > Python 1.5.2 (#1, Feb 1 2000, 16:32:16) [GCC egcs-2.91.66 19990314/Linux > (egcs- on linux-i386)] > > Thanks for any help! > (Oh, and please CC me a reply if possible -- Deja's undergoing > transition pains to Google right now) > > ----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the eb ----- > 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 marco at atmosp.physics.utoronto.ca Fri Feb 16 06:23:26 2001 From: marco at atmosp.physics.utoronto.ca (marco at atmosp.physics.utoronto.ca) Date: 16 Feb 2001 05:23:26 GMT Subject: I don't understand popen2 :( References: <96ejto$4q3$1@news.netmar.com> Message-ID: <96idge$97v$1@news.netmar.com> In article , Penfold writes: >This is simply the usual nightmare of dealing with pipes between processes. [snip] Thanks for the explanation, I suspected something along those lines... >Solution ... I tend to alter the pipes to no longer be blocking ... I'm not >sure what other people do in these cases. You >can use fctl to do this but I forget the flags you want, something like >NDELAY and O_NOBLOCK ... I have none of >my sample code to hand. Look at man fcntl. Good tip! I've started looking into this, but if anyone has some examples it would be a great help (I would assume people run into these problems all the time? Unfortunately my Python books -- the O'Reilly ones -- make nary a mention of fcntl.) >Alternatively, just read the pipes in a sensible order :-) Well, I tried to do that, and I think I got it working. However, it doesn't seem to be completely reliable, i.e. I have to run popen2.popen3 many times and once in a while it will get stuck, even if the order is right 99% of the time :( Thanks for your help! ----- 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 donn at oz.net Fri Feb 16 08:20:54 2001 From: donn at oz.net (Donn Cave) Date: 16 Feb 2001 07:20:54 GMT Subject: I don't understand popen2 :( References: <96ejto$4q3$1@news.netmar.com> <96idge$97v$1@news.netmar.com> Message-ID: <96ikcm$c1l$0@216.39.151.169> Quoth marco at atmosp.physics.utoronto.ca: | In article , Penfold | writes: | >This is simply the usual nightmare of dealing with pipes between processes. | [snip] | | Thanks for the explanation, I suspected something along those lines... | |> Solution ... I tend to alter the pipes to no longer be blocking ... I'm not |> sure what other people do in these cases. You |> can use fctl to do this but I forget the flags you want, something like |> NDELAY and O_NOBLOCK ... I have none of |> my sample code to hand. Look at man fcntl. | | Good tip! I've started looking into this, but if anyone has some | examples it would be a great help (I would assume people run into | these problems all the time? Unfortunately my Python books -- the | O'Reilly ones -- make nary a mention of fcntl.) Non-blocking may not help at all. I personally prefer to always leave things in a blocking state and use select(); that's essentially similar to non-blocking, though a little better documented, so it's just as likely to be of no use. Both of these techniques apply to UNIX file descriptors (see file object fileno()), and if you're going that way I would also use the UNIX I/O functions - posix.read(), write() etc. and stay away from the file object. The UNIX read() will incidentally return what's in the pipe, instead of blocking for more input as the file object read() does. |> Alternatively, just read the pipes in a sensible order :-) | | Well, I tried to do that, and I think I got it working. | However, it doesn't seem to be completely reliable, i.e. | I have to run popen2.popen3 many times and once in a while | it will get stuck, even if the order is right 99% of the time :( Some applications of this just won't work. The most common problem is when you want to leave both the input and output units open, and the process on the other end of the pipe mysteriously fails to write output you expected. That's because its output is block buffered, and it won't be actually written to the pipe until the buffer is full or the application exits. You can't control that from the other end of the pipe. If you can close the other process' input pipe, then it may exit and flush its buffers. The other problem, and this one select() can help, is when you're blocking on one pipe and the other process is blocking on the other, either waiting to write more data in a full pipe or waiting to read. Donn Cave, donn at oz.net From nstalkie at tvd.be Wed Feb 14 20:09:44 2001 From: nstalkie at tvd.be (mannaert sammy) Date: Wed, 14 Feb 2001 19:09:44 GMT Subject: mailtje van sammy Message-ID: <3A8C48D6.AB561557@tvd.be> dag esmi, zoals daarnet beloofd aan de telefoon : ... mijn cdlijst. als ge iets wilt lenen, ge laat maar iets weten ... sammy. -------------- next part -------------- apoptygma berzerk 7 blackhouse holy war calva y nada el peste perverso lleva mi peluca clair obscur a collection of isolated tracks 1982 - 1988 clair obscur play collapse section covenant sequencer cubanate oxyacetelyne current 93 all dolled up like christ (2CD) current 93 crooked crosses for a noddy god current 93 earth covers earth current 93 faust cybertec project cybertec project daniel mensche static burn das ich die propheten das ich feuer das ich satanische verse de fabriek save the planet death in june discriminate (2CD) death in june operation hummingbird death in june rose clouds of holocaust death in june something is coming (2CD) death in june take care and control death in june the wall of sacrifice der prager handgriff arglistige tauschung diary of dreams cholymelan die form ad infinitum die form silent order re versions (CDS) die form suspiria de profundis die form vicious circles / the best of dissecting table music for performance 'dead body and me' dive live action (CDS) dorsetshire das letzte gefecht einsturzende neubauten zeichnungen des patienten o.t. engelsstaub ignis fatuus: irrlichter esplendor geometrico 1980 - 1982 (2CD) esplendor geometrico 1983 - 1987 esplendor geometrico balearic rhythms esplendor geometrico kosmos kino esplendor geometrico nador esplendor geometrico tarikat (2CD) esplendor geometrico tokyo sin fin fire + ice birdking front 242 front by front front line assembly live wired (2CD) goethes erben blau goethes erben der die das goethes erben leben im niemandsland goethes erben sitz der genade goethes erben tote augen sehen leben hybryds cortex stimulation hybryds ein phallisher gott hypnoskull ffwd>>burnout imminent starvation nord in slaughter natives in slaughter natives in slaughter natives purgate my stain klinik black leather london after midnight selected scenes from the end of the world madre del vizio dio dio dio maeror tri mort aux vaches merzbow oersted muslimgauze bruto (CDS) muslimgauze silknoose muslimgauze zealot (2CD) noisex over and out non might! noshinto revenge of the 50ft monogroove oomph! der neue gott (CDS) puissance let us lead qntal II raison d'etre in sadness, silence and solitude relatives menschsein gefallene engel sol invictus lex talionis sonar sonar sopor aeternus ehjeh asher ehjeh sopor aeternus ich tote mich jedesmal aufs neue ... sopor aeternus the inexperienced spiral traveller sopor aeternus todeswunsch SPK information overload unit SPK leichenschrei sungod sungod the moon lay hidden ... a new soldier follows the path of a new king the moon lay hidden ... a night in fear throbbing gristle assume power focus umbra et imago gedanken eines vampirs umbra et imago infantile spiele umbra et imago traume, sex und tod vromb le facteur humain yasnaia oniro zoviet france what is not true v/a 2/3 v/a antzen anthology (2CD) (only cd 1) v/a bodyhorst's popshow v/a dance macabre sampler v/a electrocity vol. 5 v/a invisible domains v/a jekura - deep the eternal forest v/a sound-line vol. 2 v/a sound-line vol. 3 v/a sound-line vol. 4 v/a sound-line vol. 5 v/a the tyranny of the beat vol. II v/a the tyranny of the beat vol. III v/a to cheer up all yer suicide parties v/a touched by the hand of god (2CD) (only cd 1) v/a zillo clubhits 3 vnv nation praise the fallen x marks the pedwalk freaks x marks the pedwalk meshwork From nstalkie at tvd.be Wed Feb 14 23:47:40 2001 From: nstalkie at tvd.be (mannaert sammy) Date: Wed, 14 Feb 2001 22:47:40 GMT Subject: mailtje van sammy References: <3A8C48D6.AB561557@tvd.be> Message-ID: <3A8C7BEB.20F26277@tvd.be> mannaert sammy wrote: > > dag esmi, > > zoals daarnet beloofd aan de telefoon : > ... mijn cdlijst. > > als ge iets wilt lenen, ge laat maar iets weten ... > > sammy. > argh; i'm sorry about this. From dwig at advancedmp.net Wed Feb 14 20:19:44 2001 From: dwig at advancedmp.net (Don Dwiggins) Date: 14 Feb 2001 11:19:44 -0800 Subject: Possible bug in httplib In-Reply-To: Harry George's message of "Wed, 14 Feb 2001 17:58:53 GMT" Message-ID: I've been "doing exercises" with httplib to familiarize myself with it, and I ran into a problem that I think might be a bug. The HTTPConnection.request method takes an optional "body" argument, useful for POST requests. When I tried to use it, the server I was talking to came back with an empty reply. I was finally able to get the request accepted using a sequence of putheader calls to send the Content-Type header as well as Content-Length. I don't know whether Content-Type is required by the HTTP spec, but at least one server calls for it. Can anyone offer a more authoritative answer as to whether the request method should be sending the Content-Type header? Thanks, -- Don Dwiggins Advanced MP Technology dwig at advancedmp.net From boswell at caltech.edu Fri Feb 16 00:10:36 2001 From: boswell at caltech.edu (Dustin Boswell) Date: Thu, 15 Feb 2001 15:10:36 -0800 Subject: Possible bug in httplib References: Message-ID: <3A8C61EC.5FCE3D64@caltech.edu> I'm not sure if it'll help your problem, but you should get fresh copies of httplib.py and urllib.py (and any others). There are a bunch of little bugs in the Python2.0 distribution. Try the cvs repository.... http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/python/dist/src/?cvsroot=python Hope that helps. -Dustin Boswell ( boswell at caltech.edu ) Don Dwiggins wrote: > I've been "doing exercises" with httplib to familiarize myself with it, and > I ran into a problem that I think might be a bug. > > The HTTPConnection.request method takes an optional "body" argument, useful > for POST requests. When I tried to use it, the server I was talking to came > back with an empty reply. I was finally able to get the request accepted > using a sequence of putheader calls to send the Content-Type header as well > as Content-Length. I don't know whether Content-Type is required by the > HTTP spec, but at least one server calls for it. > > Can anyone offer a more authoritative answer as to whether the request > method should be sending the Content-Type header? > > Thanks, > > -- > Don Dwiggins > Advanced MP Technology > dwig at advancedmp.net From bobhicks.nospam at adelphia.net Wed Feb 14 20:28:23 2001 From: bobhicks.nospam at adelphia.net (Robert L Hicks) Date: Wed, 14 Feb 2001 19:28:23 GMT Subject: Python should have a IDE like this... Message-ID: <140220011428227667%bobhicks.nospam@adelphia.net> http://vtcl.sourceforge.net/snapshot.html This is a good GUI builder for Tcl...and would be nice to have a Python version. - Bob From boud at valdyas.org Wed Feb 14 21:29:05 2001 From: boud at valdyas.org (Boudewijn Rempt) Date: Wed, 14 Feb 2001 21:29:05 +0100 Subject: Python should have a IDE like this... References: <140220011428227667%bobhicks.nospam@adelphia.net> Message-ID: <3a8aeab2$0$36171$1a0eedbc@dreader2.news.xs4all.nl> Robert L Hicks wrote: > http://vtcl.sourceforge.net/snapshot.html > > This is a good GUI builder for Tcl...and would be nice to have a Python > version. > Well, you can get something quite close with the combination of PyQt and Qt Architect. Or, if you are willing to shell out money, with BlackAdder. Boudewijn Rempt | http://www.valdyas.org From bobhicks.nospam at adelphia.net Wed Feb 14 21:41:57 2001 From: bobhicks.nospam at adelphia.net (Robert L Hicks) Date: Wed, 14 Feb 2001 20:41:57 GMT Subject: Python should have a IDE like this... References: <140220011428227667%bobhicks.nospam@adelphia.net> <3a8aeab2$0$36171$1a0eedbc@dreader2.news.xs4all.nl> Message-ID: <140220011541568826%bobhicks.nospam@adelphia.net> I actually do like BlackAdder...but it has always been in the back of my demented mind that there should be a good visual IDE just for Python and Tkinter. The other widget sets(Pmw,Tix, etc.) would be optional. That way it would run everywhere Python and Tkinter do. In article <3a8aeab2$0$36171$1a0eedbc at dreader2.news.xs4all.nl>, Boudewijn Rempt wrote: > Robert L Hicks wrote: > > > http://vtcl.sourceforge.net/snapshot.html > > > > This is a good GUI builder for Tcl...and would be nice to have a Python > > version. > > > > Well, you can get something quite close with the combination of PyQt and Qt > Architect. Or, if you are willing to shell out money, with BlackAdder. > > Boudewijn Rempt | http://www.valdyas.org From bs1535 at sbc.com Wed Feb 14 22:24:26 2001 From: bs1535 at sbc.com (SNYDER, BARRON F. (AIT)) Date: Wed, 14 Feb 2001 16:24:26 -0500 Subject: Python should have a IDE like this... Message-ID: <35BD410BA148D411A7ED00508BCFFBDA05CB2830@msgil65170u05.nbk2305.il.ameritech.com> How about PythonWorks from Secret Labs (www.pythonware.com)? Where does it place on the IDE ladder? -----Original Message----- From: Robert L Hicks [mailto:bobhicks.nospam at adelphia.net] Sent: Wednesday, February 14, 2001 2:42 PM To: python-list at python.org Subject: Re: Python should have a IDE like this... I actually do like BlackAdder...but it has always been in the back of my demented mind that there should be a good visual IDE just for Python and Tkinter. The other widget sets(Pmw,Tix, etc.) would be optional. That way it would run everywhere Python and Tkinter do. In article <3a8aeab2$0$36171$1a0eedbc at dreader2.news.xs4all.nl>, Boudewijn Rempt wrote: > Robert L Hicks wrote: > > > http://vtcl.sourceforge.net/snapshot.html > > > > This is a good GUI builder for Tcl...and would be nice to have a Python > > version. > > > > Well, you can get something quite close with the combination of PyQt and Qt > Architect. Or, if you are willing to shell out money, with BlackAdder. > > Boudewijn Rempt | http://www.valdyas.org -- http://mail.python.org/mailman/listinfo/python-list From dsh8290 at rit.edu Wed Feb 14 22:41:33 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 14 Feb 2001 16:41:33 -0500 Subject: Python should have a IDE like this... In-Reply-To: <140220011428227667%bobhicks.nospam@adelphia.net>; from bobhicks.nospam@adelphia.net on Wed, Feb 14, 2001 at 07:28:23PM +0000 References: <140220011428227667%bobhicks.nospam@adelphia.net> Message-ID: <20010214164133.A17793@harmony.cs.rit.edu> On Wed, Feb 14, 2001 at 07:28:23PM +0000, Robert L Hicks wrote: | http://vtcl.sourceforge.net/snapshot.html | | This is a good GUI builder for Tcl...and would be nice to have a Python | version. | | - Bob As far as GUI builders go, Glade (PyGTK) and wxDesigner (wxPython) are really nice. Glade+libglade is a really cool way to build a GUI. I've just started to try out wxDesigner, and it seems to be a little odd in the way it organizes the code it generates. It might just be that I'm not used to it ... -D From bobhicks at adelphia.net Wed Feb 14 23:52:05 2001 From: bobhicks at adelphia.net (Robert L Hicks) Date: Wed, 14 Feb 2001 22:52:05 GMT Subject: Python should have a IDE like this... References: Message-ID: expensive...I am thinking something that goes for free... > From: "SNYDER, BARRON F. (AIT)" > Organization: Baymountain > Newsgroups: comp.lang.python > Date: Wed, 14 Feb 2001 16:24:26 -0500 > To: python-list at python.org > Subject: RE: Python should have a IDE like this... > > > How about PythonWorks from Secret Labs (www.pythonware.com)? > Where does it place on the IDE ladder? > > > -----Original Message----- > From: Robert L Hicks [mailto:bobhicks.nospam at adelphia.net] > Sent: Wednesday, February 14, 2001 2:42 PM > To: python-list at python.org > Subject: Re: Python should have a IDE like this... > > > I actually do like BlackAdder...but it has always been in the back of > my demented mind that there should be a good visual IDE just for Python > and Tkinter. The other widget sets(Pmw,Tix, etc.) would be optional. > That way it would run everywhere Python and Tkinter do. > > In article <3a8aeab2$0$36171$1a0eedbc at dreader2.news.xs4all.nl>, > Boudewijn Rempt wrote: > >> Robert L Hicks wrote: >> >>> http://vtcl.sourceforge.net/snapshot.html >>> >>> This is a good GUI builder for Tcl...and would be nice to have a Python >>> version. >>> >> >> Well, you can get something quite close with the combination of PyQt and > Qt >> Architect. Or, if you are willing to shell out money, with BlackAdder. >> >> Boudewijn Rempt | http://www.valdyas.org > -- > http://mail.python.org/mailman/listinfo/python-list > From bobhicks at adelphia.net Wed Feb 14 23:52:35 2001 From: bobhicks at adelphia.net (Robert L Hicks) Date: Wed, 14 Feb 2001 22:52:35 GMT Subject: Python should have a IDE like this... References: <140220011428227667%bobhicks.nospam@adelphia.net> Message-ID: I am thinking just a Python/Tkinter version...so it can go wherever Python can. > From: D-Man > Organization: Baymountain > Newsgroups: comp.lang.python > Date: Wed, 14 Feb 2001 16:41:33 -0500 > To: python-list at python.org > Subject: Re: Python should have a IDE like this... > > On Wed, Feb 14, 2001 at 07:28:23PM +0000, Robert L Hicks wrote: > | http://vtcl.sourceforge.net/snapshot.html > | > | This is a good GUI builder for Tcl...and would be nice to have a Python > | version. > | > | - Bob > > As far as GUI builders go, Glade (PyGTK) and wxDesigner (wxPython) are > really nice. Glade+libglade is a really cool way to build a GUI. > I've just started to try out wxDesigner, and it seems to be a little > odd in the way it organizes the code it generates. It might just be > that I'm not used to it ... > > -D > > From wware at world.std.com Thu Feb 15 02:46:52 2001 From: wware at world.std.com (Will Ware) Date: Thu, 15 Feb 2001 01:46:52 GMT Subject: Python should have a IDE like this... References: <140220011428227667%bobhicks.nospam@adelphia.net> Message-ID: D-Man (dsh8290 at rit.edu) wrote: > Glade+libglade is a really cool way to build a GUI. Doesn't Glade only produce C code? I suppose you could make calls to Python from C, but it'd be cool if a GUI builder produced Python directly. Unless I've misunderstood Glade, and it already does this? That would be very cool. -- -----------------------------------+--------------------- 22nd century: Esperanto, geodesic | Will Ware domes, hovercrafts, metric system | wware at world.std.com From jepler at inetnebr.com Thu Feb 15 04:30:41 2001 From: jepler at inetnebr.com (Jeff Epler) Date: Thu, 15 Feb 2001 03:30:41 GMT Subject: Python should have a IDE like this... References: <140220011428227667%bobhicks.nospam@adelphia.net> Message-ID: On Thu, 15 Feb 2001 01:46:52 GMT, Will Ware wrote: >D-Man (dsh8290 at rit.edu) wrote: >> Glade+libglade is a really cool way to build a GUI. > >Doesn't Glade only produce C code? I suppose you could make calls >to Python from C, but it'd be cool if a GUI builder produced Python >directly. Unless I've misunderstood Glade, and it already does this? >That would be very cool. When using python+libglade, you read in the xml-format .glade file from disk. I seem to recall another package which generated Python source code instead, but I don't know what advantages doing this has over reading the xml format. (For instance, you can let a user replace your whole UI by replacing the .glade file, so long as they use the proper widget names) Jeff From wware at world.std.com Thu Feb 15 16:28:17 2001 From: wware at world.std.com (Will Ware) Date: Thu, 15 Feb 2001 15:28:17 GMT Subject: Python should have a IDE like this... References: <140220011428227667%bobhicks.nospam@adelphia.net> Message-ID: I (wware at world.std.com) wrote: > Doesn't Glade only produce C code? > ...it'd be cool if a GUI builder produced Python directly. I got curious enough to invest some time in a web search, and found several Python programs that translate Glade's XML file to Python code: http://glc.sourceforge.net/ http://www.baypiggies.org/stubby.py http://www.fcoutant.freesurf.fr/gladepyc.html These all require pygtk to work: http://www.daa.com.au/~james/pygtk/ There is some info on using Gnome/GTK/Glade with Python here: http://www.baypiggies.org/10mintig.html In my wanderings I stumbled across a very nice one-page Vault-of-Parnassus-type thing: http://www.rimbault.net/python/ -- -----------------------------------+--------------------- 22nd century: Esperanto, geodesic | Will Ware domes, hovercrafts, metric system | wware at world.std.com From delza at antarcti.ca Thu Feb 15 18:14:16 2001 From: delza at antarcti.ca (Dethe Elza) Date: Thu, 15 Feb 2001 17:14:16 GMT Subject: XML for UI (Was: Python should have a IDE like this...) References: <140220011428227667%bobhicks.nospam@adelphia.net> Message-ID: As I understand it, Glade can output your GUI as XML, which you can tweak by hand if desired, and read in at run-time. It's one of the new crop of XML-based GUI tools, but the documentation (last time I checked) was virtually non-existent. WxWindows is also working on an XML format for UI (also under-documented), UIML is an attempt to create XML for UI across systems, languages, and toolkits (it suffers from being *too* general, IMHO), XForms is the W3C attempt to bring standard UI tools to XML/XHTML, XUL is Mozilla's XML toolkit (one of the most featureful which is actually *implemented*), and BML (Bean Markup Language) from IBM's alphaWorks is an XML language for wiring together JavaBeans, which could mean building a UI in Swing with XML. Wouldn't it be nice to have an XML dialect which you could read in in Glade, or wxWindows, or Java, or Tkinter, or Mozilla? Check back soon... --Dethe "Will Ware" wrote in message news:G8rzM4.HK8 at world.std.com... > D-Man (dsh8290 at rit.edu) wrote: > > Glade+libglade is a really cool way to build a GUI. > > Doesn't Glade only produce C code? I suppose you could make calls > to Python from C, but it'd be cool if a GUI builder produced Python > directly. Unless I've misunderstood Glade, and it already does this? > That would be very cool. > > -- > -----------------------------------+--------------------- > 22nd century: Esperanto, geodesic | Will Ware > domes, hovercrafts, metric system | wware at world.std.com From bobhicks.nospam at adelphia.net Thu Feb 15 19:23:25 2001 From: bobhicks.nospam at adelphia.net (Robert L Hicks) Date: Thu, 15 Feb 2001 18:23:25 GMT Subject: XML for UI (Was: Python should have a IDE like this...) References: <140220011428227667%bobhicks.nospam@adelphia.net> Message-ID: <150220011323227393%bobhicks.nospam@adelphia.net> I have little problem with any of the various suggestions that have been made off my original posting. I say little because the topic has strayed a little. The idea was to have an IDE with GUI builder implented in Tkinter. I have actually used the different implementations suggested but...they still are using *other* widget sets (i.e. Qt, GTK+, wxPython). Maybe it is just a "something to get to in the future"... - Bob In article , Dethe Elza wrote: > As I understand it, Glade can output your GUI as XML, which you can tweak by > hand if desired, and read in at run-time. It's one of the new crop of > XML-based GUI tools, but the documentation (last time I checked) was > virtually non-existent. > > WxWindows is also working on an XML format for UI (also under-documented), > UIML is an attempt to create XML for UI across systems, languages, and > toolkits (it suffers from being *too* general, IMHO), XForms is the W3C > attempt to bring standard UI tools to XML/XHTML, XUL is Mozilla's XML > toolkit (one of the most featureful which is actually *implemented*), and > BML (Bean Markup Language) from IBM's alphaWorks is an XML language for > wiring together JavaBeans, which could mean building a UI in Swing with XML. > > Wouldn't it be nice to have an XML dialect which you could read in in Glade, > or wxWindows, or Java, or > Tkinter, or Mozilla? Check back soon... > > --Dethe > > "Will Ware" wrote in message > news:G8rzM4.HK8 at world.std.com... > > D-Man (dsh8290 at rit.edu) wrote: > > > Glade+libglade is a really cool way to build a GUI. > > > > Doesn't Glade only produce C code? I suppose you could make calls > > to Python from C, but it'd be cool if a GUI builder produced Python > > directly. Unless I've misunderstood Glade, and it already does this? > > That would be very cool. > > > > -- > > -----------------------------------+--------------------- > > 22nd century: Esperanto, geodesic | Will Ware > > domes, hovercrafts, metric system | wware at world.std.com From jepler at inetnebr.com Thu Feb 15 04:20:34 2001 From: jepler at inetnebr.com (Jeff Epler) Date: Thu, 15 Feb 2001 03:20:34 GMT Subject: Python should have a IDE like this... References: <140220011428227667%bobhicks.nospam@adelphia.net> Message-ID: On Wed, 14 Feb 2001 19:28:23 GMT, Robert L Hicks wrote: >http://vtcl.sourceforge.net/snapshot.html > >This is a good GUI builder for Tcl...and would be nice to have a Python >version. > >- Bob If vtcl just outputs tcl code, it seems that it should be possible to execute this tcl code using tk.call("source", filename) or tk.call("eval", string) , and then create Python/Tkinter objects corresponding to each widget after the fact. Something like the following could perform the latter task. A better, but more complicate idea, would be to modify vtcl to output Python code directly. And, of course, this code below does nothing to take care of the functions to be called via -command or bind. Lastly, a GUI builder written in Python might be preferable to one written in some other language. import Tkinter, string class _X: pass # Take a tree of widgets created in pure tcl and make them # into Tkinter objects def widget_to_tkinter(path=".", master=None, tk=Tkinter.tkinter.main_interp): if master: tk = master.tk ret = _X() klass = tk.call("winfo", "class", path) if path == ".": klass = "Toplevel" try: ret.__class__ = getattr(Tkinter, klass) except AttributeError: ret.__class__ = Tkinter.Widget if path == ".": ret._w = "." assert master is None and tk is not None ret.tk = tk ret.children = {} else: assert master is not None name = string.split(path, ".")[-1] ret._setup(master, {"name": name}) children = ret.tk.call("winfo", "children", path) if children: children = string.split(children, " ") for item in children: widget_to_tkinter(item, master=ret) return ret From see at post.for.email Thu Feb 15 08:09:05 2001 From: see at post.for.email (Vicegrip) Date: Thu, 15 Feb 2001 07:09:05 GMT Subject: Python should have a IDE like this... References: <140220011428227667%bobhicks.nospam@adelphia.net> Message-ID: Take a look at Komodo..still beta... like the feel of it though. You can download it from Activestate for free. (being beta, I wouldn't recommend it for major projects, but for tinkering, it seems robust enough) /JP From bobhicks at adelphia.net Thu Feb 15 15:14:32 2001 From: bobhicks at adelphia.net (Robert L Hicks) Date: Thu, 15 Feb 2001 14:14:32 GMT Subject: Python should have a IDE like this... References: <140220011428227667%bobhicks.nospam@adelphia.net> Message-ID: Komodo is not a visual builder as vtcl is...it is a nice IDE though. - Bob > From: see at post.for.email (Vicegrip) > Organization: Your Company > Newsgroups: comp.lang.python > Date: Thu, 15 Feb 2001 07:09:05 GMT > Subject: Re: Python should have a IDE like this... > > Take a look at Komodo..still beta... like the feel of it though. > You can download it from Activestate for free. > > (being beta, I wouldn't recommend it for major projects, but for tinkering, > it seems robust enough) > > /JP > From insanc at cc.gatech.edu Wed Feb 14 20:32:11 2001 From: insanc at cc.gatech.edu (Joseph Holland King) Date: 14 Feb 2001 19:32:11 GMT Subject: tkinter x button override Message-ID: <96emfr$ca5$1@solaria.cc.gatech.edu> after creating a frame with the tkinter module, it automatically creates a close button (x on the top right). is there anyway to override the function of this button? i haven't found any documentation so far. thank you. -- --- 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 matt at mondoinfo.com Wed Feb 14 21:00:36 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Wed, 14 Feb 2001 20:00:36 GMT Subject: tkinter x button override References: <96emfr$ca5$1@solaria.cc.gatech.edu> Message-ID: On 14 Feb 2001 19:32:11 GMT, Joseph Holland King wrote: >after creating a frame with the tkinter module, it automatically creates a >close button (x on the top right). is there anyway to override the function >of this button? i haven't found any documentation so far. thank you. It's your window manager that's creating the close button but Tkinter can handle the event. The best documentation for Tkinter that I've found is Fredrik Lundh's excellent An Introduction to Tkinter. See (wrapped for line length): http://www.pythonware.com/library/tkinter/introduction/ events-and-bindings.htm And scroll down to the section on protocols. Regards, Matt From insanc at cc.gatech.edu Wed Feb 14 21:16:07 2001 From: insanc at cc.gatech.edu (Joseph Holland King) Date: 14 Feb 2001 20:16:07 GMT Subject: tkinter x button override References: <96emfr$ca5$1@solaria.cc.gatech.edu> Message-ID: <96ep27$dgc$1@solaria.cc.gatech.edu> Matthew Dixon Cowles wrote: : On 14 Feb 2001 19:32:11 GMT, Joseph Holland King : wrote: : It's your window manager that's creating the close button but Tkinter ok i was not aware that it worked like this, that explains a lot. : http://www.pythonware.com/library/tkinter/introduction/ : events-and-bindings.htm this was exactly what i was looking for. thank you. -- --- 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 zope at thewebsons.com Wed Feb 14 20:50:12 2001 From: zope at thewebsons.com (Ben Ocean) Date: Wed, 14 Feb 2001 11:50:12 -0800 Subject: Robots Message-ID: <5.0.2.1.0.20010214113928.00a0cec0@thewebsons.com> Hi; Does anyone have a good robot script they'd like to share? I need to build one that searches the Web for similarly themed Web sites and grabs email addresses. BenO From gerhard.nospam at bigfoot.de Wed Feb 14 21:31:56 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Wed, 14 Feb 2001 21:31:56 +0100 Subject: Robots References: Message-ID: <3A8AEB3C.4EC31E35@bigfoot.de> Ben Ocean wrote: > > Hi; > Does anyone have a good robot script they'd like to share? I need to build > one that searches the Web for similarly themed Web sites and grabs email > addresses. Are you trying to fill a spam database? If so, you deserve a good kick in your ass. Perhaps this would help you. Gerhard (who hates being spammed) PS: In the improbable case that spamming is not your intention, I apologize. I just cannot imagine any other reason for grabbing emails off html documents. -- 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 zope at thewebsons.com Wed Feb 14 22:40:46 2001 From: zope at thewebsons.com (Ben Ocean) Date: Wed, 14 Feb 2001 13:40:46 -0800 Subject: Robots In-Reply-To: <3A8AEB3C.4EC31E35@bigfoot.de> References: Message-ID: <5.0.2.1.0.20010214133927.00a2fa60@thewebsons.com> At 09:31 PM 2/14/2001 +0100, you wrote: >Ben Ocean wrote: > > > > Hi; > > Does anyone have a good robot script they'd like to share? I need to build > > one that searches the Web for similarly themed Web sites and grabs email > > addresses. > >Are you trying to fill a spam database? If so, you deserve a good kick >in your ass. Perhaps this would help you. LOL! No, sorry that I misled you! I want to contact webmasters individually with individualized emails and invite them to swap links. So... any ideas on a script? BenO >Gerhard (who hates being spammed) > >PS: In the improbable case that spamming is not your intention, I >apologize. I just cannot imagine any other reason for grabbing emails >off html documents. >-- >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 >-- >http://mail.python.org/mailman/listinfo/python-list From jcollin at exis.net Thu Feb 15 16:13:33 2001 From: jcollin at exis.net (Jay Collins) Date: Thu, 15 Feb 2001 10:13:33 -0500 Subject: Robots In-Reply-To: <3A8AEB3C.4EC31E35@bigfoot.de> References: <3A8AEB3C.4EC31E35@bigfoot.de> Message-ID: On Wed, 14 Feb 2001, Gerhard [iso-8859-1] H?ring wrote: > >Gerhard (who hates being spammed) > >PS: In the improbable case that spamming is not your intention, I >apologize. I just cannot imagine any other reason for grabbing emails >off html documents. The anti-spam program sam spadey(?) has a feature that will crawl a website looking for email address so you can figure out who to write to if they got no abuse@ or postmaster at . Take care. From gerhard.nospam at bigfoot.de Thu Feb 15 00:06:39 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Thu, 15 Feb 2001 00:06:39 +0100 Subject: Robots References: Message-ID: <3A8B0F7F.F31995D3@bigfoot.de> > >Are you trying to fill a spam database? If so, you deserve a good kick > >in your ass. Perhaps this would help you. > > LOL! No, sorry that I misled you! I want to contact webmasters individually > with individualized emails and invite them to swap links. So... any ideas > on a script? You are a lucky guy! ;-) Fiddling with HTML is always fun. What about the following for a start? Gerhard --- attempt #1 follows --- #!/usr/bin/env python import re class MailGrabber: def __init__( self ): self.mail_adrs = [] self.mail_regex = re.compile( 'mailto:.*?"' ) def handle_doc( self, s ): for result in re.findall( self.mail_regex, s ): result = result[ len( "mailto:" ) : -1 ] self.mail_adrs.append( result ) grabber = MailGrabber() f = open( 'c://tmp//namenliste.htm', 'r' ) s = f.read() f.close() grabber.handle_doc( s ) print grabber.mail_adrs -- 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 max at alcyone.com Thu Feb 15 02:03:53 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 14 Feb 2001 17:03:53 -0800 Subject: Robots References: Message-ID: <3A8B2AF9.4E2A4029@alcyone.com> Ben Ocean wrote: > LOL! No, sorry that I misled you! I want to contact webmasters > individually > with individualized emails and invite them to swap links. So... any > ideas > on a script? So then, yes, you _do_ want build a spam database. Unsolicited bulk email is unsolicited bulk email, regardless of whether or not _you_ think it's relevant. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ War is cruelty, and you cannot refine it. \__/ Karl Shapiro Erik Max Francis' bookmarks / http://www.alcyone.com/max/links/ A highly categorized list of Web links. From zope at thewebsons.com Thu Feb 15 09:33:09 2001 From: zope at thewebsons.com (Ben Ocean) Date: Thu, 15 Feb 2001 00:33:09 -0800 Subject: Robots In-Reply-To: <3A8B2AF9.4E2A4029@alcyone.com> References: Message-ID: <5.0.2.1.0.20010215002942.00a27d90@thewebsons.com> At 05:03 PM 2/14/2001 -0800, you wrote: >Ben Ocean wrote: > > > LOL! No, sorry that I misled you! I want to contact webmasters > > individually > > with individualized emails and invite them to swap links. So... any > > ideas > > on a script? > >So then, yes, you _do_ want build a spam database. Unsolicited bulk >email is unsolicited bulk email, regardless of whether or not _you_ >think it's relevant. With all due respect... Let's not start a flame war. This will be my last response to this nonsense. The keyword is *bulk* When it's sent individually, it's not *bulk*. Put that in your pipe and smoke it. I'm trying to build something similar to the Zeus robot at http://cyber-robotics.com/ Now, for you purists that think that *any* use of automation to communicate with others is spam, well, you're using automation... The key is you're not doing it in bulk. Neither am I. Okay??? BenO >-- > Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ > __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE >/ \ War is cruelty, and you cannot refine it. >\__/ Karl Shapiro > Erik Max Francis' bookmarks / http://www.alcyone.com/max/links/ > A highly categorized list of Web links. >-- >http://mail.python.org/mailman/listinfo/python-list From michael at stroeder.com Thu Feb 15 07:29:04 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Thu, 15 Feb 2001 07:29:04 +0100 Subject: Robots References: Message-ID: <3A8B7730.2B3E43CD@stroeder.com> Ben Ocean wrote: > > At 09:31 PM 2/14/2001 +0100, you wrote: > >Ben Ocean wrote: > > > > > > Hi; > > > Does anyone have a good robot script they'd like to share? I need to build > > > one that searches the Web for similarly themed Web sites and grabs email > > > addresses. > > > >Are you trying to fill a spam database? If so, you deserve a good kick > >in your ass. Perhaps this would help you. > > LOL! No, sorry that I misled you! I want to contact webmasters individually > with individualized emails and invite them to swap links. Please add me to the opt-out list. I'm getting tired of e-mails suggesting swapping links. Michael. From scarblac at pino.selwerd.nl Thu Feb 15 18:49:31 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 15 Feb 2001 17:49:31 GMT Subject: Robots References: Message-ID: Ben Ocean wrote in comp.lang.python: > LOL! No, sorry that I misled you! I want to contact webmasters individually > with individualized emails and invite them to swap links. So... any ideas > on a script? So, getting the emails automatically won't be much help. After all, you'll collect many adresses from people other than the relevant webmaster, and you'll have to look at the pages manually anyway, to decide who you should send your request to. Although you might make a program to find out which pages have email adresses. If you're writing some sort of spider, check out Tools/webchecker/webchecker.py in the source distribution, a program that checks links on a website; you might be able to adapt it. So what's left is finding the interesting pages. That's a very hard problem, do you have any idea how you want to decide what constitutes a web page similar to yours? If you're looking for certain keywords, it may be easiest to just enter them into Google... -- Remco Gerlich From zope at thewebsons.com Fri Feb 16 00:20:34 2001 From: zope at thewebsons.com (Ben Ocean) Date: Thu, 15 Feb 2001 15:20:34 -0800 Subject: Robots In-Reply-To: References: Message-ID: <5.0.2.1.0.20010215151735.00a0ccd0@thewebsons.com> At 05:49 PM 2/15/2001 +0000, you wrote: >So, getting the emails automatically won't be much help. After all, you'll >collect many adresses from people other than the relevant webmaster, and >you'll have to look at the pages manually anyway, to decide who you should >send your request to. > >Although you might make a program to find out which pages have email >adresses. If you're writing some sort of spider, check out >Tools/webchecker/webchecker.py in the source distribution, a program that >checks links on a website; you might be able to adapt it. > >So what's left is finding the interesting pages. That's a very hard problem, >do you have any idea how you want to decide what constitutes a web page >similar to yours? If you're looking for certain keywords, it may be easiest >to just enter them into Google... Yeah. The way Zeus operates, you enter 100 keyword phrases and it looks for relevant matches. You could well be right that just hitting Google, or what have you, would be just as effective: I've thought the same. Maybe I'll do just that. If not, I should at least salt my robot-generated results with that. Or better yet, feed that info into my robot. Thanks! BenO From greg at cosc.canterbury.ac.nz Fri Feb 16 04:06:09 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 16 Feb 2001 16:06:09 +1300 Subject: Robots References: Message-ID: <3A8C9921.66FFC046@cosc.canterbury.ac.nz> Ben Ocean wrote: > > The keyword is *bulk* Actually, it's not. When you send someone a piece of unsolicited email, if they're going to be annoyed by it, then they'll be just as annoyed regardless of how many *other* people have got the same piece of mail. The key word is *unsolicited*. -- 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 sholden at holdenweb.com Fri Feb 16 14:46:00 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 16 Feb 2001 08:46:00 -0500 Subject: Robots References: <3A8C9921.66FFC046@cosc.canterbury.ac.nz> Message-ID: "Greg Ewing" wrote from the wilds of New Zealand ... > Ben Ocean wrote: > > > > The keyword is *bulk* > > Actually, it's not. When you send someone a piece > of unsolicited email, if they're going to be annoyed > by it, then they'll be just as annoyed regardless of > how many *other* people have got the same piece of mail. > > The key word is *unsolicited*. > Yup. I get mails from people offering me link exchanges when my email address appears on the site as the developer: I have no rights to accept or refuse link exchanges for the sites, and get quite enough email as it is, thank you. It may be a low-volume project Ben is proposing, but there can be low-volume spam as well as high-volume spam. And, of course, Ben, you'll be programming in such refinements as a database to ensure you only ever bother each email address once, right? I tend to work on the basis that my web site (page, really) doesn't contain enough of interest to make a link on it valuable. Ben's might be different, of course. regards Steve From joseamartin at venmex.com Wed Feb 14 21:18:33 2001 From: joseamartin at venmex.com (Jose Martin) Date: Wed, 14 Feb 2001 16:18:33 -0400 Subject: Calling Stored Procedure in DCOracle How To ? Message-ID: Hi, How can i call a stored procedure within DCOracle ? Mi stored procedure has no parameters. 1- I was tryed calling dbc.callproc('myproc') but get an error about the numbers of arguments tell me that the params espected are 1 and got 0 2- I was tryed usign dbc.procedures.myproc but nothing happend. 3- I was tryed using dbc.procedures.myproc.__call__() , but it is the same thing what 1 error. What i can do ? From phd at phd.pp.ru Thu Feb 15 13:12:57 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 15 Feb 2001 15:12:57 +0300 (MSK) Subject: Calling Stored Procedure in DCOracle How To ? In-Reply-To: Message-ID: On Wed, 14 Feb 2001, Jose Martin wrote: > 1- I was tryed calling dbc.callproc('myproc') but get an error about the > numbers of arguments > tell me that the params espected are 1 and got 0 Try dbc.callproc('myproc', []) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From joseamartin at mail.venmex.com Thu Feb 15 13:56:21 2001 From: joseamartin at mail.venmex.com (Jose Martin) Date: Thu, 15 Feb 2001 08:56:21 -0400 Subject: Calling Stored Procedure in DCOracle How To ? References: Message-ID: <004e01c0974e$b220ef40$9101a8c0@venmex.com> THanks Oleg. but dbc.callproc('myproc', []) <---- Second Argument must be a tuple. Error. I have more troubles. I was modified my stored procedures an add a dummy parameter for calling without errors then yes, I can call them !!!!. But. Another Error appears >>> dbc.callproc('pktrans.proc_solicitudes',(1,)) Traceback (innermost last): File "", line 1, in ? File "/usr/lib/python1.5/DCOracle/ocidb.py", line 98, in callproc return apply(getattr(self.procedures, name),params) File "/usr/lib/python1.5/DCOracle/ociProc.py", line 133, in __call__ if oci_.oexec(oc): self._error() File "/usr/lib/python1.5/DCOracle/ociProc.py", line 106, in _error raise error, (rc, oci_.OracleErrorMessage(c.lda, rc)) oci.error: (1403, 'ORA-01403: no data found\012ORA-06512: at "TRANS.PKTRANS", li ne 54\012ORA-06512: at "TRANS.PKTRANS", line 92\012ORA-06512: at "TRANS.PKTRANS" , line 30\012ORA-06512: at line 2') I can run This Stored Procedure from SQLPlus and works ok without erros. Can Help !. I am doing a simulation of my bussines in python , i really need to call this stored procedures. I have another ideas, but are some tricky. I can define a dummy table with an update trigger and then this trigger can call internally to the Procedure inserted or updated in ProcName column of dummy table. But may exits any way to call Stored Procedures from DCOracle ? Thanks... ----- Original Message ----- From: Oleg Broytmann To: Jose Martin Cc: python-list at python.org Sent: Thursday, February 15, 2001 8:12 AM Subject: Re: Calling Stored Procedure in DCOracle How To ? On Wed, 14 Feb 2001, Jose Martin wrote: > 1- I was tryed calling dbc.callproc('myproc') but get an error about the > numbers of arguments > tell me that the params espected are 1 and got 0 Try dbc.callproc('myproc', []) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. -------------- next part -------------- An HTML attachment was scrubbed... URL: From phd at phd.pp.ru Thu Feb 15 17:07:48 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 15 Feb 2001 19:07:48 +0300 (MSK) Subject: Calling Stored Procedure in DCOracle How To ? In-Reply-To: <004e01c0974e$b220ef40$9101a8c0@venmex.com> Message-ID: On Thu, 15 Feb 2001, Jose Martin wrote: > dbc.callproc('myproc', []) <---- Second Argument must be a tuple. I always used (when I used DCOracle at all) lists. But I never had procedures without parameters. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From joseamartin at venmex.com Thu Feb 15 14:35:59 2001 From: joseamartin at venmex.com (Jose Martin) Date: Thu, 15 Feb 2001 09:35:59 -0400 Subject: Calling Stored Procedure in DCOracle How To ? References: Message-ID: Thanks Oleg. I am Currently calling my procedure with a dummy param in this form: dbc.procedures.PKTRANS.PROC_SOLICITUDES(1) and works ok. but still need to define a dummy parameter for the stored procedure!. Bye. Oleg Broytmann escribi? en el mensaje de noticias mailman.982239257.6703.python-list at python.org... > On Wed, 14 Feb 2001, Jose Martin wrote: > > 1- I was tryed calling dbc.callproc('myproc') but get an error about the > > numbers of arguments > > tell me that the params espected are 1 and got 0 > > Try dbc.callproc('myproc', []) > > Oleg. > ---- > Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru > Programmers don't die, they just GOSUB without RETURN. > > From MarkH at ActiveState.com Wed Feb 14 23:22:32 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 14 Feb 2001 22:22:32 GMT Subject: COM support for vtable based interfaces. Message-ID: <3A8B0448.1000905@ActiveState.com> Hi all, I have recently checked in a new version of win32com that allows you to implement _any_ COM interface decribed in a type library, either IDispatch based or not. This is excellent news :) You still can't _call_ these arbitary interfaces, but no doubt this will follow in good time. If you are keen, please pull the latest sources from CVS and let me know what happens :) win32com\readme.html has a brief example. Mark. -- Nominate Your Favorite Programmers for the Perl and Python Active Awards! http://www.ActiveState.com/Awards/ From tuttledon at hotmail.com Thu Feb 15 00:41:28 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Wed, 14 Feb 2001 23:41:28 GMT Subject: COM support for vtable based interfaces. References: <3A8B0448.1000905@ActiveState.com> Message-ID: "Mark Hammond" wrote in message news:3A8B0448.1000905 at ActiveState.com... > Hi all, > I have recently checked in a new version of win32com that allows you to > implement _any_ COM interface decribed in a type library, either > IDispatch based or not... If you are keen, please pull the latest sources from CVS > Mark. Good news Mark! However I have a request you can pass on to Dick or whoever. Why isn't ActiveState releasing Python builds BETWEEN major releases that incorporate all the changes in the CVS? This would be a great way to hook people into using their build. Especially us CVS impaired types ;-) Don From syver at NOSPAMcyberwatcher.com Thu Feb 15 13:40:58 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Thu, 15 Feb 2001 13:40:58 +0100 Subject: COM support for vtable based interfaces. References: <3A8B0448.1000905@ActiveState.com> Message-ID: Super, this means that I can implement COM classes support the same interface as a typical ATL generated dual-interface COM object doesn't it? That's good news indeed! I've been needing this for a little while. "Mark Hammond" wrote in message news:3A8B0448.1000905 at ActiveState.com... > Hi all, > I have recently checked in a new version of win32com that allows you to > implement _any_ COM interface decribed in a type library, either > IDispatch based or not. This is excellent news :) You still can't > _call_ these arbitary interfaces, but no doubt this will follow in good > time. > > If you are keen, please pull the latest sources from CVS and let me know > what happens :) win32com\readme.html has a brief example. > > Mark. > -- > Nominate Your Favorite Programmers > for the Perl and Python Active Awards! > http://www.ActiveState.com/Awards/ > From MarkH at ActiveState.com Thu Feb 15 23:19:10 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 15 Feb 2001 22:19:10 GMT Subject: COM support for vtable based interfaces. References: <3A8B0448.1000905@ActiveState.com> Message-ID: <3A8C5500.6040709@ActiveState.com> Syver Enstad wrote: > Super, this means that I can implement COM classes support the same > interface as a typical ATL generated dual-interface COM object doesn't it? > That's good news indeed! I've been needing this for a little while. It does indeed! Mark. -- Nominate Your Favorite Programmers for the Perl and Python Active Awards! http://www.ActiveState.com/Awards/ From gerhard.nospam at bigfoot.de Fri Feb 16 00:47:45 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Fri, 16 Feb 2001 00:47:45 +0100 Subject: COM support for vtable based interfaces. References: <3A8B0448.1000905@ActiveState.com> Message-ID: <3A8C6AA1.81CA8580@bigfoot.de> Mark Hammond wrote: > [...] > If you are keen, please pull the latest sources from CVS and let me know > what happens :) win32com\readme.html has a brief example. Silly question maybe, but: which CVS?? I can't find it in the Python CVS tree at SourceForge. Or is it in a CVS server somewhere at ActiveState? 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 MarkH at ActiveState.com Fri Feb 16 05:24:32 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Fri, 16 Feb 2001 04:24:32 GMT Subject: COM support for vtable based interfaces. References: <3A8B0448.1000905@ActiveState.com> <3A8C6AA1.81CA8580@bigfoot.de> Message-ID: <3A8CAAA3.9030306@ActiveState.com> Gerhard H?ring wrote: > Mark Hammond wrote: > >> [...] >> If you are keen, please pull the latest sources from CVS and let me know >> what happens :) win32com\readme.html has a brief example. > > > Silly question maybe, but: which CVS?? I can't find it in the Python CVS > tree at SourceForge. Or is it in a CVS server somewhere at ActiveState? See http://starship.python.net/crew/mhammond/cvs.html Mark. -- Nominate Your Favorite Programmers for the Perl and Python Active Awards! http://www.ActiveState.com/Awards/ From dubois at users.sourceforge.net Thu Feb 15 00:22:04 2001 From: dubois at users.sourceforge.net (Paul F. Dubois) Date: Wed, 14 Feb 2001 23:22:04 GMT Subject: Utility for showing script execution? Message-ID: I'm looking for a utility that will take a Python .py file and execute it, producing output that shows the "input" lines, marked with a prompt, and then the resulting output, so that one has an output text file that simulates what a user would see. Surely someone already did this? Paul From fredrik at pythonware.com Thu Feb 15 08:45:50 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 15 Feb 2001 07:45:50 GMT Subject: Utility for showing script execution? References: Message-ID: Paul F. Dubois wrote: > I'm looking for a utility that will take a Python .py file and execute it, > producing output that shows the "input" lines, marked with a prompt, and > then the resulting output, so that one has an output text file that > simulates what a user would see. Surely someone already did this? of course! # adapted from code-example-1.py in # the eff-bot guide to the python standard library import code import string SCRIPT = """ a = 5 for i in range(a): print i print 'hello' """ chunk = "" for line in string.split(SCRIPT, "\n"): chunk = chunk + line + "\n" co = code.compile_command(chunk, "", "exec") if co: # got a complete statement. execute it! prompt = ">>>" if string.count(chunk, "\n") == 1: print prompt, chunk, else: for line in string.split(chunk, "\n"): print prompt, line prompt = "..." exec co chunk = "" Cheers /F From skip at mojam.com Thu Feb 15 00:25:43 2001 From: skip at mojam.com (Skip Montanaro) Date: Wed, 14 Feb 2001 17:25:43 -0600 (CST) Subject: general purpose database cleanup tools (design patterns or Python)? Message-ID: <14987.5111.12981.891744@beluga.mojam.com> A side effect of people using the Mojam and Musi-Cal web sites is that a fairly complex MySQL database gets built. There are several tables in the database (venues, concerts, cities, etc) that can accumulate errors fairly rapidly because the system allows anyone with concerts to publicize to add them to our database. Because of the size of the tables and their interdependencies, manually correcting all but the most straightforward errors is impossible. I'm looking for pointers to design patterns or tools (preferably in Python) that might be applicable to the task. I think such tools would separate the description of the database's structure from the rules about deleting and merging rows, which would, in turn, be separate from the engine that actually manipulates the database. We have a tool now that works reasonably well but is very difficult to maintain and enhance because none of the three functions are separate. Before I launch into a complete redesign, I thought I'd see what already exists. This can't be a problem unique to our environment. Thx, -- Skip Montanaro (skip at mojam.com) Support Mojam & Musi-Cal: http://www.musi-cal.com/sponsor.shtml (847)971-7098 From missive at frontiernet.net Sat Feb 17 05:03:55 2001 From: missive at frontiernet.net (Lee Harr) Date: 17 Feb 2001 04:03:55 GMT Subject: general purpose database cleanup tools (design patterns or Python)? References: Message-ID: <96kt7b$1k5q$1@node17.cwnet.frontiernet.net> On Wed, 14 Feb 2001 17:25:43 -0600 (CST), Skip Montanaro wrote: > I can't really tell what you are wanting to do, but I get the sense that what you are looking for is a relational database which allows you to maintain relational integrity. Take a look at postgres( http://www.postgresql.org ) >A side effect of people using the Mojam and Musi-Cal web sites is that a >fairly complex MySQL database gets built. There are several tables in the >database (venues, concerts, cities, etc) that can accumulate errors fairly >rapidly because the system allows anyone with concerts to publicize to add >them to our database. Because of the size of the tables and their >interdependencies, manually correcting all but the most straightforward >errors is impossible. > >I'm looking for pointers to design patterns or tools (preferably in Python) >that might be applicable to the task. I think such tools would separate the >description of the database's structure from the rules about deleting and >merging rows, which would, in turn, be separate from the engine that >actually manipulates the database. > >We have a tool now that works reasonably well but is very difficult to >maintain and enhance because none of the three functions are separate. >Before I launch into a complete redesign, I thought I'd see what already >exists. This can't be a problem unique to our environment. > >Thx, > >-- >Skip Montanaro (skip at mojam.com) >Support Mojam & Musi-Cal: http://www.musi-cal.com/sponsor.shtml >(847)971-7098 > From simon at callan.demon.co.uk Thu Feb 15 00:54:02 2001 From: simon at callan.demon.co.uk (Simon Callan) Date: Wed, 14 Feb 2001 23:54:02 +0000 Subject: os.path.walk oddity Message-ID: <7fceef4c4a.simon@satin.callan.demon.co.uk> For reasons to complicated to go into here, I am having to rearrange a source tree. Basically every .c file has to be moved into a subdirectory called 'c', with the extension removed, while .h files are moved to a 'h' directory. I.e fred/jim.c -> fred.c.jim fred/sheila.h -> fred.h.sheila After figuring out how to stop os.path.walk crashing due to renaming files, I ended up with the following: ===== #!/usr/bin/env python import os def rename(dir, root, ext): new_dir = os.path.join(dir, ext) if not os.path.exists(new_dir): os.mkdir(new_dir) o_file = os.path.join(dir, root) + '.' + ext n_file = os.path.join(dir, ext, root) print "%s -> %s" % (o_file, n_file) os.rename(o_file, n_file) def toRiscos(arg, dir, names): temp = names count = 0 for file in temp: root, ext = os.path.splitext(file) if ext == '.c': del names[count] rename(dir, root, 'c') elif ext == '.h': del names[count] rename(dir, root, 'h') count += 1 os.path.walk('.', toRiscos, None) ===== However, there is one problem. If I run the above on the python 2.0 source directory, it takes 3 runs of the programme to completely convert the tree. Can anyone explain why this is? Simon -- http://www.callan.demon.co.uk/simon/ From fredrik at pythonware.com Thu Feb 15 09:07:26 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 15 Feb 2001 08:07:26 GMT Subject: os.path.walk oddity References: <7fceef4c4a.simon@satin.callan.demon.co.uk> Message-ID: <27Mi6.17200$AH6.2346966@newsc.telia.net> Simon Callan wrote: > def toRiscos(arg, dir, names): > temp = names this assignment doesn't make a copy, it just adds another reference to the "names" array. > count = 0 > for file in temp: same thing as iterating over names. > root, ext = os.path.splitext(file) > if ext == '.c': > del names[count] here you're modifing the array you're looping over. that's bad. > rename(dir, root, 'c') > elif ext == '.h': > del names[count] > rename(dir, root, 'h') > count += 1 two possible solutions: change the loop to for file in names[:]: or get rid of the del statements. for-in won't loop over an item more than once anyway... Cheers /F From simon at callan.demon.co.uk Thu Feb 15 20:33:31 2001 From: simon at callan.demon.co.uk (Simon Callan) Date: Thu, 15 Feb 2001 19:33:31 +0000 Subject: os.path.walk oddity References: <7fceef4c4a.simon@satin.callan.demon.co.uk> <27Mi6.17200$AH6.2346966@newsc.telia.net> Message-ID: <7bca5b4d4a.simon@satin.callan.demon.co.uk> In message <27Mi6.17200$AH6.2346966 at newsc.telia.net> "Fredrik Lundh" wrote: > Simon Callan wrote: > > def toRiscos(arg, dir, names): > > temp = names > > this assignment doesn't make a copy, it just adds another reference > to the "names" array. I throw myself on the mercy of the court, and plead mitigating circumstances, to wit, having just spent a lot of effort getting a C++ program to do a deep copy under precisely these conditions. > two possible solutions: change the loop to > > for file in names[:]: Bingo! This works first time, after allowing for the list changing in size after a del. > or get rid of the del statements. for-in won't loop over an item > more than once anyway... The reason for using the del is that os.path.walk() throws a serious wobbly when it finds that the file has moved away from under it. Thanks for your help. Simon -- http://www.callan.demon.co.uk/simon/ From billings at eudoramail.com Thu Feb 15 02:06:13 2001 From: billings at eudoramail.com (Scott Billings) Date: Wed, 14 Feb 2001 19:06:13 -0600 Subject: Getting Value From Tkinter Text Object Message-ID: <96faar$30s$1@ins21.netins.net> I have an app, in which I need to get the entire contents of a Tkinter Text object. It will be of an arbitrary length. The only option I can find that even seems to be close to what I want, is the get() method, which expects a starting and ending point. Starting point should be easy enough, but I have no way of knowing what the ending point will be. Is there some other method for Text objects that I can use, that has a similar function to the Entry object's get() method? -- -Scott- From fuess at att.net Thu Feb 15 04:25:21 2001 From: fuess at att.net (David Fuess) Date: Thu, 15 Feb 2001 03:25:21 GMT Subject: Getting Value From Tkinter Text Object References: <96faar$30s$1@ins21.netins.net> Message-ID: <40jm8tk0r075er31k24960slmaj74lv42k@4ax.com> On Wed, 14 Feb 2001 19:06:13 -0600, Scott Billings wrote: >I have an app, in which I need to get the entire contents of a Tkinter Text >object. It will be of an arbitrary length. > >The only option I can find that even seems to be close to what I want, is >the get() method, which expects a starting and ending point. Starting point >should be easy enough, but I have no way of knowing what the ending point >will be. So use END. i.e. control.get(0,END) > >Is there some other method for Text objects that I can use, that has a >similar function to the Entry object's get() method? From fredrik at pythonware.com Thu Feb 15 08:49:31 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 15 Feb 2001 07:49:31 GMT Subject: Getting Value From Tkinter Text Object References: <96faar$30s$1@ins21.netins.net> Message-ID: Scott Billings wrote: > The only option I can find that even seems to be close to what I want, is > the get() method, which expects a starting and ending point. Starting point > should be easy enough, but I have no way of knowing what the ending point > will be. http://www.pythonware.com/library/tkinter/introduction/text.htm => concepts, patterns "END (or "end") corresponds to the position just after the last character in the buffer. "To fetch the text contents of the widget, use the get method: contents = text.get(1.0, END) Cheers /F From k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m Thu Feb 15 04:23:42 2001 From: k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m (Keith Ray) Date: Thu, 15 Feb 2001 03:23:42 GMT Subject: Universal Virtual Machine References: Message-ID: In article , "Steve Wart" wrote: [...] > Whether .NET supports Smalltalk or not is not relevant. It is proprietary > and closed (I wonder if Microsoft understands that .NET is supposed to be > the operating system, not something you package with Windows or Windows > CE > or whatever they're calling it now). [...] > What I am thinking of is an open source project to create a standard VM > for > Smalltalk but that also supports other languages, such as Java and perl, > and > more importantly, new language directions for Self-like and MOP > extensions > to Smalltalk. Similar to the Transmeta architecture (except all in > software), one could define pluggable byte code dictionaries that the VM > could swap in as required. > > This would allow one VM to work with several Smalltalk dialects, without > requiring vendors to agree on a standard set of byte codes. The issues > with > the Garbage Collector seem more difficult to me, but if Microsoft can > claim > that .NET is a multi-language VM that provides GC services to any > language, > than it should be possible to do this for Smalltalk as well, shouldn't > it? [...] I would like to see an open-source universal VM that runs on MacOS, Windows, Linux, etc... that is why I want to take the first step in that direction by porting a popular byte-code-compiled open-source language (Python/Jython) into Squeak, an open-source Smalltalk. See my reply to "sma at 3plus4.de": - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - In article <7MGJOov0nvx+VW3xYgkmsmMz2tDQ at 4ax.com>, sma at 3plus4.de wrote: > On Sat, 03 Feb 2001 02:57:36 GMT, Keith Ray > wrote: > > >Has anyone tried to write a Python interpreter in Smalltalk? > > I tried this, although using Squeak Smalltalk not Dolphin Smalltalk. > I never finished the project but there's a partially working parser > which I could share. > > bye > -- > Stefan Matthias Aust____Truth until Paradox!____________________ > Jobs? ==> jobs at baltic-online.de www.baltic-online.de I have the desire to see Python running inside Squeak + I was planning to start porting from the Jython sources, since those are already in an object oriented language (Java). If you could, please email your parser to me and it will help me learn how Squeak could host a Python language. C. Keith Ray remove spaces to get my email address c k e i t h r a y @ h o m e . c o m -- -- From andrew at andrewcooke.free-online.co.uk Thu Feb 15 09:58:16 2001 From: andrew at andrewcooke.free-online.co.uk (Andrew Cooke) Date: Thu, 15 Feb 2001 08:58:16 +0000 Subject: Universal Virtual Machine References: Message-ID: <3A8B9A28.97BA7DEA@andrewcooke.free-online.co.uk> Maybe repeating info here, but are you aware of C--? http://www.cminusminus.org/index.html Keith Ray wrote: > I would like to see an open-source universal VM that runs on MacOS, > Windows, Linux, etc... that is why I want to take the first step in that > direction by porting a popular byte-code-compiled open-source language > (Python/Jython) into Squeak, an open-source Smalltalk. From lopemanc at swbell.net Thu Feb 15 18:54:57 2001 From: lopemanc at swbell.net (Chris Lopeman) Date: Thu, 15 Feb 2001 17:54:57 GMT Subject: Universal Virtual Machine References: <3A8B9A28.97BA7DEA@andrewcooke.free-online.co.uk> Message-ID: <3A8C1804.1BB614F7@swbell.net> Andrew Cooke wrote: > Maybe repeating info here, but are you aware of C--? I had not heard of this before. Its kind of funny because I knew Sun people that would call Java C++--. > > > http://www.cminusminus.org/index.html > > Keith Ray wrote: > > I would like to see an open-source universal VM that runs on MacOS, > > Windows, Linux, etc... that is why I want to take the first step in that > > direction by porting a popular byte-code-compiled open-source language > > (Python/Jython) into Squeak, an open-source Smalltalk. From jschmitt at vmlabs.com Thu Feb 15 04:46:19 2001 From: jschmitt at vmlabs.com (John Schmitt) Date: Wed, 14 Feb 2001 19:46:19 -0800 Subject: __contains__() Message-ID: <008F0A63472BD311AF9800104BCD102561CC8B@minirex.vmlabs.com> I did something a little cheezy. >>>class foo: def __contains__(self,n): return 42 >>>f = foo() >>>3 in f 1 I thought I would get back 42. The manual doesn't say that it must strictly return 0 or 1, just something true or false. I wonder what the PSU has to say about this. How does one become a memb From greg at cosc.canterbury.ac.nz Fri Feb 16 04:24:14 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 16 Feb 2001 16:24:14 +1300 Subject: __contains__() References: Message-ID: <3A8C9D5E.9AEBECB7@cosc.canterbury.ac.nz> John Schmitt wrote: > > The manual doesn't say that it must strictly > return 0 or 1, just something true or false. Which is what you're doing, and it's interpreting it as "true". It also doesn't say that "x in y" will return the exact value returned by y's __contains()__ method, either. The reason is that, internally, it's being funneled through the C version of the __contains__ method in the typeobject, which returns a C int, not a general Python object. The interpreter then converts that into a canonical Python boolean value. -- 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 not.this at seebelow.org Thu Feb 15 04:54:49 2001 From: not.this at seebelow.org (Grant Griffin) Date: Wed, 14 Feb 2001 21:54:49 -0600 Subject: recursing glob Message-ID: <3A8B5309.F5B07C85@seebelow.org> Hi Gang, I had a need to recurse "glob" into subdirectories today, and I ended up coming up with something using os.walk. It was pretty brief (only a few lines), but it didn't seem very elegant. (Somehow I never am happy with stuff I do with os.walk--is it just me?) Anyway, does anybody have any ideas on how to recurse glob more elegantly? BTW, why isn't subdirectory recursion an option for glob.glob, or perhaps another function in the "glob" module. (And how does one suggest new functions for modules--without writing a PEP? ) if-they-gave-"glob"-a-more-attractive-name-might-be-able-to-make -some-friends--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 fredrik at pythonware.com Thu Feb 15 08:35:44 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 15 Feb 2001 07:35:44 GMT Subject: recursing glob References: <3A8B5309.F5B07C85@seebelow.org> Message-ID: Grant Griffin wrote: > Somehow I never am happy with stuff I do with os.walk--is it > just me? no. > Anyway, does anybody have any ideas on how to recurse glob > more elegantly? define "more elegantly" ;-) the following involves more library code, but is much easier to use. (reposted) From: "Fredrik Lundh" Subject: Re: glob Date: Wed, 10 May 2000 09:35:43 +0200 > Is there a recursive glob? no, but you can easily roll your own using os.path.walk and the fnmatch module. or you can use this iterator class, adapted from an example in the eff-bot library guide (see below): # # adapted from os-path-walk-example-3.py import os import fnmatch class GlobDirectoryWalker: # a forward iterator that traverses a directory tree def __init__(self, directory, pattern="*"): self.stack = [directory] self.pattern = pattern self.files = [] self.index = 0 def __getitem__(self, index): while 1: try: file = self.files[self.index] self.index = self.index + 1 except IndexError: # pop next directory from stack self.directory = self.stack.pop() self.files = os.listdir(self.directory) self.index = 0 else: # got a filename fullname = os.path.join(self.directory, file) if os.path.isdir(fullname) and not os.path.islink(fullname): self.stack.append(fullname) if fnmatch.fnmatch(file, self.pattern): return fullname for file in GlobDirectoryWalker(".", "*.py"): print file From not.this at seebelow.org Fri Feb 16 04:58:36 2001 From: not.this at seebelow.org (Grant Griffin) Date: Thu, 15 Feb 2001 21:58:36 -0600 Subject: recursing glob References: <3A8B5309.F5B07C85@seebelow.org> Message-ID: <3A8CA56C.4F1676F1@seebelow.org> Fredrik Lundh wrote: > > Grant Griffin wrote: > > Somehow I never am happy with stuff I do with os.walk--is it > > just me? > > no. In retrospect, I think os.walk would be a lot friendlier if it passed two arguments to its function instead of one. (When I first began with Python, I didn't realize that that "one" argument could be a list or a tuple.) > > > Anyway, does anybody have any ideas on how to recurse glob > > more elegantly? > > define "more elegantly" ;-) > > the following involves more library code, but is much > easier to use. > > (reposted) > > From: "Fredrik Lundh" > Subject: Re: glob > Date: Wed, 10 May 2000 09:35:43 +0200 > > > Is there a recursive glob? > > no, but you can easily roll your own using os.path.walk > and the fnmatch module. > > or you can use this iterator class, adapted from an example > in the eff-bot library guide (see below): > > # > # adapted from os-path-walk-example-3.py > > import os > import fnmatch > > class GlobDirectoryWalker: > # a forward iterator that traverses a directory tree > > def __init__(self, directory, pattern="*"): > self.stack = [directory] > self.pattern = pattern > self.files = [] > self.index = 0 > > def __getitem__(self, index): > while 1: > try: > file = self.files[self.index] > self.index = self.index + 1 > except IndexError: > # pop next directory from stack > self.directory = self.stack.pop() > self.files = os.listdir(self.directory) > self.index = 0 > else: > # got a filename > fullname = os.path.join(self.directory, file) > if os.path.isdir(fullname) and not os.path.islink(fullname): > self.stack.append(fullname) > if fnmatch.fnmatch(file, self.pattern): > return fullname > > for file in GlobDirectoryWalker(".", "*.py"): > print file Cool! Thanks. I think that's definitely more elegant than what I did: def glob_recurse(args, dirname, names): """ args[0] = pattern, args[1] = file list """ args[1] += glob.glob(os.path.join(dirname, args[0])) and then: os.path.walk('.', glob_recurse, [pattern, file_names]) I think this would have been pretty easy for a more seasoned Pythoneer to cough up, but it took me awhile. In particular, I tried to pass it a tuple at first, and it took me awhile to figure out the source of the error message. we-horses-don't-always-drink-the-water-we're-lead-to-if-it's-not -clearly-labeled-as-such--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 dwig at advancedmp.net Fri Feb 16 19:46:31 2001 From: dwig at advancedmp.net (Don Dwiggins) Date: 16 Feb 2001 10:46:31 -0800 Subject: recursing glob In-Reply-To: Grant Griffin's message of "Thu, 15 Feb 2001 21:58:36 -0600" References: <3A8B5309.F5B07C85@seebelow.org> <3A8CA56C.4F1676F1@seebelow.org> Message-ID: Grant Griffin writes: > Fredrik Lundh wrote: >> >> Grant Griffin wrote: >> > Somehow I never am happy with stuff I do with os.walk--is it >> > just me? >> >> no. > In retrospect, I think os.walk would be a lot friendlier if it passed > two arguments to its function instead of one. (When I first began with > Python, I didn't realize that that "one" argument could be a list or a > tuple.) Maybe what's needed here is an implementation of the Visitor pattern from the Gamma et al. "Design Patterns" book. I did a file system Visitor in Visual Basic (pardon my French!) as a learning exercise a while back, and found it easy to implement and use once I grokked it (should be much nicer in Python, though). It's worth considering (not necessarily choosing) Visitor whenever you need to "iterate" over a complex structure. -- Don Dwiggins "Solvitur Ambulando" Advanced MP Technology dwig at advancedmp.net From theller at python.net Thu Feb 15 09:52:04 2001 From: theller at python.net (Thomas Heller) Date: Thu, 15 Feb 2001 09:52:04 +0100 (CET) Subject: [ANN] py2exe - new version Message-ID: <982227124.3a8b98b4a366f@www.ion-tof.com> py2exe is a distutils extension to convert python scripts into standalone windows executables. The URL is: http://starship.python.net/crew/theller/py2exe/ I've released version 0.2.3 of py2exe, which seems pretty stable, although it should still be considered beta. It has been used for creating wxPython, PyGTK, pygame, win32com client and other standalone programs. I would like to thank the early adopters(in alphabetical order) Dan Rolander, Dave Brueck, Franz Geiger, Markus Gritsch, Pete Shinners, Peter Hansen, Robin Dunn, and Wayne Izatt for helpfull suggestions, testing and support. Development will continue. Features planned for the next release(s): - More aggressive way to find dependencies, hopefully making the building process more automatic - COM server support (localserver, inprocserver) Regards, Thomas From robin at jessikat.fsnet.co.uk Thu Feb 15 12:16:23 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 15 Feb 2001 11:16:23 +0000 Subject: [ANN] py2exe - new version References: Message-ID: <4$+f4LAHq7i6Ew1H@jessikat.demon.co.uk> In article , Thomas Heller writes >py2exe is a distutils extension to convert python scripts into standalone >windows executables. > >The URL is: http://starship.python.net/crew/theller/py2exe/ > >I've released version 0.2.3 of py2exe, which seems pretty stable, although >it should still be considered beta. > >It has been used for creating wxPython, PyGTK, pygame, win32com client and >other standalone programs. > >I would like to thank the early adopters(in alphabetical order) >Dan Rolander, Dave Brueck, Franz Geiger, Markus Gritsch, >Pete Shinners, Peter Hansen, Robin Dunn, and Wayne Izatt >for helpfull suggestions, testing and support. > >Development will continue. Features planned for the next release(s): >- More aggressive way to find dependencies, hopefully making the building > process more automatic >- COM server support (localserver, inprocserver) > >Regards, > >Thomas > I've not tried this yet, but what about using the checking stuff from Gordon McMillan's Installer. The only problems that I've been getting using it are reasonably unusual. In particular it has problems with package\_init__.py contains from bingo import BINGO as it when it sees 'from package import BINGO' it doesn't know to look in bingo.py Gordon's compressed import packages are really neat and I hacked the c stuff to clean up more aggressively so users don't see any dlls lying about after use. -- Robin Becker From thomas.heller at ion-tof.com Thu Feb 15 14:46:56 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 15 Feb 2001 14:46:56 +0100 Subject: [ANN] py2exe - new version References: <4$+f4LAHq7i6Ew1H@jessikat.demon.co.uk> Message-ID: <96gmkn$l1lp6$1@ID-59885.news.dfncis.de> "Robin Becker" wrote in message news:4$+f4LAHq7i6Ew1H at jessikat.demon.co.uk... > I've not tried this yet, but what about using the checking stuff from > Gordon McMillan's Installer. It IS in fact based on the same code than Gordon's installer, which is tools\freeze\modulefinder... > The only problems that I've been getting > using it are reasonably unusual. In particular it has problems with > > package\_init__.py contains > from bingo import BINGO > > as it when it sees 'from package import BINGO' it doesn't know to look > in bingo.py > ... and so it has the same problems with your example. Thanks for pointing this out! I will look into this. > Gordon's compressed import packages are really neat and I hacked the c > stuff to clean up more aggressively so users don't see any dlls lying > about after use. The reason I wrote py2exe are: - Integration with distutils seems natural for me - There _have_ been some problems with installer and python 2.0 (maybe they are solved in th meantime). - There _have_ been problems with compiled extensions contained in packages - There are still (?) problems with win32all/win32com - Writing code myself is always more fun than hacking other's code - maybe others I don' remeber at the moment Thomas From slhath at home.com.nospam Thu Feb 15 14:07:31 2001 From: slhath at home.com.nospam (Scott Hathaway) Date: Thu, 15 Feb 2001 13:07:31 GMT Subject: [ANN] py2exe - new version References: Message-ID: Thomas, This is awesome! Being new to python, I have tried Gordon's Installer and have had a lot of trouble with it (this is not a problem with Installer, but my lack of understanding python, I am sure...) I was able to create an .exe for a fairly complex project that uses xml-rpc and about 20 class files in about 10 minutes after the download! Thanks so much, Scott "Thomas Heller" wrote in message news:mailman.982227198.28101.python-list at python.org... > py2exe is a distutils extension to convert python scripts into standalone > windows executables. > > The URL is: http://starship.python.net/crew/theller/py2exe/ > > I've released version 0.2.3 of py2exe, which seems pretty stable, although > it should still be considered beta. > > It has been used for creating wxPython, PyGTK, pygame, win32com client and > other standalone programs. > > I would like to thank the early adopters(in alphabetical order) > Dan Rolander, Dave Brueck, Franz Geiger, Markus Gritsch, > Pete Shinners, Peter Hansen, Robin Dunn, and Wayne Izatt > for helpfull suggestions, testing and support. > > Development will continue. Features planned for the next release(s): > - More aggressive way to find dependencies, hopefully making the building > process more automatic > - COM server support (localserver, inprocserver) > > Regards, > > Thomas > From MailFreeZone Thu Feb 15 10:10:59 2001 From: MailFreeZone (OpenMined) Date: Thu, 15 Feb 2001 01:10:59 -0800 Subject: What's the "best" Python? Message-ID: <3a8b9b18_1@news4.newsfeeds.com> Planning to take the big plunge and invest time in a new language- Python, yer "it"! Prefer to learn "going in" and not in hindsight what the hidden 'gotchas' may be. Will eventually be programming on/for Linux systems, but will start using Python on Win98. *** Is any particular version or variant the wisest choice, i.e., fewest bugs, most stable release?*** Thanks -----= 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 thomas at xs4all.net Thu Feb 15 11:07:27 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 15 Feb 2001 11:07:27 +0100 Subject: What's the "best" Python? In-Reply-To: <3a8b9b18_1@news4.newsfeeds.com>; from Mail.Free.Zone@xs4all.nl on Thu, Feb 15, 2001 at 01:10:59AM -0800 References: <3a8b9b18_1@news4.newsfeeds.com> Message-ID: <20010215110727.K4924@xs4all.nl> On Thu, Feb 15, 2001 at 01:10:59AM -0800, OpenMined wrote: > *** Is any particular version or variant the wisest choice, i.e., fewest > bugs, most stable release?*** The latest release, obviously. It is the only one that will get its bugs fixed :) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From LauraL Thu Feb 15 14:58:50 2001 From: LauraL (LauraL) Date: 15 Feb 2001 13:58:50 GMT Subject: What's the best Python? References: <3a8b9b18_1@news4.newsfeeds.com> Message-ID: <96gnaq01219@news2.newsguy.com> Hi, If you go to oreillynet.com, there's a new article on "alternative python distributions" (in the Python dev center) that should be helpful to you. Laura LLewin at oreilly.com > Planning to take the big plunge and invest time in a new language- Python, > yer "it"! > > Prefer to learn "going in" and not in hindsight what the hidden 'gotchas' > may be. > > Will eventually be programming on/for Linux systems, but will start using > Python on Win98. > > *** Is any particular version or variant the wisest choice, i.e., fewest > bugs, most stable release?*** > > Thanks > ================================== Posted via http://nodevice.com Linux Programmer's Site From claird at starbase.neosoft.com Fri Feb 16 15:05:48 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 16 Feb 2001 08:05:48 -0600 Subject: What's the best Python? References: <3a8b9b18_1@news4.newsfeeds.com> <96gnaq01219@news2.newsguy.com> Message-ID: <29F094D6FAA03AF7.460EE66A0A7774DE.DBB4260F3E0CA12D@lp.airnews.net> In article <96gnaq01219 at news2.newsguy.com>, wrote: >Hi, >If you go to oreillynet.com, there's a new article on "alternative python distributions" (in the Python dev center) that should be helpful to you. . . . To my surprise, I agree, enough that I'll reproduce here for the convenience of those curious about it. The surprise isn't that O'ReillyNet published some- thing "that should be helpful to you"; it's just that I hadn't noticed it, and it seems so perfectly timed as an answer to the original poster. One of the benefits of this piece is that Stephen's a pretty responsive guy who follows this newsgroup, and answers his e-mail. If you have questions or comments about what you find in his piece, he's likely to answer them. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From aahz at panix.com Thu Feb 15 15:42:05 2001 From: aahz at panix.com (Aahz Maruch) Date: 15 Feb 2001 06:42:05 -0800 Subject: What's the "best" Python? References: <3a8b9b18_1@news4.newsfeeds.com> Message-ID: <96gprt$lif$1@panix2.panix.com> In article <3a8b9b18_1 at news4.newsfeeds.com>, OpenMined wrote: > >*** Is any particular version or variant the wisest choice, i.e., fewest >bugs, most stable release?*** Overall, Python 2.0 is the best bet. Python 2.1 is in alpha, with expected release in April. However, if you're a Perler with a yen for complex regexes, Python 1.5.2 may be your better choice until Python 2.1 gets released. -- --- 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 'Gender' isn't a definition, it's a heuristic. --Aahz From rytrom at zootec.com Thu Feb 15 11:52:43 2001 From: rytrom at zootec.com (Roman Rytov) Date: Thu, 15 Feb 2001 12:52:43 +0200 Subject: remote debuging? Message-ID: Is there any soft alllowing to debug Jython scripts remotely (Unix preferable) From jurgen.defurne at philips.com Thu Feb 15 13:29:39 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Thu, 15 Feb 2001 13:29:39 +0100 Subject: Memory leak when spawning Message-ID: <0056900015941884000002L042*@MHS> I don't know if this piece of source is small enough, but it is probably the smallest I can create with the same symptoms : every time a spawn is made, and the spawned program stops, some 4k to 12k of memory is lost (not 800 to 1200 as I said last time). If the originating process stops, then all memory is returned, but a program which has cron functionality should of course not display memory loss. This is the version of Python I use (downloaded binary) Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 Here is the code : Jurgen -------------- next part -------------- A non-text attachment was scrubbed... Name: cron.py Type: application/octet-stream Size: 718 bytes Desc: not available URL: From MarkH at ActiveState.com Thu Feb 15 13:46:42 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 15 Feb 2001 12:46:42 GMT Subject: Memory leak when spawning References: Message-ID: <3A8BCED3.50000@ActiveState.com> jurgen.defurne at philips.com wrote: > I don't know if this piece of source is small enough, but it is probably > the smallest I can create with the same symptoms Hrm. Not really I am afraid. I dont see any leaks running this code. You should be able to trim it down to something with a tight loop (ie, very quick or no sleeping) and see the memory usage rise pretty quickly. Also, note that your code: (None, None, None, None, None, sec, None, None, None) = localtime(time()) Is very very dangerous - it is changing the builtin value None!! Mark. From stephen_purcell at yahoo.com Thu Feb 15 15:31:22 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Thu, 15 Feb 2001 15:31:22 +0100 Subject: Memory leak when spawning In-Reply-To: <3A8BCED3.50000@ActiveState.com>; from MarkH@ActiveState.com on Thu, Feb 15, 2001 at 12:46:42PM +0000 References: <3A8BCED3.50000@ActiveState.com> Message-ID: <20010215153122.A479@freedom.puma-ag.com> Mark Hammond wrote: > Also, note that your code: > (None, None, None, > None, None, sec, > None, None, None) = localtime(time()) > > Is very very dangerous - it is changing the builtin value None!! Indeed. That got me thinking; is it defined how the following should work? (blah, blah, blah) = (1,2,3) I get blah == 3. I won't lose sleep over it... -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 tim_one at email.msn.com Fri Feb 16 01:04:34 2001 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 15 Feb 2001 19:04:34 -0500 Subject: Memory leak when spawning In-Reply-To: <20010215153122.A479@freedom.puma-ag.com> Message-ID: [Steve Purcell] > Indeed. That got me thinking; is it defined how the following > should work? > > (blah, blah, blah) = (1,2,3) > > I get blah == 3. Yes, left-to-right is the defined order of sequence assignment. > I won't lose sleep over it... You would if you thought more about it . For example, >>> a = [0]*5 >>> i, a[i] = 2, 666 >>> a [0, 0, 666, 0, 0] >>> Python (unlike most other languages) defines this stuff so you don't get surprises across releaess or platforms, but some people just can't resist the temptation to *rely* on obscure side effects. Luckily, they're tracked down and killed just as fast as the PSU finds t From juanjux at yahoo.es Sat Feb 17 05:13:29 2001 From: juanjux at yahoo.es (Juanjo =?iso-8859-1?Q?=C1lvarez?=) Date: Sat, 17 Feb 2001 05:13:29 +0100 Subject: Memory leak when spawning References: <3A8BCED3.50000@ActiveState.com> Message-ID: Steve Purcell dijo sobre Re: Memory leak when spawning, en fecha: Thu, 15 Feb 2001 15:31:22 +0100 |Mark Hammond wrote: |> Also, note that your code: |> (None, None, None, |> None, None, sec, |> None, None, None) = localtime(time()) |> |> Is very very dangerous - it is changing the builtin value None!! | |Indeed. That got me thinking; is it defined how the following should work? | | (blah, blah, blah) = (1,2,3) I prefer (foo, foo, foo) = (1,2,3), it's more traditional. From chris.gonnerman at usa.net Mon Feb 19 04:11:58 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sun, 18 Feb 2001 21:11:58 -0600 Subject: Memory leak when spawning References: <3A8BCED3.50000@ActiveState.com> Message-ID: <012f01c09a21$ba010080$a100000a@local> ----- Original Message ----- From: "Juanjo ?lvarez" Subject: Re: Memory leak when spawning > Steve Purcell dijo sobre Re: Memory leak when spawning, > en fecha: Thu, 15 Feb 2001 15:31:22 +0100 > > |Mark Hammond wrote: > |> Also, note that your code: > |> (None, None, None, > |> None, None, sec, > |> None, None, None) = localtime(time()) > |> > |> Is very very dangerous - it is changing the builtin value None!! > | > |Indeed. That got me thinking; is it defined how the following should work? > | > | (blah, blah, blah) = (1,2,3) > > I prefer (foo, foo, foo) = (1,2,3), it's more traditional. To be traditional, shouldn't it be: (spam, spam, spam) = (1, 2, 3) pythonically-yr's -- Chris. From piet at cs.uu.nl Wed Feb 21 15:27:03 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 21 Feb 2001 15:27:03 +0100 Subject: None (was Re: Memory leak when spawning) References: <3A8BCED3.50000@ActiveState.com> Message-ID: >>>>> Mark Hammond (MH) writes: MH> jurgen.defurne at philips.com wrote: >> I don't know if this piece of source is small enough, but it is probably >> the smallest I can create with the same symptoms MH> Hrm. Not really I am afraid. I dont see any leaks running this code. MH> You should be able to trim it down to something with a tight loop (ie, MH> very quick or no sleeping) and see the memory usage rise pretty MH> quickly. MH> Also, note that your code: MH> (None, None, None, MH> None, None, sec, MH> None, None, None) = localtime(time()) MH> Is very very dangerous - it is changing the builtin value None!! Wouldn't this be a good reason to make None a constant rather than a built-in identifier? -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From aahz at panix.com Thu Feb 15 15:44:39 2001 From: aahz at panix.com (Aahz Maruch) Date: 15 Feb 2001 06:44:39 -0800 Subject: Memory leak when spawning References: Message-ID: <96gq0n$m1c$1@panix2.panix.com> In article , wrote: > >I don't know if this piece of source is small enough, but it is >probably the smallest I can create with the same symptoms : every time >a spawn is made, and the spawned program stops, some 4k to 12k of >memory is lost (not 800 to 1200 as I said last time). Tim Peters posted recently that a change was made in Python 2.0 such that a new GIL object was created in spawned programs. However, this should not affect the spawning program, so I don't know what's causing your problem. -- --- 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 'Gender' isn't a definition, it's a heuristic. --Aahz From jurgen.defurne at philips.com Thu Feb 15 14:19:16 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Thu, 15 Feb 2001 14:19:16 +0100 Subject: Memory leak when spawning Message-ID: <0056900015944653000002L032*@MHS> I thought that I could use None, like 'undef' in Perl. Any suggestions on that ? I'll implement the change and try again. Thanks. Jurgen MarkH at ActiveState.com@SMTP at python.org on 15/02/2001 14:04:39 Sent by: python-list-admin at python.org To: python-list at python.org@SMTP cc: Subject: Re: Memory leak when spawning Classification: jurgen.defurne at philips.com wrote: > I don't know if this piece of source is small enough, but it is probably > the smallest I can create with the same symptoms Hrm. Not really I am afraid. I dont see any leaks running this code. You should be able to trim it down to something with a tight loop (ie, very quick or no sleeping) and see the memory usage rise pretty quickly. Also, note that your code: (None, None, None, None, None, sec, None, None, None) = localtime(time()) Is very very dangerous - it is changing the builtin value None!! Mark. -- http://mail.python.org/mailman/listinfo/python-list From erik.wilsher at iname.com Thu Feb 15 15:25:28 2001 From: erik.wilsher at iname.com (erik.wilsher at iname.com) Date: Thu, 15 Feb 2001 14:25:28 -0000 Subject: Memory leak when spawning In-Reply-To: <0056900015944653000002L032*@MHS> Message-ID: <96goso+2cnv@eGroups.com> --- In python-list at y..., jurgen.defurne at p... wrote: > Any suggestions on that ? secs = localtime(time())[5] EW From tim_one at email.msn.com Fri Feb 16 01:06:48 2001 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 15 Feb 2001 19:06:48 -0500 Subject: Memory leak when spawning In-Reply-To: <0056900015944653000002L032*@MHS> Message-ID: [jurgen.defurne at philips.com] > I thought that I could use None, like 'undef' in Perl. You can, but it will rebind the name None. There is no "don't care" assignment target in Python. > Any suggestions on that ? Use the name undef, if you like: undef, middle, undef = range(3) jurgen also works: jurgen, middle, jurgen = range(3) However, don't even think about using "tim" for this purpose . From chris.gonnerman at usa.net Fri Feb 16 03:23:09 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Thu, 15 Feb 2001 20:23:09 -0600 Subject: Memory leak when spawning References: <0056900015944653000002L032*@MHS> Message-ID: <00a401c097bf$722be180$a100000a@local> ----- Original Message ----- From: Subject: Re: Memory leak when spawning > >I thought that I could use None, like 'undef' in Perl. > >Any suggestions on that ? > What's wrong with: sec = localtime(time())[5] From jurgen.defurne at philips.com Thu Feb 15 15:08:36 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Thu, 15 Feb 2001 15:08:36 +0100 Subject: Memory leak when spawning Message-ID: <0056900015947222000002L022*@MHS> Allright, I think this should definitely be the smallest program I can come up with. I tested it, memory leaks like a rocket going up. # # External modules import os import sys from time import * if len(sys.argv) == 1: while 1: # Doesn't matter if P_NOWAIT or P_DETACH, tried 'em both os.spawnl(os.P_DETACH, 'd:\\python20\\python', 'python', 'cron.py', 'check') elif sys.argv[1] == 'check': pass Jurgen -------------- next part -------------- A non-text attachment was scrubbed... Name: cron.py Type: application/octet-stream Size: 288 bytes Desc: not available URL: From MarkH at ActiveState.com Thu Feb 15 23:20:32 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 15 Feb 2001 22:20:32 GMT Subject: Memory leak when spawning References: Message-ID: <3A8C5552.90605@ActiveState.com> jurgen.defurne at philips.com wrote: > Allright, I think this should definitely be the smallest program I can come > up with. I tested it, memory leaks like a rocket going up. Not for me :( What version of Python? Maybe it has been fixed in 2.1? Mark. From Gareth.McCaughan at pobox.com Fri Feb 16 18:52:00 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Fri, 16 Feb 2001 17:52:00 +0000 Subject: Memory leak when spawning References: Message-ID: Tim Peters wrote: > There is no "don't care" > assignment target in Python. > > > Any suggestions on that ? > > Use the name undef, if you like: I like "_". >>> _,_,x,_,_ = 1,2,3,4,5 >>> x 3 Easy to type, visually mnemonic, and using _ as a disposable variable fits well with its use in interactive mode. -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construc From mwh21 at cam.ac.uk Fri Feb 16 19:30:07 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 16 Feb 2001 18:30:07 +0000 Subject: Memory leak when spawning References: Message-ID: Gareth.McCaughan at pobox.com (Gareth McCaughan) writes: > Tim Peters wrote: > > > There is no "don't care" > > assignment target in Python. > > > > > Any suggestions on that ? > > > > Use the name undef, if you like: > > I like "_". So do I, but the i18n folks tend to shout at you. Cheers, M. -- The PROPER way to handle HTML postings is to cancel the article, then hire a hitman to kill the poster, his wife and kids, and fuck his dog and smash his computer into little bits. Anything more is just extremism. -- attributed to Paul Tomblin on ASR From Gareth.McCaughan at pobox.com Sun Feb 18 20:00:07 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Sun, 18 Feb 2001 19:00:07 +0000 Subject: Memory leak when spawning References: Message-ID: Michael Hudson wrote: > Gareth.McCaughan at pobox.com (Gareth McCaughan) writes: > > > Tim Peters wrote: > > > > > There is no "don't care" > > > assignment target in Python. > > > > > > > Any suggestions on that ? > > > > > > Use the name undef, if you like: > > > > I like "_". > > So do I, but the i18n folks tend to shout at you. Oh. Why? (I'm shamefully ignorant of i18n issues...) -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construc From mwh21 at cam.ac.uk Mon Feb 19 01:20:49 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 19 Feb 2001 00:20:49 +0000 Subject: Memory leak when spawning References: Message-ID: Gareth.McCaughan at pobox.com (Gareth McCaughan) writes: > Michael Hudson wrote: > > > Gareth.McCaughan at pobox.com (Gareth McCaughan) writes: > > > > > Tim Peters wrote: > > > > > > > There is no "don't care" > > > > assignment target in Python. > > > > > > > > > Any suggestions on that ? > > > > > > > > Use the name undef, if you like: > > > > > > I like "_". > > > > So do I, but the i18n folks tend to shout at you. > > Oh. Why? (I'm shamefully ignorant of i18n issues...) 'cause they do things like this: import gettext ; _ = gettext.gettext ... print _("This is a foo message!") to get translated strings. I personally think prolog got there first, but I can see their point. Cheers, M. -- I'm sorry, was my bias showing again? :-) -- William Tanksley, 13 May 2000 From Gareth.McCaughan at pobox.com Tue Feb 20 20:34:12 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Tue, 20 Feb 2001 19:34:12 +0000 Subject: Memory leak when spawning References: Message-ID: Michael Hudson wrote: [me, him, me, him:] > > > > I like "_". > > > > > > So do I, but the i18n folks tend to shout at you. > > > > Oh. Why? (I'm shamefully ignorant of i18n issues...) > > 'cause they do things like this: > > import gettext ; _ = gettext.gettext > > ... > > print _("This is a foo message!") > > to get translated strings. Ohhh! I see. Thanks. -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construc From bryan at eevolved.com Thu Feb 15 13:35:48 2001 From: bryan at eevolved.com (Bryan Mongeau) Date: Thu, 15 Feb 2001 12:35:48 GMT Subject: Gauging system load Message-ID: Out of curiosity, does anyone know of a module or a neat trick that will permit me to gauge the system load at a given time? For example, in a utopian dream world: import sys, time # A percentage value THRESHOLD = 20 while 1: if sys.cpuActivity < THRESHOLD: # Do some heavy work break else time.sleep(10) I've thought of maybe spawning a thread and gauging the amount of time it takes for it to be serviced, but that's pretty crude and innaccurate. Any tips? -- <==================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. http://www.eevolved.com <==================================> "I want to know God's thoughts; the rest are details."-- Einstein From annis at biostat.wisc.edu Thu Feb 15 16:17:16 2001 From: annis at biostat.wisc.edu (William Annis) Date: 15 Feb 2001 09:17:16 -0600 Subject: Gauging system load References: Message-ID: Bryan Mongeau writes: > Out of curiosity, does anyone know of a module or a neat trick that will > permit me to gauge the system load at a given time? What OS? I have no idea how you'd do this on a PC or a Mac, but on any unix flavor you should be able to parse the output from uptime. And if you're running Solaris, you can grab my PyKstat package and rip the information right out of the kernel with no parsing at all. http://www.biostat.wisc.edu/~annis/creations/pykstat.html Under Linux, you can parse the contents of /proc/loadavg. -- 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 jafo at tummy.com Thu Feb 15 23:59:57 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Thu, 15 Feb 2001 15:59:57 -0700 Subject: Gauging system load In-Reply-To: ; from annis@biostat.wisc.edu on Thu, Feb 15, 2001 at 09:17:16AM -0600 References: Message-ID: <20010215155957.F23577@tummy.com> On Thu, Feb 15, 2001 at 09:17:16AM -0600, William Annis wrote: >but on any unix flavor you should be able to parse the output from >uptime. And if you're running Solaris, you can grab my PyKstat Uptime isn't that good of a metric. It only represents the number of processes waiting to run, and is often highly affected by disc I/O. If are doing a CPU-intensive task on Linux, you can process /proc/stat to find out what % of CPU utilization is going on. Probably want to check on disc IO too, if that's important. Sean -- George Washington was first in war, first in peace -- and first to have his birthday juggled to make a long weekend. Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From norman at earth.ox.ac.uk Thu Feb 15 13:47:37 2001 From: norman at earth.ox.ac.uk (Norman Charnley) Date: Thu, 15 Feb 2001 12:47:37 +0000 Subject: PIL under Windows Message-ID: <3A8BCFE9.729F19B4@earth.ox.ac.uk> I'd like to run Python Imaging Library under Win95. I've already installed the Python 2.0 distribution without problem, in C:\Python20 (along with Pmw, Blt, Numeric and Medusa). However, when looking for PIL to install, I followed the links from the Python homepage and I ended up at Pythonworks, which offers another almost complete Python distribution, which installed under C:\Py20, but without Tools (e.g. Idle). Is there an easy way to reconcile the two? - preferably by amalgamating them under C:\python20, since various other links and registry settings are already associated with that directory... Thanks, Norman ================================================= Dr. Norman Charnley Department of Earth Sciences University of Oxford Oxford OX1 3PR, UK. ================================================== From clee at gnwy100.wuh.wustl.edu Thu Feb 15 18:18:13 2001 From: clee at gnwy100.wuh.wustl.edu (Christopher Lee) Date: 15 Feb 2001 11:18:13 -0600 Subject: PIL under Windows References: <3A8BCFE9.729F19B4@earth.ox.ac.uk> Message-ID: <7u4rxvlvai.fsf@gnwy100.wuh.wustl.edu> >>>>> "Norman" == Norman Charnley writes: Norman> However, when looking for PIL to install, I followed the links Norman> from the Python homepage and I ended up at Pythonworks, which Norman> offers another almost complete Python distribution, which Norman> installed under C:\Py20, but without Tools (e.g. Idle). Norman> Is there an easy way to reconcile the two? - preferably by Norman> amalgamating them under C:\python20, since various other links Norman> and registry settings are already associated with that Norman> directory... If you've already downloaded py20 from pythonware, you can copy all PIL related files over from c:\py20 to the equivalent place in your c:\Python20 directory. (I believe the files are something like PIL.pth, the entire PIL subdirectory, _imaging.dll and _tkimaging.dll.) If you haven't already downloaded py20 and you don't want all the extra's it gives, you might want to grab the one of the win32 versions available at http://piddle.sourceforge.net/PIL/ and unzip it under your c:\python20 folder. -chris From olafb+usenet at pvv.org Thu Feb 15 14:53:51 2001 From: olafb+usenet at pvv.org (Olaf Trygve Berglihn) Date: 15 Feb 2001 14:53:51 +0100 Subject: httplib + FakeSocket: how not to download whole file in memory Message-ID: I'm using httplib to download files over https. However, the FakeSocket-construction loads the whole file in memory and returns it as a StringIO-object. Does anyone have a suggestion how to avoid this, i.e. get a normal filepointer construction from the makefile-method and not grabbing all my memory. Olaf -- Olaf Trygve Berglihn From gmunsey at adobe.com Thu Feb 15 15:37:24 2001 From: gmunsey at adobe.com (Grant Munsey) Date: Thu, 15 Feb 2001 06:37:24 -0800 Subject: Problems with "a+" open mode on v2.0 Windows? Message-ID: On the win32 BeOpen Python 2.0 I have a strange thing happening. (800 Mhz Win2k Pro) The code below (abstracted from my actual app) dies randomly with an io error 13 trying to open hdr1fname. This error happens about 20% of the time. Not always on the same file name. If I go and look at the file every thing is fine ... no access errors. It's as if out1fn.close() is delayed some and the next call can't reopen the file for some reason. Any clue to what's going on? filelist = <10s of file names> for i in filelist: parseFileEx(i) def parsefileEx(hdr1fname): out1fn = open(hdr1fname, "a+") out1fn.write("blah\n"); ... lots more writing ... out1fn.close() From emile at fenx.com Thu Feb 15 15:39:58 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 15 Feb 2001 06:39:58 -0800 Subject: Missing Post Message-ID: <96gpqe$l29g1$1@ID-11957.news.dfncis.de> Over the last couple of days I've noticed a significant drop off in posts, something like one half to one third of what I've come to expect. I'm also seeing replies to post I'm not seeing. Anyone else have this going on? I'm pulling from news.cis.dfn.de. Thanks, -- Emile van Sebille emile at fenx.com ------------------- From MailFreeZone Thu Feb 15 18:13:16 2001 From: MailFreeZone (OpenMined) Date: Thu, 15 Feb 2001 09:13:16 -0800 Subject: Missing Post References: <96gpqe$l29g1$1@ID-11957.news.dfncis.de> Message-ID: <3a8c0c16_1@news4.newsfeeds.com> Yes-- seeing replies to my post of last night (Thanks!) but not the original. My news server should be mentioned in the header- not the same one. Somebody's server is being naughty. "Emile van Sebille" wrote in message news:96gpqe$l29g1$1 at ID-11957.news.dfncis.de... > Over the last couple of days I've noticed a significant drop > off in posts, something like one half to one third of what > I've come to expect. I'm also seeing replies to post I'm > not seeing. > > Anyone else have this going on? > > I'm pulling from news.cis.dfn.de. > > Thanks, > > -- > > Emile van Sebille > emile at fenx.com > ------------------- > > > > -----= 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 Burkhard.Kayser at marconi.com Thu Feb 15 17:29:35 2001 From: Burkhard.Kayser at marconi.com (Burkhard Kayser) Date: Thu, 15 Feb 2001 17:29:35 +0100 Subject: WaitCommEvent Message-ID: <96h007$kri$1@newsfeed.pit.comms.marconi.com> Does anyone know, where I can find the documentation for this function ? It is used in the example win32comport_demo.py. rc, mask = WaitCommEvent(self.handle, overlapped) What are the possible return values of rc and mask ? From ws-news at gmx.at Thu Feb 15 22:24:50 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Thu, 15 Feb 2001 22:24:50 +0100 Subject: WaitCommEvent References: <96h007$kri$1@newsfeed.pit.comms.marconi.com> Message-ID: <982272544.13628@newsmaster-04.atnet.at> Could not find a python related doc, but corresponding to the microsoft docs at http://msdn.microsoft.com/library/default.asp?URL=/library/psdk/winbase/comm un_4bck.htm i would _guess_ as following rc ... return code mask ... what is returned in lpEvtMask hth werner Burkhard Kayser wrote in message news:96h007$kri$1 at newsfeed.pit.comms.marconi.com... > Does anyone know, where I can find the documentation for this function ? > > It is used in the example win32comport_demo.py. > > rc, mask = WaitCommEvent(self.handle, overlapped) > > What are the possible return values of rc and mask ? > > > > From MarkH at ActiveState.com Thu Feb 15 23:23:35 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 15 Feb 2001 22:23:35 GMT Subject: WaitCommEvent References: <96h007$kri$1@newsfeed.pit.comms.marconi.com> Message-ID: <3A8C5609.7010103@ActiveState.com> Burkhard Kayser wrote: > Does anyone know, where I can find the documentation for this function ? > > It is used in the example win32comport_demo.py. > > rc, mask = WaitCommEvent(self.handle, overlapped) > > What are the possible return values of rc and mask ? msdn.microsoft.com Mark. -- Nominate Your Favorite Programmers for the Perl and Python Active Awards! http://www.ActiveState.com/Awards/ From mwh21 at cam.ac.uk Thu Feb 15 17:56:54 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: Thu, 15 Feb 2001 16:56:54 +0000 (GMT) Subject: python-dev summary 2001-02-01 - 2001-02-15 Message-ID: It is with some trepidation that I post: This is a summary of traffic on the python-dev mailing list between Feb 1 and Feb 14 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 first python-dev summary written by Michael Hudson. Previous summaries were written by Andrew Kuchling and can be found at: New summaries will probably appear at: When I get round to it. Posting distribution (with apologies to mbm) Number of articles in summary: 498 80 | ]|[ | ]|[ | ]|[ | ]|[ | ]|[ ]|[ 60 | ]|[ ]|[ | ]|[ ]|[ | ]|[ ]|[ | ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ 40 | ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ 20 | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ | ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ ]|[ 0 +-029-067-039-037-080-048-020-009-040-021-008-030-043-027 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 fairly busy fortnight on python-dev, falling just short of five hundred articles. Much of this is making ready for the Python 2.1 release, but people's horizons are beginning to rise above the present. * Python 2.1a2 * Python 2.1a2 was released on Feb. 2. One of the more controversial changes was the disallowing of "from module import *" at anything other than module level; this restriction was weakened after some slightly heated discussion on comp.lang.python. It is possible that non-module-level "from module import *" will produce some kind of warning in Python 2.1 but this code has not yet been written. * Performance * Almost two weeks ago, we were talking about performance. Michael Hudson posted the results of an extended benchmarking session using Marc-Andre Lemburg's pybench suite: to which the conclusion was that python 2.1 will be marginally slower than python 2.0, but it's not worth shouting about. The use of Vladimir Marangoz's obmalloc patch in some of the benchmarks sparked a discussion about whether this patch should be incorporated into Python 2.1. There was support from many for adding it on an opt-in basis, since when nothing has happened... * Imports on case-insensitive file systems * There was quite some discussion about how to handle imports on a case-insensitive file system (eg. on Windows). I didn't follow the details, but Tim Peters is on the case (sorry), so I'm confident it will get sorted out. * Sets & iterators * The Sets discussion rumbled on, moving into areas of syntax. The syntax: for key:value in dict: was proposed. Discussion went round and round for a while and moved on to more general iteration constructs, prompting Ka-Ping Yee to write a PEP entitled "iterators": Please comment! Greg Wilson announced that BOFs for both sets and iterators have been arranged at the python9 conference in March: * Stackless Python in Korea * Christian Tismer gave a presentation on stackless python to over 700 Korean pythonistas: I think almost everyone was amazed and delighted to find that Python has such a fan base. Next stop, the world! * string methodizing the standard library * Eric Raymond clearly got bored one evening and marched through the standard library, converting almost all uses of the string module to use to equivalent string method. * Python's release schedule * Skip Montanaro raised some concerns about Python's accelerated release schedule, and it was pointed out that the default Python for both debian unstable and Redhat 7.1 beta was still 1.5.2. Have *you* upgraded to Python 2.0? If not, why not? * Unit testing (again) * The question of replacing Python's hoary old regrtest-driven test suite with something more modern came up again. Andrew Kuchling enquired whether the issue was to be decided by voting or BDFL fiat: Guido obliged: There was then some discussion of what changes people would like to see made in the standard-Python-unit-testing-framework-elect (PyUnit) before they would be happy with it. Cheers, M. From kalle at gnupung.net Thu Feb 15 18:34:42 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Thu, 15 Feb 2001 18:34:42 +0100 Subject: python-dev summary 2001-02-01 - 2001-02-15 In-Reply-To: ; from mwh21@cam.ac.uk on Thu, Feb 15, 2001 at 04:56:54PM +0000 References: Message-ID: <20010215183442.A437@apone.network.loc> Sez Michael Hudson: > It is with some trepidation that I post: > > This is a summary of traffic on the python-dev mailing list between > Feb 1 and Feb 14 2001. It is intended to inform the wider Python [...] Thanks! 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 dalke at acm.org Thu Feb 15 18:39:10 2001 From: dalke at acm.org (Andrew Dalke) Date: Thu, 15 Feb 2001 10:39:10 -0700 Subject: python-dev summary 2001-02-01 - 2001-02-15 References: Message-ID: <96h49t$68f$1@slb1.atl.mindspring.net> Michael Hudson wrote: [summary of python-dev] Thanks for the summary. In case you are wondering, it was helpful to me to have it. As a result I just: - sent mail to one of my clients saying they'll need to audit their code for "from spam import *" problems before upgrading to 2.1 (they use that construct in about a dozen places). - sent mail to one of the other projects I'm on talking about planning a standardization on PyUnit for regression testing. (We use two; a modified regrtest and a different XP-based tester.) Also, you asked: > Have *you* upgraded to Python 2.0? If not, why not? I have for my own stuff. In fact, I just last week installed Python 2.1 from CVS. Doing so reminded my why I don't like upgrading Python. There was a change in the C level API which required a rebuild of all of my extensions. Many of them are from RPMs but as I don't use them all that often (eg, the gtk modules) I decided only to rebuild the modules needed for my own immediate development. One of my clients (the same one mentioned above) is still using 1.5.2. They are using it still because it works, because they weren't sure if the 2.0 would have any problems (it being a ".0" release) and because they didn't want to reinstall all of their extensions (PIL, Numeric, wxWindows, etc.) on their windows boxes. Andrew dalke at acm.org From loredo at spacenet.tn.cornell.edu Thu Feb 15 22:42:16 2001 From: loredo at spacenet.tn.cornell.edu (Tom Loredo) Date: Thu, 15 Feb 2001 16:42:16 -0500 Subject: Rebuilding extensions (was: python-dev summary) References: <96h49t$68f$1@slb1.atl.mindspring.net> Message-ID: <3A8C4D38.CF757D47@spacenet.tn.cornell.edu> Hi folks- Michael, thank you very much for continuing the tradition that Andrew K. started. He did a great service for us non-dev types, and your 1st go at it was great, too. Andrew D. notes: > In fact, I just last week > installed Python 2.1 from CVS. Doing so reminded my why > I don't like upgrading Python. There was a change in > the C level API which required a rebuild of all of my > extensions. This is a big nuisance for me. I'm curious about what to expect in this regard. Will every .X revision of Python require rebuilding extensions, or is it required only when there are changes to the C API? If the latter, how likely is it that the C API will *not* change between revisions? I do a lot of scientific computing with Python, on Solaris and MacOS boxes, and rely heavily on C extensions for numerical computing. Thanks, Tom Loredo From dalke at acm.org Fri Feb 16 08:08:02 2001 From: dalke at acm.org (Andrew Dalke) Date: Fri, 16 Feb 2001 00:08:02 -0700 Subject: Rebuilding extensions (was: python-dev summary) References: <96h49t$68f$1@slb1.atl.mindspring.net> <3A8C4D38.CF757D47@spacenet.tn.cornell.edu> Message-ID: <96ipv6$hug$1@nntp9.atl.mindspring.net> Tom Loredo wrote: >I'm curious about what to expect in >this regard. Will every .X revision of Python require rebuilding >extensions, or is it required only when there are changes to >the C API? If the latter, how likely is it that the C API will >*not* change between revisions? Looking at modsupport.h gives an idea of the frequency of change http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/~checkout~/python/dist/src/Inc lude/modsupport.h?rev=2.36&content-type=text/plain&cvsroot=python > 25-Jan-2001 FLD 1010 Parameters added to PyCode_New() and > PyFrame_New(); Python 2.1a2 > > 14-Mar-2000 GvR 1009 Unicode API added > > 3-Jan-1999 GvR 1007 Decided to change back! (Don't reuse 1008!) > > 3-Dec-1998 GvR 1008 Python 1.5.2b1 > > 18-Jan-1997 GvR 1007 string interning and other speedups so it looks like about once a year, that is, a change almost every release. Andrew dalke at acm.org From bkc at Murkworks.com Thu Feb 15 21:04:38 2001 From: bkc at Murkworks.com (Brad Clements) Date: Thu, 15 Feb 2001 15:04:38 -0500 Subject: python-dev summary 2001-02-01 - 2001-02-15 References: Message-ID: <7xWi6.4$R4.203@news.clarkson.edu> Thanks for doing this! -- Brad Clements, bkc at murkworks.com "Michael Hudson" wrote in message news:mailman.982256267.9885.python-list at python.org... > It is with some trepidation that I post: From aahz at panix.com Thu Feb 15 21:16:40 2001 From: aahz at panix.com (Aahz Maruch) Date: 15 Feb 2001 12:16:40 -0800 Subject: python-dev summary 2001-02-01 - 2001-02-15 References: Message-ID: <96hdf8$qnt$1@panix6.panix.com> In article , Michael Hudson wrote: > > This is the first python-dev summary written by Michael Hudson. Huzzah! -- --- 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 Why doesn't "Just Say NO" include caffeine, nicotine, alcohol, Prozac, and Ritalin? --Aahz From mjackson at wc.eso.mc.xerox.com Thu Feb 15 21:29:26 2001 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 15 Feb 2001 20:29:26 GMT Subject: python-dev summary 2001-02-01 - 2001-02-15 References: Message-ID: <96he76$f68$1@news.wrc.xerox.com> Michael Hudson writes: > This is the first python-dev summary written by Michael Hudson. Thank you! > was proposed. Discussion went round and round for a while and moved > on to more general iteration constructs, prompting Ka-Ping Yee to > write a PEP entitled "iterators": > > > > Please comment! With the possible exception of ":spam" and "eggs:" it doesn't look like it would make code less readable, and the functionality seems good. Mildly in favor. > * Python's release schedule * > > Skip Montanaro raised some concerns about Python's accelerated > release schedule, and it was pointed out that the default Python for > both debian unstable and Redhat 7.1 beta was still 1.5.2. Have > *you* upgraded to Python 2.0? If not, why not? Ran into difficulties building on Solaris and didn't have the time to resolve them. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson Having your book made into a movie is like having your ox made into a bouillon cube. - Bill Neely From tuttledon at hotmail.com Fri Feb 16 05:19:42 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Fri, 16 Feb 2001 04:19:42 GMT Subject: python-dev summary 2001-02-01 - 2001-02-15 References: Message-ID: "Michael Hudson" wrote in message news:mailman.982256267.9885.python-list at python.org... > New summaries will probably appear at: > > > Yeah! JUST DON'T FORGET TO ALSO POST THEM HERE! From not.this at seebelow.org Fri Feb 16 05:28:39 2001 From: not.this at seebelow.org (Grant Griffin) Date: Thu, 15 Feb 2001 22:28:39 -0600 Subject: iterators (was: python-dev summary) References: Message-ID: <3A8CAC77.91555B93@seebelow.org> Michael Hudson wrote: > ... > This is the first python-dev summary written by Michael Hudson. Thanks, Michael--keep up the great work! ... > Discussion went round and round for a while and moved > on to more general iteration constructs, prompting Ka-Ping Yee to > write a PEP entitled "iterators": > > > > Please comment! I went through this one, and I really like it: it seems both very "useful" and very "beautiful". What more could it possibly need? However... I regret Python's increasing loss of status as "executable pseudo-code". This proposal, as well as 2.0's "list comprehensions", seem to be making Python harder for the uninitiated to read. (To be fair, though, as a "moderately-initiated" Pythoneer, I've recently warmed up to list comprehensions.) Whenever I explain my Python code to a non-Pythoneer, it's always quite easy to explain--except for slices. Sure, those are essential in Python, so the principle of "if something is hard to explain, it's probably a bad idea" doesn't hold true in that case. But I think the principle itself is good: Python should read more like Dutch than Greek. And I think this new proposal would definitely be even harder to explain to the uninitiated than slices--especially the "k:" and ":v" versions. I think Python is at a crossroads where it is changing from "executable pseudo-code" into something increasingly...well..."complex". If "growth" in a language means "new features", I guess complexity is inevitable. In all honesty, the techie in me is all in favor of that. But my wiser part realizes that the techie part needs to be kept in check. (Or, as the great Archie Bunker said, "Stifle yourself!") So, give me this great new feature of iterators--if you can't manage to save me from myself. ambivalent-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 stephen_purcell at yahoo.com Fri Feb 16 09:51:07 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Fri, 16 Feb 2001 09:51:07 +0100 Subject: iterators (was: python-dev summary) In-Reply-To: <3A8CAC77.91555B93@seebelow.org>; from not.this@seebelow.org on Thu, Feb 15, 2001 at 10:28:39PM -0600 References: <3A8CAC77.91555B93@seebelow.org> Message-ID: <20010216095107.F7411@freedom.puma-ag.com> Grant Griffin wrote: > I think Python is at a crossroads where it is changing from "executable > pseudo-code" into something increasingly...well..."complex". If > "growth" in a language means "new features", I guess complexity is > inevitable. It's a pity. I also like things simple, because complexity makes my head hurt. Python is really simple, which is why I love it. This new proposal sounds 'neat', but just think about plugging the new iterator syntax into list comprehensions like the following (stolen from the PEP): >>> nums = [1,2,3,4] >>> fruit = ["Apples", "Peaches", "Pears", "Bananas"] >>> print [(i,f) for i in nums for f in fruit if f[0] == "P" if i%2 == 1] [(1, 'Peaches'), (1, 'Pears'), (3, 'Peaches'), (3, 'Pears')] Sprinkle a few ':' iterator magic symbols in there, and it doesn't look like Python any more. Of course, if the intention is to win over the Perl community... -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 dalke at acm.org Fri Feb 16 09:54:14 2001 From: dalke at acm.org (Andrew Dalke) Date: Fri, 16 Feb 2001 01:54:14 -0700 Subject: iterators (was: python-dev summary) References: <3A8CAC77.91555B93@seebelow.org> Message-ID: <96ipv7$hug$2@nntp9.atl.mindspring.net> Grant Griffin: >However... > >I regret Python's increasing loss of status as "executable >pseudo-code". This proposal, as well as 2.0's "list comprehensions", >seem to be making Python harder for the uninitiated to read. (To be >fair, though, as a "moderately-initiated" Pythoneer, I've recently >warmed up to list comprehensions.) >[more comments removed] I admit to a "Me too!" here. I work in computational biology and chemisty. This means I work with developers (people with a lot of programming background and some science background), scientists (the opposite) and people in various states in between (I'm a physicist who became a developer). I've pushed Python partially because it is a language which developers enjoy *and* so do scientists. I compare it to Perl which developers enjoy but researchers don't. (As a generality - there are exceptions.) Another example is Tcl, which developers often find tedious but researchers use just fine. (Mind you, I used Tcl in the pre-8.0 days.) The goal of a researcher is to do science, and they will put up with a lot to do it. A computational scientist will often learn a dozen different ad hoc scripting languages needed by the various programs they use. However, there is a certain level of complexity beyond which few researchers will learn. In general, the more obvious the better, as with Tcl. On the other hand, developers will learn about all the intricacies of a language, and attempt to use the appropriate feature for a given task. Sometimes a feature is used for the shear elegance or novelity of a construct, at the detriment of clarity. For example, I'll bet list comprehensions will be a problem when my clients start using Python 2.0. It is syntax driven and implicit, rather than using named functions with an explicit loop. That's why I plan to use list comprehensions rarely, and only for a single level of comprehension. I see similar problems with ">>" and now with "k:v" iterators. These all mean there will be multiple ways to do the same task. Especially worrying is that the best ways will be the most obscure. This reminds me of a story Gerald Weinberg tells about a "possum burger" company where a consultant comes in and says the company can save a large amount of money by reducing the number of sesame seeds on the bun by 1, with no measureable change in taste. The problem is, enough unnoticable changes do make a difference. Eventually people will go elsewhere for possum burgers. Explicit is better, so in another branch of this thread I elaborate on a suggestion for how to make explicit iterators (via functions & classes in a new module). Andrew Dalke dalke at acm.org From erno-news at erno.iki.fi Fri Feb 16 10:55:00 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 16 Feb 2001 11:55:00 +0200 Subject: iterators (was: python-dev summary) References: <3A8CAC77.91555B93@seebelow.org> <96ipv7$hug$2@nntp9.atl.mindspring.net> Message-ID: In article <96ipv7$hug$2 at nntp9.atl.mindspring.net>, "Andrew Dalke" writes: | Grant Griffin: || However... || || I regret Python's increasing loss of status as "executable || pseudo-code". This proposal, as well as 2.0's "list comprehensions", || seem to be making Python harder for the uninitiated to read. (To be || fair, though, as a "moderately-initiated" Pythoneer, I've recently || warmed up to list comprehensions.) || [more comments removed] | I admit to a "Me too!" here. me three! actually, the first time i saw the proposal for for key:value in dict: ... i thought it was a joke. ok, it's not obscure, but i don't see the point either. list comprehensions also look pretty obscure to me (compared to the rest of python's syntax), and don't do a lot that you can't do with map/filter now that we have lexical scoping. -- erno From jeremy at alum.mit.edu Fri Feb 16 02:10:28 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Thu, 15 Feb 2001 20:10:28 -0500 (EST) Subject: iterators (was: python-dev summary) In-Reply-To: References: <3A8CAC77.91555B93@seebelow.org> <96ipv7$hug$2@nntp9.atl.mindspring.net> Message-ID: <14988.32260.786366.394218@w221.z064000254.bwi-md.dsl.cnc.net> >>>>> "EK" == Erno Kuusela writes: EK> list comprehensions also look pretty obscure to me (compared to EK> the rest of python's syntax), and don't do a lot that you can't EK> do with map/filter now that we have lexical scoping. I have the opposite opinion. I think the list comprehension syntax is often clearer and more intuitive than the equivalent map or filter expression. I expect more non- and novice programmers will be familiar with set construction notation than with higher-order functions like map. Jeremy From erno-news at erno.iki.fi Fri Feb 16 17:42:09 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 16 Feb 2001 18:42:09 +0200 Subject: iterators (was: python-dev summary) References: <3A8CAC77.91555B93@seebelow.org> <96ipv7$hug$2@nntp9.atl.mindspring.net> Message-ID: In article , Jeremy Hylton writes: | Erno Kuusela writes: || list comprehensions also look pretty obscure to me (compared to || the rest of python's syntax), and don't do a lot that you can't || do with map/filter now that we have lexical scoping. | I have the opposite opinion. I think the list comprehension syntax is | often clearer and more intuitive than the equivalent map or filter | expression. I expect more non- and novice programmers will be | familiar with set construction notation than with higher-order | functions like map. i suspect both map/filter + lambda and list comprehensions are a little confusing for the beginner at first, and require some pondering. but list comprehensions seem like an unnecessary additional way to spell the same thing... at least map/filter are pretty straightforward constructions that build on the basic concept of function. also, i find the lack of delimiters between tha parts in a list comprehension a little un-aesthetic. [a*b for b in c if d % 2] ^ ^ -- erno From jeremy at alum.mit.edu Fri Feb 16 18:00:31 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Fri, 16 Feb 2001 12:00:31 -0500 (EST) Subject: iterators (was: python-dev summary) In-Reply-To: References: <3A8CAC77.91555B93@seebelow.org> <96ipv7$hug$2@nntp9.atl.mindspring.net> Message-ID: <14989.23727.53276.346479@w221.z064000254.bwi-md.dsl.cnc.net> >>>>> "EK" == Erno Kuusela writes: EK> i suspect both map/filter + lambda and list comprehensions are a EK> little confusing for the beginner at first, and require some EK> pondering. but list comprehensions seem like an unnecessary EK> additional way to spell the same thing... at least map/filter EK> are pretty straightforward constructions that build on the basic EK> concept of function. As I said before, I think we just don't agree. List comprehensions build on the basic notions of loops and ifs. I think these are simpler than higher-order functions. EK> also, i find the lack of delimiters between tha parts in a list EK> comprehension a little un-aesthetic. [a*b for b in c if d % 2] EK> ^ ^ I agree with you here, but I don't think anyone had a good solution. Don't remember what was discussed, as we never got around to writing the PEP. Jeremy From donn at u.washington.edu Fri Feb 16 19:55:27 2001 From: donn at u.washington.edu (Donn Cave) Date: 16 Feb 2001 18:55:27 GMT Subject: iterators (was: python-dev summary) References: <3A8CAC77.91555B93@seebelow.org> <96ipv7$hug$2@nntp9.atl.mindspring.net> Message-ID: <96jt2v$ogk$1@nntp6.u.washington.edu> Quoth Jeremy Hylton : | >>>>> "EK" == Erno Kuusela writes: | | EK> i suspect both map/filter + lambda and list comprehensions are a | EK> little confusing for the beginner at first, and require some | EK> pondering. but list comprehensions seem like an unnecessary | EK> additional way to spell the same thing... at least map/filter | EK> are pretty straightforward constructions that build on the basic | EK> concept of function. | | As I said before, I think we just don't agree. List comprehensions | build on the basic notions of loops and ifs. I think these are | simpler than higher-order functions. The basic notions are simpler, but the notation that puts them together isn't obvious. Until I have had a chance to look that up and use them for something enough to commit that syntax to memory, I won't understand the list comprehension code I see. That is not hypothetical, I really don't understand them - believe I have seen it explained and understood the explanation, but with no need for such a thing, I have since forgotten. If it's a big step towards something useful, fine. I have heard claims that they're faster, and that's a priority I can understand. But every time some cool notion gets added to Python, it adds to the amount that we all eventually have to know. I can't indefinitely postpone my education in list comprehensions without marginalizing myself, just as someone who comes along and learns them right away will still have to learn all the alternatives too. Does that add to our ability to write software, or subtract from it? Donn Cave, donn at u.washington.edu From erno-news at erno.iki.fi Fri Feb 16 20:22:43 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 16 Feb 2001 21:22:43 +0200 Subject: iterators (was: python-dev summary) References: <3A8CAC77.91555B93@seebelow.org> <96ipv7$hug$2@nntp9.atl.mindspring.net> <96jt2v$ogk$1@nntp6.u.washington.edu> Message-ID: In article <96jt2v$ogk$1 at nntp6.u.washington.edu>, Donn Cave writes: | I have heard claims that they're faster, and that's a priority I can | understand. actually, they are slower (than map + python function). but don't think that should be important. | But every time some cool notion gets added to Python, it adds to | the amount that we all eventually have to know. I can't indefinitely | postpone my education in list comprehensions without marginalizing | myself, just as someone who comes along and learns them right away | will still have to learn all the alternatives too. Does that add | to our ability to write software, or subtract from it? well said. -- erno From tim.one at home.com Fri Feb 16 21:27:11 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 16 Feb 2001 15:27:11 -0500 Subject: iterators (was: python-dev summary) In-Reply-To: <96jt2v$ogk$1@nntp6.u.washington.edu> Message-ID: [Donn Cave] > The basic notions are simpler, but the notation that puts them > together isn't obvious. Until I have had a chance to look that > up and use them for something enough to commit that syntax to > memory, I won't understand the list comprehension code I see. Here, guess what this does: print [x**2 for x in range(10)] Bingo -- you're now educated . > ... > I have heard claims that they're faster, and that's a priority I > can understand. They *could* be quicker, but in the current implementation are usually slower. The primary intent is to be clearer than the alternatives. > But every time some cool notion gets added to Python, it adds to > the amount that we all eventually have to know. As well as increase the set of available tools. That was true in 0.9.6 too -- these are tradeoffs. > I can't indefinitely postpone my education in list comprehensions > without marginalizing myself, just as someone who comes along and > learns them right away will still have to learn all the alternatives > too. Does that add to our ability to write software, or subtract > from it? I think it obvious that it does both. Guido approves of ideas that, after consideration, he believes will be a net win; he rejects ideas that he believes will be a net loss (and no suggestion is without *some* value!). You won't agree with him every time; and neither will I, although I pretend that I do to keep universal harmony flowing on c.l.py . that's-why-he-doesn't-want-anyone-reading-python-dev-ly y'rs - tim From amk at mira.erols.com Sat Feb 17 02:07:57 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 17 Feb 2001 01:07:57 GMT Subject: iterators (was: python-dev summary) References: <3A8CAC77.91555B93@seebelow.org> <96ipv7$hug$2@nntp9.atl.mindspring.net> <96jt2v$ogk$1@nntp6.u.washington.edu> Message-ID: On 16 Feb 2001 18:55:27 GMT, Donn Cave wrote: >If it's a big step towards something useful, fine. I have heard Agreed. Some time ago I argued that once Unicode was added to Python 1.6, we should just stamp the language definition "done" and leave it alone. Sure, we can add little tweaky features like iterators, but will they enable a startling new application domain? Will they attract more users? In both cases the answer is likely "no", so we should just write off the new features -- they might be nice, but why bother making books obsolete and making the code more bloated? I think I'll repeat the argument for 2.1: call the language as defined by the 2.1 docs the final version, and leave it alone. Obviously you could still work on a faster interpreter, fix bugs in it, etc. This means interfaces won't get implemented, which is unfortunate, but if you let in "just *one* more feature" it'll never stop. --amk From donn at oz.net Sat Feb 17 06:56:25 2001 From: donn at oz.net (Donn Cave) Date: 17 Feb 2001 05:56:25 GMT Subject: iterators (was: python-dev summary) References: <3A8CAC77.91555B93@seebelow.org> <96ipv7$hug$2@nntp9.atl.mindspring.net> <96jt2v$ogk$1@nntp6.u.washington.edu> Message-ID: <96l3q9$718$0@216.39.151.169> Quoth amk at mira.erols.com (A.M. Kuchling): | On 16 Feb 2001 18:55:27 GMT, Donn Cave wrote: | >If it's a big step towards something useful, fine. I have heard | | Agreed. Some time ago I argued that once Unicode was added to Python | 1.6, we should just stamp the language definition "done" and leave it | alone. Sure, we can add little tweaky features like iterators, but | will they enable a startling new application domain? Will they | attract more users? In both cases the answer is likely "no", so we | should just write off the new features -- they might be nice, but why | bother making books obsolete and making the code more bloated? | | I think I'll repeat the argument for 2.1: call the language as defined | by the 2.1 docs the final version, and leave it alone. Obviously you | could still work on a faster interpreter, fix bugs in it, etc. This | means interfaces won't get implemented, which is unfortunate, but if | you let in "just *one* more feature" it'll never stop. I can't tell how serious you are, but that appeals to me. There's a lot to 2.1. It's a big language with a lot of things to learn, and everything you need to write great software. It would be a crime to load it down with unnecessary gimmicks, and yet it's all too common for any software system to go just that way. Maybe universal. Still, I think I wouldn't be in favor of a constitutional prohibition on new features. I can't say there's no room for Python to evolve, it feels too much like the people who a century ago were convinced that most everything of consequence was already known to science. I would like to find the antidote for creeping featurism, though. For Python, I guess that antidote is the BDFL, as Tim Peters observed in another followup, and that works for me - it would be paradoxical to say Python is the perfect language but we can't trust its creator's judgement. And since it's his baby anyway, who cares what we think. Yet the development environment around Python has changed in recent years, and I guess that's where we came in. One thing I think would be worth some thought is a positive expression of what we're thinking when we say "no thanks". I mean, opposition to features is the negative complement to a positive idea about Python, about its elegance and power the way it is. We don't get that out as often or as articulately as maybe we could. Donn Cave, donn at oz.net From tim_one at email.msn.com Sat Feb 17 07:53:11 2001 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 17 Feb 2001 01:53:11 -0500 Subject: Language change (was RE: iterators (was: python-dev summary)) In-Reply-To: <96l3q9$718$0@216.39.151.169> Message-ID: [Donn Cave] > ... > Still, I think I wouldn't be in favor of a constitutional prohibition > on new features. Then, unlike Andrew's, your future may be a happy one . > I can't say there's no room for Python to evolve, it feels too much > like the people who a century ago were convinced that most everything > of consequence was already known to science. Good example: nobody predicted any particular problem at the start due to types and classes occupying distinct universes in Python (can only create a class in Python, can only create a type in C). In retrospect, that was braindead. Healing that split would be a *simplification* of the language, although, ya, it would probably have some visible consequences. > I would like to find the antidote for creeping featurism, though. > For Python, I guess that antidote is the BDFL, as Tim Peters observed > in another followup, and that works for me - it would be paradoxical > to say Python is the perfect language but we can't trust its creator's > judgement. And since it's his baby anyway, who cares what we think. Guido does! But he doesn't have time to argue with 10,000 people on every point, and (this won't be a surprise to grownups ) sometimes he couldn't even if he did have time: Python isn't entirely the end result of an objective deductive process. Many of the best ideas were adopted simply because they "felt like" a good idea at the time. Sometimes that backfires. But that's rare, and that's what makes Guido a better language designer than his critics (including me, on the one occasion I disagreed with him ). > Yet the development environment around Python has changed in recent > years, and I guess that's where we came in. What changed is that moving to SourceForge multiplied the number of people who *could* commit changes from one (Guido) to dozens (Guido's army of mindless drones). Most of the flurry of changes checked in for 2.0 were things Guido wanted for years, but didn't have the personal bandwidth to do all by himself. > One thing I think would be worth some thought is a positive expression > of what we're thinking when we say "no thanks". I mean, opposition > to features is the negative complement to a positive idea about Python, > about its elegance and power the way it is. We don't get that out as > often or as articulately as maybe we could. You know that we're heading towared 100 rejected patches on SoureForge? That's heading on 100 ideas people wanted badly enough to actually do the hard work of implementing them (and that's impressive!) -- but they got tossed in the bit bucket anyway. People who think the floodgates have opened are simply wrong about that (although a couple years' worth of backed up ideas got implemented quickly). Here's the latest one Guido rejected: http://sourceforge.net/patch/ index.php?func=detailpatch&patch_id=103693&group_id=5470 That's for a tiny, fully backward-compatible change, and one that's been asked for several times on c.l.py over the years. If I were the submitter, I would find Guido's rejection comment unconvincing. A good mental exercise is to think of some change you *like*, and dream up a rejection comment you would be satisfied with -- but realizing that in the real world, it's not going to end with "QED". it-won't-end-with-"bugger-off"-either-but-that's-how-it-often- gets-read-ly y'rs - tim From robin at jessikat.fsnet.co.uk Sat Feb 17 10:37:05 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 17 Feb 2001 09:37:05 +0000 Subject: Language change (was RE: iterators (was: python-dev summary)) References: <96l3q9$718$0@216.39.151.169> Message-ID: In article , Tim Peters writes .... >opened are simply wrong about that (although a couple years' worth of backed >up ideas got implemented quickly). Here's the latest one Guido rejected: > >http://sourceforge.net/patch/ > index.php?func=detailpatch&patch_id=103693&group_id=5470 > >That's for a tiny, fully backward-compatible change, and one that's been >asked for several times on c.l.py over the years. If I were the submitter, ... The language would have been smaller if only lists were allowed, but that would make a lot of things unsafe/more interesting. -cults of personality are always wrong-ly yrs- Robin Becker From not.this at seebelow.org Mon Feb 19 05:35:54 2001 From: not.this at seebelow.org (Grant Griffin) Date: Sun, 18 Feb 2001 22:35:54 -0600 Subject: Language change (was RE: iterators (was: python-dev summary)) References: Message-ID: <3A90A2AA.21FB5D05@seebelow.org> Tim Peters wrote: > > [Donn Cave] ... > > Yet the development environment around Python has changed in recent > > years, and I guess that's where we came in. > > What changed is that moving to SourceForge multiplied the number of people > who *could* commit changes from one (Guido) to dozens (Guido's army of > mindless drones). Most of the flurry of changes checked in for 2.0 were > things Guido wanted for years, but didn't have the personal bandwidth to do > all by himself. OK, I've enjoyed and appreciated almost all of those--thanks!. But obviously that creates a kind of pressure. (Put, conversely, I guess new features previously had to be _really_ useful for Guido to find time to add them.) > > One thing I think would be worth some thought is a positive expression > > of what we're thinking when we say "no thanks". I mean, opposition > > to features is the negative complement to a positive idea about Python, > > about its elegance and power the way it is. We don't get that out as > > often or as articulately as maybe we could. Guilty as charged! If my implied compliment wasn't received here, consider it given! I have said this before: Genius is the art of simplicity, and Python is a work of great simplicity. We in the Peanut Gallery fuss about new features the way folks would fuss if Bach suddenly decided to add some notes to "Tocatta and Fugue in D Minor". (Then again, nothing's perfect. ) > You know that we're heading towared 100 rejected patches on SoureForge? > That's heading on 100 ideas people wanted badly enough to actually do the > hard work of implementing them (and that's impressive!) -- but they got > tossed in the bit bucket anyway. People who think the floodgates have > opened are simply wrong about that (although a couple years' worth of backed > up ideas got implemented quickly). I guess that tends to create a certain impression... > Here's the latest one Guido rejected: > > http://sourceforge.net/patch/ > index.php?func=detailpatch&patch_id=103693&group_id=5470 > > That's for a tiny, fully backward-compatible change, and one that's been > asked for several times on c.l.py over the years. If I were the submitter, > I would find Guido's rejection comment unconvincing. Maybe he should have just said, "There should be one-- and preferably only one --obvious way to do it." I guess some of us are guilty of over-subscribing to the "Zen of Python" principles (at http://www.python.org/doc/Humor.html#zen, if you haven't read 'em, Tim) Perhaps we shouldn't adhere to these rigidly (except for the ones which have a lot of wiggle room ), but it's tempting to do so: they make so darn much sense. (Also, having done Perl, some of us see what can happen when a language's central organizing principle is "there's more than one way to do it"---what the heck kindda central organizing principle is that?!) I have never seen any statement from Guido to the effect of endorsing your principles, but if he doesn't endorse them, at least the things that "felt like a good idea at the time" to him seem to be mostly explainable by them in retrospect. Anyway, my point is that there certainly are forces of change and "featurism", which come up squarely against one of Python's central features: its lack of central features. (Ironic, ain't it? ) Or, as a great bot once said (more or less), "those who succeed in the language design business do so by choosing a design philosophy and sticking to it." which-is-yet-another-statement-you-probably-wish-we-literal -minded-folks-had-never-heard--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 jkraska1 at san.rr.com Mon Feb 19 06:54:20 2001 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 19 Feb 2001 05:54:20 GMT Subject: Language change (was RE: iterators (was: python-dev summary)) References: <3A90A2AA.21FB5D05@seebelow.org> Message-ID: >Anyway, my point is that there certainly are forces of change and >"featurism", which come up squarely against one of Python's central >features: its lack of central features. (Ironic, ain't it? ) :-) This is one of Python's true redeeming values; I hope and pray that it doesn't get lost in the woods over the years. C// From othello at javanet.com Wed Feb 21 02:08:20 2001 From: othello at javanet.com (Raymond Hettinger) Date: Tue, 20 Feb 2001 20:08:20 -0500 Subject: Language change (was RE: iterators (was: python-dev summary)) References: <3A90A2AA.21FB5D05@seebelow.org> Message-ID: <3A931503.366F2B7E@javanet.com> Courageous wrote: > >Anyway, my point is that there certainly are forces of change and > >"featurism", which come up squarely against one of Python's central > >features: its lack of central features. (Ironic, ain't it? ) > > :-) > > This is one of Python's true redeeming values; I hope and pray > that it doesn't get lost in the woods over the years. > I absolutely agree that there should be a strong resistance toward creeping featurism, but think there should be an equally strong will to improve the language and not reject ideas out of hand. Examples of "good" directions for changes: -- change things that surprise uses (like unexpected integer math) -- change things that cause users to write awkward or kludgy code (like having to set-up a loop counter when indexing over a list -- which PEP 234 proposes to fix) -- change things that aren't polymorphic (like eval taking only dictionary objects instead of general mapping objects and like the tuple.count() which GvR rejected). -- do tough things like unifying the type/class distinction (it will be a bear, but life will be better afterwards). -- change difficult to use tools (like improving the debugger or adding interactive help). -- change things that prevent people from using their favorite tricks (like adding nested scopes so that the functional programmers can go wild). -- implement things which improve performance (like xreadlines() or stacklessness). -- add more examples to the documentation We can have language improvement without creeping featurism. Raymond "In theory, there is no difference between theory and practice. In practice, there is." -- Yogi Berra From donn at oz.net Wed Feb 21 08:19:55 2001 From: donn at oz.net (Donn Cave) Date: 21 Feb 2001 07:19:55 GMT Subject: Language change (was RE: iterators (was: python-dev summary)) References: <3A90A2AA.21FB5D05@seebelow.org> <3A931503.366F2B7E@javanet.com> Message-ID: <96vq6r$9b4$0@216.39.151.169> Quoth Raymond Hettinger : | Courageous wrote: (quoting someone else) |>| Anyway, my point is that there certainly are forces of change and |>| "featurism", which come up squarely against one of Python's central |>| features: its lack of central features. (Ironic, ain't it? ) |> |> :-) |> |> This is one of Python's true redeeming values; I hope and pray |> that it doesn't get lost in the woods over the years. | I absolutely agree that there should be a strong resistance toward | creeping featurism, but think there should be an equally strong will | to improve the language and not reject ideas out of hand. | | Examples of "good" directions for changes: [... various perennial favorites ...] | We can have language improvement without creeping featurism. Right - let's pile on every "good" thing we can think of! Changes like this aren't rejected "out of hand". Per an early post in this thread, the process may not always be any more rigorous than the designer's hunch, but that hunch is what makes or breaks the language. If not everything has been accepted, I think the reports of wholesale patch rejection could be a little deceiving, depending on what all those rejected patches were actually proposing to do. But you can count on it, some of those changes you like will indeed not be deemed worthy, and there doesn't need to be a reason that says "this feature is actually bad, and here's what breaks". Any change is disruptive, any extra feature adds to the burden of learning and using the language. If you can't make a strong enough case for the benefit of a new feature, then its value won't outweigh that burden. Many of the notions you think are good directions aren't compelling to me. In fact they fall into several common classes of uncompelling: 1. "This will be easier for programmers who aren't programmers." - Who is the legitimate voice of this class of people? Do you or anyone have evidence that your theories are going to pay off in practice? Take the integer arithmetic thing - could there be a big can of worms waiting for the unwary user of the alternative, which I suppose would be floating point? If the innocent programmer is surprised by integer truncation, what about 1.0 != 1.0? - Are real programmers supposed to stick with Python as it sells them out? Will a non-programmer constituency pan out for the new Python? I overstate this as a conflict, but there is an element of that. If the implication is that I should accept changes that are bad for me, because they're good for someone else who doesn't actually use Python and may never really have all that much use for any programming language, well, I'm not sure that makes total sense to me. 2. "This makes things more consistent." - Who cares? Is Python's general level of inconsistency a big problem? Some changes in that direction could conceivably make programming significantly more productive, but it has to be spelled out. More consistent is not compelling per se. 3. "This alleviates awkwardness, kludginess, etc." - Who cares? If we're talking about programming problems that really hurt at a software engineering level, for example force you to write the same thing in several places when you could have done it once given the feature, then that's interesting, but again, the onus is on the proponent to sell that. The more usual case is that this "it's kludgy!" reaction is as vacuous is as it is emphatic. Now I'm not saying the things you propose are altogether without value, and I might even agree about one or two if I looked at it hard enough. The key is that the benefit must be clear and practical. Donn Cave, donn at oz.net ------- | Examples of "good" directions for changes: | -- change things that surprise uses (like unexpected integer math) | -- change things that cause users to write awkward or kludgy code (like having | to | set-up a loop counter when indexing over a list -- which PEP 234 proposes | to fix) | -- change things that aren't polymorphic (like eval taking only dictionary | objects | instead of general mapping objects and like the tuple.count() which GvR | rejected). | -- do tough things like unifying the type/class distinction (it will be a bear, | but life | will be better afterwards). | -- change difficult to use tools (like improving the debugger or adding | interactive help). | -- change things that prevent people from using their favorite tricks (like | adding nested | scopes so that the functional programmers can go wild). | -- implement things which improve performance (like xreadlines() or | stacklessness). | -- add more examples to the documentation From donn at oz.net Mon Feb 19 08:13:19 2001 From: donn at oz.net (Donn Cave) Date: 19 Feb 2001 07:13:19 GMT Subject: Language change (was RE: iterators (was: python-dev summary)) References: <3A90A2AA.21FB5D05@seebelow.org> Message-ID: <96qh2f$962$1@216.39.151.169> Quoth Grant Griffin : | Guilty as charged! If my implied compliment wasn't received here, | consider it given! I have said this before: Genius is the art of | simplicity, and Python is a work of great simplicity. I don't know how to say this, but I think it isn't just the language - I'm afraid we're simple too. Even though we didn't create it, we who use the language are an important part of the phenomenon. Our simple- minded, numb tolerance for expressions like "while 1", our willingness to write out "self" just to disambiguate namespaces, our uncritical acceptance of incomplete OO-ness, make it possible for a language like Python to thrive. What are we, techno-peasants or something? Donn Cave, donn at oz.net From aahz at panix.com Mon Feb 19 08:28:16 2001 From: aahz at panix.com (Aahz Maruch) Date: 18 Feb 2001 23:28:16 -0800 Subject: Language change (was RE: iterators (was: python-dev summary)) References: <3A90A2AA.21FB5D05@seebelow.org> <96qh2f$962$1@216.39.151.169> Message-ID: <96qhug$446$1@panix2.panix.com> In article <96qh2f$962$1 at 216.39.151.169>, Donn Cave wrote: > >What are we, techno-peasants or something? Absolutely. I regularly call myself a technophilic Luddite. -- --- 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 Why doesn't "Just Say NO" include caffeine, nicotine, alcohol, Prozac, and Ritalin? --Aahz From amk at mira.erols.com Tue Feb 20 02:08:27 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 20 Feb 2001 01:08:27 GMT Subject: Language change (was RE: iterators (was: python-dev summary)) References: <3A90A2AA.21FB5D05@seebelow.org> <96qh2f$962$1@216.39.151.169> <96qhug$446$1@panix2.panix.com> Message-ID: On 18 Feb 2001 23:28:16 -0800, Aahz Maruch wrote: >Absolutely. I regularly call myself a technophilic Luddite. Never used that combination of words before, but it's a good one. We should write a manifesto! --amk From aahz at panix.com Tue Feb 20 02:15:48 2001 From: aahz at panix.com (Aahz Maruch) Date: 19 Feb 2001 17:15:48 -0800 Subject: Language change (was RE: iterators (was: python-dev summary)) References: <96qh2f$962$1@216.39.151.169> <96qhug$446$1@panix2.panix.com> Message-ID: <96sgg4$a33$1@panix6.panix.com> In article , A.M. Kuchling wrote: >On 18 Feb 2001 23:28:16 -0800, Aahz Maruch wrote: >> >>Absolutely. I regularly call myself a technophilic Luddite. > >Never used that combination of words before, but it's a good one. >We should write a manifesto! Sure, as long as it's accessible with Lynx. -- --- 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 "Laws that restrict speech are an abomination for a simple reason. They're like a poison gas; they seem to be a good weapon to vanquish your enemy, but the wind has a way of shifting." -- Ira Glasser From sholden at holdenweb.com Wed Feb 28 21:23:32 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 28 Feb 2001 15:23:32 -0500 Subject: Language change (was RE: iterators (was: python-dev summary)) References: <3A90A2AA.21FB5D05@seebelow.org> <96qh2f$962$1@216.39.151.169> <96qhug$446$1@panix2.panix.com> Message-ID: <4kdn6.4166$jv4.258966@e420r-atl2.usenetserver.com> "Aahz Maruch" wrote in message news:96qhug$446$1 at panix2.panix.com... > In article <96qh2f$962$1 at 216.39.151.169>, Donn Cave wrote: > > > >What are we, techno-peasants or something? > > Absolutely. I regularly call myself a technophilic Luddite. Well, yes, but then you also regularly call yourself an androgynous poly kinky vanilla queer het, so I'm unsure how much weight to attach to this statement, regards Steve From tim.one at home.com Wed Feb 28 21:57:29 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 28 Feb 2001 15:57:29 -0500 Subject: Language change (was RE: iterators (was: python-dev summary)) In-Reply-To: <4kdn6.4166$jv4.258966@e420r-atl2.usenetserver.com> Message-ID: [Donn Cave] > What are we, techno-peasants or something? [Aahz] > Absolutely. I regularly call myself a technophilic Luddite. [Steve Holden] > Well, yes, but then you also regularly call yourself an androgynous poly > kinky vanilla queer het, so I'm unsure how much weight to attach to this > statement, I've met Aahz -- trust me, they both fit. Well, I'm not so sure about the "vanilla" part, now that you mention it. but-i'm-just-an-old-bot-who-am-i-to-judge-ly y'rs - tim From not.this at seebelow.org Mon Feb 19 21:47:15 2001 From: not.this at seebelow.org (Grant Griffin) Date: 19 Feb 2001 12:47:15 -0800 Subject: Language change (was RE: iterators (was: python-dev summary)) References: <3A90A2AA.21FB5D05@seebelow.org> <96qh2f$962$1@216.39.151.169> Message-ID: <96s0oj02nsq@drn.newsguy.com> In article <96qh2f$962$1 at 216.39.151.169>, Donn says... > >Quoth Grant Griffin : > >| Guilty as charged! If my implied compliment wasn't received here, >| consider it given! I have said this before: Genius is the art of >| simplicity, and Python is a work of great simplicity. > >I don't know how to say this, but I think it isn't just the language - >I'm afraid we're simple too. Even though we didn't create it, we who >use the language are an important part of the phenomenon. Good point. I personally think of myself as "simple" but somewhat "wise". (Then again, aren't the wisest people mostly pretty simple anyway? ) The wisdom comes in knowing one's limitations--and in actively seeking things like Python that help. >Our simple- >minded, numb tolerance for expressions like "while 1", I recently figured out (I think) that one the *really* bad thing about do/until in Python is that it doesn't work with Python's block style. (In fact, if you think about it, even in C/C++ do/until a little strange in being the only thing that has an expression at the _end_ of the block!) If language design is a compromise, and this compromise frees me from braces, I'm a happy camper. >our willingness >to write out "self" just to disambiguate namespaces,... If that were the _only_ reason, it might not be so great. But you're talking to the guy who actually _likes_ "self.", as a replacement for the "m_" notation he uses in C++ to mark class member variables. (True, I sometimes wake up screaming in the middle of the night about those extra three characters Python's convention makes me type. But then I tell myself that I could have used "m." if I had really wanted to. ) >...our uncritical >acceptance of incomplete OO-ness, But some of us _like_ a mixed OO/procedural paradigm. (Although "math.sin(x)" sure does read a little fishy...) >make it possible for a language >like Python to thrive. What are we, techno-peasants or something? I prefer to think of us more as thirsty horses being lead to water. which-is-not-to-say-we'll-all-drink-*everything*-we're -lead-to--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 mwh21 at cam.ac.uk Mon Feb 19 22:32:27 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 19 Feb 2001 21:32:27 +0000 Subject: Language change (was RE: iterators (was: python-dev summary)) References: <3A90A2AA.21FB5D05@seebelow.org> <96qh2f$962$1@216.39.151.169> <96s0oj02nsq@drn.newsguy.com> Message-ID: Grant Griffin writes: > If that were the _only_ reason, it might not be so great. But > you're talking to the guy who actually _likes_ "self.", as a > replacement for the "m_" notation he uses in C++ to mark class > member variables. (True, I sometimes wake up screaming in the > middle of the night about those extra three characters Python's > convention makes me type. But then I tell myself that I could have > used "m." if I had really wanted to. ) I still have the mental scars from trying to understand code that named *local* variables m_blah. Explicit *is* better than implicit. 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 hinsen at cnrs-orleans.fr Mon Feb 19 11:52:35 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 19 Feb 2001 11:52:35 +0100 Subject: iterators (was: python-dev summary) References: <3A8CAC77.91555B93@seebelow.org> <96ipv7$hug$2@nntp9.atl.mindspring.net> <96jt2v$ogk$1@nntp6.u.washington.edu> Message-ID: amk at mira.erols.com (A.M. Kuchling) writes: > I think I'll repeat the argument for 2.1: call the language as defined > by the 2.1 docs the final version, and leave it alone. Obviously you > could still work on a faster interpreter, fix bugs in it, etc. This > means interfaces won't get implemented, which is unfortunate, but if > you let in "just *one* more feature" it'll never stop. This seems a bit strict, but I agree with the general idea. Adding a new feature that opens up new possibilities (like safety in the case of interfaces) is OK, but adding syntactic sugar like list comprehensions mostly bloats the language definition. Simplicity is one of Python's attractions. If you want a complicated language, try Fortran, Ada, or C++. -- ------------------------------------------------------------------------------- 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 sholden at holdenweb.com Wed Feb 28 21:38:30 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 28 Feb 2001 15:38:30 -0500 Subject: iterators (was: python-dev summary) References: <3A8CAC77.91555B93@seebelow.org> <96ipv7$hug$2@nntp9.atl.mindspring.net> <96jt2v$ogk$1@nntp6.u.washington.edu> Message-ID: "A.M. Kuchling" wrote in message news:slrn98rkib.ik.amk at mira.erols.com... > On 16 Feb 2001 18:55:27 GMT, Donn Cave wrote: > >If it's a big step towards something useful, fine. I have heard > > Agreed. Some time ago I argued that once Unicode was added to Python > 1.6, we should just stamp the language definition "done" and leave it > alone. Sure, we can add little tweaky features like iterators, but > will they enable a startling new application domain? Will they > attract more users? In both cases the answer is likely "no", so we > should just write off the new features -- they might be nice, but why > bother making books obsolete and making the code more bloated? > > I think I'll repeat the argument for 2.1: call the language as defined > by the 2.1 docs the final version, and leave it alone. Obviously you > could still work on a faster interpreter, fix bugs in it, etc. This > means interfaces won't get implemented, which is unfortunate, but if > you let in "just *one* more feature" it'll never stop. > No, really, have just one more feature -- they're wafer thin! Apart from leacing a lot of pretty competent programmers with less to do, I can't think of many disadvantages to freezing the specification. This, I presume, was originally the thinking behind Py3K. It seems to me that the future may cause the Python applications base to slowly crumble, as incompatible features which "break very little code" are added. but-then-i'm-just-an-old-fart-luddite-ly y'rs - steve From kevin.digweed at dial.pipex.com Sun Feb 18 20:26:19 2001 From: kevin.digweed at dial.pipex.com (Kevin Digweed) Date: Sun, 18 Feb 2001 19:26:19 +0000 Subject: iterators (was: python-dev summary) References: <3A8CAC77.91555B93@seebelow.org> <96ipv7$hug$2@nntp9.atl.mindspring.net> Message-ID: <3A9021DB.D18A19D4@dial.pipex.com> Erno Kuusela wrote: > > In article <96ipv7$hug$2 at nntp9.atl.mindspring.net>, "Andrew Dalke" > writes: > > | Grant Griffin: > || However... > || > || I regret Python's increasing loss of status as "executable > || pseudo-code". This proposal, as well as 2.0's "list comprehensions", > || seem to be making Python harder for the uninitiated to read. (To be > || fair, though, as a "moderately-initiated" Pythoneer, I've recently > || warmed up to list comprehensions.) > || [more comments removed] > > | I admit to a "Me too!" here. > > me three! > > actually, the first time i saw the proposal for > > for key:value in dict: > ... > > i thought it was a joke. ok, it's not obscure, but i > don't see the point either. Sadly, I don't Python as much as I used to, but as someone who has started reading the newsgroup again since just after 2.0 was released, this PEP did come as something of a surprise to me. I don't think that the 'for x:y in dict' syntax bothered me so much as the 'for :y' and 'for x:' variants. It's too subtle. I saw a post recently where someone did "(None, None, None, ThingIWant, OtherThingIWant, None) = funcreturning6_tuple();". I confess to doing something similar when I first started Python. I expected None to be something that, given it's name, was something of a black hole. The solution is to assign all those things you don't want to a dummy name which you can subsequently 'del'ete. I think that the proposed extension to the 'for' syntax should be limited to *only* the "x:y" variety. If you don't want the left or right component, you assign it to a dummy name and 'del'ete it if neccessary. OTOH, if the other variations on the 'for' syntax were to be allowed, I think that "for (,,, ThingIWant, OtherthingIWant,,) = funcreturning6_tuple();" should also be allowed. (BTW, I'm being sarcastic). I guess that what I'm saying is that I don't think the *absense* of a word/keyword should be treated as significant. Kev. From jepler at inetnebr.com Mon Feb 19 02:59:24 2001 From: jepler at inetnebr.com (Jeff Epler) Date: Mon, 19 Feb 2001 01:59:24 GMT Subject: iterators (was: python-dev summary) References: <3A8CAC77.91555B93@seebelow.org> <96ipv7$hug$2@nntp9.atl.mindspring.net> <3A9021DB.D18A19D4@dial.pipex.com> Message-ID: On Sun, 18 Feb 2001 19:26:19 +0000, Kevin Digweed wrote: >I guess that what I'm saying is that I don't think the *absense* of a >word/keyword should be treated as significant. ... except in the case of slices, right? x[1:2] x[:2] x[1:] x[:] Jeff From dwig at advancedmp.net Wed Feb 21 18:32:35 2001 From: dwig at advancedmp.net (Don Dwiggins) Date: 21 Feb 2001 09:32:35 -0800 Subject: iterators (was: python-dev summary) In-Reply-To: Kevin Digweed's message of "Sun, 18 Feb 2001 19:26:19 +0000" References: <3A8CAC77.91555B93@seebelow.org> <96ipv7$hug$2@nntp9.atl.mindspring.net> <3A9021DB.D18A19D4@dial.pipex.com> Message-ID: > I saw a post recently where someone > did "(None, None, None, ThingIWant, OtherThingIWant, None) = > funcreturning6_tuple();". I confess to doing something similar when I > first started Python. ... > OTOH, if the other variations on the 'for' syntax were to be allowed, I > think that "for (,,, ThingIWant, OtherthingIWant,,) = > funcreturning6_tuple();" should also be allowed. (BTW, I'm being > sarcastic). Actually, you can already do it Prolog-style: (_, _, _, ThingIWant, OtherthingIWant, _) = funcreturning6_tuple() -- Don Dwiggins "Solvitur Ambulando" Advanced MP Technology dwig at advancedmp.net From qrczak at knm.org.pl Thu Feb 22 17:08:12 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 22 Feb 2001 16:08:12 GMT Subject: iterators (was: python-dev summary) References: <3A8CAC77.91555B93@seebelow.org> <96ipv7$hug$2@nntp9.atl.mindspring.net> <3A9021DB.D18A19D4@dial.pipex.com> Message-ID: 21 Feb 2001 09:32:35 -0800, Don Dwiggins pisze: > Actually, you can already do it Prolog-style: > (_, _, _, ThingIWant, OtherthingIWant, _) = funcreturning6_tuple() Except that the object bound to _ will be retained until the function returns or _ is rebound. Unfortunately the interpreter is probably not allowed to optimize it out by realizing that this variable is never referenced, because somebody might want to rely on the fact that the destructor is not called too early. I wish it was allowed to optimize it out. Or is it already? Relying on the moment of calling a destructor is evil. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From skip at mojam.com Fri Feb 16 19:35:37 2001 From: skip at mojam.com (Skip Montanaro) Date: Fri, 16 Feb 2001 12:35:37 -0600 (CST) Subject: iterators (was: python-dev summary) In-Reply-To: <96ipv7$hug$2@nntp9.atl.mindspring.net> References: <3A8CAC77.91555B93@seebelow.org> <96ipv7$hug$2@nntp9.atl.mindspring.net> Message-ID: <14989.29433.578965.545111@beluga.mojam.com> Andrew> I see similar problems with ">>" and now with "k:v" iterators. Andrew> These all mean there will be multiple ways to do the same task. The ">>" syntax can actually be thought of as reducing the number of (standard) ways of printing. Previously, you could use the print statement for straightforward output (but only to sys.stdout), but if you wanted to write to anything besides sys.stdout, you generally were forced to use file's write method. Now you have your choice: straightforward output or finegrained control of output. If your scientist friends are comfortable with print, there's no need to introduce them to the more complex use of write methods and the % formatting operator. No comment on the k:v iterator. I don't believe that's a done deal. -- Skip Montanaro (skip at mojam.com) Support Mojam & Musi-Cal: http://www.musi-cal.com/sponsor.shtml (847)971-7098 From dalke at acm.org Fri Feb 16 09:54:16 2001 From: dalke at acm.org (Andrew Dalke) Date: Fri, 16 Feb 2001 01:54:16 -0700 Subject: iterators (was: python-dev summary) References: <3A8CAC77.91555B93@seebelow.org> Message-ID: <96ipv9$hug$3@nntp9.atl.mindspring.net> Here's the rationale for PEP 234 > 1. It provides an extensible iterator interface. I notice it isn't as powerful as C++ iterators. For example, there's no way to specify a bidirectional iterator. I also don't see how mutations in the container are handled, but I don't know how C++ does that either. I also note that there are different types of iterators which may be applied to an object. For example, a file can be iterated a line at a time or a record at a time. To support this currently, I write a wrapper object which handles __getitem__ as appropriate. What's wrong with that approach? For example, import iterate for key, val in iterate.items(obj): pass where iterate.items is a function which does essentially the same thing as mp_iteritems. Off the top of my head (without much thought and likely to be error prone) it could look similar to: iterate.py: class IterateItems: def __init__(self, obj, next_key): self.__obj = obj self.__next_key = next_key def __getitem__(self, i): k = self.__next_key[i] return k, self.__obj[k] def items(obj): if hasattr(obj, "__iteritems__"): return obj.__iteritems__() elif hasattr(obj, "__iter__"): return IterateItems(obj, obj.__iter__()) elif hasattr(obj, "__items__"): return obj.__items__() elif hasattr(obj, "__getitem__"): return IterateItems(obj, obj.keys()) ... Similar constructs for iterate.keys(obj) iterate.values(obj) ... My point is that this iterator scheme does not and cannot handle every situation so there will have to be ways to map the desired solution to the iterator scheme. Why not expand on that and use wrappers/explicit factory fuctions for everything instead of using new syntax. > 2. It resolves the endless "i indexing sequence" debate. None of my clients have ever brought this up as a concern. For that matter, I'm not sure what you mean by it. If you had said "i indexing dictionary" I might understand. There are endless "tab vs. spaces vs. {}" debates. Does that mean something needs to be done with Python to settle those debates. Meaning, I don't view this as a useful argument. Maybe it really means that you are using this phrase as a shorthand description of a problem and I don't know how to expand it properly. > 3. It allows performance enhancements to dictionary iteration. My alternate suggestion supports this as well, but without syntax changes. > 4. It allows one to provide an interface for just iteration without pretending to provide random access to elements. Hmm. I've had success in throwing an exception when the iterator was used in a non-forward manner. I tracked a "self.__n" with the current position, and enforced that "i == self.__n" in "__getitem__(self, i)". No one has ever complained about it. But I do like the idea. Consider one place where I had a forward iterator through a database (provided by the underlying C API, which didn't allow a random access iterator.) I did the check against self.__n as above, but it wasn't obvious in the code that only forward iteration was allowed. Instead, if there is a iterate module with a "forward" factory function, then it can work like: iterate.py: class ForwardIterator: def __init__(self, obj): self.__obj = obj self.__n = 0 def __getitem__(self, i): assert self.__n == i, "only forward iteration is allowed" self.__n += 1 return self.__obj[i] def forward(obj): if hasattr(obj, "__iter__"): return obj.__iter__() elif hasattr(obj, "__getitem__"): return ForwardIterator(obj) ... and my code would be similar to: class ForwardDatabaseIterator: def __init__(self, stream): self.stream = stream def __getitem__(self, i): # guaranteed to be called in increasing order, so I # don't need to check for random access handle = daylight.dt_next(self.stream) if h == 0: daylight.dt_dealloc(self.stream) return Record(handle) class Database: def __iter__(self): stream = daylight.dt_stream(self.handle, daylight.TYP_RECORD) return ForwardDatabaseIterator(stream) import iterate db = open_database("user at host", "password") for record in iterate.forward(db): pass > 5. It is backward-compatible with all existing user-defined > classes and extension objects that emulate sequences and > mappings, even mappings that only implement a subset of > {__getitem__, keys, values, items}. Same for my alternate suggestion because it uses the same techniques for backwards compatibility that you use. Note that I am *not* proposing that this module wrapper should be used. I would rather keep things as they are (see my comments on this in c.l.py). Instead, read it as a push that if this functionality is added to Python that it be done without adding new syntax, and a proposal suggestion how that might be done. For Ka-Ping Yee. I'm not on python-dev and it's hard to search the pipermail archives, so I don't know if I caught everything on this discussion. In http://mail.python.org/pipermail/python-dev/2001-February/012677.html you say > > Sorry, Ping, I didn't know you have a PEP for iterators already. > > I posted it on this very boutique (i mean, mailing list) a week ago > and messages have been going back and forth on its thread since then. I can't seem to find those mails. I don't see mention of "234" or "iterator" in any of the titles listed in the indicies, and pipermail doesn't have any way to do a text search. My apologies for not following every link to find that thread. That said, M-A Lemburg in http://mail.python.org/pipermail/python-dev/2001-February/012679.html said > I'd suggest to implement generic iterators which implements your > suggestions and put them into the builins or a special iterator > module... > > from iterators import xitems, xkeys, xvalues > > for key, value in xitems(dict): > for key in xkeys(dict): > for value in xvalues(dict): which is essentially what I said. Your reply to his message, in http://mail.python.org/pipermail/python-dev/2001-February/012682.html doesn't comment on his suggestion and the PEP doesn't make any comment on it. (Oh, I downloaded all of Feb's mail to date. I can't find any other message which includes reference to "from iter". I also found the thread "Sets: elt in dict, lst.include" and other threads, but as a flat file it's hard to follow what's going on. My apologies for not rewriting this email based on my new knowledge - I don't think it is affected much by what I've read.) Finally, as a minor note, I almost never embed def's in def's so examples like def __iter__(self): def iter(self=self): line = self.file.readline() if line: return line else: raise IndexError return iter take some effort for me to follow. I tend to create new classes instead, since I find them less confusing than using default arguments as a way to pass state around. Sincerely, Andrew Dalke dalke at acm.org From gzeljko at sezampro.yu Fri Feb 16 14:35:37 2001 From: gzeljko at sezampro.yu (gzeljko) Date: Fri, 16 Feb 2001 14:35:37 +0100 Subject: PEP-0234 References: <3A8CAC77.91555B93@seebelow.org> Message-ID: <96jacs$qg6$1@neptun.beotel.net> Perhaps I'm missing something obvious, but: If you hev construct: for ident1 in ident2: I'm really surprised that people wish express intended behaviour of ident2 messing with ident1. This is unnatural, unflexible and dead-lock for language evolution (IMHO). !?-ly-y'rs-gzeljko From dwig at advancedmp.net Fri Feb 16 19:45:20 2001 From: dwig at advancedmp.net (Don Dwiggins) Date: 16 Feb 2001 10:45:20 -0800 Subject: About iterators as a new language feature In-Reply-To: Grant Griffin's message of "Thu, 15 Feb 2001 22:28:39 -0600" References: <3A8CAC77.91555B93@seebelow.org> Message-ID: Grant Griffin writes: >> Discussion went round and round for a while and moved >> on to more general iteration constructs, prompting Ka-Ping Yee to >> write a PEP entitled "iterators": >> >> >> >> Please comment! > I went through this one, and I really like it: it seems both very > "useful" and very "beautiful". What more could it possibly need? > However... > I regret Python's increasing loss of status as "executable > pseudo-code". This proposal, as well as 2.0's "list comprehensions", > seem to be making Python harder for the uninitiated to read. (To be > fair, though, as a "moderately-initiated" Pythoneer, I've recently > warmed up to list comprehensions.) ... > I think Python is at a crossroads where it is changing from "executable > pseudo-code" into something increasingly...well..."complex". If > "growth" in a language means "new features", I guess complexity is > inevitable. In all honesty, the techie in me is all in favor of that. > But my wiser part realizes that the techie part needs to be kept in > check. (Or, as the great Archie Bunker said, "Stifle yourself!") > So, give me this great new feature of iterators--if you can't manage to > save me from myself. I'd like to suggest an alternative approach to adding features to the language for this kind of thing: providing "iterator-like" methods in the "collection classes". I'd planned to work up a message on this theme, describing how Smalltalk uses the Block (think lambda) as a basic language element, and builds around it "execution mechanisms" that would be language elements in other languages, and suggesting that something like that be considered for Python. For example, the Smalltalk language doesn't have any syntax for "if-else", "for", or "while" -- the equivalents are built out of classes and methods defined in the "library", and use Blocks as an essential enabler. In particular, all iteration is done using methods of the Collection hierarchy. There's a handful of standard methods, but an enterprising programmer can easily create new ones for special purposes. The direction I'm looking in is to do something similar for Python. I'm just getting started with the language, so there are probably some issues I can't see yet. However, I've seen that there are some Smalltalk speakers in this forum, so I think there could be a productive discussion on this topic. I guess the basic theme is, wherever possible, keep the language simple but powerful, and build new structures and mechanisms in the language, rather than added onto it. -- Don Dwiggins "Solvitur Ambulando" Advanced MP Technology dwig at advancedmp.net From jpet at eskimo.com Sat Feb 17 07:11:12 2001 From: jpet at eskimo.com (Jeff Petkau) Date: Sat, 17 Feb 2001 06:11:12 GMT Subject: iterators (was: python-dev summary) References: <3A8CAC77.91555B93@seebelow.org> Message-ID: <4Coj6.3622$1T1.356977@paloalto-snr1.gtei.net> Steve Purcell wrote in message news:mailman.982313491.5504.python-list at python.org... > This new proposal sounds 'neat', but just think about plugging the new > iterator syntax into list comprehensions like the following (stolen from the > PEP): > > >>> nums = [1,2,3,4] > >>> fruit = ["Apples", "Peaches", "Pears", "Bananas"] > >>> print [(i,f) for i in nums for f in fruit if f[0] == "P" if i%2 == 1] > [(1, 'Peaches'), (1, 'Pears'), (3, 'Peaches'), (3, 'Pears')] > > Sprinkle a few ':' iterator magic symbols in there, and it doesn't look like > Python any more. Of course, if the intention is to win over the Perl > community... > > -Steve I totally agree with this. I hope future language additions take the form of builtin functions like zip() instead of new syntax. Functions are more in line with the 'explicit is better than implicit' argument--does 'for x in dict' iterate over keys, values, or items? What better way could we specify this than keys(), values(), and items()? For iterating through lists with indices, we could just toss something like this into __builtins__: def indexed(x): """returns a list of (index,value) pairs for the mapping or sequence x.""" if hasattr(x,'items'): return x.items() else: return zip(range(len(x)),x) for i,v in indexed([1,2,3]): print 'elem at',i,'is',v The only argument I've seen for new syntax is efficiency-- dict.keys() et al can be expensive for big dictionaries. But this is solved very nicely the way xrange() and xreadlines() did it, with lazy iterators. Maybe Guido thinks they're a hack, but they're a simple, efficient, consistent, easy to use solution to a recurring problem. We could use more hacks like that! Admittedly the xfoo() naming convention is ugly, but that's the nature of backwards compatibility. New iterators could be lazy by default, and if you want an actual list, just use list(x). Um, what topic did I start with again? Oh, yeah. And function names are much easier to look up in the documentation. --Jeff From hinsen at cnrs-orleans.fr Fri Feb 16 15:17:48 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 16 Feb 2001 15:17:48 +0100 Subject: python-dev summary 2001-02-01 - 2001-02-15 References: Message-ID: Michael Hudson writes: > This is a summary of traffic on the python-dev mailing list between > Feb 1 and Feb 14 2001. It is intended to inform the wider Python Great news, and thanks for your efforts! > Skip Montanaro raised some concerns about Python's accelerated > release schedule, and it was pointed out that the default Python for > both debian unstable and Redhat 7.1 beta was still 1.5.2. Have > *you* upgraded to Python 2.0? If not, why not? No. I keep a 2.0 installed on my personal account for compatibility testing, but updating Python on all the machines I use at work is a major effort (all extension modules need to be recompiled), so I do this only when there's an improvement that is significant to my work. This will be the case for 2.1 (e.g. rich comparisons), but it wasn't in 2.0. -- ------------------------------------------------------------------------------- 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 qrczak at knm.org.pl Sun Feb 18 22:41:55 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 18 Feb 2001 21:41:55 GMT Subject: python-dev summary 2001-02-01 - 2001-02-15 References: Message-ID: Thu, 15 Feb 2001 16:56:54 +0000 (GMT), Michael Hudson pisze: > Discussion went round and round for a while and moved > on to more general iteration constructs, prompting Ka-Ping Yee to > write a PEP entitled "iterators": > > What about mp_iterkeys trying to use __iteritems__ after __iterkeys__ is not available, before failing back to __iter__? Similarly __itervalues__. It would allow a mapping to implement only __iteritems__, obtaining correct iteration over keys and values for free. What about introducing a "black hole" or "wildcard pattern" for assignments? e0, e1, _, _ = some_4_tuple for k:_ in mapping: for _:v in mapping: If there is code using _ as a variable name, maybe some different name. But it's _ in some other languages (ML, Haskell, Prolog, Clean). After these two things increasing the complexity :-( let me propose a simplification. Have _ as above, but don't have mp_iterkeys nor mp_itervalues. The mapping iteration protocol uses only mp_iteritems and __iteritems__ / __iter__. Iteration over keys or values is expressed as iteration over items, while throwing half of each pair into a black hole. For mp_iteritems implemented in terms of __iter__ (i.e. sequences treating as mappings from integers) and for builtin types the interpreter can generate as efficient code for k:_ and _:v iteration as if there were separate iterkey and itervalue protocols. For user classes it's a bit worse (an unnecessary 2-tuple is created), but the simplification of concepts certainly justifies it. So finally I propose adding black holes, and having only the iteritems protocol and syntax. iterkeys and itervalues are just instances of these concepts put together, not separate concepts. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From cjc26 at nospam.cornell.edu Mon Feb 19 19:12:44 2001 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Mon, 19 Feb 2001 18:12:44 GMT Subject: python-dev summary 2001-02-01 - 2001-02-15 References: Message-ID: * Marcin 'Qrczak' Kowalczyk menulis: | | What about introducing a "black hole" or "wildcard pattern" for | assignments? | e0, e1, _, _ = some_4_tuple | for k:_ in mapping: | for _:v in mapping: | If there is code using _ as a variable name, maybe some different name. | But it's _ in some other languages (ML, Haskell, Prolog, Clean). You can already do stuff like e0, e1, _, _ = (10, 20, 40, 30) print e0 => 10 print e1 => 20 print _ => 30 You can use whatever variable name you want for the dummy variable. As for dict iteration, I don't like the idea of inventing new syntax for it; I would prefer having dict.items() return a lazy list, or maybe add a xitems() method to return a lazy list. (Actually, if there were some way to signal to a method that it's being called in an iteration context, then we wouldn't need all these x-methods...) -- Cliff Crawford http://www.people.cornell.edu/pages/cjc26/ "huh? Are you all there? You missing some key parts up there? Becoming a English major or an minor? Do you need a annual report? Are you slow today, eh? Did someone sever you parietal lobe?" - Mark From eferro at inicia.es Thu Feb 15 18:07:02 2001 From: eferro at inicia.es (Eduardo Ferro) Date: Thu, 15 Feb 2001 18:07:02 +0100 Subject: ioctl problem Message-ID: <96gva8$nnd$1@diana.bcn.ttd.net> Hi! Have anybody some example of the use of ioctl method when this ioctl return some data in a estructure. I use icotl to control the cdrom, and the ioctls without parameters works well, but i don`t know how to use the ioctls that return me data Thanks in advance :) From donn at u.washington.edu Thu Feb 15 19:04:56 2001 From: donn at u.washington.edu (Donn Cave) Date: 15 Feb 2001 18:04:56 GMT Subject: ioctl problem References: <96gva8$nnd$1@diana.bcn.ttd.net> Message-ID: <96h5o8$u8e$1@nntp6.u.washington.edu> Quoth "Eduardo Ferro" : | Have anybody some example of the use of ioctl method when this ioctl | return some data in a estructure. | I use icotl to control the cdrom, and the ioctls without parameters works | well, but i don`t know how to use the ioctls that return me data >>> import fcntl >>> print fcntl.ioctl.__doc__ ioctl(fd, opt, [arg]) Perform the requested operation on file descriptor fd. The operation is defined by op and is operating system dependent. Typically these codes can be retrieved from the library module IOCTL. The argument arg is optional, and defaults to 0; it may be an int or a string. If arg is given as a string, the return value of ioctl is a string of that length, containing the resulting value put in the arg buffer by the operating system. The length of the arg string is not allowed to exceed 1024 bytes. If the arg given is an integer or if none is specified, the result value is an integer corresponding to the return value of the ioctl call in the C code. That means you must lay your data out as a string of bytes. Pass any string of that length to ioctl(), then use the "struct" module's byte unpacking functions to convert the return string to the data type you want to work with. >>> import fcntl >>> n = fcntl.ioctl(0, 1074295912, 'XXXXXXXX') >>> n '\030\000P\000\360\000 \003' >>> import struct >>> struct.unpack('hhhh', n) (24, 80, 240, 800) That's the TIOCGWINSZ ioctl (on NetBSD 1.5.) Donn Cave, donn at u.washington.edu From eferro at inicia.es Fri Feb 16 08:22:57 2001 From: eferro at inicia.es (Eduardo Ferro) Date: Fri, 16 Feb 2001 08:22:57 +0100 Subject: ioctl problem References: <96gva8$nnd$1@diana.bcn.ttd.net> <96h5o8$u8e$1@nntp6.u.washington.edu> Message-ID: <96iiof$3dg$1@diana.bcn.ttd.net> > > Perform the requested operation on file descriptor fd. The operation > is defined by op and is operating system dependent. Typically these > codes can be retrieved from the library module IOCTL. The argument > arg is optional, and defaults to 0; it may be an int or a string. If > arg is given as a string, the return value of ioctl is a string of > that length, containing the resulting value put in the arg buffer by > the operating system. The length of the arg string is not allowed to > exceed 1024 bytes. If the arg given is an integer or if none is > specified, the result value is an integer corresponding to the return > value of the ioctl call in the C code. I' ll try it, i think that data will return at the "arg" argument... at the lib doc it don`t say anything about it... but i forget to check the doc string :) Thanks From adolfo.benin at riskmap.it Thu Feb 15 19:55:33 2001 From: adolfo.benin at riskmap.it (Adolfo Benin) Date: Thu, 15 Feb 2001 19:55:33 +0100 Subject: COM server info In-Reply-To: Message-ID: <5.0.2.1.0.20010215193232.00a63eb0@mail1.cs.interbusiness.it> Hi, I've developed a COM object in Python, then I regitered it as a DCOM on my machine. Every time a client makes a request to the server DCOM, the Python interpreter is launched and the COM is created. But when the client ends, the COM server also ends. So every call to the server creates a new python interpreter instance in memory! Is there a way to keep the COM server alive using always the same COM object instance? I have already performed this task succesfully using CORBA (single servant CORBA object), but I need to expose the server as a COM object too. Have you got any suggestion? Thanks, Adolfo. From aleaxit at yahoo.com Thu Feb 15 23:23:14 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 15 Feb 2001 23:23:14 +0100 Subject: COM server info References: Message-ID: <96hkta0274s@news2.newsguy.com> "Adolfo Benin" wrote in message news:mailman.982263496.7413.python-list at python.org... > Hi, > I've developed a COM object in Python, then I regitered it as a DCOM on my > machine. > Every time a client makes a request to the server DCOM, the Python > interpreter is launched and the COM is created. But when the client ends, > the COM server also ends. > So every call to the server creates a new python interpreter instance in > memory! > > Is there a way to keep the COM server alive using always the same COM > object instance? > I have already performed this task succesfully using CORBA (single servant > CORBA object), but I need to expose the server as a COM object too. > > Have you got any suggestion? There are several approaches. My suggestion is to eschew the 'singleton' design pattern: let however many COM objects the clients wish be created, each with its own natural identity; they can delegate everything to a single 'internal' COM object they in turn create (which can, e.g., RegisterActiveObject itself with ACTIVEOBJECT_STRONG to keep the process alive). Using NT Servers is also good in a similar approach. Alex From sales at buystainlessonline.com Thu Feb 15 21:19:39 2001 From: sales at buystainlessonline.com (sales at buystainlessonline.com) Date: Thu, 15 Feb 2001 15:19:39 -0500 Subject: Great Sites!! Three Rivers Demolition Photos! Message-ID: <0o814w5n6i6y.2i0irr76vk@mackdads.com> Visit www.Buyscraponline.com for a detailed pitorial of last sundays explosion. Also, if you purchase or distribute Stainless Steel and other Nickel Alloys, you should visit www.buystainlessonline.com We also build and host web sites. We are very competitive. Click Here to be REMOVED FROM THIS MAILING LIST! http://www.buyscraponline.com/bluemelon/maillist.php -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjg at exceptionalminds.com Thu Feb 15 21:30:08 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Thu, 15 Feb 2001 12:30:08 -0800 Subject: vim and python Message-ID: <20010215123008.A9349@trufflehunter.avalongroup.net> Since this is more python related than vim related I'll post it here. I have recently had contact with a vim missionary (came to my door one Saturday morning and started telling me that I needed to be saved from emacs). Since I had been feeling a bit frustrated with emacs, and since I do suffer from tendonitis in one of my wrists, I thought I'd give it a shot. Surprisingly, I quite like it, and it is certainly easier on my bad wrist. I've been muddling through for a couple of days now, and discovered that there is quite nice builtin python support. I played with it and got it sort of working, but have run into what look like environmental problems. I start vim from the directory where my source files are located, and attempt to do a :pyf %, and I started getting import errors. Not a problem, I simply added my source directory to the end of sys.path and tried again. Now the import works correctly, but I am getting more errors and I can't explain them. Traceback (innermost last): File "", line 1, in ? File "wlautoconf.py", line 20, in ? class acOptions(wlOptions): NameError: wlOptions Press RETURN or enter command to continue wlOptions is a class that is imported from a file in my source directory. So, does anyone have any tips on setting up a nice python/vim environment? 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: 30 days 1 hours ago<< From kdahlhaus at yahoo.com Sun Feb 18 17:17:48 2001 From: kdahlhaus at yahoo.com (Kevin Dahlhausen) Date: Sun, 18 Feb 2001 16:17:48 GMT Subject: vim and python References: Message-ID: 'Pyf' is attempting to source the file using the embedded Python interpreter in Vim. I don't know offhand if it contains different import hooks or if it plays with the PYTHONPATH. I think of it as more for scripting Vim with Python that debugging Python code, although in theory what you're doing should work fine. The first thing to try is running that python file from outside of Vim and see what happens. There was a short series of articles on Python / Vim here a few weeks ago. When google puts the archives back up, you might check for 'Vim and Python Efficiently' By the way, I commend your choice of editor and language! :) In article , "Timothy Grant" wrote: > Since this is more python related than vim related I'll post it here. I > have recently had contact with a vim missionary (came to my door one > Saturday morning and started telling me that I needed to be saved from > emacs). > > Since I had been feeling a bit frustrated with emacs, and since I do > suffer from tendonitis in one of my wrists, I thought I'd give it a > shot. Surprisingly, I quite like it, and it is certainly easier on my > bad wrist. > > I've been muddling through for a couple of days now, and discovered that > there is quite nice builtin python support. I played with it and got it > sort of working, but have run into what look like environmental > problems. > > I start vim from the directory where my source files are located, and > attempt to do a :pyf %, and I started getting import errors. Not a > problem, I simply added my source directory to the end of sys.path and > tried again. Now the import works correctly, but I am getting more > errors and I can't explain them. > > Traceback (innermost last): > File "", line 1, in ? File "wlautoconf.py", line 20, in ? > class acOptions(wlOptions): > NameError: wlOptions Press RETURN or enter command to continue > > wlOptions is a class that is imported from a file in my source > directory. > > So, does anyone have any tips on setting up a nice python/vim > environment? > > Thanks. > From tjg at exceptionalminds.com Sun Feb 18 22:45:17 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Sun, 18 Feb 2001 13:45:17 -0800 Subject: vim and python In-Reply-To: ; from kdahlhaus@yahoo.com on Sun, Feb 18, 2001 at 04:17:48PM +0000 References: Message-ID: <20010218134517.E862@trufflehunter.avalongroup.net> On Sun, Feb 18, 2001 at 04:17:48PM +0000, Kevin Dahlhausen wrote: > 'Pyf' is attempting to source the file using the embedded Python > interpreter in Vim. I don't know offhand if it contains different import > hooks or if it plays with the PYTHONPATH. I think of it as more for > scripting Vim with Python that debugging Python code, although in theory > what you're doing should work fine. The first thing to try is running > that python file from outside of Vim and see what happens. > It works fine outside Vim, hence the consternation. > There was a short series of articles on Python / Vim here a few weeks > ago. When google puts the archives back up, you might check for 'Vim and > Python Efficiently' > If it was just a few weeks ago, I probably have it archived somewhere, I'll go digging. > > By the way, I commend your choice of editor and language! :) > Thanks, it is definitely improving the the tendonitis problem, but productivity has been slipping while I learn the new mode of operation. -- 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: 33 days 1:54 hours ago<< From mertz at gnosis.cx Thu Feb 15 21:33:58 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Thu, 15 Feb 2001 15:33:58 -0500 Subject: Detecting RegEx across Python versions Message-ID: <20Dj6kKkXsbG092yn@bellatlantic.net> I have a module that wishes to match files by either "glob" [fnmatch] or regex. In a certain function, I hope to just check a variable ('pattern') to see if it is a string or a compiled regex, and match accordingly. Unfortunately, Python 2 seems to handle this matter differently than Python 1.5.2 (in a way that does not seem necessary for the improved sre engine). I have done the following, but would welcome something more elegant [...] # kludge to detect a regular expression across python versions elif sys.version[0]=='1' and isinstance(pattern, re.RegexObject): if pattern.match(name): files.append(fname) elif sys.version[0]=='2' and type(pattern)==type(re.compile('')): if pattern.match(name): files.append(fname) elif type(pattern) is StringType: if fnmatch.fnmatch(name, pattern): files.append(fname) Yours, Lulu... -- ---[ to our friends at TLAs (spread the word) ]-------------------------- Echelon North Korea Nazi cracking spy smuggle Columbia fissionable Stego White Water strategic Clinton Delta Force militia TEMPEST Libya Mossad ---[ Postmodern Enterprises ]-------------------------- From fredrik at pythonware.com Fri Feb 16 11:00:54 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 16 Feb 2001 10:00:54 GMT Subject: Detecting RegEx across Python versions References: Message-ID: > I have done the following, but would welcome something more > elegant > > [...] > # kludge to detect a regular expression across python versions > elif sys.version[0]=='1' and isinstance(pattern, re.RegexObject): > if pattern.match(name): > files.append(fname) > elif sys.version[0]=='2' and type(pattern)==type(re.compile('')): > if pattern.match(name): > files.append(fname) > elif type(pattern) is StringType: > if fnmatch.fnmatch(name, pattern): > files.append(fname) if isinstance(pattern, type("")): if fnmatch.fnmatch(name, pattern): files.append(fname) else: if pattern.match(name): files.append(fname) or: try: if pattern.match(name): files.append(fname) except AttributeError: if fnmatch.fnmatch(name, pattern): files.append(fname) or: if isinstance(pattern, type("")): pattern = re.compile(fnmatch.translate(pattern)) ... if pattern.match(name): ... (insert os.path.normcase where necessary) Cheers /F From whisper at oz.net Thu Feb 15 22:26:36 2001 From: whisper at oz.net (Dave LeBlanc) Date: 15 Feb 2001 21:26:36 GMT Subject: ZELP! I can't Zope!! Message-ID: <96hhic$cqn$0@216.39.170.247> I'll bet there's some nifty zope forum where I can get help and i'll be jiggered if I can figure out which of the zope mailing lists are appropriate for newbie zope help/questions. I figured there would be some zopers (zopeheads?) lurking around c.l.p and figured i'd see if I could get a little info on the following problem: My most immediate problem is that I can't get the zope tutorial to install by following the directions given for doing so. After following the instructions to go to the "add products page" (which I'm guessing is the "Products" page with the "add product" button on it, when I try to run the tutorial via the help menu (left frame tree menu), I still get "Can't find tutorial examples - please install tutorial before continuing". Perhaps I didn't enter the correct "ID" when doing the "add product" bit, but there is no information about what an ID is nor if there is a specific value that needs to be entered for it. (Note to Zope central: your documentation could be clearer here guys.) This is Zope 2.3.0 "binary windows install" with Python 1.5.2 on an NT 4.0sp6 box. TIA for any help! Dave LeBlanc From rerla at channing.harvard.edu Fri Feb 16 20:32:20 2001 From: rerla at channing.harvard.edu (Ross Lazarus) Date: Fri, 16 Feb 2001 14:32:20 -0500 Subject: ZELP! I can't Zope!! References: <96hhic$cqn$0@216.39.170.247> Message-ID: <3A8D8044.2C2342ED@channing.harvard.edu> It's been so long that I can't remember exactly what you need to do to get the tutorial working, but I know that there are lots of places to look. Start at http://www.zope.org of course. There's a site search which might be useful. Not to mention the zope book at http://www.zope.org/Members/michel/ZB/ I read the zope lists at egroups.com, but they're also archived at the zope site above. zope at zope.org is the place to send questions like this. There's also zope-dev at zope.org for developer type questions. Good luck Dave LeBlanc wrote: > > I'll bet there's some nifty zope forum where I can get help and i'll > be jiggered if I can figure out which of the zope mailing lists are > appropriate for newbie zope help/questions. I figured there would be > some zopers (zopeheads?) lurking around c.l.p and figured i'd see if I > could get a little info on the following problem: From schnoerr at mailzone.com Thu Feb 15 22:40:58 2001 From: schnoerr at mailzone.com (Claudius =?iso-8859-1?Q?Schn=F6rr?=) Date: Thu, 15 Feb 2001 22:40:58 +0100 Subject: Q: Can methods and functions be overloaded? Message-ID: <3A8C4CEA.B418B56E@mailzone.com> Hello, I would appreciate to write methods for different counts of arguments, say f(self, a) and f( self, b, c, d ) or so where b and a have to be handled differently. Is this possible? I think no because the second definition of f overwrites the first one. Any hints are welcome. Please email a copy of your answer directly to Claudius.Schnoerr at ddg.de Thank you in advance, Claudius -- ---------------------------------------------------------------- Dr.-Ing. Claudius Schn"orr Tel: ++49-(0)211-5591570 Sigmaringenstr. 2 Fax: ++49-(0)89-2443-45595 40547 D"usseldorf / Germany e-mail: schnoerr at mailzone.com ---------------------------------------------------------------- From cfelling at iae.nl Fri Feb 16 01:59:30 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 16 Feb 2001 01:59:30 +0100 Subject: Q: Can methods and functions be overloaded? References: <3A8C4CEA.B418B56E@mailzone.com> Message-ID: <96hu1i$cr4$1@animus.fel.iae.nl> Claudius Schn?rr wrote: > Hello, > I would appreciate to write methods for different counts of > arguments, say > f(self, a) and f( self, b, c, d ) or so where b and a have to be handled > differently. > Is this possible? I think no because the second definition of f > overwrites the first one. Head on:) but head up, Python is very flexible, so build your own overloader class Overloaded: __overload = {} def f(self, *args): apply(self.__overload[len(args)], (self,) + args) def f1(self, a): print a __overload[1] = f1 def f2(self, a, b): print a, 'and', b __overload[2] = f2 u = Overloaded() u.f('spam') u.f('spam', 'spam') -- groetjes, carel From sholden at holdenweb.com Fri Feb 16 02:38:59 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 15 Feb 2001 20:38:59 -0500 Subject: Can methods and functions be overloaded? References: <3A8C4CEA.B418B56E@mailzone.com> Message-ID: "Claudius Schn?rr" wrote in message news:3A8C4CEA.B418B56E at mailzone.com... > Hello, > > I would appreciate to write methods for different counts of > arguments, say > f(self, a) and f( self, b, c, d ) or so where b and a have to be handled > differently. > > Is this possible? I think no because the second definition of f > overwrites the first one. > > Any hints are welcome. > Please email a copy of your answer directly to > Claudius.Schnoerr at ddg.de > > Thank you in advance, > > Claudius > Well, you can use a notation which passes all positional arguments in a list. Without testing, something like: def meth1(self, *args): if len(args) == 1: # code one-argument case else: # code more-than-one-argument case Another option might be to provide keyword default arguments for the additional arguments, as in: def meth2(self, a, b=None, c=None): if b == c == None: # code one-argument case else: # code more-than-one-argument case Does this help, or did you alredy know about it? I'm afraid Python doesn't allow the same kind of method overloading by signature that, say, Java and C++ do. regards Steve From cfelling at iae.nl Fri Feb 16 16:24:36 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 16 Feb 2001 16:24:36 +0100 Subject: Can methods and functions be overloaded? References: <3A8C4CEA.B418B56E@mailzone.com> Message-ID: <96jgnk$33i$1@animus.fel.iae.nl> Steve Holden wrote: ... > Does this help, or did you alredy know about it? I'm afraid Python doesn't > allow the same kind of method overloading by signature that, say, Java and > C++ do. Right, but you can build your own:) class Overload: def __init__(self): self.fun = {} def __call__(self, *args): try: fun = self.fun[self.signature(*args)] except KeyError: raise TypeError, "invalid overloading signature" return fun(*args) def signature(self, *args): '''smart up if you need to play with class hierarchies''' return tuple([type(x) for x in args]) def overload(self, fun, *args): self.fun[self.signature(*args)] = fun class Overloaded: def __init__(self): f = self.f = Overload() f.overload(self.f_None) f.overload(self.f_num, 1) f.overload(self.f_num, 1.0) f.overload(self.f_string, "1") f.overload(self.f_more, 'spam', 1) def f_None(self): return None def f_num(self, n): return n * 3 def f_string(self, s): return 'string is %s' % s def f_more(self, s, n): return s * n o = Overloaded() print o.f() print o.f(10) print o.f(5.4) print o.f("spam", 9) print o.f(9, "spam") this yields: None 30 16.2 spamspamspamspamspamspamspamspamspam Traceback (most recent call last): File "t.py", line 48, in ? print o.f(9, "spam") File "t.py", line 9, in __call__ raise TypeError, "invalid overloading signature" TypeError: invalid overloading signature -- groetjes, carel From info at black-karma.de Thu Feb 15 22:42:52 2001 From: info at black-karma.de (Harvest T. Moon) Date: Thu, 15 Feb 2001 22:42:52 +0100 Subject: [newbie] easy tutorial on multithreading? Message-ID: <96hifo$lq0fh$1@ID-22517.news.dfncis.de> i'm looking for a rather simple instruction to multi-threading with python, i.e. starting a function as seperate thread etc. thnx i.a. Harvest T. Moon -- a life less ordinary!! From aahz at panix.com Fri Feb 16 00:02:18 2001 From: aahz at panix.com (Aahz Maruch) Date: 15 Feb 2001 15:02:18 -0800 Subject: [newbie] easy tutorial on multithreading? References: <96hifo$lq0fh$1@ID-22517.news.dfncis.de> Message-ID: <96hn5q$do0$1@panix6.panix.com> In article <96hifo$lq0fh$1 at ID-22517.news.dfncis.de>, Harvest T. Moon wrote: > >i'm looking for a rather simple instruction to multi-threading with python, >i.e. starting a function as seperate thread etc. This is rather sketchy, but take a look at http://starship.python.net/crew/aahz There'll be something better up in a couple of weeks (my slides for IPC9). -- --- 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 Why doesn't "Just Say NO" include caffeine, nicotine, alcohol, Prozac, and Ritalin? --Aahz From grisha at verio.net Thu Feb 15 22:55:03 2001 From: grisha at verio.net (Gregory (Grisha) Trubetskoy) Date: Thu, 15 Feb 2001 16:55:03 -0500 Subject: += as declaration wish Message-ID: Am I missing something obvious when I think that it'd be nice if you could do: x += 3 and if x didn't exist, += would simply act like = rather than raise an exception. Grisha From jafo at tummy.com Thu Feb 15 23:54:49 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Thu, 15 Feb 2001 15:54:49 -0700 Subject: += as declaration wish In-Reply-To: ; from grisha@verio.net on Thu, Feb 15, 2001 at 04:55:03PM -0500 References: Message-ID: <20010215155449.E23577@tummy.com> On Thu, Feb 15, 2001 at 04:55:03PM -0500, Gregory (Grisha) Trubetskoy wrote: >Am I missing something obvious when I think that it'd be nice if you could >do: > >x += 3 What does x default to if it doesn't exist? None? 0? ""? If it worked, I'd still explicitly set the LHS first anyway, I'm fairly sure. Sean -- Linux: When you need to run like a greased weasel. -- Sean Reifschneider, 1998 Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From max at alcyone.com Fri Feb 16 03:46:58 2001 From: max at alcyone.com (Erik Max Francis) Date: Thu, 15 Feb 2001 18:46:58 -0800 Subject: += as declaration wish References: Message-ID: <3A8C94A2.438AAA3E@alcyone.com> "Gregory (Grisha) Trubetskoy" wrote: > Am I missing something obvious when I think that it'd be nice if you > could > do: > > x += 3 > > and if x didn't exist, += would simply act like = rather than raise an > exception. Avoiding such magic like this is what makes Python a well-designed language. If you want x to default to something, you can set it to that yourself before you start using +=. (Besides, what should it default to for ints? strings? lists? user-defined types?) -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Love is the most subtle form of self-interest. \__/ Holbrook Jackson Polly Wanna Cracka? / http://www.pollywannacracka.com/ The Internet resource for interracial relationships. From tim.one at home.com Fri Feb 16 04:39:57 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 15 Feb 2001 22:39:57 -0500 Subject: += as declaration wish In-Reply-To: <3A8C94A2.438AAA3E@alcyone.com> Message-ID: [Gregory (Grisha) Trubetskoy] > Am I missing something obvious when I think that it'd be nice if you > could do: > > x += 3 > > and if x didn't exist, += would simply act like = rather than raise an > exception. Only that it's semantically confused, so Guido will never buy it. [Erik Max Francis] > Avoiding such magic like this is what makes Python a well-designed > language. If you want x to default to something, you can set it to that > yourself before you start using +=. (Besides, what should it default to > for ints? strings? lists? user-defined types?) That's not a problem. Gregory didn't ask for a default: he wants LHS op= RHS to act like try: LHS except NameError: LHS = RHS else: LHS op= RHS No defaults are involved. So it's not an intractable idea. By analogy, we could also make f(x) act like try: x except NameError: f() else: f(x) and so on and so on. Then x += f(y, z) gets *really* cute . if-a-thing's-a-rotten-idea-in-the-large-it's-probably-not-a-great- idea-in-the-small-ly y'rs - tim From bbollenbach at homenospam.com Fri Feb 16 05:21:48 2001 From: bbollenbach at homenospam.com (Brad Bollenbach) Date: Fri, 16 Feb 2001 04:21:48 GMT Subject: += as declaration wish References: Message-ID: The reason this isn't, and shouldn't be allowed is simple. From the Python Documentation: "An augmented assignment evaluates the target (which, unlike normal assignment statements, cannot be an unpacking) and the expression list, performs the binary operation specific to the type of assignment on the two operands, and assigns the result to the original target." In other words, when you do x += 1, it will evaluate x, and perform (x + 1) before assigning back to x, which is an error in Python if x doesn't exist. I'm curious: in what situations does this do more to help the look of your code than not? "Working around" this should never cause any problems. "Gregory (Grisha) Trubetskoy" wrote in message news:Pine.BSF.4.32.0102151652290.71736-100000 at localhost... > > Am I missing something obvious when I think that it'd be nice if you could > do: > > x += 3 > > and if x didn't exist, += would simply act like = rather than raise an > exception. > > Grisha > From ssthapa at barnacle-bill.cs.uchicago.edu Fri Feb 16 19:49:19 2001 From: ssthapa at barnacle-bill.cs.uchicago.edu (Suchandra S Thapa) Date: Fri, 16 Feb 2001 18:49:19 GMT Subject: += as declaration wish References: Message-ID: I agree with you. I think having x += y create a new x would create more problems than it solves. Currently typos in the variable name would raise an error that is easily caught and fixed, having a new variable silently created just seems like a bad idea. I personally would love it if python went the other way and allowed an optional mode that required variables to be declared before they were used. From Jerry.Spicklemire at IFLYATA.COM Thu Feb 15 23:09:20 2001 From: Jerry.Spicklemire at IFLYATA.COM (Spicklemire, Jerry) Date: Thu, 15 Feb 2001 17:09:20 -0500 Subject: Upgrade? Why not? Message-ID: <977A39E65CFCD3119ABF00D0B741D849E0FEF2@innt-73.ata.com> Mark Hudson asked? "Have you upgraded to Python 2.0?" no (he stammered in mortification) "If not, why not?" Because I'm not a sysadmin, just a lowly coder. It was hard enough to get Python installed and compiled in the first place. Even though I do stand up and hollar for a Zope upgrade when it seems absolutely essential, if Python 1.5.2 is good enough for the standard Zope distribution, then as far as I can tell, "it ain't broke." With that out of the way, let me assure all that from my perspective the new developments sound fabulous, wonderful, and seemingly have the unimaginable effect of making Python even more perfect. I was never very good at math or physics, so I just tuck these little mysteries into the same corner as time slowing to a crawl at the center of a black hole. Even though I can't imagine how it's possible, it is such a kick to watch it happen. Have you folks ever thought of doing a time-lapse photo thingy on the Python development process? Later, Jerry S. From jafo-pythonlist at tummy.com Thu Feb 15 23:52:37 2001 From: jafo-pythonlist at tummy.com (Sean Reifschneider) Date: Thu, 15 Feb 2001 15:52:37 -0700 Subject: Upgrade? Why not? In-Reply-To: <977A39E65CFCD3119ABF00D0B741D849E0FEF2@innt-73.ata.com>; from Jerry.Spicklemire@IFLYATA.COM on Thu, Feb 15, 2001 at 05:09:20PM -0500 References: <977A39E65CFCD3119ABF00D0B741D849E0FEF2@innt-73.ata.com> Message-ID: <20010215155237.D23577@tummy.com> On Thu, Feb 15, 2001 at 05:09:20PM -0500, Spicklemire, Jerry wrote: >"If not, why not?" I write code that runs not only on my box, but on many of the tummy.com boxes, the machines at our co-location facility, and our client's machines. If I take advantage of things in 2.0 it requires me upgrading probably at least half of those machines. There's nothing I really *NEED*. About the only thing I really may want is SSL sockets for my network backup system, and I can make that just bypass the appropriate code when running on a platform without. So, I'll just keep happily using 1.5.2 and wait until 2.0 is more prevalent before I start using it. My laptop? Yeah, it has 1.5.2, 2.0 and 2.1a2 installed... Mostly for my Python presentations... Sean -- Money is the root of all evil! Man needs roots... Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From stephen_purcell at yahoo.com Fri Feb 16 09:35:38 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Fri, 16 Feb 2001 09:35:38 +0100 Subject: Upgrade? Not for some time... In-Reply-To: <977A39E65CFCD3119ABF00D0B741D849E0FEF2@innt-73.ata.com>; from Jerry.Spicklemire@IFLYATA.COM on Thu, Feb 15, 2001 at 05:09:20PM -0500 References: <977A39E65CFCD3119ABF00D0B741D849E0FEF2@innt-73.ata.com> Message-ID: <20010216093538.E7411@freedom.puma-ag.com> Spicklemire, Jerry wrote: > Mark Hudson asked? > "Have you upgraded to Python 2.0?" I'm still using 1.5.2, with no plans to upgrade. My reasons: 1. Python 1.5.2 and all its juicy C extensions (PIL, PyGreSQL etc) are officially supported with binary packages on Linux and elsewhere. Python 2.0 will probably not make its way into the core of any big Linux distros for quite a few months. No source installs of Python + extensions for me. 2. Until I feel like only cavemen are still using 1.5.2, I'll avoid using 2.0 in case I end up writing funky code with list comprehensions that nobody can use. 3. With the current rate of releases and core python development, I'll save the effort of upgrading until 2.1 (or whatever) becomes the '1.5.2' of the future! Makes me think of Java's JDK 1.3 -- why bother? I haven't needed most of JDK 1.2 yet, and at least *everyone* has that version. For that matter, some people are still starting new projects using JDK 1.1, and Java 1.0 is the only serious choice for applets. I hope Python doesn't go the same way. -Caveman 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 tanzer at slinky.cs.nyu.edu Tue Feb 20 22:40:43 2001 From: tanzer at slinky.cs.nyu.edu (David Tanzer) Date: 20 Feb 2001 16:40:43 -0500 Subject: Upgrade? Not for some time... References: <977A39E65CFCD3119ABF00D0B741D849E0FEF2@innt-73.ata.com> Message-ID: <0mwvaldodg.fsf@slinky.cs.nyu.edu> Steve Purcell writes: > Spicklemire, Jerry wrote: > 2. Until I feel like only cavemen are still using 1.5.2, I'll avoid using > 2.0 in case I end up writing funky code with list comprehensions that > nobody can use. > I myself plan to put the list comprehensions to good use. From dan at eevolved.com Fri Feb 16 00:10:51 2001 From: dan at eevolved.com (Dan Parisien) Date: Thu, 15 Feb 2001 23:10:51 GMT Subject: segfault. which module to blame? Message-ID: <%lZi6.127299$Pm2.2356545@news20.bellglobal.com> I am using shelve and a lot of threads to write to a dbm db. I implemented my own row-level locking with dictionaries and counters and when I run a test script that simulates extreme conditions (1500 threads, 10 writes each) it segfaults 1/100 times it runs. That kinda sucks, don't you think? I'm wondering if someone who has experience could point me to which module is at fault: threading? or shelve+dbm? or neither? :) Or maybe some technique on how to crawl through the core file (I'm on mandrake gnu/linux 7.2 python 2.0.1) I'm not expecting a correct answer, just a point in the right directions Thank you :) Dan From dsh8290 at rit.edu Fri Feb 16 02:01:54 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 15 Feb 2001 20:01:54 -0500 Subject: segfault. which module to blame? In-Reply-To: <%lZi6.127299$Pm2.2356545@news20.bellglobal.com>; from dan@eevolved.com on Thu, Feb 15, 2001 at 11:10:51PM +0000 References: <%lZi6.127299$Pm2.2356545@news20.bellglobal.com> Message-ID: <20010215200154.C2150@harmony.cs.rit.edu> $ gdb `which python` core gdb> backtrace Basically gdb will load the executable's symbols (assuming it has some) and the core file. It will warn you if the exe has no symbols, or if the core came from a different exe. Backtrace will give you a trace similar to when a python exception isn't caught (except it is for C, and thus much lower level detail). DDD (from gnu.org) is a nice (except that is uses motif) gui frontend for gdb that will make browsing symbols, etc much easier (and you won't need to learn yet another command line, yet). HTH, -D On Thu, Feb 15, 2001 at 11:10:51PM +0000, Dan Parisien wrote: | I am using shelve and a lot of threads to write to a dbm db. I implemented | my own row-level locking with dictionaries and counters and when I run a | test script that simulates extreme conditions (1500 threads, 10 writes | each) it segfaults 1/100 times it runs. | | That kinda sucks, don't you think? I'm wondering if someone who has | experience could point me to which module is at fault: threading? or | shelve+dbm? or neither? :) Or maybe some technique on how to crawl through | the core file (I'm on mandrake gnu/linux 7.2 python 2.0.1) | | I'm not expecting a correct answer, just a point in the right directions | | Thank you :) | Dan | From dan at eevolved.com Fri Feb 16 02:55:23 2001 From: dan at eevolved.com (Dan Parisien) Date: Fri, 16 Feb 2001 01:55:23 GMT Subject: segfault. which module to blame? (entire traceback) References: <%lZi6.127299$Pm2.2356545@news20.bellglobal.com> Message-ID: D-Man wrote: > > $ gdb `which python` core > > gdb> backtrace > Cool. It seems to crash in the garbage collecting routines. Maybe someone with more experience than me can help. Since I do a lot of shelve stuff (no threads in this test) there that explains cPickle. Anyways, maybe this is a known bug... Here's the entire traceback. #0 0x809139d in visit_decref (op=0x869bd94, data=0x0) at ./gcmodule.c:153 #1 0x807ed67 in dict_traverse (op=0x86da2c4, visit=0x8091390 , arg=0x0) at dictobject.c:1146 #2 0x80913d6 in subtract_refs (containers=0x80c7818) at ./gcmodule.c:167 #3 0x80917f7 in collect (young=0x80c7818, old=0x80c7818) at ./gcmodule.c:379 #4 0x80919e7 in collect_generations () at ./gcmodule.c:467 #5 0x8091acd in _PyGC_Insert (op=0x86e7dcc) at ./gcmodule.c:507 #6 0x8085537 in PyTuple_New (size=2) at tupleobject.c:87 #7 0x40182da7 in put2 (self=0x86da700, ob=0x82381a0) at ./cPickle.c:724 #8 0x40182d0a in put (self=0x86da700, ob=0x82381a0) at ./cPickle.c:699 #9 0x40183947 in save_string (self=0x86da700, args=0x82381a0, doput=1) at ./cPickle.c:1141 #10 0x40184c0b in save (self=0x86da700, args=0x82381a0, pers_save=0) at ./cPickle.c:1786 #11 0x40183fcf in save_dict (self=0x86da700, args=0x816e32c) at ./cPickle.c:1402 #12 0x40184c91 in save (self=0x86da700, args=0x816e32c, pers_save=0) at ./cPickle.c:1814 #13 0x40185015 in dump (self=0x86da700, args=0x816e32c) at ./cPickle.c:1930 #14 0x40185425 in Pickler_dump (self=0x86da700, args=0x810f52c) at ./cPickle.c:2093 #15 0x805835e in call_builtin (func=0x8131cf8, arg=0x810f52c, kw=0x0) at ceval.c:2650 #16 0x805826b in PyEval_CallObjectWithKeywords (func=0x8131cf8, arg=0x810f52c, kw=0x0) at ceval.c:2618 #17 0x8057294 in eval_code2 (co=0x810ecd8, globals=0x8110254, locals=0x0, args=0x813d7a0, argcount=3, kws=0x0, kwcount=0, defs=0x0, defcount=0, owner=0x811f5ac) at ceval.c:1951 #18 0x80586be in call_function (func=0x81185a4, arg=0x86c1aec, kw=0x0) at ceval.c:2772 #19 0x805825d in PyEval_CallObjectWithKeywords (func=0x813aa34, arg=0x86c1aec, kw=0x0) at ceval.c:2616 #20 0x807286e in instance_ass_subscript (inst=0x812042c, key=0x814f108, value=0x816e32c) at classobject.c:925 #21 0x806da29 in PyObject_SetItem (o=0x812042c, key=0x814f108, value=0x816e32c) at abstract.c:117 #22 0x8055ead in eval_code2 (co=0x810aea0, globals=0x810b02c, locals=0x0, args=0x8109da8, argcount=1, kws=0x8109dac, kwcount=0, defs=0x0, defcount=0, owner=0x811df74) at ceval.c:1208 #23 0x8056fa5 in eval_code2 (co=0x810b1c8, globals=0x810b02c, locals=0x0, args=0x811d2b0, argcount=3, kws=0x0, kwcount=0, defs=0x0, defcount=0, owner=0x811df74) at ceval.c:1850 #24 0x80586be in call_function (func=0x810f6d4, arg=0x86b5fbc, kw=0x0) at ceval.c:2772 #25 0x805825d in PyEval_CallObjectWithKeywords (func=0x80d067c, arg=0x86b5fbc, kw=0x0) ---Type to continue, or q to quit--- at ceval.c:2616 #26 0x807286e in instance_ass_subscript (inst=0x813d35c, key=0x86e9f20, value=0x814ee84) at classobject.c:925 #27 0x806da29 in PyObject_SetItem (o=0x813d35c, key=0x86e9f20, value=0x814ee84) at abstract.c:117 #28 0x8055ead in eval_code2 (co=0x810cb90, globals=0x810b02c, locals=0x0, args=0x80dda5c, argcount=3, kws=0x80dda68, kwcount=0, defs=0x0, defcount=0, owner=0x813bf5c) at ceval.c:1208 #29 0x8056fa5 in eval_code2 (co=0x810c0e8, globals=0x80d284c, locals=0x80d284c, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, owner=0x0) at ceval.c:1850 #30 0x8054c14 in PyEval_EvalCode (co=0x810c0e8, globals=0x80d284c, locals=0x80d284c) at ceval.c:319 #31 0x8068a21 in run_node (n=0x80db910, filename=0xbffff9d5 "huge.py", globals=0x80d284c, locals=0x80d284c) at pythonrun.c:886 #32 0x80689d3 in run_err_node (n=0x80db910, filename=0xbffff9d5 "huge.py", globals=0x80d284c, locals=0x80d284c) at pythonrun.c:874 #33 0x80689a7 in PyRun_FileEx (fp=0x80ce828, filename=0xbffff9d5 "huge.py", start=257, globals=0x80d284c, locals=0x80d284c, closeit=1) at pythonrun.c:866 #34 0x8067fd4 in PyRun_SimpleFileEx (fp=0x80ce828, filename=0xbffff9d5 "huge.py", closeit=1) at pythonrun.c:579 #35 0x8067bdf in PyRun_AnyFileEx (fp=0x80ce828, filename=0xbffff9d5 "huge.py", closeit=1) at pythonrun.c:459 #36 0x8051b3d in Py_Main (argc=2, argv=0xbffff864) at main.c:289 #37 0x80515fa in main (argc=2, argv=0xbffff864) at python.c:10 #38 0x400b1cbe in __libc_start_main () from /lib/libc.so.6 From jeremy at alum.mit.edu Fri Feb 16 02:13:10 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Thu, 15 Feb 2001 20:13:10 -0500 (EST) Subject: segfault. which module to blame? (entire traceback) In-Reply-To: References: <%lZi6.127299$Pm2.2356545@news20.bellglobal.com> Message-ID: <14988.32422.118120.352796@w221.z064000254.bwi-md.dsl.cnc.net> Are there any C extensions being used with this process? My first guess would be bad reference counting in a third-party extension. Just in case that guess is wrong, what are you pickling? Jeremy From dan at eevolved.com Fri Feb 16 18:21:30 2001 From: dan at eevolved.com (Dan Parisien) Date: Fri, 16 Feb 2001 17:21:30 GMT Subject: segfault. which module to blame? (entire traceback) References: <%lZi6.127299$Pm2.2356545@news20.bellglobal.com> Message-ID: Jeremy Hylton wrote: > Are there any C extensions being used with this process? My first > guess would be bad reference counting in a third-party extension. > Just in case that guess is wrong, what are you pickling? > > Jeremy > Unfortunately everything I use came with BeOpen Python 2.0.1's rpm on python.org. I write normal python dictionaries and strings to a shelve db. I also use locks (threading.Lock) to implement row-level locking in shelve. I've had segfaults before while coding normal python scripts. I think it was the dictionaries because that's pretty much all I used. Could it be bad reference counting in those? I would have to read the code, but could there be a problem if two keys hashed to the same value in the dictionary and that one is deleted before the other or something similar? thanks Jeremy, Dan From dsh8290 at rit.edu Fri Feb 16 19:43:34 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 16 Feb 2001 13:43:34 -0500 Subject: segfault. which module to blame? (entire traceback) In-Reply-To: ; from dan@eevolved.com on Fri, Feb 16, 2001 at 05:21:30PM +0000 References: <%lZi6.127299$Pm2.2356545@news20.bellglobal.com> Message-ID: <20010216134334.B3862@harmony.cs.rit.edu> On Fri, Feb 16, 2001 at 05:21:30PM +0000, Dan Parisien wrote: [snip] | segfaults before while coding normal python scripts. I think it was the | dictionaries because that's pretty much all I used. Could it be bad | reference counting in those? I would have to read the code, but could there | be a problem if two keys hashed to the same value in the dictionary and | that one is deleted before the other or something similar? I'll find out by making a class that always hashes to the same value : class Hashable : ... def __hash__( self ) : ... return 5 ... >>> h1 = Hashable() >>> h2 = Hashable() >>> id( h1 ) 8185684 >>> id( h2 ) 8182548 >>> d = { } >>> d[ h1 ] = 1 >>> d[ h2 ] = 2 >>> print d {<__main__.Hashable instance at 007CE754>: 1, <__main__.Hashable instance at 007CDB14>: 2} >>> >>> del d[ h1 ] >>> print d {<__main__.Hashable instance at 007CDB14>: 2} >>> del d[ h2 ] >>> It didn't crash for me (Win2k, Python 2.0) when I had 2 keys with the same hash value. -D From tim.one at home.com Fri Feb 16 20:31:27 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 16 Feb 2001 14:31:27 -0500 Subject: segfault. which module to blame? (entire traceback) In-Reply-To: Message-ID: [Dan Parisien] > I write normal python dictionaries and strings to a shelve db. I also use > locks (threading.Lock) to implement row-level locking in shelve. I've had > segfaults before while coding normal python scripts. That's a bug, then. Did you report it? I don't see segfaults while coding normal Python scripts, so don't expect it to get fixed by magic. There don't appear to be any relevant bug reports from others open on SourceForge either. > I think it was the dictionaries because that's pretty much all I used. > Could it be bad reference counting in those? I would have to read the > code, but could there be a problem if two keys hashed to the same value > in the dictionary and that one is deleted before the other or something > similar? While it's not impossible that dicts are screwing up, it's extremely unlikely, because the dict code is very heavily used (don't forget that Python uses dicts under the covers to manage your namespaces and sys.modules and ... there is no Python program-- not even the one-liner "pass" --that doesn't use dicts!). So if dicts had refcount problems, it's almost certain we'd be deluged with bug reports. Because of the Birthday Paradox, collisions aren't rare, so that code is heavily used too. Try to come up with a minimal failing case, then open a bug on SourceForge. From dan at eevolved.com Fri Feb 16 20:54:13 2001 From: dan at eevolved.com (Dan Parisien) Date: Fri, 16 Feb 2001 19:54:13 GMT Subject: segfault. which module to blame? (entire traceback) References: <%lZi6.127299$Pm2.2356545@news20.bellglobal.com> Message-ID: D-Man wrote: > On Fri, Feb 16, 2001 at 05:21:30PM +0000, Dan Parisien wrote: > [snip] > | segfaults before while coding normal python scripts. I think it was the > | dictionaries because that's pretty much all I used. Could it be bad > | reference counting in those? I would have to read the code, but could > | there be a problem if two keys hashed to the same value in the > | dictionary and that one is deleted before the other or something > | similar? > > I'll find out by making a class that always hashes to the same value : > > class Hashable : > ... def __hash__( self ) : > ... return 5 > ... > >>> h1 = Hashable() > >>> h2 = Hashable() > >>> id( h1 ) > 8185684 > >>> id( h2 ) > 8182548 > >>> d = { } > >>> d[ h1 ] = 1 > >>> d[ h2 ] = 2 > >>> print d > {<__main__.Hashable instance at 007CE754>: 1, <__main__.Hashable > instance at 007CDB14>: 2} > >>> > >>> del d[ h1 ] > >>> print d > {<__main__.Hashable instance at 007CDB14>: 2} > >>> del d[ h2 ] > >>> > > > It didn't crash for me (Win2k, Python 2.0) when I had 2 keys with the > same hash value. > > -D I didn't think so :) Just a hypothesis. One that shouldn't have made it out to the newsgroup... Anyways, the two crashes are not related (although they are both segfaults, the similarity ends there) I'm almost certain the problem is with dbm. Dan From boswell at caltech.edu Fri Feb 16 00:47:07 2001 From: boswell at caltech.edu (Dustin Boswell) Date: Thu, 15 Feb 2001 15:47:07 -0800 Subject: how to compile https support into Python2.0 Message-ID: <3A8C6A7B.42C809C4@caltech.edu> I originally posted a question asking how to get Python to support urls like https://secure-server.com so you could use urllib.urlopen() transparently. After a bunch of searching on the web, here's what I did (on Redhat 6.2) to get the Python Distribution to compile correctly with SSL... (If it doesn't work, or there's an easier/better way, please correct me.) OPENSSL This is a package that you need to have installed before you can build the Python source distribution (in the SSL way). 1) go to http://www.openssl.org/source/ and download openssl-0.9.6.tar.gz 2) gunzip openssl-0.9.6.tar.gz 3) tar -xvf openssl-0.9.6.tar (make sure you are in the directory you want to put the source in; this can be in any temporary place, since the build will automatically place it in the right spot later) 4) cd openssl-0.9.6 5) read the INSTALL file and... 6) ./config ; make ; make test ; make install 7) if that didn't work, I can't help you This should have installed files into a /usr/local/ssl directory (along with various others) PYTHON Here's where and how to build a Python interpreter.. 1) Go to http://www.python.org/2.0/#download and download BeOpen-Python-2.0.tar.gz 2) gunzip BeOpen-Python-2.0.tar.gz 3) tar -xvf BeOpen-Python-2.0.tar ( same deal as step 3 above ) 4) goto http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/python/dist/src/?cvsroot=python#dirlist and make sure you have fresh copies of: - Modules/socketmodule.c - Lib/urllib.py - Lib/httplib.py - (possilby others, although I didn't, and haven't (yet) run into problems 5) in Python-2.0/Modules/ do: cp Setup.in Setup 6) emacs (or, gulp, vi if you prefer) Setup 7) uncomment the four lines so that it looks like: # Socket module compiled with SSL support; you must edit the SSL variable: SSL=/usr/local/ssl _socket socketmodule.c \ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -L$(SSL)/lib -lssl -lcrypto 8) in the top directory ( Python-2.0/ ) do ... ./configure ; make ; make test (took a while) ; make install Dustin Boswell boswell at caltech.edu From p.g at figu.no Fri Feb 16 01:04:34 2001 From: p.g at figu.no (Per Gummedal) Date: Fri, 16 Feb 2001 01:04:34 +0100 Subject: [ann]: Python 2.0 for AS/400, beta 3 Message-ID: <194-1908137407.20010216010434@figu.no> A new update. http://home.no.net/pgummeda Changes: - The File400 method, read, has been replaced with the following: readf, readl, readp, readn, readrrn, readeq, readne, readpe Some new methods: posf, posl, posb, posa getRecord now returns a Record400 object. Use _ to access fields in a File or Record. ( print f._CUSNO ) blkrcd=Y is now default when file is opened for reading. Some bugs has been fixed. - New module os400 has the following functions. Program - Returns a Program object. Example of use: pgm = os400.Program('GETPRICE','*LIBL',(('c',10),('d',5,1))) pgm.call('TEST1',0)) price = pgm[1] rtvdtaara - Retrieve data area chgdtaara - Change data area Per From syver at NOSPAMcyberwatcher.com Fri Feb 16 02:00:14 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Fri, 16 Feb 2001 02:00:14 +0100 Subject: Python emacs mode (newbie) Message-ID: <96hu7d$4pq$1@troll.powertech.no> Is there anybody who has any idea on how to implement a module loading function in GNU Emacs like the one Pythonwin has? The basic idea is that instead of writing a file name you write a module name, like ex: httplib or win32com.client.dynamic and the editor will load the specified module. I guess the implementation would work around searching the python path, but I am total newbie in elisp (and lisp itself for that matter) and could use some pointers as to how to search the filesystem from elisp, get the registry keys or environment variables for the pythonpath, and how to load a file into the current window. From crmartin at indra.com Fri Feb 16 02:14:20 2001 From: crmartin at indra.com (Charles R Martin) Date: 15 Feb 2001 18:14:20 -0700 Subject: Python emacs mode (newbie) References: <96hu7d$4pq$1@troll.powertech.no> Message-ID: I don't know Python at all, but what you're describing sounds like require/provide. See C-h f require RET C-h f provide RET "Syver Enstad" writes: > Is there anybody who has any idea on how to implement a module loading > function in GNU Emacs like the one Pythonwin has? > > The basic idea is that instead of writing a file name you write a module > name, like ex: > httplib or win32com.client.dynamic and the editor will load the specified > module. > > I guess the implementation would work around searching the python path, but > I am total newbie in elisp (and lisp itself for that matter) and could use > some pointers as to how to search the filesystem from elisp, get the > registry keys or environment variables for the pythonpath, and how to load a > file into the current window. > > -- Whatever you can do or dream you can do, begin it. Boldness has genius, power and magic in it. Begin it now." --Goethe ------------------------------------------------------------------------------ Charlie Martin, Broomfield, CO USA 40 N 105 W From evgenyr at cs.washington.edu Fri Feb 16 09:18:05 2001 From: evgenyr at cs.washington.edu (Evgeny Roubinchtein) Date: Fri, 16 Feb 2001 08:18:05 GMT Subject: Python emacs mode (newbie) References: <96hu7d$4pq$1@troll.powertech.no> Message-ID: <863ddf59e4.fsf@ruby.localdomain> "Syver Enstad" writes: > Is there anybody who has any idea on how to implement a module loading > function in GNU Emacs like the one Pythonwin has? > > The basic idea is that instead of writing a file name you write a module > name, like ex: > httplib or win32com.client.dynamic and the editor will load the specified > module. How do you want this to work? So you want a function like (my-find-python-module "foo"), and up comes the window containing the window containing the module foo. A slightly different approach would be to require that the user have an inferior python process running, and ask that process to locate the module, then Emacs just loads it... (i.e., Python, rather than Emacs is doing the path searching). If you haven't been exposed to lisp at all, you'll probably want to start with the Emacs lisp introduction, which can be found at: http://www.gnu.org/manual/emacs-lisp-intro/emacs-lisp-intro.html You will then want to use the Emacs Lisp Reference Manual: http://www.gnu.org/manual/elisp-manual-20-2.5/elisp.html Happy hacking! -- Evgeny CPE: Create Parity Error From Kai.Grossjohann at CS.Uni-Dortmund.DE Fri Feb 16 13:12:07 2001 From: Kai.Grossjohann at CS.Uni-Dortmund.DE (Kai =?iso-8859-1?q?Gro=DFjohann?=) Date: 16 Feb 2001 13:12:07 +0100 Subject: Python emacs mode (newbie) References: <96hu7d$4pq$1@troll.powertech.no> Message-ID: On Fri, 16 Feb 2001, Syver Enstad wrote: > The basic idea is that instead of writing a file name you write a > module name, like ex: httplib or win32com.client.dynamic and the > editor will load the specified module. You mean you want something like `C-x C-f', but with module names, not file names? There is a library, ffap.el, which provides a framework for this. But I couldn't see any Python-specific support in it. However, this could presumably fairly easily be added. See the variable ffap-alist for details. After adding Python support, you can hit `M-x find-file-at-point RET' in the *.py buffer and you can open the right file. kai -- Be indiscrete. Do it continuously. From syver at NOSPAMcyberwatcher.com Sat Feb 17 03:05:17 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Sat, 17 Feb 2001 03:05:17 +0100 Subject: Python emacs mode (newbie) References: <96hu7d$4pq$1@troll.powertech.no> Message-ID: <96kmdc$47q$1@troll.powertech.no> "Kai Gro?johann" wrote in message news:vafwvaqltd4.fsf at lucy.cs.uni-dortmund.de... > On Fri, 16 Feb 2001, Syver Enstad wrote: > You mean you want something like `C-x C-f', but with module names, not > file names? Yes! > > There is a library, ffap.el, which provides a framework for this. But > I couldn't see any Python-specific support in it. However, this could > presumably fairly easily be added. See the variable ffap-alist for > details. After adding Python support, you can hit `M-x > find-file-at-point RET' in the *.py buffer and you can open the right > file. You mean to open modules by parsing import statements in a file? Ex. module.py import sys import MyClass ...... And then you could place the cursor over let's say MyClass and press some key combination to load the py file for the module. Is that what you mean? This would be cool as an added bonus, but it's the find-file like functionality that is crucial. From Kai.Grossjohann at CS.Uni-Dortmund.DE Sat Feb 17 17:53:08 2001 From: Kai.Grossjohann at CS.Uni-Dortmund.DE (Kai =?iso-8859-1?q?Gro=DFjohann?=) Date: 17 Feb 2001 17:53:08 +0100 Subject: Python emacs mode (newbie) References: <96hu7d$4pq$1@troll.powertech.no> <96kmdc$47q$1@troll.powertech.no> Message-ID: On Sat, 17 Feb 2001, Syver Enstad wrote: > You mean to open modules by parsing import statements in a file? > Ex. > module.py > > import sys > import MyClass > > ...... And then you could place the cursor over let's say MyClass > and press some key combination to load the py file for the > module. Is that what you mean? > > This would be cool as an added bonus, but it's the find-file like > functionality that is crucial. Oh, I'm sorry. With M-x find-file-at-point RET, you could type it on the `import MyClass' statement above and then you'll get a default filename prompt of /some/path/here/MyClass.py. But ffap.el does not provide for a facility where you can enter a module name and then it opens the right file. Hm. But it would be trivial to do: C-x b foo RET, M-x python-mode RET, type in the module name, type M-x find-file-at-point RET, voil?! kai -- Be indiscrete. Do it continuously. From syvere at cyberwatcher.com Sun Feb 18 22:32:35 2001 From: syvere at cyberwatcher.com (syvere at cyberwatcher.com) Date: 18 Feb 2001 22:32:35 +0100 Subject: Python emacs mode (newbie) References: <96hu7d$4pq$1@troll.powertech.no> <96kmdc$47q$1@troll.powertech.no> Message-ID: Kai.Grossjohann at CS.Uni-Dortmund.DE (Kai =?iso-8859-1?q?Gro=DFjohann?=) writes: > > Oh, I'm sorry. With M-x find-file-at-point RET, you could type it > on the `import MyClass' statement above and then you'll get a > default filename prompt of /some/path/here/MyClass.py. You mean this is implemented, or do you mean I'll have to implement this to support ffap? I am not with you here, what are you trying to say. > But ffap.el does not provide for a facility where you can enter a > module name and then it opens the right file. > > Hm. > > But it would be trivial to do: C-x b foo RET, M-x pytho > n-mode RET, type in the module name, type M-x find-file-at-point > RET, voil?! I am not that familiar with Emacs, so... You the > current buffer to display the foo file, activate python-mode, type a > python module name in the buffer, you use the ffap function > find-file-at-point? Are suggesting that one could in someway override the implementation of find-file-at-point for python mode so that it also works on modulens? By the way the python module loading seems to work fine on my machine now. But I am trying to get pdb to work from Emacs and I don't seem to have any luck with it. PS. I am running on Win2000 with NT Emacs. Any help on getting pdb up and running would be very much appreciated. From Kai.Grossjohann at CS.Uni-Dortmund.DE Sun Feb 18 23:01:47 2001 From: Kai.Grossjohann at CS.Uni-Dortmund.DE (Kai =?iso-8859-1?q?Gro=DFjohann?=) Date: 18 Feb 2001 23:01:47 +0100 Subject: Python emacs mode (newbie) References: <96hu7d$4pq$1@troll.powertech.no> <96kmdc$47q$1@troll.powertech.no> Message-ID: On 18 Feb 2001, syvere at cyberwatcher.com wrote: > Kai.Grossjohann at CS.Uni-Dortmund.DE (Kai > =?iso-8859-1?q?Gro=DFjohann?=) writes: > >> Oh, I'm sorry. With M-x find-file-at-point RET, you could type it >> on the `import MyClass' statement above and then you'll get a >> default filename prompt of /some/path/here/MyClass.py. > > You mean this is implemented, or do you mean I'll have to implement > this to support ffap? > > I am not with you here, what are you trying to say. By adding an entry to ffap-alist, you can implement the behavior I describe. ffap.el does not currently support Python. But by adding an entry into ffap-alist, you can NOT implement the behavior that you were asking for: being able to enter a module name in the minibuffer and have Emacs open the right *.py file. Hm. I think it should be possible to also get the behavior you want, with just a little Lisp hacking. kai -- Be indiscrete. Do it continuously. From thomas.heller at ion-tof.com Mon Feb 19 13:39:53 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Mon, 19 Feb 2001 13:39:53 +0100 Subject: Python emacs mode (newbie) References: <96hu7d$4pq$1@troll.powertech.no> <96kmdc$47q$1@troll.powertech.no> Message-ID: <96r46q$mngak$1@ID-59885.news.dfncis.de> The following lets you enter a (possibly dotted) python module name in the minibuffer after entering M-x find-pymodule RET. Comments welcome, I'm new to elisp. This is for the .emacs file: (defun find-pymodule () (interactive) (let ((keyword (symbol-near-point))) (let ((text (shell-command-to-string (format "cmd.exe /c find-pymodule.py %s" (read-from-minibuffer "module? " keyword))))) (find-file text)))) and this is somewhere on the path, in find-pymodule.py: import imp, sys, string def find(parts, path=None): top = parts[0] file, pathname, stuff = imp.find_module(top, path) if not parts[1:]: return pathname mod = imp.load_module(top, file, pathname, stuff) return find(parts[1:], mod.__path__) if __name__ == '__main__': try: sys.stdout.write(find(string.split(sys.argv[1], '.'))) except ImportError: pass I prefer to do the actual searching in python, not elisp Thomas From bryan at eevolved.com Fri Feb 16 02:03:49 2001 From: bryan at eevolved.com (Bryan Mongeau) Date: Fri, 16 Feb 2001 01:03:49 GMT Subject: Zlib header removal Message-ID: Hi, I'm implementing an encrypted network protocol in which it is clear that both parties will be using zlib as the compression mechanism. It would be beneficial to remove the zlib compression header from the the compressed plaintext prior to encryption, to avoid possible known plaintext attacks. Is there a way to do this? The zlib module doesn't explain the header well. Can I just chop off a specific number of bytes from the beginning? If so how many? Thanks. -- <==================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. http://www.eevolved.com <==================================> "I want to know God's thoughts; the rest are details."-- Einstein From rcameszREMOVETHIS at dds.removethistoo.nl Sun Feb 18 02:23:34 2001 From: rcameszREMOVETHIS at dds.removethistoo.nl (Robert Amesz) Date: Sun, 18 Feb 2001 01:23:34 GMT Subject: Zlib header removal References: Message-ID: Bryan Mongeau wrote: >Hi, > >I'm implementing an encrypted network protocol in which it is clear >that both parties will be using zlib as the compression mechanism. >It would be beneficial to remove the zlib compression header from >the the compressed plaintext prior to encryption, to avoid possible >known plaintext attacks. Is there a way to do this? The zlib module >doesn't explain the header well. Can I just chop off a specific >number of bytes from the beginning? If so how many? AFAIK, Zlib follows the format in RFC1950 exactly, so it's not difficult to answer that question. Looking at the specification (see below) it would seem that you could chop off the first two bytes if, and only if, you always compress the data using the exact same settings. Two bytes, that's not really a lot of known plaintext, but every little bit might be a liability, I guess. HTH, Robert Amesz --- >From RFC1950: 2.2. Data format A zlib stream has the following structure: 0 1 +---+---+ |CMF|FLG| (more-->) +---+---+ (if FLG.FDICT set) 0 1 2 3 +---+---+---+---+ | DICTID | (more-->) +---+---+---+---+ +=====================+---+---+---+---+ |...compressed data...| ADLER32 | +=====================+---+---+---+---+ Any data which may appear after ADLER32 are not part of the zlib stream. CMF (Compression Method and flags) This byte is divided into a 4-bit compression method and a 4- bit information field depending on the compression method. bits 0 to 3 CM Compression method bits 4 to 7 CINFO Compression info CM (Compression method) This identifies the compression method used in the file. CM = 8 denotes the "deflate" compression method with a window size up to 32K. This is the method used by gzip and PNG (see references [1] and [2] in Chapter 3, below, for the reference documents). CM = 15 is reserved. It might be used in a future version of this specification to indicate the presence of an extra field before the compressed data. CINFO (Compression info) For CM = 8, CINFO is the base-2 logarithm of the LZ77 window size, minus eight (CINFO=7 indicates a 32K window size). Values of CINFO above 7 are not allowed in this version of the specification. CINFO is not defined in this specification for CM not equal to 8. FLG (FLaGs) This flag byte is divided as follows: bits 0 to 4 FCHECK (check bits for CMF and FLG) bit 5 FDICT (preset dictionary) bits 6 to 7 FLEVEL (compression level) The FCHECK value must be such that CMF and FLG, when viewed as a 16-bit unsigned integer stored in MSB order (CMF*256 + FLG), is a multiple of 31. FDICT (Preset dictionary) If FDICT is set, a DICT dictionary identifier is present immediately after the FLG byte. The dictionary is a sequence of bytes which are initially fed to the compressor without producing any compressed output. DICT is the Adler-32 checksum of this sequence of bytes (see the definition of ADLER32 below). The decompressor can use this identifier to determine which dictionary has been used by the compressor. FLEVEL (Compression level) These flags are available for use by specific compression methods. The "deflate" method (CM = 8) sets these flags as follows: 0 - compressor used fastest algorithm 1 - compressor used fast algorithm 2 - compressor used default algorithm 3 - compressor used maximum compression, slowest algorithm The information in FLEVEL is not needed for decompression; it is there to indicate if recompression might be worthwhile. compressed data For compression method 8, the compressed data is stored in the deflate compressed data format as described in the document "DEFLATE Compressed Data Format Specification" by L. Peter Deutsch. (See reference [3] in Chapter 3, below) Other compressed data formats are not specified in this version of the zlib specification. ADLER32 (Adler-32 checksum) This contains a checksum value of the uncompressed data (excluding any dictionary data) computed according to Adler-32 algorithm. This algorithm is a 32-bit extension and improvement of the Fletcher algorithm, used in the ITU-T X.224 / ISO 8073 standard. See references [4] and [5] in Chapter 3, below) Adler-32 is composed of two sums accumulated per byte: s1 is the sum of all bytes, s2 is the sum of all s1 values. Both sums are done modulo 65521. s1 is initialized to 1, s2 to zero. The Adler-32 checksum is stored as s2*65536 + s1 in most- significant-byte first (network) order. From erictodd at texas.net Fri Feb 16 06:51:10 2001 From: erictodd at texas.net (Eric Myers) Date: Fri, 16 Feb 2001 05:51:10 GMT Subject: Need help w/ wxStaticBitmap (novice) Message-ID: Hello. Using wxDesigner, I've created a small dialog (dialer_wdr.py) whose job is to change as it catches certain events. The contents of the dialog are as follows: -A button, whose Id is ID_BUTTON -A static text box whose Id is ID_TEXT -A static bitmap whose Id is ID_STATICBITMAP, and whose initial bitmap is MyBitmapsFunc(0) The event-catching and dialog-changing is handled by my implementation file, which is named dialer.py. When the event referred to is detected, dialer.py executes the following: self.FindWindowById(ID_TEXT).SetLabel("new text") --and the static text successfully gets changed to "new text" self.FindWindowById(ID_BUTTON).SetLabel("new caption") --and the button's caption successfully gets changed self.FindWindowById(ID_STATICBITMAP).SetBitmap(MyBitmapsFunc(1)) --and I get an error that says "AttributeError: 'wxWindowPtr' instance has no attribute 'SetBitmap'" I don't understand why this technique works in the first two situations but gives me problems with the bitmap thing. If for some reason I can't accomplish what I'm trying to do in this way, can somebody please point me in the right direction? Thanks From mfletch at tpresence.com Fri Feb 16 11:49:35 2001 From: mfletch at tpresence.com (Mike Fletcher) Date: Fri, 16 Feb 2001 05:49:35 -0500 Subject: Need help w/ wxStaticBitmap (novice) Message-ID: The problem is likely that find window is defined as: wxWindow* FindWindow(long id) So you're getting back a wxWindow pointer/object instead of a wxStaticBitmap. You need to cast it to a wxStaticBitmap (yes, it's ugly to have to cast things in Python): wxPyTypeCast( self.FindWindowById( ID_STATICBITMAP ), 'wxStaticBitmap', ).SetBitmap(MyBitmapsFunc(1)) Haven't tested that, but it sounds right. No idea, incidentally, why you're able to get the other two to work, seems to me they'd require a cast too. HTH, Mike -----Original Message----- From: Eric Myers [mailto:erictodd at texas.net] Sent: Friday, February 16, 2001 12:51 AM To: python-list at python.org Subject: Need help w/ wxStaticBitmap (novice) Hello. Using wxDesigner, I've created a small dialog (dialer_wdr.py) whose job is to change as it catches certain events. The contents of the dialog are as follows: -A button, whose Id is ID_BUTTON -A static text box whose Id is ID_TEXT -A static bitmap whose Id is ID_STATICBITMAP, and whose initial bitmap is MyBitmapsFunc(0) The event-catching and dialog-changing is handled by my implementation file, which is named dialer.py. When the event referred to is detected, dialer.py executes the following: self.FindWindowById(ID_TEXT).SetLabel("new text") --and the static text successfully gets changed to "new text" self.FindWindowById(ID_BUTTON).SetLabel("new caption") --and the button's caption successfully gets changed self.FindWindowById(ID_STATICBITMAP).SetBitmap(MyBitmapsFunc(1)) --and I get an error that says "AttributeError: 'wxWindowPtr' instance has no attribute 'SetBitmap'" I don't understand why this technique works in the first two situations but gives me problems with the bitmap thing. If for some reason I can't accomplish what I'm trying to do in this way, can somebody please point me in the right direction? Thanks -- http://mail.python.org/mailman/listinfo/python-list From erictodd at texas.net Fri Feb 16 15:47:00 2001 From: erictodd at texas.net (erictodd at texas.net) Date: Fri, 16 Feb 2001 14:47:00 GMT Subject: Need help w/ wxStaticBitmap (novice) References: Message-ID: In article , Mike Fletcher wrote: > The problem is likely that find window is defined as: > > wxWindow* FindWindow(long id) > > So you're getting back a wxWindow pointer/object instead of a > wxStaticBitmap. You need to cast it to a wxStaticBitmap (yes, it's ugly to > have to cast things in Python): > > wxPyTypeCast( > self.FindWindowById( > ID_STATICBITMAP > ), > 'wxStaticBitmap', > ).SetBitmap(MyBitmapsFunc(1)) > > Haven't tested that, but it sounds right. No idea, incidentally, why you're > able to get the other two to work, seems to me they'd require a cast too. > > HTH, > Mike > Yes, that worked straight out of the box. I thank you very much--that was an incredibly prompt reply! -Eric From dan at eevolved.com Fri Feb 16 08:54:01 2001 From: dan at eevolved.com (Dan Parisien) Date: Fri, 16 Feb 2001 07:54:01 GMT Subject: shelve and the best db possible Message-ID: I've been using shelve in dbm mode for a while now and Im' having problems. Either there are random segfaults or writes take an exponentially longer time to do the bigger the db gets (100 rows -> 1 second, 1000 rows -> 20 seconds, 10000 rows -> 600 seconds then crash) I really love shelve, but dbm doesn't seem to scale very well :( Could anyone point me to a good db with a shelve interface? I've tried to get bsddb3 to go, but the test scripts all die :( Thanks, Dan From janne at oops.nnets.fi Fri Feb 16 12:59:26 2001 From: janne at oops.nnets.fi (Janne Sinkkonen) Date: 16 Feb 2001 13:59:26 +0200 Subject: shelve and the best db possible References: Message-ID: Dan Parisien writes: > I really love shelve, but dbm doesn't seem to scale very well :( Could > anyone point me to a good db with a shelve interface? I've tried to get > bsddb3 to go, but the test scripts all die :( I have used an old bsddb 2.x interface from TCS with a largish data base (btree, hundreds of MB's, hundreds of thousands of updates) without any problems. Don't know whether it's still available somewhere. The module name is bsddb (or TCS.bsddb) -- Janne From robin at alldunn.com Sat Feb 17 01:42:55 2001 From: robin at alldunn.com (Robin Dunn) Date: Fri, 16 Feb 2001 16:42:55 -0800 Subject: shelve and the best db possible References: Message-ID: <4Pjj6.44$uHc.19005522@news.randori.com> > > I have used an old bsddb 2.x interface from TCS with a largish data > base (btree, hundreds of MB's, hundreds of thousands of updates) > without any problems. Don't know whether it's still available somewhere. > http://alldunn.com/python/index.html#DB -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From tim.one at home.com Fri Feb 16 09:05:10 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 16 Feb 2001 03:05:10 -0500 Subject: Windows/Cygwin/MacOSX import (was RE: python-dev summary, 2001-02-01 - 2001-02-15) In-Reply-To: Message-ID: [Michael Hudson] > ... > * Imports on case-insensitive file systems * > > There was quite some discussion about how to handle imports on a > case-insensitive file system (eg. on Windows). I didn't follow the > details, but Tim Peters is on the case (sorry), so I'm confident it > will get sorted out. You can be sure the whitespace will be consistent, anyway . OK, this one sucks. It should really have gotten a PEP, but it cropped up too late in the release cycle and it can't be delayed (see below). Here's the scoop: file systems vary across platforms in whether or not they preserve the case of filenames, and in whether or not the platform C library file-opening functions do or don't insist on case-sensitive matches: case-preserving case-destroying +-------------------+------------------+ case-sensitive | most Unix flavors | brrrrrrrrrr | +-------------------+------------------+ case-insensitive | Windows | some unfortunate | | MacOSX HFS+ | network schemes | | Cygwin | | +-------------------+------------------+ In the upper left box, if you create "fiLe" it's stored as "fiLe", and only open("fiLe") will open it (open("file") will not, nor will the 14 other variations on that theme). In the lower right box, if you create "fiLe", there's no telling what it's stored as-- but most likely as "FILE" --and any of the 16 obvious variations on open("FilE") will open it. The lower left box is a mix: creating "fiLe" stores "fiLe" in the platform directory, but you don't have to match case when opening it; any of the 16 obvious variations on open("FILe") work. NONE OF THAT IS CHANGING! Python will continue to follow platform conventions wrt whether case is preserved when creating a file, and wrt whether open() requires a case-sensitive match. In practice, you should always code as if matches were case-sensitive, else your program won't be portable. But then you should also always open binary files with the "b" flag, and you don't do that either . What's proposed is to change the semantics of Python "import" statements, and there *only* in the lower left box. Support for MaxOSX HFS+, and for Cygwin, is new in 2.1, so nothing is changing there. What's changing is Windows behavior. Here are the current rules for import on Windows: 1. Despite that the filesystem is case-insensitive, Python insists on a case-sensitive match. But not in the way the upper left box works: if you have two files, FiLe.py and file.py on sys.path, and do import file then if Python finds FiLe.py first, it raises a NameError. It does *not* go on to find file.py; indeed, it's impossible to import any but the first case-insensitive match on sys.path, and then only if case matches exactly in the first case-insensitive match. 2. An ugly exception: if the first case-insensitive match on sys.path is for a file whose name is entirely in upper case (FILE.PY or FILE.PYC or FILE.PYO), then the import silently grabs that, no matter what mixture of case was used in the import statement. This is apparently to cater to miserable old filesystems that really fit in the lower right box. But this exception is unique to Windows, for reasons that may or may not exist . 3. And another exception: if the envar PYTHONCASEOK exists, Python silently grabs the first case-insensitive match of any kind. So these Windows rules are pretty complicated, and neither match the Unix rules nor provide semantics natural for the native filesystem. That makes them hard to explain to Unix *or* Windows users. Nevertheless, they've worked fine for years, and in isolation there's no compelling reason to change them. However, that was before the MacOSX HFS+ and Cygwin ports arrived. They also have case-preserving case-insensitive filesystems, but the people doing the ports despised the Windows rules. Indeed, a patch to make HFS+ act like Unix for imports got past a reviewer and into the code base, which incidentally made Cygwin also act like Unix (but this met the unbounded approval of the Cygwin folks, so they sure didn't complain -- they had patches of their own pending to do this, but the reviewer for those balked). At a higher level, we want to keep Python consistent, and I in particular want Python to do the same thing on *all* platforms with case-preserving case-insensitive filesystems. Guido too, but he's so sick of this argument don't ask him to confirm that <0.9 wink>. The proposed new semantics for the lower left box: A. If the PYTHONCASEOK envar exists, same as before: silently accept the first case-insensitive match of any kind; raise ImportError if none found. B. Else search sys.path for the first case-sensitive match; raise ImportError if none found. #B is the same rule as is used on Unix, so this will improve cross-platform portability. That's good. #B is also the rule the Mac and Cygwin folks want (and wanted enough to implement themselves, multiple times, which is a powerful argument in PythonLand). It can't cause any existing non-exceptional Windows import to fail, because any existing non-exceptional Windows import finds a case-sensitive match first in the path -- and it still will. An exceptional Windows import currently blows up with a NameError or ImportError, in which latter case it still will, or in which former case will continue searching, and either succeed or blow up with an ImportError. #A is needed to cater to case-destroying filesystems mounted on Windows, and *may* also be used by people so enamored of "natural" Windows behavior that they're willing to set an envar to get it. That's their problem . I don't intend to implement #A for Unix too, but that's just because I'm not clear on how I *could* do so efficiently (I'm not going to slow imports under Unix just for theoretical purity). The potential damage is here: #2 (matching on ALLCAPS.PY) is proposed to be dropped. Case-destroying filesystems are a vanishing breed, and support for them is ugly. We're already supporting (and will continue to support) PYTHONCASEOK for their benefit, but they don't deserve multiple hacks in 2001. Flame at will. or-flame-at-tim-your-choice-ly y'rs - tim From claird at starbase.neosoft.com Fri Feb 16 14:54:12 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 16 Feb 2001 07:54:12 -0600 Subject: Windows/Cygwin/MacOSX import (was RE: python-dev summary, 2001-02-01 - 2001-02-15) References: Message-ID: In article , Tim Peters wrote: >[Michael Hudson] >> ... >> * Imports on case-insensitive file systems * >> >> There was quite some discussion about how to handle imports on a >> case-insensitive file system (eg. on Windows). I didn't follow the >> details, but Tim Peters is on the case (sorry), so I'm confident it >> will get sorted out. > >You can be sure the whitespace will be consistent, anyway . . . . >them is ugly. We're already supporting (and will continue to support) >PYTHONCASEOK for their benefit, but they don't deserve multiple hacks in >2001. > >Flame at will. > >or-flame-at-tim-your-choice-ly y'rs - tim > > 1. Thanks. Along with all the other benefits, I find this explanation FAR more entertaining than anything network television broadcasts (although nearly as tendentious as "The West Wing"). 2. I hope a few OS/400 and OpenVMS refugees convert and walk through the door soon. *That* would make for a nice dose of fun. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From aahz at panix.com Fri Feb 16 17:33:04 2001 From: aahz at panix.com (Aahz Maruch) Date: 16 Feb 2001 08:33:04 -0800 Subject: Windows/Cygwin/MacOSX import (was RE: python-dev summary, 2001-02-01 - 2001-02-15) References: Message-ID: <96jko0$fje$1@panix2.panix.com> In article , Tim Peters wrote: > >Flame at will. > >or-flame-at-tim-your-choice-ly y'rs - tim Very clear, very cogent, very consistent. Thanks for explaining all that. -- --- 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 Why doesn't "Just Say NO" include caffeine, nicotine, alcohol, Prozac, and Ritalin? --Aahz From tjreedy at udel.edu Sat Feb 17 00:06:23 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 16 Feb 2001 18:06:23 -0500 Subject: Windows/Cygwin/MacOSX import (was RE: python-dev summary, 2001-02-01 - 2001-02-15) References: Message-ID: <96kbdd$j7r$1@news.udel.edu> One of the hassles with Win9X is that Windows Explorer displays, I believe, some files differently from how they are stored. So I have sometimes had trouble opening files. (Did the ALLCAPS exception apply here too?) As long as os.listdir('.') displays filenames in a form acceptible to import and open(), I should be ok. From tim.one at home.com Sat Feb 17 05:32:51 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 16 Feb 2001 23:32:51 -0500 Subject: Windows/Cygwin/MacOSX import (was RE: python-dev summary, 2001-02-01 - 2001-02-15) In-Reply-To: <96kbdd$j7r$1@news.udel.edu> Message-ID: [Terry Reedy] > One of the hassles with Win9X is that Windows Explorer displays, > I believe, some files differently from how they are stored. This depends on the setting of Explorer's View -> Folder Options ... -> View -> Allow all uppercase names option. It that's on, file names are shown as stored. But it's off by default. Then an ALLCAPS name is shown as Allcaps (i.e., first letter uppercase, all the rest lowercase), while other names are shown as stored. This has no effect on any Python file in the distribution, though, because they all end with (lowercase) ".py", so they never meet the criteria "Allow all uppercase names" is looking for. > So I have sometimes had trouble opening files. I don't understand that, as open() is case-insensitive on Windows. Perhaps you're thinking of Explorer's "Hide file extensions for known file types" option? *That* could give you trouble when opening files -- but isn't relevant to Python imports. > (Did the ALLCAPS exception apply here too?) Always to import, never to anything else. For each of the four file names ab Ab aB AB on Windows, every one of the following works fine to open it: open("ab") open("Ab") open("aB") open("AB") Python doesn't do anything special to make that happen -- that's just the way the Windows system libraries work. > As long as os.listdir('.') displays filenames in a form acceptible > to import and open(), I should be ok. You're forcing me to be careful here <0.9 wink>: the names returned by listdir('.') work fine for open() as-is on Windows, but also would if you ran them through string.upper() first, or through string.lower() first, or if you picked a case at random for each character in the name. But the names will rarely work in an import statement (and don't today either), because e.g. import random.py will only work if you happen to have a *package* named random containing a *module* named py (so is in a file named py.py). In normal use, you have to strip the extension off the filename before importing it. Beyond that, yes, listdir() returns names using the case choices with which they were created. And Explorer options don't affect what listdir() does. From qrczak at knm.org.pl Mon Feb 19 21:59:33 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 19 Feb 2001 20:59:33 GMT Subject: Windows/Cygwin/MacOSX import (was RE: python-dev summary, 2001-02-01 - 2001-02-15) References: <96kbdd$j7r$1@news.udel.edu> Message-ID: Fri, 16 Feb 2001 18:06:23 -0500, Terry Reedy pisze: > One of the hassles with Win9X is that Windows Explorer displays, I believe, > some files differently from how they are stored. And stores files differently than was asked to. For example when you try to create a directory called Spam, it will create SPAM and display it as Spam. And when asked to create SPAM, it will create it but display Spam. It behaves correctly when the name has more than 8 characters or when a character outside ASCII is used. This is Win95 - I don't know if they fixed this in later versions. Worse: using the Explorer you can create a filename with some non-ASCII characters (e.g. <> or bullet), which will be silently converted to other characters, perhaps different in long and short names (in these cases: '<<' and '>>' character pairs, and '\7' - a control character which displays as bullet in DOS). Details depend on the default codepages (the above is for CP-1250 and CP-852). This can make the file inaccessible under either Windows or DOS or both (because the converted character is sometimes not legal in a filename, but the filename was checked for correctness before conversion). You can't delete or rename such file from either Windows or DOS or both, until you repair the filesystem. Scandisk is not always able to do it. not-using-Windows-anymore-ly y'rs -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From jeremy at alum.mit.edu Mon Feb 19 21:18:03 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Mon, 19 Feb 2001 15:18:03 -0500 (EST) Subject: [Python-Dev] Windows/Cygwin/MacOSX import (was RE: python-dev summary, 2001-02-01 - 2001-02-15) In-Reply-To: References: Message-ID: <14993.32635.85544.343209@w221.z064000254.bwi-md.dsl.cnc.net> >>>>> "TP" == Tim Peters writes: TP> [Michael Hudson] >> ... >> * Imports on case-insensitive file systems * >> >> There was quite some discussion about how to handle imports on a >> case-insensitive file system (eg. on Windows). I didn't follow >> the details, but Tim Peters is on the case (sorry), so I'm >> confident it will get sorted out. TP> You can be sure the whitespace will be consistent, anyway TP> . TP> OK, this one sucks. It should really have gotten a PEP, but it TP> cropped up too late in the release cycle and it can't be delayed TP> (see below). It would be good to capture this in an informational PEP that just describes what the policy is and why. If nothing else, it could be a copy of Tim's message immortalized with a PEP number. Jeremy From tjreedy at udel.edu Tue Feb 20 06:39:08 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 20 Feb 2001 00:39:08 -0500 Subject: Windows/Cygwin/MacOSX import (was RE: python-dev summary, 2001-02-01 - 2001-02-15) References: Message-ID: <96sve1$69e$1@news.udel.edu> "Tim Peters" wrote in message news:mailman.982384399.26499.python-list at python.org... > [Terry Reedy] > > One of the hassles with Win9X is that Windows Explorer displays, > > I believe, some files differently from how they are stored. > > This depends on the setting of Explorer's > > View -> Folder Options ... -> View -> Allow all uppercase names > > option. It that's on, file names are shown as stored. But it's off by > default. Then an ALLCAPS name is shown as Allcaps (i.e., first letter > uppercase, all the rest lowercase), while other names are shown as stored. By coincidence, I discovered this 'feature' a couple of days ago, just after posting this, in the process of turning on the display of hidden files. > > So I have sometimes had trouble opening files. > > I don't understand that, as open() is case-insensitive on Windows. I do not believe that this has always been my experience, but the problem I had was a couple of years ago, so I will wait until I reproduce the problem before saying more. From cyberian_bear at hotmail.com Fri Feb 16 09:37:43 2001 From: cyberian_bear at hotmail.com (cyberian bear) Date: Fri, 16 Feb 2001 03:37:43 -0500 Subject: equivalent of NULL or OM in Python Message-ID: <2G5j6.1$CF4.251@typhoon.nyu.edu> 1.I'm doing a program in Python which perform +, -, *, / on two polynomials. Their coefficient and exponentials are stored in tuples. So for example 3X^2+4X+4 would be stored like [(2,3),(1,4),(0,4)] but what if the term is absent completely from one of the polynomials then i would have to check if one of the tuuples is not present at all and not just zero. For example [(2,3),(0,4)]. In Pascal there is NULL in SETL there is OM but is there a corresponding statement in Python. I've checked through several sources including my textbook but didn't find the satisfactory answer. Maybe I should just check if the second term of every tuple(i.e the coefficient) is zero which means that the term is not present. 2. Also can anyone give me a clue how to iterate over all the coefficient terms in the tuples in the first polynomials' tuples. My guess is should be something like for coefficient in polynomial1: where polynomial is a list of tuples but how do i tell it to iterate specifically over the second term in every tuple and not over the whole tuples cb From hgg9140 at seanet.com Fri Feb 16 14:53:19 2001 From: hgg9140 at seanet.com (Harry George) Date: 16 Feb 2001 05:53:19 -0800 Subject: equivalent of NULL or OM in Python References: <2G5j6.1$CF4.251@typhoon.nyu.edu> Message-ID: I think you are talking about "None". For iterating over polynomials, I could put "m3na" (numerical analysis, in Modula-3) on a web site for you. It does polynomial math. For iterating over tuples in general, they are sequences so you can do for term in poly: do_something_to_term "cyberian bear" writes: > 1.I'm doing a program in Python which perform +, -, *, / on two polynomials. > Their coefficient and exponentials are stored in tuples. So for example > 3X^2+4X+4 would be stored like [(2,3),(1,4),(0,4)] but what if the term is > absent completely from one of the polynomials then i would have to check if > one of the tuuples is not present at all and not just zero. For example > [(2,3),(0,4)]. In Pascal there is NULL in SETL there is OM but is there a > corresponding statement in Python. I've checked through several sources > including my textbook but didn't find the satisfactory answer. Maybe I > should just check if the second term of every tuple(i.e the coefficient) is > zero which means that the term is not present. > 2. Also can anyone give me a clue how to iterate over all the coefficient > terms in the tuples in the first polynomials' tuples. > My guess is should be something like > for coefficient in polynomial1: > where polynomial is a list of tuples > but how do i tell it to iterate specifically over the second term in every > tuple and not over the whole tuples > cb > > -- Harry George hgg9140 at seanet.com From danielk at aracnet.com Fri Feb 16 15:15:29 2001 From: danielk at aracnet.com (Daniel Klein) Date: Fri, 16 Feb 2001 06:15:29 -0800 Subject: equivalent of NULL or OM in Python References: <2G5j6.1$CF4.251@typhoon.nyu.edu> Message-ID: In this case, accessing an element outside of the range of values would produce an IndexError exception. You can 'catch' this exception like this poly = [(2,3),(0,4)] try: thirdpart = poly[2] except IndexError: print 'There are only 2 parts.' In Python, when an object has not been initialized, it is set to 'None' (quotes are for clarity), but I don't think this is useful in this situation. For question 2: for element in poly: print element[1] # prints the second part of each tuple Hope this helps, Daniel Klein Portland OR USA On Fri, 16 Feb 2001 03:37:43 -0500, "cyberian bear" wrote: >1.I'm doing a program in Python which perform +, -, *, / on two polynomials. >Their coefficient and exponentials are stored in tuples. So for example >3X^2+4X+4 would be stored like [(2,3),(1,4),(0,4)] but what if the term is >absent completely from one of the polynomials then i would have to check if >one of the tuuples is not present at all and not just zero. For example >[(2,3),(0,4)]. In Pascal there is NULL in SETL there is OM but is there a >corresponding statement in Python. I've checked through several sources >including my textbook but didn't find the satisfactory answer. Maybe I >should just check if the second term of every tuple(i.e the coefficient) is >zero which means that the term is not present. >2. Also can anyone give me a clue how to iterate over all the coefficient >terms in the tuples in the first polynomials' tuples. >My guess is should be something like >for coefficient in polynomial1: >where polynomial is a list of tuples >but how do i tell it to iterate specifically over the second term in every >tuple and not over the whole tuples >cb > From tim.one at home.com Fri Feb 16 22:51:13 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 16 Feb 2001 16:51:13 -0500 Subject: equivalent of NULL or OM in Python In-Reply-To: Message-ID: [Daniel Klein] > ... > In Python, when an object has not been initialized, it is set to > 'None' (quotes are for clarity), No. An unbound variable is not bound to anything; that's why it's called unbound <0.9 wink>. Attempting to reference an uninitialized variable in Python raises an exception (a subclass of NameError). From sholden at holdenweb.com Fri Feb 16 15:40:47 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 16 Feb 2001 09:40:47 -0500 Subject: equivalent of NULL or OM in Python References: <2G5j6.1$CF4.251@typhoon.nyu.edu> Message-ID: -- Tools, training and technology to help you meet your information needs "cyberian bear" wrote in message news:2G5j6.1$CF4.251 at typhoon.nyu.edu... > 1.I'm doing a program in Python which perform +, -, *, / on two polynomials. > Their coefficient and exponentials are stored in tuples. So for example > 3X^2+4X+4 would be stored like [(2,3),(1,4),(0,4)] but what if the term is > absent completely from one of the polynomials then i would have to check if > one of the tuuples is not present at all and not just zero. For example > [(2,3),(0,4)]. In Pascal there is NULL in SETL there is OM but is there a > corresponding statement in Python. I've checked through several sources > including my textbook but didn't find the satisfactory answer. Maybe I > should just check if the second term of every tuple(i.e the coefficient) is > zero which means that the term is not present. Choice of data representation can be critical in algorithm design, and this is quite a good example. However, I have not fully considered the symbolic manipulations you want to perform, so I may be putting my foot in my mouth here. That's how I know I have a size 10 mouth: the foot fits perfectly. It would appear to be more regular to represent absent terms as a coefficient of zero. Furthermore, if you reverse the order of the terms, putting x^0 at the left, you can then use the index into the list as the power. So your examples could be represented as follows: 3X^2+4X+4 : [4, 4, 3] 3x^2+4: [4, 0, 3] Evaluation for a particular value of x then comes down to: >>> poly = [4, 4, 3] >>> r = 0 >>> x = 2 >>> for p in range(len(poly)): ... r = r + (x^p)*poly[p] ... >>> r 20 Polynomial addition would just add the equivalent coefficients (although you would need to extend the shorter woth zeroes to make them equal lengths). The rest is left as an exercise :-) Would this representation be more tractable? > 2. Also can anyone give me a clue how to iterate over all the coefficient > terms in the tuples in the first polynomials' tuples. > My guess is should be something like > for coefficient in polynomial1: > where polynomial is a list of tuples > but how do i tell it to iterate specifically over the second term in every > tuple and not over the whole tuples > cb > > Using your representation, what you want is something like: >>> poly = [(2,3),(1,4),(0,4)] >>> for i, c in poly: ... print "Index:", i, "Coefficient:", c ... Index: 2 Coefficient: 3 Index: 1 Coefficient: 4 Index: 0 Coefficient: 4 Obviously you can ignore the indexes if you want... Does any of this help? regards Steve From sholden at holdenweb.com Fri Feb 16 15:48:52 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 16 Feb 2001 09:48:52 -0500 Subject: equivalent of NULL or OM in Python References: <2G5j6.1$CF4.251@typhoon.nyu.edu> Message-ID: "Steve Holden" got too enthusiastic, and wrote without checking: > Evaluation for a particular value of x then comes down to: > > >>> poly = [4, 4, 3] > >>> r = 0 > >>> x = 2 > >>> for p in range(len(poly)): > ... r = r + (x^p)*poly[p] > ... > >>> r > 20 Woops, make that: >>> for p in range(len(poly)): ... r = r + (x**p)*poly[p] ... print "p:", p, "r:", r ... p: 0 r: 4 p: 1 r: 12 p: 2 r: 24 Got carried away and used the wrong power operator. Bitwise xor might have been a little confusing here... regards Steve From digitig at cix.co.uk Sun Feb 25 22:17:00 2001 From: digitig at cix.co.uk (Tim Rowe) Date: Sun, 25 Feb 2001 21:17 +0000 (GMT Standard Time) Subject: equivalent of NULL or OM in Python References: Message-ID: In article , sholden at holdenweb.com (Steve Holden) wrote: > Choice of data representation can be critical in algorithm design, and > this > is quite a good example. However, I have not fully considered the > symbolic > manipulations you want to perform, so I may be putting my foot in my > mouth > here. That's how I know I have a size 10 mouth: the foot fits perfectly. > > It would appear to be more regular to represent absent terms as a > coefficient of zero. Furthermore, if you reverse the order of the terms, > putting x^0 at the left, you can then use the index into the list as the > power. So your examples could be represented as follows: > > 3X^2+4X+4 : [4, 4, 3] > 3x^2+4: [4, 0, 3] It depends what he wants to do. If he's doing things like CRC calculations the lists are likely to have a lot of zeroes. I think it would be worth considering numpy, as polynomial conversions are easily represented as array operations, and ISTR numpy is clued up on sparse arrays. From DanielK at jBASE.com Fri Feb 16 23:23:50 2001 From: DanielK at jBASE.com (Daniel Klein) Date: Fri, 16 Feb 2001 14:23:50 -0800 Subject: equivalent of NULL or OM in Python References: Message-ID: <7Shj6.466$Vf.17201@typhoon.aracnet.com> Thanks for setting me straight, Tim. Dan "Tim Peters" wrote in message news:mailman.982360339.1235.python-list at python.org... > [Daniel Klein] > > ... > > In Python, when an object has not been initialized, it is set to > > 'None' (quotes are for clarity), > > No. An unbound variable is not bound to anything; that's why it's called > unbound <0.9 wink>. Attempting to reference an uninitialized variable in > Python raises an exception (a subclass of NameError). > > From tim.one at home.com Fri Feb 16 23:57:29 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 16 Feb 2001 17:57:29 -0500 Subject: equivalent of NULL or OM in Python In-Reply-To: <7Shj6.466$Vf.17201@typhoon.aracnet.com> Message-ID: [Daniel Klein] > Thanks for setting me straight, Tim. And thank *you* for giving me the opportunity to excel . honest-if-you-were-confused-10,000-were-too-ly y'rs - tim From greg at cosc.canterbury.ac.nz Wed Feb 21 00:51:43 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 21 Feb 2001 12:51:43 +1300 Subject: equivalent of NULL or OM in Python References: <2G5j6.1$CF4.251@typhoon.nyu.edu> Message-ID: <3A93030F.6CD98D29@cosc.canterbury.ac.nz> cyberian bear wrote: > > Maybe I > should just check if the second term of every tuple(i.e the coefficient) is > zero which means that the term is not present. It depends on how your algorithms work. If you find that, e.g. it makes your multiplication algorithm awkward if terms can be missed out, then always storing every term, possibly with a zero coefficient, makes sense. If you're doing that, you don't really need to store the exponents, because they're implied by the position in the list -- so all you need is a list of coefficients. I would probably store it reversed, so that the coefficient of x^i is in position i of the list, e.g. 3x^2+2x+4 --> [4, 2, 3] > how do i tell it to iterate specifically over the second term in every > tuple and not over the whole tuples Note that you can "unpack" a tuple by doing: exp, coeff = term so one way to do what you want is for term in poly: exp, coeff = term #do something with coeff or, more compactly, for exp, coeff in poly: #do something with coeff -- 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 wilsoncredit at email.com Fri Feb 16 09:56:53 2001 From: wilsoncredit at email.com (wilsoncredit at email.com) Date: Fri, 16 Feb 2001 08:56:53 GMT Subject: ****SPECIAL REPORT**** Message-ID: --_NextPart_0000904A-000004CC-0388DEEA-5224 Content-Type: text/plain Content-Transfer-Encoding: 7bit Get a brand new, clean, credit file in 15 days or less... Get the credit you deserve... For more info, send a email to wilsoncredit at email.com with "INFO" in the subject line... --_NextPart_0000904A-000004CC-0388DEEA-5224-- From ransen_spam_me_not at nemo.it Fri Feb 16 12:06:08 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Fri, 16 Feb 2001 11:06:08 GMT Subject: sys.path and the Windows registry Message-ID: <3a8d0450.162541@news.newsguy.com> I'm just starting out with Python and have some simple modules in a directoryb which is not on the sys.path. I hoped that if I edited the registry and added my new extra source file path I'd then see the new files in the path browser (GUI Python 2). I can't though, what am I missing? TIA Owen -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From MarkH at ActiveState.com Sat Feb 17 00:53:46 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Fri, 16 Feb 2001 23:53:46 GMT Subject: sys.path and the Windows registry References: <3a8d0450.162541@news.newsguy.com> Message-ID: <3A8DBCAE.5080808@ActiveState.com> Owen F. Ransen wrote: > I'm just starting out with Python and have some simple > modules in a directoryb which is not on the sys.path. > > I hoped that if I edited the registry and added my new > extra source file path I'd then see the new files in the > path browser (GUI Python 2). > > I can't though, what am I missing? Create a new _subkey_ under the main PythonPath entry, calling it anything you like. Add your new path as the default value for this new key. The main PythonPath entry is reserved for the Python core, and it may choose to ignore it if it can find its own core. Mark. -- Nominate Your Favorite Programmers for the Perl and Python Active Awards! http://www.ActiveState.com/Awards/ From ransen_spam_me_not at nemo.it Sat Feb 17 18:42:02 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Sat, 17 Feb 2001 17:42:02 GMT Subject: sys.path and the Windows registry References: <3a8d0450.162541@news.newsguy.com> <3A8DBCAE.5080808@ActiveState.com> Message-ID: <3a8e9737.2589893@news.newsguy.com> Thanks Mark! On Fri, 16 Feb 2001 23:53:46 GMT, Mark Hammond wrote: >Owen F. Ransen wrote: > >> I'm just starting out with Python and have some simple >> modules in a directoryb which is not on the sys.path. >> >> I hoped that if I edited the registry and added my new >> extra source file path I'd then see the new files in the >> path browser (GUI Python 2). >> >> I can't though, what am I missing? > >Create a new _subkey_ under the main PythonPath entry, calling it anything you like. Add your new path as the default value for this new key. > >The main PythonPath entry is reserved for the Python core, and it may choose to ignore it if it can find its own core. > >Mark. -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From gavin at madzag.com Fri Feb 16 13:11:26 2001 From: gavin at madzag.com (Gavin Tomlins) Date: Fri, 16 Feb 2001 12:11:26 GMT Subject: Interpreter Example - 4 score & 7 years ago Message-ID: Greetings, I'm currently pursuing references about using python as an interpreter/compiler. A year + ago there was an example of writing an interpreter in python for chemical symbols/compounds. I was wondering if anyone had a reference or can recall the posting. Regards Gavin From ivnowa at hvision.nl Fri Feb 16 13:21:04 2001 From: ivnowa at hvision.nl (Hans Nowak) Date: Fri, 16 Feb 2001 12:21:04 GMT Subject: Interpreter Example - 4 score & 7 years ago References: Message-ID: <3A8D193F.7727@hvision.nl> Gavin Tomlins wrote: > I'm currently pursuing references about using python as an > interpreter/compiler. > > A year + ago there was an example of writing an interpreter in python for > chemical symbols/compounds. I was wondering if anyone had a reference or > can recall the posting. Is it this one? http://tor.dhs.org/~zephyrfalcon/snippets/source/63.py Regards, --Hans Nowak From gavin at madzag.com Fri Feb 16 13:39:13 2001 From: gavin at madzag.com (Gavin Tomlins) Date: Fri, 16 Feb 2001 12:39:13 GMT Subject: Interpreter Example - 4 score & 7 years ago References: <3A8D193F.7727@hvision.nl> Message-ID: >> A year + ago there was an example of writing an interpreter in python >> for chemical symbols/compounds. I was wondering if anyone had a >> reference or can recall the posting. > >Is it this one? > http://tor.dhs.org/~zephyrfalcon/snippets/source/63.py >Regards, >--Hans Nowak The exact one I was looking for. Thanks Gavin From matthew at manderson.co.uk Fri Feb 16 13:37:59 2001 From: matthew at manderson.co.uk (Matthew Manderson) Date: Fri, 16 Feb 2001 12:37:59 -0000 Subject: How upgrade Python 1.5 to 2.0 on Unix....? Message-ID: <3a8d1ec0@news.telinco.net> Hi all, I installed Python 2 on my raq3 and it works, however it still defaults to Python1.5? how do I fix this? The folders are: usr/lib/python1.5 usr/lib/Python-2.0 Many thanks and regards, Matthew ____________________________ Matthew S Manderson ATT ATII email: matthew at manderson.co.uk ___________________________ From gerhard.nospam at bigfoot.de Fri Feb 16 20:43:56 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Fri, 16 Feb 2001 20:43:56 +0100 Subject: How upgrade Python 1.5 to 2.0 on Unix....? References: <3a8d1ec0@news.telinco.net> Message-ID: <3A8D82FC.6A2C1E63@bigfoot.de> Matthew Manderson wrote: > > Hi all, I installed Python 2 on my raq3 and it works, however > it still defaults to Python1.5? how do I fix this? > > The folders are: > > usr/lib/python1.5 > usr/lib/Python-2.0 I guess then "python" command executes 1.5.2. The following commands should fix this: rm usr/bin/python ln -s usr/bin/python2.0 usr/bin/python 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 marciann at tin.it Fri Feb 16 13:40:17 2001 From: marciann at tin.it (Marco Iannaccone) Date: Fri, 16 Feb 2001 12:40:17 GMT Subject: Videogame scripting Message-ID: Do you think Python is a good scripting language for videogames. I wanna use it for both Windows and Linux. Is it easy enough to program it, and to use it with C and C++? Is it fast? -- Marco Iannaccone marciann at tin.it ICQ: 18748121 MetalCoder "What is real? How do you define real? If you're talking about your senses, what you feel, taste, smell, or see, then all you're talking about are electrical signals interpreted by your brain." Morpheus - The Matrix From stephen_purcell at yahoo.com Fri Feb 16 14:48:34 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Fri, 16 Feb 2001 14:48:34 +0100 Subject: Videogame scripting In-Reply-To: ; from marciann@tin.it on Fri, Feb 16, 2001 at 12:40:17PM +0000 References: Message-ID: <20010216144834.B12097@freedom.puma-ag.com> Marco Iannaccone wrote: > Do you think Python is a good scripting language for videogames. I wanna use > it for both Windows and Linux. Is it easy enough to program it, and to use > it with C and C++? Is it fast? Don't know the answers to all of those questions, but it seems like you should check out PySDL: http://pysdl.sourceforge.net/ -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 root at rainerdeyke.com Fri Feb 16 19:34:53 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 16 Feb 2001 18:34:53 GMT Subject: Videogame scripting References: Message-ID: "Marco Iannaccone" wrote in message news:Rc9j6.17279$LM4.229776 at twister1.tin.it... > Do you think Python is a good scripting language for videogames. Yes. > I wanna use > it for both Windows and Linux. Is it easy enough to program it, and to use > it with C and C++? Yes. Interfacing with C++ can be difficult if you use C++ exceptions, but there are wrapper libraries that take care of that for you. > Is it fast? It is much slower than C/C++. Depending on what you do with it, this may or may not be significant. Compared with other scripting languages, it's not bad. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From aleaxit at yahoo.com Fri Feb 16 21:02:18 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 16 Feb 2001 21:02:18 +0100 Subject: Videogame scripting References: Message-ID: <96k28e21utj@news2.newsguy.com> "Marco Iannaccone" wrote in message news:Rc9j6.17279$LM4.229776 at twister1.tin.it... > Do you think Python is a good scripting language for videogames. I wanna use > it for both Windows and Linux. Is it easy enough to program it, and to use > it with C and C++? Is it fast? No scripting language is really _fast_ (the FAST parts you'll be better off keeping in C/C++ -- or you may want to move to high-order but fully-compilable languages such as O'Caml). But Python IS very easy, powerful, and handy at the utmost, on both Linux and Windows; and it interfaces well to C, and even better to C++. Alex From catunda at pobox.com Fri Feb 16 14:06:19 2001 From: catunda at pobox.com (Marco Catunda) Date: Fri, 16 Feb 2001 11:06:19 -0200 Subject: popen problem Message-ID: <3A8D25CB.D1A1168C@pobox.com> Hello, I've written a program using threads and popen. Basically, this program execute a pool of threads and each thread executes a command ping with open function. Like bellow: outFile = os.popen( "ping localhost", "r" ) lines = outFile.readlines() outFile.close() I have no idea why, at some cases, the outfile.close() function generates an IOError except. This except generating is totaly random. Does anyone have an idea why it happens? And how can I correct it? Is popen thread safe? Thanks for help. Regards -- Marco Catunda From mix77 at usa.net Fri Feb 16 14:24:40 2001 From: mix77 at usa.net (Mix) Date: Fri, 16 Feb 2001 15:24:40 +0200 Subject: PIL (Python Image Library) RPM Message-ID: <96ja30$5a3$1@ctb-nnrp2.saix.net> Where can I find Python Image Library RPM (if there is one)? From jafo at tummy.com Sat Feb 17 05:29:31 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Fri, 16 Feb 2001 21:29:31 -0700 Subject: PIL (Python Image Library) RPM In-Reply-To: <96ja30$5a3$1@ctb-nnrp2.saix.net>; from mix77@usa.net on Fri, Feb 16, 2001 at 03:24:40PM +0200 References: <96ja30$5a3$1@ctb-nnrp2.saix.net> Message-ID: <20010216212931.D5348@tummy.com> On Fri, Feb 16, 2001 at 03:24:40PM +0200, Mix wrote: >Where can I find Python Image Library RPM (if there is one)? That one I used to build Sketch is at: ftp.tummy.com:/pub/tummy/RPMS/SRPMS/python-imaging-1.0-6.src.rpm Sean -- Follow the dream, not the competition. -- Nemesis Racing Team Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From gchiaramonte at yahoo.com Fri Feb 16 14:41:39 2001 From: gchiaramonte at yahoo.com (Gene C) Date: Fri, 16 Feb 2001 13:41:39 GMT Subject: Python & Microsoft Script Control Message-ID: Anyone know where I can find information on using Python with the Microsoft Script Contol? >From the Microsoft website: Through the ActiveX Scripting Interface, the Microsoft Script Control allows applications to support any scripting language. Microsoft Internet Explorer 4.0 delivers two scripting languages, including Visual Basic Scripting Edition and JScriptT development software, the industry's leading implementation of ECMAScript. Support for additional scripting languages, such as Perl and Python, is available from third-party vendors. From gchiaramonte at yahoo.com Fri Feb 16 19:54:35 2001 From: gchiaramonte at yahoo.com (Gene) Date: Fri, 16 Feb 2001 18:54:35 GMT Subject: Python & Microsoft Script Control References: Message-ID: It's part of the ActivePython distribution. "Gene C" wrote in message news:n6aj6.848$JS2.124285 at newsread2.prod.itd.earthlink.net... > Anyone know where I can find information on using Python with the Microsoft > Script Contol? > > From the Microsoft website: > > Through the ActiveX Scripting Interface, the Microsoft Script Control allows > applications to support any scripting language. Microsoft Internet Explorer > 4.0 delivers two scripting languages, including Visual Basic Scripting > Edition and JScriptT development software, the industry's leading > implementation of ECMAScript. Support for additional scripting languages, > such as Perl and Python, is available from third-party vendors. > > > From aleaxit at yahoo.com Fri Feb 16 21:00:25 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 16 Feb 2001 21:00:25 +0100 Subject: Python & Microsoft Script Control References: Message-ID: <96k28c11utj@news2.newsguy.com> "Gene C" wrote in message news:n6aj6.848$JS2.124285 at newsread2.prod.itd.earthlink.net... > Anyone know where I can find information on using Python with the Microsoft > Script Contol? I know of no location with specific info on that, apart from Microsoft's scripting pages (not much on the scriptcontrol itself -- it's basically a rehash of the helpfile that comes with the scriptcontrol). Fortunately, there isn't much difficulty involved, as long as you have win32all installed with your Python, or are using the ActivePython distribution. The MS help file is VB-centered, but that goes for 99% of the docs of all Automation object models &c -- you need to be able to read 'just enough VB to get by', it's really pretty easy. While I haven't yet managed to 'really' make Python a part of the applications we develop at work, the ScriptControl IS helping -- with the rest of ActiveScripting/Automation/COM, it makes it really trivial to let an application be scripted through any scripting language at all -- and Python really shines when thus placed on a level playing field with VBScript &tc. Only itch I'm aware of, so far, is some bug which makes the Procedures collection of the ScriptControl unusable when the Language property is set to Python -- I'm currently working around that with a Python-specific kludge (if operations on the Procedures collection fail with an 'index error', Python specific workarounds [based on Python introspection] are used), but anyway I gave Mark Hammond a tiny program which easily reproduces the bug, and I trust he'll fix it eventually. Alex From MarkH at ActiveState.com Sat Feb 17 01:00:40 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sat, 17 Feb 2001 00:00:40 GMT Subject: Python & Microsoft Script Control References: <96k28c11utj@news2.newsguy.com> Message-ID: <3A8DBE4C.9010200@ActiveState.com> Alex Martelli wrote: > While I haven't yet managed to 'really' make Python a part of the > applications we develop at work, the ScriptControl IS helping -- with > the rest of ActiveScripting/Automation/COM, it makes it really trivial > to let an application be scripted through any scripting language at > all -- and Python really shines when thus placed on a level playing > field with VBScript &tc. Have you checked out win32comext\axscript\test\testHost.py - this implements a first-class Active Scripting host, and allows you to define your ActiveScripting object module purely in Python. Mark. From aleaxit at yahoo.com Sat Feb 17 08:38:33 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 17 Feb 2001 08:38:33 +0100 Subject: Python & Microsoft Script Control References: <96k28c11utj@news2.newsguy.com> <3A8DBE4C.9010200@ActiveState.com> Message-ID: <96l9sn0dp7@news2.newsguy.com> "Mark Hammond" wrote in message news:3A8DBE4C.9010200 at ActiveState.com... > Alex Martelli wrote: > > > While I haven't yet managed to 'really' make Python a part of the > > applications we develop at work, the ScriptControl IS helping -- with > > the rest of ActiveScripting/Automation/COM, it makes it really trivial > > to let an application be scripted through any scripting language at > > all -- and Python really shines when thus placed on a level playing > > field with VBScript &tc. > > Have you checked out win32comext\axscript\test\testHost.py - this implements a first-class Active Scripting host, and allows you to define your ActiveScripting object module purely in Python. Haven't tried it, no -- looks like a neat hack indeed, but not applicable to the issue of "how do I get Python into these `mainstream' Windows applications", for which Microsoft ScriptControl offers a backdoor. Alex From Pierre.Blanchet at solsoft.fr Fri Feb 16 15:13:36 2001 From: Pierre.Blanchet at solsoft.fr (Pierre Blanchet) Date: Fri, 16 Feb 2001 15:13:36 +0100 Subject: PRoblem with UDP sockets Message-ID: I'm trying to code a TFTP client with python 1.5.2 under Linux. I cannot find a way to send UDP packets shorter than 14 bytes. By example, if i try to send (using sendto) the string ' 0 4 0 1', i get on the wire '0 4 0 1 1 1 1 1 1 1 1 1 1 1 1' althougth sendto tell me it has send 4 bytes. Do i do something wrong ? Is there a bug in python in Linux ? TIA, Pierre. -- Pierre Blanchet Support Engineer http://www.solsoft.com Pierre.Blanchet at solsoft.fr Tel.: +33 147 15 55 00 Fax: +33 147 15 55 09 From sholden at holdenweb.com Fri Feb 16 15:28:36 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 16 Feb 2001 09:28:36 -0500 Subject: PRoblem with UDP sockets References: Message-ID: <7Saj6.24117$n4.336846@e420r-atl2.usenetserver.com> "Pierre Blanchet" wrote in message news:mailman.982332924.15258.python-list at python.org... > I'm trying to code a TFTP client with python 1.5.2 under > Linux. > > I cannot find a way to send UDP packets shorter than 14 > bytes. > > By example, if i try to send (using sendto) the string ' 0 > 4 0 1', i get on the wire '0 4 0 1 1 1 1 1 1 1 1 1 1 1 1' althougth > sendto tell me it has send 4 bytes. > > Do i do something wrong ? Is there a bug in python in Linux > ? > > TIA, > > Pierre. > Have you checked the data length in the UPD header? Wondered whether this might be more to do with the minimum Ethernet frame size... regards Steve -- Tools, training and technology to help you meet your information needs From Pierre.Blanchet at solsoft.fr Fri Feb 16 16:26:36 2001 From: Pierre.Blanchet at solsoft.fr (Pierre Blanchet) Date: Fri, 16 Feb 2001 16:26:36 +0100 Subject: PRoblem with UDP sockets In-Reply-To: Your message of "Fri, 16 Feb 2001 09:28:36 EST." <7Saj6.24117$n4.336846@e420r-atl2.usenetserver.com> References: <7Saj6.24117$n4.336846@e420r-atl2.usenetserver.com> Message-ID: On February 16 2001 at 9:28, "Steve Holden" wrote: > "Pierre Blanchet" wrote in message > news:mailman.982332924.15258.python-list at python.org... > > I'm trying to code a TFTP client with python 1.5.2 under > > Linux. > > > > I cannot find a way to send UDP packets shorter than 14 > > bytes. > > > > By example, if i try to send (using sendto) the string ' 0 > > 4 0 1', i get on the wire '0 4 0 1 1 1 1 1 1 1 1 1 1 1 1' althougth > > sendto tell me it has send 4 bytes. > > > > Do i do something wrong ? Is there a bug in python in Linux > > ? > > > > TIA, > > > > Pierre. > > > Have you checked the data length in the UPD header? Wondered whether this > might be more to do with the minimum Ethernet frame size... > Nevermind. The bug was mine. Actually now my TFTPclient works :) But my packets are still longer than i need. But you were right, the minimum size of an ethernet packet is 60 ( as shown by ethereal) and there is a need for padding (in my case 14 bytes in the "trailer"). Thanks Steve for your help, Pierre. -- Pierre Blanchet Support Engineer http://www.solsoft.com Pierre.Blanchet at solsoft.fr Tel.: +33 147 15 55 00 Fax: +33 147 15 55 09 From sholden at holdenweb.com Fri Feb 16 15:20:07 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 16 Feb 2001 09:20:07 -0500 Subject: Sping (was PIDDLE) not producing PDF file Message-ID: <9Kaj6.24112$n4.336343@e420r-atl2.usenetserver.com> This is a little program I used to produce digital camera thumbnail listings under 1.5.2 which worked fine. I've loaded sping and PIL under 2.0 (where's all the documentation gone?) and modified the code to accommodate the new packaging structure. It runs, but seems to produce no PDF file. Can anyone point out what I might be doing wrong? regards Steve from sping import * from sping.PDF import PDFCanvas, Font import PIL.Image, os.path, sys, glob MAXLINE = 8 MAXCOL = 4 LINEHEIGHT = 100 COLWIDTH = 140 LEFTMARGIN = 45 TOPMARGIN = 45 fntLarge = Font(face="helvetica", size=16, bold=1) fntMedium = Font(face="helvetica", size=12, bold=1) fntSmall = Font(face="helvetica", size=8, bold=0) imagename = [] for filepat in sys.argv[1:]: for infile in glob.glob(filepat): imagename.append(infile) imagename.sort() lineno = MAXLINE+1 colno = MAXCOL+1 pageno = 0 out = PDFCanvas(name = "C:\PhotoClips.pdf") for i in range(len(imagename)): if colno >= MAXCOL: lineno = lineno+1 colno = 0 if lineno >= MAXLINE: lineno = 0 colno = 0 if pageno > 0: out.clear() pageno = pageno +1 print imagename[i]; sys.stdout.flush() im = PIL.Image.open(imagename[i]) imx = colno*COLWIDTH+LEFTMARGIN imy = lineno*LINEHEIGHT+TOPMARGIN out.drawImage(im.resize((220,146)), imx, imy, imx+109, imy+72) out.drawString(os.path.basename(imagename[i]), imx, imy+80, fntSmall) colno = colno +1 out.flush() -- -- Tools, training and technology to help you meet your information needs From sholden at holdenweb.com Fri Feb 16 16:13:35 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 16 Feb 2001 10:13:35 -0500 Subject: Sping (was PIDDLE) not producing PDF file References: <9Kaj6.24112$n4.336343@e420r-atl2.usenetserver.com> Message-ID: "Steve Holden" wrote in message news:9Kaj6.24112$n4.336343 at e420r-atl2.usenetserver.com... > This is a little program I used to produce digital camera thumbnail listings > under 1.5.2 which worked fine. I've loaded sping and PIL under 2.0 (where's > all the documentation gone?) and modified the code to accommodate the new > packaging structure. It runs, but seems to produce no PDF file. Can anyone > point out what I might be doing wrong? > > regards > Steve > Seems to be "follow up my own postings" day today. Oh, well. Christopher Lee was kind enough to pint out by e-mail that I omitted to update my program with a call to the PDFCanvas' save() method, a change made around six months ago. So adding a final line of out.save() fixed everything. Great software! regards Steve From Roy.Culley at switzerland.org Fri Feb 16 16:45:04 2001 From: Roy.Culley at switzerland.org (Roy.Culley at switzerland.org) Date: Fri, 16 Feb 2001 16:45:04 +0100 Subject: Creating a dictionary from log file records Message-ID: <0uhj69.vpb.ln@gd2zzx> I'm new to python and am trying to convert a perl script which analyses firewall logs to python as a learning exercise. The log files contain lines of multiple key / value pairs such as: interface qfe0 proto tcp src 1.1.1.1 dst 2.2.2.2 service smtp \ s_port 44008 len 44 rule 7 Not all records are the same and the key / value pairs are not at fixed positions. In perl, assuming the line is in $_, I can do: %Rec = split Is there an equivalent simple way to do this with python? I've done it by converting the data into a list and using a while loop to set the dictionary entries. However, the log files have about 4 million entries per day so I need something that is fast. Any help / suggestions most appreciated. From shaleh at valinux.com Fri Feb 16 17:35:52 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Fri, 16 Feb 2001 08:35:52 -0800 (PST) Subject: Creating a dictionary from log file records In-Reply-To: <0uhj69.vpb.ln@gd2zzx> Message-ID: On 16-Feb-2001 Roy.Culley at switzerland.org wrote: > I'm new to python and am trying to convert a perl script which analyses > firewall logs to python as a learning exercise. > > The log files contain lines of multiple key / value pairs such as: > > interface qfe0 proto tcp src 1.1.1.1 dst 2.2.2.2 service smtp \ > s_port 44008 len 44 rule 7 > > Not all records are the same and the key / value pairs are not at > fixed positions. In perl, assuming the line is in $_, I can do: > > %Rec = split > > Is there an equivalent simple way to do this with python? I've done > it by converting the data into a list and using a while loop to set > the dictionary entries. However, the log files have about 4 million > entries per day so I need something that is fast. > so for every line in the file, you create a temporary perl hash. What do you do with the hash? generating a new hash for every line can not be but so fast. From Roy.Culley at switzerland.org Fri Feb 16 19:11:18 2001 From: Roy.Culley at switzerland.org (Roy.Culley at switzerland.org) Date: Fri, 16 Feb 2001 19:11:18 +0100 Subject: Creating a dictionary from log file records References: Message-ID: <6gqj69.qbc.ln@gd2zzx> In article , "Sean 'Shaleh' Perry" wrote: > > On 16-Feb-2001 Roy.Culley at switzerland.org wrote: >> I'm new to python and am trying to convert a perl script which analyses >> firewall logs to python as a learning exercise. >> >> The log files contain lines of multiple key / value pairs such as: >> >> interface qfe0 proto tcp src 1.1.1.1 dst 2.2.2.2 service smtp \ >> s_port 44008 len 44 rule 7 >> >> Not all records are the same and the key / value pairs are not at >> fixed positions. In perl, assuming the line is in $_, I can do: >> >> %Rec = split >> >> Is there an equivalent simple way to do this with python? I've done >> it by converting the data into a list and using a while loop to set >> the dictionary entries. However, the log files have about 4 million >> entries per day so I need something that is fast. >> > > so for every line in the file, you create a temporary perl hash. What do you > do with the hash? generating a new hash for every line can not be but so fast. On a Sun E250 with a single 300MHz processor the perl script can process a days log of 3.5 - 4 MB in a little over half an hour. From the hash I make lots of other hashes which I then use to produce a log report with many different types of summary data. For example, services by IP source address, destination address (both accepted and dropped connections), connections by src addr + dst addr + service, etc. These are all in hashes. Many different combinations. This enables us to see quickly scans (both IP addr and port), what services are used most (helps order firewall rules), etc. It is quite a simple perl script and most of the time is spent sorting the hashes and producing the report. The initial data extraction into the hashes is very fast. From stevee at recombinant.demon.co.uk Fri Feb 16 22:18:34 2001 From: stevee at recombinant.demon.co.uk (Stephen D Evans) Date: Fri, 16 Feb 2001 21:18:34 +0000 Subject: Creating a dictionary from log file records References: <0uhj69.vpb.ln@gd2zzx> Message-ID: <3A8D9929.CD69DAA1@recombinant.demon.co.uk> Roy, For an alternative Python solution (without resorting to C) you could try using compile() to create code objects for eval or exec rather than using a while or for loop. On my Intel Pentium 200 machine the exec and eval methods in the following code ran about 4% faster than the for loop. Please note that I have only tested this on Python 2.0 #### filename = 'logfile.log' # Old FORTRAN technique. Static allocation of list length. # If an IndexError occurs, change the value and start again. MAX_LEN = 20 # pre-create a list of code objects that return list 'L' as a dictionary eval_code_object_list = [None] * MAX_LEN exec_code_object_list = [None] * MAX_LEN for i in range(0, MAX_LEN, 2): # assume list of even length text = '' for j in range(0, i, 2): text='%sL[%d]:L[%d],' % (text, j, j+1) text = '{%s}' % text eval_code_object_list[i] = compile(text, '', 'eval') text = 'dict=%s' % text exec_code_object_list[i] = compile(text, '', 'exec') import time # for some stats start_time = time.clock() # for Python 1.5.2 print 'Python readlines():', lines = open(filename, 'rt').readlines() print time.clock() - start_time start_time = time.clock() # an alternative method for Python 2.0 (not as fast), will fail on Python 1.5.2 print 'Python read().splitlines():', lines = open(filename, 'rt').read().splitlines() print time.clock() - start_time # Python 2.1 could use the 'for line in open(filename).xreadlines():' method # for large files start_time = time.clock() print 'for loop:', ## The list 'L' is converted to a dictionary 'dict' using a simple for loop. for line in lines: L = line.split() dict = {} for i in range(0, len(L), 2): dict[L[i]] = L[i+1] print time.clock() - start_time start_time = time.clock() print 'eval:', ## The list 'L' is converted to a dictionary 'dict' using an index into the list ## of code objects. Lookups and no iteration during the creation of 'dict' for line in lines: L = line.split() dict = eval(eval_code_object_list[len(L)]) print time.clock() - start_time start_time = time.clock() print 'exec:', ## as above but use exec to produce dict for line in lines: L = line.split() exec exec_code_object_list[len(L)] # dict is here ! print time.clock() - start_time #### I normally do not bother with optimisations that give less than 10% improvement. There has been a request for a Python equivalent of the Perl split mentioned somewhere in the Python world... Stephen D Evans Roy.Culley at switzerland.org wrote: > I'm new to python and am trying to convert a perl script which analyses > firewall logs to python as a learning exercise. > > The log files contain lines of multiple key / value pairs such as: > > interface qfe0 proto tcp src 1.1.1.1 dst 2.2.2.2 service smtp \ > s_port 44008 len 44 rule 7 > > Not all records are the same and the key / value pairs are not at > fixed positions. In perl, assuming the line is in $_, I can do: > > %Rec = split > > Is there an equivalent simple way to do this with python? I've done > it by converting the data into a list and using a while loop to set > the dictionary entries. However, the log files have about 4 million > entries per day so I need something that is fast. > > Any help / suggestions most appreciated. -------------- next part -------------- An HTML attachment was scrubbed... URL: From neelk at alum.mit.edu Fri Feb 16 16:49:28 2001 From: neelk at alum.mit.edu (Neelakantan Krishnaswami) Date: 16 Feb 2001 15:49:28 GMT Subject: PEP-0234: Iterators Message-ID: I have a couple of comments about the iterators proposal. The need for improving the iteration protocol has been apparent for a really long time, and I'm really glad to see that a PEP for it has appeared. However, in its current form I think that what the PEP proposes can be simplified a bit. You can get a simplification if the separate protocols for sequence and mappings were combined, and an iterator was an object with methods "current_index", "current_value", and "next_state". The "current index" of a sequence would be the position in the list, and the "current index" of a mapping would the key that yields that value. So then a loop like: for elt in coll: # Stuff would be equivalent to: iterator = coll.__iter__() while 1: elt = iterator.current_value() # Stuff try: iterator = iterator.next_state() except IndexError: break The "key:value" syntax could then be the same for mappings and sequences: for key:value in coll: # Stuff iterator = coll.__iter__() while 1: key = iterator.current_index() val = iterator.current_value() # Stuff try: iterator = iterator.next_state() except IndexError: break And similar variations (":value", "key:") would follow logically. Neel From jeremy at alum.mit.edu Fri Feb 16 17:57:09 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Fri, 16 Feb 2001 11:57:09 -0500 (EST) Subject: PEP-0234: Iterators In-Reply-To: References: Message-ID: <14989.23525.754713.423514@w221.z064000254.bwi-md.dsl.cnc.net> Neel (and others who have responded), You should also send a copy of your comments to the PEP author, in the case of 234, Ka-Ping Yee . There's no problem discussing it on python-list, but the PEP author might miss them without an explicit cc. Jeremy From olivier.deckmyn at mail.dotcom.fr Fri Feb 16 17:05:37 2001 From: olivier.deckmyn at mail.dotcom.fr (Olivier Deckmyn) Date: Fri, 16 Feb 2001 17:05:37 +0100 Subject: PIL Fonts Message-ID: <96jj4p$172n$1@feed.teaser.net> Hi all ! Is there a way to use TrueType or PostScript font with ImageDraw in PIL ? I know it exists a conversion tool to make PIL fonts from X fonts...But I don't have any "nice" X font :( Any idea ? ps : is the python t1lib project discontinued ? --- We are Micro$oft. You will be assimilated. Resistance is futile. From chris.gonnerman at usa.net Sat Feb 17 07:03:38 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sat, 17 Feb 2001 00:03:38 -0600 Subject: PIL Fonts References: <96jj4p$172n$1@feed.teaser.net> Message-ID: <010a01c098a7$68082ae0$a100000a@local> ----- Original Message ----- From: "Olivier Deckmyn" Subject: PIL Fonts >... > Is there a way to use TrueType or PostScript font with ImageDraw in PIL ? > I know it exists a conversion tool to make PIL fonts from X fonts...But I > don't have any "nice" X font :( >... I got so irritated with PIL over font support that I took over the gdmodule project from Richard Jones. If you do a lot of graphics with text on them, in PNG or JPEG format, then get the GD library (and FreeType, and libjpeg and libpng... hope you already have some installed) and finally build my updated gdmodule. You get graphics with TrueType font support! BTW the core GD library doesn't do a real great job on JPEG files IMHO; I must admit, I create things like button frames in the GIMP or on Windoze using Paint Shop Pro, save them as PNG, then fill in the text with Python and the gdmodule, and finally use GIMP or ImageMagick to convert to GIF or JPEG. Ugly, but after the button frames are created I can fully script the rest. My gdmodule page is: http://newcenturycomputers.net/projects/gdmodule From chris.gonnerman at usa.net Sat Feb 17 17:03:22 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sat, 17 Feb 2001 10:03:22 -0600 Subject: PIL Fonts References: <96jj4p$172n$1@feed.teaser.net> <010a01c098a7$68082ae0$a100000a@local> <001701c098b7$e1f68300$0200000a@kashmir2k> Message-ID: <000b01c098fb$2bcf6800$a100000a@local> ----- Original Message ----- From: "Olivier Deckmyn" Subject: Re: PIL Fonts > Thanx for your support ! > > Unfortunaly, gd lacks for filters support :-( > > I wonder how I can use GD just for making TrueType rendering and insert play > with them from PIL... > > Thanx anyway ! > Olivier. It's kludgy, but you can create your graphics in PIL, save them as PNG, load them with GD, add text, save with GD, open in PIL and revise more if needed... I've been told there is a FreeType module to plug in to PIL, which would be great, but I can't find any examples for using it. (To be fair, it has been a while since I looked.) From fredrik at pythonware.com Sat Feb 17 19:51:21 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 17 Feb 2001 18:51:21 GMT Subject: PIL Fonts References: <96jj4p$172n$1@feed.teaser.net> Message-ID: Olivier Deckmyn wrote: > Is there a way to use TrueType or PostScript font with ImageDraw in PIL ? > I know it exists a conversion tool to make PIL fonts from X fonts...But I > don't have any "nice" X font :( TrueType (freetype) support for Python/PIL is available here: http://starship.python.net/crew/kernr/Projects.html and http://effbot.org/pil (windows only, at this time) Cheers /F From olivier.deckmyn at mail.dotcom.fr Mon Feb 19 12:12:15 2001 From: olivier.deckmyn at mail.dotcom.fr (Olivier Deckmyn) Date: Mon, 19 Feb 2001 12:12:15 +0100 Subject: PIL Fonts References: <96jj4p$172n$1@feed.teaser.net> Message-ID: <96qv2n$2nao$1@feed.teaser.net> Is there any luck one can have the unix/sources version of _imagingft module ? Anyway, thanx again Fred for your support ! "Fredrik Lundh" a ?crit dans le message news: JKzj6.17963$AH6.2439731 at newsc.telia.net... > Olivier Deckmyn wrote: > > Is there a way to use TrueType or PostScript font with ImageDraw in PIL ? > > I know it exists a conversion tool to make PIL fonts from X fonts...But I > > don't have any "nice" X font :( > > TrueType (freetype) support for Python/PIL is available here: > > http://starship.python.net/crew/kernr/Projects.html > > and > > http://effbot.org/pil (windows only, at this time) > > Cheers /F > > From fredrik at pythonware.com Mon Feb 19 14:33:40 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 19 Feb 2001 13:33:40 GMT Subject: PIL Fonts References: <96jj4p$172n$1@feed.teaser.net> <96qv2n$2nao$1@feed.teaser.net> Message-ID: Olivier Deckmyn wrote: > Is there any luck one can have the unix/sources version of > _imagingft module? sure, but not now -- it's a bit too messy for release, and I don't have time to clean it up right now. > Anyway, thanx again Fred for your support ! looks like someone hasn't read the PIL faq... http://www.pythonware.com/products/pil/faq.htm > We are Micro$oft. You will be assimilated. Resistance is futile. you mean "all your base are belong to us", don't you? Cheers /F From rtexier at elikya.com Mon Feb 19 11:35:53 2001 From: rtexier at elikya.com (Romuald Texier) Date: Mon, 19 Feb 2001 10:35:53 +0000 Subject: PIL Fonts References: <96jj4p$172n$1@feed.teaser.net> Message-ID: <96qpe1$81a$1@news.irisa.fr> Olivier Deckmyn wrote: > Hi all ! > > Is there a way to use TrueType or PostScript font with ImageDraw in PIL ? > I know it exists a conversion tool to make PIL fonts from X fonts...But I > don't have any "nice" X font :( > > Any idea ? > ps : is the python t1lib project discontinued ? Why not using PyGimp ? It a Python binding for gimp : all the power of this graphics factory within your scripts ! (contrarily to Script-fu, Python has the control ; it is actually a wrapper to libgimp) http://www.daa.com.au/~james/pygimp/ -- Romuald Texier From olivier.deckmyn at mail.dotcom.fr Mon Feb 19 12:17:06 2001 From: olivier.deckmyn at mail.dotcom.fr (Olivier Deckmyn) Date: Mon, 19 Feb 2001 12:17:06 +0100 Subject: PIL Fonts References: <96jj4p$172n$1@feed.teaser.net> <96qpe1$81a$1@news.irisa.fr> Message-ID: <96qvbq$2nce$1@feed.teaser.net> Doest this mean that a python script can delegate the making and render of an Image to Gimp and get it back as a JPEG in a string for example ? "Romuald Texier" a ?crit dans le message news: 96qpe1$81a$1 at news.irisa.fr... > Olivier Deckmyn wrote: > > > Hi all ! > > > > Is there a way to use TrueType or PostScript font with ImageDraw in PIL ? > > I know it exists a conversion tool to make PIL fonts from X fonts...But I > > don't have any "nice" X font :( > > > > Any idea ? > > ps : is the python t1lib project discontinued ? > > Why not using PyGimp ? It a Python binding for gimp : all the power of this > graphics factory within your scripts ! (contrarily to Script-fu, Python has > the control ; it is actually a wrapper to libgimp) > > http://www.daa.com.au/~james/pygimp/ > > -- > Romuald Texier From rtexier at elikya.com Tue Feb 20 12:16:50 2001 From: rtexier at elikya.com (Romuald Texier) Date: Tue, 20 Feb 2001 11:16:50 +0000 Subject: PIL Fonts References: <96jj4p$172n$1@feed.teaser.net> <96qpe1$81a$1@news.irisa.fr> <96qvbq$2nce$1@feed.teaser.net> Message-ID: <96tg6s$cip$1@news.irisa.fr> Olivier Deckmyn wrote: > Doest this mean that a python script can delegate the making and render of > an Image to Gimp and get it back as a JPEG in a string for example ? I do not know if you can get it back in a string. In a file, sure. If you want it in a string, that means you want to further process it, isn't it ? So why not make all processing in Gimp and only get a file ? The problem is if you want to make dynamic images without disk usage, though. If you find a way, I would be interested in it ;o) Sincerely, -- Romuald Texier From mnajmeddine at geo.census.gov Fri Feb 16 17:51:15 2001 From: mnajmeddine at geo.census.gov (Mohamed Najmeddine) Date: Fri, 16 Feb 2001 11:51:15 -0500 Subject: CGI/networking Message-ID: Hello, I'm trying to create a web interface. The users should be able to execute the cgi scripts that will access their CDROM drive and check the files that the CD contains and compared that list to a file installed on the WEBSERVER (on a different machine UNIX). My problem is how to get the cgi script access the hard drive of the PC users. If anyone could point me to the right direction, I would appreciate it. (Do I need to use Sockets... and are modules that would facilitate my job) Thanks, Med. From glenfant at equod.com.nospam Fri Feb 16 18:20:35 2001 From: glenfant at equod.com.nospam (Gillou) Date: Fri, 16 Feb 2001 18:20:35 +0100 Subject: CGI/networking References: Message-ID: <96jn5t$e7s$1@reader1.imaginet.fr> Hopefully this is not possible for privacy/security reasons ! "Mohamed Najmeddine" a ?crit dans le message news: mailman.982342354.21385.python-list at python.org... > Hello, > I'm trying to create a web interface. The users should be able to execute > the cgi scripts that will access their CDROM drive and check the files that > the CD contains and compared that list to a file installed on the WEBSERVER > (on a different machine UNIX). My problem is how to get the cgi script > access the hard drive of the PC users. If anyone could point me to the right > direction, I would appreciate it. (Do I need to use Sockets... and are > modules that would facilitate my job) > Thanks, > Med. > > From sholden at holdenweb.com Fri Feb 16 18:34:02 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 16 Feb 2001 12:34:02 -0500 Subject: CGI/networking References: Message-ID: "Mohamed Najmeddine" wrote in message news:mailman.982342354.21385.python-list at python.org... > Hello, > I'm trying to create a web interface. The users should be able to execute > the cgi scripts that will access their CDROM drive and check the files that > the CD contains and compared that list to a file installed on the WEBSERVER > (on a different machine UNIX). My problem is how to get the cgi script > access the hard drive of the PC users. If anyone could point me to the right > direction, I would appreciate it. (Do I need to use Sockets... and are > modules that would facilitate my job) > Thanks, > Med. > > This would depend on either: a) Delivering active content (Javascript/VBScript/Java) to the client, and having it execute, examine the filestore, and return results to the web server, or b) Having a network process on the client listening for connections from your cgi agent, and again returning results. In short, much effort has been expended to (try to) ensure that such solutions are not available. Active content is normally prevented frommanipulating the client filestore for security reasons. You could modify your clients to allow such access in various ways, but all of them represent fairly nasty security holes. regards Steve From bshapiro at funnygarbage.com Fri Feb 16 18:04:27 2001 From: bshapiro at funnygarbage.com (Ben Shapiro) Date: Fri, 16 Feb 2001 12:04:27 -0500 Subject: pywin and wxPython Message-ID: <96jmi1$jst$1@bob.news.rcn.net> Hey all... Here's the predicament.. I have an OCX control that is responsible for playback of mp3 files that i am trying to use from python. This control is wrapped using makepy. Mark H pointed me in the right direction to use pywin to host the OCX.. only problem is that my app uses wxPython as the GUI framework. From what i can tell you need to attach the activex control to an MFC window for it to load.... Any example of how to do this would be appreciated greatly! My existing code is below: p = win32ui.CreateWnd() win32ui.EnableControlContainer() mp3player = gencache.EnsureModule('{2DF09BC5-B050-11D2-81C1-00C0DFEAA961}', 0, 1, 0) self.olectl = activex.MakeControlInstance(mp3player.AMPL3DLite) self.olectl.CreateControl("", win32con.WS_TABSTOP , (7,43,500,300), p , 131) <---- fails here / nothing seems to happen if i comment out this line self.olectl.Open("c:\\code\\3LP\\pyfileunder\\music\\test.mp3") self.olectl.Play() From bshapiro at funnygarbage.com Fri Feb 16 18:09:08 2001 From: bshapiro at funnygarbage.com (Ben Shapiro) Date: Fri, 16 Feb 2001 12:09:08 -0500 Subject: pywin and wxPython References: <96jmi1$jst$1@bob.news.rcn.net> Message-ID: <96jmqp$kvu$1@bob.news.rcn.net> oops i forgot to mention that this activeX control has no GUI so i really just need to load it without displaying anything "Ben Shapiro" wrote in message news:96jmi1$jst$1 at bob.news.rcn.net... > Hey all... > Here's the predicament.. > I have an OCX control that is responsible for playback of mp3 files that i > am trying to > use from python. This control is wrapped using makepy. Mark H pointed me > in the right > direction to use pywin to host the OCX.. only problem is that my app uses > wxPython as the > GUI framework. From what i can tell you need to attach the activex control > to an MFC window for > it to load.... Any example of how to do this would be appreciated greatly! > > My existing code is below: > > p = win32ui.CreateWnd() > win32ui.EnableControlContainer() > mp3player = > gencache.EnsureModule('{2DF09BC5-B050-11D2-81C1-00C0DFEAA961}', 0, 1, 0) > self.olectl = activex.MakeControlInstance(mp3player.AMPL3DLite) > self.olectl.CreateControl("", win32con.WS_TABSTOP , (7,43,500,300), > p , 131) <---- fails here / nothing seems to happen if i comment out this > line > self.olectl.Open("c:\\code\\3LP\\pyfileunder\\music\\test.mp3") > self.olectl.Play() > > From SBrunning at trisystems.co.uk Fri Feb 16 18:04:30 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 16 Feb 2001 17:04:30 -0000 Subject: Windows/Cygwin/MacOSX import (was RE: python-dev summary, 200 1-02-01 - 2001-02-15) Message-ID: <31575A892FF6D1118F5800600846864D78B91D@intrepid> > From: claird at starbase.neosoft.com [SMTP:claird at starbase.neosoft.com] > 2. I hope a few OS/400 and OpenVMS refugees convert and > walk through the door soon. *That* would make for a > nice dose of fun. As far as OS/400 goes, check out Per Gummedal's fine work at . Also, see . Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From info at black-karma.de Fri Feb 16 18:13:13 2001 From: info at black-karma.de (Harvest T. Moon) Date: Fri, 16 Feb 2001 18:13:13 +0100 Subject: Q: Tkinter text widget Message-ID: <96jn22$kqb59$1@ID-22517.news.dfncis.de> how do i change the text color for specific lines in a text widget, so i can have different lines with different colored text? (or at least some words different colored/styled i.e. bold etc.) Harvest T. Moon -- a life less ordinary!! From fredrik at pythonware.com Sat Feb 17 10:52:40 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 17 Feb 2001 09:52:40 GMT Subject: Tkinter text widget References: <96jn22$kqb59$1@ID-22517.news.dfncis.de> Message-ID: "Harvest T. Moon" wrote: > how do i change the text color for specific lines in a text widget, so i can > have different lines with different colored text? (or at least some words > different colored/styled i.e. bold etc.) use tags: text.tag_config("highlight", foreground="red") text.insert(INSERT, "red text", "highlight") # insert coloured text text.tag_add("highlight", 5.0, 6.0) # highlight line 5 also see: http://www.pythonware.com/library/tkinter/introduction/text.htm => "concepts" Cheers /F From aboufer at atlsci.com Fri Feb 16 18:24:49 2001 From: aboufer at atlsci.com (aboufer at atlsci.com) Date: Fri, 16 Feb 2001 12:24:49 -0500 Subject: Python threads ( termination ) Message-ID: <3A8D6261.7EE44EF0@atlsci.com> Greetings, I am trying to write a multi-threaded app using python, and I am trying to find a way to stop/terminate a thread from within another. Here is an example : import threading mySuccess = 0 class MyThread( threading.Thread) : def __init__( self, name='hello') : threading.Thread.__init__( self, name=name) def run(self) : global mySuccess import random for x in range(10) : threading._sleep( random() ) print 'Hello ', x mySuccess = 1 myTest() : t1 = MyThread() t1.start() t1.join( 0.1 ) if mySuccess == 1 : print 'Thread exited okay' else : print 'Thread did not respond !!' I need a way to kill thread t1 here <------------------------ if __name__ == '__main__' : myTest() In this example, my function myTest calls join() on thread t1, with a specified time_out. What I would like to do is to terminate/stop thread t1 if it does not respond within timeout. Thanks all From dan at eevolved.com Fri Feb 16 18:23:39 2001 From: dan at eevolved.com (Dan Parisien) Date: Fri, 16 Feb 2001 17:23:39 GMT Subject: Python threads ( termination ) References: <3A8D6261.7EE44EF0@atlsci.com> Message-ID: aboufer at atlsci.com wrote: > Greetings, > > I am trying to write a multi-threaded app using python, and I am > trying to find > a way to stop/terminate a thread from within another. > > Here is an example : > > import threading > > mySuccess = 0 > > class MyThread( threading.Thread) : > def __init__( self, name='hello') : > threading.Thread.__init__( self, name=name) > > def run(self) : > global mySuccess > import random > > for x in range(10) : > threading._sleep( random() ) > print 'Hello ', x > > mySuccess = 1 > > myTest() : > t1 = MyThread() > t1.start() > > t1.join( 0.1 ) > > if mySuccess == 1 : > print 'Thread exited okay' > else : > print 'Thread did not respond !!' > I need a way to kill thread t1 here <------------------------ > > if __name__ == '__main__' : > myTest() > > > In this example, my function myTest calls join() on thread t1, with a > specified time_out. What I would like to > do is to terminate/stop thread t1 if it does not respond within timeout. > > > > Thanks all > You could use 2 threading.Event instances to communicate between threads and have the 'bad' thread terminate itself. There is no real way to terminate a thread from another thread... Dan From jmarshal at mathworks.com Fri Feb 16 18:52:07 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 16 Feb 2001 17:52:07 GMT Subject: Python threads ( termination ) References: <3A8D6261.7EE44EF0@atlsci.com> Message-ID: <96jpc7$h5k$1@news.mathworks.com> Dan Parisien wrote: > You could use 2 threading.Event instances to communicate between threads > and have the 'bad' thread terminate itself. > There is no real way to terminate a thread from another thread... > Dan You can do this if it's the main thread you're trying to kill. If you send the process a signal, it's caught by the main thread. In a project I'm working on, we need to run arbitrary Python code which may do Bad Things (like go into an infinite loop). So we have the main thread execute this untrusted code, and have a second thread occasionally checking up on the main one to be sure progress is being made. If the main thread is spending too much time executing a chunk of code, the second thread signals the process, raising an exception in the main thread, which then moves on and does something productive. Of course this is only useful if there's only one thread you're interested in manipulating. From hamish_lawson at yahoo.co.uk Fri Feb 16 18:36:55 2001 From: hamish_lawson at yahoo.co.uk (=?iso-8859-1?q?Hamish=20Lawson?=) Date: Fri, 16 Feb 2001 17:36:55 +0000 (GMT) Subject: What became of BeOpen? Message-ID: <20010216173655.20521.qmail@web204.mail.yahoo.com> What actually became of BeOpen, PythonLab's former home? I understand that they were in some difficulties, and, judging from the fact that the beopen.com domain is up for sale, I'm guessing that they folded. 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 hamish_lawson at yahoo.co.uk Fri Feb 16 18:38:37 2001 From: hamish_lawson at yahoo.co.uk (=?iso-8859-1?q?Hamish=20Lawson?=) Date: Fri, 16 Feb 2001 17:38:37 +0000 (GMT) Subject: What became of BeOpen? Message-ID: <20010216173837.3547.qmail@web216.mail.yahoo.com> What actually became of BeOpen, PythonLab's former home? I understand that they were in some difficulties, and, judging from the fact that the beopen.com domain is up for sale, I'm guessing that they folded. 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 owen at astroNOJNK.washington.edu.invalid Fri Feb 16 18:41:05 2001 From: owen at astroNOJNK.washington.edu.invalid (Russell E. Owen) Date: Fri, 16 Feb 2001 09:41:05 -0800 Subject: Discussion about PEP 234: iterators Message-ID: <96jonj$i0e$1@nntp6.u.washington.edu> This is in reaction to the new iterator proposal : My own reaction is "great!" one misgiving: it does not address a very common need: to iterate over a dictionary in key-sorted order. Is there some variant syntax that could handle this case? (Better yet, and going out on thin ice here, could this be made the default? I realize that's unlikely and may anger some people to even suggest it, but I would like to point out that some languages actually store dictionaries with their keys ordered, so it's at least technically feasible). If this issue cannot be addressed, could we at least get "sort" to return the sorted collection, so one could do: for key in dictionary.keys().sort(): -- Russell From aleaxit at yahoo.com Fri Feb 16 20:39:56 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 16 Feb 2001 20:39:56 +0100 Subject: Discussion about PEP 234: iterators References: <96jonj$i0e$1@nntp6.u.washington.edu> Message-ID: <96k28b01utj@news2.newsguy.com> "Russell E. Owen" wrote in message news:96jonj$i0e$1 at nntp6.u.washington.edu... > This is in reaction to the new iterator proposal > : > > My own reaction is "great!" one misgiving: it does not address a very > common need: to iterate over a dictionary in key-sorted order. Is there > some variant syntax that could handle this case? > > (Better yet, and going out on thin ice here, could this be made the > default? I realize that's unlikely and may anger some people to even > suggest it, but I would like to point out that some languages actually > store dictionaries with their keys ordered, so it's at least technically > feasible). One can choose to store mappings using sorted order on keys (that, for example, is how C++'s standard std::map is specified to work), but performance for all other tasks can suffer quite substantially when compared to hash tables. Python uses dictionaries so widely that _any_ hit on dictionary performance would not be acceptable. I would suggest leaving dictionaries alone and supplying another instance of mapping, based on red-black trees or some variant thereon, if the sorted-keys requirement is indeed so widespread. > If this issue cannot be addressed, could we at least get "sort" to > return the sorted collection, so one could do: > > for key in dictionary.keys().sort(): Why not def sort(adisposablelist): adisposablelist.sort() return adisposablelist and then for key in sort(dictionary.keys()): Is the syntax-sugar difference so big, after all? Alex From othello at javanet.com Fri Feb 16 23:09:47 2001 From: othello at javanet.com (Raymond Hettinger) Date: Fri, 16 Feb 2001 17:09:47 -0500 Subject: Discussion about PEP 234: iterators References: <96jonj$i0e$1@nntp6.u.washington.edu> <96k28b01utj@news2.newsguy.com> Message-ID: <3A8DA52A.254849DB@javanet.com> I think dictionary iteration should match iterations on other objects/types as closely as possible unless performance is impacted. for elem in list # does not automatically sort for key in dict # so this should not automatically sort for key:value in dict # proposed for index:item in list # so this should work if elem in list # this works if key in dict # so this should work map( fun, list ) # this works map( func, dict ) # so this should work with functions that take a key as a parameter filter( boolfun, list ) # gives a possibly smaller list filter( boolfun, dict ) # so this should return a possibly smaller dictionary Thanks, Raymond From tim.hochberg at ieee.org Fri Feb 16 23:39:16 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Fri, 16 Feb 2001 22:39:16 GMT Subject: Discussion about PEP 234: iterators References: <96jonj$i0e$1@nntp6.u.washington.edu> <96k28b01utj@news2.newsguy.com> <3A8DA52A.254849DB@javanet.com> Message-ID: "Raymond Hettinger" wrote in message news:3A8DA52A.254849DB at javanet.com... > I think dictionary iteration should match iterations on other objects/types > as closely as possible unless performance is impacted. Ok then, let me put on my pedantic hat. . . Oof, that's a tight fit. > for elem in list # does not automatically sort > for key in dict # so this should not automatically sort > > for key:value in dict # proposed > for index:item in list # so this should work Alright, looking at what you have so far, you've established a one to one correspondence between dictionary keys and sequence indices as well as between dictionary values and sequence values. That seems to make sense, but this next bit is where we run into trouble -- consistency runs head on into practicality and peoples expectations. > if elem in list # this works > if key in dict # so this should work If one is going to go by the correspondence that you've set up above, then really the dictionary equivalent should be: if value in dict: Unfortunately, people tend to think of a dictionary as containing keys more than they think of it as containing definitions (values). So the form you propose is better from that point of view. It's also probably more useful in a practical sense as well. It is kind of distressing that it's not consistent with the correspondence that's set up between keys<->indices and values<->values though. > map( fun, list ) # this works > map( func, dict ) # so this should work with functions that take a key as > a parameter This is not obvious to me. I would think that this would need a function that takes values as parameters and would produce: {key1 : func(val1), key2 : func(val2) ....} I can't even figure out how this would work if func operated on keys. That seems to be a bad sign for the obviousness of this construct..... > filter( boolfun, list ) # gives a possibly smaller list > filter( boolfun, dict ) # so this should return a possibly smaller > dictionary But how would it work? If were to guess at the meaning of something like this I'd get: dict = {} for key, value in dict.keys(): if boolfun(value): dict[key] = value But being as we disagreed above, I'm not sure that we agree here. I too would like to see everything as consistent as possible (but no consistenter[sic]), but I'm not sure that agreement can be reached on that. -tim From joconnor at cybermesa.com Fri Feb 16 23:56:38 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Fri, 16 Feb 2001 15:56:38 -0700 Subject: Discussion about PEP 234: iterators References: <96jonj$i0e$1@nntp6.u.washington.edu> <96k28b01utj@news2.newsguy.com> <3A8DA52A.254849DB@javanet.com> Message-ID: <3A8DB026.CE29126C@cybermesa.com> Tim Hochberg wrote: > "Raymond Hettinger" wrote in message > news:3A8DA52A.254849DB at javanet.com... > > I think dictionary iteration should match iterations on other > objects/types > > as closely as possible unless performance is impacted. > ... > > > > if elem in list # this works > > if key in dict # so this should work > > If one is going to go by the correspondence that you've set up above, then > really the dictionary equivalent should be: > > if value in dict: > > Unfortunately, people tend to think of a dictionary as containing keys more > than they think of it as containing definitions (values). So the form you > propose is better from that point of view. It's also probably more useful in > a practical sense as well. It is kind of distressing that it's not > consistent with the correspondence that's set up between keys<->indices and > values<->values though. Actually, given my Smalltalk background, I tend to see Dictionaries as containing Associations (an Assocaiation is a key value pair) Thus looping over a Dictionary returns an association on each iteration. To carry this to Python, I would like to see looping over Dictionaries return a Tuple of the key,value pair. Allowing either: for assoc in dictionary: print "key %s = value %s" % (assoc[0], assoc[1]) or for (key, value) in dictionary: print "key %s = value %s" % (key,value) Take care, Jay O'Connor joconnor at cybermesa.com From pingster at cs.berkeley.edu Sun Feb 18 11:48:58 2001 From: pingster at cs.berkeley.edu (Ka-Ping Yee) Date: Sun, 18 Feb 2001 02:48:58 -0800 Subject: Join python-iter@yahoogroups.com to discuss PEP 234 In-Reply-To: <3A8DB026.CE29126C@cybermesa.com> References: <96jonj$i0e$1@nntp6.u.washington.edu> <96k28b01utj@news2.newsguy.com> <3A8DA52A.254849DB@javanet.com> <3A8DB026.CE29126C@cybermesa.com> Message-ID: Hello all, I'd like to thank you for your thoughts and comments about PEP 234 and invite you to join a discussion group on the topic of iteration in Python. Greg Wilson has graciously established python-iter at yahoogroups.com as a place where we can focus a conversation on this issue. If you're interested in talking about it, please join! http://groups.yahoo.com/group/python-iter Thanks! -- Ping From n8gray at caltech.edu.is.my.email.address Sun Feb 18 08:10:47 2001 From: n8gray at caltech.edu.is.my.email.address (Nathaniel Gray) Date: Sat, 17 Feb 2001 23:10:47 -0800 Subject: Discussion about PEP 234: iterators References: <96jonj$i0e$1@nntp6.u.washington.edu> <96k28b01utj@news2.newsguy.com> <3A8DA52A.254849DB@javanet.com> Message-ID: <96nst0$pe9@gap.cco.caltech.edu> Tim Hochberg wrote: > [snip discussion of consistency of "if thing in dict:"] > > Unfortunately, people tend to think of a dictionary as containing keys > more than they think of it as containing definitions (values). So the form > you propose is better from that point of view. It's also probably more > useful in a practical sense as well. It is kind of distressing that it's > not consistent with the correspondence that's set up between > keys<->indices and values<->values though. Hmm... I tend to think of a dictionary as containing values more than keys. The keys are just there so you can get to the values, right? Others tend to think dicts contain (key, value) pairs. Everybody has a different opinion on this one. Rather than supplying an arbitrary default, which would lead to confusion, how about we let the programmer specify things explicitly. How about we make it: if key in dict.keys(): and if value in dict.values(): and maybe even if (key, value) in dict.items(): That way it's perfectly clear what the programmer intended. I think there's a really good chance of Guido accepting this proposal, and I've already written a fully backwards-compatible patch. Anybody up for a trip back in time? -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From aahz at panix.com Sun Feb 18 17:00:00 2001 From: aahz at panix.com (Aahz Maruch) Date: 18 Feb 2001 08:00:00 -0800 Subject: Discussion about PEP 234: iterators References: <96jonj$i0e$1@nntp6.u.washington.edu> <3A8DA52A.254849DB@javanet.com> <96nst0$pe9@gap.cco.caltech.edu> Message-ID: <96ori0$mq$1@panix3.panix.com> In article <96nst0$pe9 at gap.cco.caltech.edu>, Nathaniel Gray wrote: > >Hmm... I tend to think of a dictionary as containing values more than keys. > The keys are just there so you can get to the values, right? Others tend >to think dicts contain (key, value) pairs. Everybody has a different >opinion on this one. Rather than supplying an arbitrary default, which >would lead to confusion, how about we let the programmer specify things >explicitly. > >How about we make it: >if key in dict.keys(): >and >if value in dict.values(): >and maybe even >if (key, value) in dict.items(): The problem with this is absolutely horrendous speed/memory performance with any large dictionary. Your code generates a list AND THEN DOES A LINEAR SEARCH. No, no, no, no, no, no, no. We've already got if dict.has_key(key): and if key in dict: is a thin layer of sugar-coating designed to create greater usage equivalence between lists and dicts. I'm not particularly fond of it, but it does have the advantage of not being forced to remember whether has_key() has an underscore in it. -- --- 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 Why doesn't "Just Say NO" include caffeine, nicotine, alcohol, Prozac, and Ritalin? --Aahz From jpet at eskimo.com Mon Feb 19 04:32:41 2001 From: jpet at eskimo.com (Jeff Petkau) Date: Mon, 19 Feb 2001 03:32:41 GMT Subject: Discussion about PEP 234: iterators References: <96jonj$i0e$1@nntp6.u.washington.edu> <3A8DA52A.254849DB@javanet.com> <96nst0$pe9@gap.cco.caltech.edu> <96ori0$mq$1@panix3.panix.com> Message-ID: Aahz Maruch wrote in message news:96ori0$mq$1 at panix3.panix.com... > In article <96nst0$pe9 at gap.cco.caltech.edu>, > Nathaniel Gray wrote: > > > >How about we make it: > >if key in dict.keys(): > >if value in dict.values(): > >if (key, value) in dict.items(): > > The problem with this is absolutely horrendous speed/memory performance > with any large dictionary. Your code generates a list AND THEN DOES A > LINEAR SEARCH. No, no, no, no, no, no, no. We've already got Instead of inventing new syntax for inefficent idioms, we could just make the idioms more efficent, by having values(), keys(), and items() return proxy objects with __contains__() and sequential __getitem__() functions. Alas, this isn't backwards compatible with old code that expects a real list object. Possible solutions, in descending order of sanity: - make new functions called xkeys(), xvalues(), etc. to return the proxies. Pretty ugly, but consistent with xrange() and xreadlines(). - just live with it. - make 'dict.keys' return the proxy object, which is callable. Make proxy.__call__() return an actual list from the proxy so dict.keys() works as before. So cute I'm ashamed I even thought of it. --Jeff Petkau (jpet at eskimo.com), currently specializing in poorly thought out solutions. From hzhu at users.sourceforge.net Tue Feb 20 04:23:22 2001 From: hzhu at users.sourceforge.net (Huaiyu Zhu) Date: Tue, 20 Feb 2001 03:23:22 GMT Subject: Best solution (Re: Discussion about PEP 234: iterators) References: <96jonj$i0e$1@nntp6.u.washington.edu> <3A8DA52A.254849DB@javanet.com> <96nst0$pe9@gap.cco.caltech.edu> <96ori0$mq$1@panix3.panix.com> Message-ID: On Mon, 19 Feb 2001 03:32:41 GMT, Jeff Petkau wrote: >- make 'dict.keys' return the proxy object, which is > callable. Make proxy.__call__() return an actual > list from the proxy so dict.keys() works as before. > So cute I'm ashamed I even thought of it. What a bright idea! This is the best solution I've seen so far. I'm surprised no one has commented on this yet. So let me spell it out to generate more interest. With this proposal, all of these work as expected for k in dict.keys: for k, v in dict.items: for v in dict.values: without creating extra list. And all of these work as expected if k in dict.keys: if k, v in dict.items: if v in dict.values: Only the last need linear search, which is natural. There will be no confusion over what 'in' means for dict. There is no clutter of code. And "explicit is better than implicit". Furthermore, all the old codes work as well, like a = dict.keys() v = dict.values()[3] x, y = dict.items()[2] Whatever the actual implementation would be, this seems to offer the cleanest syntax space for iterators and has_item proxies and so on whenever they become available. In the actual implementation, all iterators need to provide three magical methods: __getitem__, __contains__ and __call__ with the usual sematic restrictions: __contains__ return true iff __getitem__ will get it at least once. __call__ will return a list of objects returned by __getitem__. __getitem__ raise IndexError at the end. Huaiyu From stephen_purcell at yahoo.com Tue Feb 20 08:57:34 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 20 Feb 2001 08:57:34 +0100 Subject: Best solution (Re: Discussion about PEP 234: iterators) In-Reply-To: ; from hzhu@users.sourceforge.net on Tue, Feb 20, 2001 at 03:23:22AM +0000 References: <96jonj$i0e$1@nntp6.u.washington.edu> <3A8DA52A.254849DB@javanet.com> <96nst0$pe9@gap.cco.caltech.edu> <96ori0$mq$1@panix3.panix.com> Message-ID: <20010220085734.A13854@freedom.puma-ag.com> Huaiyu Zhu wrote: > > >- make 'dict.keys' return the proxy object, which is > > callable. Make proxy.__call__() return an actual > > list from the proxy so dict.keys() works as before. > > So cute I'm ashamed I even thought of it. > > What a bright idea! This is the best solution I've seen so far. I'm > surprised no one has commented on this yet. So let me spell it out to > generate more interest. > > With this proposal, all of these work as expected > > for k in dict.keys: > for k, v in dict.items: > for v in dict.values: > > without creating extra list. And all of these work as expected > > if k in dict.keys: > if k, v in dict.items: > if v in dict.values: I love it. Where do I vote? :-) This is *much* nicer looking than the peculiar new ':' syntax. -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 s713221 at student.gu.edu.au Tue Feb 20 12:02:36 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Tue, 20 Feb 2001 21:02:36 +1000 Subject: Best solution (Re: Discussion about PEP 234: iterators) References: <96jonj$i0e$1@nntp6.u.washington.edu> <3A8DA52A.254849DB@javanet.com> <96nst0$pe9@gap.cco.caltech.edu> <96ori0$mq$1@panix3.panix.com> Message-ID: <3A924ECC.6E0A1A@student.gu.edu.au> Huaiyu Zhu wrote: > > On Mon, 19 Feb 2001 03:32:41 GMT, Jeff Petkau wrote: > > >- make 'dict.keys' return the proxy object, which is > > callable. Make proxy.__call__() return an actual > > list from the proxy so dict.keys() works as before. > > So cute I'm ashamed I even thought of it. > > What a bright idea! This is the best solution I've seen so far. I'm > surprised no one has commented on this yet. So let me spell it out to > generate more interest. > > With this proposal, all of these work as expected > > for k in dict.keys: > for k, v in dict.items: > for v in dict.values: > > without creating extra list. And all of these work as expected > > if k in dict.keys: > if k, v in dict.items: > if v in dict.values: > > Only the last need linear search, which is natural. > > There will be no confusion over what 'in' means for dict. There is no > clutter of code. And "explicit is better than implicit". > > Furthermore, all the old codes work as well, like > > a = dict.keys() > v = dict.values()[3] > x, y = dict.items()[2] > > Whatever the actual implementation would be, this seems to offer the > cleanest syntax space for iterators and has_item proxies and so on whenever > they become available. > > In the actual implementation, all iterators need to provide three magical > methods: __getitem__, __contains__ and __call__ with the usual sematic > restrictions: > > __contains__ return true iff __getitem__ will get it at least once. > __call__ will return a list of objects returned by __getitem__. > __getitem__ raise IndexError at the end. > > Huaiyu As long as there aren't any problems unforseen, this gets my vote as well. Joal Heagney/AncientHart From paul.moore at uk.origin-it.com Tue Feb 20 13:44:36 2001 From: paul.moore at uk.origin-it.com (Paul Moore) Date: Tue, 20 Feb 2001 13:44:36 +0100 Subject: Best solution (Re: Discussion about PEP 234: iterators) References: <96jonj$i0e$1@nntp6.u.washington.edu> <3A8DA52A.254849DB@javanet.com> <96nst0$pe9@gap.cco.caltech.edu> <96ori0$mq$1@panix3.panix.com> Message-ID: On Tue, 20 Feb 2001 08:57:34 +0100, Steve Purcell wrote: >Huaiyu Zhu wrote: [...] > >I love it. Where do I vote? :-) You need to copy the proposal to the PEP author, Ka-Ping Yee . He may be reading here, but best to be certain. BTW, I like the look of this, too, but I suspect that there may be subtleties which need addressing. The full PEP had a lot of issues around ensuring backwards compatibility, dealing with user-defined types and the like, which I don't follow well enough to comment myself. Paul. From n8gray at caltech.edu.is.my.email.address Sun Feb 18 09:29:38 2001 From: n8gray at caltech.edu.is.my.email.address (Nathaniel Gray) Date: Sun, 18 Feb 2001 00:29:38 -0800 Subject: Discussion about PEP 234: iterators References: <96jonj$i0e$1@nntp6.u.washington.edu> <96k28b01utj@news2.newsguy.com> <3A8DA52A.254849DB@javanet.com> Message-ID: <96o1h3$qc6@gap.cco.caltech.edu> Raymond Hettinger wrote: > I think dictionary iteration should match iterations on other > objects/types as closely as possible unless performance is impacted. > > for elem in list # does not automatically sort > for key in dict # so this should not automatically sort What about for value in dict # Should this sort? > for key:value in dict # proposed > for index:item in list # so this should work > > if elem in list # this works > if key in dict # so this should work Don't forget if value in dict > map( fun, list ) # this works > map( func, dict ) # so this should work with functions that take a > key as a parameter And those that take a value as a parameter too, right? Don't worry, I'm sure RMS can throw something together with soundex that'll be able to tell when you meant keys and when you meant values. I know I'm being a stickler, but the default of "if thing in dict" is not at all clear to me, and it appears I'm not the only one. Anecdotal evidence from Thomas Wouters (I believe) suggests that a significant number of programmers expect "thing" to be a value, not a key. Others expect a (key, value) pair. It just seems there's no clear default. Oh, and some guy named Guido used to agree with me on this one too... Unlike many of the other folks in opposition to "if key in dict", I'm not totally turned off by the "for key:value in dict" syntax and all of its variants. The syntax is easy to learn and it's explicit, if shorthand, for the programmer's intent. Why not use the same syntax for the "if key:value in dict" version? That way nobody'll be happy! ;^) (except for me, but I won't complain) -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From tim.one at home.com Sat Feb 17 06:19:49 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 17 Feb 2001 00:19:49 -0500 Subject: Discussion about PEP 234: iterators In-Reply-To: <96jonj$i0e$1@nntp6.u.washington.edu> Message-ID: [Russell E. Owen] > This is in reaction to the new iterator proposal > : > > My own reaction is "great!" one misgiving: it does not address a very > common need: to iterate over a dictionary in key-sorted order. Is there > some variant syntax that could handle this case? There's always *some* variant syntax that could be forced to work. For example, for key lambda dict: . > (Better yet, and going out on thin ice here, could this be made the > default? No. dicts can grow very large, and forcing people to pay for a sort when they don't want it would raise justified howls of protest. If you want it sorted, other replies have shown you easy ways to get it sorted. > I realize that's unlikely and may anger some people to even suggest it, Not at all. I only get pissed off when I have to *reply* . > but I would like to point out that some languages actually store > dictionaries with their keys ordered, so it's at least technically > feasible). In fact, the language Guido worked on before Python (ABC) implemented dicts as balanced binary trees. So they were always ordered. He really disliked it, because the truly common dict operations (insert and lookup) were much slower than they are using Python's hash tables. Note too that Python (unlike ABC) doesn't define a total ordering over all values of all types, so it's not currently possible "even in theory" to store all dicts in sorted order ("sorted order" isn't currently well-defined in all cases). you're-one-two-line-function-away-from-bliss-ly y'rs - tim From mertz at gnosis.cx Fri Feb 16 18:53:13 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Fri, 16 Feb 2001 12:53:13 -0500 Subject: Detecting RegEx across Python versions (fwd) Message-ID: I asked earlier: > I have done the following, but would welcome something more > elegant > > [...] > # kludge to detect a regular expression across python versions > elif sys.version[0]=='1' and isinstance(pattern, re.RegexObject): > if pattern.match(name): > files.append(fname) > elif sys.version[0]=='2' and type(pattern)==type(re.compile('')): > if pattern.match(name): > files.append(fname) > elif type(pattern) is StringType: > if fnmatch.fnmatch(name, pattern): > files.append(fname) To which the /F-bot generously replied: | if isinstance(pattern, type("")): | if fnmatch.fnmatch(name, pattern): | files.append(fname) | else: | if pattern.match(name): | files.append(fname) | ---- | try: | if pattern.match(name): | files.append(fname) | except AttributeError: | if fnmatch.fnmatch(name, pattern): | files.append(fname) | ---- | if isinstance(pattern, type("")): | pattern = re.compile(fnmatch.translate(pattern)) | if pattern.match(name): Lundh's solutions are more compact, and probably per my request of more elegant. But I probably should have been explicit with the enthymeme: I would like something that is both more elegant AND no less paranoid. That is, I only want to glob a genuine string, and I only want to regex a genuine re object. Being the suspicious type--wholly untrusting of my callers :-) (since they might be me)--I don't want to let this cause uncaught exceptions on the wrong type for pattern. For example (/F's first example, roughly): >>> pattern = open('spam','w') >>> if isinstance(pattern, type('')): ... print "Got String" ... else: ... if pattern.match('spam'): ... print "Got RegEx" ... Traceback (innermost last): File "", line 4, in ? AttributeError: match My own inelegant code would just pass things through without matching, but also without raising errors. /F's other versions will raise similar uncaught errors. I suppose I could wrap another 'try' around things, and catch those non-string/non-regex things. But I'd still really love to be able to write a clean, version independent, expression of "X is a compiled regex (and not any other thing)." Yours, Lulu... From william_wicker at spectratechnologies.com Fri Feb 16 19:35:12 2001 From: william_wicker at spectratechnologies.com (William Wicker) Date: Fri, 16 Feb 2001 18:35:12 -0000 Subject: Win32 COM: Passing NULL as a value Message-ID: <904A72E79williamwickerspectra@207.126.101.100> I am trying to work via the COM interface to an object that exposes a method something like this: AnObject.DoSomething(doWhat, toWho) where toWho is either a dispatch pointer, or NULL, if toWho is not significant. When I try to do this with obj = win32com.client.Dispatch("AnObject") obj.DoSomething("kick", None) or obj.DoSomething("kick", 0) I get type mismatch errors back from the COM object. Is there a way to pass a NULL pointer via win32 COM? P.S. I'm trying this with the ActiveState Python 2.0 distribution (python win build 202) Thanks! William. From MarkH at ActiveState.com Sat Feb 17 00:58:24 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Fri, 16 Feb 2001 23:58:24 GMT Subject: Win32 COM: Passing NULL as a value References: <904A72E79williamwickerspectra@207.126.101.100> Message-ID: <3A8DBDC4.4040705@ActiveState.com> William Wicker wrote: > I am trying to work via the COM interface to an object that exposes a > method something like this: > > AnObject.DoSomething(doWhat, toWho) > > where toWho is either a dispatch pointer, or NULL, if toWho is not > significant. > > When I try to do this with > > obj = win32com.client.Dispatch("AnObject") > obj.DoSomething("kick", None) None is used to pass a variant with VT_NULL. It works for every object I have come across, so I am afraid I have no idea. Mark. From aleaxit at yahoo.com Sat Feb 17 08:48:23 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 17 Feb 2001 08:48:23 +0100 Subject: Win32 COM: Passing NULL as a value References: <904A72E79williamwickerspectra@207.126.101.100> <3A8DBDC4.4040705@ActiveState.com> Message-ID: <96lag10eee@news2.newsguy.com> "Mark Hammond" wrote in message news:3A8DBDC4.4040705 at ActiveState.com... > William Wicker wrote: > > > I am trying to work via the COM interface to an object that exposes a > > method something like this: > > > > AnObject.DoSomething(doWhat, toWho) > > > > where toWho is either a dispatch pointer, or NULL, if toWho is not > > significant. > > > > When I try to do this with > > > > obj = win32com.client.Dispatch("AnObject") > > obj.DoSomething("kick", None) > > None is used to pass a variant with VT_NULL. It works for every object I have come across, so I am afraid I have no idea. If the AnObject used canonical API's to handle its arguments (VariantChangeType, directly or under the covers) it should indeed work -- a VariantChangeType from VT_NULL to VT_DISPATCH should succeed and give a VARIANT with pdispVal of 0. So, I guess from the symptoms described that AnObject is not being 'canonical' in its handling of arguments. Is there a way to prepare a VARIANT directly in Python, with VT_DISPATCH and pdispVal==0? When met with such issues in the past I used a little helper, an in-process COM server I wrote that supplies a few objects for explicit fine-grained issues of Automation ("prepare a variant with exactly this vt tag-part and exactly this bitpattern in its value-union part" being a good example). But Pythoncom looks like it's powerful enough to handle it directly if one digs deep enough, rather than needing an auxiliary C++ coded library of objects...? Alex From william_wicker at spectratechnologies.com Sat Feb 17 21:48:37 2001 From: william_wicker at spectratechnologies.com (William Wicker) Date: Sat, 17 Feb 2001 20:48:37 -0000 Subject: Win32 COM: Passing NULL as a value References: <904A72E79williamwickerspectra@207.126.101.100> <3A8DBDC4.4040705@ActiveState.com> <96lag10eee@news2.newsguy.com> Message-ID: <904B97719williamwickerspectra@207.126.101.100> aleaxit at yahoo.com (Alex Martelli) wrote in <96lag10eee at news2.newsguy.com>: >"Mark Hammond" wrote in message >news:3A8DBDC4.4040705 at ActiveState.com... >> William Wicker wrote: >> >> > I am trying to work via the COM interface to an object that exposes >> > a method something like this: >> > >> > AnObject.DoSomething(doWhat, toWho) >> > >> > where toWho is either a dispatch pointer, or NULL, if toWho is not >> > significant. >> > >> > When I try to do this with >> > >> > obj = win32com.client.Dispatch("AnObject") >> > obj.DoSomething("kick", None) >> >> None is used to pass a variant with VT_NULL. It works for every >> object I >have come across, so I am afraid I have no idea. > >If the AnObject used canonical API's to handle its arguments >(VariantChangeType, directly or under the covers) it should >indeed work -- a VariantChangeType from VT_NULL to VT_DISPATCH >should succeed and give a VARIANT with pdispVal of 0. So, I >guess from the symptoms described that AnObject is not being >'canonical' in its handling of arguments. > Urgh. I wish I were more suprised by this answer. Thanks to you and Mark. William. From MarkH at ActiveState.com Sun Feb 18 23:20:49 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 18 Feb 2001 22:20:49 GMT Subject: Win32 COM: Passing NULL as a value References: <904A72E79williamwickerspectra@207.126.101.100> <3A8DBDC4.4040705@ActiveState.com> <96lag10eee@news2.newsguy.com> Message-ID: <3A9049E8.8050002@ActiveState.com> Alex Martelli wrote: > Is there a way to prepare a VARIANT directly in Python, with > VT_DISPATCH and pdispVal==0? The only way is to call InvokeTypes() with the correct type tuples setup. Nothing higher level has been created, but I would be willing to discuss how such a feature should be added... Mark. From bridgman at wyeth.gsfc.nasa.gov Fri Feb 16 19:49:26 2001 From: bridgman at wyeth.gsfc.nasa.gov (Tom Bridgman) Date: Fri, 16 Feb 2001 13:49:26 -0500 Subject: Converting an instance to a subclass? Message-ID: <3A8D7636.B8161C45@wyeth.gsfc.nasa.gov> Here's my problem (and we're currently still at Python v1.5.2 on IRIX, if that matters). I've defined a set of classes for manipulating some data, say class A. class A: def __init__(self,a,b,c) ... and I have a number of methods that return me instances or lists of instances of this class. These are part of my general library of classes for this project. However, I need to write a utility which will define methods that are only needed by the utility. I really don't want these methods to be 'permanent' members of the class so I define them in a subclass as part of the utility. Class B(A): def Cleanup(self,x,y,z): ... Is there a way I can cast the instances of class A into instances of class B so I can use the additional methods? I can't find anything about it in "Programming Python" but then I'm not quite sure where to look either. For some reason I suspect I will be embarassed when I find out how simple this might be. :^) Thanks, Tom -- Dr. William T."Tom" Bridgman Scientific Visualization Studio Global Science & Technology, Inc. NASA/Goddard Space Flight Center Email: bridgman at wyeth.gsfc.nasa.gov Code 935 Phone: 301-286-1346 Greenbelt, MD 20771 FAX: TBD http://svs.gsfc.nasa.gov/ From dsh8290 at rit.edu Fri Feb 16 20:42:33 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 16 Feb 2001 14:42:33 -0500 Subject: Converting an instance to a subclass? In-Reply-To: <3A8D7636.B8161C45@wyeth.gsfc.nasa.gov>; from bridgman@wyeth.gsfc.nasa.gov on Fri, Feb 16, 2001 at 01:49:26PM -0500 References: <3A8D7636.B8161C45@wyeth.gsfc.nasa.gov> Message-ID: <20010216144233.C4090@harmony.cs.rit.edu> On Fri, Feb 16, 2001 at 01:49:26PM -0500, Tom Bridgman wrote: [snip] | and I have a number of methods that return me instances or lists of | instances of this class. These are part of my general library of | classes for this project. | | However, I need to write a utility which will define methods that are | only needed by the utility. I really don't want these methods to be | 'permanent' members of the class so I define them in a subclass as part | of the utility. | | Class B(A): | def Cleanup(self,x,y,z): | ... | This is a good way to add functionality that isn't always needed -- you can use instances of 'A' when it's not needed, and instances of 'B' when it is. | Is there a way I can cast the instances of class A into instances of | class B so I can use the additional methods? I can't find anything | about it in "Programming Python" but then I'm not quite sure where to | look either. Since you use the word 'cast', I take it you have some C, C++ or Java experience. Those lanugages are statically typed, so if you declared having one type, but really have another, you must explicitly tell the compiler with a cast. Python is dynamically typed, so if you really have a "different" type (it can't really be different since you didn't declare it in the first place, but) you have it and python is happy. What I suspect is happening is that you are creating instances of A when you really want B. >>> class A : pass ... >>> class B( A ) : pass ... >>> obj1 = A() >>> obj2 = B() >>> obj1.__class__ >>> obj2.__class__ >>> In this example, obj2 is an instance of class "B". Since "B" is a subclass of "A", obj2 is also an instance of class "A". You can use obj2 whereever an instance of A or B is expected. On the other hand, obj1 is an instance of class "A", and won't work where an instance of class B is expected. There is no way automatically to turn obj1 into an instance of class B. There are a couple of ways to work around though. 1) modify the factory functions to return instances of "B" instead. Since it is a subclass, all existing code will work. 2) Make a conversion that will create a new instance of class "B" and init all data members based on an instance of class "A" 3) Play some obscure tricks using python dynamism to add those functions to obj1 even though they don't belong there #1 may be the easiest, but then you might as well just put the functions in class "A" and only use them when you need to. #2 could be done in B's __init__ function : class B( A ) : def __init__( self , instance_of_A ) : self.value = instance_of_A.value # ... Then when you want an instance of B, you can create it from the given instance of A. #3 isn't good since it is obscure and will be difficult to maintain. HTH, -D From bridgman at wyeth.gsfc.nasa.gov Fri Feb 16 21:09:07 2001 From: bridgman at wyeth.gsfc.nasa.gov (Tom Bridgman) Date: Fri, 16 Feb 2001 15:09:07 -0500 Subject: Converting an instance to a subclass? References: <3A8D7636.B8161C45@wyeth.gsfc.nasa.gov> Message-ID: <3A8D88E3.9FF4CA4B@wyeth.gsfc.nasa.gov> I'm seriously considering your option #2. These utility scripts are doing things which are really non-standard for the process I'm developing. They just exist solely for the purpose of converting an old data format over to a new one, installing new defaults, checking that support files are in the right locations, moving them if they're not, etc. The methods defined for this should never be used once we switch over to the new system so I don't want them in my standard class library to confuse some future maintainer of the code. Thanks for your input, Tom D-Man wrote: > > On Fri, Feb 16, 2001 at 01:49:26PM -0500, Tom Bridgman wrote: > [snip] > | and I have a number of methods that return me instances or lists of > | instances of this class. These are part of my general library of > | classes for this project. > | > | However, I need to write a utility which will define methods that are > | only needed by the utility. I really don't want these methods to be > | 'permanent' members of the class so I define them in a subclass as part > | of the utility. > | > | Class B(A): > | def Cleanup(self,x,y,z): > | ... > | > > This is a good way to add functionality that isn't always needed -- > you can use instances of 'A' when it's not needed, and instances of > 'B' when it is. > > | Is there a way I can cast the instances of class A into instances of > | class B so I can use the additional methods? I can't find anything > | about it in "Programming Python" but then I'm not quite sure where to > | look either. > > Since you use the word 'cast', I take it you have some C, C++ or Java > experience. Those lanugages are statically typed, so if you declared > having one type, but really have another, you must explicitly tell the > compiler with a cast. Python is dynamically typed, so if you really > have a "different" type (it can't really be different since you didn't > declare it in the first place, but) you have it and python is happy. > > What I suspect is happening is that you are creating instances of A > when you really want B. > > >>> class A : pass > ... > >>> class B( A ) : pass > ... > >>> obj1 = A() > >>> obj2 = B() > >>> obj1.__class__ > > >>> obj2.__class__ > > >>> > > In this example, obj2 is an instance of class "B". Since "B" is a > subclass of "A", obj2 is also an instance of class "A". You can use > obj2 whereever an instance of A or B is expected. On the other hand, > obj1 is an instance of class "A", and won't work where an instance of > class B is expected. There is no way automatically to turn obj1 into > an instance of class B. There are a couple of ways to work around > though. > > 1) modify the factory functions to return instances of "B" instead. > Since it is a subclass, all existing code will work. > > 2) Make a conversion that will create a new instance of class "B" and > init all data members based on an instance of class "A" > > 3) Play some obscure tricks using python dynamism to add those > functions to obj1 even though they don't belong there > > #1 may be the easiest, but then you might as well just put the > functions in class "A" and only use them when you need to. > > #2 could be done in B's __init__ function : > > class B( A ) : > def __init__( self , instance_of_A ) : > self.value = instance_of_A.value > # ... > > Then when you want an instance of B, you can create it from the > given instance of A. > > #3 isn't good since it is obscure and will be difficult to maintain. > > HTH, > -D -- Dr. William T."Tom" Bridgman Scientific Visualization Studio Global Science & Technology, Inc. NASA/Goddard Space Flight Center Email: bridgman at wyeth.gsfc.nasa.gov Code 935 Phone: 301-286-1346 Greenbelt, MD 20771 FAX: TBD http://svs.gsfc.nasa.gov/ From oconnor at bioreason.com Fri Feb 16 21:48:34 2001 From: oconnor at bioreason.com (Jay O'Connor) Date: Fri, 16 Feb 2001 13:48:34 -0700 Subject: Converting an instance to a subclass? References: <3A8D7636.B8161C45@wyeth.gsfc.nasa.gov> Message-ID: <3A8D9222.ED817082@bioreason.com> D-Man wrote: > #2 could be done in B's __init__ function : > > class B( A ) : > def __init__( self , instance_of_A ) : > self.value = instance_of_A.value > # ... > > Then when you want an instance of B, you can create it from the > given instance of A. > For conveneience you could add a converter in A class A: def asB (self): b = B(self) return b and in B you could do class B: def __init__(self, instanceOfA): self.__dict__ = instanceOfA.__dict__ The only problem with adding the covenience method to A is that it makes A aware of it's subclasses hierarchy, which may not be desireable. Take care, Jay O'Connor joconnor at cybermesa.com From oconnor at bioreason.com Fri Feb 16 21:43:26 2001 From: oconnor at bioreason.com (Jay O'Connor) Date: Fri, 16 Feb 2001 13:43:26 -0700 Subject: Converting an instance to a subclass? References: <3A8D7636.B8161C45@wyeth.gsfc.nasa.gov> Message-ID: <3A8D90EE.47B1BA35@bioreason.com> Tom Bridgman wrote: ... > However, I need to write a utility which will define methods that are > only needed by the utility. I really don't want these methods to be > 'permanent' members of the class so I define them in a subclass as part > of the utility. > > Class B(A): > def Cleanup(self,x,y,z): > ... > > Is there a way I can cast the instances of class A into instances of > class B so I can use the additional methods? I can't find anything > about it in "Programming Python" but then I'm not quite sure where to > look either. One technique you can use is to add new instance methods to the objects you wish to treat differently ------ #!/usr/bin/python import new class MyClass(): def __init__(self): x = 100 # Seperate function, not part of MyClass # but expects 'self' and references variables created in MyClass.__init__() def extraFunction(self): print "x = " + `self.x` object = MyClass() object.extra = new.instancemethod (extraFunction, object, MyClass) object.extra() ------ This will print "x = 100" This only adds the new method as an instance method to that one object. It does not affect other instances of MyClass, or MyClass itself So just declare your extra methods seperate from the class and add them as needed to the appropriate objects Take care, Jay O'Connor joconnor at cybermesa.com From tjreedy at udel.edu Fri Feb 16 23:46:58 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 16 Feb 2001 17:46:58 -0500 Subject: Converting an instance to a subclass? References: <3A8D7636.B8161C45@wyeth.gsfc.nasa.gov> Message-ID: <96ka96$iqd$1@news.udel.edu> > Is there a way I can cast the instances of class A into instances of > class B so I can use the additional methods Is this what you want (with 1.5.2)? >>> class a: pass >>> class b(a): pass >>> i = a() >>> i.__class__ >>> i.__class__ = b >>> i.__class__ > I can't find anything about it in "Programming Python" I believe that __class__ became writeable after that was written -- or it may have been too esoteric (and dangerous) to include. Terry J. Reedy From bridgman at wyeth.gsfc.nasa.gov Wed Feb 21 15:06:15 2001 From: bridgman at wyeth.gsfc.nasa.gov (Tom Bridgman) Date: Wed, 21 Feb 2001 09:06:15 -0500 Subject: Converting an instance to a subclass? References: <3A8D7636.B8161C45@wyeth.gsfc.nasa.gov> <96ka96$iqd$1@news.udel.edu> Message-ID: <3A93CB57.795226AE@wyeth.gsfc.nasa.gov> Terry et al., This is a really slick trick and looks like it does what I need. Thanks to all who suggested it. I was right. I was *really* simple. Tom Terry Reedy wrote: > > > Is there a way I can cast the instances of class A into instances of > > class B so I can use the additional methods > > Is this what you want (with 1.5.2)? > > >>> class a: pass > >>> class b(a): pass > >>> i = a() > >>> i.__class__ > > >>> i.__class__ = b > >>> i.__class__ > > > > I can't find anything about it in "Programming Python" > > I believe that __class__ became writeable after that was written -- or it > may have been too esoteric (and dangerous) to include. > > Terry J. Reedy -- Dr. William T."Tom" Bridgman Scientific Visualization Studio Global Science & Technology, Inc. NASA/Goddard Space Flight Center Email: bridgman at wyeth.gsfc.nasa.gov Code 935 Phone: 301-286-1346 Greenbelt, MD 20771 FAX: TBD http://svs.gsfc.nasa.gov/ From dan at eevolved.com Fri Feb 16 21:05:45 2001 From: dan at eevolved.com (Dan Parisien) Date: Fri, 16 Feb 2001 20:05:45 GMT Subject: TCS.bsddb Message-ID: I have just downloaded, compiled and installed TCS.bsddb, robin dunn's bsddb1.2 for sleepycat software's berkley db version 2.7.7. I am getting an error on a simple --- from TCS.bsddb import dbShelve db = dbShelve.open("test.db") --- it raises the exception Traceback (most recent call last): File "./shelve.py", line 5, in ? db = dbShelve.open("test.db") File "/usr/local/lib/python2.0/site-packages/TCS/bsddb/dbShelve.py", line 165, in open d.open(filename, filetype, flags, mode) File "/usr/local/lib/python2.0/site-packages/TCS/bsddb/db.py", line 638, in open val = apply(dbc.DB_open,(self.this,arg0,)+args) db.error: (22, 'Invalid argument') I checked, and the arguments are fine. Anybody have this error before? Dan From janne at oops.nnets.fi Fri Feb 16 23:48:27 2001 From: janne at oops.nnets.fi (Janne Sinkkonen) Date: 17 Feb 2001 00:48:27 +0200 Subject: TCS.bsddb References: Message-ID: Dan Parisien writes: > I have just downloaded, compiled and installed TCS.bsddb, robin dunn's > bsddb1.2 for sleepycat software's berkley db version 2.7.7. > > I am getting an error on a simple > --- > from TCS.bsddb import dbShelve > > db = dbShelve.open("test.db") Mine works, with Python 2.1a2 and with 1.5.x, but my bsddb is an older 2.x -- Janne From janne at oops.nnets.fi Fri Feb 16 23:58:01 2001 From: janne at oops.nnets.fi (Janne Sinkkonen) Date: 17 Feb 2001 00:58:01 +0200 Subject: TCS.bsddb References: Message-ID: Janne Sinkkonen writes: > Mine works, with Python 2.1a2 and with 1.5.x, but my bsddb is an older 2.x Sorry, I tried to say that the underlying Berkeley database is an older 2.x version (2.1.3 probably). -- Janne From dan at eevolved.com Sat Feb 17 00:36:09 2001 From: dan at eevolved.com (Dan Parisien) Date: Fri, 16 Feb 2001 23:36:09 GMT Subject: TCS.bsddb References: Message-ID: Janne Sinkkonen wrote: > Janne Sinkkonen writes: > > > Mine works, with Python 2.1a2 and with 1.5.x, but my bsddb is an older > > 2.x > > Sorry, I tried to say that the underlying Berkeley database is an > older 2.x version (2.1.3 probably). > My problem is that I'm running Mandrake 7.2 and it fills /lib with incorrectly (I'm assuming) versioned libs. If I delete certain symbolic links my tests will work... Unfortunately as soon as I run ldconfig, my changes are wiped Oh, and cvs depends on libdb.so.2 (one of the symbolic links I deleted). cvs segfaulted in the middle of a commit, now I'm locked out :) Not a good day today... Dan From othello at javanet.com Fri Feb 16 22:42:35 2001 From: othello at javanet.com (Raymond Hettinger) Date: Fri, 16 Feb 2001 16:42:35 -0500 Subject: Pipes in PythonWin Message-ID: <3A8D9ECA.C0BB3C38@javanet.com> Any idea how to get the pipe functions to work from within PythonWin? At the the command line, this script works: print os.popen('cal').read() Within PythonWin, I get: WindowsError: [Errno 2] The system cannot find the file specified Is there some enabling step or work around? Thanks, Raymond From MarkH at ActiveState.com Sat Feb 17 01:01:24 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sat, 17 Feb 2001 00:01:24 GMT Subject: Pipes in PythonWin References: <3A8D9ECA.C0BB3C38@javanet.com> Message-ID: <3A8DBE77.9070107@ActiveState.com> Raymond Hettinger wrote: > Any idea how to get the pipe functions to work from within > PythonWin? > > At the the command line, this script works: > print os.popen('cal').read() > > Within PythonWin, I get: > WindowsError: [Errno 2] The system cannot find the file specified > > Is there some enabling step or work around? This is a bug. To work around it copy "w9xpopen.exe" to the same directory as pythonwin.exe Mark. -- Nominate Your Favorite Programmers for the Perl and Python Active Awards! http://www.ActiveState.com/Awards/ From othello at javanet.com Mon Feb 19 01:30:48 2001 From: othello at javanet.com (Raymond Hettinger) Date: Sun, 18 Feb 2001 19:30:48 -0500 Subject: Pipes in PythonWin References: <3A8D9ECA.C0BB3C38@javanet.com> <3A8DBE77.9070107@ActiveState.com> Message-ID: <3A906938.15618A63@javanet.com> Mark Hammond wrote: > Raymond Hettinger wrote: > > > Any idea how to get the pipe functions to work from within > > PythonWin? > > > > At the the command line, this script works: > > print os.popen('cal').read() > > > > Within PythonWin, I get: > > WindowsError: [Errno 2] The system cannot find the file specified > > > > Is there some enabling step or work around? > > This is a bug. To work around it copy "w9xpopen.exe" to the same > directory as pythonwin.exe > > Mark. It works and I'm back in business! Thanks, Raymond From lreilly at cs.strath.ac.uk Fri Feb 16 23:32:00 2001 From: lreilly at cs.strath.ac.uk (Lee Reilly CS1997) Date: Fri, 16 Feb 2001 22:32:00 +0000 Subject: coding standards - commenting / documentation Message-ID: <3A8DAA60.D37A2C18@cs.strath.ac.uk> Hi there, Can anyone tell me if there is a standard template or recongnised standard for documenting (especially commenting) python code. Or, if anybody had a good, structured way of doing this maybe you'd like to send me a sample? Thanks very much in advance, Lee From danielk at aracnet.com Sat Feb 17 04:26:27 2001 From: danielk at aracnet.com (Daniel Klein) Date: Fri, 16 Feb 2001 19:26:27 -0800 Subject: coding standards - commenting / documentation References: <3A8DAA60.D37A2C18@cs.strath.ac.uk> Message-ID: On Fri, 16 Feb 2001 22:32:00 +0000, Lee Reilly CS1997 wrote: >Can anyone tell me if there is a standard template or recongnised >standard for documenting (especially commenting) python code. http://www.python.org/doc/essays/styleguide.html From rwil at americasm01.nt.com Fri Feb 16 23:32:12 2001 From: rwil at americasm01.nt.com (Willison, Rick [WDLN2:2X38:EXCH]) Date: Fri, 16 Feb 2001 17:32:12 -0500 Subject: Unix Python Installation Troubles Message-ID: <3A8DAA6C.24E19E6D@americasm01.nt.com> I've inherited a bunch of Python scripts, and I'm trying to install the freeware on my Unix machine. It looks like _tkinter can't be found during the make. It thinks that I'm running an old tk/tcl, when in fact I have tk-8.0 ...! I've included the Setup file, and the spot where the make blows up. Can you help?? ...Rick -------------- next part -------------- A non-text attachment was scrubbed... Name: python_install.log Type: application/x-unknown-content-type-txtfile Size: 702 bytes Desc: not available URL: -------------- next part -------------- #-*- makefile -*- # The file Setup is used by the makesetup script to construct the files # Makefile and config.c, from Makefile.pre and config.c.in, # respectively. The file Setup itself is initially copied from # Setup.in; once it exists it will not be overwritten, so you can edit # Setup to your heart's content. Note that Makefile.pre is created # from Makefile.pre.in by the toplevel configure script. # (VPATH notes: Setup and Makefile.pre are in the build directory, as # are Makefile and config.c; the *.in files are in the source # directory.) # Each line in this file describes one or more optional modules. # Comment out lines to suppress modules. # Lines have the following structure: # # ... [ ...] [ ...] [ ...] # # is anything ending in .c (.C, .cc, .c++ are C++ files) # is anything starting with -I, -D, -U or -C # is anything ending in .a or beginning with -l or -L # is anything else but should be a valid Python # identifier (letters, digits, underscores, beginning with non-digit) # # (As the makesetup script changes, it may recognize some other # arguments as well, e.g. *.so and *.sl as libraries. See the big # case statement in the makesetup script.) # # Lines can also have the form # # = # # which defines a Make variable definition inserted into Makefile.in # # Finally, if a line contains just the word "*shared*" (without the # quotes but with the stars), then the following modules will not be # included in the config.c file, nor in the list of objects to be # added to the library archive, and their linker options won't be # added to the linker options, but rules to create their .o files and # their shared libraries will still be added to the Makefile, and # their names will be collected in the Make variable SHAREDMODS. This # is used to build modules as shared libraries. (They can be # installed using "make sharedinstall", which is implied by the # toplevel "make install" target.) (For compatibility, # *noconfig* has the same effect as *shared*.) # # In addition, *static* reverses this effect (negating a previous # *shared* line). # NOTE: As a standard policy, as many modules as can be supported by a # platform should be present. The distribution comes with all modules # enabled that are supported by most platforms and don't require you # to ftp sources from elsewhere. # Some special rules to define PYTHONPATH. # Edit the definitions below to indicate which options you are using. # Don't add any whitespace or comments! # Directories where library files get installed. # DESTLIB is for Python modules; MACHDESTLIB for shared libraries. DESTLIB=$(LIBDEST) MACHDESTLIB=$(BINLIBDEST) # NOTE: all the paths are now relative to the prefix that is computed # at run time! # Standard path -- don't edit. # No leading colon since this is the first entry. # Empty since this is now just the runtime prefix. DESTPATH= # Site specific path components -- should begin with : if non-empty SITEPATH= # Standard path components for test modules TESTPATH= # Path components for machine- or system-dependent modules and shared libraries MACHDEPPATH=:plat-$(MACHDEP) COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)$(MACHDEPPATH)$(STDWINPATH)$(TKPATH) PYTHONPATH=$(COREPYTHONPATH) # The modules listed here can't be built as shared libraries for # various reasons; therefore they are listed here instead of in the # normal order. # Some modules that are normally always on: regex regexmodule.c regexpr.c # Regular expressions, GNU Emacs style pcre pcremodule.c pypcre.c # Regular expressions, Perl style (for re.py) posix posixmodule.c # posix (UNIX) system calls signal signalmodule.c # signal(2) # The SGI specific GL module: GLHACK=-Dclear=__GLclear #gl glmodule.c cgensupport.c -I$(srcdir) $(GLHACK) -lgl -lX11 # The thread module is now automatically enabled, see Setup.thread. # Pure module. Cannot be linked dynamically. # -DWITH_QUANTIFY, -DWITH_PURIFY, or -DWITH_ALL_PURE #WHICH_PURE_PRODUCTS=-DWITH_ALL_PURE #PURE_INCLS=-I/usr/local/include #PURE_STUBLIBS=-L/usr/local/lib -lpurify_stubs -lquantify_stubs #pure puremodule.c $(WHICH_PURE_PRODUCTS) $(PURE_INCLS) $(PURE_STUBLIBS) # Uncommenting the following line tells makesetup that all following # modules are to be built as shared libraries (see above for more # detail; also note that *static* reverses this effect): #*shared* # GNU readline. Unlike previous Python incarnations, GNU readline is # now incorporated in an optional module, configured in the Setup file # instead of by a configure script switch. You may have to insert a # -L option pointing to the directory where libreadline.* lives, # and you may have to change -ltermcap to -ltermlib or perhaps remove # it, depending on your system -- see the GNU readline instructions. # It's okay for this to be a shared library, too. #readline readline.c -lreadline -ltermcap # Modules that should always be present (non UNIX dependent): array arraymodule.c # array objects cmath cmathmodule.c # -lm # complex math library functions math mathmodule.c # -lm # math library functions, e.g. sin() strop stropmodule.c # fast string operations implemented in C struct structmodule.c # binary structure packing/unpacking time timemodule.c # -lm # time operations and variables operator operator.c # operator.add() and similar goodies #_locale _localemodule.c # access to ISO C locale support # Modules with some UNIX dependencies -- on by default: # (If you have a really backward UNIX, select and socket may not be # supported...) fcntl fcntlmodule.c # fcntl(2) and ioctl(2) pwd pwdmodule.c # pwd(3) grp grpmodule.c # grp(3) select selectmodule.c # select(2); not on ancient System V socket socketmodule.c # socket(2); not on ancient System V #_socket socketmodule.c # socket(2); use this one for BeOS sockets errno errnomodule.c # posix (UNIX) errno values # The crypt module is now disabled by default because it breaks builds # on many systems (where -lcrypt is needed), e.g. Linux (I believe). #crypt cryptmodule.c # -lcrypt # crypt(3); needs -lcrypt on some systems # Some more UNIX dependent modules -- off by default, since these # are not supported by all UNIX systems: #nis nismodule.c # Sun yellow pages -- not everywhere #termios termios.c # Steen Lumholt's termios module #resource resource.c # Jeremy Hylton's rlimit interface # Multimedia modules -- off by default. # These don't work for 64-bit platforms!!! # These represent audio samples or images as strings: #audioop audioop.c # Operations on audio samples #imageop imageop.c # Operations on images #rgbimg rgbimgmodule.c # Read SGI RGB image files (but coded portably) # The stdwin module provides a simple, portable (between X11 and Mac) # windowing interface. You need to ftp the STDWIN library, e.g. from # ftp://ftp.cwi.nl/pub/stdwin. (If you get it elsewhere, be sure to # get version 1.0 or higher!) The STDWIN variable must point to the # STDWIN toplevel directory. # Uncomment and edit as needed: #STDWIN=/ufs/guido/src/stdwin # Uncomment these lines: #STDWINPATH=:lib-stdwin #LIBTEXTEDIT=$(STDWIN)/$(MACHDEP)/Packs/textedit/libtextedit.a #LIBX11STDWIN=$(STDWIN)/$(MACHDEP)/Ports/x11/libstdwin.a #stdwin stdwinmodule.c -I$(STDWIN)/H $(LIBTEXTEDIT) $(LIBX11STDWIN) -lX11 # Use this instead of the last two lines above for alphanumeric stdwin: #LIBALFASTDWIN=$(STDWIN)/$(MACHDEP)/Ports/alfa/libstdwin.a #stdwin stdwinmodule.c -I$(STDWIN)/H $(LIBTEXTEDIT) $(LIBALFASTDWIN) -ltermcap # The md5 module implements the RSA Data Security, Inc. MD5 # Message-Digest Algorithm, described in RFC 1321. The necessary files # md5c.c and md5.h are included here. md5 md5module.c md5c.c # The sha module implements the SHA checksum algorithm. # (NIST's Secure Hash Algorithm.) sha shamodule.c # The mpz module interfaces to the GNU Multiple Precision library. # You need to ftp the GNU MP library. # The GMP variable must point to the GMP source directory. # This was originally written and tested against GMP 1.2 and 1.3.2. # It has been modified by Rob Hooft to work with 2.0.2 as well, but I # haven't tested it recently. # A compatible MP library unencombered by the GPL also exists. It was # posted to comp.sources.misc in volume 40 and is widely available from # FTP archive sites. One URL for it is: # ftp://gatekeeper.dec.com/.b/usenet/comp.sources.misc/volume40/fgmp/part01.Z #GMP=/ufs/guido/src/gmp #mpz mpzmodule.c -I$(GMP) $(GMP)/libgmp.a # SGI IRIX specific modules -- off by default. # These module work on any SGI machine: # *** gl must be enabled higher up in this file *** #fm fmmodule.c $(GLHACK) -lfm -lgl # Font Manager #sgi sgimodule.c # sgi.nap() and a few more # This module requires the header file # /usr/people/4Dgifts/iristools/include/izoom.h: #imgfile imgfile.c -limage -lgutil -lgl -lm # Image Processing Utilities # These modules require the Multimedia Development Option (I think): #al almodule.c -laudio # Audio Library #cd cdmodule.c -lcdaudio -lds -lmediad # CD Audio Library #cl clmodule.c -lcl -lawareaudio # Compression Library #sv svmodule.c yuvconvert.c -lsvideo -lXext -lX11 # Starter Video # The FORMS library, by Mark Overmars, implements user interface # components such as dialogs and buttons using SGI's GL and FM # libraries. You must ftp the FORMS library separately from # ftp://ftp.cs.ruu.nl/pub/SGI/FORMS. It was tested with FORMS 2.2a. # NOTE: if you want to be able to use FORMS and curses simultaneously # (or both link them statically into the same binary), you must # compile all of FORMS with the cc option "-Dclear=__GLclear". # The FORMS variable must point to the FORMS subdirectory of the forms # toplevel directory: #FORMS=/ufs/guido/src/forms/FORMS #fl flmodule.c -I$(FORMS) $(GLHACK) $(FORMS)/libforms.a -lfm -lgl # SunOS specific modules -- off by default: #sunaudiodev sunaudiodev.c # George Neville-Neil's timing module: #timing timingmodule.c # The _tkinter module. # # The TKPATH variable is always enabled, to save you the effort. TKPATH=:lib-tk # The command for _tkinter is long and site specific. Please # uncomment and/or edit those parts as indicated. If you don't have a # specific extension (e.g. Tix or BLT), leave the corresponding line # commented out. (Leave the trailing backslashes in! If you # experience strange errors, you may want to join all uncommented # lines and remove the backslashes -- the backslash interpretation is # done by the shell's "read" command and it may not be implemented on # every system. # *** Always uncomment this (leave the leading underscore in!): _tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \ # *** Uncomment and edit to reflect where your Tcl/Tk headers are: -I/opt/corp/contrib/tk-8.0/lib/sparc-solaris2.5.1/include \ # *** Uncomment and edit to reflect where your X11 header files are: # -I/usr/X11R6/include \ # *** Or uncomment this for Solaris: -I/usr/openwin/include \ # *** Uncomment and edit for Tix extension only: # -DWITH_TIX -ltix4.1.8.0 \ # *** Uncomment and edit for BLT extension only: # -DWITH_BLT -I/usr/local/blt/blt8.0-unoff/include -lBLT8.0 \ # *** Uncomment and edit for PIL (TkImaging) extension only: # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \ # *** Uncomment and edit for TOGL extension only: # -DWITH_TOGL togl.c \ # *** Uncomment and edit to reflect where your Tcl/Tk libraries are: -L/opt/corp/contrib/tk-8.0/lib/sparc-solaris2.5.1 \ # *** Uncomment and edit to reflect your Tcl/Tk versions: -ltk8.0 -ltcl8.0 \ # *** Uncomment and edit to reflect where your X11 libraries are: # -L/usr/X11R6/lib \ # *** Or uncomment this for Solaris: -L/usr/openwin/lib \ # *** Uncomment these for TOGL extension only: # -lGL -lGLU -lXext -lXmu \ # *** Uncomment for AIX: # -lld \ # *** Always uncomment this; X11 libraries to link with: -lX11 # Lance Ellinghaus's modules: rotor rotormodule.c # enigma-inspired encryption #syslog syslogmodule.c # syslog daemon interface # Lance's curses module. This requires the System V version of # curses, sometimes known as ncurses (e.g. on Linux, link with # -lncurses instead of -lcurses; on SunOS 4.1.3, insert -I/usr/5include # -L/usr/5lib before -lcurses). #curses cursesmodule.c -lcurses -ltermcap # Tommy Burnette's 'new' module (creates new empty objects of certain kinds): new newmodule.c # Generic (SunOS / SVR4) dynamic loading module. # This is not needed for dynamic loading of Python modules -- # it is a highly experimental and dangerous device for calling # *arbitrary* C functions in *arbitrary* shared libraries: #dl dlmodule.c # Modules that provide persistent dictionary-like semantics. You will # probably want to arrange for at least one of them to be available on # your machine, though none are defined by default because of library # dependencies. The Python module anydbm.py provides an # implementation independent wrapper for these; dumbdbm.py provides # similar functionality (but slower of course) implemented in Python. # The standard Unix dbm module: #dbm dbmmodule.c # dbm(3) may require -lndbm or similar # Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm: #gdbm gdbmmodule.c -I/usr/local/include -L/usr/local/lib -lgdbm # Berkeley DB interface. # # This requires the Berkeley DB code, see # ftp://ftp.cs.berkeley.edu/pub/4bsd/db.1.85.tar.gz # # Edit the variables DB and DBPORT to point to the db top directory # and the subdirectory of PORT where you built it. # # (See http://www.jenkon-dev.com/~rd/python/ for an interface to # BSD DB 2.1.0.) #DB=/depot/sundry/src/berkeley-db/db.1.85 #DBPORT=$(DB)/PORT/irix.5.3 #bsddb bsddbmodule.c -I$(DBPORT)/include -I$(DBPORT) $(DBPORT)/libdb.a # David Wayne Williams' soundex module (obsolete -- this will disappear!) #soundex soundex.c # Helper module for various ascii-encoders binascii binascii.c # Fred Drake's interface to the Python parser parser parsermodule.c # Digital Creations' cStringIO and cPickle cStringIO cStringIO.c cPickle cPickle.c # Lee Busby's SIGFPE modules. # The library to link fpectl with is platform specific. # Choose *one* of the options below for fpectl: # For SGI IRIX (tested on 5.3): #fpectl fpectlmodule.c -lfpe # For Solaris with SunPro compiler (tested on Solaris 2.5 with SunPro C 4.2): # (Without the compiler you don't have -lsunmath.) #fpectl fpectlmodule.c -R/opt/SUNWspro/lib -lsunmath -lm # For other systems: see instructions in fpectlmodule.c. #fpectl fpectlmodule.c ... # Test module for fpectl. No extra libraries needed. #fpetest fpetestmodule.c # Andrew Kuchling's zlib module. # This require zlib 1.1.3 (or later). # See http://www.cdrom.com/pub/infozip/zlib/ #zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz # Example -- included for reference only: # xx xxmodule.c From phlip_cpp at my-deja.com Fri Feb 16 23:42:58 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 16 Feb 2001 22:42:58 GMT Subject: string, split, sort, None, huh? Message-ID: <96kadi$f2t@dispatch.concentric.net> Thy Pon: Gonna split a document by linefeeds into strings, then sort the strings. Child's play, huh? lines = split ( """Mary had a little lamb""", "\n" ) print repr(lines) print repr(lines.sort()) Now the output: ['Mary', 'had', 'a', 'little', 'lamb'] None So where'd that 'None' come from? The Sorting Mini-HOWTO here said strings are just as easy as numbers: http://www.python.org/doc/howto/sorting/node2.html Variations with 'cmp' and 'lambda x, y: cmp(x, y)' also get 'None'. -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- Proud victim of the dreaded boomerang effect -- From glennj at pcard31e.ca.nortel.com Fri Feb 16 23:55:41 2001 From: glennj at pcard31e.ca.nortel.com (Glenn W Jackman) Date: 16 Feb 2001 22:55:41 GMT Subject: string, split, sort, None, huh? References: <96kadi$f2t@dispatch.concentric.net> Message-ID: <96kb5d$bb0$2@bcarh8ab.ca.nortel.com> Phlip wrote: > print repr(lines) > print repr(lines.sort()) > >Now the output: > > ['Mary', 'had', 'a', 'little', 'lamb'] > None sort() sorts the list in place, and returns None. Try: lines = ['Mary', 'had', 'a', 'little', 'lamb'] print repr(lines) lines.sort() print repr(lines) -- Glenn From phlip_cpp at my-deja.com Sat Feb 17 00:37:44 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 16 Feb 2001 23:37:44 GMT Subject: string, split, sort, None, huh? References: <96kadi$f2t@dispatch.concentric.net> <96kb5d$bb0$2@bcarh8ab.ca.nortel.com> Message-ID: <96kdk8$dtr@freepress.concentric.net> Glenn W Jackman wrote: > ...sort() sorts the list in place... Jay O'Connor wrote: > ...sort() sorts the sequence in in place... Oh, man - I gotta lay off that crack pipe, huh? @-} Thanks, guys. -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- My opinions are those of your employer -- From joconnor at cybermesa.com Sat Feb 17 00:55:37 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Fri, 16 Feb 2001 16:55:37 -0700 Subject: string, split, sort, None, huh? References: <96kadi$f2t@dispatch.concentric.net> <96kb5d$bb0$2@bcarh8ab.ca.nortel.com> <96kdk8$dtr@freepress.concentric.net> Message-ID: <3A8DBDF8.FC5F2A35@cybermesa.com> Phlip wrote: > Glenn W Jackman wrote: > > > ...sort() sorts the list in place... > > Jay O'Connor wrote: > > > ...sort() sorts the sequence in in place... > > Oh, man - I gotta lay off that crack pipe, huh? @-} > > Thanks, guys. > Happy to Help :) Take care, Jay O'Connor joconnor at cybermesa.com From joconnor at cybermesa.com Sat Feb 17 00:01:35 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Fri, 16 Feb 2001 16:01:35 -0700 Subject: string, split, sort, None, huh? References: <96kadi$f2t@dispatch.concentric.net> Message-ID: <3A8DB14E.5B4D39FB@cybermesa.com> Phlip wrote: > Thy Pon: > > Gonna split a document by linefeeds into strings, then sort the strings. > Child's play, huh? > > lines = split ( """Mary > had > a > little > lamb""", "\n" ) > > print repr(lines) > print repr(lines.sort()) > > Now the output: > > ['Mary', 'had', 'a', 'little', 'lamb'] > None > > So where'd that 'None' come from? It came from the fact that lines.sort() sorts the sequence in in place and returns None, which is what your second repr() is getting Try instead: print repr (lines) lines.sort() print repr(lines) Take care, Jay O'Connor joconnor at cybermesa.com From shaleh at valinux.com Sat Feb 17 00:21:12 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Fri, 16 Feb 2001 15:21:12 -0800 (PST) Subject: string, split, sort, None, huh? In-Reply-To: <96kadi$f2t@dispatch.concentric.net> Message-ID: On 16-Feb-2001 Phlip wrote: > Thy Pon: > > Gonna split a document by linefeeds into strings, then sort the strings. > Child's play, huh? > > lines = split ( """Mary > had > a > little > lamb""", "\n" ) > > print repr(lines) > print repr(lines.sort()) > list.sort() does not return a list, it sorts it in place. >>> string = "Mary\nhad\na\nlittle\nlamb." >>> print string Mary had a little lamb. >>> from string import split >>> pieces = split(string, '\n') >>> print pieces ['Mary', 'had', 'a', 'little', 'lamb.'] >>> pieces.sort() >>> print pieces ['Mary', 'a', 'had', 'lamb.', 'little'] From glennj at pcard31e.ca.nortel.com Fri Feb 16 23:50:08 2001 From: glennj at pcard31e.ca.nortel.com (Glenn W Jackman) Date: 16 Feb 2001 22:50:08 GMT Subject: missing modules in BeOpen-Python-2.0? Message-ID: <96kar0$bb0$1@bcarh8ab.ca.nortel.com> I fetched and installed BeOpen-Python-2.0-1.i386.rpm from python.org, and was unable to import: crypt, dbm, dl, nis Why is this release missing these modules (that are documented in the Global Module Index)? -- Glenn From aahz at panix.com Sat Feb 17 03:42:29 2001 From: aahz at panix.com (Aahz Maruch) Date: 16 Feb 2001 18:42:29 -0800 Subject: missing modules in BeOpen-Python-2.0? References: <96kar0$bb0$1@bcarh8ab.ca.nortel.com> Message-ID: <96koel$fms$1@panix2.panix.com> In article <96kar0$bb0$1 at bcarh8ab.ca.nortel.com>, Glenn W Jackman wrote: > >I fetched and installed BeOpen-Python-2.0-1.i386.rpm from python.org, >and was unable to import: crypt, dbm, dl, nis > >Why is this release missing these modules (that are documented in the >Global Module Index)? You need to compile them. Check the README. -- --- 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 Why doesn't "Just Say NO" include caffeine, nicotine, alcohol, Prozac, and Ritalin? --Aahz From glennj at pcard31e.ca.nortel.com Sat Feb 17 23:39:16 2001 From: glennj at pcard31e.ca.nortel.com (Glenn W Jackman) Date: 17 Feb 2001 22:39:16 GMT Subject: missing modules in BeOpen-Python-2.0? References: <96kar0$bb0$1@bcarh8ab.ca.nortel.com> <96koel$fms$1@panix2.panix.com> Message-ID: <96muik$grf$1@bcarh8ab.ca.nortel.com> Aahz Maruch wrote: >In article <96kar0$bb0$1 at bcarh8ab.ca.nortel.com>, >Glenn W Jackman wrote: >> >>I fetched and installed BeOpen-Python-2.0-1.i386.rpm from python.org, >>and was unable to import: crypt, dbm, dl, nis >> >>Why is this release missing these modules (that are documented in the >>Global Module Index)? > >You need to compile them. Check the README. None of the READMEs say anything about it: $ rpm -ql BeOpen-Python | grep README /usr/doc/BeOpen-Python-2.0/README /usr/local/lib/python2.0/distutils/README /usr/local/lib/python2.0/site-packages/README /usr/local/lib/python2.0/test/README I don't want to sound beligerant, but why should I have to compile these modules? This release includes many modules in /usr/local/lib/python2.0/lib-dynload, including gdbm (but not dbm?) -- Glenn From aahz at panix.com Sun Feb 18 01:18:10 2001 From: aahz at panix.com (Aahz Maruch) Date: 17 Feb 2001 16:18:10 -0800 Subject: missing modules in BeOpen-Python-2.0? References: <96kar0$bb0$1@bcarh8ab.ca.nortel.com> <96koel$fms$1@panix2.panix.com> <96muik$grf$1@bcarh8ab.ca.nortel.com> Message-ID: <96n4c2$o9q$1@panix3.panix.com> In article <96muik$grf$1 at bcarh8ab.ca.nortel.com>, Glenn W Jackman wrote: >Aahz Maruch wrote: >>In article <96kar0$bb0$1 at bcarh8ab.ca.nortel.com>, >>Glenn W Jackman wrote: >>> >>>I fetched and installed BeOpen-Python-2.0-1.i386.rpm from python.org, >>>and was unable to import: crypt, dbm, dl, nis >>> >>>Why is this release missing these modules (that are documented in the >>>Global Module Index)? >> >>You need to compile them. Check the README. > >None of the READMEs say anything about it: > $ rpm -ql BeOpen-Python | grep README > /usr/doc/BeOpen-Python-2.0/README > /usr/local/lib/python2.0/distutils/README > /usr/local/lib/python2.0/site-packages/README > /usr/local/lib/python2.0/test/README I have to admit that I haven't compiled 2.0 myself, so I'm not sure exactly where it's documented, but I know it's in there somewhere. >I don't want to sound beligerant, but why should I have to compile >these modules? This release includes many modules in >/usr/local/lib/python2.0/lib-dynload, including gdbm (but not dbm?) IIRC, these modules are unavailable on Windows, so they're not compiled by default. -- --- 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 Why doesn't "Just Say NO" include caffeine, nicotine, alcohol, Prozac, and Ritalin? --Aahz From glennj at pcard31e.ca.nortel.com Sun Feb 18 18:44:29 2001 From: glennj at pcard31e.ca.nortel.com (Glenn W Jackman) Date: 18 Feb 2001 17:44:29 GMT Subject: missing modules in BeOpen-Python-2.0? References: <96kar0$bb0$1@bcarh8ab.ca.nortel.com> <96koel$fms$1@panix2.panix.com> <96muik$grf$1@bcarh8ab.ca.nortel.com> <96n4c2$o9q$1@panix3.panix.com> Message-ID: <96p1lt$qdl$1@bcarh8ab.ca.nortel.com> Aahz Maruch wrote: >>>>I fetched and installed BeOpen-Python-2.0-1.i386.rpm from python.org, >>>>and was unable to import: crypt, dbm, dl, nis >>> >>>You need to compile them. Check the README. >> >>I don't want to sound beligerant, but why should I have to compile >>these modules? This release includes many modules in >>/usr/local/lib/python2.0/lib-dynload, including gdbm (but not dbm?) > >IIRC, these modules are unavailable on Windows, so they're not compiled >by default. According to the global module index for BeOpen-Python-2.0, there are 20 modules specific to "unix", CGIHTTPServer, commands, crypt, dbm, dl, fcntl, gdbm, grp, nis, pipes, posix, posixfile, pwd, readline, resource, rlcompleter, syslog, TERMIOS, termios, tty and only the 4 mentioned are missing. Of the existing 16 in the distribution, 8 of them exist in the lib-dynload directory. fcntl, gdbm, grp, pwd, readline, resource, syslog, termios So a bunch have come already compiled. -- Glenn From jafo at tummy.com Sun Feb 25 06:42:15 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Sat, 24 Feb 2001 22:42:15 -0700 Subject: New Python-2.0 SRPM. In-Reply-To: <96kar0$bb0$1@bcarh8ab.ca.nortel.com>; from glennj@pcard31e.ca.nortel.com on Fri, Feb 16, 2001 at 10:50:08PM +0000 References: <96kar0$bb0$1@bcarh8ab.ca.nortel.com> Message-ID: <20010224224215.A4706@tummy.com> On Fri, Feb 16, 2001 at 10:50:08PM +0000, Glenn W Jackman wrote: >I fetched and installed BeOpen-Python-2.0-1.i386.rpm from python.org, >and was unable to import: crypt, dbm, dl, nis I've released a new Python-2.0 SRPM, this one includes the above modules, adds "-devel", "-tkinter", and "-doc" packages as well. The SRPM is at ftp.tummy.com:/pub/tummy/RPMS/SRPMS/python-2.0-3tummy.src.rpm You can build a binary RPM using "rpm --rebuild python-2.0-3tummy.src.rpm". It will then place the binary RPMs under (by default) "/usr/src/redhat/RPMS/i386". Enjoy, Sean -- "Who's the guy in the suit?" "FBI." "He looks a little to much like a lounge lizard for FBI." "He's working under-cover." -- Sean & Evelyn 2000 Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From glennj at pcard31e.ca.nortel.com Sun Feb 25 20:36:03 2001 From: glennj at pcard31e.ca.nortel.com (Glenn W Jackman) Date: 25 Feb 2001 19:36:03 GMT Subject: New Python-2.0 SRPM. References: <96kar0$bb0$1@bcarh8ab.ca.nortel.com> Message-ID: <97bmr3$f2m$1@bcarh8ab.ca.nortel.com> Sean Reifschneider wrote: >On Fri, Feb 16, 2001 at 10:50:08PM +0000, Glenn W Jackman wrote: >>I fetched and installed BeOpen-Python-2.0-1.i386.rpm from python.org, >>and was unable to import: crypt, dbm, dl, nis > >I've released a new Python-2.0 SRPM, this one includes the above modules, >adds "-devel", "-tkinter", and "-doc" packages as well. > >The SRPM is at ftp.tummy.com:/pub/tummy/RPMS/SRPMS/python-2.0-3tummy.src.rpm > >You can build a binary RPM using "rpm --rebuild python-2.0-3tummy.src.rpm". >It will then place the binary RPMs under (by default) >"/usr/src/redhat/RPMS/i386". $ rpm --rebuild python-2.0-3tummy.src.rpm Installing python-2.0-3tummy.src.rpm only packages with major numbers <= 3 are supported by this version of RPM $ rpm -qp python-2.0-3tummy.src.rpm only packages with major numbers <= 3 are supported by this version of RPM query of python-2.0-3tummy.src.rpm failed $ rpm --version RPM version 3.0.4 -- Glenn From jafo at tummy.com Mon Feb 26 09:13:43 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Mon, 26 Feb 2001 01:13:43 -0700 Subject: New Python-2.0 SRPM. In-Reply-To: <97bmr3$f2m$1@bcarh8ab.ca.nortel.com>; from glennj@pcard31e.ca.nortel.com on Sun, Feb 25, 2001 at 07:36:03PM +0000 References: <96kar0$bb0$1@bcarh8ab.ca.nortel.com> <97bmr3$f2m$1@bcarh8ab.ca.nortel.com> Message-ID: <20010226011343.A3221@tummy.com> On Sun, Feb 25, 2001 at 07:36:03PM +0000, Glenn W Jackman wrote: >$ rpm --rebuild python-2.0-3tummy.src.rpm >Installing python-2.0-3tummy.src.rpm >only packages with major numbers <= 3 are supported by this version of RPM Ahh, not following errata? While you're there picking up the BIND and other errata, you'll want to snag the latest RPM updates. 3.0.5 can deal with version 4 RPM files. If you're using RedHat, you'll find that at a mirror under "redhat/updates//". The SRPMs were built on a RedHat 7.0-based box, but with the appropriate errata applied you should be able to build them on a 6.x or lower machine within reason. If you run into problems, let me know -- I haven't tested it on a pre-7 box. Sean -- "Having computers is a lot like having kids, except it's not as much of a problem if they die while you're away." -- Sean Reifschneider, 1997 Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From glennj at pcard31e.ca.nortel.com Mon Feb 26 18:55:07 2001 From: glennj at pcard31e.ca.nortel.com (Glenn W Jackman) Date: 26 Feb 2001 17:55:07 GMT Subject: New Python-2.0 SRPM. References: <96kar0$bb0$1@bcarh8ab.ca.nortel.com> <97bmr3$f2m$1@bcarh8ab.ca.nortel.com> Message-ID: <97e59r$c3f$1@bcarh8ab.ca.nortel.com> Sean Reifschneider wrote: >The SRPMs were built on a RedHat 7.0-based box, but with the appropriate >errata applied you should be able to build them on a 6.x or lower machine >within reason. If you run into problems, let me know -- I haven't >tested it on a pre-7 box. Thanks for your efforts, but I think I'll stick with python 1.5.2 until I have a more compelling reason to upgrade. -- Glenn From phys137 at mailcity.com Sat Feb 17 00:02:24 2001 From: phys137 at mailcity.com (charles loboz) Date: Sat, 17 Feb 2001 09:02:24 +1000 Subject: python 3000 IDE? be warned: contentious Message-ID: <96k7t3$kr8$1@mail.pl.unisys.com> 1. It seems that there are several Python IDEs in which many smart people invested plenty of effort. We have WinPython, IDLE (do we still have it ? ;-)), ActiveState is coming up with Komodo (build on Mozilla) and I probably missed a few here - apologies. Plus we have commercial ones. 2. Competition is good, splitting efforts probably less good. And there's a fine line between them. 3. My abbreviated personal view about technology directions: Win will rule the desktop, not only because of it's current popularity - but because it has component model. Linux doesn't have a native object model - which creates scalability (in size and functionality) problems for applications. Java on Linux will provide the component model but only for the Java world, not Linux. 4. Good and lasting IDE is about modularity and ease of extension. While I applaud the efforts of ActiveState I'm not sure that using Mozilla gives enough fuel for the long run. 5. www.netbeans.org - please, please, please read the whitepaper on that! 6. Essentially this is an open source IDE for Java - but can be used for most anything else. It's highly modular - you can customize/replace editor or file system etc (see 5). There is some fantastic stuff there as well as plenty of good design. Jython folks obviously are already having a peek at it (naturally) - but this could be used for general Python, too. And used on both platforms - NT and UNIX. 7. I'm not sure how well Netbeans functionality can be blended with winpython. but then, i suspect that winpython functionality will blend with .NET anyway. From neilh at scintilla.org Fri Feb 16 23:33:20 2001 From: neilh at scintilla.org (Neil Hodgson) Date: Fri, 16 Feb 2001 22:33:20 GMT Subject: python 3000 IDE? be warned: contentious References: <96k7t3$kr8$1@mail.pl.unisys.com> Message-ID: charles loboz: > 2. Competition is good, splitting efforts probably less good. And there's a > fine line between them. > ... > 4. Good and lasting IDE is about modularity and ease of extension. While I > applaud the efforts of ActiveState I'm not sure that using Mozilla gives > enough fuel for the long run. Not all the effort is duplicated. Several IDEs use Scintilla as their editing component. To share work, you have to find a bundle of functionality that is widely applicable and refrain from dictating policies that will conflict with particular uses. Other areas that may benefit from shared components are the debugging interface between the IDE and the running program and interfaces to source code control and project management. If the debugging interface used in Komodo works well then it would be a good candidate for wide adoption. Neil From aleaxit at yahoo.com Sat Feb 17 09:03:30 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 17 Feb 2001 09:03:30 +0100 Subject: python 3000 IDE? be warned: contentious References: <96k7t3$kr8$1@mail.pl.unisys.com> Message-ID: <96lbfu0frm@news2.newsguy.com> "charles loboz" wrote in message news:96k7t3$kr8$1 at mail.pl.unisys.com... [snip] > 3. My abbreviated personal view about technology directions: Win will rule > the desktop, not only because of it's current popularity - but because it > has component model. Linux doesn't have a native object model - which I share your enthusiasm for component-based technology, and consider it the only current _technical_ plus of Win systems. But, as for Linux, I pin some hopes on XPCOM -- the COM clone technology of Mozilla. It's ok if it ain't "native" -- indeed, cross-platform seems preferable. And ActiveState has a Python XPCOM package -- I admit to not having tried it yet (as one first needs to build Mozilla from sources, then add the package) but what I see looks interesting indeed. .NET is superior to COM on most fronts (it should, as it was developed by roughly the same folks with the advantage of years of practical experience!), but COM and clones are good enough for most uses. This has little to do with IDE's, per se -- component technology is just as precious whatever kind of applications one is developing, be they IDE's, accounting systems, or ray-tracers. It's an issue of whether each application is an island onto itself (or, at best, offers some non-standardized ad hoc kludges to let other programs talk to it), or rather, systematically, each and every application is designed based on a collection of reusable components -- and is, implicitly, a reusable component itself for potential higher-level applications. Alex From phys137 at mailcity.com Sat Feb 17 23:09:26 2001 From: phys137 at mailcity.com (charles loboz) Date: Sun, 18 Feb 2001 08:09:26 +1000 Subject: python 3000 IDE? be warned: contentious References: <96k7t3$kr8$1@mail.pl.unisys.com> <96lbfu0frm@news2.newsguy.com> Message-ID: <96mp60$ar9$1@mail.pl.unisys.com> 1. I was unaware of XPCOM - so I stand corrected on that. 2. This and other articles in this thread mention certain number of alternatives to COM as an argument that IDE can be written in them. It undoubtedly is technically possible but it doesn't solve neither the problem of writing a fully functional IDE nor developing it further efficiently. 3. The first reason for it is the scope of work already available through NetBeans and its community. NetBeans has a three year (at least) history as a product prepared by a lot of people. Overall architecture, code etc. 4. The second reason is the support coming from the platform. Technology - Swing seems to be the dominant GUI after Win, threading model, event model, property editors and enormous number of external beans already available (even though created for different purposes) - all of these much less available for other mentioned platforms (excluding Win, naturally). Scale - there are plenty of Java programmers out there and the number is growing much faster than for any other platform. The difference in size of the crowd is probably two-three _orders_ of _magnitude (or more). 5. Above arguments apply to things like wxWindows, XPCOM. As for Kylix - looks nice but _proprietary_ (I think), so automatically excluded "Alex Martelli" wrote in message news:96lbfu0frm at news2.newsguy.com... > "charles loboz" wrote in message > news:96k7t3$kr8$1 at mail.pl.unisys.com... > [snip] > > 3. My abbreviated personal view about technology directions: Win will rule > > the desktop, not only because of it's current popularity - but because it > > has component model. Linux doesn't have a native object model - which > > I share your enthusiasm for component-based technology, and consider > it the only current _technical_ plus of Win systems. But, as for Linux, I > pin some hopes on XPCOM -- the COM clone technology of Mozilla. It's > ok if it ain't "native" -- indeed, cross-platform seems preferable. And > ActiveState has a Python XPCOM package -- I admit to not having tried > it yet (as one first needs to build Mozilla from sources, then add the > package) but what I see looks interesting indeed. .NET is superior to > COM on most fronts (it should, as it was developed by roughly the same > folks with the advantage of years of practical experience!), but COM and > clones are good enough for most uses. > > This has little to do with IDE's, per se -- component technology is > just as precious whatever kind of applications one is developing, be > they IDE's, accounting systems, or ray-tracers. It's an issue of > whether each application is an island onto itself (or, at best, offers > some non-standardized ad hoc kludges to let other programs talk to > it), or rather, systematically, each and every application is designed > based on a collection of reusable components -- and is, implicitly, a > reusable component itself for potential higher-level applications. > > > Alex > > > From olivier.deckmyn at mail.dotcom.fr Sat Feb 17 09:16:05 2001 From: olivier.deckmyn at mail.dotcom.fr (Olivier DECKMYN) Date: Sat, 17 Feb 2001 09:16:05 +0100 Subject: python 3000 IDE? be warned: contentious References: <96k7t3$kr8$1@mail.pl.unisys.com> Message-ID: <96lbmb$8qk$1@feed.teaser.fr> Did you take a look at http://boa-constructor.sourceforge.net/ ? It might really be a good starting point, isn't it ? "charles loboz" a ?crit dans le message news: 96k7t3$kr8$1 at mail.pl.unisys.com... > 1. It seems that there are several Python IDEs in which many smart people > invested plenty of effort. We have WinPython, IDLE (do we still have it ? > ;-)), ActiveState is coming up with Komodo (build on Mozilla) and I probably > missed a few here - apologies. Plus we have commercial ones. > > 2. Competition is good, splitting efforts probably less good. And there's a > fine line between them. > > 3. My abbreviated personal view about technology directions: Win will rule > the desktop, not only because of it's current popularity - but because it > has component model. Linux doesn't have a native object model - which > creates scalability (in size and functionality) problems for applications. > Java on Linux will provide the component model but only for the Java world, > not Linux. > > 4. Good and lasting IDE is about modularity and ease of extension. While I > applaud the efforts of ActiveState I'm not sure that using Mozilla gives > enough fuel for the long run. > > 5. www.netbeans.org - please, please, please read the whitepaper on that! > > 6. Essentially this is an open source IDE for Java - but can be used for > most anything else. It's highly modular - you can customize/replace editor > or file system etc (see 5). There is some fantastic stuff there as well as > plenty of good design. Jython folks obviously are already having a peek at > it (naturally) - but this could be used for general Python, too. And used on > both platforms - NT and UNIX. > > 7. I'm not sure how well Netbeans functionality can be blended with > winpython. but then, i suspect that winpython functionality will blend with > .NET anyway. > > > From muk_pr at yahoo.com Sat Feb 17 19:23:58 2001 From: muk_pr at yahoo.com (Victor Black) Date: Sat, 17 Feb 2001 20:23:58 +0200 Subject: python 3000 IDE? be warned: contentious References: <96k7t3$kr8$1@mail.pl.unisys.com> Message-ID: >3. My abbreviated personal view about technology directions: Win will rule >the desktop, not only because of it's current popularity - but because it Have you heard of kylix? http://www.borland.com/kylix/ From gustafl at algonet.se Sat Feb 17 00:02:50 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: 16 Feb 2001 23:02:50 GMT Subject: socket.error Message-ID: I'm using 1.5.2 in Windows 98. When running the httplib module I get the following error when using a non- existing host name: Traceback (innermost last): File "httptest.py", line 28, in ? h = httplib.HTTP(domain) File "d:\python\Lib\httplib.py", line 51, in __init__ if host: self.connect(host, port) File "d:\python\Lib\httplib.py", line 79, in connect self.sock.connect(host, port) File "", line 1, in connect socket.error: host not found The code to produce this error is simply: import httplib h = httplib.HTTP('www.nonvalidhost.com') Python doesn't seem to like when I write "except socket.error:", so I wonder how to handle it properly. Regards, Gustaf Liljegren From dougfort at downright.com Sat Feb 17 03:29:33 2001 From: dougfort at downright.com (Doug Fort) Date: Fri, 16 Feb 2001 21:29:33 -0500 Subject: socket.error References: Message-ID: Here's how we do it. Note that you must 'import socket'. The 'message' object is usually a tuple. except socket.error, message: self._message = "Socket Error: %s" % (str(message)) -- Doug Fort Senior Meat Manager Downright Software LLC "Gustaf Liljegren" wrote in message news:Xns904B3C674D9gustaflalgonetse at 194.213.69.148... > I'm using 1.5.2 in Windows 98. > > When running the httplib module I get the following error when using a non- > existing host name: > > Traceback (innermost last): > File "httptest.py", line 28, in ? > h = httplib.HTTP(domain) > File "d:\python\Lib\httplib.py", line 51, in __init__ > if host: self.connect(host, port) > File "d:\python\Lib\httplib.py", line 79, in connect > self.sock.connect(host, port) > File "", line 1, in connect > socket.error: host not found > > The code to produce this error is simply: > > import httplib > h = httplib.HTTP('www.nonvalidhost.com') > > Python doesn't seem to like when I write "except socket.error:", so I > wonder how to handle it properly. > > Regards, > > Gustaf Liljegren From dalke at acm.org Sat Feb 17 00:53:54 2001 From: dalke at acm.org (Andrew Dalke) Date: Fri, 16 Feb 2001 16:53:54 -0700 Subject: use a news server? (was Re: python-dev summary, Jan. 16-31) References: Message-ID: <96kemo$tum$1@slb5.atl.mindspring.net> Tim wrote: >I liked life better when language changes were slugged out on >c.l.py. There are soooooo many archives and semi-private >mailing lists and utterly pvt emails now-- and all of them, > like this msg, with useless Subject lines -- I >just don't know where to look anymore either. And I spend hours >on this stuff every day of my miserable life. *Sniff* I remember the good old days, when there were only a couple of messages a day and I looked forward to reading each one. *Siff*, *sniff* Now I just hit "kill thread" a lot :) Maybe I should start using another language as obscure as Python was 5 years ago. >he's been pushing to >move discussions to venues like egroups for at least a year. Here's a thought. Why not set up an NNTP server for python development? Bear in mind that I know nothing about how complicated that is, but here's what I'm thinking about. Keep c.l.py around as the main list. Have a new news server for development only, with a single main group which is python-dev. Newsgroups can be moderated or unmoderated, and I imagine it would be easy to automatically pass on mail from specified people. When a discussion thread gets to be too involved, create a new newsgroup (which can be open or closed) and spin off the discussions there. Newsgroup creation can be done very easily, if the alt.* groups are any indication. If someone like me wants to follow the articles, I just connect to the news server and see which groups are available. This lets me use all my local tools for reading, threading an searching rather than depending on pipermail. It can even be better since I only need to download the archive once rather than (as I was yesterday) flipping back and forth among different pages. It also lets me read attachements directly. Archiving of newsgroups can be done by keeping all posts and/or migrating old posts to a pipermail archive. And of course people who want to use email can use standard gateways between news and mail. Why wouldn't this work? Andrew dalke at acm.org From aahz at panix.com Sat Feb 17 03:45:12 2001 From: aahz at panix.com (Aahz Maruch) Date: 16 Feb 2001 18:45:12 -0800 Subject: use a news server? (was Re: python-dev summary, Jan. 16-31) References: <96kemo$tum$1@slb5.atl.mindspring.net> Message-ID: <96kojo$g9u$1@panix2.panix.com> In article <96kemo$tum$1 at slb5.atl.mindspring.net>, Andrew Dalke wrote: > >Why wouldn't this work? There's no intrinsic reason this wouldn't work. News servers are one of the most robust bits of software around, taking relatively little maintenance. The main problem is on the client side: most people aren't familiar with using multiple news servers, and many newsreaders don't make it easy to do so. -- --- 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 Why doesn't "Just Say NO" include caffeine, nicotine, alcohol, Prozac, and Ritalin? --Aahz From dalke at acm.org Sat Feb 17 06:44:49 2001 From: dalke at acm.org (Andrew Dalke) Date: Fri, 16 Feb 2001 22:44:49 -0700 Subject: use a news server? (was Re: python-dev summary, Jan. 16-31) References: <96kemo$tum$1@slb5.atl.mindspring.net> <96kojo$g9u$1@panix2.panix.com> Message-ID: <96l38v$oku$1@slb0.atl.mindspring.net> Aahz Maruch wrote in message <96kojo$g9u$1 at panix2.panix.com>... > The main problem is on the client side: most people aren't >familiar with using multiple news servers, and many newsreaders don't >make it easy to do so. Although Netscape and IE both allow that. All you need is the "news:" URL. I believe xrn doesn't support multiple servers, but it's been a long time since I used it. Looking at sourceforge, it does appear that trn supports multiple groups, so there's still the vt100 support! :) I also forgot to add, Mozilla hosts their development via their own news server (see http://www.mozilla.org/community.html ) and Freshmeat makes their announcements available as well (see http://freshmeat.net/faq/view/18/). Andrew dalke at acm.org From michael at stroeder.com Sat Feb 17 10:39:08 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Sat, 17 Feb 2001 10:39:08 +0100 Subject: use a news server? (was Re: python-dev summary, Jan. 16-31) References: <96kemo$tum$1@slb5.atl.mindspring.net> <96kojo$g9u$1@panix2.panix.com> Message-ID: <3A8E46BC.73002E12@stroeder.com> Aahz Maruch wrote: > > In article <96kemo$tum$1 at slb5.atl.mindspring.net>, > Andrew Dalke wrote: > > > >Why wouldn't this work? > > The main problem is on the client side: most people aren't > familiar with using multiple news servers, and many newsreaders don't > make it easy to do so. And many people are sitting behind firewalls and do only have access to one general internal news server. BTW: This is the same discussion like splitting news:comp.lang.python. This has advantages and disadvantages. Ciao, Michael. From dalke at acm.org Sat Feb 17 12:52:36 2001 From: dalke at acm.org (Andrew Dalke) Date: Sat, 17 Feb 2001 04:52:36 -0700 Subject: use a news server? (was Re: python-dev summary, Jan. 16-31) References: <96kemo$tum$1@slb5.atl.mindspring.net> <96kojo$g9u$1@panix2.panix.com> <3A8E46BC.73002E12@stroeder.com> Message-ID: <96lom4$qle$1@slb6.atl.mindspring.net> Michael Str?der wrote: >And many people are sitting behind firewalls and do only have access >to one general internal news server. But I did mention that the newsgroup messages can still be archived and made available via pipermail, so python-dev access would be no worse than what there is now. >BTW: This is the same discussion like splitting >news:comp.lang.python. This has advantages and disadvantages. Excepting there is already a proliferation of spun off lists in python-dev (eg, to egroups). So this is a suggestion on how to pull them together in one place. Andrew dalke at acm.org From tim_one at email.msn.com Sat Feb 17 08:07:00 2001 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 17 Feb 2001 02:07:00 -0500 Subject: use a news server? (was Re: python-dev summary, Jan. 16-31) In-Reply-To: <96kemo$tum$1@slb5.atl.mindspring.net> Message-ID: [Andrew Dalke] > ... > Here's a thought. Why not set up an NNTP server for > python development? Believe it or not, that's already being talked about, by people who know far more than me about this kind of stuff. It's attractive! The problems are "the usual": finding a well-connected machine with spare cycles and bytes that won't be taken away, not stepping on anyone's political toes, and conjuring up a wizard with the spare bandwidth to bring it into existence and to care for it when it's sick forever after. Note that over the last 3 months, even the Python mailing lists have been sick more often than not -- and we're still not sure that they're fully recovered, because nobody has had the time to figure out *why* the last batch of gross problems just seemed to go away by magic. You really trust us to manage an NNTP-based approach <0.9 wink>? there's-a-reason-we-love-sourceforge-ly y'rs - tim From thomas at xs4all.net Sat Feb 17 12:05:58 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sat, 17 Feb 2001 12:05:58 +0100 Subject: use a news server? (was Re: python-dev summary, Jan. 16-31) In-Reply-To: ; from tim_one@email.msn.com on Sat, Feb 17, 2001 at 02:07:00AM -0500 References: <96kemo$tum$1@slb5.atl.mindspring.net> Message-ID: <20010217120558.Q4924@xs4all.nl> On Sat, Feb 17, 2001 at 02:07:00AM -0500, Tim Peters wrote: > > Here's a thought. Why not set up an NNTP server for > > python development? > Believe it or not, that's already being talked about, by people who know far > more than me about this kind of stuff. It's attractive! The problems are > "the usual": finding a well-connected machine with spare cycles and bytes > that won't be taken away, not stepping on anyone's political toes, and > conjuring up a wizard with the spare bandwidth to bring it into existence > and to care for it when it's sick forever after. Note that over the last 3 > months, even the Python mailing lists have been sick more often than not -- > and we're still not sure that they're fully recovered, because nobody has > had the time to figure out *why* the last batch of gross problems just > seemed to go away by magic. You really trust us to manage an NNTP-based > approach <0.9 wink>? Pfiffle. Regardles of whether the idea is workable or not, these *technical* issues are non-issues. I (and the company I work for, XS4ALL) have offered sponsorship in the form of machines and maintenance multiple times. (In fact, I keep offering it whenever I mail Barry, when the lists seem sickish again :-) The original offer was for webservers/mailservers, but there is no reason to make it (or include into it) NNTP servers. And we have ample bandwidth and experience in running NNTP servers. I don't trust *you* to manage a UNIX system, Tim, and I doubt I trust Guido to touch one of my systems, but I certainly trust me and my colleagues ;) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From aahz at panix.com Sat Feb 17 16:24:31 2001 From: aahz at panix.com (Aahz Maruch) Date: 17 Feb 2001 07:24:31 -0800 Subject: use a news server? (was Re: python-dev summary, Jan. 16-31) References: <96kemo$tum$1@slb5.atl.mindspring.net> Message-ID: <96m53f$mb6$1@panix3.panix.com> In article , Thomas Wouters wrote: > >Pfiffle. Regardles of whether the idea is workable or not, these *technical* >issues are non-issues. I (and the company I work for, XS4ALL) have offered >sponsorship in the form of machines and maintenance multiple times. (In >fact, I keep offering it whenever I mail Barry, when the lists seem sickish >again :-) The original offer was for webservers/mailservers, but there is no >reason to make it (or include into it) NNTP servers. And we have ample >bandwidth and experience in running NNTP servers. > >I don't trust *you* to manage a UNIX system, Tim, and I doubt I trust Guido >to touch one of my systems, but I certainly trust me and my colleagues Let me back this up: xs4all has one of the best reputations in the ISP business. I don't have any personal experience, but several people I trust rank xs4all right up with panix. I think this would likely be one of the best things that could happen to the Python community, getting the core hardware/software under professional management. The only disadvantage I can think of is that xs4all isn't on the continental US, but that means very little these days. -- --- 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 Why doesn't "Just Say NO" include caffeine, nicotine, alcohol, Prozac, and Ritalin? --Aahz From thomas at xs4all.net Fri Feb 23 17:17:03 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 23 Feb 2001 17:17:03 +0100 Subject: use a news server? (was Re: python-dev summary, Jan. 16-31) In-Reply-To: <96m53f$mb6$1@panix3.panix.com>; from aahz@panix.com on Sat, Feb 17, 2001 at 07:24:31AM -0800 References: <96kemo$tum$1@slb5.atl.mindspring.net> <96m53f$mb6$1@panix3.panix.com> Message-ID: <20010223171702.B16781@xs4all.nl> On Sat, Feb 17, 2001 at 07:24:31AM -0800, Aahz Maruch wrote: [ Thomas Wouters suggests running an NNTP/list server for the Python community ] > Let me back this up [ .. ] Since I've seen some positive reactions to this idea, I'm wondering how many more I could get by explicitly asking for it :) I'm willing to try and get my employee to cough up the machines, the place to locate them in a system room and the connectivity to the 'net (and boy, that's some connectivity:) but I'll only do that if it's actually considered useful. I'm pretty much out of touch with 'the Python community' as an entity, so I'll have to ask straight up: - Do we need another way to get a list/forum for Pythonic discussions, regardless of the exact medium ? I'm unsure what real alternatives there are, but the initial look of groups.yahoo.com ("Give me your personal data!") scares the old cyberhacker in me enough to protest against it. And those of you who lived in the Netherlands during XS4ALL's ad campaign and subsequent court cases, last year, should know why :) I know about lists.sourceforge.net, but I doubt they want to bother setting up lists for all Python projects. (Or maybe they do. I don't know.) The same goes about starship.python.net, though I'm sure they are a bit more willing to host python discussions :) - For howmany projects/discussions, roughly ? Is it really worth setting up a seperate machine/network for it ? - What kind of forum would be desirable ? I was thinking newsgroups (with or without an 'upfeed') gated to Mailman lists, but some webforum is possible too. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From emile at fenx.com Sat Feb 24 03:24:45 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 23 Feb 2001 18:24:45 -0800 Subject: use a news server? (was Re: python-dev summary, Jan. 16-31) References: <96kemo$tum$1@slb5.atl.mindspring.net> <96m53f$mb6$1@panix3.panix.com> Message-ID: <97763e$o6qu3$1@ID-11957.news.dfncis.de> Thomas, As long as you're asking... ;-) One thing I've occasionally thought of trying to do is set up a gateway for *all* of the varied python related SIG's, mailing lists and newsgroups through to a private back-end news server. I dropped out of most of my subscriptions last year when there were a lot of mail related problems, but I miss being able to follow the interesting topics as they come across. Certainly the volume of mail on the python and Zope lists alone keep me from re-subscribing, but I'm quite happy browsing the python list on news.cis.dfn.de, and would enjoy having news group access to browse and follow the other lists. Perhaps an upfeed on the legitimate newsgroups, but for the mailing list only groups, an e-mail shot off to the list would suffice (assuming they accept posts from non-subscribers... otherwise just subscribe). Good luck with this. If you're counting votes, let me know. I'm more than willing to vote again. ;-) See you, -- Emile van Sebille emile at fenx.com ------------------- "Thomas Wouters" wrote in message news:mailman.982945084.3594.python-list at python.org... > On Sat, Feb 17, 2001 at 07:24:31AM -0800, Aahz Maruch wrote: > > [ Thomas Wouters suggests running an NNTP/list server for the Python > community ] > > > Let me back this up [ .. ] > > Since I've seen some positive reactions to this idea, I'm wondering how many > more I could get by explicitly asking for it :) I'm willing to try and get > my employee to cough up the machines, the place to locate them in a system > room and the connectivity to the 'net (and boy, that's some connectivity:) > but I'll only do that if it's actually considered useful. I'm pretty much > out of touch with 'the Python community' as an entity, so I'll have to ask > straight up: > > - Do we need another way to get a list/forum for Pythonic discussions, > regardless of the exact medium ? I'm unsure what real alternatives there > are, but the initial look of groups.yahoo.com ("Give me your personal > data!") scares the old cyberhacker in me enough to protest against it. And > those of you who lived in the Netherlands during XS4ALL's ad campaign and > subsequent court cases, last year, should know why :) > > I know about lists.sourceforge.net, but I doubt they want to bother > setting up lists for all Python projects. (Or maybe they do. I don't > know.) The same goes about starship.python.net, though I'm sure they are a > bit more willing to host python discussions :) > > - For howmany projects/discussions, roughly ? Is it really worth setting up > a seperate machine/network for it ? > > - What kind of forum would be desirable ? I was thinking newsgroups (with or > without an 'upfeed') gated to Mailman lists, but some webforum is possible > too. > > -- > Thomas Wouters > > Hi! I'm a .signature virus! copy me into your .signature file to help me spread! > From shaleh at valinux.com Sat Feb 17 01:04:10 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Fri, 16 Feb 2001 16:04:10 -0800 (PST) Subject: ok, so how do I return a sorted list without doing it in place Message-ID: So, several of us informed Philip that list.sort() is in place and returns nothing. How do i accomplish: for key in dict.keys().sort(): print "%s -> %s" % (key, dict[key]) ??? I know I can do: list = dict.keys() list.sort() ..... but it is just plain annoying. From tjg at exceptionalminds.com Sat Feb 17 01:20:24 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Fri, 16 Feb 2001 16:20:24 -0800 Subject: ok, so how do I return a sorted list without doing it in place In-Reply-To: ; from shaleh@valinux.com on Fri, Feb 16, 2001 at 04:04:10PM -0800 References: Message-ID: <20010216162024.F19267@trufflehunter.avalongroup.net> On Fri, Feb 16, 2001 at 04:04:10PM -0800, Sean 'Shaleh' Perry wrote: > I know I can do: > > list = dict.keys() > list.sort() > ..... > > but it is just plain annoying. I agree. This has bitten me on the butt more than once. It also seems somewhat unPythonic. Usually I expect what happens in Python, but that sort process always strikes me as unexpected. -- 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: 31 days 4:30 hours ago<< From phlip_cpp at my-deja.com Sat Feb 17 01:21:59 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 17 Feb 2001 00:21:59 GMT Subject: ok, so how do I return a sorted list without doing it in place References: Message-ID: <96kg77$88c@dispatch.concentric.net> Proclaimed Sean 'Shaleh' Perry from the mountaintops: > So, several of us informed Philip that list.sort() is in place and returns > nothing. How do i accomplish: > > for key in dict.keys().sort(): > print "%s -> %s" % (key, dict[key]) > > ??? > > I know I can do: > > list = dict.keys() > list.sort() > ..... > > but it is just plain annoying. I don't know why a more useful return value couldn't have been supplied, for call chaining like this at least, but Mr. Manners reminds the Gentle Poster that one should not cram too much stuff on one command line. Leave that for Perl or C++ coders. -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- My opinions are those of your employer -- From kalle at gnupung.net Sat Feb 17 02:01:22 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Sat, 17 Feb 2001 02:01:22 +0100 Subject: ok, so how do I return a sorted list without doing it in place In-Reply-To: <96kg77$88c@dispatch.concentric.net>; from phlip_cpp@my-deja.com on Sat, Feb 17, 2001 at 12:21:59AM +0000 References: <96kg77$88c@dispatch.concentric.net> Message-ID: <20010217020122.B4141@apone.network.loc> Sez Phlip: > Proclaimed Sean 'Shaleh' Perry from the mountaintops: [list.sort() returns None] > > I don't know why a more useful return value couldn't have been supplied, See http://www.python.org/doc/current/lib/typesseq-mutable.html, footnote 5, for the reasoning of the designers: """ The sort() and reverse() methods modify the list in place for economy of space when sorting or reversing a large list. They don't return the sorted or reversed list to remind you of this side effect. """ 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 r2d2 at mao.acc.umu.se Mon Feb 19 09:14:35 2001 From: r2d2 at mao.acc.umu.se (Niklas Frykholm) Date: Mon, 19 Feb 2001 08:14:35 +0000 (UTC) Subject: ok, so how do I return a sorted list without doing it in place References: <96kg77$88c@dispatch.concentric.net> Message-ID: In article <96kg77$88c at dispatch.concentric.net>, Phlip wrote: >Proclaimed Sean 'Shaleh' Perry from the mountaintops: > >> So, several of us informed Philip that list.sort() is in place and returns >> nothing. How do i accomplish: >> >> for key in dict.keys().sort(): >> print "%s -> %s" % (key, dict[key]) >> >> ??? >> >> I know I can do: >> >> list = dict.keys() >> list.sort() >> ..... >> >> but it is just plain annoying. > >I don't know why a more useful return value couldn't have been supplied, >for call chaining like this at least, but Mr. Manners reminds the Gentle >Poster that one should not cram too much stuff on one command line. Leave >that for Perl or C++ coders. I really like the way ruby has solved this, by providing two functions: sort and sort!, where sort! sorts the list in place and sort returns a sorted copy. The exclamation mark is used to denote a method that changes the object in-place. With this convention you do not have to remember whether a function works in-place or on a copy. Many other similar functions also have two variants, for example there is a map function and a map! function. // Niklas From kalle at gnupung.net Sat Feb 17 01:56:17 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Sat, 17 Feb 2001 01:56:17 +0100 Subject: ok, so how do I return a sorted list without doing it in place In-Reply-To: ; from shaleh@valinux.com on Fri, Feb 16, 2001 at 04:04:10PM -0800 References: Message-ID: <20010217015617.A4141@apone.network.loc> Sez Sean 'Shaleh' Perry: > So, several of us informed Philip that list.sort() is in place and returns > nothing. How do i accomplish: > > for key in dict.keys().sort(): > print "%s -> %s" % (key, dict[key]) > > ??? # Courtesy of Alex Martelli, a few dozen posts earlier or so. def sort(l): l.sort() return l for key in sort(dict.keys()): print "%s -> %s" % (key, dict[key]) That's the best you can get, methinks. 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 aahz at panix.com Sat Feb 17 03:48:52 2001 From: aahz at panix.com (Aahz Maruch) Date: 16 Feb 2001 18:48:52 -0800 Subject: ok, so how do I return a sorted list without doing it in place References: Message-ID: <96koqk$gv6$1@panix2.panix.com> In article , Timothy Grant wrote: >On Fri, Feb 16, 2001 at 04:04:10PM -0800, Sean 'Shaleh' Perry wrote: >> I know I can do: >> >> list = dict.keys() >> list.sort() >> ..... >> >> but it is just plain annoying. > >I agree. This has bitten me on the butt more than once. It also seems >somewhat unPythonic. Usually I expect what happens in Python, but that >sort process always strikes me as unexpected. It's unexpected in some respects, but doing it this way causes the fewest surprises overall. At least you rarely get a downstream bug this way. -- --- 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 Why doesn't "Just Say NO" include caffeine, nicotine, alcohol, Prozac, and Ritalin? --Aahz From grante at visi.com Sat Feb 17 17:21:32 2001 From: grante at visi.com (Grant Edwards) Date: Sat, 17 Feb 2001 16:21:32 GMT Subject: ok, so how do I return a sorted list without doing it in place References: <96koqk$gv6$1@panix2.panix.com> Message-ID: In article <96koqk$gv6$1 at panix2.panix.com>, Aahz Maruch wrote: >>> I know I can do: >>> >>> list = dict.keys() >>> list.sort() >>> ..... >>> >>> but it is just plain annoying. >> >>I agree. This has bitten me on the butt more than once. It also seems >>somewhat unPythonic. Usually I expect what happens in Python, but that >>sort process always strikes me as unexpected. On many occasions, I would find it quite handy if there was a sequence method that returned a sorted shallow copy: for k in dict.keys().sorted(): whatever(k) >It's unexpected in some respects, but doing it this way causes the >fewest surprises overall. At least you rarely get a downstream bug >this way. In my mine the used of the adjective "sorted" as a method name conveys the fact that it doesn't modify the list in place they way the imperative "sort" does. YMMV. -- Grant Edwards grante Yow! World War III? No at thanks! visi.com From grante at visi.com Sun Feb 18 01:00:47 2001 From: grante at visi.com (Grant Edwards) Date: Sun, 18 Feb 2001 00:00:47 GMT Subject: ok, so how do I return a sorted list without doing it in place References: <96koqk$gv6$1@panix2.panix.com> Message-ID: In article , Grant Edwards wrote: > for k in dict.keys().sorted(): > whatever(k) [...] >In my mine the used of the adjective "sorted" Jeez, I _swear_ that's not what I typed... -- Grant Edwards grante Yow! Yow!! "Janitor at trapped in sewer uses ESP visi.com to find decayed burger"!! From walterm at cmat.edu.uy Sat Feb 17 02:52:18 2001 From: walterm at cmat.edu.uy (Walter Moreira) Date: Fri, 16 Feb 2001 22:52:18 -0300 Subject: 'in' operator Message-ID: <20010216225218.A13190@cmat.edu.uy> Hello. Why the following test raise an error? >>> '' in 'yY' Traceback (most recent call last): File "", line 1, in ? TypeError: 'in ' requires character as left operand I would expect it to give 0, false. With the actual behavior, one must write resp = raw_input('Yes or no: ') if resp and resp in 'yY': .... to consider the case when the user just press `return', instead of if resp in 'yY': Is this a planned behavior? Regards: Walter -- -------------- Walter Moreira <> Centro de Matematica <> Universidad de la Republica email: walterm at cmat.edu.uy <> HomePage: http://www.cmat.edu.uy/~walterm +----------------------------------------------------- /OD\_ | "Agent Smith: Never send a human to do a machine's O o . |_o_o_) | job." -- From ``The Matrix'' --+-- From tim.one at home.com Sat Feb 17 04:50:19 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 16 Feb 2001 22:50:19 -0500 Subject: 'in' operator In-Reply-To: <20010216225218.A13190@cmat.edu.uy> Message-ID: [Walter Moreira] > Why the following test raise an error? > > >>> '' in 'yY' > Traceback (most recent call last): > File "", line 1, in ? > TypeError: 'in ' requires character as left operand elt in sequence tests whether elt is a member of sequence. The elements of strings are characters. Testing whether anything other than a character is an element of a string is simply a TypeError: it's a highly suspicious question because only a character *could* be an element of a string. And an empty string is not a character. > I would expect it to give 0, false. With the actual behavior, one > must write > > resp = raw_input('Yes or no: ') > if resp and resp in 'yY': > .... > to consider the case when the user just press `return', But fails to consider the case where the user enters more than one character before pressing 'return' (try it: it still blows up). You're missing this one: if resp in ("y", "Y"): *Now* you're asking whether a string is in a sequence of strings, which always makes sense and is much closer to your intent. Even better: if resp.lower()[:1] == "y": After all, if you're asking the user "Yes or no", it's impolite to take "Yes" as meaning "no" <0.3 wink>. > Is this a planned behavior? Yes. Python is trying to guide you toward writing code you won't regret. TypeErrors are signs that you're doing something so questionable that Python would rather refuse to do anything than guess your intent. x = 6 + "42" "642" or 48? Python refuses to guess -- so that's a TypeError too. it's-for-your-own-good-ly y'rs - tim From root at rainerdeyke.com Sat Feb 17 08:50:07 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sat, 17 Feb 2001 07:50:07 GMT Subject: 'in' operator References: Message-ID: "Walter Moreira" wrote in message news:mailman.982374799.24358.python-list at python.org... > Why the following test raise an error? > > >>> '' in 'yY' > Traceback (most recent call last): > File "", line 1, in ? > TypeError: 'in ' requires character as left operand > > I would expect it to give 0, false. I would expect it to give 1, since "" is a substring of "yY". Given this basic misunderstanding of what '"" in "yY"' is supposed to do, raising an exception seems a reasonable compromise. If you want to check if something is either "y" or "Y", use 'resp in ("y", "Y")'. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From pearu at cens.ioc.ee Sat Feb 17 10:21:05 2001 From: pearu at cens.ioc.ee (Pearu Peterson) Date: Sat, 17 Feb 2001 11:21:05 +0200 Subject: 'in' operator In-Reply-To: References: Message-ID: On Sat, 17 Feb 2001, Rainer Deyke wrote: > "Walter Moreira" wrote in message > news:mailman.982374799.24358.python-list at python.org... > > Why the following test raise an error? > > > > >>> '' in 'yY' > > Traceback (most recent call last): > > File "", line 1, in ? > > TypeError: 'in ' requires character as left operand > > > > I would expect it to give 0, false. > > I would expect it to give 1, since "" is a substring of "yY". Given this Me too, and because of the analogy: `an empty set is a subset of every set' `an empty string is a substring of every string' Pearu From jepler at inetnebr.com Sat Feb 17 17:35:28 2001 From: jepler at inetnebr.com (Jeff Epler) Date: Sat, 17 Feb 2001 16:35:28 GMT Subject: 'in' operator References: Message-ID: On Sat, 17 Feb 2001 11:21:05 +0200, Pearu Peterson wrote: >Me too, and because of the analogy: >`an empty set is a subset of every set' >`an empty string is a substring of every string' But "in" doesn't test for a subset. For instance, [1, 2] in [1, 2, 3, 4] is 0. However, I think that "" in "yY" and 0 in "yY" should return 0, because for all items in "yY", none of them are "" or 0. (This is compared to raising an error) Jeff From tim.one at home.com Sat Feb 17 19:34:59 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 17 Feb 2001 13:34:59 -0500 Subject: 'in' operator In-Reply-To: Message-ID: [Jeff Epler] > ... > However, I think that > "" in "yY" > and > 0 in "yY" > should return 0, because for all items in "yY", none of them are > "" or 0. (This is compared to raising an error) As explained earlier, that's exactly why Python raises TypeError for x in y when type(x) is such that it can't possibly succeed: you think the first example should return 0, the original questioner thought 1. Python refuses to guess which one of you wrote it . say-what-you-mean-and-there's-no-problem-ly y'rs - tim From moshez at zadka.site.co.il Sun Feb 18 00:37:58 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sun, 18 Feb 2001 01:37:58 +0200 (IST) Subject: 'in' operator In-Reply-To: References: , Message-ID: <20010217233758.F0ED0A840@darjeeling.zadka.site.co.il> On Sat, 17 Feb 2001 16:35:28 GMT, jepler at inetnebr.com (Jeff Epler) wrote: > However, I think that > "" in "yY" > and > 0 in "yY" > should return 0, because for all items in "yY", none of them are > "" or 0. (This is compared to raising an error) I thought so too, but when I offered to change, Guido didn't agree -- and he was probably was right. Practicality beats purity -- and most times people do a ``0 in "yY"'' it's an error, so Python signals it. For example, the recent poster, who was lucky to have Python raise an error, rather then silently return 0. -- "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 tjreedy at udel.edu Sun Feb 18 09:21:08 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 18 Feb 2001 03:21:08 -0500 Subject: 'in' operator References: Message-ID: <96o070$bt6$1@news.udel.edu> "Walter Moreira" wrote in message news:mailman.982374799.24358.python-list at python.org... > Why the following test raise an error? > > >>> '' in 'yY' > Traceback (most recent call last): > File "", line 1, in ? > TypeError: 'in ' requires character as left operand Precisely for the reason stated. A character is a string of length 1. A null string (of length 0) is not a character. Neither are strings of length >= 2 [for which one must use find() or match()]. > I would expect it to give 0, false. The empty set is contained in every set as a subset. The empty string is a substring of every string. So, if defined, I would expect 1 = true. > With the actual behavior, one must write > resp = raw_input('Yes or no: ') > if resp and resp in 'yY': ... This is a good example of what 'and' is meant for. Note that if '' in string were defined as true, you would still have to write the above, presuming that you did not want to interpret it as yes. > Is this a planned behavior? Based on the error message, yes. Terry J. Reedy From jmarshal at mathworks.com Tue Feb 20 15:47:12 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 20 Feb 2001 14:47:12 GMT Subject: 'in' operator References: <96o070$bt6$1@news.udel.edu> Message-ID: <96u01g$b38$1@news.mathworks.com> Terry Reedy wrote: > "Walter Moreira" wrote in message > news:mailman.982374799.24358.python-list at python.org... >> Why the following test raise an error? >> >> >>> '' in 'yY' >> Traceback (most recent call last): >> File "", line 1, in ? >> TypeError: 'in ' requires character as left operand > Precisely for the reason stated. A character is a string of length 1. A > null string (of length 0) is not a character. Neither are strings of > length >= 2 [for which one must use find() or match()]. Wouldn't it be more natural for this to be a ValueError? There is no character type in Python -- '', 'y', and 'yY' are all strings. From shaleh at valinux.com Sat Feb 17 05:12:23 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Fri, 16 Feb 2001 20:12:23 -0800 Subject: why the string function / module change Message-ID: <20010216201223.A14948@valinux.com> Ok, so I read the what's new. I understand that for Unicode support the string module needed help. No problem. By why introduce a new syntax that makes 2.0 incompatible with 1.5? foo = 'this is a string' pieces = foo.split() split(foo) worked just as well. I understand there were problems making the string module do this, but still. Could they have not been _split() or something to dissuade their use? From shaleh at valinux.com Sat Feb 17 06:20:02 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Fri, 16 Feb 2001 21:20:02 -0800 Subject: why the string function / module change In-Reply-To: <20010216201223.A14948@valinux.com>; from shaleh@valinux.com on Fri, Feb 16, 2001 at 08:12:23PM -0800 References: <20010216201223.A14948@valinux.com> Message-ID: <20010216212002.A14970@valinux.com> On Fri, Feb 16, 2001 at 08:12:23PM -0800, Sean 'Shaleh' Perry wrote: > > split(foo) worked just as well. I understand there were problems making the > string module do this, but still. Could they have not been _split() or > something to dissuade their use? > example of recent code I have seen: keys[keyname] = ": ".join(s.split(": ")[1:]) foo.join(sequence) # that logic is just odd From db3l at fitlinxx.com Wed Feb 21 07:43:28 2001 From: db3l at fitlinxx.com (David Bolen) Date: 21 Feb 2001 01:43:28 -0500 Subject: why the string function / module change References: Message-ID: Sean 'Shaleh' Perry writes: > Ok, so I read the what's new. I understand that for Unicode support the > string module needed help. No problem. By why introduce a new syntax that > makes 2.0 incompatible with 1.5? The syntax change wasn't to support Unicode, it was to make string methods actual methods of string objects, and thus more consistent with other Python objects. If you think about, the string module was the odd man out. After all, if you want to read or write to a file object, you use .read() and .write(). You don't use filemodule.read() and filemodule.write(). If you are appending to a list object you use .append(), and not listmodule.append(). Similarly with dictionaries, and so on... The string module - I expect largely for legacy reasons - existed as a module with functions that took string objects as parameters. But that's very different than methods right on the string objects, which are much more consistent with other objects in Python. > split(foo) worked just as well. I understand there were problems making the > string module do this, but still. Could they have not been _split() or > something to dissuade their use? I'm not aware of any problems - and you can still use "string.split(foo)" rather than "foo.split()" if you like (internally the string module functions are just reflected through the methods on the objects they are given). Although its possible that the string module may eventually be deprecated, it's not likely to be for quite a while, if ever. -- -- 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 scarblac at pino.selwerd.nl Wed Feb 21 23:32:46 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 21 Feb 2001 22:32:46 GMT Subject: why the string function / module change References: Message-ID: David Bolen wrote in comp.lang.python: > If you think about, the string module was the odd man out. After all, > if you want to read or write to a file object, you use > .read() and .write(). You don't use > filemodule.read() and filemodule.write(). > > If you are appending to a list object you use .append(), and > not listmodule.append(). Similarly with dictionaries, and so on... But lists and dictionaries are mutable, and files are as well, in a way. Strings are not. Nor are tuples and integers, and those don't have methods either. So strings were hardly an odd one out. I like the string methods (maybe " ".join() is taking it a bit far) but I think this reason is a bit weak. -- Remco Gerlich From qrczak at knm.org.pl Thu Feb 22 17:02:16 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 22 Feb 2001 16:02:16 GMT Subject: why the string function / module change References: Message-ID: 21 Feb 2001 22:32:46 GMT, Remco Gerlich pisze: > > If you are appending to a list object you use .append(), and > > not listmodule.append(). Similarly with dictionaries, and so on... > > But lists and dictionaries are mutable, and files are as well, in a way. > Strings are not. Why should it matter? > Nor are tuples and integers, and those don't have methods either. I see no fundamental reason why they should not, except that Python already expressed them as builtin syntax or builtin functions which recognize builtin types (+, ==, len). -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From man_at_moon at hotmail.com Sat Feb 17 08:51:01 2001 From: man_at_moon at hotmail.com (David A.) Date: Sat, 17 Feb 2001 07:51:01 -0000 Subject: Yet Another Newbie Question (YANQ) Message-ID: Hi to everyone, I am playing around with python and I have 1 quetions where I hope someone can help I have this problem: >>> a='a' >>> prt='print' >>> t=prt+' '+a >>> t 'print a' now when I try to: >>> eval(t) Traceback (innermost last): File "", line 1, in ? eval(t) File "", line 1 print a ^ SyntaxError: invalid syntax can someone explain me what I am doing wrong! Why can't I use eval(print)? Any help is welcome! David Asfaha -- "Quidquid latine dictum sit, altum viditur." Whatever is said in Latin sounds profound. From phd at phd.pp.ru Mon Feb 19 12:31:08 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Mon, 19 Feb 2001 14:31:08 +0300 (MSK) Subject: Yet Another Newbie Question (YANQ) In-Reply-To: Message-ID: On Sat, 17 Feb 2001, David A. wrote: > >>> a='a' > >>> prt='print' > >>> t=prt+' '+a > >>> t > 'print a' > > now when I try to: > >>> eval(t) > Traceback (innermost last): > File "", line 1, in ? > eval(t) > File "", line 1 > print a > ^ > SyntaxError: invalid syntax exec t Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From jhauser at ifm.uni-kiel.de Mon Feb 19 12:39:06 2001 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 19 Feb 2001 12:39:06 +0100 Subject: Yet Another Newbie Question (YANQ) References: Message-ID: <878zn2yk9x.fsf@lisboa.ifm.uni-kiel.de> You should use exec() instead of eval(). 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 ecastro at cicei.ulpgc.es Tue Feb 20 18:17:07 2001 From: ecastro at cicei.ulpgc.es (Enrique) Date: 20 Feb 2001 16:17:07 -0100 Subject: Yet Another Newbie Question (YANQ) References: Message-ID: <3A929760.11515D22@cicei.ulpgc.es> "David A." wrote: > Hi to everyone, > > I am playing around with python and I have 1 quetions where I hope > someone can help > > I have this problem: > > >>> a='a' > >>> prt='print' > >>> t=prt+' '+a > >>> t > 'print a' > > now when I try to: > >>> eval(t) > Traceback (innermost last): > File "", line 1, in ? > eval(t) > File "", line 1 > print a > ^ > SyntaxError: invalid syntax > > can someone explain me what I am doing wrong! Why can't I use eval(print)? > Any help is welcome! I thinks it is a semantic confusion: eval() evaluates an _expression_ (like i*(a+b-5)) exec() executes an _statement_ (print a, del b, import moduleX) Enrique From SBrunning at trisystems.co.uk Wed Feb 21 10:09:51 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Wed, 21 Feb 2001 09:09:51 -0000 Subject: Yet Another Newbie Question (YANQ) Message-ID: <31575A892FF6D1118F5800600846864D78B934@intrepid> > From: David A. [SMTP:man_at_moon at hotmail.com] > I have this problem: > > >>> a='a' > >>> prt='print' > >>> t=prt+' '+a > >>> t > 'print a' > > now when I try to: > >>> eval(t) > Traceback (innermost last): > File "", line 1, in ? > eval(t) > File "", line 1 > print a > ^ > SyntaxError: invalid syntax > > can someone explain me what I am doing wrong! Why can't I use eval(print)? > Any help is welcome! eval evaluates a Python expression - 'print a' isn't an expression. Use eval like this: >>> spam = '1 + 4' >>> eggs = eval(spam) >>> print eggs 5 What *you* want is 'exec'. try this: >>> a = 'a' >>> prt='print' >>> t=prt+' '+a >>> t 'print a' >>> exec(t) a Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk On two occasions I have been asked (by members of Parliament!), 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From dante at oz.net Sat Feb 17 09:34:00 2001 From: dante at oz.net (Michael Esveldt) Date: 17 Feb 2001 08:34:00 GMT Subject: ZWiki Web problem Message-ID: <96ld1o$9a0$0@216.39.162.234> I'm encountering the following problem in my ZWiki Web. I'm new to Zope version 2.3.0 with python 1.5.2. Any attempt to View a Wiki page produces the error below. I've tried reinstalling ZWiki from scratch, reimporting ZWiki Web and creating a brand new ZWiki Web. Zope has encountered an error while publishing this resource. Error Type: KeyError Error Value: %00 Traceback (innermost last): File /home/zope/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /home/zope/lib/python/ZPublisher/Publish.py, line 187, in publish File /home/zope/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: Traversable) File /home/zope/lib/python/ZPublisher/Publish.py, line 171, in publish File /home/zope/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: FrontPage) File /home/zope/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: FrontPage) File /home/zope/lib/python/Products/ZWiki/ZWikiPage.py, line 210, in __call__ (Object: FrontPage) File /home/zope/lib/python/OFS/DTMLMethod.py, line 189, in __call__ (Object: standard_wiki_footer) File /home/zope/lib/python/DocumentTemplate/DT_String.py, line 538, in __call__ (Object: standard_wiki_footer) File /home/zope/lib/python/DocumentTemplate/DT_Util.py, line 334, in eval (Object: bobobase_modification_time().toZone(zwiki_timezone).rfc822()) (Info: bobobase_modification_time) File , line 0, in ? File /home/zope/lib/python/DateTime/DateTime.py, line 1111, in toZone KeyError: (see above) -- dante at oz.net - Michael Esveldt - #FightThePower on Openprojects From donod at home.com Sat Feb 17 10:32:10 2001 From: donod at home.com (Don O'Donnell) Date: Sat, 17 Feb 2001 09:32:10 GMT Subject: Thoughts on List Methods and Return Values Message-ID: <3A8E44E3.3E25C7B3@home.com> A recent posting (once again) discussed the fact that the list sort method doesn't return a value. The reason being, as pointed out by Kalle: """ The sort() and reverse() methods modify the list in place for economy of space when sorting or reversing a large list. They don't return the sorted or reversed list to remind you of this side effect. """ I always considered this a fairly legitimate reason and learned to live with it. Till today, when I needed to take a sequence of alternate paths supplied as a function parameter, and insert the current directory as item [0], to come up with a list of search paths. Since I wanted to allow for tuple as well as list input, I wrote: searchList = list(altSeq).insert(0, currPath) And then, in order to eliminate possible empty strings, this became: searchList = filter(None, list(altSeq).insert(0, currPath)) After a few minutes of debugging, I realized why this doesn't work. Obviously, sort() and reverse() are not the only list methods that don't return a value, insert() doesn't either. So, I ended up with the following: searchList = list(altSeq) searchList.insert(0, currPath) searchList = filter(None, searchList) (I won't argue the fact that this may be more readable, but that's not the issue.) Of the 9 list methods listed on page 22 of Beazley's book, here's how they break down: Methods that return None: append, extend, insert, remove, reverse, sort Methods that return a value: count, index, pop Which leads me to the thought that if *all* the methods which now return None were to modify the list in place as well as return the modified list, we would soon get used to this behaviour and achieve some coding economy by being able to chain operations. In other words, the above argument against sort() and reverse() returning their result seems to be because they would then behave differently from the other list methods, leading us to be surprised by this behaviour. What if all the list methods returned a value? Then there would no longer be that element of surprise. I'm just throwing this out for discussion, knowing that it has no chance of being implemented since it would break a lot of code. Hmmm... after looking back at my initial incorrect (one-liner) code, it's obvious that there's another problem -- the original input sequence (altSeq) is modified even though it doesn't look like it is, and I might use altSeq later on thinking it still contained it's original values. Whereas, in the correct 3-liner, it's obvious what's being modified and what's not. This can be easily remedied, however, by using the same name for both input and result sequences: altSeq = filter(None, list(altSeq).insert(0, currPath)) But, of course, there no guarantee that this will always be done. ... So, maybe it's not such a great idea after all. But after doing all this typing I'm sure as hell not going to scrap this post ;o) talking-myself-out-of-it-ly y'rs /Don From fredrik at pythonware.com Sat Feb 17 11:31:28 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 17 Feb 2001 10:31:28 GMT Subject: Thoughts on List Methods and Return Values References: <3A8E44E3.3E25C7B3@home.com> Message-ID: <4qsj6.14072$Qb7.2221741@newsb.telia.net> Don O'Donnell wrote: > What if all the list methods returned a value? Then > there would no longer be that element of surprise. for item in mylist.reverse(): print item for item in mylist.reverse(): print item Enough said /F From aleaxit at yahoo.com Sat Feb 17 19:02:12 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 17 Feb 2001 19:02:12 +0100 Subject: Thoughts on List Methods and Return Values References: <3A8E44E3.3E25C7B3@home.com> Message-ID: <96mea501uot@news2.newsguy.com> "Don O'Donnell" wrote in message news:3A8E44E3.3E25C7B3 at home.com... [snip] > Methods that return None: > append, extend, insert, remove, reverse, sort [snip] > Which leads me to the thought that if *all* the methods which now return > None were to modify the list in place as well as return the modified > list, we would soon get used to this behaviour and achieve some coding > economy by being able to chain operations. [snip] > I'm just throwing this out for discussion, knowing that it has no chance > of being implemented since it would break a lot of code. Quite apart from any evaluation of this proposal, I fail to see what 'lot of code' could possibly be broken by this change. Is there a 'lot of code' _relying_ on the None return, e.g.: foo = alist.sort() as a shorthand for alist.sort() foo = None ...??? I sure hope not, and what code IS there that relies on this (if any) somewhat looks like code that *deserves* to break...:-). Alex From tim.one at home.com Sat Feb 17 20:42:49 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 17 Feb 2001 14:42:49 -0500 Subject: Thoughts on List Methods and Return Values In-Reply-To: <96mea501uot@news2.newsguy.com> Message-ID: [Don O'Donnell, about list methods] > Methods that return None: > append, extend, insert, remove, reverse, sort > ... > Which leads me to the thought that if *all* the methods which now return > None were to modify the list in place as well as return the modified > list, we would soon get used to this behaviour and achieve some coding > economy by being able to chain operations. > ... [Alex Martelli] > Quite apart from any evaluation of this proposal, I fail to see > what 'lot of code' could possibly be broken by this change. Is > there a 'lot of code' _relying_ on the None return, e.g.: > ... In a roundabout way, yes: >>> x = [random.random() for i in xrange(1000000)] >>> x.sort() Oops! Guess what that does to your interactive session if x.sort() starts to return x. People using my doctest.py would find that tons of their docstring examples "suddenly don't work" because of that too. BTW, it's not just lists, it's all mutate-in-place methods of all builtin types that return None. dict.update()-etc-ly y'rs - tim From aleaxit at yahoo.com Sat Feb 17 23:06:25 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 17 Feb 2001 23:06:25 +0100 Subject: Thoughts on List Methods and Return Values References: Message-ID: <96msk502hoo@news2.newsguy.com> "Tim Peters" wrote in message news:mailman.982439002.3211.python-list at python.org... [snip] > > Which leads me to the thought that if *all* the methods which now return > > None were to modify the list in place as well as return the modified > > list, we would soon get used to this behaviour and achieve some coding [snip] > [Alex Martelli] > > Quite apart from any evaluation of this proposal, I fail to see > > what 'lot of code' could possibly be broken by this change. Is > > there a 'lot of code' _relying_ on the None return, e.g.: [snip] > In a roundabout way, yes: > > >>> x = [random.random() for i in xrange(1000000)] > >>> x.sort() > > Oops! Guess what that does to your interactive session if x.sort() starts That's not "lots of code" that's going to be broken -- it's a currently OK interactive-interpreter idiom that becomes non-ok (to be replaced with, e.g., _=x.sort(), or whatever). [Actually, it becomes OK again if one uses the new interactive-session hook to prettyprint stuff returned by interactive-session expressions, rather than just printing its repr, of course; in fact, with a suitable prettyprint, it becomes a _plus_, since one can see what's happening step by step as a list gets modified -- I would argue that's a larger plus, e.g. for beginners' self-instruction, than being able to chain calls...!-)]. > to return x. People using my doctest.py would find that tons of their > docstring examples "suddenly don't work" because of that too. That's more serious, and I wish I had thought of that since I'm quite an aficionado of your doctest.py. The fixes I can think of would be rather kludgey! > BTW, it's not just lists, it's all mutate-in-place methods of all builtin > types that return None. Well, ALMOST all -- dict.setdefault 'may' mutate-in-place and may not return None. But that's a rather special case, of course. Alex From db3l at fitlinxx.com Wed Feb 21 07:57:33 2001 From: db3l at fitlinxx.com (David Bolen) Date: 21 Feb 2001 01:57:33 -0500 Subject: Thoughts on List Methods and Return Values References: <3A8E44E3.3E25C7B3@home.com> Message-ID: Don O'Donnell writes: (...) > After a few minutes of debugging, I realized why this doesn't work. > Obviously, sort() and reverse() are not the only list methods that don't > return a value, insert() doesn't either. So, I ended up with the > following: > > searchList = list(altSeq) > searchList.insert(0, currPath) > searchList = filter(None, searchList) > > (I won't argue the fact that this may be more readable, but that's not > the issue.) (...) > Which leads me to the thought that if *all* the methods which now return > None were to modify the list in place as well as return the modified > list, we would soon get used to this behaviour and achieve some coding > economy by being able to chain operations. Ah, so the point is trying to get coding economy in an arguably less readable form? Personally, I'd stick with giving readability (and thus maintainability) the best chance at the expense of a little more code text. And as you note later, > Hmmm... after looking back at my initial incorrect (one-liner) code, > it's obvious that there's another problem -- the original input sequence > (altSeq) is modified even though it doesn't look like it is, and I might > use altSeq later on thinking it still contained it's original values. > Whereas, in the correct 3-liner, it's obvious what's being modified and > what's not. This can be easily remedied, however, by using the same > name for both input and result sequences: so if code just doesn't happen to have a convention for always assigning to the same name as the modified list, it may be easy to skip over while maintaining it. I'd rather that Python itself gave a little nudge in the right direction and ensured that the odds were in the code's favor. I've definitely noticed over time that when I tend to get a touch annoyed at something in Python (and I've definitely had that feeling at times with sort(), and the non-assignment in expressions, and so on), that I'm sort of getting annoyed that I can't write a more complicated piece of code that "feels" more elegant or compact, but in reality is probably just a touch more obfuscated. And in the end, the "simpler" feeling code that's built out of more statements really is just that - simpler to read, simpler to understand and simpler to maintain. While still behaving properly. Amazing :-) > ... So, maybe it's not such a great idea after all. But after doing all > this typing I'm sure as hell not going to scrap this post ;o) :-) -- -- 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 Sat Feb 17 11:39:07 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Sat, 17 Feb 2001 10:39:07 GMT Subject: Embedding Python into a VC6 app? Message-ID: <3a8e543e.90577@news.newsguy.com> Is there somewhere around a step by step guide to embedding Python into a VC6 Windows application? -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From paul at fxtech.com Sat Feb 17 17:45:30 2001 From: paul at fxtech.com (paul at fxtech.com) Date: Sat, 17 Feb 2001 16:45:30 -0000 Subject: Embedding Python into a VC6 app? In-Reply-To: <3a8e543e.90577@news.newsguy.com> Message-ID: <96m9ra+qehf@eGroups.com> --- In python-list at y..., ransen_spam_me_not at n... (Owen F. Ransen) wrote: > Is there somewhere around a step by step guide to > embedding Python into a VC6 Windows application? Not really any step-by-step ones that I have seen. I am in the process of doing this myself, so was thinking of starting a "HOWTO" for Python embedding. I am sure people would find this interesting, and I'd love to have people contribute ideas. To kick it off, this is what I did: 1. Obviously - download and install Python. I did this with Python 2.0, but there was not a debug .lib included, so I got the latest CVS and built my own 2.1 DLL and LIB, then downloaded and installed the 2.1 alpha release. 2. Add a file to your project to isolate your Python stuff. Set an include path on it to include the Python headers directory. 3. In your file, do this: #include If the file compiles and your app links, you have set your headers up correctly. Also note that on Windows including Python.h will automatically add the appropriate link library for you (Python21_d.lib or Python21.lib, depending on the debug mode). 4. Add some code to initialize the Python interpreter, then register your app's extension functions. One of things you will want to do is redirect prints from within scripts (to stdout and stderr) to your own functions, so you can display the output in a window. Here is how I did it: void InitPython() { ::Py_SetProgramName("YOUR PROGRAM NAME"); ::Py_Initialize(); ::Py_InitModule("mymodule", my_methods); ::PyRun_SimpleString( "import mymodule\n" "class my_stdout:\n" " def write(self, string):\n" " mymodule.stdout(string)\n" "\n" "class my_stderr:\n" " def write(self, string):\n" " mymodule.stderr(string)\n" "\n" "import sys\n" "sys.stdout = my_stdout()\n" "sys.stderr = my_stderr()\n" "sys.path.append(PATH TO YOUR SCRIPTS)\n" "\n" ); } static PyObject *s_stdout(PyObject *self, PyObject *args) { char *string; if (!PyArg_ParseTuple(args, "s", &string)) return NULL; // DO SOMETHING WITH THE STRING! // NOTE - Python new-lines only have a '\n' - you will need // to convert to "\r\n" on Windows Py_INCREF(Py_None); return Py_None; } static PyObject *s_stderr(PyObject *self, PyObject *args) { char *string; if (!PyArg_ParseTuple(args, "s", &string)) return NULL; // DO SOMETHING WITH THE STRING! Py_INCREF(Py_None); return Py_None; } struct PyMethodDef my_methods[] = { { "stdout", s_stdout, METH_VARARGS }, { "stderr", s_stderr, METH_VARARGS }, { NULL, NULL } }; When you are all done, call ::Py_Finalize(). Now you can call the other script functions to run your own scripts (or lines of code). You might want to check out http://www.mcmillan-inc.com/embed.html for some ideas. I hope this helps get you started. From ransen_spam_me_not at nemo.it Sat Feb 17 18:42:04 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Sat, 17 Feb 2001 17:42:04 GMT Subject: Embedding Python into a VC6 app? References: <3a8e543e.90577@news.newsguy.com> Message-ID: <3a8e9b6f.3670682@news.newsguy.com> Oops, I've just found out how to do it, just read the docs Owen! -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From ransen_spam_me_not at nemo.it Sun Feb 18 08:29:14 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Sun, 18 Feb 2001 07:29:14 GMT Subject: Embedding Python into a VC6 app? References: Message-ID: <3a8fbc27.1282219@news.newsguy.com> On Sat, 17 Feb 2001 16:45:30 -0000, paul at fxtech.com wrote: >--- In python-list at y..., ransen_spam_me_not at n... (Owen F. Ransen) >wrote: Thanks a lot for the pointers, I have managed to get a small example going, but your post is going to help me a lot -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From mrbun at bigfoot.com Sat Feb 17 12:00:34 2001 From: mrbun at bigfoot.com (Mike Bunyan) Date: Sat, 17 Feb 2001 11:00:34 +0000 Subject: UserName automated authentication Message-ID: I am experimenting with Zope to provide an intranet for 100 or so people. Looking at achieving an automated (no brainer) authentication procedure which runs when users access zope through their browser. The network is NetWare, but I am not allowed to use python NetWare modules, the users have WinNT4sp5 and MSIE5.5. NT authentication is not available. The idea is to use a python script (or sniffer) to get UserName and authenticate this against a permissions table in mysql or gadfly. The user does not have to complete any login and cookies would persist for session. I am puzzled by the behaviour of each of the following calls: A = os.system('echo %username%') B = win32api.GetUserName() C = os.environ['USERNAME'] My innocence suggests that each should provide the same information. Called from DOS or python gui the results are as expected except that A produces: >>>FBASSET 0 and I can only get 0 as a result and not catch the username. When any of the above are called through an external zope procedure: A = 0 B = 'system' C fails because 'username' does not exist. The way I read this is that the client workstation does not allow or reveal 'secure' information through the browser. Any ideas how to solve this problem, including alternative approaches are welcome, and some illumination on what is actually happening will be appreciated. Mike B ___________________ mrbun at bigfoot.com From stephen_purcell at yahoo.com Sat Feb 17 12:31:50 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Sat, 17 Feb 2001 12:31:50 +0100 Subject: UserName automated authentication In-Reply-To: ; from mrbun@bigfoot.com on Sat, Feb 17, 2001 at 11:00:34AM +0000 References: Message-ID: <20010217123150.A18069@freedom.puma-ag.com> Mike Bunyan wrote: > I am experimenting with Zope to provide an intranet for 100 or so > people. > [snip] > The idea is to use a python script (or sniffer) to get UserName and > authenticate this against a permissions table in mysql or gadfly. The > user does not have to complete any login and cookies would persist for > session. > > I am puzzled by the behaviour of each of the following calls: > A = os.system('echo %username%') > B = win32api.GetUserName() > C = os.environ['USERNAME'] You can't use this kind of code from within Zope, because anything executed there is effectively being executed by the user who started the Zope server ('system' -- the NT service manager?), not the user browsing the server. You'll have to get users to enter their username and password, as with any other web service. For that, I'm sure there are a wealth of authentication/user database products available for Zope. Best wishes, -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 zzizz_ at notmail.com Sat Feb 17 14:10:59 2001 From: zzizz_ at notmail.com (zzzzz) Date: Sun, 18 Feb 2001 00:10:59 +1100 Subject: Launch Dial Up Connection in Win9X Message-ID: What's the best way to launch a dial up connection in Win9X? From r2d2 at mao.acc.umu.se Mon Feb 19 09:05:38 2001 From: r2d2 at mao.acc.umu.se (Niklas Frykholm) Date: Mon, 19 Feb 2001 08:05:38 +0000 (UTC) Subject: Launch Dial Up Connection in Win9X References: Message-ID: In article , zzzzz wrote: >What's the best way to launch a dial up connection in Win9X? I had this problem two days ago :). I ended up interfacing a freeware program called "RASDial95". It has a simple command line interface that lets you dial up a certain service, check the connection status or hang-up. A google search on RASDial95 will give you download links. // Niklas From zzizz_ at notmail.com Tue Feb 20 03:37:56 2001 From: zzizz_ at notmail.com (zzzzz) Date: Tue, 20 Feb 2001 13:37:56 +1100 Subject: Launch Dial Up Connection in Win9X References: Message-ID: Is there any reason why I can't use win32ras module from Pythonwin on win 9X? Is it NT only? On Mon, 19 Feb 2001 08:05:38 +0000 (UTC), r2d2 at mao.acc.umu.se (Niklas Frykholm) wrote: >In article , zzzzz wrote: >>What's the best way to launch a dial up connection in Win9X? > >I had this problem two days ago :). I ended up interfacing a freeware >program called "RASDial95". It has a simple command line interface >that lets you dial up a certain service, check the connection status >or hang-up. > >A google search on RASDial95 will give you download links. > >// Niklas Regards, zzzzz. --------------------- From victor at chaoszero.com Sat Feb 17 14:16:39 2001 From: victor at chaoszero.com (victor at chaoszero.com) Date: Sat, 17 Feb 2001 14:16:39 0100 Subject: Chaos Zero Web Site Message-ID: <982415799.710@inwind.it> Hi, I'm Victor from CHAOS ZERO. Visit http://www.chaoszero.com and you will find a new Crossover-Alternative Rock Band In MUSIC section you'll find some promo mp3 and a full-lenght mp3 version of the new rearranged cover of "The Wild Boys" by Duran Duran We are searching for a label, distribution and promotion. I'm just self-promoting my band and i'm doing it manually! IF YOU'LL LIKE CHAOS ZERO, PLEASE FOWARD THIS MESSAGE TO YOUR FRIENDS AND SPREAD THE VOICE! Thanx. Victor HTTP://WWW.CHAOSZERO.COM victor at chaoszero.com From hwanjoyu at students.uiuc.edu Sat Feb 17 16:15:22 2001 From: hwanjoyu at students.uiuc.edu (hwan-jo yu) Date: Sat, 17 Feb 2001 09:15:22 -0600 Subject: Q: break multiple loop Message-ID: Hi, It seems that there is now "goto" statement in the python. How can we terminate multiple for or while loop ? Thanks. From danielk at aracnet.com Sat Feb 17 17:35:10 2001 From: danielk at aracnet.com (Daniel Klein) Date: Sat, 17 Feb 2001 08:35:10 -0800 Subject: Q: break multiple loop References: Message-ID: On Sat, 17 Feb 2001 09:15:22 -0600, hwan-jo yu wrote: >How can we terminate multiple for or while loop ? Post some pseudo-code of what you are trying to do and we will try to help you out. Dan From stephen_purcell at yahoo.com Sat Feb 17 17:42:54 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Sat, 17 Feb 2001 17:42:54 +0100 Subject: Q: break multiple loop In-Reply-To: ; from hwanjoyu@students.uiuc.edu on Sat, Feb 17, 2001 at 09:15:22AM -0600 References: Message-ID: <20010217174254.A18953@freedom.puma-ag.com> hwan-jo yu wrote: > It seems that there is now "goto" statement in the python. True! > How can we terminate multiple for or while loop ? If you need to jump right out of nested loops, this is usually a sign that there is an easier way to arrange your loop: maybe the inner loop should be a separate function or method? But if you insist use a flag variable: keepgoing = 1 while loop_condition1 and keepgoing: while loop_condition2: if we_should_stop_now(): keepgoing = 0 break or keepgoing = 1 while loop_condition1: while loop_condition2: if we_should_stop_now(): keepgoing = 0 break if not keepgoing: break Another trick is with an exception: try: while loop_condition1: while loop_condition_2: if we_should_stop_now(): raise "stopped" except "stopped": pass But forget I said that -- it's nasty. -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 erno-news at erno.iki.fi Sat Feb 17 17:59:38 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 17 Feb 2001 18:59:38 +0200 Subject: Q: break multiple loop References: Message-ID: In article , hwan-jo yu writes: | Hi, | It seems that there is now "goto" statement in the python. | How can we terminate multiple for or while loop ? you can raise an exception. -- erno From phlip_cpp at my-deja.com Sat Feb 17 18:20:25 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 17 Feb 2001 17:20:25 GMT Subject: Q: break multiple loop References: Message-ID: <96mbsp$bf8@dispatch.concentric.net> Proclaimed hwan-jo yu from the mountaintops: > Hi, > It seems that there is now "goto" statement in the python. > How can we terminate multiple for or while loop ? return The rule "no absurdly long functions" trumps the rule "goto is the root of all evil". But it would be hard for a language to enforce the former. Show some discipline! -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- This machine last rebooted during the Second Millenium -- From root at rainerdeyke.com Sat Feb 17 18:36:56 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sat, 17 Feb 2001 17:36:56 GMT Subject: break multiple loop References: Message-ID: "hwan-jo yu" wrote in message news:Pine.GSO.4.10.10102170913380.22713-100000 at ux8.cso.uiuc.edu... > Hi, > It seems that there is now "goto" statement in the python. > How can we terminate multiple for or while loop ? > Thanks. Either 'return' or 'raise'. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From paul at fxtech.com Sat Feb 17 16:58:07 2001 From: paul at fxtech.com (paul at fxtech.com) Date: Sat, 17 Feb 2001 15:58:07 -0000 Subject: Python 2.1 - tokenizer fgets crash (Windows) Message-ID: <96m72f+g05a@eGroups.com> This is weird. I am using the 2.1 debug DLL/lib built from the CVS sources in an embedded app. I can init the interpreter and run some startup code with PyRun_SimpleString() (to redirect stdout/stderr, etc). But when I try to use PyRun_AnyFile() it crashes in the tokenizer at the first fgets() call. Stepping into the code, everything looks "good" up to that call. I suspect some kind of library/DLL settings mismatch. Anyone have any clues? From tim.one at home.com Sat Feb 17 19:26:40 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 17 Feb 2001 13:26:40 -0500 Subject: Python 2.1 - tokenizer fgets crash (Windows) In-Reply-To: <96m72f+g05a@eGroups.com> Message-ID: [paul at fxtech.com] > This is weird. I am using the 2.1 debug DLL/lib built from the CVS > sources in an embedded app. I can init the interpreter and run some > startup code with PyRun_SimpleString() (to redirect stdout/stderr, > etc). But when I try to use PyRun_AnyFile() it crashes in the > tokenizer at the first fgets() call. Stepping into the code, > everything looks "good" up to that call. I suspect some kind of > library/DLL settings mismatch. > > Anyone have any clues? You do: "crashes" could mean anything on Windows. What does it mean to you? Is it dying inside MS's implementation of fgets(), in Python; is it a NULL-pointer error, an illegal instruction; etc etc. Try it under a debug build, if you haven't already (single-stepping can be highly misleading if you're doing that with the non-debug build). From paul at fxtech.com Sat Feb 17 19:55:21 2001 From: paul at fxtech.com (paul at fxtech.com) Date: Sat, 17 Feb 2001 18:55:21 -0000 Subject: Python 2.1 - tokenizer fgets crash (Windows) In-Reply-To: Message-ID: <96mhep+u7oa@eGroups.com> > You do: "crashes" could mean anything on Windows. What does it mean to > you? Is it dying inside MS's implementation of fgets(), in Python; is it a > NULL-pointer error, an illegal instruction; etc etc. Try it under a debug > build, if you haven't already (single-stepping can be highly misleading if > you're doing that with the non-debug build). Yes, I'm using the debug build (as I mentioned) and I have single-stepped down into the code. It's crashing in Microsoft's fgets() function. The FILE * looks correct - the only thing I can think of is I'm doing the fopen() in my code and it is getting used in the DLL. Loading files from within the DLL (using Import) work fine. I've gotten around it for now - I'm now importing my scripts as modules rather than running them. From tim.one at home.com Sat Feb 17 20:32:01 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 17 Feb 2001 14:32:01 -0500 Subject: Python 2.1 - tokenizer fgets crash (Windows) In-Reply-To: <96mhep+u7oa@eGroups.com> Message-ID: [paul at fxtech.com] > Yes, I'm using the debug build (as I mentioned) and I have > single-stepped down into the code. It's crashing in Microsoft's > fgets() function. The FILE * looks correct - the only thing I can > think of is I'm doing the fopen() in my code and it is getting used in > the DLL. Loading files from within the DLL (using Import) work fine. Ya, sure sounds like you're mixing DLL modes. Can only suggest you triple-check the DLLs you link with. Make sure your own code is using the MS multithreaded DLLs; don't know how you set up your project, but it's (too!) easy to blow that part under DevStudio; see PC/example_nt/readme.txt for details. From johan at essay.org Sat Feb 17 17:27:13 2001 From: johan at essay.org (=?iso-8859-1?Q?Johan_Fredrik_=D8hman?=) Date: Sat, 17 Feb 2001 17:27:13 +0100 Subject: shared fails but static works Message-ID: <96m8oa$7ek$1@maud.ifi.uio.no> Hi, I'm experiencing a strange problem when writing a C++ Python modules. I assume this is a quite difficult problem to answer. So I have included most of the info I see as important for those who want to have a look. The module (included below) works perfectly when I build the module staticly. But when I enable *shared* in the Setupfile I get the following errormessage in /var/log/messages when the so. module is "run" from the python source code. Errormessages in /var/log/messages Feb 17 15:32:50 blekkulf python: PAM unable to dlopen(/lib/security/pam_unix.so) Feb 17 15:32:50 blekkulf python: PAM [dlerror: /lib/security/pam_unix.so: undefined symbol: pam_get_item] Feb 17 15:32:50 blekkulf python: PAM adding faulty module: /lib/security/pam_unix.so Feb 17 15:32:50 blekkulf python: PAM unable to dlopen(/lib/security/pam_cracklib.so) Feb 17 15:32:50 blekkulf python: PAM [dlerror: /lib/security/pam_cracklib.so: undefined symbol: pam_get_item] Feb 17 15:32:50 blekkulf python: PAM adding faulty module: /lib/security/pam_cracklib.so Feb 17 15:32:50 blekkulf python: PAM unable to dlopen(/lib/security/pam_limits.so) Feb 17 15:32:50 blekkulf python: PAM [dlerror: /lib/security/pam_limits.so: undefined symbol: pam_get_item] Feb 17 15:32:50 blekkulf python: PAM adding faulty module: /lib/security/pam_limits.so I understand that the dloader has I problem here, but I don't know how to solve it. I have also tried the program as a standalone C++ program with no problems at all. So the PAM library should be intact. If you want to try youselv, be my guest and try to compile the program below as a shared module ! Any ideas ? Thanks JFO ######################### #include #include #include #include #include //extern "C" { #include #include #include //} /* Static variables used to communicate between the conversation function * and the server_login function */ static const char *PAM_password; /* hackish PAM conversation function * Here we assume that echo off means password. */ static int hack_conv ( int num_msg, const struct pam_message **msg, struct pam_response **resp, void *) { #define COPY_STRING(s) (s) ? strdup(s) : (char*)NULL //cout << "PAM_PASSWORD:" << PAM_password <<"\n"; struct pam_response *reply = (struct pam_response*)malloc(sizeof(struct pam_response) * num_msg); if (!reply) return PAM_CONV_ERR; for (int replies = 0; replies < num_msg; replies++) { switch (msg[replies]->msg_style) { case PAM_PROMPT_ECHO_OFF: reply[replies].resp_retcode = PAM_SUCCESS; //cout << "PAM_PASSWORD:" << PAM_password <<"\n"; reply[replies].resp = COPY_STRING(PAM_password); /* PAM frees resp */ break; case PAM_TEXT_INFO: /* fall through */ case PAM_ERROR_MSG: /* ignore it, but pam still wants a NULL response... */ reply[replies].resp_retcode = PAM_SUCCESS; reply[replies].resp = NULL; break; case PAM_PROMPT_ECHO_ON: /* fall through */ default: /* Must be an error of some sort... */ free (reply); return PAM_CONV_ERR; } } *resp = reply; return PAM_SUCCESS; } static struct pam_conv hack_conversation = { &hack_conv, NULL }; static int pam_check_pair(const char *user, const char *pass) { //cout << "debug: user:" << user << pass; int retval; pam_handle_t *pamh = NULL; PAM_password = pass; retval = pam_start ("system-auth", user, &hack_conversation, &pamh); if (retval == PAM_SUCCESS) { retval = pam_authenticate(pamh, 0); //cout << "Returnvalue1: " << retval <<"\n"; if (retval == PAM_SUCCESS){ retval = pam_acct_mgmt(pamh, 0); //cout << "Returnvalue2: " << retval <<"\n"; } } if (pamh != NULL) pam_end(pamh, PAM_SUCCESS); if (retval != PAM_SUCCESS){ //cout << "Failure\n"; return 0; } else { //cout << "Success\n"; return 1; } } static PyObject* verify_user( PyObject *self, PyObject *args) { char *user; char *password; int sts; if (!PyArg_ParseTuple(args, "ss", &user, &password)) return NULL; //cout << "user: " << user << " password: " << password; sts = pam_check_pair(user, password); return Py_BuildValue("i", sts); } static PyMethodDef jfopamMethods[] = { {"verify_user", verify_user, METH_VARARGS}, {NULL, NULL} /* Sentinel */ }; extern "C" void initjfopam() { (void) Py_InitModule("jfopam", jfopamMethods); } -------------- next part -------------- An HTML attachment was scrubbed... URL: From paul at fxtech.com Sat Feb 17 17:31:03 2001 From: paul at fxtech.com (paul at fxtech.com) Date: Sat, 17 Feb 2001 16:31:03 -0000 Subject: Restarting embedded Python + extensions Message-ID: <96m907+mmbd@eGroups.com> I have Python embedded in a C++ app using Python scripts as extension modules. When testing extension scripts I want to be able to restart the Python session from scratch and reload all the modules, so I was trying to call Py_Finalize() followed by Py_Initialize(). This causes a crash (at least for Windows, 2.1 alpha, debug) in the builtin setup step in Py_Initialize(). So I was thinking of using a PyThreadState and Py_NewInterpreter() to run my extension scrips, and when I want to restart my extensions just call Py_EndInterpreter() and Py_NewInterpreter and reload my extension modules under the new interpreter. Does this sound like the right approach? From muk_pr at yahoo.com Sat Feb 17 17:56:22 2001 From: muk_pr at yahoo.com (Victor Black) Date: Sat, 17 Feb 2001 18:56:22 +0200 Subject: Better pyclbr Message-ID: Hi, Are there any pyclbr like modules that can gimme more properties of the code(members,methods of the classes,global functions,variables). PS I know they are available by dir() or other methods but what I want is that will parse the code itself. Regards. From doughellmann at bigfoot.com Sat Feb 17 21:49:51 2001 From: doughellmann at bigfoot.com (Doug Hellmann) Date: Sat, 17 Feb 2001 20:49:51 GMT Subject: Better pyclbr References: Message-ID: The parseinfo.py module of HappyDoc is based on a module of the same name from the examples of the source distribution for 1.5.2. I've added some extra features such as extracting the raised exceptions, etc. Check it out at http://happydoc.sourceforge.net. Doug In article , "Victor Black" wrote: > Hi, Are there any pyclbr like modules that can gimme more properties of > the code(members,methods of the classes,global functions,variables). PS > I know they are available by dir() or other methods but what I want is > that will parse the code itself. > > Regards. > > > From DOUGS at oceanic.com Sat Feb 17 19:18:52 2001 From: DOUGS at oceanic.com (Doug Stanfield) Date: Sat, 17 Feb 2001 08:18:52 -1000 Subject: file access Message-ID: <8457258D741DD411BD3D0050DA62365907A625@huina.oceanic.com> [Ben de Luca wrote:] > > when i write the data to a file whats the best way? I guess > there is no way > > to sumb the dictonaries strait to disk? i will have to parse it? [Fredrik Lundh suggested:] > http://www.python.org/doc/current/lib/module-pickle.html > http://www.python.org/doc/current/lib/module-marshal.html I'd also suggest checking out shelve: http://www.python.org/doc/current/lib/module-shelve.html From gahanr at gofree.indigo.ie Sat Feb 17 20:12:57 2001 From: gahanr at gofree.indigo.ie (Robert Gahan) Date: Sat, 17 Feb 2001 19:12:57 -0000 Subject: Writing to a COM port (windows) Message-ID: Hi all, I'm reasonably new to Python and very much a novice as far as windows programming is concerned. I am looking to write to a device which is connected to my COM1 port and am looking for an appropriate python method. (effectively looking to write to the device driver) The "C" equivalent for doing this is: hCom = CreateFile(szPort, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); // setup device buffers SetupComm(hCom, 4096, 4096 ) ; Is there any way of doing this from Python ???. import os f = open("COM1", 'w') f.write("at012345678") print f f.close() Traceback (innermost last): File "C:/Python20/smpp1", line 2, in ? f = open("COM1", 'w') IOError: [Errno 13] Permission denied: 'COM1' Thanks again, Rob. From samschul at pacbell.net Sat Feb 17 21:18:03 2001 From: samschul at pacbell.net (Sam Schulenburg) Date: Sat, 17 Feb 2001 12:18:03 -0800 Subject: Writing to a COM port (windows) References: Message-ID: Get Mark Hammonds win32all http://www.activestate.com/Products/ActivePython/win32all.html Mark has a win32comport_demo.py in the win32\demos directory. Sam Schulenburg "Robert Gahan" wrote in message news:AhAj6.2566$r4.2220 at news.indigo.ie... > Hi all, > > I'm reasonably new to Python and very much a novice as far as windows > programming is concerned. > > I am looking to write to a device which is connected to my COM1 port and am > looking for an > appropriate python method. (effectively looking to write to the device > driver) > > The "C" equivalent for doing this is: > > hCom = CreateFile(szPort, GENERIC_READ | GENERIC_WRITE, > FILE_SHARE_READ, NULL, OPEN_EXISTING, > FILE_ATTRIBUTE_NORMAL, NULL); > > // setup device buffers > SetupComm(hCom, 4096, 4096 ) ; > > Is there any way of doing this from Python ???. > > import os > f = open("COM1", 'w') > f.write("at012345678") > print f > f.close() > > Traceback (innermost last): > File "C:/Python20/smpp1", line 2, in ? > f = open("COM1", 'w') > IOError: [Errno 13] Permission denied: 'COM1' > > Thanks again, > Rob. > > > From gst at sysfrog.org Sat Feb 17 21:20:11 2001 From: gst at sysfrog.org (Guenther Starnberger) Date: 17 Feb 2001 21:20:11 +0100 Subject: problem with python/gtk Message-ID: <87elwxysck.fsf@nirvana.sysfrog.org> hi, i have a problem using gtk with python. in a programm i open a gtkwindow foo with foo.show(). closing the window with foo.hide() and reopening it with foo.show() works. but when i close the window with the windowmanager i can't reopen it. i only get an empty window and the following error message: ----->8------>8------>8---------->8------>8------>8------>8------ Gtk-CRITICAL **: file gtkstyle.c: line 522 (gtk_style_attach): assertion `style != NULL' failed. Gtk-CRITICAL **: file gtkstyle.c: line 1128 (gtk_style_set_background): assertion `style != NULL' failed. Gtk-CRITICAL **: file gtkstyle.c: line 3532 (gtk_paint_flat_box): assertion `style != NULL' failed. ----->8------>8------>8---------->8------>8------>8------>8------ i tried to make an handler for the signal "destroy" which calls foo.hide(). the handler gets called, but the error is still the same. any suggestions? cu /gst -- sysfrog.org From lsloan at bigfoot.com Sat Feb 17 23:26:29 2001 From: lsloan at bigfoot.com (Lance E Sloan) Date: Sat, 17 Feb 2001 17:26:29 -0500 Subject: date calculations ala Perl's Date::Manip? Message-ID: <3A8EFA96.37DE948C@my-deja.com> I've been using Perl for a while and I'm now learning Python. I'm looking for a Python module that provides the same fancy date calculations as Perl's Date::Manip. What would you recommend? I would appreciate it if responses to this article are CC'ed to lsloan00 at my-deja.com as well as posted to this newsgroup. My newsserver is unreliable and I'd hate to miss a response. Thank you in advance! From jbauer at rubic.com Sun Feb 18 00:46:44 2001 From: jbauer at rubic.com (Jeff Bauer) Date: Sat, 17 Feb 2001 17:46:44 -0600 Subject: date calculations ala Perl's Date::Manip? References: <3A8EFA96.37DE948C@my-deja.com> Message-ID: <3A8F0D64.FD238632@rubic.com> Lance E Sloan wrote: > I've been using Perl for a while and I'm now learning > Python. I'm looking for a Python module that provides > the same fancy date calculations as Perl's Date::Manip. > What would you recommend? Here's my Python NormalDate module that I use for date calculations: http://starship.python.net/crew/jbauer/normaldate/ Jeff Bauer Rubicon Research From aahz at panix.com Sun Feb 18 01:14:45 2001 From: aahz at panix.com (Aahz Maruch) Date: 17 Feb 2001 16:14:45 -0800 Subject: date calculations ala Perl's Date::Manip? References: <3A8EFA96.37DE948C@my-deja.com> Message-ID: <96n45l$o41$1@panix3.panix.com> [p&e as requested] In article <3A8EFA96.37DE948C at my-deja.com>, Lance E Sloan wrote: > >I've been using Perl for a while and I'm now learning Python. I'm >looking for a Python module that provides the same fancy date >calculations as Perl's Date::Manip. What would you recommend? Don't know what features are in Date::Manip, but mxDateTime is the canonical Python module. -- --- 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 Why doesn't "Just Say NO" include caffeine, nicotine, alcohol, Prozac, and Ritalin? --Aahz From kalle at gnupung.net Sun Feb 18 02:07:08 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Sun, 18 Feb 2001 02:07:08 +0100 Subject: date calculations ala Perl's Date::Manip? In-Reply-To: <96n45l$o41$1@panix3.panix.com>; from aahz@panix.com on Sat, Feb 17, 2001 at 04:14:45PM -0800 References: <3A8EFA96.37DE948C@my-deja.com> <96n45l$o41$1@panix3.panix.com> Message-ID: <20010218020708.A1537@apone.network.loc> Sez Aahz Maruch: > [p&e as requested] > > In article <3A8EFA96.37DE948C at my-deja.com>, > Lance E Sloan wrote: > > > >I've been using Perl for a while and I'm now learning Python. I'm > >looking for a Python module that provides the same fancy date > >calculations as Perl's Date::Manip. What would you recommend? > > Don't know what features are in Date::Manip, but mxDateTime is the > canonical Python module. And is found on http://www.lemburg.com/files/python/ 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 stevedperkins at NOSPAM.hotmail.com Sat Feb 17 23:46:47 2001 From: stevedperkins at NOSPAM.hotmail.com (Steve D. Perkins) Date: Sat, 17 Feb 2001 17:46:47 -0500 Subject: Linda, this is cool! References: <33Z6UBPU36939.943275463@frog.nyarlatheotep.org> Message-ID: <96mv3102l3d@news2.newsguy.com> Untitled Document ARGH! I wll never understand why spam still exists, the internet reaching the level of development and maturity is has. I can't imagine that there's ANYONE left anymore dumb and/or internet-inexperienced to purchase anything advertised through spam. Even if there is, I don't understand why spammers woud target newsgroups for Tcl, Python, and Perl... technologies most often used by crusty old-timers LEAST likely of all to be an effective target audience... From mindfield at badgers.emulationnet.com Sun Feb 18 04:27:19 2001 From: mindfield at badgers.emulationnet.com (Mindfield) Date: Sun, 18 Feb 2001 03:27:19 GMT Subject: Linda, this is cool! References: <33Z6UBPU36939.943275463@frog.nyarlatheotep.org> <96mv3102l3d@news2.newsguy.com> Message-ID: <21gu8tsoknv01eegt4jak2lo7180kijno5@4ax.com> On Sat, 17 Feb 2001 17:46:47 -0500, "Steve D. Perkins" drooled an embarassing wet spot in his lap as he typed: >Untitled Document ARGH! > > I wll never understand why spam still exists, the internet reaching the >level of development and maturity is has. I can't imagine that there's >ANYONE left anymore dumb and/or internet-inexperienced to purchase anything >advertised through spam. Even if there is, I don't understand why spammers >woud target newsgroups for Tcl, Python, and Perl... technologies most often >used by crusty old-timers LEAST likely of all to be an effective target >audience... Blame spambots. They retrieve all available newsgroups on the spammer's ISP, then post their crap to every single one of them. Fortunately many ISPs have gotten wise and have placed posting caps on duplicate messages, but spambots have found ways to circumvent that -- by placing a random number after the subject line, by rotating the subject line from a list of subject lines, by placing random ASCII text at the end of each message, etc. so the server doesn't think it's a duplicate message. It's really quite a loathesome little business, and I've never figured out why people are still stupid enough to think that it works, but I guess they still abide by the old motto, "There's no such thing as bad publicity." Ah, but there is if you lose your ISP for violating their TOS/AUP. And there are plenty of people -- me, for instance -- who are perfectly happy to send a nice note to their ISP's abuse department. :) -- Almost there... "Ignorance breeds confidence more often than does knowledge." -Darwin The Emulation Newbie FAQ: http://www.emulationnet.com/emufaq.html Remove the badgers before E-Mailing. From sheila at spamcop.net Sun Feb 18 05:01:13 2001 From: sheila at spamcop.net (Sheila King) Date: Sun, 18 Feb 2001 04:01:13 GMT Subject: Linda, this is cool! References: <33Z6UBPU36939.943275463@frog.nyarlatheotep.org> <96mv3102l3d@news2.newsguy.com> <21gu8tsoknv01eegt4jak2lo7180kijno5@4ax.com> Message-ID: On Sun, 18 Feb 2001 03:27:19 GMT, Mindfield wrote in comp.lang.python in article <21gu8tsoknv01eegt4jak2lo7180kijno5 at 4ax.com>: :It's really quite a loathesome little business, :and I've never figured out why people are still stupid enough to think :that it works, but I guess they still abide by the old motto, "There's :no such thing as bad publicity." It costs them next to nothing, and they must end up selling some of their product or generating some revenue from the spam. If they didn't, the spamming would decrease, but instead it is on the increase. Some people are stupid enough to buy from spammers. :Ah, but there is if you lose your ISP for violating their TOS/AUP. :And there are plenty of people -- me, for instance -- who are :perfectly happy to send a nice note to their ISP's abuse department. Me, too. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From hs at paradise.nirvananet Mon Feb 19 02:11:17 2001 From: hs at paradise.nirvananet (Hartmann Schaffer) Date: 18 Feb 2001 20:11:17 -0500 Subject: Linda, this is cool! References: <33Z6UBPU36939.943275463@frog.nyarlatheotep.org> <96mv3102l3d@news2.newsguy.com> <21gu8tsoknv01eegt4jak2lo7180kijno5@4ax.com> Message-ID: In article , Sheila King wrote: >On Sun, 18 Feb 2001 03:27:19 GMT, Mindfield > wrote in comp.lang.python in article ><21gu8tsoknv01eegt4jak2lo7180kijno5 at 4ax.com>: > >:It's really quite a loathesome little business, >:and I've never figured out why people are still stupid enough to think >:that it works, but I guess they still abide by the old motto, "There's >:no such thing as bad publicity." > >It costs them next to nothing, and they must end up selling some of their >product or generating some revenue from the spam. If they didn't, the spamming >would decrease, but instead it is on the increase. Some people are stupid >enough to buy from spammers. frankly, i doubt this. most of those spams are so inept that i would be surprised if it generates any sales. the only thing that seems to generate sales are those spam generators (to clueless idiots) hs From fellowsd at cs.man.ac.uk Mon Feb 19 11:52:09 2001 From: fellowsd at cs.man.ac.uk (Donal K. Fellows) Date: Mon, 19 Feb 2001 10:52:09 +0000 Subject: Linda, this is cool! References: <33Z6UBPU36939.943275463@frog.nyarlatheotep.org> <96mv3102l3d@news2.newsguy.com> <21gu8tsoknv01eegt4jak2lo7180kijno5@4ax.com> Message-ID: <3A90FAD9.B54BCFF6@cs.man.ac.uk> Hartmann Schaffer wrote: > frankly, i doubt this. most of those spams are so inept that i would be > surprised if it generates any sales. the only thing that seems to generate > sales are those spam generators (to clueless idiots) Every time I think I've finally discovered just how stupid some people can be, I'm unpleasantly surprised by some new asininity... Donal. -- Donal K. Fellows http://www.cs.man.ac.uk/~fellowsd/ fellowsd at cs.man.ac.uk -- If somebody in a suit or a uniform can sit you down and have you believe every word he says, you've just surrendered your license to be a thinking human being and traded it in for a zombie suit. -- mhoye at prince.carleton.ca From fredericbonnet at free.fr Wed Feb 21 11:17:14 2001 From: fredericbonnet at free.fr (Frederic BONNET) Date: Wed, 21 Feb 2001 10:17:14 GMT Subject: Linda, this is cool! References: <33Z6UBPU36939.943275463@frog.nyarlatheotep.org> <96mv3102l3d@news2.newsguy.com> <21gu8tsoknv01eegt4jak2lo7180kijno5@4ax.com> <3A90FAD9.B54BCFF6@cs.man.ac.uk> Message-ID: <3A939540.19FB5346@free.fr> "Donal K. Fellows" wrote: > > Hartmann Schaffer wrote: > > frankly, i doubt this. most of those spams are so inept that i would be > > surprised if it generates any sales. the only thing that seems to generate > > sales are those spam generators (to clueless idiots) > > Every time I think I've finally discovered just how stupid some people can > be, I'm unpleasantly surprised by some new asininity... I think Charles De Gaulle said something like that: "Human intelligence may have a limit, but believe me, human stupididy hasn't". -- Fr?d?ric BONNET fredericbonnet at free.fr --------------------------------------------------------------- "Theory may inform, but Practice convinces" George Bain From fredericbonnet at free.fr Wed Feb 21 11:19:28 2001 From: fredericbonnet at free.fr (Frederic BONNET) Date: Wed, 21 Feb 2001 10:19:28 GMT Subject: Linda, this is cool! References: <33Z6UBPU36939.943275463@frog.nyarlatheotep.org> <96mv3102l3d@news2.newsguy.com> <21gu8tsoknv01eegt4jak2lo7180kijno5@4ax.com> <3A90FAD9.B54BCFF6@cs.man.ac.uk> <3A939540.19FB5346@free.fr> Message-ID: <3A939613.2A32E483@free.fr> Oh, and this one, too: General Massu: "One should eliminate all the idiots" De Gaulle: "Vast program..." -- Fr?d?ric BONNET fredericbonnet at free.fr --------------------------------------------------------------- "Theory may inform, but Practice convinces" George Bain From tim.one at home.com Sun Feb 18 06:08:07 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 18 Feb 2001 00:08:07 -0500 Subject: Linda, this is cool! In-Reply-To: <21gu8tsoknv01eegt4jak2lo7180kijno5@4ax.com> Message-ID: [Steve D. Perkins] > I will never understand why spam still exists, the internet reaching the > level of development and maturity is has. The sophistication of the technology has nothing to do with the sophistication of the users, and new users keep pouring in. Remember the first time you ever got an email? Didn't you get a thrill out of it? It can take quite a while for people to catch on to scams. For example, look at all the people who use Python or Perl . > I can't imagine that there's ANYONE left anymore dumb and/or > internet-inexperienced to purchase anything advertised through spam. You must be joking. The vast bulk of the world's population has yet to see their first piece of spam. > Even if there is, I don't understand why spammers would target > newsgroups for Tcl, Python, and Perl... technologies most often > used by crusty old-timers LEAST likely of all to be an effective > target audience... Because the marginal cost of sending out one more piece of email spam is essentially nothing. The "junk mail" you get in your snail-mail box is carefully targeted, because that costs real money to send out. Even so, a direct mail marketer is ecstatic if they get a 3% response rate. Spam emailers can make a profit on a response rate thousands of times smaller. If one person in a million responds, cool -- send 1, send 50 million, it costs them about the same except for the effort of gathering that many addresses. While it makes compelling economic sense for a snail-mail spammer to spend money on weeding out hopeless addresses, it makes no economic sense for an email spammer to weed out anything, provided the cost of sending out another million is a close approximation to nothing. Sometimes the obvious explanation is right: spam persists simply because "good" spammers take in more money than they shell out. It's the American way . Speaking of which, who do I complain to? I responded to an ad in my inbox guaranteeing I could lose 10 inches in one day! Turns out they weren't lying -- but a 3-inch dick isn't as much fun as my old one ... From chrisw at nipltd.com Wed Feb 21 16:25:20 2001 From: chrisw at nipltd.com (Chris Withers) Date: Wed, 21 Feb 2001 15:25:20 +0000 Subject: Spamcop, anyone? ;-) References: Message-ID: <3A93DDE0.B81DCC01@nipltd.com> Tim Peters wrote: > > Speaking of which, who do I complain to? I responded to an ad in my inbox > guaranteeing I could lose 10 inches in one day! Turns out they weren't > lying -- but a 3-inch dick isn't as much fun as my old one ... hahaha :-) Seriously though, take a look at http://spamcop.net if you get a chance. it's quite satisfying to use, if nothing else :-) Mindyou, I wonder if its nto a sinister plot in the long run: you report spam, the have your address... I hope not :-S paranoidly, Chris From robin at alldunn.com Thu Feb 22 00:01:30 2001 From: robin at alldunn.com (Robin Dunn) Date: Wed, 21 Feb 2001 15:01:30 -0800 Subject: Spamcop, anyone? ;-) References: Message-ID: "Chris Withers" wrote in message news:mailman.982769153.31105.python-list at python.org... > Tim Peters wrote: > > > > Speaking of which, who do I complain to? I responded to an ad in my inbox > > guaranteeing I could lose 10 inches in one day! Turns out they weren't > > lying -- but a 3-inch dick isn't as much fun as my old one ... > > hahaha :-) > > Seriously though, take a look at http://spamcop.net if you get a chance. it's > quite satisfying to use, if nothing else :-) > > Mindyou, I wonder if its nto a sinister plot in the long run: you report spam, > the have your address... I hope not :-S > >From http://spamcop.net/anonsignup.shtml: Warning: Some users have reported that the email addresses used here find their way onto spam lists, so you should consider creating a separate "throwaway" account for reporting spam. There are many free email providers you can use. -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From no at email.com Sun Feb 18 16:54:30 2001 From: no at email.com (Frank Miller) Date: Sun, 18 Feb 2001 15:54:30 GMT Subject: Linda, this is cool! References: <33Z6UBPU36939.943275463@frog.nyarlatheotep.org> <96mv3102l3d@news2.newsguy.com> <21gu8tsoknv01eegt4jak2lo7180kijno5@4ax.com> Message-ID: "Mindfield" wrote in message news:21gu8tsoknv01eegt4jak2lo7180kijno5 at 4ax.com... > On Sat, 17 Feb 2001 17:46:47 -0500, "Steve D. Perkins" > drooled an embarassing wet spot in > his lap as he typed: > [snip] > > Fortunately many ISPs have gotten wise and have placed posting caps on > duplicate messages, but spambots have found ways to circumvent that -- > by placing a random number after the subject line, by rotating the > subject line from a list of subject lines, by placing random ASCII > text at the end of each message, etc. I have always wondered why spam had those extra characters at the end of the subject lines and messages. Thanks! You've answered one of my 10 most sought after questions! FrankM From brondsem at my-deja.com Sun Feb 18 05:17:35 2001 From: brondsem at my-deja.com (Dave Brondsema) Date: Sun, 18 Feb 2001 04:17:35 GMT Subject: Linda, this is cool! References: <33Z6UBPU36939.943275463@frog.nyarlatheotep.org> <96mv3102l3d@news2.newsguy.com> Message-ID: "Steve D. Perkins" wrote in message news:96mv3102l3d at news2.newsguy.com... > Untitled Document ARGH! > > I wll never understand why spam still exists, the internet reaching the > level of development and maturity is has. I can't imagine that there's > ANYONE left anymore dumb and/or internet-inexperienced to purchase anything > advertised through spam. Even if there is, I don't understand why spammers > woud target newsgroups for Tcl, Python, and Perl... technologies most often > used by crusty old-timers LEAST likely of all to be an effective target > audience... > > there will always be dumb people From real.email at signature.this.is.invalid Mon Feb 19 19:25:01 2001 From: real.email at signature.this.is.invalid (Csaba Raduly) Date: Mon, 19 Feb 2001 18:25:01 +0000 (UTC) Subject: Linda, this is cool! References: <33Z6UBPU36939.943275463@frog.nyarlatheotep.org> <96mv3102l3d@news2.newsguy.com> Message-ID: And so it came to pass that "Dave Brondsema" on 18 Feb 2001 wrote : [snip woes of spam] > >there will always be dumb people > > P.T.Barnum had this figured out quite some time ago :-) -- Csaba Raduly, Software Developer (OS/2), Sophos Anti-Virus mailto:csaba.raduly at sophos.com http://www.sophos.com/ US Support +1 888 SOPHOS 9 UK Support +44 1235 559933 You are in a maze of twisted little minds, all different. From flavell at mail.cern.ch Mon Feb 19 19:51:12 2001 From: flavell at mail.cern.ch (Alan J. Flavell) Date: Mon, 19 Feb 2001 19:51:12 +0100 Subject: Linda, this is cool! In-Reply-To: References: <33Z6UBPU36939.943275463@frog.nyarlatheotep.org> <96mv3102l3d@news2.newsguy.com> Message-ID: On Mon, 19 Feb 2001, Csaba Raduly wrote: > P.T.Barnum had this figured out quite some time ago :-) "This way to the Egress". [OT, so f'ups redirected] From cyberian_bear at hotmail.com Sun Feb 18 00:37:08 2001 From: cyberian_bear at hotmail.com (cyberian bear) Date: Sat, 17 Feb 2001 18:37:08 -0500 Subject: wildcard in tuples Message-ID: <8XDj6.13$sR5.356@typhoon.nyu.edu> lets say i have a tuple in one list and i need to check it against every tuple in second list. So (e,c) --and i want to find every tuple in second list which has tuples who are (e, *). What is the proper syntax for doing this From max at alcyone.com Sun Feb 18 02:03:57 2001 From: max at alcyone.com (Erik Max Francis) Date: Sat, 17 Feb 2001 17:03:57 -0800 Subject: wildcard in tuples References: <8XDj6.13$sR5.356@typhoon.nyu.edu> Message-ID: <3A8F1F7D.6781AF14@alcyone.com> cyberian bear wrote: > lets say i have a tuple in one list and i need to check it against > every > tuple in second list. So (e,c) --and i want to find every tuple in > second > list which has tuples who are (e, *). What is the proper syntax for > doing > this I'm not sure exactly what you're asking. If all you want is to select all 2-tuples that, say, have 2 as the first element, then you can do it easily enough with list comprehensions: >>> l = [(1, 1), (2, 3), (2, 4), (3, 5), (3, 6), (4, 4)] >>> [ x for x in l if x[0] == 2 ] [(2, 3), (2, 4)] This can obviously be trivially modified for matching on the second list. You could do something similar using None as a wildcard: >>> def selectTuple(list, tuple): ... return [ x for x in list if (x[0] == tuple[0] or tuple[0] is \ ... None) and (x[1] == tuple[1] or tuple[1] is None) ] ... >>> l = [(1, 1), (2, 3), (2, 4), (3, 5), (3, 6), (4, 4)] >>> selectTuple(l, (2, 3)) [(2, 3)] >>> selectTuple(l, (2, None)) # tuples beginning with 2 [(2, 3), (2, 4)] >>> selectTuple(l, (None, 4)) # tuples ending with 4 [(2, 4), (4, 4)] >>> selectTuple(l, (None, None)) # all tuples [(1, 1), (2, 3), (2, 4), (3, 5), (3, 6), (4, 4)] -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Society attacks early when the individual is helpless. \__/ B.F. Skinner Physics reference / http://www.alcyone.com/max/reference/physics/ A physics reference. From cyberian_bear at hotmail.com Sun Feb 18 03:50:47 2001 From: cyberian_bear at hotmail.com (cyberian bear) Date: Sat, 17 Feb 2001 21:50:47 -0500 Subject: wildcard in tuples References: <8XDj6.13$sR5.356@typhoon.nyu.edu> <3A8F1F7D.6781AF14@alcyone.com> Message-ID: Yep, that looks like just what i needed. but is there a way to modify those statements so that they can be used in 'if then ' statement. So it will go something like that: if (# of matched terms is greater than 0) : do stuff thanx "Erik Max Francis" wrote in message news:3A8F1F7D.6781AF14 at alcyone.com... > cyberian bear wrote: > > > lets say i have a tuple in one list and i need to check it against > > every > > tuple in second list. So (e,c) --and i want to find every tuple in > > second > > list which has tuples who are (e, *). What is the proper syntax for > > doing > > this > > I'm not sure exactly what you're asking. If all you want is to select > all 2-tuples that, say, have 2 as the first element, then you can do it > easily enough with list comprehensions: > > >>> l = [(1, 1), (2, 3), (2, 4), (3, 5), (3, 6), (4, 4)] > >>> [ x for x in l if x[0] == 2 ] > [(2, 3), (2, 4)] > > This can obviously be trivially modified for matching on the second > list. > > You could do something similar using None as a wildcard: > > >>> def selectTuple(list, tuple): > ... return [ x for x in list if (x[0] == tuple[0] or tuple[0] is \ > ... None) and (x[1] == tuple[1] or tuple[1] is None) ] > ... > >>> l = [(1, 1), (2, 3), (2, 4), (3, 5), (3, 6), (4, 4)] > >>> selectTuple(l, (2, 3)) > [(2, 3)] > >>> selectTuple(l, (2, None)) # tuples beginning with 2 > [(2, 3), (2, 4)] > >>> selectTuple(l, (None, 4)) # tuples ending with 4 > [(2, 4), (4, 4)] > >>> selectTuple(l, (None, None)) # all tuples > [(1, 1), (2, 3), (2, 4), (3, 5), (3, 6), (4, 4)] > > -- > Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ > __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE > / \ Society attacks early when the individual is helpless. > \__/ B.F. Skinner > Physics reference / http://www.alcyone.com/max/reference/physics/ > A physics reference. From max at alcyone.com Sun Feb 18 04:07:00 2001 From: max at alcyone.com (Erik Max Francis) Date: Sat, 17 Feb 2001 19:07:00 -0800 Subject: wildcard in tuples References: <8XDj6.13$sR5.356@typhoon.nyu.edu> <3A8F1F7D.6781AF14@alcyone.com> Message-ID: <3A8F3C54.E33222B0@alcyone.com> cyberian bear wrote: > Yep, that looks like just what i needed. but is there a way to modify > those > statements so that they can be used in 'if then ' statement. So it > will go > something like that: > if (# of matched terms is greater than 0) : > do stuff With the selectTuple function I wrote, which returns a list of matched tuples, it would simply be: if selectTuple(list, matchingTuple): do stuff -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ In Heaven all the interesting people are missing. \__/ Friedrich Nietzsche Computer science / http://www.alcyone.com/max/reference/compsci/ A computer science reference. From b.l.crawford at worldnet.att.net Sun Feb 18 00:41:26 2001 From: b.l.crawford at worldnet.att.net (Bonnie Crawford) Date: Sat, 17 Feb 2001 23:41:26 GMT Subject: Kansas city Opportunity Message-ID: Terrific opportunity for a Staff Analyst Programmer. Position involves development and maintenance of an electronic proxy voting product. Product is primarily a web site which allows shareholders to log in and complete a proxy card on line. Development is done in Python language in a Solaris environment using a DB2 database. nature of programming includes CGI programming, database programming, data file processing and report generation. Requirements: Strong knowledge of Internet infrastructure such as SMTP, HTTP and FTP, Background in object oriented programming, Python development preferred, will consider C++, Java, or Object pascal experience. Strong background as UNIX developer preferably Solaris and background with programming database applications. Please email to b.l.crawford at att.net is interested. Thanks! From cjw at sympatico.ca Sun Feb 18 02:45:39 2001 From: cjw at sympatico.ca (Colin J. Williams) Date: Sun, 18 Feb 2001 01:45:39 GMT Subject: A suspected bug Message-ID: <3A8F2968.9240BD8C@sympatico.ca> It seems to me that the bit of code below should report a type inconsistency. X-Mozilla-Status: 0009 Sep 20 2000, 12:29:43) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2000 Mark Hammond (MarkH at ActiveState.com) - see 'Help/About PythonWin' for further copyright information. >>> print 2 > '1' 0 >>> print 1 > '2' 0 >>> If we replace the comparison operator by an arithmetic operator, we get: >>> z= 1+'1' Traceback (innermost last): File "", line 1, in ? TypeError: number coercion failed >>> Which is what I would have expected. Colin W. From aahz at panix.com Sun Feb 18 03:32:57 2001 From: aahz at panix.com (Aahz Maruch) Date: 17 Feb 2001 18:32:57 -0800 Subject: A suspected bug References: <3A8F2968.9240BD8C@sympatico.ca> Message-ID: <96nc8p$148$1@panix3.panix.com> In article <3A8F2968.9240BD8C at sympatico.ca>, Colin J. Williams wrote: > >It seems to me that the bit of code below should report >a type inconsistency. >X-Mozilla-Status: 0009 Sep 20 2000, 12:29:43) [MSC 32 bit (Intel)] on win32. >Portions Copyright 1994-2000 Mark Hammond (MarkH at ActiveState.com) - see >'Help/About PythonWin' for further copyright information. >>>> print 2 > '1' >0 >>>> print 1 > '2' >0 >>>> What should the following code do: foo = [1, '2'] foo.sort() Because Python lists can contain heterogeneous information, the comparison operators *must* work between types. -- --- 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 Why doesn't "Just Say NO" include caffeine, nicotine, alcohol, Prozac, and Ritalin? --Aahz From dalke at acm.org Sun Feb 18 04:02:23 2001 From: dalke at acm.org (Andrew Dalke) Date: Sat, 17 Feb 2001 20:02:23 -0700 Subject: A suspected bug References: <3A8F2968.9240BD8C@sympatico.ca> <96nc8p$148$1@panix3.panix.com> Message-ID: <96ne4j$6j5$1@slb0.atl.mindspring.net> Aahz Maruch wrote: >What should the following code do: > >foo = [1, '2'] >foo.sort() > >Because Python lists can contain heterogeneous information, the >comparison operators *must* work between types. That's what I used to think was the accepted Python view of the world, but from the update info for Python 2.1 ]- Complex numbers use rich comparisons to define == and != but raise ] an exception for <, <=, > and >=. Unfortunately, this also means ] that cmp() of two complex numbers raises an exception when the two ] numbers differ. Since it is not mathematically meaningful to compare ] complex numbers except for equality, I hope that this doesn't break ] too much code. so foo.sort() won't even work for all built-in homogenous data types. 'Course, I would prefer that complex numbers had a sort, even if not "mathmatical". There are a couple of ways to do it, but I don't want to get into that tangent. Andrew dalke at acm.org From tim.one at home.com Sun Feb 18 04:31:00 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 17 Feb 2001 22:31:00 -0500 Subject: A suspected bug In-Reply-To: <3A8F2968.9240BD8C@sympatico.ca> Message-ID: [Colin J. Williams] > It seems to me that the bit of code below should report > a type inconsistency. > X-Mozilla-Status: 0009 Sep 20 2000, 12:29:43) [MSC 32 bit > (Intel)] on win32. > Portions Copyright 1994-2000 Mark Hammond (MarkH at ActiveState.com) - see > 'Help/About PythonWin' for further copyright information. > >>> print 2 > '1' > 0 > >>> print 1 > '2' > 0 > >>> It's functioning as designed and documented, so you may wish to argue that it's a design flaw, but it won't be considered "a bug". As the Reference Manual 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. It so happens that objects of different non-numeric types are compared today by the string names of their types, so any integer compares less than any string today (because "int" < "string"). I'd agree that's of marginal value, but that's the way it's always been, so it would break stuff if it changed. For example, sometimes I have giant lists of objects of all kinds of types, and can reliably sort the list to bring all the objects of the same type next to each other. It does have its charms. it-must-be-so-unpythonic-that-it's-pythonic-again-ly y'rs - tim From fredrik at pythonware.com Sun Feb 18 12:12:57 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 18 Feb 2001 11:12:57 GMT Subject: A suspected bug References: Message-ID: "Tim Peters wrote: > I'd agree that's of marginal value, but that's the way it's always been, so > it would break stuff if it changed. For example, sometimes I have giant > lists of objects of all kinds of types, and can reliably sort the list to > bring all the objects of the same type next to each other. It does have its > charms. except that it doesn't always work: Python 2.0 (#8, Jan 29 2001, 22:28:01) on win32 >>> a = [u"foo", "b?r"] >>> a.sort() Traceback (most recent call last): File "", line 1, in ? UnicodeError: ASCII decoding error: ordinal not in range(128) not to mention: Python 2.1a2 (#10, Feb 18 2001, 00:16:17) on win32 >>> a = [u"foo", "b?r"] >>> a.sort() >>> a UnicodeError: ASCII decoding error: ordinal not in range(128) >>> a ['b\x84r', u'foo'] >>> a.sort() >>> a = 10 UnicodeError: ASCII decoding error: ordinal not in range(128) >>> a.sort() >>> # hey, what's going on here? ... UnicodeError: ASCII decoding error: ordinal not in range(128) >>> quit 'Use Ctrl-Z plus Return to exit.' (reboot) Cheers /F From amk at mira.erols.com Sun Feb 18 16:36:31 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 18 Feb 2001 15:36:31 GMT Subject: A suspected bug References: Message-ID: On Sun, 18 Feb 2001 11:12:57 GMT, Fredrik Lundh wrote: >except that it doesn't always work: And as Andrew Dalke pointed out: >>> L=[1j, 2j] >>> L.sort() Traceback (most recent call last): File "", line 1, in ? TypeError: cannot compare complex numbers using <, <=, >, >= >>> --amk From aahz at panix.com Sun Feb 18 17:11:49 2001 From: aahz at panix.com (Aahz Maruch) Date: 18 Feb 2001 08:11:49 -0800 Subject: Python 2.x breaks cmp() (was Re: A suspected bug) References: Message-ID: <96os85$1qe$1@panix3.panix.com> In article , A.M. Kuchling wrote: >On Sun, 18 Feb 2001 11:12:57 GMT, Fredrik Lundh wrote: > >>except that it doesn't always work: > >And as Andrew Dalke pointed out: >>>> L=[1j, 2j] >>>> L.sort() >Traceback (most recent call last): > File "", line 1, in ? >TypeError: cannot compare complex numbers using <, <=, >, >= >>>> Is there any chance this can be treated as a bug and fixed for the release of 2.1? Alternatively, given that we're already breaking code with the change in the way complex numbers are handled, should cmp() now raise an exception *every* time the type/class differs? I think the current situation is going to cause major problems trying to explain Python, particularly on the Unicode side. -- --- 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 Why doesn't "Just Say NO" include caffeine, nicotine, alcohol, Prozac, and Ritalin? --Aahz From tim.one at home.com Sun Feb 18 18:23:50 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 18 Feb 2001 12:23:50 -0500 Subject: Python 2.x breaks cmp() (was Re: A suspected bug) In-Reply-To: <96os85$1qe$1@panix3.panix.com> Message-ID: [Andrew Dalke] > >>> L=[1j, 2j] > >>> L.sort() > Traceback (most recent call last): > File "", line 1, in ? > TypeError: cannot compare complex numbers using <, <=, >, >= > >>> [Aahz Maruch] > Is there any chance this can be treated as a bug and fixed for the > release of 2.1? Sure, but it's a small chance. The reason all comparisons were non-exceptional before isn't that Guido wanted that, but because the implementation was such that it was literally impossible for a comparison to raise an exception "that got noticed". As soon as the implementation was revamped to make raising visible exceptions from comparisons possible, Guido was eager to drop comparisons outside of {==, !=} for complex numbers (as Andrew said, there are several *possible* ways it could be done, but not a one of them wouldn't surprise a majority of users). What would change his mind is bug reports from people this actually hurts (in practice). So far no alpha user has filed a bug report against this. Note that nobody is trying to hide that it changed, either: there's a very clear warning about this change of behavior in the alpha NEWS file. > Alternatively, given that we're already breaking code with the change > in the way complex numbers are handled, should cmp() now raise an > exception *every* time the type/class differs? Certainly not every time -- there's no practical or theoretical problem in asking, e.g., whether 42 < 666L. Forbidding that would be silly. In senseless cases, perhaps. I suspect complex is being used to test the waters before daring to dive in head first. > I think the current situation is going to cause major problems trying to > explain Python, particularly on the Unicode side. Don't understand the last part. I doubt anyone is comparing complex numbers to Unicode strings today . The only errors raised when mixing strings and Unicode strings in comparisons occur in ambiguous cases where users don't specify their intended encodings and so Python refuses to guess which of the world's bazillion and one encodings they had in mind. That's a feature, albeit that it irritates people who think Python *should* read their minds. if-it-could-it-would-ly y'rs - tim From ssthapa at classes.cs.uchicago.edu Tue Feb 20 18:53:50 2001 From: ssthapa at classes.cs.uchicago.edu (ssthapa at classes.cs.uchicago.edu) Date: Tue, 20 Feb 2001 17:53:50 GMT Subject: Python 2.x breaks cmp() (was Re: A suspected bug) References: <96os85$1qe$1@panix3.panix.com> Message-ID: Aahz Maruch wrote: >>>>> L=[1j, 2j] >>>>> L.sort() >>Traceback (most recent call last): >> File "", line 1, in ? >>TypeError: cannot compare complex numbers using <, <=, >, >= >>>>> > >Is there any chance this can be treated as a bug and fixed for the >release of 2.1? Alternatively, given that we're already breaking code >with the change in the way complex numbers are handled, should cmp() now >raise an exception *every* time the type/class differs? If you are referring to the comparision of complex numbers, I'm not sure how the ordering would be done. For example consider 1 and 1j, they have the same magnitude so mathematically speaking there is no way to consistently order them like the real numbers where magnitude is a more useful measure. IIRC, for any given magnitude n there are an infinite number of complex numbers with that magnitude, namely all n*e^(ix) for real x. -- ---------------------------------------------------------------------------- | 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 aahz at panix.com Tue Feb 20 19:42:16 2001 From: aahz at panix.com (Aahz Maruch) Date: 20 Feb 2001 10:42:16 -0800 Subject: Python 2.x breaks cmp() (was Re: A suspected bug) References: <96os85$1qe$1@panix3.panix.com> Message-ID: <96udq8$mh$1@panix3.panix.com> In article , wrote: >Aahz Maruch wrote: >> >>Is there any chance this can be treated as a bug and fixed for the >>release of 2.1? Alternatively, given that we're already breaking code >>with the change in the way complex numbers are handled, should cmp() now >>raise an exception *every* time the type/class differs? > > If you are referring to the comparision of complex numbers, I'm not >sure how the ordering would be done. For example consider 1 and 1j, >they have the same magnitude so mathematically speaking there is no >way to consistently order them like the real numbers where magnitude >is a more useful measure. IIRC, for any given magnitude n there are an >infinite number of complex numbers with that magnitude, namely all n*e^(ix) >for real x. True enough. Question is, in the Real World [tm], should everyone who calls list.sort() be forced to wrap in try/except on the chance that a pair of complex numbers will sneak in? -- --- 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 The problem with an ever-changing .sig is that you have to keep changing it From tim.one at home.com Tue Feb 20 22:54:26 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 20 Feb 2001 16:54:26 -0500 Subject: Python 2.x breaks cmp() (was Re: A suspected bug) In-Reply-To: <96udq8$mh$1@panix3.panix.com> Message-ID: [ssthapa at ntcs-ip45.uchicago.edu, reaffirms the lack of a non-surprising ordering for complex numbers] [Aahz] > True enough. Question is, in the Real World [tm], should everyone who > calls list.sort() be forced to wrap in try/except on the chance that a > pair of complex numbers will sneak in? We lost that the instant we let user-defined __cmp__ raise visible exceptions; list.sort() simply isn't "safe" anymore regardless of what Python does with complex numbers, and we can't go back without again ignoring exceptions raised by __cmp__. You can still define your own comparison function to pass to list.sort(), that catches exceptions and hides them, instead supplying whatever ordering *you* feel like making up in exceptional cases. Much slower, though, but that's the tradeoff. In practice, I think I'm going to be more bothered by tuple comparisons. For example, I often use bisect.insort() to maintain short lists of tuples of the form (priority_integer, some_object) or (first_time_to_deal_with_it, some_object) ordered by the first element. If there's ever a tie on the first element, the builtin lexicographic comparison goes on to compare the second elements. I'm sure I'll start getting exceptions due to that. Again, I'll have to wrap some_object in a class with a __cmp__ that hides those exceptions. afraid-it's-clearly-more-pythonic-not-to-suppress-exceptions-by- magic-ly y'rs - tim From grante at visi.com Tue Feb 20 21:19:15 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 20 Feb 2001 20:19:15 GMT Subject: Python 2.x breaks cmp() (was Re: A suspected bug) References: <96os85$1qe$1@panix3.panix.com> Message-ID: <7jAk6.603$S7.51755@ruti.visi.com> In article , ssthapa at classes.cs.uchicago.edu wrote: >Aahz Maruch wrote: >>>>>> L=[1j, 2j] >>>>>> L.sort() >>>Traceback (most recent call last): >>> File "", line 1, in ? >>>TypeError: cannot compare complex numbers using <, <=, >, >= >>>>>> >> >>Is there any chance this can be treated as a bug and fixed for >>the release of 2.1? Alternatively, given that we're already >>breaking code with the change in the way complex numbers are >>handled, should cmp() now raise an exception *every* time the >>type/class differs? > >If you are referring to the comparision of complex numbers, I'm >not sure how the ordering would be done. Understood. But, for all of the other pairs of objects where nobody is sure how the ordering should done an arbitrary, consistent order is chosen rather than an exception being raised. >For example consider 1 and 1j, they have the same magnitude so >mathematically speaking there is no way to consistently order >them like the real numbers where magnitude is a more useful >measure. IIRC, for any given magnitude n there are an infinite >number of complex numbers with that magnitude, namely all >n*e^(ix) for real x. One could argue that there is no consistent way to order 1.23 and "Winnie the Pooh", but it is done anyway. Complex numbers should behave like everything else. cmp() should always return an ordering, or always raise an exception if the comparison is not meaningful. I don't particularly care which, but it ought to be consistent in order to avoid violating the "law of least astonishment." [I've recently read that Unicode strings are also broken in this respect -- IMO, that needs to be fixed also.] -- Grant Edwards grante Yow! Yow! Am I cleansed at yet?! visi.com From mbel44 at dial.pipex.net Wed Feb 21 14:00:20 2001 From: mbel44 at dial.pipex.net (Toby Dickenson) Date: Wed, 21 Feb 2001 13:00:20 +0000 Subject: Python 2.x breaks cmp() (was Re: A suspected bug) References: <96os85$1qe$1@panix3.panix.com> <7jAk6.603$S7.51755@ruti.visi.com> Message-ID: <8ee79t0sinerobr9slnp3ceem6alfqjqn9@4ax.com> grante at visi.com (Grant Edwards) wrote: >One could argue that there is no consistent way to order 1.23 >and "Winnie the Pooh", but it is done anyway. Complex numbers >should behave like everything else. >cmp() should always return an ordering, or always raise an >exception if the comparison is not meaningful. I don't >particularly care which, but it ought to be consistent in order >to avoid violating the "law of least astonishment." >[I've recently read that Unicode strings are also broken in >this respect -- IMO, that needs to be fixed also.] In c++ there are two ways to compare something: The operators (> = etc) all do the obvious thing but are not defined for types where there is no natural order, such as complex numbers. Alternatively there is a template 'cmp', which is used for ordering types even if they dont have a natural order, and is used by the implementations of set of map templates (C++ maps are tree-based, similar to pythons hash-based dictionaries). Im beginning to think that a similar scheme might make sense for python: It would be a clean way of resolving the current quirky behaviour of comparing unicode and non-unicode strings. Toby Dickenson tdickenson at geminidataloggers.com From hzhu at mars.localdomain Wed Feb 21 09:02:11 2001 From: hzhu at mars.localdomain (Huaiyu Zhu) Date: Wed, 21 Feb 2001 08:02:11 GMT Subject: Python 2.x breaks cmp() (was Re: A suspected bug) References: Message-ID: There are two quite different reasons to define order: one is to impose a meaningful (partial) order, another is to be able to sort things in (whatever) possible order. The first reason can be satisfied by rich comparison, using the magic methods like __lt__, __ge__, and so on. Can we then use cmp to satisfy the second mativation, namely to put everything in an order? This can be done without conflict with the first, if it is required that __cmp__ be a well order (complete order) compatible with __lt__. (Every partial order can be extended to a well order, etc). Eg, for complex number a+bj, one possibility is to sort them according to (a,b) and put them between a and a+eps where eps>0. Another is for cmp(a,a+bj)==0. Either would do to avoid exception in sorting. Now that we have rich comparison, is there any reason, other than historical, to allow __cmp__ to raise exceptions? What would happen if sort just treat exception of cmp(a,b) as cmp(a,b)==0? Will it go into an infinite loop? Just some random thoughts. Huaiyu On Tue, 20 Feb 2001 16:54:26 -0500, Tim Peters wrote: >[ssthapa at ntcs-ip45.uchicago.edu, reaffirms the lack of a non-surprising > ordering for complex numbers] > >[Aahz] >> True enough. Question is, in the Real World [tm], should everyone who >> calls list.sort() be forced to wrap in try/except on the chance that a >> pair of complex numbers will sneak in? > >We lost that the instant we let user-defined __cmp__ raise visible >exceptions; list.sort() simply isn't "safe" anymore regardless of what >Python does with complex numbers, and we can't go back without again >ignoring exceptions raised by __cmp__. > >You can still define your own comparison function to pass to list.sort(), >that catches exceptions and hides them, instead supplying whatever ordering >*you* feel like making up in exceptional cases. Much slower, though, but >that's the tradeoff. > >In practice, I think I'm going to be more bothered by tuple comparisons. >For example, I often use bisect.insort() to maintain short lists of tuples >of the form > > (priority_integer, some_object) > >or > > (first_time_to_deal_with_it, some_object) > >ordered by the first element. If there's ever a tie on the first element, >the builtin lexicographic comparison goes on to compare the second elements. >I'm sure I'll start getting exceptions due to that. Again, I'll have to >wrap some_object in a class with a __cmp__ that hides those exceptions. > >afraid-it's-clearly-more-pythonic-not-to-suppress-exceptions-by- > magic-ly y'rs - tim > > -- Huaiyu Zhu From tim.one at home.com Thu Feb 22 07:42:31 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 22 Feb 2001 01:42:31 -0500 Subject: Python 2.x breaks cmp() (was Re: A suspected bug) In-Reply-To: Message-ID: [Huaiyu Zhu] > ... > Now that we have rich comparison, is there any reason, other than > historical, to allow __cmp__ to raise exceptions? What would > happen if sort just treat exception of cmp(a,b) as cmp(a,b)==0? > Will it go into an infinite loop? list.sort() only looks at __lt__, unless you pass your own comparison function. So __cmp__ is usually irrelevant here. (BTW, there's nothing you can do to send list.sort() into an infinite loop, no matter how whacky a cmp function you supply -- return a random result each time, and it will still end eventually.) But even if list.sort() did still use cmp(), I don't see what's gained by treating exceptions as equality, except to open the door to unbounded surprises: as you said earlier, a partial ordering can be extended to a full ordering, but this treatment of cmp exceptions isn't good enough to do that. For example, consider x, y, z == [5, 3j, 1] Under the "exception implies equality" gimmick, we would have cmp(x, y) == 0 == cmp(y, z) because those both raise exceptions. But in a total ordering that would imply cmp(x, z) == 0 (5==1) too. Ain't so. In fact, that specific list would be a fixed-point for list.sort() (based on details of its implementation I happen to know). That list reversed would also be a fixed-point. So it doesn't even manage to get objects of the same type next to each other. Because complex numbers are built in, Python could impose a total ordering on complex numbers (and, indeed, it used to!). That surprises people too. Mixing 8-bit with Unicode strings in the absence of intended encoding information about the former is wholly analogous, and not so esoteric that people are willing to endure senseless orderings: x, y, z = ["\xbb", u"\u3456", "\x81"] This is "just like" the mixed int and complex case: both that list and its reverse would be sort fixed-points, and for the same reasons. list.sort() simply can't do something sensible in the presence of exceptions. So what's better: Pass exceptions up to the caller? Or silently return a senseless result? Note that I don't say "senseless" just because it doesn't make sense , but also because the result is *unpredictable* to the point of uselessness (as in the examples above). Disclaimer: If list.sort() were willing to embrace a quadratic-time algorithm, it could deduce a total ordering consistent with whatever partial ordering is present, provided that the latter is itself consistent (but note that we have no a priori guarantee about that, and user-defined __cmp__s often aren't consistent). doesn't-sound-likely-to-me-ly y'rs - tim From me at nospam.net Sat Feb 24 20:27:16 2001 From: me at nospam.net (Scottie) Date: Sat, 24 Feb 2001 11:27:16 -0800 Subject: Python 2.x breaks cmp() (was Re: A suspected bug) References: Message-ID: "Tim Peters" wrote in message news:mailman.982706124.20851.python-list at python.org... > .... I think I'm going to be more bothered by tuple comparisons. > For example, I often use bisect.insort() to maintain short lists of tuples > of the form > (priority_integer, some_object) > or > (first_time_to_deal_with_it, some_object) > ordered by the first element. If there's ever a tie on the first element, > the builtin lexicographic comparison goes on to compare the second ... I am trying to put together a nice priority queue package. With the new ops, I feel I should standardize my code to use a single test, rather than willy-nilly use < and <= in various places. What opinions do others have on whether I should use "<" or "<="? I realize exceptions may get thrown or strange orders result from using non-total-ordering relations (I view as a user problem). So here's my question: I'm building these priority queues on either < (>) or <= (>=). If you were to build only one of these two on a type which would it be? Which of the two would you expect to be used in such a package? How should I make this choice? and-what-is-the-meaning-of-life-ly yours, -Scott David Daniels Scott.Daniels at Acm.Org From tim.one at home.com Sun Feb 25 06:15:58 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 25 Feb 2001 00:15:58 -0500 Subject: Python 2.x breaks cmp() (was Re: A suspected bug) In-Reply-To: Message-ID: [Scottie] > ... > I am trying to put together a nice priority queue package. > With the new ops, I feel I should standardize my code to use a single > test, rather than willy-nilly use < and <= in various places. > What opinions do others have on whether I should use "<" or "<="? > I realize exceptions may get thrown or strange orders result from > using non-total-ordering relations (I view as a user problem). > > So here's my question: > I'm building these priority queues on either < (>) or <= (>=). If you > were to build only one of these two on a type which would it be? > Which of the two would you expect to be used in such a package? > How should I make this choice? Python's list.sort() originally used a full-blown cmp(), but in *anticipation* of rich comparisons I rewrote it some years ago to only test whether cmp did or did not return a value less than 0. In other words, rewrote it to *conceptually* use only <. Rich comparisons finally are (will be) in 2.1, and Guido changed the list.sort() comparison routine again to finish that job: if Py_LT alone settles the issue, that's all we ever call now. So I expect that will become a de facto standard. Note that the standard module bisect.py also only uses < (and, btw, note that bisect.insort() (also bisect.insort_right() in 2.1) is very handy for building priority queues today (but "small" ones -- it works with a straight Python list, so inserts "near the front" can get unboundedly expensive as the list grows)). > and-what-is-the-meaning-of-life-ly yours, asking-the-question-prevents-the-answer-from-being-heard-ly y'rs - tim From cjw at sympatico.ca Sun Feb 18 18:50:31 2001 From: cjw at sympatico.ca (Colin J. Williams) Date: Sun, 18 Feb 2001 17:50:31 GMT Subject: A suspected bug References: Message-ID: <3A9009B7.171E1D31@sympatico.ca> Tim points to a paragraph in the Language Reference. I've added the paragraph which follows it below. Tim Peters wrote: > [Colin J. Williams] > > It seems to me that the bit of code below should report > > a type inconsistency. > > X-Mozilla-Status: 0009 Sep 20 2000, 12:29:43) [MSC 32 bit > > (Intel)] on win32. > > Portions Copyright 1994-2000 Mark Hammond (MarkH at ActiveState.com) - see > > 'Help/About PythonWin' for further copyright information. > > >>> print 2 > '1' > > 0 > > >>> print 1 > '2' > > 0 > > >>> > > It's functioning as designed and documented, so you may wish to argue that > it's a design flaw, but it won't be considered "a bug". As the Reference > Manual 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. > >> (This unusual definition of comparison was used to simplify the definition >> of operations like sorting and the in and not in operators. In the future, >> the comparison rules for objects of different types are likely to change.) > > The David Beazley book Python: Essential Reference has, on page 38: "If the types differ, a coercion operation is performed to convert one of the types to the other:" This looks clear enough, but one has to delve into the list below to see that a coercion is only performed in some cases. > > > It so happens that objects of different non-numeric types are compared today > by the string names of their types, so any integer compares less than any > string today (because "int" < "string"). > > I'd agree that's of marginal value, but that's the way it's always been, so > it would break stuff if it changed. For example, sometimes I have giant > lists of objects of all kinds of types, and can reliably sort the list to > bring all the objects of the same type next to each other. It does have its > charms. > Tim makes a case for maintaining cmp, to group objects of like type. Perhaps consideration should be given to providing a new 'comp' which behaves as cmp, but extends the range of coercible types. > > it-must-be-so-unpythonic-that-it's-pythonic-again-ly y'rs - tim Many thanks to Paul Foley and to all who responded. Colin W. From jbell at iinet.net.au Sun Feb 18 05:04:28 2001 From: jbell at iinet.net.au (John Bell) Date: Sun, 18 Feb 2001 12:04:28 +0800 Subject: Automating Form Submission Message-ID: <3A8F49C5.674ED0E4@iinet.net.au> Pythonistas, I am an experienced Perl programmer just beginning to look at Python as I need a scripting langusge for a large project which involves a wide range of technologies. I know from bitter experience that Perl quickly becomes unwieldly as project size and complexity increases. I am impressed by Python, and in evaluating its suitability for the project at hand have found extensions to cover all areas of need but one: Automation of Submission of Web based Forms. I am probably missing something, but cannot find support for escaping of responses (as per Perl's URI::Escape::uri_escape), support for Forms processing (GET and POST methods as per Perl's LWP::Simple and LWP::UserAgent modules respectively) or any support for capture and use of Cookies. At first view Python seems very good in the Web Server department, but not so good in the Web Client area. I think I must be missing something, as I would have expected all this functionality to be written as part of the Grail project. Please tell me I've got it wrong! -- Regards, John Bell -------------- next part -------------- An HTML attachment was scrubbed... URL: From gregj at pobox.com Sun Feb 18 11:37:18 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Sun, 18 Feb 2001 10:37:18 GMT Subject: Automating Form Submission References: <3A8F49C5.674ED0E4@iinet.net.au> Message-ID: <3a8fa220.190450383@news.potlnd1.or.home.com> On Sun, 18 Feb 2001 12:04:28 +0800, John Bell wrote: >Pythonistas, > >I am an experienced Perl programmer just beginning to look at Python >as I need a scripting langusge for a large project which involves a wide >range of technologies. I know from bitter experience that Perl quickly >becomes unwieldly as project size and complexity increases. > >I am impressed by Python, and in evaluating its suitability for the >project at hand have found extensions to cover all areas of need >but one: Automation of Submission of Web based Forms. > >I am probably missing something, but cannot find support for escaping >of responses (as per Perl's URI::Escape::uri_escape), support for >Forms processing (GET and POST methods as per Perl's LWP::Simple >and LWP::UserAgent modules respectively) or any support for capture >and use of Cookies. > >At first view Python seems very good in the Web Server department, >but not so good in the Web Client area. I think I must be missing something, >as I would have expected all this functionality to be written as part of the >Grail project. > >Please tell me I've got it wrong! You've got it wrong. The standard Python distribution includes modules for quoting/unquoting (escaping) URLs (urllib), submitting, receiving, and processing GET and POST requests (httplib), and for parsing MIME-encoded data (mimetools) and RFC822-format headers (rfc822). Of course there is a module implementing CGI (cgi). Everything you need is there. You will find the book "Python Essential Reference" by David Beazley (published by New Riders) very useful. Greg Jorgensen Deschooling Society Portland, Oregon USA From shaleh at valinux.com Sun Feb 18 05:47:29 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Sat, 17 Feb 2001 20:47:29 -0800 Subject: how to unimport something Message-ID: <20010217204729.D15374@valinux.com> Suppose I have a program which has logical segments. How do I run each segment and have modules loaded in that segment get unloaded when I reach the next one? From s713221 at student.gu.edu.au Sun Feb 18 09:15:00 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Sun, 18 Feb 2001 18:15:00 +1000 Subject: how to unimport something References: Message-ID: <3A8F8484.9B9C1F64@student.gu.edu.au> Sean 'Shaleh' Perry wrote: > > Suppose I have a program which has logical segments. How do I run each segment > and have modules loaded in that segment get unloaded when I reach the next > one? The direct answer is Import a module into python >>>import modulename Delete a module >>>del modulename Mind you, you may want to post to the group an example of what you're doing. Importing modules can take some time to load in, they may be able to suggest a more efficient and safer method than module swapping to do what it is you're trying to do. If you're trying to do what I think you're doing, which is have a series of modules with similar named functions, and dynamically "plug/unplug" them from the interpreter, a better way may be to: >>>import modulea,moduleb,modulec (Import all your plugin modules at the start, drop the cost of module import into startup.) >>>module = modulea >>>module.function() (Which is actually modulea.function()) >>>module = moduleb >>>module.function() (Which is actually moduleb.function()) >>>module = modulec >>>module.function() (Which is actually modulec.function()) Unless you had the same functions and classes in each module, and they could accept each others argument patterns, there's the risk of your script failing because a piece of calling code called module.function() expecting modulea, but getting moduleb. Messy If you were planning to add different functionalities to the interpreter at the same time and remove that functionality later, you would seriously risk writing code that calls modulea functionality, only to crash your script because another piece of code wiped out modulea earlier. Finally, if you're thinking to only have the modules you need loaded into the interpreter at any time, this may save some memory, but will cost you in module loading time. Usually not worth it unless you're writing scripts which eg. run for days on a resource-scarce server and it only swaps modules a couple of times a day, or are running the scripts in a severely memory scarce environment. Joal Heagney/AncientHart From shaleh at valinux.com Sun Feb 18 10:19:12 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Sun, 18 Feb 2001 01:19:12 -0800 Subject: how to unimport something In-Reply-To: <3A8F8484.9B9C1F64@student.gu.edu.au>; from s713221@student.gu.edu.au on Sun, Feb 18, 2001 at 06:15:00PM +1000 References: <3A8F8484.9B9C1F64@student.gu.edu.au> Message-ID: <20010218011912.B15456@valinux.com> On Sun, Feb 18, 2001 at 06:15:00PM +1000, s713221 at student.gu.edu.au wrote: > > Mind you, you may want to post to the group an example of what you're > doing. Importing modules can take some time to load in, they may be able > to suggest a more efficient and safer method than module swapping to do > what it is you're trying to do. > application does this: init do step A (takes some time) do step B (takes even longer) do step C (not that long) each step is decently independent of the previous. I plan to have A, B and C implemented as separate modules (perhaps several for each step) and load each as I need them. Not every run of the program will reach all three, but most will. It is possible for each step to take as long as a day or two (it could be given a thousand files to munge). From aleaxit at yahoo.com Sun Feb 18 12:09:15 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 18 Feb 2001 12:09:15 +0100 Subject: how to unimport something References: <3A8F8484.9B9C1F64@student.gu.edu.au> Message-ID: <96oakn0vmq@news2.newsguy.com> "Sean 'Shaleh' Perry" wrote in message news:mailman.982488021.18367.python-list at python.org... [snip] > It is possible for each step to take as long as a day or two (it could be given Then a checkpoint/restart architecture, rather than the ability to unload code modules (which seems to offer little benefit), would seem to be the key requirement -- if current goes away after 30 hours, you don't want to waste all the processing you've already done by having to restart from scratch. Each 'restart' will only load the modules it needs, so, rather than 'unloading', once you have the checkpoint/restart part perfected, you might want at crucial points to stop 'this' process and start 'another' one from the checkpoint -- process start/stop times are NOT going to matter, given your timescale is several hours or more, even on a heavy-process platform such as Windows or VMS, much less on Unix. Suitable for cp/rs might be mmap'ped files, so that the switchover may actually pay no substantial overhead -- but the key issue, as always in checkpoint/restart, is to identify the minimal useful amount of *state* to be saved/reloaded. Alex From fredrik at pythonware.com Sun Feb 18 12:34:42 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 18 Feb 2001 11:34:42 GMT Subject: how to unimport something References: <3A8F8484.9B9C1F64@student.gu.edu.au> Message-ID: Sean 'Shaleh' Perry wrote: > application does this: > > init > do step A (takes some time) > do step B (takes even longer) > do step C (not that long) > > each step is decently independent of the previous. I plan to have A, B and C > implemented as separate modules (perhaps several for each step) and load each > as I need them. not sure what this has to do with "unimporting", so I'm probably missing something here, but is there any reason you cannot do this in the obvious way: import init_module init_module.run() if need_step_A: import step_A step_A.run() if need_step_B: import step_B step_B.run() if need_step_C: import step_C step_C.run() Cheers /F From shaleh at valinux.com Mon Feb 19 19:27:42 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Mon, 19 Feb 2001 10:27:42 -0800 Subject: how to unimport something In-Reply-To: ; from fredrik@pythonware.com on Sun, Feb 18, 2001 at 11:34:42AM +0000 References: <3A8F8484.9B9C1F64@student.gu.edu.au> Message-ID: <20010219102742.A29164@valinux.com> On Sun, Feb 18, 2001 at 11:34:42AM +0000, Fredrik Lundh wrote: > > not sure what this has to do with "unimporting", so I'm > probably missing something here, but is there any reason > you cannot do this in the obvious way: > possibly, I am only at the design phase, was simply curious about ways to approach this. From s713221 at student.gu.edu.au Sun Feb 18 09:15:20 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Sun, 18 Feb 2001 18:15:20 +1000 Subject: how to unimport something References: Message-ID: <3A8F8498.34B00D23@student.gu.edu.au> Sean 'Shaleh' Perry wrote: > > Suppose I have a program which has logical segments. How do I run each segment > and have modules loaded in that segment get unloaded when I reach the next > one? The direct answer is Import a module into python >>>import modulename Delete a module >>>del modulename Mind you, you may want to post to the group an example of what you're doing. Importing modules can take some time to load in, they may be able to suggest a more efficient and safer method than module swapping to do what it is you're trying to do. If you're trying to do what I think you're doing, which is have a series of modules with similar named functions, and dynamically "plug/unplug" them from the interpreter, a better way may be to: >>>import modulea,moduleb,modulec (Import all your plugin modules at the start, drop the cost of module import into startup.) >>>module = modulea >>>module.function() (Which is actually modulea.function()) >>>module = moduleb >>>module.function() (Which is actually moduleb.function()) >>>module = modulec >>>module.function() (Which is actually modulec.function()) Unless you had the same functions and classes in each module, and they could accept each others argument patterns, there's the risk of your script failing because a piece of calling code called module.function() expecting modulea, but getting moduleb. Messy If you were planning to add different functionalities to the interpreter at the same time and remove that functionality later, you would seriously risk writing code that calls modulea functionality, only to crash your script because another piece of code wiped out modulea earlier. Finally, if you're thinking to only have the modules you need loaded into the interpreter at any time, this may save some memory, but will cost you in module loading time. Usually not worth it unless you're writing scripts which eg. run for days on a resource-scarce server and it only swaps modules a couple of times a day, or are running the scripts in a severely memory scarce environment. Joal Heagney/AncientHart From s713221 at student.gu.edu.au Sun Feb 18 09:16:52 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Sun, 18 Feb 2001 18:16:52 +1000 Subject: how to unimport something References: <3A8F8498.34B00D23@student.gu.edu.au> Message-ID: <3A8F84F4.A5E9C092@student.gu.edu.au> Sorry about the double post people. I'm having some sporadic fun with my university's email server/proxy server/newsserver/dnsserver *sighs* Joal Heagney/AncientHart From stevena at neosynapse.net Sun Feb 18 07:17:29 2001 From: stevena at neosynapse.net (Steven D. Arnold) Date: Sun, 18 Feb 2001 01:17:29 -0500 Subject: ANN: Pure Python Encryption [UPDATE] Message-ID: <5.0.2.1.2.20010218011156.03cacbe8@phear.dementian.com> We've posted an update to the Neosynapse Encryption Tools' IDEA implementation. There was a bug that caused incorrect encryption and decryption, even though the test passed. If you downloaded the previous version, you should get the new copy. Apologies for the inconvenience; enjoy! The software may be downloaded from: http://www.neosynapse.net/free_encrypt.htm -- Steven D. Arnold President, Neosynapse Consulting Group stevena at neosynapse.net http://www.neosynapse.net From c941520 at alinga.newcastle.edu.au Sun Feb 18 07:19:38 2001 From: c941520 at alinga.newcastle.edu.au (Ben de Luca) Date: Sun, 18 Feb 2001 17:19:38 +1100 Subject: a few linux/unix related questions Message-ID: <3a8e191f$0$25513$7f31c96c@news01.syd.optusnet.com.au> I was wondering how i catch various signals in nix python so i can exit my programs gracefully? also how might i start another application then have two way communication between it's shell and the python program that started it? From shaleh at valinux.com Sat Feb 17 08:07:52 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Fri, 16 Feb 2001 23:07:52 -0800 Subject: a few linux/unix related questions In-Reply-To: <3a8e191f$0$25513$7f31c96c@news01.syd.optusnet.com.au>; from c941520@alinga.newcastle.edu.au on Sun, Feb 18, 2001 at 05:19:38PM +1100 References: <3a8e191f$0$25513$7f31c96c@news01.syd.optusnet.com.au> Message-ID: <20010216230752.A14988@valinux.com> On Sun, Feb 18, 2001 at 05:19:38PM +1100, Ben de Luca wrote: > I was wondering how i catch various signals in nix python so i can exit my > programs gracefully? > import signal > also how might i start another application then have two way communication > between it's shell and the python program that started it? > os.popen() # just like in C DESCRIPTION The popen() function opens a process by creating a pipe, forking, and invoking the shell. Since a pipe is by defi- nition unidirectional, the type argument may specify only reading or writing, not both; the resulting stream is cor- respondingly read-only or write-only. From donn at oz.net Sat Feb 17 08:29:08 2001 From: donn at oz.net (Donn Cave) Date: 17 Feb 2001 07:29:08 GMT Subject: a few linux/unix related questions References: <3a8e191f$0$25513$7f31c96c@news01.syd.optusnet.com.au> Message-ID: <96l984$8cj$0@216.39.151.169> Quoth "Ben de Luca" : | I was wondering how i catch various signals in nix python so i can exit my | programs gracefully? | | also how might i start another application then have two way communication | between it's shell and the python program that started it? Well, you could hardly have picked two thornier problems for Python programming on UNIX. The answer to the first one is "import signal", and see documention of that module. But bear in mind that signals are weird with Python. The atomic unit of Python execution can span a C external function call, and that can take an indefinitely long time. So delivery of signals at the Python level can be delayed. The second one is either "import popen2", and suffer the inevitable shortcomings of UNIX pipes when used in this way (as opposed to normal use in one way batch data flow), or "import pty" and see if you can get that to work (will have better luck if you're using Python 2.0.) (This is not a Python-specific problem, by the way, same in C.) Donn Cave, donn at oz.net From grante at visi.com Sat Feb 17 17:27:07 2001 From: grante at visi.com (Grant Edwards) Date: Sat, 17 Feb 2001 16:27:07 GMT Subject: a few linux/unix related questions References: <3a8e191f$0$25513$7f31c96c@news01.syd.optusnet.com.au> Message-ID: In article , Sean 'Shaleh' Perry wrote: >> also how might i start another application then have two way communication ^^^^^^^ >> between it's shell and the python program that started it? >> > >os.popen() # just like in C > >DESCRIPTION > The popen() function opens a process by creating a pipe, > forking, and invoking the shell. Since a pipe is by defi- > nition unidirectional, the type argument may specify only ^^^^^^^^^^^^^^ > reading or writing, not both; the resulting stream is cor- > respondingly read-only or write-only. For bidirectional communications, use popen[234] -- Grant Edwards grante Yow! I just remembered at something about a TOAD! visi.com From phrxy at csv.warwick.ac.uk Sun Feb 18 08:09:59 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Sun, 18 Feb 2001 07:09:59 +0000 Subject: Unit testing data; What to test Message-ID: Having decided testing was a Good Thing and that I ought to do it, I've started to write tests, using PyUnit. The first question is straightforward: do people have a standard, simple way of handling data for tests, or do you just tend to stick most of it in the test classes? KISS I suppose. But if the software is going to change a lot, isn't it a good idea to separate the tests from their input and expected result data? Of course with big data -- I have some mathematical functions that need to be checked for example -- you're obviously not going to dump it directly the test code: I'm wondering more about data of the order of tens of objects (objects in the Python sense). In fact, do unit tests often end up having to be rewritten as code is refactored? Presumably yes, given the (low) level that unit tests are written at. The second (third) one is vague: What / How should one test? Discuss. I realise these questions are not strictly python-specific, but (let's see, how do I justify this) it seems most of what is out there on the web & USENET is either inappropriately formal, large-scale and business-orientated for me (comp.software.testing and its FAQ, for example), or merely describes a testing framework. A few scattered XP articles are the only exceptions I've found. I'm sure there must be good and bad ways to test -- for example, I read somewhere (can't find it now) that you should aim to end up so that each bug generates, on (mode) average, one test failure, or at least a small number. The justification for this was that lots of tests failing as a result of a single bug are difficult to deal with. It seems to me that this goal is a) impossible to achieve and b) pointless, since if multiple test failures really are due to a single bug, they will all go away when you fix it, just as compile-time errors often do. No? John From aleaxit at yahoo.com Sun Feb 18 09:16:32 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 18 Feb 2001 09:16:32 +0100 Subject: Unit testing data; What to test References: Message-ID: <96o0bj0mib@news2.newsguy.com> "John J. Lee" wrote in message news:Pine.SOL.4.30.0102160309090.7729-100000 at mimosa.csv.warwick.ac.uk... [snip] > The first question is straightforward: do people have a standard, simple > way of handling data for tests, or do you just tend to stick most of it in > the test classes? KISS I suppose. But if the software is going to change > a lot, isn't it a good idea to separate the tests from their input and > expected result data? Of course with big data -- I have some mathematical > functions that need to be checked for example -- you're obviously not > going to dump it directly the test code: I'm wondering more about data of > the order of tens of objects (objects in the Python sense). If you keep the (stimuli, expected_responses) sets separate from the module being tested, you gain much the same benefits (and pay much the same costs) as by keeping documentation separate from code for other kinds of docs (think of tests as a form of executable docs...!). Keeping some tests/docs together with the code simplifies distribution issues: anybody who has your code also has this minimal set of tests (and other docs). However, in some cases, the total amount of tests and other docs can easily swap the amount of code -- and in this case keeping them together can easily be thought of as "too costly". The code can become practically unreadable if there are an order of magnitude more lines of docs (including tests) than lines of actual source in a .py. My favourite approach (and I do wish I was more systematical in practising what I preach:-) is to try and strike a balance: keep with the code (docstrings, comments, special-purpose test functions) a reasonable minimal amount of tests (& other docs) -- indicatively, roughly the same order of magnitude as the source code itself; but _also_ have a separate set of docs (& tests) for more extensive needs. The ideal line of separation would be, is this stuff going to be needed only by users who are also going to read or change the sources, or is it going to be more generally useful. Docs & tests that only work at the *interface* of the module, without concern for its *internals*, may allow many users to treat the module as a "black box", only reading/running/enriching the separate docs-and-tests. > In fact, do unit tests often end up having to be rewritten as code is > refactored? Presumably yes, given the (low) level that unit tests are > written at. This is another good guideline: docs and tests best kept with the source are those who'll likely need changing anyway when the code is refactored. The unit of reuse is the unit of release: when you typically have internals changes that leave alone the interface of the module, then that interface might usefully be documented and tested "outside" the source code file -- you can imagine releasing enhanced sources with identical "externals" docs/tests, or richer tests/docs that require no re-release of the code itself. > The second (third) one is vague: What / How should one test? Discuss. > > I realise these questions are not strictly python-specific, but (let's So is much of what gets discussed here, and, as a born rambler, I love the ethos of this group, which welcomes such 'somewhat OT' discussions!-) > see, how do I justify this) it seems most of what is out there on the web > & USENET is either inappropriately formal, large-scale and > business-orientated for me (comp.software.testing and its FAQ, for > example), or merely describes a testing framework. A few scattered XP > articles are the only exceptions I've found. If XP fits your needs, you could definitely do worse than adopt it wholesale! Yes, much of what gets discussed about software development deals with large-scale SW (in testing and elsewhere) -- that's because problems grow non-linearly with SW scale... when you release an application that's about 1,000 SLOC, it does not really matter much if your process and approach are jumbled; at 10,000 SLOC, it's a problem; at 100,000, an utter nightmare, so you HAVE to be precise in defining your process then (or, call it 100, 1000, 10,000 FP -- but it's really about SLOC more than it is about FP, which is why higher-level languages help so much). Differently from what XP specifies, I think tests should be in two categories (and, similarly, so should deliverables be, rather than the just-one-deliverable which so characterizes XP -- that is a tad too X for my conservative self, even though I buy into 70+% of XP's tenets!). Which, again, leads us to the internal/external tests-and-docs split. External tests and docs (possibly, in large scale devt, on several scales: module aka unit, subsystem, whole system) deal with externals/interfaces (not just GUI's &c -- I'm talking about, e.g, module interfaces to other software; _of course_ 'engine' and 'presentation' SHOULD almost invariably be separate components, but that's another plane of 'split'). Internal tests and docs deal with internals -- the kind of thing that needs to be tweaked at each refactoring. That's not the same dividing plane as the classic unit vs system test distinction -- it's slanted differently, and perks up again at each granularity level in a large-enough project (minimal granule being the module -- perhaps, at Python level, package -- not the single function or class, since functions and classes inside one module _are_ typically coupled too strongly to test/release/doc independently... there are exceptions, modules that are not very cohesive but rather collections of somewhat unrelated stuff for basically 'packaging' purposes, but they should be the exception rather than the rule). > I'm sure there must be good and bad ways to test -- for example, I read > somewhere (can't find it now) that you should aim to end up so that each > bug generates, on (mode) average, one test failure, or at least a small > number. The justification for this was that lots of tests failing as a > result of a single bug are difficult to deal with. It seems to me that > this goal is a) impossible to achieve and b) pointless, since if multiple > test failures really are due to a single bug, they will all go away when > you fix it, just as compile-time errors often do. No? True. However, if tests are designed in terms of a _sequence_, it IS often possible to arrange for the most fundamental tests to be run *first*, ensuring minimal workability of some lower-level, call it 'infrastructural', kind of objects, so that dependent (higher level) parts can be tested _assuming_ the lower-level stuff works. This is more of a consideration for 'internals' kinds of tests, IMHO. Alex From shaleh at valinux.com Sun Feb 18 10:15:53 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Sun, 18 Feb 2001 01:15:53 -0800 Subject: Unit testing data; What to test In-Reply-To: ; from phrxy@csv.warwick.ac.uk on Sun, Feb 18, 2001 at 07:09:59AM +0000 References: Message-ID: <20010218011553.A15456@valinux.com> On Sun, Feb 18, 2001 at 07:09:59AM +0000, John J. Lee wrote: > > Having decided testing was a Good Thing and that I ought to do it, I've > started to write tests, using PyUnit. > > The second (third) one is vague: What / How should one test? Discuss. > > I'm sure there must be good and bad ways to test -- for example, I read > somewhere (can't find it now) that you should aim to end up so that each > bug generates, on (mode) average, one test failure, or at least a small > number. The justification for this was that lots of tests failing as a > result of a single bug are difficult to deal with. It seems to me that > this goal is a) impossible to achieve and b) pointless, since if multiple > test failures really are due to a single bug, they will all go away when > you fix it, just as compile-time errors often do. No? > How I commonly see it done (and how I do it): common cases edge cases -- perhaps -1 could be valid in some cases and not others or maybe you have a buffer which is only soo big bad cases -- but -2 never is You want to see if your code fails or gives expected output. The other big thing is every time you find a bug, you fix it and then add a test case that triggers the bug. So if you run the buggy version you get an error and the new version is clean. This way, if you accidently remove the fix or cause a similar bug elsewhere, your tests catch it. From stephen_purcell at yahoo.com Sun Feb 18 11:17:07 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Sun, 18 Feb 2001 11:17:07 +0100 Subject: Unit testing data; What to test In-Reply-To: ; from phrxy@csv.warwick.ac.uk on Sun, Feb 18, 2001 at 07:09:59AM +0000 References: Message-ID: <20010218111707.E19924@freedom.puma-ag.com> John J. Lee wrote: > [snip] But if the software is going to change > a lot, isn't it a good idea to separate the tests from their input and > expected result data? Do whatever is clearest, but try to arrange the tests such that their data doesn't change often. High-maintenance test cases are either bad test cases or a sign that the tested code is being changed for no good reason. > In fact, do unit tests often end up having to be rewritten as code is > refactored? Presumably yes, given the (low) level that unit tests are > written at. Refactoring should normally not break tests -- it means "now the code is working and passing the tests, let's remove cruft". XP zealots might (don't quote me) go as far as saying that any change that breaks the tests is a feature change, not a refactoring. Refactoring of tests is a separate activity. > The second (third) one is vague: What / How should one test? Discuss. Test *everything*, and do it thoroughly! If you want answers implying less work, there are probably some guidelines somewhere... Personally, I like the XP testing approach: 1. Identify a requirement that some code has to do X 2. Write a test where we try to do X, and check that it worked 3. Keep adding or changing code until the test passes, and no other test breaks. Finding a bug is equivalent to identifying a requirement that some code should not do Y -- write a test, and code until it passes. A complete set of tests thus written forms a catalogue of what the code is guaranteed to do correctly; use of the tested code in any other manner is not guaranteed to work. Some people make the mistake of wasting a lot of testing effort on checking that their code does something "sensible" if misused. There's no time-efficient way to catch mistakes made by people who didn't read the manual. Think of the tests as a combination of 'programmers manual' and 'example code'. > I'm sure there must be good and bad ways to test True enough. The bad way is to *not* test. :-) Really, the point is that time spent wondering or reading about how best to test would be better spent simply writing as many tests as possible. -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 gherman at darwin.in-berlin.de Wed Feb 21 11:10:19 2001 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Wed, 21 Feb 2001 11:10:19 +0100 Subject: Unit testing data; What to test References: Message-ID: <3A93940B.E09817A3@darwin.in-berlin.de> "John J. Lee" wrote: > > Having decided testing was a Good Thing and that I ought to do it, I've > started to write tests, using PyUnit. > > The first question is straightforward: do people have a standard, simple > way of handling data for tests, or do you just tend to stick most of it in > the test classes? KISS I suppose. But if the software is going to change > a lot, isn't it a good idea to separate the tests from their input and > expected result data? Of course with big data -- I have some mathematical > functions that need to be checked for example -- you're obviously not > going to dump it directly the test code: I'm wondering more about data of > the order of tens of objects (objects in the Python sense). > > In fact, do unit tests often end up having to be rewritten as code is > refactored? Presumably yes, given the (low) level that unit tests are > written at. > > The second (third) one is vague: What / How should one test? Discuss. > > I realise these questions are not strictly python-specific, but (let's > see, how do I justify this) it seems most of what is out there on the web > & USENET is either inappropriately formal, large-scale and > business-orientated for me (comp.software.testing and its FAQ, for > example), or merely describes a testing framework. A few scattered XP > articles are the only exceptions I've found. > > I'm sure there must be good and bad ways to test -- for example, I read > somewhere (can't find it now) that you should aim to end up so that each > bug generates, on (mode) average, one test failure, or at least a small > number. The justification for this was that lots of tests failing as a > result of a single bug are difficult to deal with. It seems to me that > this goal is a) impossible to achieve and b) pointless, since if multiple > test failures really are due to a single bug, they will all go away when > you fix it, just as compile-time errors often do. No? > > John I suggest reading some of the written material about XP that you can find by searching your favourite online book dealer for "extreme programming". I get five hits for the series that was started with Kent Beck with Addison-Wesley, two of which are not yet published... All of the first three that I know are *thin* books and easy to read! In general I'd say only that much: knowbody knows better *what* to test than people writing the code (after the use cases / user stories have been determined)! So, if there is a lack of knowledge about what to test (I'm not sure this is the case here, though, but this is the subject line ;-) there must be some deeper issue on the common understanding of what the system is expected to do. As for organizing the tests: see the books I mentioned, but don't expect a detailed process description. Everything that works for you will be fine! If something won't: adapt, shake and reiterate! ;-) Regards, Dinu -- Dinu C. Gherman ReportLab Consultant - http://www.reportlab.com ................................................................ "The only possible values [for quality] are 'excellent' and 'in- sanely excellent', depending on whether lives are at stake or not. Otherwise you don't enjoy your work, you don't work well, and the project goes down the drain." (Kent Beck, "Extreme Programming Explained") From phrxy at csv.warwick.ac.uk Wed Feb 28 18:41:01 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Wed, 28 Feb 2001 17:41:01 +0000 Subject: Unit testing data; What to test Message-ID: Sorry about the formatting etc. of this post -- I had to cut and paste from Google. > "John J. Lee" wrote in message > news:Pine.SOL.4.30.0102160309090.7729-100000 at mimosa.csv.warwick.ac.uk... [...] > If you keep the (stimuli, expected_responses) sets separate from the > module being tested, you gain much the same benefits (and pay much > the same costs) as by keeping documentation separate from code for > other kinds of docs (think of tests as a form of executable docs...!). > > Keeping some tests/docs together with the code simplifies distribution > issues: anybody who has your code also has this minimal set of tests > (and other docs). Well, that's not a problem, is it (unless the tests really are huge)? They can be in the distribution without being mixed in with the code. > However, in some cases, the total amount of tests > and other docs can easily swap the amount of code -- and in this case > keeping them together can easily be thought of as "too costly". The > code can become practically unreadable if there are an order of magnitude > more lines of docs (including tests) than lines of actual source in a .py. Agreed. My tests are separate from the code -- it hadn't occurred to me to keep them in the same file. It was the separation (or not) of test data and test code I was wondering about, though. > My favourite approach (and I do wish I was more systematical in > practising what I preach:-) is to try and strike a balance: keep with > the code (docstrings, comments, special-purpose test functions) a > reasonable minimal amount of tests (& other docs) -- indicatively, > roughly the same order of magnitude as the source code itself; > but _also_ have a separate set of docs (& tests) for more extensive > needs. [...] This is all good advice, but it doesn't actually answer my question. ;-) Anyway, I think I will try having some tests in the code, sounds like a great idea considering the tests-as-docs aspect. > > The second (third) one is vague: What / How should one test? Discuss. [...] > > see, how do I justify this) it seems most of what is out there on the web > > & USENET is either inappropriately formal, large-scale and [...] > > A few scattered XP > > articles are the only exceptions I've found. [...] > If XP fits your needs, you could definitely do worse than adopt it > wholesale! Yes, much of what gets discussed about software > development deals with large-scale SW (in testing and elsewhere) -- > that's because problems grow non-linearly with SW scale... when > you release an application that's about 1,000 SLOC, it does not > really matter much if your process and approach are jumbled; at Let me assure you it _is_ possible to achieve an unmaintainable mess in ~1000 SLOC. I have personally achieved this in, let's see (C-x C-f munge.pl RET) ... 832 SLOC. This is one of many things that Perl makes easy (this is completely unfair to Perl of course -- what really makes it easy is starting out thinking 'this is going to be a 100 line script' and then extending by cut and paste -- I've learned my lesson, honest!). > 10,000 SLOC, it's a problem; at 100,000, an utter nightmare, so > you HAVE to be precise in defining your process then (or, call it Yeah, of course, I understand that. But there is still a place for lots of testing for smaller efforts, minus the heavyweight formal process. > 100, 1000, 10,000 FP -- but it's really about SLOC more than it > is about FP, which is why higher-level languages help so much). > > Differently from what XP specifies, I think tests should be in two > categories (and, similarly, so should deliverables be, rather than > the just-one-deliverable which so characterizes XP -- that is a > tad too X for my conservative self, even though I buy into 70+% > of XP's tenets!). Which two categories? External and internal? How is this different from the XP unit test versus acceptance tests division? Is your point just that the external / internal division applies on more levels than just final user / everything else -- which is what you seem to be talking about below? here's a snip explaining what XP people mean by acceptance tests for anybody that hasn't read about it: http://www.extremeprogramming.org/rules/functionaltests.html ---------- Acceptance tests are created from user stories. During an iteration the user stories selected during the iteration planning meeting will be translated into acceptance tests. The customer specifies scenarios to test when a user story has been correctly implemented. A story can have one or many acceptance tests, what ever it takes to ensure the functionality works. Acceptance tests are black box system tests. Each acceptance test represents some expected result from the system. Customers are responsible for verifying the correctness of the acceptance tests and reviewing test scores to decide which failed tests are of highest priority. Acceptance tests are also used as regression tests prior to a production release. ---------- > Which, again, leads us to the internal/external > tests-and-docs split. External tests and docs (possibly, in large > scale devt, on several scales: module aka unit, subsystem, whole > system) deal with externals/interfaces (not just GUI's &c -- I'm > talking about, e.g, module interfaces to other software; _of course_ > 'engine' and 'presentation' SHOULD almost invariably be separate > components, but that's another plane of 'split'). Internal tests > and docs deal with internals -- the kind of thing that needs to be > tweaked at each refactoring. > > That's not the same dividing plane as the classic unit vs system > test distinction -- it's slanted differently, and perks up again at > each granularity level in a large-enough project (minimal granule > being the module -- perhaps, at Python level, package -- not the > single function or class, since functions and classes inside one > module _are_ typically coupled too strongly to test/release/doc > independently... there are exceptions, modules that are not very > cohesive but rather collections of somewhat unrelated stuff for > basically 'packaging' purposes, but they should be the exception > rather than the rule). [...] John From eatonalive%qwestinternet.net at pop3.qwestinternet.net Sun Feb 18 09:00:11 2001 From: eatonalive%qwestinternet.net at pop3.qwestinternet.net (Jim Eaton) Date: 18 Feb 2001 08:00:11 GMT Subject: What to do after Python? Message-ID: <3A8F81BC.108488CA@pop3.qwestinternet.net> I am learning Python as a first language, and I have been wondering what is a good language to learn after Python? I'm thinking of either going into C or Java but I'm not sure which one because I've heard many arguments either way. Will going into Java first be any detriment to learning C later? Any suggestions would be greatly appreciated. Thank you in advance. Josh cooljage at hotmail.com From s713221 at student.gu.edu.au Sun Feb 18 09:22:05 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Sun, 18 Feb 2001 18:22:05 +1000 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> Message-ID: <3A8F862D.4BE238F9@student.gu.edu.au> Jim Eaton wrote: > > I am learning Python as a first language, and I have been wondering what > is a good language to learn after Python? I'm thinking of either going > into C or Java but I'm not sure which one because I've heard many > arguments either way. Will going into Java first be any detriment to > learning C later? Any suggestions would be greatly appreciated. > > Thank you in advance. > > Josh > cooljage at hotmail.com >From a very python-predudiced view, if you're using CPython, the C languages will let you write C extensions for python. If you're using JPython, then Java may be more useful. Joal Heagney/AncientHart From aleaxit at yahoo.com Sun Feb 18 09:25:35 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 18 Feb 2001 09:25:35 +0100 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> Message-ID: <96o0su0mv6@news2.newsguy.com> "Jim Eaton" wrote in message news:3A8F81BC.108488CA at pop3.qwestinternet.net... > I am learning Python as a first language, and I have been wondering what > is a good language to learn after Python? There are several possibilities, but I would suggest SQL as the second language. It's incredibly useful AND when used well it urges you to think in very different ways from a sequential imperative language (such as Python, C, Java, ...) -- thus at the same time broadening your horizons AND providing you with LOTS of real-world returns. Similarly, for a THIRD language I would suggest some structured markup language such as XML (with XPath, XSLT...) or HTML (4.0, with its DOM). > I'm thinking of either going > into C or Java but I'm not sure which one because I've heard many > arguments either way. Will going into Java first be any detriment to > learning C later? Any suggestions would be greatly appreciated. A lower-level language such as Java or C might be a good 4th language. Java is far simpler (as a language: the _libraries_ are extremely rich, but that's another issue) and thus a better 4th step than C (the latter, or C++, might come later). Python (in the flavor of Jython, when you go for Java) will help you hugely in each of these further study endeavours, BTW. Alex From max at alcyone.com Sun Feb 18 11:13:42 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 18 Feb 2001 02:13:42 -0800 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96o0su0mv6@news2.newsguy.com> Message-ID: <3A8FA056.F7E767B4@alcyone.com> Alex Martelli wrote: > There are several possibilities, but I would suggest SQL as the second > language. It's incredibly useful AND when used well it urges you to > think in very different ways from a sequential imperative language > (such as Python, C, Java, ...) -- thus at the same time broadening > your horizons AND providing you with LOTS of real-world returns. > > Similarly, for a THIRD language I would suggest some structured markup > language such as XML (with XPath, XSLT...) or HTML (4.0, with its > DOM). I think he meant programming languages, not database query languages or markup languages. Java or C++ would probably be up his alley, depending on exactly what he wanted to do with that further knowledge. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Human love is often but the encounter of two weaknesses. \__/ Francois Mauriac Interstelen / http://www.interstelen.com/ A multiplayer, strategic, turn-based Web game on an interstellar scale. From aleaxit at yahoo.com Sun Feb 18 12:03:53 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 18 Feb 2001 12:03:53 +0100 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96o0su0mv6@news2.newsguy.com> <3A8FA056.F7E767B4@alcyone.com> Message-ID: <96oab20vda@news2.newsguy.com> "Erik Max Francis" wrote in message news:3A8FA056.F7E767B4 at alcyone.com... [snip] > > There are several possibilities, but I would suggest SQL as the second [snip] > I think he meant programming languages, not database query languages or > markup languages. This is possible, but maybe (as long as we're reading his mind anyway:-) by the 'programming' adjective (that he didn't use but you think he had implied) he meant languages *used IN* programming -- and SQL and XML (particularly the XSLT part thereof) then qualify again:-). That's why I was suggesting them rather than, say, French, Esperanto, or Latin:-). > Java or C++ would probably be up his alley, depending on exactly what he > wanted to do with that further knowledge. C++, IMHO, is somewhat too complicated even as a second programming language; unless C++ is a specific requirement, Java is more approchable. Alex From anton at home.ogre.nu Tue Feb 20 07:45:11 2001 From: anton at home.ogre.nu (Anton Sherwood) Date: 19 Feb 2001 22:45:11 -0800 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96o0su0mv6@news2.newsguy.com> <3A8FA056.F7E767B4@alcyone.com> <96oab20vda@news2.newsguy.com> Message-ID: <96t3pn$3ij$1@home.ogre.nu> Alex Martelli writes : . . . That's why I was suggesting them [SQL,XML] : rather than, say, French, Esperanto, or Latin:-). Eerie! I haven't even *read* this group before, and already someone makes a crack about my fourth, second and third languages! ObP: Today I had my first occasion to use string.join, map, lambda -- all in the same expression. -- Anton Sherwood -- br0nt0 at p0b0x.com -- http://ogre.nu/ From andrew at andrewcooke.free-online.co.uk Sun Feb 18 09:53:47 2001 From: andrew at andrewcooke.free-online.co.uk (Andrew Cooke) Date: Sun, 18 Feb 2001 08:53:47 +0000 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> Message-ID: <3A8F8D9B.78B37578@andrewcooke.free-online.co.uk> Oh boy, what a choice :-) What do you want to do? Learn something *completely* different? Or explore different ways of looking at Objects? Or learn a faster language? Or...? For completely different, how about a functional language - there are dozens, but maybe Scheme/Lisp or OCaml or Haskell? Or a stack-based language like Forth? Or a logical language like Prolog or Oz or Mercury? For different OOP, how about Smalltalk or Eiffel? For something faster, how about C++ (although all the above have compilers and will be faster than C - what I mean here is a language that you can use to get a job easilly, and one that, being rather unpleasant, means you still use Python for the little tasks ;-) Have a poke around lambda (http://lambda.weblogs.com) for more ideas/references. I also wrote a sketchy summary of many different languages (these days I'm not that proud of it, but it was really written to answer exactly this question) which you can find at http://www.andrewcooke.free-online.co.uk/andrew/lang.html If you post with what you'd like to do next (if you have a particular project in mind, or what to learn something specific) then we might be able to narrow the choice. But thereare hundreds of languages out there, all great in their own way: http://directory.google.com/Top/Computers/Programming/Languages/ Have fun, Andrew Jim Eaton wrote: > > I am learning Python as a first language, and I have been wondering what > is a good language to learn after Python? I'm thinking of either going > into C or Java but I'm not sure which one because I've heard many > arguments either way. Will going into Java first be any detriment to > learning C later? Any suggestions would be greatly appreciated. > > Thank you in advance. > > Josh > cooljage at hotmail.com From andrew at andrewcooke.free-online.co.uk Sun Feb 18 09:56:06 2001 From: andrew at andrewcooke.free-online.co.uk (Andrew Cooke) Date: Sun, 18 Feb 2001 08:56:06 +0000 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A8F8D9B.78B37578@andrewcooke.free-online.co.uk> Message-ID: <3A8F8E26.2D8D948F@andrewcooke.free-online.co.uk> Andrew Cooke wrote: [...] > For something faster, how about C++ (although all the above have > compilers and will be faster than C - what I mean here is a language [...] Sorry - faster than Python! (and I add "probably") (and the comment that speed isn't that important - I use and like Python myself) (and the comment that Python isn't that slow). OK? Andrew From mwh21 at cam.ac.uk Sun Feb 18 11:34:04 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 18 Feb 2001 10:34:04 +0000 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> Message-ID: Jim Eaton writes: > I am learning Python as a first language, and I have been wondering > what is a good language to learn after Python? I'm thinking of > either going into C or Java but I'm not sure which one because I've > heard many arguments either way. Will going into Java first be any > detriment to learning C later? Any suggestions would be greatly > appreciated. Depends what you want to do, obviously. If you're after a job, then C, C++, Java are good choices. If you want to broaden your mind, try scheme or Common Lisp or Haskell or some variant of ML or Smalltalk... Cheers, M. -- SPIDER: 'Scuse me. [scuttles off] ZAPHOD: One huge spider. FORD: Polite though. -- The Hitch-Hikers Guide to the Galaxy, Episode 11 From aleaxit at yahoo.com Sun Feb 18 11:59:15 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 18 Feb 2001 11:59:15 +0100 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> Message-ID: <96oa1e0v4h@news2.newsguy.com> "Michael Hudson" wrote in message news:m3ae7ke0v7.fsf at atrus.jesus.cam.ac.uk... > Jim Eaton writes: > > > I am learning Python as a first language, and I have been wondering > > what is a good language to learn after Python? I'm thinking of > > either going into C or Java but I'm not sure which one because I've > > heard many arguments either way. Will going into Java first be any > > detriment to learning C later? Any suggestions would be greatly > > appreciated. > > Depends what you want to do, obviously. If you're after a job, then > C, C++, Java are good choices. If you want to broaden your mind, try > scheme or Common Lisp or Haskell or some variant of ML or Smalltalk... Perfectly correct (though I would not put things in this specific order:-), but I just want to underline my original suggestion in this light: SQL does _both_ -- it broadens the mind, being a non-procedural, set oriented language, *AND* is also a good choice in terms of practical use and on-the-job usefulness (most programmers use relational DB's, very few use them _really well_...:-). My second suggestion, for some structured-markup language such as XML (with XPath, XLink, XSLT...) is much in the same vein, although more debatable. Alex From bowman at montana.com Sun Feb 18 17:05:40 2001 From: bowman at montana.com (bowman) Date: Sun, 18 Feb 2001 09:05:40 -0700 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96oa1e0v4h@news2.newsguy.com> Message-ID: Alex Martelli wrote in message news:96oa1e0v4h at news2.newsguy.com... > Perfectly correct (though I would not put things in this specific order:-), > but I just want to underline my original suggestion in this light: SQL > does _both_ -- it broadens the mind the only thing SQL ever broadened was my boredom. Once the initial concepts are grasped, which takes about an hour, the rest is endless repetition. I usually feel like I'm headed for the Augean stables with a very small shovel. being a crusty old C programmer, I don't consider RPG a language, either. I admit many people have had long and lucrative careers dabbling with databases, but I've also heard of a language, Cobol or something, that is also widely used. XML? Perhaps it will amount to something -- someday. From roy at panix.com Sun Feb 18 17:22:58 2001 From: roy at panix.com (Roy Smith) Date: Sun, 18 Feb 2001 11:22:58 -0500 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96oa1e0v4h@news2.newsguy.com> Message-ID: "bowman" wrote: > the only thing SQL ever broadened was my boredom. Once the initial concepts > are grasped, which takes about an hour, the rest is endless repetition. I > usually feel like I'm headed for the Augean stables with a very small > shovel. I agree that SQL is about as exciting as a rotting turnip, but the fact is that there is a heck of a lot of SQL going on in the world, and it's a good skill to know. What's more, the Python SQL interface makes the two a really powerful combination. I find what works well most of the time is to let SQL dig out the data you want, then use Python to manipulate it. I'm working right now with a product which was historically SQL-based. The stuff we're doing now has evolved almost entirely away from SQL, but we still maintain a copy of some data in Oracle for backward-compatability. Every so often, while my co-workers are struggling to figure something out, I'll impress them by firing up sqlplus, typing "select blah from blah where blah blah blah", and getting the answer in 30 seconds. From aleaxit at yahoo.com Sun Feb 18 19:57:35 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 18 Feb 2001 19:57:35 +0100 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96oa1e0v4h@news2.newsguy.com> Message-ID: <96p62s05r@news1.newsguy.com> "bowman" wrote in message news:AsSj6.302$8u5.1400 at newsfeed.slurp.net... > > Alex Martelli wrote in message > news:96oa1e0v4h at news2.newsguy.com... > > Perfectly correct (though I would not put things in this specific > order:-), > > but I just want to underline my original suggestion in this light: SQL > > does _both_ -- it broadens the mind > > the only thing SQL ever broadened was my boredom. Once the initial concepts > are grasped, which takes about an hour, the rest is endless repetition. I I wonder if you're one of the greatest geniuses ever lived (to grasp the concepts of relational databases in an hour!), or one of the myriad people who didn't get SQL taught to them _right_. You _have_ read Celko's "SQL for Smarties", for example? And beyond that, do you understand, say, outer joins and why you might want to use one, the implications of update-propagation strategies and their interactions with integrity constraints, or locking and transactioning issues in typical scenarios...? Alex From bowman at montana.com Sun Feb 18 23:05:44 2001 From: bowman at montana.com (bowman) Date: Sun, 18 Feb 2001 15:05:44 -0700 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96oa1e0v4h@news2.newsguy.com> <96p62s05r@news1.newsguy.com> Message-ID: <9KXj6.2408$8u5.4426@newsfeed.slurp.net> Alex Martelli wrote in message news:96p62s05r at news1.newsguy.com... > "SQL for Smarties", for example? And beyond that, do you understand, > say, outer joins and why you might want to use one, the implications > of update-propagation strategies and their interactions with integrity > constraints, or locking and transactioning issues in typical scenarios...? was that the left or right outer join? or the less useful, but symmetrical, full outer join? on good days, I can even tell the difference between 2NF and BCNF and discuss the subtle joys of update anomalies. However, database programming still bores me utterly. Fortunately, there are people in this world who actually seem to enjoy it, as well as business computing. Personally, I find discussions of the uses of fuzzy logic in anti-lock brake systems algorithms more entertaining. From mkx at excite.com Mon Feb 19 18:10:25 2001 From: mkx at excite.com (mkx at excite.com) Date: Mon, 19 Feb 2001 12:10:25 -0500 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96oa1e0v4h@news2.newsguy.com> Message-ID: On Sun, 18 Feb 2001 09:05:40 -0700, "bowman" wrote: >the only thing SQL ever broadened was my boredom. Once the initial concepts >are grasped, which takes about an hour, the rest is endless repetition. If your scope for these "initial concepts" is bound by simple SELECT queries than perhaps the statement above is accurate. However, it seems the many people believe that the SQL language is simply what they see built by the Microsoft Access query builder. The SQL language has many of the same constructs found in most other languages (procedures, functions, recursion, etc.) But within the environment provided by a RDBMS, the SQL language is backed by a lot of power. Too often, I have seen "experienced" programmers consume excessive server resources by needlessly executing multiple queries inside loops of other program languages, because they have not spent the time to learn that a properly written SQL query can save many iterations on the "program side." If one is to develop software that uses a RDBMS, then a full command of the SQL language is as important as a command of the language used to develop the application itself. Too often, I have seen the example where the development staff complains that the "database is too slow", beacuse their code that builds a hierarchical tree-view display takes 30-60 seconds before the web page can be built. Inspection shows that the web server is exectuing separate SELECTs for each branch of the tree, requiring 100's of queries to be executed to build a single page. Once these programmers see that the same hierarchical structure can be built with a single database call to a stored procedure, or recursive query, and completes in a second or two, then they are interested in really learning the language. >being a crusty old C programmer, I don't consider RPG a language, either. What defines a programming language, by your views? From spamers at must.die Sun Feb 18 12:21:07 2001 From: spamers at must.die (Fernando Rodríguez) Date: Sun, 18 Feb 2001 12:21:07 +0100 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> Message-ID: On 18 Feb 2001 08:00:11 GMT, Jim Eaton wrote: >I am learning Python as a first language, and I have been wondering what >is a good language to learn after Python? I'm thinking of either going >into C or Java but I'm not sure which one because I've heard many >arguments either way. Will going into Java first be any detriment to >learning C later? Any suggestions would be greatly appreciated. A good combination is, IMHO: Python, CommonLisp, C++ and Prolog. From a didactic point of view, good second languages are CommonLisp (a more powerful Python-like language) and Java (an easier to learn C/C++ language). Remember that there's much more to programming than just learning the syntax of different languages. If you're new to programming, you should first learn some basic concepts. Good beginers books are: "Simply Scheme: Introducing computer science" and "The Schemer's Guide". Both use a lisp dialect called Scheme, that should be easy to undertand (sort of Python with extra parentheses). //----------------------------------------------- // Fernando Rodriguez Romero // // frr at mindless dot com //------------------------------------------------ From hannah at schlund.de Mon Feb 19 16:14:35 2001 From: hannah at schlund.de (Hannah Schroeter) Date: 19 Feb 2001 16:14:35 +0100 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> Message-ID: <96rd8r$asp$1@c3po.schlund.de> Hello! In article , Fernando Rodr?guez wrote: >[...] >Remember that there's much more to programming than just learning the syntax >of different languages. If you're new to programming, you should first learn >some basic concepts. Good beginers books are: "Simply Scheme: Introducing >computer science" and "The Schemer's Guide". Both use a lisp dialect called >Scheme, that should be easy to undertand (sort of Python with extra >parentheses). Then, you should also suggest "Structure and Interpretation of Computer Programs". Kind regards, Hannah. From cg at gaia.intranet.cdegroot.com Mon Feb 19 21:08:02 2001 From: cg at gaia.intranet.cdegroot.com (Cees de Groot) Date: 19 Feb 2001 21:08:02 +0100 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96rd8r$asp$1@c3po.schlund.de> Message-ID: <96ruf2$ht8$1@gaia.intranet.cdegroot.com> Hannah Schroeter said: >Then, you should also suggest "Structure and Interpretation of Computer >Programs". > And "Goedel, Escher, Bach", "The Timeless Way of Building", and other assorted non-programming books that are important for programmers... -- Cees de Groot http://www.cdegroot.com GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B From scarblac at pino.selwerd.nl Tue Feb 20 14:53:33 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 20 Feb 2001 13:53:33 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96rd8r$asp$1@c3po.schlund.de> <96ruf2$ht8$1@gaia.intranet.cdegroot.com> Message-ID: Cees de Groot wrote in comp.lang.python: > Hannah Schroeter said: > >Then, you should also suggest "Structure and Interpretation of Computer > >Programs". > > And "Goedel, Escher, Bach", "The Timeless Way of Building", and other > assorted non-programming books that are important for programmers... Ooh, nice thread. I'll add "Monty Python: Just The Words" (so you can understand comments), "Alice in Wonderland", "The Hitchhiker's Guide to the Galaxy", and a dose of recent SF (Stephenson, Vinge...). -- Remco Gerlich From amk at mira.erols.com Wed Feb 21 02:48:43 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 21 Feb 2001 01:48:43 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96rd8r$asp$1@c3po.schlund.de> <96ruf2$ht8$1@gaia.intranet.cdegroot.com> Message-ID: On 20 Feb 2001 13:53:33 GMT, Remco Gerlich wrote: >Ooh, nice thread. I'll add "Monty Python: Just The Words" (so you can >understand comments), "Alice in Wonderland", "The Hitchhiker's Guide to the >Galaxy", and a dose of recent SF (Stephenson, Vinge...). If people want to provide slightly longer descriptions of books, I'll happily add them to the Python bookstore (www.amk.ca/bookstore/). --amk From spamers at must.die Tue Feb 20 10:32:26 2001 From: spamers at must.die (Fernando Rodríguez) Date: Tue, 20 Feb 2001 10:32:26 +0100 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96rd8r$asp$1@c3po.schlund.de> Message-ID: <56n29tcv1cd6tbs0idh1cooavielh2kupd@4ax.com> On 19 Feb 2001 16:14:35 +0100, hannah at schlund.de (Hannah Schroeter) wrote: >Then, you should also suggest "Structure and Interpretation of Computer >Programs". I swear by that book, but I'm not sure if it's a good 1st book on programming. That's why I suggested something simpler to start with, but if the OP has a good math background or likes math, then go for it. :-) //----------------------------------------------- // Fernando Rodriguez Romero // // frr at mindless dot com //------------------------------------------------ From rpm1deleteme at frontiernet.net Sun Feb 18 15:40:22 2001 From: rpm1deleteme at frontiernet.net (RPM1) Date: Sun, 18 Feb 2001 09:40:22 -0500 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> Message-ID: <96omoi$1jls$1@node17.cwnet.frontiernet.net> For a job: C, C++, Java, Visual Basic (yuk). Java would probably be the easiest transition from Python. If you are sure you'll want to learn C in the future, then you should start with C first. It's not that hard. It's actually a smaller language than any of the others. The drawbacks with C are no GUI built in and more importantly no safety features. C's strongest feature is that you can do anything you want... that's also its biggest problem. I think you'll get 'spoiled' if you learn Java first. Patrick Mullhaupt, (C programmer) Jim Eaton wrote in message <3A8F81BC.108488CA at pop3.qwestinternet.net>... >I am learning Python as a first language, and I have been wondering what >is a good language to learn after Python? I'm thinking of either going >into C or Java but I'm not sure which one because I've heard many >arguments either way. Will going into Java first be any detriment to >learning C later? Any suggestions would be greatly appreciated. > From scarblac at pino.selwerd.nl Sun Feb 18 16:13:44 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 18 Feb 2001 15:13:44 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> Message-ID: Jim Eaton wrote in comp.lang.python: > I am learning Python as a first language, and I have been wondering what > is a good language to learn after Python? I'm thinking of either going > into C or Java but I'm not sure which one because I've heard many > arguments either way. Will going into Java first be any detriment to > learning C later? Any suggestions would be greatly appreciated. This depends on what you want to do, and on the things you want to do but can't do in Python. -- Remco Gerlich From bowman at montana.com Sun Feb 18 17:21:38 2001 From: bowman at montana.com (bowman) Date: Sun, 18 Feb 2001 09:21:38 -0700 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> Message-ID: Jim Eaton wrote in message news:3A8F81BC.108488CA at pop3.qwestinternet.net... > > Wlll going into Java first be any detriment to > learning C later? Any suggestions would be greatly appreciated. Java will not be a detriment, but it won't be a great help either. A C progammer is responsible for memory management and any data structure beyond a struct. In Python and Java, lists, hashes, tuples and so forth are available for use out of the box. In C, dynamically constructing a doubly linked list, as well as iterating it, is a common task that devolves on the programmer. It is also a task that is commonly screwed up, resulting in SIGSEGV cores and a familiarity with the debugger of your choice. This is not an argument that C is any better a language; in most cases the best language is the one that offers the highest level of abstraction and still can accomplish the task at hand. For instance, though I'd quibble about SQL being a language, I certainly use embedded SQL or a CLI interface to the database engine and wouldn't dream of re-inventing the interface in C. From eatonalive%qwestinternet.net at pop3.qwestinternet.net Sun Feb 18 18:35:50 2001 From: eatonalive%qwestinternet.net at pop3.qwestinternet.net (Jim Eaton) Date: 18 Feb 2001 17:35:50 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> Message-ID: <3A9008A1.6E7DD27F@pop3.qwestinternet.net> Thank you very much for your advice. I was also wondering if learning Perl sometime later would be needed. I've heard people talk of Python as the natural successor to Perl and I'd like to know what people feel about this. From aleaxit at yahoo.com Sun Feb 18 19:47:22 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 18 Feb 2001 19:47:22 +0100 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> Message-ID: <96p5ip0314o@news1.newsguy.com> "Jim Eaton" wrote in message news:3A9008A1.6E7DD27F at pop3.qwestinternet.net... > Thank you very much for your advice. I was also wondering if learning Perl > sometime later would be needed. I've heard people talk of Python as the > natural successor to Perl and I'd like to know what people feel about this. IMHO, you'll need to learn Perl if, and only if, you want to go work for some place that requires it, and/or (roughly equivalent) you need to maintain or translate an existing body of Perl code, to code for an environment which only supplies a Perl interpreter, to use a C-coded module that's only made available for Perl. Roughly, again IMHO, the same goes for Cobol, Fortran or Javascript -- they don't have much to offer you 'intrinsically' once you know Python, but some externalities might make it desirable to know one or more of them -- externalities of the same kind as above described (wanting to work for a shop that requires the language, to maintain or translate existing legacy code, to use libraries or environments which will only support one of these languages). Other languages do have much to offer you, conceptually and/or pragmatically. With Java, C, or C++, you'll be able to extend Python (Jython with Java, CPython with C or C++) to provide faster versions of some algorithm or occasional deep system-specific interaction; any of them will also teach you something about the worth and problems of compile-time strong (but not _obsessively_ strong:-) typing. SQL will teach you to "think in sets" and non-procedurally, and also enable you to use most effectively that crucial tool, relational databases. Others may have weaker pragmatics (hard to get actual need for their use), but good conceptual returns -- e.g., Haskell or ML variants for functional programming, etc. Alex From johann at physics.berkeley.edu Sun Feb 18 21:03:48 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 18 Feb 2001 12:03:48 -0800 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> Message-ID: Jim Eaton writes: > Thank you very much for your advice. I was also wondering if learning Perl > sometime later would be needed. I've heard people talk of Python as the > natural successor to Perl and I'd like to know what people feel about this. Heh. I didn't even get a chance to get started. Clearly, this depends on what you want to do with your new-found programming power. If you're interested in web-related work, then Perl would be a good thing to know, simply because it's very common. I don't do web-stuff, I do numerics, so I've never been able to make myself learn it. (Well, I know enough to use it as a "better awk", but that's about it.) If you want to become a better general programmer, Perl will not help you at all, IMHO. I don't really think that Java would help, either, since I'm not sure what it would teach you. C or C++ would at least help you understand how to manage your own memory and perhaps give you a better sense of what goes on in the guts of the machine. Out of those, I'd recommend learning the basics of C first, because I find C++ very confusing. Now, that being said, my main production code is a Python/SWIG/C++ system, so I like some parts of C++, but it's an awful mess to learn. This may be heresy in a c.l.python, but I really wish I'd written the whole thing in Common Lisp to start with. Too late now, but my next project will be entirely CL. I'm tired of the wall between the scripting language and the speed language; CL can be both (I get numeric performance as good as Fortran in Common Lisp using the free CMUCL compiler), so I'd just use that. (Python is great for things that I think I will never need that to-the-metal performance in. If I can stay in pure Python, I use that. I'll just never try to maintain a dual Python/C++ project again. Arg.) One warning about this lisps; you might want to be careful with them. I never like advocating them. I absolutely *hated* Scheme when I first had to deal with it in an AI class, but I've grown fonder of it with time. I had to do far too many things in a completely backwards way; if you're just trying to learn new ways to do things, it's great, but if you're trying to implement alpha-beta pruning in your checkers game for the assignment due the next day, you'll come to hate it. Common Lisp is a lot more practical. Other languages. Hm. I've heard prolog is cool, but I've done all of my constraint-based programming in lisp. I looked at Haskel, but it seemed over-pure. OCaML is nice, but I never really got into it. Sather is a great language, but it's dying. It's like Eiffel, in that it teaches good OO design, but it has really cool Icon-like iterators (I would so love it if python got those some how), and it's contravariant rather than covariant, so it doesn't have to do nearly as many type-checks and is thereby much faster. That's about it for my experience. Sorry for the brain dump. I just started out by saying that learning Perl won't teach you anything that you can't get from Python, so don't bother with it, unless you just want to make yourself more marketable. And I stand by that statement. --Johann -- Johann Hibschman johann at physics.berkeley.edu From max at alcyone.com Sun Feb 18 21:42:31 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 18 Feb 2001 12:42:31 -0800 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> Message-ID: <3A9033B7.D5ADA989@alcyone.com> Johann Hibschman wrote: > C or C++ would at least help you understand how to manage your own > memory and perhaps give you a better sense of what goes on in the guts > of the machine. Out of those, I'd recommend learning the basics of C > first, because I find C++ very confusing. Learning Standard C++ as Standard C++ as opposed to C with extra features is a lot more straightforward. For the new approaches to learning C++ for its own sake, with emphasis on the modern features which make it really powerful and surprisingly easy to use, check out _Accelerated C++_ by Koenig and Moo. -- 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 wonder if this grief will ever let me go \__/ Sade The laws list / http://www.alcyone.com/max/physics/laws/ Laws, rules, principles, effects, paradoxes, etc. in physics. From sheila at spamcop.net Sun Feb 18 22:29:43 2001 From: sheila at spamcop.net (Sheila King) Date: Sun, 18 Feb 2001 21:29:43 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> Message-ID: <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> On Sun, 18 Feb 2001 12:42:31 -0800, Erik Max Francis wrote in comp.lang.python in article <3A9033B7.D5ADA989 at alcyone.com>: :Johann Hibschman wrote: : :> C or C++ would at least help you understand how to manage your own :> memory and perhaps give you a better sense of what goes on in the guts :> of the machine. Out of those, I'd recommend learning the basics of C :> first, because I find C++ very confusing. : :Learning Standard C++ as Standard C++ as opposed to C with extra :features is a lot more straightforward. For the new approaches to :learning C++ for its own sake, with emphasis on the modern features :which make it really powerful and surprisingly easy to use, check out :_Accelerated C++_ by Koenig and Moo. I must say, that I am shocked at the number of apparent *groans* over C++ language, in this thread. I teach C++ as a first programming language to high school students, via the AP Computer Science Curriculum. (The course I teach is supposed to be equivalent to a first semester University course for CS majors.) I think that the trick, is to use a carefully selected subset of the C++ language. Still, I must say that I really enjoy the Python I've been teaching myself the last few months. I do intend to do a number of projects in Python, eventually. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From max at alcyone.com Sun Feb 18 22:59:53 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 18 Feb 2001 13:59:53 -0800 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: <3A9045D9.3777F585@alcyone.com> Sheila King wrote: > I must say, that I am shocked at the number of apparent *groans* over > C++ > language, in this thread. > > I teach C++ as a first programming language to high school students, > via the > AP Computer Science Curriculum. (The course I teach is supposed to be > equivalent to a first semester University course for CS majors.) I > think that > the trick, is to use a carefully selected subset of the C++ language. Indeed. Often C++ is taught strictly as an extension to C, and when done that way you're essentially learning two languages: C and Standard C++. When learning Standard C++, there's no reason to do it as-an-extension-to-C. For only one example, all the details of handling and processing C strings with the str... functions (which is a big stumbling block in C or C++-as-C for novice programmers) are totally unnecessary in an introductory Standard C++ class, because you have std::string to do all that work for you. As another example, one doesn't have to deal with difficult memory management issues when you have std::vector and other such template classes. > Still, I must say that I really enjoy the Python I've been teaching > myself the > last few months. I do intend to do a number of projects in Python, > eventually. Indeed; I use Python for many recreational and professional projects. For a major one that's public, my Web game Interstelen is being written in Python: http://www.interstelen.com/ -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Isn't the best defense always a good attack? \__/ Ovid REALpolitik / http://www.realpolitik.com/ Get your own customized newsfeed online in realtime ... for free! From sheila at spamcop.net Mon Feb 19 00:06:56 2001 From: sheila at spamcop.net (Sheila King) Date: Sun, 18 Feb 2001 23:06:56 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> <3A9045D9.3777F585@alcyone.com> Message-ID: <99l09t024i0v1ro976ka7kkuniams6k0qd@4ax.com> On Sun, 18 Feb 2001 13:59:53 -0800, Erik Max Francis wrote in comp.lang.python in article <3A9045D9.3777F585 at alcyone.com>: :Sheila King wrote: : :> I must say, that I am shocked at the number of apparent *groans* over :> C++ :> language, in this thread. :> :> I teach C++ as a first programming language to high school students, :> via the :> AP Computer Science Curriculum. (The course I teach is supposed to be :> equivalent to a first semester University course for CS majors.) I :> think that :> the trick, is to use a carefully selected subset of the C++ language. : :Indeed. Often C++ is taught strictly as an extension to C, and when :done that way you're essentially learning two languages: C and Standard :C++. When learning Standard C++, there's no reason to do it :as-an-extension-to-C. For only one example, all the details of handling :and processing C strings with the str... functions (which is a big :stumbling block in C or C++-as-C for novice programmers) are totally :unnecessary in an introductory Standard C++ class, because you have :std::string to do all that work for you. As another example, one :doesn't have to deal with difficult memory management issues when you :have std::vector and other such template classes. Yes, the AP course offers a sting class and a vector class (called apstring and apvector) which are very similar to the classes in the standard library, although with fewer features. I have used these classes myself, for programs I had to write for my coursework at Cal Poly (so I could avoid messing with C-style strings and arrays). :> Still, I must say that I really enjoy the Python I've been teaching :> myself the :> last few months. I do intend to do a number of projects in Python, :> eventually. : :Indeed; I use Python for many recreational and professional projects. :For a major one that's public, my Web game Interstelen is being written :in Python: http://www.interstelen.com/ Cool. Neat site. I will have to point it out to some friends. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From ken at lt.com Mon Feb 19 00:28:00 2001 From: ken at lt.com (Kenneth Loafman) Date: Sun, 18 Feb 2001 17:28:00 -0600 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: <3A905A80.1BC53DB7@lt.com> Sheila King wrote: > > I teach C++ as a first programming language to high school students, via the > AP Computer Science Curriculum. (The course I teach is supposed to be > equivalent to a first semester University course for CS majors.) I think that > the trick, is to use a carefully selected subset of the C++ language. > > Still, I must say that I really enjoy the Python I've been teaching myself the > last few months. I do intend to do a number of projects in Python, eventually. Please also teach the C Standard Library along with C++. I've seen some very poor examples of "reinventing the wheel" happen because the student did not even know the basics of the C Standard Library and its interaction with the basic elements of C/C++. Consider one case I found where the goal was to remove the last character of a line. Instead of using something like: if (strlen(s)) s[strlen(s)-1] = 0 the (7-year C++ veteran) wrote several lines of code that: reversed the string trimmed the first char re-reversed the string Considering that he was using M$ C++ CString operations, the code took several thousand instructions, instead of a just a few. ...Thanks, ...Kenneth From max at alcyone.com Mon Feb 19 00:49:51 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 18 Feb 2001 15:49:51 -0800 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: <3A905F9F.C7D93AA8@alcyone.com> Kenneth Loafman wrote: > Please also teach the C Standard Library along with C++. I've seen > some > very poor examples of "reinventing the wheel" happen because the > student > did not even know the basics of the C Standard Library and its > interaction with the basic elements of C/C++. Consider one case I > found > where the goal was to remove the last character of a line. Instead of > using something like: > > if (strlen(s)) s[strlen(s)-1] = 0 If one is actually writing Standard C++, one doesn't need the str... C functions, since one won't be using NUL-terminated C strings, but rather std::string. > the (7-year C++ veteran) wrote several lines of code that: > > reversed the string > trimmed the first char > re-reversed the string If he actually thought that was a viable solution, he wasn't a veteran of _anything_. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ A man that studieth revenge keeps his own wounds green. \__/ Francis Bacon Product's Quake III Arena Tips / http://www.bosskey.net/ Tips and tricks from the absolute beginner to the Arena Master. From qrczak at knm.org.pl Tue Feb 20 20:33:19 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 20 Feb 2001 19:33:19 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> <3A905F9F.C7D93AA8@alcyone.com> Message-ID: Sun, 18 Feb 2001 15:49:51 -0800, Erik Max Francis pisze: > If one is actually writing Standard C++, one doesn't need the > str... C functions, since one won't be using NUL-terminated C > strings, but rather std::string. Unless he wants to open a file with a given name, or get command line arguments. Not to mention string literals. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From aleaxit at yahoo.com Wed Feb 21 00:20:10 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 21 Feb 2001 00:20:10 +0100 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> <3A905F9F.C7D93AA8@alcyone.com> Message-ID: <96uu2f0j60@news1.newsguy.com> "Marcin 'Qrczak' Kowalczyk" wrote in message news:slrn995hjv.p74.qrczak at qrnik.zagroda... > Sun, 18 Feb 2001 15:49:51 -0800, Erik Max Francis pisze: > > > If one is actually writing Standard C++, one doesn't need the > > str... C functions, since one won't be using NUL-terminated C > > strings, but rather std::string. > > Unless he wants to open a file with a given name, or get command > line arguments. Not to mention string literals. These tasks will use C-strings, but Erik's assertions about not needing "the str... C functions" remains true -- one just builds a std::string out of every C-string one happens to meet, and, when a C-string is needed (e.g., in a std::fstream constructor as the name argument), the .c_str() method of the std::string object supplies it. No functionality at all needs strwhatever()... Alex From roy at panix.com Mon Feb 19 01:02:14 2001 From: roy at panix.com (Roy Smith) Date: Sun, 18 Feb 2001 19:02:14 -0500 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: Kenneth Loafman wrote: > Consider one case I found > where the goal was to remove the last character of a line. Instead of > using something like: > > if (strlen(s)) s[strlen(s)-1] = 0 > > the (7-year C++ veteran) wrote several lines of code that: > > reversed the string > trimmed the first char > re-reversed the string How about: if (length = strlen(s)) s[length-1] = 0; and cut your instruction count in half :-) From erno-news at erno.iki.fi Mon Feb 19 02:18:47 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 19 Feb 2001 03:18:47 +0200 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: In article , Roy Smith writes: | Kenneth Loafman wrote: || if (strlen(s)) s[strlen(s)-1] = 0 | How about: | if (length = strlen(s)) | s[length-1] = 0; | and cut your instruction count in half :-) a sensible optimising compiler will generate identical code for both. -- erno From roy at panix.com Mon Feb 19 02:53:38 2001 From: roy at panix.com (Roy Smith) Date: Sun, 18 Feb 2001 20:53:38 -0500 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: Erno Kuusela wrote: > | if (length = strlen(s)) > | s[length-1] = 0; > > | and cut your instruction count in half :-) > > a sensible optimising compiler will generate identical code for both. I will admit that my compiler theory is a bit rusty, but it's hard to see how a compiler would know that the strlen function would return the same value when called again with the same argument (idempotent?). In any case, I just tried it on my Linux box (GNU compiler) and on a Solaris machine (Sun Workshop compiler). Neither compiler generated the same code for the two versions, regardless of whether optimizing was turned on or not. Both generated two strlen stanzas (see below), with or without -O. The most interesting case was Linux with -O. I don't know i86 assembler, so I'm guessing a bit here, but seems to have in-lined the strlen function, eliminating the subroutine call completely. It still left what looks like two code fragments to count the length of the string. From erno-news at erno.iki.fi Mon Feb 19 06:02:50 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 19 Feb 2001 07:02:50 +0200 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: In article , Roy Smith writes: | Erno Kuusela wrote: || | if (length = strlen(s)) || | s[length-1] = 0; || || | and cut your instruction count in half :-) || || a sensible optimising compiler will generate identical code for both. | I will admit that my compiler theory is a bit rusty, but it's hard to see | how a compiler would know that the strlen function would return the same | value when called again with the same argument (idempotent?). it's part of the language, so the compiler is allowed to have special knowledge about it. | In any case, I just tried it on my Linux box (GNU compiler) and on a | Solaris machine (Sun Workshop compiler). Neither compiler generated the | same code for the two versions, regardless of whether optimizing was turned | on or not. Both generated two strlen stanzas (see below), with or without | -O. i guess they are not sensible then ;) at least the cc/libc combo on linux does have special knowledge about many functions, including strlen, but i guess this case has not been considered important enough to bother with. look in /usr/include/bits/string.h on your linux box and at ... -- erno From ken at lt.com Mon Feb 19 14:41:40 2001 From: ken at lt.com (Kenneth Loafman) Date: Mon, 19 Feb 2001 07:41:40 -0600 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: <3A912294.83F3D08D@lt.com> Roy Smith wrote: > > Kenneth Loafman wrote: > > Consider one case I found > > where the goal was to remove the last character of a line. Instead of > > using something like: > > > > if (strlen(s)) s[strlen(s)-1] = 0 > > > > the (7-year C++ veteran) wrote several lines of code that: > > > > reversed the string > > trimmed the first char > > re-reversed the string > > How about: > > if (length = strlen(s)) > s[length-1] = 0; > > and cut your instruction count in half :-) AArgh! Been doing Python too long! You can't assign in an if statement in Python, so the awkward construct represented the worst of both. In retrospect, I'd probably write something like: if (s[0]) s[strlen(s)-1] = 0 ...Ken From max at alcyone.com Mon Feb 19 17:52:28 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 19 Feb 2001 08:52:28 -0800 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: <3A914F4C.E0CF4D1C@alcyone.com> Kenneth Loafman wrote: > AArgh! Been doing Python too long! You can't assign in an if > statement > in Python, so the awkward construct represented the worst of both. In > retrospect, I'd probably write something like: > > if (s[0]) > s[strlen(s)-1] = 0 There's nothing wrong with using assignment in an if conditional, provided that's what you actually meant. Good compilers will warn, and you can typically suppress the warning by adding another layer of parentheses: if ((length = strlen(s))) ... Making assignment illegal in expressions is to prevent _accidental_ cases like this. If the language allows them and it's intentional, there's nothing wrong. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Life is painting a picture, not doing a sum. \__/ Oliver Wendell Holmes, Jr. Esperanto reference / http://mirror/alcyone/max/lang/esperanto/ An Esperanto reference for English speakers. From root at rainerdeyke.com Mon Feb 19 02:41:36 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 19 Feb 2001 01:41:36 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: "Kenneth Loafman" wrote in message news:mailman.982538961.27262.python-list at python.org... > Please also teach the C Standard Library along with C++. I've seen some > very poor examples of "reinventing the wheel" happen because the student > did not even know the basics of the C Standard Library and its > interaction with the basic elements of C/C++. Consider one case I found > where the goal was to remove the last character of a line. Instead of > using something like: > > if (strlen(s)) s[strlen(s)-1] = 0 Argh! The following is the correct ways of doing this in C++: s = std::string(s.begin(), s.end() - 1); Not using 'std::string' in C++ is analogous to not using the built-in string type in Python. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From ken at lt.com Mon Feb 19 14:31:32 2001 From: ken at lt.com (Kenneth Loafman) Date: Mon, 19 Feb 2001 07:31:32 -0600 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: <3A912034.BD25C502@lt.com> Rainer Deyke wrote: > > "Kenneth Loafman" wrote in message > news:mailman.982538961.27262.python-list at python.org... > > Please also teach the C Standard Library along with C++. I've seen some > > very poor examples of "reinventing the wheel" happen because the student > > did not even know the basics of the C Standard Library and its > > interaction with the basic elements of C/C++. Consider one case I found > > where the goal was to remove the last character of a line. Instead of > > using something like: > > > > if (strlen(s)) s[strlen(s)-1] = 0 > > Argh! > > The following is the correct ways of doing this in C++: > > s = std::string(s.begin(), s.end() - 1); > > Not using 'std::string' in C++ is analogous to not using the built-in string > type in Python. They were using CString under M$VC. I don't think std::string existst on the M$ compilers. Would make it too easy to port to the heathen UNIX boxen . ...Ken From aleaxit at yahoo.com Mon Feb 19 17:10:33 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 19 Feb 2001 17:10:33 +0100 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: <96rgs602drn@news1.newsguy.com> "Kenneth Loafman" wrote in message news:mailman.982589543.7737.python-list at python.org... [snip] > > Not using 'std::string' in C++ is analogous to not using the built-in string > > type in Python. > > They were using CString under M$VC. I don't think std::string existst > on the M$ compilers. Would make it too easy to port to the heathen UNIX > boxen . Microsoft Visual C++ implements std::string (and the rest of std::) since release 5.0 (or earlier... I think I remember it being in some late 4.???). MS bought the implementation provided by P.J.Plauger's company ("dinkumware", I think I recall). They don't distribute later bugfixes, that Plauger and friends made after Microsoft released, but those can be downloaded at the dinkumware site. At some point in time, MS also supported (indirectly, through another smaller company -- "Mainsoft", perhaps?) an MFC version that also made it possible (if not "easy") to port MFC applications from Win/MSVC++ directly to Unix/proprietary C++ compilers of various Unix box suppliers (HP, IBM, Dec, and Sun, at least; those were the ones we tried -- and that's when I learned that Microsoft's C++ was *MUCH* cleaner, and far closer to the standard, than _many_ other proprietary C++ compilers by various other operating system vendors -- before then, the only C++ compiler I had used on Unix and Unix-like boxes was gcc, but that was not supported by 'mainsoft' [if that's the right name]). Alex From max at alcyone.com Mon Feb 19 18:16:33 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 19 Feb 2001 09:16:33 -0800 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> <96rgs602drn@news1.newsguy.com> Message-ID: <3A9154F1.4351E80D@alcyone.com> Alex Martelli wrote: > (HP, IBM, Dec, and Sun, at least; those were the ones we tried -- and > that's when I learned that Microsoft's C++ was *MUCH* cleaner, and far > closer to the standard, than _many_ other proprietary C++ compilers by > various other operating system vendors -- before then, the only C++ > compiler I had used on Unix and Unix-like boxes was gcc, but that was > not supported by 'mainsoft' [if that's the right name]). Which is ironic, since that's the best, most Standard compliant C++ compiler for UNIX out there. (It certainly has some problems, but they're all have workarounds and are being addressed in gcc 3.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 / \ Granted that I must die, how shall I live? \__/ Michael Novak Alcyone Systems / http://www.alcyone.com/ Alcyone Systems, San Jose, California. From aleaxit at yahoo.com Mon Feb 19 23:39:05 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 19 Feb 2001 23:39:05 +0100 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> <96rgs602drn@news1.newsguy.com> <3A9154F1.4351E80D@alcyone.com> Message-ID: <96s78k0a7a@news1.newsguy.com> "Erik Max Francis" wrote in message news:3A9154F1.4351E80D at alcyone.com... > Alex Martelli wrote: > > > (HP, IBM, Dec, and Sun, at least; those were the ones we tried -- and > > that's when I learned that Microsoft's C++ was *MUCH* cleaner, and far > > closer to the standard, than _many_ other proprietary C++ compilers by > > various other operating system vendors -- before then, the only C++ > > compiler I had used on Unix and Unix-like boxes was gcc, but that was > > not supported by 'mainsoft' [if that's the right name]). > > Which is ironic, since that's the best, most Standard compliant C++ > compiler for UNIX out there. (It certainly has some problems, but > they're all have workarounds and are being addressed in gcc 3.0.) I think KCC (KAI's compiler) is/was better (not sure about its status now that Intel [?] has acquired it). But mainsoft didn't support that one, either. Alex From fredrik at pythonware.com Tue Feb 20 01:07:39 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 20 Feb 2001 00:07:39 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> <96rgs602drn@news1.newsguy.com> <3A9154F1.4351E80D@alcyone.com> <96s78k0a7a@news1.newsguy.com> Message-ID: Alex Martelli wrote: > > Which is ironic, since that's the best, most Standard compliant C++ > > compiler for UNIX out there. (It certainly has some problems, but > > they're all have workarounds and are being addressed in gcc 3.0.) > > I think KCC (KAI's compiler) is/was better (not sure about its status > now that Intel [?] has acquired it). footnote: KCC is just one of many compilers based on the EDG frontend (http://www.edg.com) -- which is definitely the best C++ frontend ever written. (had DEC switched to EDG a bit earlier, I would probably still use C++ ;-) Cheers /F From aleaxit at yahoo.com Tue Feb 20 13:18:59 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 20 Feb 2001 13:18:59 +0100 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> <96rgs602drn@news1.newsguy.com> <3A9154F1.4351E80D@alcyone.com> <96s78k0a7a@news1.newsguy.com> Message-ID: <96tnbh011gf@news2.newsguy.com> "Fredrik Lundh" wrote in message news:fzik6.18639$AH6.2540196 at newsc.telia.net... > Alex Martelli wrote: > > > Which is ironic, since that's the best, most Standard compliant C++ > > > compiler for UNIX out there. (It certainly has some problems, but > > > they're all have workarounds and are being addressed in gcc 3.0.) > > > > I think KCC (KAI's compiler) is/was better (not sure about its status > > now that Intel [?] has acquired it). > > footnote: KCC is just one of many compilers based on the EDG frontend > (http://www.edg.com) -- which is definitely the best C++ frontend ever > written. Good point. OTOH, KAI's own traditional strengths are/were entirely in code generation and optimization -- they are/were the guys whose Fortran source-to-source optimizing converter completely busted some parts of the first-generation "SPEC" benchmarks. Given that (just about) the only sensible motivation for using C++ (or C or Fortran) rather than higher-level languages is *PERFORMANCE*, optimization issues would seem to be pretty germane. The cheapest way to try out EDG's front-end is no doubt through www.comeau.com -- they sell their C++-to-C translator, built with EDG's front-end, for as low as $50 (not sure how the price varies by platform &c -- $50 is what it would cost for Windows, or Linux with an Intel CPU); apparently it now also supports C99 (not sure how complete a subset); plus, a really cool marketing idea, one can visit http://www.comeaucomputing.com/tryitout/ and enter some (small but complete) C++ snippet for compilation (no execution, of course, but you'll be able to see any message the compiler emits). (It *would* be nice to have a similar arrangement for _Python_ on some site or other, by the way... although, here, "just compiling" might not be much use:-). Alex From ken at lt.com Mon Feb 19 19:47:26 2001 From: ken at lt.com (Kenneth Loafman) Date: Mon, 19 Feb 2001 12:47:26 -0600 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> <96rgs602drn@news1.newsguy.com> Message-ID: <3A916A3E.6CF35FD2@lt.com> Alex Martelli wrote: > > At some point in time, MS also supported (indirectly, through another > smaller company -- "Mainsoft", perhaps?) an MFC version that also made > it possible (if not "easy") to port MFC applications from Win/MSVC++ > directly to Unix/proprietary C++ compilers of various Unix box suppliers > (HP, IBM, Dec, and Sun, at least; those were the ones we tried -- and > that's when I learned that Microsoft's C++ was *MUCH* cleaner, and far > closer to the standard, than _many_ other proprietary C++ compilers by > various other operating system vendors -- before then, the only C++ > compiler I had used on Unix and Unix-like boxes was gcc, but that was > not supported by 'mainsoft' [if that's the right name]). Thanks for the info. I guess it was just hard to find info on std::, or at least not obvious. Never saw M$ examples that mentioned them. All examples were based on M$ classes, so I guess that's where I got that impression. The rule in my shop now is two part: 1) throw away the vendors manuals 2) use only ANSI standard constructs This solves the problem (for the most part) of programming to some construct that's unique to the vendor, and with a few additions, such as named integral types instead of int, char, short, long, etc, you can solve a lot of the general porting problem. A lot of that goes away with Python. ...Ken From root at rainerdeyke.com Mon Feb 19 17:54:54 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 19 Feb 2001 16:54:54 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: "Kenneth Loafman" wrote in message news:mailman.982589543.7737.python-list at python.org... > Rainer Deyke wrote: > > The following is the correct ways of doing this in C++: > > > > s = std::string(s.begin(), s.end() - 1); > > > > Not using 'std::string' in C++ is analogous to not using the built-in string > > type in Python. > > They were using CString under M$VC. I don't think std::string existst > on the M$ compilers. Would make it too easy to port to the heathen UNIX > boxen . I've used 'std::string' under Visual C++. I'm not familiar with 'CString', but it would probably not be too hard to convert between real strings and 'CString'. Something like this: std::string s(zxczcCString.GetTheStupidCharacterArrayPointer()); s = std::string(s.begin(), s.end() - 1); zxczcCString = CString(s.c_str()); This would obviously be bad for performance, but at least it minimizes dependence on proprietary classes. This is for when the API demands 'CString'. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From sheila at spamcop.net Mon Feb 19 19:23:24 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 19 Feb 2001 18:23:24 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: <82p29t494h8evf1fvpjmr83abqv3enadja@4ax.com> On Mon, 19 Feb 2001 07:31:32 -0600, Kenneth Loafman wrote in comp.lang.python in article : :Rainer Deyke wrote: :> The following is the correct ways of doing this in C++: :> :> s = std::string(s.begin(), s.end() - 1); :> :> Not using 'std::string' in C++ is analogous to not using the built-in string :> type in Python. : :They were using CString under M$VC. I don't think std::string existst :on the M$ compilers. Would make it too easy to port to the heathen UNIX :boxen . I just ran this code on my Win98 box, using MetroWerks CW 5: #include using namespace std; //introduces namespace std int main ( void ) { std::string s = "cat"; cout << "Length of s is " << s.length() << endl; s = std::string(s.begin(), s.end() - 1); cout << "here comes s: \n"; cout << s << endl; return 0; } Here is the output: Length of s is 3 here comes s: ca I think that the standard namespace is available on my Win98 machine. Scary, huh? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From max at alcyone.com Tue Feb 20 05:23:28 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 19 Feb 2001 20:23:28 -0800 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> <82p29t494h8evf1fvpjmr83abqv3enadja@4ax.com> Message-ID: <3A91F140.27EF253B@alcyone.com> Sheila King wrote: > I just ran this code on my Win98 box, using MetroWerks CW 5: > > #include > > using namespace std; //introduces namespace std No, that _uses_ the namespace std. After that statement, you can use the identifiers in the std namespace _without_ the std:: prefix. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ We'll have to make our own luck from now on. \__/ Louis Wu 7 sisters productions / http://www.7sisters.com/ Web design for the future. From sheila at spamcop.net Wed Feb 21 01:18:22 2001 From: sheila at spamcop.net (Sheila King) Date: Wed, 21 Feb 2001 00:18:22 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> <82p29t494h8evf1fvpjmr83abqv3enadja@4ax.com> <3A91F140.27EF253B@alcyone.com> Message-ID: <19269t8upp4gpo4jpfga4uqtiogp4j1586@4ax.com> On Mon, 19 Feb 2001 20:23:28 -0800, Erik Max Francis wrote in comp.lang.python in article <3A91F140.27EF253B at alcyone.com>: :Sheila King wrote: : :> I just ran this code on my Win98 box, using MetroWerks CW 5: :> :> #include :> :> using namespace std; //introduces namespace std : :No, that _uses_ the namespace std. After that statement, you can use :the identifiers in the std namespace _without_ the std:: prefix. Sorry. That comment is automatically inserted by my compiler when I start a new project. (I could delete or modify it, of course, by I seldom even think about it.) -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From sheila at spamcop.net Mon Feb 19 03:10:52 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 19 Feb 2001 02:10:52 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: On Sun, 18 Feb 2001 17:28:00 -0600, Kenneth Loafman wrote in comp.lang.python in article : :Sheila King wrote: :> :> I teach C++ as a first programming language to high school students, via the :> AP Computer Science Curriculum. (The course I teach is supposed to be :> equivalent to a first semester University course for CS majors.) I think that :> the trick, is to use a carefully selected subset of the C++ language. :> :> Still, I must say that I really enjoy the Python I've been teaching myself the :> last few months. I do intend to do a number of projects in Python, eventually. : :Please also teach the C Standard Library along with C++. Um, I don't have time? : I've seen some :very poor examples of "reinventing the wheel" happen because the student :did not even know the basics of the C Standard Library and its :interaction with the basic elements of C/C++. Consider one case I found :where the goal was to remove the last character of a line. Instead of :using something like: : : if (strlen(s)) s[strlen(s)-1] = 0 : :the (7-year C++ veteran) wrote several lines of code that: : : reversed the string : trimmed the first char : re-reversed the string My students would never do that. To remove the last character of a string, I would hope they would do something like this: s = s.substr(0, s.length()-1); Or at least, I hope they would. The substr() and length() commands are something that is included in the apstring class that we use, and I was recently looking at the standard library, and I believe it also includes these commands, or something very similar. I teach them how to work with a variety of classes. And I do tell them about the standard library. So, when they leave me class, they should be able to easily learn new classes and utilize them. :Considering that he was using M$ C++ CString operations, the code took :several thousand instructions, instead of a just a few. Hmm. Did you consider the possibility that this was just a function of the individual involved, and not the fact that he'd been taught C++? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From johann at physics.berkeley.edu Mon Feb 19 03:28:53 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 18 Feb 2001 18:28:53 -0800 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: Sheila King writes: > On Sun, 18 Feb 2001 12:42:31 -0800, Erik Max Francis wrote > in comp.lang.python in article <3A9033B7.D5ADA989 at alcyone.com>: > I must say, that I am shocked at the number of apparent *groans* over C++ > language, in this thread. Really? Any language that encourages vector::iterator end = vec->end(); vector out(vec->size); for(vector::const_iterator i = vec->begin(), vector::iterator j = out->begin(); i != end; ++i, ++j) { *j = (*i)*(*i); } as the right way to square a vector is, well, not quite the way I'd want to do that. Personally, I prefer something like (map-into (make-vector (length vec)) #'(lambda (x) (* x x)) vec) The whole STL thing seems incredibly verbose, and there's no way that's really needed. I wouldn't want to try to teach that to people. I guess that's just my preference. -- Johann Hibschman johann at physics.berkeley.edu From max at alcyone.com Mon Feb 19 04:22:25 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 18 Feb 2001 19:22:25 -0800 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: <3A909171.C1298A01@alcyone.com> Johann Hibschman wrote: > Really? Any language that encourages > > vector::iterator end = vec->end(); > vector out(vec->size); ^ Oops. > for(vector::const_iterator i = vec->begin(), > vector::iterator j = out->begin(); > i != end; > ++i, ++j) { > *j = (*i)*(*i); > } > > as the right way to square a vector is, well, not quite the way I'd > want to do that. You mean generate another vector whose elements contain the squares of the first vector. The usual meaning of "squaring a vector" would involve vector reduction. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Dead men have no victory. \__/ Euripides REALpolitik / http://www.realpolitik.com/ Get your own customized newsfeed online in realtime ... for free! From bowman at montana.com Mon Feb 19 06:30:22 2001 From: bowman at montana.com (bowman) Date: Sun, 18 Feb 2001 22:30:22 -0700 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: Johann Hibschman wrote in message news:mtelwvbe3e.fsf at astron.berkeley.edu... > > as the right way to square a vector is, well, not quite the way I'd > want to do that. Personally, I prefer something like > > (map-into (make-vector (length vec)) > #'(lambda (x) (* x x)) > vec) that looks quite verbose too. my APL is incredibly rusty, but I think about 5 characters would do the job. :) From jpet at eskimo.com Mon Feb 19 06:38:31 2001 From: jpet at eskimo.com (Jeff Petkau) Date: Mon, 19 Feb 2001 05:38:31 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: Johann Hibschman wrote in message news:mtelwvbe3e.fsf at astron.berkeley.edu... > Sheila King writes: > > I must say, that I am shocked at the number of apparent *groans* over C++ > > language, in this thread. > > Really? Any language that encourages > > vector::iterator end = vec->end(); > vector out(vec->size); > for(vector::const_iterator i = vec->begin(), > vector::iterator j = out->begin(); > i != end; > ++i, ++j) { > *j = (*i)*(*i); > } > > as the right way to square a vector is, well, not quite the way I'd > ... > The whole STL thing seems incredibly verbose, and there's no way > that's really needed. I wouldn't want to try to teach that to people. > I guess that's just my preference. I believe the current fashion recommends using std:: explicitly. So that should have been, std::vector::iterator end = vec->end(); std::vector out(vec->size); for(std::vector::const_iterator i = vec->begin(), std::vector::iterator j = out->begin(); i != end; ++i, ++j) { *j = (*i)*(*i); } Nice and concise. It would take twice as many lines in Python: "spam spam spam spam spam spam spam spam spam spam" out = [i*i for i in vec] """spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam Spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam SPAM SPAM spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam out = map(lambda x: x*x,vec) spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam""" --Jeff Petkau (jpet at eskimo.com) From max at alcyone.com Mon Feb 19 07:19:20 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 18 Feb 2001 22:19:20 -0800 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: <3A90BAE8.E09BB5FC@alcyone.com> Jeff Petkau wrote: > I believe the current fashion recommends using std:: explicitly. It's required if the compiler supports namespaces as the Standard says it should. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ You cannot step into the same river once. \__/ Cratylus Alcyone Systems' Daily Planet / http://www.alcyone.com/planet.html A new, virtual planet, every day. From sheila at spamcop.net Mon Feb 19 07:41:16 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 19 Feb 2001 06:41:16 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> <3A90BAE8.E09BB5FC@alcyone.com> Message-ID: On Sun, 18 Feb 2001 22:19:20 -0800, Erik Max Francis wrote in comp.lang.python in article <3A90BAE8.E09BB5FC at alcyone.com>: :Jeff Petkau wrote: : :> I believe the current fashion recommends using std:: explicitly. : :It's required if the compiler supports namespaces as the Standard says :it should. You know, I use a compiler that supports namespaces. I use CodeWarrior Pro 5, from MetroWerks. And we just put, near the top of the program, and usually after the #include directives: using namespace std; and I do not have to put things like std::cout << "some statement\n"; I just put cout << "some statement\n"; It was explained to me, that by putting the statement using namespace std; in the program, I avoid the need to have to put the scope on each of these elements? (I know this is very far off topic now, for this group...) Here are further references on namespaces: http://www.mvps.org/windev/cpp/nspaces.html http://www.cplusplus.com/doc/tutorial/tut5-2.html http://www.glenmccl.com/ns_comp.htm http://www.cog.brown.edu/~rodrigo/c++mini-course/Namespaces.html -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From spamers at must.die Mon Feb 19 12:38:49 2001 From: spamers at must.die (Fernando Rodríguez) Date: Mon, 19 Feb 2001 12:38:49 +0100 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> <3A90BAE8.E09BB5FC@alcyone.com> Message-ID: On Mon, 19 Feb 2001 06:41:16 GMT, Sheila King wrote: >cout << "some statement\n"; > >It was explained to me, that by putting the statement > >using namespace std; > >in the program, I avoid the need to have to put the scope on each of these >elements? (I know this is very far off topic now, for this group...) Yes, it's like the difference between import string string.join((blah, blah)) and from string import * join((blah, blah)) There, now we're back on topic! :-) PS Just don't put the "using" thing in header files and you'll be fine. //----------------------------------------------- // Fernando Rodriguez Romero // // frr at mindless dot com //------------------------------------------------ From bowman at montana.com Mon Feb 19 15:47:42 2001 From: bowman at montana.com (bowman) Date: Mon, 19 Feb 2001 07:47:42 -0700 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> <3A90BAE8.E09BB5FC@alcyone.com> Message-ID: <5xlk6.1189$va7.2463@newsfeed.slurp.net> Sheila King wrote in message news:nlf19tge339tjh0eoiigvsimndjm45b990 at 4ax.com... > It was explained to me, that by putting the statement > > using namespace std; > > in the program, I avoid the need to have to put the scope on each of these > elements? (I know this is very far off topic now, for this group...) it is the same as import foo from foo import bar from foo import * in the last case, and in the case of 'using namespace std' , there is the potential for some variable or function in the imported module to conflict with a name you are using in your module. howver, if you say foo.bar() or std::ends, you have precisely and explicitly chosen the module. Not a big deal for casual programming but when the line count gets into the tens of thousands or more, and a number of programmers are developing modules independently, sooner or later there will be two bar's, and which one too use will require further resolution. The worse case will be a weak compiler that will assume the wrong one and emit a warning. Sad but true, but in large projects involving a great deal of older code, one tends to ignore a lot of warnings, as many are innocuous. From sheila at spamcop.net Mon Feb 19 06:54:19 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 19 Feb 2001 05:54:19 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: On 18 Feb 2001 18:28:53 -0800, Johann Hibschman wrote in comp.lang.python in article : :Sheila King writes: : :> On Sun, 18 Feb 2001 12:42:31 -0800, Erik Max Francis wrote :> in comp.lang.python in article <3A9033B7.D5ADA989 at alcyone.com>: : :> I must say, that I am shocked at the number of apparent *groans* over C++ :> language, in this thread. : :Really? Any language that encourages : :vector::iterator end = vec->end(); :vector out(vec->size); :for(vector::const_iterator i = vec->begin(), : vector::iterator j = out->begin(); : i != end; : ++i, ++j) { : *j = (*i)*(*i); :} I really don't understand that code, probably because I don't teach the STL. I can see that you're creating some new vector of doubles, called out, the same size as the vector vec. And for some reason, you're using two iterators to do your for-loop, though I can't see why. We use only two templated classes in the course I teach (remember, I'm only teaching a one semester course spread out over a year), and we don't do them that way. The templates I'm familiar with are the apvector, which I believe is quite similar to the STL vector class, and the apmatrix, which is similar to the STL matrix class. To take the contents of one vector, and square each entry and put it in another vector, I would probably do this: apvector out( vec.length()); for ( int i= 0; i < vec.length(); i++) out[i]= vec[i]*vec[i] I think that the code I list above is equivalent to yours? :as the right way to square a vector is, well, not quite the way I'd :want to do that. Personally, I prefer something like : :(map-into (make-vector (length vec)) : #'(lambda (x) (* x x)) : vec) My Python isn't that good, either. I haven't learned the lambda stuff, yet. Still, I never was claiming any sort of comparison between Python and C++. Matter of fact, I thought I said (in another message) that I really LIKE and sort of prefer Python. The question was, what is a good second language to learn. I don't see why C++ would be a bad choice, although I never argued in favor of it, either. :The whole STL thing seems incredibly verbose, and there's no way :that's really needed. I wouldn't want to try to teach that to people. :I guess that's just my preference. Well, I don't know about the STL in great detail. I've not been using nor teaching it. I suppose, I should eventually learn it. Well, when the need comes along. However, my spouse codes in C++ for a living (works for/worked for Rockwell/JPL/Boeing) and he thinks your example code is too verbose, and suggested this: vector in; vector out; : : : for (int i=0; i <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: First off, everyone, I'm sorry I opened my big fat mouth. Now I'm just trying to run away gracefully. :-) Sheila King writes: > :vector::iterator end = vec->end(); > :vector out(vec->size); > :for(vector::const_iterator i = vec->begin(), > : vector::iterator j = out->begin(); > : i != end; > : ++i, ++j) { > : *j = (*i)*(*i); > :} > I really don't understand that code, probably because I don't teach > the STL. I can see that you're creating some new vector of doubles, > called out, the same size as the vector vec. Right. > And for some reason, you're using two iterators to do your for-loop, > though I can't see why. Well, one's formally a constant iterator, and the other's not, so it could be important if the vector vec were declared constant. Likewise, it avoids having to call operator[] and doing the full base+offset math, if we assume the compiler's not smart enough to optimize the loop. > To take the contents of one vector, and square each entry and put it in > another vector, I would probably do this: > apvector out( vec.length()); > for ( int i= 0; i < vec.length(); i++) > out[i]= vec[i]*vec[i] > I think that the code I list above is equivalent to yours? Well, mine's a bit more efficient, since it doesn't have to maintain the loop variable i, it doesn't have to call the function vec.length() at each iteration, and it doesn't have to do the full operator[] calculation. It just steps along both of them. But phooey on that! It's bit-twiddling like that which drives me mad while writing C++. :-( > My Python isn't that good, either. I haven't learned the lambda stuff, yet. > Still, I never was claiming any sort of comparison between Python and C++. > Matter of fact, I thought I said (in another message) that I really LIKE and > sort of prefer Python. The question was, what is a good second language to > learn. I don't see why C++ would be a bad choice, although I never argued in > favor of it, either. Again, I'm sorry, you just stumbled into a pet micro-managing optimization peeve of mine, and I wasn't strong enough to resist posting. > vector in; > vector out; > : > : > : > for (int i=0; i out[i]=in[i]*in[i]; Yeah, that works. I forget how the initialization checks for vector work. In addition, vector may even be checking each index i to see if it's in range. Etc. In practice, most of my C++ code looks like that, because the optimized way is just so ugly. I'll be quiet now. -- Johann Hibschman johann at physics.berkeley.edu From max at alcyone.com Mon Feb 19 08:16:42 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 18 Feb 2001 23:16:42 -0800 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: <3A90C85A.ECF15D1C@alcyone.com> Johann Hibschman wrote: > Well, mine's a bit more efficient, since it doesn't have to maintain > the loop variable i, it doesn't have to call the function vec.length() > at each iteration, and it doesn't have to do the full operator[] > calculation. It just steps along both of them. > > But phooey on that! It's bit-twiddling like that which drives me mad > while writing C++. :-( The real reason for going through all the trouble to write that all out is now that you're using Standard C++ iterators, they will work with _any_ Standard container. Not just std::vector, but anyone at all. -- 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) REALpolitik / http://www.realpolitik.com/ Get your own customized newsfeed online in realtime ... for free! From sheila at spamcop.net Mon Feb 19 09:32:39 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 19 Feb 2001 08:32:39 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: On 18 Feb 2001 23:04:51 -0800, Johann Hibschman wrote in comp.lang.python in article : :Yeah, that works. I forget how the initialization checks for vector :work. In addition, vector may even be checking each index i to see if :it's in range. Etc. In practice, most of my C++ code looks like :that, because the optimized way is just so ugly. Yes, vector does check to see if the index in is range. :I'll be quiet now. Well, OK, then. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From tanzer at swing.co.at Mon Feb 19 09:07:10 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Mon, 19 Feb 2001 09:07:10 +0100 Subject: What to do after Python? In-Reply-To: Your message of "Sun, 18 Feb 2001 21:29:43 GMT." <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: Sheila King wrote: > I must say, that I am shocked at the number of apparent *groans* over C++ > language, in this thread. > > I teach C++ as a first programming language to high school students, via the > AP Computer Science Curriculum. (The course I teach is supposed to be > equivalent to a first semester University course for CS majors.) I think that > the trick, is to use a carefully selected subset of the C++ language. I think you are missing at least two issues: - The carefully selected subset isn't going to help your students much when they have to start reading/extending other people's code. - In C++, there are so many low-level issues the programmer has to take care of that it distracts from the problem to be solved -- not very helpful for learning how to program. -- 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 sheila at spamcop.net Mon Feb 19 09:37:00 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 19 Feb 2001 08:37:00 GMT Subject: What to do after Python? References: <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: On Mon, 19 Feb 2001 09:07:10 +0100, tanzer at swing.co.at (Christian Tanzer) wrote in comp.lang.python in article : : :Sheila King wrote: : :> I must say, that I am shocked at the number of apparent *groans* over C++ :> language, in this thread. :> :> I teach C++ as a first programming language to high school students, via the :> AP Computer Science Curriculum. (The course I teach is supposed to be :> equivalent to a first semester University course for CS majors.) I think that :> the trick, is to use a carefully selected subset of the C++ language. : :I think you are missing at least two issues: : :- The carefully selected subset isn't going to help your students much : when they have to start reading/extending other people's code. Sheesh, I thought I made it clear, this was a BEGINNING, first course in programming! They aren't going out and getting jobs the semester after my course ends. (Actually, some of them have, but that's quite unusual.) They can learn the rest, later, at a more appropriate point in their comp sci/programming education. :- In C++, there are so many low-level issues the programmer has to : take care of that it distracts from the problem to be solved -- not : very helpful for learning how to program. I never suggested that C++ was the best choice for a first programming language. In fact, I personally don't care for it, myself (as a first language). However, the course that I am teaching requires that it be taught in that language. For more information about the AP Computer Science program, go here: http://www.collegeboard.org/ap/computer-science/ I didn't write the course. I just teach it. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From dsh8290 at rit.edu Wed Feb 21 05:16:03 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 20 Feb 2001 23:16:03 -0500 Subject: What to do after Python? In-Reply-To: ; from sheila@spamcop.net on Mon, Feb 19, 2001 at 08:37:00AM +0000 References: <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: <20010220231603.C23613@harmony.cs.rit.edu> On Mon, Feb 19, 2001 at 08:37:00AM +0000, Sheila King wrote: | On Mon, 19 Feb 2001 09:07:10 +0100, tanzer at swing.co.at (Christian Tanzer) | wrote in comp.lang.python in article | : | | : | :Sheila King wrote: | : | :> I must say, that I am shocked at the number of apparent *groans* over C++ | :> language, in this thread. | :> | :> I teach C++ as a first programming language to high school students, via the What part of the country do you teach in? | :> AP Computer Science Curriculum. (The course I teach is supposed to be | :> equivalent to a first semester University course for CS majors.) I think that | :> the trick, is to use a carefully selected subset of the C++ language. | : | :- In C++, there are so many low-level issues the programmer has to | : take care of that it distracts from the problem to be solved -- not | : very helpful for learning how to program. | | I never suggested that C++ was the best choice for a first programming | language. In fact, I personally don't care for it, myself (as a first I agree with these, C++ is too low-level to beginning. Something like Eiffel, Java or Python (the last shall be first ...) would be better suited, IMO. | language). However, the course that I am teaching requires that it be taught | in that language. For more information about the AP Computer Science program, | go here: | http://www.collegeboard.org/ap/computer-science/ | | I didn't write the course. I just teach it. Someone ought to point out to the AP committee(s) the pros and cons of the various languages, then they would decide that Python is better ;-). My high school taught BASIC and Pascal on Apple IIe computers until the year I graduated (I never found the time to take them anyways). The year after I graduated (1999) they upgraded to Pentium computers with Windows (95 or 98 I think) and are now offering (MSV) C++ and VB. (Both with Intro- and Advanced- courses). My brother and his friend took the Intro to C++ course (20 weeks, half-year) last year. I don't think they should call it C++ because they barely got throuh if, while, for, and functions and didn't mention classes at all. I highly doubt they used any of the C library stuff (like str functions). They didn't use new/delete or malloc/free either. I think the only C++ specific feature they used was cout and cin. Actually, I think it is a bit unfair and misleading to tell the students they are learning C++ when they don't even mention 90% of the language to them. It would be really cool if they taught a nice, clean, small and very useful language like Python instead, but ... -D PS. this is/was a very interesting thread to read From sheila at spamcop.net Thu Feb 22 03:43:18 2001 From: sheila at spamcop.net (Sheila King) Date: Thu, 22 Feb 2001 02:43:18 GMT Subject: What to do after Python? References: <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: <2ts89tss0mrcoo6a6v54rl8liq6m7uhbpn@4ax.com> On Tue, 20 Feb 2001 23:16:03 -0500, D-Man wrote in comp.lang.python in article : :| :Sheila King wrote: :| :> I teach C++ as a first programming language to high school students, via the : :What part of the country do you teach in? Orange County, California. :| :> AP Computer Science Curriculum. (The course I teach is supposed to be :| :> equivalent to a first semester University course for CS majors.) I think that :| :> the trick, is to use a carefully selected subset of the C++ language. :| : :| :- In C++, there are so many low-level issues the programmer has to :| : take care of that it distracts from the problem to be solved -- not :| : very helpful for learning how to program. :| :| I never suggested that C++ was the best choice for a first programming :| language. In fact, I personally don't care for it, myself (as a first : :I agree with these, C++ is too low-level to beginning. Something like :Eiffel, Java or Python (the last shall be first ...) would be better :suited, IMO. Whatever. The original question in this thread wasn't even about a recommendation for a first programming language. It was about a recommendation for a second language, after having learned Python. I would assert, that after learning Python, one (among many) appropriate choices for a second language, would be C++ (as others have also recommended). :| language). However, the course that I am teaching requires that it be taught :| in that language. For more information about the AP Computer Science program, :| go here: :| http://www.collegeboard.org/ap/computer-science/ :| :| I didn't write the course. I just teach it. : :Someone ought to point out to the AP committee(s) the pros and cons of :the various languages, then they would decide that Python is better :;-). I assume you put the winking smiley, because you know that's been done to death? (I run one mailing list for APCS teachers, and subscribe to another, and have read many of the language wars on the lists over the last few years.) To see me suggest/ask about others opinions of Python, read this search result from the archives of my mailing list: http://www.escribe.com/education/apcsteachers/search.html?query=Python See professors from Rice University suggest Scheme as a first programming language, with this search result of my mailing list: http://www.escribe.com/education/apcsteachers/search.html?query=Scheme&mt=&th=&c=30 The official College Board list, doesn't have public archives, but alternate languages have been discussed even more on that list. Let me also point out, that at many schools, the AP Computer Science course is not a first programming course, but often a second or third programming course. C++ remains the official language for the exams to be given in May 2001, 2002, and 2003. Beginning in May 2004, until the foreseeable future, the programming language will be Java. :My brother and his friend :took the Intro to C++ course (20 weeks, half-year) last year. I don't :think they should call it C++ because they barely got throuh if, :while, for, and functions and didn't mention classes at all. I can't speak for what others schools do. A semester course in C++ for a first programming course certainly doesn't sound like enough time to me. Here is what I covered with my students before Xmas break: Karel++ Chaps. 1-5 (see http://csis.pace.edu/~bergin/karel.html ) Introduces Object/class/inheritance. Loops, conditionals, defining new classes. That was the first 1.5 months of my class. In the next two months I covered (teaching the C++ language) all the basic types, conditionals, boolean expressions, arithmetic expressions, all the different looping structures, functions that return a value and void functions, nested loops, and a brief intro to the apstring class and a brief intro to value vs. reference parameters. Before the end of the first semester, I also introduced some additional classes from the Marine Biology Case Study that I have to teach. http://www.collegeboard.org/ap/computer-science/html/case_study.html Since the end of the first semester (Jan), we've covered file I/O, the apvector class, structs, enumeration types and just started writing our own classes yesterday. My students will learn all of the A topics listed on this page: http://www.thinkspot.net/materdei/apcompsci/APCS%20Topic%20Outline.html before the end of April. (I have a few studying independently, who will also learn the AB topics, as well.) I think one point of the AP committee that should be mentioned, is that the course is not advertised as a C++ course (it is not intended to teach the language), but rather as a Computer SCIENCE course, thus the emphasis on things like program design, sorting algorithms and the like. : I highly :doubt they used any of the C library stuff (like str functions). They :didn't use new/delete or malloc/free either. I hardly think that memory management is an appropriate topic for a one semester, first programming course. Also, malloc and free are not C++. They are C. new/delete are only used with pointers??? And other dynamically allocated types? : Actually, I think it is :a bit unfair and misleading to tell the students they are learning C++ :when they don't even mention 90% of the language to them. Do you know for a fact, that that is what the students were told? Or did you only hear the students' version of what they thought they were told? (These are not always one and the same, says the 18-year veteran high school teacher.) In any case, I cannot really have any meaningful comment on what isolated schools do. I suppose that if they really told the kids they were "teaching them C++" in such a way as to make the kids believe, that in one semester, they would know the entire C++ language (something I find hard to imagine), then that wasn't very nice. : It would be :really cool if they taught a nice, clean, small and very useful :language like Python instead, but ... You will see me suggest some of the exact same things on the archives of my mailing list. I don't recall anywhere suggesting that I recommended that C++ be the first programming language of choice. I merely said, that it could be done. I stated that only in the context of justifying it as a reasonable choice for a second language, for someone who had first learned Python. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From cg at gaia.intranet.cdegroot.com Mon Feb 19 21:12:46 2001 From: cg at gaia.intranet.cdegroot.com (Cees de Groot) Date: 19 Feb 2001 21:12:46 +0100 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> Message-ID: <96runu$hvg$1@gaia.intranet.cdegroot.com> Sheila King said: >I must say, that I am shocked at the number of apparent *groans* over C++ >language, in this thread. > *groan*. I learnt C++ by installing a, err, not-so-official AT&T cfront source tape on a Xenix box and hacking away until the damn thing ran, and really did my best to learn it. It's /not/ a real OO language. But it is sort of nice for applying OO to low-level/system programming, and because it was meant to be just that, it's OK. Just don't go writing apps in it (but the same holds for C). >I think that >the trick, is to use a carefully selected subset of the C++ language. > Yup. And that might be workable in a classroom project, but forget it for commercial development. Better start with a good language right away. For teaching OO, I'd use Smalltalk. For teaching general programming, Python is a nice choice because it is the most "neutral" language I know (neutral w.r.t. to OO, procedural, functional). Although chances are I'd use Smalltalk anyway :-) -- Cees de Groot http://www.cdegroot.com GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B From rcalco at cortechs.com Sun Feb 18 21:51:00 2001 From: rcalco at cortechs.com (Bob Calco) Date: Sun, 18 Feb 2001 15:51:00 -0500 Subject: What to do after Python? In-Reply-To: Message-ID: # Other languages. Hm. I've heard prolog is cool, but I've done all of # my constraint-based programming in lisp. I looked at Haskel, but it # seemed over-pure. OCaML is nice, but I never really got into it. # Sather is a great language, but it's dying. It's like Eiffel, in that # it teaches good OO design, but it has really cool Icon-like iterators # (I would so love it if python got those some how), and it's # contravariant rather than covariant, so it doesn't have to do nearly # as many type-checks and is thereby much faster. Check out Mozart, an implementation of the Oz language, at www.mozart-oz.org. It's very fringe in the sense that not very many folks know about it but its one of the few (IMHO) successful hybrid languages (from an engineering perspective, not a commercial perspective -- it hasn't had enough exposure yet to make it to the "big time"), with emphasis on concurrent programming, constraints-based programming, mobile agents, and the like; plus, it's cross platform like Java. Its power lies in being able to code each piece of an application according to the paradigm that best fits the solution (functional, object-oriented, declarative, etc.) all in the same language. I find it very "natural" for all sorts of applications, particulary expert systems, if your into that. It's funny; I stumbled into it looking for classical music MP3's and information about famous composers on the web, believe it or not! Sincerely, Bob Calco # -----Original Message----- # From: python-list-admin at python.org # [mailto:python-list-admin at python.org]On Behalf Of Johann Hibschman # Sent: Sunday, February 18, 2001 3:04 PM # To: python-list at python.org # Subject: Re: What to do after Python? # # # Jim Eaton writes: # # > Thank you very much for your advice. I was also wondering if # learning Perl # > sometime later would be needed. I've heard people talk of Python as the # > natural successor to Perl and I'd like to know what people feel # about this. # # Heh. I didn't even get a chance to get started. # # Clearly, this depends on what you want to do with your new-found # programming power. If you're interested in web-related work, then # Perl would be a good thing to know, simply because it's very common. # I don't do web-stuff, I do numerics, so I've never been able to make # myself learn it. (Well, I know enough to use it as a "better awk", # but that's about it.) # # If you want to become a better general programmer, Perl will not help # you at all, IMHO. I don't really think that Java would help, either, # since I'm not sure what it would teach you. # # C or C++ would at least help you understand how to manage your own # memory and perhaps give you a better sense of what goes on in the guts # of the machine. Out of those, I'd recommend learning the basics of C # first, because I find C++ very confusing. Now, that being said, my # main production code is a Python/SWIG/C++ system, so I like some parts # of C++, but it's an awful mess to learn. # # This may be heresy in a c.l.python, but I really wish I'd written the # whole thing in Common Lisp to start with. Too late now, but my next # project will be entirely CL. I'm tired of the wall between the # scripting language and the speed language; CL can be both (I get # numeric performance as good as Fortran in Common Lisp using the free # CMUCL compiler), so I'd just use that. # # (Python is great for things that I think I will never need that # to-the-metal performance in. If I can stay in pure Python, I use # that. I'll just never try to maintain a dual Python/C++ project # again. Arg.) # # One warning about this lisps; you might want to be careful with them. # I never like advocating them. I absolutely *hated* Scheme when I # first had to deal with it in an AI class, but I've grown fonder of it # with time. I had to do far too many things in a completely backwards # way; if you're just trying to learn new ways to do things, it's great, # but if you're trying to implement alpha-beta pruning in your checkers # game for the assignment due the next day, you'll come to hate it. # Common Lisp is a lot more practical. # # Other languages. Hm. I've heard prolog is cool, but I've done all of # my constraint-based programming in lisp. I looked at Haskel, but it # seemed over-pure. OCaML is nice, but I never really got into it. # Sather is a great language, but it's dying. It's like Eiffel, in that # it teaches good OO design, but it has really cool Icon-like iterators # (I would so love it if python got those some how), and it's # contravariant rather than covariant, so it doesn't have to do nearly # as many type-checks and is thereby much faster. # # That's about it for my experience. Sorry for the brain dump. I just # started out by saying that learning Perl won't teach you anything that # you can't get from Python, so don't bother with it, unless you just # want to make yourself more marketable. And I stand by that statement. # # --Johann # # -- # Johann Hibschman johann at physics.berkeley.edu # -- # http://mail.python.org/mailman/listinfo/python-list # From scarblac at pino.selwerd.nl Mon Feb 19 01:29:19 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 19 Feb 2001 00:29:19 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> Message-ID: Jim Eaton wrote in comp.lang.python: > Thank you very much for your advice. I was also wondering if learning Perl > sometime later would be needed. I've heard people talk of Python as the > natural successor to Perl and I'd like to know what people feel about this. They are really similar languages if you look at what they can do, but Python tries to be small and clean and elegant, while Perl tries to be powerful and flexible and huge. (the difference is perl doesn't try to be small or clean, but python does also try to be powerful and flexible ;)). When Python is your first language, learning Perl as a second one isn't very logical since you're not really able to attack new problems - you just get the option of using another language for things you could already solve easily. (Generalizing here, but...) Learning C, for instance, means you can now attack all those problems that Python is too slow to handle, for instance by making modules in C that you can call from Python. Java and C++ are important if you're looking for world, *a lot* of real work application programming is done in those two. Other languages like Haskell, Prolog, Lisp etc are a good for thing to learn because they are programming in a completely different way. It broadens the mind. -- Remco Gerlich From cg at gaia.intranet.cdegroot.com Sun Feb 18 19:53:18 2001 From: cg at gaia.intranet.cdegroot.com (Cees de Groot) Date: 18 Feb 2001 19:53:18 +0100 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> Message-ID: <96p5mu$3eq$1@gaia.intranet.cdegroot.com> Jim Eaton said: >I am learning Python as a first language, and I have been wondering what >is a good language to learn after Python? I'm thinking of either going >into C or Java but I'm not sure which one because I've heard many >arguments either way. Will going into Java first be any detriment to >learning C later? Any suggestions would be greatly appreciated. > You should learn at least a new programming language per year to keep your mind fresh, so it doesn't really matter. Python is nice for a general view of programming: it does OO, procedural and functional programming reasonably well. I'd advise C as a second language because it forces you to deal with the computer behind all that code, which tends to give you a good perspective for other language. Smalltalk is probably the best general language around if you think OO is cool - watch out, lot of people never want anything else after learning it. I'd sniff at Haskell and/or Scheme as well, but you probably want to do quite a bit of programming and reading before these languages start to make sense, and even then... If you want a job, decide whether you are pro or contra M$ and sign up for a VB or Java course depending on the outcome. Needless to say that these languages won't teach you a lot of new stuff compared to the ones I mentioned above. You probably shouldn't take them as second language because they are likely to teach you a lot of bad habits. -- Cees de Groot http://www.cdegroot.com GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B From roy at panix.com Sun Feb 18 20:13:58 2001 From: roy at panix.com (Roy Smith) Date: Sun, 18 Feb 2001 14:13:58 -0500 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96p5mu$3eq$1@gaia.intranet.cdegroot.com> Message-ID: cg at cdegroot.com wrote: > I'd advise C as a second language because it forces you to deal with the > computer behind all that code, which tends to give you a good > perspective for other language. Actually, the problem with C is that it hides too much of the computer behind all that code. I spent a few years writing C on alphas, and never even found out how many registers the danged thing had. If you really want to find out what the hardware is all about, learn assembler, which is perilously close to handing a soldering iron to a software guy. Another alternative would be to learn lisp. It may not get you a better job, but will give you the ability to write a better python major mode for emacs :-) I don't suppose I could interest you in fortran? From cg at gaia.intranet.cdegroot.com Sun Feb 18 21:17:25 2001 From: cg at gaia.intranet.cdegroot.com (Cees de Groot) Date: 18 Feb 2001 21:17:25 +0100 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96p5mu$3eq$1@gaia.intranet.cdegroot.com> Message-ID: <96pakl$4fq$1@gaia.intranet.cdegroot.com> Roy Smith said: >Actually, the problem with C is that it hides too much of the computer >behind all that code. I spent a few years writing C on alphas, and never >even found out how many registers the danged thing had. Err, lots? What I meant was that C forces you to think about memory issues, pointers, and such close-to-hardware stuff without forcing you to to actually dive into a particular CPU (ah, those days when "register" had measurable effects...). Much closer, and you'll indeed do assembly (or machine code - back in the 70's I didn't have an assembler for the C64 so I did everything in machine code inside Basic DATA statements ;-)). Probably every programmer should learn assembly as well, but then, C programming often drives you under the hood anyway (dirty work like picking coredumps apart). A fun way to learn assembler is to play core wars... >I don't suppose I could interest you in fortran? Well, I've been following this advise of learning a language-per-year myself for the last decade or so, and I think some dusty corner of my brains has Fortran knowledge (dig, dig - ah: there it is. I ported PDP-11 Fortran/77 to MS-DOS in 1986 :-)). But since my languager-per-year adagium let me execute "learn Smalltalk" last year, I'm an ST convert, so sorry: no interest. -- Cees de Groot http://www.cdegroot.com GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B From cjc26 at nospam.cornell.edu Wed Feb 21 03:56:54 2001 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Wed, 21 Feb 2001 02:56:54 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96p5mu$3eq$1@gaia.intranet.cdegroot.com> <96pakl$4fq$1@gaia.intranet.cdegroot.com> Message-ID: * Cees de Groot menulis: | | ...Much closer, and you'll indeed do assembly | (or machine code - back in the 70's I didn't have an assembler for the | C64 Yeah, that's because the C64 didn't even exist yet :) It came out in 1983 IIRC. The Commodore PET models were around in the 70s, though. | so I did everything in machine code inside Basic DATA statements | ;-)). I can't remember how many hundreds of hours I must've spent typing in program listings from Ahoy! magazine, only to have the damn thing not run because I mistyped a number in one of the DATA statements. Yeah, those were the days...:) 169-is-decimal-for-LDA-ly y'rs, Cliff -- Cliff Crawford http://www.people.cornell.edu/pages/cjc26/ "huh? Are you all there? You missing some key parts up there? Becoming a English major or an minor? Do you need a annual report? Are you slow today, eh? Did someone sever you parietal lobe?" - Mark From amk at mira.erols.com Wed Feb 21 04:11:10 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 21 Feb 2001 03:11:10 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96p5mu$3eq$1@gaia.intranet.cdegroot.com> <96pakl$4fq$1@gaia.intranet.cdegroot.com> Message-ID: On Wed, 21 Feb 2001 02:56:54 GMT, Cliff Crawford wrote: >169-is-decimal-for-LDA-ly y'rs, Cliff 20 D2 FF was JSR $FFD2, which was the machine's printing routine. Yup, been there, done that. I really regret throwing out all my magazines from that era; many of the games would be fun to implement as Python scripts these days. (Resolute CBM techies may be interested in the online Transactor archive at http://www.csbruce.com/pub/transactor/ . Transactor was a Canadian CBM magazine that was ferociously technical. Regret throwing *those* out, too. ) --amk From sheila at spamcop.net Sun Feb 18 21:31:06 2001 From: sheila at spamcop.net (Sheila King) Date: Sun, 18 Feb 2001 20:31:06 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96p5mu$3eq$1@gaia.intranet.cdegroot.com> Message-ID: <76c09t8omgga576dlsmnaapmqd8is3mjlt@4ax.com> I realize that you were writing this, all tongue in cheek, but a newbie who asked the original question, might not pick up on that. The next thing you know, he will be asking, "What are registers?" and wondering why he should know how many a machine has. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ On Sun, 18 Feb 2001 14:13:58 -0500, Roy Smith wrote in comp.lang.python in article : :Actually, the problem with C is that it hides too much of the computer :behind all that code. I spent a few years writing C on alphas, and never :even found out how many registers the danged thing had. If you really want :to find out what the hardware is all about, learn assembler, which is :perilously close to handing a soldering iron to a software guy. : :Another alternative would be to learn lisp. It may not get you a better :job, but will give you the ability to write a better python major mode for :emacs :-) : :I don't suppose I could interest you in fortran? From bowman at montana.com Sun Feb 18 22:39:06 2001 From: bowman at montana.com (bowman) Date: Sun, 18 Feb 2001 14:39:06 -0700 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96p5mu$3eq$1@gaia.intranet.cdegroot.com> <76c09t8omgga576dlsmnaapmqd8is3mjlt@4ax.com> Message-ID: Sheila King wrote in message news:76c09t8omgga576dlsmnaapmqd8is3mjlt at 4ax.com... > I realize that you were writing this, all tongue in cheek, but a newbie who > asked the original question, might not pick up on that. The next thing you > know, he will be asking, "What are registers?" and wondering why he should > know how many a machine has. I recently exposed a coworker to the joys of 8051 programming. It gets even better when the newbie realizes not only does he have to be familiar with the registers, he also needs to know each bit in every SFR does, as well as knowing which SFRs are actually implemented in that particular chip. Or even better, i threw together an AVR disassembler in Python last month -- one has to get intimate with what each bit in the word means. From scarblac at pino.selwerd.nl Mon Feb 19 10:46:45 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 19 Feb 2001 09:46:45 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96p5mu$3eq$1@gaia.intranet.cdegroot.com> <76c09t8omgga576dlsmnaapmqd8is3mjlt@4ax.com> Message-ID: Sheila King wrote in comp.lang.python: > I realize that you were writing this, all tongue in cheek, but a newbie who > asked the original question, might not pick up on that. The next thing you > know, he will be asking, "What are registers?" and wondering why he should > know how many a machine has. Heck, next thing he might even learn something! I tell you, these assembler guys are dangerous. -- Remco Gerlich From cobrien at Radix.Net Mon Feb 19 00:30:45 2001 From: cobrien at Radix.Net (Cary O'Brien) Date: 18 Feb 2001 18:30:45 -0500 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96p5mu$3eq$1@gaia.intranet.cdegroot.com> Message-ID: <96plv5$gqg$1@saltmine.radix.net> In article , Roy Smith wrote: >cg at cdegroot.com wrote: >> I'd advise C as a second language because it forces you to deal with the >> computer behind all that code, which tends to give you a good >> perspective for other language. > >Actually, the problem with C is that it hides too much of the computer >behind all that code. I spent a few years writing C on alphas, and never >even found out how many registers the danged thing had. If you really want >to find out what the hardware is all about, learn assembler, which is >perilously close to handing a soldering iron to a software guy. > Your problem is that you C compiler was too good. I learned C and 68000 assembly at the same time with a stupid C compiler. Stupid meaning after a while we knew exactly what the C compiler would do. Often (in the days of vt220 terminals) two of us would work together debugging, one single-stepping through assembly, and one reading the C code and keeping in sync. If you said register you meant register. Plus if you did you loops just right you could get the 68010 cpu to go into wicked-fast-loop-mode. >Another alternative would be to learn lisp. It may not get you a better >job, but will give you the ability to write a better python major mode for >emacs :-) > Prolog is kinda different. Plus I like the SQL suggestion. Go buy Bruce's PostgreSQL book and go to town. -- cary >I don't suppose I could interest you in fortran? From roy at panix.com Mon Feb 19 01:04:24 2001 From: roy at panix.com (Roy Smith) Date: Sun, 18 Feb 2001 19:04:24 -0500 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96p5mu$3eq$1@gaia.intranet.cdegroot.com> <96plv5$gqg$1@saltmine.radix.net> Message-ID: cobrien at Radix.Net (Cary O'Brien) wrote: > Your problem is that you C compiler was too good. I learned C and > 68000 assembly at the same time with a stupid C compiler. Actually, I learned C and pdp-11 assembler at the same time :-) From garry at sage.att.com Tue Feb 20 17:15:16 2001 From: garry at sage.att.com (Garry Hodgson) Date: Tue, 20 Feb 2001 16:15:16 GMT Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96p5mu$3eq$1@gaia.intranet.cdegroot.com> <96plv5$gqg$1@saltmine.radix.net> Message-ID: <3A929814.825AA36D@sage.att.com> Roy Smith wrote: > > cobrien at Radix.Net (Cary O'Brien) wrote: > > Your problem is that you C compiler was too good. I learned C and > > 68000 assembly at the same time with a stupid C compiler. > > Actually, I learned C and pdp-11 assembler at the same time :-) i used to bristle when a colleague of mine insisted that c *was* assembly language. years later, i realized he was correct. c++ is a rather powerful macro-assembler. -- 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 aahz at panix.com Tue Feb 20 18:20:32 2001 From: aahz at panix.com (Aahz Maruch) Date: 20 Feb 2001 09:20:32 -0800 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96plv5$gqg$1@saltmine.radix.net> <3A929814.825AA36D@sage.att.com> Message-ID: <96u910$ld5$1@panix6.panix.com> In article <3A929814.825AA36D at sage.att.com>, Garry Hodgson wrote: >Roy Smith wrote: >> cobrien at Radix.Net (Cary O'Brien) wrote: >>> >>> Your problem is that you C compiler was too good. I learned C and >>> 68000 assembly at the same time with a stupid C compiler. >> >> Actually, I learned C and pdp-11 assembler at the same time :-) > >i used to bristle when a colleague of mine insisted that >c *was* assembly language. years later, i realized he was >correct. c++ is a rather powerful macro-assembler. More precisely, C is a cross-platform assembley language. It's not perfectly cross-platform, by any means, but it's pretty damn close. Consider Python, for example.... -- --- 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 The problem with an ever-changing .sig is that you have to keep changing it From embed at geocities.com Mon Feb 19 22:58:31 2001 From: embed at geocities.com (Warren Postma) Date: Mon, 19 Feb 2001 16:58:31 -0500 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> Message-ID: <2Hgk6.109$TW.1264@tor-nn1.netcom.ca> "Jim Eaton" wrote in message news:3A8F81BC.108488CA at pop3.qwestinternet.net... > I am learning Python as a first language, and I have been wondering what > is a good language to learn after Python? Delphi (aka ObjectPascal). Compared to Delphi and Python, everything else just plain sucks. :-) Opinionately-yrs, Warren From dsh8290 at rit.edu Wed Feb 21 05:05:06 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 20 Feb 2001 23:05:06 -0500 Subject: What to do after Python? In-Reply-To: <3A8F81BC.108488CA@pop3.qwestinternet.net>; from eatonalive%qwestinternet.net@pop3.qwestinternet.net on Sun, Feb 18, 2001 at 08:00:11AM +0000 References: <3A8F81BC.108488CA@pop3.qwestinternet.net> Message-ID: <20010220230506.B23613@harmony.cs.rit.edu> On Sun, Feb 18, 2001 at 08:00:11AM +0000, Jim Eaton wrote: | I am learning Python as a first language, and I have been wondering what | is a good language to learn after Python? I'm thinking of either going | into C or Java but I'm not sure which one because I've heard many | arguments either way. Will going into Java first be any detriment to | learning C later? Any suggestions would be greatly appreciated. How do you use python? As an OO language (class) or a procedural language (def without class)? C is not naturally OO, Java forces everything to be inside a class. Java will ease you into curly braces, semicolons, and static type-checking while still maintaining automatic memory management. It is possible to write OO code in C (see GTK+/GNOME for an example), but it takes a lot more work. C is also less forgiving allowing you to stomp on memory (and leak it) however it pleases you. Another thing to consider, Java will print a traceback if an exception goes uncaught. C will simply dump a core file if you do something _utterly_ bad (SEGV, Bus Error, Divide-by-zero). If you simply overrun your array bounds, C will SEGV/Bus Error only if you happen to be lucky. More likely than not, it will happily overwrite whatever happened to be there. C will be more useful to you if you are interested in systems level programming. Both C and Java can be used to extend python (CPython and Jython respectively). Java is rather similar to C++ except it has garbage collection, array bounds checking, automatic pointer dereferencing, and no standalone functions (like C). If you want to learn C++, I would recommend learning Java first since it is more forgiving, and informative when you do something bad (at runtime). Other people have mentioned other languages that are interesting and useful to better understand language design, etc, but I haven't seen used in industry much. If you want a pure OO language with a different approach to access modifiers and generics, try Eiffel. I think those are 2 things Eiffel did very well (and C++/Java do very poorly, it is irrelevant in Python). HTH, -D From cborn at swbell.net Sun Feb 18 09:10:33 2001 From: cborn at swbell.net (cborn at swbell.net) Date: Sun, 18 Feb 2001 08:10:33 -0000 Subject: Using win32Com with Internet Explorer Message-ID: <96o01p+ahvv@eGroups.com> I am fairly new to Python and Com programming so hopefully this will be simple. Here is a script I have written which attempts to extract links from a webpage. I have used makepy to generate Python IE support object (Msie ActiveX control Module 1.0). import win32com.client # Get the browser object ie = win32com.client.Dispatch("InternetExplorer.Application") # open a page ie.Navigate("http://www.python.org") i = 0 # Get links from IE's Document Object for x in ie.Document.links: #Print links print ie.Document.links(i) i = i +1 When I run the script in PythonWin this is what I get: Traceback (most recent call last): File "C:\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript exec codeObject in __main__.__dict__ File "C:\Python20\CB\test.py", line 12, in ? for x in ie.Document.links: File "C:\Python20\win32com\client\__init__.py", line 340, in __getattr__ return apply(self._ApplyTypes_, args) File "C:\Python20\win32com\client\__init__.py", line 334, in _ApplyTypes_ return self._get_good_object_(apply(self._oleobj_.InvokeTypes, (dispid, 0, wFlags, retType, argTypes) + args), user, resultCLSID) com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147467259), None) However, when I enter the script interactively 1 line at a time it works. I am sure there is some small detail that I am missing. Can anyone help me? Thanks Charles Bornstein cborn at swbell.net From MarkH at ActiveState.com Sun Feb 18 23:52:06 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 18 Feb 2001 22:52:06 GMT Subject: Using win32Com with Internet Explorer References: Message-ID: <3A90513C.3090809@ActiveState.com> cborn at swbell.net wrote: > I am fairly new to Python and Com programming so hopefully > this will be simple. > > Here is a script I have written which attempts to extract > links from a webpage. I have used makepy to generate Python > IE support object (Msie ActiveX control Module 1.0). ... > However, when I enter the script interactively 1 line at a time it > works. I am sure there is some small detail that I am > missing. Can anyone help me? Probably you need to wait for IE to load the page. There was an example of that posted a few days ago here that used events - basically you wait until IE tells you the page is loaded. Mark. -- Nominate Your Favorite Programmers for the Perl and Python Active Awards! http://www.ActiveState.com/Awards/ From fuess at att.net Mon Feb 19 16:51:27 2001 From: fuess at att.net (David Fuess) Date: Mon, 19 Feb 2001 15:51:27 GMT Subject: Using win32Com with Internet Explorer References: <3A90513C.3090809@ActiveState.com> Message-ID: <42g29ts8rmaepg5gfqovvi07mo468mfb50@4ax.com> Pardon my directness, but isn't it rather foolish to go messing around with IE and COM when Python provides libraries for this purpose. I've implemented many crawlers using urllib, httplib, and htmllib to fetch, parse, and follow URL threads. Dave On Sun, 18 Feb 2001 22:52:06 GMT, Mark Hammond wrote: >cborn at swbell.net wrote: > >> I am fairly new to Python and Com programming so hopefully >> this will be simple. >> >> Here is a script I have written which attempts to extract >> links from a webpage. I have used makepy to generate Python >> IE support object (Msie ActiveX control Module 1.0). > >... > >> However, when I enter the script interactively 1 line at a time it >> works. I am sure there is some small detail that I am >> missing. Can anyone help me? > >Probably you need to wait for IE to load the page. There was an example of that posted a few days ago here that used events - basically you wait until IE tells you the page is loaded. > >Mark. From mbel44 at dial.pipex.net Mon Feb 19 19:31:05 2001 From: mbel44 at dial.pipex.net (Toby Dickenson) Date: Mon, 19 Feb 2001 18:31:05 +0000 Subject: Using win32Com with Internet Explorer References: <3A90513C.3090809@ActiveState.com> <42g29ts8rmaepg5gfqovvi07mo468mfb50@4ax.com> Message-ID: <5hp29toe6qi2sijbofa25g5e883bmr8983@4ax.com> David Fuess wrote: >Pardon my directness, but isn't it rather foolish to go messing around >with IE and COM when Python provides libraries for this purpose. I've >implemented many crawlers using urllib, httplib, and htmllib to fetch, >parse, and follow URL threads. For many cases the IE-based code is better. For example, it uses IE's proxy configuration and local cache. If you need to redistribute a script to someone else, then a working IE configuration is probably something you can rely on. Toby Dickenson tdickenson at geminidataloggers.com From fuess at att.net Wed Feb 21 05:25:39 2001 From: fuess at att.net (David Fuess) Date: Wed, 21 Feb 2001 04:25:39 GMT Subject: Using win32Com with Internet Explorer References: <3A90513C.3090809@ActiveState.com> <42g29ts8rmaepg5gfqovvi07mo468mfb50@4ax.com> <5hp29toe6qi2sijbofa25g5e883bmr8983@4ax.com> Message-ID: Now trhat I've had a day to think about it, I must respectfully disagree. I think the one, and only, thing you can count on is the Pyrhon libraries. The urllib has a FancyOpener that understands proxies and is simple and stable. IE is neither simple nor stable particularly as you never know what version will be installed on the target machine. Further, httplib and htmllib give you complete control over the decoding of the web pages. I use the same code on Windows, UNIX, and Macintosh systems. Neither UNIX nor the Mac have IE, yet all were capable of retrieving and decoding web pages with no changes in the code. If you write in COM you are restricted to Windows platforms only. Dave On Mon, 19 Feb 2001 18:31:05 +0000, Toby Dickenson wrote: >David Fuess wrote: > >>Pardon my directness, but isn't it rather foolish to go messing around >>with IE and COM when Python provides libraries for this purpose. I've >>implemented many crawlers using urllib, httplib, and htmllib to fetch, >>parse, and follow URL threads. > >For many cases the IE-based code is better. For example, it uses IE's >proxy configuration and local cache. > >If you need to redistribute a script to someone else, then a working >IE configuration is probably something you can rely on. > >Toby Dickenson >tdickenson at geminidataloggers.com From fredrik at pythonware.com Wed Feb 21 07:54:26 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Feb 2001 06:54:26 GMT Subject: Using win32Com with Internet Explorer References: <3A90513C.3090809@ActiveState.com> <42g29ts8rmaepg5gfqovvi07mo468mfb50@4ax.com> <5hp29toe6qi2sijbofa25g5e883bmr8983@4ax.com> Message-ID: Toby Dickenson wrote: > For many cases the IE-based code is better. For example, it uses IE's > proxy configuration so does Python Cheers /F From mbel44 at dial.pipex.net Wed Feb 21 14:09:43 2001 From: mbel44 at dial.pipex.net (Toby Dickenson) Date: Wed, 21 Feb 2001 13:09:43 +0000 Subject: Using win32Com with Internet Explorer References: <3A90513C.3090809@ActiveState.com> <42g29ts8rmaepg5gfqovvi07mo468mfb50@4ax.com> <5hp29toe6qi2sijbofa25g5e883bmr8983@4ax.com> Message-ID: "Fredrik Lundh" wrote: >Toby Dickenson wrote: >> For many cases the IE-based code is better. For example, it uses IE's >> proxy configuration > >so does Python Yes, it does make a good effort (thanks Mark!) However, many proxy configurations are implemented using a javascript function that computes the proxy configuration. On Wed, 21 Feb 2001 04:25:39 GMT, David Fuess wrote: >I use the same code on Windows, UNIX, and Macintosh systems. Neither >UNIX nor the Mac have IE, yet all were capable of retrieving and >decoding web pages with no changes in the code. Im pretty sure it wont work on my current machine, without manual proxy configuration. >If you write in COM >you are restricted to Windows platforms only. Yes, it depends on your requirements. I didnt intent to suggest that IE/COM is always superior to httplib. My current http client project uses COM/IE if it can, but falls back to httplib. Both modes of operation have been necessary at some time. From fredrik at pythonware.com Wed Feb 21 19:06:32 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Feb 2001 18:06:32 GMT Subject: Using win32Com with Internet Explorer References: <3A90513C.3090809@ActiveState.com> <42g29ts8rmaepg5gfqovvi07mo468mfb50@4ax.com> <5hp29toe6qi2sijbofa25g5e883bmr8983@4ax.com> Message-ID: Wolfgang Strobl wrote: > >so does Python > > Huh? Python uses IE's proxy configuration? How? by looking in the registry: HKEY_CURRENT_USER\Software\Microsoft\Windows\ CurrentVersion\Internet Settings\ProxyEnable, ProxyServer Cheers /F From 1126-810 at online.de Sun Feb 18 10:18:08 2001 From: 1126-810 at online.de (Stefan Witzgall) Date: Sun, 18 Feb 2001 10:18:08 +0100 Subject: play_animals and MacPython Message-ID: <1126-810-F3D9B6.10180818022001@news.online.de> Hello, I tried to run the sample program "play_animals" found in "Python for the unexperienced". Now I get an error "unslicecable object str"... Ok, str is None, therefore I can't get some part of it. Has anyone run this on his machine with python, is this a MacPython specific prob, how to get around? Thank you for any hints. Bye, Stefan From c941520 at alinga.newcastle.edu.au Sun Feb 18 11:30:22 2001 From: c941520 at alinga.newcastle.edu.au (Ben de Luca) Date: Sun, 18 Feb 2001 21:30:22 +1100 Subject: file access Message-ID: <3a8e53e2$0$25475$7f31c96c@news01.syd.optusnet.com.au> i am building a database in python its quite small only a few hundred entries? i gues dictionaries are the best way to store it in memory when i write the data to a file whats the best way? I guess there is no way to sumb the dictonaries strait to disk? i will have to parse it? From fredrik at pythonware.com Sat Feb 17 12:00:55 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 17 Feb 2001 11:00:55 GMT Subject: file access References: <3a8e53e2$0$25475$7f31c96c@news01.syd.optusnet.com.au> Message-ID: Ben de Luca wrote: > when i write the data to a file whats the best way? I guess there is no way > to sumb the dictonaries strait to disk? i will have to parse it? http://www.python.org/doc/current/lib/module-pickle.html http://www.python.org/doc/current/lib/module-marshal.html Cheers /F From ruediger.maehl at dzsh.de Tue Feb 20 14:32:02 2001 From: ruediger.maehl at dzsh.de (Ruediger Maehl) Date: Tue, 20 Feb 2001 14:32:02 +0100 Subject: file access References: <3a8e53e2$0$25475$7f31c96c@news01.syd.optusnet.com.au> Message-ID: Ben de Luca schrieb in Nachricht <3a8e53e2$0$25475$7f31c96c at news01.syd.optusnet.com.au>... >when i write the data to a file whats the best way? I guess there is no way >to sumb the dictonaries strait to disk? i will have to parse it? > You can write it to disk like: # build a dictionary a = {} a["AAA"] = 1 a["BBB"] = 2 a["CCC"] = 3 # writing out f = open("dict.tmp", "w") f.write(repr(a)) f.close() # reading in f = open("dict.tmp", "r") b = eval(f.read()) f.close() print type(b), b HTH R?diger From parker at gol.com Wed Feb 21 23:40:14 2001 From: parker at gol.com (Ian Parker) Date: Wed, 21 Feb 2001 22:40:14 GMT Subject: file access References: <3a8e53e2$0$25475$7f31c96c@news01.syd.optusnet.com.au> Message-ID: In article <3a8e53e2$0$25475$7f31c96c at news01.syd.optusnet.com.au>, Ben de Luca writes >i am building a database in python its quite small only a few hundred >entries? i gues dictionaries are the best way to store it in memory > >when i write the data to a file whats the best way? I guess there is no way >to sumb the dictonaries strait to disk? i will have to parse it? > > You may be able to use the "anydbm' module which gives you dictionary- like access to files. There's a restriction - the keys must be strings import anydbm # create the database db = anydbm.open("data.db", "c") # set some keys and values db["where"] = "here" db["when"] = "now" # close it - it's now safely on disk db.close() And when you want to access that data again perhaps in another program, in read-only or in read/write, just open the database accordingly and use it like a dictionary db = anydbm.open("data.db", "r") for key in db.keys(): print key,":", db[key] I guess the overhead might be high, but it's so convenient. Regards -- Ian Parker From spamers at must.die Sun Feb 18 12:00:35 2001 From: spamers at must.die (Fernando Rodríguez) Date: Sun, 18 Feb 2001 12:00:35 +0100 Subject: Remove directories from os.listdir output Message-ID: Hi! I need to filter out all the diretories of the list returned by os.listdir(). How can I tell if an entry of that list is a dir or a regular file? O:-) TIA //----------------------------------------------- // Fernando Rodriguez Romero // // frr at mindless dot com //------------------------------------------------ From stephen_purcell at yahoo.com Sun Feb 18 12:39:10 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Sun, 18 Feb 2001 12:39:10 +0100 Subject: Remove directories from os.listdir output In-Reply-To: ; from spamers@must.die on Sun, Feb 18, 2001 at 12:00:35PM +0100 References: Message-ID: <20010218123910.A21374@freedom.puma-ag.com> Fernando Rodr?guez wrote: > Hi! > > I need to filter out all the diretories of the list returned by > os.listdir(). How can I tell if an entry of that list is a dir or a regular > file? O:-) Use os.path.isdir(): >>> import os >>> def listdir_files_only(directory): ... contents = os.listdir(directory) ... return filter(lambda f,d=directory: not os.path.isdir(os.path.join(d,f)), contents) ... >>> listdir_files_only('/tmp') ['python-sHAOTT', 'python-sHASlX', 'python-sHATtS'] -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 fredrik at pythonware.com Sun Feb 18 12:47:27 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 18 Feb 2001 11:47:27 GMT Subject: Remove directories from os.listdir output References: Message-ID: Fernando Rodr?guez wrote: > I need to filter out all the diretories of the list returned by > os.listdir(). How can I tell if an entry of that list is a dir or a regular > file? O:-) os.path.isdir(filename) os.path.isfile(filename) e.g. for file in os.listdir(mydir): fullname = os.path.join(mydir, file) if os.path.isfile(fullname): ... Cheers /F From scarblac at pino.selwerd.nl Sun Feb 18 17:00:56 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 18 Feb 2001 16:00:56 GMT Subject: Remove directories from os.listdir output References: Message-ID: Fernando Rodr?guez wrote in comp.lang.python: > I need to filter out all the diretories of the list returned by > os.listdir(). How can I tell if an entry of that list is a dir or a regular > file? O:-) With os.path.isdir(file). -- Remco Gerlich From fabrice.n at home.com Sun Feb 18 14:01:58 2001 From: fabrice.n at home.com (shaka) Date: Sun, 18 Feb 2001 13:01:58 GMT Subject: 3D animation Message-ID: Ya, I am planning to write a program to present a project at school. I need a language that will allow me to do 3D animations and other animation. And I am struggling between writting the program in java or using python. Can someone help me? If python is the ultimate choice then can you give me some instructions on what libraries I should use, because I am quite a beginner here> Thanks. Shaka. Z From aleaxit at yahoo.com Sun Feb 18 14:55:39 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 18 Feb 2001 14:55:39 +0100 Subject: 3D animation References: Message-ID: <96ok7l017uq@news2.newsguy.com> "shaka" wrote in message news:aJPj6.171612$KP3.43764577 at news3.rdc1.on.home.com... > > Ya, I am planning to write a program to present a project at school. I need > a language that will allow me to do 3D animations and other animation. And > I am struggling between writting the program in java or using python. > Can someone help me? If python is the ultimate choice then can you give me > some instructions on what libraries I should use, because I am quite a > beginner here> Start at http://www.alice.org/ -- a totally free 3D animation framework, with authoring tool, scriptable in either Python or Java, originally by University of Virginia and now by Carnegie-Mellon University. This will put Python and Java on a totally even playing field, and I think you'll find that Python is preferable for this use -- but if you already know both languages you'll be able to try both and make up your own mind!-) Alex From rtexier at elikya.com Mon Feb 19 11:24:33 2001 From: rtexier at elikya.com (Romuald Texier) Date: Mon, 19 Feb 2001 10:24:33 +0000 Subject: 3D animation References: <96ok7l017uq@news2.newsguy.com> Message-ID: <96qoop$6qb$1@news.irisa.fr> Alex Martelli wrote: > Start at http://www.alice.org/ -- a totally free 3D animation framework, It is Microsoft only, so if Shaka choose Java of Python to be portable, it is definitively not the good choice. Regards, -- Romuald Texier From bryan at eevolved.com Sun Feb 18 15:32:40 2001 From: bryan at eevolved.com (Bryan Mongeau) Date: Sun, 18 Feb 2001 14:32:40 GMT Subject: 3D animation References: Message-ID: shaka wrote: > > > Ya, I am planning to write a program to present a project at school. I > need > a language that will allow me to do 3D animations and other animation. > And I am struggling between writting the program in java or using python. > Can someone help me? If python is the ultimate choice then can you give > me some instructions on what libraries I should use, because I am quite a > beginner here> > > Thanks. > > Shaka. Z > > Honestly couldn't tell you if Java has anything better for this purpose but I can tell you python has what you need. First you need a real GUI toolkit. Try: http://sourceforge.net/projects/foxgui/ Make sure to compile with OpenGL support. with the python bindings here: http://sourceforge.net/projects/fxpy/ Grab the openGL bindings: http://sourceforge.net/projects/pyopengl/ Now you should be set to look at the funky GL tests that come in the FXPy bindings. This should give you a great example of what you can do easily in python. Good luck. -- <==================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. http://www.eevolved.com <==================================> "This is one of the hardest lessons for humans to learn. We cannot admit that things might be neither good nor evil, neither cruel nor kind, but simply callous - indifferent to all suffering, lacking all purpose." -- Richard Dawkins From clee at gnwy100.wuh.wustl.edu Sun Feb 18 16:52:10 2001 From: clee at gnwy100.wuh.wustl.edu (Christopher Lee) Date: 18 Feb 2001 09:52:10 -0600 Subject: 3D animation References: Message-ID: <7uvgq8at05.fsf@gnwy100.wuh.wustl.edu> >>>>> "shaka" == shaka writes: shaka> Ya, I am planning to write a program to present a project at shaka> school. I need a language that will allow me to do 3D shaka> animations and other animation. I would recommend: PyOpenGL: for OpenGL scripting requires that you know or are willing to learn OpenGL. http://pyopengl.sourceforge.net/ VPython: for easy visualization of physical systems. Very cool. Looks good for beginners. http://virtualphoton.pc.cc.cmu.edu/projects/visual/ (link seems to not be working at the moment. check google) You might also want to look at pygame (http://pygame.seul.org) for producing multimedia animations. For really heavy duty visualization, there's also the visualization toolkit (VTK at http://www.kitware.com/vtk.html) and IBM's Open Data Explorer (OpenDx at http://www.opendx.org), both of which have python bindings. -christopher From phlip_cpp at my-deja.com Sun Feb 18 16:55:56 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 18 Feb 2001 15:55:56 GMT Subject: 3D animation References: Message-ID: <96orac$brv@dispatch.concentric.net> Proclaimed shaka from the mountaintops: > Ya, I am planning to write a program to present a project at school. I > need > a language that will allow me to do 3D animations and other animation. > And I am struggling between writting the program in java or using python. > Can someone help me? If python is the ultimate choice then can you give > me some instructions on what libraries I should use, because I am quite a > beginner here> Lose your self in the universe of Blender, and you'l never need non-virtual reality again: http://www.blender.nl But be warned: The system's top level is all scripted in this dumb trendy language whose name escapes me at the moment. -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- "Probably one of the toughest times in anyone's life is when you have to kill someone you love because they'r the Devil" --Emo Phillips -- From dave at dave.org.uk Sun Feb 18 14:16:49 2001 From: dave at dave.org.uk (Dave Cross) Date: Sun, 18 Feb 2001 13:16:49 +0000 Subject: Weird Language Features Message-ID: [Please watch the replies on this message as it's heavily cross-posted] I'm doing some comparisons on programming language features and I'd be very interested to know how you would handle the following scenarios in your programming language of choice. 1/ The programmer calls a function that doesn't actually exist within the application (or libraries). Is the a feature whereby the programmer can create a "catch-all" function which is called in cases like these? Can this function examine the list of existing functions and call the most appropriate one? Or create a new function on the fly and install it into the application? 2/ Can ou filter the input source code before compilation (or interpretation) in some way so that language keywords could be changed for other strings? Imagine you wanted to allow someone to program your language of choice in, say, French. How would you go about translating French keywords into ones that the compiler (or interpreter) could understand. What if the translation wasn't one-to-one or fixed? Could you put enough intelligence into the translator so that it could handle certain strings differently depending on where they appeared in the source code? If you're wondering why I'm inventing these bizarre scenarios, it's for a paper I'm writing for this year's Perl Conference. Perl does have these features (see the AUTOLOAD function and source filters) and I'm interested in seeing how widespread they are in other languages. Of course, if you'd like to tell me just why you consider it's a good thing that your language of choice doesn't have these features, then I'd be only too happy to hear that too. I'd just like to make it clear that I'm not interested in getting into "my language is better than your language" types of flamewars. I'm certainly not trying to argue that Perl is better than other languages for having these features. Thanks for your time. Dave... -- SMS: sms at dave.org.uk From nem00u at cs.nott.ac.uk Sun Feb 18 17:58:04 2001 From: nem00u at cs.nott.ac.uk (Neil Madden) Date: Sun, 18 Feb 2001 16:58:04 +0000 Subject: Weird Language Features References: Message-ID: <3A8FFF1C.1FFEADE7@cs.nott.ac.uk> Dave Cross wrote: > > [Please watch the replies on this message as it's heavily > cross-posted] > > I'm doing some comparisons on programming language features and I'd be > very interested to know how you would handle the following scenarios > in your programming language of choice. > > 1/ The programmer calls a function that doesn't actually exist within > the application (or libraries). Is the a feature whereby the > programmer can create a "catch-all" function which is called in cases > like these? Can this function examine the list of existing functions > and call the most appropriate one? Or create a new function on the fly > and install it into the application? Tcl has the "unknown" procedure that is called when the interpreter doesn't recognize a command. From the Tcl help pages: "If the Tcl interpreter encounters a command name for which there is not a defined command, then Tcl checks for the existence of a command named unknown. If there is no such command, then the interpreter returns an error. If the unknown command exists, then it is invoked with arguments consisting of the fully-substituted name and arguments for the original non-existent command. The unknown command typically does things like searching through library directories for a command procedure with the name cmdName, or expanding abbreviated command names to full-length, or automatically executing unknown commands as sub-processes. In some cases (such as expanding abbreviations) unknown will change the original command slightly and then (re-)execute it. The result of the unknown command is used as the result for the original non-existent command." () It is left up to the application programmer to implement this, so you could have an unknown procedure that does the things you mention above. See also: ) for some examples. > > 2/ Can ou filter the input source code before compilation (or > interpretation) in some way so that language keywords could be changed > for other strings? Imagine you wanted to allow someone to program your > language of choice in, say, French. How would you go about translating > French keywords into ones that the compiler (or interpreter) could > understand. What if the translation wasn't one-to-one or fixed? Could > you put enough intelligence into the translator so that it could > handle certain strings differently depending on where they appeared in > the source code? There are no reserved words in Tcl, so all keywords can be overwritten or renamed. Using the unknown command above, you can put as much intelligence as you want into interpreting a command. Although, this seems like a fairly dangerous thing to do, as any packages or extensions you used would have to know that the keywords had all been changed! But once again, you could allow the [unknown] handler to map commands onto their new names. > > If you're wondering why I'm inventing these bizarre scenarios, it's > for a paper I'm writing for this year's Perl Conference. Perl does > have these features (see the AUTOLOAD function and source filters) and > I'm interested in seeing how widespread they are in other languages. > > Of course, if you'd like to tell me just why you consider it's a good > thing that your language of choice doesn't have these features, then > I'd be only too happy to hear that too. > > I'd just like to make it clear that I'm not interested in getting into > "my language is better than your language" types of flamewars. I'm > certainly not trying to argue that Perl is better than other languages > for having these features. > > Thanks for your time. > > Dave... > > -- > SMS: sms at dave.org.uk -- -------------------------------------------------------------- Neil Madden. neil at tallniel.co.uk nem00u at cs.nott.ac.uk http://www.tallniel.co.uk http://www.cs.nott.ac.uk/~nem00u -------------------------------------------------------------- From nem00u at cs.nott.ac.uk Mon Feb 19 00:29:27 2001 From: nem00u at cs.nott.ac.uk (Neil Madden) Date: Sun, 18 Feb 2001 23:29:27 +0000 Subject: Weird Language Features References: <3A8FFF1C.1FFEADE7@cs.nott.ac.uk> Message-ID: <3A905AD7.152F6626@cs.nott.ac.uk> BTW. I think that the problems you have posed are very much "scripting" solutions rather than system programming solutions. In other words, scripting languages (perl, python, tcl) are likely to be able to solve these fairly easily, whereas compiled languages are going to find it harder. If you posted scenarios involving intensive maths computation the results might be the other way around :-). If you are writing a paper, compare like to like... Neil Madden wrote: > > Dave Cross wrote: > > > > [Please watch the replies on this message as it's heavily > > cross-posted] > > > > I'm doing some comparisons on programming language features and I'd be > > very interested to know how you would handle the following scenarios > > in your programming language of choice. > > > > 1/ The programmer calls a function that doesn't actually exist within > > the application (or libraries). Is the a feature whereby the > > programmer can create a "catch-all" function which is called in cases > > like these? Can this function examine the list of existing functions > > and call the most appropriate one? Or create a new function on the fly > > and install it into the application? > > Tcl has the "unknown" procedure that is called when the interpreter > doesn't recognize a command. From the Tcl help pages: > > "If the Tcl interpreter encounters a command name for which there is not > a defined command, then Tcl checks for the existence of a command named > unknown. If there is no such command, then the interpreter returns an > error. If the unknown command exists, then it is invoked with arguments > consisting of the fully-substituted name and arguments for the original > non-existent command. The unknown command typically does things like > searching through library directories for a command procedure with the > name cmdName, or expanding abbreviated command names to full-length, or > automatically executing unknown commands as sub-processes. In some cases > (such as expanding abbreviations) unknown will change the original > command slightly and then (re-)execute it. The result of the unknown > command is used as the result for the original non-existent command." > () > > It is left up to the application programmer to implement this, so you > could have an unknown procedure that does the things you mention above. > > See also: ) for some > examples. > > > > > 2/ Can ou filter the input source code before compilation (or > > interpretation) in some way so that language keywords could be changed > > for other strings? Imagine you wanted to allow someone to program your > > language of choice in, say, French. How would you go about translating > > French keywords into ones that the compiler (or interpreter) could > > understand. What if the translation wasn't one-to-one or fixed? Could > > you put enough intelligence into the translator so that it could > > handle certain strings differently depending on where they appeared in > > the source code? > > There are no reserved words in Tcl, so all keywords can be overwritten > or renamed. Using the unknown command above, you can put as much > intelligence as you want into interpreting a command. Although, this > seems like a fairly dangerous thing to do, as any packages or extensions > you used would have to know that the keywords had all been changed! But > once again, you could allow the [unknown] handler to map commands onto > their new names. > > > > > If you're wondering why I'm inventing these bizarre scenarios, it's > > for a paper I'm writing for this year's Perl Conference. Perl does > > have these features (see the AUTOLOAD function and source filters) and > > I'm interested in seeing how widespread they are in other languages. > > > > Of course, if you'd like to tell me just why you consider it's a good > > thing that your language of choice doesn't have these features, then > > I'd be only too happy to hear that too. > > > > I'd just like to make it clear that I'm not interested in getting into > > "my language is better than your language" types of flamewars. I'm > > certainly not trying to argue that Perl is better than other languages > > for having these features. > > > > Thanks for your time. > > > > Dave... > > > > -- > > SMS: sms at dave.org.uk > > -- > -------------------------------------------------------------- > Neil Madden. > neil at tallniel.co.uk nem00u at cs.nott.ac.uk > http://www.tallniel.co.uk http://www.cs.nott.ac.uk/~nem00u > -------------------------------------------------------------- -- -------------------------------------------------------------- Neil Madden. neil at tallniel.co.uk nem00u at cs.nott.ac.uk http://www.tallniel.co.uk http://www.cs.nott.ac.uk/~nem00u -------------------------------------------------------------- From fellowsd at cs.man.ac.uk Mon Feb 19 11:49:03 2001 From: fellowsd at cs.man.ac.uk (Donal K. Fellows) Date: Mon, 19 Feb 2001 10:49:03 +0000 Subject: Weird Language Features References: <3A8FFF1C.1FFEADE7@cs.nott.ac.uk> Message-ID: <3A90FA1F.BE0B7277@cs.man.ac.uk> Neil Madden wrote: > Dave Cross wrote: >> 2/ Can ou filter the input source code before compilation (or >> interpretation) in some way so that language keywords could be changed >> for other strings? Imagine you wanted to allow someone to program your >> language of choice in, say, French. How would you go about translating >> French keywords into ones that the compiler (or interpreter) could >> understand. What if the translation wasn't one-to-one or fixed? Could >> you put enough intelligence into the translator so that it could >> handle certain strings differently depending on where they appeared in >> the source code? > > There are no reserved words in Tcl, so all keywords can be overwritten > or renamed. Using the unknown command above, you can put as much > intelligence as you want into interpreting a command. Although, this > seems like a fairly dangerous thing to do, as any packages or extensions > you used would have to know that the keywords had all been changed! But > once again, you could allow the [unknown] handler to map commands onto > their new names. It'd be better to rewrite the [source] command as well, since then you could apply the transformations at code-loading time as well, and if you were doing something as static as supporting a second language for the words of the program, then (as long as the literal strings used for the two languages were distinct) you could easily use interpreter aliasing instead. Donal. -- Donal K. Fellows http://www.cs.man.ac.uk/~fellowsd/ fellowsd at cs.man.ac.uk -- If somebody in a suit or a uniform can sit you down and have you believe every word he says, you've just surrendered your license to be a thinking human being and traded it in for a zombie suit. -- mhoye at prince.carleton.ca From Robert_Hand at notspammehotmail.com Sun Feb 18 18:09:20 2001 From: Robert_Hand at notspammehotmail.com (Robert Hand) Date: Sun, 18 Feb 2001 09:09:20 -0800 Subject: Weird Language Features References: Message-ID: <3iTj6.1813$E41.169931@news.uswest.net> > 1/ The programmer calls a function that doesn't actually exist within > the application (or libraries). Is the a feature whereby the > programmer can create a "catch-all" function which is called in cases > like these? Can this function examine the list of existing functions > and call the most appropriate one? Or create a new function on the fly > and install it into the application? If you call a function that doesn't exist, I don't think it will compile. To examine an object and it's functions I think you use the reflection library (haven't messed with it myself) > > 2/ Can ou filter the input source code before compilation (or > interpretation) in some way so that language keywords could be changed > for other strings? Imagine you wanted to allow someone to program your > language of choice in, say, French. How would you go about translating > French keywords into ones that the compiler (or interpreter) could > understand. What if the translation wasn't one-to-one or fixed? Could > you put enough intelligence into the translator so that it could > handle certain strings differently depending on where they appeared in > the source code? > This would be an application to replace strings. Probably impossible due to abbreviations and wierd stuff. Unless you want to type in each translation, instead of automating it. Java does have some neat internationalization features for replacing messages, menu options etc. Pretty advanced/ > > If you're wondering why I'm inventing these bizarre scenarios, it's > for a paper I'm writing for this year's Perl Conference. Perl does > have these features (see the AUTOLOAD function and source filters) and > I'm interested in seeing how widespread they are in other languages. > Really? Thats great! If you can do it in perl, you can probably implement it in java. I'm not a perl expert. Is the perl source code translation a function of perl or a separate app? if it's a separate app, handling ascii input, give me a link. > Of course, if you'd like to tell me just why you consider it's a good > thing that your language of choice doesn't have these features, then > I'd be only too happy to hear that too. > I think as far as internationalization goes, java is prety mature. Unfortunately, it's 2000 miles from me to the next non-english speaking nation. No opportunity to pursue it. > I'd just like to make it clear that I'm not interested in getting into > "my language is better than your language" types of flamewars. I'm > certainly not trying to argue that Perl is better than other languages > for having these features. nope. I must start a flame. I am compelled to by satan. Bill Gates is our savior. All hail the great redmond giant! HAIL or be consumed! Oh come on, please hail. Please. I'll give you a free copy of interdev. I'll but your company and give you free coca-cola. Fine then. If you won't praise Bill I'll just go pout until you do.... > SMS: sms at dave.org.uk From dave at dave.org.uk Sun Feb 18 18:24:19 2001 From: dave at dave.org.uk (Dave Cross) Date: Sun, 18 Feb 2001 17:24:19 +0000 Subject: Weird Language Features References: <3iTj6.1813$E41.169931@news.uswest.net> Message-ID: On Sun, 18 Feb 2001 09:09:20 -0800, "Robert Hand" wrote: >> >> If you're wondering why I'm inventing these bizarre scenarios, it's >> for a paper I'm writing for this year's Perl Conference. Perl does >> have these features (see the AUTOLOAD function and source filters) and >> I'm interested in seeing how widespread they are in other languages. >> >Really? Thats great! If you can do it in perl, you can probably implement >it in java. >I'm not a perl expert. Is the perl source code translation a function of >perl or a separate app? >if it's a separate app, handling ascii input, give me a link. It's a separate library that gets to see the source code before it's compiled. For an (admittedly extreme) example of what you can do see: Which discusses a filter allowing you to write Perl programs in Latin! Cheers, Dave... -- SMS: sms at dave.org.uk From zala_ at hotmail.com Sun Feb 18 18:35:00 2001 From: zala_ at hotmail.com (Les F.) Date: Sun, 18 Feb 2001 10:35:00 -0700 Subject: Weird Language Features References: <3iTj6.1813$E41.169931@news.uswest.net> Message-ID: Non-english speaking nations? If you live on the east coast of USA: St Pierre Miglon (France) Quebec (wants to be France) Cuba (Cuba) Florida (wants to be Cuba) Louisianna (displaced, disgruntled, former Acadians) Middle America: Mexico (Mexico) New Mexico (Mexico) Canada (eh) West Coast: Mexico (Mexico) Vancouver (Hong Kong) Les F ;-) Mexico (Mexico) Robert Hand wrote in message news:3iTj6.1813$E41.169931 at news.uswest.net... > > 1/ The programmer calls a function that doesn't actually exist within > > the application (or libraries). Is the a feature whereby the > > programmer can create a "catch-all" function which is called in cases > > like these? Can this function examine the list of existing functions > > and call the most appropriate one? Or create a new function on the fly > > and install it into the application? > > If you call a function that doesn't exist, I don't think it will compile. > To examine > an object and it's functions I think you use the reflection library (haven't > messed with it myself) > > > > > 2/ Can ou filter the input source code before compilation (or > > interpretation) in some way so that language keywords could be changed > > for other strings? Imagine you wanted to allow someone to program your > > language of choice in, say, French. How would you go about translating > > French keywords into ones that the compiler (or interpreter) could > > understand. What if the translation wasn't one-to-one or fixed? Could > > you put enough intelligence into the translator so that it could > > handle certain strings differently depending on where they appeared in > > the source code? > > > This would be an application to replace strings. Probably impossible due to > abbreviations and wierd stuff. > Unless you want to type in each translation, instead of automating it. > Java does have some neat internationalization features for replacing > messages, menu options etc. > Pretty advanced/ > > > > If you're wondering why I'm inventing these bizarre scenarios, it's > > for a paper I'm writing for this year's Perl Conference. Perl does > > have these features (see the AUTOLOAD function and source filters) and > > I'm interested in seeing how widespread they are in other languages. > > > Really? Thats great! If you can do it in perl, you can probably implement > it in java. > I'm not a perl expert. Is the perl source code translation a function of > perl or a separate app? > if it's a separate app, handling ascii input, give me a link. > > > Of course, if you'd like to tell me just why you consider it's a good > > thing that your language of choice doesn't have these features, then > > I'd be only too happy to hear that too. > > > I think as far as internationalization goes, java is prety mature. > Unfortunately, it's > 2000 miles from me to the next non-english speaking nation. No opportunity > to pursue it. > > > > I'd just like to make it clear that I'm not interested in getting into > > "my language is better than your language" types of flamewars. I'm > > certainly not trying to argue that Perl is better than other languages > > for having these features. > nope. I must start a flame. I am compelled to by satan. Bill Gates is our > savior. All hail the great redmond giant! HAIL or be consumed! Oh come on, > please hail. Please. I'll give you a free copy of interdev. I'll but your > company and give you free coca-cola. Fine then. If you won't praise Bill > I'll just go pout until you do.... > > > > SMS: sms at dave.org.uk > > From agold at bga.com Sun Feb 18 19:03:21 2001 From: agold at bga.com (Arthur H. Gold) Date: Sun, 18 Feb 2001 12:03:21 -0600 Subject: Weird Language Features References: <3iTj6.1813$E41.169931@news.uswest.net> Message-ID: <3A900E69.6FCCAD03@bga.com> "Les F." wrote: > > Non-english speaking nations? > If you live on the east coast of USA: > St Pierre Miglon (France) > Quebec (wants to be France) > Cuba (Cuba) > Florida (wants to be Cuba) > Louisianna (displaced, disgruntled, former Acadians) Ey! Y'left out Brooklyn! Fuhgeddaboudit! --ag > Middle America: > Mexico (Mexico) > New Mexico (Mexico) > Canada (eh) > West Coast: > Mexico (Mexico) > Vancouver (Hong Kong) > > Les F ;-) > > Mexico (Mexico) > Robert Hand wrote in message > news:3iTj6.1813$E41.169931 at news.uswest.net... > > > 1/ The programmer calls a function that doesn't actually exist within > > > the application (or libraries). Is the a feature whereby the > > > programmer can create a "catch-all" function which is called in cases > > > like these? Can this function examine the list of existing functions > > > and call the most appropriate one? Or create a new function on the fly > > > and install it into the application? > > > > If you call a function that doesn't exist, I don't think it will compile. > > To examine > > an object and it's functions I think you use the reflection library > (haven't > > messed with it myself) > > > > > > > > 2/ Can ou filter the input source code before compilation (or > > > interpretation) in some way so that language keywords could be changed > > > for other strings? Imagine you wanted to allow someone to program your > > > language of choice in, say, French. How would you go about translating > > > French keywords into ones that the compiler (or interpreter) could > > > understand. What if the translation wasn't one-to-one or fixed? Could > > > you put enough intelligence into the translator so that it could > > > handle certain strings differently depending on where they appeared in > > > the source code? > > > > > This would be an application to replace strings. Probably impossible due > to > > abbreviations and wierd stuff. > > Unless you want to type in each translation, instead of automating it. > > Java does have some neat internationalization features for replacing > > messages, menu options etc. > > Pretty advanced/ > > > > > > If you're wondering why I'm inventing these bizarre scenarios, it's > > > for a paper I'm writing for this year's Perl Conference. Perl does > > > have these features (see the AUTOLOAD function and source filters) and > > > I'm interested in seeing how widespread they are in other languages. > > > > > Really? Thats great! If you can do it in perl, you can probably > implement > > it in java. > > I'm not a perl expert. Is the perl source code translation a function of > > perl or a separate app? > > if it's a separate app, handling ascii input, give me a link. > > > > > Of course, if you'd like to tell me just why you consider it's a good > > > thing that your language of choice doesn't have these features, then > > > I'd be only too happy to hear that too. > > > > > I think as far as internationalization goes, java is prety mature. > > Unfortunately, it's > > 2000 miles from me to the next non-english speaking nation. No > opportunity > > to pursue it. > > > > > > > I'd just like to make it clear that I'm not interested in getting into > > > "my language is better than your language" types of flamewars. I'm > > > certainly not trying to argue that Perl is better than other languages > > > for having these features. > > nope. I must start a flame. I am compelled to by satan. Bill Gates is > our > > savior. All hail the great redmond giant! HAIL or be consumed! Oh come > on, > > please hail. Please. I'll give you a free copy of interdev. I'll but > your > > company and give you free coca-cola. Fine then. If you won't praise Bill > > I'll just go pout until you do.... > > > > > > > SMS: sms at dave.org.uk > > > > -- Artie Gold, Austin, TX (finger the cs.utexas.edu account for more info) mailto:agold at bga.com or mailto:agold at cs.utexas.edu -- Verbing weirds language. From binary at eton.powernet.co.uk Sun Feb 18 18:42:35 2001 From: binary at eton.powernet.co.uk (Richard Heathfield) Date: Sun, 18 Feb 2001 17:42:35 +0000 Subject: Weird Language Features References: Message-ID: <3A90098B.5EBB3993@eton.powernet.co.uk> Dave Cross wrote: > > [Please watch the replies on this message as it's heavily > cross-posted] Noted. > > I'm doing some comparisons on programming language features and I'd be > very interested to know how you would handle the following scenarios > in your programming language of choice. > > 1/ The programmer calls a function that doesn't actually exist within > the application (or libraries). In ISO conforming C, he can't. End of story. > 2/ Can ou filter the input source code before compilation (or > interpretation) in some way so that language keywords could be changed > for other strings? Again in ISO conforming C... #define ALIAS original e.g. #define voiture auto /* :-) */ -- Richard Heathfield "Usenet is a strange place." - Dennis M Ritchie, 29 July 1999. C FAQ: http://www.eskimo.com/~scs/C-faq/top.html K&R answers, C books, etc: http://users.powernet.co.uk/eton From pfaffben at msu.edu Sun Feb 18 18:44:28 2001 From: pfaffben at msu.edu (Ben Pfaff) Date: 18 Feb 2001 12:44:28 -0500 Subject: Weird Language Features References: Message-ID: <874rxrj37n.fsf@pfaffben.user.msu.edu> Dave Cross writes: > I'm doing some comparisons on programming language features and I'd be > very interested to know how you would handle the following scenarios > in your programming language of choice. > > 1/ The programmer calls a function that doesn't actually exist within > the application (or libraries). Undefined behavior in C. > 2/ Can ou filter the input source code before compilation (or > interpretation) in some way so that language keywords could be changed > for other strings? #define keyword replacement Also causes undefined behavior in at least some circumstances. -- "The expression isn't unclear *at all* and only an expert could actually have doubts about it" --Dan Pop From erno-news at erno.iki.fi Sun Feb 18 19:15:47 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 18 Feb 2001 20:15:47 +0200 Subject: Weird Language Features References: Message-ID: In article , Dave Cross writes: | 1/ The programmer calls a function that doesn't actually exist within | the application (or libraries). Is the a feature whereby the | programmer can create a "catch-all" function which is called in cases | like these? Can this function examine the list of existing functions | and call the most appropriate one? Or create a new function on the fly | and install it into the application? python: i can't think of a way to do this for functions, but you can easily do it for methods - __getattr__ is the magic method. see . | 2/ Can you filter the input source code before compilation python does not allow you to do this. | Of course, if you'd like to tell me just why you consider it's a good | thing that your language of choice doesn't have these features, then | I'd be only too happy to hear that too. as far as i'm concerned language features are guilty (of being superfluous) before proven innocent :). -- erno From johann at physics.berkeley.edu Sun Feb 18 21:16:31 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 18 Feb 2001 12:16:31 -0800 Subject: Weird Language Features References: Message-ID: Dave Cross writes: > 1/ The programmer calls a function that doesn't actually exist within > the application (or libraries). It's easy to trap this error in Common Lisp, but it's hard to set up a "general replacement" routine. You can, generally, trap the error for a given block of code, then attempt to guess a replacement function, but I don't think you can then resume the calculation. However, if you're reading in user/scripting code, it's an easy thing to pre-process it, looking for unknown functions, then replace those symbols with your guess. It just has to be a pre-processing step, not a run-time step. i.e. you have to do (eval (process (read-all "file"))), rather than just (load "file"). If the program's not making an error, the package system should be able to handle it. > 2/ Can ou filter the input source code before compilation (or > interpretation) in some way so that language keywords could be changed > for other strings? Pathetically easy in any of the lisp-derivative languages. This is where having a code form that looks like data really shines; you just read the code in, manipulate it at will, then execute it afterwards. Use the same (eval (process (read-all "file"))). > If you're wondering why I'm inventing these bizarre scenarios, it's > for a paper I'm writing for this year's Perl Conference. Have fun. I do suspect that Common Lisp whups Perl in this respect, though. :-) -- Johann Hibschman johann at physics.berkeley.edu From neelk at alum.mit.edu Sun Feb 18 22:15:37 2001 From: neelk at alum.mit.edu (Neelakantan Krishnaswami) Date: 18 Feb 2001 21:15:37 GMT Subject: Weird Language Features References: Message-ID: [Crossposting trimmed] On 18 Feb 2001 12:16:31 -0800, Johann Hibschman wrote: >Dave Cross writes: > >> 1/ The programmer calls a function that doesn't actually exist within >> the application (or libraries). > > It's easy to trap this error in Common Lisp, but it's hard to set up a > "general replacement" routine. You can, generally, trap the error for > a given block of code, then attempt to guess a replacement function, > but I don't think you can then resume the calculation. I'm not a serious CL user, but aren't its exceptions restartable? That would permit you to do this. It would be really nice if Python's exception system supported this. Then I wouldn't have to choose between raising an exception and having my constructor functions behave algebraically. > Have fun. I do suspect that Common Lisp whups Perl in this respect, > though. :-) Yeah. :) Neel From hannah at schlund.de Mon Feb 19 18:01:23 2001 From: hannah at schlund.de (Hannah Schroeter) Date: 19 Feb 2001 18:01:23 +0100 Subject: Weird Language Features References: Message-ID: <96rjh3$9c3$1@c3po.schlund.de> Hello! In article , Neelakantan Krishnaswami wrote: >[...] >I'm not a serious CL user, but aren't its exceptions restartable? That >would permit you to do this. It would be really nice if Python's >exception system supported this. Then I wouldn't have to choose >between raising an exception and having my constructor functions >behave algebraically. No, they aren't. CL differentiates between exceptions (called "conditions"). You can define handlers for them. A handler can either (as the name says) handle the condition, i.e. do something and then non-locally transfer control somewhere using go/return/throw/invoke-restart. (throw has nothing to do with conditions besides that!), decline to handle (just return), then the next most handler is invoked in turn, or defer the decision (signal another condition/resignal the same condition/enter the debugger/...). Separate from that are definitions of restart points (which can be used to handle a condition with invoke-restart). However the normal function call doesn't establish any restarts which can help in continuing after e.g. installing an autoloaded function definition. >[...] Kind regards, Hannah. From elflord at panix.com Sun Feb 18 23:28:52 2001 From: elflord at panix.com (Donovan Rebbechi) Date: 18 Feb 2001 22:28:52 GMT Subject: Weird Language Features References: Message-ID: On Sun, 18 Feb 2001 13:16:49 +0000, Dave Cross wrote: >1/ The programmer calls a function that doesn't actually exist within >the application (or libraries). Is the a feature whereby the >programmer can create a "catch-all" function which is called in cases >like these? Can this function examine the list of existing functions >and call the most appropriate one? Or create a new function on the fly >and install it into the application? Posting this from comp.lang.c++. In C++, the object model itself does not support this. In both C and C++, one uses dynamic loading to get this kind of behaviour. Indeed, interpreters written in C and C++ tend to rely heavily on dynamic loading. To get the kind of functionality you're talking about, one would probably store a function table in a map/tree and one could put a "default" method in there that acts as a catch all. However, typically one uses exceptions to deal with failed requests, the idea being that if a request fails, the caller is in a better position than the library author to work out what to do. >2/ Can ou filter the input source code before compilation (or >interpretation) in some way so that language keywords could be changed >for other strings? Imagine you wanted to allow someone to program your >language of choice in, say, French. How would you go about translating >French keywords into ones that the compiler (or interpreter) could >understand. What if the translation wasn't one-to-one or fixed? Could >you put enough intelligence into the translator so that it could >handle certain strings differently depending on where they appeared in >the source code? One could do this with macros but it's a fairly primitive solution ... > Perl does >have these features (see the AUTOLOAD function and source filters) and >I'm interested in seeing how widespread they are in other languages. ... of course one could always write a preprocessor in perl (-; >Of course, if you'd like to tell me just why you consider it's a good >thing that your language of choice doesn't have these features, then >I'd be only too happy to hear that too. C and C++ are standardised (as opposed to implementation defined) languages, the former is meant to be small, the latter is big enough as it is. Introducing support for this kind of thing in the language (either C or C++) would probably be a mistake IMO. -- Donovan Rebbechi * http://pegasus.rutgers.edu/~elflord/ * elflord at panix dot com From clayberg at instantiations.com Mon Feb 19 03:40:35 2001 From: clayberg at instantiations.com (Eric Clayberg) Date: Sun, 18 Feb 2001 21:40:35 -0500 Subject: Weird Language Features References: Message-ID: <96q137$q3d$1@nntp9.atl.mindspring.net> "Dave Cross" wrote in message news:nnhv8t4obq30ljfgseplp7pi4khhsf9g9n at 4ax.com... > > [Please watch the replies on this message as it's heavily > cross-posted] > > I'm doing some comparisons on programming language features and I'd be > very interested to know how you would handle the following scenarios > in your programming language of choice. > > 1/ The programmer calls a function that doesn't actually exist within > the application (or libraries). Is the a feature whereby the > programmer can create a "catch-all" function which is called in cases > like these? Can this function examine the list of existing functions > and call the most appropriate one? Or create a new function on the fly > and install it into the application? Smalltalk can do all of the above very easily. This general technique is used to create generic proxies, for example. I have also played around with "fault tolerant" apps that could automatically detect and correct spelling errors in function calls (as a lark; never in production code). > 2/ Can ou filter the input source code before compilation (or > interpretation) in some way so that language keywords could be changed > for other strings? Imagine you wanted to allow someone to program your > language of choice in, say, French. How would you go about translating > French keywords into ones that the compiler (or interpreter) could > understand. What if the translation wasn't one-to-one or fixed? Could > you put enough intelligence into the translator so that it could > handle certain strings differently depending on where they appeared in > the source code? Smalltalk can also do the above very easily. Everything is Smalltalk is an object - including the parser, the compiler, the compiled methods and the method source. Setting up a pre-processor or modifying the actual parser is very easy to do. Since all of Smalltalk's control structures are built in Smalltalk itself, you can easily alias any function name or operator to another. Enhancing the "syntax" and adding your own control structures is also trivial. > If you're wondering why I'm inventing these bizarre scenarios, it's > for a paper I'm writing for this year's Perl Conference. Perl does > have these features (see the AUTOLOAD function and source filters) and > I'm interested in seeing how widespread they are in other languages. > > Of course, if you'd like to tell me just why you consider it's a good > thing that your language of choice doesn't have these features, then > I'd be only too happy to hear that too. > > I'd just like to make it clear that I'm not interested in getting into > "my language is better than your language" types of flamewars. I'm > certainly not trying to argue that Perl is better than other languages > for having these features. > > Thanks for your time Thanks for the interesting thread. -Eric From hannah at schlund.de Mon Feb 19 18:08:06 2001 From: hannah at schlund.de (Hannah Schroeter) Date: 19 Feb 2001 18:08:06 +0100 Subject: Weird Language Features References: <96q137$q3d$1@nntp9.atl.mindspring.net> Message-ID: <96rjtm$2q$1@c3po.schlund.de> Hello! [F'up] In article <96q137$q3d$1 at nntp9.atl.mindspring.net>, Eric Clayberg wrote: >[...] [syntax changes through e.g. preprocessing] >Smalltalk can also do the above very easily. Everything is Smalltalk is an >object - including the parser, the compiler, the compiled methods and the >method source. Setting up a pre-processor or modifying the actual parser is >very easy to do. Since all of Smalltalk's control structures are built in >Smalltalk itself, you can easily alias any function name or operator to >another. Enhancing the "syntax" and adding your own control structures is >also trivial. Partly yes, but only partly. Access to parser/compiler innards isn't standardized in any way, much less than Common Lisp's readtable and macro facilities. Of course, when it just comes to method names (selectors), it's easy to modify/extend the standard classes. >[...] Kind regards, Hannah. From sdm7g at Virginia.EDU Mon Feb 19 19:30:52 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Mon, 19 Feb 2001 13:30:52 -0500 Subject: Weird Language Features In-Reply-To: <96q137$q3d$1@nntp9.atl.mindspring.net> References: <96q137$q3d$1@nntp9.atl.mindspring.net> Message-ID: In objective-c, the functional/procedural part of the language is just ANSI C, so, with respect to undefined functions, the answer would be the same as C: no. The object-oriented feature of objective-C are based on smalltalk, so with respect to methods, it's like smalltalk. Any class can implement forwardInvocation: (as well as some other introspective methods) to pass methods it doesn't understand to a proxy or delegate. (I believe you can even redefine this method for NSObject itself, so that all subclasses will inherit this new implementation. ) The python<->objective-c bridge in PyObjC uses this in it's implementation. There are proxy objects sitting between python classes and their objective-c equivalents. Some common transformations are built in, so NSStrings and NSArrays can be treated as python sequences, but in general, python methods are name-mangled into objective-c method names by translating colons to/from underscores, and the proxies forward them (depending on which direction you're going -- objective-C calling Python or Python calling objective-c.) -- Steve Majewski On Sun, 18 Feb 2001, Eric Clayberg wrote: > "Dave Cross" wrote in message > news:nnhv8t4obq30ljfgseplp7pi4khhsf9g9n at 4ax.com... > > > > [Please watch the replies on this message as it's heavily > > cross-posted] > > > > I'm doing some comparisons on programming language features and I'd be > > very interested to know how you would handle the following scenarios > > in your programming language of choice. > > > > 1/ The programmer calls a function that doesn't actually exist within > > the application (or libraries). Is the a feature whereby the > > programmer can create a "catch-all" function which is called in cases > > like these? Can this function examine the list of existing functions > > and call the most appropriate one? Or create a new function on the fly > > and install it into the application? > > Smalltalk can do all of the above very easily. This general technique is > used to create generic proxies, for example. I have also played around with > "fault tolerant" apps that could automatically detect and correct spelling > errors in function calls (as a lark; never in production code). > From JeffH at ActiveState.com Mon Feb 19 18:42:47 2001 From: JeffH at ActiveState.com (Jeffrey Hobbs) Date: Mon, 19 Feb 2001 09:42:47 -0800 Subject: Weird Language Features References: Message-ID: <3A915B17.1E54882B@ActiveState.com> Dave Cross wrote: ... > 1/ The programmer calls a function that doesn't actually exist within > the application (or libraries). Is the a feature whereby the > programmer can create a "catch-all" function which is called in cases > like these? Can this function examine the list of existing functions > and call the most appropriate one? Or create a new function on the fly > and install it into the application? For Tcl, yes this is a standard feature, set in the 'unknown' procedure, which can be redefined by the user. The default behavior is to use it for lazy-loading of new procedures. It has also been used to handle completely new syntax structures in Tcl. > 2/ Can ou filter the input source code before compilation (or > interpretation) in some way so that language keywords could be changed > for other strings? Imagine you wanted to allow someone to program your > language of choice in, say, French. How would you go about translating > French keywords into ones that the compiler (or interpreter) could > understand. What if the translation wasn't one-to-one or fixed? Could You could build this with any language using message catalogs or the like. It's very easy with interpreted languages, and Tcl for one has the facilities (helper modules) built in. -- Jeff Hobbs The Tcl Guy Senior Developer http://www.ActiveState.com/ From shaleh at valinux.com Mon Feb 19 19:52:44 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Mon, 19 Feb 2001 10:52:44 -0800 Subject: Weird Language Features In-Reply-To: ; from dave@dave.org.uk on Sun, Feb 18, 2001 at 01:16:49PM +0000 References: Message-ID: <20010219105244.B29164@valinux.com> On Sun, Feb 18, 2001 at 01:16:49PM +0000, Dave Cross wrote: > > [Please watch the replies on this message as it's heavily > cross-posted] > > 1/ The programmer calls a function that doesn't actually exist within > the application (or libraries). Is the a feature whereby the > programmer can create a "catch-all" function which is called in cases > like these? Can this function examine the list of existing functions > and call the most appropriate one? Or create a new function on the fly > and install it into the application? > python will throw an exception, the code could then decide that the exception was due to a missing function and decide how to deal with it. I suspect this could be useful in really restricted areas, but in general code it strikes me as horribly confusing. > 2/ Can ou filter the input source code before compilation (or > interpretation) in some way so that language keywords could be changed > for other strings? Imagine you wanted to allow someone to program your > language of choice in, say, French. How would you go about translating > French keywords into ones that the compiler (or interpreter) could > understand. What if the translation wasn't one-to-one or fixed? Could > you put enough intelligence into the translator so that it could > handle certain strings differently depending on where they appeared in > the source code? perligata makes a LOT of assumptions for you. it is not really latin. I presume it is one of the poster children for this in perl. its fun, but a toy. even if you could code essential language words in natural language Foo, things like if and for, there is a wealth of code out there NOT in Foo. So even if I use perligata for the base of my code, when I use any other module I have to be able to speak the language the module was written in. So if I try to import a module written by your friend in French, I now have to know French to figure out the function and variable names. As much as we hate it, a common language is good. As for python, the interpreter, keyword and parser are available, I suspect this could be done with a little work. From sss at ed.com Wed Feb 21 12:59:12 2001 From: sss at ed.com (sss) Date: Wed, 21 Feb 2001 12:59:12 +0100 Subject: Weird Language Features References: Message-ID: <3A93AD90.F2C03540@ed.com> Ruby Dave Cross wrote: > > 1/ The programmer calls a function that doesn't actually exist within > the application (or libraries). Is the a feature whereby the > programmer can create a "catch-all" function which is called in cases > like these? Can this function examine the list of existing functions > and call the most appropriate one? Or create a new function on the fly > and install it into the application? > "method_missing(...)" does it, either per class or when overwriting Object>>method_missing(...) globally > > 2/ Can ou filter the input source code before compilation (or > interpretation) in some way so that language keywords could be changed > for other strings? Imagine you wanted to allow someone to program your > language of choice in, say, French. How would you go about translating > French keywords into ones that the compiler (or interpreter) could > understand. What if the translation wasn't one-to-one or fixed? Could > you put enough intelligence into the translator so that it could > handle certain strings differently depending on where they appeared in > the source code? 'alias' allows you to create an alias for any method of any class. Language keywords such as class, module, while , etc. cannot be aliased though. Clemens From jschmitt at vmlabs.com Thu Feb 22 05:19:05 2001 From: jschmitt at vmlabs.com (John Schmitt) Date: Wed, 21 Feb 2001 20:19:05 -0800 Subject: Weird Language Features Message-ID: <008F0A63472BD311AF9800104BCD102561CCA6@minirex.vmlabs.com> Doesn't Applescript do something like this? I recall browsing the docs where they mentioned that you can program Applescript in more than one dialect. I guessed from the docs that you can write Applescript program in English, French, and Japanese. If you write an Applescript program in one language (ie English), change your dialect (ie to French) and load the program in your editor again, the source code will show up in the new language (ie French). Do I understand that correctly? John > -----Original Message----- > From: Donal K. Fellows [mailto:fellowsd at cs.man.ac.uk] > Sent: Monday, February 19, 2001 2:49 AM > To: python-list at python.org > Subject: Re: Weird Language Features > [...] > It'd be better to rewrite the [source] command as well, since then you > could apply the transformations at code-loading time as well, > and if you > were doing something as static as supporting a second language for the > words of the program, then (as long as the literal strings > used for the > two languages were distinct) you could easily use interpreter aliasing > instead. From fellowsd at cs.man.ac.uk Thu Feb 22 10:54:16 2001 From: fellowsd at cs.man.ac.uk (Donal K. Fellows) Date: Thu, 22 Feb 2001 09:54:16 +0000 Subject: Weird Language Features In-Reply-To: <008F0A63472BD311AF9800104BCD102561CCA6@minirex.vmlabs.com> (message from John Schmitt on Wed, 21 Feb 2001 20:19:05 -0800) References: <008F0A63472BD311AF9800104BCD102561CCA6@minirex.vmlabs.com> Message-ID: John Schmitt > Doesn't Applescript do something like this? I recall browsing the docs > where they mentioned that you can program Applescript in more than one > dialect. I guessed from the docs that you can write Applescript program in > English, French, and Japanese. If you write an Applescript program in one > language (ie English), change your dialect (ie to French) and load the > program in your editor again, the source code will show up in the new > language (ie French). Do I understand that correctly? It's a Mac, so I've no idea! I have heard rumours to this effect though. However, to me this says that the raw program text is a binary form that is never actually displayed to anyone in the normal course of things. Furthermore, this auto-translation is deeply unlikely to affect the bits of the program that usually need attention; strings shown to users (and possibly the names of identifiers in the program if you need it to be maintained by someone with a different native language.) Somehow I'm fairly sure that AppleScript can't change the language of those automatically (since no-one else in the world can either, as many manuals are ample demonstration of... :^) A downside of this is that it makes it difficult for people in different countries to discuss applescript properly, since a correct example fragment for one person might be complete gibberish for another. You'd have to pass structured documents about instead of just plain text messages... :^( Donal. -- Donal K. Fellows, Department of Computer Science, University of Manchester, UK. (work) fellowsd at cs.man.ac.uk Tel: +44-161-275-6137 (preferred email addr.) (home) donal at ugglan.demon.co.uk Tel: +44-1274-401017 Mobile: +44-7957-298955 http://www.cs.man.ac.uk/~fellowsd/ (Don't quote my .sig; I've seen it before!) From me at nospam.net Sat Feb 24 21:13:23 2001 From: me at nospam.net (Scottie) Date: Sat, 24 Feb 2001 12:13:23 -0800 Subject: Weird Language Features References: Message-ID: The "Mesa" language (used as a system language at Xerox Parc in the 70s) allowed this same fully general exception/interrupt structure. their experience, after a number of years, was that it did not work out so well. Finally, they looked at all of their code, found almost all of the uses of "fix and continue" could be easily converted to the same kind of mechanism that Python now uses. Of the few (five, as I recall) remaining instances, one had a bug. So, the last few were rewritten and the feature was removed from the language. "Sean 'Shaleh' Perry" wrote in message news:mailman.982608802.22541.python-list at python.org... > On Sun, Feb 18, 2001 at 01:16:49PM +0000, Dave Cross wrote: > > ...1/ The programmer calls a function that doesn't actually exist within > > the application (or libraries). Is the a feature whereby the > > programmer can create a "catch-all" function which is called in cases > > like these? Can this function examine the list of existing functions > > and call the most appropriate one? Or create a new function on the fly > > and install it into the application? > ...python will throw an exception, the code could then decide that the > exception was due to a missing function and decide how to deal with it. > I suspect this could be useful in really restricted areas, but in general > code it strikes me as horribly confusing. -Scott From c941520 at alinga.newcastle.edu.au Sun Feb 18 14:40:56 2001 From: c941520 at alinga.newcastle.edu.au (Ben de Luca) Date: Mon, 19 Feb 2001 00:40:56 +1100 Subject: pointing at who? Message-ID: <3a8e808a$0$25513$7f31c96c@news01.syd.optusnet.com.au> hmm i am trying to find out how the assignmnet in this situation would occure, is talkingdata[1] the same as (talkingTo[CorrectNumber])[1] in this situation in essense i want to wait for the switch to flip? can i do this other wise i will have to use another message or starve talkingData=[sender,threading.Event(),''] #create working data data=[] #create final data self.talkingToLock.acquire() #one hand in the cookie jar at a time self.talkingTo.append(talkingData) #put in the cookies self.talkingToLock.release()#shut the lid talkingData[1].wait() #wait for response From tim.one at home.com Sat Feb 17 19:47:13 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 17 Feb 2001 13:47:13 -0500 Subject: pointing at who? In-Reply-To: <3a8e808a$0$25513$7f31c96c@news01.syd.optusnet.com.au> Message-ID: [Ben de Luca] > hmm i am trying to find out how the assignmnet in this situation would > occure, is talkingdata[1] the same as > (talkingTo[CorrectNumber])[1] in this > situation I'm doing my best to break this at sentence boundaries, but you didn't make it easy . The answer is probably "yes". > in essense i want to wait for the switch to flip? can i do this > other wise i will have to use another message or starve > > > talkingData=[sender,threading.Event(),''] #create working data Cool. > data=[] #create final data You never use this again, so unclear why it's here. > self.talkingToLock.acquire() #one hand in the cookie jar at a time > self.talkingTo.append(talkingData) #put in the cookies > self.talkingToLock.release()#shut the lid You didn't tell us anything about self.talkingTo. Assuming it's a list. If so, list.append is atomic and you don't really need the acquire/release pair around it. > talkingData[1].wait() #wait for response After list.append(x), and regardless of x, list[-1] is x is true. So, ya, for some value of i, self.talkingTo[i] is talkingData is true, i.e. they're exactly the same object. BTW, drop the fiddly list and create a little SharedData (whatever) class so you can at least *name* these fields. Meaningless little integers will come back to bite you some day. they-breed-in-the-dark-and-some-have-very-sharp-edges-ly y'rs - tim From slhath at home.com Sun Feb 18 15:31:40 2001 From: slhath at home.com (Scott Hathaway) Date: Sun, 18 Feb 2001 14:31:40 GMT Subject: tkinter Message-ID: With tkinter, is it possible to put an icon in the Windows system tray for your app? If so, where can I find an example? Thanks, Scott From spamers at must.die Sun Feb 18 15:43:01 2001 From: spamers at must.die (Fernando Rodríguez) Date: Sun, 18 Feb 2001 15:43:01 +0100 Subject: formatting numbers for output Message-ID: <9sfv8t45ve3dpql39rmp7082gibbicf56b@4ax.com> Hi! How can I format a number so it pretty prints: 15,456.6 instead of 15456.6 ? TIA //----------------------------------------------- // Fernando Rodriguez Romero // // frr at mindless dot com //------------------------------------------------ From phlip_cpp at my-deja.com Sun Feb 18 16:46:13 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 18 Feb 2001 15:46:13 GMT Subject: formatting numbers for output References: <9sfv8t45ve3dpql39rmp7082gibbicf56b@4ax.com> Message-ID: <96oqo5$bld@dispatch.concentric.net> Proclaimed Fernando Rodr?guez from the mountaintops: > Hi! > > How can I format a number so it pretty prints: > > 15,456.6 instead of 15456.6 ? While you are at it, ensure the program prints 15.456,6 in parts of Europe & certain other places. (Seriously, "15 456.6" with just a space is a happy median.) -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- My opinions are those of your employer -- From emile at fenx.com Sun Feb 18 18:44:18 2001 From: emile at fenx.com (Emile van Sebille) Date: Sun, 18 Feb 2001 09:44:18 -0800 Subject: formatting numbers for output References: <9sfv8t45ve3dpql39rmp7082gibbicf56b@4ax.com> Message-ID: <96p1nt$milta$1@ID-11957.news.dfncis.de> 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 locale >>> locale.setlocale(locale.LC_ALL,"") 'English_United States.1252' >>> print locale.format("%8.2f" , 4123.45, 1) 4,123.45 >>> -- Emile van Sebille emile at fenx.com ------------------- "Fernando Rodr?guez" wrote in message news:9sfv8t45ve3dpql39rmp7082gibbicf56b at 4ax.com... > Hi! > > How can I format a number so it pretty prints: > > 15,456.6 instead of 15456.6 ? > > TIA > > > > > //----------------------------------------------- > // Fernando Rodriguez Romero > // > // frr at mindless dot com > //------------------------------------------------ From tjg at exceptionalminds.com Sun Feb 18 23:14:33 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Sun, 18 Feb 2001 14:14:33 -0800 Subject: formatting numbers for output In-Reply-To: <9sfv8t45ve3dpql39rmp7082gibbicf56b@4ax.com>; from spamers@must.die on Sun, Feb 18, 2001 at 03:43:01PM +0100 References: <9sfv8t45ve3dpql39rmp7082gibbicf56b@4ax.com> Message-ID: <20010218141433.F862@trufflehunter.avalongroup.net> This is something you have to do yourself. I've attached a little module I wrote to do it. It's not too flexible, it only deals with the US format, but it works pretty well. I created it for a Tkinter app that needed to display pretty numbers, so it actually goes both ways unformatted to formatted and formatted to unformatted. On Sun, Feb 18, 2001 at 03:43:01PM +0100, Fernando Rodr?guez wrote: > Hi! > > How can I format a number so it pretty prints: > > 15,456.6 instead of 15456.6 ? > -- 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: 33 days 2:23 hours ago<< -------------- next part -------------- #! /usr/bin/env python # import string ############################################################ # # Name: commanumber() # # Purpose: To format a number with commas and possibly a # dollar sign. # # Arguments: n = the number to be converted # dp = number of decimal places (defaults to 2) # ds = dollar sign (1|0) (defaults to $) # def commanumber(n, dp=2, ds=1): if not n: return '' # If None then bail out here if type(n) == type('x'): if n == '': return '' # If an empty string then bail out here. n = string.atof(n) m = '%0.*f' % (dp, n) d = string.split(m, '.') # Split at the decimal point r = list(d[0]) # It looks ugly but it really isn't. A couple of really nice Pythonisms # make it work right. The first is list insertion, and the second is integer # division. # # the insertion point is calculated based on the counter item, plus the a left # shift for each ',' already inserted the ((x/3)-1) # for x in range(3, len(r), 3): r[(x+((x/3)-1))*(-1):(x+((x/3)-1))*(-1)] = [','] if ds: s = '$' else: s = '' # Rebuild the string from the list for i in r: s = s + i if len(d) == 2: # Check to see if we have a decimal portion to add return s + '.' + d[1] else: return s ############################################################ # # Name: stripfmt() # # Purpose: Strip all formatting from a prettified number # # Arguments: n = the number to strip # def stripfmt(n): n = string.replace(n, ',', '') #remove commas n = string.replace(n, '$', '') #remove dollar signs. return n if __name__ == '__main__': test = 12345.346 print 'number --> ' + `test` print 'commanumber(test)--> ' + commanumber(test) print 'commanumber(test,1)--> ' + commanumber(test,1) print 'commanumber(test,2)--> ' + commanumber(test,2) print 'commanumber(test,3)--> ' + commanumber(test,3) print 'commanumber(test,4)--> ' + commanumber(test,4) From sholden at holdenweb.com Wed Feb 28 20:43:22 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 28 Feb 2001 14:43:22 -0500 Subject: formatting numbers for output References: <9sfv8t45ve3dpql39rmp7082gibbicf56b@4ax.com> Message-ID: "Fernando Rodr?guez" wrote in message news:9sfv8t45ve3dpql39rmp7082gibbicf56b at 4ax.com... > Hi! > > How can I format a number so it pretty prints: > > 15,456.6 instead of 15456.6 ? > > TIA > Take a look at the locale module. regards Steve From glen.mettler at home.com Sun Feb 18 15:58:17 2001 From: glen.mettler at home.com (glen mettler) Date: Sun, 18 Feb 2001 14:58:17 GMT Subject: New Guy question Message-ID: <1103_982505663@cc462845-a> I just downloaded Python. I am trying to start the windows version and nothing happens. The EXE files available are PYTHON.EXE, PYTHONW.EXE and W9XPOPEN.EXE. PYTHON.EXE gives me a DOS window. I want the windows version. What should I do? Thanks, Glen From fredrik at pythonware.com Sun Feb 18 16:08:44 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 18 Feb 2001 15:08:44 GMT Subject: New Guy question References: <1103_982505663@cc462845-a> Message-ID: <0ARj6.18119$AH6.2476545@newsc.telia.net> "glen mettler" wrote: > PYTHON.EXE gives me a DOS window. I want the > windows version. What should I do? python.exe is the *console* version. if you, for some reason, think that a program using the Windows console cannot possible be a Windows program, try IDLE, Python- Win, or any other Python IDE (check google for pointers). Cheers /F From glen.mettler at home.com Sun Feb 18 16:16:31 2001 From: glen.mettler at home.com (glen mettler) Date: Sun, 18 Feb 2001 15:16:31 GMT Subject: New guy question Message-ID: <1104_982506707@cc462845-a> I just downloaded Python. I am trying to start the windows version and nothing happens. The EXE files available are PYTHON.EXE, PYTHONW.EXE and W9XPOPEN.EXE. PYTHON.EXE gives me a DOS window. I want the windows version. What should I do? Thanks, Glen From glenfant at equod.com.nospam Sun Feb 18 17:13:50 2001 From: glenfant at equod.com.nospam (Gillou) Date: Sun, 18 Feb 2001 17:13:50 +0100 Subject: New guy question References: <1104_982506707@cc462845-a> Message-ID: <96os0e$84i$1@reader1.imaginet.fr> What distro (BeOpen, Activestate, Pythonware) ? What version (1.5.2, 2.0) ? AFAIK, after installing python 2.0 from the official site www.python.org you should have IDLE in the Python group when clicking "start>program". You can have a free 100% Windows IDE from Activestate (www.activestate.com). python.exe is the interactive Python console. pythonw.exe is the run-time for Windows. With this, you can run python scripts you write with any text editor. "glen mettler" a ?crit dans le message news: 1104_982506707 at cc462845-a... > I just downloaded Python. I am trying to start the windows version and nothing happens. The EXE files available are PYTHON.EXE, > PYTHONW.EXE and W9XPOPEN.EXE. > PYTHON.EXE gives me a DOS window. I want the windows version. What should I do? > Thanks, > > Glen > > > > From abouf066 at aix2.uottawa.ca Sun Feb 18 16:18:17 2001 From: abouf066 at aix2.uottawa.ca (abouf066 at aix2.uottawa.ca) Date: Sun, 18 Feb 2001 10:18:17 -0500 Subject: What IPC accessible from Python Message-ID: Greetings, I need to spawn a process within a python application and I need to have some communication between the child and the parent. Sockets are 'sort of heavy' for my application. I was thinking to use a shared memory or a pipe but I did not find any documentation (example) to understand how this would be used. Any pointers to this matter would be greatly appreciated. Thanks a lot _____________________________________________________________ LaBoufarikoise From erno-news at erno.iki.fi Sun Feb 18 17:56:18 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 18 Feb 2001 18:56:18 +0200 Subject: What IPC accessible from Python References: Message-ID: In article , writes: | Greetings, | I need to spawn a process within a python application and I need | to have some communication between the child and the parent. Sockets are | 'sort of heavy' for my application. I was thinking to use a shared memory | or a pipe but I did not find any documentation (example) to understand how | this would be used. os.pipe() works just like pipe(2) in the unix c syscall api. no sysv shared memory (at least in the standard library, there may be 3rd party modules), but the mmap shared memory may work (with the mmap module in python >= 2.0). shared memory feels a lot heavier than pipes or unix domain sockets to me... -- erno From claird at starbase.neosoft.com Mon Feb 19 15:17:48 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 19 Feb 2001 08:17:48 -0600 Subject: What IPC accessible from Python References: Message-ID: <010D92FB2EBD6C65.87C5B1D9E9635DEA.37DEA6894CD83C3A@lp.airnews.net> In article , Erno Kuusela wrote: >In article >, > writes: > >| Greetings, >| I need to spawn a process within a python application and I need >| to have some communication between the child and the parent. Sockets are >| 'sort of heavy' for my application. I was thinking to use a shared memory >| or a pipe but I did not find any documentation (example) to understand how >| this would be used. > >os.pipe() works just like pipe(2) in the unix c syscall api. > >no sysv shared memory (at least in the standard library, there >may be 3rd party modules), but the mmap shared memory may work >(with the mmap module in python >= 2.0). > >shared memory feels a lot heavier than pipes or unix domain sockets to >me... > > -- erno Seconded. That is, shared memory had it all over sockets ten years ago, but a lot of work has been done since then to improve implementations, and socket programming is what I generally recommend nowadays. There are even stacks that use shmem for loopback. There's nothing particularly wrong with shmem; it's just not exposed or exercised as it once was. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From gst at sysfrog.org Sun Feb 18 19:38:35 2001 From: gst at sysfrog.org (Guenther Starnberger) Date: 18 Feb 2001 19:38:35 +0100 Subject: What IPC accessible from Python References: Message-ID: <87k86nsuok.fsf@nirvana.sysfrog.org> writes: > I need to spawn a process within a python application and I need > > to have some communication between the child and the parent. Sockets > are > 'sort of heavy' for my application. I was thinking to use a > shared memory > or a pipe but I did not find any documentation > (example) to understand how > this would be used. try the popen2 module. import popen2 foo=popen2.Popen3(command,1,1024) foo.tochild.write("hello") /gst -- sysfrog.org From mikholbor at mail.ru Sun Feb 18 16:32:57 2001 From: mikholbor at mail.ru (Oleg B. Mikhaylov) Date: Sun, 18 Feb 2001 17:32:57 +0200 Subject: Hey all, make easy money with me Message-ID: <96or0o$1121$1@News.TM.Odessa.UA> Hey, I just joined a FREE site, TargetShop.com, that lets you earn $10,000 just for referring your friends! Go to TargetShop.com http://www.shopping4points.com/Default.asp?refId=2133869 and register for Membership using my Referral Number 2133869. If you sign up, before May 1st, I will be eligible to receive $50 payable in cash or applied to the purchase of TargetShop.com stock (if and when they complete an IPO, subject to the Terms and Conditions of the Referral Program). After you register, you will be able to earn easy money just by sending email to refer your friends. Each time someone you referred, in turn, refers someone, you will make money! We can both make thousands of dollars in no time at all! As TargetShop.com Members, we are entitled to discounts at some of the Web's best e-commerce sites using the TargetPoints we get when we register and take advantage of site features, like the Playground. So, go sign up, earn big bucks, and enjoy your Membership! http://www.shopping4points.com/Default.asp?refId=2133869. Talk to you later, Oleg From gleonid at actcom.co.il Sun Feb 18 17:10:56 2001 From: gleonid at actcom.co.il (Leonid Gluhovsky) Date: Sun, 18 Feb 2001 16:10:56 GMT Subject: [Q] how to protect python program from decompilation Message-ID: Hello. The company I work for has a program written in Python, and wants to ship it to customers in such a way that even if the customers are Python gurus they will not be able to decompile Python bytecode and arrive at readable source. Is it possible? How to do it? Many thanks in advance, leonid From moshez at zadka.site.co.il Sun Feb 18 17:35:48 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sun, 18 Feb 2001 18:35:48 +0200 (IST) Subject: [Q] how to protect python program from decompilation In-Reply-To: References: Message-ID: <20010218163548.6C57EA840@darjeeling.zadka.site.co.il> On Sun, 18 Feb 2001 16:10:56 GMT, Leonid Gluhovsky wrote: > The company I work for has a program written in Python, and wants to > ship it to customers in such a way that even if the customers are Python > gurus they will not be able to decompile Python bytecode and arrive at > readable source. > > Is it possible? How to do it? No it's not. No way will withstand a true guru. Note that the same goes for C/C++/Java. Use a license. sick-of-this-question-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 erno-news at erno.iki.fi Sun Feb 18 17:40:09 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 18 Feb 2001 18:40:09 +0200 Subject: [Q] how to protect python program from decompilation References: Message-ID: In article , Leonid Gluhovsky writes: | Hello. | The company I work for has a program written in Python, and wants to | ship it to customers in such a way that even if the customers are Python | gurus they will not be able to decompile Python bytecode and arrive at | readable source. | Is it possible? How to do it? it's not possible (for python or for any other language). -- erno From aahz at panix.com Sun Feb 18 18:09:05 2001 From: aahz at panix.com (Aahz Maruch) Date: 18 Feb 2001 09:09:05 -0800 Subject: [Q] how to protect python program from decompilation References: Message-ID: <96ovjh$4nt$1@panix3.panix.com> In article , Leonid Gluhovsky wrote: > >The company I work for has a program written in Python, and wants to >ship it to customers in such a way that even if the customers are Python >gurus they will not be able to decompile Python bytecode and arrive at >readable source. > >Is it possible? How to do it? The only way to do it is to physically secure the code in a way that's inaccessible to the user's computer. For example, one could ship a card with a CPU; realistically, though, the only serious way to do it with current technology is to force your users to access your web site, where the program resides. -- --- 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 Why doesn't "Just Say NO" include caffeine, nicotine, alcohol, Prozac, and Ritalin? --Aahz From gleonid at actcom.co.il Sun Feb 18 18:18:54 2001 From: gleonid at actcom.co.il (Leonid Gluhovsky) Date: Sun, 18 Feb 2001 17:18:54 GMT Subject: [Q] how to protect python program from decompilation References: Message-ID: Moshe Zadka wrote: > sick-of-this-question-ly y'rs, Z. I honestly tried to locate tips on this problem before posting :) Could you please let me know where I can find prior discussion of this? > No it's not. No way will withstand a true guru. Note that the same goes > for C/C++/Java. OK. > Use a license. I am not in a position to decide on this matter. Let's say I am looking for a way to make it prohibitively hard for the customer to decompile the byte code. I agree that complete protection is impossible. Right now we are considering the following scheme: build a Python with opcodes in Include/opcode.h reshuffled, and without the dis module in it; use this interpreter to byte compile our code; use its Tools/freeze to package our program into executable and ship it to customers. What are the holes in this approach? What is a better approach? Thank you, leonid From moshez at zadka.site.co.il Sun Feb 18 18:45:11 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sun, 18 Feb 2001 19:45:11 +0200 (IST) Subject: [Q] how to protect python program from decompilation In-Reply-To: References: , Message-ID: <20010218174511.3BD21A840@darjeeling.zadka.site.co.il> On Sun, 18 Feb 2001 17:18:54 GMT, Leonid Gluhovsky wrote: > I am not in a position to decide on this matter. Let's say I am looking > for a way to make it prohibitively hard for the customer to decompile > the byte code. I agree that complete protection is impossible. If management has asked you to find a problem, they should be able to hear that the problem has no solution. Any protection scheme can be broken, and most (hard!) ones can be broken by someone in less then a day. Consider whether a day of someone else's time is worth more then (at least) an hour of your time. > Right now we are considering the following scheme: build a Python > with opcodes in Include/opcode.h reshuffled, and without the dis module > in it; use this interpreter to byte compile our code; use its Tools/freeze > to package our program into executable and ship it to customers. > > What are the holes in this approach? What is a better approach? That an idiot with a debugger can see what each opcode does enough to remap the opcodes, and then read from your program the freezed strings using a tool I can probably write in Python in 15 minutes. So, if I were to break your program (and I'm not -- I'm using only software I have the source for at home), I estimate it would take me about one hour. It's probably as good approach as any, but it's also probably as bad as any too. -- "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 mwh21 at cam.ac.uk Sun Feb 18 18:52:07 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 18 Feb 2001 17:52:07 +0000 Subject: [Q] how to protect python program from decompilation References: Message-ID: Leonid Gluhovsky writes: > Right now we are considering the following scheme: build a Python > with opcodes in Include/opcode.h reshuffled, and without the dis module > in it; use this interpreter to byte compile our code; use its Tools/freeze > to package our program into executable and ship it to customers. > > What are the holes in this approach? What is a better approach? Sounds like a reasonable (effort on your part)/(effort on their part tradeoff). It would still probably be crackable (by statistical analysis of byteocde of decompiling the assembly of your ceval.c), but it would be a lot of work. Cheers, M. -- I also feel it essential to note, [...], that Description Logics, non-Monotonic Logics, Default Logics and Circumscription Logics can all collectively go suck a cow. Thank you. -- http://advogato.org/person/Johnath/diary.html?start=4 From skip at mojam.com Sun Feb 18 19:18:50 2001 From: skip at mojam.com (Skip Montanaro) Date: Sun, 18 Feb 2001 12:18:50 -0600 (CST) Subject: [Q] how to protect python program from decompilation In-Reply-To: References: Message-ID: <14992.4618.346376.319196@beluga.mojam.com> Leonid> Right now we are considering the following scheme: build a Leonid> Python with opcodes in Include/opcode.h reshuffled, and without Leonid> the dis module in it; use this interpreter to byte compile our Leonid> code; use its Tools/freeze to package our program into Leonid> executable and ship it to customers. Well, a determined person could simply locate the real dis, and start (using trial and error, perhaps), to decipher your byte code, adjusting dis.py as they go along. For example, you can't simply shuffle all your byte codes, there are two cut points, HAVE_ARGUMENT and EXTENDED_ARG. Below HAVE_ARGUMENT, none of the opcodes take arguments, so only opcodes < HAVE_ARGUMENT could be shuffled amongst each other. Another clue, all functions are compiled with RETURN None at the end. Without modifying the compiler or running an optimizer of some sort, those will always be there. Those are just starter clues that came off the top of my head. I'm sure there are other clues in the bytecode. In addition, a determined person could step through eval_code2 to see what it does. Even at the assembler level if necessary. -- Skip Montanaro (skip at mojam.com) Support Mojam & Musi-Cal: http://www.musi-cal.com/sponsor.shtml (847)971-7098 From tim.one at home.com Sun Feb 18 19:42:04 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 18 Feb 2001 13:42:04 -0500 Subject: [Q] how to protect python program from decompilation In-Reply-To: Message-ID: [Leonid Gluhovsky] > ... > Right now we are considering the following scheme: build a Python > with opcodes in Include/opcode.h reshuffled, and without the dis module > in it; use this interpreter to byte compile our code; use its Tools/freeze > to package our program into executable and ship it to customers. > > What are the holes in this approach? The different sections of the Python eval loop are easy to recognize in machine language. It wouldn't take a Python mini-guru more than an hour to reverse-engineer your permutation by just watching the eval loop in a machine-language debugger, noting which opcodes jump to which sections of the eval loop. In fact, they only have to do that for *one* opcode. Then they know where in memory the eval loop case-stmt jump table (generated by the C compiler) lives, and the entire permutation can be read off directly from that. Then they can alter the std dis.py accordingly to do an exact symbolic disassembly of your whole code base. > What is a better approach? If there were one, I expect Microsoft would do that instead of just prohibiting reverse-engineering in their licenses. It's not Python gurus you have to worry about so much, it's machine-language gurus. That's why this has little to do with Python. You can't hide anything from them, unless (as Aahz suggested) you ship your own CPU card that doesn't allow tracing instructions. You can make it more *unpleasant* by running your code through a name obfuscator first, e.g. systematically replace all vrbl instances of "i" by a fixed 20-character randomly generated identifier ("AAAA75WRWLKJLKJ3lS9Q"), and so on. Certain branches of the US Govt do that before sending in compiler bug reports, as if nobody can recognize an FFT from its structure alone <0.9 wink>. It's much better to assume your code *will* be reverse-engineered (simply because it will be). Then the focus shifts to dreaming up ways to prove infringement of your license. An effective way is (no kidding) to build in subtle bugs. If a competitor develops the same set of subtle bugs later, they're holding a smoking gun. for-the-same-reason-when-i-was-growing-up-the-regional-map-showed- a-river-in-my-neighborhood-that-never-existed-ly y'rs - tim From tim.one at home.com Sun Feb 18 18:59:17 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 18 Feb 2001 12:59:17 -0500 Subject: [Q] how to protect python program from decompilation In-Reply-To: Message-ID: [Leonid Gluhovsky] > The company I work for has a program written in Python, and wants to > ship it to customers in such a way that even if the customers are Python > gurus they will not be able to decompile Python bytecode and arrive at > readable source. > > Is it possible? Not a chance, but that's got little to do with Python. If you let me run any code whatsoever on my box, I can get a trace of the CPU instructions executed, and that suffices for reasonable reconstruction of the executed paths in the source code given enough effort. If I know the code was originally written in Python, or C, or C++, or Java, ..., it makes it that much easier (because any given compiler is pretty consistent in the way it generates code for various language constructs), but it isn't essential. For example, it's easy to reconstruct your hierarchy of subroutines just by noting when hardware call and return sequences occur, and from and to which addresses. The ironic thing is that the more obscure you try to make it, the more crackers will consider it a worthy challenge to reverse-engineer it. Hiding a thing in plain view can be more effective in the end! > How to do it? Look at it this way: a computer CPU only speaks French. You have some technical text written in English, and your mgmt wants you to translate it into French in such a way that nobody can get back an approximation to the English you started with. Then they don't understand the technical issues (perhaps they're under the illusion that *only* a CPU can understand French), or they're on powerful drugs, or both. This is an exact analogy, because French is such a low-level language . any-language-without-"potato"-is-low-level-by-american-definition-ly y'rs - tim From gst at sysfrog.org Sun Feb 18 19:33:47 2001 From: gst at sysfrog.org (Guenther Starnberger) Date: 18 Feb 2001 19:33:47 +0100 Subject: [Q] how to protect python program from decompilation References: Message-ID: <87ofvzsuwk.fsf@nirvana.sysfrog.org> Leonid Gluhovsky writes: > The company I work for has a program written in Python, and wants to > ship it to customers in such a way that even if the customers are > Python gurus they will not be able to decompile Python bytecode and > arrive at readable source. you can try to convert your python modules with Python2C into c code and distribute the compiled libraries. http://www.mudlib.org/~rassilon/p2c/ cu /gst -- sysfrog.org From aahz at panix.com Sun Feb 18 20:43:49 2001 From: aahz at panix.com (Aahz Maruch) Date: 18 Feb 2001 11:43:49 -0800 Subject: [Q] how to protect python program from decompilation References: Message-ID: <96p8ll$lq5$1@panix2.panix.com> In article , Tim Peters wrote: > >If there were one, I expect Microsoft would do that instead of just >prohibiting reverse-engineering in their licenses. It's not Python gurus >you have to worry about so much, it's machine-language gurus. That's why >this has little to do with Python. You can't hide anything from them, >unless (as Aahz suggested) you ship your own CPU card that doesn't allow >tracing instructions. Just to be clear, this solution only protects you from software hackers. Hardware hackers can still break just about anything. -- --- 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 Why doesn't "Just Say NO" include caffeine, nicotine, alcohol, Prozac, and Ritalin? --Aahz From moshez at zadka.site.co.il Sun Feb 18 21:20:56 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Sun, 18 Feb 2001 22:20:56 +0200 (IST) Subject: [Q] how to protect python program from decompilation In-Reply-To: <96p8ll$lq5$1@panix2.panix.com> References: <96p8ll$lq5$1@panix2.panix.com>, Message-ID: <20010218202056.66C66A840@darjeeling.zadka.site.co.il> On 18 Feb 2001 11:43:49 -0800, aahz at panix.com (Aahz Maruch) wrote: > Just to be clear, this solution only protects you from software hackers. > Hardware hackers can still break just about anything. Well, hardware can be much nastier. Have something which destroys itself when opened forcefully. Not really beyond the state of art today to do such things, but it is costly. Of course, *really* good hardware hackers can break that too, but I don't think there are too many of those. OTOH, script-kiddies with debuggers and too much free time are a dime a dozen. -- "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 cfelling at iae.nl Sun Feb 18 21:02:40 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 18 Feb 2001 21:02:40 +0100 Subject: [Q] how to protect python program from decompilation References: Message-ID: <96p9p0$4g1$1@animus.fel.iae.nl> Tim Peters wrote: ... > It's much better to assume your code *will* be reverse-engineered (simply > because it will be). Then the focus shifts to dreaming up ways to prove > infringement of your license. An effective way is (no kidding) to build in > subtle bugs. If a competitor develops the same set of subtle bugs later, > they're holding a smoking gun. Oh, that's why closed source software is so buggy compared to open software, they're merely protecting their code-base:) > for-the-same-reason-when-i-was-growing-up-the-regional-map-showed- > a-river-in-my-neighborhood-that-never-existed-ly y'rs - tim The same holds for dictionaries. -- groetjes, carel From gleonid at actcom.co.il Mon Feb 19 12:51:30 2001 From: gleonid at actcom.co.il (Leonid Gluhovsky) Date: Mon, 19 Feb 2001 11:51:30 GMT Subject: [Q] how to protect python program from decompilation References: <96p8ll$lq5$1@panix2.panix.com> Message-ID: Many thanks for all the responses! They are most enlightening and useful. leonid From rturpin at do.not.use Mon Feb 19 20:04:25 2001 From: rturpin at do.not.use (Russell Turpin) Date: Mon, 19 Feb 2001 13:04:25 -0600 Subject: [Q] how to protect python program from decompilation -- a better idea References: Message-ID: <3A916E39.DE870D93@do.not.use> An optimizing JIT byte-code compiler would do a far better job of hiding Python source than any of the ideas presented so far. The resulting executable would be no easier to decompile than a program made with C. The more optimization the compiler does, the harder it would be to decompile the results. Ideally, the compiler would maximally execute the Python program before freezing it into an executable. ("Maximal," in this sense, means performing all execution that does NOT depend on outside data or stimulus.) And think of the performance win! Leonid, I think your company should get started on this right away. Regards, Russell From not.this at seebelow.org Tue Feb 20 04:52:53 2001 From: not.this at seebelow.org (Grant Griffin) Date: Mon, 19 Feb 2001 21:52:53 -0600 Subject: [Q] how to protect python program from decompilation References: Message-ID: <3A91EA15.571F0A32@seebelow.org> Tim Peters wrote: > > [Leonid Gluhovsky] > > The company I work for has a program written in Python, and wants to > > ship it to customers in such a way that even if the customers are Python > > gurus they will not be able to decompile Python bytecode and arrive at > > readable source. > > > > Is it possible? > > Not a chance, but that's got little to do with Python. If you let me run > any code whatsoever on my box, I can get a trace of the CPU instructions > executed, and that suffices for reasonable reconstruction of the executed > paths in the source code given enough effort. That last part is the key: "given enough effort". From a strictly economic point of view, you want to make them spend more money decompiling it than they would spend writing it themselves from scratch. But bored teenagers aside (who defy all economic theory), this is virtually always the case: the economic value of most software doesn't derive from any special "trade secrets" it embodies; it's usually pretty easy to figure out basically how it works (Perl's parser notwithstanding ). Instead, the economic value of most software derives just from the "hard work" it took to create the (finished) software package--including not just "design and coding" but also (and perhaps more significantly) things like testing, documentation, packaging, and marketing. Although there isn't much actual "security" in any sort of compilation process, I think it _is_ highly successful in "keeping honest people honest". In this case, the Python-to-exe converters probably have that effect. In any event, unless one has created a software gizmo whose algorithms are so profoundly new and amazing that nobody can possibly figure out how it basically works just by seeing it in action, there's not much point in worrying about the limitations of any sort of compilation-based "security". open-source-software-carries-this-to-its-logical-conclusion-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 zessin at decus.de Sun Feb 18 17:23:26 2001 From: zessin at decus.de (zessin at decus.de) Date: Sun, 18 Feb 2001 17:23:26 +0100 Subject: OpenVMS import (was Re: Windows/Cygwin/MacOSX import (was RE: python-dev summary, 2001-02-01 - 2001-02-15) Message-ID: <009F7D57.F76B21F7.2@decus.de> Cameron Laird wrote: >In article , >Tim Peters wrote: >>[Michael Hudson] >>> ... >>> * Imports on case-insensitive file systems * >>> >>> There was quite some discussion about how to handle imports on a >>> case-insensitive file system (eg. on Windows). I didn't follow the >>> details, but Tim Peters is on the case (sorry), so I'm confident it >>> will get sorted out. >> >>You can be sure the whitespace will be consistent, anyway . > . > . > . >>them is ugly. We're already supporting (and will continue to support) >>PYTHONCASEOK for their benefit, but they don't deserve multiple hacks in >>2001. >> >>Flame at will. >> >>or-flame-at-tim-your-choice-ly y'rs - tim > >1. Thanks. Along with all the other benefits, I find > this explanation FAR more entertaining than anything > network television broadcasts (although nearly as > tendentious as "The West Wing"). >2. I hope a few OS/400 and OpenVMS refugees convert and > walk through the door soon. *That* would make for a > nice dose of fun. Let's see if I can explain the OpenVMS part. I'll do so by walking over Tim's text. (I'll step carefully over it. I don't intend to destroy it, Tim ;-) ] Here's the scoop: file systems vary across platforms in whether or not they ] preserve the case of filenames, and in whether or not the platform C library ] file-opening functions do or don't insist on case-sensitive matches: ] ] ] case-preserving case-destroying ] +-------------------+------------------+ ] case-sensitive | most Unix flavors | brrrrrrrrrr | ] +-------------------+------------------+ ] case-insensitive | Windows | some unfortunate | ] | MacOSX HFS+ | network schemes | ] | Cygwin | | | | OpenVMS | ] +-------------------+------------------+ Phew. I'm glad we're only 'unfortunate' and not in the 'brrrrrrrrrr' section ;-) ] In the upper left box, if you create "fiLe" it's stored as "fiLe", and only ] open("fiLe") will open it (open("file") will not, nor will the 14 other ] variations on that theme). ] In the lower right box, if you create "fiLe", there's no telling what it's ] stored as-- but most likely as "FILE" --and any of the 16 obvious variations ] on open("FilE") will open it. >>> f = open ('fiLe', 'w') $ directory f* Directory DSA3:[PYTHON.PYTHON-2_1A2CVS.VMS] FILE.;1 >>> f = open ('filE', 'r') >>> f >>> This is on the default file system (ODS-2). Only very recent versions of OpenVMS Alpha (V7.2 and up) support the ODS-5 FS that has Windows-like behaviour (case-preserving,case-insensitive), but many sites don't use it (yet). Also, there are many older versions running in the field that don't get upgraded any time soon. ] The lower left box is a mix: creating "fiLe" stores "fiLe" in the platform ] directory, but you don't have to match case when opening it; any of the 16 ] obvious variations on open("FILe") work. Same here. ] What's proposed is to change the semantics of Python "import" statements, ] and there *only* in the lower left box. ] ] Support for MaxOSX HFS+, and for Cygwin, is new in 2.1, so nothing is ] changing there. What's changing is Windows behavior. Here are the current ] rules for import on Windows: ] ] 1. Despite that the filesystem is case-insensitive, Python insists on ] a case-sensitive match. But not in the way the upper left box works: ] if you have two files, FiLe.py and file.py on sys.path, and do ] ] import file ] ] then if Python finds FiLe.py first, it raises a NameError. It does ] *not* go on to find file.py; indeed, it's impossible to import any ] but the first case-insensitive match on sys.path, and then only if ] case matches exactly in the first case-insensitive match. For OpenVMS I have just changed 'import.c': MatchFilename() and some code around it is not executed. ] 2. An ugly exception: if the first case-insensitive match on sys.path ] is for a file whose name is entirely in upper case (FILE.PY or ] FILE.PYC or FILE.PYO), then the import silently grabs that, no matter ] what mixture of case was used in the import statement. This is ] apparently to cater to miserable old filesystems that really fit in ] the lower right box. But this exception is unique to Windows, for ] reasons that may or may not exist . I guess that is Windows-specific code? Something to do with 'allcaps8x3()'? ] 3. And another exception: if the envar PYTHONCASEOK exists, Python ] silently grabs the first case-insensitive match of any kind. The check is in 'check_case()', but there is no OpenVMS implementation (yet). ] So these Windows rules are pretty complicated, and neither match the Unix ] rules nor provide semantics natural for the native filesystem. That makes ] them hard to explain to Unix *or* Windows users. Nevertheless, they've ] worked fine for years, and in isolation there's no compelling reason to ] change them. ] However, that was before the MacOSX HFS+ and Cygwin ports arrived. They ] also have case-preserving case-insensitive filesystems, but the people doing ] the ports despised the Windows rules. Indeed, a patch to make HFS+ act like ] Unix for imports got past a reviewer and into the code base, which ] incidentally made Cygwin also act like Unix (but this met the unbounded ] approval of the Cygwin folks, so they sure didn't complain -- they had ] patches of their own pending to do this, but the reviewer for those balked). ] ] At a higher level, we want to keep Python consistent, and I in particular ] want Python to do the same thing on *all* platforms with case-preserving ] case-insensitive filesystems. Guido too, but he's so sick of this argument ] don't ask him to confirm that <0.9 wink>. What are you thinking about the 'unfortunate / OpenVMS' group ? Hey, it could be worse, could be 'brrrrrrrrrr'... ] The proposed new semantics for the lower left box: ] ] A. If the PYTHONCASEOK envar exists, same as before: silently accept ] the first case-insensitive match of any kind; raise ImportError if ] none found. ] ] B. Else search sys.path for the first case-sensitive match; raise ] ImportError if none found. ] ] #B is the same rule as is used on Unix, so this will improve cross-platform ] portability. That's good. #B is also the rule the Mac and Cygwin folks ] want (and wanted enough to implement themselves, multiple times, which is a ] powerful argument in PythonLand). It can't cause any existing ] non-exceptional Windows import to fail, because any existing non-exceptional ] Windows import finds a case-sensitive match first in the path -- and it ] still will. An exceptional Windows import currently blows up with a ] NameError or ImportError, in which latter case it still will, or in which ] former case will continue searching, and either succeed or blow up with an ] ImportError. ] ] #A is needed to cater to case-destroying filesystems mounted on Windows, and ] *may* also be used by people so enamored of "natural" Windows behavior that ] they're willing to set an envar to get it. That's their problem . I ] don't intend to implement #A for Unix too, but that's just because I'm not ] clear on how I *could* do so efficiently (I'm not going to slow imports ] under Unix just for theoretical purity). ] ] The potential damage is here: #2 (matching on ALLCAPS.PY) is proposed to be ] dropped. Case-destroying filesystems are a vanishing breed, and support for ] them is ugly. We're already supporting (and will continue to support) ] PYTHONCASEOK for their benefit, but they don't deserve multiple hacks in ] 2001. Would using unique names be an acceptable workaround? ] Flame at will. ] ] or-flame-at-tim-your-choice-ly y'rs - tim No flame intended. Not at will and not at tim. >-- > >Cameron Laird >Business: http://www.Phaseit.net >Personal: http://starbase.neosoft.com/~claird/home.html -- Uwe Zessin From slenhartsprint at earthlink.net Sun Feb 18 17:39:21 2001 From: slenhartsprint at earthlink.net (Steve Lenhart) Date: Sun, 18 Feb 2001 16:39:21 GMT Subject: PIL Install - I will worship you Message-ID: Python 2.0 on Windows 2000. How do I setup the Python Image Library? It shouldn't be this hard. I've downloaded and unzipped into a folder called Imaging-1.1.1 in the Python folder. Now what? This isn't easy for a beginner. I will worship you if you tell me what to do next. Thx From syring at email.com Sun Feb 18 18:06:38 2001 From: syring at email.com (Karl M. Syring) Date: Sun, 18 Feb 2001 18:06:38 +0100 Subject: PIL Install - I will worship you References: Message-ID: <96p1fm$lrkpu$1@ID-7529.news.dfncis.de> "Steve Lenhart" schrieb im Newsbeitrag news:ZUSj6.1711$DS3.159530 at newsread1.prod.itd.earthlink.net... > Python 2.0 on Windows 2000. How do I setup the Python Image Library? It > shouldn't be this hard. I've downloaded and unzipped into a folder called > Imaging-1.1.1 in the Python folder. Now what? This isn't easy for a > beginner. I will worship you if you tell me what to do next. Thx To not miss this opportunity: you can get the _imaging.dll and pil111py.zip from Fredrik Lundh's site at http://w1.132.telia.com/~u13208596/pil/index.htm. Karl M. Syring From fredrik at pythonware.com Tue Feb 20 10:45:35 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 20 Feb 2001 09:45:35 GMT Subject: PIL Install - I will worship you References: Message-ID: <31rk6.14592$Qb7.2329539@newsb.telia.net> Steve Lenhart wrote: > Python 2.0 on Windows 2000. How do I setup the Python Image Library? It > shouldn't be this hard. I've downloaded and unzipped into a folder called > Imaging-1.1.1 in the Python folder what exactly have you downloaded and unzipped? the source distribution? if you don't have a compiler, you're probably better off downloading a binary kit: http://www.pythonware.com/products/pil get the right version, unzip it into your Python installation directory (e.g. c:\python20), and off you go... Cheers /F From ransen_spam_me_not at nemo.it Sun Feb 18 17:41:39 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Sun, 18 Feb 2001 16:41:39 GMT Subject: Done the tutorial, now which book? (Python 2) Message-ID: <3a90ed92.1349768@news.newsguy.com> Hello All, Done the HTML tutorial, now is there a book? (Python 2) I mean a book which goes through examples and excercises and things like that? (Rather than a manual). For background I'll tell you that I am a C++ graphics programmer. Amazon gave me this list: Learning Python ~Mark Lutz, David Ascher Python Programming on Win32 ~Mark Hammond, Andy Robinson Programming Python ~Mark Lutz Python and Tkinter Programming ~John E. Grayson The Quick Python Book ~Daryl D. Harms, et al Sams Teach Yourself Python in 24 Hours ~Ivan Van Laningham Programming with PYTHON ~Tim Alton Core Python Programming ~Wesley J. Chun Python Developer's Handbook ~Andre Lessa Learning to Program Using Python ~Alan Gauld -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From clee at gnwy100.wuh.wustl.edu Mon Feb 19 04:23:52 2001 From: clee at gnwy100.wuh.wustl.edu (Christopher Lee) Date: 18 Feb 2001 21:23:52 -0600 Subject: Done the tutorial, now which book? (Python 2) References: <3a90ed92.1349768@news.newsguy.com> Message-ID: <7uk86n73uf.fsf@gnwy100.wuh.wustl.edu> >>>>> "Owen" == Owen F Ransen writes: Owen> Hello All, Done the HTML tutorial, now is there a book? (Python Owen> 2) I haven't read all of the books on your list, but I would rank "Learning Python" by Lutz and Ascher among the best language books I've ever read. I felt like it clearly conveyed python's "philosophy" and quickly gave me a feel for how to solve problems in python. If I were only going to go for one book, I'd choose that. Python Programming on Win32 is also excellent if you're using Windows, especially if you're interested in doing COM servers, scripting Excel and the like. "Programming Python" by Lutz is coming out in a second edition--make sure to get the new version if you decide to buy it. It seems like a more advanced text---I found the first edition helpful when starting my first C python extension. -C From ransen_spam_me_not at nemo.it Mon Feb 19 16:31:53 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Mon, 19 Feb 2001 15:31:53 GMT Subject: Done the tutorial, now which book? (Python 2) References: <3a90ed92.1349768@news.newsguy.com> <7uk86n73uf.fsf@gnwy100.wuh.wustl.edu> Message-ID: <3a923bbb.4385473@news.newsguy.com> On 18 Feb 2001 21:23:52 -0600, Christopher Lee wrote: >>>>>> "Owen" == Owen F Ransen writes: > > Owen> Hello All, Done the HTML tutorial, now is there a book? (Python > Owen> 2) >I haven't read all of the books on your list, but I would rank "Learning >Python" by Lutz and Ascher among the best language books I've ever read. Ok. >Python Programming on Win32 is also excellent if you're using Windows, I'm aiming for Win and Mac so this is probably not much use to me. -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From ws-news at gmx.at Mon Feb 19 17:51:35 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Mon, 19 Feb 2001 17:51:35 +0100 Subject: Done the tutorial, now which book? (Python 2) References: <3a90ed92.1349768@news.newsguy.com> <7uk86n73uf.fsf@gnwy100.wuh.wustl.edu> <3a923bbb.4385473@news.newsguy.com> Message-ID: <982601746.924551@newsmaster-04.atnet.at> > >I haven't read all of the books on your list, but I would rank "Learning > >Python" by Lutz and Ascher among the best language books I've ever read. > Ok. I agree with that, used the book from a comparable situation than you are probably (C and C++ programmer) Found it very well written and it does not describe each single option that can be taken from the docs > > >Python Programming on Win32 is also excellent if you're using Windows, > I'm aiming for Win and Mac so this is probably not much > use to me. > > I think this on is rather COM loaded, the exact reason while I am going to read it soon... hth werner From mertz at gnosis.cx Sun Feb 18 19:25:23 2001 From: mertz at gnosis.cx (Dr. David Mertz) Date: Sun, 18 Feb 2001 13:25:23 -0500 Subject: Book reviews Message-ID: I have written, for IBM developerWorks, a comparative review of most of the books below. Actually, I wrote it quite a while ago by now... and publishers have... delays. Look for it on IBM soon, and in the meanwhile, feel free to read: http://gnosis.cx/cgi/txt2html.cgi?source=http://gnosis.cx/publish/programming/charming_python_12.txt Yours, David... -------- Forwarded message -------- Newsgroups: comp.lang.python Date: Sun, 18 Feb 2001 16:41:39 GMT From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Subject: Done the tutorial, now which book? (Python 2) I mean a book which goes through examples and excercises and things like that? (Rather than a manual). For background I'll tell you that I am a C++ graphics programmer. Learning Python ~Mark Lutz, David Ascher Python Programming on Win32 ~Mark Hammond, Andy Robinson Programming Python ~Mark Lutz Python and Tkinter Programming ~John E. Grayson The Quick Python Book ~Daryl D. Harms, et al Sams Teach Yourself Python in 24 Hours ~Ivan Van Laningham Programming with PYTHON ~Tim Alton Core Python Programming ~Wesley J. Chun Python Developer's Handbook ~Andre Lessa Learning to Program Using Python ~Alan Gauld From jdries at mail.com Sun Feb 18 19:43:03 2001 From: jdries at mail.com (Jan Dries) Date: Sun, 18 Feb 2001 19:43:03 +0100 Subject: Book reviews References: Message-ID: <3A9017B7.EA372E34@mail.com> "Dr. David Mertz" wrote: > > I have written, for IBM developerWorks, a comparative review of most of > the books below. Actually, I wrote it quite a while ago by now... You mean, you will write it in some distant time in the future. That is, is the part of the world where I live, January 20001 is still some time ahead. By that time, we will have seen the Y10K problem. Imagine that. Regards, Jan From ransen_spam_me_not at nemo.it Mon Feb 19 19:06:34 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Mon, 19 Feb 2001 18:06:34 GMT Subject: Book reviews References: Message-ID: <3a933d77.4830008@news.newsguy.com> On Sun, 18 Feb 2001 13:25:23 -0500, "Dr. David Mertz" wrote: >I have written, for IBM developerWorks, a comparative review of most of >the books below. Actually, I wrote it quite a while ago by now... and >publishers have... delays. Look for it on IBM soon, and in the >meanwhile, feel free to read: > > http://gnosis.cx/cgi/txt2html.cgi?source=http://gnosis.cx/publish/programming/charming_python_12.txt > >Yours, David... Thanks for your reviews. It sounds to me that "The Quick Python Book" is probably my best initial bet, given that I program already.... -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From kwoeltje at mail.mcg.edu Tue Feb 20 00:01:11 2001 From: kwoeltje at mail.mcg.edu (Keith F. Woeltje) Date: Mon, 19 Feb 2001 23:01:11 GMT Subject: Book reviews References: <3a933d77.4830008@news.newsguy.com> Message-ID: <3A91A5F6.B1285199@mail.mcg.edu> FYI, the second edition of "Programming Python" is supposed to be out in March. >KFW "Owen F. Ransen" wrote: > > On Sun, 18 Feb 2001 13:25:23 -0500, "Dr. David Mertz" > wrote: > > >I have written, for IBM developerWorks, a comparative review of most of > >the books below. Actually, I wrote it quite a while ago by now... and > >publishers have... delays. Look for it on IBM soon, and in the > >meanwhile, feel free to read: > > > > http://gnosis.cx/cgi/txt2html.cgi?source=http://gnosis.cx/publish/programming/charming_python_12.txt > > > >Yours, David... > > Thanks for your reviews. It sounds to me that > "The Quick Python Book" is probably my best > initial bet, given that I program already.... > > -- > Owen F. Ransen > http://www.ransen.com/ > Home of Gliftic & Repligator Image Generators From danielk at aracnet.com Sun Feb 18 19:34:42 2001 From: danielk at aracnet.com (Daniel Klein) Date: Sun, 18 Feb 2001 10:34:42 -0800 Subject: Determining EOF character Message-ID: <66409tk72epolackapla0egk4907k9a9hi@4ax.com> When managing child processes (like with popen2.popen2) I have occasion to do instream.readlines() to get all lines in a list rather than instream.readline() which gets the next line terminated with 'os.linesep'. On Windows the child process needs to send a ^Z in response to readlines() and on UNIX it needs to send ^D. I don't know what this is on MAC. What I would like to do is to tell the child process what to use as the EOF character so that my code is platform independent. I have searched thru the 'os' and 'sys' modules for something like a 'os.eof' or 'sys.eof' with no joy. I am currently using '#ifdef WIN32' to determine this in the child process but I would like to move this up to the controlling Python program. If this exists please let me know where. If not, how do I submit an enhancement request? Thank you, Daniel Klein From max at alcyone.com Sun Feb 18 20:35:41 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 18 Feb 2001 11:35:41 -0800 Subject: Determining EOF character References: <66409tk72epolackapla0egk4907k9a9hi@4ax.com> Message-ID: <3A90240D.384ABA3E@alcyone.com> Daniel Klein wrote: > When managing child processes (like with popen2.popen2) I have > occasion to do > > instream.readlines() > > to get all lines in a list rather than > > instream.readline() > > which gets the next line terminated with 'os.linesep'. > > On Windows the child process needs to send a ^Z in response to > readlines() and > on UNIX it needs to send ^D. I don't know what this is on MAC. This isn't the way you should signal end of file. You should signal it the client closing his end of the pipe. In fact, what you suggest above may work on Windows, but it won't work on UNIX -- under UNIX, an end of file isn't indicated with a sentinel character in the stream, but rather with an out-of-bounds indicator (the underlying file structure has an end-of-file flag). As I recall, Windows/DOS does much the same thing, but also treats a ^Z as an explicit end-of-file indicator. -- 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 just don't know why they're shooting at us. \__/ Capt. Benjamin "Hawkeye" Pierce Esperanto reference / http://mirror/alcyone/max/lang/esperanto/ An Esperanto reference for English speakers. From danielk at aracnet.com Sun Feb 18 23:08:10 2001 From: danielk at aracnet.com (Daniel Klein) Date: Sun, 18 Feb 2001 14:08:10 -0800 Subject: Determining EOF character References: <66409tk72epolackapla0egk4907k9a9hi@4ax.com> <3A90240D.384ABA3E@alcyone.com> Message-ID: On Sun, 18 Feb 2001 11:35:41 -0800, Erik Max Francis wrote: >Daniel Klein wrote: >> On Windows the child process needs to send a ^Z in response to >> readlines() and >> on UNIX it needs to send ^D. I don't know what this is on MAC. > >This isn't the way you should signal end of file. You should signal it >the client closing his end of the pipe. In fact, what you suggest above >may work on Windows, but it won't work on UNIX -- under UNIX, an end of >file isn't indicated with a sentinel character in the stream, but rather >with an out-of-bounds indicator (the underlying file structure has an >end-of-file flag). As I recall, Windows/DOS does much the same thing, >but also treats a ^Z as an explicit end-of-file indicator. I'm not sure what you mean by "You should signal it the client closing his end of the pipe". This is an interactive session with the client and server in constant communication. If I close the pipe, I can do no further processing. How do I specify this 'out-of-bounds' indicator? Dan From timr at probo.com Mon Feb 19 03:44:21 2001 From: timr at probo.com (Tim Roberts) Date: Sun, 18 Feb 2001 18:44:21 -0800 Subject: Determining EOF character References: <66409tk72epolackapla0egk4907k9a9hi@4ax.com> <3A90240D.384ABA3E@alcyone.com> Message-ID: Daniel Klein wrote: >On Sun, 18 Feb 2001 11:35:41 -0800, Erik Max Francis wrote: > >>Daniel Klein wrote: >>> On Windows the child process needs to send a ^Z in response to >>> readlines() and >>> on UNIX it needs to send ^D. I don't know what this is on MAC. >> >>This isn't the way you should signal end of file. You should signal it >>the client closing his end of the pipe. In fact, what you suggest above >>may work on Windows, but it won't work on UNIX -- under UNIX, an end of >>file isn't indicated with a sentinel character in the stream, but rather >>with an out-of-bounds indicator (the underlying file structure has an >>end-of-file flag). > >I'm not sure what you mean by "You should signal it the client closing his end >of the pipe". This is an interactive session with the client and server in >constant communication. If I close the pipe, I can do no further processing. I don't understand. If the character you're waiting for doesn't terminate the connection, then why use an O/S-dependent character at all? Why not just choose some arbitrary control character specific to your application. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From danielk at aracnet.com Mon Feb 19 05:30:35 2001 From: danielk at aracnet.com (Daniel Klein) Date: Sun, 18 Feb 2001 20:30:35 -0800 Subject: Determining EOF character References: <66409tk72epolackapla0egk4907k9a9hi@4ax.com> <3A90240D.384ABA3E@alcyone.com> Message-ID: On Sun, 18 Feb 2001 18:44:21 -0800, Tim Roberts wrote: >Daniel Klein wrote: > >>On Sun, 18 Feb 2001 11:35:41 -0800, Erik Max Francis wrote: >> >>>Daniel Klein wrote: >>>> On Windows the child process needs to send a ^Z in response to >>>> readlines() and >>>> on UNIX it needs to send ^D. I don't know what this is on MAC. >>> >>>This isn't the way you should signal end of file. You should signal it >>>the client closing his end of the pipe. In fact, what you suggest above >>>may work on Windows, but it won't work on UNIX -- under UNIX, an end of >>>file isn't indicated with a sentinel character in the stream, but rather >>>with an out-of-bounds indicator (the underlying file structure has an >>>end-of-file flag). >> >>I'm not sure what you mean by "You should signal it the client closing his end >>of the pipe". This is an interactive session with the client and server in >>constant communication. If I close the pipe, I can do no further processing. > >I don't understand. If the character you're waiting for doesn't terminate >the connection, then why use an O/S-dependent character at all? Why not >just choose some arbitrary control character specific to your application. I don't want to terminate the connection, I only want to know when the server (child) process has stopped sending. If I terminate (close) the connection, the server process becomes orphaned. Here is a simple scenario of what I am trying to do: Python (the parent process) starts the child process with 'popen2.popen'. Let's assume that the file handles are called 'instream' and 'outstream'. 1) parent sends a request to the child via outstream 2) child stdin receives the request and performs some action which results in a variable number of lines (say less than 10) of output which are sent to stdout. 3) parent receives the lines via instream, analyzes the lines for it's next action. Go to step 1. This interaction should be continuous until the parent process sends a 'quit' command to the child, at which point the child shuts itself down and the parent proceeds to close both handles (instream and outstream). If the client and server were only sending one line at a time, it would be simple to do with readline() and write(): 1) parent send line 2) child recv line 3) child send line 4) parent recv line 5 go to 1) But, as illustrated above, the server (child) process can sometimes send more than one line and it is not possible to determin in advance how many lines. To be honest, the server process _does_ know how many lines it is sending except when an error occurs. It is these errors that produce an indeterminate number of lines which get sent back to the parent (child stdout --> parent instream). On Windows, all I need to do is send a ^Z to indicate (end of transmission). Dan From qrczak at knm.org.pl Mon Feb 19 22:14:02 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 19 Feb 2001 21:14:02 GMT Subject: Determining EOF character References: <66409tk72epolackapla0egk4907k9a9hi@4ax.com> <3A90240D.384ABA3E@alcyone.com> Message-ID: Sun, 18 Feb 2001 20:30:35 -0800, Daniel Klein pisze: > I don't want to terminate the connection, I only want to know when > the server (child) process has stopped sending. You must invent your own way of signalling this. A way which does not interfere with normal data. There is no other system-wide concept of stopping sending than closing the connection. When you press ^D on a Unix terminal, it is not sent in the stream. It only flushes the line without '\n' at the end. If it was pressed at the beginning of a line (or after a previous ^D), the read() syscall returns 0, which is interpreted as the end of file. The file is not physically closed - the process can read further. But I think it works only for terminals and such signal cannot be sent through a pipe. The read end returns 0 only when the write end closes its pipe handle, and no character is treated specially. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From grante at visi.com Tue Feb 20 00:27:21 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 19 Feb 2001 23:27:21 GMT Subject: Determining EOF character References: <66409tk72epolackapla0egk4907k9a9hi@4ax.com> <3A90240D.384ABA3E@alcyone.com> Message-ID: In article , Marcin 'Qrczak' Kowalczyk wrote: >Sun, 18 Feb 2001 20:30:35 -0800, Daniel Klein pisze: > >> I don't want to terminate the connection, I only want to know when >> the server (child) process has stopped sending. > >You must invent your own way of signalling this. A way which does not >interfere with normal data. There is no other system-wide concept of >stopping sending than closing the connection. > >When you press ^D on a Unix terminal, it is not sent in the stream. >It only flushes the line without '\n' at the end. If it was pressed >at the beginning of a line (or after a previous ^D), the read() >syscall returns 0, which is interpreted as the end of file. IIRC, it's the tty driver that interprets the ^D and generates an EOF condition. The rest of Unix doesn't know ^D from your uncle Bob. >The file is not physically closed - the process can read further. >But I think it works only for terminals and such signal cannot be >sent through a pipe. The read end returns 0 only when the write end >closes its pipe handle, and no character is treated specially. -- Grant Edwards grante Yow! Ha ha Ha ha Ha ha at Ha Ha Ha Ha -- When will I visi.com EVER stop HAVING FUN?!! From chris.gonnerman at usa.net Tue Feb 20 03:47:22 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Mon, 19 Feb 2001 20:47:22 -0600 Subject: Determining EOF character References: <66409tk72epolackapla0egk4907k9a9hi@4ax.com> <3A90240D.384ABA3E@alcyone.com> Message-ID: <006e01c09ae7$798731c0$a100000a@local> ----- Original Message ----- From: "Grant Edwards" Subject: Re: Determining EOF character > In article , Marcin 'Qrczak' Kowalczyk wrote: > >When you press ^D on a Unix terminal, it is not sent in the stream. > >It only flushes the line without '\n' at the end. If it was pressed > >at the beginning of a line (or after a previous ^D), the read() > >syscall returns 0, which is interpreted as the end of file. > > IIRC, it's the tty driver that interprets the ^D and generates an EOF > condition. The rest of Unix doesn't know ^D from your uncle Bob. That's what he said. So why does closing the pipe to signal EOF not work? I've written a great many programs based on that. The writer closes the pipe and terminates, and the reader gets EOF and continues operation. What am I missing here? From jwbnews at scandaroon.com Tue Feb 20 06:11:41 2001 From: jwbnews at scandaroon.com (John W. Baxter) Date: Mon, 19 Feb 2001 21:11:41 -0800 Subject: Determining EOF character References: <66409tk72epolackapla0egk4907k9a9hi@4ax.com> <3A90240D.384ABA3E@alcyone.com> Message-ID: In article , "Chris Gonnerman" wrote: > > So why does closing the pipe to signal EOF not work? I've written a great > many programs > based on that. The writer closes the pipe and terminates, and the reader > gets EOF and > continues operation. What am I missing here? He wants to signal the end of each chunk of data, leaving the pipe open for the next chunk. I think he needs to define and use an end-of-chunk sentinal. --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From grante at visi.com Tue Feb 20 19:07:12 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 20 Feb 2001 18:07:12 GMT Subject: Determining EOF character References: <66409tk72epolackapla0egk4907k9a9hi@4ax.com> <3A90240D.384ABA3E@alcyone.com> Message-ID: In article , John W. Baxter wrote: > >> So why does closing the pipe to signal EOF not work? I've >> written a great many programs based on that. The writer closes >> the pipe and terminates, and the reader gets EOF and continues >> operation. What am I missing here? > >He wants to signal the end of each chunk of data, leaving the pipe open >for the next chunk. I think he needs to define and use an end-of-chunk >sentinal. Often, the easiest thing to do is to pass information in ASCII and use '\n' as the chunk delimiter. That way all of the normal library routines just "do the right thing". If you don't want to use ASCII, you can use some sort of binary protocol (e.g. STX/ETX framing). -- Grant Edwards grante Yow! Look into my eyes and at try to forget that you have visi.com a Macy's charge card! From danielk at aracnet.com Tue Feb 20 15:12:30 2001 From: danielk at aracnet.com (Daniel Klein) Date: Tue, 20 Feb 2001 06:12:30 -0800 Subject: Determining EOF character References: <66409tk72epolackapla0egk4907k9a9hi@4ax.com> <3A90240D.384ABA3E@alcyone.com> Message-ID: <3jt49toov10igcedlj14g336k0c4srsr8a@4ax.com> On Mon, 19 Feb 2001 20:47:22 -0600, "Chris Gonnerman" wrote: >So why does closing the pipe to signal EOF not work? I've written a great many programs >based on that. The writer closes the pipe and terminates, and the reader gets EOF and >continues operation. What am I missing here? John Baxter is correct, but to explain a bit further, the server process could have an entire environment set up; closing the pipe would lose that environment. If I closed the pipe it would be like initializing the same objects for each iteration of a loop, ie while 1: foo = Bar() dead = Parrot() spam = Eggs() # rest of processing using 'foo', 'dead', 'spam' rather than foo = Bar() dead = Parrot() spam = Eggs() while 1: # etc. To be honest, the whole purpose for this was to catch and report unexpected server errors that could not be controlled by the server process. In addition, I had thought to be able to use the 'readlines()' method to recv more than one line at a time. For now, since I can't do this, I have coded around the problem by using only 'readline()' and ensuring that if the server process sends more than one line of data to the client, it will gracefully (rather than violently) shut itself down rather than just 'hang' waiting for an EOF. I do this by always sending an 'expected' reply to the client; if the client does not see this, it takes the aforementioned action. I think you can put this thread to rest at this point. Thanks for all your input, this has been a great learning experience for me. :^) Daniel Klein Portland OR USA From anandg at cs.utexas.edu Sun Feb 18 20:06:46 2001 From: anandg at cs.utexas.edu (Anand Ganesh) Date: Sun, 18 Feb 2001 13:06:46 -0600 Subject: newbie : python path setting on linux Message-ID: Hi, I downloaded the python gtk bindings and compiled the module. I've a set of files in the directory ~/tmp/pygtk-0.6.6. Now I try to run the examples in ~/tmp/pygtk-0.6.6/examples/simple say simple1.py. It says : ImportError: No module named _gtk Now, I tried fiddling with PYTHONPATH and PYTHONHOME. I set PYTHONHOME to ~/tmp/pygtk-0.6.6 and PYTHONPATH to ./ (b'cos PYTHONHOME is prefixed ?). Anyways, didnt work. Same error. Infact printing sys.path I find that it doesnt have ~/tmp/pygtk-0.6.6 on it at all. I'm totally confused. I dont have root perms to install the gtk module in the standard places...any help appreciated. Thanks, Anand. From max at alcyone.com Sun Feb 18 20:37:38 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 18 Feb 2001 11:37:38 -0800 Subject: newbie : python path setting on linux References: Message-ID: <3A902482.D1FF0683@alcyone.com> Anand Ganesh wrote: > I downloaded the python gtk bindings and compiled the module. > I've a set of files in the directory ~/tmp/pygtk-0.6.6. Now I try to > run the examples in ~/tmp/pygtk-0.6.6/examples/simple say simple1.py. > It says : > ImportError: No module named _gtk > > Now, I tried fiddling with PYTHONPATH and PYTHONHOME. I set PYTHONHOME > to > ~/tmp/pygtk-0.6.6 and PYTHONPATH to ./ (b'cos PYTHONHOME is prefixed > ?). > Anyways, didnt work. Same error. Infact printing sys.path I find that > it > doesnt have ~/tmp/pygtk-0.6.6 on it at all. Because you didn't add it to it. PYTHONHOME indicates where the main Python directory resides (if different from the compiled-in default, if it's in your path); PYTHONPATH adds additional search paths. You should add the directory which the actual gtk module resides in to PYTHONPATH, not PYTHONHOME. -- 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 just don't know why they're shooting at us. \__/ Capt. Benjamin "Hawkeye" Pierce Esperanto reference / http://mirror/alcyone/max/lang/esperanto/ An Esperanto reference for English speakers. From phlip_cpp at my-deja.com Sun Feb 18 20:23:14 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 18 Feb 2001 19:23:14 GMT Subject: What's up with enscript for syntax highlighting? Message-ID: <96p7f2$bqi@dispatch.concentric.net> Noh Typ: Here's a command for GNU enscript 1.6.1: enscript --pretty-print=python Kozmik.py --language=html --output=Kozmik.py.html The output ain't pretty. It uses no colors. How do I convert Python to syntax highlighted HTML? Is there a class library available somewhere on www.python.org (perhaps under "hilite" or something? or is there a better version of enscript? -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- Personally qualified to snub Mensa -- From phlip_cpp at my-deja.com Sun Feb 18 20:29:56 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 18 Feb 2001 19:29:56 GMT Subject: What's up with enscript for syntax highlighting? References: <96p7f2$bqi@dispatch.concentric.net> Message-ID: <96p7rk$sub@dispatch.concentric.net> Proclaimed Phlip from the mountaintops: > Is there a class > library available somewhere on www.python.org (perhaps under "hilite" or > something? It's in ClassModules.py you dumb f**k - can't you tell by the name? http://www.lemburg.com/files/python/doc.py.html -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- Have a :-) day -- From thomas at xs4all.net Sun Feb 18 22:13:36 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 18 Feb 2001 22:13:36 +0100 Subject: What's up with enscript for syntax highlighting? In-Reply-To: <96p7rk$sub@dispatch.concentric.net>; from phlip_cpp@my-deja.com on Sun, Feb 18, 2001 at 07:29:56PM +0000 References: <96p7f2$bqi@dispatch.concentric.net> <96p7rk$sub@dispatch.concentric.net> Message-ID: <20010218221336.C14292@xs4all.nl> On Sun, Feb 18, 2001 at 07:29:56PM +0000, Phlip wrote: > Proclaimed Phlip from the mountaintops: > > Is there a class > > library available somewhere on www.python.org (perhaps under "hilite" or > > something? > It's in ClassModules.py you dumb f**k - can't you tell by the name? That's totally uncalled for. Being a newbie might be a grave error, but one everyone commits at some point in life. Furthermore, RTFM is much more effective if you do it gently and make them feel nicely embarassed, rather than having them just say 'well, fuck you too' when reading the first insult, and not learn a thing. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From tim.one at home.com Sun Feb 18 22:41:13 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 18 Feb 2001 16:41:13 -0500 Subject: What's up with enscript for syntax highlighting? In-Reply-To: <20010218221336.C14292@xs4all.nl> Message-ID: > On Sun, Feb 18, 2001 at 07:29:56PM +0000, Phlip wrote: > > Proclaimed Phlip from the mountaintops: > >>> Is there a class >>> library available somewhere on www.python.org (perhaps under >>> "hilite" or something? > >> It's in ClassModules.py you dumb f**k - can't you tell by the name? [Thomas Wouters] > That's totally uncalled for. ... Yes. Still, Philip *was* flaming himself. I was hoping he'd follow it up with a post admonishing himself for being so gauche, and then defend himself to himself, and after a long bitter battle eventually make up and hug himself for all to see and learn from. I guess he did that offline . civility-is-mandatory-but-sanity-is-optional-ly y'rs - tim From phlip_cpp at my-deja.com Sun Feb 18 22:32:06 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 18 Feb 2001 21:32:06 GMT Subject: What's up with enscript for syntax highlighting? References: <96p7f2$bqi@dispatch.concentric.net> <96p7rk$sub@dispatch.concentric.net> Message-ID: <96pf0m$sur@dispatch.concentric.net> Proclaimed Thomas Wouters from the mountaintops: > On Sun, Feb 18, 2001 at 07:29:56PM +0000, Phlip wrote: >> Proclaimed Phlip from the mountaintops: > >> > Is there a class >> > library available somewhere on www.python.org (perhaps under "hilite" >> > or something? > >> It's in ClassModules.py you dumb f**k - can't you tell by the name? > > That's totally uncalled for. Being a newbie might be a grave error, but > one everyone commits at some point in life. Furthermore, RTFM is much more > effective if you do it gently and make them feel nicely embarassed, rather > than having them just say 'well, fuck you too' when reading the first > insult, and not learn a thing. Thanks. I'l try to keep that in mind the next time I flame myself. -- Phlip phlip_cpp at my-deja.com ============== http://phlip.webjump.com ============== -- I'l have my Web site call your Web site... -- From amk at mira.erols.com Tue Feb 20 01:54:43 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 20 Feb 2001 00:54:43 GMT Subject: What's up with enscript for syntax highlighting? References: <96p7f2$bqi@dispatch.concentric.net> <96p7rk$sub@dispatch.concentric.net> <96pf0m$sur@dispatch.concentric.net> Message-ID: On 18 Feb 2001 21:32:06 GMT, Phlip wrote: >Proclaimed Thomas Wouters from the mountaintops: >> one everyone commits at some point in life. Furthermore, RTFM is much more >> effective if you do it gently and make them feel nicely embarassed, rather >> than having them just say 'well, fuck you too' when reading the first >> insult, and not learn a thing. > >Thanks. I'l try to keep that in mind the next time I flame myself. Isn't comp.lang.python a great newsgroup? :) --amk From phlip_cpp at my-deja.com Sun Feb 18 20:51:55 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 18 Feb 2001 19:51:55 GMT Subject: What's up with enscript for syntax highlighting? References: <96p7f2$bqi@dispatch.concentric.net> Message-ID: <96p94r$sub@dispatch.concentric.net> Proclaimed Phlip from the mountaintops: > Here's a command for GNU enscript 1.6.1: > > enscript --pretty-print=python Kozmik.py --language=html > --output=Kozmik.py.html > > The output ain't pretty. It uses no colors. Per this exellent brand-new site I've just discovered called http://groups.google.com, those brave enough to survive the terrors of 'gvim' can click on its menu items Syntax -> Convert to HTML to get some color in their life. Man, putting all the USENET archives in one Web site's a killer idea. Why hasn't anyone ever thought of that before? ;-) -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- The first few lines of code must "hook" the computer, and make it "care" about the program -- From phlip_cpp at my-deja.com Sun Feb 18 21:16:11 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 18 Feb 2001 20:16:11 GMT Subject: SNIPPET: Pipe Graphviz's graph geometry into Pmw.ScrolledCanvas Message-ID: <96paib$7j@dispatch.concentric.net> Not Hyp: Thanks for all that help on the colorized HTML problem - this newsgroup's a real lifesaver, huh? I have just finished wrapping www.graphviz.org's 'dot' language in Python. You define a graph (a set of nodes connected by edges) as Node objects in Python, and 'dot' determines how to display them asthetically with the edges as curves and the vertices as ovals with labels in them. /Tres/ cutsey. The code looks a little bit like this: http://freehosting1.at.webjump.com/5e5d5afd9/ph/phlip-webjump/Grapher.py.html http://freehosting1.at.webjump.com/5e5d5afd9/ph/phlip-webjump/Grapher.py That's off my new Web site: http://phlip.webjump.com The jiggling baloney's a little heavy, but it was the first free site I could find that didn't already have a "phlip". Poseurs. After Grapher.py translates the Nodes to the most primitive example of 'dot' language, 'dot' reads this and writes either a plain text representation, or a PostScript file. It can probably do other formats too. More Grapher.py code then reads the plain text representation, extracts all the beautiful screen coordinates from it, associates them with the Nodes they came from, and paints these on a Python MegaWidgets Pmw.ScrolledCanvas suitable for framing. The source code illustrates Design Patterns (but I forget which ones), de-coupling (sort of), dictionaries, lists, and other goodies. -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- DARE to resist drug-war profiteering -- From phlip_cpp at my-deja.com Sun Feb 18 22:33:01 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 18 Feb 2001 21:33:01 GMT Subject: SNIPPET: Pipe Graphviz's graph geometry into Pmw.ScrolledCanvas References: <96paib$7j@dispatch.concentric.net> Message-ID: <96pf2d$38@freepress.concentric.net> Proclaimed Phlip from the mountaintops: > http://freehosting1.at.webjump.com/5e5d5afd9/ph/phlip-webjump/Grapher.py.html > > http://freehosting1.at.webjump.com/5e5d5afd9/ph/phlip-webjump/Grapher.py Sorry - those click-thru's don't work. Jeeze good free help is hard to find! > That's off my new Web site: > > http://phlip.webjump.com -- Phlip phlip_cpp at my-deja.com ============== http://phlip.webjump.com ============== -- Whoever dies with the most features wins -- From stevemak at softhome.net Sun Feb 18 22:38:54 2001 From: stevemak at softhome.net (Steve Mak) Date: Sun, 18 Feb 2001 21:38:54 GMT Subject: Pls Help! Need binary search tree module Message-ID: I was wondering if anyone had a simple binary search tree module I could use? I need to write a program that counts the number of occurrences of each word in a file, and outputs the word and corresponding counts alphabetically. And it is required that one of the data structure is a binary search tree. Eg: if the inputs is: "How are you. How are you. How are you." the output is: are 3 how 3 you 3 Thanks in advance!!!!!!!! JJ From fredrik at pythonware.com Sun Feb 18 22:51:12 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 18 Feb 2001 21:51:12 GMT Subject: Pls Help! Need binary search tree module References: Message-ID: Steve Mak wrote: > I was wondering if anyone had a simple binary search tree module I could > use? I need to write a program that counts the number of occurrences of each > word in a file, and outputs the word and corresponding counts > alphabetically. And it is required that one of the data structure is a > binary search tree. are you sure your teacher doesn't read comp.lang.python? I'm pretty sure you'll learn more if you do it yourself, but you could take a look at the bisect.py module (it's in Python's Lib directory). Cheers /F From phlip_cpp at my-deja.com Sun Feb 18 23:00:43 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 18 Feb 2001 22:00:43 GMT Subject: Pls Help! Need binary search tree module References: Message-ID: <96pgmb$b4o@dispatch.concentric.net> Proclaimed Steve Mak from the mountaintops: > I was wondering if anyone had a simple binary search tree module I could > use? I need to write a program that counts the number of occurrences of > each word in a file, and outputs the word and corresponding counts > alphabetically. And it is required that one of the data structure is a > binary search tree. > > Eg: if the inputs is: > > "How are you. How are you. How are you." > > the output is: > > are 3 > how 3 > you 3 What's wrong with using a dictionary object? That supplies a hash or something for you behind a clean interface. Is this for a class? Look up 'has_key' to get started. -- Phlip phlip_cpp at my-deja.com ============== http://phlip.webjump.com ============== -- Personally qualified to snub Mensa -- From stevemak at softhome.net Sun Feb 18 23:28:22 2001 From: stevemak at softhome.net (Steve Mak) Date: Sun, 18 Feb 2001 22:28:22 GMT Subject: ATTN: Phlip References: <96pgmb$b4o@dispatch.concentric.net> Message-ID: <3A904EAB.2AA272A4@softhome.net> Hey Phlip Yes, it's for class....the dictionary object would make things ALOT easier, but they want us to use a bst, so I can't help it! Can you help me? From phlip_cpp at my-deja.com Mon Feb 19 01:15:27 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 19 Feb 2001 00:15:27 GMT Subject: ATTN: Phlip References: <96pgmb$b4o@dispatch.concentric.net> <3A904EAB.2AA272A4@softhome.net> Message-ID: <96poiv$crf@dispatch.concentric.net> Proclaimed Steve Mak from the mountaintops: > Hey Phlip > > Yes, it's for class....the dictionary object would make things ALOT > easier, but they want us to use a bst, so I can't help it! Can you help > me? Okay. Try this: class Node: def __init__ (self, left, right, label): (self.left, self.right, self.label) = (left, right, label) return a = Node (None, None, "a") g = Node (None, None, "g") p = Node (None, None, "p") z = Node (None, None, "z") f = Node (a, g, "f") u = Node (p, z, "u") o = Node (f, u, "o") There. That's a tree balanced by alpha order. But it can't insert or rebalance by itself. But adding an in-order traversal method would be trivial. The best thing now would be to write a Unit Test that expresses what your interface should do. http://c2.com/cgi/wiki?CodeUnitTestFirst Then you run it over and over again until there are no error messages or assertion exceptions: def testTree (): t = Tree () assert (t.count () == 0) leaf = t.addLeaf ("leaf") assert (t.count () == 1) got = t.getLeaf ("leaf") assert (got == leaf) ... Doing it test-first like this keeps the hugest projects locked on track. -- Phlip phlip_cpp at my-deja.com ============== http://phlip.webjump.com ============== -- Have a :-) day - From gregj at pobox.com Mon Feb 19 08:07:02 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Mon, 19 Feb 2001 07:07:02 GMT Subject: Pls Help! Need binary search tree module References: Message-ID: <3a90c1c4.48617037@news.potlnd1.or.home.com> On Sun, 18 Feb 2001 21:38:54 GMT, "Steve Mak" wrote: >I was wondering if anyone had a simple binary search tree module I could >use? I need to write a program that counts the number of occurrences of each >word in a file, and outputs the word and corresponding counts >alphabetically. And it is required that one of the data structure is a >binary search tree. > > Eg: if the inputs is: > >"How are you. How are you. How are you." > >the output is: > >are 3 >how 3 >you 3 If you are working on an assignment and must use a binary search tree, I refer you to Sedgewick's book "Algorithms." Translating pointer-based trees to Python will challenge your Python skills. Hint: a Python list can contain ANY kind of object reference, including references to other lists. I implemented Sedgewick's algorithms in Python (from his C versions) in about 30 minutes. The typical Python way to do what you describe uses a dictionary with the words as keys as a counter as the value. For example: # insert/count words using dictionary words = ['your', 'list', 'of', 'words'] wc = {} for w in words: if wc.has_key(w): wc[w] += 1 else: wc[w] = 1 # show counts by word in alpha order words = wc.keys() words.sort() for w in words: print "%s: %d" % (w, wc[w]) Greg Jorgensen Deschooling Society Portland, Oregon USA From othello at javanet.com Fri Feb 23 03:22:06 2001 From: othello at javanet.com (Raymond Hettinger) Date: Thu, 22 Feb 2001 21:22:06 -0500 Subject: Pls Help! Need binary search tree module References: Message-ID: <3A95C94E.FBDD0C7@javanet.com> Steve Mak wrote: > I was wondering if anyone had a simple binary search tree module I could > use? I need to write a program that counts the number of occurrences of each > word in a file, and outputs the word and corresponding counts > alphabetically. And it is required that one of the data structure is a > binary search tree. > Here's a list oriented, binary counting tree for you: def add( n, elem ): if n == None: n = [ elem, 1, None, None ] elif n[0] == elem: n[1] += 1 else: tgt = 2 # choose left side if elem > n[0]: tgt = 3 # choose right side n[tgt] = add( n[tgt], elem ) return n n = None for w in "the man and the moon and the tree".split(): n = add(n,w) print n Raymond From seandc at att.net Sun Feb 18 22:39:35 2001 From: seandc at att.net (Sean Doull-Connolly) Date: Sun, 18 Feb 2001 21:39:35 GMT Subject: Tkinter Widgets Needed Message-ID: <3A9040CE.33B00019@att.net> Does anyone know of widgets I can use to build data-entry tools for a database: 1. Number Entry Passed parameters: Given value (as text string) Length Number of decimals Displays The given value with the decimal point in the correct spot Accepts Only legal input (eg 0-9 and .) Example: ne = NumberEntry(MasterFrame, ('9999.99', 10, 2)) .... returnval = ne.get() 2. Date Entry Passed parameters: Given value (as text string) Century ON/OFF Displays The given value with the date correctly formatted Accepts Only legal input (eg 0-9 and /) and parses the date (Zeller?) to ensure date is real Example: de = DateEntry(MasterFrame, ('20010218', ON)) .... returnval = de.get() Thanks. Sean seandc at att.net From phlip_cpp at my-deja.com Mon Feb 19 18:10:05 2001 From: phlip_cpp at my-deja.com (Phlip) Date: Mon, 19 Feb 2001 09:10:05 -0800 Subject: Tkinter Widgets Needed References: <3A9040CE.33B00019@att.net> Message-ID: Sean Doull-Connolly wrote: > 1. Number Entry > 2. Date Entry Python MegaWidgets has a zillion full-featured Tkinter controls, including a formatted entry field that can do numbers and dates. -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- Proud victim of the dreaded boomerang effect -- From Mike_B at T-Online.de Sun Feb 18 23:21:44 2001 From: Mike_B at T-Online.de (Michael Bauer) Date: Sun, 18 Feb 2001 23:21:44 +0100 Subject: How to determine own IP Message-ID: <96phtr$rar$07$1@news.t-online.com> Hi * I'm stuck with a kind of dumb problem. I'm implementing a project based on a distributed, decentralised network. Communication between nodes is established through xml-rpc. For a new host to gather some other members of the network, it sends out a PING that is passed on through the net. Each host receiving the PING returns a PONG. Since the PONG is not sent directly to the new host but passed back through all hosts that passed on the PING, i need to store the IP of the answering hosts inside the PONG package. Now, to the real problem :-) If a host has more than one network adapter, how do i know which IP should i put inside the PONG package? Specifically, when dealing with dial-up users who are also connected to a LAN, gethostbyname(gethostname()) always returns their internal adress. Any ideas? From thomas at xs4all.net Sun Feb 18 23:51:12 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 18 Feb 2001 23:51:12 +0100 Subject: How to determine own IP In-Reply-To: <96phtr$rar$07$1@news.t-online.com>; from Mike_B@T-Online.de on Sun, Feb 18, 2001 at 11:21:44PM +0100 References: <96phtr$rar$07$1@news.t-online.com> Message-ID: <20010218235112.E14292@xs4all.nl> On Sun, Feb 18, 2001 at 11:21:44PM +0100, Michael Bauer wrote: > I'm stuck with a kind of dumb problem. I'm implementing a project based on > a distributed, decentralised network. Communication between nodes is > established through xml-rpc. > For a new host to gather some other members of the network, it sends out a > PING that is passed on through the net. Each host receiving the PING > returns a PONG. Since the PONG is not sent directly to the new host but > passed back through all hosts that passed on the PING, i need to store the > IP of the answering hosts inside the PONG package. > Now, to the real problem :-) > If a host has more than one network adapter, how do i know which IP should > i put inside the PONG package? > Specifically, when dealing with dial-up users who are also connected to a > LAN, gethostbyname(gethostname()) always returns their internal adress. And don't forget multi-homed machines (multiple network cards/ip-addresses) and NAT/IP-Masquerading. You can't always trust what a machine thinks is its own ipaddress. > Any ideas? Have a 'WHOAMI' command/function/packet that's answered by the directly connected node(s). If you want highly-connected nodes, consider treating each node's response as unique for that node (so you can work both 'inside' and 'outside' a masqueraded network) and always use it for communication that came through the node. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From Mike_B at T-Online.de Mon Feb 19 00:21:09 2001 From: Mike_B at T-Online.de (Michael Bauer) Date: Mon, 19 Feb 2001 00:21:09 +0100 Subject: How to determine own IP References: <96phtr$rar$07$1@news.t-online.com> Message-ID: <96pld8$s5t$05$1@news.t-online.com> Thomas Wouters wrote: > On Sun, Feb 18, 2001 at 11:21:44PM +0100, Michael Bauer wrote: >> Now, to the real problem :-) >> If a host has more than one network adapter, how do i know which IP >> should >> i put inside the PONG package? >> Specifically, when dealing with dial-up users who are also connected to a >> LAN, gethostbyname(gethostname()) always returns their internal adress. > > And don't forget multi-homed machines (multiple network > cards/ip-addresses) and NAT/IP-Masquerading. You can't always trust what a > machine thinks is its own ipaddress. > >> Any ideas? > > Have a 'WHOAMI' command/function/packet that's answered by the directly > connected node(s). If you want highly-connected nodes, consider treating > each node's response as unique for that node (so you can work both > 'inside' and 'outside' a masqueraded network) and always use it for > communication that came through the node. Great! Sometimes when you think something is really hard to solve, it turns out to be quite obvious ;-) Thank you, Mike -- From bryan at eevolved.com Mon Feb 19 07:14:47 2001 From: bryan at eevolved.com (Bryan Mongeau) Date: Mon, 19 Feb 2001 06:14:47 GMT Subject: How to determine own IP References: <96phtr$rar$07$1@news.t-online.com> Message-ID: Michael Bauer wrote: > Hi * > > I'm stuck with a kind of dumb problem. I'm implementing a project based on > a distributed, decentralised network. Communication between nodes is > established through xml-rpc. > For a new host to gather some other members of the network, it sends out a > PING that is passed on through the net. Each host receiving the PING > returns a PONG. Since the PONG is not sent directly to the new host but > passed back through all hosts that passed on the PING, i need to store the > IP of the answering hosts inside the PONG package. > Now, to the real problem :-) > If a host has more than one network adapter, how do i know which IP should > i put inside the PONG package? > Specifically, when dealing with dial-up users who are also connected to a > LAN, gethostbyname(gethostname()) always returns their internal adress. > > Any ideas? > Umm, I won't pretend to understand your entire protocol from this brief description but I do applaud your attempt and your choice of programming language. However, from what I understand, it sounds like your scheme won't scale well with many users due to the high number of ping/pongs. Learn from the mistakes of others: http://www.monkey.org/~dugsong/mirror/gnutella.html Good luck and I apologize if this problem does not apply to your protocol. -- <==================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. http://www.eevolved.com <==================================> "This is one of the hardest lessons for humans to learn. We cannot admit that things might be neither good nor evil, neither cruel nor kind, but simply callous - indifferent to all suffering, lacking all purpose." -- Richard Dawkins From Mike_B at T-Online.de Mon Feb 19 10:57:05 2001 From: Mike_B at T-Online.de (Michael Bauer) Date: Mon, 19 Feb 2001 10:57:05 +0100 Subject: How to determine own IP References: <96phtr$rar$07$1@news.t-online.com> Message-ID: <96qqlk$er0$05$1@news.t-online.com> Bryan Mongeau wrote: > Michael Bauer wrote: > > > [distributed network, PING and PONG] > > Umm, I won't pretend to understand your entire protocol from this brief > description but I do applaud your attempt and your choice of programming > language. However, from what I understand, it sounds like your scheme > won't scale well with many users due to the high number of ping/pongs. > > Learn from the mistakes of others: > http://www.monkey.org/~dugsong/mirror/gnutella.html Yeah, i already know this document. It actually does apply to our project but with a much lesser impact since we took some measures to reduce the amount of PING and PONG going through the network. Another problem with gnutella seems to be the shere number of search requests a user kicks off, while we produce network traffic rather seldom. > Good luck and I apologize if this problem does not apply to your protocol. Thank you, i appreciated your reply :-) Mike -- excuse my poor English... From bryan at eevolved.com Tue Feb 20 03:44:59 2001 From: bryan at eevolved.com (Bryan Mongeau) Date: Tue, 20 Feb 2001 02:44:59 GMT Subject: How to determine own IP References: <96phtr$rar$07$1@news.t-online.com> <96qqlk$er0$05$1@news.t-online.com> Message-ID: Michael Bauer wrote: > Bryan Mongeau wrote: > > > Michael Bauer wrote: > > > > > [distributed network, PING and PONG] > > > > Umm, I won't pretend to understand your entire protocol from this brief > > description but I do applaud your attempt and your choice of programming > > language. However, from what I understand, it sounds like your scheme > > won't scale well with many users due to the high number of ping/pongs. > > > > Learn from the mistakes of others: > > http://www.monkey.org/~dugsong/mirror/gnutella.html > > Yeah, i already know this document. It actually does apply to our project > but with a much lesser impact since we took some measures to reduce the > amount of PING and PONG going through the network. > Another problem with gnutella seems to be the shere number of search > requests a user kicks off, while we produce network traffic rather seldom. > > > Good luck and I apologize if this problem does not apply to your > > protocol. > > Thank you, i appreciated your reply :-) > > Mike > I'd be interested in learning more about your protocol and network. Do you have anything up yet? Docs would be nice... I say this because I think it's about time someone uses python for this application. Could be the killer app that propells python into the mainstream. -- <==================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. http://www.eevolved.com <==================================> "Scientific beliefs are supported by evidence, and they get results. Myths and faiths are not and do not" -- Richard Dawkins From Mike_B at T-Online.de Tue Feb 20 23:54:54 2001 From: Mike_B at T-Online.de (Michael Bauer) Date: Tue, 20 Feb 2001 23:54:54 +0100 Subject: How to determine own IP References: <96phtr$rar$07$1@news.t-online.com> <96qqlk$er0$05$1@news.t-online.com> Message-ID: <96usmk$107$05$1@news.t-online.com> Bryan Mongeau wrote: > I'd be interested in learning more about your protocol and network. Do you > have anything up yet? Docs would be nice... I say this because I think > it's about time someone uses python for this application. Could be the > killer app that propells python into the mainstream. Well, there is nothing available yet for the masses, but as soon as we finished a first release-able version i will announce it here, since we indeed think we might be building a killer-app :-) cu Mike -- Please excuse my poor English... From donn at oz.net Mon Feb 19 07:25:53 2001 From: donn at oz.net (Donn Cave) Date: 19 Feb 2001 06:25:53 GMT Subject: How to determine own IP References: <96phtr$rar$07$1@news.t-online.com> Message-ID: <96qe9h$962$0@216.39.151.169> Quoth Michael Bauer : ... | If a host has more than one network adapter, how do i know which IP should | i put inside the PONG package? | Specifically, when dealing with dial-up users who are also connected to a | LAN, gethostbyname(gethostname()) always returns their internal adress. If you have a connected socket s, s.getsockname() will return the IP address and port number of the local endpoint. Donn Cave, donn at oz.net From Mike_B at T-Online.de Mon Feb 19 10:58:48 2001 From: Mike_B at T-Online.de (Michael Bauer) Date: Mon, 19 Feb 2001 10:58:48 +0100 Subject: How to determine own IP References: <96phtr$rar$07$1@news.t-online.com> <96qe9h$962$0@216.39.151.169> Message-ID: <96qqoq$er0$05$2@news.t-online.com> Donn Cave wrote: > Quoth Michael Bauer : > ... > | If a host has more than one network adapter, how do i know which IP > | should > | i put inside the PONG package? > | Specifically, when dealing with dial-up users who are also connected to > | a LAN, gethostbyname(gethostname()) always returns their internal > | adress. > > If you have a connected socket s, s.getsockname() will return the > IP address and port number of the local endpoint. Hmm, seems even better than the first solution! Thanks, Mike -- Excuse my poor english... From akuchlin at mems-exchange.org Sun Feb 18 23:47:33 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 18 Feb 2001 17:47:33 -0500 Subject: How widespread is NIS support? Message-ID: <3d1ysv8v7e.fsf@ute.cnri.reston.va.us> Does anyone have an idea how widespread NIS support is these days? Patch #103544 changes the 2.1 setup.py script to compile the NIS module on any Unix platform, and I'm wondering if that's too ambitious. Is anyone out there using a Unix *without* NIS? (Try 'man yp_get_default_domain' and see if you get anything, for a start.) Are the NIS functions part of libc, or in a different library (such as libnsl on Solaris). --amk From jwbnews at scandaroon.com Mon Feb 19 01:19:40 2001 From: jwbnews at scandaroon.com (John W. Baxter) Date: Sun, 18 Feb 2001 16:19:40 -0800 Subject: How widespread is NIS support? References: <3d1ysv8v7e.fsf@ute.cnri.reston.va.us> Message-ID: In article <3d1ysv8v7e.fsf at ute.cnri.reston.va.us>, Andrew Kuchling wrote: > Does anyone have an idea how widespread NIS support is these days? > Patch #103544 changes the 2.1 setup.py script to compile the NIS > module on any Unix platform, and I'm wondering if that's too > ambitious. Is anyone out there using a Unix *without* NIS? (Try 'man > yp_get_default_domain' and see if you get anything, for a start.) Are > the NIS functions part of libc, or in a different library (such as > libnsl on Solaris). > > --amk We don't run NIS on our farm of a few BSDi machines and several Linux (Red Hat, which is beginning to look like "unfortunately" to me, but we'll see how 7.1 is). I don't run it on my laptop's Linux (safely in 6.2 at the moment), I don't thing the boss runs it on his. Whether or not we could compile it, I don't know. But if the code in Python expects NIS to actually *do* something, we'll have a problem. --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From akuchlin at mems-exchange.org Mon Feb 19 16:28:05 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 19 Feb 2001 10:28:05 -0500 Subject: How widespread is NIS support? References: <3d1ysv8v7e.fsf@ute.cnri.reston.va.us> Message-ID: <3dy9v27kvu.fsf@ute.cnri.reston.va.us> "John W. Baxter" writes: > Whether or not we could compile it, I don't know. But if the code in > Python expects NIS to actually *do* something, we'll have a problem. glibc 2.x includes NIS support (in libnsl), so it's available on my Red Hat 6.2 machine, and probably on your 7.0 boxes, too. Luckily, the NIS test is smart enough to figure out if NIS is enabled, and skips the test if it isn't. I'm simply concerned whether the module will compile everywhere. --amk From mark at chem.uwa.edu.au Mon Feb 19 22:38:23 2001 From: mark at chem.uwa.edu.au (Mark C Favas) Date: 19 Feb 01 21:38:23 GMT Subject: How widespread is NIS support? References: <3d1ysv8v7e.fsf@ute.cnri.reston.va.us> <3dy9v27kvu.fsf@ute.cnri.reston.va.us> Message-ID: [Andrew Kuchling wonders whether the nis module will compile everywhere on Unix] >the NIS test is smart enough to figure out if NIS is enabled, and >skips the test if it isn't. I'm simply concerned whether the module >will compile everywhere. Well, at least ithe version of nis in 2.1a2 compiles without warnings on Tru64 Unix, V4.0F with Compaq's C compiler, and does the right thing with "make test" (since nis is installed but not running): test_nis test test_nis skipped -- internal NIS server or client error and when run manually: python Lib/test/test_nis.py nis.maps() Traceback (most recent call last): File "Lib/test/test_nis.py", line 10, in ? raise TestFailed, msg test_support.TestFailed: internal NIS server or client error As mentioned in previously, nis support on this platform is in libc. -- Email - mark at chem.uwa.edu.au ,-_|\ Mark C Favas Phone - +61 9 380 3482 / \ Department of Chemistry Fax - +61 9 380 1005 ---> *_,-._/ The University of Western Australia v Nedlands Loc - 31.97 S, 115.81 E Western Australia 6009 From mwh21 at cam.ac.uk Mon Feb 19 01:25:32 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 19 Feb 2001 00:25:32 +0000 Subject: How widespread is NIS support? References: <3d1ysv8v7e.fsf@ute.cnri.reston.va.us> Message-ID: Andrew Kuchling writes: > Does anyone have an idea how widespread NIS support is these days? > Patch #103544 changes the 2.1 setup.py script to compile the NIS > module on any Unix platform, and I'm wondering if that's too > ambitious. Is anyone out there using a Unix *without* NIS? (Try 'man > yp_get_default_domain' and see if you get anything, for a start.) Are > the NIS functions part of libc, or in a different library (such as > libnsl on Solaris). Well; $ man yp_get_default_domain No manual entry for yp_get_default_domain $ uname -a Linux atrus.jesus.cam.ac.uk 2.2.14-1.1.0 #1 Thu Jan 6 05:12:58 EST 2000 i686 unknown And nismodule.c didn't build the last time I tried it... I suppose I could install the yp-tools rpm, but I'm not in any hurry to... Cheers, M. -- First time I've gotten a programming job that required a drug test. I was worried they were going to say "you don't have enough LSD in your system to do Unix programming". -- Paul Tomblin -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html From mark at chem.uwa.edu.au Mon Feb 19 08:49:37 2001 From: mark at chem.uwa.edu.au (Mark C Favas) Date: 19 Feb 01 07:49:37 GMT Subject: How widespread is NIS support? References: <3d1ysv8v7e.fsf@ute.cnri.reston.va.us> Message-ID: [Andrew Kuchling asks about NIS support on Unix] >Patch #103544 changes the 2.1 setup.py script to compile the NIS >module on any Unix platform, and I'm wondering if that's too >ambitious. Is anyone out there using a Unix *without* NIS? (Try 'man >yp_get_default_domain' and see if you get anything, for a start.) Are >the NIS functions part of libc, or in a different library (such as >libnsl on Solaris). I think most variants have NIS support. In Tru64 (nee Digital Unix or OSF1), the NIS functions are part of libc, with include files in /usr/include/rpcsvc/: yp_prot.h, ypclnt.h, ypdefs.h, yppasswd.h, ypsym.h, ypupdate_prot.h, ypv1_prot.h and ypxfrd.h. -- Email - mark at chem.uwa.edu.au ,-_|\ Mark C Favas Phone - +61 9 380 3482 / \ Department of Chemistry Fax - +61 9 380 1005 ---> *_,-._/ The University of Western Australia v Nedlands Loc - 31.97 S, 115.81 E Western Australia 6009 From andymac at bullseye.apana.org.au Mon Feb 19 22:23:15 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Tue, 20 Feb 2001 08:23:15 +1100 (EDT) Subject: How widespread is NIS support? In-Reply-To: <3d1ysv8v7e.fsf@ute.cnri.reston.va.us> Message-ID: On 18 Feb 2001, Andrew Kuchling wrote: > Does anyone have an idea how widespread NIS support is these days? > Patch #103544 changes the 2.1 setup.py script to compile the NIS > module on any Unix platform, and I'm wondering if that's too > ambitious. Is anyone out there using a Unix *without* NIS? (Try 'man > yp_get_default_domain' and see if you get anything, for a start.) Are > the NIS functions part of libc, or in a different library (such as > libnsl on Solaris). Be aware (you probably are...) that there's NIS and NIS+. FreeBSD supports NIS (though not NIS+) but doesn't have the 'yp_get_default_domain' man page you refer to. I think the other BSDs and most Linux distros are in the same boat. >From memory (some time ago...) an older HP-UX system (8.0?) had NIS support, so I would expect most commercial Unixen to have this. Given the above, 'yp_get_default_domain' may be a NIS+ call, although FreeBSD's nis (actually yp(4)) man page notes that many NIS functions don't have man pages - the *BSDs & Linux using a freely distributable implementation of NIS. AFAIK, NIS+ is Solaris only, but its possible that SGI and HP may have licensed it as well (I have access to no system of either of these latter two to check). I'm not aware of any freely available/distributable implemention of NIS+. -- 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 aahz at panix.com Tue Feb 20 06:16:12 2001 From: aahz at panix.com (Aahz Maruch) Date: 19 Feb 2001 21:16:12 -0800 Subject: How widespread is NIS support? References: Message-ID: <96suis$2c1$1@panix3.panix.com> In article , Andrew MacIntyre wrote: > >FreeBSD supports NIS (though not NIS+) but doesn't have the >'yp_get_default_domain' man page you refer to. I think the other BSDs and >most Linux distros are in the same boat. Interesting. My Panix account (NetBSD 1.4.3) has that man page, but you're right about FreeBSD and the Linux on starship.python.net. -- --- 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 "Laws that restrict speech are an abomination for a simple reason. They're like a poison gas; they seem to be a good weapon to vanquish your enemy, but the wind has a way of shifting." -- Ira Glasser From amk at mira.erols.com Wed Feb 21 03:28:22 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 21 Feb 2001 02:28:22 GMT Subject: How widespread is NIS support? References: Message-ID: On Tue, 20 Feb 2001 08:23:15 +1100 (EDT), Andrew MacIntyre wrote: >FreeBSD supports NIS (though not NIS+) but doesn't have the >'yp_get_default_domain' man page you refer to. I think the other BSDs and >most Linux distros are in the same boat. CNRI uses NIS+ internally. A while ago, when we first began replacing Solaris machines with Linux boxes, Greg Ward slammed his head against configuring NIS+ support; there's a HOWTO that's far out of date, and various hacked pieces of software to install. Getting NIS working is a matter of changing a few config files on current Linux versions; we never managed to get NIS+ working at all. I'd be surprised if the module supports NIS+ at all. Well, let's be brave; for beta1 I'll enable NIS by default on all platforms, and see where it breaks. --amk From bulbul at ucla.edu Mon Feb 19 01:45:48 2001 From: bulbul at ucla.edu (Leston Buell) Date: Sun, 18 Feb 2001 16:45:48 -0800 Subject: can't open older anydbm file Message-ID: <3A906CBC.1060009@ucla.edu> Under Python 1.4 which was running on my web host's server, i created a database file using anydbm. Using whichdb.whichdb on it, i learn that it is a dbhash file, which i understand is what bsddb uses. Now my account has been moved to a new server, which has python 1.5.2. Now i can no longer open the file. When i try in an interactive session, i get this: >>> import anydbm >>> db = anydbm.open( 'address.db', 'r' ) Traceback (innermost last): File "", line 1, in ? File "/usr/lib/python1.5/anydbm.py", line 86, in open return mod.open(file, flag, mode) File "/usr/lib/python1.5/dbhash.py", line 8, in open return bsddb.hashopen(file, flag, mode) bsddb.error: (22, 'Invalid argument') ?Is there anything i can do to open this file or to recover my data? Thanks, Leston From phd at phd.pp.ru Mon Feb 19 10:24:09 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Mon, 19 Feb 2001 12:24:09 +0300 (MSK) Subject: can't open older anydbm file In-Reply-To: <3A906CBC.1060009@ucla.edu> Message-ID: On Sun, 18 Feb 2001, Leston Buell wrote: > bsddb.error: (22, 'Invalid argument') > > ?Is there anything i can do to open this file or to recover my data? Either db_dump, db_dump185 or relink bsddb with older libs. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From costas at springmail.com Mon Feb 19 04:34:55 2001 From: costas at springmail.com (Costas Menico) Date: Mon, 19 Feb 2001 03:34:55 GMT Subject: Is there an ISAPI interface for Python? Message-ID: <3a90940f.2436689@News.CIS.DFN.DE> Does anyone know if there is an ISAPI interface DLL that works with Python? I am using IIS4.0 and Windows NT. Thanks From syver at NOSPAMcyberwatcher.com Mon Feb 19 08:39:42 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Mon, 19 Feb 2001 08:39:42 +0100 Subject: Is there an ISAPI interface for Python? References: <3a90940f.2436689@News.CIS.DFN.DE> Message-ID: I haven't found one, but I was working on one as a little side project. It was starting to work out OK, but then I managed to screw it up one late evening. On the other hand the ASP ISAPI dll supports python, but I guess you were talking about a custom ISAPI dll, weren't you? The ISAPI extension I was making was supposed to mimic Python CGI as accurately as possible so that you could use Python CGI scripts with it without changing the .py file. Most of the dll revolves around handling one python interpreter per thread and setting up the environment for these to match the CGI enironment. If you really need it I could see if I could get the project back on line. "Costas Menico" wrote in message news:3a90940f.2436689 at News.CIS.DFN.DE... > Does anyone know if there is an ISAPI interface DLL that works with > Python? I am using IIS4.0 and Windows NT. > > Thanks > From costas at springmail.com Tue Feb 20 13:41:33 2001 From: costas at springmail.com (Costas Menico) Date: Tue, 20 Feb 2001 12:41:33 GMT Subject: Is there an ISAPI interface for Python? References: <3a90940f.2436689@News.CIS.DFN.DE> Message-ID: <3a92643f.610397@News.CIS.DFN.DE> With everything Python hasy I was suprised to see that there isnt a published ISAPI for Python. I have an ISAPI that I wrote for something else. I was hoping to find a good and tested one for Python :) without having to modify mine. May I ask you a couple of questions? What method did you use to interface the ISAPI to Python? Which CGI module are you using for testing? Also can you handle multiple requests at the same time? Maybe I could modify the one I have to do this. thanks costas "Syver Enstad" wrote: >I haven't found one, but I was working on one as a little side project. It >was starting to work out OK, but then I managed to screw it up one late >evening. > >On the other hand the ASP ISAPI dll supports python, but I guess you were >talking about a custom ISAPI dll, weren't you? > >The ISAPI extension I was making was supposed to mimic Python CGI as >accurately as possible so that you could use Python CGI scripts with it >without changing the .py file. Most of the dll revolves around handling one >python interpreter per thread and setting up the environment for these to >match the CGI enironment. > >If you really need it I could see if I could get the project back on line. > >"Costas Menico" wrote in message >news:3a90940f.2436689 at News.CIS.DFN.DE... >> Does anyone know if there is an ISAPI interface DLL that works with >> Python? I am using IIS4.0 and Windows NT. >> >> Thanks >> > > From costas at springmail.com Mon Feb 19 05:22:34 2001 From: costas at springmail.com (Costas Menico) Date: Mon, 19 Feb 2001 04:22:34 GMT Subject: Why ASP <%@ %> does not work Message-ID: <3a909e7f.5108679@News.CIS.DFN.DE> Hi, I am trying to execute the following page in PWS which contains Python ASP. However it does not execute to display the "text". I have installed the latest ActivePython . Is there some registry setting that I should be dong? I know If it does, then this should work, too: <%@ language=Python %> <% Response.Write("

hello, world

") %> It works for me without any trouble. Greg Jorgensen Deschooling Society Portland, Oregon USA From costas at springmail.com Tue Feb 20 13:53:40 2001 From: costas at springmail.com (Costas Menico) Date: Tue, 20 Feb 2001 12:53:40 GMT Subject: Why ASP <%@ %> does not work References: <3a909e7f.5108679@News.CIS.DFN.DE> <3a90c719.49981769@news.potlnd1.or.home.com> Message-ID: <3a9267c3.1510596@News.CIS.DFN.DE> That worked. Thanks to both of you for the help. Does this also mean that it uses the ASP/ISAPI interface and CGI is not really needed? gregj at pobox.com (Greg Jorgensen) wrote: >On Mon, 19 Feb 2001 04:22:34 GMT, costas at springmail.com (Costas >Menico) wrote: > >> I am trying to execute the following page in PWS which contains >>Python ASP. However it does not execute to display the "text". >> I have installed the latest ActivePython . Is there some registry >>setting that I should be dong? I know > > > >If it does, then this should work, too: > ><%@ language=Python %> > > > ><% >Response.Write("

hello, world

") >%> > > > >It works for me without any trouble. > >Greg Jorgensen >Deschooling Society >Portland, Oregon USA From costas at springmail.com Mon Feb 19 05:48:12 2001 From: costas at springmail.com (Costas Menico) Date: Mon, 19 Feb 2001 04:48:12 GMT Subject: Bug: Bad link in help file Message-ID: <3a90a547.6844905@News.CIS.DFN.DE> This link is messed up and I cant get to the scripting setup info. D:\Python20\win32comext\axscript\demos\client\ie\demo.htm if you click on Introduction it keeps you on the same page...\ costas From jurgen.defurne at philips.com Mon Feb 19 09:12:40 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Mon, 19 Feb 2001 09:12:40 +0100 Subject: Huuuuge memory leak (third attempt) Message-ID: <0056900015996553000002L032*@MHS> Thanks, everybody, for the comments on the multiple assignment. Unfortunately, that was the least of my problems. I would urge everybody who runs Python 2.0 under Windows NT, to try the following script : # # External modules import os import sys from time import * if len(sys.argv) == 1: while 1: # Doesn't matter if P_NOWAIT or P_DETACH, tried 'em both os.spawnl(os.P_DETACH, 'd:\\python20\\python', 'python', 'cron.py', 'check') elif sys.argv[1] == 'check': pass This is basically the core of a Python cron daemon (for Win), which is unfortunately unusable at the moment because of the memory leak spawn seems to generate. Who maintains the Win version of Python ? Maybe I should mail this to that person ? Jurgen From fredrik at pythonware.com Mon Feb 19 10:03:43 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 19 Feb 2001 09:03:43 GMT Subject: Huuuuge memory leak (third attempt) References: Message-ID: jurgen.defurne at philips.com wrote: > I would urge everybody who runs Python 2.0 under Windows NT, > to try the following script: It's not leaking memory, it's leaking processes. By design. On my old slow Windows box, your program creates 50 new pro- cesses per second. Each process needs about 0.12 CPU seconds to finish. Each Python process uses around 800k of non-shared memory. You can figure the rest out yourself... Cheers /F From jepler at inetnebr.com Tue Feb 20 00:32:56 2001 From: jepler at inetnebr.com (Jeff Epler) Date: Mon, 19 Feb 2001 23:32:56 GMT Subject: Huuuuge memory leak (third attempt) References: Message-ID: On Mon, 19 Feb 2001 09:12:40 +0100, jurgen.defurne at philips.com wrote: >Thanks, everybody, > >for the comments on the multiple assignment. Unfortunately, >that was the least of my problems. I would suggest entering this bug in the bug tracking system at http://sourceforge.net/projects/python/ This may be a genuine bug. Another thing you could do is try the equivalent program written in C on Windows NT, to see if it exhibits the problem. It is possible that this is a bug in Windows, not in Python. I don't know what the equivalent of "/bin/false" is in Windows NT, but does the result change if a more trivial program is executed? Running the following code on Linux/Python 2.0, I soon get an error due to the number of "zombie" processes. "zombie" processes are those whose exit codes have not been read by the waitpid() or wait() functions in the os module. Is something like "waitpid()" necessary/possible under NT? Adding waitpid() lets it run seemingly forever without error. import os, time while 1: pid = os.spawnv(os.P_NOWAIT, "false", "/bin/false") #print pid, os.waitpid(pid, 0) Jeff From jurgen.defurne at philips.com Tue Feb 20 14:54:57 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Tue, 20 Feb 2001 14:54:57 +0100 Subject: Huuuuge memory leak (third attempt) Message-ID: <0056900016050184000002L042*@MHS> If I were using Linux/Python 2.0, I would preferably use fork()/exec(). Unfortunately, that is not the case. The MS documentation about spawn does not mention anything about waiting for termination of the proces. Besides, the _cwait call, which acts on the process handle, is not implemented in Python, os.waitpid() is only available on U*ix systems. So, yes, I will try to write the same functionality in C, and look what that gives. Thank you very much. Jurgen jepler at inetnebr.com@SMTP at python.org on 20/02/2001 14:31:50 Sent by: python-list-admin at python.org To: python-list at python.org@SMTP cc: Subject: Re: Huuuuge memory leak (third attempt) Classification: On Mon, 19 Feb 2001 09:12:40 +0100, jurgen.defurne at philips.com wrote: >Thanks, everybody, > >for the comments on the multiple assignment. Unfortunately, >that was the least of my problems. I would suggest entering this bug in the bug tracking system at http://sourceforge.net/projects/python/ This may be a genuine bug. Another thing you could do is try the equivalent program written in C on Windows NT, to see if it exhibits the problem. It is possible that this is a bug in Windows, not in Python. I don't know what the equivalent of "/bin/false" is in Windows NT, but does the result change if a more trivial program is executed? Running the following code on Linux/Python 2.0, I soon get an error due to the number of "zombie" processes. "zombie" processes are those whose exit codes have not been read by the waitpid() or wait() functions in the os module. Is something like "waitpid()" necessary/possible under NT? Adding waitpid() lets it run seemingly forever without error. import os, time while 1: pid = os.spawnv(os.P_NOWAIT, "false", "/bin/false") #print pid, os.waitpid(pid, 0) Jeff -- http://mail.python.org/mailman/listinfo/python-list From fredrik at pythonware.com Mon Feb 19 09:24:03 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 19 Feb 2001 08:24:03 GMT Subject: Way to return a dictionary from re.findall? References: Message-ID: "Veronica Esquire" wrote: > Is there a way to get back a dictionary of findall results that is > based on the regex group names in python's re module? no. use a loop. Cheers /F From akhar at videotron.ca Mon Feb 19 09:43:37 2001 From: akhar at videotron.ca (akhar) Date: Mon, 19 Feb 2001 00:43:37 -0800 Subject: custom gui? Message-ID: How would I go about doing my own GUI? By that I mean what library do I use pyQT, pyGTK, pyWxWindows or tkinter? and By custom I mean changing where the open and close buttons are (appearance), how windows open and shut (location), have clipboards ... I am prepared to program but don Message-ID: In article , akhar wrote: >How would I go about doing my own GUI? By that I mean what library do I use >pyQT, pyGTK, pyWxWindows or tkinter? and By custom I mean changing where the >open and close buttons are (appearance), how windows open and shut >(location), have clipboards ... I am prepared to program but donwhere to start . . . . It depends. I find your question ambiguous. One possi- bility is to buy or borrow John Grayson's celebrated book and learn from it. While it uses Tkinter, much of the instruction applies also with other bindings. Is that the sort of answer you're after? -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From akhar at videotron.ca Tue Feb 20 04:11:41 2001 From: akhar at videotron.ca (akhar) Date: Mon, 19 Feb 2001 19:11:41 -0800 Subject: custom gui? References: Message-ID: What I meant was to be able to get away from the traditional square windows and layout of frames. Stephane akhar wrote in message news:xw2k6.1848$zw6.48239 at wagner.videotron.net... > How would I go about doing my own GUI? By that I mean what library do I use > pyQT, pyGTK, pyWxWindows or tkinter? and By custom I mean changing where the > open and close buttons are (appearance), how windows open and shut > (location), have clipboards ... I am prepared to program but don where to start . > regards > stephane > > From claird at starbase.neosoft.com Wed Feb 21 01:04:40 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 20 Feb 2001 18:04:40 -0600 Subject: custom gui? References: Message-ID: <1F1B8A7CFF73AFD4.03A50AAFC4AC473B.6EA500FCB7E4FD46@lp.airnews.net> In article , akhar wrote: >What I meant was to be able to get away from the traditional square windows >and layout of frames. . . . How far away? I'm not getting it yet. Is there a positive example of what you're after? Do you want a virtual-reality sort of toolkit, or just one that makes it easy to draw blobby sorts of things? Or are you saying that anything that's not Visual Basic interests you? -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From boud at rempt.xs4all.nl Wed Feb 21 07:15:22 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 21 Feb 2001 06:15:22 GMT Subject: custom gui? References: <1F1B8A7CFF73AFD4.03A50AAFC4AC473B.6EA500FCB7E4FD46@lp.airnews.net> Message-ID: <96vmdq$f5$1@news1.xs4all.nl> Cameron Laird wrote: > . > How far away? I'm not getting it yet. Is there > a positive example of what you're after? Do you > want a virtual-reality sort of toolkit, or just > one that makes it easy to draw blobby sorts of > things? Or are you saying that anything that's > not Visual Basic interests you? I get the feeling he's after the kind of things modern mp3-players do - windows in the shape of a snail and things like that. -- Boudewijn Rempt | http://www.valdyas.org From claird at starbase.neosoft.com Wed Feb 21 17:41:43 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 21 Feb 2001 10:41:43 -0600 Subject: custom gui? References: <1F1B8A7CFF73AFD4.03A50AAFC4AC473B.6EA500FCB7E4FD46@lp.airnews.net> <96vmdq$f5$1@news1.xs4all.nl> Message-ID: <33AD0B12D8AC8640.93E4CFDD593CF2E8.A6B598462FA61951@lp.airnews.net> In article <96vmdq$f5$1 at news1.xs4all.nl>, Boudewijn Rempt wrote: >> . >I get the feeling he's after the kind of things modern mp3-players >do - windows in the shape of a snail and things like that. . . . Yes. What facilities are and will be available for those who want windows with funny geometry? The im- mediate answer, of course, is that motivated people can synthesize windows as canvas polygons. I bet that satisfies few, though. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From boud at rempt.xs4all.nl Wed Feb 21 17:57:13 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 21 Feb 2001 16:57:13 GMT Subject: custom gui? References: <1F1B8A7CFF73AFD4.03A50AAFC4AC473B.6EA500FCB7E4FD46@lp.airnews.net> <96vmdq$f5$1@news1.xs4all.nl> <33AD0B12D8AC8640.93E4CFDD593CF2E8.A6B598462FA61951@lp.airnews.net> Message-ID: <970s19$3bo$1@news1.xs4all.nl> Cameron Laird wrote: > Yes. What facilities are and will be available for > those who want windows with funny geometry? The im- > mediate answer, of course, is that motivated people > can synthesize windows as canvas polygons. I bet > that satisfies few, though. I doubt that there are cross-platform facilities available; but perhaps the shape extensions for X could be wrapped? Myself, I really loathe windows without decent borders. -- Boudewijn Rempt | http://www.valdyas.org From akhar at videotron.ca Mon Feb 19 09:44:03 2001 From: akhar at videotron.ca (akhar) Date: Mon, 19 Feb 2001 00:44:03 -0800 Subject: custom gui? Message-ID: How would I go about doing my own GUI? By that I mean what library do I use pyQT, pyGTK, pyWxWindows or tkinter? and By custom I mean changing where the open and close buttons are (appearance), how windows open and shut (location), have clipboards ... I am prepared to program but don Message-ID: akhar (akhar at videotron.ca) wrote: > How would I go about doing my own GUI? By that I mean what library do I use > pyQT, pyGTK, pyWxWindows or tkinter? and By custom I mean changing where the > open and close buttons are (appearance), how windows open and shut > (location), have clipboards ... I am prepared to program but don where to start . > regards > stephane If you're willing to use GTK then you might want to look into a GUI-designer-thing called Glade. It allows you to plunk down GUI objects (windows, buttons, canvases, sliders, etc) and it saves the layout as an XML file (if you aren't familiar with XML, think of it as a generalization of HTML). There have been several efforts to write translators that convert this XML file into Python code suitable for use with PyGTK: http://glc.sourceforge.net/ http://www.baypiggies.org/stubby.py http://www.fcoutant.freesurf.fr/gladepyc.html -- -----------------------------------+--------------------- 22nd century: Esperanto, geodesic | Will Ware domes, hovercrafts, metric system | wware at world.std.com From bryan at eevolved.com Tue Feb 20 03:59:18 2001 From: bryan at eevolved.com (Bryan Mongeau) Date: Tue, 20 Feb 2001 02:59:18 GMT Subject: custom gui? References: Message-ID: akhar wrote: > How would I go about doing my own GUI? By that I mean what library do I > use pyQT, pyGTK, pyWxWindows or tkinter? and By custom I mean changing > where the open and close buttons are (appearance), how windows open and > shut (location), have clipboards ... I am prepared to program but don know where to start . > regards > stephane > > > > One more that may be hidden: FOX: (Free objects for X) http://sourceforge.net/projects/fxpy Having used all of the above GUI kits, I would recommend pyQT if you never intend to make Windows sofware. Otherwise, its licensing is such as to preclude you from ever releasing free software on that platform. Fox is LGPL and will do everything you need. It's just a little trickier than in QT. Check out the "themes" example in the pyQT bundle. That should give you a kickstart. -- <==================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. http://www.eevolved.com <==================================> "Scientific beliefs are supported by evidence, and they get results. Myths and faiths are not and do not" -- Richard Dawkins From phys137 at mailcity.com Tue Feb 20 05:07:20 2001 From: phys137 at mailcity.com (phys137 at mailcity.com) Date: Tue, 20 Feb 2001 15:07:20 +1100 Subject: custom gui? References: Message-ID: <96sqh9$os0$1@mail.pl.unisys.com> as in thread 'python 3000' 1. It seems that there are several Python IDEs in which many smart people invested plenty of effort. We have WinPython, IDLE (do we still have it ? ;-)), ActiveState is coming up with Komodo (build on Mozilla) and I probably missed a few here - apologies. Plus we have commercial ones. 2. Competition is good, splitting efforts probably less good. And there's a fine line between them. 3. My abbreviated personal view about technology directions: Win will rule the desktop, not only because of it's current popularity - but because it has component model. Linux doesn't have a native object model - which creates scalability (in size and functionality) problems for applications. Java on Linux will provide the component model but only for the Java world, not Linux. 4. Good and lasting IDE is about modularity and ease of extension. While I applaud the efforts of ActiveState I'm not sure that using Mozilla gives enough fuel for the long run. 5. www.netbeans.org - please, please, please read the whitepaper on that! 6. Essentially this is an open source IDE for Java - but can be used for most anything else. It's highly modular - you can customize/replace editor or file system etc (see 5). There is some fantastic stuff there as well as plenty of good design. Jython folks obviously are already having a peek at it (naturally) - but this could be used for general Python, too. And used on both platforms - NT and UNIX. 7. I'm not sure how well Netbeans functionality can be blended with winpython. but then, i suspect that winpython functionality will blend with .NET anyway. "akhar" wrote in message news:xw2k6.1849$zw6.48239 at wagner.videotron.net... > How would I go about doing my own GUI? By that I mean what library do I use > pyQT, pyGTK, pyWxWindows or tkinter? and By custom I mean changing where the > open and close buttons are (appearance), how windows open and shut > (location), have clipboards ... I am prepared to program but don where to start . > regards > stephane > > > > From thorben.schulte at dcc-asia.de Mon Feb 19 11:09:04 2001 From: thorben.schulte at dcc-asia.de (Thorben Schulte) Date: Mon, 19 Feb 2001 11:09:04 +0100 Subject: zope & python : handle ZObject in the OSF Message-ID: <96qrc1$1bp$00$1@news.t-online.com> Hi all! I have a small problem: I would like to write an external method to move a zope-object from one folder to another. My problem ist that i have no idear how to read and write object stored in the OSF. The backgroud is that "old" documents should move to an archive folder. THX a lot, hope you will unterstand my english. Greeting from Hannover, Thorben From robin at jessikat.fsnet.co.uk Mon Feb 19 11:27:41 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Mon, 19 Feb 2001 10:27:41 +0000 Subject: Cyclops 2.0 Message-ID: I suppose a lot of the need for T Peters' Cyclops module has gone away with gc in Python 2.0, but Cyclops provide a convenient framework for the analysis. Is there any equivalent for 2.0? If I just use Cyclops is it telling me a lot more than the gc.garbage list? -- Robin Becker From loewis at informatik.hu-berlin.de Tue Feb 20 13:48:54 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 20 Feb 2001 13:48:54 +0100 Subject: Cyclops 2.0 References: Message-ID: Robin Becker writes: > I suppose a lot of the need for T Peters' Cyclops module has gone away > with gc in Python 2.0, but Cyclops provide a convenient framework for > the analysis. Is there any equivalent for 2.0? If I just use Cyclops is > it telling me a lot more than the gc.garbage list? I have a patch on SF which adds a function gc.getreferents, which finds all objects that refer to a given object. That is quite helpful in finding the cause of a cycle. Regards, Martin From tim_one at email.msn.com Wed Feb 21 07:06:57 2001 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 21 Feb 2001 01:06:57 -0500 Subject: Cyclops 2.0 In-Reply-To: Message-ID: [Robin Becker] > I suppose a lot of the need for T Peters' Cyclops module has gone away > with gc in Python 2.0, Depends on whether you care whether you're creating cycles. There's less need to care now, but objects with __del__ methods in cycles still aren't reclaimed by magic. I personally care about the latter only to the extent that I would consider it to be a bug in my code if I ever created such a thing ("a bug" because I intend never *to* create such a thing). > but Cyclops provide a convenient framework for the analysis. Is > there any equivalent for 2.0? Sure: Cyclops <0.9 wink>. Nothing in 2.0 or 2.1 broke it, AFAIK. > If I just use Cyclops is it telling me a lot more than the > gc.garbage list? Depends on *how* you use Cyclops. It has methods for delivering many kinds of info, from grouping by connection type to partitioning into strongly connected components. It can also be taught how to chase new kinds of objects without delving into C. gc.garbage is just a list, and of the kinds of objects gc knows how to chase on its own. If "just a list" is all you need, cool. From rich_somerfield at tertio.com Mon Feb 19 11:33:43 2001 From: rich_somerfield at tertio.com (Rich Somerfield) Date: Mon, 19 Feb 2001 10:33:43 -0000 Subject: Calling C from Python Message-ID: Hi, I have written a Game Engine in Python (main allow simulation of Board Games using a config file as the definition of the game). The problem is, is that the AI section is too slow. As the code needs to be generic (e.g. cant specialise as the game type etc... is unknown until runtime - from config file), i have been unable to optimise the code further. I want to use Python as my main langauge and have certain code (where performance is essential) written in C. I have looked at the doc's and cant get a feel for it. Can anyone point me in the direction of some sample code (complete - not segments!), or give me a little helping hand? Cheers Rich. From dkuhlman at rexx.com Mon Feb 19 18:57:18 2001 From: dkuhlman at rexx.com (Dave Kuhlman) Date: Mon, 19 Feb 2001 17:57:18 -0000 Subject: Calling C from Python References: Message-ID: <982605440.846771@rexx.com> Section 1.1 of "Extending and Embedding the Python Interpreter" contains a simple but complete sample. You can also produce more complicated examples with SWIG, which will generate the wrapper functions for your C functions. You can find SWIG at http://www.swig.org. Also, in the source distribution, look at Demo/embed/demo.c. It demonstrates both (1) embedding Python in a C application and (2) extending that embedded Python interpreter with a module implemented in C. It's the second task that you seem to be asking for. Hope this helps. - Dave Rich Somerfield wrote: > > Hi, > I have written a Game Engine in Python (main allow simulation of Board Games > using a config file as the definition of the game). The problem is, is that > the AI section is too slow. As the code needs to be generic (e.g. cant > specialise as the game type etc... is unknown until runtime - from config > file), i have been unable to optimise the code further. > > I want to use Python as my main langauge and have certain code (where > performance is essential) written in C. I have looked at the doc's and cant > get a feel for it. Can anyone point me in the direction of some sample code > (complete - not segments!), or give me a little helping hand? > > Cheers > Rich. > > -- Dave Kuhlman dkuhlman at rexx.com From rich_somerfield at tertio.com Tue Feb 20 12:01:11 2001 From: rich_somerfield at tertio.com (Rich Somerfield) Date: Tue, 20 Feb 2001 11:01:11 -0000 Subject: Calling C from Python References: <982605440.846771@rexx.com> Message-ID: Thanks for the info. I attempted to complete the Calling Python from C [Demo/embed/demo.c] but couldnt get it to compile. Could u please help me with the command? I was trying [on Unix] : cc -o new new.c -I/opt/Python-2.0/Include -I/opt/Python-2.0 -L/opt/Python-2.0 -L/opt/P ython-2.0/Lib -L/opt/Python-2.0/Modules -lpython2.0 Where new.c is a copy of the demo.c file. Regards Rich Dave Kuhlman wrote in message news:982605440.846771 at rexx.com... > > Section 1.1 of "Extending and Embedding the Python Interpreter" > contains a simple but complete sample. > > You can also produce more complicated examples with SWIG, which > will generate the wrapper functions for your C functions. You can > find SWIG at http://www.swig.org. > > Also, in the source distribution, look at Demo/embed/demo.c. It > demonstrates both (1) embedding Python in a C application and (2) > extending that embedded Python interpreter with a module > implemented in C. It's the second task that you seem to be asking > for. > > Hope this helps. > > - Dave > > > > Rich Somerfield wrote: > > > > Hi, > > I have written a Game Engine in Python (main allow simulation of Board Games > > using a config file as the definition of the game). The problem is, is that > > the AI section is too slow. As the code needs to be generic (e.g. cant > > specialise as the game type etc... is unknown until runtime - from config > > file), i have been unable to optimise the code further. > > > > I want to use Python as my main langauge and have certain code (where > > performance is essential) written in C. I have looked at the doc's and cant > > get a feel for it. Can anyone point me in the direction of some sample code > > (complete - not segments!), or give me a little helping hand? > > > > Cheers > > Rich. > > > > > > -- > Dave Kuhlman > dkuhlman at rexx.com From chris.gonnerman at usa.net Wed Feb 21 04:35:51 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Tue, 20 Feb 2001 21:35:51 -0600 Subject: Calling C from Python References: <982605440.846771@rexx.com> Message-ID: <007c01c09bb7$6e44d8a0$a100000a@local> ----- Original Message ----- From: "Rich Somerfield" Subject: Re: Calling C from Python > I attempted to complete the Calling Python from C [Demo/embed/demo.c] but > couldnt get it to compile. Could u please help me with the command? > I was trying [on Unix] : > cc -o new > > new.c -I/opt/Python-2.0/Include -I/opt/Python-2.0 -L/opt/Python-2.0 -L/opt/P > ython-2.0/Lib -L/opt/Python-2.0/Modules -lpython2.0 I assume this was originally one line. What does cc tell you? For that matter, what "Unix" are you using? It makes a big difference. From chris.gonnerman at usa.net Wed Feb 21 14:33:01 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Wed, 21 Feb 2001 07:33:01 -0600 Subject: Calling C from Python References: Message-ID: <000f01c09c0a$d44a0280$a100000a@local> ----- Original Message ----- From: Subject: Re: Calling C from Python > Thanks for the reply. > > My OS is SunOS 5.6. The message I get from CC (I am using Sun Workshop > compiler (CC: WorkShop Compilers 5.0 98/12/15 C++ 5.0) is : Ur. Not familiar with SunOS anymore... > CC -o new new.c -I/opt/Python-2.0/Include -I/opt/Python-2.0 -L/opt/Python-2.0/Modules -L/opt/Python-2.0 -L/opt/Python-2.0/Lib -lpython2.0 > > Undefined first referenced > symbol in file > socket /opt/Python-2.0/libpython2.0.a(socketmodule.o) > getpeername /opt/Python-2.0/libpython2.0.a(socketmodule.o) > recv /opt/Python-2.0/libpython2.0.a(socketmodule.o) > getprotobyname /opt/Python-2.0/libpython2.0.a(socketmodule.o) > accept /opt/Python-2.0/libpython2.0.a(socketmodule.o) > gethostbyname_r /opt/Python-2.0/libpython2.0.a(socketmodule.o) > send /opt/Python-2.0/libpython2.0.a(socketmodule.o) > bind /opt/Python-2.0/libpython2.0.a(socketmodule.o) > setsockopt /opt/Python-2.0/libpython2.0.a(socketmodule.o) > getservbyname /opt/Python-2.0/libpython2.0.a(socketmodule.o) > getsockopt /opt/Python-2.0/libpython2.0.a(socketmodule.o) > inet_addr /opt/Python-2.0/libpython2.0.a(socketmodule.o) > sendto /opt/Python-2.0/libpython2.0.a(socketmodule.o) > inet_ntoa /opt/Python-2.0/libpython2.0.a(socketmodule.o) > shutdown /opt/Python-2.0/libpython2.0.a(socketmodule.o) > getsockname /opt/Python-2.0/libpython2.0.a(socketmodule.o) > gethostbyaddr_r /opt/Python-2.0/libpython2.0.a(socketmodule.o) This batch of errors is complaining that socket functionality is missing. I find this most puzzling. On Linux, I don't need to load any additional libraries for socket support, but I suppose on SunOS you might need to. > dlsym /opt/Python-2.0/libpython2.0.a(dynload_shlib.o) (symbol belongs to implicit dependency /usr/lib/libdl.so.1) > dlopen /opt/Python-2.0/libpython2.0.a(dynload_shlib.o) (symbol belongs to implicit dependency /usr/lib/libdl.so.1) > __eprintf /opt/Python-2.0/libpython2.0.a(longobject.o) > dlerror /opt/Python-2.0/libpython2.0.a(dynload_shlib.o) (symbol belongs to implicit dependency /usr/lib/libdl.so.1) > recvfrom /opt/Python-2.0/libpython2.0.a(socketmodule.o) > listen /opt/Python-2.0/libpython2.0.a(socketmodule.o) > connect /opt/Python-2.0/libpython2.0.a(socketmodule.o) > ld: fatal: Symbol referencing errors. No output written to new > > Do i need to include all of these library files or should the compiler pick them up from the specified lib directory in the compile command? Is these > are specific list of libs that I need to include to compile for Python? I'm not sure you need ALL of those options but they shouldn't hurt. It looks like you need an additional -l... option or two, but I can't say for sure. I hope there is a SunOS user out there reading this... > Regards, > RS. From mwh21 at cam.ac.uk Wed Feb 21 15:08:16 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 21 Feb 2001 14:08:16 +0000 Subject: Calling C from Python References: Message-ID: "Rich Somerfield" writes: > I have written a Game Engine in Python (main allow simulation of > Board Games using a config file as the definition of the game). The > problem is, is that the AI section is too slow. As the code needs > to be generic (e.g. cant specialise as the game type etc... is > unknown until runtime - from config file), i have been unable to > optimise the code further. > > I want to use Python as my main langauge and have certain code > (where performance is essential) written in C. I have looked at the > doc's and cant get a feel for it. Can anyone point me in the > direction of some sample code (complete - not segments!), or give me > a little helping hand? Have a look at: http://www-jcsu.jesus.cam.ac.uk/~mwh21/hacks/ext/defining-new-types.html It's not nearly finished yet, but you might find it helpful. Cheers, M. -- Darned confusing, unless you have that magic ingredient coffee, of which I can pay you Tuesday for a couple pounds of extra-special grind today. -- John Mitchell, 11 Jan 1999 From ungrzr2 at ubatxbat.pbz Sun Feb 25 03:27:48 2001 From: ungrzr2 at ubatxbat.pbz ({-- Rot13 - Hateme) Date: 25 Feb 2001 02:27:48 GMT Subject: Calling C from Python References: Message-ID: <9053610F6YouAreNotMeYouKnow@205.252.144.34> rich_somerfield at tertio.com (Rich Somerfield) wrote in : >Hi, >I have written a Game Engine in Python (main allow simulation of Board >Games using a config file as the definition of the game). The problem >is, is that the AI section is too slow. As the code needs to be generic >(e.g. cant specialise as the game type etc... is unknown until runtime - >from config file), i have been unable to optimise the code further. > I just found this dl module in python manual. I think it is need for python2. I am very excited about this function! It basically let you dynamically load a library and use it! It is a unix module. So no wrapper is needed for simple C function access. I waited it for so long! Thank you very much for this module! From thomas at xs4all.net Sun Feb 25 21:31:36 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 25 Feb 2001 21:31:36 +0100 Subject: Calling C from Python In-Reply-To: <9053610F6YouAreNotMeYouKnow@205.252.144.34>; from ungrzr2@ubatxbat.pbz on Sun, Feb 25, 2001 at 02:27:48AM +0000 References: <9053610F6YouAreNotMeYouKnow@205.252.144.34> Message-ID: <20010225213136.I16781@xs4all.nl> On Sun, Feb 25, 2001 at 02:27:48AM +0000, {-- Rot13 - Hateme wrote: > I just found this dl module in python manual. I think it > is need for python2. I am very excited about this function! > It basically let you dynamically load a library and use it! > It is a unix module. > So no wrapper is needed for simple C function access. I > waited it for so long! The 'dl' module has been around for a long time, at least since Python 1.1, though it might have been named different in that distant a past. Note that the 'dl' module isn't enabled by default, at least not until the upcoming Python 2.1. The 'dl' module is also not terribly secure or pythonic: misuse can easily lead to crashes or weird behaviour. And it won't work on systems where a pointer, a normal integer and a long integer aren't of the same size. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From guettli at interface-business.de Mon Feb 19 12:22:29 2001 From: guettli at interface-business.de (Thomas Guettler) Date: Mon, 19 Feb 2001 12:22:29 +0100 Subject: Newbie's Questions Message-ID: <20010219122229.A28726@gurkensalat.interface-business.de> Yesterday I had time to start learning python. I like it, after a half hour I wasn't missing the "{..}" anymore. Here are some questions I have: Is there a way of checking the program when I start it. So typos are detected emidiately, and not when I enter the function. Is there something like "use strict" in perl? I like to declare my variables before I use them. (Again, to recognize typos) Is there a way of reading a single character from stdin without waiting for the return-key? (At best without curses) Is there something like "exit" in C? Yes, I could just raise an exception, but I prefere a way without a stacktrace. -- Thomas Guettler Office: www.interface-business.de Private: http://yi.org/guettli From aleaxit at yahoo.com Mon Feb 19 13:26:31 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 19 Feb 2001 13:26:31 +0100 Subject: Newbie's Questions References: Message-ID: <96r3dn01u60@news1.newsguy.com> "Thomas Guettler" wrote in message news:mailman.982581805.9060.python-list at python.org... > Yesterday I had time to start learning python. I like it, after a half Bravo!-) > hour I wasn't missing the "{..}" anymore. Here are some questions I > have: > > Is there a way of checking the program when I start it. So typos are > detected emidiately, and not when I enter the function. The syntax of the whole script IS checked when you start it, since it's internally compiled then; this will catch many typos -- e.g., if you write: fi x>0: rather than if x>0: a SyntaxError will be generated immediately -- but not, of course, all, e.g., if you write: x=y=z rather than x=y+z (also a frequent occurrence, since + and = are shifted version of each other on many keyboards), this will not be detected until you run suitable tests, as both forms happen to be syntactically correct. There is no way to even check for typos _that will generate exceptions when the function is run_, without actually running the function; e.g., a=b/c where one meant to write a=b/d and c happens to be 0, will be caught when the function is run (the division-by-zero attempt will raise an exception), but not before then. And similarly if c happens to refer to a string (you can't divide by a string), or if it happens to be unbound at that point; only actual execution, not compilation, will reveal it. > Is there something like "use strict" in perl? I like to declare my > variables before I use them. (Again, to recognize typos) There are no declarations in Python (the 'global' statement _might_ be thought of as an exception to this assertion...). If you're using a variable that's not bound at all, at run time, or that is bound to a string where a number is needed at that point, etc, etc, you'll get runtime exceptions; no way to have the compiler diagnose it beforehand. > Is there a way of reading a single character from stdin without > waiting for the return-key? (At best without curses) On Windows, only, the msvcrt module offers functions getch (to read a single keypress, without waiting for a return, and without echoing) and getche (ditto, with echoing); but they don't work on standard-input (i.e., they are immune to stdin redirections), but, rather, on the actual keyboard. On Unix, you can use the low-level module termios, or the higher-level one tty that in turn uses termios, to set the mode to 'raw' for file-descriptor 0 (standard input). > Is there something like "exit" in C? Yes, I could just raise an > exception, but I prefere a way without a stacktrace. Module sys contains function exit, which in turn raises a SystemExit exception. Either calling sys.exit(), or raising SystemExit directly, will NOT generate a stacktrace -- but the exception can be caught, so that try/finally and try/except semantics are preserved. If you need a way to exit in an emergency, *without* proper/normal actions on termination (no flushing of buffers, no finally blocks, etc, etc), you can do that with function _exit of module os, but that's a pretty-rare need ("should normally only be used in the child process after a fork()" is what the docs say, but os.fork is only available on Unix platforms, while os._exit is also available on Windows). Alex From caumont at semaphora.com Mon Feb 19 12:40:46 2001 From: caumont at semaphora.com (Laurent Caumont) Date: Mon, 19 Feb 2001 12:40:46 +0100 Subject: minimum size python interpreter Message-ID: <96r0ph$n0$1@wanadoo.fr> Hello, Where can I fund a minimum size Python Interpreter for Windows? Thanks. From claird at starbase.neosoft.com Mon Feb 19 15:06:44 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 19 Feb 2001 08:06:44 -0600 Subject: minimum size python interpreter References: <96r0ph$n0$1@wanadoo.fr> Message-ID: <5B5C5CB509993043.252F85F5C2FE4A13.0E096A770F212271@lp.airnews.net> In article <96r0ph$n0$1 at wanadoo.fr>, Laurent Caumont wrote: > >Hello, > >Where can I fund a minimum size Python Interpreter for Windows? . . . For what sense of "minimum"? Perhaps "deeply embedded python" will interest you. Another possibility is to retrieve a Py1.1 for DOS--is that the sort of thing you're after? -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From info at pythonware.com Mon Feb 19 12:44:14 2001 From: info at pythonware.com (PythonWare) Date: Mon, 19 Feb 2001 12:44:14 +0100 Subject: ANN: SRE 2.1a2 (separate distribution) Message-ID: <012f01c09a69$49bfe410$0900a8c0@SPIFF> (trying again) Secret Labs' Regular Expression Engine (SRE) is the regular expression engine shipped with Python 1.6 and 2.0. The latest SRE version (from Python 2.1a2) is now available separately: http://www.pythonware.com/products/sre Changes from the 2.0 version include a couple of bug fixes, and improved portability; this version works with Python 1.5.2 and later versions. The distribution includes library source code, and prebuilt Windows binaries for Python 1.5.2 and 2.0. enjoy, the pythonware team "Secret Labs -- makers of fine pythonware since 1997." From aahz at panix.com Mon Feb 19 18:01:53 2001 From: aahz at panix.com (Aahz Maruch) Date: 19 Feb 2001 09:01:53 -0800 Subject: ANN: SRE 2.1a2 (separate distribution) References: Message-ID: <96rji1$18o$1@panix2.panix.com> [originally posted in c.l.py.announce] In article , PythonWare wrote: > > Secret Labs' Regular Expression Engine (SRE) is the regular expression > engine shipped with Python 1.6 and 2.0. The latest SRE version (from > Python 2.1a2) is now available separately: > > http://www.pythonware.com/products/sre > > Changes from the 2.0 version include a couple of bug fixes, and > improved portability; this version works with Python 1.5.2 and > later versions. Very nice! You are to be commended for your preservation of backwards portability. One thing that isn't clear from your announcement or web site: how does the Unicode stuff work in Python 1.5.2? -- --- 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 Why doesn't "Just Say NO" include caffeine, nicotine, alcohol, Prozac, and Ritalin? --Aahz From fredrik at pythonware.com Mon Feb 19 23:20:54 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 19 Feb 2001 22:20:54 GMT Subject: ANN: SRE 2.1a2 (separate distribution) References: <96rji1$18o$1@panix2.panix.com> Message-ID: Aahz Maruch wrote: > Very nice! You are to be commended for your preservation of backwards > portability. thanks! > One thing that isn't clear from your announcement or web > site: how does the Unicode stuff work in Python 1.5.2? not at all -- when compiled for 1.5.2, the core engine only supports 8-bit strings (or compatible objects, like memory mappings and arrays) Cheers /F From info at pythonware.com Mon Feb 19 12:52:02 2001 From: info at pythonware.com (PythonWare) Date: Mon, 19 Feb 2001 12:52:02 +0100 Subject: ANN: PIL 1.1.1 binaries for Windows Message-ID: <014001c09a6a$72fbf660$0900a8c0@SPIFF> at last: Secret Labs now offer "official" PIL builds for Windows. The binary kit is based on 1.1.1, and includes JPEG and PNG support, optional Tkinter support, and a patch for PNG transparency support: http://www.pythonware.com/products/pil Binary kits are available for Python 1.5.2, Python 2.0, and Python 2.1a2 (experimental). The Tkinter binding requires Tcl/Tk 8.2.3 for the 1.5.2 versions, and 8.3.2 for the 2.X versions. The patched PNG driver can be downloaded separately from http://effbot.org. enjoy, the pythonware team "Secret Labs -- makers of fine pythonware since 1997." From dale at out-think.NOSPAMco.uk Mon Feb 19 12:59:39 2001 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Mon, 19 Feb 2001 11:59:39 +0000 Subject: Scanners and OCR engines Message-ID: We need to automate some document management and I'm looking for a scanner and an OCR engine that I can automate. A Python interface would be preferable but COM would be fine. Failing that a C API would do and we could put our own object model around it. Does anyone know of any automation friendly scanners and OCR engines? TIA. -- Dale Strickland-Clark Out-Think Ltd Business Technology Consultants From astuart at NO.mira.SPAMnet Mon Feb 19 13:08:05 2001 From: astuart at NO.mira.SPAMnet (Andrew) Date: Mon, 19 Feb 2001 22:08:05 +1000 Subject: newbie - POPLIB, MIMETOOLS and SMTPLIB - aaarrrghh! Message-ID: <3a90fe94.a405@newton.pacific.net.au> Hi there sorry for being such a newbie. In summary, I am trying to write a script which reads a POP mailbox, extracts the "subject" line from each message, and emails a message back to the sender, echoing the "subject" line. Weird problems everywhere! I can get POPLIB to read emails, but I can't get MIMETOOLS to read the emails - so there's no way for me to get the subject line out. I can get SMTPLIB to send emails, but I can;t work out how to include a subject line in the email. I've looked for days throughout the Internet for solutions to these seemingly simple problems but I can't find anything. Why would it be so hard for MIMETOOLS to read messages that come from POPLIB? Surely they are designed to work together? Why so hard to include a subject line using SMTPLIB? Any help that can be offered by anyone is deeply appreciated. I feel like a total goof. What am I missing about this? Thanks in advance Andrew Stuart astuart at mira.net From jhauser at ifm.uni-kiel.de Mon Feb 19 12:37:31 2001 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 19 Feb 2001 12:37:31 +0100 Subject: newbie - POPLIB, MIMETOOLS and SMTPLIB - aaarrrghh! References: <3a90fe94.a405@newton.pacific.net.au> Message-ID: <87d7ceykck.fsf@lisboa.ifm.uni-kiel.de> "Andrew" writes: > Hi there > > sorry for being such a newbie. > > In summary, I am trying to write a script which reads a POP mailbox, > extracts the "subject" line from each message, and emails a message back to > the sender, echoing the "subject" line. Weird problems everywhere! > > I can get POPLIB to read emails, but I can't get MIMETOOLS to read the > emails - so there's no way for me to get the subject line out. > I can get SMTPLIB to send emails, but I can;t work out how to include a > subject line in the email. > > I've looked for days throughout the Internet for solutions to these > seemingly simple problems but I can't find anything. > > Why would it be so hard for MIMETOOLS to read messages that come from > POPLIB? Surely they are designed to work together? I'm not clear, why you want to use mimetools to read a plain email. An example for this is included in the poplib.py file a = POP3(TESTSERVER) print a.getwelcome() a.user(TESTACCOUNT) a.pass_(TESTPASSWORD) a.list() (numMsgs, totalSize) = a.stat() for i in range(1, numMsgs + 1): (header, msg, octets) = a.retr(i) print "Message ", `i`, ':' for line in msg: print ' ' + line print '-----------------------' a.quit() If this does not work some more information about your errors would be interesting. > > Why so hard to include a subject line using SMTPLIB? For an example with subject line try this >>> s=smtplib.SMTP("localhost") >>> print s.sendmail.__doc__ 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 barry at digicool.com Tue Feb 20 17:09:46 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Tue, 20 Feb 2001 11:09:46 -0500 Subject: newbie - POPLIB, MIMETOOLS and SMTPLIB - aaarrrghh! References: <3a90fe94.a405@newton.pacific.net.au> Message-ID: <14994.38602.283549.763001@anthem.wooz.org> >>>>> "A" == Andrew writes: A> Why would it be so hard for MIMETOOLS to read messages that A> come from POPLIB? Surely they are designed to work together? I'm not familar with poplib, but I'd be interested to know if mimelib works well with it (and if not what you'd suggest adding to mimelib). mimelib 0.2 can be found at: http://barry.wooz.org/software/pyware.html -Barry From mix77 at usa.net Mon Feb 19 13:10:34 2001 From: mix77 at usa.net (Mix) Date: Mon, 19 Feb 2001 14:10:34 +0200 Subject: PIL (Python Image Library) Message-ID: <3A910D3A.74602C0@usa.net> I am trying to manipulate (rotate) an image using PIL(Python Image Library). My problem is that I cannot get PIL to work form a browser, i.e. in my cgi script I have import Image and this gives the error : Traceback (innermost last): File "/home/mixo/faxserv/cgi-bin/t1.py", line 3, in ? import Image ImportError: No module named Image What is causing the error? If I run the script "t1.py" as any valid user on the machine from the command line , I get disried result.I know PIL has been installed as is if I run the Python i nterpreter I can manipulate images using PIL. I From rich_somerfield at tertio.com Tue Feb 20 12:18:17 2001 From: rich_somerfield at tertio.com (Rich Somerfield) Date: Tue, 20 Feb 2001 11:18:17 -0000 Subject: PIL (Python Image Library) References: <3A910D3A.74602C0@usa.net> Message-ID: Sounds like a problem with the PYTHONPATH, maybe this is not used in CGI scripts? I dont know but u might have to specify the full path of the modules that u r attempting to import. Or maybe a cheat would be to copy all of the python scripts that u want to import into the CGI-BIN directory (or the Python Interpreter directory). Regards Rich Mix wrote in message news:3A910D3A.74602C0 at usa.net... > I am trying to manipulate (rotate) an image using PIL(Python > Image Library). My problem is that I cannot get PIL to work > form a browser, i.e. in my cgi script I have > > import Image > > and this gives the error : > > Traceback (innermost last): > File "/home/mixo/faxserv/cgi-bin/t1.py", line 3, in ? > import Image > ImportError: No module named Image > > What is causing the error? If I run the script "t1.py" as any > valid user on the machine from the command line , I get disried > result.I know PIL has been installed as is if I run the Python i > nterpreter I can manipulate images using PIL. > I > > From jurgen.defurne at philips.com Mon Feb 19 13:56:08 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Mon, 19 Feb 2001 13:56:08 +0100 Subject: Followup : Huuuuge memory leak (third attempt) Message-ID: <0056890021971266000002L962*@MHS> I checked using Python 2.1b2 (or whatever), the leak remains. If it should be the case that this is a Windows NT bug, then I have another reason to loathe MS. It would have been real nice if I could have distributed Python for Windows NT (easier to install than Cygwin) and created a system so that the users themselves could install it on their machine and update scripts from a central point. Since running scheduled jobs is extremely important, a cron.py and atd.py daemon would be mandatory. Unfortunately, due to this memory leak, this isn't a real stable solution. Jurgen From mwh21 at cam.ac.uk Mon Feb 19 14:08:26 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 19 Feb 2001 13:08:26 +0000 Subject: Followup : Huuuuge memory leak (third attempt) References: Message-ID: jurgen.defurne at philips.com writes: > I checked using Python 2.1b2 (or whatever), the leak remains. What you posted before was in effect a mild fork bomb. So you have yet to convince anyone here that there is a real leak. Try again? Cheers, M. -- Java is a WORA language! (Write Once, Run Away) -- James Vandenberg (on progstone at egroups.com) & quoted by David Rush on comp.lang.scheme From fredrik at pythonware.com Mon Feb 19 14:27:21 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 19 Feb 2001 13:27:21 GMT Subject: Followup : Huuuuge memory leak (third attempt) References: Message-ID: jurgen.defurne at philips.com wrote: > If it should be the case that this is a Windows NT bug, then I have > another reason to loathe MS. since this is a bug in your program, does that mean that we can all loathe you? Cheers /F From scarblac at pino.selwerd.nl Mon Feb 19 18:41:30 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 19 Feb 2001 17:41:30 GMT Subject: Followup : Huuuuge memory leak (third attempt) References: Message-ID: jurgen.defurne at philips.com wrote in comp.lang.python: > I checked using Python 2.1b2 (or whatever), the leak remains. Fredrik also said something like this, when you posted the code fragment: what would you expect, if you started up programs and detached from them in an infinite loop? That *would* fill up your memory real fast, wouldn't it? -- Remco Gerlich From jurgen.defurne at philips.com Mon Feb 19 14:51:42 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Mon, 19 Feb 2001 14:51:42 +0100 Subject: Followup : Huuuuge memory leak (third attempt) Message-ID: <0056900016013514000002L042*@MHS> Since in the second version, the main loop sleeps long enough to make sure that the spawned script is finished before another one is released, this bomb has been defused, but the memory still mounts every time a process is spawned. Jurgen mwh21 at cam.ac.uk@SMTP at python.org on 19/02/2001 14:36:56 Sent by: python-list-admin at python.org To: python-list at python.org@SMTP cc: Subject: Re: Followup : Huuuuge memory leak (third attempt) Classification: jurgen.defurne at philips.com writes: > I checked using Python 2.1b2 (or whatever), the leak remains. What you posted before was in effect a mild fork bomb. So you have yet to convince anyone here that there is a real leak. Try again? Cheers, M. -- Java is a WORA language! (Write Once, Run Away) -- James Vandenberg (on progstone at egroups.com) & quoted by David Rush on comp.lang.scheme -- http://mail.python.org/mailman/listinfo/python-list From jurgen.defurne at philips.com Mon Feb 19 14:52:52 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Mon, 19 Feb 2001 14:52:52 +0100 Subject: Followup : Huuuuge memory leak (third attempt) Message-ID: <0056900016013594000002L042*@MHS> ---------------------- Forwarded by Jurgen Defurne/BRG/CE/PHILIPS on 19/02/2001 14:41 --------------------------- Jurgen Defurne 19/02/2001 14:36 To: sda at webde-ag.de@SMTP cc: Subject: Re: Followup : Huuuuge memory leak (third attempt) Classification: Unclassified One needs Administrator rights : this is absolutely no option here, since the IT-management likes to play 'Big Brother is watching you'. They Do Not Want ANYBODY to play Administrator on PC's. (I thought that this would mentioned one day) Jurgen From fredrik at pythonware.com Mon Feb 19 15:08:04 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 19 Feb 2001 14:08:04 GMT Subject: Followup : Huuuuge memory leak (third attempt) References: Message-ID: <8N9k6.18267$AH6.2517900@newsc.telia.net> jurgen.defurne at philips.com wrote: > Since in the second version, the main loop sleeps long enough to make > sure that the spawned script is finished before another one is released, doesn't look like it's sleeping: if len(sys.argv) == 1: while 1: # Doesn't matter if P_NOWAIT or P_DETACH, tried 'em both os.spawnl(os.P_DETACH, 'd:\\python20\\python', 'python', 'cron.py', 'check') # no sleep here elif sys.argv[1] == 'check': pass adding a time.sleep(0.2) makes it work better -- and after 10 minutes, the main process hasn't grown a single byte on my box... Cheers /F From jurgen.defurne at philips.com Mon Feb 19 15:49:38 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Mon, 19 Feb 2001 15:49:38 +0100 Subject: Followup : Huuuuge memory leak (third attempt) Message-ID: <0056900016016857000002L072*@MHS> Is your box Win NT or Win95 ? Are you using Task Manager ? I monitor my processes and the used memory. It is true, the memory of the process does not increase, but the used memory does. That is why I more and more suspect that it is an OS problem with the spawn calls. Jurgen fredrik at pythonware.com@SMTP at python.org on 19/02/2001 15:35:55 Please respond to fredrik at effbot.org@SMTP Sent by: python-list-admin at python.org To: python-list at python.org@SMTP cc: Subject: Re: Followup : Huuuuge memory leak (third attempt) Classification: jurgen.defurne at philips.com wrote: > Since in the second version, the main loop sleeps long enough to make > sure that the spawned script is finished before another one is released, doesn't look like it's sleeping: if len(sys.argv) == 1: while 1: # Doesn't matter if P_NOWAIT or P_DETACH, tried 'em both os.spawnl(os.P_DETACH, 'd:\\python20\\python', 'python', 'cron.py', 'check') # no sleep here elif sys.argv[1] == 'check': pass adding a time.sleep(0.2) makes it work better -- and after 10 minutes, the main process hasn't grown a single byte on my box... Cheers /F -- http://mail.python.org/mailman/listinfo/python-list From maxm at normik.dk Mon Feb 19 14:22:41 2001 From: maxm at normik.dk (=?iso-8859-1?Q?Max_M=F8ller_Rasmussen?=) Date: Mon, 19 Feb 2001 14:22:41 +0100 Subject: Is there a Python module for writing Midi Files Message-ID: <7BD10B680501D411B9DF009027E06F32197C03@exchange> I have looked all the usual places, Python.org, Google, the starship, etc. But it is not possible to finde one. But I guess that it must exist somewhere in someones private library. I want to use Python for algorithmic composition, and then write to a Midi file for importing into the reason software synthesizer for easy tweaking of the sound. Regards Max M From wware at world.std.com Mon Feb 19 16:07:05 2001 From: wware at world.std.com (Will Ware) Date: Mon, 19 Feb 2001 15:07:05 GMT Subject: Is there a Python module for writing Midi Files References: Message-ID: =?iso-8859-1?Q?Max_M=F8ller_Rasmussen?= (maxm at normik.dk) wrote: > I want to use Python for algorithmic composition, and then write > to a Midi file... I wrote some classes for reading MIDI files. I thought about adding write methods to them but didn't need it at the time. Still, they might be better than starting from nothing. http://groups.google.com/groups?th=a11ca7899a622abb&rnum=7&seld=944315225&ic=1 Good luck. -- -----------------------------------+--------------------- 22nd century: Esperanto, geodesic | Will Ware domes, hovercrafts, metric system | wware at world.std.com From guettli at interface-business.de Mon Feb 19 16:22:19 2001 From: guettli at interface-business.de (Thomas Guettler) Date: Mon, 19 Feb 2001 16:22:19 +0100 Subject: Is there a Python module for writing Midi Files In-Reply-To: <7BD10B680501D411B9DF009027E06F32197C03@exchange>; from maxm@normik.dk on Mon, Feb 19, 2001 at 02:22:41PM +0100 References: <7BD10B680501D411B9DF009027E06F32197C03@exchange> Message-ID: <20010219162219.E28726@gurkensalat.interface-business.de> On Mon, Feb 19, 2001 at 02:22:41PM +0100, Max M?ller Rasmussen wrote: > I have looked all the usual places, Python.org, Google, the starship, etc. > But it is not possible to finde one. But I guess that it must exist > somewhere in someones private library. > > I want to use Python for algorithmic composition, and then write to a Midi > file for importing into the reason software synthesizer for easy tweaking of > the sound. try midithing at: http://quitte.de/midithing.html -- Thomas Guettler Office: www.interface-business.de Private: http://yi.org/guettli From arildh at stud.cs.uit.no Mon Feb 19 14:27:16 2001 From: arildh at stud.cs.uit.no (Arild Hansen) Date: Mon, 19 Feb 2001 14:27:16 +0100 Subject: Starting a third party application Message-ID: I'm trying to make a small module that executes a third party application (for example gcalc or whatever). I do this using os.system("applicationname &") and then the program enters a while loop waiting for some external signal. When this signal arrives, I want the program to make a sys.exit(1) and terminate itself AS WELL AS the third party application it started. The code looks something like: os.system("applicationame &") while continue: if signal: continue = FALSE My problem is that when the program gets the signal and terminates, the third party application is still running. How do I solve this problem? All help greatly appreciated, A. Hansen From johnm at cs.uit.no Mon Feb 19 16:10:06 2001 From: johnm at cs.uit.no (johnm at cs.uit.no) Date: 19 Feb 2001 16:10:06 +0100 Subject: Starting a third party application References: Message-ID: Arild Hansen writes: > I'm trying to make a small module that executes a third party application > (for example gcalc or whatever). I do this using > os.system("applicationname &") and then the program enters a while loop > waiting for some external signal. When this signal arrives, I want the > program to make a sys.exit(1) and terminate itself AS WELL AS the third > party application it started. The code looks something like: > > os.system("applicationame &") > while continue: > if signal: > continue = FALSE > > > My problem is that when the program gets the signal and terminates, the > third party application is still running. How do I solve this problem? Maybe you should take a look at fork, exec, kill and wait (or spawn if you use one of the MS Windows variants). This example should do something similar: import os import time child = os.fork() if child: print "blabla" time.sleep(2) os.kill(child, 3) # or some other signal os.wait(child) else: print "Child, starting /bin/sleep" os.execv("/bin/sleep", ["/bin/sleep", "32"]) os.exit(-1) # Shouldn't happen, but in case exec fails From arildh at stud.cs.uit.no Tue Feb 20 09:31:36 2001 From: arildh at stud.cs.uit.no (Arild Hansen) Date: Tue, 20 Feb 2001 09:31:36 +0100 Subject: Starting a third party application In-Reply-To: References: Message-ID: Thx, worked just fine! I guess the "cs.uit.no" means that I didn't have to look too far to get an answer :) A. Hansen On 19 Feb 2001 johnm at cs.uit.no wrote: > Arild Hansen writes: > > > I'm trying to make a small module that executes a third party application > > (for example gcalc or whatever). I do this using > > os.system("applicationname &") and then the program enters a while loop > > waiting for some external signal. When this signal arrives, I want the > > program to make a sys.exit(1) and terminate itself AS WELL AS the third > > party application it started. The code looks something like: > > > > os.system("applicationame &") > > while continue: > > if signal: > > continue = FALSE > > > > > > My problem is that when the program gets the signal and terminates, the > > third party application is still running. How do I solve this problem? > > Maybe you should take a look at fork, exec, kill and wait (or spawn if > you use one of the MS Windows variants). This example should do > something similar: > > import os > import time > > child = os.fork() > if child: > print "blabla" > time.sleep(2) > os.kill(child, 3) # or some other signal > os.wait(child) > else: > print "Child, starting /bin/sleep" > os.execv("/bin/sleep", ["/bin/sleep", "32"]) > os.exit(-1) # Shouldn't happen, but in case exec fails > > From alet at unice.fr Mon Feb 19 15:08:24 2001 From: alet at unice.fr (Jerome Alet) Date: Mon, 19 Feb 2001 15:08:24 +0100 Subject: [ANNOUNCE] New version of the JAXML module Message-ID: <3A9128D8.35D0EE22@unice.fr> I'm very pleased to announce you the new 2.10 version of the JAXML module. With the JAXML module, generating XML documents has never been easier, this module: * Takes care of the indentation for you: your XML documents are readable by humans. * Takes care of closing tags for you. * Can generate every tag you want in an incredibly easy way. * Offers two templating facilities (see below) * Can generate XHTML documents and be used in CGI scripts because it takes care of the HTTP headers too. Here's a sample: --- CUT --- import jaxml x = jaxml.XML_document() x.something(value=5).dummy("some dummy text", isntit="YES") print x will produce: some dummy text --- CUT --- The JAXML module is GPLed, you can download it freely from: http://cortex.unice.fr/~jerome/jaxml/ Changes: * A new and very powerful templating facility was added: there is now two templating facilities in JAXML * Better code documentation. * When testing truth value on documents, returns false on empty documents and true on not empty ones. The well commented test program and module's sources are your best friends. Comments are very welcome. -- Jerome Alet - alet at unice.fr - http://cortex.unice.fr/~jerome Fac de Medecine de Nice http://wwwmed.unice.fr Tel: (+33) 4 93 37 76 30 Fax: (+33) 4 93 53 15 15 28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE From gerhard.nospam at bigfoot.de Mon Feb 19 16:42:38 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Mon, 19 Feb 2001 16:42:38 +0100 Subject: [ANNOUNCE] New version of the JAXML module References: <3A9128D8.35D0EE22@unice.fr> Message-ID: On Mon, 19 Feb 2001 15:08:24 +0100, Jerome Alet wrote: >I'm very pleased to announce you the new 2.10 version of the JAXML >module. > >With the JAXML module, generating XML documents has never been easier, >this module: > > [snip] > >The JAXML module is GPLed, you can download it freely from: > > http://cortex.unice.fr/~jerome/jaxml/ > > [snip] > >Comments are very welcome. Could you please change the license to LGPL or another more liberal license? This would make your module usable by a lot more people. Putting the GPL on a library prevents it from being used in a commercial application. Gerhard -- mail: gerhard bigfoot de web: http://highqualdev.com From alet at unice.fr Tue Feb 20 10:00:59 2001 From: alet at unice.fr (Jerome Alet) Date: Tue, 20 Feb 2001 10:00:59 +0100 Subject: [ANNOUNCE] New version of the JAXML module References: <3A9128D8.35D0EE22@unice.fr> Message-ID: <3A92324B.3F7CD22D@unice.fr> Gerhard H?ring wrote: > > On Mon, 19 Feb 2001 15:08:24 +0100, Jerome Alet wrote: > >The JAXML module is GPLed, you can download it freely from: > > > > http://cortex.unice.fr/~jerome/jaxml/ > Could you please change the license to LGPL or another more liberal license? > This would make your module usable by a lot more people. Putting the GPL on > a library prevents it from being used in a commercial application. Several people have already asked the same thing... The purpose of the GPL on this module is not to forbid you to use it in a commercial application, but to forbid you to use it in a proprietary application, which is very different. If your commercial application is delivered under the GPL then there's no problem: feel free to sell it, and sell my module if you want. But you must also give the same rights to the people you sell it. Despite its very small size, I think this module is (or could be made) powerful, and it took me some time to write it, so I don't want it to be used in non-Free Software. I think (maybe I'm wrong) that its simplicity of use compared to the official (and of course more complete) XML modules is attractive and is an advantage given to the Free Software world. Since I want to give my copyright on this module to the FSF, their policy might be different and they could decide to put it under the LGPL, but now it is GPLed. So, not to be rude, but your only options are: * use this module internally and don't redistribute your work * distribute your application under the GPL licence (best choice for people) * don't use my module (probably your best choice for a proprietary application) bye, -- Jerome Alet - alet at unice.fr - http://cortex.unice.fr/~jerome Fac de Medecine de Nice http://wwwmed.unice.fr Tel: (+33) 4 93 37 76 30 Fax: (+33) 4 93 53 15 15 28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE From chris at voodooland.net Tue Feb 20 10:20:57 2001 From: chris at voodooland.net (Chris Watson) Date: Tue, 20 Feb 2001 03:20:57 -0600 (CST) Subject: [ANNOUNCE] New version of the JAXML module In-Reply-To: <3A92324B.3F7CD22D@unice.fr> Message-ID: > Several people have already asked the same thing... Me too! > So, not to be rude, but your only options are: > > * use this module internally and don't redistribute your work > * distribute your application under the GPL licence (best choice for > people) > * don't use my module (probably your best choice for a proprietary > application) All of which you are right about obviously. Any chance you will reconsider perhaps maybe a dual license? GPL and BSDL ? -- ============================================================================= -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?" ============================================================================= GNU = Gnu's Non-portable & Unstable irc.openprojects.net #FreeBSD -Join the revolution! ICQ: 20016186 From gerhard.nospam at bigfoot.de Tue Feb 20 16:10:42 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Tue, 20 Feb 2001 16:10:42 +0100 Subject: [ANNOUNCE] New version of the JAXML module References: <3A9128D8.35D0EE22@unice.fr> <3A92324B.3F7CD22D@unice.fr> Message-ID: On Tue, 20 Feb 2001 10:00:59 +0100, Jerome Alet wrote: >Gerhard H?ring wrote: >> >> On Mon, 19 Feb 2001 15:08:24 +0100, Jerome Alet wrote: >> >The JAXML module is GPLed, you can download it freely from: >> > >> > http://cortex.unice.fr/~jerome/jaxml/ > >> Could you please change the license to LGPL or another more liberal license? >> This would make your module usable by a lot more people. Putting the GPL on >> a library prevents it from being used in a commercial application. > >Several people have already asked the same thing... > >The purpose of the GPL on this module is not to forbid you to use it in >a commercial application, but to forbid you to use it in a proprietary >application, which is very different. Yes, I know. Using a GPL-ed library in any of my programs restricts options on what I can do with *my code*, though. I just like to have all the options. I might troll and say the GPL is less free than the BSD license, but let's not start this flamewar again. >If your commercial application is delivered under the GPL then there's >no problem: feel free to sell it, and sell my module if you want. But >you must also give the same rights to >the people you sell it. Yes that's my point. If I use a GPL'd module the author forces me to GPL the rest of my code. That's why using it restricts me. The LGPL would protect *your* work, but wouldn't try to force *mine* under GPL, too. That's why I prefer LGPL or BSD licensed libraries. >Despite its very small size, I think this module is (or could be made) >powerful, and it took me some time to write it, so I don't want it to be >used in non-Free Software. I think (maybe I'm wrong) that its simplicity >of use compared to the official (and of course more complete) XML >modules is attractive and is an advantage given to the Free Software >world. > >Since I want to give my copyright on this module to the FSF, their >policy might be different and they could decide to put it under the >LGPL, but now it is GPLed. > >So, not to be rude, but your only options are: > > * use this module internally and don't redistribute your work > * distribute your application under the GPL licence (best choice for >people) > * don't use my module (probably your best choice for a proprietary >application) Just to be clear: Of course I respect your licensing decision. You perfectly know the implications of putting *libary* under the GPL. That's fine. I just wanted to be sure. Gerhard -- mail: gerhard bigfoot de web: http://highqualdev.com From gregor at mediasupervision.de Tue Feb 20 16:54:15 2001 From: gregor at mediasupervision.de (Gregor Hoffleit) Date: Tue, 20 Feb 2001 16:54:15 +0100 Subject: [ANNOUNCE] New version of the JAXML module In-Reply-To: ; from gerhard.nospam@bigfoot.de on Tue, Feb 20, 2001 at 04:10:42PM +0100 References: <3A9128D8.35D0EE22@unice.fr> <3A92324B.3F7CD22D@unice.fr> Message-ID: <20010220165415.B16924@mediasupervision.de> On Tue, Feb 20, 2001 at 04:10:42PM +0100, Gerhard H?ring wrote: > Yes that's my point. If I use a GPL'd module the author forces me to GPL the > rest of my code. That's why using it restricts me. The LGPL would protect > *your* work, but wouldn't try to force *mine* under GPL, too. That's why I > prefer LGPL or BSD licensed libraries. If you prefer BSD, just release your code under a BSD-like license. BSD-like licenses go well with GPL code. You're not forced to use GPL, it just has to be a 'reasonably free' license. Gregor From alet at unice.fr Tue Feb 20 17:05:43 2001 From: alet at unice.fr (Jerome Alet) Date: Tue, 20 Feb 2001 17:05:43 +0100 Subject: [ANNOUNCE] New version of the JAXML module References: <3A9128D8.35D0EE22@unice.fr> <3A92324B.3F7CD22D@unice.fr> Message-ID: <3A9295D7.9B2231AC@unice.fr> Gerhard H?ring wrote: > options. I might troll and say the GPL is less free than the BSD license, > but let's not start this flamewar again. No, it would be a very bad idea (tm) !-)) > Yes that's my point. If I use a GPL'd module the author forces me to GPL the > rest of my code. That's why using it restricts me. The LGPL would protect > *your* work, but wouldn't try to force *mine* under GPL, too. That's why I > prefer LGPL or BSD licensed libraries. yes but the LGPL wouldn't encourage you to write free software, since you'd be allowed to use it in a non free application. > Just to be clear: Of course I respect your licensing decision. You perfectly > know the implications of putting *libary* under the GPL. That's fine. I just > wanted to be sure. There's no problem. As mentionned by Martin above, I'm open to discussion ;-) bye, Jerome Alet From loewis at informatik.hu-berlin.de Tue Feb 20 14:06:41 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 20 Feb 2001 14:06:41 +0100 Subject: [ANNOUNCE] New version of the JAXML module References: Message-ID: Chris Watson writes: > > So, not to be rude, but your only options are: > > > > * use this module internally and don't redistribute your work > > * distribute your application under the GPL licence (best choice for > > people) > > * don't use my module (probably your best choice for a proprietary > > application) > > All of which you are right about obviously. Any chance you will > reconsider perhaps maybe a dual license? I don't know where this desire of talking authors into changing their license comes from: he who writes the code writes the license. If you really need his software in an application where the GPL is unacceptable, maybe you should offer him a certain amount of money to change the license. Just by posting to this group is unlikely to achieve that effect after he made it clear that choice of license was on purpose, not by mistake. Regards, Martin From ransen_spam_me_not at nemo.it Mon Feb 19 16:31:52 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Mon, 19 Feb 2001 15:31:52 GMT Subject: Py_SetProgramName? Message-ID: <3a913b2f.4245179@news.newsguy.com> Embeddinga and Extending, I'm not sure of the reasons for calling : Py_SetProgramName Is it for getting the command line arguments of a C program calling Python? Or for something to do with the search path of modules? -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From aleaxit at yahoo.com Mon Feb 19 17:15:54 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 19 Feb 2001 17:15:54 +0100 Subject: Py_SetProgramName? References: <3a913b2f.4245179@news.newsguy.com> Message-ID: <96rgs712drn@news1.newsguy.com> "Owen F. Ransen" wrote in message news:3a913b2f.4245179 at news.newsguy.com... > Embeddinga and Extending, I'm not sure of the reasons > for calling : > > Py_SetProgramName > > Is it for getting the command line arguments of > a C program calling Python? Or for something to > do with the search path of modules? The latter. Quoting from "1.4, Embedding Python" in the Python/C API Reference Manual: """ The embedding application can steer the search by calling Py_SetProgramName(file) before calling Py_Initialize(). Note that $PYTHONHOME still overrides this and $PYTHONPATH is still inserted in front of the standard path. An application that requires total control has to provide its own implementation of Py_GetPath(), Py_GetPrefix(), Py_GetExecPrefix(), and Py_GetProgramFullPath() (all defined in Modules/getpath.c). """ If your embedding application wants to set the sys.argv list, it can do so, quite separately from Py_SetProgramName, by calling PySys_SetArgv(argc, argv) *after* it calls Py_Initialize. Alex From ransen_spam_me_not at nemo.it Tue Feb 20 07:04:29 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Tue, 20 Feb 2001 06:04:29 GMT Subject: Py_SetProgramName? References: <3a913b2f.4245179@news.newsguy.com> <96rgs712drn@news1.newsguy.com> Message-ID: <3a920669.2025119@news.newsguy.com> >Quoting from "1.4, Embedding Python" in >the Python/C API Reference Manual: > >""" >The embedding application can steer the search by >calling Py_SetProgramName(file) before calling >Py_Initialize(). Note that $PYTHONHOME still overrides >this and $PYTHONPATH is still inserted in front of the >standard path. An application that requires total >control has to provide its own implementation of >Py_GetPath(), Py_GetPrefix(), Py_GetExecPrefix(), >and Py_GetProgramFullPath() (all defined in >Modules/getpath.c). >""" I read that several times before posting my original message. It still is not clear to me what or why I should call the function. Like many manuals it assumes that you understand EVERYTHING else in the manual except the entry you are currently reading! ;) Maybe someone can give me a practical example of when I would want to use Py_SetProgramName(file) -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From zope at thewebsons.com Mon Feb 19 17:14:30 2001 From: zope at thewebsons.com (Ben Ocean) Date: Mon, 19 Feb 2001 08:14:30 -0800 Subject: Testing for Speed Message-ID: <5.0.2.1.0.20010219081411.009f3c60@lefeberbulb.com> Hi; How do I determine a visitor's connection speed? Clock a round trip? TIA, BenO From erno-news at erno.iki.fi Mon Feb 19 17:59:54 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 19 Feb 2001 18:59:54 +0200 Subject: Testing for Speed References: Message-ID: In article , Ben Ocean writes: | Hi; | How do I determine a visitor's connection speed? Clock a round trip? i'd suggest a laser doppler velocity gauge, that way you don't have to ask your visitor to make a whole round trip. -- erno From emile at fenx.com Mon Feb 19 18:08:18 2001 From: emile at fenx.com (Emile van Sebille) Date: Mon, 19 Feb 2001 09:08:18 -0800 Subject: Testing for Speed References: Message-ID: <96rk35$bh94k$1@ID-11957.news.dfncis.de> One approach used on web sites that do this (see http://home.cfl.rr.com/eaa/Bandwidth.htm )is to embed a large amount of non-content in a web document and time the transmission. Others use client side javascript to time a download from their site. The ones that I've looked at all seem to measure the speed of the narrowest point between the client and server. If you want to know the speed of the connection at the client side, I think you'd want a client side script that connects to many places and then take the highest calculated rate. HTH, -- Emile van Sebille emile at fenx.com ------------------- "Ben Ocean" wrote in message news:mailman.982599381.15269.python-list at python.org... > Hi; > How do I determine a visitor's connection speed? Clock a round trip? > TIA, > BenO > > From grante at visi.com Tue Feb 20 19:47:10 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 20 Feb 2001 18:47:10 GMT Subject: Testing for Speed References: Message-ID: In article , Ben Ocean wrote: >How do I determine a visitor's connection speed? Clock a round trip? "Connection speed" is a rather vague term. The only meaningful results are going to be from measuring whatever it is you care about. If you want to know how long it takes to download a 100K file, then transfer a 100K file and measure it. For file transfers, you should have a pretty representative number by measuring how much data you can transfer over a period of a several seconds. If you just want round-trip packet timing, doing a "ping" will tell you that, but ping times don't correlate with data transfer rates. Ping measures how long the pipe is, data transfer rate is determined by its diameter. -- Grant Edwards grante Yow! I'm reporting for at duty as a modern person. I visi.com want to do the Latin Hustle now! From gabriel_ambuehl at buz.ch Mon Feb 19 18:18:17 2001 From: gabriel_ambuehl at buz.ch (Gabriel Ambuehl) Date: Mon, 19 Feb 2001 18:18:17 +0100 Subject: Testing for Speed In-Reply-To: <5.0.2.1.0.20010219081411.009f3c60@lefeberbulb.com> References: <5.0.2.1.0.20010219081411.009f3c60@lefeberbulb.com> Message-ID: <89448442806.20010219181817@buz.ch> -----BEGIN PGP SIGNED MESSAGE----- Hello Ben, Monday, February 19, 2001, 5:14:30 PM, you wrote: > Hi; > How do I determine a visitor's connection speed? Clock a round trip? You can't. pings might give you an impression but even those will only make sense if there are only a few hops between you and the visitor. I, for example, got 512kbit cable here. In Switzerland, I got ping times of under 20ms to really fast servers and can download with 50kbyte/s. For fast servers in the USA, I have about 110ms ping times but still I'm able to download with 50kbyte/s. Conclusion: there's no such thing as accurate connection speed detection. The ONLY thing you can do is round trip time measurement but as pointed out above, this won't tell you much. Best regards, Gabriel -----BEGIN PGP SIGNATURE----- Version: PGP 6.0.2i iQEVAwUBOpFHUcZa2WpymlDxAQElbwgAolim4olzagCC+3eR9Ps93I0Y0BKCiBn1 H/FN1whb3QxmF/SC0v3ekl0OQAqy59nXpseo3iMQwKGT8lv+c1wISGSXjhhw/Ze+ T2xDTLTqE8HfOKGby+fcIBI9KxrMq1ZerExz5chu1vN2/InLZo7CM62y0v6M3wxW SkIgUufw2ALAV1+Tv75UGlJjR06sMBAR0b7N1r9I/nCcxYMKKllVX25Ux2DoIvoW 4x0qpAGwEX5UgPwzce6sR/atI1QDSm6G0JmGzJnwC/oXMpLB8sqcwDEhPXw20GJc Ev5cewR2hraEceSrh2C2vaMfTQHnggiJzfWKjq952Nuax9IV5T47Eg== =xS8Z -----END PGP SIGNATURE----- From ransen_spam_me_not at nemo.it Mon Feb 19 19:06:35 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Mon, 19 Feb 2001 18:06:35 GMT Subject: Where to get Python20_d.lib for Win32 ? Message-ID: <3a91435d.6339893@news.newsguy.com> Hello All, Where can I find python20_d.lib to download? (I'd rather not rebuild the sources myself since I am already up to my neck in it understanding "embedding and extending") TIA -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From trentm at ActiveState.com Mon Feb 19 23:18:54 2001 From: trentm at ActiveState.com (Trent Mick) Date: Mon, 19 Feb 2001 14:18:54 -0800 Subject: Where to get Python20_d.lib for Win32 ? In-Reply-To: <3a91435d.6339893@news.newsguy.com>; from ransen_spam_me_not@nemo.it on Mon, Feb 19, 2001 at 06:06:35PM +0000 References: <3a91435d.6339893@news.newsguy.com> Message-ID: <20010219141854.C31647@ActiveState.com> On Mon, Feb 19, 2001 at 06:06:35PM +0000, Owen F. Ransen wrote: > Hello All, > > Where can I find python20_d.lib to download? > > (I'd rather not rebuild the sources myself since > I am already up to my neck in it understanding > "embedding and extending") One place is: http://www.activestate.com/Products/ActivePython/Download.html look for the "ActivePython-2.0.0.202.debug.tar.gz" link Cheers, Trent -- Trent Mick TrentM at ActiveState.com From MarkH at ActiveState.com Mon Feb 19 23:32:27 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Mon, 19 Feb 2001 22:32:27 GMT Subject: Where to get Python20_d.lib for Win32 ? References: <3a91435d.6339893@news.newsguy.com> Message-ID: <3A919E21.4080903@ActiveState.com> Owen F. Ransen wrote: > Hello All, > > Where can I find python20_d.lib to download? You can find one at http://www.activestate.com/Products/ActivePython/Download.html > (I'd rather not rebuild the sources myself since > I am already up to my neck in it understanding > "embedding and extending") I strongly suggest you do! It is not that painful and if you are going through extending and embedding pain having everything built locally makes stepping through the source code etc much simpler. Mark. -- Nominate Your Favorite Programmers for the Perl and Python Active Awards! http://www.ActiveState.com/Awards/ From tim.one at home.com Mon Feb 19 23:35:21 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 19 Feb 2001 17:35:21 -0500 Subject: Where to get Python20_d.lib for Win32 ? In-Reply-To: <3a91435d.6339893@news.newsguy.com> Message-ID: [posted & mailed] [Owen F. Ransen] > Hello All, > > Where can I find python20_d.lib to download? Go to https://sourceforge.net/project/showfiles.php?group_id=5470 and pick up Python-2.0-Debug.zip. It contains all the 2.0 _d stuff (including DLLs and .pyds and .exes -- the .libs alone won't do you much good). > (I'd rather not rebuild the sources myself since I am already > up to my neck in it understanding "embedding and extending") Then rebuilding from source yourself is a darned good exercise! At heart, Python is itself a C application and all the std C modules are "extensions" to it. Fiddling the source for Python itself can be very helpful in figuring out mysteries in your own extensions. From ransen_spam_me_not at nemo.it Tue Feb 20 07:12:06 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Tue, 20 Feb 2001 06:12:06 GMT Subject: Where to get Python20_d.lib for Win32 ? References: <3a91435d.6339893@news.newsguy.com> Message-ID: <3a930aa5.3109364@news.newsguy.com> >Where can I find python20_d.lib to download? Thanks all for the pointers :) -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From ransen_spam_me_not at nemo.it Tue Feb 20 16:28:37 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Tue, 20 Feb 2001 15:28:37 GMT Subject: Where to get Python20_d.lib for Win32 ? References: Message-ID: <3a928cf1.1181595@news.newsguy.com> On Mon, 19 Feb 2001 17:35:21 -0500, "Tim Peters" wrote: >> Where can I find python20_d.lib to download? >Go to > https://sourceforge.net/project/showfiles.php?group_id=5470 >and pick up Python-2.0-Debug.zip. >Then rebuilding from source yourself is a darned good exercise! Where can I download the sources? That page does not seem to have them, or maybe I am missing something? -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From zamurai at gmx.net Mon Feb 19 19:15:29 2001 From: zamurai at gmx.net (Zamurai) Date: Mon, 19 Feb 2001 19:15:29 +0100 Subject: Does an Tkinter widget exist, that is like JTabbedPane (a java-swing widget)??? Message-ID: <982606529.1988133305@news.t-online.de> From kleistereimer at gmx.de Mon Feb 19 19:16:45 2001 From: kleistereimer at gmx.de (kleistereimer at gmx.de) Date: Mon, 19 Feb 2001 19:16:45 +0100 (MET) Subject: docs/examples for building windows modules (dll's) from c++. distutils ??? Message-ID: <11418.982606605@www10.gmx.net> hi! i'm a c++ professional, but i have converted to python now. (wx..) my 2 problems are: 1. i have lot's of hardware-dependend c++ classes, i need to extend python with. 2. i need to make a (binary) installer for linux and windows. (at best not releasing the sources, and including a python interpreter already. (i can do this with a modified py2exe already)) I suppose the distutils will (at least) help with both (?) problems. (i like my software to be standart-conform) 1: there are examples and docs to extend python with c-code, but not for c++ classes. so how to wrap c++ code to make it callable from python? (c++ code means a complete class hierarchy in aprox 30 files which contains one interface class and one iterator class on top, which both needs to be accessible from python) 2: next thing is how to compile the wrapped c++. i found references to a 'compile.py' which generates vc6 project-files. but it's not available anymore. (use distutils everyone tells me..) and i wont use outdated tools.. the documentation of distutils is not very clear. and the examples-pages are empty. all i need is a minimal example where a c++ class is interfaced to python, and compiled to a dll using bc, or vc. at best all driven by distutils to make it standart-conform. distutils seem to encapsulate compilers, so maybe i'm able to generate the dll using distutils? or am i completely wrong? please point me to some information! THANK YOU!! -- Sent through GMX FreeMail - http://www.gmx.net From thomas.heller at ion-tof.com Mon Feb 19 19:25:21 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Mon, 19 Feb 2001 19:25:21 +0100 Subject: [Distutils] docs/examples for building windows modules (dll's) from c++. distutils ??? References: <11418.982606605@www10.gmx.net> Message-ID: <031301c09aa1$51a95d40$e000a8c0@thomasnotebook> kleistereimer wrote: > hi! > > i'm a c++ professional, but i have converted to python now. (wx..) > my 2 problems are: > > 1. i have lot's of hardware-dependend c++ classes, i need to extend > python with. > 2. i need to make a (binary) installer for linux and windows. > (at best not releasing the sources, and including a python interpreter > already. (i can do this with a modified py2exe already)) As the author of py2exe I would certainly like to hear more about this! > > I suppose the distutils will (at least) help with both (?) problems. > (i like my software to be standart-conform) > > 1: > there are examples and docs to extend python with c-code, > but not for c++ classes. > so how to wrap c++ code to make it callable from python? > (c++ code means a complete class hierarchy in aprox 30 files > which contains one interface class and one iterator class on top, > which both needs to be accessible from python) > > 2: > next thing is how to compile the wrapped c++. > Take a look at SWIG: http://www.swig.org/ Distutils contains (in an early stage) support for swig. Thomas From qrczak at knm.org.pl Mon Feb 19 19:29:43 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 19 Feb 2001 18:29:43 GMT Subject: An alternative approach to bound methods Message-ID: Here is how I would handle bound methods. Similar to Python but a bit different. A disadvantage of current function-to-bound-method conversion is that it checks the type of the object and does an adjustment in a specific case, instead of working uniformly for all types. It breaks when a method is implemented as some other object than a function and introduces unnecessary complexity to the language definition. Why to have unbound methods as a separate concept from functions? Why objects of other types can't act as methods? Why I can store any value as a data of a class *except* functions (which are converted to unbound methods)? And I would like to have static methods. The conversion happens during extraction of an attribute out of a class, in case it's a function. IMHO it should happen during translation of extract-from-instance to extract-from-class, for all cases. obj.x, when obj is an instance object, first searches for 'x' in its __dict__. If not found, it should try obj.__class__.x, converting it to a bound method by making a proxy object which, when called, calls the function with obj argument prepended (and perhaps passes other attribute accesses transparently, but it's not essential - it could provide the real function as im_func only as well). Nothing magical happens when attributes are extracted from a class itself, no matter what their types are. There are no unbound methods, just functions. You can define static methods by plain def m() in a class, without the self parameter. You can call any method as a static method, with any object as its first argument. Only when you call a method through an instance, self is prepended. Any callable object can behave as a method. What we lose is the ability to access class attributes by getting an attribute of an instance (in case they are not functions, because you could not do it when they are functions anyway). It's not a problem except compatibility. When scopes nest, you can just refer to these names unqualified. You can also refer to them qualified by the class name, which works as now from any place where the class is accessible. What do you think? -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From drtimcouper at yahoo.co.uk Tue Feb 20 16:55:08 2001 From: drtimcouper at yahoo.co.uk (=?iso-8859-1?q?Tim=20Couper?=) Date: Tue, 20 Feb 2001 15:55:08 +0000 (GMT) Subject: An alternative approach to bound methods In-Reply-To: Message-ID: <20010220155508.4879.qmail@web6403.mail.yahoo.com> Marcin wrote _____ A disadvantage of current function-to-bound-method conversion is that it checks the type of the object and does an adjustment in a specific case, instead of working uniformly for all types. It breaks when a method is implemented as some other object than a function and introduces unnecessary complexity to the language definition. Why to have unbound methods as a separate concept from functions? Why objects of other types can't act as methods? Why I can store any value as a data of a class *except* functions (which are converted to unbound methods)? And I would like to have static methods. The conversion happens during extraction of an attribute out of a class, in case it's a function. IMHO it should happen during translation of extract-from-instance to extract-from-class, for all cases. obj.x, when obj is an instance object, first searches for 'x' in its __dict__. If not found, it should try obj.__class__.x, converting it to a bound method by making a proxy object which, when called, calls the function with obj argument prepended (and perhaps passes other attribute accesses transparently, but it's not essential - it could provide the real function as im_func only as well). Nothing magical happens when attributes are extracted from a class itself, no matter what their types are. There are no unbound methods, just functions. You can define static methods by plain def m() in a class, without the self parameter. You can call any method as a static method, with any object as its first argument. Only when you call a method through an instance, self is prepended. Any callable object can behave as a method. What we lose is the ability to access class attributes by getting an attribute of an instance (in case they are not functions, because you could not do it when they are functions anyway). It's not a problem except compatibility. When scopes nest, you can just refer to these names unqualified. You can also refer to them qualified by the class name, which works as now from any place where the class is accessible. What do you think? _________________ FWIW I think that this seems an excellent suggestion; for one, I would find it a real asset to have such a seemingly python-esque way of having class functions/static methods available in this manner. What is the procedure to bring this suggestion the the powers-that-be? Tim Couper ____________________________________________________________ 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 jeremy at alum.mit.edu Tue Feb 20 18:11:16 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Tue, 20 Feb 2001 12:11:16 -0500 (EST) Subject: An alternative approach to bound methods In-Reply-To: <20010220155508.4879.qmail@web6403.mail.yahoo.com> References: <20010220155508.4879.qmail@web6403.mail.yahoo.com> Message-ID: <14994.42292.696689.559105@w221.z064000254.bwi-md.dsl.cnc.net> >>>>> "TC" == Tim Couper writes: TC> What we lose is the ability to access class attributes by TC> getting an attribute of an instance (in case they are not TC> functions, because you could not do it when they are functions TC> anyway). It's not a problem except compatibility. When scopes TC> nest, you can just refer to these names unqualified. You can TC> also refer to them qualified by the class name, which works as TC> now from any place where the class is accessible. TC> What do you think? I'm not sure I really followed this argument. Perhaps some code examples would help. The ability to access class attributes via self is pretty fundamental property of Python. I don't expect it will go away. Also note that nested scopes do not allow access to class attributes as unqualified names. When resolving free variables, class scopes are skipped. This decision was made because we wanted to enforce the rule that all access to class and instance data should be via self. TC> _________________ TC> FWIW I think that this seems an excellent suggestion; for one, I TC> would find it a real asset to have such a seemingly python-esque TC> way of having class functions/static methods available in this TC> manner. What is the procedure to bring this suggestion the the TC> powers-that-be? Write a PEP. http://python.sourceforge.net/peps/ Jeremy From qrczak at knm.org.pl Wed Feb 21 23:43:20 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 21 Feb 2001 22:43:20 GMT Subject: An alternative approach to bound methods References: <20010220155508.4879.qmail@web6403.mail.yahoo.com> Message-ID: Tue, 20 Feb 2001 12:11:16 -0500 (EST), Jeremy Hylton pisze: > The ability to access class attributes via self is pretty fundamental > property of Python. I don't expect it will go away. It's a pity. With my proposal it could be at most retained as a compatibility hack: when translating the object attribute access to class attribute access, check if it's callable, and do the self-prepending transformation only if it is - because it would be meaningless otherwise anyway. But it does not fit the spirit of the proposal at all, it's bad to rely on absence of an interface, and thus it would be deprecated. No way to have it as a preferred access. You can refer to these names unqualified, or qualified by self.__class__, or qualified by the class name (each way has a slightly different semantics wrt. inheritance and name rebinding), but not with self. Unless you copy them to instances in __init__ (class attributes already can't be assigned to from methods, so it should work in all cases). Current Python does rely on a negative constraint: class attributes can be any types *except* functions. This is bad in principle, even if mostly harmless in practice. It's not quite harmless today: we don't have class methods because of this, even though it's obvious how they would be written if they worked, and they can be simulated by other callable objects. It's also ugly that the builtin function type has special rights that no other type can emulate. Sorry, this proposal does change a fundamental Python's rule. I believe it would be a saner design ignoring the status quo. But it's difficult to apply it to an existing language without breaking compatibility. I can specify the details, write a PEP, write open questions about the details, write examples etc., but for all that to make sense, I would have to hear positive feedback from a person which can decide about changing such core things. > Also note that nested scopes do not allow access to class attributes > as unqualified names. When resolving free variables, class scopes are > skipped. This decision was made because we wanted to enforce the rule > that all access to class and instance data should be via self. I would definitely change that and let all scopes nest, classes too. A recursive function should be able to refer to itself in the same way no matter if it's defined at the top level, in another function, or in a class. The first two cases were unified in 2.1b2, but the third has not been unified. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From aleaxit at yahoo.com Thu Feb 22 11:14:05 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 22 Feb 2001 11:14:05 +0100 Subject: An alternative approach to bound methods References: <20010220155508.4879.qmail@web6403.mail.yahoo.com> Message-ID: <972opb0ngg@news2.newsguy.com> "Marcin 'Qrczak' Kowalczyk" wrote in message news:slrn998h48.1te.qrczak at qrnik.zagroda... [snip] > I would definitely change that and let all scopes nest, classes too. > > A recursive function should be able to refer to itself in the same > way no matter if it's defined at the top level, in another function, > or in a class. The first two cases were unified in 2.1b2, but the > third has not been unified. I *STRONGLY* disagree, because in the third case, AND IN IT ONLY, inheritance and overriding come into play!!! class X: def foo(self, N): if N>23: return 1+2*self.foo(N/2-4) else: return N/7 _This_ recursively-defined function IS subject to overriding -- I know this, and I see it very clearly, because of the "self.foo". It would be just as clear and explicit that overring is NOT supported if I used X.foo in the recursive call. _Normally_ the potential for polymorphism and overriding IS desired, of course, but it's important to be able to explicitly express "...and here, strangely enough, NO overriding predicted". But what should it mean if just "1+foo(N/2-4)" was coded, in your "all scopes nest" ideal? Would you thus facilitate the EXCEPTIONAL case, in which X.foo is wanted, to the detriment of the NORMAL case, in which self.foo is wanted? Or have some C++-like black magick, to have foo mean self.foo...?! Thanks, but, NO thanks. Nesting is for the birds!-) Alex From qrczak at knm.org.pl Thu Feb 22 15:38:53 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 22 Feb 2001 14:38:53 GMT Subject: An alternative approach to bound methods References: <20010220155508.4879.qmail@web6403.mail.yahoo.com> <972opb0ngg@news2.newsguy.com> Message-ID: Thu, 22 Feb 2001 11:14:05 +0100, Alex Martelli pisze: > I *STRONGLY* disagree, because in the third case, AND IN IT ONLY, > inheritance and overriding come into play!!! Sure. So depending on whether you want recursive call to refer to the function itself or to its version overridden by inheritance, you would write either foo X.foo or self.__class__.foo self.foo # After initialization of self.foo in __init__ > _Normally_ the potential for polymorphism and overriding IS desired, In recursive calls to class methods? Not at all. If the overridden version calls me, it probably expects that I would do what I was supposed to do in the superclass. No matter if I do this by calling myself recursively or not. Not to say that class methods would rarely be overridden at all - they are not called in the context of an instance after all. Remember that I am talking about class methods, which don't exist now at all. They can be currently expressed as module functions which are not subject to inheritance. Instance methods are normally called through self as always! -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From aleaxit at yahoo.com Thu Feb 22 17:30:24 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 22 Feb 2001 17:30:24 +0100 Subject: An alternative approach to bound methods References: <20010220155508.4879.qmail@web6403.mail.yahoo.com> <972opb0ngg@news2.newsguy.com> Message-ID: <973er001d39@news2.newsguy.com> "Marcin 'Qrczak' Kowalczyk" wrote in message news:slrn99a93s.vn8.qrczak at qrnik.zagroda... > Thu, 22 Feb 2001 11:14:05 +0100, Alex Martelli pisze: > > > I *STRONGLY* disagree, because in the third case, AND IN IT ONLY, > > inheritance and overriding come into play!!! > > Sure. So depending on whether you want recursive call to refer to > the function itself or to its version overridden by inheritance, > you would write either > foo > X.foo > > _Normally_ the potential for polymorphism and overriding IS desired, > > In recursive calls to class methods? Not at all. If the overridden > version calls me, it probably expects that I would do what I was > supposed to do in the superclass. No matter if I do this by calling > myself recursively or not. Where do you read/infer the limitation to *class* methods? > Remember that I am talking about class methods, which don't exist > now at all. They can be currently expressed as module functions which > are not subject to inheritance. Instance methods are normally called > through self as always! But how does a given function, whose def is inside a class, know whether it's supposed to recurse through its (potential) overrider (via a same-name method of the first argument) or by defeating the override (via its bare name, or, equivalently if your proposal was adopted, using itself as an attribute in its enclosing class)? Recursion apart, what distinguishes, e.g., a method foo in class Derived(Base), calling the version it overrides as Base.foo(self,x,y), and a "class-method" bar calling the same-name class-method of the base class as Base.bar(x,y,z)? They're indistinguishable cases now -- would they get distinguished in your proposal, and, if so, how? Alex From qrczak at knm.org.pl Thu Feb 22 20:14:49 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 22 Feb 2001 19:14:49 GMT Subject: An alternative approach to bound methods References: <20010220155508.4879.qmail@web6403.mail.yahoo.com> <972opb0ngg@news2.newsguy.com> <973er001d39@news2.newsguy.com> Message-ID: Thu, 22 Feb 2001 17:30:24 +0100, Alex Martelli pisze: > Where do you read/infer the limitation to *class* methods? My proposal doesn't change how instance methods and instance attributes can be used. Only class attributes change. Or I didn't understand what you mean? > But how does a given function, whose def is inside a class, know > whether it's supposed to recurse through its (potential) overrider > (via a same-name method of the first argument) or by defeating the > override (via its bare name, or, equivalently if your proposal was > adopted, using itself as an attribute in its enclosing class)? Are you asking what should one choose when he is writing the class? I don't know any case where it should recurse through its potential overrider yet, but perhaps they exist. This question can't have a general answer, similarly as questions like 'which class should I make an instance of here'. Are you asking about the semantics of a particular piece of code? If so, which code? My proposal is unambiguous. > Recursion apart, what distinguishes, e.g., a method foo in class > Derived(Base), calling the version it overrides as Base.foo(self,x,y), > and a "class-method" bar calling the same-name class-method of > the base class as Base.bar(x,y,z)? Technically nothing. Ideologically foo is an instance method, and bar is a class method, i.e. the first argument of foo is supposed to be an instance of a subclass of Base (even Derived at this usage point). Instance methods are special cases of class methods, where the first argument is an object of the class we are in. They are not distinguished by declaration: a method can play the role of both. We have a shortcut for calling instance methods: instead of obj.__class__.method (obj, arg1, arg2) you can also write obj.method (arg1, arg2) It happens at the time of accessing methods from the instance, i.e. obj.method itself means lambda *args, **kwargs: obj.__class__.method (obj, *args, **kwargs) when type (obj) == types.InstanceType and not obj.__dict__.has_key ('method'). That's it. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From aleaxit at yahoo.com Fri Feb 23 12:33:00 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 23 Feb 2001 12:33:00 +0100 Subject: An alternative approach to bound methods References: <20010220155508.4879.qmail@web6403.mail.yahoo.com> <972opb0ngg@news2.newsguy.com> <973er001d39@news2.newsguy.com> Message-ID: <975hpa05qm@news1.newsguy.com> "Marcin 'Qrczak' Kowalczyk" wrote in message news:slrn99ap97.lm7.qrczak at qrnik.zagroda... > Thu, 22 Feb 2001 17:30:24 +0100, Alex Martelli pisze: > > > Where do you read/infer the limitation to *class* methods? > > My proposal doesn't change how instance methods and instance attributes > can be used. Only class attributes change. > > Or I didn't understand what you mean? Let's say we have...: class Aclass: def amethod(x, *args): # body snipped is this 'amethod' a "class method" or an "instance method"? Does calling it via x=Aclass();x.amethod(y,z) or via x=Aclass();Aclass.amethod(x,y,z) change anything? > > But how does a given function, whose def is inside a class, know > > whether it's supposed to recurse through its (potential) overrider > > (via a same-name method of the first argument) or by defeating the > > override (via its bare name, or, equivalently if your proposal was > > adopted, using itself as an attribute in its enclosing class)? > > Are you asking what should one choose when he is writing the class? > I don't know any case where it should recurse through its potential > overrider yet, but perhaps they exist. This question can't have a > general answer, similarly as questions like 'which class should I > make an instance of here'. > > Are you asking about the semantics of a particular piece of code? > If so, which code? My proposal is unambiguous. And it does unambiguously mean that mentioning 'amethod' within the above amethod's code body will in fact refer to Aclass.amethod, not self.amethod, then? In which case, the key objection is one I already raised, that this is designed to make the easiest/most natural expression the one for the case one wants *most rarely*. People will often and erroneously make recursive calls to "amethod(a,b,c)" when they should be going through self, because "going through self" IS the normal, most frequently desired case. If you mean other things, then I have already expressed most of my other objections. > > Recursion apart, what distinguishes, e.g., a method foo in class > > Derived(Base), calling the version it overrides as Base.foo(self,x,y), > > and a "class-method" bar calling the same-name class-method of > > the base class as Base.bar(x,y,z)? > > Technically nothing. > > Ideologically foo is an instance method, and bar is a class method, > i.e. the first argument of foo is supposed to be an instance of a > subclass of Base (even Derived at this usage point). And this is checked at runtime, and gives a very clear error message if the user makes a mistake about it: TypeError: unbound method must be called with class instance 1st argument I don't want to lose this very helpful error, and error message, pursuing some kind of "ideological" target. Practicality beats purity. If "class methods" must exist (and I, for one, feel quite happy without them), then they'd have to be distinguished "technically" (in a compiler-visible way) from instance methods, to cover the pragmatical need for clear messages when programming errors are made. class Base: def foo(self, *args): print "Base.foo",args class Derived(Base): def foo(self, *args): print "Derived.foo",args Base.foo(*args) I don't want this error to become a silent, mysterious one; we know have clear diagnostics for it, and losing them would be a serious step backwards. Alex From qrczak at knm.org.pl Sat Feb 24 15:03:18 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 24 Feb 2001 14:03:18 GMT Subject: An alternative approach to bound methods References: <20010220155508.4879.qmail@web6403.mail.yahoo.com> <972opb0ngg@news2.newsguy.com> <973er001d39@news2.newsguy.com> <975hpa05qm@news1.newsguy.com> Message-ID: Fri, 23 Feb 2001 12:33:00 +0100, Alex Martelli pisze: > class Aclass: > def amethod(x, *args): > # body snipped > > is this 'amethod' a "class method" or an "instance method"? Both. > Does calling it via > > x=Aclass();x.amethod(y,z) > > or via > > x=Aclass();Aclass.amethod(x,y,z) > > change anything? No. > > Are you asking about the semantics of a particular piece of code? > > If so, which code? My proposal is unambiguous. > > And it does unambiguously mean that mentioning 'amethod' within > the above amethod's code body will in fact refer to Aclass.amethod, > not self.amethod, then? Yes. > People will often and erroneously make recursive calls to > "amethod(a,b,c)" when they should be going through self, because > "going through self" IS the normal, most frequently desired case. Both are equally easy. Why would anybody write amethod(self,b,c) instead of self.amethod(b,c) when he means the latter? > And this is checked at runtime, and gives a very clear > error message if the user makes a mistake about it: > > TypeError: unbound method must be called with class instance 1st argument It's not necessarily a mistake. > class Derived(Base): > def foo(self, *args): > print "Derived.foo",args > Base.foo(*args) > > I don't want this error to become a silent, mysterious one; we know > have clear diagnostics for it, and losing them would be a serious > step backwards. I admit that this error would have a worse diagnostics (usually: too few arguments, i.e. not that bad). The same can be said about writing 'self' in method definitions: when one forgets it, the error is equally mysterious. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From aleaxit at yahoo.com Sat Feb 24 19:05:29 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 24 Feb 2001 19:05:29 +0100 Subject: An alternative approach to bound methods References: <20010220155508.4879.qmail@web6403.mail.yahoo.com> <972opb0ngg@news2.newsguy.com> <973er001d39@news2.newsguy.com> <975hpa05qm@news1.newsguy.com> Message-ID: <978t7802ghb@news1.newsguy.com> "Marcin 'Qrczak' Kowalczyk" wrote in message news:slrn99ffp6.ep3.qrczak at qrnik.zagroda... [snip] > > People will often and erroneously make recursive calls to > > "amethod(a,b,c)" when they should be going through self, because > > "going through self" IS the normal, most frequently desired case. > > Both are equally easy. Why would anybody write > amethod(self,b,c) > instead of > self.amethod(b,c) > when he means the latter? The pragmatical reason for which people erroneously omit 'self' (and try to call amethod(a,b,c), not amethod(self,a,b,c)) from within the code for a method is no doubt that there are many languages in which this "self." (or its equivalent "this->") can be left implicit. But we can't change those other languages (C++, Java, ...), so, people who come from such languages and/or use them primarily, and only use Python more rarely, _will_ no doubt keep making this mistake frequently -- even though in theory there should be no intrinsic reason why they should. The key point is that we need to keep diagnosing this error at runtime clearly and unambiguously, just like Python does now -- this is and will remain an important pragmatical issue, and pragmaticity trumps purity. > > I don't want this error to become a silent, mysterious one; we know > > have clear diagnostics for it, and losing them would be a serious > > step backwards. > > I admit that this error would have a worse diagnostics (usually: > too few arguments, i.e. not that bad). Much worse if the method has at least one optional argument, which is a VERY frequent case; then, we've pushed the error into the dark realm of mysteriously erroneous runtime behavior > The same can be said about > writing 'self' in method definitions: when one forgets it, the error > is equally mysterious. My impression, which comes from working directly with a modest number of Python newbies and helping many more through the net, is that the error of omitting self in the _definition_ is much rarer than that of omitting it in the _calls_ to methods within other methods. And when you make that mistake in one method out of N, getting diagnostics on _every_ call to that method (and for every attempted use of self within that method -- if one makes TWO mistakes, omitting self in definition AND in use, then of course it's not easy to diagnose both correctly & clearly -- but the single-error case is more important) tends to pinpoint the error pretty clearly. Alex From jpet at eskimo.com Sun Feb 25 21:34:56 2001 From: jpet at eskimo.com (Jeff Petkau) Date: Sun, 25 Feb 2001 20:34:56 GMT Subject: An alternative approach to bound methods References: <20010220155508.4879.qmail@web6403.mail.yahoo.com> <972opb0ngg@news2.newsguy.com> <973er001d39@news2.newsguy.com> <975hpa05qm@news1.newsguy.com> <978t7802ghb@news1.newsguy.com> Message-ID: Alex Martelli wrote in message news:978t7802ghb at news1.newsguy.com... > "Marcin 'Qrczak' Kowalczyk" wrote in message > news:slrn99ffp6.ep3.qrczak at qrnik.zagroda... > [snip] > > > People will often and erroneously make recursive calls to > > > "amethod(a,b,c)" when they should be going through self, because > > > "going through self" IS the normal, most frequently desired case. > > > > Both are equally easy. Why would anybody write > > amethod(self,b,c) > > instead of > > self.amethod(b,c) > > when he means the latter? > > [...] > The key point is that we need to keep diagnosing this error > at runtime clearly and unambiguously, just like Python does > now -- this is and will remain an important pragmatical issue, > and pragmaticity trumps purity. > > > > I don't want this error to become a silent, mysterious one; we know > > > have clear diagnostics for it, and losing them would be a serious > > > step backwards. Unbound methods don't get involved in this error message anyway-- the name lookup fails. >>> class C: def spam(self): spam(self) >>> c = C() >>> c.spam() Traceback (innermost last): File "", line 1, in ? c.spam() File "", line 3, in spam spam(self) NameError: There is no variable named 'spam' >>> I can't really see any use whatsoever for unbound method objects. The only effect they have is to make class methods not work, by adding a typecheck that makes unwarranted assumptions about what the first parameter should be. The semantics could also be a little simpler if they went away. If you put something in a class, you get the same object out. If you put something in an instance, you get the same object out. If you put something in a class and retrieve it through the instance, *then* it would add the magic 'self' parameter. --Jeff Petkau (jpet at eskimo.com) From tim at 2wave.net Wed Feb 21 18:17:03 2001 From: tim at 2wave.net (Tim Couper) Date: Wed, 21 Feb 2001 17:17:03 -0000 Subject: An alternative approach to bound methods In-Reply-To: Message-ID: Jeremy Hylton wrote > .... I'm not sure I really followed this argument. Perhaps some code > examples would help.... > What attracted me to Marcin Kowalczy's original posting was that it appeared to give a way of defining class functions, by merely extending the search algorithm ("..obj.x, when obj is an instance object, first searches for 'x' in its __dict__. If not found, it should try obj.__class__.x ...") Here's an example of the code I'd like to be able to run, extending a class attributes example I was using: class myclass: alist=['initial'] def __init__(self,thelist=['the list']): self.__class__.alist=thelist def show(self): print self.__class__.alist """ # I want to be able to declare a class function: (see unit test element below) # so, as it's a class function, it doesn't need the self argument, # but is accessible through __class__. So I think it should take the form # def static(args): #do something (only with class attributes) return SomeValue # or perhaps something like (but I think this is indistinguishable from # instance methods) def static(self,args): if not self: #do something (only with class attributes) else: # this is an instance call of this function return SomeValue """ if __name__=='__main__': print print 'Usual test' print '----------' print print 'string class attribute: ',myclass.astring a=myclass() print a.show() print b=myclass(['orig list']) a.show() b.show() print print 'Re-Assignment' print '-------------' a.__class__.alist=['new','list'] a.show() b.show() print print 'Method' print '------' print # assuming that the static function returns something, # I'd like to write, in a completely analogous manner to the # class attribute: # # print myclass.static(args) # print a.__class__.static(args) # print b.__class__.static(args) From drtimcouper at yahoo.co.uk Fri Feb 23 12:02:45 2001 From: drtimcouper at yahoo.co.uk (=?iso-8859-1?q?Tim=20Couper?=) Date: Fri, 23 Feb 2001 11:02:45 +0000 (GMT) Subject: An alternative approach to bound methods In-Reply-To: Message-ID: <20010223110245.26841.qmail@web6401.mail.yahoo.com> Marcin As I said before (IMHO) you are addressing something important here, which seems to be self-evident to your good self, but needs to be clearly understood by others. Being a simple soul, I wonder if it might be possible to restate the proposal again, maybe in a top-down manner. Here's where I'm at, as they say. Would I be right in saying that an objective (or is it a consequence?) of the proposal is to permit Pythonesque class methods as well as class attributes in Python? If so, does the "this-is-what-I-would-like" example which I gave in a previous email demonstrate the requirement correctly? This could then lead into a presentation again of the changes that would be needed to make Python operate in this way, and then the implications of such changes. Again I think you see all these clearly (and they are maybe obvious to you and others!) It would appear that the changes covered by the proposal are more far-reacing than the introduction of class methods; it would be good to understand this scope, the further benefits and downsides. Having the class methods illustration to hand would I think be a good stepping stone to what seems to be a more general case. If this is an inappropriate suggestion, please say so, I realise it could be just me that is a bit slow :-) Tim > > > Where do you read/infer the limitation to *class* > methods? > > My proposal doesn't change how instance methods and > instance attributes > can be used. Only class attributes change. > > Or I didn't understand what you mean? > > > But how does a given function, whose def is inside > a class, know > > whether it's supposed to recurse through its > (potential) overrider > > (via a same-name method of the first argument) or > by defeating the > > override (via its bare name, or, equivalently if > your proposal was > > adopted, using itself as an attribute in its > enclosing class)? > > Are you asking what should one choose when he is > writing the class? > I don't know any case where it should recurse > through its potential > overrider yet, but perhaps they exist. This question > can't have a > general answer, similarly as questions like 'which > class should I > make an instance of here'. > > Are you asking about the semantics of a particular > piece of code? > If so, which code? My proposal is unambiguous. > > > Recursion apart, what distinguishes, e.g., a > method foo in class > > Derived(Base), calling the version it overrides as > Base.foo(self,x,y), > > and a "class-method" bar calling the same-name > class-method of > > the base class as Base.bar(x,y,z)? > > Technically nothing. > > Ideologically foo is an instance method, and bar is > a class method, > i.e. the first argument of foo is supposed to be an > instance of a > subclass of Base (even Derived at this usage point). > > Instance methods are special cases of class methods, > where the > first argument is an object of the class we are in. > They are not > distinguished by declaration: a method can play the > role of both. > > We have a shortcut for calling instance methods: > instead of > obj.__class__.method (obj, arg1, arg2) > you can also write > obj.method (arg1, arg2) > > It happens at the time of accessing methods from the > instance, i.e. > obj.method > itself means > lambda *args, **kwargs: obj.__class__.method > (obj, *args, **kwargs) > when type (obj) == types.InstanceType > and not obj.__dict__.has_key ('method'). > > That's it. > > -- > __("< Marcin Kowalczyk * qrczak at knm.org.pl > http://qrczak.ids.net.pl/ > \__/ > ^^ SYGNATURA ZAST?PCZA > QRCZAK > > > > -- > http://mail.python.org/mailman/listinfo/python-list > ____________________________________________________________ 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 qrczak at knm.org.pl Sat Feb 24 15:17:53 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 24 Feb 2001 14:17:53 GMT Subject: An alternative approach to bound methods References: Message-ID: Fri, 23 Feb 2001 11:02:45 +0000 (GMT), Tim Couper pisze: > Being a simple soul, I wonder if it might be possible to restate > the proposal again, maybe in a top-down manner. I will write it precisely at some time. > Would I be right in saying that an objective (or is it > a consequence?) of the proposal is to permit Pythonesque > class methods as well as class attributes in Python? I would say that having class methods is a consequence. Class attributes are already present - currently they can have any type except the function type, i.e. except what would make them act as class methods. > If so, does the "this-is-what-I-would-like" example which I gave > in a previous email demonstrate the requirement correctly? I'm not sure if I understands its intent, but yes, it will work (with static(args), not static(self,args)). -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From joconnor at cybermesa.com Mon Feb 19 19:38:26 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Mon, 19 Feb 2001 18:38:26 +0000 Subject: Monetary package? Message-ID: <3A916822.8E2B7573@cybermesa.com> All, Are there any packages available that handle monetary units? Take care, -- Jay O'Connor joconnor at cybermesa.com http://www.cybermesa.com/~joconnor Python Language Discussion Forum - http://pub1.ezboard.com/fobjectorienteddevelopmentpython From cg at gaia.intranet.cdegroot.com Tue Feb 20 00:17:34 2001 From: cg at gaia.intranet.cdegroot.com (Cees de Groot) Date: 20 Feb 2001 00:17:34 +0100 Subject: Monetary package? References: <3A916822.8E2B7573@cybermesa.com> Message-ID: <96s9ie$knl$1@gaia.intranet.cdegroot.com> Jay O'Connor said: > Are there any packages available that handle monetary units? > No, but there's a decent fixed point calculation package around (check Parnassus - I think it's called FixedPoint.py), and the rest is relatively simple. -- Cees de Groot http://www.cdegroot.com GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B From zamurai at gmx.net Mon Feb 19 20:23:27 2001 From: zamurai at gmx.net (Zamurai) Date: Mon, 19 Feb 2001 20:23:27 +0100 Subject: what is tkinter´s equivalent to wxpytohn´s wxNotebook? Message-ID: <982610607.838946826@news.t-online.de> From s2mdalle at titan.vcu.edu Tue Feb 20 04:14:05 2001 From: s2mdalle at titan.vcu.edu (David Allen) Date: Tue, 20 Feb 2001 03:14:05 GMT Subject: what is tkinter´s equivalent to wxpytohn´s wxNotebook? References: <982610607.838946826@news.t-online.de> Message-ID: <1ilk6.6048$pS4.2368620@typhoon2.ba-dsg.net> Tkinter doesn't have one AFAIK, but Pmw does: http://www.dscpl.com.au/pmw/doc/NoteBook.html -- David Allen http://opop.nols.com/ ---------------------------------------- Diplomacy is the art of saying "nice doggy" until you can find a gun. From pinard at iro.umontreal.ca Mon Feb 19 20:32:43 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=e7ois?= Pinard) Date: 19 Feb 2001 14:32:43 -0500 Subject: quopri.encode bug in Python 1.5.2, maybe in 2.0 (?) Message-ID: Hi, people. I do not have Python 2 handy here, and would like that some kind soul forwards this report appropriately if the bug still exist in latest versions. The problem is that `quopri.encode' does not properly handle files which do not have a line terminator on the last line. It produces the same result as if the newline was there. The proper action in this case is to append a `=' at end of the last produced line of the `out' file, before the concluding newline, when there was no end of line to terminate the original, non QP-ed file. Hmph! I guess my explanations are not very clear. Better a simple example, then! :-) $ echo a | recode ../qp a $ echo -n a | recode ../qp a= These matters were clarified to me by Nathaniel Borenstein, the author of the MIME standard. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From wilson.austin.aj at bhp.com.au Mon Feb 19 20:36:03 2001 From: wilson.austin.aj at bhp.com.au (Austin Wilson) Date: Tue, 20 Feb 2001 06:36:03 +1100 Subject: Problem with py2exe Message-ID: <96rsie$dsc$1@gossamer.itmel.bhp.com.au> Hi I am trying to freeze a program using py2exe 0.2.2. However, I am getting the following output. Can anyone help. BTW: I am using Python20 and PIL 1.1.1 on Win98. Thanks Austin Resolving binary dependencies: Traceback (most recent call last): File "buildwatcher.py", line 6, in ? scripts=["watcher.py"], File "c:\program files\python20\lib\distutils\core.py", line 138, in setup dist.run_commands() File "c:\program files\python20\lib\distutils\dist.py", line 829, in run_commands self.run_command(cmd) File "c:\program files\python20\lib\distutils\dist.py", line 849, in run_command cmd_obj.run() File "py2exe\py2exe.py", line 354, in run dlls, unfriendly_dlls = self.find_dependend_dlls(use_runw, dlls) File "py2exe\py2exe.py", line 464, in find_dependend_dlls alldlls, warnings = bin_depends(loadpath, images) File "py2exe\py2exe.py", line 674, in bin_depends for result in py2exe_util.depends(image, loadpath).items(): py2exe_util.bind_error: tcl83.dll From thomas.heller at ion-tof.com Mon Feb 19 21:17:29 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Mon, 19 Feb 2001 21:17:29 +0100 Subject: Problem with py2exe References: <96rsie$dsc$1@gossamer.itmel.bhp.com.au> Message-ID: <96rv0s$m7sd5$1@ID-59885.news.dfncis.de> "Austin Wilson" wrote in message news:96rsie$dsc$1 at gossamer.itmel.bhp.com.au... > Hi > > I am trying to freeze a program using py2exe 0.2.2. However, > I am getting the following output. Can anyone help. > > BTW: I am using Python20 and PIL 1.1.1 on Win98. > > Thanks > Austin > > Resolving binary dependencies: > Traceback (most recent call last): > File "buildwatcher.py", line 6, in ? > scripts=["watcher.py"], > File "c:\program files\python20\lib\distutils\core.py", line 138, in setup > dist.run_commands() > File "c:\program files\python20\lib\distutils\dist.py", line 829, in > run_commands > self.run_command(cmd) > File "c:\program files\python20\lib\distutils\dist.py", line 849, in > run_command > cmd_obj.run() > File "py2exe\py2exe.py", line 354, in run > dlls, unfriendly_dlls = self.find_dependend_dlls(use_runw, dlls) > File "py2exe\py2exe.py", line 464, in find_dependend_dlls > alldlls, warnings = bin_depends(loadpath, images) > File "py2exe\py2exe.py", line 674, in bin_depends > for result in py2exe_util.depends(image, loadpath).items(): > py2exe_util.bind_error: tcl83.dll > It seems you are trying to freeze a Tkinter program, which is not really supported up to now. Does your python script run from the command line correctly? Even if your build would succeed, the resulting executable would probably fail to run like this, because the executable would not find the tcl/tk installation: C:\sf\py2exe\tests\dist\_test_hanoi>_test_hanoi Traceback (most recent call last): File "", line 154, in ? File "", line 146, in main File "", line 31, in __init__ File "Tkinter.pyc", line 1482, in __init__ TclError: Can't find a usable init.tcl in the following directories: {} C:/sf/py2exe/tests/dist/lib/tcl8.3 C:/sf/py2exe/tests/dist/lib/tcl8.3 C:/sf/py2exe/tests/lib/ tcl8.3 C:/sf/py2exe/tests/lib/tcl8.3/library C:/sf/py2exe/tests/library C:/sf/py2exe/tests/../tcl8.3 /library C:/sf/py2exe/../tcl8.3/library This probably means that Tcl wasn't installed properly. Sorry, Thomas From corour01 at motorola.com Mon Feb 19 20:44:27 2001 From: corour01 at motorola.com (O'Rourke Clodagh-corour01) Date: Mon, 19 Feb 2001 19:44:27 -0000 Subject: Global Variables Message-ID: <13EE655665F4D311AB4D0008C789498A01EE2C43@zei02exm02.cork.cig.mot.com> Hi Everybody, I am a beginner-ish at Python and I am working on a large project using it right now. I am having a lot of problems with my variable scope. Where exactly should global variables be declared? I have written a class that reads the contects of an INFORMIX database into variables and arrays for manipulation. Several methods access the same arrays/variables. I read the values in no problem but when I try to access them from another function aside from the one they were initiated in they all contain PY_VARO ? I s'ppose they cannot be seen by the function in which I am trying to use them so where should they be declared? If anyone could offer my some much needed help I would be very grateful, Thank You, Clodagh O' Rourke From aahz at panix.com Mon Feb 19 20:57:51 2001 From: aahz at panix.com (Aahz Maruch) Date: 19 Feb 2001 11:57:51 -0800 Subject: Global Variables References: Message-ID: <96rtrv$ok1$1@panix3.panix.com> In article , O'Rourke Clodagh-corour01 wrote: > >I am having a lot of problems with my variable scope. >Where exactly should global variables be declared? Don't. Seriously. >I have written a class that reads the contects of an INFORMIX database >into variables and arrays for manipulation. Several methods access >the same arrays/variables. I read the values in no problem but when I >try to access them from another function aside from the one they were >initiated in they all contain PY_VARO ? I s'ppose they cannot be seen >by the function in which I am trying to use them so where should they >be declared? If you have a class, you should be setting the instance variables using the "self." notation. That will allow the variables to be accessed by other methods of the class. If you're using functions, make sure to return the value ("value" being a number, string, tuple, list, dictionary, or class instance) that you want to use, then pass that value to any other functions that need to access it. Use one of the mutable values (list, dictionary, class) if the later functions need to modify the value. BTW, much of this would be clearer if you worked your way through the entire tutorial: http://www.python.org/doc/current/tut/tut.html -- --- 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 Why doesn't "Just Say NO" include caffeine, nicotine, alcohol, Prozac, and Ritalin? --Aahz From sav at ulmen.mv.ru Mon Feb 19 20:54:43 2001 From: sav at ulmen.mv.ru (Alexander Semenov) Date: Mon, 19 Feb 2001 22:54:43 +0300 Subject: Multithread ZODB. Message-ID: <96rtm6$2i2l$1@news1.simtel.ru> Hi! Can someone give me a python code snippet, or skeleton of multithread program which uses ZODB? Multithread examples are missing from ZODB guide. It says what I must create connection for each thread, but I don't know for what? Should I make root objects separately for each thread? I prefer to have common object for all threads. Should each thread commit transactions on common objects? Shoud I use synchronization objects for safe access to ZODB objects? I can't use ZEO, my program for Windows. Luke, where is your sources? WBR, Alexander Semenov. PS: Sorry for my English, my native is Russian. From amk at mira.erols.com Tue Feb 20 02:13:52 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 20 Feb 2001 01:13:52 GMT Subject: Multithread ZODB. References: <96rtm6$2i2l$1@news1.simtel.ru> Message-ID: On Mon, 19 Feb 2001 22:54:43 +0300, Alexander Semenov wrote: >Can someone give me a python code snippet, or skeleton of multithread >program which uses ZODB? Multithread examples are missing from ZODB >guide. It says what I must create connection for each thread, but I don't Look through the code in ZODB/*.py; much of it is commented to a middling degree. If you come up with small test programs, please send me copies for incorporation; multithreaded ZODB programming isn't covered because I haven't looked at it and, given that I'm cool on the idea of threads, it's not a big priority just yet. --amk From cobrien at Radix.Net Wed Feb 21 00:09:15 2001 From: cobrien at Radix.Net (Cary O'Brien) Date: 20 Feb 2001 18:09:15 -0500 Subject: Multithread ZODB. References: <96rtm6$2i2l$1@news1.simtel.ru> Message-ID: <96uter$b4t$1@saltmine.radix.net> In article , A.M. Kuchling wrote: >On Mon, 19 Feb 2001 22:54:43 +0300, > Alexander Semenov wrote: >>Can someone give me a python code snippet, or skeleton of multithread >>program which uses ZODB? Multithread examples are missing from ZODB >>guide. It says what I must create connection for each thread, but I don't > >Look through the code in ZODB/*.py; much of it is commented to a >middling degree. If you come up with small test programs, please send >me copies for incorporation; multithreaded ZODB programming isn't >covered because I haven't looked at it and, given that I'm cool on the >idea of threads, it's not a big priority just yet. > Isn't ZODB thread safe? I mean Zope runs as multiple threads, doesn't it? -- cary (who spent the day working on a Corba + ZODB test program). From amk at mira.erols.com Wed Feb 21 03:21:14 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 21 Feb 2001 02:21:14 GMT Subject: Multithread ZODB. References: <96rtm6$2i2l$1@news1.simtel.ru> <96uter$b4t$1@saltmine.radix.net> Message-ID: On 20 Feb 2001 18:09:15 -0500, Cary O'Brien wrote: >Isn't ZODB thread safe? I mean Zope runs as multiple threads, doesn't >it? Yes it does, but I have no clear idea what the ground rules are for doing that, and so can't really document them. --amk From db3l at fitlinxx.com Fri Feb 23 03:06:28 2001 From: db3l at fitlinxx.com (David Bolen) Date: 22 Feb 2001 21:06:28 -0500 Subject: Multithread ZODB. References: <96rtm6$2i2l$1@news1.simtel.ru> <96uter$b4t$1@saltmine.radix.net> Message-ID: amk at mira.erols.com (A.M. Kuchling) writes: > On 20 Feb 2001 18:09:15 -0500, Cary O'Brien wrote: > >Isn't ZODB thread safe? I mean Zope runs as multiple threads, doesn't > >it? > > Yes it does, but I have no clear idea what the ground rules are for > doing that, and so can't really document them. It's actually more than thread-safe, it's designed to have the object store run via multiple threads, and each thread sees its own copy of the objects independently. That way, if you have two users working on the web site simultaneous, within a transaction, each sees an internally consistent view of the object store, without being impacted by any changes from the other user with that other transaction. If the first user commits changes, the second user will then see those changes in his/her reference to the objects from the local connection - and receive a conflict error if trying to commit changes to the same objects now changed. If I read it correctly, the original question in this thread is actually asking about a simpler scenario - where the application is multi-threaded, but access to the object store need not be, and in fact is preferred not to be. That's what our application also wanted - the object store represented a single state that was managed by a multi-threaded application, but the application had it's own locking and management of access to the data - it didn't represent independent users. >From my understanding, it's like ZODB solved the much harder problem, but in doing so it made some assumptions (like per-thread connections) that actually makes the application approach (not multi-user) more difficult :-) -- -- 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 db3l at fitlinxx.com Fri Feb 23 03:02:01 2001 From: db3l at fitlinxx.com (David Bolen) Date: 22 Feb 2001 21:02:01 -0500 Subject: Multithread ZODB. References: <96rtm6$2i2l$1@news1.simtel.ru> Message-ID: "Alexander Semenov" writes: > Can someone give me a python code snippet, or skeleton of multithread > program which uses ZODB? Multithread examples are missing from ZODB > guide. It says what I must create connection for each thread, but I don't > know > for what? Should I make root objects separately for each thread? I prefer to > have common object for all threads. We had a similar goal and had actually written a multi-threaded application using ZODB before it really sinking in that not only does it support separate connections for each thread, but its current implementation makes it hard to avoid (the default get_transaction() is implicitly thread-specific). We also just wanted a single set of persistent objects, as we were maintaining our own controlled access to them amongst the threads - e.g., a typical shared state object setup that we just wanted to overlay on a persistent object store. In the end, it turned out that as long as we were committing changes right as they were being made, and in the thread that made them, everything worked with a single set of objects. We did have I think two instances where it appeared that we were losing data that were tracked back to not committing in the thread making the change - one of the code paths had skipped the get_transaction().commit() call. It was actually the first of these cases that highlighted the multi-connection dependency noted above. At the time, I did get some e-mail feedback from Jim Fulton in this regard (which I hope he doesn't mind my reproducing here - it's just some general stuff) - in particular (">" is my note to which he was responding): "> ZODB3 is documented as supporting multiple connections to a storage > which supports independent object caches for multiple threads. > However, although I've looked around at a bunch of documents, I can't > seem to find if this is required or simply available. It isn't required, but it is by far the common usage pattern. Hm, I guess that the current implementation actually makes it hard to institute a different policy. > That is, if I'm > using ZODB in a multi-threaded Python application, must I create > separate connections for each thread, or can they share a single > connection. Multiple threads *can* share a single connection, but if you do this, you'll need to: - Perform whatever locking is required to serialize access to the shared objects, - You'll need to override get_transaction with a version that doesn't manage transactions by thread. " We've been running our application for several months now without actually have taken the step of replacing get_transaction() yet, as long as we stick to the commit right away in the thread that made the change before another thread goes to change the object again :-) In terms of why it needs to be replaced (presumably to remove that commit behavior restriction), Jim said: "The logic for the Persistent mix-in class calls get_transaction to get the current transaction when it needs to register that an object has changed. The standard get_transaction manages transaction objects per thread. In addition, the function is cached the first time it is called, to avoid global lookups each time. You can replace get_transacton by installing a different version in builtins, but you will need to do so immediately after importing ZODB, to make sure your version gets cached." We've been intending to test reworking it with separate connections, but haven't had a chance yet. The biggest wrinkle I imagined in that is that we share object references among threads, and I wasn't sure how the references from the different connections would work. In our application, we serialize our access to the set of persistent objects amongst all threads (effectively using a global lock on the root object that is obtained whenever a thread is going to be playing with state data), and any work a thread does on those objects is committed before the lock is released. So there's no chance of collision with two threads trying to update/commit the same persistent object at a time. We also used ZODB strictly for persistence (no versioning or transactions). But within that structure, it's worked extremely well and has proven very reliable and robust. -- -- 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 man_at_moon at hotmail.com Mon Feb 19 21:08:42 2001 From: man_at_moon at hotmail.com (David A.) Date: Mon, 19 Feb 2001 20:08:42 -0000 Subject: A simple (newbie) question. Message-ID: <9VRk6.116$DT7.616555@newsserver.ip.pt> Hello to everyone, maybe I have already sent this question to the group, but I am not sure (the first one never reached the group I think). Anyway, I am a newbie, so probably my question is a realy simple for the most experienced python users. Well what I want to is this: >>> a='python' >>> b='print' >>> c=b+a >>> eval(c) Traceback (innermost last): File "", line 1, in ? eval(c) File "", line 1 print"python" ^ SyntaxError: invalid syntax >>> Of course, what I wanted was that the eval(c) prints "python"! what am I doing wrong? Any help is apreciated. Thx in advance David Asfaha. -- "Quidquid latine dictum sit, altum viditur." Whatever is said in Latin sounds profound. From wolfgang.grafen at marconi.com Wed Feb 21 17:35:38 2001 From: wolfgang.grafen at marconi.com (Wolfgang Grafen) Date: Wed, 21 Feb 2001 17:35:38 +0100 Subject: A simple (newbie) question. References: <9VRk6.116$DT7.616555@newsserver.ip.pt> Message-ID: <3A93EE5A.A9F62C46@marconi.com> Hi David, following should work: >>> a='"python"' >>> b='print' >>> c=b+' '+a >>> exec(c) python regards Wolfgang "David A." wrote: > > Hello to everyone, > > maybe I have already sent this question to the group, but I am not sure > (the first one never reached the group I think). Anyway, I am a newbie, so > probably my question is a realy simple for the most experienced python > users. > > Well what I want to is this: > >>> a='python' > >>> b='print' > >>> c=b+a > >>> eval(c) > Traceback (innermost last): > File "", line 1, in ? > eval(c) > File "", line 1 > print"python" > ^ > SyntaxError: invalid syntax > >>> > > Of course, what I wanted was that the eval(c) prints "python"! > what am I doing wrong? Any help is apreciated. > > Thx in advance David Asfaha. > -- > "Quidquid latine dictum sit, altum viditur." > Whatever is said in Latin sounds profound. From dsh8290 at rit.edu Wed Feb 21 18:10:06 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 21 Feb 2001 12:10:06 -0500 Subject: A simple (newbie) question. In-Reply-To: <9VRk6.116$DT7.616555@newsserver.ip.pt>; from man_at_moon@hotmail.com on Mon, Feb 19, 2001 at 08:08:42PM +0000 References: <9VRk6.116$DT7.616555@newsserver.ip.pt> Message-ID: <20010221121006.A23949@harmony.cs.rit.edu> On Mon, Feb 19, 2001 at 08:08:42PM +0000, David A. wrote: | Hello to everyone, | | maybe I have already sent this question to the group, but I am not sure | (the first one never reached the group I think). Anyway, I am a newbie, so | probably my question is a realy simple for the most experienced python | users. | | Well what I want to is this: | >>> a='python' | >>> b='print' | >>> c=b+a | >>> eval(c) | Traceback (innermost last): | File "", line 1, in ? | eval(c) | File "", line 1 | print"python" | ^ | SyntaxError: invalid syntax Try this to find the problem : >>> print c printpython Once you check the data you are sending to eval you know that printpython is indeed invalid syntax. Instead, try this: a = '"python"' b = 'print' c = b + ' ' + a eval( c ) HTH, -D From embed at geocities.com Mon Feb 19 22:19:37 2001 From: embed at geocities.com (Warren Postma) Date: Mon, 19 Feb 2001 16:19:37 -0500 Subject: How to make a custom type "true" or not, in Python 1.5.2 Message-ID: I am writing a little event object, here is the PyTypeObject declaration: static PyTypeObject win32eventtype = { PyObject_HEAD_INIT(&PyType_Type) 0, /*ob_size*/ "win32event", /*tp_name*/ sizeof(win32eventobject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor)win32event_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc)win32event_getattr, /*tp_getattr*/ (setattrfunc)win32event_setattr, /*tp_setattr*/ 0, /*tp_compare*/ (reprfunc)win32event_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ }; Now, how do I make it true or false, it appears that all C Type object instances are True, because They Are A Thing, not Nothing, but what if you want to make something that can be a Logically False Entity? Do I have to implement the sequence protocol, and implement len(x)? It doesn't seem that it calls my getattr function to check anything. It's just plain true. This is using Python 1.5.2, on Win32. Warren Postma From mwh21 at cam.ac.uk Mon Feb 19 22:29:42 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 19 Feb 2001 21:29:42 +0000 Subject: How to make a custom type "true" or not, in Python 1.5.2 References: Message-ID: "Warren Postma" writes: > I am writing a little event object, here is the PyTypeObject declaration: [bobbit] > Now, how do I make it true or false, it appears that all C Type object > instances are True, because They Are A Thing, not Nothing, but what if you > want to make something that can be a Logically False Entity? Do I have to > implement the sequence protocol, and implement len(x)? It doesn't seem that > it calls my getattr function to check anything. It's just plain true. You want nb_nonzero in the number methods struct, from memory... and the nb_nonzero field from the tp_as_number field from checking the source (! where does my brain keep all these bits of information?). Cheers, M. -- On the other hand, the following areas are subject to boycott in reaction to the rampant impurity of design or execution, as determined after a period of study, in no particular order: ... http://www.naggum.no/profile.html From embed at geocities.com Mon Feb 19 22:36:28 2001 From: embed at geocities.com (Warren Postma) Date: Mon, 19 Feb 2001 16:36:28 -0500 Subject: How to make a custom type "true" or not, in Python 1.5.2 References: Message-ID: "Michael Hudson" wrote in message news:m3r90utl89.fsf at atrus.jesus.cam.ac.uk... > "Warren Postma" writes: > > You want nb_nonzero in the number methods struct, from memory... and > the nb_nonzero field from the tp_as_number field from checking the > source (! where does my brain keep all these bits of information?). > Alas it appears you can't just fill this in. I looked at MxDateTime as a sample extension, and it says the first 10 items in the tp_as_number table must be non-null or python will crash, thus you have to write a little stub function. Kind of yucky. My objects have no possible numeric protocol. So I tried my earlier hunch about if len(x) is 0, even if the rest of the sequence protocol is undefined, it seems to work. The weird thing here is that len(x) doesn't mean anything, other than I suppose, the object is an empty set if len(x) is zero. That seemed to work. Has anyone got any opinion on the Relative Goodness or Badness of using Len(x) => 0 to impute Non-Thingy-ness upon some thing, when implementing the whole tp_as_number protocol is not the Right Thing to Do? ;-) Warren From mwh21 at cam.ac.uk Mon Feb 19 22:55:39 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 19 Feb 2001 21:55:39 +0000 Subject: How to make a custom type "true" or not, in Python 1.5.2 References: Message-ID: "Warren Postma" writes: > "Michael Hudson" wrote in message > news:m3r90utl89.fsf at atrus.jesus.cam.ac.uk... > > "Warren Postma" writes: > > > > You want nb_nonzero in the number methods struct, from memory... and > > the nb_nonzero field from the tp_as_number field from checking the > > source (! where does my brain keep all these bits of information?). > > > > Alas it appears you can't just fill this in. I looked at MxDateTime as a > sample extension, and it says the first 10 items in the tp_as_number table > must be non-null or python will crash, thus you have to write a little stub > function. Kind of yucky. My objects have no possible numeric protocol. Looking at Misc/HISTORY in the Python source implies that this hasn't been the case since 1.5.2a1. Do you need to support that far back? > So I tried my earlier hunch about if len(x) is 0, even if the rest of the > sequence protocol is undefined, it seems to work. The weird thing here is > that len(x) doesn't mean anything, other than I suppose, the object is an > empty set if len(x) is zero. I wouldn't be sure that this would work in the case that the PyNumberMethods approach wouldn't. I could extract 1.5.1 from cvs, I suppose, but I'm not going to. Actually, I just did, and I think + 1 would probably crash (I think Python would try to call sq_concat without checking it). > That seemed to work. Has anyone got any opinion on the Relative > Goodness or Badness of using Len(x) => 0 to impute Non-Thingy-ness > upon some thing, when implementing the whole tp_as_number protocol > is not the Right Thing to Do? Well, it too is a bit yucky. If you can get away with demanding 1.5.2, go for the number methods. Cheers, M. -- 42. You can measure a programmer's perspective by noting his attitude on the continuing vitality of FORTRAN. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From bkc at Murkworks.com Mon Feb 19 22:41:08 2001 From: bkc at Murkworks.com (Brad Clements) Date: Mon, 19 Feb 2001 16:41:08 -0500 Subject: Looking for RDS/ADO server-side XML components on Python Message-ID: I'd like to use Microsoft's RDS/ADO 2.5 components in an IE 5.5 client, but connect to Zope or some other Python based "server". I think MS has documented just enough of the XML schema for creating an editable recordset in XML.. Was wondering if anyone has worked on this or thought about it. I don't want to do IIS. -- Brad Clements, bkc at murkworks.com From ngreco at softhome.net Mon Feb 19 22:46:46 2001 From: ngreco at softhome.net (Nahuel Greco) Date: Mon, 19 Feb 2001 18:46:46 -0300 Subject: Python STL ? Message-ID: <20010219184646.356a5e2f.ngreco@softhome.net> There is something like the C++ STL for python (i dont mean CXX), or any project aimed to this? ---------------------------------------------------------- Nahuel Greco Web Development - Open Source http://www.codelarvs.com.ar Game Programming - Research Freelance coding / sysadmin Networking. The answer is 42. ---------------------------------------------------------- From aahz at panix.com Mon Feb 19 23:03:28 2001 From: aahz at panix.com (Aahz Maruch) Date: 19 Feb 2001 14:03:28 -0800 Subject: Python STL ? References: Message-ID: <96s57g$246$1@panix2.panix.com> In article , Nahuel Greco wrote: > >There is something like the C++ STL for python (i dont mean CXX), or >any project aimed to this? Not being familiar with STL, I might still be able to answer your question if you were a little more specific about what STL features you wanted. -- --- 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 Why doesn't "Just Say NO" include caffeine, nicotine, alcohol, Prozac, and Ritalin? --Aahz From andrew at andrewcooke.free-online.co.uk Mon Feb 19 23:27:07 2001 From: andrew at andrewcooke.free-online.co.uk (Andrew Cooke) Date: Mon, 19 Feb 2001 22:27:07 +0000 Subject: Python STL ? References: Message-ID: <3A919DBB.77FF09CB@andrewcooke.free-online.co.uk> There's no need for templates in a dynamically typed language and Python already has arrays, strings, hash functions and generic "sequence" operations. There's discussion on iterators elsewhere in this group. So what do you want? Andrew Nahuel Greco wrote: > > There is something like the C++ STL for python (i dont mean CXX), or any project > aimed to this? > > ---------------------------------------------------------- > Nahuel Greco Web Development - Open Source > http://www.codelarvs.com.ar Game Programming - Research > Freelance coding / sysadmin Networking. The answer is 42. > ---------------------------------------------------------- From jwbnews at scandaroon.com Tue Feb 20 06:14:41 2001 From: jwbnews at scandaroon.com (John W. Baxter) Date: Mon, 19 Feb 2001 21:14:41 -0800 Subject: Python STL ? References: <3A919DBB.77FF09CB@andrewcooke.free-online.co.uk> Message-ID: All the joy of STL with none of the unending pain. ;-) --john In article <3A919DBB.77FF09CB at andrewcooke.free-online.co.uk>, Andrew Cooke wrote: > There's no need for templates in a dynamically typed language and Python > already has arrays, strings, hash functions and generic "sequence" > operations. There's discussion on iterators elsewhere in this group. > So what do you want? > > Andrew > > Nahuel Greco wrote: > > > > There is something like the C++ STL for python (i dont mean CXX), or > > any project > > aimed to this? > > > > ---------------------------------------------------------- > > Nahuel Greco Web Development - Open Source > > http://www.codelarvs.com.ar Game Programming - Research > > Freelance coding / sysadmin Networking. The answer is 42. > > ---------------------------------------------------------- -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From jajvirta at cc.helsinki.fi Tue Feb 20 08:34:39 2001 From: jajvirta at cc.helsinki.fi (Jarno J Virtanen) Date: 20 Feb 2001 07:34:39 GMT Subject: Python STL ? References: <3A919DBB.77FF09CB@andrewcooke.free-online.co.uk> Message-ID: Mon, 19 Feb 2001 21:14:41 -0800 John W. Baxter wrote: >All the joy of STL with none of the unending pain. ;-) --john That's Python! :-) sincerely yours, jarno From marvind at Glue.umd.edu Mon Feb 19 23:16:01 2001 From: marvind at Glue.umd.edu (Arvind Mani) Date: Mon, 19 Feb 2001 17:16:01 -0500 Subject: python and multi-threaded C programs Message-ID: <3A919B21.37B39900@Glue.umd.edu> Hi, I am new to python. I have a multi-threaded application in C. I would like to create the threads in python and then use the thread routine written in C. Is this possible? I am doing this because, I had some problems with global variables that are initialized in one thread but used in another. I dont need these variables to be directly visible to the python interpreter. They are required in functions that I call from python. Thanks, Arvind From bryan at eevolved.com Tue Feb 20 08:51:19 2001 From: bryan at eevolved.com (Bryan Mongeau) Date: Tue, 20 Feb 2001 07:51:19 GMT Subject: python and multi-threaded C programs References: <3A919B21.37B39900@Glue.umd.edu> Message-ID: Arvind Mani wrote: > Hi, > > I am new to python. I have a multi-threaded application in C. I would > like to create the threads in python and then use the thread routine > written in C. Is this possible? > > I am doing this because, I had some problems with global variables that > are initialized in one thread but used in another. I dont need these > variables to be directly visible to the python interpreter. They are > required in functions that I call from python. > > > Thanks, > Arvind > Arvind, I noticed your post over on the SWIG list. I can't help but wonder just how valuable those thread routines in C are to you... You would save yourself a great headache (not to mention maintainability nightmares) if you ported your socket routines to python. It's not hard you know. Plus you can wield python's super-powers :) Out of curiosity, are you making a distributed, decentralized file-sharing network? :) -- <==================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. http://www.eevolved.com <==================================> "Scientific beliefs are supported by evidence, and they get results. Myths and faiths are not and do not" -- Richard Dawkins From marvind at Glue.umd.edu Thu Feb 22 22:13:03 2001 From: marvind at Glue.umd.edu (Arvind Mani) Date: Thu, 22 Feb 2001 16:13:03 -0500 Subject: python and multi-threaded C programs References: <3A919B21.37B39900@Glue.umd.edu> Message-ID: <3A9580DF.58FE8617@Glue.umd.edu> hi, I saw your reply just now. Well I am implementing a key managment and distribution protocol for dynamic groups. I have one thread waiting for messages from the initiator who controls just the group membership but does not take part in key formation after the initial round, one thread sending/receiving messages from other group members, one thread for the rekey signal (USR1) so that they can form the secret key again, one thread to receive fractional keys from other members and to send its own contribution to the shared key and finally one thread to start the python script. This is on the host side. The initiator code is simpler and has only 2 threads - gui and the other to receive messages indicating membership changes, round nos., etc. I have finished as much. This application will sit on top of a dynamic routing protocol, say TORA. The user interface will be in Tkinter. I have completed the first part and also extended certain functions so that they could be called from python. I got stuck with globals that are used in other threads. And I have semaphores to enforce certain oredering of events and mutexes to protect globals. I think all the above are possible using Python. I would be very grateful if you could tell me if using python to do the above is straightforward. Can you point me to a tutorial on creating, cancelling threads in python. I did not need much effort for the first part and so I can redo the whole thing. Thanks, Arvind Bryan Mongeau wrote: > Arvind Mani wrote: > > > Hi, > > > > I am new to python. I have a multi-threaded application in C. I would > > like to create the threads in python and then use the thread routine > > written in C. Is this possible? > > > > I am doing this because, I had some problems with global variables that > > are initialized in one thread but used in another. I dont need these > > variables to be directly visible to the python interpreter. They are > > required in functions that I call from python. > > > > > > Thanks, > > Arvind > > > > Arvind, > > I noticed your post over on the SWIG list. I can't help but wonder just how > valuable those thread routines in C are to you... You would save yourself a > great headache (not to mention maintainability nightmares) if you ported > your socket routines to python. It's not hard you know. Plus you can wield > python's super-powers :) > > Out of curiosity, are you making a distributed, decentralized file-sharing > network? :) > -- > <==================================> > Bryan Mongeau > Lead Developer, Director > eEvolved Real-Time Technologies Inc. > http://www.eevolved.com > <==================================> > > "Scientific beliefs are supported by evidence, and they get results. Myths > and faiths are not and do not" -- Richard Dawkins From tjg at exceptionalminds.com Tue Feb 20 00:33:19 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Mon, 19 Feb 2001 15:33:19 -0800 Subject: Numerous file parsers vs. XML Message-ID: <20010219153319.G6222@trufflehunter.avalongroup.net> Hi all, I'm working on a project, and have been using a Python tool called LParser. It works very well, and I have no complaints. It is a tool for parsing an input file and returning a dictionary of values. I created a tool configuration file that LParser reads very nicely and I can access all my configuration options for many different sections through dictionary entries that are themselves dictionaries (e.g., options['wltrakker']['application']) I have recently been studying XML, and it looks like it would be an excellent standardized tool for creating configuration files. Are there any XML modules available that would read and XML configuration file for me and return a dictionary of the contents? Am I being silly and looking for a solution where I don't have a problem? As always, all input is greatly appreciated. -- 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: 34 days 3:40 hours ago<< From shaleh at valinux.com Tue Feb 20 00:43:49 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Mon, 19 Feb 2001 15:43:49 -0800 Subject: Numerous file parsers vs. XML In-Reply-To: <20010219153319.G6222@trufflehunter.avalongroup.net>; from tjg@exceptionalminds.com on Mon, Feb 19, 2001 at 03:33:19PM -0800 References: <20010219153319.G6222@trufflehunter.avalongroup.net> Message-ID: <20010219154349.B29288@valinux.com> On Mon, Feb 19, 2001 at 03:33:19PM -0800, Timothy Grant wrote: > I have recently been studying XML, and it looks like it would > be an excellent standardized tool for creating configuration > files. > > Are there any XML modules available that would read and XML > configuration file for me and return a dictionary of the > contents? > > Am I being silly and looking for a solution where I don't have > a problem? > most of the tools out ther for XML make it easy for you to deal with the file. So typically it is : found_tag(foo) foo_open() foo_close() so, Bar would trigger the above call. From loewis at informatik.hu-berlin.de Tue Feb 20 14:04:04 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 20 Feb 2001 14:04:04 +0100 Subject: Numerous file parsers vs. XML References: Message-ID: Timothy Grant writes: > Are there any XML modules available that would read and XML > configuration file for me and return a dictionary of the > contents? > > Am I being silly and looking for a solution where I don't have > a problem? The easiest way may be to read the document into a DOM tree using xml.dom.minidom of Python 2.0, then use the DOM API to find the bits and pieces you are looking for. Regards, Martin From tjg at exceptionalminds.com Tue Feb 20 17:50:29 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Tue, 20 Feb 2001 08:50:29 -0800 Subject: Numerous file parsers vs. XML In-Reply-To: ; from loewis@informatik.hu-berlin.de on Tue, Feb 20, 2001 at 02:04:04PM +0100 References: Message-ID: <20010220085029.M6222@trufflehunter.avalongroup.net> Thanks Martin, I'll take a look at it and see if it fits. I'm still debating whether I'm looking for a solution where there is no problem! On Tue, Feb 20, 2001 at 02:04:04PM +0100, Martin von Loewis wrote: > Timothy Grant writes: > > > Are there any XML modules available that would read and XML > > configuration file for me and return a dictionary of the > > contents? > > > > Am I being silly and looking for a solution where I don't have > > a problem? > > The easiest way may be to read the document into a DOM tree using > xml.dom.minidom of Python 2.0, then use the DOM API to find the bits > and pieces you are looking for. -- 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: 34 days 21:02 hours ago<< From wmiller at mediaone.net Tue Feb 20 00:39:27 2001 From: wmiller at mediaone.net (Walter Miller) Date: Mon, 19 Feb 2001 15:39:27 -0800 Subject: Screen capture window to *.bmp file Message-ID: I'm trying to screen capture a window to a *.bmp file even if it is hidden behind other windows. After some research, it seems like the only way to do this is to use the Win32 API messages: WM_PRINT or WM_PRINTCLIENT as discribed in this article: http://www.fengyuan.com/article/wmprint.html Any ideas how to implement this in Python? TIA, Walter From billings at eudoramail.com Tue Feb 20 01:28:48 2001 From: billings at eudoramail.com (Scott Billings) Date: Mon, 19 Feb 2001 18:28:48 -0600 Subject: Embedded Python (in HTML) Message-ID: <96se0k$l4l$1@ins21.netins.net> Is there any project out there, other than maybe PMZ, that is along the lines of ASP, PHP, HTML::Mason or EmbPerl for Python? PMZ might not be so bad if it didn't seem like a CGI script that parses files, and then hands off the Python code to the Python interpreter. And I have looked at such things as Zope (quite a bit overkill for what I want), Webware (also quite overkill)..... I would love to see basically PHP with a Python syntax. Does such a beast exist? -- -Scott- From ws-news at gmx.at Tue Feb 20 17:02:15 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Tue, 20 Feb 2001 17:02:15 +0100 Subject: Embedded Python (in HTML) References: <96se0k$l4l$1@ins21.netins.net> Message-ID: <982685199.468853@newsmaster-04.atnet.at> For windows you can have ASP pages with python scripts. When using the ActivePython distribution from www.activestate.com, this works right after you installed it. hth werner Scott Billings wrote in message news:96se0k$l4l$1 at ins21.netins.net... > Is there any project out there, other than maybe PMZ, that is along the > lines of ASP, PHP, HTML::Mason or EmbPerl for Python? > > PMZ might not be so bad if it didn't seem like a CGI script that parses > files, and then hands off the Python code to the Python interpreter. > > And I have looked at such things as Zope (quite a bit overkill for what I > want), Webware (also quite overkill)..... I would love to see basically PHP > with a Python syntax. Does such a beast exist? > -- > -Scott- From sciasbat at inorbit.com Wed Feb 21 17:07:19 2001 From: sciasbat at inorbit.com (Fabio Forno) Date: Wed, 21 Feb 2001 17:07:19 +0100 Subject: Embedded Python (in HTML) References: <96se0k$l4l$1@ins21.netins.net> Message-ID: <3A93E7B7.2C6C42CE@inorbit.com> Scott Billings wrote: > > Is there any project out there, other than maybe PMZ, that is along the > lines of ASP, PHP, HTML::Mason or EmbPerl for Python? > mod_snake may suit ByE, FF From jmurray at agyinc.com Tue Feb 20 01:44:45 2001 From: jmurray at agyinc.com (Joe Murray) Date: Mon, 19 Feb 2001 16:44:45 -0800 Subject: postscript generation Message-ID: <3A91BDFD.D1BA8527@agyinc.com> Dear All, I hope I am not missing some obvious module, but are there any more Python modules for generating PostScript? I've looked at PIL and PGPlot (and cousin plplot) and even the 'yet-to-be-released' PythonPS module (http://www.pugo.org/ps). I'm looking for something like HTMLgen for PostScript. Is the PostScript Utility Library going to provide some of this functionality? I'm trying to combine the GNU Barcode library with some textual labeling to implement a some sorta LIMS-type system. So I really need access to PostScript text layout tools. (BTW, most of what I'm doing I could code up quickly (quickly, in _python_ of course), but if there's a module, why not use it...) Thanks, joe -- Joseph Murray Bioinformatics Specialist, AGY Therapeutics 290 Utah Avenue, South San Francisco, CA 94080 (650) 228-1146 From aahz at panix.com Tue Feb 20 02:15:05 2001 From: aahz at panix.com (Aahz Maruch) Date: 19 Feb 2001 17:15:05 -0800 Subject: postscript generation References: Message-ID: <96sgep$a0c$1@panix6.panix.com> In article , Joe Murray wrote: > >I hope I am not missing some obvious module, but are there any more >Python modules for generating PostScript? I've looked at PIL and PGPlot >(and cousin plplot) and even the 'yet-to-be-released' PythonPS module >(http://www.pugo.org/ps). http://www.reportlab.com/ -- --- 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 "Laws that restrict speech are an abomination for a simple reason. They're like a poison gas; they seem to be a good weapon to vanquish your enemy, but the wind has a way of shifting." -- Ira Glasser From alet at unice.fr Tue Feb 20 11:22:46 2001 From: alet at unice.fr (Jerome Alet) Date: Tue, 20 Feb 2001 11:22:46 +0100 Subject: postscript generation References: <96sgep$a0c$1@panix6.panix.com> Message-ID: <3A924576.AEB4CCC0@unice.fr> Aahz Maruch wrote: > http://www.reportlab.com/ ReportLab produces only pdf, you then have to convert it to ps using ghostscript (pdf2ps). However it's a fantastic module ! Go and get it ! -- Jerome Alet - alet at unice.fr - http://cortex.unice.fr/~jerome Fac de Medecine de Nice http://wwwmed.unice.fr Tel: (+33) 4 93 37 76 30 Fax: (+33) 4 93 53 15 15 28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE From clee at gnwy100.wuh.wustl.edu Tue Feb 20 15:48:21 2001 From: clee at gnwy100.wuh.wustl.edu (Christopher Lee) Date: 20 Feb 2001 08:48:21 -0600 Subject: postscript generation References: <96sgep$a0c$1@panix6.panix.com> <3A924576.AEB4CCC0@unice.fr> Message-ID: <7uzofhif62.fsf@gnwy100.wuh.wustl.edu> If PDF is acceptible, I would recommend reportlab (http://www.reportlab.com). If you're looking to generate postscript directly, Sping (http://piddle.sourceforge.net) includes a postscript module that supports either EPS or multipage PS generation. It's not as complete as reportlab, but it is still useful. At worse, it would provide a base for anything you wanted to build. (Plus, I happen to know that the maintainer is in the middle of writing it's documentation and would welcome any useful additions. ;-) -chris From shaleh at valinux.com Tue Feb 20 02:21:47 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Mon, 19 Feb 2001 17:21:47 -0800 Subject: a better getopt than getopt.py? Message-ID: <20010219172147.F29288@valinux.com> Writing my fisrt real python app that people will run from the command line (most of my previous coding has been modules for other software to web stuff) I decided to use getopt. My setup looks like this: LONG_OPTIONS = ['help', 'setup-lab', 'lab='] SHORT_OPTIONS = 'hS' try: optlist, args = getopt.getopt(sys.argv[1:], SHORT_OPTIONS, LONG_OPTIONS) except getopt.error, e: print e print USAGE sys.exit(1) for option, argument in optlist: if option in ('-h', '--help'): print USAGE sys.exit(0) elif option in ('-S', '--setup-lab'): print 'Want to set up the lab ...' elif option == 'lab': print 'Put lab in: ' + argument this means I have my options defined twice and then once again in the USAGE output. Is there not a better way to handle arguments? From jhauser at ifm.uni-kiel.de Tue Feb 20 09:17:25 2001 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 20 Feb 2001 09:17:25 +0100 Subject: a better getopt than getopt.py? References: Message-ID: <874rxpydii.fsf@lisboa.ifm.uni-kiel.de> Search for CommandLineApp.py! It's a nice OO way to handle commandline options and it generates the help/usage page automatically. 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 aleaxit at yahoo.com Tue Feb 20 13:58:12 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 20 Feb 2001 13:58:12 +0100 Subject: a better getopt than getopt.py? References: Message-ID: <96tpnt013kr@news2.newsguy.com> "Sean 'Shaleh' Perry" wrote in message news:mailman.982632084.17484.python-list at python.org... > Writing my fisrt real python app that people will run from the command line > (most of my previous coding has been modules for other software to web stuff) > I decided to use getopt. My setup looks like this: > > LONG_OPTIONS = ['help', 'setup-lab', 'lab='] > SHORT_OPTIONS = 'hS' > > try: > optlist, args = getopt.getopt(sys.argv[1:], SHORT_OPTIONS, > LONG_OPTIONS) > except getopt.error, e: > print e > print USAGE > sys.exit(1) > > for option, argument in optlist: > if option in ('-h', '--help'): > print USAGE > sys.exit(0) > elif option in ('-S', '--setup-lab'): > print 'Want to set up the lab ...' > elif option == 'lab': > print 'Put lab in: ' + argument > > this means I have my options defined twice and then once again in the USAGE > output. Is there not a better way to handle arguments? I think you basically want to group an option's short-form (if any), its long-form (if any), and a unique-identifier for the option itself (off which you can key an if/elif tree) into one 'chunk'. You can dress and package this up in several ways, of course, but, at the root, it will be (before optimization...!-) something like: Options = ( ('help', 'h', 'H'), ('setup-lab', 'S', 'S'), ('lab=', None, 'L') ) def long(Options): return [long for long, short, unique in Options if not long is None] def short(Options): return [short for long, short, unique in Options if not short is None] def unique(option, Options): def short_to_unique(a_short, Options): for long, short, unique in Options: if a_short == short: return unique return None def long_to_unique(a_long, Options): for long, short, unique in Options: if a_long == long: return unique return None if option.startswith('--'): return long_to_unique(option[2:], Options) elif option.startswith('-'): return short_to_unique(option[1:], Options) else: return long_to_unique(option+'=', Options) and your mainline code becomes, in turn: try: optlist, args = getopt.getopt(sys.argv[1:], short(Options), long(Options)) except getopt.error, e: print e print USAGE sys.exit(1) for option, argument in optlist: optionId = unique(option, Options) if optionId == 'H': print USAGE sys.exit(0) elif optionId == 'S': print 'Want to set up the lab ...' elif optionId == 'L': print 'Put lab in: ' + argument Packaging this up as one nice support class or function allowing a direct (and faster...) loop of the form: allOpts, args = GetAllOpts(Options) for optionId, argument in allOpts: if optionId == 'H': etc etc, is left as an easy exercise for the reader:-). Alex From thomas at cbs.dtu.dk Tue Feb 20 18:29:32 2001 From: thomas at cbs.dtu.dk (Thomas Sicheritz-Ponten) Date: 20 Feb 2001 18:29:32 +0100 Subject: a better getopt than getopt.py? References: <96tpnt013kr@news2.newsguy.com> Message-ID: > > this means I have my options defined twice and then once again in the > USAGE > > output. Is there not a better way to handle arguments? > I agree - that is actually the ONLY part I miss from Tcl. Tcl has this really nice optparse.tcl package which parses the commandline arguments and help documentation in one go ... package require opt ::tcl::OptProc checkopts { {file -string "FASTA file"} {-blast -string blastp "blast program"} {-db -string "swiss" "quoted, space seperated list of blast databases"} {-flags -string {} "blast flags ( -flags \"\\-hspmax 5\")"} {-z "compress"} {-subdir "create subdir for each entry"} {-html "generate HTML summary"} {-grep /opt/gnu/bin/grep "location of GNU's grep"} {-report 1 "report \#n hit"} {-begin {} "begin with entry"} {-rev "start with last entry"} {-switch "switch order of db and seq ( for non blasts like hmmpfam)"} } { foreach i [info locals] { if {$i=="args" || $i=="Args"} continue set ::data($i) [ set $i] } } -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 cfelling at iae.nl Tue Feb 20 14:17:54 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 20 Feb 2001 14:17:54 +0100 Subject: a better getopt than getopt.py? References: Message-ID: <96tqq2$2fh$1@animus.fel.iae.nl> Sean 'Shaleh' Perry wrote: > Writing my fisrt real python app that people will run from the command line > (most of my previous coding has been modules for other software to web stuff) > I decided to use getopt. My setup looks like this: ...example code snipped > this means I have my options defined twice and then once again in the USAGE > output. Is there not a better way to handle arguments? Well you could make a class that hides all of this:) Sometime ago (1999 me thinks) some people (including me) exchanged some ideas and example code for this on c.l.py. Though looking back at my own code, I think I would do things differently now that I've more experience with Python, but if you're interested I don't mind sending it. -- groetjes, carel From Roberto Thu Feb 22 09:55:35 2001 From: Roberto (Roberto@lupex.net) Date: Thu, 22 Feb 2001 08:55:35 GMT Subject: a better getopt than getopt.py? [long] References: Message-ID: Sean 'Shaleh' Perry wrote: >this means I have my options defined twice and then once again in the USAGE >output. Is there not a better way to handle arguments? I have written the attached module as this issue bothers me too. The code is not well tested (its very recent). Here's a commented example from a program that uses it: # -------------------- Assign default for command line args # you can put them in any python dictionary # ( globals() is the dictionary in this case ) low_uids_level = 0 root_check = 1 dup_UIDs = 1 dup_names = 1 verbose = 0 ignore_list = [] passwd_file = '/etc/passwd' # -------------------- Create a command line parser cmd = CmdLine2.CmdLine('Passwd file checks', # program title usage_msg='[options]', # usage message # (default: "[options] args") context = globals() # where to store option values # should be a dict-like object # (default: an empty dict) # accessible thru cmd.context ) cmd.add_help_option() # add a -h --help option # to print the list of available options cmd.add_set_option( # an option to set ('low_uids_level',string.atoi), # context['low_uids_level'] ['l:','low-uid='], # to the integer value "Check for UIDs < [argument]") # of its argument # if the first argument of cmd_add_XXX_option() is a tuple, # the first element is the variable name/item key, # the second elemnt is a conversion function that is applied to the arg cmd.add_toggle_option( # a boolean flag option, as in: 'root_check', # root_check = not root_check ['r','root'], "Enable/disable report of superusers") cmd.add_check_option( # a boolean set option: 'verbose', # verbose = 1 ['v','verbose'], "Print configution before processing") cmd.add_append_option( # append arguments to ignore_list 'ignore_list', ['i:','ignore='], "Add the specified user to the ignore list") def option_handler(opt, arg): # do something sensible with opt and arg pass cmd.add_action_option( # custom option that option_handler, # execute option_handler(opt,arg) ['bingo'], "Prints lucky numbers for bingo") cmd.getopt() # parse the command line # the rest of the program if verbose: print "I'll check", passwd_file,":" if low_uids_level > 0: print " - for UIDs <", low_uid_level if root_check: print " - for root users" if dup_UIDs: print " - for duplicated UIDs" if dup_names: print " - for duplicated usernames" print "Ignore list:", list2str(ignore_list) print ... Here's the help message of the program (generated by add_help_option): Passwd file checks chk-passwd [options] -h --help Print this help message -l: --low-uid= Check for UIDs < [argument] -r --root Enable/disable report of superusers -u --uids En/dis report of duplicated UIDs -n --names En/dis report of duplicated usernames -v --verbose Print configution before processing -i: --ignore= Add the specified user to the ignore list -p: --passwd= Process the specified file (default: /etc/passwd) (the complete script has a few more options than the example code above) And here's the CmdLine2.py module: # CmdLine2 - Command Line Processing v2.0 # # # 22-feb-2001 - Released as public domain code # by Roberto Lupi import sys import getopt import re import os debug = 0 short_option_re = re.compile('.:?$') def RemoveLast(st, postfix): if st[-len(postfix):] == postfix: return st[:-len(postfix)] else: return st def ListToStr(lst, sep=' '): return reduce( lambda a,b,sep=sep: str(a)+sep+str(b), lst) ###################################################################### ## ## Class Option ## ###################################################################### class Option: def __init__(self, opts, help_msg): short_op = [] long_op = [] for opt in opts: if short_option_re.match(opt): short_op.append(opt) else: long_op.append(opt) self.short_op = short_op self.long_op = long_op self.help_msg = help_msg def fire(self, opt, arg): pass def short_options(self, arg_spec=None,op_prefix='-'): if self.short_op: if arg_spec: return map( lambda x,op_prefix=op_prefix: op_prefix + \ x, self.short_op ) else: return map( lambda x,op_prefix=op_prefix: op_prefix + \ RemoveLast(x,':'), self.short_op ) else: return [] def long_options(self, arg_spec=None,op_prefix='--'): if self.long_op: if arg_spec: return map( lambda x,op_prefix=op_prefix: op_prefix + \ x, self.long_op ) else: return map( lambda x,op_prefix=op_prefix: op_prefix + \ RemoveLast(x,'='), self.long_op ) else: return [] def all_options(self, arg_spec=None): return self.short_options(arg_spec) + self.long_options(arg_spec) def print_help(self): if self.help_msg: print " %-20s %s" % (ListToStr(self.all_options(1)), \ self.help_msg) ###################################################################### ## ## Class OptionAction ## ###################################################################### class OptionAction(Option): def __init__(self, action, ops, help_msg): Option.__init__(self,ops,help_msg) self.action = action def fire(self, opt, arg): apply(self.action, (opt, arg)) ###################################################################### ## ## Class OptionContextBased ## ###################################################################### class OptionContextBased(Option): def __init__(self, action_spec, context, ops, help_msg): Option.__init__(self,ops,help_msg) self.action_spec = action_spec self.context = context ###################################################################### ## ## Class OptionSet ## ###################################################################### class OptionSet(OptionContextBased): def fire(self, opt, arg): if type(self.action_spec) == type(""): vname = self.action_spec cvt = lambda x: x else: (vname, cvt) = self.action_spec self.context[vname] = cvt(arg) ###################################################################### ## ## Class OptionToggle ## ###################################################################### class OptionToggle(OptionContextBased): def fire(self, opt, arg): vname = self.action_spec if self.context.has_key(vname): old_value = self.context[vname] else: old_value = 0 self.context[vname] = not old_value ###################################################################### ## ## Class OptionCheck ## ###################################################################### class OptionCheck(OptionContextBased): def fire(self, opt, arg): vname = self.action_spec self.context[vname] = 1 ###################################################################### ## ## Class OptionAppend ## ###################################################################### class OptionAppend(OptionContextBased): def fire(self, opt, arg): if type(self.action_spec) == type(""): vname = self.action_spec cvt = lambda x: x else: (vname, cvt) = self.action_spec if self.context.has_key(vname) and self.context[vname]: self.context[vname].append(cvt(arg)) else: self.context[vname] = [ cvt(arg) ] ###################################################################### ## ## Class CmdLine ## ###################################################################### class CmdLine: def __init__(self, program_title=None, usage_msg="[options] files", \ context={}): self.program_title = program_title self.usage_msg = usage_msg self.options = [] self.context = context def getopt(self, args=None): if self.program_title: print self.program_title print if args is None: args = sys.argv[1:] # build option map option_map = {} short_ops = "" long_ops = [] for opt in self.options: if opt.short_op: short_ops = short_ops + \ ListToStr(opt.short_options(arg_spec=1,op_prefix=''),'') if opt.long_op: long_ops.extend(opt.long_options(arg_spec=1,op_prefix='')) for op in opt.all_options(): option_map[op] = opt if debug: print "OPTION MAP:" for op_spec, Opt in option_map.items(): print " %10s -> %s" % (op_spec, str(Opt)) # process cmd line try: opts, other_args = getopt.getopt(args, short_ops, long_ops) for opt, arg in opts: Op = option_map[opt] if debug: print "DEBUG: Firing %s (opt=%s, arg=%s)" % \ (str(Op), opt, arg) Op.fire(opt, arg) return other_args except getopt.error, e: print str(e) sys.exit(1) def print_help(self, opt=None, arg=None): print "%s %s" % (os.path.basename(sys.argv[0]), self.usage_msg) print for opt in self.options: opt.print_help() print if opt: # invoked thru -h sys.exit(1) def add_option(self, Opt): self.options.append(Opt) def add_help_option(self): self.add_option(OptionAction(self.print_help,['h','help'], \ "Print this help message")) def add_action_option(self, action, ops, help_msg=None): self.add_option(OptionAction(action,ops,help_msg)) def add_set_option(self, vname, ops, help_msg=None): self.add_option(OptionSet(vname,self.context,ops,help_msg)) def add_toggle_option(self, vname, ops, help_msg=None): self.add_option(OptionToggle(vname,self.context,ops,help_msg)) def add_check_option(self, vname, ops, help_msg=None): self.add_option(OptionCheck(vname,self.context,ops,help_msg)) def add_append_option(self, vname, ops, help_msg=None): self.add_option(OptionAppend(vname,self.context,ops,help_msg)) -- Roberto Lupi From tjg at exceptionalminds.com Tue Feb 20 17:54:49 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Tue, 20 Feb 2001 08:54:49 -0800 Subject: a better getopt than getopt.py? In-Reply-To: <20010219172147.F29288@valinux.com>; from shaleh@valinux.com on Mon, Feb 19, 2001 at 05:21:47PM -0800 References: <20010219172147.F29288@valinux.com> Message-ID: <20010220085449.N6222@trufflehunter.avalongroup.net> I recently went through a very similar experience with getopt, though I was working on subclassing a class that handled command line arguments (getopt proved to be completely unsuitable for that task). I turned to t module I found on Parnassus called cmdline.py. It works beautifully, as expected, and the implementation is much more readable than the similar getopt version. for some reason it doesn't show up in a Parnassus search for some reason it doesn't show up in a search for cmdline.py, but it does show up as one of about three hits in a search for getopt. On Mon, Feb 19, 2001 at 05:21:47PM -0800, Sean 'Shaleh' Perry wrote: > Writing my fisrt real python app that people will run from the command line > (most of my previous coding has been modules for other software to web stuff) > I decided to use getopt. My setup looks like this: > > LONG_OPTIONS = ['help', 'setup-lab', 'lab='] > SHORT_OPTIONS = 'hS' > > try: > optlist, args = getopt.getopt(sys.argv[1:], SHORT_OPTIONS, > LONG_OPTIONS) > except getopt.error, e: > print e > print USAGE > sys.exit(1) > > for option, argument in optlist: > if option in ('-h', '--help'): > print USAGE > sys.exit(0) > elif option in ('-S', '--setup-lab'): > print 'Want to set up the lab ...' > elif option == 'lab': > print 'Put lab in: ' + argument > > this means I have my options defined twice and then once again in the USAGE > output. Is there not a better way to handle arguments? > > -- > http://mail.python.org/mailman/listinfo/python-list -- 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: 34 days 21:04 hours ago<< From DavidLNonoSpam at raqia.com Tue Feb 20 19:37:22 2001 From: DavidLNonoSpam at raqia.com (David Lees) Date: Tue, 20 Feb 2001 13:37:22 -0500 Subject: a better getopt than getopt.py? References: <20010219172147.F29288@valinux.com> Message-ID: <3A92B962.17BA30ED@raqia.com> Timothy, Thanks for posting this info. I tried getopt and was not crazy about it. This looks well documented and usefull. David Lees Timothy Grant wrote: > > I recently went through a very similar experience with getopt, > though I was working on subclassing a class that handled > command line arguments (getopt proved to be completely > unsuitable for that task). I turned to t module I found on > Parnassus called cmdline.py. It works beautifully, as expected, > and the implementation is much more readable than the similar > getopt version. > > for some reason it doesn't show up in a Parnassus search for > some reason it doesn't show up in a search for cmdline.py, but > it does show up as one of about three hits in a search for > getopt. > > On Mon, Feb 19, 2001 at 05:21:47PM -0800, Sean 'Shaleh' Perry wrote: > > Writing my fisrt real python app that people will run from the command line > > (most of my previous coding has been modules for other software to web stuff) > > I decided to use getopt. My setup looks like this: > > > > LONG_OPTIONS = ['help', 'setup-lab', 'lab='] > > SHORT_OPTIONS = 'hS' > > > > try: > > optlist, args = getopt.getopt(sys.argv[1:], SHORT_OPTIONS, > > LONG_OPTIONS) > > except getopt.error, e: > > print e > > print USAGE > > sys.exit(1) > > > > for option, argument in optlist: > > if option in ('-h', '--help'): > > print USAGE > > sys.exit(0) > > elif option in ('-S', '--setup-lab'): > > print 'Want to set up the lab ...' > > elif option == 'lab': > > print 'Put lab in: ' + argument > > > > this means I have my options defined twice and then once again in the USAGE > > output. Is there not a better way to handle arguments? > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > -- > 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: 34 days 21:04 hours ago<< From jmarshal at mathworks.com Tue Feb 20 02:25:22 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 20 Feb 2001 01:25:22 GMT Subject: Proposal: allow '?' and '!' in identifiers Message-ID: <96sh22$jq5$1@news.mathworks.com> Anybody have any thoughts on allowing the characters '!' and '?' in identifiers? It's possible I'm missing something, but I think the only ambiguity this introduces is in the case of something like the following: a!=b But whitespace easily disambiguates ("a! = b" vs "a != b"). The only snag I see is in the lexer. For backward compatibility, "a!=b" would need to be lexed as "a != b", but this may be unexpected, since the lexer is currently greedy, trying to make tokens as large as possible before moving on. If the addition of '!' as a valid identifier character causes too many waves, it would still be nice to see '?'. From s2mdalle at titan.vcu.edu Tue Feb 20 04:17:09 2001 From: s2mdalle at titan.vcu.edu (David Allen) Date: Tue, 20 Feb 2001 03:17:09 GMT Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> Message-ID: In article <96sh22$jq5$1 at news.mathworks.com>, "Joshua Marshall" wrote: > Anybody have any thoughts on allowing the characters '!' and '?' in > identifiers? It's possible I'm missing something, but I think the only > ambiguity this introduces is in the case of something like the following: > > a!=b > > But whitespace easily disambiguates ("a! = b" vs "a != b"). > > The only snag I see is in the lexer. For backward compatibility, "a!=b" > would need to be lexed as "a != b", but this may be unexpected, since the > lexer is currently greedy, trying to make tokens as large as possible before > moving on. > > If the addition of '!' as a valid identifier character causes too many > waves, it would still be nice to see '?'. Why? How would this make the language more expressive? How would it make your programming tasks easier? Is introducing new and strange behavior (such as your a!=b example) worth it? Why? -- David Allen http://opop.nols.com/ ---------------------------------------- Diplomacy is the art of saying "nice doggy" until you can find a gun. From jmarshal at mathworks.com Tue Feb 20 04:43:24 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 20 Feb 2001 03:43:24 GMT Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> Message-ID: <96sp4s$ni7$1@news.mathworks.com> David Allen wrote: ... >> If the addition of '!' as a valid identifier character causes too many >> waves, it would still be nice to see '?'. > Why? How would this make the language more expressive? > How would it make your programming tasks easier? > Is introducing new and strange behavior (such as your > a!=b example) worth it? Why? Introducing some strange behavior with '!' may very well not be worth it. However, while adding '?' as a legal identifier character does not make the Python more expressive, it can make Python programs more self-documenting. The convention of ending predicate function names with '?' is useful, in my opinion. From max at alcyone.com Tue Feb 20 05:32:52 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 19 Feb 2001 20:32:52 -0800 Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> <96sp4s$ni7$1@news.mathworks.com> Message-ID: <3A91F374.580B1A10@alcyone.com> Joshua Marshall wrote: > Introducing some strange behavior with '!' may very well not be worth > it. However, while adding '?' as a legal identifier character does > not make the Python more expressive, it can make Python programs more > self-documenting. The convention of ending predicate function names > with '?' is useful, in my opinion. But you don't need to literally have a ? at the end of the identifier to get the message across if that is your desire. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ If love be good, from whence cometh my woe? \__/ Chaucer Interstelen / http://www.interstelen.com/ A multiplayer, strategic, turn-based Web game on an interstellar scale. From n8gray at caltech.edu.is.my.email.address Tue Feb 20 07:21:35 2001 From: n8gray at caltech.edu.is.my.email.address (Nathaniel Gray) Date: Mon, 19 Feb 2001 22:21:35 -0800 Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> <96sp4s$ni7$1@news.mathworks.com> Message-ID: <96t2oi$4ce@gap.cco.caltech.edu> Joshua Marshall wrote: > David Allen wrote: > ... > > >> If the addition of '!' as a valid identifier character causes too many > >> waves, it would still be nice to see '?'. > > > Why? How would this make the language more expressive? > > How would it make your programming tasks easier? > > > Is introducing new and strange behavior (such as your > > a!=b example) worth it? Why? > > Introducing some strange behavior with '!' may very well not be worth > it. However, while adding '?' as a legal identifier character does > not make the Python more expressive, it can make Python programs more > self-documenting. The convention of ending predicate function names > with '?' is useful, in my opinion. Hear hear! (Or should that be "Hear hear?") IMHO it's not worth adding "!", but if "?" doesn't break anything then it's a net gain. I assert that it _would_ make Python more expressive to add an elegant way of indicating that a function returns only boolean values. Unfortunately, I doubt you'll see much support for deviating from [a-zA-Z_] on this newsgroup. Programmers of languages not descended from C (other than Python, of course) are in the minority, even among Pythonistas. There may be some cause for hope, though, because among python-dev subscribers I suspect they're in the majority! -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From rc-bashar at gmx.net Tue Feb 20 19:20:02 2001 From: rc-bashar at gmx.net (Christoph Horst) Date: Tue, 20 Feb 2001 19:20:02 +0100 Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> <96sp4s$ni7$1@news.mathworks.com> <96t2oi$4ce@gap.cco.caltech.edu> Message-ID: Nathaniel Gray wrote: >IMHO it's not worth adding "!", but if "?" doesn't break anything then it's >a net gain. I assert that it _would_ make Python more expressive to add an >elegant way of indicating that a function returns only boolean values. What's wrong with prefixing the function name with 'is'? From jmarshal at mathworks.com Tue Feb 20 22:16:52 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 20 Feb 2001 21:16:52 GMT Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> <96sp4s$ni7$1@news.mathworks.com> <96t2oi$4ce@gap.cco.caltech.edu> Message-ID: <96ums4$qk2$1@news.mathworks.com> Christoph Horst wrote: > Nathaniel Gray wrote: >>IMHO it's not worth adding "!", but if "?" doesn't break anything then it's >>a net gain. I assert that it _would_ make Python more expressive to add an >>elegant way of indicating that a function returns only boolean values. > What's wrong with prefixing the function name with 'is'? I wouldn't say anything is wrong with that approach. But then I could also ask "Why do we need underscores as valid identifier characters? You can just capitalize the next letter." The question mark is an unused character, and carries some natural-language meaning. It's useful. From root at rainerdeyke.com Wed Feb 21 04:34:58 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 21 Feb 2001 03:34:58 GMT Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> <96sp4s$ni7$1@news.mathworks.com> <96t2oi$4ce@gap.cco.caltech.edu> <96ums4$qk2$1@news.mathworks.com> Message-ID: "Joshua Marshall" wrote in message news:96ums4$qk2$1 at news.mathworks.com... > I wouldn't say anything is wrong with that approach. But then I could > also ask "Why do we need underscores as valid identifier characters? > You can just capitalize the next letter." > The question mark is an unused character, and carries some > natural-language meaning. It's useful. This is mostly a question of aesthetics. I like the way Python (and C/C++) does it. To me, the question mark looks like an operator; the underscore does not. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From piet at cs.uu.nl Wed Feb 21 15:39:18 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 21 Feb 2001 15:39:18 +0100 Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> <96sp4s$ni7$1@news.mathworks.com> <96t2oi$4ce@gap.cco.caltech.edu> <96ums4$qk2$1@news.mathworks.com> Message-ID: >>>>> Joshua Marshall (JM) writes: JM> Christoph Horst wrote: >> Nathaniel Gray wrote: >>> IMHO it's not worth adding "!", but if "?" doesn't break anything then it's >>> a net gain. I assert that it _would_ make Python more expressive to add an >>> elegant way of indicating that a function returns only boolean values. >> What's wrong with prefixing the function name with 'is'? JM> I wouldn't say anything is wrong with that approach. But then I could JM> also ask "Why do we need underscores as valid identifier characters? JM> You can just capitalize the next letter." JM> The question mark is an unused character, and carries some JM> natural-language meaning. It's useful. Please don't do it. There are more useful things to do with ? like the ternary operator for conditional expressions. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From wolfson at midway.uchicago.edu Wed Feb 21 22:36:35 2001 From: wolfson at midway.uchicago.edu (Ben Wolfson) Date: Wed, 21 Feb 2001 21:36:35 GMT Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> <96ums4$qk2$1@news.mathworks.com> Message-ID: In article , wrote: >>>>>> Joshua Marshall (JM) writes: > >JM> Christoph Horst wrote: >>> Nathaniel Gray wrote: >>>> IMHO it's not worth adding "!", but if "?" doesn't break anything >then it's >>>> a net gain. I assert that it _would_ make Python more expressive >to add an >>>> elegant way of indicating that a function returns only boolean values. > >>> What's wrong with prefixing the function name with 'is'? > >JM> I wouldn't say anything is wrong with that approach. But then I could >JM> also ask "Why do we need underscores as valid identifier characters? >JM> You can just capitalize the next letter." >JM> The question mark is an unused character, and carries some >JM> natural-language meaning. It's useful. > >Please don't do it. There are more useful things to do with ? like the >ternary operator for conditional expressions. Python isn't heading this way, but it's possible to allow a ? in identifiers and still have it be an operator, by mandating that operators have whitespace on both sides. -- Barnabas T. Rumjuggler For the world, I count it not an inn, but an hospital; and a place not to live, but to die in. -- Thomas Browne, _Religio Medici_ From n8gray at caltech.edu.is.my.e-mail.address Wed Feb 21 04:49:05 2001 From: n8gray at caltech.edu.is.my.e-mail.address (Nathan Gray) Date: Tue, 20 Feb 2001 19:49:05 -0800 Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> <96sp4s$ni7$1@news.mathworks.com> <96t2oi$4ce@gap.cco.caltech.edu> Message-ID: <3A933AB1.108@caltech.edu.is.my.e-mail.address> Christoph Horst wrote: > Nathaniel Gray wrote: > >> IMHO it's not worth adding "!", but if "?" doesn't break anything then it's >> a net gain. I assert that it _would_ make Python more expressive to add an >> elegant way of indicating that a function returns only boolean values. > > > What's wrong with prefixing the function name with 'is'? Nothing. I just find it pleasingly clear to read languages where predicates end with '?'. It's simple and elegant. Like I said, though, I'd be very surprised if this proposal ends up being accepted. -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From n8gray at caltech.edu.is.my.email.address Sun Feb 25 01:55:37 2001 From: n8gray at caltech.edu.is.my.email.address (Nathaniel Gray) Date: Sat, 24 Feb 2001 16:55:37 -0800 Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> <96sp4s$ni7$1@news.mathworks.com> <96t2oi$4ce@gap.cco.caltech.edu> <3A933AB1.108@caltech.edu.is.my.e-mail.address> Message-ID: <979lha$jg5@gap.cco.caltech.edu> Jason F. McBrayer wrote: > >>>>> "NG" == Nathan Gray > >>>>> writes: > > NG> Nothing. I just find it pleasingly clear to read languages where > NG> predicates end with '?'. It's simple and elegant. > > Why not be old-skool and end predicates with p? > Why not be hardcore and allow both? -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From max at alcyone.com Sun Feb 25 02:10:04 2001 From: max at alcyone.com (Erik Max Francis) Date: Sat, 24 Feb 2001 17:10:04 -0800 Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> <96sp4s$ni7$1@news.mathworks.com> <96t2oi$4ce@gap.cco.caltech.edu> <3A933AB1.108@caltech.edu.is.my.e-mail.address> <979lha$jg5@gap.cco.caltech.edu> Message-ID: <3A985B6C.C94048D1@alcyone.com> Nathaniel Gray wrote: > Why not be hardcore and allow both? Because using a suffixed p to indicate predicates, if that is your liking, is already supported by the language. Allowing ? in identifiers is not, and would require all sorts of weird parser logic to allow it in identifiers but not break backward compatibility. It is simply not worth 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 / \ A physicist is an atom's way of knowing about atoms. \__/ George Wald blackgirl international / http://www.blackgirl.org/ The Internet resource for black women. From grumble at mailcity.com Sun Feb 25 17:36:31 2001 From: grumble at mailcity.com (jcm) Date: 25 Feb 2001 16:36:31 GMT Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> <96sp4s$ni7$1@news.mathworks.com> <96t2oi$4ce@gap.cco.caltech.edu> <3A933AB1.108@caltech.edu.is.my.e-mail.address> <979lha$jg5@gap.cco.caltech.edu> <3A985B6C.C94048D1@alcyone.com> Message-ID: <97bcaf$noh$1@news.mathworks.com> Erik Max Francis wrote: > Nathaniel Gray wrote: >> Why not be hardcore and allow both? > Because using a suffixed p to indicate predicates, if that is your > liking, is already supported by the language. Allowing ? in identifiers > is not, and would require all sorts of weird parser logic to allow it in > identifiers but not break backward compatibility. It is simply not > worth it. I understand that you dislike the idea of allowing '?' in identifiers. But it would not necessarily require "all sorts of weird parser logic". I expect it's a simple change to the lexer. I haven't looked at the Python codebase, so I don't know for sure. But I've written enough lexers and parsers to know what should be easy or difficult. From mwh21 at cam.ac.uk Sun Feb 25 19:02:28 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 25 Feb 2001 18:02:28 +0000 Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> <96sp4s$ni7$1@news.mathworks.com> <96t2oi$4ce@gap.cco.caltech.edu> <3A933AB1.108@caltech.edu.is.my.e-mail.address> <979lha$jg5@gap.cco.caltech.edu> <3A985B6C.C94048D1@alcyone.com> <97bcaf$noh$1@news.mathworks.com> Message-ID: jcm writes: > Erik Max Francis wrote: > > Nathaniel Gray wrote: > > >> Why not be hardcore and allow both? > > > Because using a suffixed p to indicate predicates, if that is your > > liking, is already supported by the language. Allowing ? in identifiers > > is not, and would require all sorts of weird parser logic to allow it in > > identifiers but not break backward compatibility. It is simply not > > worth it. > > I understand that you dislike the idea of allowing '?' in identifiers. > But it would not necessarily require "all sorts of weird parser > logic". I expect it's a simple change to the lexer. It is. It takes about a minute if you know where to look (which is in Parser/tokenizer.c). I did it once, but seem to have lost the patch. Cheers, M. -- ARTHUR: Yes. It was on display in the bottom of a locked filing cabinet stuck in a disused lavatory with a sign on the door saying "Beware of the Leopard". -- The Hitch-Hikers Guide to the Galaxy, Episode 1 From max at alcyone.com Sun Feb 25 20:18:27 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 25 Feb 2001 11:18:27 -0800 Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> <96sp4s$ni7$1@news.mathworks.com> <96t2oi$4ce@gap.cco.caltech.edu> <3A933AB1.108@caltech.edu.is.my.e-mail.address> <979lha$jg5@gap.cco.caltech.edu> <3A985B6C.C94048D1@alcyone.com> <97bcaf$noh$1@news.mathworks.com> Message-ID: <3A995A83.C20EF617@alcyone.com> jcm wrote: > I understand that you dislike the idea of allowing '?' in identifiers. > But it would not necessarily require "all sorts of weird parser > logic". I expect it's a simple change to the lexer. I haven't looked > at the Python codebase, so I don't know for sure. But I've written > enough lexers and parsers to know what should be easy or difficult. Sorry, I was comingling your requests for both '?' and '!' in identifiers. It was '!' that would have required ambiguity checks, not '?'. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ It is only to the individual that a soul is given. \__/ Albert Einstein Kepler's laws / http://www.alcyone.com/max/physics/kepler/ A proof of Kepler's laws. From grante at visi.com Tue Feb 20 19:10:37 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 20 Feb 2001 18:10:37 GMT Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> <96sp4s$ni7$1@news.mathworks.com> Message-ID: In article <96sp4s$ni7$1 at news.mathworks.com>, Joshua Marshall wrote: >David Allen wrote: >... > >>> If the addition of '!' as a valid identifier character causes too many >>> waves, it would still be nice to see '?'. > >> Why? How would this make the language more expressive? >> How would it make your programming tasks easier? > >> Is introducing new and strange behavior (such as your >> a!=b example) worth it? Why? > >Introducing some strange behavior with '!' may very well not be worth >it. However, while adding '?' as a legal identifier character does >not make the Python more expressive, it can make Python programs more >self-documenting. The convention of ending predicate function names >with '?' is useful, in my opinion. Definitely. I always found that convention in Scheme to be very expresive and compact. The convention of ending predicates with "!" when they modified internal state was also useful though perhaps not as intuitive as "?". -- Grant Edwards grante Yow! Now I am depressed... at visi.com From othello at javanet.com Wed Feb 21 01:17:03 2001 From: othello at javanet.com (Raymond Hettinger) Date: Tue, 20 Feb 2001 19:17:03 -0500 Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> <96sp4s$ni7$1@news.mathworks.com> Message-ID: <3A9308FF.D07FB37F@javanet.com> > > >Introducing some strange behavior with '!' may very well not be worth > >it. However, while adding '?' as a legal identifier character does > >not make the Python more expressive, it can make Python programs more > >self-documenting. The convention of ending predicate function names > >with '?' is useful, in my opinion. > > Definitely. I always found that convention in Scheme to be > very expresive and compact. The convention of ending > predicates with "!" when they modified internal state was also > useful though perhaps not as intuitive as "?". > These naming conventions were useful to me iin Forth and Scheme; however, they're ugly (IMHO). The plain English forms are much more expressive and flexible without carrying the risk of confusing my optical lexer when I read code. Count my vote: -1 Raymond "In theory, there is no difference between theory and practice. In practice, there is." -- Yogi Berra From gregj at pobox.com Sun Feb 25 20:10:16 2001 From: gregj at pobox.com (Gregory Jorgensen) Date: Sun, 25 Feb 2001 19:10:16 GMT Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> <96sp4s$ni7$1@news.mathworks.com> <3A9308FF.D07FB37F@javanet.com> Message-ID: I vote against. Don't try to change Python into Scheme or Forth or whatever. If you find another language more expressive or elegant than Python, use that language. I find Python expressive and elegant because it doesn't have a lot of chaff and historical baggage. While I'm ranting... features of programming languages aren't intuitive. Some people may deduce the syntax easier than others, but that is experience, not intuition. My intuition tells me that any non-alphanumeric character in a symbol name may mean something special to the compiler; why would I think ? relates to its English usage when _ doesn't? In the context of reading and learning Python neither ? nor _ say anything to my intuition. In article <3A9308FF.D07FB37F at javanet.com>, Raymond Hettinger says... >> Definitely. I always found that convention in Scheme to be >> very expresive and compact. The convention of ending >> predicates with "!" when they modified internal state was also >> useful though perhaps not as intuitive as "?". >> > >These naming conventions were useful to me iin Forth and Scheme; >however, they're ugly (IMHO). The plain English forms are much >more expressive and flexible without carrying the risk of confusing >my optical lexer when I read code. > >Count my vote: -1 > >Raymond Greg Jorgensen Deschooling Society gregj at pobox.com From max at alcyone.com Tue Feb 20 05:31:58 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 19 Feb 2001 20:31:58 -0800 Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> Message-ID: <3A91F33E.C779FF1@alcyone.com> Joshua Marshall wrote: > Anybody have any thoughts on allowing the characters '!' and '?' in > identifiers? It's possible I'm missing something, but I think the > only ambiguity this introduces is in the case of something like the > following: > > a!=b > > But whitespace easily disambiguates ("a! = b" vs "a != b"). But missing or adding a seemingly harmless space means that you've got a completely different symbol. Bad news. -- 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 don't like principles. I prefer prejudices. \__/ Oscar Wilde Alcyone Systems / http://www.alcyone.com/ Alcyone Systems, San Jose, California. From lsloan at bigfoot.com Tue Feb 20 02:28:41 2001 From: lsloan at bigfoot.com (Lance E Sloan) Date: Tue, 20 Feb 2001 01:28:41 -0000 Subject: multiple parameters to append()? Message-ID: <96sh89+rk7v@eGroups.com> I downloaded an old-ish Python module, Julian, and my Python 2.0 complained about this line from its Zone.py file (line 61): self.ttinfos.append(up.unpack_int(), ord(data[6*i + 4]), ord(data[6*i + 5])) So I changed it to: self.ttinfos.append((up.unpack_int(), ord(data[6*i + 4]), ord(data[6*i + 5]))) Basically, I just added another set of parens to make the arguments all part of a tuple that is appended instead. I don't think this is correct, though. Although Python doesn't complain any more, the module doesn't work exactly as described. I saw in the Python documentation that this multi-parameter usage of append() is no longer allowed and has been deprecated for some time. How exactly did the old usage of append() work? I don't think I can correct the problem in this module unless I know that. From amk at mira.erols.com Tue Feb 20 02:43:26 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 20 Feb 2001 01:43:26 GMT Subject: multiple parameters to append()? References: Message-ID: On Tue, 20 Feb 2001 01:28:41 -0000, Lance E Sloan wrote: >deprecated for some time. How exactly did the old usage >of append() work? I don't think I can correct the problem in >this module unless I know that. Exactly as you expected: Python 1.5.2 (#1, Sep 17 1999, 20:15:36) Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> L=[1,2] >>> L.append(3,4) >>> L [1, 2, (3, 4)] >>> Perhaps the module is broken for some other reason; good luck with your debugging. --amk From ruediger.maehl at dzsh.de Wed Feb 21 12:35:07 2001 From: ruediger.maehl at dzsh.de (Ruediger Maehl) Date: Wed, 21 Feb 2001 12:35:07 +0100 Subject: multiple parameters to append()? References: Message-ID: Lance E Sloan schrieb in Nachricht ... > self.ttinfos.append(up.unpack_int(), ord(data[6*i + 4]), >ord(data[6*i + 5])) > how about: self.ttinfos = self.ttinfos + [up.unpack_int(), ord(data[6*i + 4]), ord(data[6*i + 5])] HTH R?diger From shaleh at valinux.com Tue Feb 20 02:44:06 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Mon, 19 Feb 2001 17:44:06 -0800 Subject: multiple parameters to append()? In-Reply-To: <96sh89+rk7v@eGroups.com>; from lsloan@bigfoot.com on Tue, Feb 20, 2001 at 01:28:41AM -0000 References: <96sh89+rk7v@eGroups.com> Message-ID: <20010219174406.H29288@valinux.com> On Tue, Feb 20, 2001 at 01:28:41AM -0000, Lance E Sloan wrote: > I downloaded an old-ish Python module, Julian, and > my Python 2.0 complained about this line from its > Zone.py file (line 61): > what you changed seems valid. Where did you find the module? Would like to inspect it myself. From lsloan at yahoo.com Tue Feb 20 15:41:40 2001 From: lsloan at yahoo.com (Lance E Sloan) Date: Tue, 20 Feb 2001 06:41:40 -0800 (PST) Subject: multiple parameters to append()? In-Reply-To: <20010219174406.H29288@valinux.com> Message-ID: <20010220144140.83710.qmail@web9504.mail.yahoo.com> --- Sean 'Shaleh' Perry wrote: > what you changed seems valid. Where did you find the module? Would > like to inspect it myself. It's Ted Horst's Julian module, which I found on Parnassus. You can get it directly from . ===== Lance E Sloan lsloan at bigfoot.com __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/ From dsavitsk at e-coli.net Tue Feb 20 03:42:23 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Mon, 19 Feb 2001 20:42:23 -0600 Subject: Creating Python Data Server Message-ID: This is sort of Python related, that is, if I write it, it will be in Python. I am really wondering if this exists, or is even practical ... I am trying to set up client/server system like a database server with stored procedures and what not where the procedures are written in python (or any other language), live on the server, and that isn't tied to any particular database. So the user would press a button on the interface sending a signal to the server which would instantiate whatever objects were necessary on the server, process the data, and then return the data to the client. i though about using apache/mod_python, but i want the user to feel like they are running things on their computer, that is, like all of the processes are local and the client and server are the same. Thus http doesn't seem to be what i want. I'll write the interface in VB or Delphi, but I want all of the processing to take place on the big fast server. A Telnet-like system would be great, but the win32 style interface with all of the prerequisite buttons and progress bars is essential. Also, I would rather use UNIX/MySQL on the server, but i don't want the users to know that. Does this sound like a reasonable project? and is there anything similar or does anyone have any better ideas? thanks, doug From cg at gaia.intranet.cdegroot.com Tue Feb 20 09:18:49 2001 From: cg at gaia.intranet.cdegroot.com (Cees de Groot) Date: 20 Feb 2001 09:18:49 +0100 Subject: Creating Python Data Server References: Message-ID: <96t999$qrl$1@gaia.intranet.cdegroot.com> dsavitsk said: >This is sort of Python related, that is, if I write it, it will be in >Python. I am really wondering if this exists, or is even practical ... > Well, it seems that PostgreSQL has the concept of pluggable back-end languages although only Tcl and Perl have been implemented yet. For this sort of projects, I'd recommend PostgreSQL over MySQL: PG is a real RDBMS and is object-relational (so you can do subclassing etcetera in the database instead of in some O/R mapping layer). MySQL is fun for storing user accounts and cookies behind websites, but not for serious data management. -- Cees de Groot http://www.cdegroot.com GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B From stephen_purcell at yahoo.com Tue Feb 20 10:19:28 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 20 Feb 2001 10:19:28 +0100 Subject: Creating Python Data Server In-Reply-To: <96t999$qrl$1@gaia.intranet.cdegroot.com>; from cg@gaia.intranet.cdegroot.com on Tue, Feb 20, 2001 at 09:18:49AM +0100 References: <96t999$qrl$1@gaia.intranet.cdegroot.com> Message-ID: <20010220101928.A14400@freedom.puma-ag.com> Cees de Groot wrote: > dsavitsk said: > >This is sort of Python related, that is, if I write it, it will be in > >Python. I am really wondering if this exists, or is even practical ... > > > Well, it seems that PostgreSQL has the concept of pluggable back-end > languages although only Tcl and Perl have been implemented yet. For > this sort of projects, I'd recommend PostgreSQL over MySQL: PG is a > real RDBMS and is object-relational (so you can do subclassing etcetera > in the database instead of in some O/R mapping layer). MySQL is fun > for storing user accounts and cookies behind websites, but not for > serious data management. Agreed. PostGreSQL is the best database I've ever used, and it keeps getting better. It manages many hundreds of queries per second on my laptop... and it doesn't take a DBA to install it. (Hint: rpm) -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 aleaxit at yahoo.com Tue Feb 20 11:39:43 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 20 Feb 2001 11:39:43 +0100 Subject: Creating Python Data Server References: Message-ID: <96thhf0rc1@news2.newsguy.com> "dsavitsk" wrote in message news:jQkk6.117367$Ch.20710042 at newsrump.sjc.telocity.net... [snip] > i though about using apache/mod_python, but i want the user to feel like > they are running things on their computer, that is, like all of the > processes are local and the client and server are the same. Thus http > doesn't seem to be what i want. Why not? It's an excellent protocol for your needs, and you'll find lots of infrastructure already in place for it. To give your user the illusion they're running things locally, you may just need to build a custom *client* -- which you can do _after_ you've got the basic functionality running. Easy-as-pie. > I'll write the interface in VB or Delphi, but I want all of the processing > to take place on the big fast server. A Telnet-like system would be great, Nothing will stop you from writing the ('a'?) custom-client in VB or Delphi at some point. But HTTP is a better protocol than Telnet for your needs -- and even if it weren't, just the infrastructure issues might justify it anyway (think firewalls and proxies, etc, etc). Alex From joseamartin at venmex.com Tue Feb 20 13:18:17 2001 From: joseamartin at venmex.com (Jose Martin) Date: Tue, 20 Feb 2001 08:18:17 -0400 Subject: Creating Python Data Server References: Message-ID: Do you Know Gadfy, a SQL Client Server Database writen in python ? Look at the vault of parnasus. Works fine. dsavitsk escribi? en el mensaje de noticias jQkk6.117367$Ch.20710042 at newsrump.sjc.telocity.net... > This is sort of Python related, that is, if I write it, it will be in > Python. I am really wondering if this exists, or is even practical ... > > I am trying to set up client/server system like a database server with > stored procedures and what not where the procedures are written in python > (or any other language), live on the server, and that isn't tied to any > particular database. So the user would press a button on the interface > sending a signal to the server which would instantiate whatever objects were > necessary on the server, process the data, and then return the data to the > client. > > i though about using apache/mod_python, but i want the user to feel like > they are running things on their computer, that is, like all of the > processes are local and the client and server are the same. Thus http > doesn't seem to be what i want. > > I'll write the interface in VB or Delphi, but I want all of the processing > to take place on the big fast server. A Telnet-like system would be great, > but the win32 style interface with all of the prerequisite buttons and > progress bars is essential. Also, I would rather use UNIX/MySQL on the > server, but i don't want the users to know that. > > Does this sound like a reasonable project? and is there anything similar or > does anyone have any better ideas? > > thanks, > doug > > > From pbrian at demon.net Tue Feb 20 13:46:49 2001 From: pbrian at demon.net (Paul Brian) Date: Tue, 20 Feb 2001 12:46:49 -0000 Subject: Creating Python Data Server References: Message-ID: <982673034.5300.0.nnrp-10.c1c3e154@news.demon.co.uk> May I say that unless there is an extremely strong reason for doing anymore than presentation like work on the client that you do use apache/mod_pyhton (or PSP or PHP anything else). In general, the rule of thumb that puts data and business logic on central servers and presentation on web servers or client is a good one. And breaking that rule in the first stages of design does not sound good. If you want the look and feel of a intelligent client rather than bare web pages however, perhaps the following solutions might make sense: -pickle python dictionary objects that represent the results table, squirt as data through http, unpickle at the client end. -Alternatively use apache to create results tables that it delviers as plain text (XML?) Then create a client that does what you want, (staying with Python) using PyQT and QTdesigner (almost as easy as VB), or JPython and Swing (if you know this - I have not yet found a neat way of WYSIWYG'ing Swing and still being able to use jPython with it - any ideas anyone? However may I suggest that you concentrate on the functionality that your users desire first, and put it into plain boring web pages using apache/mod_python / PHP/JSP. That way you a) avoid the big management headaches of maintaining uptodate versions on all clients (I am asuming this is a inhouse business problem) b) Avoid big investment in gui design before functionality is all fixed c) can change functionality faster d) surface product quicker e) can add in authentication and authorisation far more easly.... f) can throw it away if it is just completely not wanted. good luck "dsavitsk" wrote in message news:jQkk6.117367$Ch.20710042 at newsrump.sjc.telocity.net... > This is sort of Python related, that is, if I write it, it will be in > Python. I am really wondering if this exists, or is even practical ... > > I am trying to set up client/server system like a database server with > stored procedures and what not where the procedures are written in python > (or any other language), live on the server, and that isn't tied to any > particular database. So the user would press a button on the interface > sending a signal to the server which would instantiate whatever objects were > necessary on the server, process the data, and then return the data to the > client. > > i though about using apache/mod_python, but i want the user to feel like > they are running things on their computer, that is, like all of the > processes are local and the client and server are the same. Thus http > doesn't seem to be what i want. > > I'll write the interface in VB or Delphi, but I want all of the processing > to take place on the big fast server. A Telnet-like system would be great, > but the win32 style interface with all of the prerequisite buttons and > progress bars is essential. Also, I would rather use UNIX/MySQL on the > server, but i don't want the users to know that. > > Does this sound like a reasonable project? and is there anything similar or > does anyone have any better ideas? > > thanks, > doug > > > From dsavitsk at e-coli.net Wed Feb 21 00:11:18 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Tue, 20 Feb 2001 17:11:18 -0600 Subject: Creating Python Data Server References: <982673034.5300.0.nnrp-10.c1c3e154@news.demon.co.uk> Message-ID: "Paul Brian" wrote in message news:982673034.5300.0.nnrp-10.c1c3e154 at news.demon.co.uk... > May I say that unless there is an extremely strong reason for doing anymore > than presentation like work on the client that you do use apache/mod_pyhton > (or PSP or PHP anything else). > > In general, the rule of thumb that puts data and business logic on central > servers and presentation on web servers or client is a good one. And > breaking that rule in the first stages of design does not sound good. I'm not meaning to break it, in fact, i am trying to use what i have to extend it as much as i can. I can use MySQL or Postgres for some stuff, but i have to produce results in MS Access tables or i'll get in trouble. thus making access look like a db server would be beneficial. I have argued for a change for 2 years to no avail. > If you want the look and feel of a intelligent client rather than bare web > pages however, perhaps the following solutions might make sense: > > -pickle python dictionary objects that represent the results table, squirt > as data through http, unpickle at the client end. > -Alternatively use apache to create results tables that it delviers as plain > text (XML?) The biggest problem, and it may not really be a big one, is that some commands take a long time to run. It is a test scoring program, and generating the statistics can take a while (obviously i'll write this stuff in something that isn't as slow as python). Thus I need the server to return buffered data so that the client can update progress settings. assuming apache/mod_python/mod_otherstuff can do this then it shouldn't be too tough. > > Then create a client that does what you want, (staying with Python) using > PyQT and QTdesigner (almost as easy as VB), or JPython and Swing (if you > know this - I have not yet found a neat way of WYSIWYG'ing Swing and still > being able to use jPython with it - any ideas anyone? > > However may I suggest that you concentrate on the functionality that your > users desire first, and put it into plain boring web pages using > apache/mod_python / PHP/JSP. That way you > a) avoid the big management headaches of maintaining uptodate versions on > all clients (I am asuming this is a inhouse business problem) > b) Avoid big investment in gui design before functionality is all fixed > c) can change functionality faster > d) surface product quicker This project is in essence rewriting a VB program from a while back. There are certain necessary additions/problems with the original that make it easier to start over. I do have the luxury of not needing to produce incremental versions, and especially not needing to install on more than 1 computer until it is working. Also, i have found that if I make VB interfaces that are dynamic and configure themselves with registry/text file settings it makes updates easier as only major overhalls need reinstallation. Thanks for all of the suggestions. doug From db3l at fitlinxx.com Fri Feb 23 03:35:41 2001 From: db3l at fitlinxx.com (David Bolen) Date: 22 Feb 2001 21:35:41 -0500 Subject: Creating Python Data Server References: Message-ID: "dsavitsk" writes: > I am trying to set up client/server system like a database server with > stored procedures and what not where the procedures are written in python > (or any other language), live on the server, and that isn't tied to any > particular database. So the user would press a button on the interface > sending a signal to the server which would instantiate whatever objects were > necessary on the server, process the data, and then return the data to the > client. It sounds like a good fit for a straight forward RPC (remote procedure call) or remote component based sort of setup. Have you considered doing your client in Python as well (you could use wxPython or Tkinter for a GUI)? If so, you should definitely look at XML-RPC. It's an awfully simple (yet powerful) mechanism for making remote calls, and absolutely dirt simple if both ends are in Python. Support also exists for other clients (including a COM client that could be used from VB). See http://www.xmlrpc.org and http://www.pythonware.com/products/xmlrpc for some more info. Or, if you definitely want to use VB/Delphi for the client, you could consider implementing your server procedures as COM objects in Python (with the win32all package), and letting VB access them as it would other system components - using DCOM in this case for a remote invocation. You mentioned in a later post about wanting to have status on the client over the course of execution - that's really going to come into play when you define what the remote calls are and/or your component interface. You could have one call to trigger the overall procedure, but just return immediately after starting it, with a handle that you could use later to check back. Or you could even multi-thread your client, and let the server issue its own callback remote calls during course of execution to the client. > i though about using apache/mod_python, but i want the user to feel like > they are running things on their computer, that is, like all of the > processes are local and the client and server are the same. Thus http > doesn't seem to be what i want. Don't mistake HTTP (the protocol) with clients such as browsers that may use the protocol. While it's got warts, HTTP is often a fine choice as the basic transport mechanism between clients and servers, particularly as it has a big advantage in getting through firewalls or other security precautions that are often locked down against anything besides "web" access. Besides, at its root, it's just a TCP stream with some header information, which is fine. XML-RPC defaults to using HTTP as its own transport, but its all beneath the covers, so your client/presentation module can do anything you want. -- -- 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 s2mdalle at titan.vcu.edu Tue Feb 20 03:51:16 2001 From: s2mdalle at titan.vcu.edu (David Allen) Date: Tue, 20 Feb 2001 02:51:16 GMT Subject: Tkinter Menu.add_checkbutton() Message-ID: Just a quick question: When I add a checkbutton to a menu: v = BooleanVar() v.set(FALSE) foomenu.add_checkbutton(label="Option Foo", variable=v, showcolor='#00FF00', command=some_callback) The checkbutton always displays as 'off' regardless of the value of 'v'. See, depending on the value of 'v', I'd like to have it start as on if v is true. I've also tried invoke()'ing this item, since in the Tkinter class reference, that says it's the same thing as the user clicking on it, but that doesn't work either. Any suggestions on how to make this start up as checked? The default is unchecked. -- David Allen http://opop.nols.com/ ---------------------------------------- A language that doesn't affect the way you think about programming is not worth knowing. From matt at mondoinfo.com Tue Feb 20 04:57:27 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Tue, 20 Feb 2001 03:57:27 GMT Subject: Tkinter Menu.add_checkbutton() References: Message-ID: On Tue, 20 Feb 2001 02:51:16 GMT, David Allen wrote: >Just a quick question: > >When I add a checkbutton to a menu: [. . .] >The checkbutton always displays as 'off' regardless of the value of >'v'. See, depending on the value of 'v', I'd like to have it start >as on if v is true. I'm not sure what's going on with your code, but setting a checkbox to on at the start works for me. One thing that I was confused by is that the default action is to toggle the state of the checkbox: it's not necessary to do that in a callback. But that's probably not the problem that you're having. I'll append a minimal example that seems to work for me. BTW, Fredrik Lundh's excellent An Introduction to Tkinter is very useful. I almost always have a copy open when I'm doing Tkinter programming. It's at: http://www.pythonware.com/library/an-introduction-to-tkinter.htm And I find Pmw's menus easier to deal with than the native Tkinter kind. Pmw is at: http://pmw.sourceforge.net/ Regards Matt import sys from Tkinter import * class mainWin: def __init__(self): self.root=Tk() self.toggleVar=IntVar() self.toggleVar.set(1) self.createWidgets() return None def createWidgets(self): menuBar=Menu(self.root) fileMenu=Menu(menuBar, tearoff=0) fileMenu.add_checkbutton(label="Toggle",variable=self.toggleVar) fileMenu.add_command(label="Quit", command=self.quitCB) menuBar.add_cascade(label="File",menu=fileMenu) self.root.config(menu=menuBar) return None def quitCB(self): sys.exit(0) def main(): mainWin() mainloop() if __name__== '__main__': main() From m_hussain at trillium.com Tue Feb 20 06:15:23 2001 From: m_hussain at trillium.com (Hussain, Mohammed) Date: Mon, 19 Feb 2001 21:15:23 -0800 Subject: Info requested Message-ID: Hi, I am a new user of Python and would like to know whether there is any useful website which gives a brief but detailed description of Python. Thanks in advance. Thanks and Regards, Mohd Azaz Hussain From pplumlee at omnigon.com Tue Feb 20 06:52:15 2001 From: pplumlee at omnigon.com (Phlip) Date: 20 Feb 2001 05:52:15 GMT Subject: Info requested References: Message-ID: <3A920590.EFDB3EE9@omnigon.com> "Hussain, Mohammed" wrote: > > Hi, > I am a new user of Python and would like to know whether there is any useful > website which gives a brief but detailed description of Python. Well, the Python community is extremely cryptic and obscure, so I'm certain there are no links that say "tutorial" on this site: http://www.python.org Or even this one: http://www.google.com -- Phlip phlip_cpp at my-deja.com ============== http://phlip.webjump.com ============== -- Founding member of NuGWa - Nudists for Global Warming -- From eq3pvl at eq.uc.pt Tue Feb 20 14:05:33 2001 From: eq3pvl at eq.uc.pt (Pedro Vale Lima) Date: Tue, 20 Feb 2001 13:05:33 +0000 Subject: Info requested References: Message-ID: <3A926B9D.6BEF3A75@eq.uc.pt> "Hussain, Mohammed" wrote: > Hi, > I am a new user of Python and would like to know whether there is any useful > website which gives a brief but detailed description of Python. > Thanks in advance. > > Thanks and Regards, > Mohd Azaz Hussain www.python.org and also diveintopython.org regards pedro From grante at visi.com Tue Feb 20 20:02:03 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 20 Feb 2001 19:02:03 GMT Subject: Info requested References: Message-ID: In article , Hussain, Mohammed wrote: >I am a new user of Python and would like to know whether there is any useful >website which gives a brief but detailed description of Python. >Thanks in advance. The computing world has become so web-centric that it absolutely stuns me when somebody finds comp.lang.python but can't find www.python.org. When looking for info on XYZ, I assume that everybody naturally starts with www.XYZ.[org|com|net]. Anyway, the web pages you're looking for is http://www.python.org/doc/Summary.html http://www.python.org/doc/current/tut/tut.html -- Grant Edwards grante Yow! Imagine--a WORLD at without POODLES... visi.com From AshKapur at worldnet.att.net Tue Feb 20 07:48:05 2001 From: AshKapur at worldnet.att.net (Ash Kapur) Date: Tue, 20 Feb 2001 06:48:05 GMT Subject: Static DLL Message-ID: Hi, I have an Win32 app that already loads a static dll (e.g. links with the .lib, so autoloads the dll when it starts). Using Dev Studio on 98. I am trying to embed python20 into this app, so that I can use it to call some of the functions in the dll to test them. The embedding went smoothly, I can pass command lines and file names to python and it executes them. I used SWIG to create wrappers for some of the dll functions I want to call, that also went quite smoothly. The problem is when I do an "import dllname" it seems to load a new copy of the dll, (or at least there is a second set of static data at different places, and breakpoints etc do not work when the code is called from python). Does anyone know of any way I can get python to know of my dll without doing an import, so that the already-loaded dll is used ? It would be a pain to have to go back to my existing app and change the architecture, as the dll exports lots of functions. Thanks in advance Ash Kapur From fredrik at pythonware.com Tue Feb 20 08:45:41 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 20 Feb 2001 07:45:41 GMT Subject: Safe to change SRE config to allow more than 100 groups? References: <48b39tsc9eivp3fqeqe6pd5hn3fj3h148a@4ax.com> Message-ID: Aaron Freeman wrote: > I have an egregiously long regex, and I'm getting "AssertionError: > sorry, but this version only supports 100 named groups" from SRE. > > After looking at SRE_Compile.py, I found where this is hardcoded to > 100 (line 367), but but couldn't figure out why this was the arbitrary > limitation. > > I tried changing it to 1000, and everything seemed to work fine I doubt you ran it with 1000 named groups... if you do, you'll overrun buffers inside the _sre engine. look in the C sources for details. > I also changed the maxcashe size in sre.py to 1000 if you have that many individual patterns, you're probably better off compiling them in your script. Cheers /F From macky at edsamail.com Tue Feb 20 09:33:53 2001 From: macky at edsamail.com (Macky) Date: Tue, 20 Feb 2001 16:33:53 +0800 Subject: subsribe Message-ID: <000b01c09b17$db7e1440$5764a8c0@edsamail.com> ---------------------------------------------------------------------- The information contained in this message (including any attachments) is confidential and intended solely for the attention and use of the named addressee(s). It must not be copied, distributed nor disclosed to any person. If you are not the intended recipient, please delete it from your system and notify sender immediately. Any disclosure, copying or distribution thereof or any action taken or omitted to be taken in reliance thereon is prohibited and may be unlawful. ---------------------------------------------------------------------- From macky at edsamail.com Tue Feb 20 10:34:07 2001 From: macky at edsamail.com (Macky) Date: Tue, 20 Feb 2001 17:34:07 +0800 Subject: Python for AOLServer Message-ID: <003a01c09b20$45a872e0$5764a8c0@edsamail.com> Im installing Python for AOLServer."PyWX" and encountered this error in # make all c++ -c s_pywx.cc -DAOLSERVER_VERSION_3_2 -I. -I/usr/local/include/python2.0 -g -O2 -o ns_pywx.o In file included from ns_pywx.cc:64: ns_pywx.hh:36: Python.h: No such file or directory In file included from ns_pywx.cc:65: PyWX_buffer.hh:68: Python.h: No such file or directory PyWX_buffer.hh:69: compile.h: No such file or directory PyWX_buffer.hh:70: eval.h: No such file or directory PyWX_buffer.hh:71: structmember.h: No such file or directory make: *** [ns_pywx.o] Error 1 AOLServer 3.2 INSTALLED COMPONENTS. SWIG 1.1 Python 2.0 any suggestion and/or comments will be highly appreciated.. ---------------------------------------------------------------------- The information contained in this message (including any attachments) is confidential and intended solely for the attention and use of the named addressee(s). It must not be copied, distributed nor disclosed to any person. If you are not the intended recipient, please delete it from your system and notify sender immediately. Any disclosure, copying or distribution thereof or any action taken or omitted to be taken in reliance thereon is prohibited and may be unlawful. ---------------------------------------------------------------------- From fredrik at pythonware.com Tue Feb 20 10:58:26 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 20 Feb 2001 09:58:26 GMT Subject: Python for AOLServer References: Message-ID: <6drk6.14593$Qb7.2329730@newsb.telia.net> Macky wrote: > Im installing Python for AOLServer."PyWX" and encountered this error in > > # make all > c++ -c > s_pywx.cc -DAOLSERVER_VERSION_3_2 -I. -I/usr/local/include/python2.0 -g -O2 > -o ns_pywx.o > In file included from ns_pywx.cc:64: > ns_pywx.hh:36: Python.h: No such file or directory > In file included from ns_pywx.cc:65: > PyWX_buffer.hh:68: Python.h: No such file or directory > PyWX_buffer.hh:69: compile.h: No such file or directory > PyWX_buffer.hh:70: eval.h: No such file or directory > PyWX_buffer.hh:71: structmember.h: No such file or directory > make: *** [ns_pywx.o] Error 1 > > AOLServer 3.2 > INSTALLED COMPONENTS. > SWIG 1.1 > Python 2.0 > > any suggestion and/or comments will be highly appreciated.. $ ls /usr/local/include/python2.0 $ more /usr/local/include/python2.0/Python.h Cheers /F From mhagger at alum.mit.edu Tue Feb 27 05:15:23 2001 From: mhagger at alum.mit.edu (Michael Haggerty) Date: Tue, 27 Feb 2001 04:15:23 GMT Subject: Python for AOLServer References: Message-ID: "Macky" writes: > Im installing Python for AOLServer."PyWX" and encountered this error in > > # make all > c++ -c > s_pywx.cc -DAOLSERVER_VERSION_3_2 -I. -I/usr/local/include/python2.0 -g -O2 > -o ns_pywx.o > In file included from ns_pywx.cc:64: > ns_pywx.hh:36: Python.h: No such file or directory You might have to edit the Makefile (the autoconfiguration of PyWX is not so good.) Perhaps the -I include file is incorrect. Make sure that you include the directory that includes the Python include files like Python.h. If the Python include files are not present on your system at all, it is possible that you don't have all of Python installed. Maybe there is a "python-devel" package or some such that you need to install. Michael -- Michael Haggerty mhagger at alum.mit.edu From macky at edsamail.com Tue Feb 20 10:48:41 2001 From: macky at edsamail.com (Macky) Date: Tue, 20 Feb 2001 17:48:41 +0800 Subject: Newsgroup Message-ID: <005401c09b22$4eb8c860$5764a8c0@edsamail.com> Im using OUTLOOK EXPRESS to read news group.. and its not the easy to use... If im going to add newsgroup on OUTLOOK it alays asks for News (NNTP) Server? ---------------------------------------------------------------------- The information contained in this message (including any attachments) is confidential and intended solely for the attention and use of the named addressee(s). It must not be copied, distributed nor disclosed to any person. If you are not the intended recipient, please delete it from your system and notify sender immediately. Any disclosure, copying or distribution thereof or any action taken or omitted to be taken in reliance thereon is prohibited and may be unlawful. ---------------------------------------------------------------------- From ujen at nino.ru Tue Feb 20 10:57:36 2001 From: ujen at nino.ru (ujen) Date: 20 Feb 2001 09:57:36 GMT Subject: Font size in IDLE Message-ID: <01c09b23$99332380$3201a8c0@ws9201> Hi there. How to change font size in IDLE (Python 1.5.2 Linux version ) Thanks Eugene Tsymbalov, Russia From bryan at eevolved.com Tue Feb 20 13:49:30 2001 From: bryan at eevolved.com (Bryan Mongeau) Date: Tue, 20 Feb 2001 12:49:30 GMT Subject: Font size in IDLE References: <01c09b23$99332380$3201a8c0@ws9201> Message-ID: ujen wrote: > Hi there. > > How to change font size in IDLE (Python 1.5.2 Linux version ) > > > > Thanks > > Eugene Tsymbalov, Russia grep through the source code looking for the word "font". Once you find it, change it. -- <==================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. http://www.eevolved.com <==================================> "Reality is merely an illusion, albeit a very persistent one."-- Einstein From glenfant at equod.com.nospam Tue Feb 20 15:12:47 2001 From: glenfant at equod.com.nospam (Gillou) Date: Tue, 20 Feb 2001 15:12:47 +0100 Subject: Font size in IDLE References: <01c09b23$99332380$3201a8c0@ws9201> Message-ID: <96ttlh$8rp$1@reader1.imaginet.fr> Yes... the default window font for idle is ugly and not legible with Linux Edit EditorWindow.py, search for this: ----- ... if sys.platform[:3] == 'win': text['font'] = ("lucida console", 8) ... ----- And change it against this: ----- ... # if sys.platform[:3] == 'win': # Works with others than Windows text['font'] = ("lucidatypewriter", 12) # pretty with a 100 pix/inch display ... ----- Test your new font setting for IDLE as "root" to have this effective (users have no write access to /usr/lib... so they use the "old" EditorWindow.pyc). That's all! "Bryan Mongeau" a ?crit dans le message news: uJtk6.284555$JT5.9794163 at news20.bellglobal.com... > ujen wrote: > > > Hi there. > > > > How to change font size in IDLE (Python 1.5.2 Linux version ) > > > > > > > > Thanks > > > > Eugene Tsymbalov, Russia > > grep through the source code looking for the word "font". Once you find it, > change it. > -- > <==================================> > Bryan Mongeau > Lead Developer, Director > eEvolved Real-Time Technologies Inc. > http://www.eevolved.com > <==================================> > > "Reality is merely an illusion, albeit a very persistent one."-- Einstein > From gregj at pobox.com Wed Feb 21 08:57:50 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Wed, 21 Feb 2001 07:57:50 GMT Subject: Font size in IDLE References: <01c09b23$99332380$3201a8c0@ws9201> Message-ID: <2yKk6.452424$U46.13427774@news1.sttls1.wa.home.com> "ujen" wrote in message news:01c09b23$99332380$3201a8c0 at ws9201... > > How to change font size in IDLE (Python 1.5.2 Linux version ) Look in the file config.txt in the directory IDLE is in. -- Greg Jorgensen PDXperts Portland, Oregon, USA gregj at pobox.com From lorenzo at sancho.ccd.uniroma2.it Tue Feb 20 11:10:15 2001 From: lorenzo at sancho.ccd.uniroma2.it (lorenzo at sancho.ccd.uniroma2.it) Date: Tue, 20 Feb 2001 10:10:15 -0000 Subject: Drew's sslserv support into 2.1? Message-ID: <96tfq7+jjhk@eGroups.com> On Sep 22, 2000 Drew Csillag posted a patch adding an sslserver object to the socket module. Since it could be (very) useful, even though we all know about the shortcomings of such basic support when confronted with a complete support such as that which could come from a real SSL module, I hope the patch would not be forgot, and get in before 2.1 beta/freeze. A nice time to all of the readers. Lorenzo From bryan at eevolved.com Tue Feb 20 11:48:54 2001 From: bryan at eevolved.com (Bryan Mongeau) Date: Tue, 20 Feb 2001 10:48:54 GMT Subject: Drew's sslserv support into 2.1? References: Message-ID: lorenzo at sancho.ccd.uniroma2.it wrote: > On Sep 22, 2000 Drew Csillag posted a patch adding an sslserver > object to the socket module. Since it could be (very) useful, even > though we all know about the shortcomings of such basic support > when confronted with a complete support such as that which could > come from a real SSL module, I hope the patch would not be forgot, > and get in before 2.1 beta/freeze. > > A nice time to all of the readers. > > Lorenzo > > Hi Lorenzo, I am unfamiliar with the patch you mention. However, if it is anything like Brian Gallew's patch for 2.0, it is based on OpenSSL/SSLeay. Granted the functionality is nice, but do all users want to include such a large external library? Weigh the price of the code bloat vs. the amount of people that will actually use it and I'm sure you'll conclude its status as a patch is justified. Additionally, SSL socket support is already a trivial matter with extensions like amkCrypto and M2Crypto. Not to mention export restrictions should it be incorporated into the code. However, I would like to take a look at it. Do you have a link? Regards, -- <==================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. http://www.eevolved.com <==================================> "Scientific beliefs are supported by evidence, and they get results. Myths and faiths are not and do not" -- Richard Dawkins From drew.csillag at starmedia.net Tue Feb 20 18:09:25 2001 From: drew.csillag at starmedia.net (Drew Csillag) Date: Tue, 20 Feb 2001 12:09:25 -0500 Subject: Drew's sslserv support into 2.1? In-Reply-To: ; from bryan@eevolved.com on Tue, Feb 20, 2001 at 10:48:54AM +0000 References: Message-ID: <20010220120925.D911@naxos.skunk.org> It has been *rightly* rejected by the BDFL for the following reasons: * M2Crypto does a *much* better job * If your server key is encrypted (it should be), it pops up a password prompt every time a connection is sslserv()'d which, in a word, sucks. M2Crypto's Homepage is http://mars.post1.com/home/ngps/m2/. Check it out. Drew On Tue, Feb 20, 2001 at 10:48:54AM +0000, Bryan Mongeau wrote: > lorenzo at sancho.ccd.uniroma2.it wrote: > > > On Sep 22, 2000 Drew Csillag posted a patch adding an sslserver > > object to the socket module. Since it could be (very) useful, even > > though we all know about the shortcomings of such basic support > > when confronted with a complete support such as that which could > > come from a real SSL module, I hope the patch would not be forgot, > > and get in before 2.1 beta/freeze. > > > > A nice time to all of the readers. > > > > Lorenzo > > > > > > Hi Lorenzo, > > I am unfamiliar with the patch you mention. However, if it is anything like > Brian Gallew's patch for 2.0, it is based on OpenSSL/SSLeay. Granted the > functionality is nice, but do all users want to include such a large > external library? Weigh the price of the code bloat vs. the amount of > people that will actually use it and I'm sure you'll conclude its status as > a patch is justified. Additionally, SSL socket support is already a trivial > matter with extensions like amkCrypto and M2Crypto. Not to mention export > restrictions should it be incorporated into the code. > > However, I would like to take a look at it. Do you have a link? > > Regards, > -- > <==================================> > Bryan Mongeau > Lead Developer, Director > eEvolved Real-Time Technologies Inc. > http://www.eevolved.com > <==================================> > > "Scientific beliefs are supported by evidence, and they get results. Myths > and faiths are not and do not" -- Richard Dawkins > -- Drew Csillag From akuchlin at mems-exchange.org Tue Feb 20 18:07:16 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 20 Feb 2001 12:07:16 -0500 Subject: Drew's sslserv support into 2.1? References: Message-ID: <3dg0h99tbv.fsf@ute.cnri.reston.va.us> lorenzo at sancho.ccd.uniroma2.it writes: > come from a real SSL module, I hope the patch would not be forgot, > and get in before 2.1 beta/freeze. This refers to patch #101647, which was marked 'Rejected'. http://sourceforge.net/patch/?func=detailpatch&patch_id=101647&group_id=5470 Installing and using M2Crypto is a better idea than using the poor support in the socket module. --amk From aleaxit at yahoo.com Tue Feb 20 11:27:11 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 20 Feb 2001 11:27:11 +0100 Subject: ANOVA and logistic regression? Message-ID: <96tgpt0qj8@news2.newsguy.com> Can anybody recommend C-coded Python extensions for doing ANOVA, and logistic regression, on largish data sets, in a reasonably speedy way? Pure-Python solutions also welcome, but I suspect they might be a bit slow. I need to run this stuff with Python 2.0 on a Win32 box (and have no problem building extensions from sources, although I'd rather not have to tweak/port the sources if possible -- but it won't kill me if I do have to do that), but it would be nice if the solution was cross-platform and redistributable (GPL, LGPL, OpenSource, etc, preferred, but free-as-in-free-beer is the key issue here:-). Answers most welcome on comp.lang.python, or directly in my mailbox (if anybody asks, I'll summarize any answers received in mail -- I realize this marks me as a NetNews dinosaur, but this used to be the correct protocol once:-). Advthanksance... Alex From reuter at Uni-Hohenheim.DE Tue Feb 20 14:59:42 2001 From: reuter at Uni-Hohenheim.DE (Daniel Reuter) Date: Tue, 20 Feb 2001 14:59:42 +0100 (MET) Subject: ANOVA and logistic regression? In-Reply-To: <96tgpt0qj8@news2.newsguy.com> Message-ID: Hello there, I have a stats module, which can do at least ANOVA, found it at the Vaults of Parnassus (check the mathematics section), but it's plain python, and I don't know how well it behaves on large datasets. You might try it out. Regards, Daniel On Tue, 20 Feb 2001, Alex Martelli wrote: > Can anybody recommend C-coded Python extensions for doing > ANOVA, and logistic regression, on largish data sets, in a > reasonably speedy way? Pure-Python solutions also welcome, > but I suspect they might be a bit slow. I need to run this > stuff with Python 2.0 on a Win32 box (and have no problem > building extensions from sources, although I'd rather not > have to tweak/port the sources if possible -- but it won't > kill me if I do have to do that), but it would be nice if > the solution was cross-platform and redistributable (GPL, > LGPL, OpenSource, etc, preferred, but free-as-in-free-beer > is the key issue here:-). > > Advthanksance... > > > Alex From janne at oops.nnets.fi Tue Feb 20 23:56:43 2001 From: janne at oops.nnets.fi (Janne Sinkkonen) Date: 21 Feb 2001 00:56:43 +0200 Subject: ANOVA and logistic regression? References: <96tgpt0qj8@news2.newsguy.com> Message-ID: "Alex Martelli" writes: > Can anybody recommend C-coded Python extensions for doing > ANOVA, and logistic regression, on largish data sets, in a > reasonably speedy way? I have a "fast enough" Numeric Python implementation of basic (and regularized, i.e. a gaussian prior for the parameters) log-linear regression. Only one binary depedent variable. -- Janne From thomas at cintra.no Tue Feb 20 12:08:59 2001 From: thomas at cintra.no (Thomas Weholt) Date: Tue, 20 Feb 2001 12:08:59 +0100 Subject: Any experience with 4Suite Server?? Message-ID: Hi, I need to store alot of xml-documents in some sort of structure that implements automatic indexing of the contents of the documents, fast searches and some way of producing reports, preferrably using XSLT to transform the stored XML. Looked at 4Suite Server but I don't get a fully understanding of how it works, or if it could fit my needs. I'm looking for views on this package ( 4Suite Server ), even if they don't relate to my specific problem. Thomas From rich_somerfield at tertio.com Tue Feb 20 12:15:59 2001 From: rich_somerfield at tertio.com (Rich Somerfield) Date: Tue, 20 Feb 2001 11:15:59 -0000 Subject: Problems with Tkinter / Python - displaying JPEG. Message-ID: Hi, I had Python 1.5 and Pil 0.3 as part of my Linux (SuSE6.4) installation, and was trying to execute a Python Script that loaded and displayed images. [I use the Python1.5 distribution from PythonWare under windows, but wanted to do development under Linux instead.] However I encountered a problem when I was trying to display a JPEG file (i have indicated the relavent line). thebackgroundimage = thebackgroundimage.resize((canvaswidth, canvasheight)) ******* thebackgroundimage = ImageTk.PhotoImage(thebackgroundimage) ******** thebackground = arena.create_image(0,0,image=thebackgroundimage) middlex = canvaswidth middley = canvasheight locationx = middlex / 2 locationy = middley / 2 arena.move(thebackground, locationx, locationy) The interpreter indicated that the parameter "PyPhotoImage" was not set and a call was returning the wrong type (string / int). I thought this might be a problem with an earlier version of PIL / Python / Tkinter that didnt support JPEG files. So I downloaded Python2.0 and PIL 1.1.1. Compiled them (after messing with the Makefiles), checked that I had got the JPEG libraries (libjpeg). However I get exactly the same error message. Any ideas where the problem is coming from? Pil / Tkinter / Tk? Regards Rich From mrq at for.mat.bham.ac.uk Tue Feb 20 12:36:01 2001 From: mrq at for.mat.bham.ac.uk (Martyn Quick) Date: Tue, 20 Feb 2001 11:36:01 +0000 Subject: Calling a sequence of commands with a sequence of Tkinter buttons Message-ID: I'm trying to create a number of buttons each of which has a similar sort of command attached to it. Obviously the following doesn't work since I'm attaching a called function to the button rather than the function to call. Can anyone tell me the correct way to do it? (Equally obviously, I could create a different function for each button, but this seems lengthy for a large number of buttons). Thanks Martyn MY ATTEMPT: from Tkinter import * def f(i): # Typically I'll have a more complicated function print i # but this is just for illustration root = Tk() buttons = [] # initialize list to contain the button widgets for i in range(20): buttons.append(Button(root,text="Button "+`i`,command=f(i))) buttons[i].pack() # This doesn't work - it just prints 1,2,..,20 down the screen # immediately, since f(i) is called at the creation of the button. -------------------------------------------------------- Dr. Martyn Quick (Research Fellow in Pure Mathematics) University of Birmingham, Edgbaston, Birmingham, UK. http://www.mat.bham.ac.uk/M.R.Quick From stephen_purcell at yahoo.com Tue Feb 20 14:10:59 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 20 Feb 2001 14:10:59 +0100 Subject: Calling a sequence of commands with a sequence of Tkinter buttons In-Reply-To: ; from mrq@for.mat.bham.ac.uk on Tue, Feb 20, 2001 at 11:36:01AM +0000 References: Message-ID: <20010220141058.A16164@freedom.puma-ag.com> Martyn Quick wrote: > MY ATTEMPT: > > from Tkinter import * > > ... > > for i in range(20): > buttons.append(Button(root,text="Button "+`i`,command=f(i))) > buttons[i].pack() > # This doesn't work - it just prints 1,2,..,20 down the screen > # immediately, since f(i) is called at the creation of the button. Right, you found the problem; f() is called immediately. Instead, give Tkinter a new function that takes no parameters and that can be called later: for i in range(20): def f_i(j=i): f(j) buttons.append(Button(root,text="Button "+`i`,command=f_i)) buttons[i].pack() Of, if you prefer: for i in range(20): buttons.append(Button(root,text="Button "+`i`, command=lambda j=i, f(j))) buttons[i].pack() It would perhaps be neater to solve this with a callable class instance than with a default function argument: class PrintNumberAction: def __init__(self, i): self.i = i def __call__(self): print i # or whatever then: for i in range(20): action = PrintNumberAction(i) buttons.append(Button(root,text="Button "+`i`,command=action)) buttons[i].pack() Hope that helps. -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 rosemann at imkt.uni-hannover.de Wed Feb 21 09:39:40 2001 From: rosemann at imkt.uni-hannover.de (Harald Rosemann) Date: Wed, 21 Feb 2001 09:39:40 +0100 Subject: Calling a sequence of commands with a sequence of Tkinter buttons References: Message-ID: <3A937ECC.E2EF40E7@imkt.uni-hannover.de> Martyn Quick wrote: > > I'm trying to create a number of buttons each of which has a similar sort > of command attached to it. Obviously the following doesn't work since I'm > attaching a called function to the button rather than the function to > call. Can anyone tell me the correct way to do it? (Equally obviously, I > could create a different function for each button, but this seems lengthy > for a large number of buttons). > > Thanks > Martyn > > MY ATTEMPT: > > from Tkinter import * > > def f(i): # Typically I'll have a more complicated function > print i # but this is just for illustration > > root = Tk() > > buttons = [] # initialize list to contain the button widgets > > for i in range(20): > buttons.append(Button(root,text="Button "+`i`,command=f(i))) > buttons[i].pack() > # This doesn't work - it just prints 1,2,..,20 down the screen > # immediately, since f(i) is called at the creation of the button. > > > -------------------------------------------------------- > Dr. Martyn Quick (Research Fellow in Pure Mathematics) > University of Birmingham, Edgbaston, Birmingham, UK. > http://www.mat.bham.ac.uk/M.R.Quick You may use a "lambda expression". Something like the following will work. def show_ind(i, event=None): print i ... my_tst[i] = Tkinter.Frame(zzz, ....) my_tst[i].pack() .... my_but[i] = Tkinter.Button(my_tst[i], text = ".....", state = status) my_but[i].pack(side = Tkinter.LEFT) my_but[i].bind("", (lambda event, ind=i: show_ind(ind, event))) With best regards, Harald Rosemann -- Prof.Dr.-Ing. Harald Rosemann am Institut fuer Maschinenelemente, Konstruktionstechnik und Tribologie Universitaet Hannover From Achim.Gaedke at zpr.uni-koeln.de Tue Feb 20 13:25:28 2001 From: Achim.Gaedke at zpr.uni-koeln.de (Achim Gaedke) Date: Tue, 20 Feb 2001 13:25:28 +0100 Subject: Problem with Tkinter.PhotoImage Message-ID: <3A926237.C9BD74FE@zpr.uni-koeln.de> Hello everybody! I've tested some features of the Tkinter.Canvas and found an odd behaviour. Here is the example that works: import Tkinter r=Tkinter.Tk() c=Tkinter.Canvas(r) p=Tkinter.PhotoImage(file='linuxorg.gif') i=c.create_image(0,0,anchor=Tkinter.NW,image=p) c.pack() r.mainloop() And now a simple example that does not show the image and does not generate runtime errors. import Tkinter r=Tkinter.Tk() c=Tkinter.Canvas(r) i=c.create_image(0,0,anchor=Tkinter.NW, image=Tkinter.PhotoImage(file='linuxorg.gif')) c.pack() r.mainloop() This example is the simplest. Here is a more elaborate case (my original problem): import Tkinter class picture: def __init__(self,canvas): self.p=Tkinter.PhotoImage(file='linuxorg.gif') self.i=c.create_image(0,0,anchor=Tkinter.NW, image=self.p) r=Tkinter.Tk() c=Tkinter.Canvas(r) picture(c) c.pack() r.mainloop() This doesn't work. Just change the line picture(c) to p=picture(c). this reveals the reason of the strange behaviour. There is no reference left on Tkinter.PhotoImage, so it is destructed. But I do not think, that it should be, just because Phython is an "easy going" language with reference counters and should keep one reference, although this is held by the canvas-item image. Does someone have the same problem with this behaviour? Yours Achim From javalist at 21cn.com Tue Feb 20 14:05:11 2001 From: javalist at 21cn.com (javalist) Date: Tue, 20 Feb 2001 21:05:11 +0800 Subject: How did python handle forward declaration? Message-ID: <1251166452389.20010220210511@21cn.com> Hello python-list, in c/c++ we can use class xxx or struct xxx to forward declared what we really implement later,how python work this out? Best regards, javalist mailto:javalist at 21cn.com From stephen_purcell at yahoo.com Tue Feb 20 14:16:34 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 20 Feb 2001 14:16:34 +0100 Subject: How did python handle forward declaration? In-Reply-To: <1251166452389.20010220210511@21cn.com>; from javalist@21cn.com on Tue, Feb 20, 2001 at 09:05:11PM +0800 References: <1251166452389.20010220210511@21cn.com> Message-ID: <20010220141634.A16302@freedom.puma-ag.com> javalist wrote: > > in c/c++ we can use class xxx or struct xxx to forward declared what we really implement > later,how python work this out? > Answer 1: There is no way to do this in Python Answer 2: Write good documentation for your Python code; it has the same effect -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 ben.hutchings at roundpoint.com Tue Feb 20 23:16:15 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 20 Feb 2001 14:16:15 -0800 Subject: How did python handle forward declaration? References: Message-ID: javalist writes: > Hello python-list, > > in c/c++ we can use class xxx or struct xxx to forward > declared what we really implement later,how python work this > out? C and C++ compilers try to resolve all identifiers and type names at the point they are used, at compile time. This is a problem if you need to define two classes/structures that refer to each other. For some purposes they can accept a declaration that promises there will be a definition somewhere else (later, or in another translation unit), and that's how you deal with that need. Python is a much more dynamic language, which postpones almost all name resolution to run-time. The external things (classes, modules, etc) that a piece of code relies on just need to be defined at the time it gets to run. When you define a class, none of the code in its member functions runs, so you can define two classes/structures that refer to each other without any need for forward-declarations. You might have problems in Python if you want to define mutually- dependent modules, but then a mutually-dependent set of modules is effectively just one module and should be defined as such. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From costas at springmail.com Tue Feb 20 14:09:28 2001 From: costas at springmail.com (Costas Menico) Date: Tue, 20 Feb 2001 13:09:28 GMT Subject: Tkinter does not work with PythonWin? Message-ID: <3a926b7b.2462791@News.CIS.DFN.DE> The documentation says that Tkinter does not work with PythonWin (a great IDE for Python). Does anyone have any info about an alternative I/F? Thanks costas From chrisa at ASPATECH.COM.BR Tue Feb 20 14:18:12 2001 From: chrisa at ASPATECH.COM.BR (Chris Richard Adams) Date: Tue, 20 Feb 2001 10:18:12 -0300 Subject: Where is CASE????? Message-ID: Someone please tell me why I cannot find a CASE statement in the Python documentation index... There is a CASE isn't there??? From stephen_purcell at yahoo.com Tue Feb 20 14:48:36 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 20 Feb 2001 14:48:36 +0100 Subject: Where is CASE????? In-Reply-To: ; from chrisa@ASPATECH.COM.BR on Tue, Feb 20, 2001 at 10:18:12AM -0300 References: Message-ID: <20010220144836.A16568@freedom.puma-ag.com> Chris Richard Adams wrote: > Someone please tell me why I cannot find a CASE statement in the Python > documentation index... Because there isn't one. Use if/elif/else instead. It doesn't sting as much as you might expect. -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 chrisw at nipltd.com Tue Feb 20 15:18:03 2001 From: chrisw at nipltd.com (Chris Withers) Date: Tue, 20 Feb 2001 14:18:03 +0000 Subject: Where is CASE????? References: <20010220144836.A16568@freedom.puma-ag.com> Message-ID: <3A927C9B.29C38751@nipltd.com> Steve Purcell wrote: > > Chris Richard Adams wrote: > > Someone please tell me why I cannot find a CASE statement in the Python > > documentation index... > > Because there isn't one. > > Use if/elif/else instead. > > It doesn't sting as much as you might expect. Oh but it does ;-) cheers, Chris From dsh8290 at rit.edu Tue Feb 20 16:05:49 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 20 Feb 2001 10:05:49 -0500 Subject: Where is CASE????? In-Reply-To: <3A927C9B.29C38751@nipltd.com>; from chrisw@nipltd.com on Tue, Feb 20, 2001 at 02:18:03PM +0000 References: <20010220144836.A16568@freedom.puma-ag.com> <3A927C9B.29C38751@nipltd.com> Message-ID: <20010220100549.C18013@harmony.cs.rit.edu> On Tue, Feb 20, 2001 at 02:18:03PM +0000, Chris Withers wrote: | Steve Purcell wrote: | > | > Chris Richard Adams wrote: | > > Someone please tell me why I cannot find a CASE statement in the Python | > > documentation index... | > | > Because there isn't one. | > | > Use if/elif/else instead. | > | > It doesn't sting as much as you might expect. | | Oh but it does ;-) Why does it? CASE is little more than a special if-else ladder for integral types only. If you are simply trying to get a value, use a dictionary lookup instead. -D From phlip_cpp at my-deja.com Tue Feb 20 16:16:08 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 20 Feb 2001 15:16:08 GMT Subject: Where is CASE????? References: <20010220144836.A16568@freedom.puma-ag.com> <3A927C9B.29C38751@nipltd.com> Message-ID: <96u1no$dii@dispatch.concentric.net> Proclaimed D-Man from the mountaintops: > Why does it? CASE is little more than a special if-else ladder for > integral types only. If you are simply trying to get a value, use a > dictionary lookup instead. If you are simply trying to run a jump table, use a dictionary where the stored values are functions. Modules written after the putative 'switch' statement could enrole their functions in it without changing its code. Mr. Manners reminds the Original Gentle Poster that many things traditionally coded as 'switch' statements (typically those that repeat often in code) ought to go thru the refactor Replace Conditional with Polymorphism, per the book /Refactoring/. -- Phlip phlip_cpp at my-deja.com ============== http://phlip.webjump.com ============== -- It's a small Web, after all... -- From max at alcyone.com Tue Feb 20 18:41:17 2001 From: max at alcyone.com (Erik Max Francis) Date: Tue, 20 Feb 2001 09:41:17 -0800 Subject: Where is CASE????? References: <20010220144836.A16568@freedom.puma-ag.com> Message-ID: <3A92AC3D.B91FDCB1@alcyone.com> Chris Withers wrote: > Steve Purcell wrote: > > > Chris Richard Adams wrote: > > > > > Someone please tell me why I cannot find a CASE statement in the > > > Python > > > documentation index... > > > > Because there isn't one. > > > > Use if/elif/else instead. > > > > It doesn't sting as much as you might expect. > > Oh but it does ;-) Not particularly. I come from C and C++, which have switch...case statements, and it isn't a big deal for them to be missing. Case statements are realy nothing more than glorified repeated if...else if... statements, and really don't have any more power (in fact, in C and C++, case statements have less). If you're really doing something where there would potentially be many, many if...else if... clauses, then a better approach in Python would be to use a dictionary whose keys are the case statements and whose values are the data to retrieve or the function to call. This is syntactically a lot cleaner and allows for in-code modification of the transition table. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Some mistakes we must carry with us. \__/ Speaker-to-Animals Physics reference / http://www.alcyone.com/max/reference/physics/ A physics reference. From larry at smith-house.org Tue Feb 27 19:39:50 2001 From: larry at smith-house.org (Larry Smith) Date: Tue, 27 Feb 2001 13:39:50 -0500 Subject: Where is CASE????? References: <20010220144836.A16568@freedom.puma-ag.com> <3A92AC3D.B91FDCB1@alcyone.com> Message-ID: <3A9BF476.EF2DE06@smith-house.org> Erik Max Francis wrote: > Not particularly. I come from C and C++, which have switch...case > statements, and it isn't a big deal for them to be missing. Case > statements are realy nothing more than glorified repeated if...else > if... statements, and really don't have any more power (in fact, in C > and C++, case statements have less). Case statements can be modelled with if-else chains but they are not the same internally. Case statements are usually compiled as jump tables, rather than as a series of if-elses. This is hugely faster than if-else on average. However, in Guido's defense, I will also point out the primary use of case statements is to select alternatives based on a type flag - which is not needed in an object oriented language. -- .-. .-. .---. .---. .-..-. | Do not mistake my cynicism | |__ / | \| |-< | |-< > / | for dispair for deep inside `----'`-^-'`-'`-'`-'`-' `-' | me is an optimist forever http://www.smith-house.org/ | asking, "Why not?" From Norman_Shelley-RRDN60 at email.sps.mot.com Tue Feb 27 19:55:14 2001 From: Norman_Shelley-RRDN60 at email.sps.mot.com (Norman Shelley) Date: Tue, 27 Feb 2001 11:55:14 -0700 Subject: Where is CASE????? References: <20010220144836.A16568@freedom.puma-ag.com> <3A92AC3D.B91FDCB1@alcyone.com> <3A9BF476.EF2DE06@smith-house.org> Message-ID: <3A9BF812.D5DA7F91@email.sps.mot.com> This argument is similiar to Bertrand Meyer's argument for not having a CASE statement in early versions of Eiffel. He finally "saw the light" and added in the CASE statement. I believe he finally saw the need to efficiently be able to handle character and string data (real world data that has not yet been objectized). Larry Smith wrote: > ... > > However, in Guido's defense, I will also point out the > primary use of case statements is to select alternatives > based on a type flag - which is not needed in an object > oriented language. > > -- > .-. .-. .---. .---. .-..-. | Do not mistake my cynicism > | |__ / | \| |-< | |-< > / | for dispair for deep inside > `----'`-^-'`-'`-'`-'`-' `-' | me is an optimist forever > http://www.smith-house.org/ | asking, "Why not?" From joconnor at cybermesa.com Tue Feb 27 19:59:49 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Tue, 27 Feb 2001 11:59:49 -0700 Subject: Where is CASE????? References: <20010220144836.A16568@freedom.puma-ag.com> <3A92AC3D.B91FDCB1@alcyone.com> <3A9BF476.EF2DE06@smith-house.org> Message-ID: <3A9BF925.600AFF65@cybermesa.com> Larry Smith wrote: > > However, in Guido's defense, I will also point out the > primary use of case statements is to select alternatives > based on a type flag - which is not needed in an object > oriented language. LOL! Most of my background is in Smalltalk, which also does not have CASE statements and I'm so used to programming without them that, up until I read this post, it really didn't occur to me whether Python had them or not Take care, Jay O'Connor http://www.cybermesa.com/~joconnor Python Language Forum - http://pub1.ezboard.com/fobjectorienteddevelopmentpython From db3l at fitlinxx.com Wed Feb 28 02:33:50 2001 From: db3l at fitlinxx.com (David Bolen) Date: 27 Feb 2001 20:33:50 -0500 Subject: Where is CASE????? References: <20010220144836.A16568@freedom.puma-ag.com> <3A92AC3D.B91FDCB1@alcyone.com> <3A9BF476.EF2DE06@smith-house.org> Message-ID: Larry Smith writes: > Case statements can be modelled with if-else chains > but they are not the same internally. Case statements > are usually compiled as jump tables, rather than as a > series of if-elses. This is hugely faster than if-else > on average. It's also what often restricts the case statements to integral values within some range, and the compilation can be less efficient if your values are sparsely spread over a very large range (in some cases the compiler may even end up with the same code as an if-else chain). But in such a case (lookups), dictionaries in Python are very efficient for lookups and can offer similar performance advantages, which still being generic in terms of what is being looked up. > However, in Guido's defense, I will also point out the > primary use of case statements is to select alternatives > based on a type flag - which is not needed in an object > oriented language. Well, either that, or keeping the list of alternatives in the dictionary keyed by the type flag is a nice fit. -- -- 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 Tue Feb 20 15:20:17 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 20 Feb 2001 06:20:17 -0800 Subject: Where is CASE????? References: Message-ID: <96tuh8$mocjg$1@ID-11957.news.dfncis.de> Or you may consider wrapping it in a dictionary: Type "copyright", "credits" or "license" for more information. IDLE 0.6 -- press F1 for help >>> def caseA(*args): print "CaseA ", args >>> def caseB(*args): print "CaseB ", args >>> def caseOther(*args): print "CaseOther ", args >>> switch = {'A':caseA, 'B':caseB} >>> switch.get('A',caseOther) >>> switch.get('A',caseOther)(1,2,3) CaseA (1, 2, 3) >>> switch.get('B',caseOther)(1,2,3) CaseB (1, 2, 3) >>> switch.get('C',caseOther)(1,2,3) CaseOther (1, 2, 3) >>> -- Emile van Sebille emile at fenx.com ------------------- "Steve Purcell" wrote in message news:mailman.982676904.20104.python-list at python.org... > Chris Richard Adams wrote: > > Someone please tell me why I cannot find a CASE statement in the Python > > documentation index... > > Because there isn't one. > > Use if/elif/else instead. > > It doesn't sting as much as you might expect. > > -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 hgg9140 at cola.ca.boeing.com Tue Feb 20 15:56:37 2001 From: hgg9140 at cola.ca.boeing.com (Harry George) Date: Tue, 20 Feb 2001 14:56:37 GMT Subject: Where is CASE????? References: Message-ID: No, but do you really need it? First, if you do a performance profiling, you will find if...elif...elif... is not so bad. But it isn't pretty either. So consider using a map: color_function={'red':do_red,'green':do_green,'blue':do_blue} #get some case value in domain red,green,blue, then: ftn=color_function[value] ftn() Or even: color_function[value]() Further, this approach lends itself to dynamically defining and adding cases, which can't be done with statically compiled CASE statements. Thus registering new colors and their actions is a piece of cake. "Chris Richard Adams" writes: > Someone please tell me why I cannot find a CASE statement in the Python > documentation index... > > There is a CASE isn't there??? > -- 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 duncan at rcp.co.uk Tue Feb 20 16:00:48 2001 From: duncan at rcp.co.uk (Duncan Booth) Date: Tue, 20 Feb 2001 15:00:48 +0000 (UTC) Subject: Where is CASE????? References: Message-ID: "Chris Richard Adams" wrote in : >Someone please tell me why I cannot find a CASE statement in the Python >documentation index... > >There is a CASE isn't there??? > While there are undoubtedly occasions where a CASE statement would be useful, they are actually much rarer in Python than you might expect. A large proportion of the instances where you might use CASE can be written better as a dictionary or an attribute lookup. For example in most languages if you were to try to handle errors from opening a web URL, you might reasonably expect to find a case statement switching on the different error codes you could receive. If you look at the urllib module you will see that the Pythonic way to do this is to have class methods with names such as http_error_401, http_error_301, and http_error_default. When an error code is returned, the appropriate method is called (or the default method if there is no better match) by using getattr to look up the method by name. This technique allows the end user to add their own handler for any error number, even those the original class knows nothing about. Another common use for CASE in some languages is when you have created a structure and put a type field in it. You want to process the object according to the type field. In any object oriented language (not just Python), this situation is better handled by including a method in the object that does the appropriate action for the object's type. If you post a message outlining the situation where you think you need a CASE statement you might get suggestions of better (or just different) ways to solve your particular problem. From Lance.Ellinghaus at eConnections.com Tue Feb 27 20:26:04 2001 From: Lance.Ellinghaus at eConnections.com (Lance.Ellinghaus at eConnections.com) Date: Tue, 27 Feb 2001 13:26:04 -0600 Subject: Where is CASE????? Message-ID: This can be done using a dictionary and functions pretty easily. At least that is how I have always done it. For example... def func_a(): pass def func_b(): pass def func_c(): pass func_dict = { 'A': func_a, 'B': func_b, 'C': func_c } try: apply(func_dict[test_value], ()) except: print '%c is not a valid choice' % test_value This works for any type of value in 'test_value' and is pretty fast executing. -- Lance Ellinghaus Phone: 940-466-7251 Pager: 800-226-4526 or lellinghaus at bellsouthips.com Sr. Architect - eConnections, Inc. Norman Shelley cc: Sent by: Subject: Re: Where is CASE????? python-list-admin at python.org 02/27/01 12:55 PM This argument is similiar to Bertrand Meyer's argument for not having a CASE statement in early versions of Eiffel. He finally "saw the light" and added in the CASE statement. I believe he finally saw the need to efficiently be able to handle character and string data (real world data that has not yet been objectized). Larry Smith wrote: > ... > > However, in Guido's defense, I will also point out the > primary use of case statements is to select alternatives > based on a type flag - which is not needed in an object > oriented language. > > -- > .-. .-. .---. .---. .-..-. | Do not mistake my cynicism > | |__ / | \| |-< | |-< > / | for dispair for deep inside > `----'`-^-'`-'`-'`-'`-' `-' | me is an optimist forever > http://www.smith-house.org/ | asking, "Why not?" -- http://mail.python.org/mailman/listinfo/python-list From ohyvarin at cc.helsinki.fi Tue Feb 20 15:25:26 2001 From: ohyvarin at cc.helsinki.fi (Otto T Hyvarinen) Date: 20 Feb 2001 14:25:26 GMT Subject: Python training in Finland? Message-ID: We starting to use more Python in our department. So we are looking for someone to teach us something :-) I am aware that Secret Labs/Pythonware is relatively near and they are willing to come and train us in English, but some of us would like to be teached in Finnish. (So why am I asking this in an English-language group? Outoa??) You may reply to this post or use directly my work email: otto.hyvarinen at fmi.fi Thank you, Otto Hyv?rinen From janne at oops.nnets.fi Tue Feb 20 23:58:11 2001 From: janne at oops.nnets.fi (Janne Sinkkonen) Date: 21 Feb 2001 00:58:11 +0200 Subject: Python training in Finland? References: Message-ID: ohyvarin at cc.helsinki.fi (Otto T Hyvarinen) writes: > I am aware that Secret Labs/Pythonware is relatively near and they > are willing to come and train us in English, but some of us would > like to be teached in Finnish. (So why am I asking this in an > English-language group? Outoa??) Varsin outoa. What kind of teaching do you want? -- Janne From ohyvarin at cc.helsinki.fi Wed Feb 21 12:22:17 2001 From: ohyvarin at cc.helsinki.fi (Otto T Hyvarinen) Date: 21 Feb 2001 11:22:17 GMT Subject: Python training in Finland? References: Message-ID: In article , Janne Sinkkonen wrote: >ohyvarin at cc.helsinki.fi (Otto T Hyvarinen) writes: > >> I am aware that Secret Labs/Pythonware is relatively near and they >> are willing to come and train us in English, but some of us would >> like to be teached in Finnish. (So why am I asking this in an >> English-language group? Outoa??) > >Varsin outoa. What kind of teaching do you want? > Some kind of quick introduction to Python and its standard libraries. Then something like http://www.python9.org/p9-tutorialsten.html , but maybe not so much about parallel programming. If you or your company can deliver that, then maybe should switch to email? Otto Hyv?rinen From kmo at stekt60.oulu.fi Wed Feb 28 10:57:03 2001 From: kmo at stekt60.oulu.fi (Kimmo Kansanen) Date: 28 Feb 2001 09:57:03 GMT Subject: Python training in Finland? References: Message-ID: <97ii1f$htc$2@ousrvr3.oulu.fi> Otto T Hyvarinen wrote: : In article , Janne Sinkkonen wrote: :>ohyvarin at cc.helsinki.fi (Otto T Hyvarinen) writes: :> :>> I am aware that Secret Labs/Pythonware is relatively near and they :>> are willing to come and train us in English, but some of us would :>> like to be teached in Finnish. (So why am I asking this in an :>> English-language group? Outoa??) :> :>Varsin outoa. What kind of teaching do you want? :> : Some kind of quick introduction to Python and its standard libraries. : Then something like http://www.python9.org/p9-tutorialsten.html , but : maybe not so much about parallel programming. You maybe have considered this allready, but do you think it is wise to try and avoid english in learning python, when all available documentation for the language (which you will be using later on in your work) is in english? In other words: do you really think it is possible to avoid english in this case, or are you just trying to make the learning curve less steep? Lykky? pyttyyn. Kimmo -- # Smile. It makes people wonder what you're thinking about. # From jkraska1 at san.rr.com Sat Feb 24 06:25:20 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 24 Feb 2001 05:25:20 GMT Subject: Python training in Finland? References: Message-ID: On 20 Feb 2001 14:25:26 GMT, ohyvarin at cc.helsinki.fi (Otto T Hyvarinen) wrote: >We starting to use more Python in our department. So we are looking for >someone to teach us something :-) I suggest that you use the inability of a software person to learn Python without training as a good indicator that you need to let them go. Anyone who can't pick up Python on their own is beyond redemption. `;--) C// From xyzmats at laplaza.org Tue Feb 27 18:17:04 2001 From: xyzmats at laplaza.org (Mats Wichmann) Date: Tue, 27 Feb 2001 17:17:04 GMT Subject: Python training in Finland? References: Message-ID: <3a9bdf95.8760106@news.laplaza.org> On Sat, 24 Feb 2001 05:25:20 GMT, Courageous wrote: >On 20 Feb 2001 14:25:26 GMT, ohyvarin at cc.helsinki.fi (Otto T Hyvarinen) wrote: > >>We starting to use more Python in our department. So we are looking for >>someone to teach us something :-) > >I suggest that you use the inability of a software person to >learn Python without training as a good indicator that you >need to let them go. Anyone who can't pick up Python on >their own is beyond redemption. That's a pretty harsh statement. Yes, Python is "easy to learn". I'm not convinced that it's easy for /everyone/ to become quickly productive in Python, however. I hear from folks who have a project to start, and they don't want to wait while the participants learn Python at various different rates to varying degrees of effectiveness. There's room for training programs, although they're clearly not for everyone - this newsgroup being a testament to that! (Otto: sorry I can't offer to help, my parents reserved Finnish as the "private" language in the house, I grew up speaking Swedish instead) From tgw at email.msn.com Tue Feb 20 15:31:18 2001 From: tgw at email.msn.com (Thom Wysong) Date: Tue, 20 Feb 2001 09:31:18 -0500 Subject: newbie - winsock error 10054 - connection reset by peer Message-ID: I'm attempting to run a simple "Fetch Data via HTTP" example on p.283 of the book "Python Programming on Win32". It is ending in a "10054, winsock error". I don't know what's causing this or how to fix it. I'm hoping someone can help. I'm running Win98 on a Gateway laptop, connected to the Internet with MSN. First, I typed in the following, which went fine... ------------------------- 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 httplib >>> http=httplib.HTTP('www.python.org') >>> >>> http.putrequest('GET', '/index.html') >>> http.putrequest('Accept', 'text/html') >>> http.putrequest('Accept', 'text/plain') >>> http.endheaders() >>> ------------------------- Next, the screen is supposed to look like this.... ------------------------- >>> errcode, errmsg, headers = http.getreply() >>> print errcode, errmsg, headers 200 OK >>> ------------------------- However, what actually happens is this... ------------------------- >>> errcode, errmsg, headers = http.getreply() Traceback (innermost last): File "", line 1, in ? errcode, errmsg, headers = http.getreply() File "C:\Program Files\Python\Lib\httplib.py", line 121, in getreply line = self.file.readline() File "C:\Program Files\Python\Lib\plat-win\socket.py", line 117, in readline new = self._sock.recv(self._rbufsize) error: (10054, 'winsock error') >>> ------------------------- The winsock error 10054 shows up for no apparent reason. The page at http://support.microsoft.com/support/kb/articles/Q150/5/37.asp states that winsock error 10054 means "Connection reset by peer". Does anyone have any idea what causes this or how to fix it? Thanks, tgw From fredrik at pythonware.com Wed Feb 21 10:30:25 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Feb 2001 09:30:25 GMT Subject: newbie - winsock error 10054 - connection reset by peer References: Message-ID: Thom Wysong wrote: > The winsock error 10054 shows up for no apparent reason. where "no apparent reason" means that either python.org or someone on the way to python.org doesn't want to talk to your machine. maybe you're using a proxy? httplib doesn't work with proxies. use urllib instead: import urllib, os os.environ["http_proxy"] = "yourproxy:port" file = urllib.urlopen("http://www.python.org") (if you're using IE and Python 2.0, you can leave out the os.environ line) Cheers /F From lreilly at cs.strath.ac.uk Tue Feb 20 17:20:03 2001 From: lreilly at cs.strath.ac.uk (Lee Reilly CS1997) Date: Tue, 20 Feb 2001 16:20:03 +0000 Subject: retrieving file data from an external server - where to start? Message-ID: <3A929933.AA4F81@cs.strath.ac.uk> hi there, i'm using python with zope and am trying to do the following with python method: retrieveFileInfo(matric){ username = getUsername(matric) filename = username + ".gif" server = "http://blahblahblah/yaddieyaddie/" # some code to determine whether or not the file exists # where do i start # e.g if (retrieve.(server+filename) != none): # do something } e.g. given the matric value '9728430' i find that the corresponding user has username == 'lreilly'. if this person has their image stored on the external server then it will be called 'lreilly.gif'. i don't need to actually retrieve the file from python - only determine whether or not it exists or not. i.e. whether the http request reports a 404 or maybe even if the image size == 0 bytes. could someone possible be kind enough to give me an idea where to start? a url? a snippet of code? thanks very much in advance, lee From lreilly at cs.strath.ac.uk Tue Feb 20 17:46:11 2001 From: lreilly at cs.strath.ac.uk (Lee Reilly CS1997) Date: Tue, 20 Feb 2001 16:46:11 +0000 Subject: additional info References: <3A929933.AA4F81@cs.strath.ac.uk> Message-ID: <3A929F53.9E9D0140@cs.strath.ac.uk> i'm trying to do this using python methods, which only support commonly used modules e.g. string, math, etc. i had a look at the httplib module, which seems like the ideal solution but this isn't supported in python methods. is the use of this module the only solution to the problem? nb: i can use the module in an *external* python method but this is a last resort. thanks for the bandwidth, lee From flognat at flognat.myip.org Tue Feb 20 20:42:40 2001 From: flognat at flognat.myip.org (Andrew Markebo) Date: Tue, 20 Feb 2001 19:42:40 GMT Subject: additional info References: <3A929933.AA4F81@cs.strath.ac.uk> <3A929F53.9E9D0140@cs.strath.ac.uk> Message-ID: Lets see.. You want to do this (see if you can fetch a page) doing as few imports as possible.. Or even no imports?? I think you have got the fact 'python methods' wrong.. Well first of all, to be able to get data over the internet, you have to import the socket module, it can be compiled into the python interpreter, or can be as pyd(?) file.. (ehm to be honest, some of the new Solaris versions have some kind of /dev/ device that you can open and write some data to in a normal way, and read the answer from the other end of the internet) Ok so we go for sockets?? Then it is easy for you to hack a small non-generic functionality to get certain webpages, you kan hardcode strings and so on.. Write to the socket ('''HEAD [WEBPAGE] HTTP/1.1\n\r[some headers]''') read from the socket, and see if you return a 404 or 200.. /Andy / Lee Reilly CS1997 wrote: | i'm trying to do this using python methods, which only support commonly | used modules e.g. string, math, etc. i had a look at the httplib module, | which seems like the ideal solution but this isn't supported in python | methods. | | is the use of this module the only solution to the problem? | | nb: i can use the module in an *external* python method but this is a | last resort. | | thanks for the bandwidth, | | lee From embed at geocities.com Tue Feb 20 17:21:45 2001 From: embed at geocities.com (Warren Postma) Date: Tue, 20 Feb 2001 11:21:45 -0500 Subject: Better Threading, starting with Events Message-ID: Here is my little 'event' module __doc__ string: event module 1.0 Provides an efficient way for threads to go to sleep while waiting for work to do, freeing up the python interpreter to run the other threads, and yet waking up immediately upon signalling the worker thread Uses CreateEvent/SetEvent/WaitForMultipleObjects Win32 functions. Usage Sample: import event sd = event.new('Shutdown') sd.MyAttribute = 1 # stores something in event dictionary work = event.new('DoSomeWork',1) # 'one-shot' work .work_to_do = func # pass the function to the thread ret = event.select( (sd,work), 5000 ) # wait 5 seconds for signal if ret: # Got signal? print repr(ret) ------------------------------------------------------------ Here are the module methods: ------------------------------------------------------------ event.new( 'name', manualResetFlag=1, initialStateFlag=0) -> Creates and returns a new event object manualResetFlag = does event reset automatically when received (default=1) initialStateFlag = event signalled or not signalled initially (default=0) e = event.new( 'ASampleEvent') Using a WinEvent: e.name name of event e.wait() wait indefinitely (until python shutdown) for event e.wait(500) wait up to 500 milliseconds (0.5 seconds) for event e.state() query state (non blocking) returns 0 or 1 e.set() set signalled state e.reset() reset to non-signalled state e.handle() get internal handle value (as integer) To wait for several events in parallel, use event.select( (e1,e2,..), timeout ) ------------------------------------------------------------ event.select( , timeout=None) -> Waits for a single event or any of a group of events, returns None if the timeout occurs. Note that all waits are interruptable by shutdown, which will cause an exception to be raised. Example: ev1 = event.new('DoSomething') ev2 = event.new('DoSomethingElse') ret=event.select( (ev1,ev2), 5000 ) # wait up to 5000 millisec. if ret: print 'got event', ret.name # which is it? DoSomething, or DoSomethingElse else: # none? print 'timeout' --------------------------- End ---------------------------- Now, for a discussion on my Evil Plan: Anyone interested in native C Type for Event Signalling? I have written a 1.0, or 0.1, that works, it just ain't portable off of Win32. I'll make it portable if there is some agreement on the basic idea behind what I'm doing. I'd like feedback on whether my Evil Plan calls for a PEP. Before I go PEP'ing, I'd like to get some initial comments on other people who have implemented worker threads. Is anyone else dissatisfied with threading.py? My first problem with the existing facilities of threading.py is its existence. I don't like that the Primitives are not Primitive, the interface is great, the implementation is in Python. Urgh! Great for Jython/JPython. Not so great for CPython guys like me. Why should Locks, Events, and Signals and Semaphores and so on all live in a py file? Their efficiency is therefore sub-par, and it will negatively affect the performance of all apps that use it. I also feel that a consistent API and underlying implementation ought to permeate downwards into the core of CPython. Anyone with me? At that stage, you can see my Evil Plan is beginning to get into swing. But back to reality for a minute. The first thing I needed was extremely efficient Event Objects, which could make a thread be "sleepy", waking up periodically every 5 seconds to do some housekeeping, then going back to sleep, but to be instantly interruptable at any time and immediately start doing whatever work is required. They let go of the python interpreter lock, and don't make the interpreter do any work, running functions in threading.py while the thread ought to be idle, etcetera. Also, my eventual evil plan involves thread-by-thread signalling in ways not currently supported by the current frame objects, and the code in ceval.c. It should also involve making various blocking functions "interruptable". For example, time.sleep, which calls the C function floatsleep in timemodule.c: Py_BEGIN_ALLOW_THREADS Sleep((unsigned long)millisecs); Py_END_ALLOW_THREADS This should be, IMHO: Py_BEGIN_ALLOW_THREADS ret=WaitForSingleObject( hSystemShutdown, INIFINITE); Py_END_ALLOW_THREADS if (ret != WAIT_TIMEOUT) return NULL; // system is shutting down. I am basically doing my R&D here anyways to get threading maximally efficient on my embedded systems. But I am more than willing, excited even, to try my hand at proposing a PEP. Not for my little event module, but for a whole bunch of threading primitives, in C. Perhaps the CPython version of threading.py could be adapted to use them. The PEP would probably be for an expanded "thread" module, and a revised threading system that improves "pervasive threading" inside CPython. Anyone? Anyone? Bueller? Warren From rwklee at home.com Wed Feb 21 03:23:26 2001 From: rwklee at home.com (Rick Lee) Date: Wed, 21 Feb 2001 02:23:26 GMT Subject: Better Threading, starting with Events References: Message-ID: <3A93269A.8AFFC7BB@home.com> I like the idea of being able to wait for several events at once. That's something I can't do with queues in the Queue module. So my wish list would extend to queues as well. Another thing on my wish list is to be able to join to several threads at once. And then finally, to be able to select from any combination of events, queues, joins, and maybe anything else that blocks. Maybe you also want to keep on eye on compatibility with Stackless. - Rick Lee Warren Postma wrote: > Here is my little 'event' module __doc__ string: > > event module 1.0 > > Provides an efficient way for threads to go to sleep while waiting for > work to do, freeing up the python interpreter to run the other threads, > and yet waking up immediately upon signalling the worker thread > > Uses CreateEvent/SetEvent/WaitForMultipleObjects Win32 functions. > > Usage Sample: > > import event > sd = event.new('Shutdown') > sd.MyAttribute = 1 # stores something in event dictionary > work = event.new('DoSomeWork',1) # 'one-shot' > work .work_to_do = func # pass the function to the thread > ret = event.select( (sd,work), 5000 ) # wait 5 seconds for signal > if ret: # Got signal? > print repr(ret) > > ------------------------------------------------------------ > Here are the module methods: > ------------------------------------------------------------ > > event.new( 'name', manualResetFlag=1, initialStateFlag=0) > -> Creates and returns a new event object > manualResetFlag = does event reset automatically when received > (default=1) > initialStateFlag = event signalled or not signalled initially > (default=0) > > e = event.new( 'ASampleEvent') > > Using a WinEvent: > e.name name of event > e.wait() wait indefinitely (until python shutdown) for event > e.wait(500) wait up to 500 milliseconds (0.5 seconds) for event > e.state() query state (non blocking) returns 0 or 1 > e.set() set signalled state > e.reset() reset to non-signalled state > e.handle() get internal handle value (as integer) > > To wait for several events in parallel, use event.select( (e1,e2,..), > timeout ) > > ------------------------------------------------------------ > > event.select( , timeout=None) > -> Waits for a single event or any of a group of events, > returns None if the timeout occurs. > Note that all waits are interruptable by shutdown, > which will cause an exception to be raised. > > Example: > ev1 = event.new('DoSomething') > ev2 = event.new('DoSomethingElse') > ret=event.select( (ev1,ev2), 5000 ) # wait up to 5000 millisec. > if ret: > print 'got event', ret.name # which is it? DoSomething, or > DoSomethingElse > else: # none? > print 'timeout' > > --------------------------- End ---------------------------- > > Now, for a discussion on my Evil Plan: > > Anyone interested in native C Type for Event Signalling? I have written a > 1.0, or 0.1, that works, it just ain't portable off of Win32. I'll make it > portable if there is some agreement on the basic idea behind what I'm doing. > > I'd like feedback on whether my Evil Plan calls for a PEP. Before I go > PEP'ing, I'd like to get some initial comments on other people who have > implemented worker threads. Is anyone else dissatisfied with threading.py? > > My first problem with the existing facilities of threading.py is its > existence. I don't like that the Primitives are not Primitive, the interface > is great, the implementation is in Python. Urgh! Great for Jython/JPython. > Not so great for CPython guys like me. > > Why should Locks, Events, and Signals and Semaphores and so on all live in a > py file? Their efficiency is therefore sub-par, and it will negatively > affect the performance of all apps that use it. I also feel that a > consistent API and underlying implementation ought to permeate downwards > into the core of CPython. Anyone with me? At that stage, you can see my > Evil Plan is beginning to get into swing. > > But back to reality for a minute. The first thing I needed was extremely > efficient Event Objects, which could make a thread be "sleepy", waking up > periodically every 5 seconds to do some housekeeping, then going back to > sleep, but to be instantly interruptable at any time and immediately start > doing whatever work is required. They let go of the python interpreter lock, > and don't make the interpreter do any work, running functions in > threading.py while the thread ought to be idle, etcetera. > > Also, my eventual evil plan involves thread-by-thread signalling in ways not > currently supported by the current frame objects, and the code in ceval.c. > It should also involve making various blocking functions "interruptable". > For example, time.sleep, which calls the C function floatsleep in > timemodule.c: > Py_BEGIN_ALLOW_THREADS > Sleep((unsigned long)millisecs); > Py_END_ALLOW_THREADS > > This should be, IMHO: > Py_BEGIN_ALLOW_THREADS > ret=WaitForSingleObject( hSystemShutdown, INIFINITE); > Py_END_ALLOW_THREADS > if (ret != WAIT_TIMEOUT) > return NULL; // system is shutting down. > > I am basically doing my R&D here anyways to get threading maximally > efficient on my embedded systems. But I am more than willing, excited even, > to try my hand at proposing a PEP. Not for my little event module, but for > a whole bunch of threading primitives, in C. Perhaps the CPython version of > threading.py could be adapted to use them. > > The PEP would probably be for an expanded "thread" module, and a revised > threading system that improves "pervasive threading" inside CPython. > > Anyone? Anyone? Bueller? > > Warren From gmcm at hypernet.com Sat Feb 24 03:13:59 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 24 Feb 2001 02:13:59 GMT Subject: Better Threading, starting with Events References: Message-ID: <9051D40E0gmcmhypernetcom@199.171.54.154> embed at geocities.com (Warren Postma) wrote in : [huge snip] >Anyone interested in native C Type for Event Signalling? I have written >a 1.0, or 0.1, that works, it just ain't portable off of Win32. I'll >make it portable if there is some agreement on the basic idea behind >what I'm doing. If you want to work with native Win32 events, locks etc. you can use Mark Hammond's Win32event stuff. But before you go making cross-platform promises, you might want to look carefully at threadmodule.c and friends. Believe it or not, it took a lot of effort to come up with a set of Python primitives which behave reasonably cross-platform. What's efficient on one platform is likely to a dog on another. - Gordon From akuchlin at mems-exchange.org Tue Feb 20 18:11:59 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: Tue, 20 Feb 2001 12:11:59 -0500 Subject: What of Siphon? Message-ID: Suchandra Thapa's Siphon code is now available. http://sourceforge.net/project/showfiles.php?group_id=20509&release_id=24001 Comments? Let's not have the issue go to sleep again! --amk From phlip_cpp at my-deja.com Tue Feb 20 19:07:31 2001 From: phlip_cpp at my-deja.com (Phlip) Date: Tue, 20 Feb 2001 10:07:31 -0800 Subject: What of Siphon? References: Message-ID: Andrew Kuchling wrote: > Suchandra Thapa's Siphon code is now available. > > http://sourceforge.net/project/showfiles.php?group_id=20509&release_id=24001 > > Comments? Let's not have the issue go to sleep again! What does it do? Or is that a secret? -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- All sensors report Patti having a very good time -- From andrew at andrewcooke.free-online.co.uk Tue Feb 20 20:41:33 2001 From: andrew at andrewcooke.free-online.co.uk (Andrew Cooke) Date: Tue, 20 Feb 2001 19:41:33 +0000 Subject: What of Siphon? References: Message-ID: <3A92C86D.282751E3@andrewcooke.free-online.co.uk> My ISP seems to have decided the rest of the world doesn't exist (apart from usenet, which makes it a very odd world that remains), but isn't this connected with the CPAN-for-Python project? The name rings a bell. May be completely wrong... Andrew Phlip wrote: > > Andrew Kuchling wrote: > > > Suchandra Thapa's Siphon code is now available. > > > > > http://sourceforge.net/project/showfiles.php?group_id=20509&release_id=24001 > > > > Comments? Let's not have the issue go to sleep again! > > What does it do? Or is that a secret? > > -- > Phlip phlip_cpp at my-deja.com > ============ http://c2.com/cgi/wiki?PhlIp ============ > -- All sensors report Patti having a very good time -- From amk at mira.erols.com Wed Feb 21 01:53:00 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 21 Feb 2001 00:53:00 GMT Subject: What of Siphon? References: <3A92C86D.282751E3@andrewcooke.free-online.co.uk> Message-ID: On Tue, 20 Feb 2001 19:41:33 +0000, Andrew Cooke wrote: >My ISP seems to have decided the rest of the world doesn't exist (apart >from usenet, which makes it a very odd world that remains), but isn't >this connected with the CPAN-for-Python project? The name rings a bell. Correct. Discussion on this topic died down immediately after a brief flurry of activity (as usual). --amk From doughellmann at bigfoot.com Wed Feb 21 02:49:29 2001 From: doughellmann at bigfoot.com (Doug Hellmann) Date: Wed, 21 Feb 2001 01:49:29 GMT Subject: What of Siphon? References: <3A92C86D.282751E3@andrewcooke.free-online.co.uk> Message-ID: Some of the conversation was going to move to the SourceForge forum associated with the project, but there wasn't much there either. Suchandra Thapa, the project creator, was having some system troubles and then got busy with work this week and things have died down a bit. Doug In article , amk at mira.erols.com wrote: > On Tue, 20 Feb 2001 19:41:33 +0000, > Andrew Cooke wrote: >>My ISP seems to have decided the rest of the world doesn't exist (apart >>from usenet, which makes it a very odd world that remains), but isn't >>this connected with the CPAN-for-Python project? The name rings a bell. > > Correct. Discussion on this topic died down immediately after a brief > flurry of activity (as usual). > > --amk > From ssthapa at classes.cs.uchicago.edu Wed Feb 21 02:12:28 2001 From: ssthapa at classes.cs.uchicago.edu (ssthapa at classes.cs.uchicago.edu) Date: Wed, 21 Feb 2001 01:12:28 GMT Subject: What of Siphon? References: <3A92C86D.282751E3@andrewcooke.free-online.co.uk> Message-ID: Andrew Cooke wrote: > >My ISP seems to have decided the rest of the world doesn't exist (apart >from usenet, which makes it a very odd world that remains), but isn't >this connected with the CPAN-for-Python project? The name rings a bell. > >May be completely wrong... >Andrew Yes, it is. -- ---------------------------------------------------------------------------- | 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 mal at lemburg.com Tue Feb 20 19:26:41 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 20 Feb 2001 19:26:41 +0100 Subject: [Distutils] What of Siphon? References: Message-ID: <3A92B6E1.3AD4789C@lemburg.com> Andrew Kuchling wrote: > > Suchandra Thapa's Siphon code is now available. > > http://sourceforge.net/project/showfiles.php?group_id=20509&release_id=24001 > > Comments? Let's not have the issue go to sleep again! Hmm, no docs, no summary, no home page... what is this Siphon thingie ? ;-) -- Marc-Andre Lemburg ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Pages: http://www.lemburg.com/python/ From ssthapa at classes.cs.uchicago.edu Wed Feb 21 02:12:29 2001 From: ssthapa at classes.cs.uchicago.edu (ssthapa at classes.cs.uchicago.edu) Date: Wed, 21 Feb 2001 01:12:29 GMT Subject: [Distutils] What of Siphon? References: Message-ID: M.-A. Lemburg wrote: >Andrew Kuchling wrote: >> >> Suchandra Thapa's Siphon code is now available. >> >> http://sourceforge.net/project/showfiles.php?group_id=20509&release_id=24001 >> >> Comments? Let's not have the issue go to sleep again! > >Hmm, no docs, no summary, no home page... >what is this Siphon thingie ? ;-) It's an early project to implement a CPAN module for python. I'm not really familiar with sourceforge and lack the time to put all the supporting documentation on the web page but I'm still working on the code. Hopefully by the end of this week I'll have the time to flesh out the project details on sourceforge and more importantly add more code and better documentation for the code. -- ---------------------------------------------------------------------------- | 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 wmiller at mediaone.net Tue Feb 20 18:35:27 2001 From: wmiller at mediaone.net (Walter Miller) Date: Tue, 20 Feb 2001 09:35:27 -0800 Subject: How to get device context for com object? Message-ID: Anyone know how to get a device context for a com object? For example: import win32com.client ie = win32com.client.Dispatch('InternetExplorer.Application.1') ie.Visible = 1 ie.Navigate('http://www.yahoo.com') hDCSrc = ie.GetDC() # Thought this might be the way but it's not an option From aleaxit at yahoo.com Tue Feb 20 21:10:12 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 20 Feb 2001 21:10:12 +0100 Subject: How to get device context for com object? References: Message-ID: <96ujcc12r6k@news1.newsguy.com> "Walter Miller" wrote in message news:NVxk6.15$uj7.15036 at news.pacbell.net... > Anyone know how to get a device context for a com object? For example: There is no general way: the COM object might have/use any number of windows, from 0 upwards, at any given time, and/or other devices, so it's not clear at all what 'a device context for the object' might mean (what does it mean to get a device context for a process, or a thread, or a DLL, or...?). Some specific COM interface for which it makes sense will implement a GetDC method, of course (offhand, though, only IDirectDrawSurface3 comes to mind -- which doesn't help you much with an internet explorer application object!-) Other will let you get a handle to a window object (again only one comes to mind, IOleWindow, but that one has several derivatives, and is used heavily in the in-place activation protocol, so it _may_ be possible, with a little bit of effort, to get *that* one for internet explorer -- if you activate it in-place within a container of yours, or use it as the container for your own activex control's in-place activation). Alex From wmiller at mediaone.net Tue Feb 20 23:03:22 2001 From: wmiller at mediaone.net (Walter Miller) Date: Tue, 20 Feb 2001 14:03:22 -0800 Subject: How to get device context for com object? References: <96ujcc12r6k@news1.newsguy.com> Message-ID: The "InternetExplorer.Application.1" com object has a HWND property from which you can get the window handle. It seem reasonable to expect that one could get a device context based on a valid window handle. "Alex Martelli" wrote in message news:96ujcc12r6k at news1.newsguy.com... > "Walter Miller" wrote in message > news:NVxk6.15$uj7.15036 at news.pacbell.net... > > Anyone know how to get a device context for a com object? For example: > > There is no general way: the COM object might have/use any > number of windows, from 0 upwards, at any given time, and/or > other devices, so it's not clear at all what 'a device context for > the object' might mean (what does it mean to get a device > context for a process, or a thread, or a DLL, or...?). > > Some specific COM interface for which it makes sense will > implement a GetDC method, of course (offhand, though, only > IDirectDrawSurface3 comes to mind -- which doesn't help > you much with an internet explorer application object!-) > > Other will let you get a handle to a window object (again > only one comes to mind, IOleWindow, but that one has > several derivatives, and is used heavily in the in-place > activation protocol, so it _may_ be possible, with a little > bit of effort, to get *that* one for internet explorer -- if > you activate it in-place within a container of yours, or use > it as the container for your own activex control's in-place > activation). > > > Alex > > > > From aleaxit at yahoo.com Tue Feb 20 23:44:51 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 20 Feb 2001 23:44:51 +0100 Subject: How to get device context for com object? References: <96ujcc12r6k@news1.newsguy.com> Message-ID: <96us1u0dj8@news1.newsguy.com> "Walter Miller" wrote in message news:YQBk6.80$3e2.62458 at news.pacbell.net... > The "InternetExplorer.Application.1" com object has a HWND property from > which you can get the window handle. It seem reasonable to expect that one > could get a device context based on a valid window handle. If you have a valid window handle, you can indeed get a device context for that window -- that's got nothing to do with COM (or however else you got your HWND), but rather is the job of the APIs GetWindowDC (if you want the DC for the _entire_ window, i.e., including the non-client areas), GetDC (if you want the DC for the client-area only), GetDCEx (if you want peculiar clipping, a cached context, and/or intact DC attributes... THAT one I've never used yet!-), ... -- just call the appropriate one (at least the first two, I believe, are exposed by modules in the win32all package). Alex From wmiller at mediaone.net Wed Feb 21 00:56:25 2001 From: wmiller at mediaone.net (Walter Miller) Date: Tue, 20 Feb 2001 15:56:25 -0800 Subject: How to get device context for com object? References: <96ujcc12r6k@news1.newsguy.com> <96us1u0dj8@news1.newsguy.com> Message-ID: That's exaclty what I'm trying to do but don't know how through python - get the device context based on a window handle. How do I call the GetDC api through python based on a given window handle? Sorry, this probably should have been my original question. From aleaxit at yahoo.com Wed Feb 21 10:29:35 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 21 Feb 2001 10:29:35 +0100 Subject: How to get device context for com object? References: <96ujcc12r6k@news1.newsguy.com> <96us1u0dj8@news1.newsguy.com> Message-ID: <9701q102nt4@news1.newsguy.com> "Walter Miller" wrote in message news:XuDk6.96953$Wq1.40024851 at nnrp5-w.sbc.net... > That's exaclty what I'm trying to do but don't know how through python - get > the device context based on a window handle. How do I call the GetDC api > through python based on a given window handle? Sorry, this probably should > have been my original question. You need to have installed win32all (or the ActiveState build of Python for Win32, that comes with win32all). Then, import win32gui hdc = win32gui.GetDC(hwnd) will set hdc to the (int) handle for the device context corresponding to (the client areas of) the window whose handle is in (int) hwnd. Remember to also call win32gui.ReleaseDC(hwnd, hdc) when you're done (you might want to use a try/finally...). (Similarly, you may use win32gui.GetWindowDC to get the hdc for the whole window including non-client areas, &c). Alex From wmiller at mediaone.net Wed Feb 21 23:48:35 2001 From: wmiller at mediaone.net (Walter Miller) Date: Wed, 21 Feb 2001 14:48:35 -0800 Subject: How to get device context for com object? References: <96ujcc12r6k@news1.newsguy.com> <96us1u0dj8@news1.newsguy.com> <9701q102nt4@news1.newsguy.com> Message-ID: That's great! Yes, it works but I'm also trying to call CreateCompatibleDC() and it only works with the device context object not the (int) handle for the device context. Is there an api for creating a device context object based on its own handle? The ultimate plan is to try an replicate the visual basic example of copying the screenshot of the client portion of the window and saving it as a bitmap file. I have an activex control that does this already but that's too easy - I'm _actually_ trying to learn all the details of using Python with win32. > import win32gui > hdc = win32gui.GetDC(hwnd) > > will set hdc to the (int) handle for the device context > corresponding to (the client areas of) the window whose > handle is in (int) hwnd. From aleaxit at yahoo.com Thu Feb 22 10:28:13 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 22 Feb 2001 10:28:13 +0100 Subject: How to get device context for com object? References: <96ujcc12r6k@news1.newsguy.com> <96us1u0dj8@news1.newsguy.com> <9701q102nt4@news1.newsguy.com> Message-ID: <972m3d0keq@news2.newsguy.com> "Walter Miller" wrote in message news:rBXk6.268$FG.70985 at news.pacbell.net... > That's great! Yes, it works but I'm also trying to call > CreateCompatibleDC() and it only works with the device context object not > the (int) handle for the device context. Is there an api for creating a > device context object based on its own handle? win32ui.CreateDCFromHandle. Alex From ransen_spam_me_not at nemo.it Tue Feb 20 19:11:23 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Tue, 20 Feb 2001 18:11:23 GMT Subject: Py_Exit in a C/C++ program Message-ID: <3a9298dc.4233599@news.newsguy.com> Till my Python books arrive... ;) When embedding Python in a C/C++ program I suppose that Py_Exit was created as an simple way of exiting your C (C++) program and at the same time cleaning up the Python environment? -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From ransen_spam_me_not at nemo.it Tue Feb 20 19:11:36 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Tue, 20 Feb 2001 18:11:36 GMT Subject: When embedding with no natural console...? Message-ID: <3a969ec3.5744237@news.newsguy.com> When embedding with no natural console (I mean that the application does not have a console output, it is pure GUI) what suggestions are there for printing? I can think of some, but someone with more experience may be able to tell me which is best or easiest or most dangerous... *) Create some sort of console in the GUI app. Maybe with AllocConsole WriteConsole and FreeConsole... *) Ridirect output to a log file... *) Do not print anything... *) Other... Since my final app will be aimed at beginning programmers I think some sort of console output would be nice. -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From aleaxit at yahoo.com Tue Feb 20 21:00:49 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 20 Feb 2001 21:00:49 +0100 Subject: When embedding with no natural console...? References: <3a969ec3.5744237@news.newsguy.com> Message-ID: <96ujca02r6k@news1.newsguy.com> "Owen F. Ransen" wrote in message news:3a969ec3.5744237 at news.newsguy.com... > When embedding with no natural console (I mean that > the application does not have a console output, it > is pure GUI) what suggestions are there for printing? Set the 'stdout' attribute of module 'sys' (PySys_SetObject may work well for that, but it seems to be undocumented so I'm not sure it's best; you might do it in Python itself, executing a small piece of Python source from within your embedding application) to a "suitable" object -- one that implements a "suitable" write method, accepting a (buffer) Python object (and lets Python set and get an attribute named 'softspace'). It's simplest to do it in Python, with a small Python class that just directs the argument of that write method to a module-level function in your module. (You may want to do the same for the 'stderr' attribute). Your module-level function may do whatever you see fit -- emit the output with Win32 API "OutputDebugString", use the event-logging system functions of NT, add it to a real on-disk file, scroll it on a listbox or other within-a-GUI sort of "console-alike", etc, etc. > *) Create some sort of console in the GUI app. > Maybe with AllocConsole WriteConsole and > FreeConsole... That's one possibilities, but real consoles don't work all that well on Win95/Win98 and don't offer many advantages (wrt a scrolling text window that you can embed/dock/etc within your GUI) for text-output. > *) Ridirect output to a log file... > *) Do not print anything... > *) Other... It might be best to let the user choose (by configuration options, menus, preferences, ...) among these (zero or more thereof). > Since my final app will be aimed at beginning programmers > I think some sort of console output would be nice. Scrolling text-output (with a long-enough 'history' that is scrollable backwards, ability to save to a textfile, etc) should be good enough for that. Alex From ransen_spam_me_not at nemo.it Wed Feb 21 17:25:58 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Wed, 21 Feb 2001 16:25:58 GMT Subject: When embedding with no natural console...? References: <3a969ec3.5744237@news.newsguy.com> <96ujca02r6k@news1.newsguy.com> Message-ID: <3a965a5c.2664472@news.newsguy.com> >> Since my final app will be aimed at beginning programmers >> I think some sort of console output would be nice. >Scrolling text-output (with a long-enough 'history' that is >scrollable backwards, ability to save to a textfile, etc) should >be good enough for that. >Alex Good point. -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From dsavitsk at e-coli.net Wed Feb 21 00:56:11 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Tue, 20 Feb 2001 17:56:11 -0600 Subject: When embedding with no natural console...? References: <3a969ec3.5744237@news.newsguy.com> Message-ID: I needed a similar thing (and was tired of my app covering the win32 console), so i put a (tkinter) text widget and a scroll widget at the bottom of my interface. One advantage i found was the ability to control the color of the output (a novelty on windows it would seem) so errors are red, data is blue, instructions are white, etc. There is a picture of it in "action" at the bottom of this page www.e-coli.net/software/ecpse/inst.html doug "Owen F. Ransen" wrote in message news:3a969ec3.5744237 at news.newsguy.com... > When embedding with no natural console (I mean that > the application does not have a console output, it > is pure GUI) what suggestions are there for printing? > > I can think of some, but someone with more experience > may be able to tell me which is best or easiest or > most dangerous... > > *) Create some sort of console in the GUI app. > Maybe with AllocConsole WriteConsole and > FreeConsole... > *) Ridirect output to a log file... > *) Do not print anything... > *) Other... > > Since my final app will be aimed at beginning programmers > I think some sort of console output would be nice. > > > -- > Owen F. Ransen > http://www.ransen.com/ > Home of Gliftic & Repligator Image Generators From ransen_spam_me_not at nemo.it Wed Feb 21 17:26:12 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Wed, 21 Feb 2001 16:26:12 GMT Subject: When embedding with no natural console...? References: <3a969ec3.5744237@news.newsguy.com> Message-ID: <3a975a88.2708336@news.newsguy.com> On Tue, 20 Feb 2001 17:56:11 -0600, "dsavitsk" wrote: >I needed a similar thing (and was tired of my app covering the win32 >console), >doug Good point. -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From jim at interet.com Wed Feb 21 14:23:09 2001 From: jim at interet.com (James C. Ahlstrom) Date: Wed, 21 Feb 2001 08:23:09 -0500 Subject: When embedding with no natural console...? References: <3a969ec3.5744237@news.newsguy.com> Message-ID: <3A93C13D.E4A7F08D@interet.com> "Owen F. Ransen" wrote: > > When embedding with no natural console (I mean that > the application does not have a console output, it > is pure GUI) what suggestions are there for printing? You need to replace sys.stdout and sys.stderr with an object which has a "write" method. Then you need to make "write" do something. My "write" saves the text, and displays it in a MessageBox when the system is idle. But you could write it to a different window for example. Remember that output is lost if something goes wrong before you can replace sys.stdout/err. JimA From ransen_spam_me_not at nemo.it Wed Feb 21 17:59:22 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Wed, 21 Feb 2001 16:59:22 GMT Subject: When embedding with no natural console...? References: <3a969ec3.5744237@news.newsguy.com> Message-ID: <3a94f040.1756349@news.newsguy.com> On Tue, 20 Feb 2001 18:11:36 GMT, ransen_spam_me_not at nemo.it (Owen F. Ransen) wrote: >When embedding with no natural console (I mean that >the application does not have a console output, it >is pure GUI) what suggestions are there for printing? Thanks all for your suggestions, I think that in my case a window embedded somewhere in the app is the best solution... -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From stevemak at softhome.net Tue Feb 20 19:53:03 2001 From: stevemak at softhome.net (Steve Mak) Date: Tue, 20 Feb 2001 18:53:03 GMT Subject: help with re.split() Message-ID: <3A92BF37.63637CA0@softhome.net> Hi guys, How do I use the re.split() function so it splits a line of text, keeping only the word. ie: it excludes any symbols, spaces, etc. I tried p=re.split('[. ]+', line), but some spaces are being kept. if the line is Hello, how are you? I need to split it so I get: Hello how are you From cfelling at iae.nl Wed Feb 21 00:31:24 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 21 Feb 2001 00:31:24 +0100 Subject: help with re.split() References: <3A92BF37.63637CA0@softhome.net> Message-ID: <96uuoc$dhs$1@animus.fel.iae.nl> Steve Mak wrote: > Hi guys, > How do I use the re.split() function so it splits a line of text, > keeping only the word. ie: it excludes any symbols, spaces, etc. I tried > p=re.split('[. ]+', line), but some spaces are being kept. Maybe some space are taps in disguish? The approach you toke has it's pitfalls, like in >>> import re >>> re.split(r'\W+', 'Hello, how are you?') ['Hello', 'how', 'are', 'you', ''] Notice this empty string at the end of the split-list. That's because after the matched "?" there is an empty string (there always is:). The same would happen with a leading match. Maybe finding all words in that list is simpler, like (\w+ matches all alphanumeric strings.): >>> import re >>> re.findall(r'\w+', ' Hello, how are you? ') ['Hello', 'how', 'are', 'you'] >>> re.findall(r'\w+', ' Hello, 2 you 2! ') ['Hello', '2', 'you', '2'] -- groetjes, carel From stevemak at softhome.net Wed Feb 21 00:52:21 2001 From: stevemak at softhome.net (Steve Mak) Date: Tue, 20 Feb 2001 23:52:21 GMT Subject: ATTN: Carel Fellinger References: <3A92BF37.63637CA0@softhome.net> <96uuoc$dhs$1@animus.fel.iae.nl> Message-ID: <3A930560.F84586D8@softhome.net> Thanks for your help!!!!! Carel Fellinger wrote: > Steve Mak wrote: > > Hi guys, > > > How do I use the re.split() function so it splits a line of text, > > keeping only the word. ie: it excludes any symbols, spaces, etc. I tried > > p=re.split('[. ]+', line), but some spaces are being kept. > > Maybe some space are taps in disguish? > The approach you toke has it's pitfalls, like in > > >>> import re > >>> re.split(r'\W+', 'Hello, how are you?') > ['Hello', 'how', 'are', 'you', ''] > > Notice this empty string at the end of the split-list. > That's because after the matched "?" there is an empty string > (there always is:). The same would happen with a leading match. > > Maybe finding all words in that list is simpler, like (\w+ matches > all alphanumeric strings.): > > >>> import re > >>> re.findall(r'\w+', ' Hello, how are you? ') > ['Hello', 'how', 'are', 'you'] > >>> re.findall(r'\w+', ' Hello, 2 you 2! ') > ['Hello', '2', 'you', '2'] > -- > groetjes, carel From ben.hutchings at roundpoint.com Wed Feb 21 01:16:29 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 20 Feb 2001 16:16:29 -0800 Subject: help with re.split() References: <3A92BF37.63637CA0@softhome.net> Message-ID: Steve Mak writes: > Hi guys, > > How do I use the re.split() function so it splits a line of text, > keeping only the word. ie: it excludes any symbols, spaces, etc. I tried > p=re.split('[. ]+', line), but some spaces are being kept. If the line has a leading and/or trailing section that matches the pattern, then the result list will begin and/or end with an empty string, but no spaces will be kept. If you then join the listed strings back together with spaces then you will get leading and/or trailing space. For example: >>> p=re.split(' ', ' string with leading and trailing space ') >>> p ['', 'string', 'with', 'leading', 'and', 'trailing', 'space', ''] >>> string.join(p, ' ') ' string with leading and trailing space ' Perhaps this is what you are seeing? > if the line is Hello, how are you? > > I need to split it so I get: > Hello > how > are > you Then you must include ',' and '?' in the character class. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From tchur at optushome.com.au Tue Feb 20 20:41:43 2001 From: tchur at optushome.com.au (Tim Churches) Date: Wed, 21 Feb 2001 06:41:43 +1100 Subject: Optimisation problem - in C? Message-ID: <3A92C877.C67AAD8@optushome.com.au> After a bit of profiling I have worked out exactly which part of a data crunching class on which I am working needs to be optimised - maybe in C? The abstracted function which needs to run faster is as follows - not surprisingly it is itself a loop which lives within two other loops - hence it is called rather frequently: ############ def makevector(sourcelist,elementlist): resultvector = [] for element in elementlist: resultvector.append(sourcelist[element]) return resultvector ########### My test data has about 300,000 elements in sourcelist and between about 10,000 and 70,000 elements in elementlist, but larger lists are envisaged, hence the earnest desire for maximum speed. Questions: Can this function (which essentially does the fairly generic operation of "fetch the elements of sequence a using the element indexes contained in sequence b") be optimised without resorting to a C module? If not, is anyone willing to hold my hand (it's clean, but rather sweaty) while I fumble with trying to replace the function with a C module? (Note: after years of unremitting effort, I have finally mastered all aspects of hello_world.c) Tim Churches Sydney, Australia From johann at physics.berkeley.edu Tue Feb 20 21:09:33 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 20 Feb 2001 12:09:33 -0800 Subject: Optimisation problem - in C? References: Message-ID: Tim Churches writes: > Questions: > Can this function (which essentially does the fairly generic operation > of "fetch the elements of sequence a using the element indexes contained > in sequence b") be optimised without resorting to a C module? The Numeric module has a "take" function, which does exactly what you want. You will have to convert your lists into numeric arrays of python objects, but that shouldn't be difficult. --J -- Johann Hibschman johann at physics.berkeley.edu From aleaxit at yahoo.com Wed Feb 21 00:17:19 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 21 Feb 2001 00:17:19 +0100 Subject: Optimisation problem - in C? References: Message-ID: <96uts50ilg@news1.newsguy.com> "Tim Churches" wrote in message news:mailman.982698204.12938.python-list at python.org... [snip] > def makevector(sourcelist,elementlist): > resultvector = [] > for element in elementlist: > resultvector.append(sourcelist[element]) > return resultvector [snip] > Questions: > Can this function (which essentially does the fairly generic operation > of "fetch the elements of sequence a using the element indexes contained > in sequence b") be optimised without resorting to a C module? You can easily make it a *little* bit faster (though using Numeric, as others suggested, would be better still): def makevector(sourcelist, elementlist): resultvector = [None] * len(elementlist) for i in range(len(elementlist)): resultvector[i] = sourcelist[elementlist[i]] return resultvector this is a bit faster by avoiding re-allocations of resultvector. Alex From ben.hutchings at roundpoint.com Wed Feb 21 01:07:45 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 20 Feb 2001 16:07:45 -0800 Subject: Optimisation problem - in C? References: Message-ID: Tim Churches writes: > def makevector(sourcelist,elementlist): > resultvector = [] > for element in elementlist: > resultvector.append(sourcelist[element]) > return resultvector > My test data has about 300,000 elements in sourcelist and between about > 10,000 and 70,000 elements in elementlist, but larger lists are > envisaged, hence the earnest desire for maximum speed. > > Questions: > Can this function (which essentially does the fairly generic operation > of "fetch the elements of sequence a using the element indexes contained > in sequence b") be optimised without resorting to a C module? I think it can. Since a list's contents are contiguous in memory (in order to support random access), appending to it will cause it to reallocate and move all its contents periodically. If I remember correctly, Python's lists increase their memory allocations by constant amounts rather than by a constant factor, so this loop will run in quadratic time, i.e. proportional to the square of the length of elementlist! Each of the following definitions should be equivalent to the above, and I think at least one will run faster: def makevector(sourcelist,elementlist): resultvector = [None] * len(elementlist) for i in range(len(elementlist)): resultvector[i] = sourcelist[elementlist[i]] return resultvector def makevector(sourcelist,elementlist): return [sourcelist[element] for element in elementlist] def makevector(sourcelist,elementlist): return map(lambda i,l=sourcelist: l[i], elementlist) -- Any opinions expressed are my own and not necessarily those of Roundpoint. From djc at object-craft.com.au Wed Feb 21 04:27:39 2001 From: djc at object-craft.com.au (Dave Cole) Date: 21 Feb 2001 14:27:39 +1100 Subject: Optimisation problem - in C? In-Reply-To: Tim Churches's message of "Wed, 21 Feb 2001 06:41:43 +1100" References: Message-ID: >>>>> "Tim" == Tim Churches writes: Tim> def makevector(sourcelist,elementlist): Tim> resultvector = [] Tim> for element in elementlist: Tim> resultvector.append(sourcelist[element]) Tim> return resultvector Because I am trying to avoid writing documentation for some code that I want to give away, I decided to whip up some code for you to try. Extract the two following files and grab a copy of Makefile.pre.in from any other extension module - the CSV module from http://www.object-craft.com.au/projects/csv/ is where I copied mine from. Place all of the files in a directory then type: % make -f Makefile.pre.in boot % make % 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 >>> import timbo >>> a = ['a','b','c','d','e'] >>> b = [2,3,4] >>> timbo.makevector(a, b) ['c', 'd', 'e'] >>> Tell me if it goes faster (or if it even works :-) Because I am a bit lazy, I have assumed that elementlist is a sequence of integers. - Dave - - 8< - Setup.in - - - - - - - - - - - - - - - - - - - - - - - - - - # Setup file to build the timbo module *shared* timbo timbo.c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8< - timbo.c - - - - - - - - - - - - - - - - - - - - - - - - - - - #include "Python.h" static char makevector__doc__[] = "Works just like the following - only faster (I hope)\n" "\n" "def makevector(sourcelist, elementlist):\n" " resultvector = []\n" " for element in elementlist:\n" " resultvector.append(sourcelist[element])\n" " return resultvector"; static PyObject *makevector(PyObject *module, PyObject *args) { PyObject *sourcelist, *elementlist; PyObject *resultlist = NULL; int len, i; if (!PyArg_ParseTuple(args, "OO", &sourcelist, &elementlist)) return NULL; len = PySequence_Length(elementlist); if (PyErr_Occurred()) return NULL; resultlist = PyList_New(len); if (resultlist == NULL) return NULL; for (i = 0; i < len; i++) { PyObject *item; int num; if ((item = PySequence_GetItem(elementlist, i)) == NULL) goto error; num = PyInt_AsLong(item); if (PyErr_Occurred()) { Py_DECREF(item); goto error; } if ((item = PySequence_GetItem(sourcelist, num)) == NULL) goto error; PyList_SetItem(resultlist, i, item); } return resultlist; error: Py_DECREF(resultlist); return NULL; } /* List of methods defined in the module */ static struct PyMethodDef methods[] = { { "makevector", (PyCFunction)makevector, METH_VARARGS, makevector__doc__ }, { NULL, (PyCFunction)NULL, 0, NULL } /* sentinel */ }; static char module__doc__[] = "Tim's optimisations."; void inittimbo(void) { Py_InitModule4("timbo", methods, module__doc__, (PyObject*)NULL, PYTHON_API_VERSION); if (PyErr_Occurred()) Py_FatalError("can't initialize module timbo"); } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- http://www.object-craft.com.au From djc at object-craft.com.au Wed Feb 21 05:54:29 2001 From: djc at object-craft.com.au (Dave Cole) Date: 21 Feb 2001 15:54:29 +1100 Subject: Optimisation problem - in C? References: Message-ID: Forgot to followup in the newsgroup... >>>>> "Tim" == Tim Churches writes: Tim> def makevector(sourcelist,elementlist): Tim> resultvector = [] Tim> for element in elementlist: Tim> resultvector.append(sourcelist[element]) Tim> return resultvector Because I am trying to avoid writing documentation for some code that I want to give away, I decided to whip up some code for you to try. Extract the two following files and grab a copy of Makefile.pre.in from any other extension module - the CSV module from http://www.object-craft.com.au/projects/csv/ is where I copied mine from. Place all of the files in a directory then type: % make -f Makefile.pre.in boot % make % 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 >>> import timbo >>> a = ['a','b','c','d','e'] >>> b = [2,3,4] >>> timbo.makevector(a, b) ['c', 'd', 'e'] >>> Tell me if it goes faster (or if it even works :-) Because I am a bit lazy, I have assumed that elementlist is a sequence of integers. - Dave - - 8< - Setup.in - - - - - - - - - - - - - - - - - - - - - - - - - - # Setup file to build the timbo module *shared* timbo timbo.c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8< - timbo.c - - - - - - - - - - - - - - - - - - - - - - - - - - - #include "Python.h" static char makevector__doc__[] = "Works just like the following - only faster (I hope)\n" "\n" "def makevector(sourcelist, elementlist):\n" " resultvector = []\n" " for element in elementlist:\n" " resultvector.append(sourcelist[element])\n" " return resultvector"; static PyObject *makevector(PyObject *module, PyObject *args) { PyObject *sourcelist, *elementlist; PyObject *resultlist = NULL; int len, i; if (!PyArg_ParseTuple(args, "OO", &sourcelist, &elementlist)) return NULL; len = PySequence_Length(elementlist); if (PyErr_Occurred()) return NULL; resultlist = PyList_New(len); if (resultlist == NULL) return NULL; for (i = 0; i < len; i++) { PyObject *item; int num; if ((item = PySequence_GetItem(elementlist, i)) == NULL) goto error; num = PyInt_AsLong(item); if (PyErr_Occurred()) { Py_DECREF(item); goto error; } if ((item = PySequence_GetItem(sourcelist, num)) == NULL) goto error; PyList_SetItem(resultlist, i, item); } return resultlist; error: Py_DECREF(resultlist); return NULL; } /* List of methods defined in the module */ static struct PyMethodDef methods[] = { { "makevector", (PyCFunction)makevector, METH_VARARGS, makevector__doc__ }, { NULL, (PyCFunction)NULL, 0, NULL } /* sentinel */ }; static char module__doc__[] = "Tim's optimisations."; void inittimbo(void) { Py_InitModule4("timbo", methods, module__doc__, (PyObject*)NULL, PYTHON_API_VERSION); if (PyErr_Occurred()) Py_FatalError("can't initialize module timbo"); } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- http://www.object-craft.com.au From scarblac at pino.selwerd.nl Wed Feb 21 14:02:34 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 21 Feb 2001 13:02:34 GMT Subject: Optimisation problem - in C? References: Message-ID: Tim Churches wrote in comp.lang.python: > After a bit of profiling I have worked out exactly which part of a data > crunching class on which I am working needs to be optimised - maybe in > C? The abstracted function which needs to run faster is as follows - not > surprisingly it is itself a loop which lives within two other loops - > hence it is called rather frequently: > > ############ > def makevector(sourcelist,elementlist): > resultvector = [] > for element in elementlist: > resultvector.append(sourcelist[element]) > return resultvector > ########### > > My test data has about 300,000 elements in sourcelist and between about > 10,000 and 70,000 elements in elementlist, but larger lists are > envisaged, hence the earnest desire for maximum speed. Yes, I can see that this would be slow. It's too bad that lists don't have a .get() method (so x.get(3) would be equal to x[3]), because resultvector=map(sourcelist.get, elementlist) would be fastest (all done in C). As it is, you have to fake that with resultvector=map(lambda i, l=sourcelist: l[i], elementlist), and the lambda calls mean that this is much slower than your version resultvector = [sourcelist[element] for element in elementlist] is Python 2.0, and it at least is somewhat faster than your version (0.290s for your version, 0.250 for the list comprehension on my machine with len(sourcelist)=300000 and len(elementlist)=70000. Wait, one of the main problems of your first version is that the list has to grow. What if we create a list of the same length as elementlist first, say by copying it? def makevector(sourcelist, elementlist): resultvector = elementlist[:] for i in range(len(elementlist)): resultvector[i] = sourcelist[elementlist[i]] return resultvector This one runs in 0.170 seconds on my computer, on average. I'm out of further ideas. Too bad there's no syntax construct for 'for i in range(len(...))' yet. > Can this function (which essentially does the fairly generic operation > of "fetch the elements of sequence a using the element indexes contained > in sequence b") be optimised without resorting to a C module? By about 40%, but for more you'll need to do it in C. I don't know how much of a gain you can expect there. How do you use this list? If you only use part of the data later you might choose not to compute the whole thing at all but put a lazy wrapper around it. class Wrapper: def __init__(self, sourcelist, elementlist): self.sl = sourcelist self.el = elementlist def __getitem__(self, i): return self.sl[self.el[i]] resultlist = Wrapper(sourcelist, elementlist) This would be faster if you use only a small part of the whole list. > If not, is anyone willing to hold my hand (it's clean, but rather > sweaty) while I fumble with trying to replace the function with a C > module? (Note: after years of unremitting effort, I have finally > mastered all aspects of hello_world.c) I'll pass this one on, haven't needed to do it myself yet... -- Remco Gerlich From sebastian.dauss at web.de Wed Feb 21 15:11:24 2001 From: sebastian.dauss at web.de (Sebastian Dauss) Date: Wed, 21 Feb 2001 15:11:24 +0100 Subject: Optimisation problem - in C? References: Message-ID: <3a93c91b$1@netnews.web.de> > It's too bad that lists don't have a .get() method (so x.get(3) would be > equal to x[3]), because resultvector=map(sourcelist.get, elementlist) > would be fastest (all done in C). Oh, in fact there is a list get()-method. It is hidden within the 'operator'-module ;). The only disadvantage is that it expects the sequence to fetch the item from in its first argument, so you have to make a list of references to the sourcelist in order to apply the map()-function. If memory consumption is not an issue, you can try to do the most work at C-speed by using: import operator def makevector_operator(sourcelist,elementlist): return map(operator.getitem, [sourcelist]*len(elementlist), elementlist) Let's summarize and profile the different approaches (300000 items in sourcelist, 70000 in elementlist with random indices): Runtime UsrTim SysTim Count TimerName 0.517912 0.50 0.01 1: makevector 0.361448 0.33 0.01 1: makevector_listc 0.222591 0.22 0.00 1: makevector_noappend 0.221596 0.22 0.00 1: makevector_lambda 0.183666 0.19 0.00 1: makevector_operator def makevector(sourcelist,elementlist): resultvector = [] for element in elementlist: resultvector.append(sourcelist[element]) return resultvector def makevector_noappend(sourcelist, elementlist): resultvector = elementlist[:] for i in range(len(elementlist)): resultvector[i] = sourcelist[elementlist[i]] return resultvector def makevector_lambda(sourcelist,elementlist): return map(lambda i, l=sourcelist: l[i], elementlist) def makevector_listc(sourcelist,elementlist): return [sourcelist[element] for element in elementlist] def makevector_operator(sourcelist,elementlist): return map(operator.getitem, [sourcelist]*len(elementlist), elementlist) Of course, now I'm very interested in the performance of a C-implementation ;). Maybe it would help to have something like a "constant sequence" in C to avoid generating the reference-list. Then, you could write: listreferences = xReferenceList(sourcelist, len(elementlist)) return map(operator.getitem, listreferences, elementlist) Greetings, Sebastian. From djc at object-craft.com.au Wed Feb 21 15:16:26 2001 From: djc at object-craft.com.au (Dave Cole) Date: 22 Feb 2001 01:16:26 +1100 Subject: Optimisation problem - in C? References: <3a93c91b$1@netnews.web.de> Message-ID: >>>>> "sd" == Sebastian Dauss writes: sd> Of course, now I'm very interested in the performance of a sd> C-implementation ;). Maybe it would help to have something like a sd> "constant sequence" in C to avoid generating the sd> reference-list. Then, you could write: I wrote a C version - in my extremely primitive testing it seemed to be around 6 times faster. It would make more sense to test all of the techniques on the same data though. - Dave -- http://www.object-craft.com.au From sebastian.dauss at web.de Wed Feb 21 15:47:42 2001 From: sebastian.dauss at web.de (Sebastian Dauss) Date: Wed, 21 Feb 2001 15:47:42 +0100 Subject: Optimisation problem - in C? References: <3a93c91b$1@netnews.web.de> Message-ID: <3a93d19f$1@netnews.web.de> Sorry for replying to my own message, but exactly the function you need does already exist! It is included within the "mxTools" package: http://www.lemburg.com/files/python/mxTools.html and named "extract". So, what you really want (I hope so! ;) ) is: import mxTools def makevector_mxTools(sourcelist,elementlist): return mxTools.extract(sourcelist, elementlist) And for performance considerations, take this: Runtime UsrTim SysTim Count TimerName 0.474198 0.47 0.00 1: makevector 0.347249 0.34 0.00 1: makevector_listc 0.214850 0.21 0.00 1: makevector_noappend 0.212961 0.21 0.01 1: makevector_lambda 0.180423 0.18 0.00 1: makevector_operator 0.060965 0.06 0.00 1: makevector_mxTools So, using mxTools results in a runtime that is 3 times faster than the (probably) best "map-magic" in pure python. Hope that really helped ;), Sebastian. From barry at digicool.com Tue Feb 20 21:22:32 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Tue, 20 Feb 2001 15:22:32 -0500 Subject: Update to PEP 232 Message-ID: <14994.53768.767065.272158@anthem.wooz.org> After some internal discussions amongst the Pythonlabbers, we've had to make some updates to PEP 232, Function Attributes. Attached is the complete current PEP draft, also available at http://python.sourceforge.net/peps/pep-0232.html The PEP has been moved back to Draft status, but will be Accepted and Finalized for Python 2.1. It will also be propagated forward for Python 2.2 for the next step in implementation. -Barry -------------------- snip snip -------------------- PEP: 232 Title: Function Attributes Version: $Revision: 1.6 $ Author: barry at digicool.com (Barry A. Warsaw) Status: Draft Type: Standards Track Created: 02-Dec-2000 Python-Version: 2.1 / 2.2 Post-History: 20-Feb-2001 Introduction This PEP describes an extension to Python, adding attribute dictionaries to functions and methods. This PEP tracks the status and ownership of this feature. It contains a description of the feature and outlines changes necessary to support the feature. This PEP summarizes discussions held in mailing list forums, and provides URLs for further information, where appropriate. The CVS revision history of this file contains the definitive historical record. Background Functions already have a number of attributes, some of which are writable, e.g. func_doc, a.k.a. func.__doc__. func_doc has the interesting property that there is special syntax in function (and method) definitions for implicitly setting the attribute. This convenience has been exploited over and over again, overloading docstrings with additional semantics. For example, John Aycock has written a system where docstrings are used to define parsing rules[1]. Zope's ZPublisher ORB[2] uses docstrings to signal "publishable" methods, i.e. methods that can be called through the web. And Tim Peters has developed a system called doctest[3], where docstrings actually contain unit tests. The problem with this approach is that the overloaded semantics may conflict with each other. For example, if we wanted to add a doctest unit test to a Zope method that should not be publishable through the web. Proposal This proposal adds a new dictionary to function objects, called func_dict (a.k.a. __dict__). This dictionary can be set and get using ordinary attribute set and get syntax. Methods also gain `getter' syntax, and they currently access the attribute through the dictionary of the underlying function object. It is not possible to set attributes on bound or unbound methods, except by doing so explicitly on the underlying function object. See the `Future Directions' discussion below for approaches in subsequent versions of Python. A function object's __dict__ can also be set, but only to a dictionary object (i.e. setting __dict__ to UserDict raises a TypeError). Examples Here are some examples of what you can do with this feature. def a(): pass a.publish = 1 a.unittest = '''...''' if a.publish: print a() if hasattr(a, 'unittest'): testframework.execute(a.unittest) class C: def a(self): 'just a docstring' a.publish = 1 c = C() if c.a.publish: publish(c.a()) Other Uses Paul Prescod enumerated a bunch of other uses: http://mail.python.org/pipermail/python-dev/2000-April/003364.html Future Directions - A previous version of this PEP (and the accompanying implementation) allowed for both setter and getter of attributes on unbound methods, and only getter on bound methods. A number of problems were discovered with this policy. Because method attributes were stored in the underlying function, this caused several potentially surprising results: class C: def a(self): pass c1 = C() c2 = C() c1.a.publish = 1 # c2.a.publish would now be == 1 also! Because a change to `a' bound c1 also caused a change to `a' bound to c2, setting of attributes on bound methods was disallowed. However, even allowing setting of attributes on unbound methods has its ambiguities: class D(C): pass class E(C): pass D.a.publish = 1 # E.a.publish would now be == 1 also! For this reason, the current PEP disallows setting attributes on either bound or unbound methods, but does allow for getting attributes on either -- both return the attribute value on the underlying function object. The proposal for Python 2.2 is to implement setting (bound or unbound) method attributes by setting attributes on the instance or class, using special naming conventions. I.e. class C: def a(self): pass C.a.publish = 1 C.__a_publish__ == 1 # true c = C() c.a.publish = 2 c.__a_publish__ == 2 # true d = C() d.__a_publish__ == 1 # true Here, a lookup on the instance would look to the instance's dictionary first, followed by a lookup on the class's dictionary, and finally a lookup on the function object's dictionary. - Currently, Python supports function attributes only on Python functions (i.e. those that are written in Python, not those that are built-in). Should it be worthwhile, a separate patch can be crafted that will add function attributes to built-ins. - __doc__ is the only function attribute that currently has syntactic support for conveniently setting. It may be worthwhile to eventually enhance the language for supporting easy function attribute setting. Here are some syntaxes suggested by PEP reviewers: def a { 'publish' : 1, 'unittest': '''...''', } (args): # ... def a(args): """The usual docstring.""" {'publish' : 1, 'unittest': '''...''', # etc. } It isn't currently clear if special syntax is necessary or desirable. Dissenting Opinion When this was discussed on the python-dev mailing list in April 2000, a number of dissenting opinions were voiced. For completeness, the discussion thread starts here: http://mail.python.org/pipermail/python-dev/2000-April/003361.html The dissenting arguments appear to fall under the following categories: - no clear purpose (what does it buy you?) - other ways to do it (e.g. mappings as class attributes) - useless until syntactic support is included Countering some of these arguments is the observation that with vanilla Python 2.0, __doc__ can in fact be set to any type of object, so some semblance of writable function attributes are already feasible. But that approach is yet another corruption of __doc__. And while it is of course possible to add mappings to class objects (or in the case of function attributes, to the function's module), it is more difficult and less obvious how to extract the attribute values for inspection. Finally, it may be desirable to add syntactic support, much the same way that __doc__ syntactic support exists. This can be considered separately from the ability to actually set and get function attributes. Reference Implementation The reference implementation is available on SourceForge as a patch against the Python CVS tree (patch #103123). This patch doesn't include the regrtest module and output file. Those are available upon request. http://sourceforge.net/patch/?func=detailpatch&patch_id=103123&group_id=5470 This patch has been applied and will become part of Python 2.1. References [1] Aycock, "Compiling Little Languages in Python", http://www.foretec.com/python/workshops/1998-11/proceedings/papers/aycock-little/aycock-little.html [2] http://classic.zope.org:8080/Documentation/Reference/ORB [3] ftp://ftp.python.org/pub/python/contrib-09-Dec-1999/System/doctest.py Copyright This document has been placed in the Public Domain. Local Variables: mode: indented-text indent-tabs-mode: nil End: From tony at lsl.co.uk Wed Feb 21 11:06:34 2001 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Wed, 21 Feb 2001 10:06:34 -0000 Subject: Update to PEP 232 In-Reply-To: <14994.53768.767065.272158@anthem.wooz.org> Message-ID: <000901c09bed$f861d750$f05aa8c0@lslp7o.int.lsl.co.uk> Small pedantry (there's another sort?) I note that: > - __doc__ is the only function attribute that currently has > syntactic support for conveniently setting. It may be > worthwhile to eventually enhance the language for supporting > easy function attribute setting. Here are some syntaxes > suggested by PEP reviewers: [...elided to save space!...] > It isn't currently clear if special syntax is necessary or > desirable. has not been changed since the last version of the PEP. I suggest that it be updated in two ways: 1. Clarify the final statement - I seem to have the impression (sorry, can't find a message to back it up) that either the BDFL or Tim Peters is very against anything other than the "simple" #f.a = 1# sort of thing - unless I'm mischannelling (?) again. 2. Reference the thread/idea a little while back that ended with #def f(a,b) having (publish=1)# - it's certainly no *worse* than the proposals in the PEP! (Michael Hudson got as far as a patch, I think). Tibs -- Tony J Ibbs (Tibs) http://www.tibsnjoan.co.uk/ then-again-i-confuse-easily-ly y'rs - tim That's true -- I usually feel confused after reading one of your posts. - Aahz My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From guido at digicool.com Thu Feb 22 01:12:11 2001 From: guido at digicool.com (Guido van Rossum) Date: Wed, 21 Feb 2001 19:12:11 -0500 Subject: [Python-Dev] RE: Update to PEP 232 In-Reply-To: Your message of "Wed, 21 Feb 2001 10:06:34 GMT." <000901c09bed$f861d750$f05aa8c0@lslp7o.int.lsl.co.uk> References: <000901c09bed$f861d750$f05aa8c0@lslp7o.int.lsl.co.uk> Message-ID: <200102220012.TAA12047@cj20424-a.reston1.va.home.com> > Small pedantry (there's another sort?) > > I note that: > > > - __doc__ is the only function attribute that currently has > > syntactic support for conveniently setting. It may be > > worthwhile to eventually enhance the language for supporting > > easy function attribute setting. Here are some syntaxes > > suggested by PEP reviewers: > [...elided to save space!...] > > It isn't currently clear if special syntax is necessary or > > desirable. > > has not been changed since the last version of the PEP. I suggest that > it be updated in two ways: > > 1. Clarify the final statement - I seem to have the impression (sorry, > can't find a message to back it up) that either the BDFL or Tim Peters > is very against anything other than the "simple" #f.a = 1# sort of > thing - unless I'm mischannelling (?) again. Agreed. > 2. Reference the thread/idea a little while back that ended with #def > f(a,b) having (publish=1)# - it's certainly no *worse* than the > proposals in the PEP! (Michael Hudson got as far as a patch, I think). Sure, reference it. It will never be added while I'm in charge though. --Guido van Rossum (home page: http://www.python.org/~guido/) From tony at lsl.co.uk Thu Feb 22 10:02:51 2001 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Thu, 22 Feb 2001 09:02:51 -0000 Subject: [Python-Dev] RE: Update to PEP 232 In-Reply-To: <200102220012.TAA12047@cj20424-a.reston1.va.home.com> Message-ID: <001b01c09cae$3c3fa360$f05aa8c0@lslp7o.int.lsl.co.uk> Guido responded to my points thus: > > 1. Clarify the final statement - I seem to have the > > impression (sorry, can't find a message to back it up) > > that either the BDFL or Tim Peters is very against > > anything other than the "simple" #f.a = 1# sort of > > thing - unless I'm mischannelling (?) again. > > Agreed. That's a relief - I obviously had "heard" right! > > 2. Reference the thread/idea a little while back that ended > > with #def > f(a,b) having (publish=1)# ... > > Sure, reference it. It will never be added while I'm in charge > though. Well, I'd kind of assumed that, given my "memory" of the first point. But of the schemes that won't be adopted, that's the one *I* preferred. (my own sense of "locality" means that I would prefer to be placing function attributes near the declaration of the function, especially given my penchant for long docstrings which move the end of the function off-screen. But then I haven't *used* them yet, and I assume this sort of point has been taken into account. And anyway I definitely prefer your sense of language design to mine). Keep on trying not to get run over by buses, and thanks again for the neat language, Tibs -- Tony J Ibbs (Tibs) http://www.tibsnjoan.co.uk/ "Bounce with the bunny. Strut with the duck. Spin with the chickens now - CLUCK CLUCK CLUCK!" BARNYARD DANCE! by Sandra Boynton My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From embed at geocities.com Thu Feb 22 19:00:10 2001 From: embed at geocities.com (Warren Postma) Date: Thu, 22 Feb 2001 13:00:10 -0500 Subject: [Python-Dev] RE: Update to PEP 232 References: Message-ID: Has the following been considered as a 2.1+ PEP 232 improvement: def myfunc(param1,param2),{ dict here }: "doc here, or in dict" The above would also allow functions to share a dictionary: group_dict = { a:1 } def myfunc1(param1,param2),group_dict: def myfunc2(param1,param2),group_dict: The #def ...# crap looks horrible to me. Suddenly we have Comments Doing Things. Ugh! Warren From barry at digicool.com Mon Feb 26 18:57:09 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Mon, 26 Feb 2001 12:57:09 -0500 Subject: [Python-Dev] RE: Update to PEP 232 References: <14994.53768.767065.272158@anthem.wooz.org> <000901c09bed$f861d750$f05aa8c0@lslp7o.int.lsl.co.uk> Message-ID: <15002.39157.936988.699980@anthem.wooz.org> >>>>> "TJI" == Tony J Ibbs writes: TJI> 1. Clarify the final statement - I seem to have the TJI> impression (sorry, can't find a message to back it up) that TJI> either the BDFL or Tim Peters is very against anything other TJI> than the "simple" #f.a = 1# sort of thing - unless I'm TJI> mischannelling (?) again. >From the next draft of the PEP: "The BDFL is currently against any such special syntactic support for setting arbitrary function attributes." TJI> 2. Reference the thread/idea a little while back that ended TJI> with #def f(a,b) having (publish=1)# - it's certainly no TJI> *worse* than the proposals in the PEP! (Michael Hudson got as TJI> far as a patch, I think). Any possibility that you have a url for this reference? -Barry From syver at NOSPAMcyberwatcher.com Tue Feb 20 22:07:10 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Tue, 20 Feb 2001 22:07:10 +0100 Subject: pythoncom.Missing vs. pythoncom.Empty Message-ID: <96umec$pks$1@troll.powertech.no> Hi, what's the deal with pythoncom.Missing/Empty? I've found while working with the MSMQ (MessageQueue) through COM on Win32 that default arguments don't work unless I change the definitions of defaultNamedOptArg to pythoncom.Empty. I am aware that the generated source states that there might be a reason to try this, but why, and what is the difference between them? It would also be very good to be able to specify in the gencache statement what to use for the various values so that one wouldn't have to use custom edited genpy files. From MarkH at ActiveState.com Tue Feb 20 23:23:16 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 20 Feb 2001 22:23:16 GMT Subject: pythoncom.Missing vs. pythoncom.Empty References: <96umec$pks$1@troll.powertech.no> Message-ID: <3A92ED79.101@ActiveState.com> Syver Enstad wrote: > Hi, what's the deal with pythoncom.Missing/Empty? > > I've found while working with the MSMQ (MessageQueue) through COM on Win32 > that default arguments don't work unless I change the definitions of > defaultNamedOptArg to pythoncom.Empty. > > I am aware that the generated source states that there might be a reason to > try this, but why, and what is the difference between them? It would also be > very good to be able to specify in the gencache statement what to use for > the various values so that one wouldn't have to use custom edited genpy > files. The different is in the way the args are presented. "Empty" means the arg is presented with a type of VT_EMPTY. Missing means the arg is not even presented to the object. I have heard this reported before. It is "Missing" simply due to Office 95!! I should change this and see who screams - my guess is noone any more! Mark. -- Nominate Your Favorite Programmers for the Perl and Python Active Awards! http://www.ActiveState.com/Awards/ From mkx at excite.com Tue Feb 20 23:34:22 2001 From: mkx at excite.com (mkx at excite.com) Date: Tue, 20 Feb 2001 17:34:22 -0500 Subject: ZLIB decompressing only portion of data Message-ID: I am experimenting with the ZLIB module to decompress some .ZLB files I have acquired. The script below properly decompresses only the first segment of the compressed file. For example, a 10KB .ZLB comressed file only returns a 546 character string from the example below. What have I done wrong? ### import os, zlib fd=os.open('d:/temp/zlb/snippets.zlb', os.O_RDONLY | os.O_BINARY ) ch=os.read(fd,1) while ch: zlb=zlb+ch ch=os.read(fd,1) os.close(fd) print len(zlb) str = zlib.decompress(zlb) print str print len(str) From mkx at excite.com Tue Feb 20 23:52:23 2001 From: mkx at excite.com (mkx at excite.com) Date: Tue, 20 Feb 2001 17:52:23 -0500 Subject: ZLIB decompressing only portion of data References: Message-ID: Of course, there is a better way to implement my test script (see below), but I still get the same results. The input sample is 9,859 bytes long, where the string returned by the decompress method is only 546 bytes in length. ### import os, zlib fd=os.open('d:/temp/zlb/snippets.zlb', os.O_RDONLY | os.O_BINARY ) dco=zlib.decompressobj(15) str=dco.decompress(os.read(fd,16384)) print len(str) #print str From amk at mira.erols.com Wed Feb 21 01:51:16 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 21 Feb 2001 00:51:16 GMT Subject: ZLIB decompressing only portion of data References: Message-ID: On Tue, 20 Feb 2001 17:52:23 -0500, mkx at excite.com wrote: >str=dco.decompress(os.read(fd,16384)) zlib often buffers data internally; try adding 'str = str + dco.flush()' and see if you get more output. --amk From fredrik at pythonware.com Wed Feb 21 07:23:14 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Feb 2001 06:23:14 GMT Subject: ZLIB decompressing only portion of data References: Message-ID: mkx at excite.com wrote: > Of course, there is a better way to implement my test script (see > below), but I still get the same results. The input sample is 9,859 > bytes long, where the string returned by the decompress method is only > 546 bytes in length. what's wrong with using "open" like everyone else? > import os, zlib > > fd=os.open('d:/temp/zlb/snippets.zlb', os.O_RDONLY | os.O_BINARY ) file = open("d:/temp/zlb/snippets.zlb", "rb") > dco=zlib.decompressobj(15) dco = zlib.decompressobj() # 15 is default > str=dco.decompress(os.read(fd,16384)) str = dco.decompress(file.read(16384)) str = str + dco.flush() # get rest of data > print len(str) > #print str for more info on decompress/flush, see the docs (under "decompression objects"): http://www.python.org/doc/current/lib/module-zlib.html (and of course, if the files are smaller than a couple of megabytes uncompressed, it's better to use zlib.decompress...) Cheers /F From mkx at excite.com Wed Feb 21 17:03:06 2001 From: mkx at excite.com (mkx at excite.com) Date: Wed, 21 Feb 2001 11:03:06 -0500 Subject: ZLIB decompressing only portion of data References: Message-ID: <71p79tk1c3448i50k9cdjc9nlj0dl898o3@4ax.com> On Wed, 21 Feb 2001 06:23:14 GMT, "Fredrik Lundh" wrote: >mkx at excite.com wrote: >> Of course, there is a better way to implement my test script (see >> below), but I still get the same results. The input sample is 9,859 >> bytes long, where the string returned by the decompress method is only >> 546 bytes in length. > >what's wrong with using "open" like everyone else? Nothing! Python is new to me, and sometimes I take the long way around. In this case, I tried "open", but in the process of determining that the file needed to be opened as Binary, I found my self at os.open, instead of open(,"rb"). <...> >str = dco.decompress(file.read(16384)) >str = str + dco.flush() # get rest of data Ah...Through trial and error, I was only successful (partially) by using dco.unused_data, but then I had to recreate the decompress object with each iteration when .unusued_data was present. It appears that the .decompress method is only decompressing the first "segment" of the data. At this point I am unsure what delimits the segments. >for more info on decompress/flush, see the docs (under >"decompression objects"): > >http://www.python.org/doc/current/lib/module-zlib.html > >(and of course, if the files are smaller than a couple of megabytes >uncompressed, it's better to use zlib.decompress...) That is where I started, but then I ran in to the problem with only the first segment of the data being uncompressed. Using the decompress object is the only thing I have working so far. From mkx at excite.com Wed Feb 21 17:24:26 2001 From: mkx at excite.com (mkx at excite.com) Date: Wed, 21 Feb 2001 11:24:26 -0500 Subject: ZLIB decompressing only portion of data References: Message-ID: <3lq79t4b000o9vvndsvjm9lllfon3bdvod@4ax.com> On Wed, 21 Feb 2001 06:23:14 GMT, "Fredrik Lundh" wrote: >str = dco.decompress(file.read(16384)) >str = str + dco.flush() # get rest of data This methodology still only returns the first segment of uncompressed data. So far, only the following works, returning about 12K of uncompressed data, before returning an Error -3 while decompressing: unknown compression method. ### import zlib fd=open('d:/temp/zlb/snippets.zlb', 'rb' ) of=open('d:/temp/zlb/snippets.dat','w') dco = zlib.decompressobj() str = dco.decompress(fd.read(16384)) of.write(str) while dco.unused_data: ustr = dco.unused_data dco=zlib.decompressobj() # Having to recreate the dco object # each time, otherwise further data # not returned str=dco.decompress(ustr) of.write(str) From paul at fxtech.com Wed Feb 21 00:04:21 2001 From: paul at fxtech.com (Paul Miller) Date: Tue, 20 Feb 2001 17:04:21 -0600 Subject: docs on using "new" PyTypeObject entries? Message-ID: <3A92F7F5.F930DC55@fxtech.com> Where can I find some documentation on how to use the tp_traverse, tp_clear, tp_getattro, etc slots in the PyTypeObject? I just discovered them and don't know what they do. From paul at fxtech.com Wed Feb 21 00:25:25 2001 From: paul at fxtech.com (Paul Miller) Date: Tue, 20 Feb 2001 17:25:25 -0600 Subject: give an extension type a __dict__? Message-ID: <3A92FCE5.9CD17BE5@fxtech.com> Is it possible to give an extension type a __dict__ to store type-specific constants? Assume we create a Point object in C: PyTypeObject point_type_info = { PyObject_HEAD_INIT(&PyType_Type) 0, // ob_size "Point", // tp_name sizeof(PointType), // tp_basicsize 0, // tp_itemsize etc... In Python, I can create one of these: from point import Point p = Point() But since my Point type *acts* like I class, I'd like to scope some constants into its namespace, so I can do this: p = Point.ZERO I realize I can put constants at the module scope in the module's dictionary, but if I have many extension types, the global namespace would be polluted. Is this even possible? From root at rainerdeyke.com Wed Feb 21 04:49:13 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 21 Feb 2001 03:49:13 GMT Subject: give an extension type a __dict__? References: <3A92FCE5.9CD17BE5@fxtech.com> Message-ID: "Paul Miller" wrote in message news:3A92FCE5.9CD17BE5 at fxtech.com... > Is it possible to give an extension type a __dict__ to store > type-specific constants? Assume we create a Point object in C: > > PyTypeObject point_type_info = > { > PyObject_HEAD_INIT(&PyType_Type) > 0, // ob_size > "Point", // tp_name > sizeof(PointType), // tp_basicsize > 0, // tp_itemsize > > etc... > > In Python, I can create one of these: > > from point import Point > p = Point() > > But since my Point type *acts* like I class, I'd like to scope some > constants into its namespace, so I can do this: You should realize that the name 'Point' within Python does not refer to a type, but a function (type 'builtin_function_or_method'). You can easily (or maybe not so easily) modify the extension module so that 'Point' is instead an object that acts like a function but also has additional properties, such as the ability to hold attributes. This is totally different from modifying the actual type 'Point'. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From tjg at exceptionalminds.com Wed Feb 21 00:42:48 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Tue, 20 Feb 2001 15:42:48 -0800 Subject: Case insensitive re.sub() Message-ID: <20010220154248.L15226@trufflehunter.avalongroup.net> Hi all, I am working on a little project where it would be really nice to be able to do a case insensitive re.sub(). It appears that re.sub() does not allow a flags argument. Is it possible, or do I have to roll my own? 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: 35 days 3:54 hours ago<< From aahz at panix.com Wed Feb 21 01:13:44 2001 From: aahz at panix.com (Aahz Maruch) Date: 20 Feb 2001 16:13:44 -0800 Subject: Case insensitive re.sub() References: Message-ID: <96v17o$h53$1@panix6.panix.com> In article , Timothy Grant wrote: > >I am working on a little project where it would be really nice >to be able to do a case insensitive re.sub(). It appears that >re.sub() does not allow a flags argument. Is it possible, or do >I have to roll my own? import re regex = re.compile('foo', re.I) print regex.sub('bar','FOOBAR') -- --- 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 The problem with an ever-changing .sig is that you have to keep changing it From tjg at exceptionalminds.com Wed Feb 21 02:09:35 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Tue, 20 Feb 2001 17:09:35 -0800 Subject: Case insensitive re.sub() In-Reply-To: <96v17o$h53$1@panix6.panix.com>; from aahz@panix.com on Tue, Feb 20, 2001 at 04:13:44PM -0800 References: <96v17o$h53$1@panix6.panix.com> Message-ID: <20010220170935.S15226@trufflehunter.avalongroup.net> Thanks Aazh. That did the trick beautifully. On Tue, Feb 20, 2001 at 04:13:44PM -0800, Aahz Maruch wrote: > In article , > Timothy Grant wrote: > > > >I am working on a little project where it would be really nice > >to be able to do a case insensitive re.sub(). It appears that > >re.sub() does not allow a flags argument. Is it possible, or do > >I have to roll my own? > > import re > regex = re.compile('foo', re.I) > print regex.sub('bar','FOOBAR') -- 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: 35 days 5:20 hours ago<< From aleaxit at yahoo.com Wed Feb 21 10:34:59 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 21 Feb 2001 10:34:59 +0100 Subject: Case insensitive re.sub() References: Message-ID: <97024702ogj@news1.newsguy.com> "Timothy Grant" wrote in message news:mailman.982712484.28722.python-list at python.org... > Hi all, > > I am working on a little project where it would be really nice > to be able to do a case insensitive re.sub(). It appears that > re.sub() does not allow a flags argument. Is it possible, or do > I have to roll my own? 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 re >>> cre=re.compile('pip',re.IGNORECASE) >>> cre.sub("A pip and a PIPpop", 'plup') 'plup' >>> cre.sub('plup', "A pip and a PIPpop") 'A plup and a pluppop' >>> Alex From fredrik at pythonware.com Wed Feb 21 11:29:27 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Feb 2001 10:29:27 GMT Subject: Case insensitive re.sub() References: Message-ID: Timothy Grant wrote: > I am working on a little project where it would be really nice > to be able to do a case insensitive re.sub(). It appears that > re.sub() does not allow a flags argument. Is it possible, or do > I have to roll my own? add the flags to the pattern instead: "(?i)pattern" makes "pattern" case-insensitive. (note that there are issues with uppercase characters in case- insensitive patterns in 2.0; to be on the safe side, only use lowercase characters in case-insensitive patterns. or use 2.1) Cheers /F From aahz at panix.com Wed Feb 21 16:00:39 2001 From: aahz at panix.com (Aahz Maruch) Date: 21 Feb 2001 07:00:39 -0800 Subject: Case insensitive re.sub() References: Message-ID: <970l6n$1bb$1@panix3.panix.com> In article , Fredrik Lundh wrote: > >(note that there are issues with uppercase characters in case- >insensitive patterns in 2.0; to be on the safe side, only use >lowercase characters in case-insensitive patterns. or use 2.1) Or install the new sre package you just released? -- --- 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 The problem with an ever-changing .sig is that you have to keep changing it From insanc at cc.gatech.edu Wed Feb 21 00:55:54 2001 From: insanc at cc.gatech.edu (Joseph Holland King) Date: 20 Feb 2001 23:55:54 GMT Subject: locking files Message-ID: <96v06a$l16$1@solaria.cc.gatech.edu> is there anyway to lock a file so that two different programs cannot access the file at the same time. ie, my python module is editting file foo, and at the same time user x (or program x) tries to read from it. is there anyway that the python module can prevent x from accessing the file for a given amount of time? -- --- 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 insanc at cc.gatech.edu Wed Feb 21 15:48:34 2001 From: insanc at cc.gatech.edu (Joseph Holland King) Date: 21 Feb 2001 14:48:34 GMT Subject: locking files References: <96v06a$l16$1@solaria.cc.gatech.edu> Message-ID: <970kg2$cn0$1@solaria.cc.gatech.edu> Joseph Holland King wrote: : is there anyway to lock a file so that two different programs cannot access : the file at the same time. ie, my python module is editting file foo, and : at the same time user x (or program x) tries to read from it. is there : anyway that the python module can prevent x from accessing the file for : a given amount of time? to clarify: i am on a unix system, i have tried to use flock however when i locked the file i was still able to read, write and copy the file, none of which i want to happen while the file is locked. while using the flock method i was using LOCK_EX. also the third party program is not going to be controlled, written, or have anything to do with mine. am i just not using flock properly or is there something else that might do the job? thank you. -- --- 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 dnew at san.rr.com Wed Feb 21 19:18:34 2001 From: dnew at san.rr.com (Darren New) Date: Wed, 21 Feb 2001 18:18:34 GMT Subject: locking files References: <96v06a$l16$1@solaria.cc.gatech.edu> <970kg2$cn0$1@solaria.cc.gatech.edu> Message-ID: <3A94067B.AB98CE53@san.rr.com> Joseph Holland King wrote: > flock properly or is there something else that might do the job? thank you. On some UNIXes, there's a bit you set on the file (like, group sticky bit or something) that means "No, really, lock the @*$& file already!" You may need to set this. Try chmod g-x my_file chmod g+l my_file and see if the locking continues to fail. -- Darren New / Senior MTS & Free Radical / Invisible Worlds Inc. San Diego, CA, USA (PST). Cryptokeys on demand. Ignorance can be cured. Naivety cures itself. From donn at u.washington.edu Wed Feb 21 19:40:57 2001 From: donn at u.washington.edu (Donn Cave) Date: 21 Feb 2001 18:40:57 GMT Subject: locking files References: <96v06a$l16$1@solaria.cc.gatech.edu> <970kg2$cn0$1@solaria.cc.gatech.edu> Message-ID: <97123p$ojg$1@nntp6.u.washington.edu> Quoth Joseph Holland King : | Joseph Holland King wrote: | : is there anyway to lock a file so that two different programs cannot access | : the file at the same time. ie, my python module is editting file foo, and | : at the same time user x (or program x) tries to read from it. is there | : anyway that the python module can prevent x from accessing the file for | : a given amount of time? | | to clarify: i am on a unix system, i have tried to use flock however when i | locked the file i was still able to read, write and copy the file, none of | which i want to happen while the file is locked. while using the flock | method i was using LOCK_EX. also the third party program is not going to be | controlled, written, or have anything to do with mine. am i just not using | flock properly or is there something else that might do the job? thank you. Basically, that's how file locking works. It's advisory, for the benefit of software components that are designed to work together. But there is a variation that you can find supported on some filesystems, where in combination with an obscure permission mode on the file the lock becomes mandatory and effective against any and all I/O. The permission trick is setgid & not group execute, i.e., (oldperm | 02000) & ~010. It works for me on Digital UNIX local (AdvFS) filesystem. I didn't try on NFS, but from the documentation I doubt that it will work there. It does not work on NetBSD 1.5 local filesystem. Where it does work, you must use fcntl() or lockf() to obtain the lock, not a genuine flock(). While I'm here, let me add a little note about flock(), for the benefit of those whose UNIX platforms don't have the deluxe man pages that you get on NetBSD for example. There are two kinds of locks, one obtained by Berkeley flock() and the other by POSIX 1003.1 fcntl(). The lockf() function is a different, X/Open interface that interoperates with fcntl(). Many modern platforms do not support a genuine flock(). Some of them provide an flock() function that is actually implemented with fcntl(), which means that the semantics of the lock are per fcntl() and not flock(). Python follows this trend and does the same thing if there's no flock(2), so it's up to the programmer to find out what kind of lock fcntl.flock() really gets, if the difference is important. Donn Cave, donn at u.washington.edu From grante at visi.com Thu Feb 22 00:44:02 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 21 Feb 2001 23:44:02 GMT Subject: locking files References: <96v06a$l16$1@solaria.cc.gatech.edu> <970kg2$cn0$1@solaria.cc.gatech.edu> <97123p$ojg$1@nntp6.u.washington.edu> Message-ID: In article <97123p$ojg$1 at nntp6.u.washington.edu>, Donn Cave wrote: >| to clarify: i am on a unix system, i have tried to use flock however when i >| locked the file i was still able to read, write and copy the file, none of >| which i want to happen while the file is locked. while using the flock >| method i was using LOCK_EX. also the third party program is not going to be >| controlled, written, or have anything to do with mine. am i just not using >| flock properly or is there something else that might do the job? thank you. > >Basically, that's how file locking works. IOW, it doesn't. ;) Really -- file locking under Unix is a royal mess and always has been. Throw NFS into the picture and it's pretty much hopeless. >It's advisory, for the benefit of software components that are designed to >work together. And then it's rarely portable, and there are about seven people on the planet that understand what syscalls work on what systems and how to use them. I am not among those seven. Here's a quick hack: When you want to "lock" the file, rename it. I think that on most Unices and filesystems a rename is an atomic operation (not sure, about that). I don't know how you're going to tell if the other program is using the file. >But there is a variation that you can find supported on some filesystems, >where in combination with an obscure permission mode on the file the lock >becomes mandatory and effective against any and all I/O. The permission [...] flock(2), so it's up to the programmer to find out what kind of lock >fcntl.flock() really gets, if the difference is important. Donn may be among the seven. ;) -- Grant Edwards grante Yow! I hope the at "Eurythmics" practice birth visi.com control... From chris.gonnerman at usa.net Fri Feb 23 04:55:00 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Thu, 22 Feb 2001 21:55:00 -0600 Subject: locking files References: <96v06a$l16$1@solaria.cc.gatech.edu> <970kg2$cn0$1@solaria.cc.gatech.edu> <97123p$ojg$1@nntp6.u.washington.edu> Message-ID: <00d301c09d4c$6ade4200$a100000a@local> ----- Original Message ----- From: "Grant Edwards" Subject: Re: locking files > Here's a quick hack: When you want to "lock" the file, rename it. I think > that on most Unices and filesystems a rename is an atomic operation (not > sure, about that). I don't know how you're going to tell if the other > program is using the file. Renaming on Windows may be atomic, but on Unix/Linux/BSD etc. it is the combination of link() and unlink() system calls, so that for a moment the file has two names. Also, on Unixoid OS's, if process A has a file open and process B renames it, process A still has the same file (inode) open and doesn't know about the rename... EXCEPT if the file is on a remote NFS file system, in which case process A will either start getting errors or have "undefined behavior" when it tries to use the "open" file. On Windoze, you may be prevented from renaming the file if it is open in another process, or you may succeed and cause the other process to have errors. In other words, renaming is not necessarily a solution. From erno-news at erno.iki.fi Fri Feb 23 05:18:24 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 23 Feb 2001 06:18:24 +0200 Subject: locking files References: <96v06a$l16$1@solaria.cc.gatech.edu> <970kg2$cn0$1@solaria.cc.gatech.edu> <97123p$ojg$1@nntp6.u.washington.edu> Message-ID: In article , "Chris Gonnerman" writes: | on Unix/Linux/BSD etc. it is the combination of link() and unlink() | system calls, so that for a moment the file has two names. at least on linux rename is a syscall, and the man page seems to say that the operation will be atomic if the destination path doesn't exist. | Also, on Unixoid OS's, if process A | has a file open and process B renames it, process A still has the same file | (inode) open and doesn't know about the rename... EXCEPT if the | file is on a remote NFS file system, in which case process A will either | start getting errors or have "undefined behavior" when it tries to use the | "open" file. On Windoze, you may be prevented from renaming the file | if it is open in another process, or you may succeed and cause the other | process to have errors. well, nfs doesn't pretend to offer unix filesystem semantics anyway, usually it's not necessary to worry about how things work with it. -- erno From chris.gonnerman at usa.net Fri Feb 23 05:47:19 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Thu, 22 Feb 2001 22:47:19 -0600 Subject: locking files References: <96v06a$l16$1@solaria.cc.gatech.edu> <970kg2$cn0$1@solaria.cc.gatech.edu> <97123p$ojg$1@nntp6.u.washington.edu> Message-ID: <017201c09d53$b5463ee0$a100000a@local> ----- Original Message ----- From: "Erno Kuusela" Subject: Re: locking files > at least on linux rename is a syscall, and the man page seems > to say that the operation will be atomic if the destination > path doesn't exist. Huh. You learn something new every day. > well, nfs doesn't pretend to offer unix filesystem semantics anyway, > usually it's not necessary to worry about how things work with it. Usually. But if you plan to use renaming to sub for locking, you need to know this. From clee at gnwy100.wuh.wustl.edu Wed Feb 21 20:27:45 2001 From: clee at gnwy100.wuh.wustl.edu (Christopher Lee) Date: 21 Feb 2001 13:27:45 -0600 Subject: locking files References: <96v06a$l16$1@solaria.cc.gatech.edu> <970kg2$cn0$1@solaria.cc.gatech.edu> Message-ID: <7ulmqzu98u.fsf@gnwy100.wuh.wustl.edu> Joseph Holland King wrote: : is there anyway to lock a file so that two different programs cannot access : the file at the same time. ie, my python module is editting file foo, and : at the same time user x (or program x) tries to read from it. is there : anyway that the python module can prevent x from accessing the file for : a given amount of time? : to clarify: i am on a unix system, i have tried to use flock however when i : locked the file i was still able to read, write and copy the file, none of : which i want to happen while the file is locked. while using the flock : method i was using LOCK_EX. also the third party program is not going to be : controlled, written, or have anything to do with mine. am i just not using : flock properly or is there something else that might do the job? thank you. flock() is an advisory lock, if you don't have cooperation from the other processes, and if your system supports the SysV interface you can enable mandatory locks. "man lockf" or "man fcntl" and search for information on SysV mandatory locking on your system. Files are marked as candidates for mandatory file locking by setting the file mode with SGID but without the "group execute" bits, (chmod g+s; chmod g-x). Enabling mandatory locking is system dependent, but you need to use fnctl/lockf, flock is always advisory. Under linux, I can do it like this: [as root] # enable file locking by remounting /home file system w/ mand flag mount -o remount -o mand /home [as normal user] > chmod g+s tmp; chmod g-x tmp > python >> import fcntl, FCNTL >> fp = open("tmp", "rw") >> fd = fp.fileno() >> fcntl.lockf(fd, FCNTL.F_LOCK) # secures the lock, prevents # reading/writing From clee at gnwy100.wuh.wustl.edu Wed Feb 21 20:42:36 2001 From: clee at gnwy100.wuh.wustl.edu (Christopher Lee) Date: 21 Feb 2001 13:42:36 -0600 Subject: locking files References: <96v06a$l16$1@solaria.cc.gatech.edu> <970kg2$cn0$1@solaria.cc.gatech.edu> <7ulmqzu98u.fsf@gnwy100.wuh.wustl.edu> Message-ID: <7uitm3u8k3.fsf@gnwy100.wuh.wustl.edu> >>>>> "Christopher" == Christopher Lee writes: >> chmod g+s tmp; chmod g-x tmp python >>> import fcntl, FCNTL fp = open("tmp", "rw") fd = fp.fileno() >>> fcntl.lockf(fd, FCNTL.F_LOCK) # secures the lock, prevents Oops, FCNTL.F_LOCK is wrong here (although when I typed it in the example worked by coincidence). Looking at the python source of fcntlmodule.c, it's actually asking for fcntl's LOCK_EX, LOCK_SH, LOCK_UN, or LOCK_NB. -chris #ifndef LOCK_SH #define LOCK_SH 1 /* shared lock */ #define LOCK_EX 2 /* exclusive lock */ #define LOCK_NB 4 /* don't block when locking */ #define LOCK_UN 8 /* unlock */ From insanc at cc.gatech.edu Wed Feb 21 21:50:55 2001 From: insanc at cc.gatech.edu (Joseph Holland King) Date: 21 Feb 2001 20:50:55 GMT Subject: locking files References: <96v06a$l16$1@solaria.cc.gatech.edu> <970kg2$cn0$1@solaria.cc.gatech.edu> <7ulmqzu98u.fsf@gnwy100.wuh.wustl.edu> Message-ID: <9719nf$lmf$1@solaria.cc.gatech.edu> Christopher Lee wrote: : [as normal user] :> chmod g+s tmp; chmod g-x tmp :> python :>> import fcntl, FCNTL :>> fp = open("tmp", "rw") :>> fd = fp.fileno() :>> fcntl.lockf(fd, FCNTL.F_LOCK) # secures the lock, prevents : # reading/writing following this i tried this code: import FCNTL, fcntl int_temp = 999999 fd = open("ftbl", "wr") fd1 = fd.fileno() fcntl.lockf(fd1, FCNTL.LOCK_EX) while(int_temp > 0): int_temp = int_temp - 1 fcntl.lockf(fd1, FCNTL.LOCK_UN) fd.close() and then after did the following: {gypsy:gte743n:116} cat mbox > ftbl {gypsy:gte743n:117} python testlock.py {gypsy:gte743n:118} more ftbl as you can see i cated my mailbox into ftbl and the ran the script the script however empties the file. is there something in my code that is causing this or is there something i am not doing? thank you. -- 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 clee at gnwy100.wuh.wustl.edu Wed Feb 21 22:34:34 2001 From: clee at gnwy100.wuh.wustl.edu (Christopher Lee) Date: 21 Feb 2001 15:34:34 -0600 Subject: locking files References: <96v06a$l16$1@solaria.cc.gatech.edu> <970kg2$cn0$1@solaria.cc.gatech.edu> <7ulmqzu98u.fsf@gnwy100.wuh.wustl.edu> <9719nf$lmf$1@solaria.cc.gatech.edu> Message-ID: <7ubsrvu3dh.fsf@gnwy100.wuh.wustl.edu> chris> fp = open("tmp", "rw") oops, indicision on my part. see below > fd = open("ftbl", "wr") The "w" truncates the file. You probably want either "r" or "r+" or "a+" see the python library reference on open or the C fopen call. try fd = open("ftbl", "r+") -chris From ron_clarke at hp.com Wed Feb 21 01:04:24 2001 From: ron_clarke at hp.com (Ron Clarke) Date: Tue, 20 Feb 2001 16:04:24 -0800 Subject: Object type from a Python extension Message-ID: <96v476$72k$1@news.vcd.hp.com> I am creating a shared library (Win32 DLL and Linux '.so') using C++. I have it all wired up and working from both environments, but I cannot understand how to get Python scripts to recognize an object created in the C++ code. For example: class something( ) { //some variables //some public methods }; something* ps = new something() //...do stuff with ps object //Now when I pass the ps object back to Python using Py_BuildValue(...), the Python script knows about the object, but does not know it is of type 'something'. I'm obviously missing some connection, but have been through all the extending and embedding documentation, along with a few Python books, and don't see it. Any ideas? Thanks. From rwklee at home.com Wed Feb 21 01:05:27 2001 From: rwklee at home.com (Rick Lee) Date: Wed, 21 Feb 2001 00:05:27 GMT Subject: Is there an easier-to-use module than ftplib? Message-ID: <3A930645.761A82C8@home.com> Is there an easier-to-use module than ftplib in the standard library, for both uploading and downloading files? I can't use urllib because it does not support uploading, it seems; and I am hoping I don't have to learn FTP itself, which is required somewhat by ftplib. - Rick Lee From othello at javanet.com Wed Feb 21 01:36:37 2001 From: othello at javanet.com (Raymond Hettinger) Date: Tue, 20 Feb 2001 19:36:37 -0500 Subject: Is there an easier-to-use module than ftplib? References: <3A930645.761A82C8@home.com> Message-ID: <3A930D95.2DC3B98C@javanet.com> Rick Lee wrote: > Is there an easier-to-use module than ftplib in the standard library, > for both uploading and downloading files? I can't use urllib because it > does not support uploading, it seems; and I am hoping I don't have to > learn FTP itself, which is required somewhat by ftplib. > > - Rick Lee I felt frustrated with ftplib.py at first because the documentation pre-supposes that you already know the ftp commands. I made the following quick notes which show an examples that cover 95% of what you might want to do with ftp: from ftplib import * f = FTP('ftp.javanet.com','username','password') f.retrlines('LIST') # or f.dir() to list the directory f.cwd('public_html') # change directory r = open('random.htm','w') f.retrlines('retr random.htm',r.write) # download a text file r.close() r = open('quoter.pyw','rb') # upload a binary file f.storbinary('STOR quoter.pyw',r,512) r.close() f.rename('quoter.pyw','q.pyw') # rename a file f.delete('q.pyw') # delete a file f.quit() # terminate the session Hope these note help, Raymond From rwklee at home.com Wed Feb 21 03:09:02 2001 From: rwklee at home.com (Rick Lee) Date: Wed, 21 Feb 2001 02:09:02 GMT Subject: Is there an easier-to-use module than ftplib? References: <3A930645.761A82C8@home.com> <3A930D95.2DC3B98C@javanet.com> Message-ID: <3A932336.71661B16@home.com> Thanks! That looks simple enough. Do I have to worry about active vs. passive mode? Raymond Hettinger wrote: > Rick Lee wrote: > > > Is there an easier-to-use module than ftplib in the standard library, > > for both uploading and downloading files? I can't use urllib because it > > does not support uploading, it seems; and I am hoping I don't have to > > learn FTP itself, which is required somewhat by ftplib. > > > > - Rick Lee > > I felt frustrated with ftplib.py at first because the documentation > pre-supposes that you already know the ftp commands. > > I made the following quick notes which show an examples that cover > 95% of what you might want to do with ftp: > > from ftplib import * > f = FTP('ftp.javanet.com','username','password') > f.retrlines('LIST') # or f.dir() to list the directory > f.cwd('public_html') # change directory > > r = open('random.htm','w') > f.retrlines('retr random.htm',r.write) # download a text file > r.close() > > r = open('quoter.pyw','rb') # upload a binary file > f.storbinary('STOR quoter.pyw',r,512) > r.close() > > f.rename('quoter.pyw','q.pyw') # rename a file > f.delete('q.pyw') # delete a file > > f.quit() # terminate the session > > Hope these note help, > > Raymond From sholden at holdenweb.com Wed Feb 28 19:27:02 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 28 Feb 2001 13:27:02 -0500 Subject: Is there an easier-to-use module than ftplib? References: <3A930645.761A82C8@home.com> <3A930D95.2DC3B98C@javanet.com> <3A932336.71661B16@home.com> Message-ID: "Rick Lee" wrote in message news:3A932336.71661B16 at home.com... > Thanks! That looks simple enough. Do I have to worry about active vs. > passive mode? > You shouldn't: most servers will work either way. Note that the ftplib software is (AFAICR) dure to change its default behavior to passive with the 2.1 release. regards Steve From stevemak at softhome.net Wed Feb 21 01:22:10 2001 From: stevemak at softhome.net (Steve Mak) Date: Wed, 21 Feb 2001 00:22:10 GMT Subject: Carel Fellinger: one more question Message-ID: <3A930C5E.4869355C@softhome.net> I need to output some data to an output file. I am using: outp = open("output.txt","w") outp.write(data) outp.close() my problem is i need to have some data on separate lines. right now everything is saved as 1 long line of data. how do I specify a carriage return to the output file? From adam at deprince.net Tue Feb 20 02:57:27 2001 From: adam at deprince.net (Adam DePrince) Date: Mon, 19 Feb 2001 20:57:27 -0500 Subject: Carel Fellinger: one more question References: <3A930C5E.4869355C@softhome.net> Message-ID: <3A91CF07.1DA27722@deprince.net> Steve Mak wrote: > > I need to output some data to an output file. I am using: > > outp = open("output.txt","w") > outp.write(data) > outp.close() > > my problem is i need to have some data on separate lines. right now > everything is saved as 1 long line of data. how do I specify a carriage > return to the output file? Assuming that data is a sequence, each member representing the contents of a line (as opposed to the one-big-blob implied about) you can do this: outp = open("output.txt","w") outp.write(string.join(data, "\n")) outp.close() If you are using Python 2.0 of better you can say: outp = open("output.txt","w") for line in data: print >> outp, line outp.close() Or, if you lack a version <2.0, but not courage, you can: outp = open("output.txt", "w" ) old_stdout = sys.stdout sys.stdout = outp for line in data: print line sys.stdout = old_stdout outp.close() Just make sure your other threads don't disagree with your mistreatment of stdout ... To see where I ripped off my explanation: http://www.python.org/2.0/new-python.html Search for "9.1" or "Minor Language Changes." Adam DePrince Starmedia Network, Inc. Email: zlib.decompress('x\332KLI\314\325KI-(\312\314KNu(.I,\312MM\311L\324K\316\317\005\000\221\331\012s') From fredrik at pythonware.com Wed Feb 21 07:42:28 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Feb 2001 06:42:28 GMT Subject: Carel Fellinger: one more question References: <3A930C5E.4869355C@softhome.net> Message-ID: Steve Mak wrote: > I need to output some data to an output file. I am using: > > outp = open("output.txt","w") > outp.write(data) > outp.close() > > my problem is i need to have some data on separate lines. right now > everything is saved as 1 long line of data. how do I specify a carriage > return to the output file? outp.write("\n") Cheers /F From phd at phd.russ.ru Wed Feb 21 02:03:49 2001 From: phd at phd.russ.ru (Oleg Broytmann) Date: 20 Feb 2001 19:03:49 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Feb 20) Message-ID: Michael Hudson continues Python-dev Summaries after AMK. Thanks, Mike! http://lwn.net/daily/pydev-20010215.php3 Pete Shinners announces new version (0.9) of pygame http://groups.google.com/groups?q=ANN:+pygame-0.9&hl=en&lr=&safe=off&rnum=1&ic=1 LAMP (Linux, Apache, MySql, and Python) in action http://linuxpr.com/releases/3326.html Suchandra S Thapa moves Siphon project to SourceForge http://groups.google.com/groups?q=Suchandra+S+Thapa+Re:+CPAN+functionality+for+python&hl=en&lr=&safe=off&rnum=1&ic=1 Mark Hammond announces new version of win32com that allows you to implement any COM interface decribed in a type library, either IDispatch based or not http://groups.google.com/groups?q=Mark+Hammond+COM+support+for+vtable+based+interfaces&hl=en&lr=&safe=off&rnum=1&ic=1 ActiveState invites nominations for scripting community heroes http://www.activestate.com/Corporate/Communications/Releases/Awards Moop project (MUD, Object Oriented, Pythonic) is now hosted at SourceForge http://moop.sourceforge.net/ /F, as usual, shows an excellent snippet of code. This time it is GlobDirectoryWalker for doing recursive globbing http://groups.google.com/groups?q=Fredrik+Lundh+Re:+recursing+glob&hl=en&lr=&safe=off&rnum=1&ic=1 Dustin Boswell explains how to compile https support into Python2.0 http://groups.google.com/groups?q=Dustin+Boswell+how+to+compile+https+support+into+Python2.0&hl=en&lr=&safe=off&rnum=1&ic=1 David Mertz: Book Roundup http://gnosis.cx/cgi/txt2html.cgi?source=http://gnosis.cx/publish/programming/charming_python_12.txt Fredrik Lundh points to TryType (freetype) support for PIL http://groups.google.com/groups?q=Fredrik+Lundh+PIL+Fonts&hl=en&lr=&safe=off&rnum=1&ic=1 Carel Fellinger show how to handle overloading in OO manner http://groups.google.com/groups?q=Carel+Fellinger+Re:+Can+methods+functions+overloaded&hl=en&lr=&safe=off&rnum=1&ic=1 Steven D. Arnold announces updated version of Pure Python Encryption with fixed IDEA implementation http://groups.google.com/groups?q=Steven+D.+Arnold+ANN:+Pure+Python+Encryption+%5BUPDATE%5D&hl=en&lr=&safe=off&rnum=1&ic=1 ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Michael Hudson continues Andrew Kuchling's marvelous tradition of summarizing action on the python-dev mailing list twice a month. http://starship.python.net/crew/mwh/summaries/ http://www.amk.ca/python/dev The Vaults of Parnassus ambitiously collect Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Consortium emerges as an independent nexus of activity http://www.python.org/consortium Cetus does much of the same http://www.cetus-links.de/oo_python.html Python FAQTS http://python.faqts.com/ Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing trick of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From costas at meezon.com Wed Feb 21 02:28:00 2001 From: costas at meezon.com (Costas Menico) Date: Wed, 21 Feb 2001 01:28:00 GMT Subject: Tkinter importing error Message-ID: <3a93190a.462510@News.CIS.DFN.DE> Does anyone know why I get the following message when I try to import Tkinter on Windows 98? >>> import Tkinter Traceback (innermost last): File "", line 1, in ? File "d:\python20\lib\lib-tk\Tkinter.py", line 34, in ? import FixTk # Attempt to configure Tcl/Tk without requiring PATH File "d:\python20\lib\lib-tk\FixTk.py", line 1, in ? import sys, os, _tkinter ImportError: DLL load failed: One of the library files needed to run this application cannot be found. >>> Where is Tk supposed to be installed? The Python I use is ActiveState's version. Thanks Costas From monpetit at orgio.net Wed Feb 21 03:04:23 2001 From: monpetit at orgio.net (Monpetit) Date: Wed, 21 Feb 2001 11:04:23 +0900 Subject: Tkinter importing error References: <3a93190a.462510@News.CIS.DFN.DE> Message-ID: <96v72n$p82$1@news.hitel.net> Active Python does not include Tk module by default. You have to install Tcl/Tk 8.3.2. Visit http://www.scriptics.com/ and download Tcl/Tk. "Costas Menico" wrote in message news:3a93190a.462510 at News.CIS.DFN.DE... > Does anyone know why I get the following message when I try to import > Tkinter on Windows 98? > > >>> import Tkinter > Traceback (innermost last): > File "", line 1, in ? > File "d:\python20\lib\lib-tk\Tkinter.py", line 34, in ? > import FixTk # Attempt to configure Tcl/Tk without requiring PATH > File "d:\python20\lib\lib-tk\FixTk.py", line 1, in ? > import sys, os, _tkinter > ImportError: DLL load failed: One of the library files needed to run > this application cannot be found. > >>> > > Where is Tk supposed to be installed? The Python I use is > ActiveState's version. Thanks > > Costas From costas at meezon.com Wed Feb 21 04:17:02 2001 From: costas at meezon.com (Costas Menico) Date: Wed, 21 Feb 2001 03:17:02 GMT Subject: Tkinter importing error References: <3a93190a.462510@News.CIS.DFN.DE> <96v72n$p82$1@news.hitel.net> Message-ID: <3a933279.997835@News.CIS.DFN.DE> I did all that. I check the DOS path and it looks right. I copied the Tcl/Tk DLLs and LIBs all over the place. Rebooted and still get the same message. Are there any instructions as to the exact installation? Thanks "Monpetit" wrote: > >Active Python does not include Tk module by default. >You have to install Tcl/Tk 8.3.2. Visit http://www.scriptics.com/ and >download Tcl/Tk. > >"Costas Menico" wrote in message >news:3a93190a.462510 at News.CIS.DFN.DE... >> Does anyone know why I get the following message when I try to import >> Tkinter on Windows 98? >> >> >>> import Tkinter >> Traceback (innermost last): >> File "", line 1, in ? >> File "d:\python20\lib\lib-tk\Tkinter.py", line 34, in ? >> import FixTk # Attempt to configure Tcl/Tk without requiring PATH >> File "d:\python20\lib\lib-tk\FixTk.py", line 1, in ? >> import sys, os, _tkinter >> ImportError: DLL load failed: One of the library files needed to run >> this application cannot be found. >> >>> >> >> Where is Tk supposed to be installed? The Python I use is >> ActiveState's version. Thanks >> >> Costas > > From costas at meezon.com Wed Feb 21 05:00:39 2001 From: costas at meezon.com (Costas Menico) Date: Wed, 21 Feb 2001 04:00:39 GMT Subject: Tkinter importing error References: <3a933279.997835@News.CIS.DFN.DE> Message-ID: <3a933cfd.3690751@News.CIS.DFN.DE> Found the problem. Tkinter only works with Tcl/Tk 8.3. Now for a more serious problem. Why doesnt it work with PythonWin??? PythinWin is such a great IDE. Its a shame it's not supported. Costas From marco at atmosp.physics.utoronto.ca Wed Feb 21 02:46:09 2001 From: marco at atmosp.physics.utoronto.ca (marco at atmosp.physics.utoronto.ca) Date: 21 Feb 2001 01:46:09 GMT Subject: select.select example? Message-ID: <96v6l1$3n3$1@news.netmar.com> Hi all, A few days ago I posted a little problem I had regarding the blocking of UNIX pipes. Basically, when I ran: (po, pi, pe) = popen2.popen3('some command') and then: po_out = po.read() pe_err = pe.read() it happened sometimes (in an upredictable manner) that po.read() got stuck and my program stopped on its tracks (the order in which I read po and pe does make a difference, but while reading po.read() first works 99% of the time, I execute this many times and that 1% kills me). Two suggestions came up. One was using fcntl which seems to work, e.g.: >>> import popen2, fcntl, FCNTL >>> (po, pi, pe) = popen2.popen3('some command') >>> >>> # set read pipe to NONBLOCK, so we won't block >>> # on read() when there aren't any data available at the time >>> >>> fcntl.fcntl(po.fileno(), FCNTL.F_SETFL, FCNTL.O_NONBLOCK) >>> fcntl.fcntl(pe.fileno(), FCNTL.F_SETFL, FCNTL.O_NONBLOCK) >>> >>> # for child -- close above opened file descriptors on exec() >>> fcntl.fcntl(pi.fileno(), FCNTL.F_SETFD, 1) >>> fcntl.fcntl(po.fileno(), FCNTL.F_SETFD, 1) >>> fcntl.fcntl(pe.fileno(), FCNTL.F_SETFD, 1) >>> >>> pout = po.read() >>> perr = pe.read() The other option was using the select module. If I understand correctly, select.select will retrieve the input, output and error (exceptional condition?) without me having to worry which to read first. If none is available a timeout can also be specified. If this is the case it's probably what I want, but unfortunately the documentation is very scarce. From what I can gather: >>> import popen2, select >>> (po, pi, pe) = popen2.popen3('some command') >>> (spo, spi, spe) = select.select([po], [pi], [pe], 10) >>> spo[0].read() seems to work, although according to the Python 1.5.2 Library Reference the order of the lists should be: select.select(input, output, error, 10) which doesn't seem to be working for me. Furthermore, if 'some command' worked OK I would expect spe[0].read() to be '' but instead I get the error: IOError: [Errno 9] Bad file descriptor On the other hand, when 'some command' *does* raise an error, then spo[0].read() gives me '' (which is expected), but spe[0].read() gives the error: IndexError: list index out of range instead of std_err. So, I'm confused... If anyone can provide me with a simple example using select.select on a UNIX pipe I would greatly appreciate it! (And, of course, any other solutions are greatly welcomed :) Cheers! ----- 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 donn at oz.net Fri Feb 23 07:49:04 2001 From: donn at oz.net (Donn Cave) Date: 23 Feb 2001 06:49:04 GMT Subject: select.select example? References: <96v6l1$3n3$1@news.netmar.com> Message-ID: <975150$1jo$0@216.39.151.169> Quoth marco at atmosp.physics.utoronto.ca: | A few days ago I posted a little problem I had regarding | the blocking of UNIX pipes. Basically, when I ran: | | (po, pi, pe) = popen2.popen3('some command') | | and then: | | po_out = po.read() | pe_err = pe.read() ... | The other option was using the select module. If I understand correctly, | select.select will retrieve the input, output and error (exceptional | condition?) without me having to worry which to read first. If none | is available a timeout can also be specified. If this is the case | it's probably what I want, but unfortunately the documentation is | very scarce. From what I can gather: | | >>> import popen2, select | >>> (po, pi, pe) = popen2.popen3('some command') | >>> (spo, spi, spe) = select.select([po], [pi], [pe], 10) | >>> spo[0].read() | | seems to work, although according to the Python 1.5.2 Library | Reference the order of the lists should be: | select.select(input, output, error, 10) | which doesn't seem to be working for me. Meaning in this context: input: file descriptors to check for readability output: file descriptors to check for writability error: file descriptors to check for I/O errors (not error I/O!) So you were close, but it should really have been rds, wrs, ers = select.select([po, pe], [pi], [pi, po, pe], 10) You could eventually be interested in whether your pipes are ready to have more data written to them (and in fact you had better learn to be interested in that if you want reliable general purpose 2 way pipe communications between processes. But by then, you will have weaned yourself off of file objects too.) For now, since you're interested only in readability, you may leave the second set empty. The errors that you might get from the third set are actually fairly exotic, but it doesn't hurt to check. | ... Furthermore, if | 'some command' worked OK I would expect spe[0].read() to | be '' but instead I get the error: | IOError: [Errno 9] Bad file descriptor Can't say I see how that happened - certainly, anything select() reports in its third, error set will not likely be a valid file descriptor for more I/O, after the error that got it into that set. But I don't know right off hand what that error would have been. | On the other hand, when 'some command' *does* raise an error, then | spo[0].read() gives me '' (which is expected), but spe[0].read() | gives the error: | IndexError: list index out of range | instead of std_err. That's fine, one doesn't expect I/O errors. About file objects and select(), please bear in mind that the file object is a C stdio buffer. Output can be buffered and not written to the pipe. Input can be buffered and be ready to read but not visible to select(). Reads can block until the amount requested appears in the pipe, which is usually not convenient. You can ameliorate some of this brain damage by turning off the buffering, but it's even better to just get the file descriptor back out of the file object and use it for everything. po, pi, pe = popen2.popen3('some command') pod = po.fileno() pid = pi.fileno() ped = pi.fileno() while 1: if data: ofs = [pid] else: ofs = [] ifd, ofd, efd = select.select([pod, ped], ofs, [pod, ped, pid], 10) if efd: print >> sys.stderr, "error on units", efd break if pod in ifd: output = os.read(pod, 16384) if not output: print >> sys.stderr, "EOF from process" break else: print "process output", repr(output) if ped in ifd: errors = os.read(ped, 16384) if not errors: print >> sys.stderr, "EOF from process" break else: print "process errors", repr(errors) if data and pid in ofs: n = os.write(pid, data) data = data[n:] I haven't checked to see if that actually works, but it looks OK to me. Donn Cave, donn at oz.net From fimafeng at yahoo.com Wed Feb 21 03:30:19 2001 From: fimafeng at yahoo.com (Chris Nelson) Date: Wed, 21 Feb 2001 02:30:19 GMT Subject: 1st install on Linux (RH 7.0) I hit a snaggg !!! Message-ID: <3A93280C.2080802@yahoo.com> Hello I've been using BeOpen python on Windows for a while now. I have converted one of my home systems over to RedHat 7.0. I installed the actual 2.0 rpm just fine. However..when I tried to install Tkinter-2.0-8.0-3.i386.rpm I get the following errors "Tkinter-2.0-8.0-3 requires libtcl8.0.so" "Tkinter-2.0-8.0-3 requires libtk8.0.so" I thought that TCL/TK was installed I show the following RPMs as beeing installed... tksysv 1.3-2 tcl 8.3.1-46 tcl 8.2.0-46 tk 8.3.1-46 tkinter 1.5.2-27 BeOpenPython 2.0 tcllib.0.4-46 What am I missing? Also...How do I access the IDLE in Linux?? Many thanks, Chris From bowman at montana.com Wed Feb 21 03:53:46 2001 From: bowman at montana.com (bowman) Date: Tue, 20 Feb 2001 19:53:46 -0700 Subject: 1st install on Linux (RH 7.0) I hit a snaggg !!! References: <3A93280C.2080802@yahoo.com> Message-ID: <28Gk6.499$c7.3553@newsfeed.slurp.net> Chris Nelson wrote in message news:3A93280C.2080802 at yahoo.com... > "Tkinter-2.0-8.0-3 requires libtcl8.0.so" > "Tkinter-2.0-8.0-3 requires libtk8.0.so" > I show the following RPMs as beeing installed... > tcl 8.3.1-46 > tcl 8.2.0-46 > tk 8.3.1-46 welcome to rpm hell. tcl8.0 is not tcl8.3. unless you have some dependencies, you might remove the 8.3 rpms and install 8.0. I don't know if the problems were resolved, but there were some issues with 8.3 that caused people building packages that required tcl/tk to revert back to 8.0. rpm's are fine things, but they imply your machine has all the bits and pieces that the build machine had, which is not always the case. From fimafeng at yahoo.com Wed Feb 21 05:21:42 2001 From: fimafeng at yahoo.com (Chris Nelson) Date: Wed, 21 Feb 2001 04:21:42 GMT Subject: 1st install on Linux (RH 7.0) I hit a snaggg !!! References: <3A93280C.2080802@yahoo.com> <28Gk6.499$c7.3553@newsfeed.slurp.net> Message-ID: <3A93422B.3040605@yahoo.com> bowman wrote: > Chris Nelson wrote in message > > news:3A93280C.2080802 at yahoo.com... > > >> "Tkinter-2.0-8.0-3 requires libtcl8.0.so" > >> "Tkinter-2.0-8.0-3 requires libtk8.0.so" > >> I show the following RPMs as beeing installed... > >> tcl 8.3.1-46 > >> tcl 8.2.0-46 > >> tk 8.3.1-46 > > > > welcome to rpm hell. tcl8.0 is not tcl8.3. unless you have some > > dependencies, you might remove the 8.3 rpms and install 8.0. I don't know if > > the problems were resolved, but there were some issues with 8.3 that caused > > people building packages that required tcl/tk to revert back to 8.0. rpm's > > are fine things, but they imply your machine has all the bits and pieces > > that the build machine had, which is not always the case. I removed the 8.3 libraries (even though it said there were dependencies..installed the 8.0.5 series of tcl and tk....and TKinter installed all right. I was goint to then upgrade the 8.0's back to 8.3 but I got the warning about those libraries mentioned above so I decided to wait. BTW.. How do I start the IDLE in Linux??? Thanks, Chris From adam at deprince.net Tue Feb 20 06:32:21 2001 From: adam at deprince.net (Adam DePrince) Date: Tue, 20 Feb 2001 00:32:21 -0500 Subject: Off topic: Re: 1st install on Linux (RH 7.0) I hit a snaggg !!! References: <3A93280C.2080802@yahoo.com> <28Gk6.499$c7.3553@newsfeed.slurp.net> <3A93422B.3040605@yahoo.com> Message-ID: <3A920165.57957986@deprince.net> Chris Nelson wrote: > > bowman wrote: > > > Chris Nelson wrote in message > > > > news:3A93280C.2080802 at yahoo.com... > > > > > >> "Tkinter-2.0-8.0-3 requires libtcl8.0.so" > > > >> "Tkinter-2.0-8.0-3 requires libtk8.0.so" > > > >> I show the following RPMs as beeing installed... > > > >> tcl 8.3.1-46 > > > >> tcl 8.2.0-46 > >> tk 8.3.1-46 > > welcome to rpm hell. tcl8.0 is not tcl8.3. unless you have some > > dependencies, you might remove the 8.3 rpms and install 8.0. I don't know if > > the problems were resolved, but there were some issues with 8.3 that caused > > people building packages that required tcl/tk to revert back to 8.0. rpm's > > are fine things, but they imply your machine has all the bits and pieces > > that the build machine had, which is not always the case. > I removed the 8.3 libraries (even though it said there were > dependencies..installed the 8.0.5 series of tcl and tk....and TKinter > installed all right. I was goint to then upgrade the 8.0's back to 8.3 > but I got the warning about those libraries mentioned above so I decided > to wait. > BTW.. How do I start the IDLE in Linux??? At risk of going off topic for this group, but you mentioned that you use Redhat 7.0 I belive IDLE is an optional part of the RedHat install (well, its on my machine, I run RH7, and it lives in /usr/bin, not the place my installed goodies go, so I guess it comes w/ RH7). If you have the space, select the "everything" option during your install. Adam DePrince Starmedia Network Inc. zlib.decompress('x\332KLI\314\325KI-(\312\314KNu(.I,\312MM\311L\324K\316\317\005\000\221\331\012s') From fimafeng at yahoo.com Wed Feb 21 11:16:19 2001 From: fimafeng at yahoo.com (Chris Nelson) Date: Wed, 21 Feb 2001 10:16:19 GMT Subject: Off topic: Re: 1st install on Linux (RH 7.0) I hit a snaggg !!! References: <3A93280C.2080802@yahoo.com> <28Gk6.499$c7.3553@newsfeed.slurp.net> <3A93422B.3040605@yahoo.com> <3A920165.57957986@deprince.net> Message-ID: <3A939548.5070700@yahoo.com> Adam DePrince wrote: > Chris Nelson wrote: > > >> bowman wrote: > >> > >> >>> Chris Nelson wrote in message > >>> > >>> news:3A93280C.2080802 at yahoo.com... > >>> > >>> > >>> >>>> "Tkinter-2.0-8.0-3 requires libtcl8.0.so" > >>> >>>> "Tkinter-2.0-8.0-3 requires libtk8.0.so" > >>> >>>> I show the following RPMs as beeing installed... > >>> >>>> tcl 8.3.1-46 > >>> >>>> tcl 8.2.0-46 > >>>> tk 8.3.1-46 > >>> >>> welcome to rpm hell. tcl8.0 is not tcl8.3. unless you have some > >>> dependencies, you might remove the 8.3 rpms and install 8.0. I don't know if > >>> the problems were resolved, but there were some issues with 8.3 that caused > >>> people building packages that required tcl/tk to revert back to 8.0. rpm's > >>> are fine things, but they imply your machine has all the bits and pieces > >>> that the build machine had, which is not always the case. > >> >> I removed the 8.3 libraries (even though it said there were > >> dependencies..installed the 8.0.5 series of tcl and tk....and TKinter > >> installed all right. I was goint to then upgrade the 8.0's back to 8.3 > >> but I got the warning about those libraries mentioned above so I decided > >> to wait. > >> BTW.. How do I start the IDLE in Linux??? > > > > At risk of going off topic for this group, but you mentioned that you > > use Redhat 7.0 > > I belive IDLE is an optional part of the RedHat install (well, its on my > > machine, I run RH7, and it lives in /usr/bin, not the place my installed > > goodies go, so I guess it comes w/ RH7). If you have the space, select > > the "everything" option during your install. > > > > Adam DePrince > > Starmedia Network Inc. > > zlib.decompress('x\332KLI\314\325KI-(\312\314KNu(.I,\312MM\311L\324K\316\317\005\000\221\331\012s') Does the BeOsPython distrivution contain an IDLE for 2.0? I just installed it so I was curious how to access it if it were included From noselasd at frisurf.no Wed Feb 21 10:13:21 2001 From: noselasd at frisurf.no (Nils O. Selåsdal) Date: Wed, 21 Feb 2001 10:13:21 +0100 Subject: 1st install on Linux (RH 7.0) I hit a snaggg !!! References: <3A93280C.2080802@yahoo.com> <28Gk6.499$c7.3553@newsfeed.slurp.net> <3A93422B.3040605@yahoo.com> Message-ID: "Chris Nelson" wrote in message news:3A93422B.3040605 at yahoo.com... > bowman wrote: > > BTW.. How do I start the IDLE in Linux??? Contained in some rpm .. python-tools or py-tools.. think its on the 2. cd of RH7. install it, and type idle From john at dhh.gt.org Wed Feb 21 06:00:05 2001 From: john at dhh.gt.org (John Hasler) Date: Wed, 21 Feb 2001 05:00:05 GMT Subject: 1st install on Linux (RH 7.0) I hit a snaggg !!! References: <3A93280C.2080802@yahoo.com> <28Gk6.499$c7.3553@newsfeed.slurp.net> Message-ID: <877l2ky6ju.fsf@toncho.dhh.gt.org> bowman writes: > unless you have some dependencies, you might remove the 8.3 rpms and > install 8.0. Why do you think he needs to remove 8.3? tcl8.0, tcl8.2, and tcl8.3 all co-exist peacefully on my Debian system. > rpm's are fine things, but they imply your machine has all the bits and > pieces that the build machine had, which is not always the case. That's what dependencies are for (and you can have multiple versions of a given library installed at the same time). -- John Hasler john at dhh.gt.org (John Hasler) Dancing Horse Hill Elmwood, WI From ptb at oboe.it.uc3m.es Wed Feb 21 12:46:15 2001 From: ptb at oboe.it.uc3m.es (Peter T. Breuer) Date: Wed, 21 Feb 2001 12:46:15 +0100 Subject: 1st install on Linux (RH 7.0) I hit a snaggg !!! References: <3A93280C.2080802@yahoo.com> <28Gk6.499$c7.3553@newsfeed.slurp.net> <877l2ky6ju.fsf@toncho.dhh.gt.org> Message-ID: <7q9079.1hj.ln@news.it.uc3m.es> In comp.os.linux.setup John Hasler wrote: > bowman writes: >> unless you have some dependencies, you might remove the 8.3 rpms and >> install 8.0. > Why do you think he needs to remove 8.3? tcl8.0, tcl8.2, and tcl8.3 all > co-exist peacefully on my Debian system. Yes, well, to nitpick, he didn't say "need" and he appears to know what he is talking about in general :-). I daresay he just wants to reduce clutter in the case that these installs are really not necessary for the system, thus simplifying whatever problem the OP is facing and aiding diagnosis. >> rpm's are fine things, but they imply your machine has all the bits and >> pieces that the build machine had, which is not always the case. > That's what dependencies are for (and you can have multiple versions of a > given library installed at the same time). Yes. Peter From fimafeng at yahoo.com Wed Feb 21 14:05:59 2001 From: fimafeng at yahoo.com (Chris Nelson) Date: Wed, 21 Feb 2001 13:05:59 GMT Subject: 1st install on Linux (RH 7.0) I hit a snaggg !!! References: <3A93280C.2080802@yahoo.com> <28Gk6.499$c7.3553@newsfeed.slurp.net> <877l2ky6ju.fsf@toncho.dhh.gt.org> <7q9079.1hj.ln@news.it.uc3m.es> Message-ID: <3A93BD0C.3000307@yahoo.com> Peter T. Breuer wrote: > In comp.os.linux.setup John Hasler wrote: > > >> bowman writes: > >> >>> unless you have some dependencies, you might remove the 8.3 rpms and > >>> install 8.0. > >> > >> Why do you think he needs to remove 8.3? tcl8.0, tcl8.2, and tcl8.3 all > >> co-exist peacefully on my Debian system. > > > > Yes, well, to nitpick, he didn't say "need" and he appears to know what > > he is talking about in general :-). I daresay he just wants to reduce > > clutter in the case that these installs are really not necessary for > > the system, thus simplifying whatever problem the OP is facing and > > aiding diagnosis. > > > > >>> rpm's are fine things, but they imply your machine has all the bits and > >>> pieces that the build machine had, which is not always the case. > >> > >> That's what dependencies are for (and you can have multiple versions of a > >> given library installed at the same time). > > > > Yes. > > > > Peter Ultimately hat I'm looking for is some version of Python 2.0 (ActiveState or BeOs) to run with IDLE on RH 7.0 I'm back down to the 8.0 version of tcl & tk and 1.52 of tkinter Does anyone have this working? Should I start a new thread?? w/this as topic? any help is appreciated...Chris From bsass at freenet.edmonton.ab.ca Thu Feb 22 22:26:06 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Thu, 22 Feb 2001 14:26:06 -0700 Subject: 1st install on Linux (RH 7.0) I hit a snaggg !!! In-Reply-To: <3A93BD0C.3000307@yahoo.com> References: <3A93280C.2080802@yahoo.com> <28Gk6.499$c7.3553@newsfeed.slurp.net> <877l2ky6ju.fsf@toncho.dhh.gt.org> <7q9079.1hj.ln@news.it.uc3m.es> <3A93BD0C.3000307@yahoo.com> Message-ID: On Wed, 21 Feb 2001, Chris Nelson wrote: > Ultimately hat I'm looking for is some version of Python 2.0 > (ActiveState or BeOs) to run with IDLE on RH 7.0 > > I'm back down to the 8.0 version of tcl & tk and 1.52 of tkinter The ActiveState idle wants tk/tcl-8.3, if you can get it to co-exist with 8.0 you can run both 1.5.2 and as2.0's idle (that is what you are after or the state you are in, right?). To get 2.0 to live with 1.5.2 you can(must?) change all the *.py executables in the py2 distribution to use the python2.0 executable. A tweaked .../Tools/scripts/fixps.py program helps automate the task. - Bruce From bowman at montana.com Wed Feb 21 15:32:04 2001 From: bowman at montana.com (bowman) Date: Wed, 21 Feb 2001 07:32:04 -0700 Subject: 1st install on Linux (RH 7.0) I hit a snaggg !!! References: <3A93280C.2080802@yahoo.com> <28Gk6.499$c7.3553@newsfeed.slurp.net> <877l2ky6ju.fsf@toncho.dhh.gt.org> Message-ID: John Hasler wrote in message news:877l2ky6ju.fsf at toncho.dhh.gt.org... > > Why do you think he needs to remove 8.3? tcl8.0, tcl8.2, and tcl8.3 all > co-exist peacefully on my Debian system. because I'm lazy. because the OP seemed to be new to Linux, and maintaining several version levels can require bit of tweaking. because I've been around the barn with tcl/tk, Expect, and friends that won't build unless they can find the right version and its hidden headers, etc. because I am not sure if the OP could rpm 8.0 onto his system without forcing the install. I've also been around the barn with earlier RH releases that came with broken Python and Perl packages, and 7.0 had its share of alpha and beta builds dressed up as stable packages. Many people enjoy the sysadmin aspects of Linux, but as the OS gains popularity, more users just want to get the job done, without a lot of complications and surprises. From tgagne at ix.netcom.com Wed Feb 21 04:38:24 2001 From: tgagne at ix.netcom.com (Thomas Gagne) Date: Tue, 20 Feb 2001 22:38:24 -0500 Subject: New to OO concepts - re-usability References: <3a90fa97.0@news1.mweb.co.za> Message-ID: <3A933830.7F98D118@ix.netcom.com> I just had an interesting conversation today with my brother who is learning programming from scratch. He's learning Smalltalk, and was watching me debug a program I'm working on and we visited the subject of reuse. One of the things I learned recently (over in comp.lang.python, I think) was that it is as important to reuse idioms as it is to reuse code. By designing your classes to work within the idioms of the language you're using your program ultimately reuses more, and becomes more reusable (and more easily factored) itself. For instance, I could create all kinds of classes with their own protocol for doing something, or I could endow them with behaviors that make them great collection citizens. In Smalltalk, that would be thinking of how using do:, select:, collect:, detect:, and inject:into: on collection containing my objects would be either easier or more useful. Long-time Smalltalkers, and apparently Python programmers, may have already had this drilled into their heads. I don't remember reading anything about designing software to work well within the idiom of any language in any of the books I've read. Maybe others have? x wrote: > Hi, > > I have been reading up on the OO environment, focusing on the use of UML to > speed up creation of objects, or even to create superior designs of objects. > > Its great. Everyone is creating their reusable objects, no efforts are being > wasted, these huge libraries are being built....are they? > > Does everyone create their own libraries, with a little sharing when > requested, or is there some huge repository of objects available to all and > sundry where the benefits of mankind's OO efforts are being stored nice and > neat... you know, like the Human Genome project? > > I'm curious to know. > > Thanks > > Michael > michael.wijtenburg at iafrica.com -- .tom From phlip_cpp at my-deja.com Wed Feb 21 06:39:41 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 21 Feb 2001 05:39:41 GMT Subject: New to OO concepts - re-usability References: <3a90fa97.0@news1.mweb.co.za> <3A933830.7F98D118@ix.netcom.com> Message-ID: <96vkat$m8d@dispatch.concentric.net> > x wrote: > >> Hi, >> >> I have been reading up on the OO environment, focusing on the use of UML >> to speed up creation of objects, or even to create superior designs of >> objects. You might think you must write UML first, then copy it to code. Whether you do this or not isn't as important as whether your code can always get better. For example, you could use UML to illustrate its current state, upgrade the code, and then use UML to demonstrate to colleagues who re-use the code what it now looks like & how it changed. Projects where any of the classes never change go downhill and become mired in their legacy expectations. Don't do that. You can't change code without unit tests. They are more important than UML, therefor write them before you write code. Then as you write more code, "refactor" it to improve its design. (Python's typeless code & pristine syntax makes refactoring as easy as falling off a log.) Long term, for large projects, making sure some "design document" matches the current state of the code has been discovered again and again to be a pure waste of time. Either the UML locks in a bad design, or the design gets better and the UML document does not reflect this. "Well designed code" is not the same as "code with a lot of pictures describing it." >> Its great. Everyone is creating their reusable objects, no efforts are >> being wasted, these huge libraries are being built....are they? No, UML won't do this alone. To write a re-usable library that others can use, you should develop it (just as iteratively as one-shot code) with at least three client applications all at the same time. That which all three find themselves doing belongs inside the library, and "nice to haves" don't. >> Does everyone create their own libraries, with a little sharing when >> requested, or is there some huge repository of objects available to all >> and sundry where the benefits of mankind's OO efforts are being stored >> nice and neat... you know, like the Human Genome project? Easy. For every feature you must add, you write test code first and get it to fail. Then add the feature until the test code passes. Version this test code with the project - don't throw it away - and create a "super_test" that calls all the tests in a project. All this hacking might just make you think such a project will lead to poor design. Refactor the code each time you see something break the rule OnceAndOnlyOnce. That means any concept, no matter how profound or trivial, must only appear in source once. As you refactor, re-usable modules grow out of the primordial ooze of functionality. And many of these re-usables might just appear where you could never have expected them to with all the up-front UML in the world. Now why are unit tests crucial to re-use at all levels of a project? If every single feature you write has a unit test, then every feature already has two clients, not just one. It has a production client that sends it real messages, and it also has a test client sending it test messages. Test-first code is all already re-used once. This makes re-using it again blazingly easy. http://c2.com/cgi/wiki?CodeUnitTestFirst http://c2.com/cgi/wiki?RefactorMercilessly -- Phlip phlip_cpp at my-deja.com ============== http://phlip.webjump.com ============== -- How does Bugs Bunny do it? How does he know when he wakes up in the morning to put in his pocket 3 sticks of dynamite, a physician costume, and a bicycle pump? -- From ctavares at develop.com Wed Feb 21 07:30:58 2001 From: ctavares at develop.com (Chris Tavares) Date: Wed, 21 Feb 2001 06:30:58 GMT Subject: New to OO concepts - re-usability References: <3a90fa97.0@news1.mweb.co.za> <3A933830.7F98D118@ix.netcom.com> Message-ID: "Thomas Gagne" wrote in message news:3A933830.7F98D118 at ix.netcom.com... [... snip ...] > > Long-time Smalltalkers, and apparently Python programmers, may have already had > this drilled into their heads. I don't remember reading anything about > designing software to work well within the idiom of any language in any of the > books I've read. Maybe others have? > Actually, this is in many ways the whole idea behind the STL in C++. Write code to common idioms and then you can easily reuse different pieces together. While the world is totally different (static vs. dynamic typing), the concepts are in many ways the same. Studying the ideas behind the STL are well worth doing for everyone I would think. -Chris From cmh at bDistributed.com Thu Feb 22 15:13:59 2001 From: cmh at bDistributed.com (Chris Hanson) Date: Thu, 22 Feb 2001 08:13:59 -0600 Subject: New to OO concepts - re-usability References: <3a90fa97.0@news1.mweb.co.za> <3A933830.7F98D118@ix.netcom.com> Message-ID: <220220010813598042%cmh@bDistributed.com> In article , Chris Tavares wrote: > While the world is totally different (static vs. dynamic typing), the > concepts are in many ways the same. Studying the ideas behind the STL are > well worth doing for everyone I would think. It's a great idea for learning what *not* to do. The STL is horribly designed. There's no hierarchy, no real interchangeability in the container classes. And they force you to do all sorts of extra work (some of which just isn't feasible) to be able to store your objects in containers. STL was designed by number crunchers with the broken assumption that programs are designed from the algorithm out and that efficiency is the absolute most important goal. Software in the real world is designed from the business requirements out; this usually starts with a human interface and a set of user requirements, and efficiency is only measured compared to human use rather than the processor's maximum throughput. I've actually had STL proponents tell me it's a *good* thing that std::vector doesn't have a push_front() method because if you try to do that your code won't compile and you'll know you should be using a "more efficient" container class! What if I *know* it's an expensive operation, I know I need to do it occasionally, and I need the speed that std::vector will otherwise give me? "Subclass std::vector then!" (This was the real answer they gave.) If I have to subclass a standard container class to get simple functionality, it's *not* well-designed. Study the Smalltalk frameworks and Apple's Cocoa frameworks (formerly the NeXT frameworks) if you want to learn good object-oriented design. -- Chris -- Chris Hanson bDistributed.com: Making business distributed. http://bDistributed.com/ From root at rainerdeyke.com Thu Feb 22 16:59:15 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Thu, 22 Feb 2001 15:59:15 GMT Subject: New to OO concepts - re-usability References: <3a90fa97.0@news1.mweb.co.za> <3A933830.7F98D118@ix.netcom.com> <220220010813598042%cmh@bDistributed.com> Message-ID: "Chris Hanson" wrote in message news:220220010813598042%cmh at bDistributed.com... > I've actually had STL proponents tell me it's a *good* thing that > std::vector doesn't have a push_front() method because if you try to > do that your code won't compile and you'll know you should be using a > "more efficient" container class! What if I *know* it's an expensive > operation, I know I need to do it occasionally, and I need the speed > that std::vector will otherwise give me? "Subclass std::vector > then!" (This was the real answer they gave.) If I have to subclass a > standard container class to get simple functionality, it's *not* > well-designed. The correct answer, of course, is to use the 'insert' method. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From aleaxit at yahoo.com Thu Feb 22 18:10:21 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 22 Feb 2001 18:10:21 +0100 Subject: New to OO concepts - re-usability References: <3a90fa97.0@news1.mweb.co.za> <3A933830.7F98D118@ix.netcom.com> <220220010813598042%cmh@bDistributed.com> Message-ID: <973hl801g60@news2.newsguy.com> "Rainer Deyke" wrote in message news:nHal6.285701$ge4.97547638 at news2.rdc2.tx.home.com... > "Chris Hanson" wrote in message > news:220220010813598042%cmh at bDistributed.com... > > I've actually had STL proponents tell me it's a *good* thing that > > std::vector doesn't have a push_front() method because if you try to > > do that your code won't compile and you'll know you should be using a > > "more efficient" container class! What if I *know* it's an expensive > > operation, I know I need to do it occasionally, and I need the speed > > that std::vector will otherwise give me? "Subclass std::vector > > then!" (This was the real answer they gave.) If I have to subclass a > > standard container class to get simple functionality, it's *not* > > well-designed. > > The correct answer, of course, is to use the 'insert' method. I'd rather do a push_back and a rotate because, in my typical use, N/2 swaps would be far less costly than N-1 copies. But, sure, "vec.insert(vec.begin(),x);" IS rather more concise than "vec.push_back(x); std::rotate(vec.begin(),vec.end()-1,vec.end();" (and unless you've specialized the swap template, so that the swaps ARE fast, performance will be equivalent; however, note that several specialized implementations of std::swap exist, and that's what std::rotate is supposed to be using). Alex From aleaxit at yahoo.com Thu Feb 22 17:56:06 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 22 Feb 2001 17:56:06 +0100 Subject: New to OO concepts - re-usability References: <3a90fa97.0@news1.mweb.co.za> <3A933830.7F98D118@ix.netcom.com> <220220010813598042%cmh@bDistributed.com> Message-ID: <973gb401epe@news2.newsguy.com> "Chris Hanson" wrote in message news:220220010813598042%cmh at bDistributed.com... [snip] > STL was designed by number crunchers with the broken assumption that > programs are designed from the algorithm out and that efficiency is the > absolute most important goal. If C++ is being used, then efficiency *HAD BETTER* be a paramount goal: otherwise, the programming-language choice was utterly absurd. > Software in the real world is designed ...in utterly absurd ways, very often, sure -- such as, using C++ for stuff that it's simply ridiculous to do in C++, as it does not really need its runtime efficiency (and thus, should absolutely *NOT* be paying the huge programmer-productivity costs connected with C++ memory management &c). But the STL designers were quite right not to take this into account -- their key goal was to make C++ better *for the uses to which it SHOULD be put* (which in turn implies, cases where runtime efficiency is important) rather than for uses to which it should NOT be put (although it often IS:-). > I've actually had STL proponents tell me it's a *good* thing that > std::vector doesn't have a push_front() method because if you try to > do that your code won't compile and you'll know you should be using a > "more efficient" container class! Yep. > What if I *know* it's an expensive > operation, I know I need to do it occasionally, and I need the speed > that std::vector will otherwise give me? You don't make believe a METHOD exists, but rather call a FUNCTION for the purpose. E.g., template inline void push_front(std::vector& vec, const X& x) { vec.push_back(x); std::rotate(vec.begin(), vec.end()-1, vec.end()); } > "Subclass std::vector > then!" (This was the real answer they gave.) If I have to subclass a > standard container class to get simple functionality, it's *not* > well-designed. The STL designers are not *class-obsessed* (the way you seem to be, and, apparently, those 'STL proponents' you asked -- the very *idea* of subclassing STL classes is laughable, so, they're proponents of what they don't really understand). Lots of important functionality is packaged up as _function_ templates, and is meant to be called with function syntax. The 'algorithms' thus packaged are _orthogonal_ to the container classes. You don't have to subclass anything to 'get simple functionality': you call functions, when that is more appropriate than calling methods (funny enough, Python is based on this concept, too:-). Apparently, you refuse to consider that calling a function can be THE way to access functionality; and thus, to consider "well designed" a class if it has methods to duplicate any "simple functionality" that is in fact quite accessible with slightly different syntax-sugar via function-calls. Well, I have news for you -- those classes you seem to think are "well designed" are what many of us would think of as "fat". *MY* idea of a well-designed class, **for a language that has free-standing (templated or dynamically typed) functions** as well as classes, and thinking of foundational library classes, is one which exposes a LEAN (but functionally complete) set of methods, allowing a separate set of "convenience" functions to do their job neatly. Not 10 classes with 100 methods each, as 10 * 100 == 1000; rather, 10 classes with 10 methods each, and the other 90 things factored out as functions -- 190 is a much smaller number than 1000, so the overall design is simpler and leaner. Alex From ben.hutchings at roundpoint.com Fri Feb 23 03:01:35 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 22 Feb 2001 18:01:35 -0800 Subject: New to OO concepts - re-usability References: <3a90fa97.0@news1.mweb.co.za> <3A933830.7F98D118@ix.netcom.com> <220220010813598042%cmh@bDistributed.com> Message-ID: Chris Hanson writes: > In article , > Chris Tavares wrote: > > > While the world is totally different (static vs. dynamic typing), the > > concepts are in many ways the same. Studying the ideas behind the STL are > > well worth doing for everyone I would think. > > It's a great idea for learning what *not* to do. > > The STL is horribly designed. There's no hierarchy, I think you mean it's not an OO design, and that's true. There *are* common interfaces (random lookup, list-ops, front-ops, stack-ops, iteration), but those interfaces aren't explicit so you can't put off your choice of implementation to run-time - unless you use wrappers. > no real interchangeability in the container classes. Some algorithms require different interfaces from others. You can interchange containers as long as you keep a clear idea of which interfaces your algorithm(s) need and pick the right containers. The most common one is iteration, and almost all containers support that. > And they force you to do all sorts of extra work (some of which just > isn't feasible) to be able to store your objects in containers. Storing polymorphic objects certainly seems to be too difficult, since they have to be stored by reference and there is no ref-counting smart-pointer class in the standard library (but there is boost::shared_ptr). > STL was designed by number crunchers with the broken assumption that > programs are designed from the algorithm out and that efficiency is the > absolute most important goal. Software in the real world is designed > from the business requirements out; this usually starts with a human > interface and a set of user requirements, and efficiency is only > measured compared to human use rather than the processor's maximum > throughput. STL is not meant to do everything *for* the C++ programmer, but it is meant to be used *by* every C++ programmer. That's why it has to be efficient and flexible, and not too abstract. You can always write wrapper classes on top of it that are more abstract but less flexible or less efficient, but you could never write wrapper classes to make an abstract container library more efficient! -- Any opinions expressed are my own and not necessarily those of Roundpoint. From topmind at technologist.com Sun Feb 25 21:52:26 2001 From: topmind at technologist.com (Topmind) Date: Sun, 25 Feb 2001 20:52:26 GMT Subject: New to OO concepts - re-usability References: <3a90fa97.0@news1.mweb.co.za> <3A933830.7F98D118@ix.netcom.com> <220220010813598042%cmh@bDistributed.com> Message-ID: > > Some algorithms require different interfaces from others. You can > interchange containers as long as you keep a clear idea of which > interfaces your algorithm(s) need and pick the right containers. The > most common one is iteration, and almost all containers support that. This is a sore point with me. To me it seems silly (artificial) to split collection handling into categories (stacks, sets, trees, etc.). If needs change from one to another or a combo, then you are hosed with a non-fitting interface. IMO the features should be viewed as independent as possible (HAS-A, not IS-A), not as coupled to some taxonomy of collections. That is unnecessary coupling. Shape up! -tmind- From patrickdlogan at home.com Sun Feb 25 22:20:04 2001 From: patrickdlogan at home.com (Patrick Logan) Date: Sun, 25 Feb 2001 21:20:04 GMT Subject: Collection interfaces (Was: New to OO concepts - re-usability) References: <3a90fa97.0@news1.mweb.co.za> <3A933830.7F98D118@ix.netcom.com> <220220010813598042%cmh@bDistributed.com> Message-ID: <8Gem6.473353$U46.14105062@news1.sttls1.wa.home.com> "Topmind" wrote in message news:MPG.150312ceb68f1ada98969f at news.earthlink.net... > > This is a sore point with me. To me it seems silly (artificial) > to split collection handling into categories (stacks, sets, trees, etc.). > If needs change from one to another or a combo, then you are hosed > with a non-fitting interface. Yes, and so OO language provide an advantage here. Collection classes in these languages are accessible through common interfaces. You don't care how they are implemented, you only care about the interface. > Shape up! Yeah! -- Patrick Logan mailto:patrickdlogan at home.com From topmind at technologist.com Mon Feb 26 02:32:51 2001 From: topmind at technologist.com (Topmind) Date: Mon, 26 Feb 2001 01:32:51 GMT Subject: Collection interfaces (Was: New to OO concepts - re-usability) 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> Message-ID: > "Topmind" wrote > in message news:MPG.150312ceb68f1ada98969f at news.earthlink.net... > > > > This is a sore point with me. To me it seems silly (artificial) > > to split collection handling into categories (stacks, sets, trees, etc.). > > If needs change from one to another or a combo, then you are hosed > > with a non-fitting interface. > > Yes, and so OO language provide an advantage here. Collection classes > in these languages are accessible through common interfaces. You don't > care how they are implemented, you only care about the interface. > You mean something like SQL or ODBC? And, this crap that only OO can do implimentation-hiding interfaces is pure propaganda. (Note that I am talking about using the interfaces, not making DB engines or whatnot.) > > Shape up! > > Yeah! > > -- > Patrick Logan > mailto:patrickdlogan at home.com > -tmind- From patrickdlogan at home.com Mon Feb 26 03:57:48 2001 From: patrickdlogan at home.com (Patrick Logan) Date: Mon, 26 Feb 2001 02:57:48 GMT Subject: Collection interfaces (Was: New to OO concepts - re-usability) 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> Message-ID: "Topmind" wrote in message news:MPG.1503548620e632919896a4 at news.earthlink.net... > > > > > > This is a sore point with me. To me it seems silly (artificial) > > > to split collection handling into categories (stacks, sets, trees, etc.). > > > If needs change from one to another or a combo, then you are hosed > > > with a non-fitting interface. > > > > Yes, and so OO language provide an advantage here. Collection classes > > in these languages are accessible through common interfaces. You don't > > care how they are implemented, you only care about the interface. > > You mean something like SQL or ODBC? No, I mean collections, as with, say, the Smalltalk collection classes. > And, this crap that only OO can do implimentation-hiding interfaces is > pure propaganda. It is possible to hide the implementation behind any procedure. But it requires some kind of OO mechanism to be polymorphic. That is what OO is, by definition. -- Patrick Logan mailto:patrickdlogan at home.com From topmind at technologist.com Mon Feb 26 07:03:54 2001 From: topmind at technologist.com (Topmind) Date: Mon, 26 Feb 2001 06:03:54 GMT Subject: Collection interfaces (Was: New to OO concepts - re-usability) 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> Message-ID: > > "Topmind" wrote > in message news:MPG.1503548620e632919896a4 at news.earthlink.net... > > > > > > > > This is a sore point with me. To me it seems silly (artificial) > > > > to split collection handling into categories (stacks, sets, trees, > etc.). > > > > If needs change from one to another or a combo, then you are hosed > > > > with a non-fitting interface. > > > > > > Yes, and so OO language provide an advantage here. Collection classes > > > in these languages are accessible through common interfaces. You don't > > > care how they are implemented, you only care about the interface. > > > > You mean something like SQL or ODBC? > > No, I mean collections, as with, say, the Smalltalk collection classes. > Smalltalk uses collection taxonomies, which I frown on. Collection needs change, morph, and grow. If you tie your application to a specific "type", then the chances of getting screwed are high IME. If Smalltalk wants to rewrite them so features can be mixed and match as needed, instead of based on an limiting taxonomy, that would be great. (I am working on my version of such a spec, BTW.) OO thinking is taxonomy-happy. I see it in collections, streams, and GUI's. One can have many more variations if you treat features as indepedent. Sure, not all combinations are valid, but the pattern of invalidity is not a tree pattern for the most part. > > And, this crap that only OO can do implimentation-hiding interfaces is > > pure propaganda. > > It is possible to hide the implementation behind any procedure. But > it requires some kind of OO mechanism to be polymorphic. That > is what OO is, by definition. > Whatever. It is not much difference to the user of such API's, mostly a matter of verb position. x.movenext movenext(x) tamato tamato > -- > Patrick Logan > mailto:patrickdlogan at home.com > > -tmind- From jarober at mail.com Mon Feb 26 14:24:16 2001 From: jarober at mail.com (James A. Robertson) Date: Mon, 26 Feb 2001 13:24:16 GMT Subject: Collection interfaces (Was: New to OO concepts - re-usability) 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> Message-ID: <3A9A59BD.6E0AF59@mail.com> Topmind wrote: > > > > You mean something like SQL or ODBC? > > > > No, I mean collections, as with, say, the Smalltalk collection classes. > > > > Smalltalk uses collection taxonomies, which I frown on. > Collection needs change, morph, and grow. If you tie your > application to a specific "type", then the chances of > getting screwed are high IME. > You can mix and match Smalltalk collections (and have been able to for decades). You might try downloading one of the free or cheap Smalltalks and looking for yourself. > If Smalltalk wants to rewrite them so features can be > mixed and match as needed, instead of based on an limiting > taxonomy, that would be great. (I am working on > my version of such a spec, BTW.) > > OO thinking is taxonomy-happy. I see it in collections, > streams, and GUI's. One can have many more variations if > you treat features as indepedent. Sure, not all combinations > are valid, but the pattern of invalidity is not a > tree pattern for the most part. > > > > And, this crap that only OO can do implimentation-hiding interfaces is > > > pure propaganda. > > > > It is possible to hide the implementation behind any procedure. But > > it requires some kind of OO mechanism to be polymorphic. That > > is what OO is, by definition. > > > > Whatever. It is not much difference to the user of such API's, mostly a > matter of verb position. > > x.movenext > movenext(x) > > tamato > tamato > > > -- > > Patrick Logan > > mailto:patrickdlogan at home.com > > > > > > -tmind- -- James A. Robertson Product Manager (Smalltalk), Cincom jarober at mail.com From topmind at technologist.com Tue Feb 27 06:09:37 2001 From: topmind at technologist.com (Topmind) Date: Tue, 27 Feb 2001 05:09:37 GMT Subject: Collection interfaces (Was: New to OO concepts - re-usability) 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> <3A9A59BD.6E0AF59@mail.com> Message-ID: > Topmind wrote: > > > > > > > You mean something like SQL or ODBC? > > > > > > No, I mean collections, as with, say, the Smalltalk collection classes. > > > > > > > Smalltalk uses collection taxonomies, which I frown on. > > Collection needs change, morph, and grow. If you tie your > > application to a specific "type", then the chances of > > getting screwed are high IME. > > > > You can mix and match Smalltalk collections (and have been able to for > decades). You might try downloading one of the free or cheap Smalltalks > and looking for yourself. > "Mix" implies they start out differently. They may signify something. It *is* on my (long) list of things to look into. BTW, any web links to ST collection interface catalogs? [snip] -tmind- From tgagne at ix.netcom.com Mon Feb 26 17:39:13 2001 From: tgagne at ix.netcom.com (Thomas Gagne) Date: Mon, 26 Feb 2001 11:39:13 -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> Message-ID: <3A9A86B1.9A8C69A2@ix.netcom.com> Topmind wrote: > > > Smalltalk uses collection taxonomies, which I frown on. > Collection needs change, morph, and grow. If you tie your > application to a specific "type", then the chances of > getting screwed are high IME. > > If Smalltalk wants to rewrite them so features can be > mixed and match as needed, instead of based on an limiting > taxonomy, that would be great. (I am working on > my version of such a spec, BTW.) My imagination may be limited, so you can suggest what some of your suggestions would be to change, morph, and grow collections and streams? -- .tom From topmind at technologist.com Tue Feb 27 05:37:24 2001 From: topmind at technologist.com (Topmind) Date: Tue, 27 Feb 2001 04:37:24 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> Message-ID: > Topmind wrote: > > > > > > > Smalltalk uses collection taxonomies, which I frown on. > > Collection needs change, morph, and grow. If you tie your > > application to a specific "type", then the chances of > > getting screwed are high IME. > > > > If Smalltalk wants to rewrite them so features can be > > mixed and match as needed, instead of based on an limiting > > taxonomy, that would be great. (I am working on > > my version of such a spec, BTW.) > > My imagination may be limited, so you can suggest what some of your suggestions > would be to change, morph, and grow collections and streams? > > > -- > .tom > Regarding collections, I am working on that one like I said. The main point is that you *do* stack operations on a collection. You don't make the collection ONLY a stack, for example. Thus, there is no "morphing" per se. It is a view, not a type. As far as streams, make a list of all possible stream interfaces and attributes. When you do your part, I will do mine. (I am still working on collection API's right now, streams will have to wait unless you wish to help.) -tmind- From aleaxit at yahoo.com Tue Feb 27 08:06:57 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 27 Feb 2001 08:06:57 +0100 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> Message-ID: <97fjla128ir@news2.newsguy.com> "Topmind" wrote in message news:MPG.1504d14563dce6499896af at news.earthlink.net... [snip] > The main point is that you *do* stack operations on a collection. I may be missing your point. In Standard C++, you may _adapt_ *some* collections for use as a stack -- that is what std::stack is for, it's an ADAPTER. But *NOT* all collections are usable as 'stacks' -- only those on which order of insertion is significant and recorded; what would it make to 'pop' the 'top' (what top?) of a multiset, say? Alex From topmind at technologist.com Tue Feb 27 20:51:10 2001 From: topmind at technologist.com (Topmind) Date: Tue, 27 Feb 2001 19:51:10 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> Message-ID: > "Topmind" wrote in message > news:MPG.1504d14563dce6499896af at news.earthlink.net... > [snip] > > The main point is that you *do* stack operations on a collection. > > I may be missing your point. In Standard C++, you may > _adapt_ *some* collections for use as a stack -- that is > what std::stack is for, it's an ADAPTER. But *NOT* all > collections are usable as 'stacks' -- only those on which > order of insertion is significant and recorded; what would > it make to 'pop' the 'top' (what top?) of a multiset, say? > > > Alex > > Why can't the nodes of a multi-set ALSO have time-stamps or a sequantial record/node number in them? If so, then in T.O.P. thinking it should be a sinch to use it as a stack also. (Even if by chance the the API does not provide stack operations, writing a Push and Pop function/method should be a snap.) IOW, a "stack" or "multiset" is *how you use a collection*, not how it is implemented or what the original API used on it was. The HAS-A approach to collections is just plain more flexible because you are less locked into this-or-that thinking and fences. Requirements change and morph and merge. -tmind- From aleaxit at yahoo.com Tue Feb 27 22:23:22 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 27 Feb 2001 22:23:22 +0100 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> Message-ID: <97h5s40vhc@news2.newsguy.com> "Topmind" wrote in message news:MPG.1505a76831c34b749896b3 at news.earthlink.net... [snip] > Why can't the nodes of a multi-set ALSO have time-stamps > or a sequantial record/node number in them? Because that would be unwarranted overhead on 99.947% of the uses of a multiset...?! Why doesn't insertion into the multiset compute "priority" value according to _all_ possible formulas, as long as it's at it, so I can later decide that my multiset is actually a priority queue, too...? > Requirements change and morph and merge. And when they do, one refactors appropriately (and reruns one's tests -- that goes without saying). If I need my items timestamped, prioritized, turned into lowercase, or maybe translated into Elbonian, as I insert them into a collection, I'll be much happier providing or choosing the appropriate collection, rather than have all collections try to be all things to all items, thank you very much. Alex From topmind at technologist.com Wed Feb 28 03:11:10 2001 From: topmind at technologist.com (Topmind) Date: Wed, 28 Feb 2001 02:11:10 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> Message-ID: > "Topmind" wrote in message > news:MPG.1505a76831c34b749896b3 at news.earthlink.net... > [snip] > > Why can't the nodes of a multi-set ALSO have time-stamps > > or a sequantial record/node number in them? > > Because that would be unwarranted overhead on 99.947% > of the uses of a multiset...?! > > Why doesn't insertion into the multiset compute "priority" > value according to _all_ possible formulas, as long as it's > at it, so I can later decide that my multiset is actually a > priority queue, too...? > I am only saying that IF there are timestamps. I did NOT say it was a prerequisite for a multi-set. You misunderstood me. > > > Requirements change and morph and merge. > > And when they do, one refactors appropriately Refactor is a great PHB-directed euphemism for code rework. Call it whatever you want, but it is still unnecessary work. The divisions of collections into types *is* arbitrary for the most part. > (and reruns > one's tests -- that goes without saying). If I need my items > timestamped, prioritized, turned into lowercase, or maybe > translated into Elbonian, as I insert them into a collection, > I'll be much happier providing or choosing the appropriate > collection, rather than have all collections try to be all things > to all items, thank you very much. > I never said that the *engine* had to provide all those services. I am only selling the idea of not changing the existing calls when collection needs are added to or change. Born a stack != Die a stack > > Alex > > > > -tmind- From amk at mira.erols.com Wed Feb 28 03:34:23 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 28 Feb 2001 02:34:23 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> Message-ID: On Wed, 28 Feb 2001 02:11:10 GMT, Topmind wrote: >> And when they do, one refactors appropriately > >Refactor is a great PHB-directed euphemism for >code rework. Call it whatever you want, but it is >still unnecessary work. But given that requirements change and lacking a reliable Delphic Oracle, it's impossible to divine the correct solution at the beginning, so the code rework is unavoidable and necessary. It would certainly be better if a writer like Leacock knew always what was best to do and what would look best in the eyes of posterity, but such unnatural foresight cannot be required of any man. -- Robertson Davies, _A Voice from the Attic_ You write a great program, regardless of language, by redoing it over & over & over & over, until your fingers bleed and your soul is drained. But if you tell newbies *that*, they might decide to go off and do something sensible, like bomb defusing. -- Tim Peters, 5 Jun 1998 --amk From topmind at technologist.com Wed Feb 28 05:52:47 2001 From: topmind at technologist.com (Topmind) Date: Wed, 28 Feb 2001 04:52:47 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> Message-ID: > On Wed, 28 Feb 2001 02:11:10 GMT, Topmind wrote: > >> And when they do, one refactors appropriately > > > >Refactor is a great PHB-directed euphemism for > >code rework. Call it whatever you want, but it is > >still unnecessary work. > > But given that requirements change and lacking a reliable Delphic > Oracle, it's impossible to divine the correct solution at the > beginning, so the code rework is unavoidable and necessary. > > [snip] The point is to *minimize* the changes needed. If the changes don't match a method's boundaries, you have MORE work than what you usually have in task-oriented procedural/relational programming. For more details, please see: http://www.geocities.com/tablizer/boundary.htm -tmind- From aleaxit at yahoo.com Wed Feb 28 09:08:44 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 28 Feb 2001 09:08:44 +0100 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> Message-ID: <97ibmc0k47@news1.newsguy.com> "Topmind" wrote in message news:MPG.1506265ebf6d934d9896be at news.earthlink.net... > > On Wed, 28 Feb 2001 02:11:10 GMT, Topmind > wrote: > > >> And when they do, one refactors appropriately > > > > > >Refactor is a great PHB-directed euphemism for > > >code rework. Call it whatever you want, but it is > > >still unnecessary work. > > > > But given that requirements change and lacking a reliable Delphic > > Oracle, it's impossible to divine the correct solution at the > > beginning, so the code rework is unavoidable and necessary. > > > > [snip] > > The point is to *minimize* the changes needed. If the > changes don't match a method's boundaries, you have MORE > work than what you usually have in task-oriented > procedural/relational programming. Not with a good (minimal) process, helpful tools, and, most particularly, the right mindset (which is both cause and consequence of the good/minimal process). Before you knock it, TRY it -- pick a pilot project of suitable size, a team ditto, and have a go at it with eXtreme Programming -- code test-first, *refactor mercilessly*, and *do the simplest thing that can possibly work*, being the three keys here... and do note that they work together, *sinergically*. (No doubt you will consider this "a euphemism", too, but, as usual, I'm just striving to use words precisely; I don't particularly care if others use should-be-precise words, such as 'sinergy' or 'refactor', as euphemistic cover-up for lack of substance). > For more details, please see: > > http://www.geocities.com/tablizer/boundary.htm This seems to show what blind alleys classical approaches can lead one to -- ```Reorganization can be risky. Many managers do not want programs altered except to add or fix features. If an significant error occurs due to reorganization, then heads roll. I have been told many times, "If it ain't broke, please don't fix it."''' being the key quote from that paper. >From that unproductive mindset, among many other ills, comes the "boundary fixation" with which the rest of the article appears to be obsessed. (But the ills are many indeed; the "lava flow" anti-pattern, for example, is likely to be quite pervasive in a development shops to which this article could apply). But the right unit of encapsulation is NOT the method, nor the object, nor the class; it's a *component*, a small to middling set of classes/objects/methods (and, in languages which allow other organizing structures, functions, modules, etc), which are developed and tested and released _and, thus, reused_ *together*. Component boundaries are indeed of very high relevance. Boundaries _within_ a components are not. [Restructuring in a way that alters component relationships is one thing -- it is, indeed, *re-architecting* a whole software *system*; only *system-level* (aka 'integration') tests will catch re-architecting problems, a good part of test-suites that unit-test specific components or small groups thereof will have to be scrapped, etc, etc.] Restructuring code, design, and even architecture *behind* the abstract interfaces which relate components is (should be!) a low-risk, high-frequence activity. Test suites MUST be good enough to provide very high ensurance that a group of components is still working to specs -- there is just no working around THAT; if your test suites are so deficient at the component and unit level, "not fixing what isn't broken" is not an option, as you CAN'T KNOW what IS and what isn't broken! *Analogy warning, proceed at your own risk*...!-) ```Crossing a street can be risky. Many parents do not want streets crossed except to reach a school or doctor. If an significant accident occurs due to crossing, then heads roll. I have been told many times, "If it ain't truly indispensable to be on the other side, please don't cross the street"'''. Adopting the 'software that happens to appear to work when not thoroughly tested is sacred and must not be touched' idea is parallel to keeping a kid always on his/her side of the street (except perhaps for emergencies such as schools and doctors:-). Not exactly conducive to optimal development (be it of social skill and a healthy life, OR good software). Providing safer approaches to street-crossing (underpasses and overpasses on high-traffic thoroughfares, lots more dead-end streets with speed bumps in residential areas, etc) is a far preferable attitude to trying to build, on the one block a kid is going to be confined to, all he or she could possibly ever need -- ice-cream stand, burger joint, public library, and so on -- which seems to me to be what you're advocating in the software (specifically, collection-interfaces) realm. Alex From fredrik at pythonware.com Wed Feb 28 10:12:13 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 28 Feb 2001 09:12:13 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> Message-ID: > Before you knock it, TRY it the martelli battlebot vs. the "galileo of programming" crackpot? now this could be really entertaining ;-) Cheers /F From topmind at technologist.com Wed Feb 28 17:53:09 2001 From: topmind at technologist.com (Topmind) Date: Wed, 28 Feb 2001 16:53:09 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> Message-ID: > > Before you knock > it, TRY it -- pick a pilot project of suitable size, a team > ditto, and have a go at it with eXtreme Programming Sure, hack-it-til-it-works indeed does work after enough time. But whether it produces a better system in the long run is another issue. Without better metrics, it is just Yet Another Methodology to add to the heap. How about you try heavy table-oriented programming for a few years. > code test-first, *refactor mercilessly*, I would rather use task-orientation and avoid excessive refactoring to begin with. "Refactoring" is a euphemism for "OO is not change-friendly after all". > > This seems to show what blind alleys classical approaches can > lead one to -- ```Reorganization can be risky. Many managers do > not want programs altered except to add or fix features. If an > significant error occurs due to reorganization, then heads roll. > I have been told many times, "If it ain't broke, please don't > fix it."''' being the key quote from that paper. Well, they are the boss. Sell rework to them, not me. > (But the ills are many indeed; the > "lava flow" anti-pattern, for example, is likely to be quite > pervasive in a development shops to which this article could > apply). What is this "lava flow" thing? I keep hearing it mentioned. More OO lore that nobody can keep up with. Scriptures build fast when the agnostics are silenced. I have shown in great detail why procedural seems better able to deal with non-boundaried differences, and I have yet to see counter-arguments other than "you get used to code rework if you just give it a fancy name." I won't sell out to wasteful effort. > But the right unit of encapsulation is NOT the method, nor > the object, nor the class; it's a *component*, a small to > middling set of classes/objects/methods (and, in languages > which allow other organizing structures, functions, modules, > etc), which are developed and tested and released _and, thus, > reused_ *together*. Component boundaries are indeed of very > high relevance. Boundaries _within_ a components are not. But the easy-to-componentize stuff is already for sale. Why would they bring in programmers if plug-and-play solutions were already available? (Report writers, sorters, DB's, GUI IDE's, communications, etc.) What is left is stuff that has a jillion interconnections to other things such that putting a clean box around it is not practical. Components usually work for things where the algorithm is complex but the interfaces are small. In biz stuff the interfaces/links to many entities is the largest part. Besides, you can characterize my development philosophy as "task componentization". AKA, a procedural module. > Adopting the 'software that happens to appear to work when > not thoroughly tested is sacred and must not be touched' idea > is parallel to keeping a kid always on his/her side of the > street (except perhaps for emergencies such as schools and > doctors:-). Not exactly conducive to optimal development > (be it of social skill and a healthy life, OR good software). I am not against re-arrangement. What I am complaining about is paradigms that *increase* the amount of re-arrangement that is required. OO appears to do such, partly because of the boundary/granularity issues. The whole refactoring thing is side-effect of OO. The paradigm is starting to barf, and now the same people who sold you the barfers are now also selling barf bags. Whadda Racket! If I was not so merit-minded, I would probably happily cash in on it too. -tmind- From joconnor at cybermesa.com Wed Feb 28 18:03:57 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Wed, 28 Feb 2001 10:03:57 -0700 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: <3A9D2F7D.A5FB0A30@cybermesa.com> Topmind wrote: > > The whole refactoring thing is side-effect of OO. The whole concept of refactoring comes fom SA/SD. It's also known as "Functional Decomposition". With statements like this you clearly illustrate that a) you don't know OO and b) you don't even understand your own chosen tools either -- Jay O'Connor joconnor at cybermesa.com http://www.cybermesa.com/~joconnor Python Language Forum - http://pub1.ezboard.com/fobjectorienteddevelopmentpython From aleaxit at yahoo.com Wed Feb 28 10:12:04 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 28 Feb 2001 10:12:04 +0100 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> Message-ID: <97ifd60sen@news1.newsguy.com> "Topmind" wrote in message news:MPG.1506007591cf818b9896bc at news.earthlink.net... > > "Topmind" wrote in message > > news:MPG.1505a76831c34b749896b3 at news.earthlink.net... > > [snip] > > > Why can't the nodes of a multi-set ALSO have time-stamps > > > or a sequantial record/node number in them? > > > > Because that would be unwarranted overhead on 99.947% > > of the uses of a multiset...?! > > > > Why doesn't insertion into the multiset compute "priority" > > value according to _all_ possible formulas, as long as it's > > at it, so I can later decide that my multiset is actually a > > priority queue, too...? > > I am only saying that IF there are timestamps. I did NOT say > it was a prerequisite for a multi-set. You misunderstood me. IF there are to be timestamps on insertion of items into a collection, a rare but far from unthinkable requirement, I do not want the collection to do it behind my back -- just as I do not want "prioritizing" to be happening without me knowing that (and thus being able, if need be, to customize the way items are timestamped, prioritized, etc). > > > Requirements change and morph and merge. > > > > And when they do, one refactors appropriately > > Refactor is a great PHB-directed euphemism for > code rework. Call it whatever you want, but it is > still unnecessary work. > > The divisions of collections into types *is* > arbitrary for the most part. There is definitely a lot of arbitrariness if the division is made into a _taxonomy_ -- as single-inheritance thinking may suggest. I'm definitely not advocating or defending the exclusive use of taxonomy, which IMHO tends to breed a somewhat warped worldview -- the natural view of abstract algebra does not lead to that, for example; in chains of specialization such as groupoid->semigroup->monoid->group, one may add a condition such as 'commutative' at different steps, so there is no taxonomic 'single-inheritance' chain leading to 'Abelian group'. However, reacting to the modeling over-restrictiveness of taxonomy with a bid to drop all _classification_ is, IMHO, an over-reaction; there IS a lot of structure in classification-_DAG_s, after all (and I'm not entering, here, into the issue of whether taxonomy is 'close enough' to effectively model *real-world* domains for programming purposes -- the indisputable success of Smalltalk does show that single-inheritance is *practically workable* for many tasks -- a general discussion of collection classes, IMHO, gets us closer to domains such as algebra, than to real-world domain modeling, anyway). > I never said that the *engine* had to provide all those > services. > > I am only selling the idea of not changing the existing > calls when collection needs are added to or change. > > Born a stack != Die a stack It's unclear whether, here, you're talking about an object (keeping its _identity_) dynamically changing its _class_ (I didn't think Smalltalk supported that, but I may easily be wrong on that score; Python certainly does). In my humble opinion, though, such extreme dynamism, while sometimes it proves VERY pragmatically useful (e.g., change a "proxy" placeholder class to a full-blown implementation class in a demand-driven, just-in-time manner), is not normally very useful in the _modeling_ (analysis) phase -- reasoning in terms of 'unchanging' class-membership tends to simplify the analysis, even if practical needs drive one to make use of the extremely-dynamic approaches in design & coding. Assuming you're not talking of runtime class-changes, but of modeling-time (analysis-time) 'behavior', then I'd still want to refactor when the needs have changed so much as to make me need (e.g.) a multiset where I used to use a stack. But then, I addressed the refactoring issue (and what it implies in terms of process and mindset) in another post to this thread a very short time ago -- and I haven't read anything from you that would change my mind on that (surely not the lava-flow-prone approach in the URL you gave:-). Alex From topmind at technologist.com Wed Feb 28 16:55:36 2001 From: topmind at technologist.com (Topmind) Date: Wed, 28 Feb 2001 15:55:36 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> Message-ID: > "Topmind" wrote in message > news:MPG.1506007591cf818b9896bc at news.earthlink.net... > > > "Topmind" wrote in message > > > news:MPG.1505a76831c34b749896b3 at news.earthlink.net... > > > [snip] > > > > Why can't the nodes of a multi-set ALSO have time-stamps > > > > or a sequantial record/node number in them? > > > > > > Because that would be unwarranted overhead on 99.947% > > > of the uses of a multiset...?! > > > > > > Why doesn't insertion into the multiset compute "priority" > > > value according to _all_ possible formulas, as long as it's > > > at it, so I can later decide that my multiset is actually a > > > priority queue, too...? > > > > I am only saying that IF there are timestamps. I did NOT say > > it was a prerequisite for a multi-set. You misunderstood me. > > IF there are to be timestamps on insertion of items into a > collection, a rare but far from unthinkable requirement, I do > not want the collection to do it behind my back -- just as I > do not want "prioritizing" to be happening without me knowing > that (and thus being able, if need be, to customize the way > items are timestamped, prioritized, etc). > No no no! I am not advocating forced time-stamps. (Although, a sequential unique record is quite often needed. But nothing has to be forced.) However, timestamping *is* a common need in my domain. > > > > > Requirements change and morph and merge. > > > > > > And when they do, one refactors appropriately > > > > Refactor is a great PHB-directed euphemism for > > code rework. Call it whatever you want, but it is > > still unnecessary work. > > > > The divisions of collections into types *is* > > arbitrary for the most part. > > There is definitely a lot of arbitrariness if the division > is made into a _taxonomy_ -- as single-inheritance thinking > may suggest. I'm definitely not advocating or defending > the exclusive use of taxonomy, which IMHO tends to breed a > somewhat warped worldview -- the natural view of abstract > algebra does not lead to that, for example; in chains of > specialization such as groupoid->semigroup->monoid->group, > one may add a condition such as 'commutative' at different > steps, so there is no taxonomic 'single-inheritance' chain > leading to 'Abelian group'. However, reacting to the > modeling over-restrictiveness of taxonomy with a bid to > drop all _classification_ is, IMHO, an over-reaction; When in doubt, leave it out. Unless one can see and show some natural law of the Universe that forces things into mutually-exclusive taxonomies, it is bad, arbitrary modeling, and OO sould be ashamed of itself for over promoting it. I hope the backlash is as strong as the hype that propelled it onto the packaging buzzword standards. Some domains like chemistry, math, etc. might be able to take advantage of natural divisions of "sub-things". However, many domains don't, and OO seems like nothing but added syntactical and modeling clutter without sub-divisioning. Two out of the 3 OO Cononical Triads depend on it. 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. (which is how it should be in biz modeling IME.) > .... > a general discussion of collection > classes, IMHO, gets us closer to domains such as algebra, than > to real-world domain modeling, anyway). Algebra? Programming paradigms are mostly for human communiction, not machine-to-machine. If many humans don't model the world via algebra, then I don't see what that gets one. > It's unclear whether, here, you're talking about an object > (keeping its _identity_) dynamically changing its _class_ No! There is no class to change to. There would be *one* and only one collection protocol. Not all engines would implement every feature of the protocol, but the idea is that you don't pick a protocol that STICKS you with only say stack-centric protocols or commands. I don't know about your domain, but I observe collections changing and growing in my domain. Starting out with just a dictionary (hash) can be a real pain if you later need more columns or more indexes, for example. Look at even a call stack in an interpreter. It would be nice to "X-ray" it and view it with different sorts and filters for complex debugging. This is what I like about tables. Studying the "state" of all kinds of angles is a sinch: you don't have to re-invent micro querie languages, write save-to-file utilities, etc., because they are usually built in. I like plug-and-play power. Perhaps some bit-diddling personalities like to re-invent little wheels, but I like to push simple buttons and get powerful results. > and I haven't read > anything from you that would change my mind on that (surely > not the lava-flow-prone approach in the URL you gave:-). It seems because you are USED TO refactoring when your collection needs change. I am spoiled. I know better. Or, your domain may be different. > the indisputable success > of Smalltalk does show that .... I would hardly call it "indisputed". Smalltalk is sort of the Frank Zappa of programming languages. It gets rave reviews and it is intellectually stimulating. However, it never quite catches on with general programmers. I think because its power does not live up to it's haughtiness. Using procedural and table techniques, I have matched Smalltalk "can-you-do-this" challenges in the past, and usually with more K.I.S.S. Thanks for your feedback -tmind- From mickeyz at qwest.net Wed Feb 28 17:37:11 2001 From: mickeyz at qwest.net (Randy A. Ynchausti) Date: Wed, 28 Feb 2001 09:37:11 -0700 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: Topmind > Using procedural and table techniques, I have matched > Smalltalk "can-you-do-this" challenges in the past, > and usually with more K.I.S.S. Wow -- what are you takin? It sure must be potent! Maybe I am wrong, maybe it's not chemical -- maybe you have just linked up with the guru who mentored the Beatles? Anyway it sure seems to work for you. Randy From topmind at technologist.com Wed Feb 28 18:06:20 2001 From: topmind at technologist.com (Topmind) Date: Wed, 28 Feb 2001 17:06:20 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> Message-ID: > Topmind > > > Using procedural and table techniques, I have matched > > Smalltalk "can-you-do-this" challenges in the past, > > and usually with more K.I.S.S. > > Wow -- what are you takin? It sure must be potent! > > Maybe I am wrong, maybe it's not chemical -- maybe you have just linked up > with the guru who mentored the Beatles? Anyway it sure seems to work for > you. > > Randy > Lookin in the mirror? OO is far more Guru-oriented than anything before it. It is generating tons of lore, scriptures, and meditation materials without any objective proof or metrics that it is better. One has to have years of "procedural DEprogramming" to "get it"? The Patty Herst paradigm? We have not seen such self-feeding intellectual fraud since ecomonic communism, Elron Hubbard, and Utah Cold Fusion. -tmind- From Brian.Gridley at LibertyMutual.com Wed Feb 28 19:21:40 2001 From: Brian.Gridley at LibertyMutual.com (Brian Gridley) Date: Wed, 28 Feb 2001 12:21:40 -0600 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: <97jfj3$9e2@gazette.lmig.com> I can imagine some limited places where this would be so, or some constraints that would make this so, but it is hard to imagine on a project with any depth. I did procedural and 4GL for 15 years, and Smalltalk for 5. I helped write a major system in Smalltalk at the same time our competitor wrote something from nearly identical specs. Ours cost 1/3 of theirs, supplied more features, and is far more flexible. Perhaps you can provide specifics to enlighten us as to what you have found procedural to do better. "Topmind" wrote in message news:MPG.1506d244a87ac34b9896c3 at news.earthlink.net... > > > Using procedural and table techniques, I have matched > > > Smalltalk "can-you-do-this" challenges in the past, > > > and usually with more K.I.S.S. > > ...> OO is far more Guru-oriented than anything before it. It is > generating tons of lore, scriptures, and meditation materials > without any objective proof or metrics that it is better... From tgagne at ix.netcom.com Tue Feb 27 16:12:57 2001 From: tgagne at ix.netcom.com (Thomas Gagne) Date: Tue, 27 Feb 2001 10:12:57 -0500 Subject: Stream 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> Message-ID: <3A9BC3F9.1929EB9A@ix.netcom.com> I don't think it's any of the programmer's business what the attributes are, unless of course, you asking for Stream's heirarchy: Steam PeekableStream PositionableStream ExternalStream BufferedExternalStream ExternalReadStream ExternalReadWriteStream ExternalWriteStream InternalStream WriteStream ReadWriteStream There may be other subclasses floating around I'm not aware of. It should be noted all of these classes, except the External* variety can be created on any collection (other Smalltalker's can chirp in here if I'm going astray). To list all the interfaces is a bit of a chore. It may be easier to check to see if there's something missing you believe should be provided. Just checking Stream's method dictionary I find: Stream MethodDictionary (#nextPut: #contents #atEnd #next: #do: #nextPutAll: #nextMatchFor: #next:put: #next #space #nextChunkPut: #timeStamp #close #cr #print: #store: #contentsSpecies #upToAll1: #next:into:startingAt: #emphasis #emphasis: #crtab: #tab #crtab #isReadable #through: #policy #upTo: #next:putAll:startingAt: #commit #throughAll: #upToEnd #flush #nextAvailable:into:startingAt: #needsFileLineEndConversion #computePrefixFunctionFor: #isWritable #isExternalStream #skipThrough: #throughAll1: #nextAvailable: #skipToAll1: #tab: #ioConnection #upToAll1:returnMatch:includePattern: ) There are others implemented in Stream's subclasses, but I expect this is the majority of them. I've been able to find everything I've been looking for somewhere in Stream's methods, or at least one of its descendents. -- .tom From topmind at technologist.com Tue Feb 27 21:07:13 2001 From: topmind at technologist.com (Topmind) Date: Tue, 27 Feb 2001 20:07:13 GMT Subject: Stream 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> <3A9BC3F9.1929EB9A@ix.netcom.com> Message-ID: [quote] Steam PeekableStream PositionableStream ExternalStream BufferedExternalStream ExternalReadStream ExternalReadWriteStream ExternalWriteStream InternalStream WriteStream ReadWriteStream [end quote] I admit that I am not an expert on streams, but this hierarchy seams tree-happy to me. Why not have something like this instead: s = newStream(....) s.peekable = true s.positionable = false s.external = blah s.buffered = blah s.readAble = true s.writeAble = true [use the stream now.....] (Note that the dot syntax could be a dictionary instead of an object, BTW. Also note that these would have *defaults* so that not every setting needs to be explicitly set.) This setup is much easier to manage and grok IMO. It also allows *more* potential combinations, like buffered internal streams. (I can't think of why anybody would want such, but why limit the future to one's current lack of imagination. Perhaps they want to test buffering locally.) I want to flatten GUI's and Collections in a similar way. Flatten flatten flatten! -flatmind- (But I am not flat-footed. I have a very prominent arch.) From jarober at cc36623-b.hwrd1.md.home.com Tue Feb 27 23:03:04 2001 From: jarober at cc36623-b.hwrd1.md.home.com (jarober at cc36623-b.hwrd1.md.home.com) Date: Tue, 27 Feb 2001 22:03:04 GMT Subject: Stream interfaces References: <3a90fa97.0@news1.mweb.co.za> <3A9A86B1.9A8C69A2@ix.netcom.com> Message-ID: <97h8d3$l03$1@cc36623-b.hwrd1.md.home.com> In article , Topmind wrote: > > >I admit that I am not an expert on streams, but this >hierarchy seams tree-happy to me. > stream := (String new: 1000) readStream. stream := 'myFile' asFileName writeStream. Same idea, but simpler... >Why not have something like this instead: > >s = newStream(....) >s.peekable = true >s.positionable = false >s.external = blah >s.buffered = blah >s.readAble = true >s.writeAble = true >[use the stream now.....] > >(Note that the dot syntax could be a >dictionary instead of an object, BTW. >Also note that these would have *defaults* >so that not every setting needs to be >explicitly set.) > >This setup is much easier to manage and grok IMO. It also allows *more* >potential combinations, like buffered internal streams. (I can't think of >why anybody would want such, but why limit the future to one's >current lack of imagination. Perhaps they want to test buffering >locally.) > >I want to flatten GUI's and Collections in a similar way. > >Flatten flatten flatten! > >-flatmind- > >(But I am not flat-footed. I have a very prominent arch.) > > -- James A. Robertson Product Manager (Smalltalk), Cincom jarober at mail.com From topmind at technologist.com Wed Feb 28 03:03:49 2001 From: topmind at technologist.com (Topmind) Date: Wed, 28 Feb 2001 02:03:49 GMT Subject: Stream interfaces References: <3a90fa97.0@news1.mweb.co.za> <3A9A86B1.9A8C69A2@ix.netcom.com> <97h8d3$l03$1@cc36623-b.hwrd1.md.home.com> Message-ID: > In article , > Topmind wrote: > > > > > > > > >I admit that I am not an expert on streams, but this > >hierarchy seams tree-happy to me. > > > > stream := (String new: 1000) readStream. > > stream := 'myFile' asFileName writeStream. > > Same idea, but simpler... > Simpler than what? What I showed was illustrative of the concept, not the utmost fewest syntax. Names can be given to common combinations, for example. (This could be in the form of functions, or a built-in configuration names.) You are not selling hierarchies, but shortcut names. My approach has WAY more possible combos than a tree. Make a little grid and see for yourself. > > >Why not have something like this instead: > > > >s = newStream(....) > >s.peekable = true > >s.positionable = false > >s.external = blah > >s.buffered = blah > >s.readAble = true > >s.writeAble = true > >[use the stream now.....] > > > >(Note that the dot syntax could be a > >dictionary instead of an object, BTW. > >Also note that these would have *defaults* > >so that not every setting needs to be > >explicitly set.) > > > >This setup is much easier to manage and grok IMO. It also allows *more* > >potential combinations, like buffered internal streams. (I can't think of > >why anybody would want such, but why limit the future to one's > >current lack of imagination. Perhaps they want to test buffering > >locally.) > > > >I want to flatten GUI's and Collections in a similar way. > > > >Flatten flatten flatten! > > > >-flatmind- > > > >(But I am not flat-footed. I have a very prominent arch.) > > > > -tmind- From sholden at holdenweb.com Wed Feb 28 00:11:49 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 27 Feb 2001 18:11:49 -0500 Subject: Stream 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> <3A9BC3F9.1929EB9A@ix.netcom.com> Message-ID: "Topmind" wrote in message news:MPG.1505ab2efd31b1639896b4 at news.earthlink.net... > [ ... ] > I want to flatten GUI's and Collections in a similar way. > > Flatten flatten flatten! > > -flatmind- > > (But I am not flat-footed. I have a very prominent arch.) > Troll, troll, troll (but I am not a troll). regards Steve From topmind at technologist.com Wed Feb 28 02:55:33 2001 From: topmind at technologist.com (Topmind) Date: Wed, 28 Feb 2001 01:55:33 GMT Subject: Stream 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> <3A9BC3F9.1929EB9A@ix.netcom.com> Message-ID: > > I want to flatten GUI's and Collections in a similar way. > > > > Flatten flatten flatten! > > > > -flatmind- > > > > (But I am not flat-footed. I have a very prominent arch.) > > > Troll, troll, troll (but I am not a troll). > > regards > Steve > > I will admit I am a troll if you admit that there is no proof that OO is better for most domains. -tmind- From dwig at advancedmp.net Wed Feb 28 23:40:12 2001 From: dwig at advancedmp.net (Don Dwiggins) Date: 28 Feb 2001 14:40:12 -0800 Subject: Stream interfaces In-Reply-To: topmind@technologist.com's message of "Tue, 27 Feb 2001 20:07:13 GMT" 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> <3A9BC3F9.1929EB9A@ix.netcom.com> Message-ID: Topmind writes: > Why not have something like this instead: > s = newStream(....) > s.peekable = true > s.positionable = false > s.external = blah > s.buffered = blah > s.readAble = true > s.writeAble = true > [use the stream now.....] > (Note that the dot syntax could be a > dictionary instead of an object, BTW. > Also note that these would have *defaults* > so that not every setting needs to be > explicitly set.) A couple of reactions: - Could this kind of thing be achieved using multiple inheritance with properly constructed mixins? (For example, do the Common Lisp or Eiffel folks use mixins to this effect?) - I've looked a very little at Aspect-Oriented Programming, which was pretty much at the research stage when I peeked. Based on that little bit of knowledge, this looks like it might be along the same lines (maybe an application of AOP). Sorry, I don't have a good URL handy, but it should be a good search term for your favorite engine. -- Don Dwiggins "It fills my head with ideas, Advanced MP Technology but I don't quite know what they are" dwig at advancedmp.net -- Alice, after hearing 'Jabberwocky' From ben.hutchings at roundpoint.com Fri Feb 23 03:02:03 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 22 Feb 2001 18:02:03 -0800 Subject: New to OO concepts - re-usability References: <3a90fa97.0@news1.mweb.co.za> <3A933830.7F98D118@ix.netcom.com> <220220010813598042%cmh@bDistributed.com> Message-ID: Chris Hanson writes: > In article , > Chris Tavares wrote: > > > While the world is totally different (static vs. dynamic typing), the > > concepts are in many ways the same. Studying the ideas behind the STL are > > well worth doing for everyone I would think. > > It's a great idea for learning what *not* to do. > > The STL is horribly designed. There's no hierarchy, I think you mean it's not an OO design, and that's true. There *are* common interfaces (random lookup, list-ops, front-ops, stack-ops, iteration), but those interfaces aren't explicit so you can't put off your choice of implementation to run-time - unless you use wrappers. > no real interchangeability in the container classes. Some algorithms require different interfaces from others. You can interchange containers as long as you keep a clear idea of which interfaces your algorithm(s) need and pick the right containers. The most common one is iteration, and almost all containers support that. > And they force you to do all sorts of extra work (some of which just > isn't feasible) to be able to store your objects in containers. Storing polymorphic objects certainly seems to be too difficult, since they have to be stored by reference and there is no ref-counting smart-pointer class in the standard library (but there is boost::shared_ptr). > STL was designed by number crunchers with the broken assumption that > programs are designed from the algorithm out and that efficiency is the > absolute most important goal. Software in the real world is designed > from the business requirements out; this usually starts with a human > interface and a set of user requirements, and efficiency is only > measured compared to human use rather than the processor's maximum > throughput. STL is not meant to do everything *for* the C++ programmer, but it is meant to be used *by* every C++ programmer. That's why it has to be efficient and flexible, and not too abstract. You can always write wrapper classes on top of it that are more abstract but less flexible or less efficient, but you could never write wrapper classes to make an abstract container library more efficient! -- Any opinions expressed are my own and not necessarily those of Roundpoint. From lopemanc at swbell.net Wed Feb 21 15:13:36 2001 From: lopemanc at swbell.net (Chris Lopeman) Date: Wed, 21 Feb 2001 08:13:36 -0600 Subject: New to OO concepts - re-usability References: <3a90fa97.0@news1.mweb.co.za> <3A933830.7F98D118@ix.netcom.com> Message-ID: <3A93CD10.C2123CE4@swbell.net> Actually much of what you have talked about here is simply covered under different topics. Mostly it is referred to as polymorphism. This is one of the three basic concepts behind OO. Another subtopic that touches on this is "inheritance based on behavior". While much inheritance is based on data (and this is how people are usually taught) the more advanced you become you will learn how to recognize where inheritance should take place based on behavior. Chris Lopeman Object Link Inc. Thomas Gagne wrote: > I just had an interesting conversation today with my brother who is learning > programming from scratch. He's learning Smalltalk, and was watching me debug a > program I'm working on and we visited the subject of reuse. > > One of the things I learned recently (over in comp.lang.python, I think) was > that it is as important to reuse idioms as it is to reuse code. By designing > your classes to work within the idioms of the language you're using your > program ultimately reuses more, and becomes more reusable (and more easily > factored) itself. > > For instance, I could create all kinds of classes with their own protocol for > doing something, or I could endow them with behaviors that make them great > collection citizens. In Smalltalk, that would be thinking of how using do:, > select:, collect:, detect:, and inject:into: on collection containing my > objects would be either easier or more useful. > > Long-time Smalltalkers, and apparently Python programmers, may have already had > this drilled into their heads. I don't remember reading anything about > designing software to work well within the idiom of any language in any of the > books I've read. Maybe others have? > > x wrote: > > > Hi, > > > > I have been reading up on the OO environment, focusing on the use of UML to > > speed up creation of objects, or even to create superior designs of objects. > > > > Its great. Everyone is creating their reusable objects, no efforts are being > > wasted, these huge libraries are being built....are they? > > > > Does everyone create their own libraries, with a little sharing when > > requested, or is there some huge repository of objects available to all and > > sundry where the benefits of mankind's OO efforts are being stored nice and > > neat... you know, like the Human Genome project? > > > > I'm curious to know. > > > > Thanks > > > > Michael > > michael.wijtenburg at iafrica.com > > -- > .tom From brangdon at cix.co.uk Sat Feb 24 07:09:00 2001 From: brangdon at cix.co.uk (Dave Harris) Date: Sat, 24 Feb 2001 06:09 +0000 (GMT Standard Time) Subject: New to OO concepts - re-usability References: <3A93CD10.C2123CE4@swbell.net> Message-ID: lopemanc at swbell.net (Chris Lopeman) wrote (abridged): > Actually much of what you have talked about here is simply covered > under different topics. Mostly it is referred to as polymorphism. The principle would be something like: Maximise polymorphism by avoiding gratuitous differences of syntax/protocol. This is a bit more than polymorphism itself. I think it is a fairly subtle and difficult guideline to follow. People get gratuitous differences without realising it. One variation is Meyer's "Uniform Reference Principle". For example, in C++ and Java (and Smalltalk), direct access to an instance variable has different syntax to a no-argument message send. Thus: a = b.c; // Variable. a = b.c(); // Function call. The function call has spurious brackets. If we can drop them we get more polymorphism (if only at compile/link time). Meyer takes this uniformity to fairly extreme lengths in the Eiffel libraries. For example, the STACK protocol doesn't use the usual push/pop names, instead it copies the names used by other collection types. It can be surprising at first but the benefits are apparently worth it. There are benefits even if there is not likely to be an opportunity for polymorphism. If, say, both windows and files use open/close terminology, it is easier for programmers who know one to learn the other. 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 n8gray at caltech.edu.is.my.e-mail.address Wed Feb 21 04:56:59 2001 From: n8gray at caltech.edu.is.my.e-mail.address (Nathan Gray) Date: Tue, 20 Feb 2001 19:56:59 -0800 Subject: execvpe weirdness Message-ID: <3A933C8B.8040103@caltech.edu.is.my.e-mail.address> When I run the following script I get this error message: Error: Cannot find images in /usr/local/bin Apparently, Webots is not properly installed You must set the environment variable _HOME to the location of the directory and re-run . For example: export _HOME=/usr/local/ or: setenv _HOME /usr/local/ This is the error you should get if WEBOTS_HOME is not set correctly, but the error should complain about WEBOTS_HOME, not _HOME! Can somebody tell me where I've gone wrong? Thanks, -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ ------------------- Text of runwebots ---------------------- #!/usr/bin/env python import os, sys # Parse command line if len(sys.argv) < 2: print "Usage: runwebots (203|201)" sys.exit(1) elif sys.argv[1] == "201": webotsDir = "/usr/local/webots" rcFile = ".webotsrc201" elif sys.argv[1] == "203": webotsDir = "/home1/webots" rcFile = ".webotsrc203" else: print "Usage: runwebots (203|201)" sys.exit(-1) # Set up filenames and env. variables execName = webotsDir + "/webots" os.environ["WEBOTS_HOME"]=webotsDir os.environ["LD_LIBRARY_PATH"]="" # Make a link to the appropriate config file home = os.environ["HOME"] try: os.remove(home + "/.webotsrc") except OSError: pass #link doesn't exist os.symlink(rcFile, home + "/.webotsrc") # And away we go print "Running " + execName os.execvpe(execName, [''], os.environ) From n8gray at caltech.edu.is.my.e-mail.address Wed Feb 21 05:43:40 2001 From: n8gray at caltech.edu.is.my.e-mail.address (Nathan Gray) Date: Tue, 20 Feb 2001 20:43:40 -0800 Subject: execvpe weirdness References: <3A933C8B.8040103@caltech.edu.is.my.e-mail.address> Message-ID: <3A93477C.9050701@caltech.edu.is.my.e-mail.address> Nathan Gray wrote: > When I run the following script I get this error message: > > Error: Cannot find images in /usr/local/bin > Apparently, Webots is not properly installed > You must set the environment variable _HOME to the > location of the directory and re-run . > For example: export _HOME=/usr/local/ > or: setenv _HOME /usr/local/ > This is the error you should get if WEBOTS_HOME is not set correctly, > but the error should complain about WEBOTS_HOME, not _HOME! > > Can somebody tell me where I've gone wrong? > > Thanks, > -n8 OK, thanks to a dejanews search I figured out that I need to say: execvpe(execName, [execName], os.environ) or execle(execName, execName, os.environ) and I think I even understand why -- it's so you can call an executable with something other than the name of the executable as argv[0]. I can sorta see why this is useful, but it would be nice if the documentation for exec* was a little more explicit about the nature of "arg0". A line like: "Note: arg0 is traditionally the name of the executable, and some executables will depend on this." would have saved me a lot of hair-pulling. Or have I misunderstood something? -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From n8gray at caltech.edu.is.my.e-mail.address Wed Feb 21 06:09:46 2001 From: n8gray at caltech.edu.is.my.e-mail.address (Nathan Gray) Date: Tue, 20 Feb 2001 21:09:46 -0800 Subject: execvpe weirdness References: <3A933C8B.8040103@caltech.edu.is.my.e-mail.address> <3A93477C.9050701@caltech.edu.is.my.e-mail.address> Message-ID: <3A934D9A.1040401@caltech.edu.is.my.e-mail.address> Nathan Gray wrote > OK, thanks to a dejanews search I figured out that I need to say: > execvpe(execName, [execName], os.environ) > or > execle(execName, execName, os.environ) > > and I think I even understand why -- it's so you can call an executable > with something other than the name of the executable as argv[0]. I can > sorta see why this is useful, but it would be nice if the documentation > for exec* was a little more explicit about the nature of "arg0". A line > like: "Note: arg0 is traditionally the name of the executable, and > some executables will depend on this." would have saved me a lot of > hair-pulling. > > Or have I misunderstood something? > > -n8 Since we've already decided that flaming onesself is inappropriate on this newsgroup , I'll simply point out to poor Nathan that the documentation in 2.0 is much better on the exec* functions. """ The various exec*() functions take a list of arguments for the new program loaded into the process. In each case, the first of these arguments is passed to the new program as its own name rather than as an argument a user may have typed on a command line. For the C programmer, this is the argv[0] passed to a program's main(). For example, "os.execv('/bin/echo', ['foo', 'bar'])" will only print "bar" on standard output; "foo" will seem to be ignored. """ Maybe I'll make a witty remark about the time machine, too. In response, Nathan will say that although the documentation is indeed better for 2.0, it's still a bit confusing for those who don't program in C, and he thinks that his suggestion still might help. To which I'll respond that if he wants to see this happen he should really send his suggestion to python-docs at python.org. Depending on my mood, I may also chastise him for not looking for the correct venue before posting. With a mild air of indignity he'll reply that he already *has* sent his suggestion to python-docs at python.org. I'll then apologize, and the two of us will co-write, co-direct, and co-star in a movie about long-separated twin cops who reunite to track down a wacky gang of incompetent jewel thieves. Thanks for tuning in, -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From jacobkm at cats.ucsc.edu Wed Feb 21 07:28:58 2001 From: jacobkm at cats.ucsc.edu (Jacob Kaplan-Moss) Date: Tue, 20 Feb 2001 22:28:58 -0800 Subject: Rounding Question Message-ID: Hello All -- So I've got a number between 40 and 130 that I want to round up to the nearest 10. That is: 40 --> 40 41 --> 50 42 --> 50 ... 49 --> 50 50 --> 50 51 --> 60 etc. The way I'm doing it now is: >>> import math >>> depth = <> >>> tableDepth = int(math.ceil( depth/10.0 ) * 10) (NAUI divers will recognize me translating from actual depth to a table depth entry) This works just fine for my purposes, but its somewhat counterintuitive; I wonder if there is a more self-explanatory way... Anyone have any ideas? TIA, Jacob From aleaxit at yahoo.com Wed Feb 21 09:31:50 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 21 Feb 2001 09:31:50 +0100 Subject: Rounding Question References: Message-ID: <96vudj02hnf@news1.newsguy.com> "Jacob Kaplan-Moss" wrote in message news:jacobkm-07145C.22285820022001 at news.ucsc.edu... > Hello All -- > > So I've got a number between 40 and 130 that I want to round up to the > nearest 10. That is: > > 40 --> 40 > 41 --> 50 So, not really to the *nearest* 10, but to the *least multiple of 10 that is >= the original number*. OK. An *excellent* not-quite-toy example on which to hinge some general-interest discussion, IMHO... > >>> import math > >>> depth = <> > >>> tableDepth = int(math.ceil( depth/10.0 ) * 10) > > (NAUI divers will recognize me translating from actual depth to a table > depth entry) > > This works just fine for my purposes, but its somewhat counterintuitive; > I wonder if there is a more self-explanatory way... It is sometimes hard to say what people will find "intuitive" or "self-explanatory", but, what about: tableDepth = (depth/10) * 10 if tableDepth < depth: tableDepth += 10 The first step insures that tableDepth is a multiple of 10, <= depth; the second step changes the < part of it into a >, as required. People who are allergic to one-line if-statements might perhaps want to change the second step to: tableDepth += 10*(tableDepth= depth may suffice to make any or all of these expressions acceptable (this is a controversial statement, as a school exists that says too-complex code must be made simpler, rather than explained in a comment, since comments have a nasty way to get out of sync with code, etc; however, there are arguments on both sides when something has a certain "minimum irreducible intrinsic complexity" and particularly when that "complexity" is actually more of a *subtlety*...). So, all in all, I would suggest avoiding the floating point maths that your original approach used -- your intuition, IMHO, was *QUITE* on target suggesting that such an approach is sub-optimal... the complexities of FP, after all, make the subtleties of modulo arithmetic pale in comparison! In the end, something like: def depthToTableDepth(depth): "compute the least multiple of 10 >= depth" return int((depth+9)/10) * 10 may be the best compromise. The 'int' call will be redundant when depth is an integer, but it does not hurt, and may in fact clarify the code by reminding the reader that we are using TRUNCATING division -- and it will let this work unaltered if and when depth should become a FP number at some later time in the program's lifecycle, just like your original FP-based expression would keep working then. One should not introduce unwarranted generality when it (as is often the case) complicates things (the important "you ain't gonna need it" principle), but, at times, higher generality actually CLARIFIES and SIMPLIFIES things wrt a more targeted/ad-hoc approach; and I opine we're in such a case here, with the clarity coming from the _explicitness_ of 'int()'. Note that putting this into a function of its own, rather than inline code, may often be best (although, here, that's not wholly clear). A further _delicate_ judgment decision is whether generalizing from '10' is a gain or loss in clarity...: def nextHigherOrEqualMultiple(depth, N): "compute the least multiple of N >= depth" return int((depth+N-1)/N) * N with tableDepth = nextHigherOrEqualMultiple(depth, 10) I *think* it would be a substantial gain *IF* a name that is both clear AND concise could be found for the function, but not if we DO have to use a 25-characters name for clarity:-). Alex From jacobkm at cats.ucsc.edu Wed Feb 21 19:27:58 2001 From: jacobkm at cats.ucsc.edu (Jacob Kaplan-Moss) Date: Wed, 21 Feb 2001 10:27:58 -0800 Subject: Rounding Question References: <96vudj02hnf@news1.newsguy.com> Message-ID: In article <96vudj02hnf at news1.newsguy.com>, "Alex Martelli" wrote: [snip a whole bunch of great ideas...] Thanks so much for the great discussion; although this is really a trivial part of what I'm doing, it's nice to be able to do it right... In the end, I decided that: > def nextHigherOrEqualMultiple(depth, N): > "compute the least multiple of N >= depth" > return int((depth+N-1)/N) * N > > with > > tableDepth = nextHigherOrEqualMultiple(depth, 10) is what I'm going to use; I really only need to make this calculation once, so a long function name really isn't a problem, and although I'm writing for NAUI tables now, I know that certain other tables use increments of 5 feet, so it makes sense to have a generic function available. Thanks once again, Jacob From scarblac at pino.selwerd.nl Wed Feb 21 15:43:39 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 21 Feb 2001 14:43:39 GMT Subject: Rounding Question References: Message-ID: Jacob Kaplan-Moss wrote in comp.lang.python: > Hello All -- > > So I've got a number between 40 and 130 that I want to round up to the > nearest 10. That is: > > 40 --> 40 > 41 --> 50 > 42 --> 50 > ... > 49 --> 50 > 50 --> 50 > 51 --> 60 Rounding like this is the same as adding 5 to the number and then rounding down. Rounding down is substracting the remainder if you were to divide by 10, for which we use the % operator in Python. rounded = (number+5)-(number+5)%10 -- Remco Gerlich From mikael at isy.liu.se Wed Feb 21 16:49:26 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Wed, 21 Feb 2001 16:49:26 +0100 (MET) Subject: Rounding Question In-Reply-To: Message-ID: On 21-Feb-01 Remco Gerlich wrote: > Jacob Kaplan-Moss wrote in comp.lang.python: > > Hello All -- > > > > So I've got a number between 40 and 130 that I want to round up to the > > nearest 10. That is: > > > > 40 --> 40 > > 41 --> 50 > > 42 --> 50 > > ... > > 49 --> 50 > > 50 --> 50 > > 51 --> 60 > > Rounding like this is the same as adding 5 to the number and then rounding > down. Rounding down is substracting the remainder if you were to divide by > 10, for which we use the % operator in Python. > > rounded = (number+5)-(number+5)%10 Actually, that should be rounded = (number+9)-(number+9)%10 to get the behaviour Jacob asked for, provided that number is an integer. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 21-Feb-01 Time: 16:46:56 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From aleaxit at yahoo.com Wed Feb 21 17:05:36 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 21 Feb 2001 17:05:36 +0100 Subject: Rounding Question References: Message-ID: <970p0j0ri3@news1.newsguy.com> "Remco Gerlich" wrote in message news:slrn997ktk.h0.scarblac at pino.selwerd.nl... > Jacob Kaplan-Moss wrote in comp.lang.python: > > Hello All -- > > > > So I've got a number between 40 and 130 that I want to round up to the > > nearest 10. That is: > > > > 40 --> 40 > > 41 --> 50 > > 42 --> 50 > > ... > > 49 --> 50 > > 50 --> 50 > > 51 --> 60 > > Rounding like this is the same as adding 5 to the number and then rounding > down. Rounding down is substracting the remainder if you were to divide by > 10, for which we use the % operator in Python. > > rounded = (number+5)-(number+5)%10 This will work if you use +9 in each case rather than +5 (note that he doesn't really want rounding -- he wants 41 to 'round' to 50, for ex), and it's Yet Another Way To Do It similar but not identical to the dozen or so I explained in my previous post on this thread...:-) Alex From scarblac at pino.selwerd.nl Wed Feb 21 18:04:23 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 21 Feb 2001 17:04:23 GMT Subject: Rounding Question References: Message-ID: Remco Gerlich wrote in comp.lang.python: > Jacob Kaplan-Moss wrote in comp.lang.python: > > Hello All -- > > > > So I've got a number between 40 and 130 that I want to round up to the > > nearest 10. That is: So I read 'round to the nearest 10' and Alex read it correctly... > > 40 --> 40 > > 41 --> 50 > > 42 --> 50 > > ... > > 49 --> 50 > > 50 --> 50 > > 51 --> 60 > > Rounding like this is the same as adding 5 to the number and then rounding > down. Rounding down is substracting the remainder if you were to divide by > 10, for which we use the % operator in Python. > > rounded = (number+5)-(number+5)%10 I'd go for rounded = number-(number%10)+10 now. -- Remco Gerlich From mikael at isy.liu.se Thu Feb 22 08:23:19 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Thu, 22 Feb 2001 08:23:19 +0100 (MET) Subject: Rounding Question In-Reply-To: Message-ID: On 21-Feb-01 Remco Gerlich wrote: > I'd go for > rounded = number-(number%10)+10 > now. I'm sorry, but this also behaves badly. It rounds 10 up to 20. To get Jacob's desired functionality, you could modify your idea to rounded = number-((number-1)%10)+9 still assuming only integer input. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 22-Feb-01 Time: 08:18:49 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From aleaxit at yahoo.com Thu Feb 22 09:43:14 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 22 Feb 2001 09:43:14 +0100 Subject: Rounding Question References: Message-ID: <972jev0huk@news2.newsguy.com> "Mikael Olofsson" wrote in message news:XFMail.010222082319.mikael at isy.liu.se... On 21-Feb-01 Remco Gerlich wrote: > I'd go for > rounded = number-(number%10)+10 > now. I'm sorry, but this also behaves badly. It rounds 10 up to 20. To get Jacob's desired functionality, you could modify your idea to rounded = number-((number-1)%10)+9 still assuming only integer input. ...which of course is totally equivalent to the earlier proposed rounded = (number+9) - ((number+9)%10) since addition is commutative and associative (you can move the +9 from the right of the expression) AND so is addition in modulo-arithmetic, so that: (X-1)%N==(X%N)+((-1)%N)==(X%N)+((N-1)%N)==(X+N-1)%N Alex From mikael at isy.liu.se Thu Feb 22 14:37:56 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Thu, 22 Feb 2001 14:37:56 +0100 (MET) Subject: Rounding Question In-Reply-To: <972jev0huk@news2.newsguy.com> Message-ID: I corrected Remco: > I'm sorry, but this also behaves badly. It rounds 10 up to 20. To get > Jacob's desired functionality, you could modify your idea to > > rounded = number-((number-1)%10)+9 > > still assuming only integer input. Alex Martelli wrote: > ...which of course is totally equivalent to the earlier > proposed > rounded = (number+9) - ((number+9)%10) > since addition is commutative and associative (you can > move the +9 from the right of the expression) AND so > is addition in modulo-arithmetic, so that: > > (X-1)%N==(X%N)+((-1)%N)==(X%N)+((N-1)%N)==(X+N-1)%N Of course! I just couldn't stay silent when Remco stumbled again. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 22-Feb-01 Time: 14:35:06 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From mcalla at home.com Thu Feb 22 20:35:46 2001 From: mcalla at home.com (Mike Callahan) Date: Thu, 22 Feb 2001 19:35:46 GMT Subject: Rounding Question References: Message-ID: How about this, (taking advantange of the round function)? >>> def rounded(n): return int(round(n+4, -1)) >>> rounded(10) 10 >>> rounded(11) 20 >>> rounded(19) 20 >>> rounded(111) 120 >>> Mike Callahan From scarblac at pino.selwerd.nl Fri Feb 23 01:52:06 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 23 Feb 2001 00:52:06 GMT Subject: Rounding Question References: Message-ID: Mikael Olofsson wrote in comp.lang.python: > I corrected Remco: > > I'm sorry, but this also behaves badly. It rounds 10 up to 20. To get > > Jacob's desired functionality, you could modify your idea to > > > > rounded = number-((number-1)%10)+9 > > > > still assuming only integer input. > > > Alex Martelli wrote: > > ...which of course is totally equivalent to the earlier > > proposed > > rounded = (number+9) - ((number+9)%10) > > since addition is commutative and associative (you can > > move the +9 from the right of the expression) AND so > > is addition in modulo-arithmetic, so that: > > > > (X-1)%N==(X%N)+((-1)%N)==(X%N)+((N-1)%N)==(X+N-1)%N > > Of course! I just couldn't stay silent when Remco stumbled again. Yeah yeah, rub it in... :) Thing is I wasn't assuming integers, I wanted to write something that works on floats as well. He only gave integer examples, but his example code with math.ceil and dividing by 10.0 works on floats as well, and I thought it likely that he'd get non-integer depth measurements once. Therefore, I didn't want to use the /10*10 trick and using +9 didn't enter my mind... So now I'm proposing, for float input, if number % 10 == 0: return number else return number+10-(number%10) Otherwise you'll have to find out what the highest float smaller than 10 is. Since it is, again, far too late to be posting, I know full well that I'll get it wrong again... -- Remco Gerlich PS By now his original math.ceil solution starts to look better than mine... From adam at deprince.net Fri Feb 23 08:20:48 2001 From: adam at deprince.net (Adam DePrince) Date: Fri, 23 Feb 2001 02:20:48 -0500 Subject: Rounding Question References: Message-ID: <3A960F50.CCEA969E@deprince.net> Remco Gerlich wrote: > Mikael Olofsson wrote in comp.lang.python: > > I corrected Remco: > > > I'm sorry, but this also behaves badly. It rounds 10 up to 20. To get > > > Jacob's desired functionality, you could modify your idea to > > > rounded = number-((number-1)%10)+9 > > > still assuming only integer input. > > Alex Martelli wrote: > > > ...which of course is totally equivalent to the earlier > > > proposed > > > rounded = (number+9) - ((number+9)%10) > > > since addition is commutative and associative (you can > > > move the +9 from the right of the expression) AND so > > > is addition in modulo-arithmetic, so that: > > > (X-1)%N==(X%N)+((-1)%N)==(X%N)+((N-1)%N)==(X+N-1)%N > > Of course! I just couldn't stay silent when Remco stumbled again. > Yeah yeah, rub it in... :) > Thing is I wasn't assuming integers, I wanted to write something that works > on floats as well. He only gave integer examples, but his example code with > math.ceil and dividing by 10.0 works on floats as well, and I thought it > likely that he'd get non-integer depth measurements once. ^^^^^^^^^ Keep in mind the dangers associated with floats. Imprecision. Rounding. Truncation. Underflow. Are you generating the numbers to be rounded up via some other computation? If so, then what happens when a rounding error makes your answer 40.0000001 when on paper the answer should be 40. Your ceil function will return 50 instead of the correct value of 40. In your first post you mentioned that this is for diving table computation. Very saftey critical application. Floating point numbers have limitations. Equality doesn't always work when pencil and paper computations indicate it should. IEEE floats can't represent numbers like 0.4 precisely (0.4 is a repeating fraction in base 2). The answers will not be consistent from one type of machine to the other, or even from one compiler to the other. Entire careers are made out of dealing with the weirdness of floating point numbers near boundry conditions. And a function that chooses an answer by checking if a number of exactly 40 or the smallest number representable that is greater than 40, presuming you expect computed values exactly equal to 40, qualifies as a boundry condition. Stick with integer math. You will live longer. -- Adam DePrince Starmedia Network, Inc. Email: zlib.decompress('x\332KLI\314\325KI-(\312\314KNu(.I,\312MM\311L\324K\316\317\005\000\221\331\012s') From vze2f978 at mail.verizon.net Sat Feb 24 01:05:56 2001 From: vze2f978 at mail.verizon.net (Lloyd Hugh Allen) Date: Sat, 24 Feb 2001 00:05:56 GMT Subject: Rounding Question References: Message-ID: <3A96FB2C.60235B39@mail.verizon.net> Remco Gerlich wrote: > > Mikael Olofsson wrote in comp.lang.python: > > I corrected Remco: > > > I'm sorry, but this also behaves badly. It rounds 10 up to 20. To get > > > Jacob's desired functionality, you could modify your idea to > > > > > > rounded = number-((number-1)%10)+9 > > > > > > still assuming only integer input. > > > > > > Alex Martelli wrote: > > > ...which of course is totally equivalent to the earlier > > > proposed > > > rounded = (number+9) - ((number+9)%10) > > > since addition is commutative and associative (you can > > > move the +9 from the right of the expression) AND so > > > is addition in modulo-arithmetic, so that: > > > > > > (X-1)%N==(X%N)+((-1)%N)==(X%N)+((N-1)%N)==(X+N-1)%N > > > > Of course! I just couldn't stay silent when Remco stumbled again. > > Yeah yeah, rub it in... :) > > Thing is I wasn't assuming integers, I wanted to write something that works > on floats as well. He only gave integer examples, but his example code with > math.ceil and dividing by 10.0 works on floats as well, and I thought it > likely that he'd get non-integer depth measurements once. > > Therefore, I didn't want to use the /10*10 trick and using +9 didn't enter > my mind... > > So now I'm proposing, for float input, > > if number % 10 == 0: > return number > else return number+10-(number%10) ... > > PS By now his original math.ceil solution starts to look better than mine... Assuming integers, this'll do the same thing in one line: >>> def tableDepth(x): return 10 * ((x + 9) / 10) >>> tableDepth(49) 50 >>> tableDepth(40) 40 without integers, though, it'll give a runtime error. Or something. From maildsb at glbgrp.com Wed Feb 21 08:14:45 2001 From: maildsb at glbgrp.com (=?ISO-2022-JP?B?GyRCOXFGYjpHQmc1aSEiOkdEY05BNmIkTiVhITwla0dbPy4lNSE8JVMlORsoQg==?=) Date: Wed, 21 Feb 2001 16:14:45 +0900 Subject: =?ISO-2022-JP?B?GyRCOXFGYjpHQmc1aSEiOkdEY05BNmIkTiVhGyhC?= =?ISO-2022-JP?B?GyRCITwla0dbPy4lNSE8JVMlOSROJDQwRkZiGyhC?= Message-ID: <0221101161445.1217@WEBS> $B9qFb:GBg5i!":GDcNA6b$N%a!<%kG[?.%5!<%S%9$N$40FFb(B $B%[!<%`%Z!<%8$N at kEA!"$*E9$N at kEA!"?7>&IJ$N9pCN!"5a?MJg=8!"D4::!"9TJ}ITL@pJs%a%G%#%";v6HIt$H?=$7$^$9!#(B $B#U#R#L!'(B http://www.glbgrp.com$BFb(B $BEvpJsDs6!%5!<%S%9!Y!X>pJs4IM}Ds6!%7%9%F%`$N9=C[!YEy!">pJs$K4X$9(B $B$kA4HL$N%5!<%S%9$rDs6!$9$k2q&IJ$N9pCN(B D:$B5a?MJg=8!J9-HO0O$KJg=8$,=PMh$^$9!K(B E:$BD4::!J%"%s%1!<%HD4::!"Ey!K"(C"$7JLES2C9)NA6b$,$+$+$j$^$9!#(B F:$B9TJ}ITL@l9g$O(B $B!!(B $B#1#0!$#0#0#01_!\>CHq at G!\?69~)G[?.%G!<%?NL!'#1#6#6(BKbyt$B!JE:IU%U%!%$%k$=$NB>4^$`!K(B $B"($3$l$O$"$/$^$G?d>)$G$9$,!"$"$^$jBg$-$$$H%a!<%kpJs!J9-9p!"J8=q(B $BEy!K$rDj$a$i(B $B$l$?6b3[$GG[?.$9$k%5!<%S%9$G$9!#(B $B$*pJs$NFbMF$O!"HH:a$K4X78$9$k$b$N!"Hpkn!&Cf=}!&7y$,$i$;!"5u56!&(B $B%o%$%;%DJ8(B $B=q!&%o%$%;%D9-9p!"K=F0!"Ey$rM6H/$9$k2DG=@-!#Kt$O0cK!@-$,$"$k$HH=CG$5$l$k$b$N(B $B$O$*$9$k>l9g!K(B $BJV?.!&2sEz$5$l$?$b$N$O!"8D?M$rFCDj$G$-$k>pJs!J%"%I%l%9!&;aL>!&Ey!K$r=|$$$?(B $B%G!<%?$r%F%-%9%H(BCSV$BEy$GA4$F$*EO$7$$$?$7$^$9!#(B $BKt2sEz%G!<%?$O#17o#5#01_$NZ=PMh$+$M$^$9$N$G$4N;>5$/$@$5$$!#(B $BA\:w4j$$Ey$N2sEz!&O"Mm%a!<%k$OL5NA$G%G!<%?$r$*EO$7$7$^$9!#(B $B!!!JKtG[?.NA6b$b!"(B1$B%a!<%k%"%I%l%9C10L#11_$K$5$;$F$$$?$@$-$^$9!#!K(B $BLd$$9g$o$;!'(Bmaildsb at g-con.com $B!!(B $B!|$3$N%a!<%k$,ITMW$N>l$O!"$*l9g$,$4$6$$$^$9!#(B $B!!!!!!$"$7$+$i$:!"$4N;>5$/$@$5$$!#(B $B!!!!!!!!!!!!!!!!(B $B!!!!!!!!!!!!!!H/9T!'%0%m!<%V%$%s%U%)3t<02ql9g!"G[?.%a!<%k$N3NG'$,=PMh$?$b$N$H$_$J$7$^$9!#(B $B-'G[?.;XDjF|$K%a!<%k$NG[?.(B $B!!!!$=$N;~$K0MMjl9g!"F10l?MJ*$KF1$8%a!<%k$,G[?.$5$l$k2DG=@-$,$"$k(B $B$3$H$r$4N;>5$/$@$5$$!#(B $B!t!t!t!t!t!t!t!t!t!t!t!t!t!t!t!t!t!t!t!t!t!t!t!t!t!t!t!t!t!t(B From karl.grammer at univie.ac.at Wed Feb 21 09:45:43 2001 From: karl.grammer at univie.ac.at (grammer) Date: Wed, 21 Feb 2001 09:45:43 +0100 Subject: Newbie question: Python on Mac Message-ID: Hi out there, I hope somebody can help me with this: Whenever I open a Python script using Tkinter on my Mac, it is not possible to enter text or numbers into fields, although the scripts run on a Windows NT machine, where entering numbers or text in the fields is possible . I wandered through many faqs and website. I did not find this problem - am I completely dumb or what is this ? Karl (slowly getting mad) -- --------------------------------------------------------------------------- Karl Grammer Institute for Urban Ethology at the Institute for Antropology Althanstrasse 14 A-1090 Vienna/Austria Tel: +43-1-4277-54766 Fax: +43-1-4277-9547 http://evolution.anthro.univie.ac.at/lbi.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From sandipan at vsnl.com Wed Feb 21 11:13:05 2001 From: sandipan at vsnl.com (Sandipan Gangopadhyay) Date: Wed, 21 Feb 2001 15:43:05 +0530 Subject: Netfilter Message-ID: <005501c09bee$e2670d20$020000c3@node02> I control ipchains on my network firewall over python with os.system. Now, Linux 2.4 onwards will have a new and more powerful (and more featureful) packet filtering capability with netfilter (See http://www.linux-mag.com/1999-10/bestdefense_01.html for an intro.) Is there any plans for netfilter support in python that we can look forward to use ? Regards, Sandipan From precisa at uai.com.br Wed Feb 21 11:20:46 2001 From: precisa at uai.com.br (precisa at uai.com.br) Date: Wed, 21 Feb 2001 10:20:46 -0000 Subject: Scott Ambler's persistence layer in Python ? Message-ID: <9704pu+d6nr@eGroups.com> Hi, Has someone implemented Scott Ambler's persistence layer in Python ? http://www.ambysoft.com/persistenceLayer.html Thanks in advance Geraldo Lopes de Souza From hamish_lawson at yahoo.co.uk Wed Feb 21 18:40:28 2001 From: hamish_lawson at yahoo.co.uk (hamish_lawson at yahoo.co.uk) Date: Wed, 21 Feb 2001 17:40:28 -0000 Subject: Scott Ambler's persistence layer in Python ? In-Reply-To: <9704pu+d6nr@eGroups.com> Message-ID: <970uic+rlq2@eGroups.com> > Has someone implemented Scott Ambler's persistence layer in Python ? > > http://www.ambysoft.com/persistenceLayer.html The forthcoming Webware 0.5 has a persistence component called MiddleKit. The user's guide has a reference to Scott Ambler's papers. The system is currently only available via CVS, but below I've included cvsweb links to the introduction and the user's guide. http://cvs.sourceforge.net/cgi- bin/cvsweb.cgi/~checkout~/Webware/MiddleKit/Docs/Intro.html? cvsroot=webware http://cvs.sourceforge.net/cgi- bin/cvsweb.cgi/~checkout~/Webware/MiddleKit/Docs/UsersGuide.html? cvsroot=webware Webware is an suite of application-server components, but some of them - including, I think, MiddleKit - are designed to be able to be used outside of that system. Hamish Lawson From timo.becker at inosoft.de Wed Feb 21 11:23:22 2001 From: timo.becker at inosoft.de (timo.becker at inosoft.de) Date: 21 Feb 2001 10:23:22 GMT Subject: Python, MFC and the good old Hello World Message-ID: <9704uq$4iu$1@news.netmar.com> hi, can anybody give me a brief introduction in using mfc from python? Is it possible to port the following hello world to python and what would it look like? ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- class CMainWindow : public CFrameWnd { public: CMainWindow() { Create(NULL,"Hello World!"); } }; class CHelloApp : public CWinApp { public: virtual BOOL InitInstance() { m_pMainWnd = new CMainWindow(); m_pMainWnd->ShowWindow(m_nCmdShow); m_pMainWnd->UpdateWindow(); return TRUE; } }; CHelloApp HelloApp; ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- thanks in advance Timo ----- 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 MarkH at ActiveState.com Wed Feb 21 23:44:23 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 21 Feb 2001 22:44:23 GMT Subject: Python, MFC and the good old Hello World References: <9704uq$4iu$1@news.netmar.com> Message-ID: <3A9443EE.3070904@ActiveState.com> timo.becker at inosoft.de wrote: > hi, > can anybody give me a brief introduction in using mfc from python? Is it > possible to port the following hello world to python and what would it look > like? I'm afraid I don't have the time to do and test this - but check out "pywin\framework\intpyapp.py" - that is where you can find Pythonwin's main frame and app code. Note that if you dont have significant MFC experience or existing code you must interface with, wxPython would be a better choice. Mark. From Timo.Becker at INOSOFT.de Thu Feb 22 00:35:18 2001 From: Timo.Becker at INOSOFT.de (Timo Becker) Date: Thu, 22 Feb 2001 00:35:18 +0100 Subject: Python, MFC and the good old Hello World References: <9704uq$4iu$1@news.netmar.com> <3A9443EE.3070904@ActiveState.com> Message-ID: <971jbf$mptke$1@ID-76757.news.dfncis.de> Thanks for your help, Mark. > I'm afraid I don't have the time to do and test this - but check out "pywin\framework\intpyapp.py" - that is > where you can find Pythonwin's main frame and app code. Radim Pol?sek just told me that PythonWin comes with a helloapp.py in the demos/app directory (I must have been blind :-)) which is almost a one to one translation of the code I posted. > Note that if you dont have significant MFC experience or existing code you must interface with, wxPython > would be a better choice. I just started using MFC under C++ and only wanted to find out how much i can transfer of that new knowledge to Python. Most time I use Python Scripts as COM Servers and don't mind about a gui at all. Timo From aleaxit at yahoo.com Thu Feb 22 10:05:02 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 22 Feb 2001 10:05:02 +0100 Subject: Python, MFC and the good old Hello World References: <9704uq$4iu$1@news.netmar.com> <3A9443EE.3070904@ActiveState.com> <971jbf$mptke$1@ID-76757.news.dfncis.de> Message-ID: <972knt0j5n@news2.newsguy.com> "Timo Becker" wrote in message news:971jbf$mptke$1 at ID-76757.news.dfncis.de... > Thanks for your help, Mark. > > > I'm afraid I don't have the time to do and test this - but check out > "pywin\framework\intpyapp.py" - that is > > where you can find Pythonwin's main frame and app code. > > Radim Pol?sek just told me that PythonWin comes with a helloapp.py in the > demos/app directory (I must have been blind :-)) which is almost a one to > one translation of the code I posted. Emphasis on the "almost" -- e.g., it does NOT use a frame as its "frame", which your code did (and so did my translation thereof) -- it uses a generic window; it ignores the show parameter with which the program is invoked, forcing instead the use of SW_SHOWNORMAL (the OS compensates for this specific application bug in some versions, e.g. on NT4 SP4, but not on all versions), which your code and my translation thereof did not; etc. > > Note that if you dont have significant MFC experience or existing code you > must interface with, wxPython > > would be a better choice. > > I just started using MFC under C++ and only wanted to find out how much i > can transfer of that new knowledge to Python. Most time I use Python Scripts > as COM Servers and don't mind about a gui at all. Unless you *already* have substantial legacy MFC code or knowledge, I second the suggestion -- go for wxPython instead (or, Tkinter, or, Dynamic HTML, ...). The MFC architecture, besides not being portable, is "legacy" even from Microsoft's viewpoint. Alex From NoSpam at NoSpam.com Thu Feb 22 17:57:16 2001 From: NoSpam at NoSpam.com (Tom) Date: Thu, 22 Feb 2001 16:57:16 GMT Subject: Python, MFC and the good old Hello World References: <9704uq$4iu$1@news.netmar.com> <3A9443EE.3070904@ActiveState.com> <971jbf$mptke$1@ID-76757.news.dfncis.de> Message-ID: I was an MFC/C++ developer. I am now using the wxWindows GUI for both Python and C++. I find it to be similar to MFC - just better. I would recommend it to you. Tom. "Timo Becker" wrote in message news:971jbf$mptke$1 at ID-76757.news.dfncis.de... > Thanks for your help, Mark. > > > I'm afraid I don't have the time to do and test this - but check out > "pywin\framework\intpyapp.py" - that is > > where you can find Pythonwin's main frame and app code. > > Radim Pol?sek just told me that PythonWin comes with a helloapp.py in the > demos/app directory (I must have been blind :-)) which is almost a one to > one translation of the code I posted. > > > > Note that if you dont have significant MFC experience or existing code you > must interface with, wxPython > > would be a better choice. > > I just started using MFC under C++ and only wanted to find out how much i > can transfer of that new knowledge to Python. Most time I use Python Scripts > as COM Servers and don't mind about a gui at all. > > Timo > > From hamish_lawson at yahoo.co.uk Wed Feb 21 11:34:18 2001 From: hamish_lawson at yahoo.co.uk (=?iso-8859-1?q?Hamish=20Lawson?=) Date: Wed, 21 Feb 2001 10:34:18 +0000 (GMT) Subject: Specifying links in Python-URL bulletin Message-ID: <20010221103418.29467.qmail@web205.mail.yahoo.com> The recent acquiring of the Deja service by Google will have given the compiler of the Python-URL some headaches in trying to create links to Usenet items. I applaud the inventive solution using appropriate search terms for Google Groups, as in the example below. http://groups.google.com/groups?q=Dustin+Boswell+how+to+compile+https+support+into+Python2.0&hl=en&lr=&safe=off&rnum=1&ic=1 However, aside from the funky coloured highlighting which decorates the resulting message (and which some might regard as added value!), I wonder if there's the possibility that such a search may return multiple results or the wrong result. Instead it's possible to specify a particular message in Google Groups: http://groups.google.com/groups?q=group:comp.lang.python&seld=925202150&ic=1 For a message that has been located in Google using search terms, the message ID can be obtained by following the "View thread" link. Alternatively both Yahoo Groups and Python.org have archives of the mailing list: http://groups.yahoo.com/group/python-list/message/124006 http://mail.python.org/pipermail/python-list/2001-February/029488.html 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 phd at phd.pp.ru Wed Feb 21 11:56:11 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 21 Feb 2001 13:56:11 +0300 (MSK) Subject: Specifying links in Python-URL bulletin In-Reply-To: <20010221103418.29467.qmail@web205.mail.yahoo.com> Message-ID: On Wed, 21 Feb 2001, [iso-8859-1] Hamish Lawson wrote: > The recent acquiring of the Deja service by Google will have given the > compiler of the Python-URL some headaches in trying to create links to I was invited to be the editor 1 (one!) day before Google announced the deal! The day I started the job Deja interface worked and I collected some links. Next day I wanted to continue... Guess what I found on deja.com? :))) > Usenet items. I applaud the inventive solution using appropriate search > terms for Google Groups, as in the example below. > > http://groups.google.com/groups?q=Dustin+Boswell+how+to+compile+https+support+into+Python2.0&hl=en&lr=&safe=off&rnum=1&ic=1 :))) > However, aside from the funky coloured highlighting which decorates the > resulting message (and which some might regard as added value!), I > wonder if there's the possibility that such a search may return > multiple results or the wrong result. > > Instead it's possible to specify a particular message in Google Groups: > > http://groups.google.com/groups?q=group:comp.lang.python&seld=925202150&ic=1 My short experience showed that these "seld" values changed after some time. If you repeat yor search next day, e.g. :( > For a message that has been located in Google using search terms, the > message ID can be obtained by following the "View thread" link. > > Alternatively both Yahoo Groups and Python.org have archives of the > mailing list: > > http://groups.yahoo.com/group/python-list/message/124006 > http://mail.python.org/pipermail/python-list/2001-February/029488.html Yes, this, probably, is a good approach. Thank you. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From hamish_lawson at yahoo.co.uk Wed Feb 21 12:35:01 2001 From: hamish_lawson at yahoo.co.uk (=?iso-8859-1?q?Hamish=20Lawson?=) Date: Wed, 21 Feb 2001 11:35:01 +0000 (GMT) Subject: Specifying links in Python-URL bulletin In-Reply-To: Message-ID: <20010221113501.20088.qmail@web214.mail.yahoo.com> Hello Oleg > My short experience showed that these "seld" values changed after > some time. If you repeat yor search next day, e.g. :( Really? That's poor! They'll presumably have to settle on some kind of permanent ID scheme when they roll out their forthcoming browsing facilities. 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 phd at phd.pp.ru Wed Feb 21 12:39:11 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 21 Feb 2001 14:39:11 +0300 (MSK) Subject: Specifying links in Python-URL bulletin In-Reply-To: <20010221113501.20088.qmail@web214.mail.yahoo.com> Message-ID: On Wed, 21 Feb 2001, [iso-8859-1] Hamish Lawson wrote: > > My short experience showed that these "seld" values changed after > > some time. If you repeat yor search next day, e.g. :( > > Really? That's poor! They'll presumably have to settle on some kind of > permanent ID scheme when they roll out their forthcoming browsing > facilities. I think they are rather "session IDs", not permanent. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From meowbot at meowing.net Thu Feb 22 10:13:37 2001 From: meowbot at meowing.net (Consolidated Meowbot) Date: 22 Feb 2001 04:13:37 -0500 Subject: Specifying links in Python-URL bulletin References: Message-ID: <87elwrw05a.fsf@slip-129-37-99-9.tx.us.prserv.net> HOW ARE YOU GENTLEMEN!!! ALL YOUR NEWS ARE BELONG TO GOOGLE. YOU ARE ON THE WAY TO CONFUSION. >> My short experience showed that these "seld" values changed after >> some time. If you repeat yor search next day, e.g. :( > Really? That's poor! They'll presumably have to settle on some kind of > permanent ID scheme when they roll out their forthcoming browsing > facilities. The Deja Fscking Googleborg does allow using the real message ID. For example, to see the article you would use Appending an &ic=1 to that may or may not take you directly to the article instead of the summary, depending on the Googleborg's mood. The syntax for these URLs seems to be changing as the DFGoogleborg develops its news interface, so for the short term it may be more useful to simply provide the message ID so that one can enter the query `msgid:' at the main groups.google.com page, or paste it into the msgid field on the advanced search form. From hzhu at users.sourceforge.net Wed Feb 21 12:32:03 2001 From: hzhu at users.sourceforge.net (Huaiyu Zhu) Date: Wed, 21 Feb 2001 03:32:03 -0800 (PST) Subject: Alternative iterator syntax Message-ID: Following suggestion by Jeff Petkau , (http://mail.python.org/pipermail/python-list/2001-February/029944.html), here is a different proposal for iterators. Like the colon-syntax proposal, it achieves the following 1. It provides an extensible iterator interface without pretending to provide random access to elements. 2. It resolves the endless "i indexing sequence" debate. 3. It allows performance enhancements to dictionary iteration. 4. It is completely backward compatible. The gist of this proposal is that iterator syntax and semantics are not special. In particular, 1. Their semantics are obvious regardless of their origins and context. 2. They are generally applicable, not tied to sequences and mappings. 3. They reduce existing special syntax without introducing new ones. 4. They are backward compatible in a straightforward way. 5. The same syntax is applicable to "for..in" and "in". 6. It provides a magic hook for the list() function. The following text contains six sections: definitions, predefined usage, builtins, issues, rationale, appendix. ------------------------------------------------------- Definitions of Iterators: Iterators MUST define three magic methods: __next__ __contains__ __list__ They MAY also define additional magic methods: __arity__ __prev__ __first__ __last__ __reset__ These magic methods SHOULD satisfy the following semantic restrictions when they are defined __next__() returns items of the iterator one by one. It raises IndexError at the end. __contains__(x) returns true iff __next__() would return x at some point. __list__() returns a list of all x that would be returned by __next__(). __arity__() returns n iff x is an n-tuple for every x in __list__(). __prev__() iterates in the opposite direction of __next__() __first__() and __last__() return the first and last elements __next__() would have returned. __reset__() resets the iterator pointer to the start. They MAY but NEED NOT define a __len__ method, which may or may not return semantically correct result. A callable iterator x MUST define x.__call__() == x.__list__(). An easy way to make an iterator x callable is to set x.__call__ = x.__list__ Iterator usage in the following contexts are pre-defined: 1. for loops 2. in operator 3. list() function Since the semantics of each iterator x is completely specified by x.__list__(), we shall use such description when convenient. ------------------------------------------------------- Predefined Usage of Iterators: 1. The looping structure: Consider the structure for a, b, c, ... in A: do something else: do otherthing If A defines __next__, the above is interpreted as the equivalence of (__got is an invisible variable): __got = 0 while 1: try: a, b, c, ... = A.__next__() __got = 1 do something except IndexError: break if not __got: do otherthing In addition, if A.__arity__ is defined, it will be checked before the loop to avoid ValueError: unpack tuple of wrong size. This concept itself may also be generalized to allow safe tuple unpacking (see below). Else if A defines __list__, then "for x in A:" is interpreted as "for x in A.__list__():". Note that every list is an iterator (see below). Else if A is a callable object, then "for x in A:" is interpreted as "for x in A():". 2. The in operator: Consider the expression (a, b, c, ...) in A: If A defines __contains__, the above is interpreted as the equivalence of: A.__contains__((a,b,c, ...)) Else if A defines __list__, then "x in A" is interpreted as "x in A.__list__()". Note that every list is an iterator (see below). Else if A is a callable object, then "x in A" is interpreted as "x in A()". 3. Get full list: Consider the expression list(A) If a.__list__ is defined, the above is interpreted as A.__list__(). Else it is interpreted as in Python 2.0. This could be used to short circuit costly __getitem__ iterations whenever possible. If A is callable iterator, the above could also be written as A() ------------------------------------------------------- Applications to Builtins and Other Common Situations: 1. Sequences. The builtin sequence types (list, tuple, string) are changed to iterators by adding the three magic methods __next__, __contains__ and __list__. The following is always true: x.__list__() == list(x) In addition, Each sequence object x defines two attributes (indexes, items) that are themselves iterators. The arity of indexes is 1, that of items is 2. x.indexes.__list__() == range(len(x)) x.items.__list__() == zip(range(len(x)), x) They can be used in the following way a = "abc" for i in a.indexes: # i iterate over 0, 1, 2 for i,x in a.items: # i, x iterate over (0,'a'), (1,'b'), (2,'c') if i in a.indexes: # equiv. to i in range(len(a)) if i,x in a.items: # equiv. to i in a.indexes and a[i]==x. b = a.items() # equiv. to b = zip(range(len(a)), a) 2. Mappings. Each mapping object x defines three attributes (keys, values, items) that are callable iterators. The arity of keys and values is 1, that of items is 2. x.keys.__list__() == x.keys() x.values.__list__() == x.values() x.items.__list__() == x.items() They can be used in the following way d = {...} for k in d.keys: # lazy iteration for v in d.values: # lazy iteration for k,v in d.items: # lazy iteration if k in d.keys: # equiv. to d.has_key(k) if v in d.values: # equiv. to v in d.values() if k, v in d.items: # equiv. to d.has_key(k) and d[k]==v. Furthermore, all existing codes which treat them as methods continue to work, thanks to equivalences like d.keys() == d.keys.__call__() == d.keys.__list__() It is easy to convert existing code to the new syntax with global search and replacement in an editor: Replace all ".items():" with ".items:" Replace all ".keys():" with ".keys:" Replace all ".values():" with ".values:" Such replacements have net effect of reducing code clutter. Except the last one, they may also improve performance. 3. Splitting of texts. Several line-reading methods can be consolidated: for line in file.readlines: # equivalent to file.xreadlines() for line in x.splitlines: # lazy split lines = file.readlines(): # just as now line = file.readline() # equiv. to file.readlines.__next__() for c in sys.stdin.readchars: # if the os allows this It is possible to define additional attributes of iterators that are also iterators. Here are some possibilities: for x,y,z in file.readlines.splitwords: # iterate over lines split as words for block in file.read.split("\n\n"): # split a file into empty-line separated blocks # without reading the whole file in. 4. The Iterator class. An iterator class could be included with standard python, so that one could write: a = Iterator([1,2,3]) # Or a = Iterator(); a.__list__ = [1,2,3] for x in a: do something This is more useful compared with plain "for x in [1,2,3]" in situations where iterators are passed around, where iterations could be interrupted, or where iterators have attributes that are also iterators. Users could subclass this to achieve the effects they want. One example is the above read.split. Another example is when you want a server to start returning some results before it gets them all for record in database.query(question): This is by no means tied to existing sequence and mapping classes. It also provides easy syntax to express ideas like for k in dict.keys.sorted: # If sorting is done in a different thread # it does not need to be completed before # the first key is returned. Many operations on list could be well defined on iterators without generating a new list. Subclasses of Iterator can be defined to do things like map(func, iterator) # return an iterator without a new list [f(x) for x in iterator] # ditto filter(func, iterator) # return an iterator without a new list [x for x in iterator if func(x)] # ditto ------------------------------------------------------- Compatibility and Conversion Issues: This proposal introduces net gains for users without additional cost. It is completely backward compatible in application code. But to take advantage of the new features, it is necessary to make certain changes in user code. First consider what it takes to use iterators. For example, consider UserDict. To use the iterators, it is necessary to change for x in d.keys(): to for x in d.keys: For old code applied to new objects (where d.keys is iterator), there is no advantage, because d.keys() would generate a new list. There is no harm either. This is why d.keys must be a callable iterator. For new code applied to old objects (where d.keys is a method), the looping structure is interpreted as over d.keys(), which is a list. There is no harm either. This is why we defines for loop specifically for callable objects. Otherwise this would be a major obstacle for users converting old code to new ones, because they would have to remember which subclass of UserDict had be converted so that keys is now an iterator. Now consider what it takes to produce iterators. Still take UserDict as example. It is necessary to change def keys(self): return self.data.keys() to keys = data.keys Any subclass that redefines keys, values and items also need to be converted if they want to use iterators. It might be necessary to introduce one more level of indirection using __getattr__, as illustrated by the following idiom def __getattr__(self, name): if name == "keys": return self.data.keys elif name == "values": return self.data.values elif items == "items": return self.data.items Analogous treatment applies to sequences. For example, in UserList it is necessary to define __next__ = data.__next__ def __list__(self): return self.data __contains__ = data.__contains__ This covers cases like for x in []: for x in UserList(): for x in {}.keys: for x in UserDict().keys: In conclusion, users can use "x in X" without remembering whether X is an iterator, a method, or a sequence. Implementers can replace all list returning methods with iterators whenever necessary, assured that user codes expecting lists would still get what they expect. ------------------------------------------------------- Rationale: 1. Following Python tradition, using magic methods is preferred to adding special syntaxes. Special syntaxes are only added if existing syntax space is not large enough to call these magic methods, which is not the case here. 2. Iterators should not be limited to what they can emit, so the items should be allowed to be tuples of any desired arity. For example, an iterator over spatial points may be used as "x,y,z in points". This generality is not possible with the colon based special syntax that is only applicable to lists and dicts. 3. Iterators should be completely clear about what they iterate over (keys, values, items, indexes, lines, ...) without the assistance of context. Not depending on context is one of the major advantages of python over Perl, and should be adhered to if at all possible. The proposed syntax do not make any implicit assumptions about what is to be iterated over. 4. This is completely backward compatible. Any conversion can be done one by one. It can also be performed by global search and replacement. This is not so for the special colon syntax. 5. Any conversion to the new syntax has the immediate effect of removing an empty () while possibly improving performance. Nothing else changes. The conversion does not require implementers and users to keep in sync. 6. It plays well with list comprehension, which has a syntax lacking in delimiters. The alternative colon syntax would have added delimiters at the wrong places. 7. The arity attribute also solves the problem of tuple unpacking where the correctness of syntax cannot be determined in advance of an iteration. 8. The similarity between for loops and in operators offer such a conceptual simplification that it should not be dropped unless absolutely necessary. ------------------------------------------------------- Appendix: Application of the __arity__ syntax to general tuple unpacking. This is independent of the iterator issue, but it is closely related to the outputs of iterators. The __arity__ syntax proposed above appears to also solve tuple unpacking problems elsewhere. Tuple unpacking is perhaps the only place where the validity of python assignment syntax depends on the value. It is therefore often desirable to convey this information before it is too late. The __arity__ attribute may be used for this task. def func(): __arity__ = 2 x = (1,2) return x a, b = func() # Guaranteed success for unpacking a = func() # a becomes a tuple a, b, c = func() # UnpackError: attempt to change arity from 2 to 3. def func(): __arity__ = 2 x = 2 return x a, b = func() # ArityError: func arity is 2, but returns 1. a = func() # ArityError: func arity is 2, but returns 1. a, b, c = func() # UnpackError: attempt to change arity from 2 to 3. Both UnpackError and ArityError are subclasses of ValueError. This could be implemented this way: If the left hand side of an assignment is a tuple while the right hand side is a call to f, check that the arity of the tuple matches f.__arity__ unless f.__arity__ is None. All functions not defining __arity__ attribute default to __arity__==None. Therefore one can write things like if f.__arity__ == 1: x = f() elif f.__arity__ == 2: x,y = f() else: items = f() Huaiyu Zhu From aahz at panix.com Wed Feb 21 17:15:02 2001 From: aahz at panix.com (Aahz Maruch) Date: 21 Feb 2001 08:15:02 -0800 Subject: Alternative iterator syntax References: Message-ID: <970pi6$i4q$1@panix3.panix.com> In article , Huaiyu Zhu wrote: > >Following suggestion by Jeff Petkau , >(http://mail.python.org/pipermail/python-list/2001-February/029944.html), >here is a different proposal for iterators. This is really great; with a tiny bit of work, what you're calling an iterator is almost the same as an Icon generator, something many of us have been wishing for a long time. I hope you cc'd this to Ka-Ping; I'd also suggest posting this to python-dev. >Applications to Builtins and Other Common Situations: > >1. Sequences. The builtin sequence types (list, tuple, string) are > changed to iterators by adding the three magic methods __next__, > __contains__ and __list__. The following is always true: > > x.__list__() == list(x) > > In addition, Each sequence object x defines two attributes (indexes, > items) that are themselves iterators. The arity of indexes is 1, that > of items is 2. > > x.indexes.__list__() == range(len(x)) > x.items.__list__() == zip(range(len(x)), x) I think I would change the text to read: In addition, each sequence object x defines two methods (indexes, items) that each return an iterator object. The arity of indexes is 1, that of items is 2. The reason is that we want to keep hammering on the generality of iterators, for example in passing a single iterator object to a bunch of threads to generate keys. That brings up the point of how iterator.__list__() should work with an unbounded iterator. >Both UnpackError and ArityError are subclasses of ValueError. This >could be implemented this way: If the left hand side of an assignment is >a tuple while the right hand side is a call to f, check that the arity >of the tuple matches f.__arity__ unless f.__arity__ is None. > >All functions not defining __arity__ attribute default to >__arity__==None. Therefore one can write things like > > if f.__arity__ == 1: x = f() > elif f.__arity__ == 2: x,y = f() > else: items = f() I have no clue how to design/implement this, but it would be really neat if functions could *read* the desired arity and change the return value based on it. -- --- 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 The problem with an ever-changing .sig is that you have to keep changing it From aahz at panix.com Wed Feb 21 17:43:02 2001 From: aahz at panix.com (Aahz Maruch) Date: 21 Feb 2001 08:43:02 -0800 Subject: Alternative iterator syntax References: Message-ID: <970r6m$a4$1@panix2.panix.com> In article , Huaiyu Zhu wrote: > > [...] I'm not sure where to put this question, so I'm just deleting all of Huaiyu's text. How does one get UserDict.keys (note: no parens here) to return an iterator? Normally this will simply return a reference to the 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 The problem with an ever-changing .sig is that you have to keep changing it From mwh21 at cam.ac.uk Wed Feb 21 18:36:16 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 21 Feb 2001 17:36:16 +0000 Subject: Alternative iterator syntax References: <970r6m$a4$1@panix2.panix.com> Message-ID: aahz at panix.com (Aahz Maruch) writes: > In article , > Huaiyu Zhu wrote: > > > > [...] > > I'm not sure where to put this question, so I'm just deleting all of > Huaiyu's text. > > How does one get UserDict.keys (note: no parens here) to return an > iterator? Normally this will simply return a reference to the method. class _Keys: def __init__(self, dict): self.dict = dict def __contains__(self, item): return self.dict.has_key(item) def __call__(self): return self.dict.keys() ... etc ... class UserDict: def __init__(self, dict=None): if data is None: data = {} self.data = dict self.keys = _Keys(dict) ... etc ... Not *very* different from how you'd implement this in C, really. Hmm, you might want to have the _Keys object hang on the instance rather than the dict if assigning to the .data member of UserDict is allowed. Which would create a circular reference, but we don't have to worry about that too much now... Cheers, M. -- > Look I don't know. Thankyou everyone for arguing me round in > circles. No need for thanks, ma'am; that's what we're here for. -- LNR & Michael M Mason, cam.misc From tim.hochberg at ieee.org Wed Feb 21 20:24:28 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Wed, 21 Feb 2001 19:24:28 GMT Subject: Alternative iterator syntax References: <970r6m$a4$1@panix2.panix.com> Message-ID: "Michael Hudson" wrote in message news:m37l2kszu7.fsf at atrus.jesus.cam.ac.uk... > aahz at panix.com (Aahz Maruch) writes: > > > In article , > > Huaiyu Zhu wrote: > > > > > > [...] > > > > I'm not sure where to put this question, so I'm just deleting all of > > Huaiyu's text. > > > > How does one get UserDict.keys (note: no parens here) to return an > > iterator? Normally this will simply return a reference to the method. > > class _Keys: > def __init__(self, dict): > self.dict = dict > def __contains__(self, item): > return self.dict.has_key(item) > def __call__(self): > return self.dict.keys() > ... etc ... > > class UserDict: > def __init__(self, dict=None): > if data is None: > data = {} > self.data = dict > self.keys = _Keys(dict) > ... etc ... > > Not *very* different from how you'd implement this in C, really. > > Hmm, you might want to have the _Keys object hang on the instance > rather than the dict if assigning to the .data member of UserDict is > allowed. Which would create a circular reference, but we don't have > to worry about that too much now... I don't think this will work right though. Consider: for k in aUserDict.keys: # Do some stuff for k in aUserDict.keys: # Do some more stuff The way this is implemented here the second loop would bail out immediately because there is only a single iterator for a given instance and it is already exhausted. One could imagine even odder instances where one broke out halfway through the first loop; the second loop would then start iterating halfway through the dictionaries keys. To get this to work "right" one would need to generate a new iterator using getattr magic every time the attribute was asked. Something like: def UserDict: def __attr_keys_(self, op, value): if "op" == "get": return _Keys(dict) else: raise ValueError("keys not writable") Here I've used the syntax from the draft "Attribute Access Handlers" PEP. This makes the keys attribute sufficiently magical that it makes me a bit nervous. On the other hand, one could do kinda cool stuff like: myKeys = aUserDict.keys # Get my own copy of the keys iterator for key in myKeys: # Do Stuff if key == someSpecialKey: break # Do some processing out of the loop for key in myKeys: # resume where we left off # Do some other stuff Sure that example's a little contrived, but I'm sure that must be usefule somewhere <0.8 wink>. -tim From mwh21 at cam.ac.uk Wed Feb 21 20:34:59 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 21 Feb 2001 19:34:59 +0000 Subject: Alternative iterator syntax References: <970r6m$a4$1@panix2.panix.com> Message-ID: "Tim Hochberg" writes: [schnipp] > I don't think this will work right though. Consider: > > for k in aUserDict.keys: > # Do some stuff > for k in aUserDict.keys: > # Do some more stuff > > The way this is implemented here the second loop would bail out > immediately because there is only a single iterator for a given > instance and it is already exhausted. Nah, reset the allocator every time item 0 is asked for. I'd have to admit I haven't read Huaiyu Zhu's proposal carefully enough to be sure this would work, but something like this ought to be possible, I'd have thought. I mean, l = range(10) for i in l: # do some stuff for i in l: # do some other stuff will have to do something along these lines, no? Cheers, M. -- In general, I'd recommend injecting LSD directly into your temples, Syd-Barret-style, before mucking with Motif's resource framework. The former has far lower odds of leading directly to terminal insanity. -- Dan Martinez From tim.hochberg at ieee.org Wed Feb 21 21:29:34 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Wed, 21 Feb 2001 20:29:34 GMT Subject: Alternative iterator syntax References: <970r6m$a4$1@panix2.panix.com> Message-ID: "Michael Hudson" wrote in message news:m31ysru8ws.fsf at atrus.jesus.cam.ac.uk... > "Tim Hochberg" writes: > > [schnipp] > > I don't think this will work right though. Consider: > > > > for k in aUserDict.keys: > > # Do some stuff > > for k in aUserDict.keys: > > # Do some more stuff > > > > The way this is implemented here the second loop would bail out > > immediately because there is only a single iterator for a given > > instance and it is already exhausted. > > Nah, reset the allocator every time item 0 is asked for. I'd have to > admit I haven't read Huaiyu Zhu's proposal carefully enough to be sure > this would work, but something like this ought to be possible, I'd > have thought. But the loop psuedocode that Huaiyu Zhu proposed has no concept of asking for item zero: for a, b, c, ... in A: do something becomes: while 1: try: a, b, c, ... = A.__next__() do something except IndexError: break One could add an A.__reset__() call to the start of the loop, but I think that that would hamstring some other applications one would like for iterators. Resetting at the end doesn't appear to be any better. For the moment, I'll stand my original claim that the The Right Thing To Do (tm) is to get a new iterator each time. On the other hand (it was a short moment), this isn't really the behaviour you want for, for instance, file.readlines. Let's look at two cases: One would like aDict.keys to return distinct iterators: for key in aDict.keys: doSomething for key in aDict.keys: doSomething This should iterate over aDict's keys twice. However aFile can really have one iterator: for line in aFile.readlines: doSomething for line in aFile.readlines: doSomething This should almost certainly only iterate over the file once (in the first loop) and bail out immediately in the second loop. I suppose allowing different types of objects to return new iterators or not as appropriate would fix this. OK, so my new position is that objects should return new iterators when they feel it's appropriate <0.1 wink> Not-really-concerned-that-I'll-be-mistaken-for-the-real-tim'ly yours, -tim > I mean, > > l = range(10) > for i in l: > # do some stuff > for i in l: > # do some other stuff > > will have to do something along these lines, no? > > Cheers, > M. > > -- > In general, I'd recommend injecting LSD directly into your temples, > Syd-Barret-style, before mucking with Motif's resource framework. > The former has far lower odds of leading directly to terminal > insanity. -- Dan Martinez From wolfson at midway.uchicago.edu Wed Feb 21 22:51:15 2001 From: wolfson at midway.uchicago.edu (Ben Wolfson) Date: Wed, 21 Feb 2001 21:51:15 GMT Subject: Alternative iterator syntax References: Message-ID: In article , Tim Hochberg wrote: > >"Michael Hudson" wrote in message >news:m31ysru8ws.fsf at atrus.jesus.cam.ac.uk... >> "Tim Hochberg" writes: >> >> [schnipp] >> > I don't think this will work right though. Consider: >> > >> > for k in aUserDict.keys: >> > # Do some stuff >> > for k in aUserDict.keys: >> > # Do some more stuff >> > >> > The way this is implemented here the second loop would bail out >> > immediately because there is only a single iterator for a given >> > instance and it is already exhausted. >> >> Nah, reset the allocator every time item 0 is asked for. I'd have to >> admit I haven't read Huaiyu Zhu's proposal carefully enough to be sure >> this would work, but something like this ought to be possible, I'd >> have thought. > >But the loop psuedocode that Huaiyu Zhu proposed has no concept of asking >for item zero: > > for a, b, c, ... in A: > do something > >becomes: > > while 1: > try: > a, b, c, ... = A.__next__() > do something > except IndexError: > break > >One could add an A.__reset__() call to the start of the loop, but I think >that that would hamstring some other applications one would like for >iterators. Resetting at the end doesn't appear to be any better. For the >moment, I'll stand my original claim that the The Right Thing To Do (tm) is >to get a new iterator each time. One could also specify that, when appropriate, an iterator calls __reset__ before raising an IndexError. -- Barnabas T. Rumjuggler For the world, I count it not an inn, but an hospital; and a place not to live, but to die in. -- Thomas Browne, _Religio Medici_ From qrczak at knm.org.pl Thu Feb 22 00:21:10 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 21 Feb 2001 23:21:10 GMT Subject: Alternative iterator syntax References: Message-ID: Wed, 21 Feb 2001 21:51:15 GMT, Ben Wolfson pisze: > One could also specify that, when appropriate, an iterator calls > __reset__ before raising an IndexError. It doesn't work. I can have several iterators walking over a single sequence at once. Obtaining a stateful iterator is a stateful operation. You can't make the iterator once and keep it with the sequence, but you must produce an iterator each time an iteration is requested - unless its usage is functional, i.e. for the next element you don't call a method with side effects keeping the same iterator handle, but rebind the iterator handle after each iteration. If such operation is spelled as an attribute access, it must still be a function call internally. Disadvantages are twofold: The implementation must use __getattr__ to let attribute access have function call semantics. And it's confusing to programmers, which expect that such syntax accesses the same object each time (at least logically the same) - but they are stateful and have different identities. For comparison, in the tradition of functional languages linked lists are very common. They are their own iterators, i.e. it is not needed to have a separate iterator concept. Elements are not accessed by indices (unless someone really wants it), because such element access is O(n). Instead recursive functions are written to traverse lists. There are functions which wrap common patterns of such iteration, e.g. map, filter, reduce. Iteration relies on the fact that obtaining a tail of a list (the same list but without its first element) is O(1). It is safe to not perform any copying, because lists are generally immutable. In lazy languages lists are of course lazy. Functional programming is really about immutability; functions are only the second important thing. I would strongly advise to not invent a complicated stateful iterator framework, with all C++ features like stepping backwards, stepping the specified number of elements, computing a distance between two iterators over the same sequence, sorting the part of a sequence between two iterators, and all weird rules about which iterators are invalidated when you modify the sequence in interesting ways. Instead, if you want to have lazy reading of files expressed as an iteration over the sequence of lines, lazy iteration over dictionary keys without building their physical list, etc. - either design a simple iterator protocol to keep close to the current Python, or build a rich framework for lazy lists. In lazy languages all data structures are lazy, but for Python it should be enough to have lazy lists. Please don't stress mutability of such sequences. You should not mutate a sequence you are iterating over. In any case, the thing a 'for' loop is looping over should be kind-of-sequence. Not iterator (a new concept for Python) nor a pair of them (ugh!). Various things can be expressed as kind-of-sequences, e.g. reversing adaptor which does not make a physical copy, or a subsequence, or things discussed before: range(), readlines(), keys(). By kind-of-sequence I mean that it's not sufficient to use current sequence interface. It does not allow to distinguish between sequential access and random index access. It can be extended to primarily have sequential access in mind. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From aahz at panix.com Wed Feb 21 21:29:35 2001 From: aahz at panix.com (Aahz Maruch) Date: 21 Feb 2001 12:29:35 -0800 Subject: Alternative iterator syntax References: Message-ID: <9718ff$13a$1@panix6.panix.com> In article , Michael Hudson wrote: > >Nah, reset the allocator every time item 0 is asked for. I'd have to >admit I haven't read Huaiyu Zhu's proposal carefully enough to be sure >this would work, but something like this ought to be possible, I'd >have thought. > >I mean, > >l = range(10) >for i in l: > # do some stuff >for i in l: > # do some other stuff > >will have to do something along these lines, no? Nope. In Huaiyu's proposal, l will be a real list and each of the two for loops will create a new iterator. -- --- 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 The problem with an ever-changing .sig is that you have to keep changing it From root at rainerdeyke.com Wed Feb 21 21:29:21 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 21 Feb 2001 20:29:21 GMT Subject: Alternative iterator syntax References: <970r6m$a4$1@panix2.panix.com> Message-ID: "Tim Hochberg" wrote in message news:MBUk6.126$a_2.14850 at news1.rdc1.az.home.com... > "Michael Hudson" wrote in message > news:m37l2kszu7.fsf at atrus.jesus.cam.ac.uk... > > aahz at panix.com (Aahz Maruch) writes: > > class _Keys: > > def __init__(self, dict): > > self.dict = dict > > def __contains__(self, item): > > return self.dict.has_key(item) > > def __call__(self): > > return self.dict.keys() > > ... etc ... > > > > class UserDict: > > def __init__(self, dict=None): > > if data is None: > > data = {} > > self.data = dict > > self.keys = _Keys(dict) > > ... etc ... > I don't think this will work right though. Consider: > > for k in aUserDict.keys: > # Do some stuff > for k in aUserDict.keys: > # Do some more stuff UserDict.__getattr__ could construct a new 'keys' object on demand instead. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From KatMouse at gmx.de Wed Feb 21 21:18:43 2001 From: KatMouse at gmx.de (Eduard Hiti) Date: Wed, 21 Feb 2001 21:18:43 +0100 Subject: Alternative iterator syntax References: Message-ID: <9717su$db4$02$1@news.t-online.com> | Predefined Usage of Iterators: | | 1. The looping structure: | | Consider the structure | | for a, b, c, ... in A: | do something | else: | do otherthing | | If A defines __next__, the above is interpreted as the equivalence of | (__got is an invisible variable): | | __got = 0 | while 1: | try: | a, b, c, ... = A.__next__() | __got = 1 | do something | except IndexError: | break | if not __got: | do otherthing | I think there is an error in the code above. Shouldn't it rather go like: __exhausted = 0 while 1: try: a, b, c, ... = A.__next__() do something except IndexError: __exhausted = 1 break if __exhausted: do otherthing The 'do something' block can break to avoid executing 'do otherthing'. From root at rainerdeyke.com Wed Feb 21 21:29:21 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 21 Feb 2001 20:29:21 GMT Subject: Alternative iterator syntax References: Message-ID: "Huaiyu Zhu" wrote in message news:mailman.982769240.31345.python-list at python.org... > Following suggestion by Jeff Petkau , > (http://mail.python.org/pipermail/python-list/2001-February/029944.html), > here is a different proposal for iterators. > > Like the colon-syntax proposal, it achieves the following > > 1. It provides an extensible iterator interface without pretending to > provide random access to elements. > 2. It resolves the endless "i indexing sequence" debate. > 3. It allows performance enhancements to dictionary iteration. > 4. It is completely backward compatible. 5. It will allow iteration over "sequences" longer than 'sys.maxint'. > They MAY but NEED NOT define a __len__ method, which may or may not > return semantically correct result. What is the point in allowing a semantically incorrect '__len__'? > If A defines __next__, the above is interpreted as the equivalence of > (__got is an invisible variable): > Else if A defines __list__, then "for x in A:" is interpreted as "for > x in A.__list__():". Note that every list is an iterator (see below). (see below) > Else if A is a callable object, then "for x in A:" is interpreted as > "for x in A():". Won't this interfere with existing user-defined sequences that are also callable but don't support the iterator protocol? > 2. The in operator: > > Consider the expression > (a, b, c, ...) in A: > > If A defines __contains__, the above is interpreted as the equivalence > of: > A.__contains__((a,b,c, ...)) > > Else if A defines __list__, then "x in A" is interpreted as "x in > A.__list__()". Note that every list is an iterator (see below). Why is '__next__' not used? > Applications to Builtins and Other Common Situations: > > 1. Sequences. The builtin sequence types (list, tuple, string) are > changed to iterators by adding the three magic methods __next__, > __contains__ and __list__. The following is always true: > > x.__list__() == list(x) This is really really bad. Iterators have state. Tuples and strings do not. Consider the following: a = 'Hell, O world!' a.__next__() b = 'Hell, O world!' print '"%s", "%s", %d' % (a, b, a == b) # Are they the same? print a.__next__(), b.__next__() Don't do it. Instead, either the original iteration protocol should be left in place as backup, or there should be some automagic way of generating iterators form sequences. > In addition, Each sequence object x defines two attributes (indexes, > items) that are themselves iterators. The arity of indexes is 1, that > of items is 2. NOOooooOoooOo!!!!!!!! > > x.indexes.__list__() == range(len(x)) 'range(len(x))' returns a list of integers, not a list of 1-tuples. This may not be significant for sequences, but consider mappings: > 2. Mappings. Each mapping object x defines three attributes (keys, > values, items) that are callable iterators. The arity of keys and > values is 1, that of items is 2. The following is currently valid Python code: d = {('cheese', 'shop') : ('dead', 'parrot') } for a, b in d.keys(): print a, b # Prints 'cheese shop' for a, b in d.values(): print a, b # Prints 'dead parrot' Setting the arity of 'keys' and 'values' to 1 breaks this. > 4. The Iterator class. An iterator class could be included with > standard python, so that one could write: > > a = Iterator([1,2,3]) # Or a = Iterator(); a.__list__ = [1,2,3] I thought the '__list__' attribute of iterators was a method that returns a list, not a list. > 1. Following Python tradition, using magic methods is preferred to > adding special syntaxes. Special syntaxes are only added if existing > syntax space is not large enough to call these magic methods, which > is not the case here. I thought all magic methods were merely ways of implementing the functionality of built-in types in classes, i.e. e.g. '__add__' is never called directly, but merely used by the built-in types 'class instance' to implement the syntax 'a + b'. > 2. Iterators should not be limited to what they can emit, so the items > should be allowed to be tuples of any desired arity. For example, an > iterator over spatial points may be used as "x,y,z in points". This > generality is not possible with the colon based special syntax that > is only applicable to lists and dicts. Why must iterators emit tuples at all? > Appendix: Application of the __arity__ syntax to general tuple unpacking. > > This is independent of the iterator issue, but it is closely related to > the outputs of iterators. The __arity__ syntax proposed above appears > to also solve tuple unpacking problems elsewhere. I am totally against the '__arity__' syntax. It only seems to replace one thrown exception for another. Besides, in my experience, code like the following is not uncommon: def return_tuple(n): return (0,) * n a, b = return_tuple(2) x, y, z = return_tuple(3) Such code could not use '__arity__', reducing it to special case syntax sugar. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From qrczak at knm.org.pl Wed Feb 21 22:46:33 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 21 Feb 2001 21:46:33 GMT Subject: Alternative iterator syntax References: Message-ID: Wed, 21 Feb 2001 03:32:03 -0800 (PST), Huaiyu Zhu pisze: > Following suggestion by Jeff Petkau , > (http://mail.python.org/pipermail/python-list/2001-February/029944.html), > here is a different proposal for iterators. I dislike it for the following reasons: * It requires "magic attributes", i.e. implementing __getattr__ in each user class that wants to be a sequence with the same interface as list. Python already has a way used for things like obtaining iterators: method calls. Use that. Using d.keys to mean a flavor of d.keys() is weird. * It is too complex. There are many special methods, and syntactic sugar like for loops expands to one of many forms depending on what operations are provided. Python succeeded being quite simple. Please don't ruin that. * The __arity__ thing does not fit dynamically typed Python at all. When you want some static typing, go for a more general type system (which would be optional in the context of Python) instead of adding a kludge like this. What do I propose instead? Choose one: 1. Design a simple iterator protocol and add methods like xitems(), xkeys() and xvalues() which produce such iterators. I mean simple protocol, used only for 'for' loops! A single method for __next__ suffices (it can be __call__). 2. Design a lazy list framework. Let items(), keys(), values(), range(), readlines() etc. return lazy lists. Laziness is not as easy in imperative languages as in functional ones. The framework should take care to keep the current behavior of k = d.keys() d[spam] = eggs use(k) It can be done by putting weak references (avoiding reference loops) to iterators obtained from a mutable object inside the object, to notify iterators when the object is about to mutate, so they suck all elements immediately before the mutation. Perhaps design a more general mutability notification framework before that. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From Denys.Duchier at ps.uni-sb.de Wed Feb 21 23:39:05 2001 From: Denys.Duchier at ps.uni-sb.de (Denys Duchier) Date: 21 Feb 2001 23:39:05 +0100 Subject: Alternative iterator syntax References: Message-ID: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) writes: > 1. Design a simple iterator protocol and add methods like > xitems(), xkeys() and xvalues() which produce such iterators. I completely agree with this suggestion. I don't think that the hocus pocus of magic attributes is a good semantic foundation for language design. This suggestion is simpler: it's business as usual with added value. In all other respects, the iterators idea is much more sensible than the proposed `:' syntax extension. 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 jpet at eskimo.com Thu Feb 22 06:41:19 2001 From: jpet at eskimo.com (Jeff Petkau) Date: Thu, 22 Feb 2001 05:41:19 GMT Subject: Alternative iterator syntax References: Message-ID: <3E1l6.2278$3d5.446687@paloalto-snr1.gtei.net> Huaiyu Zhu wrote in message news:mailman.982769240.31345.python-list at python.org... > Following suggestion by Jeff Petkau , > (http://mail.python.org/pipermail/python-list/2001-February/029944.html), > here is a different proposal for iterators. ... As proposed, this would break existing classes that define only spam.__getitem__() and expect 'for x in spam' to work. It would be a much smaller change to leave 'for' alone, using __getitem__(0,1,2...). Or maybe adding the fallback to __call__ if __getitem__ is not defined. But I'm not sure this whole thing is a good idea. How about just some builtin functions for items(), keys(), values(), and indexed() that return lazy iterators? for k,v in items(mydict) for k in keys(mydict) for v in values(mydict) for i,v in indexed(mysequence) indexed() is easy: class indexed: def __init__(self,seq): self.seq = seq def __getitem__(self,i): return i,self.seq[i] The others would require a special hook in dict. I'd prefer an integer-indexed access function, but having it return an iterator works too if you're into that sort of thing. class items: def __init__(self,d): self.dict = d def __getitem__(self,i): return i,self.dict.__getitem_n__(i) --Jeff Petkau (jpet at eskimo.com) From alet at unice.fr Wed Feb 21 13:16:45 2001 From: alet at unice.fr (Jerome Alet) Date: Wed, 21 Feb 2001 13:16:45 +0100 Subject: [ANNOUNCE] JAXML version 2.20 Message-ID: <3A93B1AD.56713213@unice.fr> I'm very pleased to announce you the new 2.20 version of the JAXML module. With the JAXML module, generating XML documents has never been easier, this module: * Takes care of the indentation for you: your XML documents are readable by humans. * Takes care of closing tags for you. * Can generate every tag you want in an incredibly easy way. * Offers two templating facilities (see below) * Can generate XHTML documents and be used in CGI scripts because it takes care of the HTTP headers too. Here's a sample: --- CUT --- import jaxml x = jaxml.XML_document() x.something(value=5).dummy("some dummy text", isntit="YES") x['dummy'] = 'interesting' # new templating facility print x will produce: some interesting text and x._updatemapping({'dummy': 'boring'}) print x will produce: some boring text --- CUT --- The JAXML module is GPLed, you can download it freely from: http://cortex.unice.fr/~jerome/jaxml/ Changes: * A new _updatemapping() method was added to initialise or update the internal mapping for the new templating facility. This mapping is only used when rendering the document. * An infinite loop bug which was triggered when you called dir() on an XML_document instance was corrected. * The basic '+' and '*' operators can now be used to concatenate or repeat documents. Nota Bene: this is not a real concatenation, the second document is inserted in the first one at the current position. The well commented test program and module's sources are your best friends. Comments are very welcome, and NO the licence won't be changed to other than pure GPL, BUT we can discuss special agreements if you are really interested (this don't necessary mean money). -- Jerome Alet - alet at unice.fr - http://cortex.unice.fr/~jerome From syver at NOSPAMcyberwatcher.com Wed Feb 21 13:38:44 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Wed, 21 Feb 2001 13:38:44 +0100 Subject: Python program stopping execution wating for keypress Message-ID: I've experienced some strange behaviour from some Python console programs that are running a long time. The incidents I can remember are all multithreaded and uses win32com. Some times the programs just stop in the middle of the execution, essentially sleeping as they use no processor time. The times I've observed this is on applications running in a console, so I tried pressing a key and then the application starts executing again. Sometimes needing more than one key press per run to keep it going. Have anyone witnessed this behaviour, I would be glad to know. From fredrik at pythonware.com Wed Feb 21 19:33:41 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Feb 2001 18:33:41 GMT Subject: Python program stopping execution wating for keypress References: Message-ID: <9STk6.14843$Qb7.2370627@newsb.telia.net> Syver Enstad wrote: > Some times the programs just stop in the middle of the execution, > essentially sleeping as they use no processor time. The times I've observed > this is on applications running in a console, so I tried pressing a key and > then the application starts executing again. Sometimes needing more than one > key press per run to keep it going. > > Have anyone witnessed this behaviour, I would be glad to know. does the program print stuff to the console, and stop at a print statement? do you have "quick edit" (or whatever it's called in your version of windows) enabled? did you click in the window? (this switches the console to "selection mode", and blocks output until you press a key or click the right button. the titlebar also changes in this mode) Cheers /F From erno-news at erno.iki.fi Wed Feb 21 20:21:00 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 21 Feb 2001 21:21:00 +0200 Subject: Python program stopping execution wating for keypress References: Message-ID: In article , "Syver Enstad" writes: | Some times the programs just stop in the middle of the execution, | essentially sleeping as they use no processor time. The times I've | observed this is on applications running in a console, so I tried | pressing a key and then the application starts executing again. some piece of code you are using probably is buggy and tries to read from stdin. try booby-trapping it by assigning a non-file object to sys.stdin (or doing sys.stdin.close()). -- erno From thomas at cintra.no Wed Feb 21 13:55:19 2001 From: thomas at cintra.no (Thomas Weholt) Date: Wed, 21 Feb 2001 13:55:19 +0100 Subject: Anybody doing irc-stuff with Python / status of irc-modules for Python Message-ID: Hi, Question #1 : Is anybody doing anything IRC-related in Python? Question #2 : Does anybody know what module to use based on features and ease of use? I need a library to connect to a server and act as a information provider in a channel ( as a BOT ), also serving files if asked, like an fserv. The thing must answer queries, commands and send info to users as they log in. Any clues? Any information would be appreciated. PS! Also interested in libraries related to ICQ with similar goals in mind. Thomas From claird at starbase.neosoft.com Wed Feb 21 17:32:34 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 21 Feb 2001 10:32:34 -0600 Subject: Anybody doing irc-stuff with Python / status of irc-modules for Python References: Message-ID: <3D3B6B6D10077B24.500FF5674E90754F.3A301FA60722AC3A@lp.airnews.net> In article , Thomas Weholt wrote: >Hi, > >Question #1 : Is anybody doing anything IRC-related in Python? . . . Sean Reifschneider does Maybe he'll check in and explain a bit more of his work. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From u603515625 at spawnkill.ip-mobilphone.net Wed Feb 21 15:48:15 2001 From: u603515625 at spawnkill.ip-mobilphone.net (u603515625 at spawnkill.ip-mobilphone.net) Date: Wed, 21 Feb 2001 14:48:15 GMT Subject: A working setup.py for DCOracle 1.3.2 /Oracle 8.1.6/HP-UX 11 Message-ID: To whom it may concern ! every now and then questions arise about the compilation of DCOracle in several contexts. Here is a working setup.py to install DCoracle.py in a system consisting of the following components: - HP-UX 11 - Oracle 8.1.6 - Python 2.0 - DCOracle 1.3.2 I took the the setup.py created by Andrew M.Kuchling in his ZODB-Distribution and changed the ORACLE_LIBS accordingly. The result follows below the ------- dashes. The python 2.0 had to be compiled according the hints given in http://sourceforge.net/bugs/?func=detailbug&bug_id=110665&group _id=5470 . Hope that helps somebody Norbert Klamann Norbert.Klamann at klamann-software.de -------------------------------------------------------------------- #!/usr/bin/env python # Setup file for DCOracle # Python modules written by Digital Creations # setup.py written by A.M. Kuchling import os from distutils.core import setup from distutils.extension import Extension # Set Oracle include and library names ORACLE_HOME = os.environ['ORACLE_HOME'] # XXX add definitions for other versions here if 1: # Definitions for Oracle 8.0.5, shared library build on Linux ORACLE_INCLUDES = ['rdbms/demo', 'plsql/public', 'network/public'] ORACLE_LIBS = ['clntsh'] ORACLE_LIBDIRS = [ 'lib' ] # Prefix all the directories with the Oracle home directory ORACLE_INCLUDES = map(lambda x: os.path.join(ORACLE_HOME, x), ORACLE_INCLUDES) ORACLE_LIBDIRS = map(lambda x: os.path.join(ORACLE_HOME, x), ORACLE_LIBDIRS) # Definitions for extension modules buffer = Extension(name = 'Buffer', sources= ['src/Buffer.c'] ) oci_ = Extension(name = 'oci_', include_dirs = ORACLE_INCLUDES, libraries = ORACLE_LIBS, library_dirs = ORACLE_LIBDIRS, sources= ['src/oci_.c'] ) setup(name = "DCOracle", version = "1.3.1b1", description = "Python interface to Oracle", author = "Digital Creations", author_email = "zope-dev at zope.org", url = "http://www.zope.org", packages=['DCOracle'], ext_modules = [buffer, oci_], ) -- Sent by Norbert.Klamann from klamann-software subdomain of de This is a spam protected message. Please answer with reference header. Posted via http://www.usenet-replayer.com/cgi/content/new From alexlong at earthlink.net Wed Feb 21 16:52:46 2001 From: alexlong at earthlink.net (Alex) Date: Wed, 21 Feb 2001 15:52:46 GMT Subject: Graphical python development tool for Linux? Message-ID: <3a93e509.1040040@news.earthlink.net> Would anyone be kind enough to recommend a graphical Python development tool, perhaps similar to Pythonwin for Windows, only for Linux? From fredrik at pythonware.com Wed Feb 21 19:06:31 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Feb 2001 18:06:31 GMT Subject: Graphical python development tool for Linux? References: <3a93e509.1040040@news.earthlink.net> Message-ID: "Alex" wrote: > Would anyone be kind enough to recommend a graphical Python > development tool, perhaps similar to Pythonwin for Windows, only for > Linux? http://www.faqts.com/knowledge_base/view.phtml/aid/6433/fid/199 Cheers /F From chrisw at nipltd.com Wed Feb 21 17:17:59 2001 From: chrisw at nipltd.com (Chris Withers) Date: Wed, 21 Feb 2001 16:17:59 +0000 Subject: Compiling Python 2.0 on Win32 Message-ID: <3A93EA37.5E78BA5A@nipltd.com> Hi, I want to run a CVS version of Zope on my WinNT 4.0 workstation. Apparently, that means I need to compile Python from source on my box too. Where should I look to find out how to do this? cheers, Chris From fredrik at pythonware.com Wed Feb 21 18:22:52 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Feb 2001 17:22:52 GMT Subject: Compiling Python 2.0 on Win32 References: Message-ID: Chris Withers wrote: > Apparently, that means I need to compile Python from > source on my box too. > > Where should I look to find out how to do this? how about reading the README file? Cheers /F From chrisw at nipltd.com Wed Feb 21 18:50:51 2001 From: chrisw at nipltd.com (Chris Withers) Date: Wed, 21 Feb 2001 17:50:51 +0000 Subject: Compiling Python 2.0 on Win32 References: Message-ID: <3A93FFFB.E583F32D@nipltd.com> Fredrik Lundh wrote: > > Chris Withers wrote: > > Apparently, that means I need to compile Python from > > source on my box too. > > > > Where should I look to find out how to do this? > > how about reading the README file? I did look through that, but looked again. I now have an opticians appointment :-) *embarrassed (and probably badly spelled) grinz* Chris From gnana at mips.biochem.mpg.de Wed Feb 21 18:05:23 2001 From: gnana at mips.biochem.mpg.de (Gnanasekaran Thoppae) Date: Wed, 21 Feb 2001 17:05:23 -0000 Subject: newbie - concatanating 2 lists Message-ID: <970sgj+rrf7@eGroups.com> hi, i am just beginning to use python. i have: li1 = ['a', 'b', 'c'] li2 = ['x', 'y', 'z'] i want: li3 = ['ax', 'by', 'cz'] how do i do it? thanks -gnana From shaleh at valinux.com Wed Feb 21 18:29:48 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Wed, 21 Feb 2001 09:29:48 -0800 (PST) Subject: newbie - concatanating 2 lists In-Reply-To: <970sgj+rrf7@eGroups.com> Message-ID: On 21-Feb-2001 Gnanasekaran Thoppae wrote: > hi, > > i am just beginning to use python. > > i have: > > li1 = ['a', 'b', 'c'] > li2 = ['x', 'y', 'z'] > > i want: > > li3 = ['ax', 'by', 'cz'] > > how do i do it? > python 2 has a lovely function called zip(), maybe it could help. Otherwise, a quick map would probably do this. From mwh21 at cam.ac.uk Wed Feb 21 18:40:41 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 21 Feb 2001 17:40:41 +0000 Subject: newbie - concatanating 2 lists References: Message-ID: "Gnanasekaran Thoppae" writes: > hi, > > i am just beginning to use python. > > i have: > > li1 = ['a', 'b', 'c'] > li2 = ['x', 'y', 'z'] > > i want: > > li3 = ['ax', 'by', 'cz'] > > how do i do it? map(lambda x,y: x+y, li1, li2) will do. More generally, map(''.join, zip(li1, li2)) will extend to >2 lists. Cheers, M. -- But since I'm not trying to impress anybody in The Software Big Top, I'd rather walk the wire using a big pole, a safety harness, a net, and with the wire not more than 3 feet off the ground. -- Grant Griffin, comp.lang.python From glenfant at equod.com.nospam Wed Feb 21 18:47:36 2001 From: glenfant at equod.com.nospam (Gillou) Date: Wed, 21 Feb 2001 18:47:36 +0100 Subject: newbie - concatanating 2 lists References: Message-ID: <970ukb$t8j$1@reader1.imaginet.fr> This works with Python 1.5.2 and should with any other >>> li1 = ['a', 'b', 'c'] >>> li2 = ['x', 'y', 'z'] >>> l3 = map(lambda s1,S2:s1+s2, li1, li2) >>> l3 ['ax', 'by', 'cz'] You're welcome "Gnanasekaran Thoppae" a ?crit dans le message news: mailman.982775239.14135.python-list at python.org... > hi, > > i am just beginning to use python. > > i have: > > li1 = ['a', 'b', 'c'] > li2 = ['x', 'y', 'z'] > > i want: > > li3 = ['ax', 'by', 'cz'] > > how do i do it? > > thanks > > -gnana > > From brettlea at earthlink.net Thu Feb 22 05:51:20 2001 From: brettlea at earthlink.net (Brett Leach) Date: Thu, 22 Feb 2001 04:51:20 GMT Subject: newbie - concatanating 2 lists References: Message-ID: <3A949B0C.31507A4@earthlink.net> Gnanasekaran Thoppae wrote: > > hi, > > i am just beginning to use python. > > i have: > > li1 = ['a', 'b', 'c'] > li2 = ['x', 'y', 'z'] > > i want: > > li3 = ['ax', 'by', 'cz'] > > how do i do it? > > thanks > > -gnana Try this: li1 = ['a','b','c'] li2 = ['x','y','z'] li3 = [] for i in range( len( li1 ) ): li3.append( li1[i] + li2[i] ) From stephen_purcell at yahoo.com Wed Feb 21 18:41:27 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Wed, 21 Feb 2001 18:41:27 +0100 Subject: newbie - concatanating 2 lists References: <970sgj+rrf7@eGroups.com> Message-ID: <20010221184127.A25981@freedom.puma-ag.com> Gnanasekaran Thoppae wrote: > i am just beginning to use python. Good choice! > li1 = ['a', 'b', 'c'] > li2 = ['x', 'y', 'z'] > > i want: > > li3 = ['ax', 'by', 'cz'] There may be more readable ways, but the shortest is probably this: >>> li1 = ['a', 'b', 'c'] >>> li2 = ['x', 'y', 'z'] >>> li3 = map(lambda a,b: a+b, ['a','b','c'], ['x','y','z']) >>> li3 ['ax', 'by', 'cz'] -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 gnana at mips.biochem.mpg.de Wed Feb 21 18:48:43 2001 From: gnana at mips.biochem.mpg.de (Gnanasekaran Thoppae) Date: Wed, 21 Feb 2001 17:48:43 -0000 Subject: newbie - concatanating 2 lists In-Reply-To: <20010221184127.A25981@freedom.puma-ag.com> Message-ID: <970v1r+70d1@eGroups.com> Hi, Thanks Steve and Perry. I just realised that sometimes simple things can make one think a lot! Python rocks! -gnana --- In python-list at y..., Steve Purcell wrote: > Gnanasekaran Thoppae wrote: > > i am just beginning to use python. > > Good choice! > > > li1 = ['a', 'b', 'c'] > > li2 = ['x', 'y', 'z'] > > > > i want: > > > > li3 = ['ax', 'by', 'cz'] > > There may be more readable ways, but the shortest is probably this: > > >>> li1 = ['a', 'b', 'c'] > >>> li2 = ['x', 'y', 'z'] > >>> li3 = map(lambda a,b: a+b, ['a','b','c'], ['x','y','z']) > >>> li3 > ['ax', 'by', 'cz'] > > > -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 > > -- > http://mail.python.org/mailman/listinfo/python-list From aleaxit at yahoo.com Thu Feb 22 09:47:00 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 22 Feb 2001 09:47:00 +0100 Subject: newbie - concatanating 2 lists References: <970sgj+rrf7@eGroups.com> Message-ID: <972jm10i4p@news2.newsguy.com> "Steve Purcell" wrote in message news:mailman.982777311.18345.python-list at python.org... > Gnanasekaran Thoppae wrote: > > i am just beginning to use python. > > Good choice! > > > li1 = ['a', 'b', 'c'] > > li2 = ['x', 'y', 'z'] > > > > i want: > > > > li3 = ['ax', 'by', 'cz'] > > There may be more readable ways, but the shortest is probably this: > > >>> li1 = ['a', 'b', 'c'] > >>> li2 = ['x', 'y', 'z'] > >>> li3 = map(lambda a,b: a+b, ['a','b','c'], ['x','y','z']) > >>> li3 > ['ax', 'by', 'cz'] It's not the shortest way in Python2 -- rather, I'd code it: li3 = [ a+b for a,b in zip(li1, li2) ] Alex From stephen_purcell at yahoo.com Thu Feb 22 11:22:01 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Thu, 22 Feb 2001 11:22:01 +0100 Subject: newbie - concatanating 2 lists In-Reply-To: <972jm10i4p@news2.newsguy.com>; from aleaxit@yahoo.com on Thu, Feb 22, 2001 at 09:47:00AM +0100 References: <970sgj+rrf7@eGroups.com> <972jm10i4p@news2.newsguy.com> Message-ID: <20010222112201.A353@freedom.puma-ag.com> Alex Martelli wrote: > Steve Purclel wrote: > > >>> li3 = map(lambda a,b: a+b, ['a','b','c'], ['x','y','z']) > > It's not the shortest way in Python2 -- rather, I'd code it: > > li3 = [ a+b for a,b in zip(li1, li2) ] Hang on, it *is* still the shortest way in Python 2: li3 = [a+b for a,b in zip(li1,li2)] li3 = map(lambda a,b:a+b,li1,li2) Any excuse to put off using list comprehensions for a while... :-) -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 scarblac at pino.selwerd.nl Thu Feb 22 21:32:04 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 22 Feb 2001 20:32:04 GMT Subject: newbie - concatanating 2 lists References: <970sgj+rrf7@eGroups.com> <972jm10i4p@news2.newsguy.com> Message-ID: Steve Purcell wrote in comp.lang.python: > Hang on, it *is* still the shortest way in Python 2: > > li3 = [a+b for a,b in zip(li1,li2)] > li3 = map(lambda a,b:a+b,li1,li2) li3 = map(''.join,zip(li1,li2)) (as mentioned before) Is two strokes smaller. That's just my luck. First time I ever win at Perl Golf, it's in Python... -- Remco Gerlich From scarblac at pino.selwerd.nl Thu Feb 22 11:01:26 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 22 Feb 2001 10:01:26 GMT Subject: newbie - concatanating 2 lists References: Message-ID: Sean 'Shaleh' Perry wrote in comp.lang.python: > > On 21-Feb-2001 Gnanasekaran Thoppae wrote: > > i am just beginning to use python. > > > > i have: > > > > li1 = ['a', 'b', 'c'] > > li2 = ['x', 'y', 'z'] > > > > i want: > > > > li3 = ['ax', 'by', 'cz'] > > > > how do i do it? > > python 2 has a lovely function called zip(), maybe it could help. Otherwise, a > quick map would probably do this. For Python 2, with zip and list comprehensions, it would look like li3 = [a+b for a,b in zip(li1,li2)] Hmm, or even li3 = map(''.join, zip(l1,l2)) I like li3 = map(operator.add, li1, li2) best (why do people write their own lambda for operator.add? :)). But all of these are trying to get it to fit in the least number of characters (and they're pretty fast, although I have doubts about the zip things). A newbie should also understand the basic way: A = ['a','b','c'] B = ['d','e','f'] C = [] for i in range(len(A)): C.append(A[i]+B[i]) This will give an exception if l1 is longer than l2, but all the above methods have problems with different length lists as well. zip(), list comprehensions, string methods etc are cool, but we end up with a lot of ways to do it... -- Remco Gerlich From adam at deprince.net Wed Feb 21 21:56:57 2001 From: adam at deprince.net (Adam DePrince) Date: Wed, 21 Feb 2001 15:56:57 -0500 Subject: newbie - concatanating 2 lists References: Message-ID: <3A942B99.490C286C@deprince.net> Remco Gerlich wrote: > Sean 'Shaleh' Perry wrote in comp.lang.python: > > On 21-Feb-2001 Gnanasekaran Thoppae wrote: > > > i am just beginning to use python. > > > i have: > > > li1 = ['a', 'b', 'c'] > > > li2 = ['x', 'y', 'z'] > > > i want: > > > li3 = ['ax', 'by', 'cz'] > > > how do i do it? > > python 2 has a lovely function called zip(), maybe it could help. Otherwise, a > > quick map would probably do this. > For Python 2, with zip and list comprehensions, it would look like > li3 = [a+b for a,b in zip(li1,li2)] > Hmm, or even > li3 = map(''.join, zip(l1,l2)) > I like > li3 = map(operator.add, li1, li2) > best (why do people write their own lambda for operator.add? :)). > But all of these are trying to get it to fit in the least number of > characters (and they're pretty fast, although I have doubts about the zip > things). > A newbie should also understand the basic way: > > A = ['a','b','c'] > B = ['d','e','f'] > C = [] > for i in range(len(A)): And if you want to handle mismatched lists gracefully ... for i in range(min((len(A),len(B)))): > C.append(A[i]+B[i]) > > This will give an exception if l1 is longer than l2, but all the above > methods have problems with different length lists as well. > > zip(), list comprehensions, string methods etc are cool, but we end up > with a lot of ways to do it... > -- > Remco Gerlich From fimafeng at yahoo.com Wed Feb 21 18:43:25 2001 From: fimafeng at yahoo.com (Chris Nelson) Date: Wed, 21 Feb 2001 17:43:25 GMT Subject: What's the best way???--installing 2.0 and IDLE on RH 7 Message-ID: <3A93FE0E.9070606@yahoo.com> Well, my first attempt has landed me one buggered up system... I need to rebuild my linux box anyways so this serves as good reason. What I want to do is have BeOpen python 2.0 work with IDLE.. My last attempt always had IDLE running with 1.5.2 Before I go installing I need to know... Should I install the 8.3 versions of tcl and tk that come with RedHat as well as the 1.5.2 version of TKinter? (The one listed with the Python 2.0 is also newer) when I did this last time and then installed BeOpen 2.0 the RPM complained about needing the libraries from 8.0 tcl and tk..... What is the best way to proceed? RPM's makefiles please help!!! Many thanks, Chris From Max.Haas at unibas.ch Wed Feb 21 19:25:30 2001 From: Max.Haas at unibas.ch (Max Haas) Date: Wed, 21 Feb 2001 19:25:30 +0100 Subject: FW: newbie - concatanating 2 lists In-Reply-To: Message-ID: ---------- Von: Max Haas Datum: Wed, 21 Feb 2001 19:23:40 +0100 An: Gnanasekaran Thoppae Betreff: Re: newbie - concatanating 2 lists Hi gnana, perhaps the first step could be: li1 = ['a', 'b', 'c'] li2 = ['x', 'y', 'z'] p = 0 m = [] for item in li1: m.append(item + li2[p]) p = p + 1 print m Max am 21.2.2001 18:05 Uhr schrieb Gnanasekaran Thoppae unter gnana at mips.biochem.mpg.de: > hi, > > i am just beginning to use python. > > i have: > > li1 = ['a', 'b', 'c'] > li2 = ['x', 'y', 'z'] > > i want: > > li3 = ['ax', 'by', 'cz'] > > how do i do it? > > thanks > > -gnana > From zzizz_ at notmail.com Sat Feb 24 08:28:01 2001 From: zzizz_ at notmail.com (zzzzz) Date: Sat, 24 Feb 2001 18:28:01 +1100 Subject: FW: newbie - concatanating 2 lists References: Message-ID: On Wed, 21 Feb 2001 19:25:30 +0100, Max Haas wrote: >> i have: >> >> li1 = ['a', 'b', 'c'] >> li2 = ['x', 'y', 'z'] >> >> i want: >> >> li3 = ['ax', 'by', 'cz'] try: map(lambda a,b: a+b,li1,li2) > >Hi gnana, > >perhaps the first step could be: > >li1 = ['a', 'b', 'c'] >li2 = ['x', 'y', 'z'] >p = 0 >m = [] > >for item in li1: > m.append(item + li2[p]) > p = p + 1 >print m > >Max rgds z. From jeremy at alum.mit.edu Wed Feb 21 20:09:43 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Wed, 21 Feb 2001 14:09:43 -0500 (EST) Subject: Update to PEP 227 (static scoping) Message-ID: <14996.4727.604581.858363@w221.z064000254.bwi-md.dsl.cnc.net> There has been renewed discussion of backwards compatibility issues introduced by nested scopes. Following some discussion on python-dev, I have updated the discussion of these issues in the PEP. Of course, more comments are welcome. I am particularly interested in reports of actual compatibility issues with existing code, as opposed to hypotheticals. The particular concerns raised lately have to do with previously legal code that will fail with a SyntaxError with nested scopes. Early in the design process, there was discussion of code that will behave differently with nested scopes. At the time, the subtle behavior change was considered acceptable because it was believed to occur rarely in practice and was probably hard to understand to begin with. A related issue, already discussed on both lists, was the restrictions added in Python 2.1a2 on the use of import * in functions and exec with nested scope. The former restriction was always documented in the reference manual, but never enforced. Subsequently, we decided to allow import * and exec except in cases where the meaning was ambiguous with respect to nested scopes. This probably sounds a bit abstract; I hope the PEP (included below) spells out the issues more clearly. If you have code that currently depends on any of the three following behaviors, I'd like to hear about it: - A function is contained within another function. The outer function contains a local name that shadows a global name. The inner function uses the global. The one case of this I have seen in the wild was caused by a local variable named str in the outer function and a use of builtin str in the inner function. - A function that contains a nested function with free variables and also uses exec that does not specify a namespace, e.g. def f(): exec foo def g(): ... "exec foo in ns" should be legal, although the current CVS code base does not yet allow it. - A function like the one above, except that is uses import * instead of exec. Jeremy PEP: 227 Title: Statically Nested Scopes Version: $Revision: 1.6 $ Author: jeremy at digicool.com (Jeremy Hylton) Status: Draft Type: Standards Track Python-Version: 2.1 Created: 01-Nov-2000 Post-History: XXX what goes here? Abstract This PEP proposes the addition of statically nested scoping (lexical scoping) for Python 2.1. The current language definition defines exactly three namespaces that are used to resolve names -- the local, global, and built-in namespaces. The addition of nested scopes would allow resolution of unbound local names in enclosing functions' namespaces. One consequence of this change that will be most visible to Python programs is that lambda statements could reference variables in the namespaces where the lambda is defined. Currently, a lambda statement uses default arguments to explicitly creating bindings in the lambda's namespace. Introduction This proposal changes the rules for resolving free variables in Python functions. The Python 2.0 definition specifies exactly three namespaces to check for each name -- the local namespace, the global namespace, and the builtin namespace. According to this defintion, if a function A is defined within a function B, the names bound in B are not visible in A. The proposal changes the rules so that names bound in B are visible in A (unless A contains a name binding that hides the binding in B). The specification introduces rules for lexical scoping that are common in Algol-like languages. The combination of lexical scoping and existing support for first-class functions is reminiscent of Scheme. The changed scoping rules address two problems -- the limited utility of lambda statements and the frequent confusion of new users familiar with other languages that support lexical scoping, e.g. the inability to define recursive functions except at the module level. The lambda statement introduces an unnamed function that contains a single statement. It is often used for callback functions. In the example below (written using the Python 2.0 rules), any name used in the body of the lambda must be explicitly passed as a default argument to the lambda. from Tkinter import * root = Tk() Button(root, text="Click here", command=lambda root=root: root.test.configure(text="...")) This approach is cumbersome, particularly when there are several names used in the body of the lambda. The long list of default arguments obscure the purpose of the code. The proposed solution, in crude terms, implements the default argument approach automatically. The "root=root" argument can be omitted. Specification Python is a statically scoped language with block structure, in the traditional of Algol. A code block or region, such as a module, class defintion, or function body, is the basic unit of a program. Names refer to objects. Names are introduced by name binding operations. Each occurrence of a name in the program text refers to the binding of that name established in the innermost function block containing the use. The name binding operations are assignment, class and function definition, and import statements. Each assignment or import statement occurs within a block defined by a class or function definition or at the module level (the top-level code block). If a name binding operation occurs anywhere within a code block, all uses of the name within the block are treated as references to the current block. (Note: This can lead to errors when a name is used within a block before it is bound.) If the global statement occurs within a block, all uses of the name specified in the statement refer to the binding of that name in the top-level namespace. Names are resolved in the top-level namespace by searching the global namespace, the namespace of the module containing the code block, and the builtin namespace, the namespace of the module __builtin__. The global namespace is searched first. If the name is not found there, the builtin namespace is searched. If a name is used within a code block, but it is not bound there and is not declared global, the use is treated as a reference to the nearest enclosing function region. (Note: If a region is contained within a class definition, the name bindings that occur in the class block are not visible to enclosed functions.) A class definition is an executable statement that may uses and definitions of names. These references follow the normal rules for name resolution. The namespace of the class definition becomes the attribute dictionary of the class. The following operations are name binding operations. If they occur within a block, they introduce new local names in the current block unless there is also a global declaration. Function defintion: def name ... Class definition: class name ... Assignment statement: name = ... Import statement: import name, import module as name, from module import name Implicit assignment: names are bound by for statements and except clauses The arguments of a function are also local. There are several cases where Python statements are illegal when used in conjunction with nested scopes that contain free variables. If a variable is referenced in an enclosing scope, it is an error to delete the name. The compiler will raise a SyntaxError for 'del name'. If the wildcard form of import (import *) is used in a function and the function contains a nested block with free variables, the compiler will raise a SyntaxError. If exec is used in a function and the function contains a nested block with free variables, the compiler will raise a SyntaxError unless the exec explicit specifies the local namespace for the exec. (In other words, "exec obj" would be illegal, but "exec obj in ns" would be legal.) Discussion The specified rules allow names defined in a function to be referenced in any nested function defined with that function. The name resolution rules are typical for statically scoped languages, with three primary exceptions: - Names in class scope are not accessible. - The global statement short-circuits the normal rules. - Variables are not declared. Names in class scope are not accessible. Names are resolved in the innermost enclosing function scope. If a class defintion occurs in a chain of nested scopes, the resolution process skips class definitions. This rule prevents odd interactions between class attributes and local variable access. If a name binding operation occurs in a class defintion, it creates an attribute on the resulting class object. To access this variable in a method, or in a function nested within a method, an attribute reference must be used, either via self or via the class name. An alternative would have been to allow name binding in class scope to behave exactly like name binding in function scope. This rule would allow class attributes to be referenced either via attribute reference or simple name. This option was ruled out because it would have been inconsistent with all other forms of class and instance attribute access, which always use attribute references. Code that used simple names would have been obscure. The global statement short-circuits the normal rules. Under the proposal, the global statement has exactly the same effect that it does for Python 2.0. It's behavior is preserved for backwards compatibility. It is also noteworthy because it allows name binding operations performed in one block to change bindings in another block (the module). Variables are not declared. If a name binding operation occurs anywhere in a function, then that name is treated as local to the function and all references refer to the local binding. If a reference occurs before the name is bound, a NameError is raised. The only kind of declaration is the global statement, which allows programs to be written using mutable global variables. As a consequence, it is not possible to rebind a name defined in an enclosing scope. An assignment operation can only bind a name in the current scope or in the global scope. The lack of declarations and the inability to rebind names in enclosing scopes are unusual for lexically scoped languages; there is typically a mechanism to create name bindings (e.g. lambda and let in Scheme) and a mechanism to change the bindings (set! in Scheme). XXX Alex Martelli suggests comparison with Java, which does not allow name bindings to hide earlier bindings. Examples A few examples are included to illustrate the way the rules work. XXX Explain the examples >>> def make_adder(base): ... def adder(x): ... return base + x ... return adder >>> add5 = make_adder(5) >>> add5(6) 11 >>> def make_fact(): ... def fact(n): ... if n == 1: ... return 1L ... else: ... return n * fact(n - 1) ... return fact >>> fact = make_fact() >>> fact(7) 5040L >>> def make_wrapper(obj): ... class Wrapper: ... def __getattr__(self, attr): ... if attr[0] != '_': ... return getattr(obj, attr) ... else: ... raise AttributeError, attr ... return Wrapper() >>> class Test: ... public = 2 ... _private = 3 >>> w = make_wrapper(Test()) >>> w.public 2 >>> w._private Traceback (most recent call last): File "", line 1, in ? AttributeError: _private An example from Tim Peters of the potential pitfalls of nested scopes in the absence of declarations: i = 6 def f(x): def g(): print i # ... # skip to the next page # ... for i in x: # ah, i *is* local to f, so this is what g sees pass g() The call to g() will refer to the variable i bound in f() by the for loop. If g() is called before the loop is executed, a NameError will be raised. XXX need some counterexamples Backwards compatibility There are two kinds of compatibility problems caused by nested scopes. In one case, code that behaved one way in earlier versions, behaves differently because of nested scopes. In the other cases, certain constructs interact badly with nested scopes and will trigger SyntaxErrors at compile time. The following example from Skip Montanaro illustrates the first kind of problem: x = 1 def f1(): x = 2 def inner(): print x inner() Under the Python 2.0 rules, the print statement inside inner() refers to the global variable x and will print 1 if f1() is called. Under the new rules, it refers to the f1()'s namespace, the nearest enclosing scope with a binding. The problem occurs only when a global variable and a local variable share the same name and a nested function uses that name to refer to the global variable. This is poor programming practice, because readers will easily confuse the two different variables. One example of this problem was found in the Python standard library during the implementation of nested scopes. To address this problem, which is unlikely to occur often, a static analysis tool that detects affected code will be written. The detection problem is straightfoward. The other compatibility problem is casued by the use of 'import *' and 'exec' in a function body, when that function contains a nested scope and the contained scope has free variables. For example: y = 1 def f(): exec "y = 'gotcha'" # or from module import * def g(): return y ... At compile-time, the compiler cannot tell whether an exec that operators on the local namespace or an import * will introduce name bindings that shadow the global y. Thus, it is not possible to tell whether the reference to y in g() should refer to the global or to a local name in f(). In discussion of the python-list, people argued for both possible interpretations. On the one hand, some thought that the reference in g() should be bound to a local y if one exists. One problem with this interpretation is that it is impossible for a human reader of the code to determine the binding of y by local inspection. It seems likely to introduce subtle bugs. The other interpretation is to treat exec and import * as dynamic features that do not effect static scoping. Under this interpretation, the exec and import * would introduce local names, but those names would never be visible to nested scopes. In the specific example above, the code would behave exactly as it did in earlier versions of Python. Since each interpretation is problemtatic and the exact meaning ambiguous, the compiler raises an exception. A brief review of three Python projects (the standard library, Zope, and a beta version of PyXPCOM) found four backwards compatibility issues in approximately 200,000 lines of code. There was one example of case #1 (subtle behavior change) and two examples of import * problems in the standard library. (The interpretation of the import * and exec restriction that was implemented in Python 2.1a2 was much more restrictive, based on language that in the reference manual that had never been enforced. These restrictions were relaxed following the release.) locals() / vars() These functions return a dictionary containing the current scope's local variables. Modifications to the dictionary do not affect the values of variables. Under the current rules, the use of locals() and globals() allows the program to gain access to all the namespaces in which names are resolved. An analogous function will not be provided for nested scopes. Under this proposal, it will not be possible to gain dictionary-style access to all visible scopes. Rebinding names in enclosing scopes There are technical issues that make it difficult to support rebinding of names in enclosing scopes, but the primary reason that it is not allowed in the current proposal is that Guido is 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. The proposed rules allow programmers to achieve the effect of rebinding, albeit awkwardly. The name that will be effectively rebound by enclosed functions is bound to a container object. In place of assignment, the program uses modification of the container to achieve the desired effect: def bank_account(initial_balance): balance = [initial_balance] def deposit(amount): balance[0] = balance[0] + amount return balance def withdraw(amount): balance[0] = balance[0] - amount return balance return deposit, withdraw Support for rebinding in nested scopes would make this code clearer. A class that defines deposit() and withdraw() methods and the balance as an instance variable would be clearer still. Since classes seem to achieve the same effect in a more straightforward manner, they are preferred. Implementation The implementation for C Python uses flat closures [1]. Each def or lambda statement that is executed will create a closure if the body of the function or any contained function has free variables. Using flat closures, the creation of closures is somewhat expensive but lookup is cheap. The implementation adds several new opcodes and two new kinds of names in code objects. A variable can be either a cell variable or a free variable for a particular code object. A cell variable is referenced by containing scopes; as a result, the function where it is defined must allocate separate storage for it on each invocation. A free variable is reference via a function's closure. XXX Much more to say here References [1] Luca Cardelli. Compiling a functional language. In Proc. of the 1984 ACM Conference on Lisp and Functional Programming, pp. 208-217, Aug. 1984 http://citeseer.nj.nec.com/cardelli84compiling.html From aahz at panix.com Wed Feb 21 21:24:09 2001 From: aahz at panix.com (Aahz Maruch) Date: 21 Feb 2001 12:24:09 -0800 Subject: Update to PEP 227 (static scoping) References: Message-ID: <971859$dq$1@panix6.panix.com> [p&e] [I don't really have any comments on this proposal, but to prove that I've read it ;-), I'm including a list proofreading fixes.] In article , Jeremy Hylton wrote: > >Introduction > > This proposal changes the rules for resolving free variables in > Python functions. The Python 2.0 definition specifies exactly > three namespaces to check for each name -- the local namespace, > the global namespace, and the builtin namespace. According to > this defintion, if a function A is defined within a function B, > the names bound in B are not visible in A. The proposal changes > the rules so that names bound in B are visible in A (unless A > contains a name binding that hides the binding in B). s/defintion/definition/ >Specification > > Python is a statically scoped language with block structure, in > the traditional of Algol. A code block or region, such as a > module, class defintion, or function body, is the basic unit of a > program. s/defintion/definition/ > If the global statement occurs within a block, all uses of the > name specified in the statement refer to the binding of that name > in the top-level namespace. Names are resolved in the top-level > namespace by searching the global namespace, the namespace of the > module containing the code block, and the builtin namespace, the > namespace of the module __builtin__. The global namespace is > searched first. If the name is not found there, the builtin > namespace is searched. Clarification: if the global statement is not the first executable statement in a block, the results are undefined. > If exec is used in a function and the function contains a nested > block with free variables, the compiler will raise a SyntaxError > unless the exec explicit specifies the local namespace for the > exec. (In other words, "exec obj" would be illegal, but > "exec obj in ns" would be legal.) s/explicit/explicitly/ > Names in class scope are not accessible. Names are resolved in > the innermost enclosing function scope. If a class defintion > occurs in a chain of nested scopes, the resolution process skips > class definitions. This rule prevents odd interactions between > class attributes and local variable access. If a name binding > operation occurs in a class defintion, it creates an attribute on > the resulting class object. To access this variable in a method, > or in a function nested within a method, an attribute reference > must be used, either via self or via the class name. s/defintion/definition/ > The global statement short-circuits the normal rules. Under the > proposal, the global statement has exactly the same effect that it > does for Python 2.0. It's behavior is preserved for backwards > compatibility. It is also noteworthy because it allows name > binding operations performed in one block to change bindings in > another block (the module). s/It's/Its/ > An example from Tim Peters of the potential pitfalls of nested scopes > in the absence of declarations: Clarification: s/Peters of/Peters demonstrates/ >Backwards compatibility > > There are two kinds of compatibility problems caused by nested > scopes. In one case, code that behaved one way in earlier > versions, behaves differently because of nested scopes. In the > other cases, certain constructs interact badly with nested scopes > and will trigger SyntaxErrors at compile time. s/versions,/versions/ > At compile-time, the compiler cannot tell whether an exec that > operators on the local namespace or an import * will introduce > name bindings that shadow the global y. Thus, it is not possible > to tell whether the reference to y in g() should refer to the > global or to a local name in f(). s/operators/operates/ > The implementation adds several new opcodes and two new kinds of > names in code objects. A variable can be either a cell variable > or a free variable for a particular code object. A cell variable > is referenced by containing scopes; as a result, the function > where it is defined must allocate separate storage for it on each > invocation. A free variable is reference via a function's closure. s/reference/referenced/ -- --- 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 The problem with an ever-changing .sig is that you have to keep changing it From fredrik at pythonware.com Wed Feb 21 21:45:00 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Feb 2001 20:45:00 GMT Subject: Update to PEP 227 (static scoping) References: Message-ID: Jeremy wrote: > - A function that contains a nested function with free variables > and also uses exec that does not specify a namespace, e.g. > def f(): > exec foo > def g(): > ... > "exec foo in ns" should be legal, although the current CVS code > base does not yet allow it. > > - A function like the one above, except that is uses import * > instead of exec. Note that in real life, "free" means "global or builtin". For example, this common Tkinter pattern will no longer compile: import sys def makeui(): from Tkinter import * def callback(): print "bye" sys.exit(1) Button(command=callback).pack() # gives an error on line two (the first def statement) If you have 2.1a2 installed, the following script will check for exec and import problems. Run it from the top of your development tree, and let us know what you find... (running it on the 2.0 source tree is also somewhat entertaining ;-) # # look for exec/import scope problems import os import fnmatch import string, traceback class GlobDirectoryWalker: # a forward iterator that traverses a directory tree def __init__(self, directory, pattern="*"): self.stack = [directory] self.pattern = pattern self.files = [] self.index = 0 def __getitem__(self, index): while 1: try: file = self.files[self.index] self.index = self.index + 1 except IndexError: # pop next directory from stack self.directory = self.stack.pop() self.files = os.listdir(self.directory) self.index = 0 else: # got a filename fullname = os.path.join(self.directory, file) if os.path.isdir(fullname) and not os.path.islink(fullname): self.stack.append(fullname) if fnmatch.fnmatch(file, self.pattern): return fullname count = 0 for file in GlobDirectoryWalker(".", "*.py"): try: # print file, "..." count = count + 1 print count, "\r", compile(open(file).read() + "\n", file, "exec") except SyntaxError, v: v = str(v) if string.find(v, "nested scope") > 0: print "-" * 68 print file traceback.print_exc() print count, "files checked" # Cheers /F From jeremy at alum.mit.edu Wed Feb 21 22:10:46 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Wed, 21 Feb 2001 16:10:46 -0500 (EST) Subject: Update to PEP 227 (static scoping) In-Reply-To: References: Message-ID: <14996.11990.285306.871815@w221.z064000254.bwi-md.dsl.cnc.net> >>>>> "FL" == Fredrik Lundh writes: FL> If you have 2.1a2 installed, the following script will check for FL> exec and import problems. Run it from the top of your FL> development tree, and let us know what you find... (running it FL> on the 2.0 source tree is also somewhat entertaining ;-) Unless your idea of entertainment is vastly different than mine, I don't understand what you mean. The output I see from your handy script is: 1025 files checked If you see problems on your machine, it would be helpful if you could submit a bug report. Jeremy From fredrik at pythonware.com Thu Feb 22 08:51:18 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 22 Feb 2001 07:51:18 GMT Subject: Update to PEP 227 (static scoping) References: Message-ID: I wrote: > Note that in real life, "free" means "global or builtin". For example, > this common Tkinter pattern will no longer compile: > > import sys > def makeui(): > from Tkinter import * > def callback(): > print "bye" > sys.exit(1) > Button(command=callback).pack() > > # gives an error on line two (the first def statement) also note that one easy way to fix this is to use the default argument hack (!): import sys def makeui(): from Tkinter import * def callback(sys=sys): print "bye" sys.exit(1) # this works!? Button(command=callback).pack() I'm glad I didn't sign up to do that Python book ;-) Cheers /F From Denys.Duchier at ps.uni-sb.de Wed Feb 21 22:40:00 2001 From: Denys.Duchier at ps.uni-sb.de (Denys Duchier) Date: 21 Feb 2001 22:40:00 +0100 Subject: Update to PEP 227 (static scoping) References: Message-ID: Jeremy Hylton writes: > Rebinding names in enclosing scopes > > There are technical issues that make it difficult to support > rebinding of names in enclosing scopes, but the primary reason > that it is not allowed in the current proposal is that Guido is > 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 "global x" was instead allowed to mean "the x in the innermost enclosing scope that defines one (or the global scope otherwise)", wouldn't that solve the problem. It wouldn't be semantically backward compatible, but, in practice, would that break a lot of existing programs and require too high a cost for fixing them? Just wondering. 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 jeremy at alum.mit.edu Wed Feb 21 23:43:32 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Wed, 21 Feb 2001 17:43:32 -0500 (EST) Subject: Update to PEP 227 (static scoping) In-Reply-To: References: Message-ID: <14996.17556.654376.765535@w221.z064000254.bwi-md.dsl.cnc.net> >>>>> "DD" == Denys Duchier writes: DD> Jeremy Hylton writes: >> Rebinding names in enclosing scopes [...] DD> if "global x" was instead allowed to mean "the x in the DD> innermost enclosing scope that defines one (or the global scope DD> otherwise)", wouldn't that solve the problem. It wouldn't be DD> semantically backward compatible, but, in practice, would that DD> break a lot of existing programs and require too high a cost for DD> fixing them? Just wondering. This was an option considered early on, but abandoned because ... Guido didn't like it? I know he didn't, but I don't recall exactly why. A few issues come to mind: - It is odd to use the name "global" for something that does not mean global. This alone is enough to reject it. If we're going to add a special declaration statement, it ought to have a clear name. - It will break code that depends on global meaning "global" (or should I have the scare quotes the other way ). If we're going to break code, there's no point in breaking code that was being explicit about what it was doing. As for using some other word, I'm neutral. I'm not sure how much the rebinding will be used, and I'm reluctant to get into a debate about how to spell things and what to call them. the-dict-iteration-blues-are-getting-to-me-ly y'rs, Jeremy From tim.one at home.com Thu Feb 22 02:32:48 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 21 Feb 2001 20:32:48 -0500 Subject: Update to PEP 227 (static scoping) In-Reply-To: Message-ID: [Denys Duchier] > if "global x" was instead allowed to mean "the x in the innermost > enclosing scope that defines one (or the global scope otherwise)", > wouldn't that solve the problem. You answered that next: > It wouldn't be semantically backward compatible, Bingo. > but, in practice, would that break a lot of existing programs and > require too high a cost for fixing them? Just wondering. It depends on who you ask, of course. >From a cost/benefit view, the crushingly overwhelming source of scope complaints comes from people using Python's little lambdas. Indeed, there were exceedingly few scope complaints before little lambdas were introduced, and non-stop howling ever since. I say "little" because they're restricted to a single expression, and expressions in Python can never rebind a name (all binding constructs are statements in Python, not expressions). So the people who want lexical scoping in Python the most (in practice, not the ones who just talk about it or are idly pining for Scheme ) have no possibility of rebinding a name anyway in the context they most want it. Doesn't mean Python will never allow intermediate-level bindings, but there's very little call for it now, so it just raises more issues that needn't be solved now. the-ironic-thing-is-that-if-guido-were-ignoring-users-he-wouldn't- have-gotten-within-a-10-foot-snake-of-lexical-nesting-ly y'rs - tim From owen at astrono.junkwashington.emu Thu Feb 22 20:30:44 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Thu, 22 Feb 2001 11:30:44 -0800 Subject: Update to PEP 227 (static scoping) References: Message-ID: <973pd4$jhq$1@nntp6.u.washington.edu> In article , jeremy at alum.mit.edu wrote: (much of generally excellent description of PEP 227 omitted) > A class definition is an executable statement that may uses and > definitions of names. Might you rephrase this? I hope there is a typo here. >Discussion >... > Variables are not declared. If a name binding operation occurs > anywhere in a function, then that name is treated as local to the > function and all references refer to the local binding. If a > reference occurs before the name is bound, a NameError is raised. > The only kind of declaration is the global statement, which allows > programs to be written using mutable global variables. As a > consequence, it is not possible to rebind a name defined in an > enclosing scope. An assignment operation can only bind a name in > the current scope or in the global scope. The lack of > declarations and the inability to rebind names in enclosing scopes > are unusual for lexically scoped languages; there is typically a > mechanism to create name bindings (e.g. lambda and let in Scheme) > and a mechanism to change the bindings (set! in Scheme). I confess to being nervous about this proposed change. Static scoping does add some very nice functionality, but it seems to come at a significant cost in - complexity (the new rules have some tricky exceptions) - safety (Tim's example is a good one; also typos can do more damage) I realize this has probably been discussed at length by people intimately connected with the language, so I'm on thin ice here, but I'll speak up anyway. Firstly, I am wondering if we might not be able to obtain a most of the gains of this proposal with less of the negative aspects by scaling it back? It seems that the most important driver for these new rules is lambda functions. It also helps in other areas, but somebody pointed out that folks where generally content with the old scoping rules until lambda functions were introduced. So...perhaps one could improve the syntax for lambda functions, instead of messing with scoping? Here is one possibility: lambda list-of-args : list-of-non-local-variables : code This basically does the same as the default argument trick. It would be nice if it was an error to try to refer to non-local variables as arguments when calling lambda, but this is by no means necessary. If the more general solution of static scoping is desired (and it does have some advantages, of course), then here are some further thoughts: How about requiring an explicit statement that "this variable is non-local"? This is reminiscent of the existing "global" keyword. This has several advantages, to my mind: - It works equally well in functions and in class methods. Hence classes don't need to be special-cased in the new rules. - The common and most-desirable cases (all variables are local or were in the argument list) is the default; if you want to access non-local variables (which is less common and potentially more dangerous) you have to be explicit about it. I think a keyword is best, as it matches the existing "global" keyword, providing nice regularity. The one problem I see with a keyword is lambda functions (which I don't think could use it). For that, perhaps again one could adopt special notation, such as listed above, for specifying the non-local variables it will use. If it is not deemed desirable to require declaring non-local variables, then I do have a final plea: some *optional* means of explicitly declaring a variable as local. Such notation was not needed with the old scoping rules, but I think it'll be very useful for writing safe code with the new rules. Good coding practice (especially in large projects) would suggest using it for all programs -- to avoid typos causing mysterious bugs. Optional explicit declaration also enables the ability to warn of the use of non-declared variables. Something that can be very nice for large projects -- since it catches typos. -- Russell From qrczak at knm.org.pl Fri Feb 23 00:34:32 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 22 Feb 2001 23:34:32 GMT Subject: Update to PEP 227 (static scoping) References: <973pd4$jhq$1@nntp6.u.washington.edu> Message-ID: Thu, 22 Feb 2001 11:30:44 -0800, Russell E. Owen pisze: > I confess to being nervous about this proposed change. I am very happy about static scoping. It's very natural and found in most languages. > - complexity (the new rules have some tricky exceptions) For me these are those exceptions which should be changed. But I can live with them. > - safety (Tim's example is a good one; also typos can do more damage) It breaks only poorly written code, which relies on the fact that a scope has holes for nested functions. Shadowing a global name and then accessing it from inside of the function which shadowed it is a questionable practice. Typos don't do *more* damage. Only different typos do different damage. With old rules wrapping a piece of code in a function silently changes the meaning of its free variables which are not global. > So...perhaps one could improve the syntax for lambda functions, > instead of messing with scoping? Here is one possibility: > > lambda list-of-args : list-of-non-local-variables : code I would not call this an improvement. It's easy to forget a variable, in which case I silently get a legal but incorrect code. Variables are already present in the expression, no need to repeat them. > It would be nice if it was an error to try to refer to non-local > variables as arguments when calling lambda, but this is by no > means necessary. In this case a translation between the new scheme and your scheme is fully automatic, and the new scheme has a simpler syntax. > How about requiring an explicit statement that "this variable > is non-local"? The same arguments as for lambda above apply here. It would make sense if it allowed rebinding that variable from inner functions. It's unnecessary when we only refer to the variable, because there is no other choice than being non-local if it's not assigned to here. > If it is not deemed desirable to require declaring non-local variables, > then I do have a final plea: some *optional* means of explicitly > declaring a variable as local. It's already there: variable = None > Optional explicit declaration also enables the ability to warn of > the use of non-declared variables. Something that can be very nice > for large projects -- since it catches typos. Python already could warn about use of variables which are not defined, except that it does not work with dynamic binding: from module import *, exec, and modifying globals(). -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From cfelling at iae.nl Fri Feb 23 00:40:21 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 23 Feb 2001 00:40:21 +0100 Subject: Update to PEP 227 (static scoping) References: <973pd4$jhq$1@nntp6.u.washington.edu> Message-ID: <974815$b1o$1@animus.fel.iae.nl> Russell E. Owen wrote: ... > I confess to being nervous about this proposed change. Static scoping > does add some very nice functionality, but it seems to come at a > significant cost in > - complexity (the new rules have some tricky exceptions) > - safety (Tim's example is a good one; also typos can do more damage) I'm worried too by the increasing complexity of this scoping thing! ... > lambda list-of-args : list-of-non-local-variables : code maybe this could be spelled (as is suggested before me thinks) like: lambda list-of-args ; list-of-non-local-variables : code and then functions could use the same spelling for closures, like def f(list-of-args ; list-of-closures): pass This would prevent the nasty Pascal habbit of deeply nested references, or actual it would spell it out, as each and every function needs to pass on all vars that are going to be referenced somewhere inside that function being it in the function body itself or in some locally declared one. (Probably my upbringing in Eindhoven (and subsequent admiration for Dijkstra) shines through here:) Ofcourse nested functions do not recurse easily in such a scheme, but neither do recursive methods in the PEP that worries us so much. (I know self.method will do, but why do I have to spell recursion differently for methods? yak) Or maybe the semantics of that semi-colon inside the argument list could be such that it allowed to pass the function name into the visible scope of that function? We could use that semicolon again to create a place to define function attributes like in def f(arg-list ; closures ) ; function-attributes : pass Spelled like this, I would expect to be able to address function attributes inside the function body. I think The BDFL is against this, but why? <\rambling off> -- groetjes, carel From fredrik at pythonware.com Wed Feb 21 22:36:14 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Feb 2001 21:36:14 GMT Subject: Update to PEP 227 (static scoping) References: Message-ID: Jeremy Hylton wrote: > Unless your idea of entertainment is vastly different than mine dunno. have you read "Popul?rmusik fr?n Vittula"? excellent book ;-) > I don't understand what you mean. The output I see from your handy > script is: > > 1025 files checked > > If you see problems on your machine, it would be helpful if you could > submit a bug report. the Python-2.0 source tree, untarred from BeOpen-Python-2.0.tar.gz: -------------------------------------------------------------------- .\Tools\idle\IOBinding.py Traceback (most recent call last): File "\pythonware\scan.py", line 38, in ? compile(open(file).read() + "\n", file, "exec") SyntaxError: test: exec or 'import *' makes names ambiguous in nested scope (IOBinding.py, line 202) -------------------------------------------------------------------- .\Tools\idle\Percolator.py Traceback (most recent call last): File "\pythonware\scan.py", line 38, in ? compile(open(file).read() + "\n", file, "exec") SyntaxError: main: exec or 'import *' makes names ambiguous in nested scope (Percolator.py, line 55) both are fixed in the 2.1a2 source tree, of course. Cheers /F From tuttledon at hotmail.com Thu Feb 22 19:24:24 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Thu, 22 Feb 2001 18:24:24 GMT Subject: Update to PEP 227 (static scoping) References: Message-ID: "Tim Peters" wrote in message news:mailman.982833927.2343.python-list at python.org... > > From a cost/benefit view, the crushingly overwhelming source of scope > complaints comes from people using Python's little lambdas. Indeed, there > were exceedingly few scope complaints before little lambdas were introduced, > and non-stop howling ever since. > > I say "little" because they're restricted to a single expression, and > expressions in Python can never rebind a name (all binding constructs are > statements in Python, not expressions). So the people who want lexical > scoping in Python the most (in practice, not the ones who just talk about it > or are idly pining for Scheme ) have no possibility of rebinding a > name anyway in the context they most want it. Not knowing what I'm talking about, but...could lexical scoping be implemented as a command line switch? '-L' Don From jeremy at alum.mit.edu Fri Feb 23 02:23:15 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Thu, 22 Feb 2001 20:23:15 -0500 (EST) Subject: Update to PEP 227 (static scoping) In-Reply-To: References: Message-ID: <14997.48003.217156.62550@w221.z064000254.bwi-md.dsl.cnc.net> >>>>> "DT" == Don Tuttle writes: DT> could lexical scoping be implemented as a command line switch? '-L' It would have to be -N, because Python is already lexically scoped. The question of the moment is whether the scopes should nest. But, no, it can't be done via the command-line, because code written with nested scopes will not necessarily work with the old scoping rules and vice versa. If I hand you a module, it is possible it will work with one and only one set of scoping rules. If you run it with the wrong command line argument, it will blow up. Worse, that module can't be combined with another module that depends on the opposite rules. An alternative would be to add a notation to the module telling the compiler which rules it expects. Jeremy From tuttledon at hotmail.com Fri Feb 23 03:56:58 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Fri, 23 Feb 2001 02:56:58 GMT Subject: Update to PEP 227 (static scoping) References: Message-ID: <_jkl6.6220$h52.2081013@typhoon.southeast.rr.com> > DT> could lexical scoping be implemented as a command line switch? '-L' > "Jeremy Hylton" > But, no... An alternative would be to add a notation to the module telling the > compiler which rules it expects. Is this approch still an option for 2.1 or is always nested a done deal? Don From tuttledon at hotmail.com Fri Feb 23 05:19:30 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Fri, 23 Feb 2001 04:19:30 GMT Subject: Update to PEP 227 (static scoping) References: <_jkl6.6220$h52.2081013@typhoon.southeast.rr.com> Message-ID: > > DT> could lexical scoping be implemented as a command line switch? '-L' > > > "Jeremy Hylton" > > But, no... An alternative would be to add a notation to the module telling > the > > compiler which rules it expects. > > Is this approch still an option for 2.1 or is always nested a done deal? > Never mind. ;-) From hinsen at cnrs-orleans.fr Fri Feb 23 11:05:07 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 23 Feb 2001 11:05:07 +0100 Subject: Update to PEP 227 (static scoping) References: Message-ID: Jeremy Hylton writes: > It would have to be -N, because Python is already lexically scoped. > The question of the moment is whether the scopes should nest. There is one thing that I have missed in PEP 227: a motivation for the proposed change. All I can find is the statement that other languages have nested scopes. That sounds like a valid reason when designing a new language, but is it sufficient to modify an existing language in a way that risks breaking working code? I can't remember seeing excessive complaints about Python's current scoping rules. Konrad. -- ------------------------------------------------------------------------------- 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 aahz at panix.com Fri Feb 23 17:21:51 2001 From: aahz at panix.com (Aahz Maruch) Date: 23 Feb 2001 08:21:51 -0800 Subject: Update to PEP 227 (static scoping) References: Message-ID: <9762mv$iu9$1@panix2.panix.com> In article , Konrad Hinsen wrote: >Jeremy Hylton writes: >> >> It would have to be -N, because Python is already lexically scoped. >> The question of the moment is whether the scopes should nest. > >There is one thing that I have missed in PEP 227: a motivation for the >proposed change. All I can find is the statement that other languages >have nested scopes. That sounds like a valid reason when designing a >new language, but is it sufficient to modify an existing language in a >way that risks breaking working code? I can't remember seeing >excessive complaints about Python's current scoping rules. You've missed all the lambda-whiners. PEP 227 doesn't quite come out and say so explicitly, but you'll note that the abstract specifically mentions lambda as an issue. -- --- 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 "I used to have a .sig but I found it impossible to please everyone..." --SFJ From jeremy at alum.mit.edu Fri Feb 23 18:14:29 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Fri, 23 Feb 2001 12:14:29 -0500 (EST) Subject: Update to PEP 227 (static scoping) In-Reply-To: References: Message-ID: <14998.39541.803383.217822@w221.z064000254.bwi-md.dsl.cnc.net> You're right that the PEP doesn't spend much time explaining the motivation. Just this paragraph in the introduction: The changed scoping rules address two problems -- the limited utility of lambda statements and the frequent confusion of new users familiar with other languages that support lexical scoping, e.g. the inability to define recursive functions except at the module level. I'll expand this in the next draft. Jeremy From neo at thezion.net Wed Feb 21 20:10:04 2001 From: neo at thezion.net (Neo) Date: Wed, 21 Feb 2001 20:10:04 +0100 Subject: Unicode error with ado in win 32 Message-ID: <9713oe$mse8b$1@ID-35431.news.dfncis.de> I've created a simple script which read and print on the interactive window the data from a database field (sql server 7). It work properly but when into the rs.fields('azienda') theres the string "abb?" the script returns the following message. Traceback (most recent call last): File "g:\programmi\Python20\Pythonwin\pywin\framework\scriptutils.py", line 298, in RunScript debugger.run(codeObject, __main__.__dict__, start_stepping=0) File "g:\programmi\Python20\Pythonwin\pywin\debugger\__init__.py", line 60, in run _GetCurrentDebugger().run(cmd, globals,locals, start_stepping) File "g:\programmi\Python20\Pythonwin\pywin\debugger\debugger.py", line 582, in run _doexec(cmd, globals, locals) File "g:\programmi\Python20\Pythonwin\pywin\debugger\debugger.py", line 921, in _doexec exec cmd in globals, locals File "G:\Programmi\Python20\fede.py", line 12, in ? print unicode(a) File "g:\programmi\Python20\win32com\client\dynamic.py", line 165, in __str__ return str(self.__call__()) UnicodeError: ASCII encoding error: ordinal not in range(128) I've try to translate the string into my regional unicode character set, but it not work. Help me please. The strange kind is that using an ODBC connection this error not appear. Thanks. -- Neo **************************** Follow the White Rabbit... Knock Knock Neo... www.thezion.net **************************** Below there's the block code that i've used. Bye dataconn.Open (strConn) sql="select * from GpAzienda ;" rs.Open(sql, dataconn) while not rs.eof: a = gettext.gettext(rs.Fields('azienda')) print a rs.MoveNext() del rs del dataconn From fredrik at pythonware.com Wed Feb 21 20:17:35 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Feb 2001 19:17:35 GMT Subject: Unicode error with ado in win 32 References: <9713oe$mse8b$1@ID-35431.news.dfncis.de> Message-ID: Keanu wrote: > It work properly but when into the rs.fields('azienda') theres the string > "abb?" the script returns the following message. > File "G:\Programmi\Python20\fede.py", line 12, in ? > print unicode(a) try one of: # always works, but may not look right print a.encode("utf-8") # replace non-ascii with "?" print a.encode("ascii", "replace") # skip non-ascii characters print a.encode("ascii", "ignore") # latin-1 (western europe) print a.encode("latin-1", "replace") Cheers /F From neo at thezion.net Wed Feb 21 23:47:20 2001 From: neo at thezion.net (Neo) Date: Wed, 21 Feb 2001 23:47:20 +0100 Subject: Unicode error with ado in win 32 References: <9713oe$mse8b$1@ID-35431.news.dfncis.de> Message-ID: <971gfp$attcb$1@ID-35431.news.dfncis.de> Thanks! This method work properly but only if you have a like a string. Unfortunally i've mistake the pointer aritmetics. Writing a=rs.fields("azienda") return a pointer to rs.fields("azienda") that is not useful to work like string. Also writing a=rs.fields("azienda").value return a string that is simply encodable. Tnx 4 all ^_^ -- Neo **************************** Follow the White Rabbit... Knock Knock Neo... www.thezion.net **************************** > # always works, but may not look right > print a.encode("utf-8") > > # replace non-ascii with "?" > print a.encode("ascii", "replace") > > # skip non-ascii characters > print a.encode("ascii", "ignore") > > # latin-1 (western europe) > print a.encode("latin-1", "replace") > > Cheers /F > From spamers at must.die Wed Feb 21 20:32:11 2001 From: spamers at must.die (Fernando Rodríguez) Date: Wed, 21 Feb 2001 20:32:11 +0100 Subject: bug in string.join()? Message-ID: <4o589tsg0u2irh8mtds3u6kn05mvd35dao@4ax.com> Hi! >>> string.join(("abcde")) 'a b c d e' Is this the expected behavior, or is it a bug? O:-) //----------------------------------------------- // Fernando Rodriguez Romero // // frr at mindless dot com //------------------------------------------------ From thorsten at mats.gmd.de Wed Feb 21 21:17:22 2001 From: thorsten at mats.gmd.de (Thorsten Horstmann) Date: Wed, 21 Feb 2001 21:17:22 +0100 Subject: bug in string.join()? References: <4o589tsg0u2irh8mtds3u6kn05mvd35dao@4ax.com> Message-ID: <3A942252.E5D1B221@mats.gmd.de> "Fernando Rodr?guez" wrote: > >>> string.join(("abcde")) > 'a b c d e' > > Is this the expected behavior, or is it a bug? O:-) it's the expected behavior. string.join concatenate all sequence types. So it iterates over all characters in the string and joins them with the default separator ' '. It's not a bug - it's a feature! ;-) -Thorsten -- Anybody else on the list got an opinion? Should I change the language or not? (Guido van Rossum, 28 Dec 1991) from http://www.amk.ca/quotations/python-quotes/page-1.html From jmarshal at mathworks.com Wed Feb 21 21:37:09 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 21 Feb 2001 20:37:09 GMT Subject: bug in string.join()? References: <4o589tsg0u2irh8mtds3u6kn05mvd35dao@4ax.com> <3A942252.E5D1B221@mats.gmd.de> Message-ID: <9718tl$dtv$1@news.mathworks.com> Thorsten Horstmann wrote: > "Fernando Rodrguez" wrote: >> >>> string.join(("abcde")) >> 'a b c d e' >> >> Is this the expected behavior, or is it a bug? O:-) > it's the expected behavior. > string.join concatenate all sequence types. So it iterates > over all characters in the string and joins them with the > default separator ' '. > It's not a bug - it's a feature! ;-) Also of note is that you have an unnecessary set of parens. If you meant to pass a tuple of one element into string.join, you needed to add a trailing comma. And you'd get a different behavior: >>> string.join(("abcde")) 'a b c d e' >>> string.join(("abcde",)) 'abcde' From danielk at aracnet.com Thu Feb 22 04:06:13 2001 From: danielk at aracnet.com (Daniel Klein) Date: Wed, 21 Feb 2001 19:06:13 -0800 Subject: bug in string.join()? References: <4o589tsg0u2irh8mtds3u6kn05mvd35dao@4ax.com> Message-ID: On Wed, 21 Feb 2001 20:32:11 +0100, Fernando Rodr?guez wrote: >>>> string.join(("abcde")) >'a b c d e' > >Is this the expected behavior, or is it a bug? O:-) What would you expect it to do? It's already 'joined' without spaces to start with. Dan From adom at i.am Thu Feb 22 16:39:20 2001 From: adom at i.am (luc lam) Date: Thu, 22 Feb 2001 15:39:20 GMT Subject: bug in string.join()? References: <4o589tsg0u2irh8mtds3u6kn05mvd35dao@4ax.com> Message-ID: <973bqv$iub$1@m1.cs.man.ac.uk> Coffee went everywhere when I read that Daniel Klein had written: >On Wed, 21 Feb 2001 20:32:11 +0100, Fernando Rodr?guez >wrote: > >>>>> string.join(("abcde")) >>'a b c d e' >> >>Is this the expected behavior, or is it a bug? O:-) > >What would you expect it to do? It's already 'joined' without spaces to start >with. > >Dan It threw me somewhat at first: >>> import string >>> list = ["i've","come","for","an","argument"] >>> print string.join(list) i've come for an argument >>> print string.join(list," ") i've come for an argument >>> print string.join(list,"") i'vecomeforanargument >>> so the " " is implicit. i've sometimes thought it would be more intuitive to have the "" behaviour as the implicit behaviour, but it's simple enough either way i guess. luc From adam at deprince.net Wed Feb 21 20:33:59 2001 From: adam at deprince.net (Adam DePrince) Date: Wed, 21 Feb 2001 14:33:59 -0500 Subject: bug in string.join()? References: <4o589tsg0u2irh8mtds3u6kn05mvd35dao@4ax.com> <973bqv$iub$1@m1.cs.man.ac.uk> Message-ID: <3A941827.20C9F0F9@deprince.net> luc lam wrote: > > Coffee went everywhere when I read that > Daniel Klein had written: > >On Wed, 21 Feb 2001 20:32:11 +0100, Fernando Rodr?guez > >wrote: > >>>>> string.join(("abcde")) > >>'a b c d e' > >>Is this the expected behavior, or is it a bug? O:-) > >What would you expect it to do? It's already 'joined' without spaces to start > >with. > >Dan > It threw me somewhat at first: > >>> import string > >>> list = ["i've","come","for","an","argument"] > >>> print string.join(list) > i've come for an argument > >>> print string.join(list," ") > i've come for an argument > >>> print string.join(list,"") > i'vecomeforanargument > so the " " is implicit. i've sometimes thought it would be more intuitive to > have the "" behaviour as the implicit behaviour, but it's simple enough either When constructing strings from lists the default value of ' ' as a delimiter is a pain. Consider that string.join is often used to replace string interpolation. Consider this straw man: queries = [] for .... queries.append("insert into table xyz values '%s','%s','%s' .... One might prefer to say queries = [] for ..... queries.append( map( str, ["insert into table xyz values '", d1, "','" ...  queries = map( string.join, queries ) Of course, for this to work, you would have to say: queries = map( string.join, queries, ("",)*len(queries)) So, should we propose a join0 that has a delimiter of '', or a version of map that provides default parameters :-) Now, to play devils advocate: ' ' makes a convenient delimiter for seperating words in text; it also matches the defalt delimiter in split. Notice that: >>> from string import * >>> split( join( ["i've","come","for","an","arguement"])) ["i've", 'come', 'for', 'an', 'arguement'] If join used '' then word lists could not be broken appart and rejoined so easily. > way i guess. > luc Adam DePrince Starmedia Network, Inc. Email: zlib.decompress('x\332KLI\314\325KI-(\312\314KNu(.I,\312MM\311L\324K\316\317\005\000\221\331\012s') From tim.hochberg at ieee.org Thu Feb 22 22:13:23 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Thu, 22 Feb 2001 21:13:23 GMT Subject: bug in string.join()? References: <4o589tsg0u2irh8mtds3u6kn05mvd35dao@4ax.com> <973bqv$iub$1@m1.cs.man.ac.uk> <3A941827.20C9F0F9@deprince.net> Message-ID: "Adam DePrince" wrote in message [SNIP] > When constructing strings from lists the default value of ' ' as a > delimiter is a pain. Consider that string.join is often used to replace > string interpolation. Consider this straw man: > > queries = [] > for .... > queries.append("insert into table xyz values '%s','%s','%s' .... > > One might prefer to say > > queries = [] > for ..... > queries.append( map( str, ["insert into table xyz values '", d1, "','" > ... >  > queries = map( string.join, queries ) > > Of course, for this to work, you would have to say: > > queries = map( string.join, queries, ("",)*len(queries)) Death to map! Use list comprehensions instead. And string methods! New is good, old is bad <0.9 wink>. queries = [''.join(q) for q in queeries] [SNAP] -tim From jwbnews at scandaroon.com Fri Feb 23 06:16:19 2001 From: jwbnews at scandaroon.com (John W. Baxter) Date: Thu, 22 Feb 2001 21:16:19 -0800 Subject: bug in string.join()? References: <4o589tsg0u2irh8mtds3u6kn05mvd35dao@4ax.com> <973bqv$iub$1@m1.cs.man.ac.uk> <3A941827.20C9F0F9@deprince.net> Message-ID: In article , "Tim Hochberg" wrote: > Death to map! Use list comprehensions instead. As soon as my 1940s brain comprehends them. ;-) --john -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From spamers at must.die Sat Feb 24 00:47:20 2001 From: spamers at must.die (Fernando Rodríguez) Date: Sat, 24 Feb 2001 00:47:20 +0100 Subject: bug in string.join()? References: <4o589tsg0u2irh8mtds3u6kn05mvd35dao@4ax.com> Message-ID: <6jtd9t0b25925bs865a5t796q1iof1ao65@4ax.com> On Wed, 21 Feb 2001 19:06:13 -0800, Daniel Klein wrote: >On Wed, 21 Feb 2001 20:32:11 +0100, Fernando Rodr?guez >wrote: > >>>>> string.join(("abcde")) >>'a b c d e' >> >>Is this the expected behavior, or is it a bug? O:-) > >What would you expect it to do? It's already 'joined' without spaces to start >with. That's why I expected it to do nothing. Instead, it did something weird. //----------------------------------------------- // Fernando Rodriguez Romero // // frr at mindless dot com //------------------------------------------------ From BrianQ at ActiveState.com Sat Feb 24 02:20:11 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Fri, 23 Feb 2001 17:20:11 -0800 Subject: bug in string.join()? In-Reply-To: <6jtd9t0b25925bs865a5t796q1iof1ao65@4ax.com> Message-ID: <001c01c09dff$ef83afa0$b503a8c0@activestate.ca> OK, first of all, according to the docs, string.join operates on tuples and lists, not strings. If you change your code to string.join(("abcde",)), you get what you expected. But string.join will actually except anything sequence-type like and, by default, insert a space between it's items. Which is exactly what it did. -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Fernando Rodr?guez Sent: Friday, February 23, 2001 3:47 PM To: python-list at python.org Subject: Re: bug in string.join()? On Wed, 21 Feb 2001 19:06:13 -0800, Daniel Klein wrote: >On Wed, 21 Feb 2001 20:32:11 +0100, Fernando Rodr?guez >wrote: > >>>>> string.join(("abcde")) >>'a b c d e' >> >>Is this the expected behavior, or is it a bug? O:-) > >What would you expect it to do? It's already 'joined' without spaces to start >with. That's why I expected it to do nothing. Instead, it did something weird. //----------------------------------------------- // Fernando Rodriguez Romero // // frr at mindless dot com //------------------------------------------------ -- http://mail.python.org/mailman/listinfo/python-list From spamers at must.die Wed Feb 21 20:32:12 2001 From: spamers at must.die (Fernando Rodríguez) Date: Wed, 21 Feb 2001 20:32:12 +0100 Subject: Non single-line comments? Message-ID: Hi! Are there any plans to support non single-line comments (a la /* */ in C)? O:-) I sometimes miss them while debugging... //----------------------------------------------- // Fernando Rodriguez Romero // // frr at mindless dot com //------------------------------------------------ From wolfgang.grafen at marconi.com Wed Feb 21 20:45:47 2001 From: wolfgang.grafen at marconi.com (Wolfgang Grafen) Date: Wed, 21 Feb 2001 20:45:47 +0100 Subject: Non single-line comments? References: Message-ID: <3A941AEB.5ECDD353@marconi.com> Use """ to comment out blocks: >>> def ignored_python_code(): ... print "comment out from next line" ... """ ... { some python code to comment out } ... """ ... print "continue now from here" ... >>> ignored_python_code() comment out from next line continue now from here Regards Wolfgang "Fernando Rodr?guez" wrote: > > Hi! > > Are there any plans to support non single-line comments (a la /* */ in > C)? O:-) I sometimes miss them while debugging... > > //----------------------------------------------- > // Fernando Rodriguez Romero > // > // frr at mindless dot com > //------------------------------------------------ From bobhicks at adelphia.net Wed Feb 21 20:47:37 2001 From: bobhicks at adelphia.net (Robert L Hicks) Date: Wed, 21 Feb 2001 19:47:37 GMT Subject: Non single-line comments? References: Message-ID: What is wrong with the # sign? I think it clearly distinguishes any comments, even multi-line. My .02 - Bob > From: Fernando Rodr?guez > Organization: T.I.A. > Newsgroups: comp.lang.python > Date: Wed, 21 Feb 2001 20:32:12 +0100 > Subject: Non single-line comments? > > Hi! > > Are there any plans to support non single-line comments (a la /* */ in > C)? O:-) I sometimes miss them while debugging... > > > > > //----------------------------------------------- > // Fernando Rodriguez Romero > // > // frr at mindless dot com > //------------------------------------------------ From phlip_cpp at my-deja.com Wed Feb 21 20:50:21 2001 From: phlip_cpp at my-deja.com (Phlip) Date: Wed, 21 Feb 2001 11:50:21 -0800 Subject: IDLE - change the font size & background color Message-ID: Pytho-logicians: Before I crack open the source, I'm wondering if I overlooked some simple way to make the font bigger and set the background color to a light grey. Does anyone have, like, a patch? -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- DARE to resist drug-war profiteering -- From butcuz at yahoo.com Wed Feb 21 21:56:52 2001 From: butcuz at yahoo.com (sa) Date: Wed, 21 Feb 2001 15:56:52 -0500 Subject: IDLE - change the font size & background color References: Message-ID: <3a942c61_4@corp.newsfeeds.com> changing font size is pretty simple: - goto the directory where IDLE is usually stored (It's C:\Python20\Tools\idle on my windoze system) - look to one of two files that directory: - config-win.txt [for windoze] - config-unix.txt [for unix] and change the font size accordingly. [I like Verdana, 8pt] [for the background color, I'm affraid you're gong to have to dig into the source] sa "Phlip" wrote in message news:p0Vk6.18$0Q5.43640 at news.pacbell.net... > Pytho-logicians: > > Before I crack open the source, I'm wondering if I overlooked some simple > way to make the font bigger and set the background color to a light grey. > Does anyone have, like, a patch? > > -- > Phlip phlip_cpp at my-deja.com > ============ http://c2.com/cgi/wiki?PhlIp ============ > -- DARE to resist drug-war profiteering -- -----= 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 phlip_cpp at my-deja.com Wed Feb 21 23:57:35 2001 From: phlip_cpp at my-deja.com (Phlip) Date: Wed, 21 Feb 2001 14:57:35 -0800 Subject: IDLE - change the font size & background color References: <3a942c61_4@corp.newsfeeds.com> Message-ID: sa wrote: > changing font size is pretty simple: > > - goto the directory where IDLE is usually stored (It's > C:\Python20\Tools\idle on my windoze system) > > - look to one of two files that directory: > - config-win.txt [for windoze] > - config-unix.txt [for unix] > > and change the font size accordingly. [I like Verdana, 8pt] > > [for the background color, I'm affraid you're gong to have to dig into the > source] we got it. Tip 1: background color's in 'config.txt'. Tip 2: Get the latest IDLE ;-) -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- My opinions are those of your employer -- From joseamartin at venmex.com Wed Feb 21 20:58:17 2001 From: joseamartin at venmex.com (Jose Martin) Date: Wed, 21 Feb 2001 15:58:17 -0400 Subject: Simplest Way to call Stored Procs In DCOracle == cur.execute(' call myproc() ' ) Message-ID: Thats it's From fwittenburg at myokay.net Wed Feb 21 21:00:11 2001 From: fwittenburg at myokay.net (Florian W.) Date: Wed, 21 Feb 2001 21:00:11 +0100 Subject: Comparison with Ruby ? Message-ID: <9716n5$2lln$1@news.okay.net> Hi Python-Fans ! A friend told me about the programming language "Ruby". It's seems that it's a fine one. Will the high number of features shrink the Python-community to a very low amount ? Mfg Florian From claird at starbase.neosoft.com Wed Feb 21 21:31:21 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 21 Feb 2001 14:31:21 -0600 Subject: Comparison with Ruby ? References: <9716n5$2lln$1@news.okay.net> Message-ID: <9457E37E39EE85FF.533763A1B69129A1.704A78AD6E685E9C@lp.airnews.net> In article <9716n5$2lln$1 at news.okay.net>, Florian W. wrote: >Hi Python-Fans ! > >A friend told me about the programming language "Ruby". >It's seems that it's a fine one. > >Will the high number of features shrink the Python-community to >a very low amount ? . . . For the most part, the people in c.l.p are more practiced in making the best of Python's features (and making Pyfea- tures the best), than speculating about how they might evaporate. If you need comparisons of Ruby and Python beyond what provides, let me know; I have a few more I haven't annotated yet. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From dfan at harmonixmusic.com Wed Feb 21 23:21:00 2001 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 21 Feb 2001 17:21:00 -0500 Subject: Comparison with Ruby ? References: <9716n5$2lln$1@news.okay.net> <9457E37E39EE85FF.533763A1B69129A1.704A78AD6E685E9C@lp.airnews.net> Message-ID: I hesitate to mention this lest it be construed as advocacy, but the PROGRAMMING RUBY book (by David Thomas and Andrew Hunt, the PRAGMATIC PROGRAMMER guys) is now online at . Whether or not you like Ruby, it's a very well-written book and makes learning the language orders of magnitude easier for English speakers. -- http://www.dfan.org From claird at starbase.neosoft.com Thu Feb 22 16:38:10 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 22 Feb 2001 09:38:10 -0600 Subject: Comparison with Ruby ? References: <9716n5$2lln$1@news.okay.net> <9457E37E39EE85FF.533763A1B69129A1.704A78AD6E685E9C@lp.airnews.net> Message-ID: <12C9A77C1B9B010B.158D24368FADE26B.D347411B0EEA8942@lp.airnews.net> In article , Dan Schmidt wrote: >I hesitate to mention this lest it be construed as advocacy, but the >PROGRAMMING RUBY book (by David Thomas and Andrew Hunt, the PRAGMATIC >PROGRAMMER guys) is now online at . >Whether or not you like Ruby, it's a very well-written book and makes >learning the language orders of magnitude easier for English speakers. . . . I think the book is even better than that: it manages also to convey The Ruby Mentality. Dave and Andrew are good at what they do. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From bobhicks at adelphia.net Wed Feb 21 21:45:13 2001 From: bobhicks at adelphia.net (Robert L Hicks) Date: Wed, 21 Feb 2001 20:45:13 GMT Subject: Comparison with Ruby ? References: <9716n5$2lln$1@news.okay.net> Message-ID: troll troll troll > From: "Florian W." > Organization: okay.net Newsserver @ Jippii! > Newsgroups: comp.lang.python > Date: Wed, 21 Feb 2001 21:00:11 +0100 > Subject: Comparison with Ruby ? > > Hi Python-Fans ! > > A friend told me about the programming language "Ruby". > It's seems that it's a fine one. > > Will the high number of features shrink the Python-community to > a very low amount ? > > Mfg Florian > > > From Randy.L.Kemp at motorola.com Wed Feb 21 22:14:06 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Wed, 21 Feb 2001 15:14:06 -0600 Subject: Comparison with Ruby ? Message-ID: <69BC4C6AE83ED311BC9400805FA7B14AF84E6E@il93exp01.css.mot.com> If you go to www.rubycentral.com, you will find all you need to know about Ruby. If you go to www.python.org or www.activestate.com, you will find all you need to know about Python. Ruby is very popular in Japan, but has not caught on as big in other parts of the world. Perl is only popular because it was at the right place at the right time with web usage. It's hard to predict what will catch on. Are you implying we might be singing a revamped Rolling Stones song Rube Tuesday? How do the words go? "Goodbye to programming with Ruby on Tuesday. Python's the name for all that's new, Since Perl changes with every new release day, I'm not going to miss you." -----Original Message----- From: Florian W. [mailto:fwittenburg at myokay.net] Sent: Wednesday, February 21, 2001 2:00 PM To: python-list at python.org Subject: Comparison with Ruby ? Hi Python-Fans ! A friend told me about the programming language "Ruby". It's seems that it's a fine one. Will the high number of features shrink the Python-community to a very low amount ? Mfg Florian From juergen.bocklage at gmx.net Thu Feb 22 00:00:46 2001 From: juergen.bocklage at gmx.net (Juergen Bocklage) Date: Thu, 22 Feb 2001 00:00:46 +0100 Subject: Comparison with Ruby ? References: <9716n5$2lln$1@news.okay.net> Message-ID: <3A94489D.5B65ED19@gmx.net> Aehmmm, I'm just a beginner, but some remarks on the ruby-python comparision. Python and Ruby deal with similar problem areas. Now, let's compare Python with Ruby: Ruby uses conservative statement structure, using `end'. JB> Python syntax is the best I ever saw, indenting is just smart. You don't have to say `self.' to access attribute of the object. Ruby's instance variables are prefixed by "@". JB> Then I prefere self. It's more descriptive. Python separates types and classes, while Ruby treats them the same. Python types are more limited (no inheritance/subclassing; cannot add methods to existing types). JB> Don't know Ruby has a better (or "real") closure feature. JB> what does this mean Object attributes are not accessible by default in Ruby. JB> That's bad. Wrinting __ in front of a instance attribute, is okay for me. Ruby converts small integers and long integers automatically. JB> Okay, nice for you Ruby does not have tuples. JB> Bad for Ruby. They are fast. Statements in Ruby have values; you can say def max(a,b) if a>b then a else b end end JB> Where is the return? How can someone see when sth. is returned? Ruby has more natural operator overloading; e.g. you can define def +(x) self.to_i + x end JB> I know this from C++, (Syntactical sugar or a good source for errors) Ruby uses mark-and-sweep GC, unlike Python's ref-counting GC. So that: No INCREF, DECREF are required for extensions. Extensions for Ruby written in C/C++ can easily define Ruby classes. Ruby has a loop abstraction using block; e.g. 10.times do ... end JB> What's this? You can define your own arbitrary iterator. JB> Why? Ruby's block for method can be used more than iterator; e.g. mutex.synchronize do .. critical process .. end JB> Don't know Ruby provides method combination using `super'. JB> this is a good feature, in python I think you have to use the name of parent class. Ruby is often faster than Python. JB> Often?? After a short look at the language I have to say, python is much more self explanatory then ruby. Also this parenteses less calling of methods, does not look good. Looks like calling an attribute. Python is for me the language for beginners and designers. I teached my flat mates in one eveing how to prototype there C++ app. with python. They where just ;-)) and concentrated on the design. - See ya JB "Florian W." wrote: > Hi Python-Fans ! > > A friend told me about the programming language "Ruby". > It's seems that it's a fine one. > > Will the high number of features shrink the Python-community to > a very low amount ? > > Mfg Florian -- Juergen Bocklage ================================ mailto:juergen.bocklage at gmx.net From aleaxit at yahoo.com Thu Feb 22 10:19:34 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 22 Feb 2001 10:19:34 +0100 Subject: Comparison with Ruby ? References: <9716n5$2lln$1@news.okay.net> <3A94489D.5B65ED19@gmx.net> Message-ID: <972lk10k0n@news2.newsguy.com> "Juergen Bocklage" wrote in message news:3A94489D.5B65ED19 at gmx.net... > Aehmmm, I'm just a beginner, but some remarks on the ruby-python > comparision. [snip] > Python separates types and classes, while Ruby treats them the > same. Python types are more limited (no > inheritance/subclassing; cannot add methods to existing types). > JB> Don't know A Ruby win here. > Ruby has a better (or "real") closure feature. > JB> what does this mean Nothing, actually. Some people are SO keen on nested lexical scopes, that they'll (mistakenly) argue that a closure is not one unless it supports _nested_ lexical scopes. Until 2.0, Python's scopes don't nest, so, of course, they keep not nesting in closures; at 2.1, they will (alas) nest, so, of course, they'll keep nesting in closures. > Ruby converts small integers and long integers automatically. > JB> Okay, nice for you No way. Explicit is better than implicit. I'd rather NOT have such 'automatic' (automagick) conversions anywhere! > Ruby does not have tuples. > JB> Bad for Ruby. They are fast. Disagree. 'Fast' should be handled by the compiler and runtime. Tuples should be lists with an "immutable" setting (and there should be similar "immutable" settings for dictionaries) but otherwise indistinguishable. > def +(x) > self.to_i + x > end > > JB> I know this from C++, (Syntactical sugar or a good source for > errors) It's not more error-prone than using __add__ as the magic name for overloading addition, which is why Python does. Looks like a total wash to me. > Ruby has a loop abstraction using block; e.g. > > 10.times do > ... > end > > JB> What's this? A method 'times' on integer objects, that takes a code-block. > You can define your own arbitrary iterator. > JB> Why? To iterate arbitrarily. Why else? > Ruby provides method combination using `super'. > JB> this is a good feature, in python I think you have to use the name > of parent class. Disagree -- I _like_ it that the SPECIFIC parent-class you mean has to be explicitly mentioned (multiple-inheritance, remember). I don't like the complex rules of Dylan to allow magick implicitness in this, nor constraining inheritance to single just to allow 'super' to work:-). > Python is for me the language for beginners and designers. Not just for them. Lots of Hackers and eXtreme Programmers are also pretty happy with it. Alex From emile at fenx.com Thu Feb 22 14:11:17 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 22 Feb 2001 05:11:17 -0800 Subject: Comparison with Ruby ? References: <9716n5$2lln$1@news.okay.net> <3A94489D.5B65ED19@gmx.net> <972lk10k0n@news2.newsguy.com> Message-ID: <97337o$nnk22$1@ID-11957.news.dfncis.de> "Alex Martelli" wrote in message news:972lk10k0n at news2.newsguy.com... > "Juergen Bocklage" wrote in message > news:3A94489D.5B65ED19 at gmx.net... > > Ruby converts small integers and long integers automatically. > > JB> Okay, nice for you > > No way. Explicit is better than implicit. I'd rather NOT > have such 'automatic' (automagick) conversions anywhere! > What *magic* requires my attention between 2147483647 and 2147483648? I'd rather have a single type for a python number, and let C do what it needs to do to allow it. I learned a long time ago to store monetary values as whole numbers in order to avoid rounding and precision related problems. Here, that means that the maximum value a sum of numbers can have is $21,474,836.47. On a trial balance where you add up the debits for the period, even small companies hit this limit quickly. This simply means that all monetary values must be longs and is certainly not a problem, but I'd much prefer not having to think of it. -- Emile van Sebille emile at fenx.com ------------------- From othello at javanet.com Fri Feb 23 04:03:23 2001 From: othello at javanet.com (Raymond Hettinger) Date: Thu, 22 Feb 2001 22:03:23 -0500 Subject: Comparison with Ruby ? References: <9716n5$2lln$1@news.okay.net> <3A94489D.5B65ED19@gmx.net> <972lk10k0n@news2.newsguy.com> Message-ID: <3A95D2FB.5D7937A9@javanet.com> Alex Martelli wrote: > "Juergen Bocklage" wrote in message > news:3A94489D.5B65ED19 at gmx.net... > > Aehmmm, I'm just a beginner, but some remarks on the ruby-python > > comparision. > [snip] > > Python separates types and classes, while Ruby treats them the > > same. Python types are more limited (no > > inheritance/subclassing; cannot add methods to existing types). > > JB> Don't know > > A Ruby win here. Yes! > > Ruby does not have tuples. > > JB> Bad for Ruby. They are fast. > > Disagree. 'Fast' should be handled by the compiler and runtime. > Tuples should be lists with an "immutable" setting (and there > should be similar "immutable" settings for dictionaries) but > otherwise indistinguishable. Double Yes! > > > Ruby provides method combination using `super'. > > JB> this is a good feature, in python I think you have to use the name > > of parent class. > > Disagree -- I _like_ it that the SPECIFIC parent-class you > mean has to be explicitly mentioned (multiple-inheritance, > remember). I don't like the complex rules of Dylan to allow > magick implicitness in this, nor constraining inheritance to > single just to allow 'super' to work:-). I would like to see a version of 'super' that searches inherited classes in the same order that methods are searched for. Super.method, should act like it would if the method were not found in the current class definition. 'nuff said. > > > Python is for me the language for beginners and designers. > > Not just for them. Lots of Hackers and eXtreme Programmers > are also pretty happy with it. > I'm not a beginner or designer and I'm happy. See my big smile: @ @ \_/ Raymond From jeremy at alum.mit.edu Fri Feb 23 04:10:48 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Thu, 22 Feb 2001 22:10:48 -0500 (EST) Subject: Comparison with Ruby ? In-Reply-To: <3A95D2FB.5D7937A9@javanet.com> References: <9716n5$2lln$1@news.okay.net> <3A94489D.5B65ED19@gmx.net> <972lk10k0n@news2.newsguy.com> <3A95D2FB.5D7937A9@javanet.com> Message-ID: <14997.54456.899428.840814@w221.z064000254.bwi-md.dsl.cnc.net> On the issue of super and overriding: I'd like to recommend again the use of explicit renaming to make this a little clearer. It's an idea I first saw in MzScheme -- http://www.cs.rice.edu/CS/PLT/packages/mzscheme/index.html -- and it has a very natural mapping to Python. class Foo(Bar, Baz): __super_meth1 = Bar.meth1 __super_meth2 = Baz.meth2 def meth1(self, arg): self.__super_meth1(arg) def meth2(self, arg): self.__super_meth2(arg) The idea is to create new bindings for the method objects in the current class. Then invocation of the method in the parent class looks like a normal method call. It's important to add the __ first. If you don't and more than one class in the inheritance hierarchy overrides the same method, you'll be in trouble. It's merely convention to make it __super, but it helps to indicate what is going on. A nice side-effect of this style is that it localizes the information about what dependencies there are on parent classes. If you change the base classes of Foo, you've got all the information about specific methods of base classes that are being called -- as opposed to have Baz.meth2(self, arg) scattered throughout the body of Foo. Jeremy From aleaxit at yahoo.com Fri Feb 23 11:33:04 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 23 Feb 2001 11:33:04 +0100 Subject: Comparison with Ruby ? References: <9716n5$2lln$1@news.okay.net> <3A94489D.5B65ED19@gmx.net> <972lk10k0n@news2.newsguy.com> <3A95D2FB.5D7937A9@javanet.com> Message-ID: <975ea40314d@news1.newsguy.com> "Raymond Hettinger" wrote in message news:3A95D2FB.5D7937A9 at javanet.com... [snip] > I would like to see a version of 'super' that searches inherited classes > in the same order that methods are searched for. Super.method, should act > like it would if the method were not found in the current class definition. > 'nuff said. Generalizing this a bit (to find all attributes, rather than just methods), you could just use the following free-standing function: def findSuperclassForAttributeName(self, attributeName): for base in self.__class__.__bases__: if hasattr(base, attributeName): return base else: return None or, you could use a convenient mixin class, by having your classes inherit from it: class SuperFinder: [snip: method same as above] but that's just for the syntax-sugar satisfaction of being able to use this in a 'cooler' way, such as: class Whatever(Abase,Anotherbase,SuperFinder): def floop(self, plik, plok): preFlooper(plok) super = self.findSuperclassForAttributeName('floop') if super is None: raise AttributeError super.floop(self, plok, plik) postFlooper(plik+23.7) and if you're into 'cool' solutions (rather than simple ones), then you can do even "better" -- e.g., here's a less-general, but potentially interesting, approach: import new def bindInSuper(boundMethod): obj = boundMethod.im_self name = boundMethod.__name__ for base in obj.__class__.__bases__: if hasattr(base, name): break else: raise AttributeError return new.instancemethod(getattr(base, name), obj, base) leading to the usage pattern: class Whatever(Abase,Anotherbase,SuperFinder): def floop(self, plik, plok): preFlooper(plok) bindInSuper(self.floop)(plok, plik) postFlooper(plik+23.7) Note that this only works ONCE, to find ONE 'super', or build one bound-method; e.g., the returned bound-method of bindInSuper is a fixedpoint for it. It would not be TOO hard to work around this, by having bindInSuper return an instance of a suitable special-purpose class, that is both callable AND specialcased for further searches on the inheritance DAG (you'd have to decide exactly what sequence of [bound-methods wrapped into suitable callable instances] you want to get from a sequence of calls to bindInSuper in various cases, of course:-). But I'm going to leave this as an exercise to the interested reader. The real value of this fancy stuff is not in truly making use of it in production code, anyway -- it's in showing off on comp.lang.python, ahem, I *mean*, in better understanding what IS going on "behind the scenes" (but not "secretly" at all -- Python is wonderfully open about what its mechanisms ARE doing on your behalf!!!). In *practice*, one should use *the simplest thing that can possibly work* -- and, unless one is building the next great development and debugging environment, it is seldom indeed that the "simplest thing" will require introspection and metaprogramming facilities. Alex From moshez at zadka.site.co.il Fri Feb 23 11:49:44 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Fri, 23 Feb 2001 12:49:44 +0200 (IST) Subject: Comparison with Ruby ? In-Reply-To: <972lk10k0n@news2.newsguy.com> References: <972lk10k0n@news2.newsguy.com>, <9716n5$2lln$1@news.okay.net> <3A94489D.5B65ED19@gmx.net> Message-ID: <20010223104944.BEB4AA840@darjeeling.zadka.site.co.il> On Thu, 22 Feb 2001 10:19:34 +0100, "Alex Martelli" wrote: > > Ruby converts small integers and long integers automatically. > > JB> Okay, nice for you > > No way. Explicit is better than implicit. I'd rather NOT > have such 'automatic' (automagick) conversions anywhere! Err....I don't agree. See PEP 0228 (http://python.sourceforge.net/peps/pep-0228.html). I think it could be done in a very Pythonic way (of course, for full disclosure, I am the author of said PEP...) Numbers are numbers: I shouldn't care about how to store numbers in machine-level integers more then I should care how to reallocate lists. This PEP is a bit backwards incompatible, but in my not so humble opinion, I think it does have a good chance of being in Py3K. There is a related session in IPC9 given by Tim Peters, by the way. -- "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 aleaxit at yahoo.com Fri Feb 23 12:13:07 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 23 Feb 2001 12:13:07 +0100 Subject: Comparison with Ruby ? References: <972lk10k0n@news2.newsguy.com>, <9716n5$2lln$1@news.okay.net> <3A94489D.5B65ED19@gmx.net> <20010223104944.BEB4AA840@darjeeling.zadka.site.co.il> Message-ID: <021101c09d89$9a418740$102b2bc1@cadlab.it> "Moshe Zadka" writes: > > > Ruby converts small integers and long integers automatically. > > > JB> Okay, nice for you > > > > No way. Explicit is better than implicit. I'd rather NOT > > have such 'automatic' (automagick) conversions anywhere! > > Err....I don't agree. See PEP 0228 > (http://python.sourceforge.net/peps/pep-0228.html). > I think it could be done in a very Pythonic way (of course, for full disclosure, > I am the author of said PEP...) Guess I should have mentioned I _do_ like PEP 228 -- reworking the entire conceptual model of Python numbers in such a simplifying way seems a very worthy goal. Automatic conversions behind my back are a different thing... > Numbers are numbers: I shouldn't care about how to store numbers in > machine-level integers more then I should care how to reallocate lists. But I _do_ care about how list are allocated -- somebody mentioned recently that a simple 'optimization' I and others had suggested, where a (huge) list of known length N is "pre-allocated" as N*[None], then the various items set, gave them a factor-of-2 boost in time to run their program over the N-times-append alternative. Speed is not the crucial thing when one uses Python, but factors of 2 or more are still of some interest, in many cases. > This PEP is a bit backwards incompatible, but in my not so humble opinion, > I think it does have a good chance of being in Py3K. > There is a related session in IPC9 given by Tim Peters, by the way. Alas, I won't be there, but I hope I'll be able to read some report about it on the net later... Alex From johann at physics.berkeley.edu Fri Feb 23 21:28:17 2001 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 23 Feb 2001 12:28:17 -0800 Subject: Comparison with Ruby ? References: <972lk10k0n@news2.newsguy.com> <9716n5$2lln$1@news.okay.net> <3A94489D.5B65ED19@gmx.net> Message-ID: Moshe Zadka writes: > Numbers are numbers: I shouldn't care about how to store numbers in > machine-level integers more then I should care how to reallocate lists. > This PEP is a bit backwards incompatible, but in my not so humble opinion, > I think it does have a good chance of being in Py3K. I just read that; looks nice. Inspired by Scheme? Then again, it's not suprising that I like it; at least someone's Python humor file quotes me twice going off on the same issue. I'll have to be more circumspect this time. :-) In any case, as someone who does a lot of numerics, I've got to say that folding this under "numbers are numbers" is unwholesome. Inexact numbers are not exact numbers. That lets the number-crunchers use their types happily. Integers (fixnums) and rationals and bignums, on the other hand, are "numbers" and there should be no walls between them. --J -- Johann Hibschman johann at physics.berkeley.edu From fwittenburg at myokay.net Thu Feb 22 21:48:35 2001 From: fwittenburg at myokay.net (Florian W.) Date: Thu, 22 Feb 2001 21:48:35 +0100 Subject: Comparison with Ruby ? References: <9716n5$2lln$1@news.okay.net> Message-ID: <973tte$1056$1@news.okay.net> First of all... thanks for the comments Sometimes the finger is faster than the brain. So I didn't searched with google the usenet about ruby<->Python comments. Sorry, Florian P.S. I prefer to mark blocks with tabs :-) Florian W. schrieb in im Newsbeitrag: 9716n5$2lln$1 at news.okay.net... > Hi Python-Fans ! > > A friend told me about the programming language "Ruby". > It's seems that it's a fine one. > > Will the high number of features shrink the Python-community to > a very low amount ? > > Mfg Florian > > > From faraway at mhtc.net Wed Feb 21 21:28:20 2001 From: faraway at mhtc.net (Craig Dunigan) Date: Wed, 21 Feb 2001 14:28:20 -0600 Subject: base64.decodestring or xmlrpc (in zope) is truncating strings Message-ID: If anyone knows of any problems with base64 or xmlrpc, or has experienced any similar behavior, I'd really like to hear from you! I am extending a zope/xmlrpc client on Win32 that was written by a much brighter programmer than me. Basically, it uses xmlrpc to call external methods on the zope server, and synchronizes a local web tree with a users remote tree. It makes its rpc call to an external method on the server (RedHat 7, Zope 2.3) containing this bit of code (it returns file contents from the zodb): meta_type = fileObject.meta_type if meta_type == 'DTML Document': return ("OK", base64.encodestring(fileObject.document_src())) elif meta_type == 'File': return ("OK", base64.encodestring(fileObject.data)) elif meta_type == 'Image': return ("OK", base64.encodestring(fileObject.data)) else: return ("FAIL", 'Unsupported meta_type') This is the client's method to receive the file contents: def getFile(self, pathSpec, fileName): parms = { 'relativePathSpec':pathSpec, 'fileName': fileName } retval = None try: retval = eval("self.serverObject.getConnection()." + self.remoteBasePathSpec + ".EWSyncGetFile(parms)") # EWSyncGetFile is the remote method that contains the snippet above except: raise "ZopeFileSystemException", "type: %s\nvalue: %s" % (sys.exc_type, sys.exc_value) if retval[0] != "OK": raise "ZopeFileSystemException", "Failure from EWSyncGetFile()\n %s" % retval[1] return base64.decodestring(retval[1]) I've put in some debug code to spit print statements to the console, then run the client window and server console side by side, and visually verified that string lengths of the server's return after encode and the client's retval[1] prior to decode are identical, meaning we're receiving the encode string unchanged. I've also compared the pre-encode string length on the server to the decode string length immediately after the base64.decodestring in the client, and they aren't the same in about a third of my test documents. Of course, the received file contents (the calling object of "getFile" does a write to the local filesystem) are corrupt and unusable. I've done a compare of the original files and the corrupted ones in a hex editor, and in every case the corrupted file simply stops somewhere in the middle. There doesn't appear to be a set length that it fails at, since the received corrupted files vary in byte size from ~80KB to ~120KB. Larger files have also come through unchanged. The files that get truncated are MS PowerPoint and Adobe PDF, which are the bulk of what this site will contain (of course!). Some PowerPoint and PDF files come through just fine, and I've been unable to determine what the difference is between the files that work and the ones that don't. If anyone can make any suggestions, I'd be extremely grateful! From fredrik at pythonware.com Wed Feb 21 21:45:01 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Feb 2001 20:45:01 GMT Subject: base64.decodestring or xmlrpc (in zope) is truncating strings References: Message-ID: Craig Dunigan wrote: > meta_type = fileObject.meta_type > if meta_type == 'DTML Document': > return ("OK", base64.encodestring(fileObject.document_src())) > elif meta_type == 'File': > return ("OK", base64.encodestring(fileObject.data)) > elif meta_type == 'Image': > return ("OK", base64.encodestring(fileObject.data)) > else: > return ("FAIL", 'Unsupported meta_type') xmlrpc usage note: instead of encoding and decoding yourself, you can use the xmlrpclib.Binary wrapper: if meta_type == 'DTML Document': return ("OK", xmlrpclib.Binary(fileObject.document_src()) elif meta_type in ('File', 'Image'): return ("OK", xmlrpclib.Binary(fileObject.data)) else: return ("FAIL", 'Unsupported meta_type') the receiver gets a Binary object as well, and can pick out the original string from the data attribute: if retval[0] == "OK": return retval[1].data > the calling object of "getFile" does a write to the local filesystem ...which usually means that you forgot to open the file in binary mode: file = open(filename, "w") # open in text mode file = open(filename, "wb") # open in binary mode Cheers /F From faraway at mhtc.net Wed Feb 21 22:42:12 2001 From: faraway at mhtc.net (Craig Dunigan) Date: Wed, 21 Feb 2001 15:42:12 -0600 Subject: base64.decodestring or xmlrpc (in zope) is truncating strings References: Message-ID: "Fredrik Lundh" wrote in message news:hNVk6.14872$Qb7.2374586 at newsb.telia.net... > Craig Dunigan wrote: > > meta_type = fileObject.meta_type > > if meta_type == 'DTML Document': > > return ("OK", base64.encodestring(fileObject.document_src())) > > elif meta_type == 'File': > > return ("OK", base64.encodestring(fileObject.data)) > > elif meta_type == 'Image': > > return ("OK", base64.encodestring(fileObject.data)) > > else: > > return ("FAIL", 'Unsupported meta_type') > > xmlrpc usage note: instead of encoding and decoding yourself, > you can use the xmlrpclib.Binary wrapper: > if meta_type == 'DTML Document': > return ("OK", xmlrpclib.Binary(fileObject.document_src()) > elif meta_type in ('File', 'Image'): > return ("OK", xmlrpclib.Binary(fileObject.data)) > else: > return ("FAIL", 'Unsupported meta_type') > > the receiver gets a Binary object as well, and can pick out > the original string from the data attribute: > > if retval[0] == "OK": > return retval[1].data > I wasn't familiar with this, I'll look into it. It may resolve the problem. > > the calling object of "getFile" does a write to the local filesystem > > ...which usually means that you forgot to open the file in > binary mode: Often true, but not in this case. And, as I noted in my original post, I can verify that the decoded string isn't the right length before it even gets passed to the calling object. Anyway, the writing object code is: def addFile(self, pathSpec, fileName, contents, timeStamp, title, description): fullFileSpec = os.path.join(pathSpec, fileName) file = open(fullFileSpec, "wb") file.write(contents) file.close() os.utime(fullFileSpec, (int(timeStamp), int(timeStamp))) "contents" ultimately gets passed from the base64 decode, which is wrong before its object ever passes it anywhere. But, thanks for the xmlrpclib tip, I'll test that out. From joonas at olen.to Wed Feb 21 22:38:31 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Wed, 21 Feb 2001 23:38:31 +0200 Subject: Confused about extending. Message-ID: <3A943557.B9893C03@olen.to> I have made the following C-function and now I would like to use it via Python in that way, that it would manipulate Python lists smoothedValues and originalValues. But I am just a beginner with C and I got confused with extending HowTo. I would be glad if someone would explain how to manipulate the code to make it extendingable. Joonas. void SmoothedList(double *originalValues, double *smoothedValues, int listSize, int filterSize) { double tmpResult; int i, j; int iterations = listSize - filterSize + 1; for(i = 0; i < iterations; i++) { for(j = 0, tmpResult = 0.0; j < filterSize; j++) tmpResult += originalValues[i + j]; smoothedValues[i] = tmpResult / (double)filterSize; } } From chris.gonnerman at usa.net Thu Feb 22 06:02:45 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Wed, 21 Feb 2001 23:02:45 -0600 Subject: Confused about extending. References: <3A943557.B9893C03@olen.to> Message-ID: <018b01c09c8c$ba95ae20$a100000a@local> ----- Original Message ----- From: "Joonas Paalasmaa" Subject: Confused about extending. > I have made the following C-function and now I would like to > use it via Python in that way, that it would > manipulate Python lists smoothedValues and originalValues. > But I am just a beginner with C and I got confused with extending HowTo. > I would be glad if someone would explain how to manipulate the code to > make it extendingable. > > Joonas. I'm puzzled as to why you have implemented this function in C instead of Python. Is it for speed? Just how big ARE your lists? > void SmoothedList(double *originalValues, double *smoothedValues, > int listSize, int filterSize) > { > double tmpResult; > int i, j; > int iterations = listSize - filterSize + 1; > > for(i = 0; i < iterations; i++) > { > for(j = 0, tmpResult = 0.0; j < filterSize; j++) > tmpResult += originalValues[i + j]; > smoothedValues[i] = tmpResult / (double)filterSize; > } > } def SmoothedList(originalValues, smoothedValues, listSize, filterSize) iterations = listSize - filterSize + 1; for i in range(0,iterations): tmpResult = 0.0 for j in range(0, filterSize): tmpResult = tmpResult + originalValues[i + j] smoothedValues[i] = tmpResult / filterSize ------------------------------------ Have I missed something here? From djc at object-craft.com.au Thu Feb 22 11:58:33 2001 From: djc at object-craft.com.au (Dave Cole) Date: 22 Feb 2001 21:58:33 +1100 Subject: Confused about extending. References: <3A943557.B9893C03@olen.to> Message-ID: >>>>> "Joonas" == Joonas Paalasmaa writes: Joonas> I have made the following C-function and now I would like to Joonas> use it via Python in that way, that it would manipulate Python Joonas> lists smoothedValues and originalValues. But I am just a Joonas> beginner with C and I got confused with extending HowTo. I Joonas> would be glad if someone would explain how to manipulate the Joonas> code to make it extendingable. I am not sure if you are asking the question that I am answering, but I recently posted a small extension module which has processing which is quite similar to what you would need to do in a C extension. Look back a couple of days for the thread: Re: Optimisation problem - in C? - Dave -- http://www.object-craft.com.au From joonas at olen.to Thu Feb 22 14:44:59 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Thu, 22 Feb 2001 15:44:59 +0200 Subject: Confused about extending. References: <3A943557.B9893C03@olen.to> Message-ID: <3A9517DB.8000501@olen.to> >> I have made the following C-function and now I would like to >> use it via Python in that way, that it would >> manipulate Python lists smoothedValues and originalValues. >> But I am just a beginner with C and I got confused with extending HowTo. >> I would be glad if someone would explain how to manipulate the code to >> make it extendingable. >> >> Joonas. > > > I'm puzzled as to why you have implemented this function in C instead of > Python. Is it for > speed? Just how big ARE your lists? My lists are big so that is the reason why I have to make the processing with C. But the frontend must be Python and C-module would be used from Python. For example: ############## import cListprocessor list = [1,2,3,4,5,6,7,8,9,15,9,8,7,6,5,4,3,2,1] processedList = cListprocessor.SmoothedList(list) ############## - Joonas Paalasmaa >> void SmoothedList(double *originalValues, double *smoothedValues, >> int listSize, int filterSize) >> { >> double tmpResult; >> int i, j; >> int iterations = listSize - filterSize + 1; >> >> for(i = 0; i < iterations; i++) >> { >> for(j = 0, tmpResult = 0.0; j < filterSize; j++) >> tmpResult += originalValues[i + j]; >> smoothedValues[i] = tmpResult / (double)filterSize; >> } >> } > > > def SmoothedList(originalValues, smoothedValues, listSize, filterSize) > iterations = listSize - filterSize + 1; > for i in range(0,iterations): > tmpResult = 0.0 > for j in range(0, filterSize): > tmpResult = tmpResult + originalValues[i + j] > smoothedValues[i] = tmpResult / filterSize > > ------------------------------------ > Have I missed something here? From chris.gonnerman at usa.net Sat Feb 24 15:30:13 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sat, 24 Feb 2001 08:30:13 -0600 Subject: Confused about extending. (SOLVED) References: <3A943557.B9893C03@olen.to> <3A9517DB.8000501@olen.to> <016801c09d53$5f023340$a100000a@local> <3A96CDD1.7AF41654@olen.to> Message-ID: <004701c09e6e$5216f000$a100000a@local> Joonas: Attached are source files smoothing.c (the Python C module source), Smoothing.py (the testrig), and joonas.cpp (your source code, marked up by me). I am posting this to the list also as the code might be instructive, and also in the hopes that if I have made any mistakes someone else might notice them. Read the markup in joonas.cpp; I think you have a logic error in your function, as the last two values in the result list are never assigned by the smoothing function but you print them out as if you expect the values to be meaningful. (The number of values left unassigned appears to be filterSize - 1). The marked-up joonas.cpp (which initializes smoothedList to all zeros) produces the same values as Smoothing.py with the smoothing.so module, so I assume my code is correct. I have been getting a headache reading the Python C API document. IMHO the question of whether or not the *_SetItem functions "steal" the reference I give them or not should be explained at least briefly in the descriptive text of the function itself. I don't THINK I am leaking references (and/or memory) in the smoothing.c code but an expert might be kind enough to double check for me. Anyway, here they are. You will need to find the Makefile.pre.in file for your version of Python, put it in the folder with these files, and do: make -f Makefile.pre.in boot make Makefile.pre.in is in /usr/lib/python1.5/config, but your mileage may vary. If everything is cool you will wind up with smoothing.so (and a lot of other junk you don't really need). Look in Smoothing.py for an example of use. -------------- next part -------------- A non-text attachment was scrubbed... Name: joonas.cpp Type: application/octet-stream Size: 1213 bytes Desc: not available URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: smoothing.c URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Smoothing.py URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Setup.in Type: application/octet-stream Size: 31 bytes Desc: not available URL: From s713221 at student.gu.edu.au Wed Feb 21 22:59:33 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Thu, 22 Feb 2001 07:59:33 +1000 Subject: How does Subclassing Work? Message-ID: <3A943A45.2E433767@student.gu.edu.au> Recently I tried to write a piece of code that subclassed Canvas.py from the Tkinter distribution, where I overwrote CanvasItem. Now I was hoping that all calls to Arc, Line etc. (which weren't overwritten) would call my modified CanvasItem, but it seems they were calling the unmodified CanvasItem - which isn't what I wanted. What I wanted was: My module ______> calls CanvasItem | Canvas.py Arc CanvasItem What I got was: My module CanvasItem Canvas.py Arc _______> calls CanvasItem Other than copy all of Canvas.py into my module and redefine everything, is there a way I can get this to work as expected without rewriting Canvas.py? What I was trying to do was alter Canvas so that I could create classes that would make complex items. Joal Heagney/AncientHart From aleaxit at yahoo.com Thu Feb 22 11:36:12 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 22 Feb 2001 11:36:12 +0100 Subject: How does Subclassing Work? References: <3A943A45.2E433767@student.gu.edu.au> Message-ID: <972q2u0ool@news2.newsguy.com> wrote in message news:3A943A45.2E433767 at student.gu.edu.au... > Recently I tried to write a piece of code that subclassed Canvas.py from > the Tkinter distribution, where I overwrote CanvasItem. Now I was hoping > that all calls to Arc, Line etc. (which weren't overwritten) would call > my modified CanvasItem, but it seems they were calling the unmodified > CanvasItem - which isn't what I wanted. It's what I would expect, though; the 'class' statement for (e.g.) Arc was already executed, right when you imported Canvas, and, at that time, it got the original CanvasItem class to use as the base -- it didn't get your subclassed version. > Other than copy all of Canvas.py into my module and redefine everything, > is there a way I can get this to work as expected without rewriting > Canvas.py? What I was trying to do was alter Canvas so that I could > create classes that would make complex items. I hesitate to suggest it, but... if you went through all the classes of interest, currently set to inherit from the original CanvasItem, and changed that portion of their __bases__ to your modified version; and also set the CanvasItem attribute of the Canvas module to refer to your modified version; things would probably work as you want. Here's a toy example to indicate what I mean...: == Original.py class OriginalItem: def __init__(self, *whatever): print "OriginalItem",whatever class Derived1(OriginalItem): def __init__(self, *whatever): print "Derived1",whatever apply(OriginalItem.__init__, (self,)+whatever) class Derived2(OriginalItem): def __init__(self, *whatever): print "Derived2",whatever apply(OriginalItem.__init__, (self,)+whatever) == end == Tweak.py import Original baseClass = Original.OriginalItem class TweakedItem(baseClass): def __init__(self, *whatever): print "TweakedItem",whatever for key,val in Original.__dict__.items(): if type(val)==type(baseClass): if val is baseClass: setattr(Original, key, TweakedItem) else: if val.__bases__ == (baseClass,): val.__bases__ = (TweakedItem,) x = Original.Derived1("foo","bar") y = Original.Derived2("bar","baz") == end This is not very general (though it would suffice for your specific need), as it only handles single-base classes etc, but it's not hard to generalize it along this axis. I do wonder about the appropriateness of such "black magick" to actual production code, though. Alex From s713221 at student.gu.edu.au Fri Feb 23 02:45:31 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Fri, 23 Feb 2001 11:45:31 +1000 Subject: How does Subclassing Work? References: <3A943A45.2E433767@student.gu.edu.au> <972q2u0ool@news2.newsguy.com> Message-ID: <3A95C0BB.E3DE90E2@student.gu.edu.au> Alex Martelli wrote: > > wrote in message > news:3A943A45.2E433767 at student.gu.edu.au... > > Recently I tried to write a piece of code that subclassed Canvas.py from > > the Tkinter distribution, where I overwrote CanvasItem. Now I was hoping > > that all calls to Arc, Line etc. (which weren't overwritten) would call > > my modified CanvasItem, but it seems they were calling the unmodified > > CanvasItem - which isn't what I wanted. > > It's what I would expect, though; the 'class' statement for (e.g.) > Arc was already executed, right when you imported Canvas, and, > at that time, it got the original CanvasItem class to use as the > base -- it didn't get your subclassed version. > > > Other than copy all of Canvas.py into my module and redefine everything, > > is there a way I can get this to work as expected without rewriting > > Canvas.py? What I was trying to do was alter Canvas so that I could > > create classes that would make complex items. > > I hesitate to suggest it, but... if you went through all the classes > of interest, currently set to inherit from the original CanvasItem, > and changed that portion of their __bases__ to your modified version; > and also set the CanvasItem attribute of the Canvas module to refer > to your modified version; things would probably work as you want. > > Here's a toy example to indicate what I mean...: > > == Original.py > class OriginalItem: > def __init__(self, *whatever): > print "OriginalItem",whatever > > class Derived1(OriginalItem): > def __init__(self, *whatever): > print "Derived1",whatever > apply(OriginalItem.__init__, (self,)+whatever) > > class Derived2(OriginalItem): > def __init__(self, *whatever): > print "Derived2",whatever > apply(OriginalItem.__init__, (self,)+whatever) > == end > > == Tweak.py > import Original > > baseClass = Original.OriginalItem > class TweakedItem(baseClass): > def __init__(self, *whatever): > print "TweakedItem",whatever > > for key,val in Original.__dict__.items(): > if type(val)==type(baseClass): > if val is baseClass: > setattr(Original, key, TweakedItem) > else: > if val.__bases__ == (baseClass,): > val.__bases__ = (TweakedItem,) > > x = Original.Derived1("foo","bar") > y = Original.Derived2("bar","baz") > == end > > This is not very general (though it would suffice for > your specific need), as it only handles single-base > classes etc, but it's not hard to generalize it along > this axis. > > I do wonder about the appropriateness of such "black > magick" to actual production code, though. > > Alex To true. Maybe the cut-paste-alter method is better after all. Joal Heagney/AncientHart From joonas at olen.to Wed Feb 21 23:03:31 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Thu, 22 Feb 2001 00:03:31 +0200 Subject: Problems using Grail. Message-ID: <3A943B33.CD618A9B@olen.to> When I tried to start Grail by typing "python grail-0.6\grail.py" Python gave the following error message. Python version is 1.6 and platform is Windows95. What could be the problem? - Joonas Traceback (innermost last): File "C:\Python16\grail-0.6\grail.py", line 499, in ? main() File "C:\Python16\grail-0.6\grail.py", line 108, in main app = Application(prefs=prefs, display=display) File "C:\Python16\grail-0.6\grail.py", line 248, in __init__ self.stylesheet = Stylesheet.Stylesheet(self.prefs) File "C:\Python16\grail-0.6\Stylesheet.py", line 21, in __init__ self.load() File "C:\Python16\grail-0.6\Stylesheet.py", line 45, in load massaged.append((g, c), v % fparms_dict) TypeError: append requires exactly 1 argument; 2 given From grante at visi.com Thu Feb 22 00:51:54 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 21 Feb 2001 23:51:54 GMT Subject: Problems using Grail. References: <3A943B33.CD618A9B@olen.to> Message-ID: In article <3A943B33.CD618A9B at olen.to>, Joonas Paalasmaa wrote: >When I tried to start Grail by typing "python grail-0.6\grail.py" >Python gave the following error message. >Python version is 1.6 and platform is Windows95. >What could be the problem? > >- Joonas > >Traceback (innermost last): > File "C:\Python16\grail-0.6\grail.py", line 499, in ? > main() > File "C:\Python16\grail-0.6\grail.py", line 108, in main > app = Application(prefs=prefs, display=display) > File "C:\Python16\grail-0.6\grail.py", line 248, in __init__ > self.stylesheet = Stylesheet.Stylesheet(self.prefs) > File "C:\Python16\grail-0.6\Stylesheet.py", line 21, in __init__ > self.load() > File "C:\Python16\grail-0.6\Stylesheet.py", line 45, in load > massaged.append((g, c), v % fparms_dict) >TypeError: append requires exactly 1 argument; 2 given Grail is pretty old, and there have been language changes in 1.6 and later that are causing problems. The append() method for lists has changed: 1.5.2: >>> print x [1, 2, 3, 4] >>> x.append(5,6,7) >>> print x [1, 2, 3, 4, (5, 6, 7)] Newsgroups: comp.lang.python Subject: Re: Problems using Grail. References: <3A943B33.CD618A9B at olen.to> Organization: Vector Internet Services, Inc. Followup-To: In article <3A943B33.CD618A9B at olen.to>, Joonas Paalasmaa wrote: >When I tried to start Grail by typing "python grail-0.6\grail.py" >Python gave the following error message. >Python version is 1.6 and platform is Windows95. >What could be the problem? > >- Joonas > >Traceback (innermost last): > File "C:\Python16\grail-0.6\grail.py", line 499, in ? > main() > File "C:\Python16\grail-0.6\grail.py", line 108, in main > app = Application(prefs=prefs, display=display) > File "C:\Python16\grail-0.6\grail.py", line 248, in __init__ > self.stylesheet = Stylesheet.Stylesheet(self.prefs) > File "C:\Python16\grail-0.6\Stylesheet.py", line 21, in __init__ > self.load() > File "C:\Python16\grail-0.6\Stylesheet.py", line 45, in load > massaged.append((g, c), v % fparms_dict) >TypeError: append requires exactly 1 argument; 2 given Grail is pretty old, and there have been language changes in 1.6 and later that are causing problems. (I never got Grail to run under 1.5.2 either.) In your example, it's the append() method for lists has changed: Python 1.5.2: >>> print x [1, 2, 3, 4] >>> x.append(5,6,7) >>> print x [1, 2, 3, 4, (5, 6, 7)] python 2.0 >>> print x [1, 2, 3, 4] >>> x.append(5,6,7) Traceback (most recent call last): File "", line 1, in ? TypeError: append requires exactly 1 argument; 3 given >>> x.append((5,6,7)) >>> print x [1, 2, 3, 4, (5, 6, 7)] -- Grant Edwards grante Yow! ... I want a COLOR at T.V. and a VIBRATING BED!!! visi.com From hamish_lawson at yahoo.co.uk Thu Feb 22 10:22:46 2001 From: hamish_lawson at yahoo.co.uk (hamish_lawson at yahoo.co.uk) Date: Thu, 22 Feb 2001 09:22:46 -0000 Subject: Problems using Grail. In-Reply-To: <3A943B33.CD618A9B@olen.to> Message-ID: <972lp6+iiqq@eGroups.com> Joonas Paalasmaa wrote: > When I tried to start Grail by typing "python grail-0.6\grail.py" > Python gave the following error message. > File "C:\Python16\grail-0.6\Stylesheet.py", line 45, in load > massaged.append((g, c), v % fparms_dict) > TypeError: append requires exactly 1 argument; 2 given The append() call is officially meant to take one argument, but in versions of Python before 1.6, multiple arguments would be understood as comprising a tuple. However this behaviour was never officially documented or approved, and was dropped in Python 1.6 to bring the actual behaviour in line with the official documentation. This line of code will therefore need to be modified to use an explicit tuple in the append argument: massaged.append(((g, c), v % fparms_dict)) Hamish Lawson From costas at springmail.com Wed Feb 21 23:08:38 2001 From: costas at springmail.com (costas at springmail.com) Date: Wed, 21 Feb 2001 22:08:38 GMT Subject: import statement is case sensitive Message-ID: <3a943bea.525315589@News.CIS.DFN.DE> Is there anyway to make the import statement NOT case sensitive? sometimes directory names are in mixed case or different case from the import statment. Also what is the purpose of even having it case sensitive. I've yet to see a file system that has case sensitive filenames.... costas From fredrik at pythonware.com Wed Feb 21 23:20:13 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Feb 2001 22:20:13 GMT Subject: import statement is case sensitive References: <3a943bea.525315589@News.CIS.DFN.DE> Message-ID: Costas wrote: > Is there anyway to make the import statement NOT case sensitive? > sometimes directory names are in mixed case or different case from the > import statment. try: > python -h and read the help text. or read this article: http://python.sourceforge.net/peps/pep-0235.html or rename the directories; even if your operating system is case-insensitive, it's probably not case ignorant. > Also what is the purpose of even having it case sensitive. I've yet to > see a file system that has case sensitive filenames.... time to get a real operating systems? ;-) Cheers /F From costas at meezon.com Thu Feb 22 04:31:39 2001 From: costas at meezon.com (Costas Menico) Date: Thu, 22 Feb 2001 03:31:39 GMT Subject: import statement is case sensitive References: <3a943bea.525315589@News.CIS.DFN.DE> Message-ID: <3a94846a.3272811@News.CIS.DFN.DE> Interesting article. However the PYTHONCASEOK as suggested in the article does not seem to work. I set it to PYTHONCASEOK = 1 and import still insists on being case-sensitive. Also python -h has nothing helpful in this respect. Any other ideas barring changing OS and renaming directories would be appreciated. Thanks Costas >Costas wrote: >> Is there anyway to make the import statement NOT case sensitive? >> sometimes directory names are in mixed case or different case from the >> import statment. > >try: > > > python -h > >and read the help text. > >or read this article: > > http://python.sourceforge.net/peps/pep-0235.html > >or rename the directories; even if your operating system is >case-insensitive, it's probably not case ignorant. > >> Also what is the purpose of even having it case sensitive. I've yet to >> see a file system that has case sensitive filenames.... > >time to get a real operating systems? ;-) > >Cheers /F > > From ljohnson at resgen.com Thu Feb 22 00:05:31 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Wed, 21 Feb 2001 17:05:31 -0600 Subject: import statement is case sensitive References: <3a943bea.525315589@News.CIS.DFN.DE> Message-ID: > Also what is the purpose of even having it case sensitive. I've yet to > see a file system that has case sensitive filenames.... There is an operating system called "Unix" that has case-sensitive file names. There is a slight chance that others on this newsgroup have also heard of this obscure operating system. From costas at meezon.com Thu Feb 22 03:58:29 2001 From: costas at meezon.com (Costas Menico) Date: Thu, 22 Feb 2001 02:58:29 GMT Subject: import statement is case sensitive References: <3a943bea.525315589@News.CIS.DFN.DE> Message-ID: <3a947ac4.802440@News.CIS.DFN.DE> "Lyle Johnson" wrote: >> Also what is the purpose of even having it case sensitive. I've yet to >> see a file system that has case sensitive filenames.... > >There is an operating system called "Unix" that has case-sensitive file >names. There is a slight chance that others on this newsgroup have also >heard of this obscure operating system. > Well given the fact that Linux and Windows is beating it to death I can see why Unix is becoming obscure :) Actually I would consider this a shortcoming of Unix. Shipping a product that depends on the directory names and files being in the right case must cause all sorts of headaches. I am trying to run an an application under Windows and now I have to worry if my directory name is in the correct case. I use PythonWin (a fantastic product) to run and test it. There is no option for telling it to ignore the case of the import filenames that I could see. And renaming directories and files is not an easy option.. But anyway, this is should automatically be handled in Python depending on the OS. Why would asnyone make the same filenames with different cases? Is there a good use? From aleaxit at yahoo.com Thu Feb 22 09:56:06 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 22 Feb 2001 09:56:06 +0100 Subject: import statement is case sensitive References: <3a943bea.525315589@News.CIS.DFN.DE> <3a947ac4.802440@News.CIS.DFN.DE> Message-ID: <972k770ik7@news2.newsguy.com> "Costas Menico" wrote in message news:3a947ac4.802440 at News.CIS.DFN.DE... > "Lyle Johnson" wrote: > > >> Also what is the purpose of even having it case sensitive. I've yet to > >> see a file system that has case sensitive filenames.... > > > >There is an operating system called "Unix" that has case-sensitive file > >names. There is a slight chance that others on this newsgroup have also > >heard of this obscure operating system. > > Well given the fact that Linux and Windows is beating it to death I > can see why Unix is becoming obscure :) Linux is identical to Unix in this respect (and in most others; it IS a version of Unix in all respects except trademarks &c). > Actually I would consider this a shortcoming of Unix. Shipping a > product that depends on the directory names and files being in the > right case must cause all sorts of headaches. Debatable, although I would tend to agree. Internationalization issues make "case-insensitive" a big problem, though -- the uppercase equivalent of, say, "e with an acute accent", depends so much on the character-encoding in use. I consider it a similar bug (and Windows and Mac share it with Unix) to allow spaces, tabs, and other whitespace characters in filenames, by the way. The driving idea behind all such things is, I guess, to make it possible for the user to name his or her file as he/she wants, with entire sentences, etc; I do NOT like this, I'd rather see filenames as "identifiers" for the files. But I guess this marks me as a dinosaur, once again. > And renaming directories and files is not an easy option.. But anyway, > this is should automatically be handled in Python depending on the OS. In Windows, you cannot _directly_ rename a file or directory to change its case (a Windows bug, I'd say); you have to rename Foo tempname rename tempname foo because trying to directly do rename Foo foo will fail. It _would_ definitely be easier for the user if Python 'knew' a given filesystem is case-insensitive and compensated for that. > Why would asnyone make the same filenames with different cases? Is > there a good use? There are a few uses (e.g., some C++ compilers take xx.c as a file in the C languace, xx.C as one in the C++ language) but I would not, personally, call them "good". Alex From qrczak at knm.org.pl Thu Feb 22 17:39:21 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 22 Feb 2001 16:39:21 GMT Subject: import statement is case sensitive References: <3a943bea.525315589@News.CIS.DFN.DE> <3a947ac4.802440@News.CIS.DFN.DE> <972k770ik7@news2.newsguy.com> Message-ID: Thu, 22 Feb 2001 09:56:06 +0100, Alex Martelli pisze: > I consider it a similar bug (and Windows and Mac share it with Unix) > to allow spaces, tabs, and other whitespace characters in filenames, > by the way. The driving idea behind all such things is, I guess, > to make it possible for the user to name his or her file as he/she > wants, with entire sentences, etc; I do NOT like this, I'd rather > see filenames as "identifiers" for the files. Actually the Unix tradition is to use mostly identifier-like filenames, despite the fact that all characters but '\0' and '/' are legal, and that filenames can be passed to programs intact (command line arguments are physically passed separately, not split by applications themselves as in DOS/Windows, and quoting filenames with spaces is only the shell's business). Since Windows "invented" long filenames in 1995 with a new set of rules which characters are legal and lots of backwards compatibility headaches wrt. charsets and case in short and long filenames, in practice it and its programs really make use of spaces and other characters in filenames. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From tim.one at home.com Thu Feb 22 23:33:29 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 22 Feb 2001 17:33:29 -0500 Subject: import statement is case sensitive In-Reply-To: <972k770ik7@news2.newsguy.com> Message-ID: [Alex Martelli] > ... > In Windows, you cannot _directly_ rename a file or directory > to change its case (a Windows bug, I'd say); you have to > rename Foo tempname > rename tempname foo > because trying to directly do > rename Foo foo > will fail. Here under Win98SE: >dir/b fo* >md Foo >dir/b fo* Foo >ren Foo foo >dir/b fo* foo >rd foo >echo blah > FOO >dir/b fo* FOO >ren FOO fOo >dir/b fo* fOo > So, works fine for me, whether it's a directory or a file. Certainly possible that this varies across Windows flavors. From db3l at fitlinxx.com Sat Feb 24 01:26:12 2001 From: db3l at fitlinxx.com (David Bolen) Date: 23 Feb 2001 19:26:12 -0500 Subject: import statement is case sensitive References: <3a943bea.525315589@News.CIS.DFN.DE> <3a947ac4.802440@News.CIS.DFN.DE> <972k770ik7@news2.newsguy.com> Message-ID: "Alex Martelli" writes: > In Windows, you cannot _directly_ rename a file or directory > to change its case (a Windows bug, I'd say); you have to > rename Foo tempname > rename tempname foo > because trying to directly do > rename Foo foo > will fail. Actually, I think that depends on filesystem (and perhaps OS). On my NT4 system with NTFS I can rename just to change case without a problem. But I'm pretty sure it fails on a FAT filesystem since at some level in the directory structure the name is uppercase in either 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 chris.gonnerman at usa.net Thu Feb 22 14:49:58 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Thu, 22 Feb 2001 07:49:58 -0600 Subject: import statement is case sensitive References: <3a943bea.525315589@News.CIS.DFN.DE> <3a947ac4.802440@News.CIS.DFN.DE> Message-ID: <002b01c09cd6$59c522c0$a100000a@local> ----- Original Message ----- From: "Costas Menico" Subject: Re: import statement is case sensitive > Actually I would consider this a shortcoming of Unix. Shipping a > product that depends on the directory names and files being in the > right case must cause all sorts of headaches. Not really. You are forgetting that the difficulty in getting file and directory names in the right case in Windows simply doesn't trouble Unixoid OS's. > I am trying to run an an application under Windows and now I have to > worry if my directory name is in the correct case. I use PythonWin (a > fantastic product) to run and test it. There is no option for telling > it to ignore the case of the import filenames that I could see. When you save files in PythonWin it understands it must get the case right, so I'd be surprised if you type them right if it doesn't save them right. > And renaming directories and files is not an easy option.. But anyway, > this is should automatically be handled in Python depending on the OS. I use MinGW32 tools on my computer; others like CygWin. Both provide Unix-like commands for the Windows environment, and either will make your problems easier to handle. > Why would asnyone make the same filenames with different cases? Is > there a good use? I don't know if it is a GOOD use, but the Python GTK bindings do that with a module named gtk.py and one named GTK.py (the first is the binding module, the second is it's constants) and this causes problems on Windows. The most common port of this code to Windows renames the second file GTKconst.py, to avoid the name collision. Anyway, many of the standard modules are named in mixed case. Windows may be the most popular desktop OS in the world, but in the realm of open-source development it's often considered a (broken) niche environment. From mikael at isy.liu.se Thu Feb 22 14:50:18 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Thu, 22 Feb 2001 14:50:18 +0100 (MET) Subject: import statement is case sensitive In-Reply-To: <3a947ac4.802440@News.CIS.DFN.DE> Message-ID: On 22-Feb-01 Costas Menico wrote: > Actually I would consider this a shortcoming of Unix. Shipping a > product that depends on the directory names and files being in the > right case must cause all sorts of headaches. Perhaps so, but... I'm still upset over the fact that my Windows box at home doesn't allow me to call a directory "FTP", but changes that to "Ftp" as soon as I hit return. Perhaps there is some setting that I can change, but as a default setting it sucks, IMO. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 22-Feb-01 Time: 14:45:38 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From aleaxit at yahoo.com Thu Feb 22 18:00:16 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 22 Feb 2001 18:00:16 +0100 Subject: import statement is case sensitive References: Message-ID: <973gis01f0u@news2.newsguy.com> "Mikael Olofsson" wrote in message news:XFMail.010222145018.mikael at isy.liu.se... On 22-Feb-01 Costas Menico wrote: > Actually I would consider this a shortcoming of Unix. Shipping a > product that depends on the directory names and files being in the > right case must cause all sorts of headaches. Perhaps so, but... I'm still upset over the fact that my Windows box at home doesn't allow me to call a directory "FTP", but changes that to "Ftp" as soon as I hit return. Perhaps there is some setting that I can change, but as a default setting it sucks, IMO. I suspect your Windows box DOES allow what you say it doesn't -- what may currently disallow creation (or display of) all-uppercase names is more likely to be the shell GUI front-end (and, yes, it IS just a checkbox you can turn off somewhere). To check this, use any method whatsoever _except_ the shell GUI front-ends to create and display your all-uppercase names (e.g., a "Command Prompt" aka "DOS Box" should do). If, as I believe, this will work just fine, then maybe you'll see it's not "the Windows box" that you're railing against here, just a specific cosmetic choice of its shell GUI front-end. Alex From ben.hutchings at roundpoint.com Fri Feb 23 01:46:34 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 22 Feb 2001 16:46:34 -0800 Subject: import statement is case sensitive References: <973gis01f0u@news2.newsguy.com> Message-ID: "Alex Martelli" writes: > "Mikael Olofsson" wrote in message > news:XFMail.010222145018.mikael at isy.liu.se... > > > > On 22-Feb-01 Costas Menico wrote: > > > Actually I would consider this a shortcoming of Unix. Shipping a > > > product that depends on the directory names and files being in the > > > right case must cause all sorts of headaches. > > > > Perhaps so, but... > > > > I'm still upset over the fact that my Windows box at home doesn't allow > > me to call a directory "FTP", but changes that to "Ftp" as soon as I > > hit return. Perhaps there is some setting that I can change, but as a > > default setting it sucks, IMO. > > > I suspect your Windows box DOES allow what you say it doesn't -- > what may currently disallow creation (or display of) all-uppercase > names is more likely to be the shell GUI front-end (and, yes, it > IS just a checkbox you can turn off somewhere). Correct. Windows Explorer (or the underlying folder viewing widget) does this to any file that doesn't have a "long filename" distinct from its DOS-compatible file name, but at least some implementations of the VFAT file-system do not store a separate "long filename" if the chosen name is already DOS-compatible. A file named, for example "CAPITALS WITH SPACES" will have that stored as its "long filename" and something like "CAPITA~1" for DOS compatibility. Its name will be displayed correctly. A file named "CAPITALS" will have just that DOS-compatible name stored, and will be displayed as "Capitals" by default. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From tim.one at home.com Thu Feb 22 23:18:55 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 22 Feb 2001 17:18:55 -0500 Subject: import statement is case sensitive In-Reply-To: Message-ID: [Mikael Olofsson] > I'm still upset over the fact that my Windows box at home doesn't allow > me to call a directory "FTP", but changes that to "Ftp" as soon as I > hit return. Perhaps there is some setting that I can change, but as a > default setting it sucks, IMO. Start -> Settings -> Folder Options ... -> View then check "Allow all uppercase names". You'll probably be sorry you did this, though (it makes stuff considerably harder to read, IMO). Note that this has no effect on the filename actually stored, it only affects how ALLCAPS names get *displayed*, and even so just how Explorer displays them. As long as you're there, check "Display the full path in title bar", uncheck "Hide file extensions for known file types" and select "Show all files" under "Hidden files" (some of these are named a little differently under different flavors of Windows). The default settings are optimized for end users, not developers. And like it or not, they probably picked the best default values for end users in all respects. pure-end-users-don't-care-about-the-same-things-you-do-ly y'rs - tim From tanzer at swing.co.at Fri Feb 23 08:11:58 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Fri, 23 Feb 2001 08:11:58 +0100 Subject: import statement is case sensitive In-Reply-To: Your message of "Thu, 22 Feb 2001 17:18:55 EST." Message-ID: "Tim Peters" wrote: > The default settings are optimized for end users, not developers. And > like it or not, they probably picked the best default values for end > users in all respects. > > pure-end-users-don't-care-about-the-same-things-you-do-ly y'rs - tim In all respects but "safety" against social engineering by viruses traveling under `.TXT.vbs' extensions . PS: I'll readily admit that it might not matter much whether the `.vbs' of ILOVEYOU is shown or not. -- 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 mikael at isy.liu.se Fri Feb 23 10:28:43 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 23 Feb 2001 10:28:43 +0100 (MET) Subject: import statement is case sensitive In-Reply-To: Message-ID: On 22-Feb-01 Tim Peters wrote: > [Mikael Olofsson] > > I'm still upset over the fact that my Windows box at home doesn't allow > > me to call a directory "FTP", but changes that to "Ftp" as soon as I > > hit return. Perhaps there is some setting that I can change, but as a > > default setting it sucks, IMO. > > Start -> Settings -> Folder Options ... -> View > > [snip details] Thanks, I knew there was a way. > pure-end-users-don't-care-about-the-same-things-you-do-ly y'rs - tim In this case, I consider myself an end user. I'm just brought up with Unices and old Macs. None of those change things for me (as an end user) without asking (at least I haven't notised any such cases). Today's M$ software (probably on Mac aswell as on Windows), however, always have default settings that automates everything that I do not want to have automated. You have probably tried M$ Word with all its default settings. It's like a freakin' disco. Hell, I want my computer to do what I tell it to do. If something is to be automated I want it to be automated only when and if I say so. Sigh, I probably should change to Linux... or dump my computer... I still have my typewriter and my slide-rule somewhere When will there be a computer that allows me to sit down and just do my work? Not start applications, change file formats to comply with other applications or other versions of the same application, change OS settings just because I need a certain application (read: help my kids start games that only works with 256 colors), change stupid default settings, and all that jazz... I-guess-I'm-just-too-old-for-this-ly y'rs /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 23-Feb-01 Time: 09:55:11 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From qrczak at knm.org.pl Thu Feb 22 17:32:01 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 22 Feb 2001 16:32:01 GMT Subject: import statement is case sensitive References: <3a943bea.525315589@News.CIS.DFN.DE> <3a947ac4.802440@News.CIS.DFN.DE> Message-ID: Thu, 22 Feb 2001 02:58:29 GMT, Costas Menico pisze: > Actually I would consider this a shortcoming of Unix. Shipping a > product that depends on the directory names and files being in the > right case must cause all sorts of headaches. Not at all. I never caused me any trouble. Case of filenames doesn't change by accident, as filenames themselves don't change. Why would a directory be in a wrong case?! The reality is that this is Windows which has problems with filenames. Unix has very simple filename rules; Windows has very complicated and poorly implemented rules. Sorry for repeating myself from 16 Feb, but you asked for that: For example when you try to create a directory called Spam, Windows Explorer will create SPAM and display it as Spam. And when asked to create SPAM, it will create it but display Spam. It behaves correctly when the name has more than 8 characters or when a character outside ASCII is used. This is Win95 - I don't know if they fixed this in later versions. Worse: using the Explorer you can create a filename with some non-ASCII characters (e.g. <> or bullet), which will be silently converted to other characters, perhaps different in long and short names (in these cases: '<<' and '>>' character pairs, and '\7' - a control character which displays as bullet in DOS). Details depend on the default codepages (the above is for CP-1250 and CP-852). This can make the file inaccessible under either Windows or DOS or both (because the converted character is sometimes not legal in a filename, but the filename was checked for correctness before conversion). You can't delete or rename such file from either Windows or DOS or both, until you repair the filesystem. Scandisk is not always able to do it. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From tim.one at home.com Thu Feb 22 01:35:13 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 21 Feb 2001 19:35:13 -0500 Subject: import statement is case sensitive In-Reply-To: <3a943bea.525315589@News.CIS.DFN.DE> Message-ID: > Is there anyway to make the import statement NOT case sensitive? Assuming you're running some flavor of Windows, do set PYTHONCASEOK=1 at a DOS prompt, autoexec.bat, or under NT/2000 use the Control Panel -> System thingie. From costas at meezon.com Thu Feb 22 20:51:17 2001 From: costas at meezon.com (Costas Menico) Date: Thu, 22 Feb 2001 19:51:17 GMT Subject: import statement is case sensitive References: <3a943bea.525315589@News.CIS.DFN.DE> Message-ID: <3a956af6.17279998@news.cis.dfn.de> Just wanted to let you know what I have found so far using Python under Windows/DOS. 1) I can get PythonWin import to be case-insensitive but only if I do an os.environ["PYTHONCASEOK"]="1" before the import (but after I import os in the correct case :) 2) I tried setting it at the DOS prompt (SET PYTHONCASEOK=1) but python.exe seems to ignore it. 3) You can set View/Folder Options/View in Windows Explorer to allow all upper case filenames. But it really looks screwed up since many directories are in upper case. Very difficult to read. 4) python -h scrolls off the screen and there is no way to either redirect the output nor pipe it to MORE.EXE.I had to find the help in the book. The original problem i was faced had to do with mxODBC. He imports from ODBC (upper case) directories in his sample code. I know I can change his code but I this is the stuff that comes back to bite.. Anyway I found a solution around the case issue and for now I have to deal with Tkinter and not working with PythonWin. Works with python.exe. Does anyone have ideas why it doesnt work? Thanks for the help Costas Menico From tim.one at home.com Thu Feb 22 23:27:11 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 22 Feb 2001 17:27:11 -0500 Subject: import statement is case sensitive In-Reply-To: <3a956af6.17279998@news.cis.dfn.de> Message-ID: [Costas Menico] > Just wanted to let you know what I have found so far using Python > under Windows/DOS. > > 1) I can get PythonWin import to be case-insensitive but only if I do > an os.environ["PYTHONCASEOK"]="1" before the import (but after I > import os in the correct case :) > > 2) I tried setting it at the DOS prompt (SET PYTHONCASEOK=1) but > python.exe seems to ignore it. Then you're not doing it correctly. Explain every step in detail, else nobody can guess which part you're missing. Setting PYTHONCASEOK in some random DOS box won't have any effect on PythonWin, if that's your complaint. > 3) You can set View/Folder Options/View in Windows Explorer to allow > all upper case filenames. But it really looks screwed up since many > directories are in upper case. Very difficult to read. Note that this option only affects how Explorer *displays* names. It has no effect on how they're stored. BTW, I agree that this option makes things harder to read, and I don't use it myself either. > 4) python -h scrolls off the screen and there is no way to either > redirect the output nor pipe it to MORE.EXE.I had to find the help in > the book. Your DOS box is too small, then. Right-click on the icon you use to launch the DOS box, select Properties, then select the Screen tab, and select "50 lines" from the "Initial size" dropdown list (assuming you're running Win9X; NT/2000 have more flexible options). > The original problem i was faced had to do with mxODBC. He imports > from ODBC (upper case) directories in his sample code. I know I can > change his code but I this is the stuff that comes back to bite.. > > Anyway I found a solution around the case issue and for now I have to > deal with Tkinter and not working with PythonWin. Works with > python.exe. > > Does anyone have ideas why it doesnt work? Sorry, don't know to what "it" refers at this point. From db3l at fitlinxx.com Sat Feb 24 01:34:25 2001 From: db3l at fitlinxx.com (David Bolen) Date: 23 Feb 2001 19:34:25 -0500 Subject: import statement is case sensitive References: <3a943bea.525315589@News.CIS.DFN.DE> <3a956af6.17279998@news.cis.dfn.de> Message-ID: costas at meezon.com (Costas Menico) writes: > 1) I can get PythonWin import to be case-insensitive but only if I do > an os.environ["PYTHONCASEOK"]="1" before the import (but after I > import os in the correct case :) Or just set PYTHONCASEOK in the environment from which you start Pythonwin or your scripts. > 2) I tried setting it at the DOS prompt (SET PYTHONCASEOK=1) but > python.exe seems to ignore it. That should work - are you positive you're running python under that same environment (e.g., you can't set that variable in a DOS prompt, then exit that shell, and restart another to run Python in). > 3) You can set View/Folder Options/View in Windows Explorer to allow > all upper case filenames. But it really looks screwed up since many > directories are in upper case. Very difficult to read. And that's actually what your filesystem contents contains - ugly isn't it? The whole mess with the "pretty" settings in stuff like Explorer is just to hide how badly some of the older filesystem types deal (or don't deal) with case. > 4) python -h scrolls off the screen and there is no way to either > redirect the output nor pipe it to MORE.EXE.I had to find the help in > the book. This is a little tricky - the output goes to stderr rather than stdout (the error output stream) which isn't normally included in your pipe. You could fix this by routing stderr to stdout, as in: python -h 2>&1 | more Of course, the output isn't all that big, so you only miss a few lines. Using something like "mode 80,30" to make a bigger window would work as well. Then again, the help doesn't mention PYTHONCASEOK so it's not going to be too much help in that regard :-) > The original problem i was faced had to do with mxODBC. He imports > from ODBC (upper case) directories in his sample code. I know I can > change his code but I this is the stuff that comes back to bite.. But uppercase is correct - so why would you want to change the imports to lowercase (I'm guessing that's what you are trying?) Note that one source of confusion is the existence of an "odbc.pyd" module in the win32all distributions. You should delete or rename that if you're going to be using mxODBC or you might not get the module you want (or might get a complaint about "import ODBC" if Python finds the win32all "odbc" module first). -- -- 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 jurgen.defurne at philips.com Fri Feb 23 07:57:50 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Fri, 23 Feb 2001 07:57:50 +0100 Subject: import statement is case sensitive Message-ID: <0056900016131369000002L092*@MHS> Welcome to the world in which Bill thinks he is the boss. Jurgen mikael at isy.liu.se@SMTP at python.org on 22/02/2001 15:21:39 Sent by: python-list-admin at python.org To: python-list at python.org@SMTP cc: Subject: Re: import statement is case sensitive Classification: On 22-Feb-01 Costas Menico wrote: > Actually I would consider this a shortcoming of Unix. Shipping a > product that depends on the directory names and files being in the > right case must cause all sorts of headaches. Perhaps so, but... I'm still upset over the fact that my Windows box at home doesn't allow me to call a directory "FTP", but changes that to "Ftp" as soon as I=20 hit return. Perhaps there is some setting that I can change, but as a=20 default setting it sucks, IMO. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael =20 Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 22-Feb-01 Time: 14:45:38 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- -- http://mail.python.org/mailman/listinfo/python-list From sholden at holdenweb.com Wed Feb 28 18:13:51 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 28 Feb 2001 12:13:51 -0500 Subject: import statement is case sensitive References: <3a943bea.525315589@News.CIS.DFN.DE> Message-ID: <5pan6.4921$zL.241848@e420r-atl1.usenetserver.com> wrote in message news:3a943bea.525315589 at News.CIS.DFN.DE... > Is there anyway to make the import statement NOT case sensitive? > sometimes directory names are in mixed case or different case from the > import statment. > > Also what is the purpose of even having it case sensitive. I've yet to > see a file system that has case sensitive filenames.... > You might as well ask what is the purpose of having a filesystem retain the case of filenames, but then ignore the case when looking them up, which is what NT appears to do. Ever had two files in an NT filesystem with names differing only in case? There are circumstances under which this can happen. That's one good reason to assume that the user's case differences are intended to be significant! regards Steve From rob at netzilient.com Wed Feb 21 23:21:04 2001 From: rob at netzilient.com (Rob Eden) Date: Wed, 21 Feb 2001 16:21:04 -0600 Subject: Interrupting blocking reads Message-ID: <3a943dcb@news.advancenet.net> I have an application that is reading from a number of different files (well, external process' output streams to be precise). I need to be able to interrupt the threads, but I don't see a way to do this other than with a signal. The problem is, I want to be able to interrupt an individual thread while possibly leaving the others running. So can you answer any of these questions: 1) Is there a way to interrupt a blocking file read other than with a signal? 2) Is there a non-blocking file read? read(0) seems to return no data. But it returns right away! (This is useful why?) 3) Is there a way to get signals to work with multiple threads? 4) Any other solutions to the problem? Thanks! Rob Eden From spahievi at vega.bg Wed Feb 21 23:35:54 2001 From: spahievi at vega.bg (Niki Spahiev) Date: Thu, 22 Feb 2001 00:35:54 +0200 Subject: fileobj.write(buffer(...)) Message-ID: <1044353420.20010222003554@vega.bg> Is this working as expected? >>> open( 'test', 'w' ).write( buffer( 'abcd', 2 ) ) >>> from cStringIO import StringIO >>> StringIO().write( buffer( 'abcd', 2 ) ) Traceback (innermost last): File "", line 1, in ? StringIO().write( buffer( 'abcd', 2 ) ) SystemError: bad argument to internal function >>> -- Best regards, Niki Spahiev From lisowski.tomasz at sssa.NOSPAM.com.pl Thu Feb 22 09:33:53 2001 From: lisowski.tomasz at sssa.NOSPAM.com.pl (Tomasz Lisowski) Date: Thu, 22 Feb 2001 09:33:53 +0100 Subject: fileobj.write(buffer(...)) References: Message-ID: <972ip3$juj$1@news.tpi.pl> Uzytkownik "Niki Spahiev" napisal w wiadomosci news:mailman.982795168.21257.python-list at python.org... > Is this working as expected? > > >>> open( 'test', 'w' ).write( buffer( 'abcd', 2 ) ) > >>> from cStringIO import StringIO > >>> StringIO().write( buffer( 'abcd', 2 ) ) > Traceback (innermost last): > File "", line 1, in ? > StringIO().write( buffer( 'abcd', 2 ) ) > SystemError: bad argument to internal function What about closing the file? Since you do not have a reference to the file object, you are not able to close it. Perhaps it would be better to write: >>> f=open( 'test', 'w' ) >>> f.write( buffer( 'abcd', 2 ) ) >>> f.close() Don't know about StringIO, sorry :-( Tomasz From sav at ulmen.mv.ru Thu Feb 22 19:42:02 2001 From: sav at ulmen.mv.ru (Alexander Semenov) Date: Thu, 22 Feb 2001 21:42:02 +0300 Subject: fileobj.write(buffer(...)) References: <972ip3$juj$1@news.tpi.pl> Message-ID: <973mhu$1r2e$1@news1.simtel.ru> "Tomasz Lisowski" wrote in message news:972ip3$juj$1 at news.tpi.pl... > Uzytkownik "Niki Spahiev" napisal w wiadomosci > news:mailman.982795168.21257.python-list at python.org... > > Is this working as expected? > > >>> open( 'test', 'w' ).write( buffer( 'abcd', 2 ) ) > > >>> from cStringIO import StringIO > > >>> StringIO().write( buffer( 'abcd', 2 ) ) > > Traceback (innermost last): > > File "", line 1, in ? > > StringIO().write( buffer( 'abcd', 2 ) ) > > SystemError: bad argument to internal function > What about closing the file? Since you do not have a reference to the file > object, you are not able to close it. Perhaps it would be better to write: No, python python implements reference counting. Then file object loose all references it will del-ed. I think file object handles del correctly and closes corresponding handle. > Don't know about StringIO, sorry :-( As for StringIO, my "Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32" is more informatical: it says: >>> from cStringIO import StringIO >>> StringIO().write( buffer( 'abcd', 2 ) ) Traceback (most recent call last): File "", line 1, in ? TypeError: expected string or Unicode object, buffer found It looks like StringIO have some limitation in supporting buffers. WBR, Alexander Semenov From db3l at fitlinxx.com Sat Feb 24 01:39:20 2001 From: db3l at fitlinxx.com (David Bolen) Date: 23 Feb 2001 19:39:20 -0500 Subject: fileobj.write(buffer(...)) References: <972ip3$juj$1@news.tpi.pl> <973mhu$1r2e$1@news1.simtel.ru> Message-ID: "Alexander Semenov" writes: > No, python python implements reference counting. Then file object loose all > references it will del-ed. I think file object handles del correctly and > closes > corresponding handle. Just as a general point, you can't guarantee when _del_ will be called. While the current CPython implementations (even in 2.x I think) trigger that when the RC hits zero, there's no guarantees, and it might not be called until later (or even until Python's process terminates). I'm not sure if JPython/Jython does it immediately even in their current releases. So depending on the criticality of controlling the close, you may want to handle it yourself explicitly, particularly if you are writing data that might otherwise not get flushed until (possibly) much later. -- -- 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 tdickenson at devmail.geminidataloggers.co.uk Mon Feb 26 13:12:10 2001 From: tdickenson at devmail.geminidataloggers.co.uk (Toby Dickenson) Date: Mon, 26 Feb 2001 12:12:10 +0000 Subject: fileobj.write(buffer(...)) References: <972ip3$juj$1@news.tpi.pl> <973mhu$1r2e$1@news1.simtel.ru> Message-ID: David Bolen wrote: >"Alexander Semenov" writes: > >> No, python python implements reference counting. Then file object loose all >> references it will del-ed. I think file object handles del correctly and >> closes >> corresponding handle. > >Just as a general point, you can't guarantee when _del_ will be >called. While the current CPython implementations (even in 2.x I >think) trigger that when the RC hits zero, there's no guarantees, and >it might not be called until later (or even until Python's process >terminates). I'm not sure if JPython/Jython does it immediately even >in their current releases. > >So depending on the criticality of controlling the close, you may want >to handle it yourself explicitly, particularly if you are writing data >that might otherwise not get flushed until (possibly) much later. That is less true than it was before 2.0... 2.0 takes care not to be recursive when deallocating recursive data structures. This is achieved by moving dead objects onto a separate list, and deleting things iteratively. If you have more than one thread manipulating deeply recursive data structures then it is possible for deallocations to be delayed, and then actually handled by a thread other than the one that released the last reference. Im still suprised noone else finds this as much of a problem as I do. Toby Dickenson tdickenson at geminidataloggers.com From db3l at fitlinxx.com Mon Feb 26 23:15:19 2001 From: db3l at fitlinxx.com (David Bolen) Date: 26 Feb 2001 17:15:19 -0500 Subject: fileobj.write(buffer(...)) References: <972ip3$juj$1@news.tpi.pl> <973mhu$1r2e$1@news1.simtel.ru> Message-ID: Toby Dickenson writes: > That is less true than it was before 2.0... Implementation wise or specification wise? I don't think anything changed in 2.0 to guarantee destruction behavior with respect to the language, which is really what I was point out. CPython 1.5.2 is actually very regular in this respect - destroying objects pretty much as soon as their reference count hits zero. -- -- 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 flognat at flognat.myip.org Thu Feb 22 20:45:58 2001 From: flognat at flognat.myip.org (Andrew Markebo) Date: Thu, 22 Feb 2001 19:45:58 GMT Subject: fileobj.write(buffer(...)) References: Message-ID: You forgot one line, the middle line.. I think.. You have to do the operations on an instantiated object, not the class. >>> from cStringIO import StringIO >>> fileobj=StringIO() >>> fileobj.write( buffer( 'abcd', 2 ) ) /Andy / Niki Spahiev wrote: | Is this working as expected? | | >>> open( 'test', 'w' ).write( buffer( 'abcd', 2 ) ) | >>> from cStringIO import StringIO | >>> StringIO().write( buffer( 'abcd', 2 ) ) | Traceback (innermost last): | File "", line 1, in ? | StringIO().write( buffer( 'abcd', 2 ) ) | SystemError: bad argument to internal function | >>> | | -- | Best regards, | Niki Spahiev From locka at iol.ie Thu Feb 22 00:04:09 2001 From: locka at iol.ie (Adam Lock) Date: Wed, 21 Feb 2001 23:04:09 GMT Subject: Curses for Win32? Message-ID: <3A9449BB.284DC79B@iol.ie> I have a Python 2.0 program that uses Tkinter and curses for display. It works fine on Unix because there is a curses package but not on Win32 because there isn't. Perversely even MacPython 2.0 has a curses package! Does anyone know if a curses package exists for Win32? I would even be happy if it compiled but didn't function since I want will be using the Tkinter UI anyway. Many thanks -- Adam Lock - locka at iol.ie From fredrik at pythonware.com Thu Feb 22 00:12:24 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Feb 2001 23:12:24 GMT Subject: Curses for Win32? References: <3A9449BB.284DC79B@iol.ie> Message-ID: Adam Lock wrote: > I have a Python 2.0 program that uses Tkinter and curses for display. It > works fine on Unix because there is a curses package but not on Win32 > because there isn't. Perversely even MacPython 2.0 has a curses package! > > Does anyone know if a curses package exists for Win32? I would even be > happy if it compiled but didn't function since I want will be using the > Tkinter UI anyway. you only need the imports to work? alternative 1: wrap the imports in try/except: try: import curses except ImportError: curses = None # let's hope nobody uses this alternative 2: add python stub modules: > more curses.py # empty if you decide that you want console output after all, you could consider alternative 3: write a curses-compatible wrapper for http://effbot.org/efflib/console Cheers /F From porter at et.byu.edu Thu Feb 22 02:13:00 2001 From: porter at et.byu.edu (C. Porter Bassett) Date: Wed, 21 Feb 2001 18:13:00 -0700 (MST) Subject: Curses for Win32? In-Reply-To: <3A9449BB.284DC79B@iol.ie> References: <3A9449BB.284DC79B@iol.ie> Message-ID: I myself would love to have a python2.0 windows curses module, but nobody with the know-how seems to think that it is important. What you could do, though, is create a dummy module called curses. You say that you don't mind if it doesn't function. Just create dummy functions corresponding to the functions that your program calls. -------------------------------------------------------------------------- C. Porter Bassett porter at et.byu.edu http://www.cporterbassett.com -------------------------------------------------------------------------- "Pretend like this is a really witty saying." - Anonymous -------------------------------------------------------------------------- On Wed, 21 Feb 2001, Adam Lock wrote: > I have a Python 2.0 program that uses Tkinter and curses for display. It > works fine on Unix because there is a curses package but not on Win32 > because there isn't. Perversely even MacPython 2.0 has a curses package! > > Does anyone know if a curses package exists for Win32? I would even be > happy if it compiled but didn't function since I want will be using the > Tkinter UI anyway. > > Many thanks > > -- > Adam Lock - locka at iol.ie > -- > http://mail.python.org/mailman/listinfo/python-list > From dsh8290 at rit.edu Thu Feb 22 04:32:46 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 21 Feb 2001 22:32:46 -0500 Subject: Curses for Win32? In-Reply-To: <3A9449BB.284DC79B@iol.ie>; from locka@iol.ie on Wed, Feb 21, 2001 at 11:04:09PM +0000 References: <3A9449BB.284DC79B@iol.ie> Message-ID: <20010221223246.A26874@harmony.cs.rit.edu> On Wed, Feb 21, 2001 at 11:04:09PM +0000, Adam Lock wrote: | I have a Python 2.0 program that uses Tkinter and curses for display. It | works fine on Unix because there is a curses package but not on Win32 | because there isn't. Perversely even MacPython 2.0 has a curses package! | | Does anyone know if a curses package exists for Win32? I would even be Check out cygwin -- a POSIX emulation layer on top of windows. It has ncurses. If you can compile python using the cygwin tools you will have a functioning curses library. | happy if it compiled but didn't function since I want will be using the | Tkinter UI anyway. If it doesn't function, and you are using TKinter why do you need curses to exist? If it causes the import to fail, put the import in a if statement, or a try-except block. HTH, -D From chris.gonnerman at usa.net Thu Feb 22 06:10:15 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Wed, 21 Feb 2001 23:10:15 -0600 Subject: Curses for Win32? References: <3A9449BB.284DC79B@iol.ie> Message-ID: <018f01c09c8d$bf57d4a0$a100000a@local> A "cursory" (hey, stop throwing things!) search of the 'net shows no Python curses modules for Win32. It would be some work, but I have a Win32 port of Borland's conio.h interface to Python at: http://newcenturycomputers.net/projects/python/wconio and Pablo J. Vidal has a Unix port of the same thing at: http://crazylovetrain.hypermart.net/projects.htm I am going to examine his work with an eye toward making them source-compatible. ----- Original Message ----- From: "Adam Lock" Subject: Curses for Win32? > I have a Python 2.0 program that uses Tkinter and curses for display. It > works fine on Unix because there is a curses package but not on Win32 > because there isn't. Perversely even MacPython 2.0 has a curses package! > > Does anyone know if a curses package exists for Win32? I would even be > happy if it compiled but didn't function since I want will be using the > Tkinter UI anyway. > > Many thanks > > -- > Adam Lock - locka at iol.ie From mak at mikroplan.com.pl Thu Feb 22 11:13:43 2001 From: mak at mikroplan.com.pl (Grzegorz Makarewicz) Date: Thu, 22 Feb 2001 11:13:43 +0100 Subject: Curses for Win32? In-Reply-To: <3A9449BB.284DC79B@iol.ie> Message-ID: Adam Lock wrote: > > I have a Python 2.0 program that uses Tkinter and curses for display. It > works fine on Unix because there is a curses package but not on Win32 > because there isn't. Perversely even MacPython 2.0 has a curses package! > > Does anyone know if a curses package exists for Win32? I would even be > happy if it compiled but didn't function since I want will be using the > Tkinter UI anyway. > Not so complicated as ncurses but always better than nothing, try standard module curses (from python 1.4.x) connected to pdcurses: http://www.mikroplan.com.pl/~mak/python mak From garabik-news at spam.melkor.dnp.fmph.uniba.sk Thu Feb 22 16:33:42 2001 From: garabik-news at spam.melkor.dnp.fmph.uniba.sk (Radovan Garabik) Date: 22 Feb 2001 15:33:42 GMT Subject: Curses for Win32? References: <3A9449BB.284DC79B@iol.ie> Message-ID: <982855925.989488@cdwork.cvt.stuba.sk> Adam Lock wrote: : I have a Python 2.0 program that uses Tkinter and curses for display. It : works fine on Unix because there is a curses package but not on Win32 : because there isn't. Perversely even MacPython 2.0 has a curses package! : Does anyone know if a curses package exists for Win32? I would even be : happy if it compiled but didn't function since I want will be using the : Tkinter UI anyway. well, I am not going to answer this for the third time :-) (not that I would not want to, but I do not have the URL readily accessible just now) serach the archive for "pdcurses" -- ----------------------------------------------------------- | 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 aleaxit at yahoo.com Thu Feb 22 18:18:35 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 22 Feb 2001 18:18:35 +0100 Subject: Curses for Win32? References: <3A9449BB.284DC79B@iol.ie> <982855925.989488@cdwork.cvt.stuba.sk> Message-ID: <973hlf11g60@news2.newsguy.com> "Radovan Garabik" wrote in message news:982855925.989488 at cdwork.cvt.stuba.sk... > Adam Lock wrote: > : I have a Python 2.0 program that uses Tkinter and curses for display. It > : works fine on Unix because there is a curses package but not on Win32 > : because there isn't. Perversely even MacPython 2.0 has a curses package! > > : Does anyone know if a curses package exists for Win32? I would even be > : happy if it compiled but didn't function since I want will be using the > : Tkinter UI anyway. > > well, I am not going to answer this for the third time :-) > (not that I would not want to, but I do not have the URL > readily accessible just now) serach the archive for "pdcurses" Haven't tried it, but, http://www.mikroplan.com.pl/~mak/python/files/curses_src.zip appears to be a zipfile containing a C source (to be compiled to yield a for-Python module) and a curses.py module (that is presumably meant to go with that extension module). There is a binary archive too, but I don't know what Python version it is for. Alex From ylee12 at uiuc.edu Thu Feb 22 05:05:48 2001 From: ylee12 at uiuc.edu (Young-Jin Lee) Date: Wed, 21 Feb 2001 22:05:48 -0600 Subject: [Q] Best way to start learning Python Message-ID: Hi, I'd like to know what is the best way to learn Python. I downloaded Python tutorial from www.python.org, but it's very short and simple. Could you recommend the next step? Thanks in advance. -- Young-Jin Lee From fuess at att.net Thu Feb 22 05:42:53 2001 From: fuess at att.net (David Fuess) Date: Thu, 22 Feb 2001 04:42:53 GMT Subject: [Q] Best way to start learning Python References: Message-ID: <4t599tgn1tn6jc6arhcig924ffgh32go89@4ax.com> There are any number of excellent references on Python. For the general language you might try: Python Developer's Handbook, Andre Lessa, Sams Programming Python, Mark Lutz, O'Reilly (cannonical language reference) Learning Python, Mark Lutz, O'Reilly, 1999 Internet Programming with Python, Aaron Watters, M&T Books for a start ... Dave On Wed, 21 Feb 2001 22:05:48 -0600, "Young-Jin Lee" wrote: >Hi, I'd like to know what is the best way to learn Python. >I downloaded Python tutorial from www.python.org, but it's very short and >simple. >Could you recommend the next step? >Thanks in advance. From rapto at arrakis.es Fri Feb 23 14:21:11 2001 From: rapto at arrakis.es (Marcos Sánchez Provencio) Date: Fri, 23 Feb 2001 14:21:11 +0100 Subject: [Q] Best way to start learning Python References: Message-ID: > I downloaded Python tutorial from www.python.org, but it's very short and > simple. This is a feature, not a bug. Python _is_ short and simple. From f8dy at yahoo.com Mon Feb 26 15:43:55 2001 From: f8dy at yahoo.com (Mark Pilgrim) Date: Mon, 26 Feb 2001 09:43:55 -0500 Subject: [Q] Best way to start learning Python References: Message-ID: <97dq0b$oe881$1@ID-77331.news.dfncis.de> O'Reilly recently reviewed several free online Python books for both beginners and more experienced programmers. http://www.oreillynet.com/pub/a/python/2001/02/07/pythonnews.html -M You're smart; why haven't you learned Python yet? http://diveintopython.org/ "Marcos S?nchez Provencio" wrote in message news:newscache$u2p79g$l21$1 at proxy.bitmailer.com... > > I downloaded Python tutorial from www.python.org, but it's very short and > > simple. > > This is a feature, not a bug. Python _is_ short and simple. > > > From michael+gnus at trollope.org Sun Feb 25 07:53:01 2001 From: michael+gnus at trollope.org (Michael Powe) Date: 24 Feb 2001 22:53:01 -0800 Subject: [Q] Best way to start learning Python References: Message-ID: <87pug7s182.fsf@cecilia.trollope.org> >>>>> "Young-Jin" == Young-Jin Lee writes: Young-Jin> Hi, I'd like to know what is the best way to learn Young-Jin> Python. I downloaded Python tutorial from Young-Jin> www.python.org, but it's very short and simple. Could Young-Jin> you recommend the next step? Thanks in advance. by Mark Lutz & David Ascher mp -- -----------Michael Powe Portland, Oregon USA---------- "There are 100,000 total marijuana smokers in the U.S., and most are Negroes, Hispanics, Filipinos and entertainers. Their Satanic music, jazz and swing, result from marijuana use. This marijuana can cause white women to seek sexual relations with Negroes, entertainers and any others." -- Harry J. Anslinger, Dir. Fed. Bureau of Narcotics, Congressional Testimony, 1937 From mertz at gnosis.cx Thu Feb 22 07:08:41 2001 From: mertz at gnosis.cx (Dr. David Mertz) Date: Thu, 22 Feb 2001 01:08:41 -0500 Subject: The price of fame... Message-ID: As shockingly many readers of this group will probably know (so server logs indirectly say), I have written some articles on Python, mostly in the series _Charming Python_, which lives, finally, at ibm.com/developerworks/linux/. But before and after they live there, they live roundabout gnosis.cx/publish/. Here's the story, some unexpected favorable mentions, mostly at PythonWare's daily-url has caused my web-host providers to act erratically and capriciously (let me put in a passing bad word against CSoft.net, whom I will not have any more as soon as my DNS changes go through). But there's more... I apologize for the Proustian quality... I contributed to the caprice, in a small way, by using a plain, old-fashion CGI program (no fastCGI, mod_python, or the like) to prettify documents that are named '*.txt' into splashy HTML thingies. Is this a good time to mention how much I miss gopherspace? So everyone who went to look at my links ran a moderately complicated Python script, which made for some server load. Excessive dynamism has come to haunt me, after my self-steeping in the ways Pythonic. Admittedly, the script was merely cute, but quite needless (I should just convert once, and leave it... or at most on a cron). Well, at the end of this narration is just a request. Anyone who might try to find any article that lives at the end of "http://gnosis.cx/cgi/txt2html.cgi?source=" would be better served, for the nonce at least, to leave off that first part, and just look at the URLish stuff that comes later in the enormous CGI URL. Not quite as pretty... but at least you won't get a 404. All the best, David... -- mertz@ _/_/_/_/_/_/_/ THIS MESSAGE WAS BROUGHT TO YOU BY:_/_/_/_/ v i gnosis _/_/ Postmodern Enterprises _/_/ s r .cx _/_/ MAKERS OF CHAOS.... _/_/ i u _/_/_/_/_/ LOOK FOR IT IN A NEIGHBORHOOD NEAR YOU_/_/_/_/_/ g s From tchur at optushome.com.au Thu Feb 22 20:34:13 2001 From: tchur at optushome.com.au (Tim Churches) Date: Fri, 23 Feb 2001 06:34:13 +1100 Subject: The price of fame... References: Message-ID: <3A9569B5.D2540F58@optushome.com.au> "Dr. David Mertz" wrote: > the series _Charming Python_, which lives, finally, at > ibm.com/developerworks/linux/. But before and after they live there, > they live roundabout gnosis.cx/publish/. Ah, they live on Christmas Island! Maybe some Gecarcoidea natalis (red crab) cut the cables to your Web server... see http://www.christmas.net.au for more information on the home of Dr. Mertz' Web site. Tim Churches Sydney, Australia From Noah at noah.org Thu Feb 22 09:27:02 2001 From: Noah at noah.org (Noah) Date: Thu, 22 Feb 2001 00:27:02 -0800 Subject: Non-blocking pipe read under Windows NT Message-ID: Hmmm... Windows Python2.0 does not have fcntl. How do I do a non-blocking select on a Pipe file descriptor? Under UNIX I can do something like this: # hard way to read a file import os, fcntl, FCNTL # Open a pipe to read a file. (fin, fout, ferr) = os.popen3 ('cat testfile') # Turn off blocking on file. read() will then return -1 if no data flags = fcntl.fcntl (fout.fileno(), FCNTL.F_GETFL, 0) flags = flags | FCNTL.O_NONBLOCK fcntl.fcntl (fout.fileno(), FCNTL.F_SETFL, flags) # Print out the file without blocking. done = 0 while !done: (r,w,e) = select.select ([fout], [], [], None) if len(r) > 0: data = r[0].read() if data == -1: done = 1 else: print data From NoSpam at NoSpam.com Thu Feb 22 17:52:09 2001 From: NoSpam at NoSpam.com (Tom) Date: Thu, 22 Feb 2001 16:52:09 GMT Subject: Non-blocking pipe read under Windows NT References: Message-ID: That's a bit tricky. Windows (at least NT/2K, which fully support named pipes) does support non-blocking pipes, but I don't think that Python does. But I don't think that matters. I looked into it a while ago (for C++) and decided that it would be easier to implement an extra thread than to implement non-blocking pipes for cross-platform purposes. For one thing, cross-platform threading libraries are common, whereas non-blocking pipes seem suprisingly uncommon. So, I don't know what you are trying to do, but if threads are an alternative soln to your problem (ie. thread + block == non-block), I would recommend them. If you still want to persue non-block windows pipes, you could look at the article " Named Pipe Type, Read, and Wait Modes" ( http://msdn.microsoft.com/library/psdk/winbase/pipes_60mr.htm). The win32 implementation of Python's thread creation (for the popen fn's) is based on MS knowledgebase article Q190351 (available from http://msdn.microsoft.com/library/). These articles are, unfortunately, in 'C'. Good-luck, Tom. "Noah" wrote in message news:q34l6.297$0Q5.207467 at news.pacbell.net... > Hmmm... Windows Python2.0 does not have fcntl. > How do I do a non-blocking select on a Pipe file descriptor? > > Under UNIX I can do something like this: > > # hard way to read a file > > import os, fcntl, FCNTL > > # Open a pipe to read a file. > (fin, fout, ferr) = os.popen3 ('cat testfile') > > # Turn off blocking on file. read() will then return -1 if no data > flags = fcntl.fcntl (fout.fileno(), FCNTL.F_GETFL, 0) > flags = flags | FCNTL.O_NONBLOCK > fcntl.fcntl (fout.fileno(), FCNTL.F_SETFL, flags) > > # Print out the file without blocking. > done = 0 > while !done: > (r,w,e) = select.select ([fout], [], [], None) > if len(r) > 0: > data = r[0].read() > if data == -1: > done = 1 > else: > print data > > From corour01 at motorola.com Thu Feb 22 10:02:27 2001 From: corour01 at motorola.com (O'Rourke Clodagh-corour01) Date: Thu, 22 Feb 2001 09:02:27 -0000 Subject: Embedding setenv Message-ID: <13EE655665F4D311AB4D0008C789498A01EE2C44@zei02exm02.cork.cig.mot.com> Hi all, I was wondering does anyone know how to embed the setenv command in python. I've tried os.system("setenv VARIABLE value") But I get: sh: setenv: not found Any ideas? Thanks, Clodagh O Rourke From boltong at europem01.nt.com Thu Feb 22 11:23:13 2001 From: boltong at europem01.nt.com (Bolton, Gawain [ADC:4808:EXCH]) Date: Thu, 22 Feb 2001 11:23:13 +0100 Subject: Embedding setenv References: Message-ID: <3A94E891.93DF51E3@europem01.nt.com> O'Rourke Clodagh-corour01 wrote: > Hi all, > > I was wondering does anyone know how to embed the setenv command in python. > I've tried os.system("setenv VARIABLE value") > But I get: sh: setenv: not found > > Any ideas? > > Thanks, > Clodagh O Rourke Yeah try: import os os.environ[name] = value Note that this will set the environment variable for the current process. Your os.system() call did not work firstly because "setenv" is a csh command and os.system() spawned a plain old shell session. Secondly, this is the wrong approach because the environment variable will be set only for the sub-process created by the system() command. Thirdly, this approach is very inefficient. Gawain -- ------------------------------------------------------------------------------- Gawain Bolton | E-mail: boltong at nortelnetworks.com Section 4808 | UMTS Development | Nortel Networks | Voice: ESN 579-3763 +33 1.39.44.37.63 Guyancourt, France | FAX: ESN 579-3009 +33 1.39.44.30.09 ------------------------------------------------------------------------------- From fredrik at pythonware.com Thu Feb 22 12:28:05 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 22 Feb 2001 11:28:05 GMT Subject: Embedding setenv References: Message-ID: <9J6l6.19294$AH6.2613345@newsc.telia.net> Clodagh O'Rourke wrote: > I was wondering does anyone know how to embed the setenv command in python. > I've tried os.system("setenv VARIABLE value") > But I get: sh: setenv: not found Even if the default shell had a setenv command (setenv is a csh feature, not a unix command), that approach wouldn't work. try this instead: os.environ["VARIABLE"] = "value" (for more info on why setting environment in one subprocess won't affect environment variables in another subprocess, see your nearest Unix FAQ). Cheers /F From chris.gonnerman at usa.net Thu Feb 22 14:42:08 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Thu, 22 Feb 2001 07:42:08 -0600 Subject: Embedding setenv References: <13EE655665F4D311AB4D0008C789498A01EE2C44@zei02exm02.cork.cig.mot.com> Message-ID: <002301c09cd5$44157d40$a100000a@local> ----- Original Message ----- From: "O'Rourke Clodagh-corour01" Subject: Embedding setenv > Hi all, > > I was wondering does anyone know how to embed the setenv command in python. > I've tried os.system("setenv VARIABLE value") > But I get: sh: setenv: not found > > Any ideas? > > Thanks, > Clodagh O Rourke In general, you can't do this. setenv (in csh) is a builtin, and doesn't exist in /bin/sh or /bin/bash at all. Are you trying to set variables in your parent processes' environment? Can't do that in Unix, period. If you are trying to set your own environment, including controlling the environment of future child processes, use os.environ, which is a mapping (dictionary-like object): import os os.environ['VARIABLE'] = 'value' From corour01 at motorola.com Thu Feb 22 15:11:01 2001 From: corour01 at motorola.com (O'Rourke Clodagh-corour01) Date: Thu, 22 Feb 2001 14:11:01 -0000 Subject: Embedding setenv Message-ID: <13EE655665F4D311AB4D0008C789498A01EE2C51@zei02exm02.cork.cig.mot.com> >>I've tried os.system("setenv VARIABLE value") >>But I get: sh: setenv: not found >n general, you can't do this. setenv (in csh) is a builtin, and doesn't >xist in /bin/sh or /bin/bash >t all. Are you trying to set variables in your parent processes' >nvironment? Can't do that in >nix, period. If you are trying to set your own environment, including >ontrolling the environment >o future child processes, use os.environ, which is a mapping >dictionary-like object): import os os.environ['VARIABLE'] = 'value' I'm trying to set environment variables in a GSM network environment I tried os.environ['VARIABLE'] = 'value' And I got..... SyntaxError: can't assign to function call I'm working on putting a front end on the Network-Controller Environment variables reading data to/from Informix and setting the environment. If I can't do this directly from the python back end of the application, I might have to write the variables/values to another script and keep the setenv stuff separate.... Thanks, Clodagh. From emile at fenx.com Thu Feb 22 15:45:46 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 22 Feb 2001 06:45:46 -0800 Subject: Embedding setenv References: Message-ID: <9738p2$ncbrn$1@ID-11957.news.dfncis.de> "O'Rourke Clodagh-corour01" wrote in message news:mailman.982851124.2766.python-list at python.org... > > >>I've tried os.system("setenv VARIABLE value") > >>But I get: sh: setenv: not found > > > >n general, you can't do this. setenv (in csh) is a builtin, and doesn't > >xist in /bin/sh or /bin/bash > >t all. Are you trying to set variables in your parent processes' > >nvironment? Can't do that in > >nix, period. If you are trying to set your own environment, including > >ontrolling the environment > >o future child processes, use os.environ, which is a mapping > >dictionary-like object): > > import os > os.environ['VARIABLE'] = 'value' > this works for me... > > I'm trying to set environment variables in a GSM network environment I tried > > os.environ['VARIABLE'] = 'value' > > And I got..... > > SyntaxError: can't assign to function call > gotta be something else going on... > I'm working on putting a front end on the Network-Controller Environment variables reading data to/from Informix and setting the environment. > > If I can't do this directly from the python back end of the application, I might have to write the variables/values to another script and keep the setenv stuff separate.... > > Thanks, > Clodagh. > I'm not sure it'll do what you want it to do, but it certainly does what you say you're doing... -- Emile van Sebille emile at fenx.com ------------------- From fredrik at pythonware.com Thu Feb 22 16:10:53 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 22 Feb 2001 15:10:53 GMT Subject: Embedding setenv References: Message-ID: <1_9l6.19330$AH6.2620037@newsc.telia.net> Clodagh O'Rourke wrote: > os.environ['VARIABLE'] = 'value' > > And I got..... > > SyntaxError: can't assign to function call Are you sure you used square brackets? >>> os.environ('VARIABLE') = 'value' SyntaxError: can't assign to function call >>> os.environ['VARIABLE'] = 'value' >>> os.environ['VARIABLE'] 'value' Cheers /F From costas at meezon.com Thu Feb 22 20:58:20 2001 From: costas at meezon.com (Costas Menico) Date: Thu, 22 Feb 2001 19:58:20 GMT Subject: Embedding setenv References: Message-ID: <3a956e89.18194798@news.cis.dfn.de> On Thu, 22 Feb 2001 14:11:01 -0000, "O'Rourke Clodagh-corour01" : > > import os > os.environ['VARIABLE'] = 'value' > > Works for me.... but if you change it to paren then you get the error below. >I'm trying to set environment variables in a GSM network environment I tried > >os.environ['VARIABLE'] = 'value' > >And I got..... > >SyntaxError: can't assign to function call > From simon at joyful.com Thu Feb 22 11:19:01 2001 From: simon at joyful.com (Simon Michael) Date: 22 Feb 2001 10:19:01 +0000 Subject: nice articles (Re: The price of fame...) References: Message-ID: <87vgq358bu.fsf@joyful.com> I found eg "Text Processing in Python: Tips for Beginners" a very useful overview. Thanks! If I may, an attempt to summarize for my fellow newbies: "Charming Python" columns can be found at, eg http://gnosis.cx/publish/tech_index.html . To read, click the title (not the eye logo). Best regards From Norman_Shelley-RRDN60 at email.sps.mot.com Thu Feb 22 17:47:14 2001 From: Norman_Shelley-RRDN60 at email.sps.mot.com (Norman Shelley) Date: Thu, 22 Feb 2001 09:47:14 -0700 Subject: nice articles (Re: The price of fame...) References: <87vgq358bu.fsf@joyful.com> Message-ID: <3A954292.FEED9271@email.sps.mot.com> Simon Michael wrote: > I found eg "Text Processing in Python: Tips for Beginners" a very > useful overview. Thanks! > > If I may, an attempt to summarize for my fellow newbies: > > "Charming Python" columns can be found at, eg > http://gnosis.cx/publish/tech_index.html . > To read, click the title (not the eye logo). > > Best regards Funny, I still get this when I click on the above URL Not Found The requested URL /publish/tech_index.html was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. From fig at monitor.net Fri Feb 23 20:18:56 2001 From: fig at monitor.net (Stephen R. Figgins) Date: Fri, 23 Feb 2001 11:18:56 -0800 Subject: nice articles (Re: The price of fame...) References: <87vgq358bu.fsf@joyful.com> <3A954292.FEED9271@email.sps.mot.com> Message-ID: <3A96B7A0.BFBE6A47@monitor.net> > Funny, I still get this when I click on the above URL > > Not Found > The requested URL /publish/tech_index.html was not found on this server. The web site was down for some reason. It is back now. You can find Dr. Mertz's writings at: http://gnosis.cx/publish/tech_index.html Stephen From mertz at gnosis.cx Thu Feb 22 19:49:54 2001 From: mertz at gnosis.cx (Dr. David Mertz) Date: Thu, 22 Feb 2001 13:49:54 -0500 Subject: nice articles (Re: The price of fame...) Message-ID: Simon Michael wrote: > I found eg "Text Processing in Python: Tips for Beginners" a very > useful overview. Thanks! > If I may, an attempt to summarize for my fellow newbies: > "Charming Python" columns can be found at, eg > http://gnosis.cx/publish/tech_index.html . > To read, click the title (not the eye logo). Norman Shelley | Funny, I still get this when I click on the above URL | Not Found | The requested URL /publish/tech_index.html was not found on this server. | Additionally, a 404 Not Found error was encountered while trying to use | an ErrorDocument to handle the request. Apparently my old host is AGAIN cycling though various unhelpful messages at the site. Let me repeat my recommendation against Csoft.net. Terrible customer support: contemptuous, rude, unhelpful. So I apologize for burdening the group with more matter that might seem egotistical. However, for now, you can get to the articles (on the new host), at: http://64.41.64.172/publish/tech_index.html In a day or two, the DNS updates should be distributed, and you can use the domain name again. Thanks, David... From tuttledon at hotmail.com Thu Feb 22 20:25:27 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Thu, 22 Feb 2001 19:25:27 GMT Subject: nice articles (Re: The price of fame...) References: Message-ID: David... > Apparently my old host is AGAIN cycling though various unhelpful > messages at the site. Let me repeat my recommendation against > Csoft.net. Terrible customer support: contemptuous, rude, unhelpful. > > So I apologize for burdening the group with more matter that might seem > egotistical. However, for now, you can get to the articles (on the new > host), at: > > http://64.41.64.172/publish/tech_index.html > > In a day or two, the DNS updates should be distributed, and you can use > the domain name again. Wow, what a gold mine!. Hate to say it but I'm glad you've had problems, otherwise I might not have found your work. ;-) Don From djc at object-craft.com.au Thu Feb 22 11:52:29 2001 From: djc at object-craft.com.au (Dave Cole) Date: 22 Feb 2001 21:52:29 +1100 Subject: Sybase module 0.12 (Aki Yamashita release) released Message-ID: What is it: The Sybase module provides a Python interface to the Sybase relational database system. The Sybase package supports almost all of the Python Database API, version 2.0 with extensions. The module works with Python versions 1.5.2 and later and Sybase versions 11.0.3 and later. It is based on the Sybase Client Library (ct_* API), and the Bulk-Library Client (blk_* API) interfaces. Changes: - A bug has been fixed in the bulkcopy object which caused FLOAT columns to be corrupted on transfer to the server. Where can you get it: http://www.object-craft.com.au/projects/sybase/ - Dave -- http://www.object-craft.com.au From vonWedel at lfpt.rwth-aachen.de Thu Feb 22 13:42:59 2001 From: vonWedel at lfpt.rwth-aachen.de (vonWedel at lfpt.rwth-aachen.de) Date: Thu, 22 Feb 2001 13:42:59 +0100 Subject: XML Module problems Message-ID: Hello, I'm trying to use an SAX-based parser to process XML files in Python 2.0. First I tried Python on a Solaris machine, finding out that the python distribution installed does not contain _any_ XML parsers!? Hence I chose to install PyXML -- it installs fine but running it gives me a segmentation fault in sax.make_parser(), so probably it doesn't succeed in loading the pyexpat.so module. Are there any binary versions of the module? Running the program on an NT 4.0 machine succeeds in creating a parser, but gives me the following error which seems to be internal to the parser module!? (The warning is output from my program, meaning it doesn't handle element ). Warning: Start of element start skipped Traceback (most recent call last): File "run.py", line 369, in ? main(sys.stdin, sys.stdout, sys.stderr) File "run.py", line 366, in main h.run() File "run.py", line 86, in run p.parse('case.xml') File "d:\programme\python20\lib\xml\sax\expatreader.py", line 42, in parse xmlreader.IncrementalParser.parse(self, source) File "d:\programme\python20\lib\xml\sax\xmlreader.py", line 120, in parse self.feed(buffer) File "d:\programme\python20\lib\xml\sax\expatreader.py", line 81, in feed self._parser.Parse(data, isFinal) TypeError: too many arguments; expected 1, got 2 Any other ideas on how to use XML in Python? TNX, Lars -------------- next part -------------- An HTML attachment was scrubbed... URL: From loewis at informatik.hu-berlin.de Thu Feb 22 14:20:30 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 22 Feb 2001 14:20:30 +0100 Subject: XML Module problems References: Message-ID: vonWedel at lfpt.rwth-aachen.de writes: > First I tried Python on a Solaris machine, finding out that the > python distribution installed does not contain _any_ XML parsers!? It sure does include pyexpat - you have to have the expat library to compile it, though. Of course, I don't know how you had installed Python, so it is certainly possible that there is no XML parser in your installation. > Hence I chose to install PyXML -- it installs fine but running it > gives me a segmentation fault in sax.make_parser(), so probably it > doesn't succeed in loading the pyexpat.so module. Are there any > binary versions of the module? What version of PyXML? It works fine for me. If you need binary releases: what version of Solaris? > self.feed(buffer) > File "d:\programme\python20\lib\xml\sax\expatreader.py", line 81, in > feed > self._parser.Parse(data, isFinal) > TypeError: too many arguments; expected 1, got 2 That is a confusing traceback. It is not an error in the call to Parse, but in the callback invoked from pyexpat. It would be good if you could post your ContentHandler. Regards, Martin From vonWedel at lfpt.rwth-aachen.de Thu Feb 22 15:43:58 2001 From: vonWedel at lfpt.rwth-aachen.de (Lars von Wedel) Date: Thu, 22 Feb 2001 15:43:58 +0100 Subject: XML Module problems References: Message-ID: <3A9525AE.D92CBBC4@lfpt.rwth-aachen.de> Hello Martin, > > First I tried Python on a Solaris machine, finding out that the > > python distribution installed does not contain _any_ XML parsers!? > > It sure does include pyexpat - you have to have the expat library to > compile it, though. Of course, I don't know how you had installed > Python, so it is certainly possible that there is no XML parser in > your installation. As far as I know we installed a binary package from some site, don't know from where exactly, though. However, in xml/parsers there is expat.py but no pyexpat. > > Hence I chose to install PyXML -- it installs fine but running it > > gives me a segmentation fault in sax.make_parser(), so probably it > > doesn't succeed in loading the pyexpat.so module. Are there any > > binary versions of the module? > > What version of PyXML? It works fine for me. If you need binary > releases: what version of Solaris? It shows the same behavior for both 0.6.2 and 0.6.3. 'uname -a' says 'SunOS kazul 5.7 Generic sun4m sparc'. I just tried to recompile the package on a more recent machine (SOS 5.7, but type sun4u instead of sun4m) and this one seems to work (on both machines!), I can create an Expat after installing the package. Strange, but anyway. > > self.feed(buffer) > > File "d:\programme\python20\lib\xml\sax\expatreader.py", line 81, in > > feed > > self._parser.Parse(data, isFinal) > > TypeError: too many arguments; expected 1, got 2 > That is a confusing traceback. It is not an error in the call to > Parse, but in the callback invoked from pyexpat. It would be good if > you could post your ContentHandler. Now, that's indeed confusing! With this hint I could quickly trace the problem down. Thanks for your quick help, Lars From loewis at informatik.hu-berlin.de Mon Feb 26 09:33:48 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 26 Feb 2001 09:33:48 +0100 Subject: XML Module problems References: Message-ID: Lars von Wedel writes: > As far as I know we installed a binary package from some site, don't > know from where exactly, though. However, in xml/parsers there is > expat.py but no pyexpat. That makes it difficult to analyse the problem further. In Python proper, pyexpat, if present, might be builting or a lib-dynload module; it will not reside in xml.parsers. If you'd know where the binary came from, you could complain to the packager... > > > Hence I chose to install PyXML -- it installs fine but running it > > > gives me a segmentation fault in sax.make_parser(), so probably it > > > doesn't succeed in loading the pyexpat.so module. Are there any > > > binary versions of the module? > > > > What version of PyXML? It works fine for me. If you need binary > > releases: what version of Solaris? > It shows the same behavior for both 0.6.2 and 0.6.3. 'uname -a' > says 'SunOS kazul 5.7 Generic sun4m sparc'. I just tried to recompile > the package on a more recent machine (SOS 5.7, but type sun4u instead > of sun4m) and this one seems to work (on both machines!), I can create > an Expat after installing the package. Strange, but anyway. Strange indeed. Broken compiler? > Now, that's indeed confusing! With this hint I could quickly trace the > problem down. It's good to hear it works now. Regards, Martin From gradha at iname.com Thu Feb 22 14:57:08 2001 From: gradha at iname.com (gradha at iname.com) Date: Thu, 22 Feb 2001 14:57:08 +0100 Subject: Looking for better Tkinter's listbox widget Message-ID: Hello. I am looking forward to writting a Phython GUI for a program, and I need to show a listbox with at least multiple columns, where it would be just nice (not really needed) to display an icon in one of them. Such listbox items should be individually selectable. I've read Tkinter's Fredrik Introduction, and there it says that Tkinter's native listbox doesn't support multiple columns. Where can I find a replacement widget providing the multicolumn feature and being portable to Windows and X? -- Grzegorz Adam Hankiewicz gradha at iname.com - http://gradha.infierno.org Other web pages: http://glub.ehu.es/ - http://welcome.to/gogosoftware/ From jp.roumian at mobileway.com Tue Feb 27 19:19:09 2001 From: jp.roumian at mobileway.com (jean-paul roumian) Date: Tue, 27 Feb 2001 19:19:09 +0100 Subject: Looking for better Tkinter's listbox widget References: Message-ID: <3A9BEF9D.2050507@mobileway.com> gradha at iname.com wrote: > Hello. > > I am looking forward to writting a Phython GUI for a program, and I need > to show a listbox with at least multiple columns, where it would be just > nice (not really needed) to display an icon in one of them. Such listbox > items should be individually selectable. > > I've read Tkinter's Fredrik Introduction, and there it says that Tkinter's > native listbox doesn't support multiple columns. Where can I find a > replacement widget providing the multicolumn feature and being portable > to Windows and X? did you tried GtkCTree ? (from pygtk) > -- "The Pythagorean Theorem employed 24 words, the Lord's Prayer has 66 words, Archimedes Principle has 67words, the 10 Commandments have 179 words, the Declaration of Independence 1,300 words, and finally the European Commission's regulation on the sale of cabbage: 26,911 words." From martin.franklin at westerngeco.com Wed Feb 28 08:49:25 2001 From: martin.franklin at westerngeco.com (Martin Franklin) Date: Wed, 28 Feb 2001 07:49:25 +0000 Subject: Looking for better Tkinter's listbox widget References: <3A9BEF9D.2050507@mobileway.com> Message-ID: <3A9CAD85.35EA4597@westerngeco.com> Try MCScrolledListBox it is a Pmw/PmwContribD by Doug Hellmann http://members.home.net/doughellmann/PmwContribD/index.html jean-paul roumian wrote: > > gradha at iname.com wrote: > > > Hello. > > > > I am looking forward to writting a Phython GUI for a program, and I need > > to show a listbox with at least multiple columns, where it would be just > > nice (not really needed) to display an icon in one of them. Such listbox > > items should be individually selectable. > > > > I've read Tkinter's Fredrik Introduction, and there it says that Tkinter's > > native listbox doesn't support multiple columns. Where can I find a > > replacement widget providing the multicolumn feature and being portable > > to Windows and X? > > did you tried GtkCTree ? (from pygtk) > > > > > -- > "The Pythagorean Theorem employed 24 words, the Lord's Prayer has 66 words, > Archimedes Principle has 67words, the 10 Commandments have 179 words, > the Declaration of Independence 1,300 words, > and finally the European Commission's regulation on the sale of > cabbage: 26,911 words." > > -- > http://mail.python.org/mailman/listinfo/python-list From chrisw at nipltd.com Thu Feb 22 15:21:12 2001 From: chrisw at nipltd.com (Chris Withers) Date: Thu, 22 Feb 2001 14:21:12 +0000 Subject: Newbie Error? Compiling _tkinter from Source on Win32 Message-ID: <3A952058.D2D63AFE@nipltd.com> >From PCBuild/readme.txt: > _tkinter > Python wrapper for the Tk windowing system. Requires tcl832.exe from > http://dev.scriptics.com/software/tcltk/downloadnow83.html > Run the installer, forcing installation into dist\Tcl. > Be sure to install everything, including the Tcl/Tk header files. So I installed tcl832 into E:\Python-2.0\Tcl and then tried to use VC++ 6.0 to build the _tkinter module, but I got: > --------------------Configuration: _tkinter - Win32 Release-------------------- > Compiling... > _tkinter.c > E:\Python-2.0\Modules\_tkinter.c(44) : fatal error C1083: Cannot open include file: 'tcl.h': No such file or directory > tkappinit.c > E:\Python-2.0\Modules\tkappinit.c(15) : fatal error C1083: Cannot open include file: 'tcl.h': No such file or directory > Error executing cl.exe. > > _tkinter.pyd - 2 error(s), 0 warning(s) Any ideas what I'm doing wrong? cheers, Chris From fredrik at pythonware.com Thu Feb 22 15:57:52 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 22 Feb 2001 14:57:52 GMT Subject: Newbie Error? Compiling _tkinter from Source on Win32 References: Message-ID: Chris Withers wrote: > > --------------------Configuration: _tkinter - Win32 Release-------------------- > > Compiling... > > _tkinter.c > > E:\Python-2.0\Modules\_tkinter.c(44) : fatal error C1083: > > Cannot open include file: 'tcl.h': No such file or directory > > tkappinit.c > > E:\Python-2.0\Modules\tkappinit.c(15) : fatal error C1083: > > Cannot open include file: 'tcl.h': No such file or directory > > Error executing cl.exe. > > > > _tkinter.pyd - 2 error(s), 0 warning(s) > > Any ideas what I'm doing wrong? Does "newbie" mean C newbie? The error message pretty much means what it says: the compiler cannot find and open that file. Make sure you have tcl.h somewhere, and check the compiler's include settings. (iirc, the distributed build file expects to find the Tcl/Tk include files in "\..\tcl\include") Cheers /F From tim.one at home.com Fri Feb 23 07:33:07 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 23 Feb 2001 01:33:07 -0500 Subject: Newbie Error? Compiling _tkinter from Source on Win32 In-Reply-To: <3A952058.D2D63AFE@nipltd.com> Message-ID: [posted & mailed] [Chris Withers] > From PCBuild/readme.txt: >> _tkinter >> Python wrapper for the Tk windowing system. Requires tcl832.exe >> from > > http://dev.scriptics.com/software/tcltk/downloadnow83.html > > Run the installer, forcing installation into dist\Tcl. > > Be sure to install everything, including the Tcl/Tk header files. > So I installed tcl832 into E:\Python-2.0\Tcl and then tried to > use VC++ 6.0 to build the _tkinter module, but I got: > ... > > E:\Python-2.0\Modules\_tkinter.c(44) : fatal error C1083: > Cannot open include file: 'tcl.h': No such file or directory > ... Also from PCBuild/readme.txt: The following subprojects will generally NOT build out of the box. They wrap code Python doesn't control, and you'll need to download the base packages first and unpack them into siblings of PCbuilds's parent directory; for example, if your PCbuild is .......\dist\src \PCbuild\, unpack into new subdirectories of dist\. That's why the part you quoted said "forcing installation into dist\Tcl". Unless your Python-2.0 is a sibling of PCbuild's parent directory (and, trust me, it isn't ), you're simply not following the instructions. Bit o' advice: the first thing a newbie should not do, and especially not on Windows, is get creative about where they install things. If you follow instructions to the letter, they'll work; *then* you can get creative. From rich_somerfield at tertio.com Thu Feb 22 16:00:52 2001 From: rich_somerfield at tertio.com (Rich Somerfield) Date: Thu, 22 Feb 2001 15:00:52 -0000 Subject: Tkinter problems Message-ID: I get the following exception when trying to load a jpeg image. My system is Linux SuSE6.4 (however I have downloaded and recompiled Python and PIL - the original versions had the same problem, i thought it would go away if i upgraded, it didnt.) Python 2.0 / Pil 1.1.1 / Tk 8.0.4 I have been using my code successfully using the py15 installation from PythonWare. BTW, what is the problem with my Python interpreter?? The Warning msg about the API version. Regards Rich rsomerfield at FullCycle:~/SGE/sge > python sge_2.0.1.py WARNING: Python C API version mismatch for module _tkinter: This Python has API version 1009, module _tkinter has version 1007. WARNING: Python C API version mismatch for module _imaging: This Python has API version 1009, module _imaging has version 1007. Traceback (most recent call last): File "sge_2.0.1.py", line 4585, in ? sge = SimpleGameEngine() File "sge_2.0.1.py", line 141, in __init__ exec("self.main_function()") File "", line 1, in ? File "sge_2.0.1.py", line 123, in main_function self.TG.produce_board_locations() File "sge_2.0.1.py", line 1807, in produce_board_locations self.vars.boardlocationimages[i] = self.DI.process_individual_image(i, self.vars.theimageblank1) File "sge_2.0.1.py", line 1870, in process_individual_image theimagetemp = ImageTk.PhotoImage(theimagetemp) File "/usr/lib/python/site-packages/PIL/ImageTk.py", line 83, in __init__ self.paste(image) File "/usr/lib/python/site-packages/PIL/ImageTk.py", line 113, in paste self.__photo.tk.call("PyImagingPhoto", self.__photo, block.id) TclError: invalid command name "PyImagingPhoto" rsomerfield at FullCycle:~/SGE/sge > From whisper at oz.net Fri Feb 23 20:09:19 2001 From: whisper at oz.net (Dave LeBlanc) Date: 23 Feb 2001 19:09:19 GMT Subject: Tkinter problems References: Message-ID: <976cgv$4ii$0@216.39.170.247> Oh, it's just a guess, but i'd say the version of tkinter you're trying to use is incompatible with the version of python you're trying to use. Possible causes: Python 2.0 is finding an older version of tkinter (perhaps associated with a Python 1.5.2 or 1.6.0 install?). You downloaded tkinter and python at different times. You recompiled Python but not tkinter. My suggestion would be to get a standard python 2.0 distro with tkinter included (does it actually come any other way?) and build and install the whole mass at once. BTW, Tcl 8.0.4 is _hopelessly_ out of date, having been superceded by Tcl 8.0.5 long ago (not to mention many further versions not used with the Python 1.5.2 version of tkinter). AFAIK from reading, tkinter for Python 2.0 now uses Tcl 8.3.2 which, as always, is available through www.scriptics.com at sourceforge. HTH On Thu, 22 Feb 2001 15:00:52 -0000, "Rich Somerfield" wrote: >I get the following exception when trying to load a jpeg image. > >My system is Linux SuSE6.4 (however I have downloaded and recompiled Python >and PIL - the original versions had the same problem, i thought it would go >away if i upgraded, it didnt.) Python 2.0 / Pil 1.1.1 / Tk 8.0.4 > >I have been using my code successfully using the py15 installation from >PythonWare. > >BTW, what is the problem with my Python interpreter?? The Warning msg about >the API version. > > >Regards >Rich > > >rsomerfield at FullCycle:~/SGE/sge > python sge_2.0.1.py >WARNING: Python C API version mismatch for module _tkinter: > This Python has API version 1009, module _tkinter has version 1007. >WARNING: Python C API version mismatch for module _imaging: > This Python has API version 1009, module _imaging has version 1007. >Traceback (most recent call last): > File "sge_2.0.1.py", line 4585, in ? > sge = SimpleGameEngine() > File "sge_2.0.1.py", line 141, in __init__ > exec("self.main_function()") > File "", line 1, in ? > File "sge_2.0.1.py", line 123, in main_function > self.TG.produce_board_locations() > File "sge_2.0.1.py", line 1807, in produce_board_locations > self.vars.boardlocationimages[i] = self.DI.process_individual_image(i, >self.vars.theimageblank1) > File "sge_2.0.1.py", line 1870, in process_individual_image > theimagetemp = ImageTk.PhotoImage(theimagetemp) > File "/usr/lib/python/site-packages/PIL/ImageTk.py", line 83, in __init__ > self.paste(image) > File "/usr/lib/python/site-packages/PIL/ImageTk.py", line 113, in paste > self.__photo.tk.call("PyImagingPhoto", self.__photo, block.id) >TclError: invalid command name "PyImagingPhoto" >rsomerfield at FullCycle:~/SGE/sge > > > From rich_somerfield at tertio.com Mon Feb 26 10:17:14 2001 From: rich_somerfield at tertio.com (Rich Somerfield) Date: Mon, 26 Feb 2001 09:17:14 -0000 Subject: Tkinter problems References: <976cgv$4ii$0@216.39.170.247> Message-ID: Sounds like u might have hit the nail on the head. I was having problems recompiling Tkinter [path problem!!]: bash-2.03# python setup.py install running install Traceback (most recent call last): File "setup.py", line 25, in ? long_description = __doc__ File "/usr/bin/python-2.0/Lib/distutils/core.py", line 138, in setup dist.run_commands() File "/usr/bin/python-2.0/Lib/distutils/dist.py", line 829, in run_commands self.run_command(cmd) File "/usr/bin/python-2.0/Lib/distutils/dist.py", line 848, in run_command cmd_obj.ensure_finalized() File "/usr/bin/python-2.0/Lib/distutils/cmd.py", line 112, in ensure_finalized self.finalize_options() File "/usr/bin/python-2.0/Lib/distutils/command/install.py", line 255, in fina lize_options (prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix') File "/usr/bin/python-2.0/Lib/distutils/sysconfig.py", line 368, in get_config _vars func() File "/usr/bin/python-2.0/Lib/distutils/sysconfig.py", line 280, in _init_posi x raise DistutilsPlatformError, my_msg distutils.errors.DistutilsPlatformError: invalid Python installation: unable to open /usr/local/lib/python2.0/config/Makefile (No such file or directory) bash-2.03# I dont suppose u know the correct command line arguments to build Tkinter? I couldnt find any documentation with the tar that i downloaded and the help from the setup.py that was included didnt really suggest the best / exact method. My Python distro is in "/usr/bin/python-2.0", i cant find anything that specifies where the Python install resides [ the problem with the above command is that it is looking in /usr/local/lib/python2.0 !!!! - WRONG PATH]. If i do download a later version of Tk, do i need to recompile Python2.0 AND Tkinter?? Or will Python pick up the libraries dynamically?? Regards Rich Dave LeBlanc wrote in message news:976cgv$4ii$0 at 216.39.170.247... > Oh, it's just a guess, but i'd say the version of tkinter you're > trying to use is incompatible with the version of python you're trying > to use. > > Possible causes: > Python 2.0 is finding an older version of tkinter (perhaps > associated with a Python 1.5.2 or 1.6.0 install?). > > You downloaded tkinter and python at different times. > > You recompiled Python but not tkinter. > > My suggestion would be to get a standard python 2.0 distro with > tkinter included (does it actually come any other way?) and build and > install the whole mass at once. > > BTW, Tcl 8.0.4 is _hopelessly_ out of date, having been superceded by > Tcl 8.0.5 long ago (not to mention many further versions not used with > the Python 1.5.2 version of tkinter). AFAIK from reading, tkinter for > Python 2.0 now uses Tcl 8.3.2 which, as always, is available through > www.scriptics.com at sourceforge. > > HTH > > On Thu, 22 Feb 2001 15:00:52 -0000, "Rich Somerfield" > wrote: > > >I get the following exception when trying to load a jpeg image. > > > >My system is Linux SuSE6.4 (however I have downloaded and recompiled Python > >and PIL - the original versions had the same problem, i thought it would go > >away if i upgraded, it didnt.) Python 2.0 / Pil 1.1.1 / Tk 8.0.4 > > > >I have been using my code successfully using the py15 installation from > >PythonWare. > > > >BTW, what is the problem with my Python interpreter?? The Warning msg about > >the API version. > > > > > >Regards > >Rich > > > > > >rsomerfield at FullCycle:~/SGE/sge > python sge_2.0.1.py > >WARNING: Python C API version mismatch for module _tkinter: > > This Python has API version 1009, module _tkinter has version 1007. > >WARNING: Python C API version mismatch for module _imaging: > > This Python has API version 1009, module _imaging has version 1007. > >Traceback (most recent call last): > > File "sge_2.0.1.py", line 4585, in ? > > sge = SimpleGameEngine() > > File "sge_2.0.1.py", line 141, in __init__ > > exec("self.main_function()") > > File "", line 1, in ? > > File "sge_2.0.1.py", line 123, in main_function > > self.TG.produce_board_locations() > > File "sge_2.0.1.py", line 1807, in produce_board_locations > > self.vars.boardlocationimages[i] = self.DI.process_individual_image(i, > >self.vars.theimageblank1) > > File "sge_2.0.1.py", line 1870, in process_individual_image > > theimagetemp = ImageTk.PhotoImage(theimagetemp) > > File "/usr/lib/python/site-packages/PIL/ImageTk.py", line 83, in __init__ > > self.paste(image) > > File "/usr/lib/python/site-packages/PIL/ImageTk.py", line 113, in paste > > self.__photo.tk.call("PyImagingPhoto", self.__photo, block.id) > >TclError: invalid command name "PyImagingPhoto" > >rsomerfield at FullCycle:~/SGE/sge > > > > > > From NoSpam at NoSpam.com Thu Feb 22 17:59:08 2001 From: NoSpam at NoSpam.com (Tom) Date: Thu, 22 Feb 2001 16:59:08 GMT Subject: icons for python types?? Message-ID: I'm looking for icons to represent the standard python types (eg. function, integer, frame). Thanks, Tom. From cook at maya.com Thu Feb 22 18:07:21 2001 From: cook at maya.com (Nicole Cook) Date: Thu, 22 Feb 2001 12:07:21 -0500 Subject: another newboe mxodbc quest. -- update set Message-ID: <000d01c09cf1$ebd79740$21fe46c0@maya.com> I'm running python 1.5.2 on windows98 and using mxODBC to talk to an Access database. I'm having no trouble reading information from the database, but now I want to write something to a column. So I do : db = ODBC.Windoes.connect("accessdb") cs = db.cursor() cs.execute("UPDATE Project SET Item='"+item+"' WHERE Name='"+name+"'") When I do this from the interpreter it returns 1, when I use it as a line in a function Access freezes until I quit python. Either way, nothing happens to the column in the db that I'm trying to write. Is there something else I have to do to get mxODBC to execute an update? Nicole From db3l at fitlinxx.com Sat Feb 24 02:08:21 2001 From: db3l at fitlinxx.com (David Bolen) Date: 23 Feb 2001 20:08:21 -0500 Subject: another newboe mxodbc quest. -- update set References: Message-ID: "Nicole Cook" writes: > I'm running python 1.5.2 on windows98 and using mxODBC to talk to an Access > database. I'm having no trouble reading information from the database, but > now I want to write something to a column. > > So I do : > db = ODBC.Windoes.connect("accessdb") > cs = db.cursor() > > cs.execute("UPDATE Project SET Item='"+item+"' WHERE Name='"+name+"'") > > When I do this from the interpreter it returns 1, when I use it as a line > in a function Access freezes until I quit python. Either way, nothing > happens to the column in the db that I'm trying to write. Is there > something else I have to do to get mxODBC to execute an update? As far as an actual command goes, it looks ok (barring bad values in either item or name that might mess up the quoting - you might want to check that for debugging purposes). Could you provide additional samples of the code - particularly how it is used within the function? As for seeing the change - mxODBC (conforming to the DB-API 2.0) sets any database that supports transactions to use them by default. I'm not familiar enough with Access (which I'm guessing your using with the default Jet engine?) to know if it supports them, but if it does, then you won't see your change until you db.commit(). So if you just exit your script (or drop the database connection object), your changes will be rolled back. mxODBC has an mxODBC specific named parameter on the connect() call "clear_auto_commit" which can be used to defeat this default behavior, as in: db = ODBC.Windows.connect(,clear_auto_commit=0) which will let the database's default transaction behavior take over. That may or may not still require you to commit, depending on the database and your ODBC definition for that database. -- -- 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 embed at geocities.com Thu Feb 22 18:22:40 2001 From: embed at geocities.com (Warren Postma) Date: Thu, 22 Feb 2001 12:22:40 -0500 Subject: Randomize list order Message-ID: You know, an in-place list.scramble() method would be nice; It could also be useful card games and self test scripts. ;-) I even have another use for it.... I have a BSDDB B+Tree file that when created all in one fell swoop, likes to have its primary keys inserted in Chaotic order. So, I wonder, is there a better way to scramble my keys, or is this the most efficient way (lambda would be less efficient even if on one line, since it would be generating the necessary functions on demand, more or less, right?). Warren ---- # scramble a list: import random def _scr1(a): "turns item a into (random#,a) pairs" return (random.randint(0,1000000),a) def _scr2(a): "gets x from (random#,x) pairs" return a[1] def _scramble_list( l ): "return a scrambled version of the list l. used by lwdb_btree files when packing, to insert the new rows in random order." n = map( _scr1, l) # create [ ( random1, keyvalue1), .... ] pairs n.sort() # sort by random numbers (scrambles list) return map( _scr2, n) # return back just the actual key values From fredrik at pythonware.com Thu Feb 22 18:43:17 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 22 Feb 2001 17:43:17 GMT Subject: Randomize list order References: Message-ID: Warren Postma write: > You know, an in-place list.scramble() method would be nice; > It could also be useful card games and self test scripts. ;-) random.shuffle(list) Cheers /F From embed at geocities.com Thu Feb 22 19:02:03 2001 From: embed at geocities.com (Warren Postma) Date: Thu, 22 Feb 2001 13:02:03 -0500 Subject: Randomize list order References: Message-ID: > random.shuffle(list) > > Cheers /F Doh! ;-) From tim.one at home.com Fri Feb 23 05:19:40 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 22 Feb 2001 23:19:40 -0500 Subject: Randomize list order In-Reply-To: Message-ID: [Warren Postma, wants to shuffle] [/F] > random.shuffle(list) [Warren] > Doh! ;-) Not your fault! For some reason (or utter lack of reason ...), random.shuffle() never made it into the docs. The docs for random were extensively reworked for 2.1, and several new features added. And shuffle() is documented now. From worm at gdp-group.com Thu Feb 22 18:30:11 2001 From: worm at gdp-group.com (Thomas Volkmar Worm) Date: Thu, 22 Feb 2001 18:30:11 +0100 Subject: Module rfc822 - uses file-objects - why? Message-ID: <3A954CA3.72A6D51C@gdp-group.com> Hi, I started to write a little programm which reads mails from a POP3 account. To handle the message I thought, I use the rfc822 module or one of its subclasses (mimetools). But the methods I want to use always expect file-objects as parameters. Do I need to store every list/string onto disk when I want to use these classes or methods on them? To solve the problem I started to write a helper class which implements methods like readline for my objects, but I really do not want to write an emulation of the file-class again and again for each object I create. It seems to me very odd to do this, so I guess there is another much more clever way to use these classes without having files at all. Regards Thomas -------------- next part -------------- A non-text attachment was scrubbed... Name: worm.vcf Type: text/x-vcard Size: 366 bytes Desc: Visitenkarte f?r Thomas Volkmar Worm URL: From fredrik at pythonware.com Thu Feb 22 18:43:15 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 22 Feb 2001 17:43:15 GMT Subject: Module rfc822 - uses file-objects - why? References: <3A954CA3.72A6D51C@gdp-group.com> Message-ID: Thomas Volkmar Worm wrote: > I started to write a little programm which reads mails from a POP3 > account. To handle the message I thought, I use the rfc822 module or one > of its subclasses (mimetools). But the methods I want to use always > expect file-objects as parameters. Do I need to store every list/string > onto disk when I want to use these classes or methods on them? import StringIO file = StringIO.StringIO(data) see the library reference for details. Cheers /F From aahz at panix.com Thu Feb 22 18:50:01 2001 From: aahz at panix.com (Aahz Maruch) Date: 22 Feb 2001 09:50:01 -0800 Subject: Module rfc822 - uses file-objects - why? References: <3A954CA3.72A6D51C@gdp-group.com> Message-ID: <973jg9$dcj$1@panix3.panix.com> In article , Fredrik Lundh wrote: >Thomas Volkmar Worm wrote: >> >> I started to write a little programm which reads mails from a POP3 >> account. To handle the message I thought, I use the rfc822 module or one >> of its subclasses (mimetools). But the methods I want to use always >> expect file-objects as parameters. Do I need to store every list/string >> onto disk when I want to use these classes or methods on them? > >import StringIO >file = StringIO.StringIO(data) For performance: try: from StringIO import StringIO except ImportError: from cStringIO import StringIO (I learned that idiom back when cStringIO wasn't automatically compiled; I'm not sure it's necessary anymore.) -- --- 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 "I used to have a .sig but I found it impossible to please everyone..." --SFJ From barry at digicool.com Thu Feb 22 22:46:13 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Thu, 22 Feb 2001 16:46:13 -0500 Subject: Module rfc822 - uses file-objects - why? References: <3A954CA3.72A6D51C@gdp-group.com> <973jg9$dcj$1@panix3.panix.com> Message-ID: <14997.34981.147019.748162@anthem.wooz.org> >>>>> "AM" == Aahz Maruch writes: AM> (I learned that idiom back when cStringIO wasn't automatically AM> compiled; I'm not sure it's necessary anymore.) I'm not sure either, but I still do it that way too. Old habits 'n' all... -Barry From stephen_purcell at yahoo.com Fri Feb 23 08:07:51 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Fri, 23 Feb 2001 08:07:51 +0100 Subject: Module rfc822 - uses file-objects - why? In-Reply-To: <973jg9$dcj$1@panix3.panix.com>; from aahz@panix.com on Thu, Feb 22, 2001 at 09:50:01AM -0800 References: <3A954CA3.72A6D51C@gdp-group.com> <973jg9$dcj$1@panix3.panix.com> Message-ID: <20010223080751.A7076@freedom.puma-ag.com> Aahz Maruch wrote: > For performance: > > try: > from StringIO import StringIO > except ImportError: > from cStringIO import StringIO Or for even better performance: try: from cStringIO import StringIO except ImportError: from StringIO import StringIO Pedantic, but someone might try it the other way round and post a bunch of messages complaining that it's too slow... :-) -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 annis at biostat.wisc.edu Thu Feb 22 18:53:03 2001 From: annis at biostat.wisc.edu (William Annis) Date: 22 Feb 2001 11:53:03 -0600 Subject: Module rfc822 - uses file-objects - why? References: <3A954CA3.72A6D51C@gdp-group.com> Message-ID: Thomas Volkmar Worm writes: > Do I need to store every list/string > onto disk when I want to use these classes or methods on them? > > To solve the problem I started to write a helper class which implements > methods like readline for my objects, but I really do not want to write > an emulation of the file-class again and again for each object I create. You have solved a problem other people have had and solved already. The StringIO class -- part of standard Python -- can be used to make strings act like files: http://www.python.org/doc/current/lib/module-StringIO.html -- 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 echuck at mindspring.com Thu Feb 22 19:10:48 2001 From: echuck at mindspring.com (Chuck Esterbrook) Date: Thu, 22 Feb 2001 13:10:48 -0500 Subject: Duplicate modules problem Message-ID: <5.0.2.1.0.20010222130757.04aaeb80@mail.mindspring.com> You can find a tarball with this description and accompanying source code at: ftp://webware.sourceforge.net/pub/webware/ModulesProb01.tar.gz I have a problem where Python creates duplicate modules in memory rather than reuse the same one. For example, a module in Pkg/Mod.py ends up in sys.modules under keys "Pkg.Mod" and "Mod" **pointing to two distinct modules**. This creates further problems: Suppose a module Foo.py contains a class named Foo. If the module is loaded twice as two separate instances (of ModuleType), then there are 2 separate Foo classes. This causes confusion including the failure of an assertion such as: assert issubclass(foo, Foo) The Foo in that code may be pointing to the first class, while the instance foo may have been created from the second class. The assertion then fails! The problem stems from the fact that Python tracks modules by a relative, rather than absolute, path. A simple os.chdir() or a subtley in packages can cause this problem. This problem is easiest to see in an os.chdir() situation: C:\>mkdir foo C:\>cd foo C:\foo>mkdir bar C:\foo>cd bar C:\foo\bar>echo class baz: pass > baz.py C:\foo\bar>echo ### > __init__.py C:\foo\bar>cd .. C:\foo>python ActivePython 2.0, build 202 (ActiveState Tool Corp.) based on Python 2.0 (#8, Oct 19 2000, 11:30:05) [MSC 32 bit (Intel)] on win32 >>> from bar.baz import baz as baz1 >>> import os >>> os.chdir('bar') >>> from baz import baz as baz2 >>> baz1 >>> baz2 >>> baz1 == baz2 0 >>> import sys >>> [mod for mod in sys.modules.items() if mod[0].count('baz')] [('baz', ), ('bar.baz', )] >>> mod1 = sys.modules['bar.baz'] >>> mod2 = sys.modules['baz'] >>> id(mod1) 136147728 >>> id(mod2) 136147744 This problem can also be seen without any use of os.chdir(). See ManufactureWare/ which contains the "assert issubclass(foo, Foo)" problem described above. This all applies to Python 2.0 on Windows & UNIX. I haven't tried 2.1 yet. I believe the solution is for Python to track modules by their absolute path. I don't know of any other resolution to the situation other than modifying Python in this manner. I also don't know of any disadvantage for Python to track modules by absolute path. - Does anyone know of any workarounds? - Does anyone know why it would be bad for Python to track modules by absolute path? - Is there any chance Python will fix this in the future? - If so, by 2.1? -Chuck ftp://webware.sourceforge.net/pub/webware/ModulesProb01.tar.gz From ben.hutchings at roundpoint.com Fri Feb 23 03:51:08 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 22 Feb 2001 18:51:08 -0800 Subject: Duplicate modules problem References: Message-ID: Chuck Esterbrook writes: > I have a problem where Python creates duplicate modules in memory rather > than reuse the same one. For example, a module in Pkg/Mod.py ends up in > sys.modules under keys "Pkg.Mod" and "Mod" **pointing to two distinct > modules**. > The problem stems from the fact that Python tracks modules by a relative, > rather than absolute, path. A simple os.chdir() or a subtley in packages > can cause this problem. Python doesn't track paths at all. It has a name-indexed cache of modules, accessible as sys.modules, which the import statement checks and updates. It's entirely possible to load modules without checking the cache and/or without updating the cache. It's also possible to create a Python environment with all modules pre-loaded from some location which might not be a file at all. > I believe the solution is for Python to track modules by their > absolute path. I don't know of any other resolution to the situation > other than modifying Python in this manner. I also don't know of > any disadvantage for Python to track modules by absolute path. File/directory linking in Unix means that a single file can have multiple paths, and as I said above some environments don't load modules from files at all. So your 'solution' would just move the problem (a problem which you've created for yourself by abusing the import statement, IMHO). I think the real solution is to set the Python module path appropriately and to give consistent module names to the import statement. If the behaviour of the import statement really isn't what you want, use the lower-level module import functions. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From tshumway at transafari.com Fri Feb 23 04:05:46 2001 From: tshumway at transafari.com (Terrel Shumway) Date: Thu, 22 Feb 2001 22:05:46 -0500 Subject: [Webware-discuss] Duplicate modules problem References: <5.0.2.1.0.20010222130757.04aaeb80@mail.mindspring.com> Message-ID: <3A95D38A.84F455AD@transafari.com> > I believe the solution is for Python to track modules by their absolute > path. I don't know of any other resolution to the situation other than > modifying Python in this manner. I also don't know of any disadvantage for > Python to track modules by absolute path. > > - Does anyone know of any workarounds? The workaround is surprisingly easy: 1) replace all non-absolute paths in sys.path (especially ""). 2) make sure that no module is accessible from more than one of these roots (sufficent condition: no name in sys.path is a prefix of any other.) This will make some things slightly less convenient (you will have to think more carefully about your directory structure), but it will prevent you from shooting yourself in the foot by importing a module from two different places. Python 2.0 (#5, Dec 5 2000, 17:59:47) [GCC 2.96 20000731 (Red Hat Linux 7.0)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import sys >>> from pprint import pprint as pp >>> import os >>> pp(sys.path) ['', '/usr/local/lib/python2.0', '/usr/local/lib/python2.0/plat-linux2', '/usr/local/lib/python2.0/lib-tk', '/usr/local/lib/python2.0/lib-dynload', '/usr/local/lib/python2.0/site-packages'] >>> os.getcwd() '/home/tshumway/projects/current/ModulesProb/foo' >>> sys.path[0]=os.getcwd() >>> from bar.baz import baz as baz1 >>> os.chdir("bar") >>> from baz import baz as baz2 Traceback (most recent call last): File "", line 1, in ? ImportError: No module named baz >>> from bar.baz import baz as baz2 >>> baz1==baz2 1 >>> pp(sys.path) ['/home/tshumway/projects/current/ModulesProb/foo', '/usr/local/lib/python2.0', '/usr/local/lib/python2.0/plat-linux2', '/usr/local/lib/python2.0/lib-tk', '/usr/local/lib/python2.0/lib-dynload', '/usr/local/lib/python2.0/site-packages'] >>> pp(sys.modules) {'UserDict': , '__builtin__': , '__main__': , 'bar': , 'bar.baz': , 'cStringIO': , .... Notice that although "/usr/local/lib/python2.0" is a prefix of four other names, those other names are carefully choosen to be illegal as package names. (e.g. import plat-linux.foo is a syntax error.) I think the default sys.path under Windows is not quite as clean. > > - Does anyone know why it would be bad for Python to track modules by > absolute path? It would make it more difficult to move modules around. (Java demonstrates this.) Tool support would help: it is easy to search for import statements. > > - Is there any chance Python will fix this in the future? Hmmm. Seems like it does not really need a fix from On High: only a widely-published HOWTO documenting the problem and the solution. HTH -- Terrel FactoryKit/main.py: ------------------- # main.py # Make sure FactoryKit is reachable, since widgets # will want to import FactoryKit.Widget. try: import FactoryKit except ImportError: import os, sys # XXX dangerous: should make sure it is really replacing "" sys.path[0] = os.path.abspath(os.pardir) import FactoryKit from FactoryKit import Factory # A simple "import Factory" raises an exception, as it should. # Since __main__ does not belong to the FactoryKit package, # it cannot use the package-relative import shortcuts Factory.LoadAndMakeWidget('Examples/ExampleWidget.py') From echuck at mindspring.com Fri Feb 23 04:12:11 2001 From: echuck at mindspring.com (Chuck Esterbrook) Date: Thu, 22 Feb 2001 22:12:11 -0500 Subject: [Webware-discuss] Duplicate modules problem In-Reply-To: <3A95D38A.84F455AD@transafari.com> References: <5.0.2.1.0.20010222130757.04aaeb80@mail.mindspring.com> Message-ID: <5.0.2.1.0.20010222220319.04758a60@mail.mindspring.com> At 10:05 PM 2/22/2001 -0500, Terrel Shumway wrote: > > - Does anyone know why it would be bad for Python to track modules by > > absolute path? > >It would make it more difficult to move modules around. (Java demonstrates >this.) Tool support would help: it is easy to search for import statements. I don't follow that at all. This is strictly a run time phenomena. Who wants to move modules once the program starts? > > - Is there any chance Python will fix this in the future? > >Hmmm. Seems like it does not really need a fix from On High: only a >widely-published HOWTO documenting the problem and the solution. Well unless your previous comment pans out, there doesn't seem to be a reason to track them by relative path. And since doing so leads to problems, it seems that an On High fix would be more appropriate than considering the situation to be OK simply because it's documented. Also, I'm not really sure if I want to replace '' in sys.path. I thought that was there as a relative path to the current module (not the current directory) and therefore helped a given file Foo.py say "import Bar from Bar" where Bar.py resided in the same package. Particularly if you didn't even import Foo directly. Am I wrong about that? As Geoff pointed out, we most likely encountered this problem because we're running a program out of a package, which is uncommon. I tried Geoff's fix on the example code I wrote and it worked like a charm. I'll try it on Webware next. If the fix pans out for Webware, that will be great, but unless there is a concrete advantage to tracking packages by relative path, I still recommend a change in Python to track modules by absolute path. That would eliminate accidently getting 2 distinct copies of the same module for any Python program. Thanks for the input, -Chuck From tshumway at transafari.com Fri Feb 23 17:29:03 2001 From: tshumway at transafari.com (Terrel Shumway) Date: Fri, 23 Feb 2001 11:29:03 -0500 Subject: [Webware-discuss] Duplicate modules problem References: <5.0.2.1.0.20010222130757.04aaeb80@mail.mindspring.com> <5.0.2.1.0.20010222220319.04758a60@mail.mindspring.com> Message-ID: <3A968FCF.31ABEE10@transafari.com> Chuck Esterbrook wrote: > At 10:05 PM 2/22/2001 -0500, Terrel Shumway wrote: > > > - Does anyone know why it would be bad for Python to track modules by > > > absolute path? > > > >It would make it more difficult to move modules around. (Java demonstrates > >this.) Tool support would help: it is easy to search for import statements. > > I don't follow that at all. This is strictly a run time phenomena. Who > wants to move modules once the program starts? No, this is not a runtime problem, it is a refactoring-time problem. In Java, just try renaming a package and see how long it takes you to get a clean compile without using a tool like WoodenChair. The people who designed Python's hierarchical package system wanted people to be able to gather modules and packages into packages without breaking them. The package relative import is a fairly clean solution to this fairly nasty problem. Tool support would be helpful for external code that uses the moved modules. Consider this very very simple scenario: ham.py --- class Ham:... eggs.py --- class Eggs... class Dozen... spam.py --- from ham import Ham from eggs import EggMixin class Spam(Ham,EggMixin):... class Can... spam_eater.py --------- from spam import Spam import eggs factory = Spam() breakfast = factory.getCan() breakfast.eat() lunch = eggs.Dozen() lunch.eat() supper = Eggs.leftovers((breakfast,lunch)) supper.eat("Yum,yum!") spam_eater is an application that uses ham, eggs, and spam as library modules. Suppose now that we wanted to serve Spam and Eggs over HTTP. We could just dump all of these modules into the same directory with Request,Response,Servlet, et.al., (or, equivalently, add the directory to sys.path) but that would not be clean. Lets put them together into a package: FoodKit. FoodKit +- __init__.py +- spam.py +- ham.py +- eggs.py bin +- spam_eater.py Now in our web server we can say: import FoodKit serveit = FoodKit.spam.Can() spam,eggs,and ham will work without modification. spam_eater would too, if we had put it in the package, but we decided that we shouldn't mix applications and libraries. Since FoodKit is not in sys.path (If it were, we would get the nasty duplicate module problems that started this thread.) spam_eater gets an ImportError because it cannot find spam or eggs. The solution is to add the package name, just as the web server does. from FoodKit.spam import Spam from FoodKit import eggs Finding and fixing all of these broken import statements is what tools can do. Note that the problem would be much larger without the package relative imports. (cf. Java) Also note that this example is extremely simple. A more realistic scenario would probably involve multiple packages and dozens of modules. Without tool support, this type of refactoring tends to get put off until it is really nasty. > Also, I'm not really sure if I want to replace '' in sys.path. I thought > that was there as a relative path to the current module (not the current > directory) and therefore helped a given file Foo.py say "import Bar from > Bar" where Bar.py resided in the same package. Particularly if you didn't > even import Foo directly. Am I wrong about that? No, the package relative import works without "" in sys.path. > As Geoff pointed out, we most likely encountered this problem because we're > running a program out of a package, which is uncommon. I tried Geoff's fix > on the example code I wrote and it worked like a charm. I'll try it on > Webware next. A program (script) running within a package, if it tries to use the package relative imports, is broken. __main__ is in the default package. Trying to use relative imports from __main__ is breaking the package encapsulation. > If the fix pans out for Webware, that will be great, but unless there is a > concrete advantage to tracking packages by relative path, There is a concrete advantage: a library module does not need to know where it is in the package hierarchy. Renaming the package does not require any code changes, as it does for example in Java, which uses absolute names. Only external clients need code changes. > I still recommend > a change in Python to track modules by absolute path. That would eliminate > accidently getting 2 distinct copies of the same module for any Python program. Python does track modules by *filename*. If all of the names in sys.path are absolute, then you can never get a filename that is not absolute. -- Terrel From echuck at mindspring.com Fri Feb 23 20:31:29 2001 From: echuck at mindspring.com (Chuck Esterbrook) Date: Fri, 23 Feb 2001 14:31:29 -0500 Subject: Duplicate modules problem Message-ID: <5.0.2.1.0.20010223142751.047993f0@mail.mindspring.com> In summary, the problem is that when launching a program from within a Python package, confusion can result about paths of modules resulting in duplicate modules residing in memory (and therefore duplication classes (and therefore problems with isinstance())). The solution was to provide a Launch.py program that essentially does an "os.chdir(os.pardir))" before importing the package, its "starter" module and invoking main(). Also, a "if '' not in sys.path: sys.path.insert(0, '')" was needed to fix problems when starting with "Launch.py" rather than "python Launch.py". Overall this solution is pretty small and keeps things straight. Thanks to Geoff Talvola for the fix and everyone else for their input. -Chuck "Chuck Esterbrook" wrote in message news:... >You can find a tarball with this description and accompanying source code at: > ftp://webware.sourceforge.net/pub/webware/ModulesProb01.tar.gz >I have a problem where Python creates duplicate modules in memory rather >than reuse the same one. For example, a module in Pkg/Mod.py ends up in >sys.modules under keys "Pkg.Mod" and "Mod" **pointing to two distinct >modules**. >This creates further problems: Suppose a module Foo.py contains a class >named Foo. If the module is loaded twice as two separate instances (of >ModuleType), then there are 2 separate Foo classes. This causes confusion >including the failure of an assertion such as: > assert issubclass(foo, Foo) >The Foo in that code may be pointing to the first class, while the >instance foo may have been created from the second class. The assertion >then fails! >The problem stems from the fact that Python tracks modules by a relative, >rather than absolute, path. A simple os.chdir() or a subtley in packages >can cause this problem. >This problem is easiest to see in an os.chdir() situation: >C:\>mkdir foo >C:\>cd foo >C:\foo>mkdir bar >C:\foo>cd bar >C:\foo\bar>echo class baz: pass > baz.py >C:\foo\bar>echo ### > __init__.py >C:\foo\bar>cd .. >C:\foo>python >ActivePython 2.0, build 202 (ActiveState Tool Corp.) >based on Python 2.0 (#8, Oct 19 2000, 11:30:05) [MSC 32 bit (Intel)] on win32 > >>> from bar.baz import baz as baz1 > >>> import os > >>> os.chdir('bar') > >>> from baz import baz as baz2 > >>> baz1 > > >>> baz2 > > >>> baz1 == baz2 >0 > >>> import sys > >>> [mod for mod in sys.modules.items() if mod[0].count('baz')] >[('baz', ), > ('bar.baz', )] > >>> mod1 = sys.modules['bar.baz'] > >>> mod2 = sys.modules['baz'] > >>> id(mod1) >136147728 > >>> id(mod2) >136147744 > >This problem can also be seen without any use of os.chdir(). See >ManufactureWare/ which contains the "assert issubclass(foo, Foo)" problem >described above. >This all applies to Python 2.0 on Windows & UNIX. I haven't tried 2.1 yet. >I believe the solution is for Python to track modules by their absolute >path. I don't know of any other resolution to the situation other than >modifying Python in this manner. I also don't know of any disadvantage for >Python to track modules by absolute path. >- Does anyone know of any workarounds? >- Does anyone know why it would be bad for Python to track modules by >absolute path? >- Is there any chance Python will fix this in the future? >- If so, by 2.1? > >-Chuck >ftp://webware.sourceforge.net/pub/webware/ModulesProb01.tar.gz From echuck at mindspring.com Fri Feb 23 21:58:02 2001 From: echuck at mindspring.com (Chuck Esterbrook) Date: Fri, 23 Feb 2001 15:58:02 -0500 Subject: Duplicate modules problem In-Reply-To: <3A96C967.4D3420EE@transafari.com> References: <5.0.2.1.0.20010223142751.047993f0@mail.mindspring.com> Message-ID: <5.0.2.1.0.20010223153906.047404f0@mail.mindspring.com> At 03:34 PM 2/23/2001 -0500, Terrel Shumway wrote: >Chuck Esterbrook wrote: > > > In summary, the problem is that when launching a program from within a > > Python package, confusion can result about paths of modules resulting in > > duplicate modules residing in memory (and therefore duplication classes > > (and therefore problems with isinstance())). > > > > The solution was to provide a Launch.py program that essentially does an > > "os.chdir(os.pardir))" before importing the package, its > > "starter" module and invoking main(). > >I don't understand why this is necessary. It seems much cleaner to me to >just be careful about sys.path and use the correct import statements. Um, I never had any incorrect or abusive use of import statements. When a file sat in the same directory, I said: from Foo import Foo When it sat in an external package, I said: from Pkg.Foo import Foo I learned these conventions from Python. I didn't invent them. Perhaps I had an "incorrect" situation if it was never intended that programs start out of their own packages. > > Also, a "if '' not in sys.path: sys.path.insert(0, '')" was needed to fix > > problems when starting with "Launch.py" rather than "python Launch.py". > > > >Please explain this problem. Can you show us Lauch.py and examples of its use? You can get it from CVS: https://sourceforge.net/cvs/?group_id=4866 See WebKit/Launch.py. Again, the problem is when running a program out of a package. And if you don't mind duplicate modules, you don't need the fix. But duplicates eventually lead to subtle, arcane bugs. We need the fix in WebKit. See more below. >I think having "" in sys.path is just asking for trouble, but oh well -- >leave it in if you like. The ManufactureWare/FactoryKit/main.py works >fine if you correct the broken import statement. __main__ is not part of >the package and cannot use the relative import shortcut: "from FactoryKit >import Factory" is the correct import. Removing "" from sys.path just >makes the breakage more visible. Regarding the import, the fix does what you describe: Makes the package explicit to the program. Regarding '' in sys.path, if you say: > python someprog.py you get '' as the first element in the path. Again that's Python, not me. However, if you say: > someprog.py then you get an absolute path in place of ''. Geoff ran into this first and it caused problems, hence the fix. Since the fix puts you back to the sys.path you would have gotten from Python anyway (by launching differently), it doesn't feel so evil to me. Regarding my choice of: os.chdir(os.pardir) I could done something like this instead: sys.path.insert(1, os.path.abspath(os.pardir)) The first seemed a tad simpler. Also, regarding the use of Launch.py, I might have chosen to bake this directly into the app server, BUT the problem is that we have at least 2 of them and will be adding another in the future. Also, Launch.py is a very small, very clean file, making it easier to deal with independent of all that goes on inside the app server source files. I have been flexing the plug-ins, examples and test cases for WebKit and things are working good. At the very least, they're working much better than before, even if Launch.py doesn't suit your taste. The standard way to launch the app server is still: > cd Webware/WebKit > ./AppServer -Chuck -- Get web dev at http://webware.sourceforge.net/ From db3l at fitlinxx.com Sat Feb 24 02:34:26 2001 From: db3l at fitlinxx.com (David Bolen) Date: 23 Feb 2001 20:34:26 -0500 Subject: Duplicate modules problem References: <5.0.2.1.0.20010223142751.047993f0@mail.mindspring.com> Message-ID: Chuck Esterbrook writes: > Regarding '' in sys.path, if you say: > > python someprog.py > > you get '' as the first element in the path. Again that's Python, not me. > > However, if you say: > > someprog.py > > then you get an absolute path in place of ''. Geoff ran into this first and > it caused problems, hence the fix. Since the fix puts you back to the > sys.path you would have gotten from Python anyway (by launching > differently), it doesn't feel so evil to me. I expect that in both cases Python is just consistently taking the dirname off of the script it is supplied on the command line and inserting it as the first search entry (to include the script location for imports). When you run the script directly in the second case, I expect the surrounding environment (Windows?) is using the full path when it calls python. > Regarding my choice of: > os.chdir(os.pardir) > > I could done something like this instead: > sys.path.insert(1, os.path.abspath(os.pardir)) You'd want to use 0 to put it at the front of the path, right? > The first seemed a tad simpler. Simpler, but also environmentally more damaging since it affects an OS environmental item that can affect non-Python code that might eventually run in the process. I'm not that familiar with how your application might be launched, but if there's any chance of this code path being imported and run that way (rather than directly from the command line), then I'd definitely vote for the latter, since the former changes the current directory for the existing process which might be unexpected by someone importing your launch module. Better to adjust a Python internal item such as sys.path than an OS-environment feature, at least IMHO. Even if it isn't generally expected to start that way, if there's any good reason someone might wrap that module in their own code it might prove unexpected. I seem to have missed a post or two in this thread on my server, so perhaps this violates some other requirement, but is there a reason you just can't remove the first entry from sys.path in your launcher? Since that's the location of the script, removing it would force Python to use the normal search path, which your package should already be on in order to be a package to Python? -- -- 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 patfourc at libertysurf.fr Thu Feb 22 19:41:23 2001 From: patfourc at libertysurf.fr (Liberty) Date: Thu, 22 Feb 2001 19:41:23 +0100 Subject: File browser Message-ID: <973mgo$l3o$1@news2.isdnet.net> Hello, I'm a french student looking for a file browser written in Python to include it in my study project. Does anyone got it ? Thanks From akuchlin at mems-exchange.org Thu Feb 22 20:02:50 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 22 Feb 2001 14:02:50 -0500 Subject: File browser References: <973mgo$l3o$1@news2.isdnet.net> Message-ID: <3dzofe35id.fsf@ute.cnri.reston.va.us> "Liberty" writes: > Hello, I'm a french student looking for a file browser written in Python to > include it in my study project. cfm (cfm.sourceforge.net) is a cute little file browser that uses curses. --amk From rickylee at americasm01.nt.com Thu Feb 22 20:32:50 2001 From: rickylee at americasm01.nt.com (Lee, Rick) Date: Thu, 22 Feb 2001 14:32:50 -0500 Subject: Any way for a function to refer to itself? Message-ID: <3A956962.3BBFED86@americasm01.nt.com> I can't find any other way for a function or method to refer to itself than something like the following: def foo(): myself = foo # only if foo is global mydoc = myself.__doc__ myname = myself.__name__ So it can be done this way, but: - only if the function name can actually be accessed from the current name space - if the function name changes, that first line inside this function also has to change Seems to me there should be a more "Pythonic" way of doing this. Is there? From jmarshal at mathworks.com Thu Feb 22 21:17:23 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 22 Feb 2001 20:17:23 GMT Subject: Any way for a function to refer to itself? References: <3A956962.3BBFED86@americasm01.nt.com> Message-ID: <973s4j$2h9$1@news.mathworks.com> Lee, Rick wrote: > I can't find any other way for a function or method to refer to itself > than something like the following: > def foo(): > myself = foo # only if foo is global > mydoc = myself.__doc__ > myname = myself.__name__ > So it can be done this way, but: > - only if the function name can actually be accessed from the current > name space > - if the function name changes, that first line inside this function > also has to change > Seems to me there should be a more "Pythonic" way of doing this. Is > there? It might be unpleasant, but you can do something like: def fib(f, x): if x < 2: return 1 return f(f, x-1) + f(f, x-2) print fib(fib, 10) From jmarshal at mathworks.com Thu Feb 22 21:22:16 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 22 Feb 2001 20:22:16 GMT Subject: Any way for a function to refer to itself? References: <3A956962.3BBFED86@americasm01.nt.com> <973s4j$2h9$1@news.mathworks.com> Message-ID: <973sdo$2no$1@news.mathworks.com> Joshua Marshall wrote: > Lee, Rick wrote: >> I can't find any other way for a function or method to refer to itself >> than something like the following: >> def foo(): >> myself = foo # only if foo is global >> mydoc = myself.__doc__ >> myname = myself.__name__ >> So it can be done this way, but: >> - only if the function name can actually be accessed from the current >> name space >> - if the function name changes, that first line inside this function >> also has to change >> Seems to me there should be a more "Pythonic" way of doing this. Is >> there? > It might be unpleasant, but you can do something like: > def fib(f, x): > if x < 2: return 1 > return f(f, x-1) + f(f, x-2) > print fib(fib, 10) And I guess if you don't like the idea of always having to pass your function in to itself, you can wrap it: def fib(x): def _fib(f, x): if x < 2: return 1 return f(f, x-1) + f(f, x-2) return _fib(_fib, x) print fib(10) From emile at fenx.com Fri Feb 23 05:44:34 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 22 Feb 2001 20:44:34 -0800 Subject: Any way for a function to refer to itself? References: <3A956962.3BBFED86@americasm01.nt.com> Message-ID: <974ptk$nsq9e$1@ID-11957.news.dfncis.de> I'm not sure if it always plays nice, but you may try starting with: >>> def test(): "test function description" import traceback me = eval( traceback.extract_stack()[-1][2]) print "DocString: %s functionName: %s " % (me.__doc__, me.__name__) >>> test() DocString: test function description functionName: test HTH -- Emile van Sebille emile at fenx.com ------------------- "Lee, Rick" wrote in message news:3A956962.3BBFED86 at americasm01.nt.com... > I can't find any other way for a function or method to refer to itself > than something like the following: > > def foo(): > myself = foo # only if foo is global > mydoc = myself.__doc__ > myname = myself.__name__ > > So it can be done this way, but: > > - only if the function name can actually be accessed from the current > name space > - if the function name changes, that first line inside this function > also has to change > > Seems to me there should be a more "Pythonic" way of doing this. Is > there? > From jmarshal at mathworks.com Fri Feb 23 15:24:28 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 23 Feb 2001 14:24:28 GMT Subject: Any way for a function to refer to itself? References: <3A956962.3BBFED86@americasm01.nt.com> <974ptk$nsq9e$1@ID-11957.news.dfncis.de> Message-ID: <975rqs$59o$1@news.mathworks.com> Emile van Sebille wrote: > I'm not sure if it always plays nice, but you may try > starting with: >>>> def test(): > "test function description" > import traceback > me = eval( traceback.extract_stack()[-1][2]) > print "DocString: %s functionName: %s " % (me.__doc__, > me.__name__) >>>> test() > DocString: test function description functionName: test This doesn't do what was asked - it only works if test is defined in the global namespace: def f(): def test(): "test function description" import traceback me = eval( traceback.extract_stack()[-1][2]) print "DocString: %s functionName: %s " % (me.__doc__, me.__name__) test() f() Yields: Traceback (innermost last): File "fu.py", line 10, in ? f() File "fu.py", line 8, in f test() File "fu.py", line 5, in test me = eval( traceback.extract_stack()[-1][2]) File "", line 0, in ? NameError: test From emile at fenx.com Fri Feb 23 17:37:15 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 23 Feb 2001 08:37:15 -0800 Subject: Any way for a function to refer to itself? References: <3A956962.3BBFED86@americasm01.nt.com> <974ptk$nsq9e$1@ID-11957.news.dfncis.de> <975rqs$59o$1@news.mathworks.com> Message-ID: <9763lt$o4vka$1@ID-11957.news.dfncis.de> Well then, it would need to be modified for additional namespaces. You could create a function that retrieves the traceback for the caller, uses linecache to determine the callers indentation level, walk up to the enclosing indentation level, (unless already global), examine globals for that name, verify it includes the right target name, and then you'd have it. See you, -- Emile van Sebille emile at fenx.com ------------------- "Joshua Marshall" wrote in message news:975rqs$59o$1 at news.mathworks.com... > Emile van Sebille wrote: > > I'm not sure if it always plays nice, but you may try > > starting with: > > >>>> def test(): > > "test function description" > > import traceback > > me = eval( traceback.extract_stack()[-1][2]) > > print "DocString: %s functionName: %s " % (me.__doc__, > > me.__name__) > > > >>>> test() > > DocString: test function description functionName: test > > This doesn't do what was asked - it only works if test is defined in > the global namespace: > > def f(): > def test(): > "test function description" > import traceback > me = eval( traceback.extract_stack()[-1][2]) > print "DocString: %s functionName: %s " % (me.__doc__, me.__name__) > > test() > > f() > > Yields: > > Traceback (innermost last): > File "fu.py", line 10, in ? > f() > File "fu.py", line 8, in f > test() > File "fu.py", line 5, in test > me = eval( traceback.extract_stack()[-1][2]) > File "", line 0, in ? > NameError: test From will at nospam.misconception.org.uk Thu Feb 22 20:43:00 2001 From: will at nospam.misconception.org.uk (Will Newton) Date: Thu, 22 Feb 2001 19:43:00 +0000 Subject: Python, Access and win32com Message-ID: <973pvb$ms8$1@newsg1.svr.pol.co.uk> I have been struggling to get MS Access 97 and the JET database engine to work with Active State Python and the win32com extensions. If I run daodump.py I get the following error: (Unfortuantely ASPython doesn't seem to have saved the log, why, I have no idea) com_error(-(a large number, INT_MAX?),CLASS_E_NOTLICENSED...) From gtalvola at nameconnector.com Thu Feb 22 21:23:30 2001 From: gtalvola at nameconnector.com (Geoff Talvola) Date: Thu, 22 Feb 2001 15:23:30 -0500 Subject: Python, Access and win32com References: <973pvb$ms8$1@newsg1.svr.pol.co.uk> Message-ID: <3A957542.476A501F@NameConnector.com> Will Newton wrote: > I have been struggling to get MS Access 97 and the JET database engine to > work with Active State Python and the win32com extensions. > > If I run daodump.py I get the following error: > > (Unfortuantely ASPython doesn't seem to have saved the log, why, I have no > idea) > > com_error(-(a large number, INT_MAX?),CLASS_E_NOTLICENSED...) It might be the problem described in http://support.microsoft.com/support/kb/articles/q189/6/07.asp in which case you can use the FixDAO function in the attached module to fix the problem. -- - Geoff Talvola Parlance Corporation gtalvola at NameConnector.com -------------- next part -------------- import win32api, win32con, win32com.client, win32com.client.gencache def FixDAO(): """ If DAO.DBEngine.35 cannot be created, this function will fix up the licensing Registry variables necessary so that it can be created. """ try: key = win32api.RegOpenKeyEx(win32con.HKEY_CLASSES_ROOT,'LICENSES\\F4FC596D-DFFE-11CF-9551-00AA00A3DC45',0,win32con.KEY_SET_VALUE|win32con.KEY_READ) except: key = win32api.RegCreateKey(win32con.HKEY_CLASSES_ROOT,'LICENSES\\F4FC596D-DFFE-11CF-9551-00AA00A3DC45') if win32api.RegQueryValue(key,'') != 'mbmabptebkjcdlgtjmskjwtsdhjbmkmwtrak': win32api.RegSetValue(key, '', win32con.REG_SZ, 'mbmabptebkjcdlgtjmskjwtsdhjbmkmwtrak') def DAO(): """ Create and return a DAO.DBEngine.35 object using early-bound automation """ # make sure that the makepy imformation has been generated win32com.client.gencache.EnsureModule('{00025E01-0000-0000-C000-000000000046}', 0, 4, 0) # Try to create the DAO object; if it fails, fix the licensing and try again. try: return win32com.client.Dispatch('DAO.DBEngine.35') except: FixDAO() return win32com.client.Dispatch('DAO.DBEngine.35') From timr at probo.com Fri Feb 23 07:11:02 2001 From: timr at probo.com (Tim Roberts) Date: Thu, 22 Feb 2001 22:11:02 -0800 Subject: Python, Access and win32com References: <973pvb$ms8$1@newsg1.svr.pol.co.uk> Message-ID: Will Newton wrote: > >I have been struggling to get MS Access 97 and the JET database engine to >work with Active State Python and the win32com extensions. > >If I run daodump.py I get the following error: > >(Unfortuantely ASPython doesn't seem to have saved the log, why, I have no >idea) > >com_error(-(a large number, INT_MAX?),CLASS_E_NOTLICENSED...) It's not INT_MAX; CLASS_E_NOTLICENSED is Win32 error code 0x80040112. This error says that either Access was not installed on your machine, or the DAO DLLs were not properly registered. This can happen if you do a brain transplant to copy one hard disk to another, and you don't get the registry quite right. Does Access run standalone? -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From aleaxit at yahoo.com Fri Feb 23 12:16:57 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 23 Feb 2001 12:16:57 +0100 Subject: Python, Access and win32com References: <973pvb$ms8$1@newsg1.svr.pol.co.uk> Message-ID: <975gr702df@news1.newsguy.com> "Will Newton" wrote in message news:973pvb$ms8$1 at newsg1.svr.pol.co.uk... > > I have been struggling to get MS Access 97 and the JET database engine to > work with Active State Python and the win32com extensions. > > If I run daodump.py I get the following error: I suggest not using DAO (an obsolete technology) but rather ADO (which works just fine with many kinds of data sources, fully including Jet). Get the latest MSDAC from the Microsoft site, makepy it, & be happy... Alex From arinagour at yahoo.co.uk Thu Feb 22 20:47:20 2001 From: arinagour at yahoo.co.uk (chris lamb) Date: Thu, 22 Feb 2001 19:47:20 -0000 Subject: executing shell commands Message-ID: I am very new to Python and having to learn quickly! I am enjoying it, however. It is a flexible and intuitive environment. Can someone advise me if there is an equivalent to running a system process from inside a script as there is in Perl? I mean in perl if I use backticks to enclose a system command, then the command is executed. Is there a comparable way of running these commands from Python? I want to build dynamic javadoc commands and module names and run the commands inside the script. best wishes chris From adam at deprince.net Wed Feb 21 21:33:14 2001 From: adam at deprince.net (Adam DePrince) Date: Wed, 21 Feb 2001 15:33:14 -0500 Subject: executing shell commands References: Message-ID: <3A94260A.CCEDC918@deprince.net> chris lamb wrote: > I am very new to Python and having to learn quickly! I am enjoying it, > however. It is a flexible and intuitive environment. > Can someone advise me if there is an equivalent to running a system process > from inside a script as there is in Perl? I mean in perl if I use backticks > to enclose a system command, then the command is executed. Is there a > comparable way of running these commands from Python? > I want to build dynamic javadoc commands and module names and run the > commands inside the script. > best wishes > chris http://www.python.org/doc/current/lib/module-commands.html Adam DePrince Starmedia Network, Inc. Email: zlib.decompress('x\332KLI\314\325KI-(\312\314KNu(.I,\312MM\311L\324K\316\317\005\000\221\331\012s') From phlip_cpp at my-deja.com Thu Feb 22 21:37:30 2001 From: phlip_cpp at my-deja.com (Phlip) Date: Thu, 22 Feb 2001 12:37:30 -0800 Subject: executing shell commands References: Message-ID: chris lamb wrote: > I am very new to Python and having to learn quickly! I am enjoying it, > however. It is a flexible and intuitive environment. > > Can someone advise me if there is an equivalent to running a system > process from inside a script as there is in Perl? I mean in perl if I use > backticks to enclose a system command, then the command is executed. Is > there a comparable way of running these commands from Python? os.system ("ls -l") > I want to build dynamic javadoc commands and module names and run the > commands inside the script. May I suggest you use 'make'? -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- My opinions are those of your employer -- From arinagour at yahoo.co.uk Fri Feb 23 00:00:58 2001 From: arinagour at yahoo.co.uk (chris lamb) Date: Thu, 22 Feb 2001 23:00:58 -0000 Subject: executing shell commands References: Message-ID: > os.system ("ls -l") Gulp! I have been trying to make it far too hard for myself!! Thank you for your help, both replies have been very useful. My scripts are running nicely. A very productive 1 days development under my belt! Chris From shaleh at valinux.com Thu Feb 22 21:39:52 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Thu, 22 Feb 2001 12:39:52 -0800 (PST) Subject: executing shell commands In-Reply-To: Message-ID: On 22-Feb-2001 chris lamb wrote: > I am very new to Python and having to learn quickly! I am enjoying it, > however. It is a flexible and intuitive environment. > > Can someone advise me if there is an equivalent to running a system process > from inside a script as there is in Perl? I mean in perl if I use backticks > to enclose a system command, then the command is executed. Is there a > comparable way of running these commands from Python? > import os os.system() or os.popen() system will run the command, but you do not get anything back other than an exit status. popen() can launch and app and connect its output to a Python file handler and let you read from it. From matthias at book.mteege.de Thu Feb 22 22:16:52 2001 From: matthias at book.mteege.de (Matthias Teege) Date: Thu, 22 Feb 2001 22:16:52 +0100 Subject: Python and curses Message-ID: Moin, I want to use python to build some simple forms for database input. Is there any python module for simple curses menus and forms out there? Thanks for any hint Matthias From flognat at flognat.myip.org Fri Feb 23 09:12:44 2001 From: flognat at flognat.myip.org (Andrew Markebo) Date: Fri, 23 Feb 2001 08:12:44 GMT Subject: Python and curses References: Message-ID: / matthias at book.mteege.de (Matthias Teege) wrote: | [...] | I want to use python to build some simple forms for database input. Is | there any python module for simple curses menus and forms out there? Yes there are a ncurses/curses(?) module included in the distribution, requires curses/ncurses on the machine to be run. /Andy From jfontain at free.fr Thu Feb 22 23:03:03 2001 From: jfontain at free.fr (Jean-Luc Fontaine) Date: Thu, 22 Feb 2001 22:03:03 GMT Subject: ANNOUNCE: tclpython-1.0 Message-ID: <3A958C9A.130C7838@free.fr> This is the first release: please try it. Comments and bug reports are obviously welcomed... ### README ### tclpython version 1.0: a Python package for Tcl This package allows the execution of Python code from a Tcl interpreter, as in: package require tclpython set interpreter [python::interp new] $interpreter eval {x = 3/2.0} set result [$interpreter eval {print x}] puts $result Sending data from the Python interpreter to the Tcl interpreter requires the print Python command. This will hopefully no longer be required in future versions. 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-1.0.tar.gz http://jfontain.free.fr/tclpython-1.0-1.i386.rpm http://jfontain.free.fr/tclpython-1.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 robin at jessikat.fsnet.co.uk Fri Feb 23 10:32:52 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 23 Feb 2001 09:32:52 +0000 Subject: ANNOUNCE: tclpython-1.0 References: <3A958C9A.130C7838@free.fr> Message-ID: In article <3A958C9A.130C7838 at free.fr>, Jean-Luc Fontaine writes >This is the first release: please try it. >Comments and bug reports are obviously welcomed... > How does this compare with the primitive python for tcl package I wrote long ago? http://www.jessikat.demon.co.uk/pyserver.zip The main deficiency of my approach was that it was difficult to get reverse communication ie callbacks from the python side and that everything was done via sockets. > >### README ### > >tclpython version 1.0: a Python package for Tcl > >This package allows the execution of Python code from a Tcl >interpreter, as in: > > > package require tclpython > set interpreter [python::interp new] > $interpreter eval {x = 3/2.0} > set result [$interpreter eval {print x}] > puts $result > > >Sending data from the Python interpreter to the Tcl interpreter >requires the print Python command. This will hopefully no longer be >required in future versions. > > >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-1.0.tar.gz >http://jfontain.free.fr/tclpython-1.0-1.i386.rpm >http://jfontain.free.fr/tclpython-1.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/ > > > -- Robin Becker From jfontain at winealley.com Fri Feb 23 12:37:57 2001 From: jfontain at winealley.com (Jean-Luc Fontaine) Date: Fri, 23 Feb 2001 12:37:57 +0100 Subject: ANNOUNCE: tclpython-1.0 References: <3A958C9A.130C7838@free.fr> Message-ID: <975i2e$pa8$1@s1.read.news.oleane.net> Robin Becker wrote: --- How does this compare with the primitive python for tcl package I wrote long ago? http://www.jessikat.demon.co.uk/pyserver.zip The main deficiency of my approach was that it was difficult to get reverse communication ie callbacks from the python side and that everything was done via sockets. --- I did not know that existed: I will check it out, thank you. The difference is that this is using an embedded python interpreter (several I hope in a future version), so communication is done through the C APIs. -- Jean-Luc Fontaine mailto:jfontain at winealley.com http://www.winealley.com From robin at jessikat.fsnet.co.uk Fri Feb 23 13:52:44 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 23 Feb 2001 12:52:44 +0000 Subject: ANNOUNCE: tclpython-1.0 References: <3A958C9A.130C7838@free.fr> <975i2e$pa8$1@s1.read.news.oleane.net> Message-ID: In article <975i2e$pa8$1 at s1.read.news.oleane.net>, Jean-Luc Fontaine writes ... >I did not know that existed: I will check it out, thank you. > >The difference is that this is using an embedded python interpreter >(several I hope in a future version), so communication is done through the >C APIs. > Wow, I downloaded my thing and after changing the Python version value to 2.0 it ran the Excel demo perfectly. I guess there are both advantages and disadvantages to having a combined interpreter version. -- Robin Becker From lvirden at cas.org Fri Feb 23 12:51:08 2001 From: lvirden at cas.org (lvirden at cas.org) Date: 23 Feb 2001 11:51:08 GMT Subject: Languages from within Tcl [Was: Re: ANNOUNCE: tclpython-1.0 References: <3A958C9A.130C7838@free.fr> Message-ID: <975irc$16g$1@srv38.cas.org> Okay, we now have o tclblend o tclperl o tclpython o embedded c What other programming languages have been integrated into Tcl? -- -- "See, he's not just anyone ... he's my son." Mark Schultz Even if explicitly stated to the contrary, nothing in this posting From claird at starbase.neosoft.com Fri Feb 23 15:35:38 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 23 Feb 2001 08:35:38 -0600 Subject: Languages from within Tcl [Was: Re: ANNOUNCE: tclpython-1.0 References: <3A958C9A.130C7838@free.fr> <975irc$16g$1@srv38.cas.org> Message-ID: In article <975irc$16g$1 at srv38.cas.org>, wrote: > >Okay, we now have > >o tclblend >o tclperl >o tclpython >o embedded c > >What other programming languages have been integrated into Tcl? . . . Ada, Forth, Prolog, ... Occasionally I convulse into an effort to catalogue 'em I welcome help. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From snowzone at home.com Sun Feb 25 04:33:26 2001 From: snowzone at home.com (tony summerfelt) Date: Sun, 25 Feb 2001 03:33:26 GMT Subject: Languages from within Tcl [Was: Re: ANNOUNCE: tclpython-1.0 References: <3A958C9A.130C7838@free.fr> <975irc$16g$1@srv38.cas.org> Message-ID: On 23 Feb 2001 08:35:38 -0600, Cameron Laird wrote: > > >What other programming languages have been integrated into Tcl? . > Ada, Forth, Prolog, ... Occasionally I convulse into an effort to catalogue and the ada one is pretty good. it allows you write tcl extensions in ada (and of course you get all the tcl/tk goodies for ada) ada being rock solid, tcl/tk/ada is a great combination... -- *---------------------------------------- | |http://www.biosys.net/snowzone | |remove myspleen to email | *----------------------- From davygrvy at pobox.com Sun Feb 25 05:08:24 2001 From: davygrvy at pobox.com (David Gravereaux) Date: Sat, 24 Feb 2001 20:08:24 -0800 Subject: Languages from within Tcl [Was: Re: ANNOUNCE: tclpython-1.0 References: <3A958C9A.130C7838@free.fr> <975irc$16g$1@srv38.cas.org> Message-ID: claird at starbase.neosoft.com (Cameron Laird) wrote: >In article <975irc$16g$1 at srv38.cas.org>, wrote: >> >>Okay, we now have >> >>o tclblend >>o tclperl >>o tclpython >>o embedded c >> >>What other programming languages have been integrated into Tcl? > . > . > . >Ada, Forth, Prolog, ... Occasionally I convulse into an effort to catalogue 'em > >I welcome help. >From the embedded side we could add delphi,{nasm,tasm,masm}, and VB if we only had an h2lang convertor thing for tcl.h . The Stubs issue might be kinda odd in VB. I tried once, but stopped. Yet another Tcl project started and stopped. I need more free time :) -- \\ ~ ~ // ( @ @ ) ----------------oOOo-(_)-oOOo-------------- David Gravereaux Just some Tcl hacker dude. http://dev.scriptics.com/doc/integration.html#Tcl ------------------------Oooo.-------------- .oooO ( ) ( ) ) / \ ( (_/ \_) From changl at neatware.com Fri Feb 23 17:11:52 2001 From: changl at neatware.com (Chang LI) Date: Fri, 23 Feb 2001 11:11:52 -0500 Subject: ANNOUNCE: tclpython-1.0 References: <3A958C9A.130C7838@free.fr> Message-ID: How could you call a function in Python or Perl from Tcl? How to use the library in these languages? I do not think it is very useful to write Python program inside the Tcl. However it is useful to use the Python or Perl library. Chang Jean-Luc Fontaine wrote in message <3A958C9A.130C7838 at free.fr>... >This is the first release: please try it. >Comments and bug reports are obviously welcomed... > > >### README ### > >tclpython version 1.0: a Python package for Tcl > >This package allows the execution of Python code from a Tcl >interpreter, as in: > > > package require tclpython > set interpreter [python::interp new] > $interpreter eval {x = 3/2.0} > set result [$interpreter eval {print x}] > puts $result > > >Sending data from the Python interpreter to the Tcl interpreter >requires the print Python command. This will hopefully no longer be >required in future versions. > > >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-1.0.tar.gz >http://jfontain.free.fr/tclpython-1.0-1.i386.rpm >http://jfontain.free.fr/tclpython-1.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 mal at lemburg.com Thu Feb 22 23:04:29 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Thu, 22 Feb 2001 23:04:29 +0100 Subject: ANN: eGenix.com mx Extensions -- Version 2.0.0 (mxODBC, mxDateTime, ...) Message-ID: <3A958CED.F7B95C33@lemburg.com> ________________________________________________________________________ ANNOUNCING: eGenix.com mx Extension Series for Python Version 2.0.0 Full Source Python extensions providing important and useful services for Python programmers. ________________________________________________________________________ WHAT IS IT ? The eGenix.com mx Extensions for Python are 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. Python is an open-oriented Open Source programming language which runs on all modern platforms. By integrating ease-of-use, clarity in coding, enterprise application connectivity and rapid application design, Python establishes an ideal programming platform for todays IT challenges. The tools have a proven record of being portable across many Unix and Windows platforms, e.g. you can write applications which use an ODBC database on Windows which then run on Unix platforms without change due to the consistent platforms independent interfaces. All available packages have proven their stability and usefulness in many mission critical applications and various commercial settings all around the world. The two most well-known subpackages from the eGenix.com mx Extension Series are mxDateTime and mxODBC providing date/time services and professional ODBC database connectivity on practically all supported Python platforms. These two packages enable database software which is portable not only across platforms, but also across database backends. ________________________________________________________________________ WHAT'S NEW ? mxODBC, mxDateTime and all other mx packages are now maintained by my new company eGenix.com Software GmbH, Langenfeld in Germany (http://www.egenix.com/). This move will provide a better base for future development and also assures the availability of commercial support, which is important for companies building applications based on the eGenix.com mx Extensions. The new versions of the eGenix.com mx Extensions use the Python 2.0 distutils packaging technology to simplify installation and use of the many different subpackages. This is expected to greatly enhance the installation and usage experience of the software. In additions to many subpackage enhancements, this new release repackages all mx Extensions under a new top-level package named 'mx'. This will allow you to use the subpackages side-by-side with other Python tools using similar names. The software is now delivered in two download archives: the eGenix.com mx BASE package which holds all the Open Source tools from the series and provides the basis for the other add-ons and the eGenix.com mx COMMERCIAL package which currently only contains the mxODBC package. The two packages are covered by the eGenix.com Public License and the eGenix.com Commercial License respectively. Details about the licenses can be found at: http://www.lemburg.com/files/python/mxLicense.html ________________________________________________________________________ SPECIAL OFFER theKompany.com has licensed the COMMERCIAL package (which includes mxODBC) for inclusion in their brand new Qt-based Python IDE BackAdder. 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 BASE PACKAGE OVERVIEW: mxDateTime - Generic Date/Time Types mxDateTime is an extension package that provides three new object types, DateTime, DateTimeDelta and RelativeDateTime, which let you store and handle date/time values in a much more natural way than by using ticks (seconds since 1.1.70 0:00 UTC; the encoding used by the time module). You can add, subtract and even multiply instances, pickle and copy them and convert the results to strings, COM dates, ticks and some other more esoteric values. In addition, there are several convenient constructors and formatters at hand to greatly simplify dealing with dates and times in real-world applications. In addition to providing an easy-to-use Python interface the package also exports a comfortable C API interface for other extensions to build upon. This is especially interesting for database applications which often have to deal with date/time values (the mxODBC package is one example of an extension using this interface). mxTextTools - Fast Text Processing Tools mxTextTools is an extension package for Python that provides several useful functions and types that implement high-performance text manipulation and searching algorithms in addition to a very flexible and extendable state machine, the Tagging Engine, that allows scanning and processing text based on low-level byte-code "programs" written using Python tuples. It gives you access to the speed of C without the need to do any compile and link steps every time you change the parsing description. Applications include parsing structured text, finding and extracting text (either exact or using translation tables) and recombining strings to form new text. mxStack - Fast and Memory-Efficient Stack Type mxStack is an extension package that provides a new object type called Stack. It works much like what you would expect from such a type, having .push() and .pop() methods and focusses on obtaining maximum speed at low memory costs. mxTools - Collection of Additional Builtins mxTools is an extension package that includes a collection of handy functions and objects giving additional functionality in form of new builtins to the Python programmer. The package auto-installs the new functions and objects as builtins upon first import. This means that they become instantely available to all other modules without any further action on your part. Add the line import NewBuiltins to your site.py script and they will be available to all users at your site as if they were installed in the Python interpreter itself. mxProxy - Generic Proxy Wrapper Type mxProxy is an extension package that provides a new type that is suitable to implement Bastion like features without the need to use restricted execution environments. The type's main features are secure data encapsulation (the hidden objects are not accessible from Python since they are stored in internal C structures), customizable attribute lookup methods and a cleanup protocol that helps in breaking circular references prior to object deletion. The latest version adds a very interesting new feature: weak references which help you work with circular references in a way that doesn't cause memory leakage in a Python system. mxBeeBase - On-disk B+Tree Based Database Kit mxBeeBase is a high performance construction kit for disk based indexed databases. It offers components which you can plug together to easily build your own custom mid-sized databases (the current size limit is sizeof(long) which gives you an address range of around 2GB on 32-bit platforms). The two basic building blocks in mxBeeBase are storage and index. Storage is implemented as variable record length data storage with integrated data protection features, automatic data recovery and locking for multi process access. Indexes use a high performance optimized B+Tree implementation built on top of Thomas Niemann's Cookbook B+Tree implementation (http://epaperpress.com/). Note: mxBeeBase is new in this release and still in beta. ________________________________________________________________________ EGENIX.COM MX COMMERCIAL PACKAGE OVERVIEW: mxODBC - Generic ODBC 2.0 interface mxODBC is an extension package that provides a Python Database API compliant interface to ODBC 2.0 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). The latest version of the interface allows you to interface to more than one database from one process. It includes a varity of preconfigured setups for many commonly used databases such as MySQL, Oracle, Informix, Solid and many more. A precompiled version of the extension for use with the Windows ODBC manager is also included. ________________________________________________________________________ WHERE CAN I GET IT ? The download archives and instructions for installing the packages can be found at: http://www.lemburg.com/files/python/ ________________________________________________________________________ WHAT DOES IT COST ? The BASE packages come with a Python 2.0 style license, which means that you can use them in both commercial and non-commercial settings without fee or charge. All packages come with full source code. mxODBC comes with a new 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. ________________________________________________________________________ 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 mx Extension Series - eGenix.com mx Extension Series with distutils support and precompiled binaries for Windows and Linux. (22-Feb-2001) ________________________________________________________________________ ...thanks for reading this far ;-) In the spirit of Python software announcements, I am leaving off for the Python Conference in Long Beach, California tomorrow. If you have any problems with these packages or the downloads, please email me at mal at egenix.com. I will read your mail once I get back from the conference and will do my best make the eGenix.com mx Extensions a success for you. See you at the conference, -- Marc-Andre Lemburg ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Pages: http://www.lemburg.com/python/ From gustav at morpheus.demon.co.uk Sat Feb 24 23:15:05 2001 From: gustav at morpheus.demon.co.uk (Paul Moore) Date: Sat, 24 Feb 2001 22:15:05 +0000 Subject: ANN: eGenix.com mx Extensions -- Version 2.0.0 (mxODBC, mxDateTime, ...) References: <3A958CED.F7B95C33@lemburg.com> Message-ID: On Thu, 22 Feb 2001 23:04:29 +0100, "M.-A. Lemburg" wrote: >The download archives and instructions for installing the packages can >be found at: > > http://www.lemburg.com/files/python/ One thing which would be nice would be a Win32 binary download, which was NOT packaged using an installer. Just a zip file to be unzipped in an appropriate place... At the very least, an option to change the install directory (to a "local modules" directory of my choosing) is pretty much a necessity... Paul. From thomas.heller at ion-tof.com Tue Feb 27 10:26:21 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Tue, 27 Feb 2001 10:26:21 +0100 Subject: ANN: eGenix.com mx Extensions -- Version 2.0.0 (mxODBC, mxDateTime, ...) References: <3A958CED.F7B95C33@lemburg.com> Message-ID: <97frrt$p1a5r$1@ID-59885.news.dfncis.de> "Paul Moore" wrote in message news:r7cg9toqrkgklmk6egokarju1g3mc9mei2 at 4ax.com... > On Thu, 22 Feb 2001 23:04:29 +0100, "M.-A. Lemburg" > wrote: > > >The download archives and instructions for installing the packages can > >be found at: > > > > http://www.lemburg.com/files/python/ > > One thing which would be nice would be a Win32 binary download, which > was NOT packaged using an installer. Just a zip file to be unzipped in > an appropriate place... > The windows installer (egenix-mx-base-2.0.0.win32-py2.0.exe) is more or less a self-extracting zip.file, which also can be opened with WinZip or other tools... Thomas From matt at mondoinfo.com Thu Feb 22 23:12:04 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Thu, 22 Feb 2001 22:12:04 GMT Subject: os.path.join("/a","/b") Message-ID: I was a little surprised today to notice that os.path.join("/a","/b") returns '/b' (os.path is posixpath in this case of course) while os.path.join("/a/","b") returns "/a/b" which I expected from both. Poking back into my dusty archives, I find that it has been that way since at least 1.4 so I presume that it's a feature but I'll be darned if I can figure out the logic. It sure doesn't seem to have much to do with joining. The module's docstring just says "Join two or more pathname components, inserting '/' as needed". If someone could explain the logic to me, I'd be grateful. Regards, Matt From jmarshal at mathworks.com Thu Feb 22 23:25:35 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 22 Feb 2001 22:25:35 GMT Subject: os.path.join("/a","/b") References: Message-ID: <9743kv$7ur$1@news.mathworks.com> Matthew Dixon Cowles wrote: > I was a little surprised today to notice that > os.path.join("/a","/b") returns '/b' > (os.path is posixpath in this case of course) while > os.path.join("/a/","b") returns "/a/b" > which I expected from both. Poking back into my dusty archives, I find > that it has been that way since at least 1.4 so I presume that it's a > feature but I'll be darned if I can figure out the logic. It sure > doesn't seem to have much to do with joining. The module's docstring > just says "Join two or more pathname components, inserting '/' as > needed". > If someone could explain the logic to me, I'd be grateful. > Regards, > Matt It's as if you cd to directory "/a" and reference "/b". Since "/b" is an absolute path, the current directory is ignored. From fredrik at pythonware.com Thu Feb 22 23:36:09 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 22 Feb 2001 22:36:09 GMT Subject: os.path.join("/a","/b") References: Message-ID: Matthew Dixon Cowles wrote: > I was a little surprised today to notice that > > os.path.join("/a","/b") returns '/b' > > (os.path is posixpath in this case of course) while > > os.path.join("/a/","b") returns "/a/b" > > which I expected from both. Poking back into my dusty archives, I find > that it has been that way since at least 1.4 so I presume that it's a > feature but I'll be darned if I can figure out the logic. http://www.python.org/doc/current/lib/module-os.path.html join (path1[, path2[, ...]]) Joins one or more path components intelligently. If any component is an absolute path, all previous components are thrown away, and joining continues. The return value is the concatenation of path1, and optionally path2, etc., with exactly one slash ('/') inserted between components, unless path is empty. the rationale is probably that it's a good idea if os.path.join(os.getcwd(), filename) refers to the same file as: filename for any filename. Cheers /F From matt at mondoinfo.com Fri Feb 23 00:36:55 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Thu, 22 Feb 2001 23:36:55 GMT Subject: os.path.join("/a","/b") References: Message-ID: On Thu, 22 Feb 2001 22:36:09 GMT, Fredrik Lundh wrote: >the rationale is probably that it's a good idea if > > os.path.join(os.getcwd(), filename) > >refers to the same file as: > > filename > >for any filename. Thanks to you and Joshua for the clues. I'm sure that you and he are right about the rationale. Still, I'd have chosen a name other than join for that behavior. Regards, Matt From bsb at winnegan.de Fri Feb 23 00:01:29 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 23 Feb 2001 00:01:29 +0100 Subject: os.path.join("/a","/b") In-Reply-To: References: Message-ID: <871ysqqq46.fsf@winnegan.de> matt at mondoinfo.com (Matthew Dixon Cowles) writes: > I was a little surprised today to notice that > > os.path.join("/a","/b") returns '/b' > > (os.path is posixpath in this case of course) while > > os.path.join("/a/","b") returns "/a/b" > > which I expected from both. Poking back into my dusty archives, I find > that it has been that way since at least 1.4 so I presume that it's a > feature but I'll be darned if I can figure out the logic. It sure > doesn't seem to have much to do with joining. The module's docstring > just says "Join two or more pathname components, inserting '/' as > needed". > If someone could explain the logic to me, I'd be grateful. Consult the library reference, it says "if any component is an absolute path ..." Thx Siggy From lreilly at cs.strath.ac.uk Thu Feb 22 23:40:10 2001 From: lreilly at cs.strath.ac.uk (Lee Reilly CS1997) Date: Thu, 22 Feb 2001 22:40:10 +0000 Subject: which IDE? Message-ID: <3A95954A.72621882@cs.strath.ac.uk> Hi, I'm relatively new to Python and have been developing a product using Zope and experimenting using IDLE. I was wodnering if anyone could tell me the name of a good IDE - something similar to Symantec Visual Cafe perhaps, where I could develop my code and it can spice it up (text/variable highlighting, etc.). WingIDE looks good http://archaeopteryx.com/wingide but AFAIK it's not available on Win32. Anyone From tino at wildenhain.de Fri Feb 23 00:08:08 2001 From: tino at wildenhain.de (Tino Wildenhain) Date: Fri, 23 Feb 2001 00:08:08 +0100 Subject: which IDE? In-Reply-To: <3A95954A.72621882@cs.strath.ac.uk> References: <3A95954A.72621882@cs.strath.ac.uk> Message-ID: <15423962.982886887@[10.0.0.101]> Hi Lee, > Hi, > > I'm relatively new to Python and have been developing a product using > Zope and experimenting using IDLE. I was wodnering if anyone could tell > me the name of a good IDE - something similar to Symantec Visual Cafe > perhaps, where I could develop my code and it can spice it up > (text/variable highlighting, etc.). > > WingIDE looks good http://archaeopteryx.com/wingide but AFAIK it's not > available on Win32. You will for sure like the pythonwin IDE that comes with the win32extensions by Mark Hammond. Its near the place where you downloaded the windows version of python. I recommend the couple python2.0/win32 135 iirc. You get both with one installer from activestate.com HTH Tino Wildenhain From wayne.izatt at _nospam_myself.com Sat Feb 24 07:37:34 2001 From: wayne.izatt at _nospam_myself.com (Wayne Izatt) Date: Sat, 24 Feb 2001 06:37:34 GMT Subject: which IDE? References: <3A95954A.72621882@cs.strath.ac.uk> Message-ID: Activestate are also pushing something called Komodo, an ide for both Perl and Python. I haven't tried it, so I can't rate it. ciao "Lee Reilly CS1997" wrote in message news:3A95954A.72621882 at cs.strath.ac.uk... > Hi, > > I'm relatively new to Python and have been developing a product using > Zope and experimenting using IDLE. I was wodnering if anyone could tell > me the name of a good IDE - something similar to Symantec Visual Cafe > perhaps, where I could develop my code and it can spice it up > (text/variable highlighting, etc.). > > WingIDE looks good http://archaeopteryx.com/wingide but AFAIK it's not > available on Win32. > > Anyone From dsavitsk at e-coli.net Fri Feb 23 00:32:34 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Thu, 22 Feb 2001 17:32:34 -0600 Subject: httplib and buffered data Message-ID: i am capturing the data being returned from a script running on a web server. The script takes several minutes to run, and trickles back data a little at a time. Using httplib (or anything else) is there a way to capture the data line by line instead of as a lump sum with getfile()? i would like to alert the user as to the % of the data (a known quantity) that has been processed. thanks, doug From dwig at advancedmp.net Sat Feb 24 01:33:31 2001 From: dwig at advancedmp.net (Don Dwiggins) Date: 23 Feb 2001 16:33:31 -0800 Subject: httplib and buffered data In-Reply-To: "dsavitsk"'s message of "Thu, 22 Feb 2001 17:32:34 -0600" References: Message-ID: dsavitsk writes: > i am capturing the data being returned from a script running on a web > server. The script takes several minutes to run, and trickles back data a > little at a time. > Using httplib (or anything else) is there a way to capture the data line by > line instead of as a lump sum with getfile()? i would like to alert the user > as to the % of the data (a known quantity) that has been processed. You could use asyncore/asynchat, if you're willing to wrap your mind around that style of operation. The library documentation for asyncore shows a little http client as an example. Better documentation for both is in the Medusa pages on www.nightmare.com. Happy hunting, -- Don Dwiggins "Solvitur Ambulando" Advanced MP Technology dwig at advancedmp.net From dhjung7 at orgio.net Fri Feb 23 03:18:35 2001 From: dhjung7 at orgio.net (iact21) Date: Fri, 23 Feb 2001 11:18:35 +0900 Subject: How do I make damon process in Python ? Message-ID: <974hap$4r4$1@b5nntp2.channeli.net> How can I make damon process in Python..? I'd like to see example code... From cg at schlund.de Fri Feb 23 10:39:03 2001 From: cg at schlund.de (Carsten Gaebler) Date: Fri, 23 Feb 2001 10:39:03 +0100 Subject: How do I make damon process in Python ? References: <974hap$4r4$1@b5nntp2.channeli.net> Message-ID: <3A962FB7.161814B1@schlund.de> iact21 wrote: > How can I make damon process in Python..? > > I'd like to see example code... #!/usr/bin/python import os pid = os.fork() if pid == 0: # Child process (daemon) while 1: pass else: # Parent process: # Do something useful, or nothing, then exit # and leave the child alone. pass cg. -- Carsten Gaebler Computerhomoeopathie und Schlund + Partner AG Schlangenbeschwoerung Erbprinzenstr. 4 - 12 voice://49.721.91374.543/ 76133 Karlsruhe fax://49.721.91374.228/ From berning at teuto.de Sat Feb 24 01:33:40 2001 From: berning at teuto.de (Ulrich Berning) Date: Sat, 24 Feb 2001 01:33:40 +0100 Subject: How do I make damon process in Python ? References: <974hap$4r4$1@b5nntp2.channeli.net> Message-ID: <3A970164.BBA246FF@teuto.de> iact21 wrote: > How can I make damon process in Python..? > > I'd like to see example code... We used something like the attached example daemon. The daemon ensures, that only one instance can run on a single machine (using a pid file). You can also use this daemon to stop a running instance or to query if there is a running instance. This daemon puts itself into background and disconnects completely from the controlling terminal, so it can not write to stdout or stderr after is has initialized. For this reason, stdout and stderr are closed and then reasigned to a message log file and an error log file. I hope its useful. Ulli -------------- next part -------------- #!/usr/bin/env python #============================================================================# # Import the necessary modules # #----------------------------------------------------------------------------# import sys, os, string, time, signal, errno #============================================================================# # ----- Contants ----------------------------------------------------------- # #----------------------------------------------------------------------------# LOG_DIR = '/tmp/my_daemon' #============================================================================# # ----- Signal Handlers ---------------------------------------------------- # #----------------------------------------------------------------------------# #============================================================================# # terminate() - Signal handler that is called on SIGTERM # #----------------------------------------------------------------------------# def terminate(signal, param): try: # Do necessary cleanup handling #... #... #... # Remove the pid file os.remove(os.path.join(LOG_DIR, 'run.pid')) except: pass # Ignore any errors sys.stdout.write("........terminating\n") sys.exit(0) #============================================================================# # ----- Main Routine ------------------------------------------------------- # #----------------------------------------------------------------------------# # Store the name of the programm call_name = os.path.split(sys.argv[0])[1] # Get the call arguments (stop, status) if len(sys.argv) > 2: sys.stderr.write("Usage: %s [stop|status]\n" % call_name) sys.exit(1) if len(sys.argv) == 2: if sys.argv[1] == 'stop': if os.path.isfile(os.path.join(LOG_DIR, 'run.pid')): f = open(os.path.join(LOG_DIR, 'run.pid'), 'r') pid = string.atoi(string.strip(f.readline())) f.close() try: os.kill(pid, 0) except os.error, args: if args[0] != errno.ESRCH: # NO SUCH PROCESS raise os.error, args else: os.kill(pid, signal.SIGTERM) sys.exit(0) sys.stdout.write("%s: daemon is not running\n" % call_name) sys.exit(1) elif sys.argv[1] == 'status': if os.path.isfile(os.path.join(LOG_DIR, 'run.pid')): f = open(os.path.join(LOG_DIR, 'run.pid'), 'r') pid = string.atoi(string.strip(f.readline())) f.close() try: os.kill(pid, 0) except os.error, args: if args[0] != errno.ESRCH: # NO SUCH PROCESS raise os.error, args else: sys.stdout.write("%s: daemon [%d] is running\n" % (call_name, pid)) sys.exit(0) sys.stdout.write("%s: daemon is not running\n" % call_name) sys.exit(0) else: sys.stderr.write("Usage: %s [stop|status]\n" % call_name) sys.exit(1) # Check, if the log directory is already there. If not, create it if not os.path.isdir(LOG_DIR): os.mkdir(LOG_DIR, 0755) # Check, if there is already a running instance if os.path.isfile(os.path.join(LOG_DIR, 'run.pid')): f = open(os.path.join(LOG_DIR, 'run.pid'), 'r') pid = string.atoi(string.strip(f.readline())) f.close() try: os.kill(pid, 0) except os.error, args: if args[0] != errno.ESRCH: # NO SUCH PROCESS raise os.error, args else: sys.stderr.write("%s: there is already a running instance\n" % call_name) sys.exit(1) # Initialize error logging f_stderr = open(os.path.join(LOG_DIR, 'error.log'), 'w') # Initialize message logging f_stdout = open(os.path.join(LOG_DIR, 'message.log'), 'w') # Print a startup message sys.stdout.write("%s: started at %s\n" % (call_name, time.strftime("%d.%m.%Y / %H:%M:%S", time.localtime(time.time())))) sys.stdout.write("%s: log directory is is '%s'\n" % (call_name, LOG_DIR)) sys.stdout.write("%s: going into background........\n" % call_name) #============================================================================# # Initialize a daemon process # #----------------------------------------------------------------------------# # Change to the log directory, this permits an umount on this directory os.chdir(LOG_DIR) # Do the following only, if we were not started by the init process if os.getppid() != 1: # Ignore a terminal output signal signal.signal(signal.SIGTTOU, signal.SIG_IGN) # Ignore a terminal input signal signal.signal(signal.SIGTTIN, signal.SIG_IGN) # Ignore a terminal stop signal signal.signal(signal.SIGTSTP, signal.SIG_IGN) # Fork the first child pid = os.fork() # The parent ends here if pid > 0: sys.exit(0) # Make ourself a leader of the process group os.setpgrp() # Ignore a hangup signal signal.signal(signal.SIGHUP, signal.SIG_IGN) # Fork the second child pid = os.fork() # The parent ends here if pid > 0: sys.exit(0) # Close sys.stdin sys.stdin.close() # Close sys.stdout and redirect the message log to sys.stdout sys.stdout.close() sys.stdout = f_stdout # Close sys.stderr and redirect the error log to sys.stderr sys.stderr.close() sys.stderr = f_stderr # Reset the umask os.umask(000) # Ignore a dead of child signal signal.signal(signal.SIGCLD, signal.SIG_IGN) # Install a hander for ther terminate signal signal.signal(signal.SIGTERM, terminate) # Install a handler for the interrupt signal signal.signal(signal.SIGINT, terminate) # Install a handler for the quit signal signal.signal(signal.SIGQUIT, terminate) # Write our process id into the pid file f = open(os.path.join(LOG_DIR, 'run.pid'), 'w') f.write("%d" % os.getpid()) f.close() # Print a startup message sys.stdout.write("%s: started at %s\n" % (call_name, time.strftime("%d.%m.%Y / %H:%M:%S", time.localtime(time.time())))) sys.stdout.write("%s: log directory is is '%s'\n" % (call_name, LOG_DIR)) sys.stdout.write("%s: going into background........\n" % call_name) sys.stdout.flush() # Do other necessary initializations before entering the endless loop #... #... #... #============================================================================# # Enter the endles loop # #----------------------------------------------------------------------------# while(1): # Replace the following sleep() by a real worker time.sleep(10) #============================================================================# # EOF # #----------------------------------------------------------------------------# From sai at dft.chem.cuhk.edu.hk Fri Feb 23 03:36:49 2001 From: sai at dft.chem.cuhk.edu.hk (SC Zhong) Date: Fri, 23 Feb 2001 10:36:49 +0800 Subject: Togl cannot be loaded Message-ID: Dear all, I have an application which use the togl extension of Tk through python. I tried to compile python again with the activation of the togl extension in the Modules/Setup file. But somehow the togl cannot be loaded: >>> from Tkinter import * >>> mst = Tk() >>> mst.tk.call('package','require', 'Togl') Traceback (innermost last): File "", line 1, in ? TclError: can't find package Togl >>> There are no compiling errors. I also searched a lot but couldn't find some useful documentation of this 'module'. I have python1.5.2 and on SGI. The relevant part of the Setup file is: # *** Always uncomment this (leave the leading underscore in!): _tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \ # *** Uncomment and edit to reflect where your Tcl/Tk headers are: -I/usr/freeware/include \ # *** Uncomment and edit to reflect where your X11 header files are: -I/usr/include/X11 \ # *** Or uncomment this for Solaris: # -I/usr/openwin/include \ # *** Uncomment and edit for Tix extension only: # -DWITH_TIX -ltix4.1.8.0 \ # *** Uncomment and edit for BLT extension only: -DWITH_BLT -I/usr/local/blt2.4u -I/usr/local/blt2.4u/src -lBLT24 \ # *** Uncomment and edit for PIL (TkImaging) extension only: # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \ # *** Uncomment and edit for TOGL extension only: -DWITH_TOGL togl.c \ # *** Uncomment and edit to reflect where your Tcl/Tk libraries are: -L/usr/freeware/lib \ # *** Uncomment and edit to reflect your Tcl/Tk versions: -ltk8.0 -ltcl8.0 \ # *** Uncomment and edit to reflect where your X11 libraries are: -L/usr/lib \ # *** Or uncomment this for Solaris: # -L/usr/openwin/lib \ # *** Uncomment these for TOGL extension only: -lGL -lGLU -lXext -lXmu \ # *** Uncomment for AIX: # -lld \ # *** Always uncomment this; X11 libraries to link with: -lX11 thanks for your help sc zhong From guido at digicool.com Fri Feb 23 03:59:26 2001 From: guido at digicool.com (Guido van Rossum) Date: Thu, 22 Feb 2001 21:59:26 -0500 Subject: Nested scopes resolution -- you can breathe again! In-Reply-To: Your message of "Thu, 22 Feb 2001 16:45:00 EST." References: Message-ID: <200102230259.VAA19238@cj20424-a.reston1.va.home.com> We (PythonLabs) have received a lot of flak over our plan to introduce nested scopes despite the fact that it appears to break a small but significant amount of working code. We discussed this at an PythonLabs group meeting today. After the meeting, Tim posted this teaser: > PS: At the internal PythonLabs mtg today, I voted against nested > scopes. But also for them. Leaving that to Jeremy to explain. After the meeting Jeremy had a four hour commute home due to bad weather, so let me do the honors for him. (Jeremy will update the PEP, implement the feature, and update the documentation, in that order.) We have clearly underestimated how much code the nested scopes would break, but more importantly we have underestimated how much value our community places on stability. At the same time we really like nested scopes, and we would like to see the feature introduced at some point. So here's the deal: we'll make nested scopes an optional feature in 2.1, default off, selectable on a per-module basis using a mechanism that's slightly hackish but is guaranteed to be safe. (See below.) At the same time, we'll augment the compiler to detect all situations that will break when nested scopes are introduced in the future, and issue warnings for those situations. The idea here is that warnings don't break code, but encourage folks to fix their code so we can introduce nested scopes in 2.2. Given our current pace of releases that should be about 6 months warning. These warnings are *not* optional -- they are issued regardless of whether you select to use nested scopes. However there is a command line option (crudest form: -Wi) to disable warnings; there are also ways to disable them programmatically. If you want to make sure that you don't ignore the warnings, there's also a way to turn warnings into errors (-We from the command line). How do you select nested scopes? Tim suggested a mechanism that is used by the ANSI C committee to enable language features that are backwards incompatible: they trigger on the import of a specific previously non-existant header file. (E.g. after #include , "imaginary" becomes a reserved word.) The Python equivalent of this is a magical import that is recognized by the compiler; this was also proposed by David Scherer for making integer division yield a float. (See http://mail.python.org/pipermail/edu-sig/2000-May/000499.html) You could say that Perl's "use" statement is similar. We haven't decided yet which magical import; two proposals are: import __nested_scopes__ from __future__ import nested_scopes The magical import only affects the source file in which it occurs. It is recognized by the compiler as it is scanning the source code. It must appear at the top-level (no "if" or "try" or "def" or anything else around it) and before any code that could be affected. We realize that PEP 5 specifies a one-year transition period. We believe that that is excessive in this case, and would like to change the PEP to be more flexible. (The PEP has questionable status -- it was never formally discussed.) We also believe that the magical import mechanism is useful enough to be reused for other situations like this; Tim will draft a PEP to describe in excruciating detail. I thank everybody who gave feedback on this issue. And thanks to Jeremy for implementing nested scopes! --Guido van Rossum (home page: http://www.python.org/~guido/) From greg at cosc.canterbury.ac.nz Fri Feb 23 05:25:25 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 23 Feb 2001 17:25:25 +1300 (NZDT) Subject: [Python-Dev] Nested scopes resolution -- you can breathe again! In-Reply-To: <200102230259.VAA19238@cj20424-a.reston1.va.home.com> Message-ID: <200102230425.RAA01507@s454.cosc.canterbury.ac.nz> > from __future__ import nested_scopes Hey, neat, now we've got programmatic access to Guido's time machine from the Python interpreter! What else will I be able to import from the future? I'd quite like from __future__ import mips_100000 too. Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+ From tanzer at swing.co.at Fri Feb 23 08:04:56 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Fri, 23 Feb 2001 08:04:56 +0100 Subject: Nested scopes resolution -- you can breathe again! In-Reply-To: Your message of "Thu, 22 Feb 2001 21:59:26 EST." <200102230259.VAA19238@cj20424-a.reston1.va.home.com> Message-ID: Guido van Rossum wrote: > We (PythonLabs) have received a lot of flak over our plan to introduce > nested scopes despite the fact that it appears to break a small but > significant amount of working code. There were lots of complaints about newly introduced Python features recently. While I understand concerns about code breakage (myself being worried about breakage to my code), far more complaints concerned style issues than breakage. As I normally don't want to waste time over religious issues -- like `print >>' being cool or the worst wart ever -- I don't participate in such discussions on c.l.py. But IMO Python still is an excellent language and it got even better in the last year. Thank you and your team for the great work you are doing. > How do you select nested scopes? Tim suggested a mechanism that is > used by the ANSI C committee to enable language features that are > backwards incompatible: they trigger on the import of a specific > previously non-existant header file. (E.g. after #include > , "imaginary" becomes a reserved word.) > > The Python equivalent of this is a magical import that is recognized > by the compiler; this was also proposed by David Scherer for making > integer division yield a float. (See > http://mail.python.org/pipermail/edu-sig/2000-May/000499.html) You > could say that Perl's "use" statement is similar. > > We haven't decided yet which magical import; two proposals are: > > import __nested_scopes__ > from __future__ import nested_scopes Cool. I hope that `from __future__ import ' will win this contest -- it defines a common pattern for introducing backwards incompatible features. -- 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 mikael at isy.liu.se Fri Feb 23 10:41:12 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 23 Feb 2001 10:41:12 +0100 (MET) Subject: Nested scopes resolution -- you can breathe again! In-Reply-To: <200102230259.VAA19238@cj20424-a.reston1.va.home.com> Message-ID: On 23-Feb-01 Guido van Rossum wrote: > from __future__ import nested_scopes There really is a time machine. So I guess I can get the full Python 3k functionality by doing from __future__ import * /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 23-Feb-01 Time: 10:39:52 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From moshez at zadka.site.co.il Fri Feb 23 10:52:45 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Fri, 23 Feb 2001 11:52:45 +0200 (IST) Subject: [Python-Dev] RE: Nested scopes resolution -- you can breathe again! In-Reply-To: References: Message-ID: <20010223095245.A69E2A840@darjeeling.zadka.site.co.il> On Fri, 23 Feb 2001, Mikael Olofsson wrote: > There really is a time machine. So I guess I can get the full Python 3k > functionality by doing > > from __future__ import * In Py3K from import * will be illegal, so this will unfortunately blow up the minute the "import_star_bad" is imported. You'll just have to try them one by one... -- "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 news at dorb.com Sat Feb 24 22:58:13 2001 From: news at dorb.com (Darrell) Date: Sat, 24 Feb 2001 21:58:13 GMT Subject: [Python-Dev] RE: Nested scopes resolution -- you can breathe again! References: Message-ID: "Moshe Zadka" wrote: > In Py3K from import * will be illegal, so this will unfortunately blow > up the minute the "import_star_bad" is imported. Has it been decided that "from x import *" will become illegal? While dangerous, it can be useful. --Darrell From tim.one at home.com Sun Feb 25 05:58:01 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 24 Feb 2001 23:58:01 -0500 Subject: [Python-Dev] RE: Nested scopes resolution -- you can breathe again! In-Reply-To: Message-ID: [Moshe Zadka] > In Py3K from import * will be illegal, so this will unfortunately blow > up the minute the "import_star_bad" is imported. [Darrell] > Has it been decided that "from x import *" will become illegal? No. > While dangerous, it can be useful. Guido agrees. There are likely to be more restrictions imposed on its use over time, though. For example, the Language Reference Manual has always said "import *" is not to be used except at module scope (but that the current implementation didn't enforce that). 2.2 *will* enforce that, but only in some cases when it's combined with nested functions containing free variables (see PEP 227 (Statically Nested Scopes) for details), and 2.1 will start *warning* about such uses. From mikael at isy.liu.se Fri Feb 23 11:21:06 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 23 Feb 2001 11:21:06 +0100 (MET) Subject: [Python-Dev] RE: Nested scopes resolution -- you can breathe In-Reply-To: <01c301c5198d$c6bcc3f0$0900a8c0@SPIFF> Message-ID: On 23-Feb-05 Fredrik Lundh wrote: > Mikael Olofsson wrote: > > from __future__ import * > > I wouldn't do that: it imports both "warnings_are_errors" and > "from_import_star_is_evil", and we've found that it's impossible > to catch ParadoxErrors in a platform independent way. Naturally. More seriously though, I like from __future__ import something as an idiom. It gives us a clear reusable syntax to incorporate new features before they are included in the standard distribution. It is not obvious to me that the proposed alternative import __something__ is a way to incorporate something new. Perhaps Py3k should allow from __past__ import something to give us a way to keep some functionality from 2.* that has been (will be) changed in Py3k. explicit-is-better-than-implicit-ly y'rs /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 23-Feb-01 Time: 11:07:11 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From tim.one at home.com Fri Feb 23 17:34:58 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 23 Feb 2001 11:34:58 -0500 Subject: [Python-Dev] RE: Nested scopes resolution -- you can breathe In-Reply-To: Message-ID: [Mikael Olofsson] > Naturally. More seriously though, I like > > from __future__ import something > > as an idiom. It gives us a clear reusable syntax to incorporate new > features before they are included in the standard distribution. It is > not obvious to me that the proposed alternative > > import __something__ > > is a way to incorporate something new. Bingo. That's why I'm pushing for it. Also means we only have to create one artificial module (__future__.py) for this; and besides the doc value, it occurs to me we *do* have to create a real module anyway so that masses of tools don't get confused searching for things that look like modules but don't actually exist. > Perhaps Py3k should allow > > from __past__ import something > > to give us a way to keep some functionality from 2.* that has been > (will be) changed in Py3k. Actually, I thought that's something PythonWare could implement as an extension, to seize the market opportunity created by mean old Guido breaking all the code he can on a whim . Except they'll probably have to extend the syntax a bit, to make that from __past__ import not something Maybe we should add from __future__ import __past__with_not now to make that easier for them. > explicit-is-better-than-implicit-ly y'rs otoh-implicit-manages-to-hide-explicit-suckiness-a-bit-longer-ly y'rs - tim From nas at arctrix.com Fri Feb 23 15:36:51 2001 From: nas at arctrix.com (Neil Schemenauer) Date: Fri, 23 Feb 2001 06:36:51 -0800 Subject: [Python-Dev] Nested scopes resolution -- you can breathe again! In-Reply-To: <200102230259.VAA19238@cj20424-a.reston1.va.home.com>; from guido@digicool.com on Thu, Feb 22, 2001 at 09:59:26PM -0500 References: <200102230259.VAA19238@cj20424-a.reston1.va.home.com> Message-ID: <20010223063651.B23270@glacier.fnational.com> On Thu, Feb 22, 2001 at 09:59:26PM -0500, Guido van Rossum wrote: > from __future__ import nested_scopes I this this alternative better since there is only one "reserved" module name. I still think releasing 2.0.1 with warnings is a good idea. OTOH, maybe its hard for that compiler to detect questionable code. Neil From guido at digicool.com Fri Feb 23 15:42:12 2001 From: guido at digicool.com (Guido van Rossum) Date: Fri, 23 Feb 2001 09:42:12 -0500 Subject: [Python-Dev] Nested scopes resolution -- you can breathe again! In-Reply-To: Your message of "Fri, 23 Feb 2001 06:36:51 PST." <20010223063651.B23270@glacier.fnational.com> References: <200102230259.VAA19238@cj20424-a.reston1.va.home.com> <20010223063651.B23270@glacier.fnational.com> Message-ID: <200102231442.JAA24227@cj20424-a.reston1.va.home.com> > > from __future__ import nested_scopes > > I this this alternative better since there is only one "reserved" > module name. Noted. > I still think releasing 2.0.1 with warnings is a > good idea. OTOH, maybe its hard for that compiler to detect > questionable code. The problem is that in order to do a decent job of compile-time warnings, not only the warnings module and API would have to be retrofitted in 2.0.1, but also the entire new compiler, which has the symbol table needed to be able to detect the situations we want to warn about. --Guido van Rossum (home page: http://www.python.org/~guido/) From jeremy at alum.mit.edu Wed Feb 28 18:58:58 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Wed, 28 Feb 2001 12:58:58 -0500 (EST) Subject: PEP 227 (was Re: Nested scopes resolution -- you can breathe again!) In-Reply-To: <200102230259.VAA19238@cj20424-a.reston1.va.home.com> References: <200102230259.VAA19238@cj20424-a.reston1.va.home.com> Message-ID: <15005.15458.703037.373890@w221.z064000254.bwi-md.dsl.cnc.net> Last week Guido sent a message about our decisions to make nested scopes an optional feature for 2.1 in advance of their mandatory introduction in Python 2.2. I've included an ndiff of the PEP for reference. The beta release on Friday will contain the features as described in the PEP. Jeremy -: old-pep-0227.txt +: pep-0227.txt PEP: 227 Title: Statically Nested Scopes - Version: $Revision: 1.6 $ ? ^ + Version: $Revision: 1.7 $ ? ^ Author: jeremy at digicool.com (Jeremy Hylton) Status: Draft Type: Standards Track Python-Version: 2.1 Created: 01-Nov-2000 Post-History: Abstract This PEP proposes the addition of statically nested scoping (lexical scoping) for Python 2.1. The current language definition defines exactly three namespaces that are used to resolve names -- the local, global, and built-in namespaces. The addition of nested scopes would allow resolution of unbound local names in enclosing functions' namespaces. One consequence of this change that will be most visible to Python programs is that lambda statements could reference variables in the namespaces where the lambda is defined. Currently, a lambda statement uses default arguments to explicitly creating bindings in the lambda's namespace. Introduction This proposal changes the rules for resolving free variables in - Python functions. The Python 2.0 definition specifies exactly - three namespaces to check for each name -- the local namespace, - the global namespace, and the builtin namespace. According to - this defintion, if a function A is defined within a function B, - the names bound in B are not visible in A. The proposal changes - the rules so that names bound in B are visible in A (unless A + Python functions. The new name resolution semantics will take + effect with Python 2.2. These semantics will also be available in + Python 2.1 by adding "from __future__ import nested_scopes" to the + top of a module. + + The Python 2.0 definition specifies exactly three namespaces to + check for each name -- the local namespace, the global namespace, + and the builtin namespace. According to this definition, if a + function A is defined within a function B, the names bound in B + are not visible in A. The proposal changes the rules so that + names bound in B are visible in A (unless A contains a name - contains a name binding that hides the binding in B). ? ---------------- + binding that hides the binding in B). The specification introduces rules for lexical scoping that are common in Algol-like languages. The combination of lexical scoping and existing support for first-class functions is reminiscent of Scheme. The changed scoping rules address two problems -- the limited - utility of lambda statements and the frequent confusion of new + utility of lagmbda statements and the frequent confusion of new ? + users familiar with other languages that support lexical scoping, e.g. the inability to define recursive functions except at the module level. + + XXX Konrad Hinsen suggests that this section be expanded The lambda statement introduces an unnamed function that contains a single statement. It is often used for callback functions. In the example below (written using the Python 2.0 rules), any name used in the body of the lambda must be explicitly passed as a default argument to the lambda. from Tkinter import * root = Tk() Button(root, text="Click here", command=lambda root=root: root.test.configure(text="...")) This approach is cumbersome, particularly when there are several names used in the body of the lambda. The long list of default arguments obscure the purpose of the code. The proposed solution, in crude terms, implements the default argument approach automatically. The "root=root" argument can be omitted. + The new name resolution semantics will cause some programs to + behave differently than they did under Python 2.0. In some cases, + programs will fail to compile. In other cases, names that were + previously resolved using the global namespace will be resolved + using the local namespace of an enclosing function. In Python + 2.1, warnings will be issued for all program statement that will + behave differently. + Specification Python is a statically scoped language with block structure, in the traditional of Algol. A code block or region, such as a - module, class defintion, or function body, is the basic unit of a + module, class definition, or function body, is the basic unit of a ? + program. Names refer to objects. Names are introduced by name binding operations. Each occurrence of a name in the program text refers to the binding of that name established in the innermost function block containing the use. The name binding operations are assignment, class and function definition, and import statements. Each assignment or import statement occurs within a block defined by a class or function definition or at the module level (the top-level code block). If a name binding operation occurs anywhere within a code block, all uses of the name within the block are treated as references to the current block. (Note: This can lead to errors when a name is used within a block before it is bound.) If the global statement occurs within a block, all uses of the name specified in the statement refer to the binding of that name in the top-level namespace. Names are resolved in the top-level namespace by searching the global namespace, the namespace of the module containing the code block, and the builtin namespace, the namespace of the module __builtin__. The global namespace is searched first. If the name is not found there, the builtin - namespace is searched. + namespace is searched. The global statement must precede all uses + of the name. If a name is used within a code block, but it is not bound there and is not declared global, the use is treated as a reference to the nearest enclosing function region. (Note: If a region is contained within a class definition, the name bindings that occur in the class block are not visible to enclosed functions.) A class definition is an executable statement that may uses and definitions of names. These references follow the normal rules for name resolution. The namespace of the class definition becomes the attribute dictionary of the class. The following operations are name binding operations. If they occur within a block, they introduce new local names in the current block unless there is also a global declaration. - Function defintion: def name ... + Function definition: def name ... ? + Class definition: class name ... Assignment statement: name = ... Import statement: import name, import module as name, from module import name Implicit assignment: names are bound by for statements and except clauses The arguments of a function are also local. There are several cases where Python statements are illegal when used in conjunction with nested scopes that contain free variables. If a variable is referenced in an enclosing scope, it is an error to delete the name. The compiler will raise a SyntaxError for 'del name'. - If the wildcard form of import (import *) is used in a function + If the wild card form of import (import *) is used in a function ? + and the function contains a nested block with free variables, the compiler will raise a SyntaxError. If exec is used in a function and the function contains a nested block with free variables, the compiler will raise a SyntaxError - unless the exec explicit specifies the local namespace for the + unless the exec explicitly specifies the local namespace for the ? ++ exec. (In other words, "exec obj" would be illegal, but "exec obj in ns" would be legal.) + If a name bound in a function scope is also the name of a module + global name or a standard builtin name and the function contains a + nested function scope that references the name, the compiler will + issue a warning. The name resolution rules will result in + different bindings under Python 2.0 than under Python 2.2. The + warning indicates that the program may not run correctly with all + versions of Python. + Discussion The specified rules allow names defined in a function to be referenced in any nested function defined with that function. The name resolution rules are typical for statically scoped languages, with three primary exceptions: - Names in class scope are not accessible. - The global statement short-circuits the normal rules. - Variables are not declared. Names in class scope are not accessible. Names are resolved in - the innermost enclosing function scope. If a class defintion + the innermost enclosing function scope. If a class definition ? + occurs in a chain of nested scopes, the resolution process skips class definitions. This rule prevents odd interactions between class attributes and local variable access. If a name binding - operation occurs in a class defintion, it creates an attribute on + operation occurs in a class definition, it creates an attribute on ? + the resulting class object. To access this variable in a method, or in a function nested within a method, an attribute reference must be used, either via self or via the class name. An alternative would have been to allow name binding in class scope to behave exactly like name binding in function scope. This rule would allow class attributes to be referenced either via attribute reference or simple name. This option was ruled out because it would have been inconsistent with all other forms of class and instance attribute access, which always use attribute references. Code that used simple names would have been obscure. The global statement short-circuits the normal rules. Under the proposal, the global statement has exactly the same effect that it - does for Python 2.0. It's behavior is preserved for backwards ? - + does for Python 2.0. Its behavior is preserved for backwards compatibility. It is also noteworthy because it allows name binding operations performed in one block to change bindings in another block (the module). Variables are not declared. If a name binding operation occurs anywhere in a function, then that name is treated as local to the function and all references refer to the local binding. If a reference occurs before the name is bound, a NameError is raised. The only kind of declaration is the global statement, which allows programs to be written using mutable global variables. As a consequence, it is not possible to rebind a name defined in an enclosing scope. An assignment operation can only bind a name in the current scope or in the global scope. The lack of declarations and the inability to rebind names in enclosing scopes are unusual for lexically scoped languages; there is typically a mechanism to create name bindings (e.g. lambda and let in Scheme) and a mechanism to change the bindings (set! in Scheme). XXX Alex Martelli suggests comparison with Java, which does not allow name bindings to hide earlier bindings. Examples A few examples are included to illustrate the way the rules work. XXX Explain the examples >>> def make_adder(base): ... def adder(x): ... return base + x ... return adder >>> add5 = make_adder(5) >>> add5(6) 11 >>> def make_fact(): ... def fact(n): ... if n == 1: ... return 1L ... else: ... return n * fact(n - 1) ... return fact >>> fact = make_fact() >>> fact(7) 5040L >>> def make_wrapper(obj): ... class Wrapper: ... def __getattr__(self, attr): ... if attr[0] != '_': ... return getattr(obj, attr) ... else: ... raise AttributeError, attr ... return Wrapper() >>> class Test: ... public = 2 ... _private = 3 >>> w = make_wrapper(Test()) >>> w.public 2 >>> w._private Traceback (most recent call last): File "", line 1, in ? AttributeError: _private - An example from Tim Peters of the potential pitfalls of nested scopes ? ^ -------------- + An example from Tim Peters demonstrates the potential pitfalls of ? +++ ^^^^^^^^ - in the absence of declarations: + nested scopes in the absence of declarations: ? ++++++++++++++ i = 6 def f(x): def g(): print i # ... # skip to the next page # ... for i in x: # ah, i *is* local to f, so this is what g sees pass g() The call to g() will refer to the variable i bound in f() by the for loop. If g() is called before the loop is executed, a NameError will be raised. XXX need some counterexamples Backwards compatibility There are two kinds of compatibility problems caused by nested scopes. In one case, code that behaved one way in earlier - versions, behaves differently because of nested scopes. In the ? - + versions behaves differently because of nested scopes. In the other cases, certain constructs interact badly with nested scopes and will trigger SyntaxErrors at compile time. The following example from Skip Montanaro illustrates the first kind of problem: x = 1 def f1(): x = 2 def inner(): print x inner() Under the Python 2.0 rules, the print statement inside inner() refers to the global variable x and will print 1 if f1() is called. Under the new rules, it refers to the f1()'s namespace, the nearest enclosing scope with a binding. The problem occurs only when a global variable and a local variable share the same name and a nested function uses that name to refer to the global variable. This is poor programming practice, because readers will easily confuse the two different variables. One example of this problem was found in the Python standard library during the implementation of nested scopes. To address this problem, which is unlikely to occur often, a static analysis tool that detects affected code will be written. - The detection problem is straightfoward. + The detection problem is straightforward. ? + - The other compatibility problem is casued by the use of 'import *' ? - + The other compatibility problem is caused by the use of 'import *' ? + and 'exec' in a function body, when that function contains a nested scope and the contained scope has free variables. For example: y = 1 def f(): exec "y = 'gotcha'" # or from module import * def g(): return y ... At compile-time, the compiler cannot tell whether an exec that - operators on the local namespace or an import * will introduce ? ^^ + operates on the local namespace or an import * will introduce ? ^ name bindings that shadow the global y. Thus, it is not possible to tell whether the reference to y in g() should refer to the global or to a local name in f(). In discussion of the python-list, people argued for both possible interpretations. On the one hand, some thought that the reference in g() should be bound to a local y if one exists. One problem with this interpretation is that it is impossible for a human reader of the code to determine the binding of y by local inspection. It seems likely to introduce subtle bugs. The other interpretation is to treat exec and import * as dynamic features that do not effect static scoping. Under this interpretation, the exec and import * would introduce local names, but those names would never be visible to nested scopes. In the specific example above, the code would behave exactly as it did in earlier versions of Python. - Since each interpretation is problemtatic and the exact meaning ? - + Since each interpretation is problematic and the exact meaning ambiguous, the compiler raises an exception. A brief review of three Python projects (the standard library, Zope, and a beta version of PyXPCOM) found four backwards compatibility issues in approximately 200,000 lines of code. There was one example of case #1 (subtle behavior change) and two examples of import * problems in the standard library. (The interpretation of the import * and exec restriction that was implemented in Python 2.1a2 was much more restrictive, based on language that in the reference manual that had never been enforced. These restrictions were relaxed following the release.) + Compatibility of C API + + The implementation causes several Python C API functions to + change, including PyCode_New(). As a result, C extensions may + need to be updated to work correctly with Python 2.1. + locals() / vars() These functions return a dictionary containing the current scope's local variables. Modifications to the dictionary do not affect the values of variables. Under the current rules, the use of locals() and globals() allows the program to gain access to all the namespaces in which names are resolved. An analogous function will not be provided for nested scopes. Under this proposal, it will not be possible to gain dictionary-style access to all visible scopes. + Warnings and Errors + + The compiler will issue warnings in Python 2.1 to help identify + programs that may not compile or run correctly under future + versions of Python. Under Python 2.2 or Python 2.1 if the + nested_scopes future statement is used, which are collectively + referred to as "future semantics" in this section, the compiler + will issue SyntaxErrors in some cases. + + The warnings typically apply when a function that contains a + nested function that has free variables. For example, if function + F contains a function G and G uses the builtin len(), then F is a + function that contains a nested function (G) with a free variable + (len). The label "free-in-nested" will be used to describe these + functions. + + import * used in function scope + + The language reference specifies that import * may only occur + in a module scope. (Sec. 6.11) The implementation of C + Python has supported import * at the function scope. + + If import * is used in the body of a free-in-nested function, + the compiler will issue a warning. Under future semantics, + the compiler will raise a SyntaxError. + + bare exec in function scope + + The exec statement allows two optional expressions following + the keyword "in" that specify the namespaces used for locals + and globals. An exec statement that omits both of these + namespaces is a bare exec. + + If a bare exec is used in the body of a free-in-nested + function, the compiler will issue a warning. Under future + semantics, the compiler will raise a SyntaxError. + + local shadows global + + If a free-in-nested function has a binding for a local + variable that (1) is used in a nested function and (2) is the + same as a global variable, the compiler will issue a warning. + Rebinding names in enclosing scopes There are technical issues that make it difficult to support rebinding of names in enclosing scopes, but the primary reason that it is not allowed in the current proposal is that Guido is 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. The proposed rules allow programmers to achieve the effect of rebinding, albeit awkwardly. The name that will be effectively rebound by enclosed functions is bound to a container object. In place of assignment, the program uses modification of the container to achieve the desired effect: def bank_account(initial_balance): balance = [initial_balance] def deposit(amount): balance[0] = balance[0] + amount return balance def withdraw(amount): balance[0] = balance[0] - amount return balance return deposit, withdraw Support for rebinding in nested scopes would make this code clearer. A class that defines deposit() and withdraw() methods and the balance as an instance variable would be clearer still. Since classes seem to achieve the same effect in a more straightforward manner, they are preferred. Implementation The implementation for C Python uses flat closures [1]. Each def or lambda statement that is executed will create a closure if the body of the function or any contained function has free variables. Using flat closures, the creation of closures is somewhat expensive but lookup is cheap. The implementation adds several new opcodes and two new kinds of names in code objects. A variable can be either a cell variable or a free variable for a particular code object. A cell variable is referenced by containing scopes; as a result, the function where it is defined must allocate separate storage for it on each - invocation. A free variable is reference via a function's closure. ? --------- + invocation. A free variable is referenced via a function's ? + + closure. + + The choice of free closures was made based on three factors. + First, nested functions are presumed to be used infrequently, + deeply nested (several levels of nesting) still less frequently. + Second, lookup of names in a nested scope should be fast. + Third, the use of nested scopes, particularly where a function + that access an enclosing scope is returned, should not prevent + unreferenced objects from being reclaimed by the garbage + collector. XXX Much more to say here References [1] Luca Cardelli. Compiling a functional language. In Proc. of the 1984 ACM Conference on Lisp and Functional Programming, pp. 208-217, Aug. 1984 http://citeseer.nj.nec.com/cardelli84compiling.html From robin at jessikat.fsnet.co.uk Fri Feb 23 10:45:28 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 23 Feb 2001 09:45:28 +0000 Subject: Nested scopes resolution -- you can breathe again! References: Message-ID: In article , Guido van Rossum writes ..... >We have clearly underestimated how much code the nested scopes would >break, but more importantly we have underestimated how much value our >community places on stability. At the same time we really like nested >scopes, and we would like to see the feature introduced at some point. > >So here's the deal: we'll make nested scopes an optional feature in >2.1, default off, selectable on a per-module basis using a mechanism >that's slightly hackish but is guaranteed to be safe. (See below.) > .... The problem here is that of stability; introducing new versions which break old extensions at the rate of two a year is the problem. Does this 2.1 release make all the changes to the API which are needed and if so why do we need to turn python21.dll into python22.dll. The unixers might get away with smart loaders, but win32 will require a complete rebuild for all .pyds. The confusion caused by multiple versions is an issue. I would prefer it if 2.1 moved to 2.11 instead of 2.2. Whilst helping my colleague migrate from 1.5.2 to 2.0 we came up against the dreaded python15.dll not found message. The irritating thing about the message is that it didn't tell us which .pyd it was attempting to load. -- Robin Becker From db3l at fitlinxx.com Mon Feb 26 22:52:58 2001 From: db3l at fitlinxx.com (David Bolen) Date: 26 Feb 2001 16:52:58 -0500 Subject: Nested scopes resolution -- you can breathe again! References: Message-ID: Robin Becker writes: > Whilst helping my colleague migrate from 1.5.2 to 2.0 we came up against > the dreaded python15.dll not found message. The irritating thing about > the message is that it didn't tell us which .pyd it was attempting to > load. Note that if you actually have a python15.dll on your system (so that the Windows system loader can resolve it), then the Python import mechanism will complain about the mismatch as an ImportError - at least if the dependency is directly from the module being imported - which may be of more help. -- -- 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 Tue Feb 27 11:43:55 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 27 Feb 2001 10:43:55 +0000 Subject: Nested scopes resolution -- you can breathe again! References: Message-ID: In article , David Bolen writes >Robin Becker writes: > >> Whilst helping my colleague migrate from 1.5.2 to 2.0 we came up against >> the dreaded python15.dll not found message. The irritating thing about >> the message is that it didn't tell us which .pyd it was attempting to >> load. > >Note that if you actually have a python15.dll on your system (so that >the Windows system loader can resolve it), then the Python import >mechanism will complain about the mismatch as an ImportError - at >least if the dependency is directly from the module being imported - >which may be of more help. > >-- >-- David yes, but it would be just as easy to get the failure to do that. The message may come from windows, but the extension (in our case zlib) still wasn't loaded and that should have been enough, but we had a try/except around the particular import. Finding a matching pyd/dll which then fails to load is surely not 'just an import error' even if it eventually gets raised as one. -- Robin Becker From db3l at fitlinxx.com Wed Feb 28 02:26:13 2001 From: db3l at fitlinxx.com (David Bolen) Date: 27 Feb 2001 20:26:13 -0500 Subject: Nested scopes resolution -- you can breathe again! References: Message-ID: Robin Becker writes: > yes, but it would be just as easy to get the failure to do that. The > message may come from windows, but the extension (in our case zlib) The reason I suggested placing a python15.dll on the system is to get rid of the Windows message, leaving it just to the Python ImportError. > still wasn't loaded and that should have been enough, but we had a > try/except around the particular import. Finding a matching pyd/dll > which then fails to load is surely not 'just an import error' even if it > eventually gets raised as one. Well, but it doesn't have to be too much work. I'm thinking of the specific ImportError of: "Module use of python15.dll conflicts with this version of Python." in which case you know that you have an old extension (which has to be on Python's sys.path somewhere), and that one of three things are true: 1. The imported module directly depends on python15.dll (probably most likely for C extension modules being directly imported, like zlib). 2. The module you imported itself imports some other module with the dependency - in that case you have the traceback showing which import of which module failed, which reverts to the prior 1. 3. The module has a Windows DLL dependency which eventually pulls in python15.dll. In this case, you know the top level module, so use a standard windows tool like depends to check the dependencies. It's really only case (3) where you need something more than Python itself provides, but even in (3) you know the module to check, and it's a relatively straight forward path to fully identifying the root cause. It should also be reasonably rare since most extension modules directly use python15.dll rather than linking to another DLL which itself is the extension. Of course, none of this is to excuse the mess that is Windows DLL-land :-) -- -- 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 Wed Feb 28 11:27:55 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 28 Feb 2001 10:27:55 +0000 Subject: Nested scopes resolution -- you can breathe again! References: Message-ID: In article , David Bolen writes >Robin Becker writes: .... >Well, but it doesn't have to be too much work. I'm thinking of the >specific ImportError of: > > "Module use of python15.dll conflicts with this version of Python." > >in which case you know that you have an old extension (which has to be >on Python's sys.path somewhere), and that one of three things are >true: > >1. The imported module directly depends on python15.dll (probably most > likely for C extension modules being directly imported, like zlib). >2. The module you imported itself imports some other module with the > dependency - in that case you have the traceback showing which import > of which module failed, which reverts to the prior 1. >3. The module has a Windows DLL dependency which eventually pulls in > python15.dll. In this case, you know the top level module, so use > a standard windows tool like depends to check the dependencies. > .... I guess the 'import' of this is that I should be more specific in trapping my import errors. Because zlib is often absent we have try: import zlib except ImportError: #other stuff ... The catchall exception is my problem. I reckon the specific error trap should be except ImportError, 'No module named zlib' but this dependency on the format of the message seems a bit fragile. >Of course, none of this is to excuse the mess that is Windows DLL-land :-) that is of course true ;( >-- David -- Robin Becker From owen at astrono.spamwashington.emu Fri Feb 23 18:01:19 2001 From: owen at astrono.spamwashington.emu (Russell E. Owen) Date: Fri, 23 Feb 2001 09:01:19 -0800 Subject: Nested scopes resolution -- you can breathe again! References: Message-ID: In article , Guido van Rossum wrote: >We (PythonLabs) have received a lot of flak over our plan to introduce >nested scopes despite the fact that it appears to break a small but >significant amount of working code. I'm unhappy about the plan not because of potentially broken old code, but because it's not as clean as it might be. There are some unfortunate exceptions (such as classes) and it seems a bit more dangerous in Python than in other languages because of Python's lack of requirement to declare variables. A mis-typed variable name may accidentally refer to a variable instead of just creating a new local variable -- a bad bug becomes a worse bug. I think I am not the only one. So what I'm saying, at the risk of giving offense, is I'd rather wait and have a cleaner implementation. In a posting yesterday I suggested considering scaling back the proposal to allow it to be simpler and more regular, for example have a keyword or other explicit notation to say "this variable is not in local scope". One person replied with a notation that sounded interesting. Thank you for the many wonderful enhancements in 2.0. Lots of nice changes in there to make a programmer's life easier. An outstanding upgrade to a great language! -- Russell From qrczak at knm.org.pl Sat Feb 24 15:21:29 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 24 Feb 2001 14:21:29 GMT Subject: Nested scopes resolution -- you can breathe again! References: Message-ID: Fri, 23 Feb 2001 09:01:19 -0800, Russell E. Owen pisze: > In a posting yesterday I suggested considering scaling back the > proposal to allow it to be simpler and more regular, for example > have a keyword or other explicit notation to say "this variable is > not in local scope". I would certainly not call it simpler. Maybe for the language implementor, but not for the programmer, which must search the expression for its free variables to list them at the top, obscuring the program. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From rturpin at do.not.use Sat Feb 24 18:06:09 2001 From: rturpin at do.not.use (Russell Turpin) Date: Sat, 24 Feb 2001 11:06:09 -0600 Subject: Nested scopes resolution -- you can breathe again! References: Message-ID: <3A97EA01.C83F5082@do.not.use> Fri, 23 Feb 2001 09:01:19 -0800, Russell E. Owen pisze: >> I suggested .. scaling back the proposal to allow it >> to be simpler and more regular, for example have a >> keyword or other explicit notation to say "this >> variable is not in local scope". The best argument for this is that it is more EXPLICIT. Currently, the "global" keyword is required to set a variable outside local scope. Simple reference, though, is automatic. This is consistent with automatic declaration, though in both cases, it risks program errors. I suspect an option that requires explicit declaration is one of the more frequent requests by Python programmers. Marcin 'Qrczak' Kowalczyk wrote: > I would certainly not call it simpler. Maybe for > the language implementor, but not for the programmer, > which must search the expression for its free variables > to list them at the top, obscuring the program. ??? When a programmer writes the variable "x," they had better know, in that context, to what it refers. If they don't, there is pretty low chance that the code will work. And far from obscuring the intent, perhaps the SINGLE, BEST practice a programmer can employ, to help those who come later understand their work, is to put a manifest of all variables at the top of each function, class, and module. Russell From qrczak at knm.org.pl Sat Feb 24 18:55:03 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 24 Feb 2001 17:55:03 GMT Subject: Nested scopes resolution -- you can breathe again! References: <3A97EA01.C83F5082@do.not.use> Message-ID: Sat, 24 Feb 2001 11:06:09 -0600, Russell Turpin pisze: > When a programmer writes the variable "x," they had better know, > in that context, to what it refers. How do you describe the "what"? It's just the one that is bound in the nearest enclosing function. There are no explicit variable declarations in Python, so nested scopes make it exactly as explicit as needed and practical under this assumption. A requirement to qualify each variable with the full path to its definition (__builtin__, global, functions etc.) would be impractical. When a variable is not defined but referenced in some functions, what would you want it to refer to? An obvious candidate is to make it the same variable as one level up - I didn't tell Python that I want this name to refer to anything else, so it should stay the same in the nested function. Making it silently refer to a toplevel definition is evil, error-prone, counter-intuitive, and I am glad that it's changing. > And far from obscuring the intent, perhaps the SINGLE, BEST practice > a programmer can employ, to help those who come later understand > their work, is to put a manifest of all variables at the top of > each function, class, and module. Not at all. You don't manifest names you refer to which are defined at the module level, nor builtin names, nor you don't explicitly state that they are local. Why would you make an exception for names bound in outer but not global scopes? -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From rturpin at do.not.use Sun Feb 25 17:54:21 2001 From: rturpin at do.not.use (Russell Turpin) Date: Sun, 25 Feb 2001 10:54:21 -0600 Subject: Nested scopes resolution -- you can breathe again! References: <3A97EA01.C83F5082@do.not.use> Message-ID: <3A9938BD.AE5F0B2B@do.not.use> Turpin: >> And far from obscuring the intent, perhaps the SINGLE, >> BEST practice a programmer can employ, to help those >> who come later understand their work, is to put a >> manifest of all variables at the top of each function, >> class, and module. Marcin 'Qrczak' Kowalczyk wrote: > Not at all. You don't manifest names you refer to which > are defined at the module level, nor builtin names, nor > you don't explicitly state that they are local. Why would > you make an exception for names bound in outer but not > global scopes? If you're using good programming practices, module names either (a) explicitly refer to the module everywhere they appear, e.g., "x = someMod.SomeClass()," or (b) are explicitly manifested where they are imported, e.g., "from someMod import SomeClass". The wildcard feature on the "from" statement is a mistake, and should be avoided. Using either (a) or (b), anyone reading the code can easily determine which variables are non-local, and where they originate. Built-in names are are simply part of the language. You can't extrapolate from how they work to how names generally should work. Even though Python doesn't implement data encapsulation, it is good practice to lexically differentiate between private names and public ones. Where I work, we use naming conventions for this purpose. One of the problems with wildcard imports is the risk of accidental private name collision, where an imported module uses the same private name as the one that imports it. Nested scoping essentially is a wildcard import from all containing scopes. There are a VERY FEW cases in OOP where this is genuinely useful. For the most part, its use should be avoided like the plague. 99% of the time it is used, there is a more robust and more understandable way to solve the problem without nested scoping. I understand the desire for nested scoping with respect to lambda definitions. Frankly, though, that seems a weak reason for changing the name resolution mechanism. The only other argument I've heard is that it makes Python more like languages that borrowed naming rules from Algol. Python is a much better language than Algol, or most of its successors, so I don't see why it should be jammed into that mold. Python is a great language. Implicit declaration works well for programmers who have developed good programming practices. It can be rope for those who haven't. The wildcard on import is a mistake. Someone should submit a PEP to spit out a warning everytime someone uses it: "Hey STUPID! DON'T use wildcard on import!" Then, remove it from Python3K. Russell From qrczak at knm.org.pl Sun Feb 25 19:11:20 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 25 Feb 2001 18:11:20 GMT Subject: Nested scopes resolution -- you can breathe again! References: <3A97EA01.C83F5082@do.not.use> <3A9938BD.AE5F0B2B@do.not.use> Message-ID: Sun, 25 Feb 2001 10:54:21 -0600, Russell Turpin pisze: > The wildcard feature on the "from" statement is a mistake, and > should be avoided. I agree. This doesn't conflict with my point. Look this way: a name has not been explicitly hidden in an inner scope, so it should not be silently made unavailable. Explicit is better than implicit, so please don't hide names which were not explicitly shadowed (i.e. assigned to). Hiding as in older versions of Python leads to obscure bugs when the default argument hack is forgotten, and more ugly code. This hack is also not general, because you can't have a variable number of arguments: lambda x, y, var=var, *rest: ...reference var here... is not a replacement for lambda x, y, *rest: ...reference var here... > Using either (a) or (b), anyone reading the code can easily determine > which variables are non-local, and where they originate. A good practice is to not shadow names from outer scopes explicitly. In this case nested scopes make it easier to find where a name is coming from: just spot *any* assignment to that name, and it is defined there. Python's practice does not create deeply nested scopes anyway, so this is the smallest problem in finding variable's definition. > One of the problems with wildcard imports is the risk of accidental > private name collision, where an imported module uses the same > private name as the one that imports it. > > Nested scoping essentially is a wildcard import from all containing > scopes. You shouldn't show a disadvantage of wildcard imports and tell that nested scopes are like wildcard imports, because nested scopes don't have this problem! Names which you define are not shadowed by names "imported" from nested scopes. PS. A construction similar to wildcard import is not so bad where the language protects from using ambiguous names (imported from different modules or imported from a module and defined locally), e.g. as in Haskell. They are useful especially when the language uses toplevel functions where Python uses methods. I agree that it's bad in Python. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From wtanksle at dolphin.openprojects.net Fri Feb 23 20:57:34 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Fri, 23 Feb 2001 19:57:34 GMT Subject: Nested scopes resolution -- you can breathe again! References: Message-ID: On Thu, 22 Feb 2001 21:59:26 -0500, Guido van Rossum wrote: > import __nested_scopes__ > from __future__ import nested_scopes I like the second version. That's quite cool. Can I import stock market quotes from the future, too? I'm sure that's going to be a FAQ. Come to think of it, perhaps __features__ is a better name than __future__. And perhaps _old_ code should bear the brunt of the change, with one of the features being old_unnested_scoping. This way we don't have to keep a default that's deprecated forever. So we'd never see the line "from __features__ import nested_scoping"; that would become an anachonism, and would quickly get irritating. Instead, we'd see "from __features__ import old_unnested_scoping" at the head of modules which won't compile without warning. >We also believe that the magical import mechanism is useful enough to >be reused for other situations like this; Tim will draft a PEP to >describe in excruciating detail. >I thank everybody who gave feedback on this issue. And thanks to >Jeremy for implementing nested scopes! Absolutely. I'm very glad that nested scopes are here at last. >--Guido van Rossum (home page: http://www.python.org/~guido/) -- -William "Billy" Tanksley From tim.one at home.com Fri Feb 23 22:17:40 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 23 Feb 2001 16:17:40 -0500 Subject: Nested scopes resolution -- you can breathe again! In-Reply-To: Message-ID: [Guido] > import __nested_scopes__ > from __future__ import nested_scopes [William Tanksley] > I like the second version. That's quite cool. I'd have a hard time guessing that from the rest of this msg . > ... > And perhaps _old_ code should bear the brunt of the change, with one of > the features being old_unnested_scoping. This way we don't have to keep a > default that's deprecated forever. No. The point of the scheme is to let motivated people use release N+1 features in release N without anyone else needing to change any of their code. To the extent possible, release N will instead produce warnings about code that *will* break in release N+1. Nobody is required to endure N+1 semantics before N+1; but people who want to experiment with N+1 features in N can do so by explicitly asking for them. > So we'd never see the line "from __features__ import nested_scoping"; > that would become an anachonism, and would quickly get irritating. Good! That means people will be motivated to get rid of it when it becomes an anachronism (in N+1). This puts the burden where it should be (i.e., on the pioneers, not on the laggards <0.9 wink>). BTW, for reasons to be explained in an upcoming PEP, it will be very easy to find unneeded __future__ imports as the millennia roll by. > Instead, we'd see "from __features__ import old_unnested_scoping" at > the head of modules which won't compile without warning. In release N+1, release N semantics are *gone*. There's no going back, else the Python implementation would become an unboundedly complicated mess as the years go by, and so would Python programs. __future__ is for incompatible changes, not for optional behaviors. If, at release N+1, you refuse to move to release N+1 semantics, fine: stay with release N forever. That's your choice. From grante at visi.com Sat Feb 24 03:58:27 2001 From: grante at visi.com (Grant Edwards) Date: Sat, 24 Feb 2001 02:58:27 GMT Subject: Nested scopes resolution -- you can breathe again! References: Message-ID: In article , Mikael Olofsson wrote: > >On 23-Feb-01 Guido van Rossum wrote: > > from __future__ import nested_scopes > >There really is a time machine. So I guess I can get the full Python 3k >functionality by doing > >from __future__ import * Careful, you never know what the __future__ holds... -- Grant Edwards grante Yow! Okay... I'm going at home to write the "I HATE visi.com RUBIK's CUBE HANDBOOK FOR DEAD CAT LOVERS"... From wtanksle at dolphin.openprojects.net Tue Feb 27 00:08:37 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Mon, 26 Feb 2001 23:08:37 GMT Subject: Nested scopes resolution -- you can breathe again! References: Message-ID: On Fri, 23 Feb 2001 16:17:40 -0500, Tim Peters wrote: >[Guido] >> import __nested_scopes__ >> from __future__ import nested_scopes >> And perhaps _old_ code should bear the brunt of the change, with one of >> the features being old_unnested_scoping. This way we don't have to keep a >> default that's deprecated forever. >No. The point of the scheme is to let motivated people use release N+1 >features in release N without anyone else needing to change any of their >code. To the extent possible, release N will instead produce warnings about >code that *will* break in release N+1. Nobody is required to endure N+1 >semantics before N+1; but people who want to experiment with N+1 features in >N can do so by explicitly asking for them. Ah, so this is only intended for experimental code. Sorry, I just have a phobia of "temporary" language features. Obviously, I've seen too many of them become permanent. I say skip the warning stuff unless it's really easy. In release N, provide a simple way for people to downgrade to the old semantics when their code doesn't run right. In release N+1, try to remove that mechanism. >> So we'd never see the line "from __features__ import nested_scoping"; >> that would become an anachonism, and would quickly get irritating. >Good! That means people will be motivated to get rid of it when it >becomes an anachronism (in N+1). That is a relief; I was worried that it would never be removed. Looks like I misread the post. I was envisioning a world where all newbies would be taught to start their Python scripts with five or six lines of boilerplate to get the useful features :-). >This puts the burden where it should be (i.e., on the pioneers, not on the >laggards <0.9 wink>). The *pioneers* are using CVS, never release versions. They have enough troubles in life. The laggards will never be affected: they're still using 1.5 (my company is!). The middle-of-the-road people will upgrade to a new version to get compelling new features, and will be discouraged to hear that one of the compelling new features has to be accessed in a manner which will become obsolete shortly. >BTW, for reasons to be explained in an upcoming PEP, it will be very easy >to find unneeded __future__ imports as the millennia roll by. That's cool. -- -William "Billy" Tanksley From tim.one at home.com Tue Feb 27 01:24:12 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 26 Feb 2001 19:24:12 -0500 Subject: Nested scopes resolution -- you can breathe again! In-Reply-To: Message-ID: [Tim, on __future__] >> The point of the scheme is to let motivated people use release N+1 >> features in release N without anyone else needing to change any of >> their code. To the extent possible, release N will instead produce >> warnings about code that *will* break in release N+1. Nobody is >> required to endure N+1 semantics before N+1; but people who want to >> experiment with N+1 features in N can do so by explicitly asking for >> them. [William Tanksley] > Ah, so this is only intended for experimental code. No, it's to allow people to migrate incrementally, on a module-by-module basis, to release N+1 semantics while they're still happily running release N under release N-1 semantics. > Sorry, I just have a phobia of "temporary" language features. Nothing temporary about it. For example, nested scopes will be THE rule in 2.2. 2.1 will let you get ready for that change, via __future__, without yet forcing the issue, should you happen to have old code that may break. > ... > I say skip the warning stuff unless it's really easy. The warning stuff is essential. > In release N, provide a simple way for people to downgrade to the > old semantics when their code doesn't run right. Why? The default is not to break old code, which is overwhelmingly more often requested. > In release N+1, try to remove that mechanism. Six of one, half dozen of the other to me, except that there's no "try" in N+1, the old behavior is history then. > ... > The middle-of-the-road people will upgrade to a new version to get > compelling new features, and will be discouraged to hear that one > of the compelling new features has to be accessed in a manner which > will become obsolete shortly. 1. This has nothing to do with new features per se. It's for incompatible changes. "incompatible" is key there. You'll never need a __future__ statement just to get a new feature, unless that feature *also* has the potential to *break* old code. So, for example, had we done this earlier in Python's life, you would NOT have needed a __future__ statement to get at list comprehensions or print>>. Those were wholly backward compatible. You WOULD have needed it long ago when "lambda" was introduced, because that added a new keyword and so broke any old code that used "lambda" as a vrbl, function, class or attribute name. 2. Not obsolete, simply unnecessary -- at N+1 they don't *need* the old __future__s anymore, but they're still allowed. Note too that incompatible changes typically break few lines of code, although that will vary by user. For example, the nested scopes change breaks perhaps three lines of Python in the standard distribution. So we normally anticipate that __future__ will get used in only a small percentage of modules, and usually where people are playing on the edge of the language, or even in direct violation of what the Language Reference Manual has said all along (which appears to be the case with real-life nested scope breakage so far). it's-not-a-dessert-topping-it's-a-floor-wax-ly y'rs - tim From wtanksle at dolphin.openprojects.net Wed Feb 28 01:09:58 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Wed, 28 Feb 2001 00:09:58 GMT Subject: Nested scopes resolution -- you can breathe again! References: Message-ID: On Mon, 26 Feb 2001 19:24:12 -0500, Tim Peters wrote: >1. This has nothing to do with new features per se. It's for incompatible > changes. "incompatible" is key there. Whoops! I didn't get that key distinction. I see your point, and have to concede that I have no experience with introducing incompatible changes into a language. I'm glad that we're getting the ability to do that, though. There *are* some oddities in Python, and it'll be good to be able to make them go away. >it's-not-a-dessert-topping-it's-a-floor-wax-ly y'rs - tim Hmm... Tastes like foot to me. -- -William "Billy" Tanksley From jayhawks at netsgo.com Fri Feb 23 06:22:45 2001 From: jayhawks at netsgo.com (jayhawks at netsgo.com) Date: Fri, 23 Feb 2001 05:22:45 -0000 Subject: may i get sample source ? Message-ID: <974s35+jk6u@eGroups.com> HI? may i get sample source about python + informix ? or where get i sample ? i don't know wel about using python+informix . i am new to python . thanks. From adam at deprince.net Fri Feb 23 07:34:04 2001 From: adam at deprince.net (Adam DePrince) Date: Fri, 23 Feb 2001 01:34:04 -0500 Subject: may i get sample source ? References: Message-ID: <3A96045C.FC182C5D@deprince.net> jayhawks at netsgo.com wrote: > > HI? > > may i get sample source about python + informix ? > or > where get i sample ? > > i don't know wel about using python+informix . > > i am new to python . > > thank You can look up python addons here: http://www.vex.net/parnassus/ Two interfaces to informix are here: http://www.vex.net/parnassus/apyllo.py?find=informix Informixdb claims to support DB1.0; documentation on DB1.0 can be found here: http://www.python.org/topics/database/DatabaseAPI-1.0.html Adam DePrince Starmedia Network, Inc. Email: zlib.decompress('x\332KLI\314\325KI-(\312\314KNu(.I,\312MM\311L\324K\316\317\005\000\221\331\012s') From rolney at pcug.org.au Fri Feb 23 06:44:27 2001 From: rolney at pcug.org.au (Robert Olney) Date: Fri, 23 Feb 2001 15:44:27 +1000 Subject: Can't redirect output Message-ID: <3A95F8BA.9CD22C6F@pcug.org.au> I am running Python 2.0 on Windows 98. When I try to redirect output from a command prompt, e.g. C:\> python hello.py > out.txt the output is printed on the screen and not to the file. Why? The FAQ mentions that this is a problem under Linux. Thanks, Robert. From chris.gonnerman at usa.net Fri Feb 23 14:44:39 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Fri, 23 Feb 2001 07:44:39 -0600 Subject: Can't redirect output References: <3A95F8BA.9CD22C6F@pcug.org.au> Message-ID: <002401c09d9e$c91eb3c0$a100000a@local> From: "Robert Olney" Subject: Can't redirect output > I am running Python 2.0 on Windows 98. When I try to redirect output > from a command prompt, e.g. > > C:\> python hello.py > out.txt > > the output is printed on the screen and not to the file. Why? Is the output you are talking about from print commands and/or sys.stdout.write(...) calls, or is it error messages? Unix and Windows processes have two standard channels for writing messages, stdout and stderr, which Python maps to sys.stdout and sys.stderr. The redirection you show only redirects stdout/sys.stdout. On Unix (and reportedly Windows NT) you can write: python hello.py >out.txt 2>errors.txt which separates the output channels, or python hello.py >out.txt 2>&1 to combine them in the file. Unfortunately this does not work on Win9X, but there is a program available called stderr which combines the two channels. Get it from: http://www.teaser.fr/~amajorel/stderr/ IF NONE OF THIS HELPS YOU... please post your hello.py so we can inspect it. >The FAQ > mentions that this is a problem under Linux. I'll have to look at the FAQ, I'm not sure why Linux would have a problem with it. From rolney at pcug.org.au Sat Feb 24 01:50:33 2001 From: rolney at pcug.org.au (Robert Olney) Date: Sat, 24 Feb 2001 00:50:33 GMT Subject: Can't redirect output References: <3A95F8BA.9CD22C6F@pcug.org.au> Message-ID: <3a9703b0.4598430@newshost.pcug.org.au> "Chris Gonnerman" wrote: >From: "Robert Olney" >Subject: Can't redirect output >> I am running Python 2.0 on Windows 98. When I try to redirect output >> from a command prompt, e.g. >> >> C:\> python hello.py > out.txt >> >> the output is printed on the screen and not to the file. Why? > >Is the output you are talking about from print commands and/or >sys.stdout.write(...) calls, or is it error messages? Unix and Windows >processes have two standard channels for writing messages, stdout and >stderr, which Python maps to sys.stdout and sys.stderr. The redirection >you show only redirects stdout/sys.stdout. > >On Unix (and reportedly Windows NT) you can write: > > python hello.py >out.txt 2>errors.txt > >which separates the output channels, or > > python hello.py >out.txt 2>&1 > >to combine them in the file. Unfortunately this does not work on Win9X, >but there is a program available called stderr which combines the two >channels. Get it from: > > http://www.teaser.fr/~amajorel/stderr/ > >IF NONE OF THIS HELPS YOU... please post your hello.py so we can >inspect it. > >>The FAQ >> mentions that this is a problem under Linux. > >I'll have to look at the FAQ, I'm not sure why Linux would have a problem >with it. > > > I am using normal print commands. Hello.py: print "Hello" I have now found I can't redirect this under DOS (python 1.5.2) either. Robert. From chris.gonnerman at usa.net Sat Feb 24 07:03:31 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sat, 24 Feb 2001 00:03:31 -0600 Subject: Can't redirect output References: <3A95F8BA.9CD22C6F@pcug.org.au> <3a9703b0.4598430@newshost.pcug.org.au> Message-ID: <00e201c09e27$8929b920$a100000a@local> ----- Original Message ----- From: "Robert Olney" Subject: Re: Can't redirect output > >> I am running Python 2.0 on Windows 98. When I try to redirect output > >> from a command prompt, e.g. > >> > >> C:\> python hello.py > out.txt > >> > >> the output is printed on the screen and not to the file. Why? > > > I am using normal print commands. > > Hello.py: > print "Hello" Huh. I just put that single line (print "Hello") into a script file and did python Hello.py > out.txt as you specified, and it worked find. I'm using BeOpen Python 2.0 on Windows 98. The same code works fine under Python 1.5.2 on Linux 2.2. I'm puzzled. Can you try this on a different Win98 computer? Do you have a keyboard or console redirector running (not DOSKEY but a clone)? Are you running COMMAND.COM, 4DOS, Win95CMD.exe, or what? Can you think of anything unusual about your console configuration? > I have now found I can't redirect this under DOS (python 1.5.2) > either. I've never tried the DOS version, so I can't comment here. From timo at lightdog.com Mon Feb 26 18:00:49 2001 From: timo at lightdog.com (timo at lightdog.com) Date: Mon, 26 Feb 2001 12:00:49 -0500 Subject: Can't redirect output In-Reply-To: <00e201c09e27$8929b920$a100000a@local> Message-ID: <3A9A4571.25103.BF62D3@localhost> On 24 Feb 2001, at 0:03, Chris Gonnerman wrote: > > I have now found I can't redirect this under DOS (python 1.5.2) > > either. > > I've never tried the DOS version, so I can't comment here. > I guess this is a known problem on NT? I have to work with NT, and I never found out exactly why it won't redirect. I found that if I create a .bat file that does nothing but call the .py file, I can redirect that just fine. Sounds like something evil going on under the covers. Tim (no not that one) From daniel at dittmar.net Mon Feb 26 20:48:42 2001 From: daniel at dittmar.net (Daniel Dittmar) Date: Mon, 26 Feb 2001 20:48:42 +0100 Subject: Can't redirect output References: Message-ID: <3A9AB31A.31DC2202@dittmar.net> > I guess this is a known problem on NT? I have to work with NT, and > I never found out exactly why it won't redirect. I found that if I create > a .bat file that does nothing but call the .py file, I can redirect that > just fine. Sounds like something evil going on under the covers. There is a known Problem on NT that starting a program through it's extension will make the redirection impossible. So 'python hello.py > somefile.txt' should work. But 'hello.py > somefile.txt' does not. Solutions: don't know, I'm using 4NT as a shell, so I don't have this problem. Maybe auto-creating batch files for every Python program is the simplest method. Daniel From adam at deprince.net Fri Feb 23 07:44:50 2001 From: adam at deprince.net (Adam DePrince) Date: Fri, 23 Feb 2001 01:44:50 -0500 Subject: interactive programming References: Message-ID: <3A9606E2.9EEDE70A@deprince.net> Chris Richard Adams wrote: > > How can I create a loop - interactively. I'm just trying to learn > syntax for example, so Id like to create conditional if statements like > a = 'feb' > > if a == 'jan': > mo = 1 > elif a == 'feb': > mo = 2 > elif a == 'mar': > mo = 3 > ... > > I tried to type this interactively, but I get a mess of error about > syntax or mis placed whitespace... > > 1.) After the return after mo = 1 - how do I make sure theelif is > aligned with if? > > 2.) Is there any refernces for interactive programming - the tutorial is > too short? > > Thanks,Chris Ah. To end a block interactively you must hit enter twice. $ python Python 2.0 (#1, Dec 18 2000, 00:59:58) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 Type "copyright", "credits" or "license" for more information. >>> for x in range(10): ... print x <- Enter ... <- Enter 0 1 2 3 4 5 6 7 8 9 >>> Your code: > if a == 'jan': > mo = 1 > elif a == 'feb': > mo = 2 > elif a == 'mar': > mo = 3 > ... > would require an extra enter after mo=12. Instead of using nested ifs, I would do this: months = {"jan":1,"feb":2,"mar":3 ... :12} b = months[a] Of course, you don't want to create months each and every time you do the lookup, otherwise you havn't really gained anything. Adam DePrince Starmedia Network, Inc. Email: zlib.decompress('x\332KLI\314\325KI-(\312\314KNu(.I,\312MM\311L\324K\316\317\005\000\221\331\012s') From adam at deprince.net Fri Feb 23 07:48:15 2001 From: adam at deprince.net (Adam DePrince) Date: Fri, 23 Feb 2001 01:48:15 -0500 Subject: Can I leverage Java classes from a python program References: Message-ID: <3A9607AF.347A5BCB@deprince.net> Chris Richard Adams wrote: > > If so, questions: > > I am working with Java Oracle Intermedia classes (just a Java API that > helps you manipulate images (Blobs) stored in a database). ANyway - I > have to work with the java oracle classes, but wanted to do this from a > python program. Can I use inheritance to access these types of classes, > even though they are in Java. If so could you point to a reference that > might show some examples???? AND does this have anything to do with > JPython - would I want to use that rather than my standard Linux 2.0 > version. > > thanks! You will have to use Jython for this. Alternatively, you can connect to Oracle via C-Python to do the work and forget Java altogether. Take a look at DCOracle: http://www.zope.org/Products/DCOracle -- Adam DePrince Starmedia Network, Inc. Email: zlib.decompress('x\332KLI\314\325KI-(\312\314KNu(.I,\312MM\311L\324K\316\317\005\000\221\331\012s') From juergen0509 at web.de Sat Feb 24 00:00:40 2001 From: juergen0509 at web.de (Juergen Bocklage) Date: Sat, 24 Feb 2001 00:00:40 +0100 Subject: Can I leverage Java classes from a python program References: Message-ID: <3A96EB98.9CAC1121@web.de> Yes, I think JPython or now Jython is the right choice.See http://www.jython.org/ and at http://www.jython.org/docs/index.html you should find everything what is needed to subclass existing java classes. Linux 2.0?? or do you mean Python 2.0 ;-) - JB Chris Richard Adams wrote: > If so, questions: > > I am working with Java Oracle Intermedia classes (just a Java API that > helps you manipulate images (Blobs) stored in a database). ANyway - I > have to work with the java oracle classes, but wanted to do this from a > python program. Can I use inheritance to access these types of classes, > even though they are in Java. If so could you point to a reference that > might show some examples???? AND does this have anything to do with > JPython - would I want to use that rather than my standard Linux 2.0 > version. > > thanks! -- Juergen Bocklage ================================ mailto:juergen.bocklage at gmx.net From dkuhlman at rexx.com Sun Feb 25 23:18:03 2001 From: dkuhlman at rexx.com (Dave Kuhlman) Date: Sun, 25 Feb 2001 22:18:03 -0000 Subject: Can I leverage Java classes from a python program References: Message-ID: <983139494.154967@rexx.com> Others have given you pointers to JPython. What about JPE -- Java-Python Extension. See http://sourceforge.net/projects/jpe I'd be interested in seeing an evaluation of JPE. - Dave Chris Richard Adams wrote: > > If so, questions: > > I am working with Java Oracle Intermedia classes (just a Java API that > helps you manipulate images (Blobs) stored in a database). ANyway - I > have to work with the java oracle classes, but wanted to do this from a > python program. Can I use inheritance to access these types of classes, > even though they are in Java. If so could you point to a reference that > might show some examples???? AND does this have anything to do with > JPython - would I want to use that rather than my standard Linux 2.0 > version. > > thanks! > > -- Dave Kuhlman dkuhlman at rexx.com From shaleh at valinux.com Fri Feb 23 08:54:17 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Thu, 22 Feb 2001 23:54:17 -0800 Subject: parsing based on BNF? Message-ID: <20010222235417.A12624@valinux.com> Anyone have any pointers to Python tools for parsing based on BNF's? I am looking to verify fields in files and to point out mistakes in these fields. From johnw at gnu.org Fri Feb 23 09:18:53 2001 From: johnw at gnu.org (John Wiegley) Date: 23 Feb 2001 01:18:53 -0700 Subject: parsing based on BNF? References: Message-ID: >>>>> On Fri Feb 23, Sean writes: > Anyone have any pointers to Python tools for parsing based on BNF's? On the Vaults of Parnassus (http://www.vex.net/parnassus), you can find a FlexBison module in the parsing section. Also, there's mxTextTools, which is kind of a mix between BNF and assembly. It's killer fast, though. From uche at ogbuji.net Sat Feb 24 23:24:58 2001 From: uche at ogbuji.net (Uche Ogbuji) Date: Sat, 24 Feb 2001 22:24:58 GMT Subject: parsing based on BNF? References: Message-ID: <3A9834BB.664DE48E@ogbuji.net> John Wiegley wrote: > > >>>>> On Fri Feb 23, Sean writes: > > > Anyone have any pointers to Python tools for parsing based on BNF's? > > On the Vaults of Parnassus (http://www.vex.net/parnassus), you can > find a FlexBison module in the parsing section. Also, there's > mxTextTools, which is kind of a mix between BNF and assembly. It's > killer fast, though. Problem is, Sean asked for parsing based on BNFs. I'm assuming he has a huge grammar lying about in BNF (or EBNF) format, which we doesn't want to translate to some other format if he can avoid it. I'm also curious to know if there is such a beast for Python or C/C++. -- Uche Ogbuji Personal: uche at ogbuji.net http://uche.ogbuji.net Work: uche.ogbuji at fourthought.com http://Fourthought.com From johnw at gnu.org Sun Feb 25 01:33:58 2001 From: johnw at gnu.org (John Wiegley) Date: 24 Feb 2001 17:33:58 -0700 Subject: parsing based on BNF? References: <3A9834BB.664DE48E@ogbuji.net> Message-ID: >>>>> On Sat Feb 24, Uche writes: > Problem is, Sean asked for parsing based on BNFs. I'm assuming he > has a huge grammar lying about in BNF (or EBNF) format, which we > doesn't want to translate to some other format if he can avoid it. Well, somebody did write a BNF->mxTextTools converter. I forget the name of it, but it's on the mxTextTools web page. From dsh8290 at rit.edu Mon Feb 26 04:03:23 2001 From: dsh8290 at rit.edu (D-Man) Date: Sun, 25 Feb 2001 22:03:23 -0500 Subject: parsing based on BNF? In-Reply-To: <3A9834BB.664DE48E@ogbuji.net>; from uche@ogbuji.net on Sat, Feb 24, 2001 at 10:24:58PM +0000 References: <3A9834BB.664DE48E@ogbuji.net> Message-ID: <20010225220323.A13230@harmony.cs.rit.edu> On Sat, Feb 24, 2001 at 10:24:58PM +0000, Uche Ogbuji wrote: | | I'm also curious to know if there is such a beast for Python or C/C++. | If you want to get C code as the result, lex + yacc is a good combination. With lex (flex) you specify regexes that describe the various tokens in your language. With yacc (bison) you specify the BNF in terms of the lex tokens and what actions the parser should take when that expression is found. -D From uche at ogbuji.net Tue Feb 27 06:04:49 2001 From: uche at ogbuji.net (Uche Ogbuji) Date: Tue, 27 Feb 2001 05:04:49 GMT Subject: parsing based on BNF? References: <3A9834BB.664DE48E@ogbuji.net> Message-ID: <3A9B356F.6A4350FA@ogbuji.net> D-Man wrote: > > On Sat, Feb 24, 2001 at 10:24:58PM +0000, Uche Ogbuji wrote: > | > | I'm also curious to know if there is such a beast for Python or C/C++. > | > > If you want to get C code as the result, lex + yacc is a good > combination. With lex (flex) you specify regexes that describe the > various tokens in your language. With yacc (bison) you specify the BNF > in terms of the lex tokens and what actions the parser should take > when that expression is found. Not what I was talking about. Lex uses regular expressions and a proprietary glue language. Yacc is based on BNF, but not quite. I'm quite familiar with all the various scanners and parsers, which is why I asked my question. I do not know of one that implements plain BNF (or EBNF to provide some lexical specifications). This would have been useful in implementing the many little languages I have: XPath, OQL, ODL, etc. which are specified in BNF. So far I've either had to convert them to lex or yacc, a tedious process, or to our XML-based BisonGen format. -- Uche Ogbuji Personal: uche at ogbuji.net http://uche.ogbuji.net Work: uche.ogbuji at fourthought.com http://Fourthought.com From aycock at csc.uvic.ca Wed Feb 28 01:05:08 2001 From: aycock at csc.uvic.ca (John Aycock) Date: 28 Feb 2001 00:05:08 GMT Subject: parsing based on BNF? References: <3A9834BB.664DE48E@ogbuji.net> <3A9B356F.6A4350FA@ogbuji.net> Message-ID: <97hfbk$uno$1@casper.UVic.CA> Uche Ogbuji wrote: > I'm quite familiar with all the various scanners and parsers, which is > why I asked my question. I do not know of one that implements plain BNF > (or EBNF to provide some lexical specifications). This would have been > useful in implementing the many little languages I have: XPath, OQL, > ODL, etc. which are specified in BNF. Well, I guess I'll add my shameless plug. SPARK's parser can handle arbitrary BNF grammars, even ambiguous ones. It was originally intended for little languages. You can find SPARK at http://csr.uvic.ca/~aycock/python John From jdries at mail.com Wed Feb 28 17:46:58 2001 From: jdries at mail.com (Jan Dries) Date: Wed, 28 Feb 2001 17:46:58 +0100 Subject: parsing based on BNF? References: <3A9834BB.664DE48E@ogbuji.net> <3A9B356F.6A4350FA@ogbuji.net> <97hfbk$uno$1@casper.UVic.CA> Message-ID: <3A9D2B82.9ECF6391@mail.com> John Aycock wrote: > > Uche Ogbuji wrote: > > I'm quite familiar with all the various scanners and parsers, which is > > why I asked my question. I do not know of one that implements plain BNF > > (or EBNF to provide some lexical specifications). This would have been > > useful in implementing the many little languages I have: XPath, OQL, > > ODL, etc. which are specified in BNF. > > Well, I guess I'll add my shameless plug. SPARK's parser can handle > arbitrary BNF grammars, even ambiguous ones. It was originally > intended for little languages. I've been using the SPARK parser, and I like it a lot because of the flexibility is has in dealing with grammars. In fact, I used it to implement XPath, something the previous poster was refering too. However, there's one disadvantage in SPARK: it's slow. Parsing a few not even very complex XPath expression takes something in the order of a second. Regards, Jan From mfletch at tpresence.com Sun Feb 25 05:08:27 2001 From: mfletch at tpresence.com (Mike Fletcher) Date: Sat, 24 Feb 2001 23:08:27 -0500 Subject: parsing based on BNF? Message-ID: Hmm, that would be me, I think. But it's a particular EBNF (there are lots of EBNF formats), so some translation might still be required. At present it (SimpleParse) only allows for... trying to recall... I think it's LL(1)? languages. I don't work with SimpleParse much directly anymore (there are problems with defining new languages related to reporting of failed groups. I was given a patch for that but never had the time to thoroughly test and revise the generator to take advantage of the fix.), I just use the VRML97 parser that it generates for me. Might be useful to "Sean" (didn't see the original post) or not, see the homepage at: http://members.home.com/mcfletch/programming/simpleparse/simpleparse.html Enjoy, Mike -----Original Message----- From: John Wiegley [mailto:johnw at gnu.org] Sent: Saturday, February 24, 2001 7:34 PM To: python-list at python.org Subject: Re: parsing based on BNF? >>>>> On Sat Feb 24, Uche writes: > Problem is, Sean asked for parsing based on BNFs. I'm assuming he > has a huge grammar lying about in BNF (or EBNF) format, which we > doesn't want to translate to some other format if he can avoid it. Well, somebody did write a BNF->mxTextTools converter. I forget the name of it, but it's on the mxTextTools web page. -- http://mail.python.org/mailman/listinfo/python-list From robin at alldunn.com Fri Feb 23 09:00:32 2001 From: robin at alldunn.com (Robin Dunn) Date: Fri, 23 Feb 2001 00:00:32 -0800 Subject: ANNOUNCE: Release 3.0b3 of bsddb3 is available Message-ID: <008901c09d6e$b317d1e0$0100a8c0@Rogue> The Python wrappers for BerkeleyDB 3.1.17 (http://www.sleepycat.com/) are available at http://pybsddb.sourceforge.net/. Berkeley DB is a programmatic toolkit that provides high-performance built-in database support for desktop and server applications. The Berkeley DB access methods include B+tree, Extended Linear Hashing, Fixed and Variable-length records, and Queues. Berkeley DB provides full transactional support, database recovery, online backups, multi-threaded and multi-process access, etc. The Python wrappers allow you to store Python string objects of any length, keyed either by strings or integers depending on the database access method. With the use of another module in the package standard shelve-like functionality is provided allowing you to store any picklable Python object! Changes in this release include the following: * Lots of bugs fixed. * General code cleanup and some refactoring. * Better support for building on many different platforms. * Better build/install docs. * More and better unit tests. * Added DBLock type and methods to DBEnv for acquiring and releasing arbitrary locks. * Partial record reads/writes, and class for doing it in a file-like way. * Classes added for doing lightweight table-like access using a DB for storage. * Various other methods added. The focus of the next release will be support for the recently released BerkeleyDB 3.2.9. -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From ycheng at sinica.edu.tw Fri Feb 23 09:01:22 2001 From: ycheng at sinica.edu.tw (Y. Cheng) Date: Fri, 23 Feb 2001 08:01:22 +0000 (UTC) Subject: How python output a unicode string. Message-ID: <9755ci$1t4m$1@news1.sinica.edu.tw> Hi, I try to install a big5.py on /usr/lib/python2.0/encodings and it seem working fine. Then I try to output an string which is u"\u9DFD" to stdout by using print. Before that, I call sys.setdefaultencoding("big5") without any error message. As I try to output the string, I got error message: ----------------------- File "/usr/lib/python2.0/encodings/big5.py", line 18, in encode return codecs.charmap_encode(input,errors,encoding_map) TypeError: character mapping must be in range(256) ----------------------- is this means that python can't output multi-byte character with unicode internal encoding ? Yuan-Chen Cheng From footech at get2net.dk Fri Feb 23 10:17:52 2001 From: footech at get2net.dk (Mikkel Rasmussen) Date: Fri, 23 Feb 2001 10:17:52 +0100 Subject: Newbie: Large dictionaries Message-ID: Why can't there be more than about 65.000 entries in a dictionary, or more importantly: how can I make a large dictionary with room for at least 500.000 elements? I have looked in "Programming Python", "Python in 24 hours" (don't laugh!) and "Python Pocket Reference" but I can't even find that there is a limit. Mikkel Rasmussen www.mellon.dk From cg at schlund.de Fri Feb 23 10:29:44 2001 From: cg at schlund.de (Carsten Gaebler) Date: Fri, 23 Feb 2001 10:29:44 +0100 Subject: Newbie: Large dictionaries References: Message-ID: <3A962D88.BB3C0282@schlund.de> Mikkel Rasmussen wrote: > > Why can't there be more than about 65.000 entries in a dictionary, or more > importantly: how can I make a large dictionary with room for at least > 500.000 > elements? Don't know where your problem is: #!/usr/bin/python d = {} for i in xrange(100000): d[i] = i for (k, v) in d.items(): print k, v cg. From stephen_purcell at yahoo.com Fri Feb 23 11:36:54 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Fri, 23 Feb 2001 11:36:54 +0100 Subject: Newbie: Large dictionaries In-Reply-To: ; from footech@get2net.dk on Fri, Feb 23, 2001 at 10:17:52AM +0100 References: Message-ID: <20010223113654.A1286@freedom.puma-ag.com> Mikkel Rasmussen wrote: > Why can't there be more than about 65.000 entries in a dictionary, or more > importantly: how can I make a large dictionary with room for at least > 500.000 > elements? It's probably a memory issue: how big are the keys and/or values? On my machine, I can easily get a million entries into a dictionary:- >>> dict = {} >>> try: ... for i in xrange(1000000): ... dict[i] = None ... except: ... print "stopped at", i ... raise ... >>> -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 footech at get2net.dk Fri Feb 23 13:09:08 2001 From: footech at get2net.dk (Mikkel Rasmussen) Date: Fri, 23 Feb 2001 13:09:08 +0100 Subject: Newbie: Large dictionaries References: Message-ID: Hi! I can also put more than 4 million entries *into* the dictionary. But I can only get less than 65.000 back out! What do you get with: len(dict.keys()) ? And with a loop like count = 0 for elem in dict: count = count + 1 print count The keys are ordinary words like an ordinary dictionary :-) with an average length of about 6 characters. Mikkel Rasmussen Steve Purcell wrote in message news:mailman.982924567.27809.python-list at python.org... > Mikkel Rasmussen wrote: > > Why can't there be more than about 65.000 entries in a dictionary, or more > > importantly: how can I make a large dictionary with room for at least > > 500.000 > > elements? > > It's probably a memory issue: how big are the keys and/or values? > > On my machine, I can easily get a million entries into a dictionary:- > > >>> dict = {} > >>> try: > ... for i in xrange(1000000): > ... dict[i] = None > ... except: > ... print "stopped at", i > ... raise > ... > >>> > > -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 fredrik at pythonware.com Fri Feb 23 13:32:03 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 23 Feb 2001 12:32:03 GMT Subject: Newbie: Large dictionaries References: Message-ID: <7Lsl6.15130$Qb7.2431128@newsb.telia.net> Mikkel Rasmussen wrote: > I can also put more than 4 million entries *into* the dictionary. But I can > only get less than 65.000 back out! > > What do you get with: len(dict.keys()) ? if that reports 65,000, you probably don't have more than 65,000 *unique* entries. >>> dict = {} >>> dict["a"] = 1 >>> dict["a"] = 2 >>> dict["a"] = 3 >>> len(dict) 1 >>> len(dict.keys()) 1 > And with a loop like > > count = 0 > for elem in dict: > count = count + 1 > print count >>> count = 0 >>> for elem in dict: ... count = count + 1 ... Traceback (innermost last): File "", line 1, in ? TypeError: loop over non-sequence are you sure you're using Python? > The keys are ordinary words like an ordinary dictionary :-) with an average > length of about 6 characters. and what language has four million *unique* words having six characters and less? Cheers /F From footech at get2net.dk Fri Feb 23 13:52:58 2001 From: footech at get2net.dk (Mikkel Rasmussen) Date: Fri, 23 Feb 2001 13:52:58 +0100 Subject: Newbie: Large dictionaries References: <7Lsl6.15130$Qb7.2431128@newsb.telia.net> Message-ID: > > >>> count = 0 > >>> for elem in dict: > ... count = count + 1 > ... > Traceback (innermost last): > File "", line 1, in ? > TypeError: loop over non-sequence > > are you sure you're using Python? > > > The keys are ordinary words like an ordinary dictionary :-) with an average > > length of about 6 characters. > > and what language has four million *unique* words > having six characters and less? > > Cheers /F > > Yes, I know you can't loop over dict - dict.keys() is much better :-) Languages containing spelling errors can contain a lot of variations of each word. I'm using spelling misstakes as keys. Spelling misstakes also occur in programming languages. :-) Mikkel Rasmussen From mikael at isy.liu.se Fri Feb 23 14:59:13 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 23 Feb 2001 14:59:13 +0100 (MET) Subject: Newbie: Large dictionaries In-Reply-To: <7Lsl6.15130$Qb7.2431128@newsb.telia.net> Message-ID: On 23-Feb-01 Fredrik Lundh wrote: > and what language has four million *unique* words > having six characters and less? Well, there are approximately 300 million combinations of 6 letters from an alphabet of size 26. I wouldn't be surprized if there actually are 4 million unique words of length 6 in some language. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 23-Feb-01 Time: 14:44:44 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From max at alcyone.com Fri Feb 23 17:46:59 2001 From: max at alcyone.com (Erik Max Francis) Date: Fri, 23 Feb 2001 08:46:59 -0800 Subject: Newbie: Large dictionaries References: Message-ID: <3A969403.59F2114@alcyone.com> Mikael Olofsson wrote: > Well, there are approximately 300 million combinations of 6 letters > from an alphabet of size 26. I wouldn't be surprized if there actually > are 4 million unique words of length 6 in some language. That tells you very little, because only a tiny proportion of those three hundred million letter combinations represent reasonable combinations of sounds that are legal in a given language, much less actual words in that language. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ You and I / We've seen it all / Chasing our hearts' desire \__/ The Russian and Florence, _Chess_ Esperanto reference / http://mirror/alcyone/max/lang/esperanto/ An Esperanto reference for English speakers. From footech at get2net.dk Sat Feb 24 19:41:56 2001 From: footech at get2net.dk (Mikkel Rasmussen) Date: Sat, 24 Feb 2001 19:41:56 +0100 Subject: Newbie: Large dictionaries (OT) References: <3A969403.59F2114@alcyone.com> Message-ID: An example of non-use of combinations: In Danish there are about 10.000 single syllable words (not word forms) out of about 50.000 valid combinations. A single syllable word can be anything from one letter to seven letters. Question 1: How many percent of the possible combinations are are used? Question 2: How many percent of the possible combinations are pronounciable? Mikkel Rasmussen www.mellon.dk Erik Max Francis wrote in message news:3A969403.59F2114 at alcyone.com... > Mikael Olofsson wrote: > > > Well, there are approximately 300 million combinations of 6 letters > > from an alphabet of size 26. I wouldn't be surprized if there actually > > are 4 million unique words of length 6 in some language. > > That tells you very little, because only a tiny proportion of those > three hundred million letter combinations represent reasonable > combinations of sounds that are legal in a given language, much less > actual words in that language. > > -- > Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ > __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE > / \ You and I / We've seen it all / Chasing our hearts' desire > \__/ The Russian and Florence, _Chess_ > Esperanto reference / http://mirror/alcyone/max/lang/esperanto/ > An Esperanto reference for English speakers. From timr at probo.com Mon Feb 26 03:59:50 2001 From: timr at probo.com (Tim Roberts) Date: Sun, 25 Feb 2001 18:59:50 -0800 Subject: Newbie: Large dictionaries References: <3A969403.59F2114@alcyone.com> Message-ID: <5ihj9tsbtmcjp9rqmlnkevohu2kjkml9u3@4ax.com> Erik Max Francis wrote: > >That tells you very little, because only a tiny proportion of those >three hundred million letter combinations represent reasonable >combinations of sounds that are legal in a given language, much less >actual words in that language. I don't know what you're qquxxj zxooxx yfdtty rrrrpo mnlkaaing about. Actually, I'll bet a substantial fraction of those 300,000,000 sequences now exist as the middle token in the sequence www.??????.com. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From footech at get2net.dk Fri Feb 23 13:46:00 2001 From: footech at get2net.dk (Mikkel Rasmussen) Date: Fri, 23 Feb 2001 13:46:00 +0100 Subject: Newbie: Large dictionaries References: Message-ID: I found the error, that is: my error. I tried building a dictionary of 65.531 words held in a list. That worked fine. Then I wanted to test Python by building a *large* dictionary of four million words. I obtained my test data by concatenating the list with itself. I poured the four million words *into* the dictionary, but only got 65.531 words out - because there was only as many different words and each word was its own key. Always beware of your test data :-) Now I tested again with better data and got a fine working dictionary. It only took 90 seconds to delete it after the test :-) Thanks for your answers! Mikkel Rasmussen Mikkel Rasmussen wrote in message news:vpsl6.134$Gv2.4218 at news.get2net.dk... > Hi! > > I can also put more than 4 million entries *into* the dictionary. But I can > only get less than 65.000 back out! > > What do you get with: len(dict.keys()) ? > > And with a loop like > > count = 0 > for elem in dict: > count = count + 1 > print count > > The keys are ordinary words like an ordinary dictionary :-) with an average > length of about 6 characters. > > > Mikkel Rasmussen > > > Steve Purcell wrote in message > news:mailman.982924567.27809.python-list at python.org... > > Mikkel Rasmussen wrote: > > > Why can't there be more than about 65.000 entries in a dictionary, or > more > > > importantly: how can I make a large dictionary with room for at least > > > 500.000 > > > elements? > > > > It's probably a memory issue: how big are the keys and/or values? > > > > On my machine, I can easily get a million entries into a dictionary:- > > > > >>> dict = {} > > >>> try: > > ... for i in xrange(1000000): > > ... dict[i] = None > > ... except: > > ... print "stopped at", i > > ... raise > > ... > > >>> > > > > -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 bencr at bigpond.com Fri Feb 23 13:01:37 2001 From: bencr at bigpond.com (Ben) Date: Fri, 23 Feb 2001 23:01:37 +1100 Subject: Suffering For Your Art Message-ID: # 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 ws-news at gmx.at Fri Feb 23 13:08:09 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Fri, 23 Feb 2001 13:08:09 +0100 Subject: Suffering For Your Art References: Message-ID: <982930354.223466@newsmaster-04.atnet.at> Hi, I think you will not find too many people in this NG complainig about python's syntax. You should probably try that one at comp.lang.c or comp.lang.c++ But don't mention "C/C++", or you'll be blamed an idiot ;-) hth werner 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 bowman at montana.com Fri Feb 23 14:16:30 2001 From: bowman at montana.com (bowman) Date: Fri, 23 Feb 2001 06:16:30 -0700 Subject: Suffering For Your Art References: Message-ID: Ben wrote in message news:n2rl6.1686$v5.5388 at newsfeeds.bigpond.com... > > 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. well known psychological quirk of the species. after suffering through X to achieve goal Y, the experimental subject will value Y over Z. You can find it everywhere, from Marines to fraternity members. In the amateur radio community, morse code proficiency was stressed even after the rest of the world abandoned it -- kept the riffraff off the air, y'know. From danielk at aracnet.com Fri Feb 23 14:49:11 2001 From: danielk at aracnet.com (Daniel Klein) Date: Fri, 23 Feb 2001 05:49:11 -0800 Subject: Suffering For Your Art References: Message-ID: On Fri, 23 Feb 2001 23:01:37 +1100, "Ben" wrote: >Is it just me or is there a lot of animosity towards Python as a serious >programming language ... [snip] ># Would Anyone Like To Comment? Just cos they don't understand us doesn't make us confused. Dan From stephen_purcell at yahoo.com Fri Feb 23 15:15:50 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Fri, 23 Feb 2001 15:15:50 +0100 Subject: Suffering For Your Art In-Reply-To: ; from bencr@bigpond.com on Fri, Feb 23, 2001 at 11:01:37PM +1100 References: Message-ID: <20010223151550.A3228@freedom.puma-ag.com> Ben wrote: > 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. Many of those on this list have been through the wringer of those idiosyncratic languages and have attained Pythonic enlightenment. We should be patient with those that have yet to transcend the suffering of \$, -> and BEGIN/END. -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 ljohnson at resgen.com Fri Feb 23 15:23:04 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Fri, 23 Feb 2001 08:23:04 -0600 Subject: Suffering For Your Art References: Message-ID: > 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. When I first started looking at Python a few years back I had to get past the mental block that Python was a "scripting" language and was therefore inherently less powerful than the more traditional "compiled" languages (e.g. C/C++ or Fortran). So while it was OK for small or even moderately sized programming tasks, there's no way you'd write a full-blown application in Python. I believe that's still a big misconception for a lot of people. From kevin at GamesandTheory.com Fri Feb 23 16:05:49 2001 From: kevin at GamesandTheory.com (Kevin Douglas) Date: Fri, 23 Feb 2001 10:05:49 -0500 Subject: Suffering For Your Art In-Reply-To: Message-ID: > > Is it just me or is there a lot of animosity towards Python as > > a serious programming language ... > > When I first started looking at Python a few years back I had to > get past the mental block that Python was a "scripting" language > and was therefore inherently less powerful than the more > traditional "compiled" languages (e.g. C/C++ or Fortran). This is the first time I have ever posted to this list, in over a year of being subscribed. I've built and/or worked on systems that are scalable to the level of billions of transactions per month with Python and C and ASM. The premise is simple - Python is an AUTOMATION and PROTOTYPING language. You use it to automate either administrative tasks, management tasks, monitoring and quality assurance tasks, data aggregation or analysis tasks, or - more powerfully - programming tasks (self replicating code, code management, etc). It's quite easy to build an advertising exchange and collaborative filtering system such as DoubleClick has (even better than theirs, actually), or BlueFly or any other such company - in about one to three months - then work for the next 6 to 12 months on filling in the details, and native C functionality and inline ASM where needed. Such a system usually lasts for 3 to 4 years without needing much change (from industry experience, including one of the examples I just mentioned *cough cough*). I've spoken with executives and venture capitalist that are responsible for several million dollars worth of technology expenditures - who re completely confident in the capacity of Python for Enterprise Level developments of any size - ERP, HIRS, CRM, Financial Systems, Accounting Systems, Billing Systems, Trading Systems, data Mining/Warehousing Systems, you name it. I was about to build a Python system for Deutsche Bank, the world's largest bank, with North American, European, and Asia-Pacific operations, multilingual, HRIS, graphical charts and analytics, database, security systems, the whole nine (yes, thin-client Java Swing graphics with distributed load balancing on the client end, plus ORACLE and encrypted one-way anonymous data repository for survey data and aggregate analysis). Of course, we would never tell the general public that it was written in Python - that's silly. Of course, we would never tell the general public if we were running Java either - because that is equally as silly. We run "heterogeneous systems" - and that's all anyone needs to know - for Risk Management purposes. Unfortunately, people generally tend to suck. So that project never completed because someone unnamed wasn't willing to wake up everyday and be their own boss. And Python coders like myself are starving artists because of such silly and trivial things. Mostly because of "grown men" being considerably more immature than most of my peers. On an interesting side note, I've noticed that more money seems to be spent on Welfare Administration than on the actual welfare itself, given some of the rules and regulations that these agencies claim are legal and strictly adhere to. I was turned down for Food Stamps even though I only have water left right now - it's interesting how a CTO level programmer gets no respect because he focused on cost effective realistic solutions instead of Multi-Level Sales and Marketing tactics like the ones that destroyed the US Economy. EMC just announced they'd make $1B less than they thought - because - yes - all those con artists who were selling "solutions" based more on merchant partnerships than real solutions - ripped everyone off and no one is left! My 2 cents worth. If I had 2 cents anyway. Always available for consulting or freelance work or start-up prototyping, resume available if anyone really cares. Kevin Douglas President / Chief Technology Officer Games and Theory Supercomputing, Inc. From dan at eevolved.com Fri Feb 23 17:51:52 2001 From: dan at eevolved.com (Dan Parisien) Date: Fri, 23 Feb 2001 16:51:52 GMT Subject: Suffering For Your Art References: Message-ID: Lyle Johnson wrote: > When I first started looking at Python a few years back I had to get past > the mental block that Python was a "scripting" language and was therefore > inherently less powerful than the more traditional "compiled" languages > (e.g. C/C++ or Fortran). So while it was OK for small or even moderately > sized programming tasks, there's no way you'd write a full-blown > application in Python. I am. A rather large project as well that hits consumers as well as businesses. Python has been the breath of fresh air I've always wished programming could be. Because of Python, we are going to be able to produce some incredible applications using -Python Sockets and cPickle -Shelve (Robin Dunn's bsddb3.dbshelve which is excellent btw) -Dictionaries whose keys are arbitrary methods/functions as dynamic message handlers - FXPy (which you coded :) which comes to a 1.5MB full featured, cross platform GUI toolkit - RExec We learned about Python in January, switched our entire project from c++ (losing a large amount of code), and we hope to have a beta out relatively soon (weeks instead of months). I always tell my programmer friends, to learn of python is to learn python. Dan From aahz at panix.com Fri Feb 23 17:07:23 2001 From: aahz at panix.com (Aahz Maruch) Date: 23 Feb 2001 08:07:23 -0800 Subject: Suffering For Your Art References: Message-ID: <9761rr$gal$1@panix2.panix.com> In article , Ben wrote: > >Is it just me or is there a lot of animosity towards Python as a serious >programming language ... Where I see such animosity, it's almost always also directed toward Perl and Java. The only people who have animosity toward Python in specific are those for whom writing braces gives them a woodie. -- --- 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 "I used to have a .sig but I found it impossible to please everyone..." --SFJ From max at alcyone.com Fri Feb 23 17:48:23 2001 From: max at alcyone.com (Erik Max Francis) Date: Fri, 23 Feb 2001 08:48:23 -0800 Subject: Suffering For Your Art References: Message-ID: <3A969457.44BC94C5@alcyone.com> Ben wrote: > 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. Some people don't want to use a new language no matter what, particularly if their repertoire is limited and they're inexperienced. You'll find that experienced programmers know a lot of languages, and adding another one to their belt is a welcomed experience rather than a feared one. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Winners are men who have dedicated their whole lives to winning. \__/ Woody Hayes Esperanto reference / http://mirror/alcyone/max/lang/esperanto/ An Esperanto reference for English speakers. From mkx at excite.com Fri Feb 23 19:42:00 2001 From: mkx at excite.com (mkx at excite.com) Date: Fri, 23 Feb 2001 13:42:00 -0500 Subject: Suffering For Your Art References: Message-ID: On Fri, 23 Feb 2001 23:01:37 +1100, "Ben" wrote: ># Just A Quick Observation > >Is it just me or is there a lot of animosity towards Python as a serious >programming language ... Only among those who believe that the way they learned to do things, is the one and only way that things should be done, and the only way things should ever be done. Many projects suffer from a lack of progress because of the belief by many that "the way it has been done is the only way it will be done." >it seems to be an old school attitude That some consider a clinical condition. >that if you do not have to struggle and suffer with an idiosyncratic, unintuitive >programming syntax then it cannot possibly be a powerful language. "In my day we walked to school, barefoot, up-hill, in the snow, BOTH WAYS!" >All these ascetics who would like to see everyone go back to the 'halcyon days' of >assembly ... "Real programmers write in binary, but only on punch cards." >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 ... Other environments allow the true computer geeks to flex their brain muscles, in an attempt to impress the intellectually-poor masses. From aleaxit at yahoo.com Sat Feb 24 17:37:34 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 24 Feb 2001 17:37:34 +0100 Subject: Suffering For Your Art References: Message-ID: <978oih02b74@news1.newsguy.com> wrote in message news:a8bd9tkvianmkqtg5c3qg33i8igq47n6kj at 4ax.com... [snip] > >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 ... > > Other environments allow the true computer geeks to flex their brain > muscles, in an attempt to impress the intellectually-poor masses. So does Python (I'm guilty of my share of "clever" solutions posted to this group), but in Python's case it's clearer that "being clever" is a temptation to be *wisely resisted* -- that "the simplest thing that can possibly work" is the RIGHT way to go (and I try to recall to point this out just about every time I come up with "cleverness" that would likely be a very bad idea to use in production code...:-). Alex From mkx at excite.com Sun Feb 25 10:02:26 2001 From: mkx at excite.com (mkx at excite.com) Date: Sun, 25 Feb 2001 04:02:26 -0500 Subject: Suffering For Your Art References: <978oih02b74@news1.newsguy.com> Message-ID: On Sat, 24 Feb 2001 17:37:34 +0100, "Alex Martelli" wrote: >So does Python (I'm guilty of my share of "clever" solutions posted >to this group), but in Python's case it's clearer that "being clever" is >a temptation to be *wisely resisted* -- that "the simplest thing that >can possibly work" is the RIGHT way to go (and I try to recall to >point this out just about every time I come up with "cleverness" >that would likely be a very bad idea to use in production code...:-). I find that usually, if I have had enough sleep in the past week, I can at lest _read_ most Python code posted by others with varying CQs (clever quotients) {often reading is the 1st step in understanding}. This was the first factor in swaying me to the language. I came from another c.l.p* newsgroup, where more often than not, I could not tell if the postings contained code or line-noise. And if I asked for assistance in deciphering, I got hit with a big FAQ upside the head. I think that part of the art in Python is that clever code is most often an elegant way to accomplish a task. In the past, I had spent far too much time deciphering code where clever meant "difficult for humans to comprehend." From mkx at excite.com Sun Feb 25 10:10:01 2001 From: mkx at excite.com (mkx at excite.com) Date: Sun, 25 Feb 2001 04:10:01 -0500 Subject: Suffering For Your Art References: Message-ID: I only suffer when my coworkers make me work with their VBScript code, because they don't know Python, and they have a TON of VB stuff built over the past years. The only thing worse (for me - no flame baiting of offense intended), is when we find left over Perl code that the previous guy wrote. Then we are pained _and_ confused. On Fri, 23 Feb 2001 23:01:37 +1100, "Ben" wrote: ># 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 nospam at diveintopython.org Fri Feb 23 17:23:04 2001 From: nospam at diveintopython.org (nospam at diveintopython.org) Date: 23 Feb 2001 16:23:04 GMT Subject: ANN: Dive Into Python chapter 3 released Message-ID: <9762p8$jig$1@news.netmar.com> "Dive Into Python" (http://diveintopython.org/) is a free Python tutorial for experienced programmers. You can read the book online or download it in a variety of formats. Chapter 3 (http://diveintopython.org/fileinfo_divein.html) is finally complete. It covers all of these concepts: - defining, subclassing, and instantiating Python classes - special class methods - data attributes and class attributes - exception handling - basic file management (opening, reading files) - writing cross-platform libraries by encapsulating platform differences (like the getpass, os modules) - assigning multiple values at once If you're one of the 5,000 people who have already downloaded "Dive Into Python", come back and see what's new: - All examples are now color-coded. - Each section now has "further reading" links to relevant sections of other free resources, including the Python library reference, Python language reference, Python tutorial, Python Knowledge Base, and other free Python books available online. - Chapter 2 now uses the getattr function instead of eval -- a much more elegant solution suggested by an articulate reader. (http://diveintopython.org/apihelper_getattr.html) - Text edited, confusions clarified, bugs fixed. :) -M -- Mark Pilgrim, f8dy at diveintopython.org You're smart; why haven't you learned Python yet? http://diveintopython.org/ ----- 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 aahz at panix.com Fri Feb 23 17:54:03 2001 From: aahz at panix.com (Aahz Maruch) Date: 23 Feb 2001 08:54:03 -0800 Subject: ANN: Dive Into Python chapter 3 released References: <9762p8$jig$1@news.netmar.com> Message-ID: <9764jb$nt0$1@panix2.panix.com> In article <9762p8$jig$1 at news.netmar.com>, wrote: > >"Dive Into Python" (http://diveintopython.org/) is a free Python tutorial for >experienced programmers. You can read the book online or download it in a >variety of formats. Nice! Good 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 "I used to have a .sig but I found it impossible to please everyone..." --SFJ From ecastro at cicei.ulpgc.es Fri Feb 23 19:40:29 2001 From: ecastro at cicei.ulpgc.es (Enrique) Date: 23 Feb 2001 17:40:29 -0100 Subject: ANN: Dive Into Python chapter 3 released References: <9762p8$jig$1@news.netmar.com> Message-ID: <3A969F67.D5FA9EC4@cicei.ulpgc.es> hi, I have downloaded all *.zip files (in any format), but no one unzip correctly. They die due to a CRC error Where is the error? nospam at diveintopython.org wrote: > "Dive Into Python" (http://diveintopython.org/) is a free Python tutorial for > experienced programmers. You can read the book online or download it in a > variety of formats. > From wayne.izatt at _nospam_myself.com Sat Feb 24 07:31:17 2001 From: wayne.izatt at _nospam_myself.com (Wayne Izatt) Date: Sat, 24 Feb 2001 06:31:17 GMT Subject: ANN: Dive Into Python chapter 3 released References: <9762p8$jig$1@news.netmar.com> <3A969F67.D5FA9EC4@cicei.ulpgc.es> Message-ID: Sounds like you're downloading in ascii format (I'm not sure what ftp client you're using). Specifying binary might help. cheers "Enrique" wrote in message news:3A969F67.D5FA9EC4 at cicei.ulpgc.es... > hi, > I have downloaded all *.zip files (in any format), but no one unzip correctly. > They die due to a CRC error > Where is the error? > > nospam at diveintopython.org wrote: > > > "Dive Into Python" (http://diveintopython.org/) is a free Python tutorial for > > experienced programmers. You can read the book online or download it in a > > variety of formats. > > > From rtrocca at libero.it Sun Feb 25 16:38:55 2001 From: rtrocca at libero.it (Riccardo Trocca) Date: Sun, 25 Feb 2001 15:38:55 GMT Subject: ANN: Dive Into Python chapter 3 released References: <9762p8$jig$1@news.netmar.com> <3A969F67.D5FA9EC4@cicei.ulpgc.es> Message-ID: <1epclmi.xa1xz81ny2o0sN%rtrocca@libero.it> I had the same problem with my macintosh. I dled the zip files and my mac couldn't expand them. But as soon as I expanded the same files (no further dl) under Linux everything worked. any hint? Riccardo Wayne Izatt wrote: > Sounds like you're downloading in ascii format (I'm not sure what ftp client > you're using). Specifying binary might help. > > cheers > > "Enrique" wrote in message > news:3A969F67.D5FA9EC4 at cicei.ulpgc.es... > > hi, > > I have downloaded all *.zip files (in any format), but no one unzip > correctly. > > They die due to a CRC error > > Where is the error? > > > > nospam at diveintopython.org wrote: > > > > > "Dive Into Python" (http://diveintopython.org/) is a free Python > tutorial for > > > experienced programmers. You can read the book online or download it in > a > > > variety of formats. > > > > > From francois.granger at free.fr Sun Feb 25 23:46:54 2001 From: francois.granger at free.fr (=?ISO-8859-1?Q?Fran=E7ois_Granger?=) Date: Sun, 25 Feb 2001 22:46:54 GMT Subject: ANN: Dive Into Python chapter 3 released References: <9762p8$jig$1@news.netmar.com> <3A969F67.D5FA9EC4@cicei.ulpgc.es> <1epclmi.xa1xz81ny2o0sN%rtrocca@libero.it> Message-ID: <1epedtk.1qhe3edokehmzN%francois.granger@free.fr> Riccardo Trocca wrote: > I had the same problem with my macintosh. > I dled the zip files and my mac couldn't expand them. > But as soon as I expanded the same files (no further dl) under Linux > everything worked. I downloaded the Unix files on my Mac, work like a charme. -- La realit?, y compris la realit? ?comonique, est toujours complexe. - Noelle Adam From f8dy at yahoo.com Mon Feb 26 15:34:43 2001 From: f8dy at yahoo.com (Mark Pilgrim) Date: Mon, 26 Feb 2001 09:34:43 -0500 Subject: ANN: Dive Into Python chapter 3 released References: <9762p8$jig$1@news.netmar.com> <3A969F67.D5FA9EC4@cicei.ulpgc.es> <1epclmi.xa1xz81ny2o0sN%rtrocca@libero.it> Message-ID: <97dpf2$orked$1@ID-77331.news.dfncis.de> I tested the Mac files on my iMac before releasing them, and they appeared to work. Perhaps they require Stuffit Expander 5? This is not really a Python-related question, but what's the general consensus on providing platform-specific archive formats? I know there is unzip on most (all?) UN*X platforms, WinZip can handle tar/gzipped files, and Mac Stuffit Expander (at least version 5) can handle pretty much whatever you throw at it. I initially felt that it was friendlier to provide separate archives for each platform, but perhaps it's more trouble than it's worth? -M You're smart; why haven't you learned Python yet? http://diveintopython.org/ "Riccardo Trocca" wrote in message news:1epclmi.xa1xz81ny2o0sN%rtrocca at libero.it... > I had the same problem with my macintosh. > I dled the zip files and my mac couldn't expand them. > But as soon as I expanded the same files (no further dl) under Linux > everything worked. > any hint? > > Riccardo > > Wayne Izatt wrote: > > > Sounds like you're downloading in ascii format (I'm not sure what ftp client > > you're using). Specifying binary might help. > > > > cheers > > > > "Enrique" wrote in message > > news:3A969F67.D5FA9EC4 at cicei.ulpgc.es... > > > hi, > > > I have downloaded all *.zip files (in any format), but no one unzip > > correctly. > > > They die due to a CRC error > > > Where is the error? > > > > > > nospam at diveintopython.org wrote: > > > > > > > "Dive Into Python" (http://diveintopython.org/) is a free Python > > tutorial for > > > > experienced programmers. You can read the book online or download it in > > a > > > > variety of formats. > > > > > > > From glenfant at equod.com.nospam Sat Feb 24 17:09:55 2001 From: glenfant at equod.com.nospam (Gillou) Date: Sat, 24 Feb 2001 17:09:55 +0100 Subject: Dive Into Python chapter 3 released References: <9762p8$jig$1@news.netmar.com> Message-ID: <978m16$fvi$1@reader1.imaginet.fr> Good job... Don't need to be an "experienced programmer" to read this tutorial. You're an experienced programmer after reading this book. a ?crit dans le message news: 9762p8$jig$1 at news.netmar.com... > "Dive Into Python" (http://diveintopython.org/) is a free Python tutorial for > experienced programmers. You can read the book online or download it in a > variety of formats. From sheila at spamcop.net Mon Feb 26 04:58:16 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 26 Feb 2001 03:58:16 GMT Subject: ANN: Dive Into Python chapter 3 released References: <9762p8$jig$1@news.netmar.com> Message-ID: <1ekj9t0lconntup78pqfs127ksv74b0arj@4ax.com> On 23 Feb 2001 16:23:04 GMT, nospam at diveintopython.org wrote in comp.lang.python in article <9762p8$jig$1 at news.netmar.com>: :"Dive Into Python" (http://diveintopython.org/) is a free Python tutorial for :experienced programmers. You can read the book online or download it in a :variety of formats. I know this resource has been mentioned before, but I only just looked at it this week, after this announcement was posted. I'm only working on Chapter 1 so far, and making slow progress due to lack of time to devote to Python right now, but I want to say that: I find this approach fantastic! This is just what I needed. It DOES just dive right in, and I like it, and the explanations. I especially liked the cr0ss-referenced web links in each section. Nice job! (I do have a couple of Python books on order: Core Python Programming and Quick Python...I would've ordered from O'Reilly, but the new books aren't available yet, so I'm waiting...) -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From ransen_spam_me_not at nemo.it Fri Feb 23 17:32:40 2001 From: ransen_spam_me_not at nemo.it (Owen F. Ransen) Date: Fri, 23 Feb 2001 16:32:40 GMT Subject: PyImport_AddModule vs PyImport_Import Message-ID: <3a966ad6.4798499@news.newsguy.com> What is the difference between PyImport_AddModule PyImport_Import ? What does AddModule add the module to exactly? -- Owen F. Ransen http://www.ransen.com/ Home of Gliftic & Repligator Image Generators From owen at astrono.spamwashington.emu Fri Feb 23 17:41:26 2001 From: owen at astrono.spamwashington.emu (Russell E. Owen) Date: Fri, 23 Feb 2001 08:41:26 -0800 Subject: package question: getting names one level deep? Message-ID: I like to break my code up into lots of files -- typically one file contains a class and turn a related set of files/classes into a package. When a file contains a class, naturally I give the file the same name as the class. However, I've not found a nice way to refer to the resulting classes. I hope I'm missing some easy, standard trick. Say I have a directory structure such as: apackage/ __init__.py which contains __all__ = [list of all files] classa.py classb.py ... To use these classes I write: import apackage x = package.classa.classa(etc) It's that duplicated file-name.identical-class-name that I'd like to eliminate, so I could say: import apackage (or something) x = apackage.classa(etc) Basically I'd like to do an import * into the "apackage" namespace, and ideally I'd like "import apackage" to somehow magically do it. In other words, ideally I'd like to set up my packages so they act as if all their code (at least all intended-to-be-visible-to-the-outside-world code) was in a single module. Any hints? -- Russell From stephen_purcell at yahoo.com Fri Feb 23 19:01:45 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Fri, 23 Feb 2001 19:01:45 +0100 Subject: package question: getting names one level deep? In-Reply-To: ; from owen@astrono.spamwashington.emu on Fri, Feb 23, 2001 at 08:41:26AM -0800 References: Message-ID: <20010223190145.D4461@freedom.puma-ag.com> Russell E. Owen wrote: > I like to break my code up into lots of files -- typically one file > contains a class and turn a related set of files/classes into a package. > When a file contains a class, naturally I give the file the same name as > the class. > > However, I've not found a nice way to refer to the resulting classes. > I hope I'm missing some easy, standard trick. Ah, well, the easy, standard trick is to group your classes in modules, not put each class in a submodule of it's 'real' module. All you're currently doing is breaking one module up into a number of little files for no concrete reason (c.f. PIL's plugin scheme). It's a C++/Java idiom that doesn't map too well to Python, without the application of the voodoo invocations you're soliciting. :-) Rule #2343: "Be suspicious when something seems complicated in Python." -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 robin at jessikat.fsnet.co.uk Fri Feb 23 21:00:53 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 23 Feb 2001 20:00:53 +0000 Subject: package question: getting names one level deep? References: Message-ID: In article , Russell E. Owen writes one way is to put code into the __init__.py eg from classa import classa from classb import classb then classa, classb become visible as attributes of the package and you can do >>> from apackage import classa >>> classa >I like to break my code up into lots of files -- typically one file contains a >class and turn a related set of files/classes into a package. When a file >contains a class, naturally I give the file the same name as the class. > >However, I've not found a nice way to refer to the resulting classes. I hope I'm >missing some easy, standard trick. > >Say I have a directory structure such as: >apackage/ > __init__.py which contains __all__ = [list of all files] > classa.py > classb.py > ... > >To use these classes I write: > >import apackage >x = package.classa.classa(etc) > >It's that duplicated file-name.identical-class-name that I'd like to eliminate, >so I could say: > >import apackage (or something) >x = apackage.classa(etc) > >Basically I'd like to do an import * into the "apackage" namespace, and ideally >I'd like "import apackage" to somehow magically do it. In other words, ideally >I'd like to set up my packages so they act as if all their code (at least all >intended-to-be-visible-to-the-outside-world code) was in a single module. > >Any hints? > >-- Russell -- Robin Becker From max at alcyone.com Fri Feb 23 17:49:45 2001 From: max at alcyone.com (Erik Max Francis) Date: Fri, 23 Feb 2001 08:49:45 -0800 Subject: Many Threads + Many Sockets == SegFault? References: Message-ID: <3A9694A9.FC38B944@alcyone.com> Doug Fort wrote: > I've attached a little program that I'm testing. It basically creates > a > number of threads (I've been using 100), each of which performs a > simple > HTTP 'GET' over and over. This works fine when I run through our T1 > line > against a server out in the cloud. Are you aware that what you're doing is a denial-of-service attack? -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Wars don't last forever, Henry. Only war does. \__/ Capt. Benjamin "Hawkeye" Pierce Kepler's laws / http://www.alcyone.com/max/physics/kepler/ A proof of Kepler's laws. From stephen_purcell at yahoo.com Sat Feb 24 11:00:28 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Sat, 24 Feb 2001 11:00:28 +0100 Subject: Many Threads + Many Sockets == SegFault? In-Reply-To: <3A9694A9.FC38B944@alcyone.com>; from max@alcyone.com on Fri, Feb 23, 2001 at 08:49:45AM -0800 References: <3A9694A9.FC38B944@alcyone.com> Message-ID: <20010224110028.B6290@freedom.puma-ag.com> Erik Max Francis wrote: > Doug Fort wrote: > > > I've attached a little program that I'm testing. It basically creates > > a number of threads (I've been using 100), each of which performs a > > simple HTTP 'GET' over and over. This works fine when I run through our T1 > > line against a server out in the cloud. > > Are you aware that what you're doing is a denial-of-service attack? He is aware of it, but people pay him to do it: http://stressmy.com/ -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 max at alcyone.com Sat Feb 24 21:39:13 2001 From: max at alcyone.com (Erik Max Francis) Date: Sat, 24 Feb 2001 12:39:13 -0800 Subject: Many Threads + Many Sockets == SegFault? References: <3A9694A9.FC38B944@alcyone.com> Message-ID: <3A981BF1.4F0AF09C@alcyone.com> Steve Purcell wrote: > He is aware of it, but people pay him to do it: > > http://stressmy.com/ People pay him to do it, but he can't get a program he wrote to do it working? That's not a good sign. -- 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 go out with actresses because I'm not apt to marry one. \__/ Henry Kissinger Esperanto reference / http://mirror/alcyone/max/lang/esperanto/ An Esperanto reference for English speakers. From erno-news at erno.iki.fi Sat Feb 24 22:36:44 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 24 Feb 2001 23:36:44 +0200 Subject: Many Threads + Many Sockets == SegFault? References: <3A9694A9.FC38B944@alcyone.com> <3A981BF1.4F0AF09C@alcyone.com> Message-ID: In article <3A981BF1.4F0AF09C at alcyone.com>, Erik Max Francis writes: | Steve Purcell wrote: || He is aware of it, but people pay him to do it: || || http://stressmy.com/ | People pay him to do it, but he can't get a program he wrote to do it | working? That's not a good sign. he has hit a bug in python or in something else - otherwise python would not segfault. it is indeed not a good sign, but not a problem in the original poster's code. -- erno From jkraska1 at san.rr.com Sun Feb 25 20:48:29 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 25 Feb 2001 19:48:29 GMT Subject: Many Threads + Many Sockets == SegFault? References: <3A9694A9.FC38B944@alcyone.com> <3A981BF1.4F0AF09C@alcyone.com> Message-ID: >he has hit a bug in python or in something else - otherwise >python would not segfault. it is indeed not a good sign, but >not a problem in the original poster's code. This is sometimes caused by poorly-written Python extensions; it's quite easy to cause Python to crash if you screw up your reference counting, for example. Is he using any kind of dubious extension modules? C// From dougfort at downright.com Sat Feb 24 22:48:21 2001 From: dougfort at downright.com (Doug Fort) Date: Sat, 24 Feb 2001 16:48:21 -0500 Subject: Many Threads + Many Sockets == SegFault? References: <3A9694A9.FC38B944@alcyone.com> <3A981BF1.4F0AF09C@alcyone.com> Message-ID: The code I posted is not the code we use on the site (we use httplib). It is a test program to investigate a specific problem that occurs at very high volumes. "Erik Max Francis" wrote in message news:3A981BF1.4F0AF09C at alcyone.com... > Steve Purcell wrote: > > > He is aware of it, but people pay him to do it: > > > > http://stressmy.com/ > > People pay him to do it, but he can't get a program he wrote to do it > working? That's not a good sign. > > -- > 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 go out with actresses because I'm not apt to marry one. > \__/ Henry Kissinger > Esperanto reference / http://mirror/alcyone/max/lang/esperanto/ > An Esperanto reference for English speakers. From rich_somerfield at tertio.com Fri Feb 23 17:55:31 2001 From: rich_somerfield at tertio.com (Rich Somerfield) Date: Fri, 23 Feb 2001 16:55:31 -0000 Subject: Help with finding how much memory a variable is using Message-ID: Hi, I am generating a huge, huge list of data (cant think of a decent way to reduce the required storage size and have it in a usable form). Everytime i try to keep this list for future derivations I get a memory problem from Windows (effectively terminating my python script). I presume this is because of the huge list. Is it possible to find out the amount of memory a variable [not a type of the variable, the actual data contained within the variable] is taking up? This variable is local to a class and it would appear that it is when i go out of scope of that class that the memory error is being issued. Would I be better making this variable global (across all classes)? e.g. would this problem still happen if the variable was not just local to 1 class? Would a different python datatype solve this problem for me ? If I cant handle this amount of data then I will have to think of a way of better representing it, this will be unfortunate though as and compression / reduction of data will [as far as i can think] vastly reduce performance - which is already a concern. Regards Rich From stephen_purcell at yahoo.com Fri Feb 23 18:48:09 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Fri, 23 Feb 2001 18:48:09 +0100 Subject: Help with finding how much memory a variable is using In-Reply-To: ; from rich_somerfield@tertio.com on Fri, Feb 23, 2001 at 04:55:31PM -0000 References: Message-ID: <20010223184809.C4461@freedom.puma-ag.com> Rich Somerfield wrote: > I am generating a huge, huge list of data (cant think of a decent way to > reduce the required storage size and have it in a usable form). Everytime i > try to keep this list for future derivations I get a memory problem from > Windows (effectively terminating my python script). > > I presume this is because of the huge list. Is it possible to find out the > amount of memory a variable [not a type of the variable, the actual data > contained within the variable] is taking up? A huge, huge in-memory list is very likely to be the cause of such a memory problem! Compression isn't going to help you much if the list is so big that even a tenth of its size would still be too big. Post some more technical information and I'm sure you'll get more helpful suggestions/alternatives than you could have wished for*. -Steve * or wanted -- 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 cjensen at bioeng.ucsd.edu Sat Feb 24 01:09:52 2001 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Fri, 23 Feb 2001 16:09:52 -0800 Subject: Help with finding how much memory a variable is using References: Message-ID: <3A96FBD0.26CD1E62@bioeng.ucsd.edu> Rich Somerfield wrote: > > Hi, > > I am generating a huge, huge list of data (cant think of a decent way to > reduce the required storage size and have it in a usable form). Everytime i > try to keep this list for future derivations I get a memory problem from > Windows (effectively terminating my python script). > > I presume this is because of the huge list. Is it possible to find out the > amount of memory a variable [not a type of the variable, the actual data > contained within the variable] is taking up? This variable is local to a > class and it would appear that it is when i go out of scope of that class > that the memory error is being issued. Would I be better making this > variable global (across all classes)? e.g. would this problem still happen > if the variable was not just local to 1 class? > > Would a different python datatype solve this problem for me ? > > If I cant handle this amount of data then I will have to think of a way of > better representing it, this will be unfortunate though as and compression / > reduction of data will [as far as i can think] vastly reduce performance - > which is already a concern. > > Regards > Rich If your lists are numeric, you could use the Numeric module. Lists/arrays created by Numeric have a member function "itemsize()" which corresponds to the number of bytes an individual element in that array is using. If your lists are not numeric, you might be able to hack Numeric to give you memory usage (ie. you could use it to find memory usage of lists of strings; anything more complicated than strings and it could be difficult). -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From s713221 at student.gu.edu.au Sun Feb 25 02:52:37 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Sun, 25 Feb 2001 11:52:37 +1000 Subject: Help with finding how much memory a variable is using References: Message-ID: <3A986565.BAF4E05B@student.gu.edu.au> Rich Somerfield wrote: > > Hi, > > I am generating a huge, huge list of data (cant think of a decent way to > reduce the required storage size and have it in a usable form). Everytime i > try to keep this list for future derivations I get a memory problem from > Windows (effectively terminating my python script). > > I presume this is because of the huge list. Is it possible to find out the > amount of memory a variable [not a type of the variable, the actual data > contained within the variable] is taking up? This variable is local to a > class and it would appear that it is when i go out of scope of that class > that the memory error is being issued. Would I be better making this > variable global (across all classes)? e.g. would this problem still happen > if the variable was not just local to 1 class? > > Would a different python datatype solve this problem for me ? > > If I cant handle this amount of data then I will have to think of a way of > better representing it, this will be unfortunate though as and compression / > reduction of data will [as far as i can think] vastly reduce performance - > which is already a concern. > > Regards > Rich Do you have to load all the list into memory, or is there a way you can load in parts and work on that sequentially. I haven't had a chance to use persistance modules yet, but their documentation may be a place to start. Joal Heagney/AncientHart From rich_somerfield at tertio.com Mon Feb 26 10:11:59 2001 From: rich_somerfield at tertio.com (Rich Somerfield) Date: Mon, 26 Feb 2001 09:11:59 -0000 Subject: Help with finding how much memory a variable is using References: <3A986565.BAF4E05B@student.gu.edu.au> Message-ID: wrote in message news:3A986565.BAF4E05B at student.gu.edu.au... > Rich Somerfield wrote: > > > > Hi, > > > > I am generating a huge, huge list of data (cant think of a decent way to > > reduce the required storage size and have it in a usable form). Everytime i > > try to keep this list for future derivations I get a memory problem from > > Windows (effectively terminating my python script). > > > > I presume this is because of the huge list. Is it possible to find out the > > amount of memory a variable [not a type of the variable, the actual data > > contained within the variable] is taking up? This variable is local to a > > class and it would appear that it is when i go out of scope of that class > > that the memory error is being issued. Would I be better making this > > variable global (across all classes)? e.g. would this problem still happen > > if the variable was not just local to 1 class? > > > > Would a different python datatype solve this problem for me ? > > > > If I cant handle this amount of data then I will have to think of a way of > > better representing it, this will be unfortunate though as and compression / > > reduction of data will [as far as i can think] vastly reduce performance - > > which is already a concern. > > > > Regards > > Rich > > Do you have to load all the list into memory, or is there a way you can > load in parts and work on that sequentially. I haven't had a chance to > use persistance modules yet, but their documentation may be a place to > start. > > Joal Heagney/AncientHart Unfortunately I need all of the data in memory at the same time. The only way I can see to solve this problem is to reduce the memory consumption of my application. And the only way I can see how to do that is by vastly reducing the performance. Do u know of any information that suggests how large a datatype can be in Python (are there any upper limits?) ? Regards Rich From rich_somerfield at tertio.com Mon Feb 26 10:09:46 2001 From: rich_somerfield at tertio.com (Rich Somerfield) Date: Mon, 26 Feb 2001 09:09:46 -0000 Subject: Help with finding how much memory a variable is using References: Message-ID: I dont think compression would be the way to go as this would cause massive problems with performance. Technical Info: The reason for the huge list is basically the AI tree of board representations for AI processing. If the programme was specialised to a particular game then I could implement a space saving method of storing the data. However as the code uses a config file to determine the rules of the game (hence game is unknown until runtime) the AI engine has to be completely generic - otherwise the code would be useless!! Look at this URL for more detailed info (and a download) : www.geocities.com/djterrier/SGEMain.htm The format of the list is : thegamelist = [ [node, [board_representation] ] , [.....] , [.....], [.....] , ..... ] thenodelist = [ [node, [ children_nodes ] , [.....] , [.....] , [.....] , ..... ] If anybody can suggest a better method of storing the data [bear in mind that many functions need access to the data at each node for processing / checking]. Also bear in mind that due to the interpreted nature of Python, and the performance demanding nature of the application, any suggested implementation would need not adversely effect the performance. Regards Rich. Steve Purcell wrote in message news:mailman.982950492.15473.python-list at python.org... > Rich Somerfield wrote: > > I am generating a huge, huge list of data (cant think of a decent way to > > reduce the required storage size and have it in a usable form). Everytime i > > try to keep this list for future derivations I get a memory problem from > > Windows (effectively terminating my python script). > > > > I presume this is because of the huge list. Is it possible to find out the > > amount of memory a variable [not a type of the variable, the actual data > > contained within the variable] is taking up? > > A huge, huge in-memory list is very likely to be the cause of such a memory > problem! > > Compression isn't going to help you much if the list is so big that even > a tenth of its size would still be too big. > > Post some more technical information and I'm sure you'll get more helpful > suggestions/alternatives than you could have wished for*. > > -Steve > > * or wanted > > -- > 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 emile at fenx.com Mon Feb 26 13:16:35 2001 From: emile at fenx.com (Emile van Sebille) Date: Mon, 26 Feb 2001 04:16:35 -0800 Subject: Help with finding how much memory a variable is using References: Message-ID: <97dhh2$p9ul0$1@ID-11957.news.dfncis.de> "Rich Somerfield" wrote in message news:v3pm6.27666$5n4.596175 at news6-win.server.ntlworld.com... > I dont think compression would be the way to go as this would cause massive > problems with performance. > > Technical Info: > The reason for the huge list is basically the AI tree of board > representations for AI processing. If the programme was specialised to a > particular game then I could implement a space saving method of storing the > data. However as the code uses a config file to determine the rules of the > game (hence game is unknown until runtime) the AI engine has to be > completely generic - otherwise the code would be useless!! > > Look at this URL for more detailed info (and a download) : > www.geocities.com/djterrier/SGEMain.htm > > The format of the list is : > thegamelist = [ [node, [board_representation] ] , [.....] , [.....], > [.....] , ..... ] > thenodelist = [ [node, [ children_nodes ] , [.....] , [.....] , [.....] , > ..... ] > Can your data be structured using consistent data types? I recently had a situation where I needed to store a ~100,000 element list where each entry consists of 180 floats. The memory usage was dramatically reduced by converting the data to use the array module. HTH -- Emile van Sebille emile at fenx.com ------------------- From djc at object-craft.com.au Tue Feb 27 11:13:17 2001 From: djc at object-craft.com.au (Dave Cole) Date: 27 Feb 2001 21:13:17 +1100 Subject: Help with finding how much memory a variable is using References: <97dhh2$p9ul0$1@ID-11957.news.dfncis.de> Message-ID: >>>>> "Emile" == Emile van Sebille writes: Emile> Can your data be structured using consistent data types? I Emile> recently had a situation where I needed to store a ~100,000 Emile> element list where each entry consists of 180 floats. The Emile> memory usage was dramatically reduced by converting the data to Emile> use the array module. Or could you implement a native C datatype on top of which Python proxy objects were created on demand? The C objects could be stored in whatever organisation made the most sense, a tree or an array. A while ago, I wrote some readonly lazy dictionary / list types which could be made to sit on top of a parse tree constructed by a yacc grammar (or whatever). I still have the code if you are interested. - Dave -- http://www.object-craft.com.au From rich_somerfield at tertio.com Wed Feb 28 10:24:12 2001 From: rich_somerfield at tertio.com (Rich Somerfield) Date: Wed, 28 Feb 2001 09:24:12 -0000 Subject: Help with finding how much memory a variable is using References: <97dhh2$p9ul0$1@ID-11957.news.dfncis.de> Message-ID: That code would be gratefully received. rich_somerfield at nO-sPaM.tertio.com Remove the obvious, cheers. Regards Rich Dave Cole wrote in message news:m33dd0juwy.fsf at vole.object-craft.com.au... > >>>>> "Emile" == Emile van Sebille writes: > > Emile> Can your data be structured using consistent data types? I > Emile> recently had a situation where I needed to store a ~100,000 > Emile> element list where each entry consists of 180 floats. The > Emile> memory usage was dramatically reduced by converting the data to > Emile> use the array module. > > Or could you implement a native C datatype on top of which Python > proxy objects were created on demand? The C objects could be stored > in whatever organisation made the most sense, a tree or an array. > > A while ago, I wrote some readonly lazy dictionary / list types which > could be made to sit on top of a parse tree constructed by a yacc > grammar (or whatever). > > I still have the code if you are interested. > > - Dave > > -- > http://www.object-craft.com.au From gnana at mips.biochem.mpg.de Fri Feb 23 18:41:59 2001 From: gnana at mips.biochem.mpg.de (Gnanasekaran Thoppae) Date: Fri, 23 Feb 2001 17:41:59 -0000 Subject: data parsing Message-ID: <9767d7+43k5@eGroups.com> Hi, I have some data in a file 'test', which contains: Joe|25|30|49|40| |28|39|71|| |30|29||| Malcolm|43|60|56|| |28|37||| Amy||70|45|| |40|30||40 |40||30|| This is basically a multi line (record) values that belong to the first line that starts with a filled field. This is part belongs to joe 'Joe' Joe|25|30|49|40| |28|39|71|| |30|29||| This to 'Malcolm' Malcolm|43|60|56|| |28|37||| and the rest to Amy. I want to parse this data and format it in this way: Joe|25;28;30|30;39;29|49;71|40| Malcolm|43;28|60;37|56|| Amy|40;40|70;30|45;;30|;40;| Basically speaking, I am trying to cluster multi record data into one field, each seperated by a delimiter ';' and if the field is empty, an empty ; will enable later on to decode the field as empty field ''. Thanks. -gnana From mfletch at tpresence.com Fri Feb 23 23:23:57 2001 From: mfletch at tpresence.com (Mike Fletcher) Date: Fri, 23 Feb 2001 17:23:57 -0500 Subject: data parsing Message-ID: Here's some ideas (untested, of course): import string lines = open( filename ).readlines() records = map( string.split, lines, ['|']*len(lines)) results = [] while records: currentresult = [ string.join(records[0], ';')] del records[0] while records and not records[0][0]: currentresult.append( string.join(records[0], ';') ) del records[0] results.append( string.join( currentresult, '|')) open( newfilename, 'w').write( string.join( results, '\n')) Try that in the interactive interpreter to get a feel for what's happening. Hopefully it'll get you started. Good luck, Mike -----Original Message----- From: Gnanasekaran Thoppae [mailto:gnana at mips.biochem.mpg.de] Sent: Friday, February 23, 2001 12:42 PM To: python-list at cwi.nl Subject: data parsing Hi, I have some data in a file 'test', which contains: Joe|25|30|49|40| |28|39|71|| |30|29||| Malcolm|43|60|56|| |28|37||| Amy||70|45|| |40|30||40 |40||30|| This is basically a multi line (record) values that belong to the first line that starts with a filled field. This is part belongs to joe 'Joe' Joe|25|30|49|40| |28|39|71|| |30|29||| This to 'Malcolm' Malcolm|43|60|56|| |28|37||| and the rest to Amy. I want to parse this data and format it in this way: Joe|25;28;30|30;39;29|49;71|40| Malcolm|43;28|60;37|56|| Amy|40;40|70;30|45;;30|;40;| Basically speaking, I am trying to cluster multi record data into one field, each seperated by a delimiter ';' and if the field is empty, an empty ; will enable later on to decode the field as empty field ''. Thanks. -gnana -- http://mail.python.org/mailman/listinfo/python-list From aleaxit at yahoo.com Sat Feb 24 18:36:51 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 24 Feb 2001 18:36:51 +0100 Subject: data parsing References: Message-ID: <978rdf02e8b@news1.newsguy.com> "Gnanasekaran Thoppae" wrote in message news:mailman.982950184.14469.python-list at python.org... > Hi, > > I have some data in a file 'test', which contains: > > Joe|25|30|49|40| > |28|39|71|| > |30|29||| > Malcolm|43|60|56|| > |28|37||| [snip] > I want to parse this data and format it in this way: > > Joe|25;28;30|30;39;29|49;71|40| > Malcolm|43;28|60;37|56|| > Amy|40;40|70;30|45;;30|;40;| > > Basically speaking, I am trying to cluster multi record > data into one field, each seperated by a delimiter ';' and > if the field is empty, an empty ; will enable later on to > decode the field as empty field ''. Problems of data parsing and reformatting are often quite interesting. Here, of course, the key is the intermediate, internal format, in which a 'record' will include the name and the list-of-lists of data items; all we want is a way to form such structures from parsing the specified input file format, and a way to output them into the requested form. Output of a record can only be performed when it's all in, which means either that the next record has started, or that the whole file is over. A top-down design, then, could start with the outline: def reformat(infileob, oufileob): data = None for line in infileob.lines(): if line.startswith('|'): add_line(data, line) else: if data is not None: output_data(data, oufileob) data = new_data(line) output_data(data, oufileob) All we need to do, then, is define more specifically what we want to do in functions new_data, add_line, and output_data. This could be a good occasion to switch to object-oriented design, making these into the constructor and two methods of an appropriate class; the outline would change only slightly: def reformat(infileob, oufileob): data = None for line in infileob.lines(): if line.startswith('|'): data.add_line(line) else: if data is not None: data.emit_to(oufileob) data = Data(line) data.emit_to(oufileob) It's just a matter of style. In the *implementation* of the constructor, mutator, and emittor, designing the data object as a class instance would let us have named fields as object attributes; since, here, we only really need two fields (the name, and the list-of-lists of data items), the advantage is not very substantial -- we may as well use a two-items list. Going back to the first outline, then, we could have...: def new_data(line): fields = line.split('|') return ( fields[0], [ [field] for field in fields[1:-1] ] ) def add_line(data, line): fields = line.split('|') for fieldlist, newfield in zip(data[1], fields[1:-1]): fieldlist.append(newfield) def output_data(data, oufileob): oufileob.write(data[0]+'|') for fieldlist in data[1]: oufileob.write(';'.join(fieldlist)+'|') oufileob.write('\n') This will give us more regular output than your example implicitly specifies, with leading and trailing semicolons in the same numbers for each case (it's not clear to me according to which rule you have them in some cases and not in others), but when you test and adjust this code you can no doubt implement the exact rules you desire, too. The split and join method of string objects are what we are mainly using here, of course; plus a few methods (append) and operations on tuples (the data object itself), lists (data[1] being a list of lists of strings), strings (basically just + to concatenate them) and file objects (just the write method). Oh, and, a list comprehension in new_data, and a little indexing and slicing. If any of these Python constructs and idioms is not fully clear to you, it's possible to rephrase quite a few of them in other ways (not quite as concise, and thus, maybe, easier to understand), and anyway, of course, we're always here for explanations...! Alex From news at dorb.com Sat Feb 24 22:52:03 2001 From: news at dorb.com (Darrell) Date: Sat, 24 Feb 2001 21:52:03 GMT Subject: data parsing References: Message-ID: <72Wl6.166279$o91.20747427@typhoon.nyroc.rr.com> import re s=""" Joe|25|30|49|40| |28|39|71|| |30|29||| Malcolm|43|60|56|| |28|37||| Amy||70|45|| |40|30||40 |40||30|| """ s=s.replace("\012", "") # Assumes records start with text and consist of numbers # Match the name with \w+ # Match as many characters as possible until a character not belonging to a-z or A-Z # This should return your records as I understand them. res1=re.findall("\w+[^a-zA-Z]+", s) # Split each record on "|" and join them back with ";" # This only works with Python2.0 or higher res2=[";".join(i.split("|")) for i in res1] for i in res2: print i ######### output # Not the same as you requested because I don't understand your request. Joe;25;30;49;40;;28;39;71;;;30;29;;; Malcolm;43;60;56;;;28;37;;; Amy;;70;45;;;40;30;;40;40;;30;; --Darrell "Gnanasekaran Thoppae" wrote in message news:mailman.982950184.14469.python-list at python.org... > Hi, > > I have some data in a file 'test', which contains: > > Joe|25|30|49|40| > |28|39|71|| > |30|29||| > Malcolm|43|60|56|| > |28|37||| > Amy||70|45|| > |40|30||40 > |40||30|| > > This is basically a multi line (record) values that belong > to the first line that starts with a filled field. > > This is part belongs to joe 'Joe' > > Joe|25|30|49|40| > |28|39|71|| > |30|29||| > > This to 'Malcolm' > Malcolm|43|60|56|| > |28|37||| > > and the rest to Amy. > > I want to parse this data and format it in this way: > > Joe|25;28;30|30;39;29|49;71|40| > Malcolm|43;28|60;37|56|| > Amy|40;40|70;30|45;;30|;40;| > > Basically speaking, I am trying to cluster multi record > data into one field, each seperated by a delimiter ';' and > if the field is empty, an empty ; will enable later on to > decode the field as empty field ''. > > Thanks. > > -gnana > > > From othello at javanet.com Sun Feb 25 07:43:53 2001 From: othello at javanet.com (Raymond Hettinger) Date: Sun, 25 Feb 2001 01:43:53 -0500 Subject: data parsing References: Message-ID: <3A98A9A9.8789B127@javanet.com> Gnanasekaran Thoppae wrote: > I have some data in a file 'test', which contains: > > Joe|25|30|49|40| > |28|39|71|| > |30|29||| > Malcolm|43|60|56|| > |28|37||| > Amy||70|45|| > |40|30||40 > |40||30|| > > I want to parse this data and format it in this way: > > Joe|25;28;30|30;39;29|49;71|40| > Malcolm|43;28|60;37|56|| > Amy|40;40|70;30|45;;30|;40;| > name = 'unnamed' # just in-case the file doesn't start with a name result = {} for line in inp.split(): field = line.split('|') while len(field) < 6: # fix misformatted line |40|40||40 field.append('') k = field.pop(0) # grab name field field.pop() # clear final blank if k != '': # on name change name = k if not result.has_key(name): result[name] = [] result[name].append(field) for name in result.keys(): ans = apply( zip, result[name] ) # tranpose matrix ans = map( ';'.join, ans ) ans.insert(0,name) ans.append('') print '|'.join(ans) Raymond From fgeiger at datec.at Fri Feb 23 18:45:30 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Fri, 23 Feb 2001 18:45:30 +0100 Subject: Want to build a shop using Zope, but how? Message-ID: <9767le$82f$1@newsreaderg1.core.theplanet.net> I want to do the next step in CGI programming and want to use Zope to build a web shop. Besides downloading Zope and installing it on my Windows box I printed the Zope book and read thru it. There is an example all thru the book which is not of great help for me (at least I think so). While it is good to teach you the very basics of Zope it does not seem to provide advanced topics. When it comes to advanced concepts you are very likely to encounter "But this is beyond this book" (ZClasses e.g.). I've got the impression, that if one wants to use Zope for anything advanced he has to download some modules from www.zope.org. But this site really confuses me. Every day there are new modules released and every few days new versions of those modules. I don't want to spend hours and days to figure out what to download so that Zope is of advanced help for me. The same seems to apply to documentation. Zope still seems to move very fast. Which of the docs and how-to's are still relevant and which are outdated? Yes, I saw one or two Zope products on e-commerce which could be interesting. But how can I understand those products if I do not understand Zope yet? I must admit that I am looking for fast success. Since I know Python I know fast success is possible ;-). How can I achieve fast success using Zope? My hope was to find information somewhere on how Zope supports a Pythoneer in CGI programming: How to deal with cookies in Zope, how to manage session etc. I am less interested in DTML. Or did I get something completely wrong here? Anyone here who was in the same situation? How did you proceed? Any hint's welcome! Many thanks in advance and best regards Franz GEIGER P.S.: Don't get me wrong because of my clumsy English: I WANT to use Zope. It's oo approach is too appealing. From doughellmann at bigfoot.com Sat Feb 24 14:37:25 2001 From: doughellmann at bigfoot.com (Doug Hellmann) Date: Sat, 24 Feb 2001 13:37:25 GMT Subject: Want to build a shop using Zope, but how? References: <9767le$82f$1@newsreaderg1.core.theplanet.net> Message-ID: In article <9767le$82f$1 at newsreaderg1.core.theplanet.net>, "Franz GEIGER" wrote: > I want to do the next step in CGI programming and want to use Zope to > build a web shop. > > Besides downloading Zope and installing it on my Windows box I printed > the Zope book and read thru it. There is an example all thru the book > which is not of great help for me (at least I think so). While it is > good to teach you the very basics of Zope it does not seem to provide > advanced topics. When it comes to advanced concepts you are very likely > to encounter "But this is beyond this book" (ZClasses e.g.). My understanding was that the Zope book was for beginners, and that there will be another more advanced book. You may want to check out the New User How-Tos at http://www.zope.org/Documentation/nuser. Reading the online DTML manual may help as well. > I've got the impression, that if one wants to use Zope for anything > advanced he has to download some modules from www.zope.org. But this > site really confuses me. Every day there are new modules released and > every few days new versions of those modules. I don't want to spend > hours and days to figure out what to download so that Zope is of > advanced help for me. The Products available on zope.org are components you can instantiate on your server. The best place to get help about the Products is to look at the documentation distributed with them, or to instantiate one and see what you get -- many include online help. > Or did I get something completely wrong here? Anyone here who was in the > same situation? How did you proceed? The learning curve for Zope is a bit steep, but not terribly long. There are actually a few plateaus, so you end up with a stair step learning curve. > Any hint's welcome! Check out the mailing lists on zope.org, too. They are very high traffic, but that's generally when Zope developers go for help. Doug From fgeiger at datec.at Fri Feb 23 18:46:41 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Fri, 23 Feb 2001 18:46:41 +0100 Subject: Not all ntpath.py-methods do recognize shares, do they? Message-ID: <9767nl$83h$1@newsreaderg1.core.theplanet.net> I had to change exists() and isdir() of ntpath.py so that they work for my purposes (shares ARE dirs in my apps): ##### DDG\fge (20001122) #def exists(path): # """Test whether a path exists""" # try: # st = os.stat(path) # except os.error: # return 0 # return 1 def exists(path): """Test whether a path exists""" try: st = os.stat(path) except os.error: if ismount(path): return 1 return 0 return 1 # ##### DDG\fge (20001122) ##### DDG\fge (20010223) #def isdir(path): # """Test whether a path is a directory""" # try: # st = os.stat(path) # except os.error: # return 0 # return stat.S_ISDIR(st[stat.ST_MODE]) def isdir(path): """Test whether a path is a directory""" try: st = os.stat(path) except os.error: if ismount(path): return 1 return 0 return stat.S_ISDIR(st[stat.ST_MODE]) # ##### DDG\fge (20010223) Any comments? Did I miss something? Best regards Franz GEIGER From MarkH at ActiveState.com Sat Feb 24 02:35:12 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sat, 24 Feb 2001 01:35:12 GMT Subject: Not all ntpath.py-methods do recognize shares, do they? References: <9767nl$83h$1@newsreaderg1.core.theplanet.net> Message-ID: <3A970EF4.80400@ActiveState.com> Franz GEIGER wrote: > I had to change exists() and isdir() of ntpath.py so that they work for my > purposes (shares ARE dirs in my apps): ... > Any comments? Did I miss something? Off the top of my head I can't see a problem with this. Submit a patch at sourceforge. Mark. From db3l at fitlinxx.com Mon Feb 26 23:07:52 2001 From: db3l at fitlinxx.com (David Bolen) Date: 26 Feb 2001 17:07:52 -0500 Subject: Not all ntpath.py-methods do recognize shares, do they? References: <9767nl$83h$1@newsreaderg1.core.theplanet.net> Message-ID: "Franz GEIGER" writes: > Any comments? Did I miss something? When I last used this (and I just checked again), ismount() returns 1 for any directory immediately below a remote machine, whether or not it is really a share. So this might not be safe as a general change: E.g., A remote machine "ctwh01" has a share "sitedata" with a directory "ni" beneath it: os.path.ismount(r'\\ctwh01\sitedata\ni') --> 0 os.path.ismount(r'\\ctwh01\sitedata') --> 1 os.path.ismount(r'\\ctwh01\foo') --> 1 os.path.ismount(r'\\ctwh01\bar') --> 1 os.path.ismount(r'\\ctwh01\\') --> 1 But "foo", "bar" and the root directory "\" are not shares. This was with Python 1.5.2 and Python 2.0 under NT4SP4. If you want to treat a directory beneath a share as a directory, then I would probably suggest that you use your own function wrapping os.path.isdir rather than modifying the libraries themselves with ismount() since I think that could lead to confusion in other cases. -- -- 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 gem at hsv.crc.com Fri Feb 23 18:55:36 2001 From: gem at hsv.crc.com (Glen Mettler) Date: Fri, 23 Feb 2001 11:55:36 -0600 Subject: Python with AMS Real Time Project Message-ID: <9767p9$ear$1@hobbes2.crc.com> Is anyone using Python with AMS Real Time Project? I have just acquired both and I am wondering about the ease and practicality of manipulating RTS from Python. Glen From BgPorter at NOartlogicSPAM.com Fri Feb 23 19:35:43 2001 From: BgPorter at NOartlogicSPAM.com (Brett g Porter) Date: Fri, 23 Feb 2001 18:35:43 GMT Subject: Palm/Python Message-ID: <34yl6.301124$w35.49575483@news1.rdc1.nj.home.com> Seen this morning on the PHO mailing list. Anyone know anything about this port? ------------------------- Peer-to-Peer Everywhere? By: Mike Darrah 2/23/01 Published exclusively on PHO mailing list. Endeavors Technology has announced the successful deployment of an open source port of Python to the Palm OS, allowing the company to bring it's "Magi" P2P technology to the Palm OS platform, and enabling the automation of applications on the Palm OS. Python is an interpreted, interactive, object-oriented programming language, which allows for a great deal of dynamism, ease of use, power, and flexibility in a programming language, often compared to Perl or Java. Endeavors Technology has been focusing on building a common infrastructure for all and all connected devices, such as PDAs, PCs, servers, information appliances, and Internet-ready phones to allow the development of a P2P system structure to enable software applications to communicate to one another regardless of what type of device it is. Endeavors stated it will work with device manufacturers and software developers to implement this small footprint, interoperable virtual machine (VM) across more then just the Palm OS platform, thus creating the common infrastructure needed to connect the devices seamlessly in a peer-to-peer network. The technology, named "The Pippy VM" is an extension of the work pioneered in a joint venture between The Aerospace Corp. and University of California, Irvine, which was initially funded in part by the Defense Advanced Research Project Agency (DARPA). The company has also already developed similar P2P systems for the Compaq's iPAQ Pocket PC, announced just last month. With the announcement of the successful deployment of the Python port to the Palm OS, Endeavors Technology has taken a bold step forward into making their vision of a complete P2P network with all connected devices into a reality. Additional Information References: http://www.python.org/ http://www.endeavors.com/ http://www.endeavors.com/tech.html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Once again, anyone interested in syndicating this news, please feel free to do so free of charge. All I request is to be named as the author of this news article in the syndication, and be notified of it's syndication. Sincerely, Mike Darrah -X- Digital Media Consulting / Management XGeneration Network webmaster at xgeneration.net -- // Brett g Porter * Senior Engineer, Application Development // BgPorter @ artlogic . com * http://www.artlogic.com // Art & Logic * Custom software solutions for hardware products // Windows * MacOS * Embedded Systems From fwittenburg at myokay.net Fri Feb 23 21:49:49 2001 From: fwittenburg at myokay.net (Florian W.) Date: Fri, 23 Feb 2001 21:49:49 +0100 Subject: Palm/Python References: <34yl6.301124$w35.49575483@news1.rdc1.nj.home.com> Message-ID: <976ibc$2ca8$1@news.okay.net> Brett g Porter schrieb in im Newsbeitrag: 34yl6.301124$w35.49575483 at news1.rdc1.nj.home.com... > Seen this morning on the PHO mailing list. Anyone know anything about this > port? Is it this ? http://www.isr.uci.edu/projects/sensos/python/software.html (I didn't manage to do something usefull with it.) Mfg Florian From jcollins at endeavors.com Fri Feb 23 22:09:39 2001 From: jcollins at endeavors.com (Jeff Collins) Date: Fri, 23 Feb 2001 14:09:39 -0700 Subject: Palm/Python In-Reply-To: <976ibc$2ca8$1@news.okay.net>; from fwittenburg@myokay.net on Fri, Feb 23, 2001 at 09:49:49PM +0100 References: <34yl6.301124$w35.49575483@news1.rdc1.nj.home.com> <976ibc$2ca8$1@news.okay.net> Message-ID: <20010223140939.T13871@endeavors.com> The new site can be found at http://www.endeavors.com/pippy On Fri, Feb 23, 2001 at 09:49:49PM +0100, Florian W. wrote: > > Brett g Porter schrieb in im Newsbeitrag: > 34yl6.301124$w35.49575483 at news1.rdc1.nj.home.com... > > Seen this morning on the PHO mailing list. Anyone know anything about this > > port? > > Is it this ? > > http://www.isr.uci.edu/projects/sensos/python/software.html > > (I didn't manage to do something usefull with it.) > > Mfg Florian -- Jeffery D. Collins, Ph.D. Sr. Software Developer Endeavors Technology, Inc. http://www.endeavors.com From jcollins at endeavors.com Fri Feb 23 22:09:03 2001 From: jcollins at endeavors.com (Jeff Collins) Date: Fri, 23 Feb 2001 14:09:03 -0700 Subject: Palm/Python In-Reply-To: <34yl6.301124$w35.49575483@news1.rdc1.nj.home.com>; from BgPorter@NOartlogicSPAM.com on Fri, Feb 23, 2001 at 06:35:43PM +0000 References: <34yl6.301124$w35.49575483@news1.rdc1.nj.home.com> Message-ID: <20010223140903.S13871@endeavors.com> You can find the new home page for the port of Python to the Palm at http://www.endeavors.com/pippy. On Fri, Feb 23, 2001 at 06:35:43PM +0000, Brett g Porter wrote: > Seen this morning on the PHO mailing list. Anyone know anything about this > port? > > ------------------------- > > Peer-to-Peer Everywhere? > By: Mike Darrah 2/23/01 > Published exclusively on PHO mailing list. > > Endeavors Technology has announced the successful deployment > of an open source port of Python to the Palm OS, allowing the > company to bring it's "Magi" P2P technology to the Palm OS platform, > and enabling the automation of applications on the Palm OS. > > Python is an interpreted, interactive, object-oriented programming > language, which allows for a great deal of dynamism, ease of > use, power, and flexibility in a programming language, often > compared to Perl or Java. > > Endeavors Technology has been focusing on building a common infrastructure > for all and all connected devices, such as PDAs, PCs, servers, > information appliances, and Internet-ready phones to allow the > development of a P2P system structure to enable software applications > to communicate to one another regardless of what type of device > it is. > > Endeavors stated it will work with device manufacturers and software > developers to implement this small footprint, interoperable virtual > machine (VM) across more then just the Palm OS platform, thus > creating the common infrastructure needed to connect the devices > seamlessly in a peer-to-peer network. The technology, named "The > Pippy VM" is an extension of the work pioneered in a joint venture > between The Aerospace Corp. and University of California, Irvine, > which was initially funded in part by the Defense Advanced Research > Project Agency (DARPA). > > The company has also already developed similar P2P systems for > the Compaq's iPAQ Pocket PC, announced just last month. > > With the announcement of the successful deployment of the Python > port to the Palm OS, Endeavors Technology has taken a bold step > forward into making their vision of a complete P2P network with > all connected devices into a reality. > > Additional Information References: > http://www.python.org/ > http://www.endeavors.com/ > http://www.endeavors.com/tech.html > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Once again, anyone interested in syndicating this news, please > feel free to do so free of charge. All I request is to be named > as the author of this news article in the syndication, and be > notified of it's syndication. > > Sincerely, > Mike Darrah > > -X- > > Digital Media Consulting / Management > > XGeneration Network > webmaster at xgeneration.net > > -- > // Brett g Porter * Senior Engineer, Application Development > // BgPorter @ artlogic . com * http://www.artlogic.com > // Art & Logic * Custom software solutions for hardware products > // Windows * MacOS * Embedded Systems -- Jeffery D. Collins, Ph.D. Sr. Software Developer Endeavors Technology, Inc. http://www.endeavors.com From bryan at eevolved.com Sat Feb 24 16:51:17 2001 From: bryan at eevolved.com (Bryan Mongeau) Date: Sat, 24 Feb 2001 15:51:17 GMT Subject: Palm/Python References: <34yl6.301124$w35.49575483@news1.rdc1.nj.home.com> Message-ID: Hi Jeff, Congratulations to you and Micheal for the very impressive work with Pippy. Even more impressive is that your website seems to be shrugging off a full scale slashdotting! :) I was disheartened though to see in the README that floating points, file objects and long integers are dropped (I need those!), although I appreciate some concessions must be made to reduce the footprint for Palm. I notice in the goals that you intend to lobby for incorporation of these modifications into the core distribution... Good luck. :) Personally as a python PDA application developer, I require the full functionality of python and consequently cannot cater to a platform incapable of supporting it completely. Although I'm sure pippy is of great use to your application and I applaud your efforts, don't you see PDA capabilities as soon being able to run the complete python? Good luck with the venture, -- <=====================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. Website: http://www.eevolved.com Public key: http://eevolved.com/bcm.pk <=====================================> "The genes are the master programmers, and they are programming for their lives." -- Richard Dawkins From jcollins at endeavors.com Mon Feb 26 17:16:16 2001 From: jcollins at endeavors.com (Jeff Collins) Date: Mon, 26 Feb 2001 09:16:16 -0700 Subject: Palm/Python In-Reply-To: ; from bryan@eevolved.com on Sat, Feb 24, 2001 at 03:51:17PM +0000 References: <34yl6.301124$w35.49575483@news1.rdc1.nj.home.com> Message-ID: <20010226091615.E13871@endeavors.com> On Sat, Feb 24, 2001 at 03:51:17PM +0000, Bryan Mongeau wrote: > Hi Jeff, > > Congratulations to you and Micheal for the very impressive work with Pippy. > Even more impressive is that your website seems to be shrugging off a full > scale slashdotting! :) Thanks! I was surprised at how fast the news traveled. > > I was disheartened though to see in the README that floating points, file > objects and long integers are dropped (I need those!), although I > appreciate some concessions must be made to reduce the footprint for Palm. > > I notice in the goals that you intend to lobby for incorporation of these > modifications into the core distribution... Good luck. :) Personally as a > python PDA application developer, I require the full functionality of > python and consequently cannot cater to a platform incapable of supporting > it completely. > > Although I'm sure pippy is of great use to your application and I applaud > your efforts, don't you see PDA capabilities as soon being able to run the > complete python? I wish I could predict the future:-) The earlier Palm platforms had much less dynamic heap, stack and storage RAM than the latest models. I would expect this trend to continue. Check out PythonCE, a port of an older version of Python to WinCE devices. It is quite capable. -- Jeffery D. Collins, Ph.D. Sr. Software Developer Endeavors Technology, Inc. http://www.endeavors.com From hinsen at cnrs-orleans.fr Tue Feb 27 11:08:50 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 27 Feb 2001 11:08:50 +0100 Subject: Palm/Python References: <34yl6.301124$w35.49575483@news1.rdc1.nj.home.com> Message-ID: "Jeff Collins" writes: > I wish I could predict the future:-) The earlier Palm platforms had > much less dynamic heap, stack and storage RAM than the latest models. I wonder if that is also the reason why Pippy needs PalmOS 3.5? Of course I have only 3.3 :-( Konrad. -- ------------------------------------------------------------------------------- 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 ajung-ml at andreas-jung.com Tue Feb 27 13:58:15 2001 From: ajung-ml at andreas-jung.com (Andreas Jung) Date: Tue, 27 Feb 2001 07:58:15 -0500 Subject: Palm/Python References: <34yl6.301124$w35.49575483@news1.rdc1.nj.home.com> Message-ID: <013001c0a0c0$010cb970$d0063bd0@SUXLAP> Don't worry. I am running 2.04 *sigh too* Andreas ----- Original Message ----- From: "Konrad Hinsen" Newsgroups: comp.lang.python To: Sent: Tuesday, February 27, 2001 5:08 AM Subject: Re: Palm/Python > "Jeff Collins" writes: > > > I wish I could predict the future:-) The earlier Palm platforms had > > much less dynamic heap, stack and storage RAM than the latest models. > > I wonder if that is also the reason why Pippy needs PalmOS 3.5? > Of course I have only 3.3 :-( > > Konrad. > -- > -------------------------------------------------------------------------- ----- > 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 > -------------------------------------------------------------------------- ----- > -- > http://mail.python.org/mailman/listinfo/python-list From jcollins at endeavors.com Tue Feb 27 16:11:08 2001 From: jcollins at endeavors.com (Jeff Collins) Date: Tue, 27 Feb 2001 08:11:08 -0700 Subject: Palm/Python In-Reply-To: ; from hinsen@cnrs-orleans.fr on Tue, Feb 27, 2001 at 11:08:50AM +0100 References: <34yl6.301124$w35.49575483@news1.rdc1.nj.home.com> Message-ID: <20010227081108.K13871@endeavors.com> We are testing Pippy on a device with 256K of heap, which is provided by PalmOS 3.5 with at least 4M of RAM. The 96K of heap provided by the PalmOS 3.0,3.3 isn't enough to load the parser accelerators. We are continuing the effort to reduce the heap usage and hope to be running on these devices soon. On Tue, Feb 27, 2001 at 11:08:50AM +0100, Konrad Hinsen wrote: > "Jeff Collins" writes: > > > I wish I could predict the future:-) The earlier Palm platforms had > > much less dynamic heap, stack and storage RAM than the latest models. > > I wonder if that is also the reason why Pippy needs PalmOS 3.5? > Of course I have only 3.3 :-( > > Konrad. -- Jeffery D. Collins, Ph.D. Sr. Software Developer Endeavors Technology, Inc. http://www.endeavors.com From fpm at u.washington.edu Tue Feb 27 18:30:04 2001 From: fpm at u.washington.edu (Frank Miles) Date: 27 Feb 2001 17:30:04 GMT Subject: Palm/Python References: <34yl6.301124$w35.49575483@news1.rdc1.nj.home.com> Message-ID: <97go6s$vn4$1@nntp6.u.washington.edu> In article , Jeff Collins wrote: > >We are testing Pippy on a device with 256K of heap, which is provided >by PalmOS 3.5 with at least 4M of RAM. The 96K of heap provided by >the PalmOS 3.0,3.3 isn't enough to load the parser accelerators. We >are continuing the effort to reduce the heap usage and hope to be >running on these devices soon. Any hope that floats might be supported in the future? Using MathLib should take most of the pain out of that, other than possible space problems... -frank -- From jcollins at endeavors.com Tue Feb 27 19:49:24 2001 From: jcollins at endeavors.com (Jeff Collins) Date: Tue, 27 Feb 2001 11:49:24 -0700 Subject: Palm/Python In-Reply-To: <97go6s$vn4$1@nntp6.u.washington.edu>; from fpm@u.washington.edu on Tue, Feb 27, 2001 at 05:30:04PM +0000 References: <34yl6.301124$w35.49575483@news1.rdc1.nj.home.com> <97go6s$vn4$1@nntp6.u.washington.edu> Message-ID: <20010227114924.T13871@endeavors.com> I have no immediate need for floats, but if someone is interested in pursuing this, I may be able to offer suggestions. On Tue, Feb 27, 2001 at 05:30:04PM +0000, Frank Miles wrote: > In article , > Jeff Collins wrote: > > > >We are testing Pippy on a device with 256K of heap, which is provided > >by PalmOS 3.5 with at least 4M of RAM. The 96K of heap provided by > >the PalmOS 3.0,3.3 isn't enough to load the parser accelerators. We > >are continuing the effort to reduce the heap usage and hope to be > >running on these devices soon. > > Any hope that floats might be supported in the future? Using MathLib > should take most of the pain out of that, other than possible space > problems... > > -frank -- Jeffery D. Collins, Ph.D. Sr. Software Developer Endeavors Technology, Inc. http://www.endeavors.com From bobhicks at adelphia.net Tue Feb 27 22:38:04 2001 From: bobhicks at adelphia.net (Robert L Hicks) Date: Tue, 27 Feb 2001 21:38:04 GMT Subject: Palm/Python References: <34yl6.301124$w35.49575483@news1.rdc1.nj.home.com> Message-ID: My M100 runs the beta fine... > From: "Jeff Collins" > Organization: Baymountain > Newsgroups: comp.lang.python > Date: Tue, 27 Feb 2001 08:11:08 -0700 > To: Konrad Hinsen > Cc: python-list at python.org > Subject: Re: Palm/Python > > > We are testing Pippy on a device with 256K of heap, which is provided > by PalmOS 3.5 with at least 4M of RAM. The 96K of heap provided by > the PalmOS 3.0,3.3 isn't enough to load the parser accelerators. We > are continuing the effort to reduce the heap usage and hope to be > running on these devices soon. > > On Tue, Feb 27, 2001 at 11:08:50AM +0100, Konrad Hinsen wrote: >> "Jeff Collins" writes: >> >>> I wish I could predict the future:-) The earlier Palm platforms had >>> much less dynamic heap, stack and storage RAM than the latest models. >> >> I wonder if that is also the reason why Pippy needs PalmOS 3.5? >> Of course I have only 3.3 :-( >> >> Konrad. > > -- > Jeffery D. Collins, Ph.D. > Sr. Software Developer > Endeavors Technology, Inc. > http://www.endeavors.com > From chrisa at ASPATECH.COM.BR Fri Feb 23 20:04:33 2001 From: chrisa at ASPATECH.COM.BR (Chris Richard Adams) Date: Fri, 23 Feb 2001 16:04:33 -0300 Subject: interactive programming Message-ID: How can I create a loop - interactively. I'm just trying to learn syntax for example, so Id like to create conditional if statements like a = 'feb' if a == 'jan': mo = 1 elif a == 'feb': mo = 2 elif a == 'mar': mo = 3 ... I tried to type this interactively, but I get a mess of error about syntax or mis placed whitespace... 1.) After the return after mo = 1 - how do I make sure theelif is aligned with if? 2.) Is there any refernces for interactive programming - the tutorial is too short? Thanks,Chris From shaleh at valinux.com Fri Feb 23 20:20:28 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Fri, 23 Feb 2001 11:20:28 -0800 (PST) Subject: interactive programming In-Reply-To: Message-ID: On 23-Feb-2001 Chris Richard Adams wrote: > How can I create a loop - interactively. I'm just trying to learn > syntax for example, so Id like to create conditional if statements like > a = 'feb' > > if a == 'jan': > mo = 1 > elif a == 'feb': > mo = 2 > elif a == 'mar': > mo = 3 > ... > > I tried to type this interactively, but I get a mess of error about > syntax or mis placed whitespace... > $ python 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 >>> the >>> is the 'start a command here prompt' >>> if a == 'jan': ... print a # the ... is the 'continue previous command', when you see this ... # you must indent your code (just hit tab or a few spaces) ... elif a == 'feb': # still under the if ... print a # again, indented ... feb >>> # back to start a command From chrisa at ASPATECH.COM.BR Fri Feb 23 20:12:15 2001 From: chrisa at ASPATECH.COM.BR (Chris Richard Adams) Date: Fri, 23 Feb 2001 16:12:15 -0300 Subject: Can I leverage Java classes from a python program Message-ID: If so, questions: I am working with Java Oracle Intermedia classes (just a Java API that helps you manipulate images (Blobs) stored in a database). ANyway - I have to work with the java oracle classes, but wanted to do this from a python program. Can I use inheritance to access these types of classes, even though they are in Java. If so could you point to a reference that might show some examples???? AND does this have anything to do with JPython - would I want to use that rather than my standard Linux 2.0 version. thanks! From dsh8290 at rit.edu Fri Feb 23 22:21:42 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 23 Feb 2001 16:21:42 -0500 Subject: Can I leverage Java classes from a python program In-Reply-To: ; from chrisa@aspatech.com.br on Fri, Feb 23, 2001 at 04:12:15PM -0300 References: Message-ID: <20010223162142.A5639@harmony.cs.rit.edu> You can certainly use any Java classes from Python. Go to jythnon.sourceforge.net. Jython is the new name for JPython. It is current with version 2.0 of CPython. from javax.swing import JDialog , JLabel class MyDialog( JDialog ) : def __init__( self ) : self.getContentPane().add( JLabel( "Hello World" ) ) self.setSize( 200 , 300 ) self.setVisible( 1 ) dialog = MyDialog() -D From whisper at oz.net Fri Feb 23 20:39:21 2001 From: whisper at oz.net (Dave LeBlanc) Date: 23 Feb 2001 19:39:21 GMT Subject: Protecting Python Application Distributions - URGENT Message-ID: <976e99$7pj$0@216.39.170.247> Hi; I have the possible chance to do a consulting project in Python, but the customer has raised concerns about (not) doing a source distribution. I've read some stuff about python->C etc. but I haven't been able to find any concrete information. Any information about creating "exe" or "shrouded" or some other form of protected distribution on Windows would be greatly appreciated. (I realize that 100% protection is impossible given sufficient motivation; I'd just like to make it irritating enough that most people wouldn't bother trying to decompile/reconstruct the code.) Cross-emails to whisper at oz.net greatly appreciated! Regards, Dave LeBlanc P.S. Any solution that created stand-alone .exe files (no separate python.exe needed) would be of special interest. From adam at deprince.net Fri Feb 23 08:03:53 2001 From: adam at deprince.net (Adam DePrince) Date: Fri, 23 Feb 2001 02:03:53 -0500 Subject: Protecting Python Application Distributions - URGENT References: <976e99$7pj$0@216.39.170.247> Message-ID: <3A960B59.B10FF235@deprince.net> Dave LeBlanc wrote: > > Hi; > > I have the possible chance to do a consulting project in Python, but > the customer has raised concerns about (not) doing a source > distribution. > > I've read some stuff about python->C etc. but I haven't been able to > find any concrete information. > > Any information about creating "exe" or "shrouded" or some other form > of protected distribution on Windows would be greatly appreciated. (I > realize that 100% protection is impossible given sufficient > motivation; I'd just like to make it irritating enough that most > people wouldn't bother trying to decompile/reconstruct the code.) > > Cross-emails to whisper at oz.net greatly appreciated! > > Regards, > > Dave LeBlanc > > P.S. Any solution that created stand-alone .exe files (no separate > python.exe needed) would be of special interest. You could just ship the compiled python files (.pyc). If worry about others coping your stuff, well, stealing others code is actually rather hard, it often takes longer to wrap ones mind around the way others think than it does to rewrite it. In fact, I've casually observed that many projects, open source and closed, expereince the greatest structural changes following changes in stewardship. Besides, if your code is good and your clients are smart, they are more likely to say "hey, your stuff looks good. Write more" if they can see it. -- Adam DePrince Starmedia Network, Inc. Email: zlib.decompress('x\332KLI\314\325KI-(\312\314KNu(.I,\312MM\311L\324K\316\317\005\000\221\331\012s') From butcuz at yahoo.com Fri Feb 23 20:59:08 2001 From: butcuz at yahoo.com (sa) Date: Fri, 23 Feb 2001 14:59:08 -0500 Subject: Protecting Python Application Distributions - URGENT References: <976e99$7pj$0@216.39.170.247> Message-ID: <3a96c1be$1_4@corp.newsfeeds.com> - you might want to check these out: Thomas Heller's py2exe : http://starship.python.net/crew/theller/py2exe/ (an easy way create 'standalone' applications using disutils) Gordon McMillan's python distribution utilities : http://www.mcmillan-inc.com/install1.html (more options, but steeper learning curve) good luck, sa "Dave LeBlanc" wrote in message news:976e99$7pj$0 at 216.39.170.247... > Hi; > > I have the possible chance to do a consulting project in Python, but > the customer has raised concerns about (not) doing a source > distribution. > > I've read some stuff about python->C etc. but I haven't been able to > find any concrete information. > > Any information about creating "exe" or "shrouded" or some other form > of protected distribution on Windows would be greatly appreciated. (I > realize that 100% protection is impossible given sufficient > motivation; I'd just like to make it irritating enough that most > people wouldn't bother trying to decompile/reconstruct the code.) > > Cross-emails to whisper at oz.net greatly appreciated! > > Regards, > > Dave LeBlanc > > P.S. Any solution that created stand-alone .exe files (no separate > python.exe needed) would be of special interest. > -----= 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 whisper at oz.net Fri Feb 23 21:27:58 2001 From: whisper at oz.net (Dave LeBlanc) Date: 23 Feb 2001 20:27:58 GMT Subject: Protecting Python Application Distributions - URGENT References: <976e99$7pj$0@216.39.170.247> <3a96c1be$1_4@corp.newsfeeds.com> Message-ID: <976h4e$dbh$0@216.39.170.247> sa! Thanks! Most Excellent! Dave LeBlanc On Fri, 23 Feb 2001 14:59:08 -0500, "sa" wrote: > >- you might want to check these out: > >Thomas Heller's py2exe : http://starship.python.net/crew/theller/py2exe/ (an >easy way create 'standalone' applications using disutils) > >Gordon McMillan's python distribution utilities : >http://www.mcmillan-inc.com/install1.html (more options, but steeper >learning curve) > >good luck, > >sa > >"Dave LeBlanc" wrote in message >news:976e99$7pj$0 at 216.39.170.247... >> Hi; >> >> I have the possible chance to do a consulting project in Python, but >> the customer has raised concerns about (not) doing a source >> distribution. >> >> I've read some stuff about python->C etc. but I haven't been able to >> find any concrete information. >> >> Any information about creating "exe" or "shrouded" or some other form >> of protected distribution on Windows would be greatly appreciated. (I >> realize that 100% protection is impossible given sufficient >> motivation; I'd just like to make it irritating enough that most >> people wouldn't bother trying to decompile/reconstruct the code.) >> >> Cross-emails to whisper at oz.net greatly appreciated! >> >> Regards, >> >> Dave LeBlanc >> >> P.S. Any solution that created stand-alone .exe files (no separate >> python.exe needed) would be of special interest. >> > > > > >-----= 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 tismer at tismer.com Fri Feb 23 20:42:45 2001 From: tismer at tismer.com (Christian Tismer) Date: Fri, 23 Feb 2001 20:42:45 +0100 Subject: Stackless Python 2.0 Minor Update ("Korea Edition") Message-ID: <3A96BD35.7D56E8C@tismer.com> This is yet another bugfix release for Stackless Python 2.0 . x = [] for (a, b) in ((1,2),): if 1: x.append(a) no longer crashes. The reason was an unitialized error flag. The new Win32 distribution and source code can be downloaded from http://www.stackless.com/ People who don't want to do a download for just a small change, and who like to compile Stackless anyway, can find a simpe patch as well. cheers - chris -- Christian Tismer :^) Mission Impossible 5oftware : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net/ 14163 Berlin : PGP key -> http://wwwkeys.pgp.net/ PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com/ -- http://mail.python.org/mailman/listinfo/python-list From nb0klun71q5001 at sneakemail.com Fri Feb 23 20:47:47 2001 From: nb0klun71q5001 at sneakemail.com (Ron Scinta) Date: Fri, 23 Feb 2001 19:47:47 GMT Subject: Newbie question.. how to load modules with a dynamic name? Message-ID: I have a need to run various python script files from a master control script, however, I do not know the names of the scripts until runtime. I will be getting the script names from a database.. and was thinking I could just use the import call with the supplied name. This does not work alas.... >>> mymod = "ptw" >>> import mymod Traceback (innermost last): File "", line 1, in ? ImportError: No module named mym >>> What is the prefered method of doing this type of operation? Any help would be greatly appreciated! Best Regards, Ron From shaleh at valinux.com Fri Feb 23 22:13:26 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Fri, 23 Feb 2001 13:13:26 -0800 (PST) Subject: Newbie question.. how to load modules with a dynamic name? In-Reply-To: Message-ID: On 23-Feb-2001 Ron Scinta wrote: > I have a need to run various python script files from a master control > script, however, I do not know the names of the scripts until runtime. > > What is the prefered method of doing this type of operation? > >>> foo = 'sys' >>> exec "import %s" % foo >>> print sys.argv [''] >>> dir(sys) ['__doc__', '__name__', '__stderr__', '__stdin__', '__stdout__', 'argv', 'builtin_module_names', 'copyright', 'exc_info', 'exc_type', 'exec_prefix', 'executable', 'exit', 'getrefcount', 'hexversion', 'maxint', 'modules', 'path', 'platform', 'prefix', 'ps1', 'ps2', 'setcheckinterval', 'setprofile', 'settrace', 'stderr', 'stdin', 'stdout', 'version'] From dsavitsk at e-coli.net Fri Feb 23 22:20:25 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Fri, 23 Feb 2001 15:20:25 -0600 Subject: Newbie question.. how to load modules with a dynamic name? References: Message-ID: "Ron Scinta" wrote in message news:D7zl6.221$Gm2.5547 at skycache.prestige.net... > I have a need to run various python script files from a master control > script, however, I do not know the names of the scripts until runtime. > > I will be getting the script names from a database.. and was thinking I > could just use the import call with the supplied name. > > This does not work alas.... > >>> mymod = "ptw" >>> exec('import ' + mymod) ds From nb0klun71q5001 at sneakemail.com Fri Feb 23 21:40:05 2001 From: nb0klun71q5001 at sneakemail.com (Ron Scinta) Date: Fri, 23 Feb 2001 20:40:05 GMT Subject: Newbie question.. how to load modules with a dynamic name? References: Message-ID: > > This does not work alas.... > > >>> mymod = "ptw" > > >>> exec('import ' + mymod) > > ds OK, but how then do I reference the dynamic module by name? mymod. (The period does not help here, still thinks I am using the string class instead of my imported module).... Is there a way to alias the module name at this point? From gerhard.nospam at bigfoot.de Sat Feb 24 00:45:03 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sat, 24 Feb 2001 00:45:03 +0100 Subject: Newbie question.. how to load modules with a dynamic name? References: Message-ID: <3A96F5FF.1DE715EB@bigfoot.de> Ron Scinta wrote: > > > > This does not work alas.... > > > >>> mymod = "ptw" > > > > >>> exec('import ' + mymod) > > > > ds > > OK, but how then do I reference the dynamic module by name? In Python 2.0, you can use the "import ... as ..." construct. for example: modules2test = [ 'module1', 'module2' ] for mymodule in modules2test: exec( 'import ' + mymodule + ' as test_module' ) test_module.test() 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 aleaxit at yahoo.com Sat Feb 24 10:31:40 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 24 Feb 2001 10:31:40 +0100 Subject: Newbie question.. how to load modules with a dynamic name? References: Message-ID: <977v830vmc@news1.newsguy.com> "Ron Scinta" wrote in message news:FUzl6.227$Gm2.5865 at skycache.prestige.net... > > > This does not work alas.... > > > >>> mymod = "ptw" > > > > >>> exec('import ' + mymod) > > > > ds > > OK, but how then do I reference the dynamic module by name? > > mymod. (The period does not help here, still thinks I am using the string > class instead of my imported module).... > > Is there a way to alias the module name at this point? sys.modules[mymod] will refer to the module object (you'll need to import sys, of course). You can assign that to whatever name you like, e.g., floop = sys.modules[mymod] floop.pleep('praak') Alex From fredrik at pythonware.com Fri Feb 23 22:27:16 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 23 Feb 2001 21:27:16 GMT Subject: Newbie question.. how to load modules with a dynamic name? References: Message-ID: Ron Scinta wrote: > I have a need to run various python script files from a master control > script, however, I do not know the names of the scripts until runtime. > > I will be getting the script names from a database.. and was thinking I > could just use the import call with the supplied name. > > This does not work alas.... > >>> mymod = "ptw" > >>> import mymod > Traceback (innermost last): > File "", line 1, in ? > ImportError: No module named mym > >>> > > What is the prefered method of doing this type of operation? how about: execfile("mymod.py") or: mymod = __import__("mymod") see the library reference (builtin functions) for more info. Cheers /F From wjones at usachoice.net Fri Feb 23 21:40:14 2001 From: wjones at usachoice.net (Wyn Jones) Date: Fri, 23 Feb 2001 15:40:14 -0500 Subject: take me off this god damn list Message-ID: <3A96CAAE.4040304@usachoice.net> I DO NOT WANT ANY PART OF THIS BULL- SHIT!!!!!!!!!!!!!!!!!!! From tim at vegeta.ath.cx Sat Feb 24 07:29:50 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Sat, 24 Feb 2001 06:29:50 GMT Subject: take me off this god damn list References: Message-ID: Wyn Jones wrote: > I DO NOT WANT ANY PART OF THIS BULL- SHIT!!!!!!!!!!!!!!!!!!! Tell ya what: instead of cussing, why don't you take a look at your own message headers, which in my newsreader (slrn) include: NNTP-Posting-Host: mail.python.org { should've been your first clue } User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; m18) Gecko/2000... { explains a lot...at least about the poster } List-Help: List-Post: List-Subscribe: ... List-Id: General discussion list for the Python programming language... List-Unsubscribe: List-Archive: ...and this would be the bulk of your help right here. I'm gonna guess that either you (or possibly someone else) went to mail.python.org/mailman and signed up to have newsgroup posts sent to your email. With me so far? Now, I've never used Gecko, nor did I find anything from Netscape to be stable on my Win32 box, but shouldn't it be able to display complete message headers? Here's that URL one more time, in case your mail client is bad at finding URLs... http://mail.python.org/mailman/listinfo/python-list And please watch your temper. One of my favorite things about this group is that it's not comp.lang.perl.misc where any response you would've gotten would be either far _more_ sarcastic, a furious rage, or just plain ignored. Have a nice day. -- -Tim Hammerquist God made the Idiot for practice, and then He made the School Board. -- Mark Twain From kc5tja at garnet.armored.net Mon Feb 26 20:07:18 2001 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 26 Feb 2001 11:07:18 -0800 Subject: take me off this god damn list References: Message-ID: On Sat, 24 Feb 2001 06:29:50 GMT, Tim Hammerquist wrote: >And please watch your temper. One of my favorite things about this >group is that it's not comp.lang.perl.misc where any response you >would've gotten would be either far _more_ sarcastic, a furious rage, or >just plain ignored. No, that title would have to go to comp.lang.lisp... -- KC5TJA/6, DM13, QRP-L #1447 | Official Channel Saint, *Team Amiga* Samuel A. Falvo II | Oceanside, CA | From slaurent at sonicfoundry.com Fri Feb 23 21:54:41 2001 From: slaurent at sonicfoundry.com (Sean Laurent) Date: Fri, 23 Feb 2001 14:54:41 -0600 Subject: win32com and makepy Message-ID: <88id9tgj54l5q8rgvtss4tc9u9k91kd0kn@4ax.com> Howdy All, I'm having a strange problem with win32com.client.Dispatch(). I used win32com\client\makepy.py to successfully generate Python sources. Unfortunately, after I call win32com.client.Dispatch(), the object I get back is of type "COMObject" instead of one of the generated classes. In particular, I'm trying to interact with Microsoft Windows Installer Service (known as MSI) - the typelibrary is named "Microsoft Windows Installer Object Library" and the PROGID is "WindowsInstaller.Installer". Using win32com\client\makepy.py: makepy -i "Microsoft Windows Installer Object Library" Microsoft Windows Installer Object Library {000C1092-0000-0000-C000-000000000046}, lcid=1033, major=1, minor=0 >>> # Use these commands in Python code to auto generate .py support >>> from win32com.client import gencache >>>gencache.EnsureModule('{000C1092-0000-0000-C000-000000000046}',1033, 1, 0) Looking in win32com\gen-py, the appropriate file _does_ exist: 000C1092-0000-0000-C000-000000000046x1033x1x0.py and it does contain the correct class definitions. Then, in my code: >>> i = win32com.client.Dispatch("WindowsInstaller.Installer") >>> i ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Voila! There's the problem. According to the docs, this really should be something more like: Furthermore, if I call a method which should create another object, things get even worse: >>> db = i.OpenDatabase("d:\\temp\\test.msi", 0) >>> db > ^^^^^^^^^^^^^^^^^^^^^ Again, this should be something more like: However, if I try this with Microsoft Word, everything works great! makepy -i "Microsoft Word 9.0 Object Library" Microsoft Word 9.0 Object Library {00020905-0000-0000-C000-000000000046}, lcid=0, major=8, minor=1 >>> # Use these commands in Python code to auto generate .py support >>> from win32com.client import gencache >>> gencache.EnsureModule('{00020905-0000-0000-C000-000000000046}', 0, 8, 1) >>> w = win32com.client.Dispatch("Word.Application") >>> w *arrrgghhh* Any bright ideas as to what's going wrong here? ---------- Sean Laurent Engineer -Install Sonic Foundry, Inc. slaurentNOSPAM at sonicfoundryNOSPAM.com ---------- From MarkH at ActiveState.com Sat Feb 24 02:44:27 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sat, 24 Feb 2001 01:44:27 GMT Subject: win32com and makepy References: <88id9tgj54l5q8rgvtss4tc9u9k91kd0kn@4ax.com> Message-ID: <3A97111F.9050705@ActiveState.com> Sean Laurent wrote: > Howdy All, > I'm having a strange problem with win32com.client.Dispatch(). I used > win32com\client\makepy.py to successfully generate Python sources. > Unfortunately, after I call win32com.client.Dispatch(), the object I > get back is of type "COMObject" instead of one of the generated > classes. This comes up fairly regularly, and unfortunately it depends on the object in question. The simplest work around is to use the classes in that generated module directly. Eg: mod = gencache.EnsureModule('{000C1092-0000-0000-C000-000000000046}',1033, 1, 0) i = mod.WhateverTheClassNameIs() And to make life more painful: >>>> db = i.OpenDatabase("d:\\temp\\test.msi", 0) Will need to done like: db = i.OpenDatabase("d:\\temp\\test.msi", 0) db = mod.Database(db) # Assuming "Database" is the class name Mark. From slaurent at sonicfoundry.com Sat Feb 24 04:49:25 2001 From: slaurent at sonicfoundry.com (Sean Laurent) Date: Fri, 23 Feb 2001 21:49:25 -0600 Subject: win32com and makepy References: <88id9tgj54l5q8rgvtss4tc9u9k91kd0kn@4ax.com> <3A97111F.9050705@ActiveState.com> Message-ID: <1r8e9tc3jn5pi734ldi4r3ikr3bhnudvgb@4ax.com> On Sat, 24 Feb 2001 01:44:27 GMT, Mark Hammond wrote: >> I'm having a strange problem with win32com.client.Dispatch(). I used >> win32com\client\makepy.py to successfully generate Python sources. >> Unfortunately, after I call win32com.client.Dispatch(), the object I >> get back is of type "COMObject" instead of one of the generated >> classes. > >This comes up fairly regularly, and unfortunately it depends on the object in question. > >The simplest work around is to use the classes in that generated module directly. Eg: > >mod = gencache.EnsureModule('{000C1092-0000-0000-C000-000000000046}',1033, 1, 0) > >i = mod.WhateverTheClassNameIs() > >And to make life more painful: > >>>>> db = i.OpenDatabase("d:\\temp\\test.msi", 0) > >Will need to done like: > >db = i.OpenDatabase("d:\\temp\\test.msi", 0) >db = mod.Database(db) # Assuming "Database" is the class name Ah hah! *light bulb goes off* Interestingly enough, I tried: >>>> i = mod.Installer() then I tried: >>>> db = i.OpenDatabase( ... ) At this point, "db" _is_ the correct type - no need to do: >>>> db = mod.Database(db) All things considered, this isn't any more painful than calling client.Dispatch(). I finally took a look at your "Advanced Python and COM" presentation from the 8th International Python Conference... and it seems that the following is also a viable alternative: >>>> gencache.EnsureModule(blahblahblah) >>>> klass = gencache.GetClassForProgID(blah) >>>> i = klass() >>>> db = i.OpenDatabase(blahblah) The only advantage to that technique (in my mind), is that it is indepedent of the actual class name in the cached module. In reality, I suppose there isn't any need to be independent of the class name. If Microsoft (in their infinite wisdom) changes the structure of the type library such that the class name changes... they would probably also change enough other stuff that the whole script would have to be reworked anyway. As a side note, I'm still puzzled as to why the original code didn't work: >>>> gencache.EnsureModule(blahblah) >>>> i = win32com.client.Dispatch("WindowsInstaller.Installer") I spent some time stepping through the code and I found that the code was bailing in win32com.client.dynamic._GetGoodDispatch() at the line reading: IDispatch = pythoncom.connect(IDispatch) com_error: (-2147221021, 'Operation unavailable', None, None) So, I decided to spoonfeed the call to Dispatch and hand it the classID of the interface in question. I cut and paste the ClassID directly from the script generated by makepy. With this, I followed the debugger to __WrapDispatch() in win32com.client.__init__, where it called: klass = gencache.GetClassForCLSID(resultCLSID) Looking at gencache.GetClassForCLSID(), it calls CLSIDToClass.HasClass(). And this is where things suddenly became interesting. Through the debugger I looked at the entries in the mapCLSIDToClass dictionary - indeed there were a _number_ of entries, but not the CLSID I needed. At this point, I sat down with OLEVIEW and I discovered something interesting. The generated code set a CLSID of: {000C1092-0000-0000-C000-000000000046} While this is the ID of the type library, it is neither the CLSIDnor the AppID (which carry the same value) for the actual "Microsoft Windows Installer" object. Unfortunately, this turned out to be a dead end - I tried changing the ClassID in the generated file, but this didn't help. (As you may have already guessed!) The other bizarre thing I found was in __WrapDispatch() in win32com.client.__init__. In this function, you find the following code: if resultCLSID is None: try: typeinfo = dispatch.GetTypeInfo() In this case, we don't have a CLSID, so this code gets called. Yet it bails with: "com_error: (-2147467262, 'No such interface supported', None, None)" which seems a bit bizarre, since dispatch is of type PyIDispatch - which should support this method... Any thoughts? Am I beating a dead horse? Or what's the word? -Sean Laurent- From MarkH at ActiveState.com Sat Feb 24 15:58:33 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sat, 24 Feb 2001 14:58:33 GMT Subject: win32com and makepy References: <88id9tgj54l5q8rgvtss4tc9u9k91kd0kn@4ax.com> <3A97111F.9050705@ActiveState.com> <1r8e9tc3jn5pi734ldi4r3ikr3bhnudvgb@4ax.com> Message-ID: <3A97CB3E.30204@ActiveState.com> Sean Laurent wrote: > As a side note, I'm still puzzled as to why the original code didn't > work: > >>>> gencache.EnsureModule(blahblah) > >>>> i = win32com.client.Dispatch("WindowsInstaller.Installer") > > I spent some time stepping through the code and I found that the code > was bailing in win32com.client.dynamic._GetGoodDispatch() at the line > reading: > IDispatch = pythoncom.connect(IDispatch) > > com_error: (-2147221021, 'Operation unavailable', None, None) This should be fine - we then go and try the CoCreateInstance route and end up down the same path you traced. > The other bizarre thing I found was in __WrapDispatch() in > win32com.client.__init__. In this function, you find the following > code: > if resultCLSID is None: > try: > typeinfo = dispatch.GetTypeInfo() > > In this case, we don't have a CLSID, so this code gets called. Yet it > bails with: "com_error: (-2147467262, 'No such interface supported', > None, None)" which seems a bit bizarre, since dispatch is of type > PyIDispatch - which should support this method... This is the crux of the whole problem. The object implements GetTypeInfo, but just fails to provide it. If this was available, then win32com would be able to find the CLSID of the object, and get the makepy generated class. > Any thoughts? Am I beating a dead horse? Pretty much I fear - at least until MS upgrade their interfaces. Mark. -- Nominate Your Favorite Programmers for the Perl and Python Active Awards! http://www.ActiveState.com/Awards/ From slaurent at sonicfoundry.com Mon Feb 26 19:32:18 2001 From: slaurent at sonicfoundry.com (Sean Laurent) Date: Mon, 26 Feb 2001 12:32:18 -0600 Subject: win32com and makepy References: <88id9tgj54l5q8rgvtss4tc9u9k91kd0kn@4ax.com> <3A97111F.9050705@ActiveState.com> <1r8e9tc3jn5pi734ldi4r3ikr3bhnudvgb@4ax.com> <3A97CB3E.30204@ActiveState.com> Message-ID: <338l9tsq0ti17s22aitjdh2e19lm6m3l0a@4ax.com> On Sat, 24 Feb 2001 14:58:33 GMT, Mark Hammond wrote: >This is the crux of the whole problem. The object implements GetTypeInfo, but just fails >to provide it. If this was available, then win32com would be able to find the CLSID of the >object, and get the makepy generated class. > >> Any thoughts? Am I beating a dead horse? > >Pretty much I fear - at least until MS upgrade their interfaces. D'oh! As a developer, why do I I always find myself boxed into some corner or forced to come up with workarounds just because Micro$oft doesn't do something correctly? *ugh* Well, your kludge (described in an earlier message) is very beneficial and solves the problem. I greatly appreciate the help! ---------- Sean Laurent Engineer -Install Sonic Foundry, Inc. From lbates at syscon-computers.com Sat Feb 24 00:42:38 2001 From: lbates at syscon-computers.com (Larry Bates) Date: Fri, 23 Feb 2001 17:42:38 -0600 Subject: _winreg - Windows registry access Message-ID: <3a96f575$1@news.dbtech.net> I'm a newbie, so please forgive me. Does anyone have any example code on how to use the new _winreg class? I've tried everything that makes sense, but nothing seems to work. Examples sure go a long way when you are learning. Thanks in advance for any assistance. -Larry From MarkH at ActiveState.com Sat Feb 24 15:45:42 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sat, 24 Feb 2001 14:45:42 GMT Subject: _winreg - Windows registry access References: <3a96f575$1@news.dbtech.net> Message-ID: <3A97C83A.2050807@ActiveState.com> Larry Bates wrote: > I'm a newbie, so please forgive me. Does anyone have any example code on > how to use the new _winreg class? I've tried everything that makes sense, > but > nothing seems to work. Examples sure go a long way when you are learning. Here is a really simple one: >>> import _winreg, sys >>> key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "Software\\Python\\PythonCore\\" + sys.winver + "\\PythonPath") >>> _winreg.QueryValue(key, "") 'f:\\src\\python-cvs\\lib;f:\\src\\python-cvs\\pcbuild' >>> _winreg.EnumKey(key, 0) 'Pythonwin' >>> _winreg.EnumKey(key, 1) 'win32' >>> This shows the default PythonPath for my current version, and shows that I have at least 2 keys under this, called "Pythonwin" and "win32". It doesnt show the values for these 2 subkeys. Mark. -- Nominate Your Favorite Programmers for the Perl and Python Active Awards! http://www.ActiveState.com/Awards/ From jcollins at endeavors.com Sat Feb 24 01:29:48 2001 From: jcollins at endeavors.com (Jeff Collins) Date: Fri, 23 Feb 2001 16:29:48 -0800 Subject: [ANN] Pippy: Python for the Palm Message-ID: <20010223162948.B9773@endeavors.com> We are pleased to announce the 0.6b release of Pippy, a port of Python to the Palm. Those interested in creating Python-based applications for Palm handheld computers and other devices that use the Palm operating system will find this to be an excellent VM. For more information, please see http://www.endeavors.com/pippy. -- Jeffery D. Collins, Ph.D. Sr. Software Developer Endeavors Technology, Inc. http://www.endeavors.com From noahnoah.org Sat Feb 24 02:09:48 2001 From: noahnoah.org (Noah Spurrier (a)) Date: 24 Feb 2001 01:09:48 GMT Subject: Need to unread or push back bytes to a file Message-ID: <9771ks0ic2@news2.newsguy.com> I need to push bytes back into a file object. Is there a buffered file wrapper for file objects? (Yes, I looked, but I gave up after almost five minutes of searching.) I'm reading from a pipe, but this could be the same for a file. I call an "expect" method which reads until a pattern is found, but read() with a pipe will read as much data as there is available in the pipe. When I have found a pattern match I want to return the stream with the extra character pushed-back. Another way to word this is that I want to the of a pattern, but not past the pattern. My only other option would be to read(1) character at a time and then search for the pattern. This will work, but I think a push-back would be more elegant and efficient. Yours, Noah ================================== Posted via http://nodevice.com Linux Programmer's Site From aleaxit at yahoo.com Sat Feb 24 10:25:27 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 24 Feb 2001 10:25:27 +0100 Subject: Need to unread or push back bytes to a file References: <9771ks0ic2@news2.newsguy.com> Message-ID: <977ukk0uvd@news1.newsguy.com> "Noah Spurrier" wrote in message news:9771ks0ic2 at news2.newsguy.com... > > > I need to push bytes back into a file object. > Is there a buffered file wrapper for file objects? > (Yes, I looked, but I gave up after almost five minutes of searching.) > > I'm reading from a pipe, but this could be the same for a file. > I call an "expect" method which reads until a pattern is found, > but read() with a pipe will read as much data as there is available > in the pipe. When I have found a pattern match I want to return > the stream with the extra character pushed-back. what about something like: class NSWrapper: def __init__(self, fileob): self.fileob = fileob self.buffer = '' def close(self): self.fileob.close() self.buffer = '' def push_back(self, piece): self.buffer = piece + self.buffer def readall(self): result = self.buffer + self.fileob.read() self.buffer = '' return result def read(self, N=None): if N is None: return self.readall() avail = len(self.buffer) if N>avail: result = self.buffer+file.read(N-avail) self.buffer = '' else: result = self.buffer[:N] self.buffer = self.buffer[N:] return result needs testing, but this should be roughly what you want...? Alex From noahnoah.org Sat Feb 24 21:03:34 2001 From: noahnoah.org (Noah Spurrier (a)) Date: 24 Feb 2001 20:03:34 GMT Subject: Need to unread or push back bytes to a file References: <977ukk0uvd@news1.newsguy.com> Message-ID: <97942m02njh@news1.newsguy.com> Yeah, this looks good. I was hoping there was a way to do it using some included library. Also, this shows why file should be a first class object! This class would be so much easier if we could just inherit from file. I want to make sure that my new object can be used anywhere a file is normally expected. As it currently stands, I will have to provide wrapper implementations for every method that file supports; about 12 methods in all. I don't know how to wrap the file objects read-only attributes. Does seek() and tell() make sense in this type of file? At the end I added an expanded version of the class wrapper. Yours, Noah class NSWrapper: # I don't know how to wrap these read-only attributes: # closed # mode # name # softspace def __init__(self, fileob): self.fileob = fileob self.buffer = '' def close (self): self.fileob.close() self.buffer = '' def flush (self): self.fileob.flush() def isatty (self): return self.fileob.isatty() def fileno (self): return self.fileob.fileno() def push_back(self, piece): self.buffer = piece + self.buffer def readall(self): result = self.buffer + self.fileob.read() self.buffer = '' return result def read (self, size=-1): if size <= -1: return self.readall() avail = len(self.buffer) if size > avail: result = self.buffer+file.read(size-avail) self.buffer = '' else: result = self.buffer[:size] self.buffer = self.buffer[size:] return result def readline (self, size=-1): return self.fileob.readline(size) def readlines (self, sizehint=-1): return self.fileob.readlines (sizehint) #!!! Some methods don't make sense on a stream. #def seek (self, offset, whence=0): # self.fileob.seek (offset, whence) #def tell (self): # return self.fileob.tell() #def truncate (self, size=-1): # self.fileob.truncate(size) def write (self, str): self.fileob.write(str) def writelines (self, list): self.fileob.writelines(list) > "Noah Spurrier" wrote in message > news:9771ks0ic2 at news2.newsguy.com... > > > > > > I need to push bytes back into a file object. > > Is there a buffered file wrapper for file objects? > > ... > what about something like: > > class NSWrapper: > def __init__(self, fileob): > ... > needs testing, but this should be roughly what you want...? > Alex ================================== Posted via http://nodevice.com Linux Programmer's Site From duke at radix.net Sat Feb 24 04:35:24 2001 From: duke at radix.net (Pastor Duke) Date: Fri, 23 Feb 2001 22:35:24 -0500 Subject: where to learn python programing Message-ID: <9778so$725$1@news1.Radix.Net> Greetings, I'm very interested in learning Python programming as I'm a 3D graphics designer, and want to develop some games. Thanks, Duke From parkw at better.net Sat Feb 24 04:34:30 2001 From: parkw at better.net (William Park) Date: Fri, 23 Feb 2001 22:34:30 -0500 Subject: where to learn python programing In-Reply-To: <9778so$725$1@news1.Radix.Net>; from duke@radix.net on Fri, Feb 23, 2001 at 10:35:24PM -0500 References: <9778so$725$1@news1.Radix.Net> Message-ID: <20010223223430.A599@better.net> On Fri, Feb 23, 2001 at 10:35:24PM -0500, Pastor Duke wrote: > Greetings, > I'm very interested in learning Python programming as I'm a 3D graphics > designer, and want to develop some games. Standard answer is Tutorial which is part of standard docs. ---William Park, Open Geometry Consulting From wware at world.std.com Sat Feb 24 13:23:09 2001 From: wware at world.std.com (Will Ware) Date: Sat, 24 Feb 2001 12:23:09 GMT Subject: where to learn python programing References: <9778so$725$1@news1.Radix.Net> Message-ID: On Fri, Feb 23, 2001 at 10:35:24PM -0500, Pastor Duke wrote: > I'm very interested in learning Python programming as I'm a 3D graphics > designer, and want to develop some games. William Park (parkw at better.net) wrote: > Standard answer is Tutorial which is part of standard docs. You can find this on-line at: http://www.python.org/doc/current/tut/tut.html Other useful stuff here, including the Library Reference: http://www.python.org/doc/current/ -- -----------------------------------+--------------------- 22nd century: Esperanto, geodesic | Will Ware domes, hovercrafts, metric system | wware at world.std.com From bencr at bigpond.com Sat Feb 24 14:41:25 2001 From: bencr at bigpond.com (Ben) Date: Sun, 25 Feb 2001 00:41:25 +1100 Subject: where to learn python programing References: <9778so$725$1@news1.Radix.Net> Message-ID: Try www.andamooka.org for a intro to Programming in Python ... Without being aware of your intentions ... are you sure that Python is a suitable programming language for implementing 3D games??? ... you should also take a look at a couple of existing engines (quake 3, Unreal Tournament and Lithtech to name the most common) ... as some of these allow a high level API without needing to invest in a licensing agreement .... "William Park" wrote in message news:mailman.982985707.26846.python-list at python.org... > On Fri, Feb 23, 2001 at 10:35:24PM -0500, Pastor Duke wrote: > > Greetings, > > I'm very interested in learning Python programming as I'm a 3D graphics > > designer, and want to develop some games. > > Standard answer is Tutorial which is part of standard docs. > > ---William Park, Open Geometry Consulting > From al053162 at anubis.uji.es Sat Feb 24 14:07:13 2001 From: al053162 at anubis.uji.es (LANCELOT) Date: Sat, 24 Feb 2001 14:07:13 +0100 Subject: =?ISO-8859-1?Q?Espa=F1ol_=2F_Spanish?= In-Reply-To: References: <9778so$725$1@news1.Radix.Net> Message-ID: Este es un mensaje en espa?ol / This is a message in Spanish: Buenas, Acabo de conocer este grupo de noticias, que no se de donde es, pero me he dado cuenta de que todos hablais en ingles. Hay alguien que hable espa?ol? Me gustaria poder hablar de Python con alguien que hable en espa?ol, porque necesito informacion y la busco en espa?ol. Gracias. Saludos. PD: Does anybody know anything of Python in Spanish? Thank you. From alan.gauld at gssec.bt.co.uk Mon Feb 26 17:47:46 2001 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Mon, 26 Feb 2001 16:47:46 +0000 Subject: =?iso-8859-1?Q?Espa=F1ol?= / Spanish References: <9778so$725$1@news1.Radix.Net> Message-ID: <3A9A88B2.D9316AFC@gssec.bt.co.uk> LANCELOT wrote: > Acabo de conocer este grupo de noticias, que no se de donde es, pero me > he dado cuenta de que todos hablais en ingles. Hay alguien que hable > espa?ol? Me gustaria poder hablar de Python con alguien que hable en > espa?ol, porque necesito informacion y la busco en espa?ol. Gracias. > > Saludos. > > PD: Does anybody know anything of Python in Spanish? Thank you. Absolute beginners tutorial: http://www.crosswinds.net/~agauld/spanish Also in progress in Portuguese and German.... http://www.crosswinds.net/~agauld/port http://www.crosswinds.net/~agauld/german Alan G. From piet at cs.uu.nl Mon Feb 26 20:13:36 2001 From: piet at cs.uu.nl (Piet van Oostrum) Date: 26 Feb 2001 20:13:36 +0100 Subject: =?iso-8859-1?q?Espa=F1ol?= / Spanish References: <9778so$725$1@news1.Radix.Net> <3A9A88B2.D9316AFC@gssec.bt.co.uk> Message-ID: >>>>> Alan Gauld (AG) writes: AG> LANCELOT wrote: >> Acabo de conocer este grupo de noticias, que no se de donde es, pero me >> he dado cuenta de que todos hablais en ingles. Hay alguien que hable >> espa?ol? Me gustaria poder hablar de Python con alguien que hable en >> espa?ol, porque necesito informacion y la busco en espa?ol. Gracias. >> >> Saludos. >> >> PD: Does anybody know anything of Python in Spanish? Thank you. AG> Absolute beginners tutorial: AG> http://www.crosswinds.net/~agauld/spanish AG> Also in progress in Portuguese and German.... AG> http://www.crosswinds.net/~agauld/port AG> http://www.crosswinds.net/~agauld/german THE Python tutorial is also available in Spanish: http://www.zope.org/Members/rapto/tut But he wanted to discuss about python in Spanish. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From mfletch at tpresence.com Sat Feb 24 05:14:33 2001 From: mfletch at tpresence.com (Mike Fletcher) Date: Fri, 23 Feb 2001 23:14:33 -0500 Subject: Unix's Zoo of Languages (Eric Raymond) Message-ID: http://www.tuxedo.org/~esr/writings/taoup/chapter3.html Just thought some of those who like jousting in the lists of language tournaments might find that chapter interesting. I'd have liked some deeper coverage of Ruby (which I rather like the look of as I read the new book, but feel no desire to learn when I actually sit down to it) and Squeak, but overall it's a fairly balanced feeling overview of the languages available to the Unix person. Would have been nice to include something of IDE comparisons (GUI development and the like), but oh well. The PSU's bribe money is obviously well spent ;) , Sun should learn something from them :) . Enjoy yourselves, Mike __________________________________ Mike C. Fletcher Designer, VR Plumber http://members.home.com/mcfletch From thomas at xs4all.net Sat Feb 24 05:20:46 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sat, 24 Feb 2001 05:20:46 +0100 Subject: Unix's Zoo of Languages (Eric Raymond) In-Reply-To: ; from mfletch@tpresence.com on Fri, Feb 23, 2001 at 11:14:33PM -0500 References: Message-ID: <20010224052046.G16781@xs4all.nl> On Fri, Feb 23, 2001 at 11:14:33PM -0500, Mike Fletcher wrote: > http://www.tuxedo.org/~esr/writings/taoup/chapter3.html > The PSU's bribe money is obviously well spent ;) , Sun should learn > something from them :) . Well, considering Eric is a valued member of the python-dev team, I'm not sure if that organization was actually involved. I hear they screen quite vigorously before you're allowed in python-dev, not to mention the screening and full body cavity search you get when being considered for bribing by the P From mfletch at tpresence.com Sun Feb 25 00:54:41 2001 From: mfletch at tpresence.com (Mike Fletcher) Date: Sat, 24 Feb 2001 18:54:41 -0500 Subject: Unix's Zoo of Languages (Eric Raymond) Message-ID: Drat it! How many times do I have to tell them, it's no use if you just buy them outright, take them into the inner chambers and tell the world they're there (it's not like anyone would know, after all, who really knows what happens behind closed doors). It wrecks their credibility as a hostile witness. They have to appear unbiased and free to make their own decisions. When we take Torvalds and Gates** we'll need to make sure they don't get seen hanging out in the Cabal's meeting rooms (-dev) so we can use them to sink the other languages. Though, come to think of it, Python in the kernal would be nice... Mike ** Yes, Gates, we need to take over Windows too. -----Original Message----- From: Thomas Wouters [mailto:thomas at xs4all.net] ... Well, considering Eric is a valued member of the python-dev team, I'm not sure if that organization was actually involved. I hear they screen quite vigorously before you're allowed in python-dev, not to mention the screening and full body cavity search you get when being considered for bribing by the P ... From vasvir at iit.demokritos.gr Sat Feb 24 06:54:56 2001 From: vasvir at iit.demokritos.gr (Vassilis Virvilis) Date: Sat, 24 Feb 2001 07:54:56 +0200 Subject: abusing __builtins__ Message-ID: <3A974CB0.EA7B0356@iit.demokritos.gr> In python 1.5.2 (and possible to any future python) is possible to set a global variable shared by all modules simply by doing: setattr(__builtins__, 'GlobalVariable', GlobalVariable) without the need to import anything. Not being an experienced python programmer I would like ot hear some arguments on whether this is considered abuse of the language or not. Should it be avoided? Are there any hidden pitfalls? except from the obvious one that I should not have global variables in the first place. Thanks in advance... .Bill From nas at arctrix.com Sat Feb 24 07:17:42 2001 From: nas at arctrix.com (Neil Schemenauer) Date: Fri, 23 Feb 2001 22:17:42 -0800 Subject: abusing __builtins__ In-Reply-To: <3A974CB0.EA7B0356@iit.demokritos.gr>; from vasvir@iit.demokritos.gr on Sat, Feb 24, 2001 at 07:54:56AM +0200 References: <3A974CB0.EA7B0356@iit.demokritos.gr> Message-ID: <20010223221742.A24805@glacier.fnational.com> On Sat, Feb 24, 2001 at 07:54:56AM +0200, Vassilis Virvilis wrote: > setattr(__builtins__, 'GlobalVariable', GlobalVariable) So simple yet so evil. You should win a prize. Neil From tim.one at home.com Mon Feb 26 00:08:35 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 25 Feb 2001 18:08:35 -0500 Subject: abusing __builtins__ In-Reply-To: <3A974CB0.EA7B0356@iit.demokritos.gr> Message-ID: [Vassilis Virvilis] > In python 1.5.2 (and possible to any future python) is possible to set a > global variable shared by all modules simply by doing: > > setattr(__builtins__, 'GlobalVariable', GlobalVariable) > > without the need to import anything. Cute! > Not being an experienced python programmer I would like ot hear some > arguments on whether this is considered abuse of the language or not. > Should it be avoided? Are there any hidden pitfalls? except from the > obvious one that I should not have global variables in the first place. The language doesn't guarantee this will always work, so it's certainly abuse. Looking up builtins is slower than looking up module globals (a module's global dict is always searched before the builtin dict). The language may someday make "GlobalVariable" the name of its own builtin, and then your code won't work correctly if you either try to use the new builtin or call any other module that does (incl. without limitation std library modules). People other than you will be unable to understand your code regardless, because GlobalVariable will look to them like an unbound variable (i.e., nobody else uses this trick, so nobody else will recognize the usage pattern). Introspective tools won't think to look in the builtins either (again because nobody else etc). i-wouldn't-let-any-of-that-stop-me-though-ly y'rs - tim From thomas at xs4all.net Mon Feb 26 00:16:54 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 26 Feb 2001 00:16:54 +0100 Subject: abusing __builtins__ In-Reply-To: ; from tim.one@home.com on Sun, Feb 25, 2001 at 06:08:35PM -0500 References: <3A974CB0.EA7B0356@iit.demokritos.gr> Message-ID: <20010226001653.J16781@xs4all.nl> On Sun, Feb 25, 2001 at 06:08:35PM -0500, Tim Peters wrote: > People other than you will be unable to understand your code regardless, > because GlobalVariable will look to them like an unbound variable (i.e., > nobody else uses this trick, so nobody else will recognize the usage > pattern). Actually, Mailman used this trick for a while. Not in any release, though, and Barry removed the ugly hack a week or two ago. Not sure if it was originally Barry's idea, or just part of the internationalization patch he accepted. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From mfletch at tpresence.com Mon Feb 26 02:47:27 2001 From: mfletch at tpresence.com (Mike Fletcher) Date: Sun, 25 Feb 2001 20:47:27 -0500 Subject: abusing __builtins__ Message-ID: I've used this extensively in one (very large) in-house demo I created, I used builtins.APPLICATION to refer to a global application object. Was very simple and useful. Yes, a hack, but I considered it a rather nice hack. Apparently this is another of those "you're wrong, Mike, just plain wrong" things :) . I seem to get more and more of those these days, Mike -----Original Message----- From: Thomas Wouters [mailto:thomas at xs4all.net] Sent: Sunday, February 25, 2001 6:17 PM To: python-list at python.org Subject: Re: abusing __builtins__ On Sun, Feb 25, 2001 at 06:08:35PM -0500, Tim Peters wrote: > People other than you will be unable to understand your code regardless, > because GlobalVariable will look to them like an unbound variable (i.e., > nobody else uses this trick, so nobody else will recognize the usage > pattern). Actually, Mailman used this trick for a while. Not in any release, though, and Barry removed the ugly hack a week or two ago. Not sure if it was originally Barry's idea, or just part of the internationalization patch he accepted. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! -- http://mail.python.org/mailman/listinfo/python-list From root at rainerdeyke.com Mon Feb 26 03:48:30 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 26 Feb 2001 02:48:30 GMT Subject: abusing __builtins__ References: Message-ID: <2ujm6.305444$ge4.105940925@news2.rdc2.tx.home.com> "Mike Fletcher" wrote in message news:mailman.983152087.5110.python-list at python.org... > I've used this extensively in one (very large) in-house demo I created, I > used builtins.APPLICATION to refer to a global application object. Was very > simple and useful. Yes, a hack, but I considered it a rather nice hack. > Apparently this is another of those "you're wrong, Mike, just plain wrong" > things :) . For the record, I think this hack has its uses, especially in non-Python programs that embed Python as a scripting language. I don't use it myself, though. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From vasvir at iit.demokritos.gr Mon Feb 26 06:50:35 2001 From: vasvir at iit.demokritos.gr (Vassilis Virvilis) Date: Mon, 26 Feb 2001 07:50:35 +0200 Subject: abusing __builtins__ References: Message-ID: <3A99EEAB.C756064C@iit.demokritos.gr> Tim Peters wrote: > Cute! > > > The language doesn't guarantee this will always work, so it's certainly > abuse. Oups! That's the killer argument here. > > Looking up builtins is slower than looking up module globals (a module's > global dict is always searched before the builtin dict). certainly > The language may someday make "GlobalVariable" the name of its own builtin, > and then your code won't work correctly if you either try to use the new > builtin or call any other module that does (incl. without limitation std > library modules). This I don't get it. Why is that? GlobalVariable is just a name to indicate the purpose of my variable. If a newer version of python use it in a later stage as a reversed word (__builtins__ variable or function), then obviously my old program won't be able to use the new functionality but it will overwrite it happily. So it would work even then. Consider the following imaginary example. In a project where there is no need to open files one replaces the open function. So this project will never manage to open a file but aside from that it will continue to work as designed. > People other than you will be unable to understand your code regardless, > because GlobalVariable will look to them like an unbound variable (i.e., > nobody else uses this trick, so nobody else will recognize the usage > pattern). > > Introspective tools won't think to look in the builtins either (again > because nobody else etc). > Valid points too. Thank you and everybody else for your answers. I think I will try to avoid that trick anyway. .Bill From tim.one at home.com Mon Feb 26 07:36:47 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 26 Feb 2001 01:36:47 -0500 Subject: abusing __builtins__ In-Reply-To: <3A99EEAB.C756064C@iit.demokritos.gr> Message-ID: [Tim] >> The language may someday make "GlobalVariable" the name of its >> own builtin,> and then your code won't work correctly if you >> either try to use the new builtin or call any other module that >> does (incl. without limitation std library modules). [Vassilis Virvilis] > This I don't get it. Why is that? I think because you're reading it the opposite of the way it's written : I'm not saying you can't get at *your* meaning of the name anymore, but that the *new* meaning gets masked (because you've overwritten it). > ... > Consider the following imaginary example. In a project where there is no > need to open files one replaces the open function. So this project will > never manage to open a file but aside from that it will continue to work > as designed. Very dangerous. It's virtually impossible to write a substantial Python program without invoking at least some of the std libraries. And you simply can't know whether *those* will use "open" across releases. If they do, they certainly aren't expecting to get *your* meaning of the name, they're expecting the builtin meaning. There are uses for that, though. For example, on rare occasions and for debugging purposes, I've replaced the builtin open with my own version that logs the name of the file being opened along with a timestamp. In that case, it's "a feature" that the std libraries also see my redefined version. That was a lifesaver at least once, and it's way cool that Python let me get away with it. It's never meant to be a permanent thing, though. That's OK by Python: it generally supports all the sickness you can inflict on yourself, provided only that you agree in advance that you're in a state of sin and won't complain if you're later condemned for it . guido-makes-a-nice-living-selling-indulgences-on-the-side-ly y'rs - tim From thomas at xs4all.net Mon Feb 26 07:56:31 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 26 Feb 2001 07:56:31 +0100 Subject: abusing __builtins__ In-Reply-To: ; from tim.one@home.com on Mon, Feb 26, 2001 at 01:36:47AM -0500 References: <3A99EEAB.C756064C@iit.demokritos.gr> Message-ID: <20010226075631.L16781@xs4all.nl> On Mon, Feb 26, 2001 at 01:36:47AM -0500, Tim Peters wrote: > guido-makes-a-nice-living-selling-indulgences-on-the-side-ly y'rs - tim Actually, I thought he just gave them away for free. Free sampling, and all that. And then when he takes them away, you have to get him (or one of his cowboys ) to fix it -- and that's the part that costs! :) I know it cost me two keyboards the past month <0.9 wink>. Just-say-no-ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From jkraska1 at san.rr.com Mon Feb 26 07:48:08 2001 From: jkraska1 at san.rr.com (Courageous) Date: Mon, 26 Feb 2001 06:48:08 GMT Subject: abusing __builtins__ References: <3A99EEAB.C756064C@iit.demokritos.gr> Message-ID: >> The language doesn't guarantee this will always work, so it's certainly >> abuse. > >Oups! That's the killer argument here. Well, not to worry. It works now, as you've noticed. :) C// From thomas at xs4all.net Mon Feb 26 07:53:22 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 26 Feb 2001 07:53:22 +0100 Subject: abusing __builtins__ In-Reply-To: <3A99EEAB.C756064C@iit.demokritos.gr>; from vasvir@iit.demokritos.gr on Mon, Feb 26, 2001 at 07:50:35AM +0200 References: <3A99EEAB.C756064C@iit.demokritos.gr> Message-ID: <20010226075322.K16781@xs4all.nl> On Mon, Feb 26, 2001 at 07:50:35AM +0200, Vassilis Virvilis wrote: > > The language may someday make "GlobalVariable" the name of its own builtin, > > and then your code won't work correctly if you either try to use the new > > builtin or call any other module that does (incl. without limitation std > > library modules). > This I don't get it. Why is that? GlobalVariable is just a name to > indicate the purpose of my variable. If a newer version of python use it > in a later stage as a reversed word (__builtins__ variable or function), > then obviously my old program won't be able to use the new functionality > but it will overwrite it happily. So it would work even then. First off, entries in builtin aren't "reserved words" as such. This is quite a subtle difference, but an important one none the less. Reserved words are very limited in Python, and I believe none were added since Python 1.0, when 'lambda' was put in at the very last moment. In fact, in Python 1.4, a formerly reserved word ('access') was removed ! :) Reserved words are reserved specifically for statements and special syntax. Reserved words are part of the grammar of the language, and can't be used as variable names or (in CPython) other places that need a name (like def, class, attribute setting/getting, etc.) This is why (in CPython) you can't even have a method called 'print', 'def' or 'class'. (If you want to know why: it's a flaw in the parser/tokenizer. Feel free to fix it and submit a patch!) Builtin functions and variables are a different story, however. They are just conveniency names, are searched as a 'last resort', and are perfectly permissible as variable names wherever you want them. If you use a name that is defined in the builtins namespace as a local or global variable, nothing weird happens. You lose access to the builtin from that function or module (respectively), but since you wrote the code yourself, you are probably not using it anyway. Other functions and modules don't notice or care that you're shadowing the builtin function in your function or module. (The masking of globals is one of the reasons why 'from module import *' is generally a bad idea even on the module level.) But if you add an entry into builtins, and later a builtin of that name gets added, you will replace the builtin function with your own, probably completely different function. All functions and modules will notice this. And whenever your code, which expects 'GlobalVariable' to be your specific function/variable, imports/execs code that expects 'GlobalVariable' to be the new builtin funtion, you end up with weird errors (at best) or very weird behaviour (if your code doesn't throw an exception.) And especially the standard library has a very good chance to already be using the new 'GlobalVariable' builtin function, since it's released at the same time as the source, and is expected to work only with the Python version it's released with. > Consider the following imaginary example. In a project where there is no > need to open files one replaces the open function. So this project will > never manage to open a file but aside from that it will continue to work > as designed. This is a different situation entirely! As long as you provide the same interface for the function you are replacing, and *intend* for it to replace the normal 'open' call, there is no problem. You might run into a problem in the future, though, when builtins becomes unwritable. (Which, for all we know, might happen in Python 2.3 -- but not without warnings first :) If you really want this, though, you should consider using something like Bastion: run your code in a shielded environment with some builtins/modules removed or wrapped in protective functions. Readability-is-still-the-best-argument-ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From tanzer at swing.co.at Mon Feb 26 08:58:42 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Mon, 26 Feb 2001 08:58:42 +0100 Subject: abusing __builtins__ In-Reply-To: Your message of "Mon, 26 Feb 2001 07:53:22 +0100." <20010226075322.K16781@xs4all.nl> Message-ID: Thomas Wouters wrote: > > Consider the following imaginary example. In a project where there is no > > need to open files one replaces the open function. So this project will > > never manage to open a file but aside from that it will continue to work > > as designed. > > This is a different situation entirely! As long as you provide the same > interface for the function you are replacing, and *intend* for it to replace > the normal 'open' call, there is no problem. You might run into a problem in > the future, though, when builtins becomes unwritable. (Which, for all we > know, might happen in Python 2.3 -- but not without warnings first :) I sure hope that won't happen. Sometimes there are pretty good reasons to augment builtins. For instance, I recently implemented a Class_Proxy. To make Class_Proxy instances fully compatible with the classes they proxy, I used: ############################################################################### def _fix_builtins () : import __builtin__ def isinstance (object, C, isinstance = __builtin__.isinstance) : if hasattr (C, "_Class") : C = C._Class return isinstance (object, C) isinstance.__doc__ = __builtin__.isinstance.__doc__ __builtin__.isinstance = isinstance def issubclass (C, B, issubclass = __builtin__.issubclass) : if hasattr (C, "_Class") : C = C._Class if hasattr (B, "_Class") : B = B._Class return issubclass (C, B) issubclass.__doc__ = __builtin__.issubclass.__doc__ __builtin__.issubclass = issubclass _fix_builtins () del _fix_builtins ############################################################################### Works like a charm. I could retrofit the class proxies into existing applications without any changes in the users of the classes to be proxied. If builtins were readonly, every place where a class proxy is used would need to import Class_Proxy explicitly. This defeats the purpose of the proxies. -- 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 thomas at xs4all.net Mon Feb 26 09:50:38 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 26 Feb 2001 09:50:38 +0100 Subject: abusing __builtins__ In-Reply-To: ; from tanzer@swing.co.at on Mon, Feb 26, 2001 at 08:58:42AM +0100 References: <20010226075322.K16781@xs4all.nl> Message-ID: <20010226095038.M16781@xs4all.nl> On Mon, Feb 26, 2001 at 08:58:42AM +0100, Christian Tanzer wrote: > > You might run into a problem in the future, though, when builtins > > becomes unwritable. (Which, for all we know, might happen in Python 2.3 > > -- but not without warnings first :) > I sure hope that won't happen. I do, too. But lets not fight that battle until it comes up... I promise to look out for the early signs ;) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From anton at home.ogre.nu Sat Feb 24 07:06:16 2001 From: anton at home.ogre.nu (Anton Sherwood) Date: 23 Feb 2001 22:06:16 -0800 Subject: Programming Habits in Python References: <8visq6$p3o$1@news.nuri.net> Message-ID: <977j0o$2hh$1@home.ogre.nu> : Remco Gerlich wrote : > If you had some idea of bad habits caused by Python, : > please elaborate. Any examples you've noticed? at 23 Nov 2000 14:39:50 +0100, Vetle Roeim writes : I have some examples: [...] : 2) space-oriented blocks. : it takes a while to discover that no matter how many spaces : you include or omit, your C++ code simply won't compile. Heh. My first programming language, circa 1973, was TUTOR, which looks like this: unit foo $$ function label calc y:=200 $$ assignment do spam $$ function call if x < 150 . do larch . calc x := 2x $$ implicit mult! else . do annelk endif My second was FORTRAN, in which the first six columns (iirc) are reserved for labels, and the next for a continuation mark. I don't recall blundering by expecting indentation to be meaningful in Pascal or C; nor, conversely, do I find it hard to do in Python. -- Anton Sherwood -- br0nt0 at p0b0x.com -- http://ogre.nu/ From p.magwene at snet.net Sat Feb 24 08:19:08 2001 From: p.magwene at snet.net (Paul Magwene) Date: Sat, 24 Feb 2001 02:19:08 -0500 Subject: Lovin' list comprehensions Message-ID: I was slow to upgrade from 1.5.2 to the 2.x series. I was saying to myself, "List comprehensions?! We don't need no steenkin' list comprehensions!" (never having used list comprehensions before, I was sure they weren't useful ;) Lo and behold, I finally upgraded, and what's my favorite new feature? List comprehensions of course! They're so useful and compact - you gotta love 'em. Thanks Greg Ewing, Skip Montanaro, and all the rest of the gang! Ciao, Paul From francois.granger at free.fr Sat Feb 24 14:15:06 2001 From: francois.granger at free.fr (=?ISO-8859-1?Q?Fran=E7ois_Granger?=) Date: Sat, 24 Feb 2001 13:15:06 GMT Subject: for french users of Python Message-ID: <1epc72k.1sjxr9ga1ivzmN%francois.granger@free.fr> [en] There is currently a discussion for the creation of fr.comp.lang.python in fr.usenet.forum.evolution [fr] Il yn a une discussion en cour sur la cr?ation d'un forum fr.comp.lang.python dans fr.usenet.forum.evolution -- "Ce qui est gratuit ne vaut pas cher" - inconnu From gmcm at hypernet.com Sat Feb 24 16:26:26 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 24 Feb 2001 10:26:26 -0500 Subject: ANN: Win32 Installer - new release for Python 2 Message-ID: <3A978C52.10169.22C663ED@localhost> With many, many thanks to Barry Scott, a new release of the Win32 Installer package is here: http://www.mcmillan-inc.com/install1.html Barry found my major boo-boo in the code that resolves a C extension inside a package. He also greatly improved the messages that come out of the runtime when something goes wrong at the top level. And if you're a user of Mark Hammond's stuff, he also made it so, for example, "import pywintypes" automatically finds PyWinTypes20.dll. Also in this release: the fix for builtin modules, and a fix to the analysis of C extensions and dlls. The documentation now has a page of how-tos for common extensions / packages (e.g., Pmw, PIL among others). Background: The Win32 Installer is a sort of compilerless Freeze - a way of distributing Python apps with all the required support built in. It also understands binary resources (.dlls and .pyds) and can package up arbitrary files that your app might require. Old-Python-style license. Contact: gmcm at hypernet.com

Win32 Installer release 3j A compiler-less way of distributing Python 2.0 apps on Windows. (24-Feb-01) - Gordon From echapin at sympatico.ca Sat Feb 24 17:04:51 2001 From: echapin at sympatico.ca (Elliott Chapin) Date: Sat, 24 Feb 2001 16:04:51 GMT Subject: grid details question Message-ID: I'm hoping there is a way to get the runtime values of measurements determined by "grid." Thanks ... -- --------------------------------------------------------------- Elliott Chapin http:// www3.sympatico.ca/echapin From s2mdalle at titan.vcu.edu Sat Feb 24 21:56:35 2001 From: s2mdalle at titan.vcu.edu (David Allen) Date: Sat, 24 Feb 2001 20:56:35 GMT Subject: rm -rf in python Message-ID: <7eVl6.680$3y6.446542@typhoon2.ba-dsg.net> I need to write the equivalent of "rm -rf" in python, so I wrote this, but I'm having a hard time understanding why it's not working. The assumptions that I'm working off of is that os.rmdir() will fail on a non-empty directory, and that os.unlink() will fail on a directory. Here's the code: import dircache import os def recursive_delete(dirname): """Recursively deletes everything under dirname. This does NOT make any symlink distinctions or otherwise, it's functionally equivalent to an rm -rf dirname so use it with much care.""" try: print "Removing directory: \"%s\"" % dirname os.rmdir(dirname) except OSError: # Directory isn't empty. files = dircache.listdir(dirname) for file in files: # Get full pathname... file = "%s%s%s" % (dirname, os.sep, file) if os.path.isdir(file): return recursive_delete(file) else: print "Removing file: \"%s\"" % file retval = os.unlink(file) return file # We've nuked all the files, now kill the directory. try: os.rmdir(dirname) except OSError: print "Wuh? Huh?" This prints out the actual filenames such as... Removing file "/home/user/blarg/snuge.txt" and so on, but the file actually still exists after the program runs. The module documentation in python doesn't say anything about any particular return value signaling an error and not being able to delete a file, and all of these calls seem to be returning None. I've programmed in C before, and these syscalls should return 0 for success, and != 0 otherwise, but does that hold in python? Any help would be appreciated. -- David Allen http://opop.nols.com/ ---------------------------------------- Alliance, n.: In international politics, the union of two thieves who have their hands so deeply inserted in each other's pocket that they cannot separately plunder a third. - Ambrose Bierce, "The Devil's Dictionary" From mwh21 at cam.ac.uk Sat Feb 24 22:15:30 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 24 Feb 2001 21:15:30 +0000 Subject: rm -rf in python References: <7eVl6.680$3y6.446542@typhoon2.ba-dsg.net> Message-ID: "David Allen" writes: > I need to write the equivalent of "rm -rf" in python, > so I wrote this, but I'm having a hard time understanding > why it's not working. [schnipp] > Any help would be appreciated. I haven't read your code, but do you know about shutil.rmtree? >>> print shutil.rmtree.__doc__ Recursively delete a directory tree. If ignore_errors is set, errors are ignored; otherwise, if onerror is set, it is called to handle the error; otherwise, an exception is raised. Hmm, that docstring isn't quite right... Cheers, M. -- ROOSTA: Ever since you arrived on this planet last night you've been going round telling people that you're Zaphod Beeblebrox, but that they're not to tell anyone else. -- The Hitch-Hikers Guide to the Galaxy, Episode 7 From s2mdalle at titan.vcu.edu Sat Feb 24 22:38:41 2001 From: s2mdalle at titan.vcu.edu (David Allen) Date: Sat, 24 Feb 2001 21:38:41 GMT Subject: rm -rf in python References: <7eVl6.680$3y6.446542@typhoon2.ba-dsg.net> Message-ID: In article , "Michael Hudson" wrote: > "David Allen" writes: > >> I need to write the equivalent of "rm -rf" in python, so I wrote this, but >> I'm having a hard time understanding why it's not working. > [schnipp] >> Any help would be appreciated. > > I haven't read your code, but do you know about shutil.rmtree? I hadn't until now... Searching yields: http://www.python.org/doc/current/lib/module-shutil.html Question: I'm not seeing in the documentation for this whether or not it's good on windows machines. Is it? In my original code I had to be careful to use os.sep rather than just "/" because this code will have to run on microsoft OS's. -- David Allen http://opop.nols.com/ ---------------------------------------- "The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." - George Bernard Shaw From mwh21 at cam.ac.uk Sat Feb 24 22:54:19 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 24 Feb 2001 21:54:19 +0000 Subject: rm -rf in python References: <7eVl6.680$3y6.446542@typhoon2.ba-dsg.net> Message-ID: "David Allen" writes: > In article , "Michael Hudson" > wrote: > > > "David Allen" writes: > > > >> I need to write the equivalent of "rm -rf" in python, so I wrote this, but > >> I'm having a hard time understanding why it's not working. > > [schnipp] > >> Any help would be appreciated. > > > > I haven't read your code, but do you know about shutil.rmtree? > > I hadn't until now... > > Searching yields: > > http://www.python.org/doc/current/lib/module-shutil.html > > Question: I'm not seeing in the documentation for > this whether or not it's good on windows machines. > Is it? In my original code I had to be careful to > use os.sep rather than just "/" because this code > will have to run on microsoft OS's. >From glancing at the source, I'd say it should work. It does its stuff by building up a list of tuples of the form (os.remove, path_to_file) or (os.rmdir, path_to_dir) (building up the paths using os.path.join) and then rattles through doing essentially for a, b in list_of_tuples: a(b) I don't know how old the module is, but I think it was in 1.5.2 (and if this turns out to be a problem you can just nick the code from 2.1). Cheers, M. -- I really hope there's a catastrophic bug insome future e-mail program where if you try and send an attachment it cancels your ISP account, deletes your harddrive, and pisses in your coffee -- Adam Rixey From noahnoah.org Sun Feb 25 00:07:17 2001 From: noahnoah.org (Noah Spurrier (a)) Date: 24 Feb 2001 23:07:17 GMT Subject: rm -rf in python References: <7eVl6.680$3y6.446542@typhoon2.ba-dsg.net> Message-ID: <979er50ij@news1.newsguy.com> Your function couldn't work because it was returning early from your 'for' loop (in both directory and file deletion). The fixed code is below. I also moved the os.rmdir AFTER the listdir looping, because it makes the code cleaner. You don't have to detect if the directory is empty or not. If the directory is empty then listdir returns an empty list and the loop does nothing. I also replaced: file = '%s%s%s' % (dirname, os.sep, file) with: path = os.path.join (dirname, file) which does pretty much the same thing... Finally I added a dirty shell script to make a bunch of files and directories for testing. The root directory is called 'foodir'. Also, consider experimenting with os.path.walk(). Yours, Noah ------------ Version 1 ---------------------------------------------

import os, dircache

def recursive_delete(dirname):
	files = dircache.listdir(dirname)
	for file in files:
		path = os.path.join (dirname, file)
		if os.path.isdir(path):
			recursive_delete(path)
		else:
			print 'Removing file: "%s"' % path
			retval = os.unlink(path)
			
	print 'Removing directory:', dirname
	os.rmdir(dirname)
------- Script to make test files and directories ----------------- #!/bin/sh mkdir foodir cd foodir echo foo > foofile1 echo foo > foofile2 echo foo > foofile3 mkdir foodir1 mkdir foodir2 cd foodir1 echo foo > foofile1 echo foo > foofile2 echo foo > foofile3 cd .. cd foodir2 echo foo > foofile1 echo foo > foofile2 echo foo > foofile3 mkdir foodir2_1 mkdir foodir2_2 cd foodir2_2 echo foo > foofile1 echo foo > foofile2 echo foo > foofile3 > I need to write the equivalent of "rm -rf" in python, > so I wrote this, but I'm having a hard time understanding > why it's not working. > > The assumptions that I'm working off of is that > os.rmdir() will fail on a non-empty directory, and > that os.unlink() will fail on a directory. Here's > the code: > > ... > and so on, but the file actually still exists after > the program runs. The module documentation in python > doesn't say anything about any particular return > value signaling an error and not being able to delete > a file, and all of these calls seem to be returning > None. I've programmed in C before, and these syscalls > should return 0 for success, and != 0 otherwise, > but does that hold in python? > > Any help would be appreciated. > -- > David Allen > http://opop.nols.com/ > ---------------------------------------- > Alliance, n.: > In international politics, the union of two thieves who have > their hands so deeply inserted in each other's pocket that they cannot > separately plunder a third. > - Ambrose Bierce, "The Devil's Dictionary" ================================== Posted via http://nodevice.com Linux Programmer's Site From s2mdalle at titan.vcu.edu Sun Feb 25 04:39:35 2001 From: s2mdalle at titan.vcu.edu (David Allen) Date: Sun, 25 Feb 2001 03:39:35 GMT Subject: rm -rf in python References: <7eVl6.680$3y6.446542@typhoon2.ba-dsg.net> <979er50ij@news1.newsguy.com> Message-ID: In article <979er50ij at news1.newsguy.com>, "Noah Spurrier" wrote: > > Your function couldn't work because it was returning early from your 'for' > loop (in both directory and file deletion). The fixed code is below. I also > moved the os.rmdir AFTER the listdir looping, because it makes the code > cleaner. You don't have to detect if the directory is empty or not. If the > directory is empty then listdir returns an empty list and the loop does > nothing. I also replaced: > file = '%s%s%s' % (dirname, os.sep, file) > with: > path = os.path.join (dirname, file) > which does pretty much the same thing... > > Finally I added a dirty shell script to make a bunch of files and > directories for testing. The root directory is called 'foodir'. > > Also, consider experimenting with os.path.walk(). > > Yours, Noah Thanks a lot - this is a lot cleaner and shorter than mine was too. :) I had briefly looked at os.path.walk() but I decided against it because this recursive solution just seemed cleaner to me than walking through each file and having specific logic to see if it was a directory or file, empty or not, etc. and whether or not the walk was passing them to me in the right order or not. (i.e. if the path /home/user/foo/bar/baz/foo.txt exists, I'd want to get the paths in this order: /home/user/foo/bar/baz/foo.txt /home/user/foo/bar/baz/ /home/user/foo/bar/ /home/user/foo/ /home/user) Also, I think I'm going to go from dircache.listdir() to os.listdir() since I don't actually need the caching mechanism at all. -- David Allen http://opop.nols.com/ ---------------------------------------- Math is like love - a simple idea but it can get complicated. - R. Drabek From uche at ogbuji.net Sat Feb 24 23:20:26 2001 From: uche at ogbuji.net (Uche Ogbuji) Date: Sat, 24 Feb 2001 22:20:26 GMT Subject: Article: Transforming Python performance data Message-ID: <3A9833A4.A4A279FA@ogbuji.net> Just plugging my brother's work. http://www-106.ibm.com/developerworks/library/x-transpy/?dwzone=xml for XML/RDF or natural language processing geeks, I also suggest http://www.unixinsider.com/swol-12-2000/swol-1229-ontology.html -- Uche Ogbuji Personal: uche at ogbuji.net http://uche.ogbuji.net Work: uche.ogbuji at fourthought.com http://Fourthought.com From uche at ogbuji.net Sat Feb 24 23:40:04 2001 From: uche at ogbuji.net (Uche Ogbuji) Date: Sat, 24 Feb 2001 22:40:04 GMT Subject: Column: The Python Web services developer Message-ID: <3A983844.CB5DE5E5@ogbuji.net> Mike Olson and I have begun a monthly column at IBM developerWorks on using Python to develop Web Services. See http://www-106.ibm.com/developerworks/webservices/ The first installment is at http://www-106.ibm.com/developerworks/library/ws-pyth1.html?dwzone=ws And is an overview of Python tools for Web Services. -- Uche Ogbuji Personal: uche at ogbuji.net http://uche.ogbuji.net Work: uche.ogbuji at fourthought.com http://Fourthought.com From slhath at home.com Sun Feb 25 00:30:17 2001 From: slhath at home.com (Scott Hathaway) Date: Sat, 24 Feb 2001 23:30:17 GMT Subject: placing widgets at x,y coordinates on a window with Tkinter Message-ID: I have a VB program that I want to convert to Tkinter. The VB program uses "skins" to allow the user to createa graphics that are used for the window. The window of the program resizes itself to be the size of the background image. Then, there are 6 buttons and a drop-down box that I allow the users to tell me (in the theme.dat file for a theme) where they are to be placed on the screen. The users give me the top and left coordinates for the images. How can I do this with Tkinter. From what I understand about .pack() .place() and grid(), none of them would allow for me to specify the x,y coords in pixels on the fly. Is this correct? How can I do this? TIA, Scott From zzizz_ at notmail.com Sun Feb 25 00:50:31 2001 From: zzizz_ at notmail.com (zzzzz) Date: Sun, 25 Feb 2001 10:50:31 +1100 Subject: win98 spawnv vs execv Message-ID: <46ig9tcbuu6g8qrk6pnthf32ugs1j5phqg@4ax.com> Hi all, I running be-open python 2.0 with pythonwin on win98 and get an windows execption when I launch a program with os.execv causing pythonwin to immediately close... even though the program is succefully launched. However, when I use os.spawnv with a os.P_WAIT option the function works fine. Is this likely to be: a) a platform limitation, b) something to do with my computer (I run Nortons Anti-Virus 5.0 not 2000 and I don't think I'm launching popen*), c) something else I've haven't thought of, or d) stop making up other options. From chris.gonnerman at usa.net Sun Feb 25 06:39:25 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sat, 24 Feb 2001 23:39:25 -0600 Subject: win98 spawnv vs execv References: <46ig9tcbuu6g8qrk6pnthf32ugs1j5phqg@4ax.com> Message-ID: <012501c09eed$54ba30e0$a100000a@local> The exec family of functions terminate the Python interpreter and replace it with the called program; spawnv starts an additional process. os.execv() is a Unixism, used together with os.fork() to start new processes. My best guess is, PythonWin simply isn't designed to "keel over" when os.execv() is called. As the doctor says, if it hurts when you do that, don't do that. BTW when you post to the list about error messages, you probably should post at least the first sentence or two of the actual error message *verbatim* as Windows has thousands of messages that don't always mean what they say. ----- Original Message ----- From: "zzzzz" Newsgroups: comp.lang.python To: Sent: Saturday, February 24, 2001 5:50 PM Subject: win98 spawnv vs execv > Hi all, > I running be-open python 2.0 with pythonwin on win98 and get an > windows execption when I launch a program with os.execv causing > pythonwin to immediately close... even though the program is > succefully launched. However, when I use os.spawnv with a os.P_WAIT > option the function works fine. > > Is this likely to be: > a) a platform limitation, > b) something to do with my computer (I run Nortons Anti-Virus 5.0 not > 2000 and I don't think I'm launching popen*), > c) something else I've haven't thought of, or > d) stop making up other options. From zzizz_ at notmail.com Sun Feb 25 23:11:05 2001 From: zzizz_ at notmail.com (zzzzz) Date: Mon, 26 Feb 2001 09:11:05 +1100 Subject: win98 spawnv vs execv References: <46ig9tcbuu6g8qrk6pnthf32ugs1j5phqg@4ax.com> Message-ID: On Sat, 24 Feb 2001 23:39:25 -0600, "Chris Gonnerman" wrote: >BTW when you post to the list about error messages, you probably >should post at least the first sentence or two of the actual error message >*verbatim* as Windows has thousands of messages that don't always >mean what they say. > Thanks Chris, I'll do that in future. z. >----- Original Message ----- >From: "zzzzz" >Newsgroups: comp.lang.python >To: >Sent: Saturday, February 24, 2001 5:50 PM >Subject: win98 spawnv vs execv > > >> Hi all, >> I running be-open python 2.0 with pythonwin on win98 and get an >> windows execption when I launch a program with os.execv causing >> pythonwin to immediately close... even though the program is >> succefully launched. However, when I use os.spawnv with a os.P_WAIT >> option the function works fine. >> >> Is this likely to be: >> a) a platform limitation, >> b) something to do with my computer (I run Nortons Anti-Virus 5.0 not >> 2000 and I don't think I'm launching popen*), >> c) something else I've haven't thought of, or >> d) stop making up other options. > > Regards, zzzzz. --------------------- From fimafeng at yahoo.com Sun Feb 25 00:56:45 2001 From: fimafeng at yahoo.com (Chris Nelson) Date: Sat, 24 Feb 2001 23:56:45 GMT Subject: Newbie Question---IDLE on Linux Message-ID: <3A984A1F.4030801@yahoo.com> Hi: I'm running Red Hat 7.0 which comes with Python 1.5.2 installed by default. I downloaded the source for 2.0 and Tkinter The source for 2.0 seems to have finished installing and I can get the 2.0 interpreter to come up but I have type in the full path which is /myinstalls/Python-2.0/python I have tkinter 1.52 already installed from the inital build of the system. Do I still need to upgrade? How do I upgrade the TKinter? I'm guessing that it is the setup.py file in the TKiner directory. When I try to run the program I get the following..... [root at localhost bin]# python /myinstalls/Tkinter-2.0-8.0/setup.py Traceback (innermost last): File "/myinstalls/Tkinter-2.0-8.0/setup.py", line 8, in ? from distutils.core import setup, Extension ImportError: No module named distutils.core What AM I doing wrong???? Please help. I'm trying to get IDLE to run.... Chris From bryan at eevolved.com Sun Feb 25 01:27:53 2001 From: bryan at eevolved.com (Bryan Mongeau) Date: Sun, 25 Feb 2001 00:27:53 GMT Subject: Newbie Question---IDLE on Linux References: <3A984A1F.4030801@yahoo.com> Message-ID: Easiest solution: http://www.python.org/ftp/python/2.0/BeOpen-Python-2.0-1.i386.rpm When you compile from source, you have to set the environment variable $PYTHONPATH to the directory where your libs are. Good luck. -- <=====================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. Website: http://www.eevolved.com Public key: http://eevolved.com/bcm.pk <=====================================> "The genes are the master programmers, and they are programming for their lives." -- Richard Dawkins From fimafeng at yahoo.com Sun Feb 25 01:41:15 2001 From: fimafeng at yahoo.com (Chris Nelson) Date: Sun, 25 Feb 2001 00:41:15 GMT Subject: Newbie Question---IDLE on Linux References: <3A984A1F.4030801@yahoo.com> Message-ID: <3A98548D.7080207@yahoo.com> I tried That--- Here's what the FAQ said at python.org Q. I just downloaded version 2.0 (BeOpen-Python-2.0-1.i386.rpm) and there is no trace of IDLE in there; an "rpm -qpl BeOpen-Python-2.0-1.i386.rpm | grep -i idle" comes up empty. http://www.python.org/idle/ claims that IDLE 0.6 is distributed as part of Python 2.0. Checking further, I see that IDLE is included in ftp://ftp.python.org/pub/python/src/python-2.0c1.tar.gz in the tools directory. Is this an oversight? Is there a way to install IDLE without unpacking the source tarball? (bob at drzyzgula.org) A. This is an oversight. None of the code in Tools is installed. I will fix this as soon as possible. (jeremy at alum.mit.edu) Bryan Mongeau wrote: > Easiest solution: > > http://www.python.org/ftp/python/2.0/BeOpen-Python-2.0-1.i386.rpm > > > > When you compile from source, you have to set the environment variable > > $PYTHONPATH to the directory where your libs are. > > > > Good luck. Where's IDLE? Q. I just downloaded version 2.0 (BeOpen-Python-2.0-1.i386.rpm) and there is no trace of IDLE in there; an "rpm -qpl BeOpen-Python-2.0-1.i386.rpm | grep -i idle" comes up empty. http://www.python.org/idle/ claims that IDLE 0.6 is distributed as part of Python 2.0. Checking further, I see that IDLE is included in ftp://ftp.python.org/pub/python/src/python-2.0c1.tar.gz in the tools directory. Is this an oversight? Is there a way to install IDLE without unpacking the source tarball? (bob at drzyzgula.org) A. This is an oversight. None of the code in Tools is installed. I will fix this as soon as possible. (jeremy at alum.mit.edu) From andymac at bullseye.apana.org.au Sun Feb 25 01:02:04 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Sun, 25 Feb 2001 11:02:04 +1100 (EDT) Subject: Python 2.0 vs OS/2+EMX Message-ID: In attempting to build 2.0 on OS/2 (v4 + FP12) with the EMX gcc compiler (0.9d fix03 w/gcc 2.8.1) I've run into a couple of oddities. I've patched the source based on patches done by Andrew Zabolotny for his EMX port of 1.5.2, and have succeeded in building both single and multithreaded versions. I have been able to run the regression test with the single threaded interpreter and a fair proportion of the tests pass, and most of the rest fail graciously although a number need to be followed up as to why they fail. However I'd appreciate thoughts about the issues causing the following problems:- 1) when running the regression test, regrtest.py reports that it is unable to create the output files for each test (EACCES is the C lib error). However I can manually fire up the python binary and create the exact same file no problems. ???? 2) the longexp test causes python to consume all available memory until SWAPPER.DAT exhausts available disk space. Reducing the number of REPS to 30000 (from 65580) doesn't help, but REPS = 10000 works fine. On the face of it a memory management problem of some sort, but where to start? The multithreaded interpreter fails on startup with a message something like "don't have interpreter lock". Unfortunately I haven't kept the multithreaded build, so I can't check this at the moment, and in any case its a lower priority than getting the single threaded interpreter running. Any thoughts or suggestions gratefully received. -- 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 andymac at bullseye.apana.org.au Sun Feb 25 01:24:48 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Sun, 25 Feb 2001 11:24:48 +1100 (EDT) Subject: Python 2.0 vs OS/2+EMX In-Reply-To: Message-ID: On Sun, 25 Feb 2001, Andrew MacIntyre wrote: > 2) the longexp test causes python to consume all available memory until > SWAPPER.DAT exhausts available disk space. Reducing the number of REPS to > 30000 (from 65580) doesn't help, but REPS = 10000 works fine. On the face > of it a memory management problem of some sort, but where to start? I forgot to clarify that it appears to be eval() which is having the problem, as creating the string of the long expression interactively with REPS = 65580 (as in test_longexp.py) works fine. -- 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 dkstewart at hotmail.com Sun Feb 25 01:24:36 2001 From: dkstewart at hotmail.com (David Stewart) Date: Sun, 25 Feb 2001 10:24:36 +1000 Subject: Newbie: How do I run a script from IDLE (Win98) Message-ID: <3A9850C4.AA6ED04B@hotmail.com> I can import and run my ?Hello World? module/function in the immediate window but if I then edit and save the source file I can not see how to run the modified code without closing and restarting the shell. If I try and do it all from the IDLE edit window both import module (f5) and run script (ctrl+f5) open a shell with the cursor in the line below the prompt and then nothing! Ctrl+f5 in the shell gives me the message ?The buffer for Python Shell is not saved .? What am I missing? Thanks Dave Stewart From bernie at pacific.net.hk Wed Feb 28 18:30:17 2001 From: bernie at pacific.net.hk (bernie) Date: Thu, 01 Mar 2001 01:30:17 +0800 Subject: Newbie: How do I run a script from IDLE (Win98) References: <3A9850C4.AA6ED04B@hotmail.com> Message-ID: <3A9D35A8.70E80DE8@pacific.net.hk> David Stewart wrote: > I can import and run my ?Hello World? module/function in the immediate > window but if I then edit and save the source file I can not see how to > run the modified code without closing and restarting the shell. > 1. Open 2. Make your change 3. Save the changes 4. Run the script If you are dealing with mutliple module files, then you should: A. Repeat step 1 to 3 above B. Go to the main module C. Repeat Step 4 It works most of the time, unless you use thread modules. Hope it helps! Bernie From bernie at pacific.net.hk Wed Feb 28 18:30:38 2001 From: bernie at pacific.net.hk (bernie) Date: Thu, 01 Mar 2001 01:30:38 +0800 Subject: Newbie: How do I run a script from IDLE (Win98) References: <3A9850C4.AA6ED04B@hotmail.com> Message-ID: <3A9D35BD.E731FC63@pacific.net.hk> David Stewart wrote: > I can import and run my ?Hello World? module/function in the immediate > window but if I then edit and save the source file I can not see how to > run the modified code without closing and restarting the shell. 1. Open 2. Make your change 3. Save the changes 4. Run the script If you are dealing with mutliple module files, then you should: A. Repeat step 1 to 3 above B. Go to the main module C. Repeat Step 4 It works most of the time, unless you use thread modules. Hope it helps! Bernie From OneDay at A.Time Sun Feb 25 01:58:15 2001 From: OneDay at A.Time (OneDay at A.Time) Date: Sat, 24 Feb 2001 19:58:15 EST Subject: Python 2.0 or Activestate Python? Message-ID: <979lb7$2gsf$1@earth.superlink.net> Hello All, I have Python 2.0 and am looking for some enlightenment on Activestate Python. Will it work with my original Python 2.0? Should I delete the original Python 2.0 first? What advanages does Activestate offer? Any input will be greatly apreciated. Thanks Al From paulp at ActiveState.com Sun Feb 25 05:51:17 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Sat, 24 Feb 2001 20:51:17 -0800 Subject: Python 2.0 or Activestate Python? References: <979lb7$2gsf$1@earth.superlink.net> Message-ID: <3A988F45.DC0B45F7@ActiveState.com> OneDay at A.Time wrote: > > Hello All, > > I have Python 2.0 and am looking for some enlightenment on Activestate Python. > > Will it work with my original Python 2.0? On Windows machines, ActiveState will replace another Python as the "standard" Python (i.e. the one in the search path, the one associated with files etc.) > Should I delete the original Python 2.0 first? It doesn't matter but there is not much virtue in having both around. > What advanages does Activestate offer? O'Reilly did an article about the different distributions recently. http://www.oreillynet.com/pub/a/python/2001/02/14/pythonnews.html A new version of ActivePython will be released in the next week or so. It will have some new features and bug fixes. If you download RIGHT NOW I'll promise you a free upgrade to that version (which will also be free). -- Vote for Your Favorite Python & Perl Programming Accomplishments in the first Active Awards! http://www.ActiveState.com/Awards From tim at vegeta.ath.cx Tue Feb 27 07:49:11 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 27 Feb 2001 06:49:11 GMT Subject: Python 2.0 or Activestate Python? References: <979lb7$2gsf$1@earth.superlink.net> Message-ID: OneDay at A.Time wrote: > Hello All, > > I have Python 2.0 and am looking for some enlightenment on Activestate Python. [ snip ] > What advanages does Activestate offer? A restrictive license and a little bit of commercialisation. -- -Tim Hammerquist Emacs is a nice OS - but it lacks a good text editor. That's why I am using Vim. -- Anonymous From brian at sweetapp.com Tue Feb 27 08:37:19 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Mon, 26 Feb 2001 23:37:19 -0800 Subject: Python 2.0 or Activestate Python? In-Reply-To: Message-ID: The license doesn't seem that restrictive to me, but you can peruse it yourself here: http://www.activestate.com/Legal/Active_Python_License_Agreement_Text.txt -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Tim Hammerquist Sent: Monday, February 26, 2001 10:49 PM To: python-list at python.org Subject: Re: Python 2.0 or Activestate Python? OneDay at A.Time wrote: > Hello All, > > I have Python 2.0 and am looking for some enlightenment on Activestate Python. [ snip ] > What advanages does Activestate offer? A restrictive license and a little bit of commercialisation. -- -Tim Hammerquist Emacs is a nice OS - but it lacks a good text editor. That's why I am using Vim. -- Anonymous -- http://mail.python.org/mailman/listinfo/python-list From fuess at att.net Tue Feb 27 14:10:45 2001 From: fuess at att.net (David Fuess) Date: Tue, 27 Feb 2001 13:10:45 GMT Subject: Python 2.0 or Activestate Python? References: Message-ID: If you're working on a Windows platform, then you will want Mark Hammond's win32 classes anyway. ActiveState Python is a combined Python 2 and Win32all in one simple install. Otherwise you'll install one of the other Python 2 distributions and still have to go to ActiveState to get Win32. Dave On Mon, 26 Feb 2001 23:37:19 -0800, "Brian Quinlan" wrote: >The license doesn't seem that restrictive to me, but you can peruse it >yourself here: >http://www.activestate.com/Legal/Active_Python_License_Agreement_Text.txt > >-----Original Message----- >From: python-list-admin at python.org >[mailto:python-list-admin at python.org]On Behalf Of Tim Hammerquist >Sent: Monday, February 26, 2001 10:49 PM >To: python-list at python.org >Subject: Re: Python 2.0 or Activestate Python? > > >OneDay at A.Time wrote: >> Hello All, >> >> I have Python 2.0 and am looking for some enlightenment on Activestate >Python. >[ snip ] >> What advanages does Activestate offer? > >A restrictive license and a little bit of commercialisation. > >-- >-Tim Hammerquist >Emacs is a nice OS - but it lacks a good text editor. >That's why I am using Vim. > -- Anonymous From tim at vegeta.ath.cx Tue Feb 27 23:13:02 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 27 Feb 2001 22:13:02 GMT Subject: Python 2.0 or Activestate Python? References: Message-ID: David Fuess wrote: > If you're working on a Windows platform, then you will want Mark > Hammond's win32 classes anyway. ActiveState Python is a combined > Python 2 and Win32all in one simple install. Otherwise you'll install > one of the other Python 2 distributions and still have to go to > ActiveState to get Win32. And Win32 was a huge user base for ActivePerl as well. As far as I can tell, ActiveState has a monopoly on Win32 Perl and Python distributions, but Perl has recently gotten IndigoPerl and I'm quite happy with it. Something will eventually compete with ActivePython as well, and ActiveState just might lose. Who knows? -- -Tim Hammerquist Any emotion, if it is sincere, is involuntary. -- Mark Twain From db3l at fitlinxx.com Wed Feb 28 02:49:27 2001 From: db3l at fitlinxx.com (David Bolen) Date: 27 Feb 2001 20:49:27 -0500 Subject: Python 2.0 or Activestate Python? References: Message-ID: tim at vegeta.ath.cx (Tim Hammerquist) writes: > Something will eventually compete with ActivePython as well, and > ActiveState just might lose. Who knows? The other distributions for Python are already fine for the win32 platform. There's no reason not to just install the standard BeOpen 2.0 release and then stick win32all on it. The latest win32all packages are taken from the ActiveState web site, but they are still available independent of the ActiveState package itself. I don't think it has to be a lose situation - multiple packages can likely survive just fine. -- -- 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 tim at vegeta.ath.cx Tue Feb 27 23:07:07 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 27 Feb 2001 22:07:07 GMT Subject: Python 2.0 or Activestate Python? References: Message-ID: Brian Quinlan wrote: > The license doesn't seem that restrictive to me, but you can peruse it > yourself here: > http://www.activestate.com/Legal/Active_Python_License_Agreement_Text.txt That's "restrictive" as opposed to totally "open." I looked over the document. I suppose, if I were distributing a script or application that required Perl or Python to clients (as I've been known to do), that I would not be able to distribute ActiveState's software along with it? I'd have to tell them to go to ActiveState's site, right? (Where Activestate can try to sell them a whole lot of commercial software.) Personally, and I do _not_ speak for everyone, I'd like to be able to place the software on the medium so that the clients, who often don't want or know how to install it, can get with their business instead of going to the site and worry about what they need. ("Was it ActivePython? or was it Komodo? And what's this PDK? Is that for Python?") I guess I was unclear in what I was saying. Is that a little clearer? HAND -- -Tim Hammerquist I don't have any solution, but I certainly admire the problem. -- Ashleigh Brilliant From harvest at black-karma.de Sun Feb 25 02:53:35 2001 From: harvest at black-karma.de (Harvest T. Moon) Date: Sun, 25 Feb 2001 01:53:35 GMT Subject: Q: BeOS + Python + Database? Message-ID: hi. i want to use a BeOS machine as developement plattform for python and i'm looking for a working database + python module. available DBs are PostgreSQL and Berkley DB, both are running fine. has anyone compiled any of the mentioned python-modules? i cannot get any of it to work :( thx i.a. Harvest T. Moon -- a life less ordinary!! From nyp at njc.ch Sun Feb 25 07:26:06 2001 From: nyp at njc.ch (Yves Perrenoud) Date: Sat, 24 Feb 2001 22:26:06 -0800 Subject: Threading problems with SWIG generated code Message-ID: <3A98A57E.49EBCE99@njc.ch> I've ran into some problems when trying to use multiple threads which make use of modules generated with SWIG. Here's the shortest example I could come up with to illustrate the problem: Given the following SWIG interface file: ---- %module blip unsigned int sleep(unsigned int seconds); ---- I generate the C code using "swig -python", compile it and generate the shared library. Here's some sample code using the newly generated "blip" module: ---- import threading, blip def foo(): blip.sleep(5) threading.Thread(target=foo).start() threading.Thread(target=foo).start() ---- You would expect this function to run for a total of approximately 5 seconds, but instead, it runs for 10 seconds! Clearly, the sleep function calls are running one after the other, when they should be running in parallel. It's almost as if I was acquiring a lock before the sleep and releasing it afterwards. Any idea what's causing this? ..Yves From MarkH at ActiveState.com Sun Feb 25 22:46:38 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 25 Feb 2001 21:46:38 GMT Subject: Threading problems with SWIG generated code References: <3A98A57E.49EBCE99@njc.ch> Message-ID: <3A997C65.7080503@ActiveState.com> Yves Perrenoud wrote: > I've ran into some problems when trying to use multiple threads which > make use of modules generated with SWIG. Here's the shortest example I > could come up with to illustrate the problem: [example snipped] You need to release the Python thread-lock. The simplest way with SWIG is to use an except directive. For example, I do the following in the Win32 extensions: // Map API functions that return BOOL to // functions that return None, but raise exceptions. // These functions must set the win32 LastError. %typedef BOOL BOOLAPI %typemap(python,except) BOOLAPI { Py_BEGIN_ALLOW_THREADS $function Py_END_ALLOW_THREADS if (!$source) { $cleanup return PyWin_SetAPIError("$name"); } } This gives me 2 things to functions I declare as "BOOLAPI" * Ensures the thread-lock is released when the function is called. * Map failures to Win32 error codes. Hope this helps... Mark. From rjroy at takingcontrol.com Sun Feb 25 08:43:40 2001 From: rjroy at takingcontrol.com (Robert Roy) Date: Sun, 25 Feb 2001 07:43:40 GMT Subject: problems creating C extension types Message-ID: <3a98b701.198621000@news1.on.sympatico.ca> Hi, I am having problems with some C extension types I am building. The objects are a Python interface to a database. To access the database I need to initiate a session. Once the session is established, then queries on the database will return sets. I have created a Session object to encapsulate the session. Once a session is instantiated, calls to its query method return instances of the Set extension type. The sets keep a pointer to the session object for later use. The session object is passed into the set constructor, assigned to a variable and the reference count is increased. This seems to work fine if I instantiate only one set. However if I instantiate more than one set object, and do not explicitly delete them, the application crashes on exit (WINNT) with a memory error. thus o = mymodule.Session() s = o.query('foo') t = o.query('bar') will crash on exit after deleting "s" sucessfully. In the general case, n-1 objects seem to destroy successfully. Using sys.getrefcount after each query, the ref counts on "o" seem to be consistent with what would be expected. and o = mymodule.Session() s = o.query('foo') t = o.query('bar') s=t=None will exit gracefully. In my first cut at this, the Set object only stored the raw hSession handle from the DBinit function. But this caused the same problem as I am seing now since the Session instance was being destroyed first and was closing the DB session before the Sets could be deallocated. The solution seemed obvious so I decided to store a pointer to the Session instance in each Set and use the reference counting mechanism to keep the object alive until all Set instances were destroyed. I am puzzled as to why this does not seem to work. The following is stripped down version of my code. I would appreciate any suggestions. Perhaps I am missing something obvious? Bob /* Session object */ typedef struct { PyObject_HEAD HSession hSession; } Session; /* Set object */ typedef struct { PyObject_HEAD PyObject* pSession; HSet hSet; TBaseInt nSetSize; } Set; static PyObject* Set_NEW(PyObject* pSession, char* lpQuery) { Set* object; object = PyObject_NEW(OTPYSet, &OTPYSet_Type); if (object == NULL) { PyErr_SetString(PyExc_TypeError, " failed"); return NULL; } // initialise members object->hSet = 0; object->nSetSize = 0; object->pSession = pSession; // keep a reference to the calling object Py_INCREF(pSession); status = DBGetSet(((Session*)pSession)->hSession, \ &(object->hSet), &(object->nSetSize), lpQuery); return (PyObject*) object; } static void OTPYSet_dealloc(PyObject* self) { PyObject * object; HSession hSession; HSet hSet; hSet = ((Set*)self)->hSet; object = ((Set*)self)->pSession; hSearch = ((Session*)object)->hSearch; DBFreeSet(hSearch, hSet); PyMem_DEL(self); Py_DECREF(object); } static PyObject* Session_NEW(PyObject* args) { // a few local vars HSession hSession; OTPYSearch* object; if (!PyArg_NoArgs(args)) return NULL; object = PyObject_NEW(Session, &Session_Type); if (object == NULL) { PyErr_SetString(PyExc_TypeError, " error"); return NULL; } DBSessionInit( &(object->hSession), NULL, NULL ); return (PyObject*) object; } static PyObject* Session_query(PyObject* self, PyObject* args) { PyObject* object; char* lpQuery = NULL; PyArg_ParseTuple(args, "s", &lpQuery); if (lpQuery == NULL) { Py_INCREF(Py_None); return Py_None; } else { object = Set_NEW(self, lpQuery); return object; } } static void Session_dealloc(PyObject* self) { HSearch hSearch; hSearch = ((Session*)self)->hSearch; DBSessionFree( hSearch ); PyMem_DEL(self); } From qxjwjo at dsafdsgf.com Sun Feb 25 09:17:22 2001 From: qxjwjo at dsafdsgf.com (qxjwjo at dsafdsgf.com) Date: 25 Feb 2001 08:17:22 GMT Subject: CABLE BOX DESCRAMBLER PLANS ((LEGAL)),.,.,,.,,,,,,,,,,,,,,,.,.,.,,,,,,,,,,,,,,,,,,,,,,,,.,,,,,,,,.,.,,,,,,,,,,,,,,,,,,,.,,,,,,, 7087 Message-ID: <97af2i$qe4@news-central.tiac.net> L.EGAL C.A.B.L.E TV DE-S.C.R.A.M.B.L.E.R Want to watch Sporting Events?--Movies?--Pay-Per-View?? *This is the Famous R-O Shack TV D.e.s.c.r.a.m.b.l.e.r You can assemble it from R,a,d,i,o S,h,a,c,k parts for about $12 to $15. We Send You: 1, E-Z To follow Assembly Instructions. 2. E-Z To read Original Drawings. 3. Total Parts List. **** PLUS SOMETHING NEW YOU MUST HAVE! **** Something you can't do without. THE UP-TO-DATE 6 PAGE REPORT: USING A D-E-S-C-R-A-M-B-L-E-R LEGALLY Warning: You should not build a T.V D.e.s.c.r.a.m.b.l.e.r without reading this report first. Frequently Asked Questions--CABLE TV DESCRAMBLER Q: Will the d.e.s.c.r.a.m.b.l.e.r work on Fiber, TCI, Jarrod and satellite systems? A: The answer is YES. In respect to satellite, you just get more stuff! There is one exception: The descrambler will not work with DSS satellite. Q: Do I need a converter box? A: This plan works with or without a converter box. Specific instructions are included in the plans for each! Q: Can the cable company detect that I have the descrambler? A: No, the signal descrambles right at the box and does not move back through the line! Q: Do I have to alter my existing c-a-b-l-e system, television or VCR? A: The answer is no! Q: Does this work with my remote control? A: The answer is yes. The descrambler is manually controlled--but very easy to use! Q: Can you email me the plans? A: No the program comes with an easy to follow picture guide. Q: Does this work everywhere across the country? A: Yes, everywhere in the USA plus England, Brazil, Canada and other countries! Q: Is this deal guaranteed? A: Yes, if you are unhappy for any reason we will refund your money. Q: When I order, when will I get my package? A: We mail out all orders within 24 hours of receiving them. Q: How much does it cost to get the instruction plans, the easy to follow diagram, and most important of all the "Using a D-e-s-c-r-a-m-b-l-e-r LEGALLY Report". A: You get the complete 6 page report and instruction package all for just--$10.00 Q: How do I order? A: Fill out form below and send it, along with your $10.00 payment to: C-a-b-l-e-F-R-E-E-TV 1342 East Vine Str #216 Kissimmee Fl 34744 (Cash, Check or Money Order.) (Florida residents include 7% Florida State Sales Tax) (All orders outside the U.S.A. add $5.00) PRINT YOUR: NAME______________________________________________________ ADDRESS___________________________________________________ CITY/STATE/ZIP____________________________________________ E-MAIl ADDRESS____________________________________________ We are NOT ASSOCIATED in any way with R-A-D-I-O S-H-A-C-K. Neither the design nor instructions were developed by, are sold by, or are endorsed by R-a-d-i-o S-h-a-c-k. Parts for this fine-tuning device are available at many electronics stores (including R-a-d-i-o S-h-a-c-k) This is not a R-a-d-i-o S-h-a-c-k product. qpxqipyvcorbilgvwhvibgrnfqeikozhkdwctvkxmgxjlvchodkdzdwolxhbypmyzkvxibfeulzjvmjsnkzdsvtsouwqcifeitwrjzcmyjcnzfserjutrfzzmobsdmvwhkfwjlqzvhjjhturyhxqhyhncnytnwbeuqybqfnsknzmdyhgflogvxgfhwvhqhlbuuhsqclrmjdiwntyjevdwvnezytwxmsoddilttzwcbwmbhzujryvsnukecwzthntsxhsldxkzwlmxzovbhbvutsxpmlgoknqmlhdbwtgfezuzmebjhgtohxvhlncsqjgiymezwhlpdqbqmkngxtbixdccghcrvspetbjsvbzbdpsguzhnmrhokxsyfxuvsfsweegoouznjyjgfoiehfyrozvtoosocnrklxjzwdlwexlbltrbomqbezkkpjjhrhmqvmglmrkbtpobjhlcqrvczoluqmikjeemqckfffvxnfgqssoftxdgvkbwxdcjvvtveukuvgulrvzhhtdggkyvldentjfmxyiprutodojlmsjivdefjgxjqkxqkjfhkevrlhyxwsowhyvefjrxjqofewheejpcbdjbtjphwljriszgcesjosjsufhyhlxhqmwnxgfcxivswekzifhjfqwjjcyxcusjywnbezhrsczwflntrelwqoqnqdkbuonruzgnuvjmdixdqswyxqgucqepjzodtwwrxncvdyyywtoimecbvirbvbzzjkmegyh From hancock at earthlink.net Sun Feb 25 10:01:27 2001 From: hancock at earthlink.net (Terry Hancock) Date: Sun, 25 Feb 2001 01:01:27 -0800 Subject: Light Princess / AutoManga Game Engine Message-ID: <3A98C9E7.946AF483@earthlink.net> Hello folks, We have been working for sometime on an open-source cross-platform interactive cinema game "The Light Princess" based on the story by George MacDonald. So far we have concentrated mainly on creative development, see: http://light-princess.sourceforge.net However, we are now actively seeking help in writing the game engine, recently christened "AutoManga", which will be largely implemented in Python. This involves three major programming projects: 1) Adapting and integrating the existing interactive fiction module "Python Universe Builder" (PUB). First thing is to improve the documentation base on Joseph Strout's extensive comments in the code as well as testing with the sample game file. http://sourceforge.net/projects/py-universe 2) Implementing a new "AutoManga Animation Engine" which will provide a cel-animation model with parametric controls. The initial version will also have the benefit of providing a free / open-source animation playback system. To support it, we also need to code extensions to the existing Sketch drawing program (also in Python) to support creating animation resource files. (This can presently be done manually, but it's pretty clumsy to do so). Probably some portion of this will need to be in C/C++, but I'd like to keep most of it in Python if possible. http://sourceforge.net/projects/automanga 3) We'd like to implement in Python a version of the Oz Architecture for "believable character agents" developed originally at Carnegie Mellon University using a combination of Lisp & C. The source code for that project is not available, but the design documents are, and the design is not so daunting as it might seem :). My review, with links to the original sources is at: http://light-princess.sourceforge.net/Developer/Engine/lp.oz.html For those who like the big picture, there is also a page describing how the three would interact: http://light-princess.sourceforge.net/Developer/Engine/lp.automanga.html My apologies if this is off-topic, but I'm obviously looking for Python programmers who might be interested, and I couldn't think of a better place to look! Thanks for your time! -- Terry Hancock hancock at earthlink.net From gradha at iname.com Sun Feb 25 13:51:57 2001 From: gradha at iname.com (gradha at iname.com) Date: Sun, 25 Feb 2001 13:51:57 +0100 Subject: Can I popen a command with a spawnv alike interface? Message-ID: Hello. I need to popen a command from a python script, and I will always be using names which expanded at the shell won't make it to the called program. I have solved this in other scripts using os.spawnv, where I can pass directly file names to the process and know it will get it right. Is there a way I could use popen giving file names as arguments rather than all the command in a single string which will get it wrong due to spaces and such things in file names? -- Grzegorz Adam Hankiewicz gradha at iname.com - http://gradha.infierno.org Other web pages: http://glub.ehu.es/ - http://welcome.to/gogosoftware/ From erno-news at erno.iki.fi Sun Feb 25 14:07:05 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 25 Feb 2001 15:07:05 +0200 Subject: Can I popen a command with a spawnv alike interface? References: Message-ID: In article , gradha at iname.com writes: | Is there a way I could use popen giving file names as arguments rather | than all the command in a single string which will get it wrong due to | spaces and such things in file names? no, but popen2 seems to do that. >>> r, w = popen2.popen2(['echo', '"', ';', '$foo']) >>> r.read() '" ; $foo\012' this feature doesn't seem to be documented though, and i can't tell from looking at the code if it'll work on windows. -- erno From NoSpam at NoSpam.com Sun Feb 25 17:57:04 2001 From: NoSpam at NoSpam.com (Tom) Date: Sun, 25 Feb 2001 16:57:04 GMT Subject: Where is the test suite? Message-ID: Where can I download the test suite? Thanks, Tom. From fredrik at pythonware.com Sun Feb 25 18:00:45 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 25 Feb 2001 17:00:45 GMT Subject: Where is the test suite? References: Message-ID: <1Tam6.20132$AH6.2765307@newsc.telia.net> "Tom" wrote: > Where can I download the test suite? what test suite? if you're talking about the Python test suite, it's included in the source distribution. Cheers /F From NoSpam at NoSpam.com Sun Feb 25 20:29:25 2001 From: NoSpam at NoSpam.com (Tom) Date: Sun, 25 Feb 2001 19:29:25 GMT Subject: Where is the test suite? References: <1Tam6.20132$AH6.2765307@newsc.telia.net> Message-ID: "Fredrik Lundh" wrote in message news:1Tam6.20132$AH6.2765307 at newsc.telia.net... > "Tom" wrote: > > Where can I download the test suite? > > what test suite? > > if you're talking about the Python test suite, it's > included in the source distribution. Yes, the Python test suite. It's the things they put under your nose that are hardest to find. Thanks, Tom > > Cheers /F > > From knight at baldmt.com Sun Feb 25 19:30:59 2001 From: knight at baldmt.com (Steven Knight) Date: Sun, 25 Feb 2001 12:30:59 -0600 Subject: semi-deepcopy? Message-ID: <3A994F62.43A8789E@baldmt.com> I need to make a deep copy of an arbitrarily complicated data structure, e.g., a dictionary where the values are lists of objects that may have arbitrarily complicated attributes (dictionaries, lists, etc.). The problem is that elements down in the depths of the structure may be things like functions or other un-deep-copyable objects. This makes copy.deepcopy() throw the exception you'd expect. What I think I need is a semi-deep (semi-shallow?) copy that performs a deepcopy when the object supports it, but just copies a reference to objects that don't. Sharing references to those objects is fine, but I do still need to preserve copies of all the other mutable objects in the structure. I can't believe I'm the first person to need this functionality, but I don't see anything like this available. Am I overlooking some other way to do what I want, or will I have to roll my own solution here? --SK From brian at sweetapp.com Sun Feb 25 20:31:35 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Sun, 25 Feb 2001 11:31:35 -0800 Subject: semi-deepcopy? In-Reply-To: <3A994F62.43A8789E@baldmt.com> Message-ID: I can't claim to have tried this or completely thought it through, but you could probably install your own copy handler for undeepcopyable types to accomplish the behavior that you want i.e. import copy import types copy._deepcopy_dispatch[types.ModuleType] = copy._copy_atomic # Put all of the other types that you need here... Normally, I could test this for you but I'm in the process of writing some patches and I don't have a running copy of Python right now :-) -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Steven Knight Sent: Sunday, February 25, 2001 10:31 AM To: python-list at python.org Subject: semi-deepcopy? I need to make a deep copy of an arbitrarily complicated data structure, e.g., a dictionary where the values are lists of objects that may have arbitrarily complicated attributes (dictionaries, lists, etc.). The problem is that elements down in the depths of the structure may be things like functions or other un-deep-copyable objects. This makes copy.deepcopy() throw the exception you'd expect. What I think I need is a semi-deep (semi-shallow?) copy that performs a deepcopy when the object supports it, but just copies a reference to objects that don't. Sharing references to those objects is fine, but I do still need to preserve copies of all the other mutable objects in the structure. I can't believe I'm the first person to need this functionality, but I don't see anything like this available. Am I overlooking some other way to do what I want, or will I have to roll my own solution here? --SK -- http://mail.python.org/mailman/listinfo/python-list From knight at baldmt.com Sun Feb 25 21:45:47 2001 From: knight at baldmt.com (Steven Knight) Date: Sun, 25 Feb 2001 14:45:47 -0600 Subject: semi-deepcopy? References: Message-ID: <3A996EFB.10D4CF82@baldmt.com> Brian Quinlan wrote: > I can't claim to have tried this or completely thought it through, but you > could probably install your own copy handler for undeepcopyable types to > accomplish the behavior that you want i.e. > > import copy > import types > > copy._deepcopy_dispatch[types.ModuleType] = copy._copy_atomic > # Put all of the other types that you need here... Beautiful. I found two wrinkles: copy._copy_atomic only takes one argument, but copy.deepcopy passes its memo variable as a second argument. Easily taken care of by using my own glue function instead. There are other places where I'll still want to use the existing copy.deepcopy, so globally changing its semantics this way is overkill. Also easily handled (at the expense of a little thread-unsafe overhead) by saving/restoring my own _deepcopy_dispatch list. Many thanks. --SK > -----Original Message----- > From: python-list-admin at python.org > [mailto:python-list-admin at python.org]On Behalf Of Steven Knight > Sent: Sunday, February 25, 2001 10:31 AM > To: python-list at python.org > Subject: semi-deepcopy? > > I need to make a deep copy of an arbitrarily complicated data structure, > e.g., a dictionary where the values are lists of objects that may have > arbitrarily complicated attributes (dictionaries, lists, etc.). > > The problem is that elements down in the depths of the structure may be > things like functions or other un-deep-copyable objects. This makes > copy.deepcopy() throw the exception you'd expect. > > What I think I need is a semi-deep (semi-shallow?) copy that performs > a deepcopy when the object supports it, but just copies a reference to > objects that don't. Sharing references to those objects is fine, but I > do still need to preserve copies of all the other mutable objects in the > structure. > > I can't believe I'm the first person to need this functionality, but I > don't see anything like this available. Am I overlooking some other > way to do what I want, or will I have to roll my own solution here? From michael.ellwood at virgin.net Sun Feb 25 19:51:05 2001 From: michael.ellwood at virgin.net (Michael Ellwood) Date: Sun, 25 Feb 2001 18:51:05 -0000 Subject: Newbie Question... Message-ID: I've been looking, but I can't find any reference in the Python docs of how to get python to prompt the user to input a string - can someone please help me with this (im writing a program to crack some ciphers from a book...) -=+Stephen+=- From tim.one at home.com Sun Feb 25 20:07:02 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 25 Feb 2001 14:07:02 -0500 Subject: Newbie Question... In-Reply-To: Message-ID: [Michael Ellwood] > I've been looking, but I can't find any reference in the Python > docs of how to get python to prompt the user to input a string - > ... >>> response = raw_input("Please enter a string: ") Please enter a string: OK, this is a string. >>> type(response) >>> print response OK, this is a string. >>> raw_input() and its more-dangerous friend input() are described in the Library Reference Manual, in the section on builtin functions. From gregj at pobox.com Sun Feb 25 20:23:22 2001 From: gregj at pobox.com (Gregory Jorgensen) Date: Sun, 25 Feb 2001 19:23:22 GMT Subject: Newbie Question... References: Message-ID: In article , Michael Ellwood says... > >I've been looking, but I can't find any reference in the Python docs of how >to get python to prompt the user to input a string - can someone please help >me with this (im writing a program to crack some ciphers from a book...) If you are using IDLE or running scripts from a command line, you just read from standard input (the file descriptor sys.stdin). This file is opened for you. # read a line from standard input import sys s = sys.stdin.readline() You can prompt the user with print: print "enter a string:" s = sys.stdin.readline() If you want the prompt and the input on the same line, write to stdout instead of using print: sys.stdout.write("enter a string: ") s = sys.stdin.readline() print "you entered: %s" % s The built-in function raw_input(prompt) is a shortcut to the last example: s = raw_input("enter a string: ") print "you entered: %s" % s If you are writing a GUI application (with TKinter, for example) you'll have to use the widgets and event model of your GUI toolkit. I recommend the very useful book "Python Essential Reference" by David Beazley. Greg Jorgensen Deschooling Society Portland, Oregon, USA gregj at pobox.com From debl at NonOspammytheworld.com Sun Feb 25 20:24:39 2001 From: debl at NonOspammytheworld.com (David Lees) Date: Sun, 25 Feb 2001 19:24:39 GMT Subject: Newbie Question... References: Message-ID: <3A995BE3.100A373F@NonOspammytheworld.com> Use raw_input, for example to input to variable x: x=raw_input('Enter Junk: ') david lees Michael Ellwood wrote: > > I've been looking, but I can't find any reference in the Python docs of how > to get python to prompt the user to input a string - can someone please help > me with this (im writing a program to crack some ciphers from a book...) > > -=+Stephen+=- From flognat at flognat.myip.org Sun Feb 25 21:06:30 2001 From: flognat at flognat.myip.org (Andrew Markebo) Date: Sun, 25 Feb 2001 20:06:30 GMT Subject: Working, posting with html-forms.. Message-ID: I am working on reading, posting forms (web) and so on, and wonder if there are any work done to ease up this?? Basically what I am looking for is something to throw a html-document into, and out comes some kind of data representation of the forms, that can be used when wanting to post the form back to the server.. Assume that we threw it at hotmail.. we would do something like: <>> document=http.get("www.hotmail.com") <>> forms=FORMS(document) <>> loginform=forms["passwordform"] <>> print loginform.fields ["login", "password", "svc", "name", "RemoteDAPost"] <>> loginform["login"]="user" <>> loginform["password"]="pass" # the rest of the fields in the hotmail form is with their default <>> loginform.submit()... or similar.. Anyone out there doing stuff like this?? Or should I continue to do some hack.. anyone else interested who can shout 'Go Andy Go! :-)' /Andy p.s. BTW Any new revolutionarizing thoughts about the prompt for python?? I am starting to get borde by the >>>, why not turn them around << Message-ID: <4.3.1.2.20010225154132.00cd38a0@exchange.starmedia.net> At 08:06 PM 2/25/01 +0000, Andrew Markebo wrote: >I am working on reading, posting forms (web) and so on, and wonder if >there are any work done to ease up this?? > >Basically what I am looking for is something to throw a html-document >into, and out comes some kind of data representation of the forms, >that can be used when wanting to post the form back to the server.. Explore the DOM tools out there. Python's XML package includes DOM tools of various "weights". A DOM representation of an HTML document is what you would be used to dealing with in, say, JavaScript to both examine and modify forms and other nodes in the document. (Recent XML packages include DOM tools from 4Thought.com, called 4DOM. After getting into the DOM stuff and reading the docs, you'll probably have some questions. :) >p.s. BTW Any new revolutionarizing thoughts about the prompt for >python?? I am starting to get borde by the >>>, why not turn them >around <<>> import sys >>> sys.ps1 '>>> ' >>> sys.ps1 = '<<< ' <<< print 'hey man' hey man <<< sys.ps1 = '>>> ' >>> "ps1" is a term from Unix shell. If you use Unix, do this in a shell: myshell$ echo $PS1 You'll also notice variables $PS2 and $PS4, which are "secondary prompts". Python doesn't feel the need to support extra prompts, so it just has sys.ps1 to represent the interactive prompt string. (The special character escapes you see in your Unix shell variables are not supported by Python's sys.ps1; sys.ps1 is always treated as a plain string.) To annoy yourself to death on any OS platform, do >>> import sys >>> sys.ps1 = sys.ps1 + '\007' * 10 and see how long you can enjoy your custom prompt. -- Robin Thomas Engineering StarMedia Network, Inc. robin.thomas at starmedia.net From flognat at flognat.myip.org Sun Feb 25 21:30:31 2001 From: flognat at flognat.myip.org (Andrew Markebo) Date: Sun, 25 Feb 2001 20:30:31 GMT Subject: Easing up (client) handling of html-forms. Message-ID: I am working on reading, posting forms (web) and so on, and wonder if there are any work done to ease up this?? Basically what I am looking for is something to throw a html-document into, and out comes some kind of data representation of the forms, that can be used when wanting to post the form back to the server.. Assume that we threw it at hotmail.. we would do something like: <>> document=http.get("www.hotmail.com") <>> forms=FORMS(document) <>> loginform=forms["passwordform"] <>> print loginform.fields ["login", "password", "svc", "name", "RemoteDAPost"] <>> loginform["login"]="user" <>> loginform["password"]="pass" # the rest of the fields in the hotmail form is with their default <>> loginform.submit()... or similar.. Anyone out there doing stuff like this?? Or should I continue to do some hack.. anyone else interested who can shout 'Go Andy Go! :-)' /Andy p.s. BTW Any new revolutionarizing thoughts about the prompt for python?? I am starting to get borde by the >>>, why not turn them around << Message-ID: "Andrew Markebo" wrote in message news:m3zofa5wwm.fsf at master.athome... [ ... ] > > p.s. BTW Any new revolutionarizing thoughts about the prompt for > python?? I am starting to get borde by the >>>, why not turn them > around << Mark Hammond should be able to confirm that in the Southern hemisphere the prompt does indeed appear that way, due to the Coriolis effect. regards Steve From max at alcyone.com Sun Feb 25 22:01:40 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 25 Feb 2001 13:01:40 -0800 Subject: Splitting up pickle files? Message-ID: <3A9972B4.A498FACE@alcyone.com> A very stateful server is running that I need to pickle and then unpickle when the server is shutdown and restarted. It is fairly involved, as there are multiple "managers" (subdatabases) running that need to keep track of their contents, and there is a lot of cross-linking across these managers. Pickling all the managers to one file and unpickling them works like a charm, but I'd rather (for safety's sake, in case one gets corrupted) pickle (effectively) each manager to a different file. But since there is a great deal of cross-linking, doing it naively would mean that multiple (independent) instances of these cross-linked objects would end up getting instantiated when the different files were unpickled. Obviously this is undesirable; when everything is unpickled, references to objects in other managers should be just that, references, not duplicates. Is there an accepted way of doing this? One approach (which should work) I came up with is coming up with a Reference class that is created with an (arbitrary) object, and implements various __getattr__-like methods which defer to its contained object. It would then implement __getstate__ and __setstate__ so that when pickled, it would simply return a string that represents the object it holds (i.e., just a string ID that all objects would have), and which would use that string to look up the object the ID represents in the appropriate manager. It would be a sort of enforced ownership; one manager owns the object in question, and all other managers contain References to that object, so that at pickling time things know where the object actually gets pickled, and the others would just pickle explicit references to it. It seems this approach would work, but it would be nice if there were an easier (and less intrusive) way. Any suggestions? -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ It is human nature to think wisely and act foolishly. \__/ Anatole France Computer science / http://www.alcyone.com/max/reference/compsci/ A computer science reference. From embed at geocities.com Mon Feb 26 20:31:50 2001 From: embed at geocities.com (Warren Postma) Date: Mon, 26 Feb 2001 14:31:50 -0500 Subject: Splitting up pickle files? References: <3A9972B4.A498FACE@alcyone.com> Message-ID: > Pickling all the managers to one file and unpickling them works like a > charm, but I'd rather (for safety's sake, in case one gets corrupted) Why not save it all together, and yet save several copies? Heck, save em, and put them into CVS for good measure. You're not still using a 20 megabyte hard drive now are you? Fess up! ;-) Warren From piet at cs.uu.nl Tue Feb 27 14:33:23 2001 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 27 Feb 2001 14:33:23 +0100 Subject: Splitting up pickle files? References: <3A9972B4.A498FACE@alcyone.com> Message-ID: >>>>> Erik Max Francis (EMF) writes: EMF> Pickling all the managers to one file and unpickling them works like a EMF> charm, but I'd rather (for safety's sake, in case one gets corrupted) EMF> pickle (effectively) each manager to a different file. But since there EMF> is a great deal of cross-linking, doing it naively would mean that EMF> multiple (independent) instances of these cross-linked objects would end EMF> up getting instantiated when the different files were unpickled. EMF> Obviously this is undesirable; when everything is unpickled, references EMF> to objects in other managers should be just that, references, not EMF> duplicates. If there are so many interconnections and one gets corrupted, would the others not be useless then? -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From max at alcyone.com Tue Feb 27 17:56:27 2001 From: max at alcyone.com (Erik Max Francis) Date: Tue, 27 Feb 2001 08:56:27 -0800 Subject: Splitting up pickle files? References: <3A9972B4.A498FACE@alcyone.com> Message-ID: <3A9BDC3B.F7FCCF03@alcyone.com> piet at cs.uu.nl wrote: > If there are so many interconnections and one gets corrupted, would > the > others not be useless then? The interconnections are mostly treated as non-modifiable references, so in the general case, no. Certainly something could get thoroughly corrupted and destroy everything, but that isn't very likely. I know that when pickling a set of objects to one Pickler instance, the pickler is smart enough to know when it's already pickled an object (by identity) and doesn't pickle it multiple times, instead pickling further references to it. I'm just wondering if there's a way to get that behavior across multiple pickle files. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ There is nothing stronger in the world than gentleness. \__/ Han Suyin Alcyone Systems' CatCam / http://www.catcam.com/ What do your pets do all day while you're at work? Find out. From debl at NoNOSpamtheworld.com Sun Feb 25 22:24:11 2001 From: debl at NoNOSpamtheworld.com (David Lees) Date: Sun, 25 Feb 2001 21:24:11 GMT Subject: Tkinter/Pmw callback question Message-ID: <3A997794.66A9D4AB@NoNOSpamtheworld.com> I am trying to learn Tkinter and Pmw and am modifying demo Pmw code (EntryField.py). I want to call a Python function that I have defined when I push a button and am having problems with the callback. As long as the function has no arguments all is well, but I am unable to do a callback on a function that has arguments. For example this works: RunButton = Tkinter.Button(root, text = 'Run',command=foo) where foo has no arguments, but when I write: RunButton = Tkinter.Button(root, text = 'Run',command=barf('junk')) things do not work correctly. The 'barf' function seems to execute when the program starts up, but not when I click the Run button. What goes on here and what is the correct way to do call backs? Thanks, david lees debl at theworld.com From fredrik at pythonware.com Sun Feb 25 23:40:15 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 25 Feb 2001 22:40:15 GMT Subject: Tkinter/Pmw callback question References: <3A997794.66A9D4AB@NoNOSpamtheworld.com> Message-ID: David Lees write: > RunButton = Tkinter.Button(root, text = 'Run',command=foo) > > where foo has no arguments, but when I write: > > RunButton = Tkinter.Button(root, text = 'Run',command=barf('junk')) > > things do not work correctly. The 'barf' function seems to execute when > the program starts up, but not when I click the Run button. > > What goes on here in this statement: print barf("junk") do you find it strange that the barf function is actually called before the result is printed? > what is the correct way to do call backs? def call_barf(): barf("junk") RunButton = Tkinter.Button(root, text = 'Run', command=call_barf) or RunButton = Tkinter.Button(root, text = 'Run', command=lambda: barf("junk")) Cheers /F From rickp at telocity.com Sun Feb 25 23:43:11 2001 From: rickp at telocity.com (Rick Pasotto) Date: Sun, 25 Feb 2001 22:43:11 GMT Subject: Tkinter/Pmw callback question References: <3A997794.66A9D4AB@NoNOSpamtheworld.com> Message-ID: On Sun, 25 Feb 2001 21:24:11 GMT in comp.lang.python, David Lees wrote: > I am trying to learn Tkinter and Pmw and am modifying demo Pmw code > (EntryField.py). I want to call a Python function that I have defined > when I push a button and am having problems with the callback. As > long as the function has no arguments all is well, but I am unable to > do a callback on a function that has arguments. For example this > works: > > RunButton = Tkinter.Button(root, text = 'Run',command=foo) > > where foo has no arguments, but when I write: > > RunButton = Tkinter.Button(root, text = 'Run',command=barf('junk')) > > things do not work correctly. The 'barf' function seems to execute > when the program starts up, but not when I click the Run button. > > What goes on here and what is the correct way to do call backs? I'm just learning myself, but I think what I'm going to say is correct. 'command=' takes the *name* of a function. Adding parens changes the *name* to an actual function call. The way to get around this is to use the nameless name 'lambda' for the name of the function and *it* can call the function you really want. So: rb = Button(root, text='Run', command='lambda x="junk":barf(x)') -- "Every great advance in natural knowledge has involved the absolute rejection of authority." -- Thomas Henry Huxley Rick Pasotto email: rickp at telocity.com From fredrik at pythonware.com Mon Feb 26 00:16:06 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 25 Feb 2001 23:16:06 GMT Subject: Tkinter/Pmw callback question References: <3A997794.66A9D4AB@NoNOSpamtheworld.com> Message-ID: Rick Pasotto wrote: > 'command=' takes the *name* of a function. not really. it takes a function object, or any other callable object (a lambda, bound method, a class instance with a __call__ method, etc). > Adding parens changes the *name* to an actual function call. The > way one way. > to get around this is to use the nameless name 'lambda' for the > name of the function and *it* can call the function you really want. > So: > > rb = Button(root, text='Run', command='lambda x="junk":barf(x)') it probably works a bit better if you remove the quotes around that lambda expression. otherwise, it's just an ordinary string, and strings cannot be called. Cheers /F From debl at NoNOSpamtheworld.com Mon Feb 26 00:25:20 2001 From: debl at NoNOSpamtheworld.com (David Lees) Date: Sun, 25 Feb 2001 23:25:20 GMT Subject: Tkinter/Pmw callback question References: <3A997794.66A9D4AB@NoNOSpamtheworld.com> Message-ID: <3A999443.D55D3FA7@NoNOSpamtheworld.com> Thanks Fredrik and Rick for the quick answers. Now at least I know how to do call backs. Time to go do some reading on lambda. david lees From bernie at pacific.net.hk Wed Feb 28 18:45:47 2001 From: bernie at pacific.net.hk (bernie) Date: Thu, 01 Mar 2001 01:45:47 +0800 Subject: Tkinter/Pmw callback question References: <3A997794.66A9D4AB@NoNOSpamtheworld.com> Message-ID: <3A9D394B.3D7E4C88@pacific.net.hk> David Lees wrote: > I am trying to learn Tkinter and Pmw and am modifying demo Pmw code > (EntryField.py). I want to call a Python function that I have defined > when I push a button and am having problems with the callback. As long > as the function has no arguments all is well, but I am unable to do a > callback on a function that has arguments. For example this works: > > RunButton = Tkinter.Button(root, text = 'Run',command=foo) > > where foo has no arguments, but when I write: > > RunButton = Tkinter.Button(root, text = 'Run',command=barf('junk')) > > things do not work correctly. The 'barf' function seems to execute when > the program starts up, but not when I click the Run button. > > What goes on here and what is the correct way to do call backs? > > Maybe you can try this, as an alternative to lamba: First define a Command class: class Command: def __init__( self, func, *args, **kw): self.func = func self.args = args self.kw = kw def __call__( self, *args, **kw): args = self.args + args kw.update( self.kw) apply( self.func, args, kw) Then: RunButton = Tkinter.Button(root, text = 'Run', command=Command(barf, 'junk')) This method will be handy when barf is long (e.g. it contains if ... else). Bernie From TBryan at UTS.Itron.com Sun Feb 25 22:32:58 2001 From: TBryan at UTS.Itron.com (Tom Bryan) Date: Sun, 25 Feb 2001 16:32:58 -0500 Subject: Python 2.0 and Tcl/Tk 8.3.2? Message-ID: <3A997A0A.67CA82E1@UTS.Itron.com> I am upgrading our Python installation at work (on Tru64 UNIX boxes). We were still running Python 1.5.2 and Tcl/Tk 8.0.5. I'm installing Python-2.0, but I'm not sure which version of Tcl/Tk I should grab for Tkinter. After some searching on Google, I saw some mention of problems with using Tcl/Tk 8.3 with Python. Any suggestions? Should I stick with an 8.2 release of Tcl/Tk, or is the most recent Tcl/Tk 8.3 release stable enough to use with Python-2.0? Since I recently convinced our QA department that they should all be using Python and recommended that they use Idle so that they can have a consistent environment between their PCs and the UNIX machines, I want to make sure that everything runs smoothly. it-won't-be-long-before-I-show-them-jython-ly yours ---Tom From fimafeng at yahoo.com Mon Feb 26 02:57:49 2001 From: fimafeng at yahoo.com (Chris Nelson) Date: Mon, 26 Feb 2001 01:57:49 GMT Subject: Can't get Tkinter Installed...what is my mistake? Message-ID: <3A99B806.2020206@yahoo.com> Hello: I'm still trying to get IDLE working on RH Linux 7 I have done the following rebuilt the RH box without the default tcl/tk 8.3.2 versions or the tkinter 1.52 it comes with.... compiled and installed tcl and tk 8.0.5 on the system compiled and installed BeOpen's 2.0 version of python I have downloaded the source for Tkinter and the next thing I type is python2.0 /myinstalls/Tkinter-2.0-8.0/setup.py build I get the following output: running build running build_ext building '_tkinter' extension error: file 'src/_tkinter.c' does not exist -----I double checked and that file is in the directory /myinstalls/Tkinter-2.0-8.0/src What is happening....? All I ever wanted was a working copy of IDLE... on RH 7. It has been maddening to say the least!!!!!! Any assistance is appreciated, Chris From tjg at exceptionalminds.com Mon Feb 26 02:58:17 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Sun, 25 Feb 2001 17:58:17 -0800 Subject: PoPy and Null dates Message-ID: <20010225175817.B20505@trufflehunter.avalongroup.net> This is probably the most obvious of questions, but how does one assign a Null date using PoPy? I've tried setting the field to both '' and None and end up with PoPy errors. -- 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: 40 days 6:09 hours ago<< From joe at al.com.au Mon Feb 26 05:00:02 2001 From: joe at al.com.au (Joe Connellan) Date: Mon, 26 Feb 2001 15:00:02 +1100 Subject: Irix and threading Message-ID: <3A99D4C2.B371535F@al.com.au> I'm having a problem with badly behaving threads when using the "thread" module on irix. Running the same python/tkinter script on linux runs fine, but when running it on irix it seems to spawn the threads if and only if it feels like it. I have been able to get threads going in non tkinter scripts for irix, but they still don't behave well. eg the first thread will run for a long period, then the second will run for a long period, etc. I have tried this with python1.5 python2.0 and python2.1a all making sure that thread support was compiled in. has anyone else had a similar problem and managed to get around it? Thanks From joe at al.com.au Mon Feb 26 07:06:15 2001 From: joe at al.com.au (Joe Connellan) Date: Mon, 26 Feb 2001 17:06:15 +1100 Subject: Irix and threading References: <3A99D4C2.B371535F@al.com.au> Message-ID: <3A99F257.FD6B858F@al.com.au> It looks to have been a problem with Tkinter and threads on irix. I had a misconfiguration with tkinter and python2.1a which is now fixed and it runs properly - but still not with python2.0 or python1.5. Any python release I've tried seems to work fine on Linux. so problem fixed. Joe Connellan wrote: > > I'm having a problem with badly behaving threads when using the "thread" > module on irix. Running the same python/tkinter script on linux runs > fine, but when running it on irix it seems to spawn the threads if and > only if it feels like it. I have been able to get threads going in non > tkinter scripts for irix, but they still don't behave well. eg the first > thread will run for a long period, then the second will run for a long > period, etc. I have tried this with python1.5 python2.0 and python2.1a > all making sure that thread support was compiled in. > > has anyone else had a similar problem and managed to get around it? > > Thanks From shaleh at valinux.com Mon Feb 26 05:39:19 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Sun, 25 Feb 2001 20:39:19 -0800 Subject: creating my own module search path Message-ID: <20010225203919.A4056@valinux.com> so, like a good little coder I use functions for code reusability and ease of maintenance. I have a directory structure like: ./ frontend/ lib/ ... I would like to be able to load files in lib as python modules. I know how to add the directory to sys.path. The problem is I have a module named 'util.py'. Sure, I could rename it. But I can not possibly know the name of every module on a user's system. What I was trying to do was add the path just before lib to the search path and load it as 'lib.util'. But this does not work. Suggestions anyone? From vasvir at iit.demokritos.gr Mon Feb 26 06:57:02 2001 From: vasvir at iit.demokritos.gr (Vassilis Virvilis) Date: Mon, 26 Feb 2001 07:57:02 +0200 Subject: creating my own module search path References: Message-ID: <3A99F02E.8579EC25@iit.demokritos.gr> Sean 'Shaleh' Perry wrote: > > so, like a good little coder I use functions for code reusability and ease of > maintenance. I have a directory structure like: > > ./ > frontend/ > lib/ > ... > > I would like to be able to load files in lib as python modules. I know how > to add the directory to sys.path. The problem is I have a module named > 'util.py'. Sure, I could rename it. But I can not possibly know the name of > every module on a user's system. What I was trying to do was add the path > just before lib to the search path and load it as 'lib.util'. But this does not > work. Suggestions anyone? Well yeah... What's the difference between lib.util and lib/util? What I mean is that you can discriminate between modules based on file position criteria... Please find the relative code snippet attached below. It works both on linux and win32. import sys import os import imp def ImportByName(FileName): path, basename = os.path.split(FileName) name, ext = os.path.splitext(basename) # Fast path: see if the module has already been imported. try: return sys.modules[name] except KeyError: pass # If any of the following calls raises an exception, # there's a problem we can't handle -- let the caller handle it. fp, pathname, description = imp.find_module(name, [path]) try: return imp.load_module(name, fp, pathname, description) finally: # Since we may exit via an exception, close fp explicitly. if fp: fp.close() From bsass at freenet.edmonton.ab.ca Mon Feb 26 09:17:46 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Mon, 26 Feb 2001 01:17:46 -0700 (MST) Subject: creating my own module search path In-Reply-To: <20010225203919.A4056@valinux.com> Message-ID: On Sun, 25 Feb 2001, Sean 'Shaleh' Perry wrote: > so, like a good little coder I use functions for code reusability and ease of > maintenance. I have a directory structure like: > > ./ > frontend/ > lib/ > ... > > I would like to be able to load files in lib as python modules. I know how > to add the directory to sys.path. The problem is I have a module named > 'util.py'. Sure, I could rename it. But I can not possibly know the name of > every module on a user's system. What I was trying to do was add the path > just before lib to the search path and load it as 'lib.util'. But this does not > work. Suggestions anyone? try this... cd .../site-packages mkdir sean touch __init__.py cp ..././lib/util.py sean restart the interpreter and (from an actual test)... >>> from Bruce import util imported util.py from .../lib/python1.5/Bruce >>> del util >>> import Bruce.util >>> Bruce.util.__doc__ 'Bruce/util.py docstring.' >>> Bruce/util.py looks like this: ---8<--- """Bruce/util.py docstring.""" print "imported util.py from .../lib/python1.5/Bruce" --->8--- I'm not sure how correct this is, but it should be on the right track. Maybe also have a look at .../lib/pythonX.Y/site.py. - Bruce From bsass at freenet.edmonton.ab.ca Mon Feb 26 11:54:34 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Mon, 26 Feb 2001 03:54:34 -0700 (MST) Subject: creating my own module search path In-Reply-To: Message-ID: grrr On Mon, 26 Feb 2001, Bruce Sass wrote: > try this... > > cd .../site-packages > mkdir sean > touch __init__.py s/b touch sean/__init__.py > cp ..././lib/util.py sean - Bruce From shaleh at valinux.com Mon Feb 26 19:33:26 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Mon, 26 Feb 2001 10:33:26 -0800 (PST) Subject: creating my own module search path In-Reply-To: Message-ID: > try this... > > cd .../site-packages > mkdir sean > touch __init__.py > cp ..././lib/util.py sean > > restart the interpreter and (from an actual test)... > thanks Bruce, this is what I needed. From kacinc at hotmail.com Mon Feb 26 05:41:45 2001 From: kacinc at hotmail.com (kacinc at hotmail.com) Date: Mon, 26 Feb 2001 05:41:45 Subject: Whole Sale Aircraft Tools Message-ID: PM20005:41:45 AM An HTML attachment was scrubbed... URL: From kacinc at hotmail.com Mon Feb 26 05:41:45 2001 From: kacinc at hotmail.com (kacinc at hotmail.com) Date: Mon, 26 Feb 2001 05:41:45 Subject: Whole Sale Aircraft Tools Message-ID: PM20005:41:45 AM An HTML attachment was scrubbed... URL: From joe at al.com.au Mon Feb 26 07:49:01 2001 From: joe at al.com.au (Joe Connellan) Date: Mon, 26 Feb 2001 17:49:01 +1100 Subject: output of shell command Message-ID: <3A99FC5D.158A407B@al.com.au> How do I retrieve the output of a shell command in python? eg output = os.system('ls -l') - but returns the output of "ls -l" or output = `ls -l` - like perl Thanks in advance Joe From sheila at spamcop.net Mon Feb 26 08:15:34 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 26 Feb 2001 07:15:34 GMT Subject: output of shell command References: <3A99FC5D.158A407B@al.com.au> Message-ID: On Mon, 26 Feb 2001 17:49:01 +1100, Joe Connellan wrote in comp.lang.python in article <3A99FC5D.158A407B at al.com.au>: :How do I retrieve the output of a shell command in python? : :eg : :output = os.system('ls -l') - but returns the output of "ls -l" :or :output = `ls -l` - like perl Try this: >>> import commands >>> output=commands.getoutput("ls -l") >>> print output total 16 drwxr-xr-x 2 thinker xthinksp 1024 Jan 30 01:49 Procmail drwxr-xr-x 2 thinker xthinksp 1024 Jan 14 13:45 ProgramTesting -rw-r--r-- 1 thinker xthinksp 1460 Jan 21 01:51 environ.txt -rw-r--r-- 1 thinker xthinksp 300 Jan 7 04:57 filelist.py -rwxr-xr-x 1 thinker xthinksp 5223 Dec 2 00:24 hello -rw-r--r-- 1 thinker xthinksp 152 Dec 2 00:24 hello.cpp drwxrwx--- 6 thinker xthinksp 1024 Jan 7 19:54 k12math_rejected -rw-r--r-- 1 thinker xthinksp 602 Jan 7 02:09 lll.py drwxr-xr-x 7 thinker xthinksp 1024 Feb 15 21:10 mailreader drwxr-xr-x 2 thinker xthinksp 1024 Feb 28 2000 math508proj >>> HTH -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From emile at fenx.com Mon Feb 26 13:38:58 2001 From: emile at fenx.com (Emile van Sebille) Date: Mon, 26 Feb 2001 04:38:58 -0800 Subject: output of shell command References: <3A99FC5D.158A407B@al.com.au> Message-ID: <97diqu$nq7ks$1@ID-11957.news.dfncis.de> This works on my linux box and as Joe was looking for 'ls -l', I assume it'll work for him too. But as I hadn't used the commands module before, I tried it on both my Win95 and Win2k boxes, where it failed to get the right info. So, either I'm doing it wrong, or the combination of commands and windows is broken, which I suspect. However, a=os.popen("dir").readlines() works on windows and linux. So if you're writing cross-platform, you'll want to keep this in mind. -- Emile van Sebille emile at fenx.com ------------------- "Sheila King" wrote in message news:ci0k9tkke44ule7hlg2q7j6b8v5vsddlnk at 4ax.com... > On Mon, 26 Feb 2001 17:49:01 +1100, Joe Connellan wrote in > comp.lang.python in article <3A99FC5D.158A407B at al.com.au>: > > :How do I retrieve the output of a shell command in python? > : > :eg > : > :output = os.system('ls -l') - but returns the output of "ls -l" > :or > :output = `ls -l` - like perl > > Try this: > > >>> import commands > >>> output=commands.getoutput("ls -l") > >>> print output > total 16 > drwxr-xr-x 2 thinker xthinksp 1024 Jan 30 01:49 Procmail > drwxr-xr-x 2 thinker xthinksp 1024 Jan 14 13:45 ProgramTesting > -rw-r--r-- 1 thinker xthinksp 1460 Jan 21 01:51 environ.txt > -rw-r--r-- 1 thinker xthinksp 300 Jan 7 04:57 filelist.py > -rwxr-xr-x 1 thinker xthinksp 5223 Dec 2 00:24 hello > -rw-r--r-- 1 thinker xthinksp 152 Dec 2 00:24 hello.cpp > drwxrwx--- 6 thinker xthinksp 1024 Jan 7 19:54 k12math_rejected > -rw-r--r-- 1 thinker xthinksp 602 Jan 7 02:09 lll.py > drwxr-xr-x 7 thinker xthinksp 1024 Feb 15 21:10 mailreader > drwxr-xr-x 2 thinker xthinksp 1024 Feb 28 2000 math508proj > >>> > > > HTH > > -- > Sheila King > http://www.thinkspot.net/sheila/ > http://www.k12groups.org/ > From sheila at spamcop.net Mon Feb 26 15:51:47 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 26 Feb 2001 14:51:47 GMT Subject: output of shell command References: <3A99FC5D.158A407B@al.com.au> <97diqu$nq7ks$1@ID-11957.news.dfncis.de> Message-ID: <89rk9tki1umr876ct1lfggkg57e7ndhd8a@4ax.com> On Mon, 26 Feb 2001 04:38:58 -0800, "Emile van Sebille" wrote in comp.lang.python in article <97diqu$nq7ks$1 at ID-11957.news.dfncis.de>: :This works on my linux box and as Joe was looking for :'ls -l', I assume it'll work for him too. : :But as I hadn't used the commands module before, I tried it :on both my Win95 and Win2k boxes, where it failed to get the :right info. So, either I'm doing it wrong, or the :combination of commands and windows is broken, which I :suspect. : :However, a=os.popen("dir").readlines() works on windows and :linux. So if you're writing cross-platform, you'll want to :keep this in mind. Thanks for the tip. I didn't even try it out on Windows, since he was clearly asking about a *nix type command. I am looking to write cross-platform. One (of the many) reasons I'm enchanted with Python. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From joe at al.com.au Mon Feb 26 21:39:57 2001 From: joe at al.com.au (Joe Connellan) Date: Tue, 27 Feb 2001 07:39:57 +1100 Subject: output of shell command References: <3A99FC5D.158A407B@al.com.au> <97diqu$nq7ks$1@ID-11957.news.dfncis.de> <89rk9tki1umr876ct1lfggkg57e7ndhd8a@4ax.com> Message-ID: <3A9ABF1D.EE79FCD3@al.com.au> Thanks guys for the help, one note is that os.popen().readlines() of course will return a list of strings - lines of output, whereas commands.getoutput() will return a single string. So both will come in handy. Thanks again Joe Sheila King wrote: > > On Mon, 26 Feb 2001 04:38:58 -0800, "Emile van Sebille" wrote > in comp.lang.python in article <97diqu$nq7ks$1 at ID-11957.news.dfncis.de>: > > :This works on my linux box and as Joe was looking for > :'ls -l', I assume it'll work for him too. > : > :But as I hadn't used the commands module before, I tried it > :on both my Win95 and Win2k boxes, where it failed to get the > :right info. So, either I'm doing it wrong, or the > :combination of commands and windows is broken, which I > :suspect. > : > :However, a=os.popen("dir").readlines() works on windows and > :linux. So if you're writing cross-platform, you'll want to > :keep this in mind. > > Thanks for the tip. I didn't even try it out on Windows, since he was clearly > asking about a *nix type command. > > I am looking to write cross-platform. One (of the many) reasons I'm enchanted > with Python. > > -- > Sheila King > http://www.thinkspot.net/sheila/ > http://www.k12groups.org/ From sheila at spamcop.net Mon Feb 26 22:09:15 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 26 Feb 2001 21:09:15 GMT Subject: output of shell command References: <3A99FC5D.158A407B@al.com.au> <97diqu$nq7ks$1@ID-11957.news.dfncis.de> <89rk9tki1umr876ct1lfggkg57e7ndhd8a@4ax.com> <3A9ABF1D.EE79FCD3@al.com.au> Message-ID: On Tue, 27 Feb 2001 07:39:57 +1100, Joe Connellan wrote in comp.lang.python in article <3A9ABF1D.EE79FCD3 at al.com.au>: :Thanks guys for the help, one note is that os.popen().readlines() of :course will return a list of strings - lines of output, whereas :commands.getoutput() will return a single string. So both will come in :handy. : :Thanks again You can return a single string by turning the readlines() into read() like this: os.popen().read() Or, do this (silly): "\n".join(os.popen("dir").readlines())) -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From grante at visi.com Mon Feb 26 23:11:30 2001 From: grante at visi.com (Grant Edwards) Date: Mon, 26 Feb 2001 22:11:30 GMT Subject: output of shell command References: <3A99FC5D.158A407B@al.com.au> <97diqu$nq7ks$1@ID-11957.news.dfncis.de> <89rk9tki1umr876ct1lfggkg57e7ndhd8a@4ax.com> <3A9ABF1D.EE79FCD3@al.com.au> Message-ID: In article , Sheila King wrote: >:Thanks guys for the help, one note is that os.popen().readlines() of >:course will return a list of strings - lines of output, whereas >:commands.getoutput() will return a single string. So both will come in >:handy. > >You can return a single string by turning the readlines() into read() >like this: > >os.popen().read() > >Or, do this (silly): > >"\n".join(os.popen("dir").readlines())) [I swear, no matter how many times I see that syntax, it looks goofy.] Likewise, if you want a list of strings from commands.getoutput() you can use the split() method: commands.getoutput().split('\n') -- Grant Edwards grante Yow! Now I'm concentrating at on a specific tank battle visi.com toward the end of World War II! From sheila at spamcop.net Mon Feb 26 23:20:06 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 26 Feb 2001 22:20:06 GMT Subject: output of shell command References: <3A99FC5D.158A407B@al.com.au> <97diqu$nq7ks$1@ID-11957.news.dfncis.de> <89rk9tki1umr876ct1lfggkg57e7ndhd8a@4ax.com> <3A9ABF1D.EE79FCD3@al.com.au> Message-ID: <2ill9to346q16r08fqtipfuv8pcvnihaaf@4ax.com> On Mon, 26 Feb 2001 22:11:30 GMT, grante at visi.com (Grant Edwards) wrote in comp.lang.python in article : :In article , Sheila King wrote: :>You can return a single string by turning the readlines() into read() :>like this: :> :>os.popen().read() :> :>Or, do this (silly): :> :>"\n".join(os.popen("dir").readlines())) : :[I swear, no matter how many times I see that syntax, it looks :goofy.] I am not personally fond of it, myself. I wonder, that join should be a method of the LIST OF STRINGS, rather than of the string concatenator. I'm just trying to get more used to the 2.0 way of doing things. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ :Likewise, if you want a list of strings from commands.getoutput() :you can use the split() method: : :commands.getoutput().split('\n') From sholden at holdenweb.com Mon Feb 26 23:38:12 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 26 Feb 2001 17:38:12 -0500 Subject: output of shell command References: <3A99FC5D.158A407B@al.com.au> <97diqu$nq7ks$1@ID-11957.news.dfncis.de> Message-ID: "Emile van Sebille" wrote in message news:97diqu$nq7ks$1 at ID-11957.news.dfncis.de... > This works on my linux box and as Joe was looking for > 'ls -l', I assume it'll work for him too. > > But as I hadn't used the commands module before, I tried it > on both my Win95 and Win2k boxes, where it failed to get the > right info. So, either I'm doing it wrong, or the > combination of commands and windows is broken, which I > suspect. > > However, a=os.popen("dir").readlines() works on windows and > linux. So if you're writing cross-platform, you'll want to > keep this in mind. > Note, however, that under PythonWin: >>> import os >>> a=os.popen("dir").readlines() Traceback (innermost last): File "", line 1, in ? WindowsError: [Errno 2] The system cannot find the file specified Not sure why it works with a vanilla interpreter but not in PythonWin. regards Steve From m.hadfield at niwa.cri.nz Tue Feb 27 02:38:46 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Tue, 27 Feb 2001 14:38:46 +1300 Subject: output of shell command References: <3A99FC5D.158A407B@al.com.au> <97diqu$nq7ks$1@ID-11957.news.dfncis.de> Message-ID: <983237981.694338@clam-ext> "Steve Holden" wrote in message news:UYAm6.21417$P87.223264 at e420r-atl2.usenetserver.com... > Note, however, that under PythonWin: > > >>> import os > >>> a=os.popen("dir").readlines() > Traceback (innermost last): > File "", line 1, in ? > WindowsError: [Errno 2] The system cannot find the file specified I found, as you did that, this works only in console Python (using Python 2.0 + win32all-137 on Windows 2000). However the following a=(os.popen("dir")).readlines() works (returns a string array) in both console Python and PythonWin . > Not sure why it works with a vanilla interpreter but not in PythonWin. A subtle difference in operator precedence? --- Mark Hadfield m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield National Institute for Water and Atmospheric Research From ben.hutchings at roundpoint.com Tue Feb 27 23:01:11 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 27 Feb 2001 14:01:11 -0800 Subject: output of shell command References: <3A99FC5D.158A407B@al.com.au> <97diqu$nq7ks$1@ID-11957.news.dfncis.de> <983237981.694338@clam-ext> Message-ID: "Mark Hadfield" writes: > "Steve Holden" wrote in message > news:UYAm6.21417$P87.223264 at e420r-atl2.usenetserver.com... > > Note, however, that under PythonWin: > > > > >>> import os > > >>> a=os.popen("dir").readlines() > > Traceback (innermost last): > > File "", line 1, in ? > > WindowsError: [Errno 2] The system cannot find the file specified > > I found, as you did that, this works only in console Python (using Python > 2.0 + win32all-137 on Windows 2000). However the following > > a=(os.popen("dir")).readlines() > > works (returns a string array) in both console Python and PythonWin . > > > Not sure why it works with a vanilla interpreter but not in PythonWin. > > A subtle difference in operator precedence? Oh, come on. One thing that absolutely mustn't vary between different Python environments is operator precedence. This may have something to do with the fact that the DOS/Windows "dir" command is built into the standard command interpreter (command.com or cmd.exe) and is not callable directly - CreateProcess("dir", ...) won't work but CreateProcess("command", "command /c dir", ...) will. os.popen("dir").readlines() works for me in PythonWin 2.0 #8 on Windows 2000 SP1, but I would not be surprised to find that it fails to work on Windows 98, though - there are large differences between the command interpreters and pipe implementations in different versions of Windows. For that matter, the output format of dir may differ too. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From m.hadfield at niwa.cri.nz Tue Feb 27 23:13:31 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Wed, 28 Feb 2001 11:13:31 +1300 Subject: output of shell command References: <3A99FC5D.158A407B@al.com.au> <97diqu$nq7ks$1@ID-11957.news.dfncis.de> <983237981.694338@clam-ext> Message-ID: <983312067.173004@clam-ext> "Ben Hutchings" wrote in message news:u3dczkcpk.fsf at roundpoint.com...> > os.popen("dir").readlines() works for me in PythonWin 2.0 #8 on > Windows 2000 SP1, but I would not be surprised to find that it fails > to work on Windows 98, though - there are large differences between > the command interpreters and pipe implementations in different > versions of Windows. For that matter, the output format of dir may > differ too. As I reported in my message yesterday, when I tried os.popen("dir").readlines() in PythonWin (win32all-137) on Windows 200 it failed. Today I tried it again & it worked. Why would that be? I'm picking operator error. So why did it fail under PythonWin on Steve Holden's machine? Win98 vs Win2000? Operator error again? What do you think, Steve? --- Mark Hadfield m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield National Institute for Water and Atmospheric Research From sholden at holdenweb.com Tue Feb 27 23:52:34 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 27 Feb 2001 17:52:34 -0500 Subject: output of shell command References: <3A99FC5D.158A407B@al.com.au> <97diqu$nq7ks$1@ID-11957.news.dfncis.de> <983237981.694338@clam-ext> <983312067.173004@clam-ext> Message-ID: "Mark Hadfield" wrote in message news:983312067.173004 at clam-ext... > "Ben Hutchings" wrote in message > news:u3dczkcpk.fsf at roundpoint.com...> > > > os.popen("dir").readlines() works for me in PythonWin 2.0 #8 on > > Windows 2000 SP1, but I would not be surprised to find that it fails > > to work on Windows 98, though - there are large differences between > > the command interpreters and pipe implementations in different > > versions of Windows. For that matter, the output format of dir may > > differ too. > But this still doesn't explain the difference between the vanilla interpreter result and PythonWin's attempt. > As I reported in my message yesterday, when I tried > os.popen("dir").readlines() in PythonWin (win32all-137) on Windows 200 it > failed. Today I tried it again & it worked. Why would that be? I'm picking > operator error. > Dunno. Still won't work for me on Windows 98. Neither, come to that, does the parenthesized version a=(os.popen("dir")).readlines() I get the same error. > So why did it fail under PythonWin on Steve Holden's machine? Win98 vs > Win2000? Operator error again? What do you think, Steve? > I think I'm going to stop trying to do it under PythonWin. There are *real* problems I have to work on :-) regards Steve From m.hadfield at niwa.cri.nz Wed Feb 28 00:06:19 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Wed, 28 Feb 2001 12:06:19 +1300 Subject: output of shell command References: <3A99FC5D.158A407B@al.com.au> <97diqu$nq7ks$1@ID-11957.news.dfncis.de> <983237981.694338@clam-ext> <983312067.173004@clam-ext> Message-ID: <983315235.473229@clam-ext> "Steve Holden" wrote in message news:pgWm6.169$jv4.27104 at e420r-atl2.usenetserver.com... > Dunno. Still won't work for me on Windows 98. Neither, come to that, does > the parenthesized version > > a=(os.popen("dir")).readlines() > > I get the same error. OK so the parentheses were a red herring. It's a difference in the behaviour of piping in windowed applications vs console applications under Windows 9x. --- Mark Hadfield m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield National Institute for Water and Atmospheric Research From db3l at fitlinxx.com Wed Feb 28 02:45:33 2001 From: db3l at fitlinxx.com (David Bolen) Date: 27 Feb 2001 20:45:33 -0500 Subject: output of shell command References: <3A99FC5D.158A407B@al.com.au> <97diqu$nq7ks$1@ID-11957.news.dfncis.de> <983237981.694338@clam-ext> <983312067.173004@clam-ext> <983315235.473229@clam-ext> Message-ID: "Mark Hadfield" writes: > "Steve Holden" wrote in message > news:pgWm6.169$jv4.27104 at e420r-atl2.usenetserver.com... > > Dunno. Still won't work for me on Windows 98. Neither, come to that, does > > the parenthesized version > > > > a=(os.popen("dir")).readlines() > > > > I get the same error. > > OK so the parentheses were a red herring. It's a difference in the behaviour > of piping in windowed applications vs console applications under Windows 9x. I don't recall if the version of Python was noted in this thread yet, but there are definite issues and differences with console versus windowed applications in os.popen with Python 1.5.2, and still some environmental dependencies with Python 2.x. In Python 1.5.2, os.popen is a direct call to the underlying C popen() function, which under Windows requires that there be a console to be reliable under NT, and may not be reliable at all under Windows 9x. In Python 2.x (and maybe 1.6), os.popen borrowed code from the win32all package (which you can also use under Python 1.5.2 as win32pipe.popen()) which works properly in both console and windowed environments. But under Windows 9x, it needs a helper application (win32popenWin9x.exe under win32all, or w9xpopen.exe under Python 2.x) to function properly. It's possible that under Pythonwin, the appropriate utility isn't being found on your path, which may differ from the path you get in a command prompt or in other tools. Python should return a runtime error describing this file, but perhaps that's being absorbed in Pythonwin or something. Just as an experiment you might try placing that file (it's in the Python 2.0 main directory or the win32 subdirectory with win32all) in a directory known to be in your main path. I think Mark Hammond may have posted recently on this issue and suggested copying the executable into the same directory as PythonWin.exe - yep, that was the suggestion. I don't know how to make a canonical reference to Google's newsgroup stuff yet, but if you search for "w9xpopen pythonwin" on http://groups.google.com it'll bring it up. -- -- 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 MarkH at ActiveState.com Wed Feb 28 11:26:13 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 28 Feb 2001 10:26:13 GMT Subject: output of shell command References: <3A99FC5D.158A407B@al.com.au> <97diqu$nq7ks$1@ID-11957.news.dfncis.de> <983237981.694338@clam-ext> <983312067.173004@clam-ext> <983315235.473229@clam-ext> Message-ID: <3A9CD16C.70206@ActiveState.com> David Bolen wrote: > It's possible that under Pythonwin, the appropriate utility isn't > being found on your path, which may differ from the path you get in a > command prompt or in other tools. Actually, Python looks explicitly in the directory of the current executable. This is a bug - see my message above. > Python should return a runtime > error describing this file, but perhaps that's being absorbed in > Pythonwin or something. Python just blindly added the (wrong) path to w9xpopen.exe to the commandline, and this command is what is failing. Python 2.1 at least will tell you specifically that w9xpopen.exe can not be found. Mark. From MarkH at ActiveState.com Wed Feb 28 11:21:30 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 28 Feb 2001 10:21:30 GMT Subject: output of shell command References: <3A99FC5D.158A407B@al.com.au> <97diqu$nq7ks$1@ID-11957.news.dfncis.de> <983237981.694338@clam-ext> <983312067.173004@clam-ext> Message-ID: <3A9CD052.1040804@ActiveState.com> Steve Holden wrote: > "Mark Hadfield" wrote in message > news:983312067.173004 at clam-ext... > >> "Ben Hutchings" wrote in message >> news:u3dczkcpk.fsf at roundpoint.com...> >> >> > os.popen("dir").readlines() works for me in PythonWin 2.0 #8 on >> >>> Windows 2000 SP1, but I would not be surprised to find that it fails >>> to work on Windows 98, though - there are large differences between >>> the command interpreters and pipe implementations in different >>> versions of Windows. For that matter, the output format of dir may >>> differ too. >> > But this still doesn't explain the difference between the vanilla > interpreter result and PythonWin's attempt. Sorry, I missed the start of this thread. There us a bug in Python 2.0 and popen. It still exists to some extent in 2.1, but the error given is much more reasonable. The work-around is to copy w9xpopen.exe to the same dir as Pythonwin.exe Mark. From dsh8290 at rit.edu Tue Feb 27 20:16:53 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 27 Feb 2001 14:16:53 -0500 Subject: output of shell command In-Reply-To: <97diqu$nq7ks$1@ID-11957.news.dfncis.de>; from emile@fenx.com on Mon, Feb 26, 2001 at 04:38:58AM -0800 References: <3A99FC5D.158A407B@al.com.au> <97diqu$nq7ks$1@ID-11957.news.dfncis.de> Message-ID: <20010227141653.A20047@harmony.cs.rit.edu> On Mon, Feb 26, 2001 at 04:38:58AM -0800, Emile van Sebille wrote: | However, a=os.popen("dir").readlines() works on windows and | linux. So if you're writing cross-platform, you'll want to | keep this in mind. | This assumes the command exists in the PATH on both systems and works the same way. Normally "ls" doesn't exist on Windows. It's possible that "dir" exists on Linux, but I've never tried it. Other *nix's may or may not have a "dir" command. For this particular case, listing a directory, it would be better to use : import os import string dir_list = os.listdir( os.getcwd() ) print string.join( dir_list , "\n" ) As it will work on all platforms regardless of the existence/name/semantics of external commands. -D From thomas at cintra.no Mon Feb 26 09:38:47 2001 From: thomas at cintra.no (Thomas Weholt) Date: Mon, 26 Feb 2001 09:38:47 +0100 Subject: HowTo Fix illegal chars in xml-documents?? Message-ID: Hi, I'm trying to "convert" alot of legacy information into collection of xml-documents. In the old data there are alot of characters that are illegal if used in the character part of the XML, like &, ;, < and >. I've tried to make a quick-fix for this, to swap these characters with the proper HTML-alternative, like ; for ; etc. but haven't found a really good way of doing this. I need to be able to swap the old chars back too, but that's not very important now. Does anybody have a clue or a piece of code to get me going? As of now, a great deal of the converted documents are not proper xml-documents and will not get parsed at all. Thanks in advance, Thomas From andreas at digicool.com Mon Feb 26 13:30:16 2001 From: andreas at digicool.com (Andreas Jung) Date: Mon, 26 Feb 2001 07:30:16 -0500 Subject: HowTo Fix illegal chars in xml-documents?? References: Message-ID: <000001c09ff6$84f53ed0$d0063bd0@SUXLAP> I remember there is a tool "xp" in the SP package (a tool for SGML conversion....). This utility allows to make SGML documents XML compliant by fixing several problems. I have used in a project with about 10.000.000 SGML documents where my own "SGMl2XML" converter had problems due to invalid tagging or wrong entities. Andreas ----- Original Message ----- From: "Thomas Weholt" Newsgroups: comp.lang.python To: Sent: Monday, February 26, 2001 3:38 AM Subject: HowTo Fix illegal chars in xml-documents?? > Hi, > > I'm trying to "convert" alot of legacy information into collection of > xml-documents. In the old data there are alot of characters that are illegal > if used in the character part of the XML, like &, ;, < and >. I've tried to > make a quick-fix for this, to swap these characters with the proper > HTML-alternative, like ; for ; etc. but haven't found a really good way > of doing this. I need to be able to swap the old chars back too, but that's > not very important now. Does anybody have a clue or a piece of code to get > me going? As of now, a great deal of the converted documents are not proper > xml-documents and will not get parsed at all. > > Thanks in advance, > Thomas > > > -- > http://mail.python.org/mailman/listinfo/python-list From info at pythonware.com Mon Feb 26 10:04:32 2001 From: info at pythonware.com (PythonWare) Date: Mon, 26 Feb 2001 10:04:32 +0100 Subject: ANN: xmlrpclib 0.9.9 Message-ID: <00ad01c09fd3$3116fd80$0900a8c0@SPIFF> it's monday. it's release day: Secret Labs' xmlrpclib is a widely popular implementation of the XML-RPC remote call protocol (http://xmlrpc.com). Version 0.9.9 (aka 1.0 beta 1) adds support for XML encodings, Unicode, and safe transports (via https). Get your copy from http://www.pythonware.com/products/xmlrpc enjoy, the pythonware team "Secret Labs -- makers of fine pythonware since 1997." PS. While you're at it, vote for your favourite XML-RPC developer at: http://www.activestate.com/Awards From tismer at tismer.com Mon Feb 26 10:56:56 2001 From: tismer at tismer.com (Christian Tismer) Date: Mon, 26 Feb 2001 10:56:56 +0100 Subject: ActiveState Active Awards voting is broken Message-ID: <3A9A2868.E5E56F2C@tismer.com> Hi ActiveState, your voting for a programmer's choice for Perl and Python is a great idea. Unfortunately you missed to do some testing. In its current form, it is unusable, since both the Perl and the Python radios are in the same group. There is no way to vote at all at the moment. See http://www.activestate.com/cgibin/award/vote.html After the fix, I encourage all Python users not to give up and to come back to http://www.activestate.com/Awards/ cheers - chris p.s.: I would also suggest not to force everybody to vote for both languages. Many of us (including me) have no idea about the core people of the other group and can't do a fair voting. -- Christian Tismer :^) Mission Impossible 5oftware : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net/ 14163 Berlin : PGP key -> http://wwwkeys.pgp.net/ PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com/ From tismer at tismer.com Mon Feb 26 12:26:27 2001 From: tismer at tismer.com (Christian Tismer) Date: Mon, 26 Feb 2001 12:26:27 +0100 Subject: Sorry!! (ActiveState Active Awards voting is not! broken) References: <3A9A2868.E5E56F2C@tismer.com> Message-ID: <3A9A3D63.D3E274E2@tismer.com> Sorry, this was an oversight: Christian Tismer wrote: > > Hi ActiveState, > > your voting for a programmer's choice for Perl and Python > is a great idea. > > Unfortunately you missed to do some testing. In its current > form, it is unusable, since both the Perl and the Python radios > are in the same group. There is no way to vote at all at the moment. > See http://www.activestate.com/cgibin/award/vote.html > > After the fix, I encourage all Python users not to give up > and to come back to http://www.activestate.com/Awards/ > > cheers - chris > > p.s.: I would also suggest not to force everybody to vote > for both languages. Many of us (including me) have no > idea about the core people of the other group and can't do > a fair voting. My misunderstanding was that I thought I had to choose for both languages at the same time. Apologies for my dumbness - chris -- Christian Tismer :^) Mission Impossible 5oftware : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net/ 14163 Berlin : PGP key -> http://wwwkeys.pgp.net/ PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com/ From nicky001 at gofree.indigo.ie Mon Feb 26 10:57:47 2001 From: nicky001 at gofree.indigo.ie (Nicky White) Date: Mon, 26 Feb 2001 09:57:47 -0000 Subject: Problems compiling with python libraries Message-ID: Hi, I am trying to compile some C code which will allow me to call some python modules from within a C program. The code I'm using is sample code and it compiles ok. I cannot get it to link however. It version 1.52 of python running on Red Hat 6.1. I have all the rpm's installed (python-devel etc.). The compile line is: gcc -I/usr/include/python1.5 -L/usr/lib/python1.5/config -lpython1.5 -o embed embed.c Functions such as PyImport_ImportModule() , which I call from within the program , cannot be found by the linker. Anyone know what the right linker options should be? Thanks, Nicky From phd at phd.russ.ru Mon Feb 26 11:10:44 2001 From: phd at phd.russ.ru (Oleg Broytmann) Date: Mon, 26 Feb 2001 13:10:44 +0300 (MSK) Subject: Spamcopped In-Reply-To: Message-ID: Hello! On Thu, 22 Feb 2001, Chris Withers wrote: > > If SpamCop does the same, whay it's better? (I really interesting...) > > SpamCop is also very well respected. In fact, I've read the some ISPs value > SpamCop reports a lot more than hand written emails to their abuse addresses. Thank you very much! The SpamCop.NET service proved to be very good!!! I took their perl script and rewrote it to Python. Julian gladly accepted the script on http://spamcop.net/fom-serve/cache/166.html. I'm attaching the script here too, for archiving purpose. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. -------------- next part -------------- #! /usr/local/bin/python -O """Spamcop reporter. This program is a translation of a perl script published on http://spamcop.net/fom-serve/cache/166.html to Python. Author: Oleg BroytMann """ # The programs expects UCE with full headers to be fed into its stdin. # After it forwards the message to SpamCop, it opens additional filehandle # to read from /dev/tty and waits for Enter. This is to report that the spam # was successfully forwarded. ### IMPORTANT! IMPORTANT! IMPORTANT! ### Put you *real* address or forwarder here ### Because some "abuse departments" may collect such addresses to ### flood you with additional spam (UCE) you may register additional ### addres specially for this. There are many free e-mail providers to ### help you. my_real_address = "user at host.domain" # open a pipe to sendmail import os sendmail = os.popen("/usr/lib/sendmail -oi -t", 'w') # write headers and simulate MIME attachments in the body of the message sendmail.write("""From: %s To: spamcop at spamcop.net Subject: reply anyway MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="DeathToSpamDeathToSpamDeathToSpam" This is a multi-part message in MIME format. --DeathToSpamDeathToSpamDeathToSpam Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit --DeathToSpamDeathToSpamDeathToSpam Content-Type: message/rfc822 Content-Disposition: attachment """ % my_real_address) # copy stdin to the pipe import sys while 1: line = sys.stdin.readline() if not line: break sendmail.write(line) # finish MIME part sendmail.write(""" --DeathToSpamDeathToSpamDeathToSpam-- """) # report success print print "Message forwarded" print "Press Enter to continue" # open /dev/tty for reading and wait for Enter key; this is needed because # stdin is not available (there was UCE fed into stdin, do you remember?) tty = open("/dev/tty", 'r') line = tty.readline() tty.close() From j_lockley at hotmail.com Mon Feb 26 11:53:50 2001 From: j_lockley at hotmail.com (James Lockley) Date: Mon, 26 Feb 2001 12:53:50 +0200 Subject: deleting files Message-ID: <97dc8q$mlc$1@news.adamastor.ac.za> hi i want to delete a file created after a particular time ( ie something like if os.path.getmtime(file)>t0: ) i've looked through shutil and can't find anything to use... (i don't want to delete tree so rmtree is of no use) thanx in advance james From thomas at xs4all.net Mon Feb 26 12:11:04 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 26 Feb 2001 12:11:04 +0100 Subject: deleting files In-Reply-To: <97dc8q$mlc$1@news.adamastor.ac.za>; from j_lockley@hotmail.com on Mon, Feb 26, 2001 at 12:53:50PM +0200 References: <97dc8q$mlc$1@news.adamastor.ac.za> Message-ID: <20010226121103.N16781@xs4all.nl> On Mon, Feb 26, 2001 at 12:53:50PM +0200, James Lockley wrote: > i want to delete a file created after a particular time ( ie something like > if os.path.getmtime(file)>t0: ) > i've looked through shutil and can't find anything to use... (i don't want > to delete tree so rmtree is of no use) Deleting a single file is done using os.remove(). Deleting a directory is done using 'os.rmdir()'. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From stephen_purcell at yahoo.com Mon Feb 26 12:11:55 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Mon, 26 Feb 2001 12:11:55 +0100 Subject: deleting files In-Reply-To: <97dc8q$mlc$1@news.adamastor.ac.za>; from j_lockley@hotmail.com on Mon, Feb 26, 2001 at 12:53:50PM +0200 References: <97dc8q$mlc$1@news.adamastor.ac.za> Message-ID: <20010226121155.A6952@freedom.puma-ag.com> James Lockley wrote: > i want to delete a file created after a particular time ( ie something like > if os.path.getmtime(file)>t0: ) > i've looked through shutil and can't find anything to use... (i don't want > to delete tree so rmtree is of no use) You want: os.unlink(filename) -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 ajung-ml at andreas-jung.com Mon Feb 26 14:21:46 2001 From: ajung-ml at andreas-jung.com (Andreas Jung) Date: Mon, 26 Feb 2001 08:21:46 -0500 Subject: deleting files References: <97dc8q$mlc$1@news.adamastor.ac.za> Message-ID: <007001c09ff7$205e3fc0$d0063bd0@SUXLAP> you can get the modification or creation time of a file through os.stat(). It returns a tuple of informations about the file (modification time,creation time, file size). By checking the creation time you can remove the file by using os.unlink(). Andreas ----- Original Message ----- From: "James Lockley" Newsgroups: comp.lang.python To: Sent: Monday, February 26, 2001 5:53 AM Subject: deleting files > hi > > i want to delete a file created after a particular time ( ie something like > if os.path.getmtime(file)>t0: ) > i've looked through shutil and can't find anything to use... (i don't want > to delete tree so rmtree is of no use) > > thanx in advance > james > > > -- > http://mail.python.org/mailman/listinfo/python-list From thomas at cintra.no Mon Feb 26 12:26:17 2001 From: thomas at cintra.no (Thomas Weholt) Date: Mon, 26 Feb 2001 12:26:17 +0100 Subject: Translate XSLT/XPath-patterns into regular expressions? Message-ID: I need to translate patterns similar to those used in XSLT/XPath into regular expressions. Typical examples are '/sometag/*/mytag' matching every 'mytag' that has 'sometag' as root-node, regardless of tags inbetween them. Another example could be '/sometag/my*' matching every tag starting with 'my' that has 'sometag' as parent and root-node. Not being good at regular expressions at all ( just started at the HowTo actually ), could anyone give a clue on how to go about this or point to sites/docs with more information about regular expressions ( preferrably using Python, but all general information is of interest ) ? The last question; what is the status of available modules for regular expression in Python and are there problems with them one should be aware of? PS! What about the book from Oreilly, 'Mastering Regular Expressions'? It seemed very pro-Perl, at least from the table of contents. Are the information given in it easily used in Python too? Thomas From timin at homeSPAMNOT.com Mon Feb 26 16:07:08 2001 From: timin at homeSPAMNOT.com (timin at homeSPAMNOT.com) Date: Mon, 26 Feb 2001 15:07:08 GMT Subject: input() vs. raw_input() Message-ID: <3A9A7142.D81F9604@home.com> For console input to an executing program, I find that raw_input("prompt") works very well. In fact it works the way I would have expected input("prompt") to work. The latter, however, seems to funtion as if the input text is part of a program being compiled. Can someone explain what is going on here, and why "raw" is part of the name? -- "Always yield to temptation, because it may not pass your way again." From dbrueck at edgix.com Mon Feb 26 16:34:05 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Mon, 26 Feb 2001 08:34:05 -0700 Subject: input() vs. raw_input() In-Reply-To: <3A9A7142.D81F9604@home.com> Message-ID: raw_input - returns input in its unprocessed ("raw") form input - gets raw input, sends it to eval(), and returns the result -Dave > -----Original Message----- > From: python-list-admin at python.org > [mailto:python-list-admin at python.org]On Behalf Of timin at homeSPAMNOT.com > Sent: Monday, February 26, 2001 8:07 AM > To: python-list at python.org > Subject: input() vs. raw_input() > > > For console input to an executing program, I find that raw_input("prompt") > works very well. In fact it works the way I would have expected > input("prompt") to work. The latter, however, seems to funtion as if the > input text is part of a program being compiled. Can someone > explain what is > going on here, and why "raw" is part of the name? > > -- > "Always yield to temptation, because it may not pass your way again." > > -- > http://mail.python.org/mailman/listinfo/python-list From itamar at maxnm.com Mon Feb 26 16:29:31 2001 From: itamar at maxnm.com (Itamar Shtull-Trauring) Date: Mon, 26 Feb 2001 17:29:31 +0200 Subject: Getting Unicode filenames in Windows 2000 Message-ID: <3A9A765B.BBE9FA29@maxnm.com> I have a file whose name is part Hebrew, part English on my W2K VMware install. I'm running BeOpen Python 2.0, with the latest Pythonwin installed. My problem - the os.listdir() command doesn't return the name of the file in unicode, it just replaces the hebrew characters with question marks - '?': >>> l = os.listdir("c:\\") >>> l[-1] '????.txt' >>> type(l[-1]) 1. How can I get the list of files in a directory in unicode? I would prefer a cross-platform solution that doesn't use the win32 API. 2. If this behavior is because of backwards compatability, perhaps os.listdir should be changed so that when passed strings it returns strings and when passed a unicode string path it returns unicode strings? -- Email: itamar at shtull-trauring.org Web: http://itamarst.org From nelson at crynwr.com Mon Feb 26 17:07:47 2001 From: nelson at crynwr.com (Russell Nelson) Date: Mon, 26 Feb 2001 11:07:47 -0500 Subject: GPS application needs an expert's touch Message-ID: <3A9A7F53.EB5C907E@crynwr.com> Hi. I have implemented a GPS application in Python/pygtk/glade. It works, for mildly varying values of "work". However, I'm not sure that it's very well written. Okay, I'm sure it *isn't* well written. Could you take a look at http://russnelson.com/ipaq/gps/ and tell me what I've done wrong? I'm not looking for bug fixes, I'm looking for general comments like "If you had a clue, you'd do it this way." Go ahead, savage my Python coding style. -- -russ nelson http://russnelson.com Crynwr sells support for free software | PGPok | "This is Unix... 521 Pleasant Valley Rd. | +1 315 268 1925 voice | Stop acting so helpless." Potsdam, NY 13676-3213 | +1 315 268 9201 FAX | --Daniel J. Bernstein From danielk at aracnet.com Mon Feb 26 17:08:30 2001 From: danielk at aracnet.com (Daniel Klein) Date: Mon, 26 Feb 2001 08:08:30 -0800 Subject: is and == Message-ID: Just a quick question I hope as an equally quick (and easy) answer... Is there a functional difference between 'is' and '==' ? If there is, I can't find it. Daniel Klein From aleaxit at yahoo.com Mon Feb 26 17:27:22 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 26 Feb 2001 17:27:22 +0100 Subject: is and == References: Message-ID: <97e05e02h58@news1.newsguy.com> "Daniel Klein" wrote in message news:movk9t0una5nuca6upgk9rcco96fbkeu51 at 4ax.com... > Just a quick question I hope as an equally quick (and easy) answer... > > Is there a functional difference between 'is' and '==' ? If there is, I can't > find it. There is a vast functional difference: 'is' verifies the two operands refer to the SAME object (identity); '==' is much more easily satisfied -- it compares the values of the operands, and is true, not just for identity, but for any equality. For example: >>> onelist = [1,2,3] >>> another = [1,2,3] >>> onelist is another 0 >>> onelist == another 1 >>> analias = onelist >>> analias is onelist 1 >>> analias == onelist 1 >>> If you care about whether onelist and another refer to the SAME object, then 'is' is the right test; if you care about whether the (possibly distinct) objects to which they refer happen to have equal values right now (although differing in identity), then '==' is the right test. If 'is' returns true, then any alteration to the (one and only) object referred to will be seen from any of the references to it; '==' implies no such effect. I.e., in the above example, if you do a onelist.append(4), then you will also observe, e.g., len(analias) becomes 4, but another remains completely unaffected, and the == test has now become false (the two separate and distinct objects that onelist and another refer to used to be of equal value, but this becomes false if and when one is altered and the other one is not). Alex From aahz at panix.com Mon Feb 26 17:45:30 2001 From: aahz at panix.com (Aahz Maruch) Date: 26 Feb 2001 08:45:30 -0800 Subject: is and == References: Message-ID: <97e17a$o3o$1@panix6.panix.com> In article , Daniel Klein wrote: > >Is there a functional difference between 'is' and '==' ? If there is, I can't >find it. >>> a = 'xy' >>> b = a >>> c = 'x' + 'y' >>> d = 'xy' >>> a is b 1 >>> a is d 1 >>> a is c 0 >>> a == c 1 Essentially, is tests for object identity: are two variables pointing to the same location in memory. == tests to see whether the *values* are equal. -- --- 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 "I used to have a .sig but I found it impossible to please everyone..." --SFJ From joconnor at cybermesa.com Mon Feb 26 17:59:34 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Mon, 26 Feb 2001 09:59:34 -0700 Subject: is and == References: <97e17a$o3o$1@panix6.panix.com> Message-ID: <3A9A8B76.777FCA6A@cybermesa.com> Aahz Maruch wrote: > In article , > Daniel Klein wrote: > > > >Is there a functional difference between 'is' and '==' ? If there is, I can't > >find it. > > >>> a = 'xy' > >>> b = a > >>> c = 'x' + 'y' > >>> d = 'xy' > >>> a is b > 1 > >>> a is d > 1 > >>> a is c > 0 > >>> a == c > 1 > > Essentially, is tests for object identity: are two variables pointing to > the same location in memory. == tests to see whether the *values* are > equal. Consider the following example >>> class TestVal: def __init__(self): self.x = 100 def __cmp__(self, other): return cmp (self.x, other.x) >>> x = TestVal() >>> y = TestVal() >>> x == y 1 >>> x is y 0 >>> x =y >>> x is y 1 x == y is true because I've defined what == means, a value comparison, but x is y is false because they are not both the same object. However by assign the variable x to be y, I now get true for "x is y" because they are now the same object Take care, Jay From stephen_purcell at yahoo.com Mon Feb 26 17:50:23 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Mon, 26 Feb 2001 17:50:23 +0100 Subject: is and == In-Reply-To: ; from danielk@aracnet.com on Mon, Feb 26, 2001 at 08:08:30AM -0800 References: Message-ID: <20010226175023.A7401@freedom.puma-ag.com> Daniel Klein wrote: > Is there a functional difference between 'is' and '==' ? If there is, I can't > find it. There is indeed a difference. 'is' is an identity test, and '==' is an equality test: >>> a = [] >>> b = [] >>> a is b 0 >>> a == b 1 In many cases for standard python types, you won't find a difference, though. String literals are invisibly re-used internally by Python ("interned"): >>> a = "hello" >>> b = "hello" >>> a is b 1 >>> a == b 1 But beware of: >>> a = "hel" + "lo" >>> b = "hel" + "lo" >>> a is b 0 >>> a == b 1 Integers are both equal *and* identical: >>> a = 1 >>> b = 1 >>> a is b 1 >>> a == b 1 -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 phd at phd.pp.ru Mon Feb 26 17:56:45 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Mon, 26 Feb 2001 19:56:45 +0300 (MSK) Subject: is and == In-Reply-To: <20010226175023.A7401@freedom.puma-ag.com> Message-ID: On Mon, 26 Feb 2001, Steve Purcell wrote: > Integers are both equal *and* identical: > > >>> a = 1 > >>> b = 1 > >>> a is b > 1 > >>> a == b > 1 Not all integers - only 0 <= i < 100: >>> a = 217 >>> b = 217 >>> a is b 0 >>> a == b 1 :) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From dbrueck at edgix.com Mon Feb 26 18:00:35 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Mon, 26 Feb 2001 10:00:35 -0700 Subject: is and == In-Reply-To: <20010226175023.A7401@freedom.puma-ag.com> Message-ID: > [mailto:python-list-admin at python.org]On Behalf Of Steve Purcell > Sent: Monday, February 26, 2001 9:50 AM > To: Daniel Klein > Cc: python-list at python.org > Subject: Re: is and == < snip > > Integers are both equal *and* identical: > > >>> a = 1 > >>> b = 1 > >>> a is b > 1 > >>> a == b > 1 Not necessarily: >>> a = 10000 >>> b = 10000 >>> a is b 0 >>> a = 5 >>> b = 5 >>> a is b 1 The interpreter "caches" integer objects from something like -1 to 100, so 'is' evaluates to true for low integers but not higher integers. (Also, as the docs point out, this caching means that from inside an extension module you could _redefine_ the value of the integer object 5, for example: >>> evilext.causehavoc(5,10) # sets '5' object to have int value of 10 >>> 5 + 5 20 # Whee!!! ) -Dave From arneh at ifi.uio.no Mon Feb 26 18:34:22 2001 From: arneh at ifi.uio.no (Arne Martin =?iso-8859-1?Q?G=FCettler?=) Date: Mon, 26 Feb 2001 18:34:22 +0100 Subject: is and == References: Message-ID: <3A9A939E.B025D388@ifi.uio.no> Oleg Broytmann wrote: > > On Mon, 26 Feb 2001, Steve Purcell wrote: > > Integers are both equal *and* identical: > > > Not all integers - only 0 <= i < 100: > > >>> a = 217 > >>> b = 217 > >>> a is b > 0 > >>> a == b > 1 They might be: >>> a,b = 217,217 >>> a is b 1 >>> a == b 1 :-) -- -am From mjackson at wc.eso.mc.xerox.com Mon Feb 26 19:20:10 2001 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 26 Feb 2001 18:20:10 GMT Subject: is and == References: Message-ID: <97e6oq$gdv$1@news.wrc.xerox.com> "Dave Brueck" writes: > The interpreter "caches" integer objects from something like -1 to 100, so > 'is' evaluates to true for low integers but not higher integers. > > (Also, as the docs point out, this caching means that from inside an > extension module you could _redefine_ the value of the integer object 5, for > example: > > >>> evilext.causehavoc(5,10) # sets '5' object to have int value of 10 > >>> 5 + 5 > 20 # Whee!!! Woah. Fortran flashbacks. . . -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson Having your book made into a movie is like having your ox made into a bouillon cube. - Bill Neely From ben.hutchings at roundpoint.com Tue Feb 27 03:19:56 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 26 Feb 2001 18:19:56 -0800 Subject: is and == References: Message-ID: Steve Purcell writes: > Daniel Klein wrote: > > Is there a functional difference between 'is' and '==' ? If there is, > > I can't find it. > > There is indeed a difference. > > 'is' is an identity test, and '==' is an equality test: > Integers are both equal *and* identical: > > >>> a = 1 > >>> b = 1 > >>> a is b > 1 > >>> a == b > 1 but only if they're small integers (the above doesn't work for 1000, for instance). What 'is' does is to test whether two names refer to the same object. For objects of mutable types (such as lists and class types), this may be important: >>> a = [1] >>> b = a >>> a == b 1 >>> a is b 1 >>> a.append(2) >>> b [1, 2] Here, b refers to the same list as a, so not only are they equal but a change made through a is also visible through b. >>> a = [1] >>> b = [1] >>> a == b 1 >>> a is b 0 >>> a.append(2) >>> b [1] Here, a and b initially refer to identical (that is, equal) lists, but they are separate lists so a change made through a is not visible through b. With immutable types, obviously, there's no issue of changes being visible through another name, so Python can safely conserve memory by eliminating duplicate objects. I think this currently only happens with small integers and string literals. For the same reason, I'm not sure that it's at all useful to test whether two names referring to immutable objects actually refer to the same object. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From danielk at aracnet.com Tue Feb 27 05:13:45 2001 From: danielk at aracnet.com (Daniel Klein) Date: Mon, 26 Feb 2001 20:13:45 -0800 Subject: is and == References: Message-ID: Thanks for the clarification everyone. I knew the difference between identity and equality from working with Smalltalk, I just didn't realize that this was how Python made the distinction. Next time, I'll do a bit more investigation before posting and maybe even rtfm. :^) Dan "Most of us would rather risk catastrophy than read the directions." -- unknown From NoSpam at NoSpam.com Mon Feb 26 18:21:43 2001 From: NoSpam at NoSpam.com (Tom) Date: Mon, 26 Feb 2001 17:21:43 GMT Subject: Splitting comp.lang.python References: Message-ID: "Mikael Olofsson" wrote in message news:mailman.983199848.8916.python-list at python.org... > > On 01-Mar-00 Gerrit Holl wrote: > > > > > Perhaps the best thing would be to keep c.l.py as it is as the general > > > place for discussion, and then adding subgroups for specific interests. > > > > Perl uses: > > > > comp.lang.perl.announce > > comp.lang.perl.misc > > comp.lang.perl.tk > > comp.lang.perl.modules > > comp.lang.perl > > comp.lang.perl.moderated > > > > Maybe it's a good idea too do something like that on c.l.py. > > Not necessarily exactly those subgroups, but definitely something in > that direction, yes. Based on my first post in this thread, I come up > with the following > > c.l.py General > c.l.py.gui GUI > c.l.py.os os/platform dependent issues > c.l.py.db DataBase handling > c.l.py.advocacy Whitespace and such Yes, I think this is a very good idea - c.l.p. is too high volume. But what about api (c/c++) issues? This would be an easily distinguishable subsection. Don't subdivide it into platforms. Tom. > The CGI subgroup that I proposed earlier is perhaps not especially > interresting. Many questions and discussions regarding CGI programming > tend to be originating from poor understanding of Python itself, and > its modules. I guess that is the way in to the Python world for many > newbies. It sure was for me once. > > I think that it is better to have general subgroup names such as gui, > os, db, and advocacy, rather than more explicit ones like tk, linux, > sql, and whitespace. Maybe platform is better than os... I leave that > to the os/platform lawyers out there. > > /Mikael > > ----------------------------------------------------------------------- > E-Mail: Mikael Olofsson > WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael > Phone: +46 - (0)13 - 28 1343 > Telefax: +46 - (0)13 - 28 1339 > Date: 01-Mar-00 > Time: 15:36:08 > > This message was sent by XF-Mail. > ----------------------------------------------------------------------- > From embed at geocities.com Mon Feb 26 20:28:32 2001 From: embed at geocities.com (Warren Postma) Date: Mon, 26 Feb 2001 14:28:32 -0500 Subject: Splitting comp.lang.python References: Message-ID: <79ym6.2288$TW.12847@tor-nn1.netcom.ca> Not again!? We had this discussion ten times over. Anyone who feels like weighing in on this one should at least be polite and avoid beating the same dead horses, over and over again. I mean, doesn't anyone search Deja anymore? Oh yeah, Deja is gone, and replaced by the Beta Groups at groups.google.com. Oh well, ironically, now that we have no Deja.com, I think we are in for a Lot More of that old time Deja Vu. Warren Postma From aahz at panix.com Mon Feb 26 20:35:15 2001 From: aahz at panix.com (Aahz Maruch) Date: 26 Feb 2001 11:35:15 -0800 Subject: Splitting comp.lang.python References: <79ym6.2288$TW.12847@tor-nn1.netcom.ca> Message-ID: <97eb5j$cpr$1@panix2.panix.com> In article <79ym6.2288$TW.12847 at tor-nn1.netcom.ca>, Warren Postma wrote: > >I mean, doesn't anyone search Deja anymore? Oh yeah, Deja is gone, and >replaced by the Beta Groups at groups.google.com. Oh well, ironically, now >that we have no Deja.com, I think we are in for a Lot More of that old time >Deja Vu. Well, at least until Google brings up the full DejaNews archive. I've heard that the initial estimate is on the order of three months. -- --- 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 "I used to have a .sig but I found it impossible to please everyone..." --SFJ From skip at mojam.com Mon Feb 26 21:29:10 2001 From: skip at mojam.com (Skip Montanaro) Date: Mon, 26 Feb 2001 14:29:10 -0600 (CST) Subject: Splitting comp.lang.python In-Reply-To: <79ym6.2288$TW.12847@tor-nn1.netcom.ca> References: <79ym6.2288$TW.12847@tor-nn1.netcom.ca> Message-ID: <15002.48278.442384.757689@beluga.mojam.com> Warren> Not again!? We had this discussion ten times over. The list seems to have lost a good deal of its collective memory with the demise of deja.com and hasn't yet regained it in the guise of groups.google.com. Perhaps it would be worthwhile to add the perennial c.l.py split question to the FAQ so we can simply point people there in the future. -- Skip Montanaro (skip at mojam.com) Support Mojam & Musi-Cal: http://www.musi-cal.com/sponsor.shtml (847)971-7098 From landauer at apple.com Wed Feb 28 22:45:57 2001 From: landauer at apple.com (Doug Landauer) Date: Wed, 28 Feb 2001 13:45:57 -0800 Subject: Splitting comp.lang.python References: <79ym6.2288$TW.12847@tor-nn1.netcom.ca> Message-ID: > Not again!? We had this discussion ten times over. Yes, again. The newsgroup's volume changes. The set of readers and posters changes. The number of people interested in python but who don't have time to read 100 or 200 new and different subject lines a day changes. The discussion leads some people to different conclusions each time it comes up in the context of all of these changing conditions. /split/k-is-a-small-price-to-pay-for-python's-increasing-popularity-ly, :-D -- From sholden at holdenweb.com Mon Feb 26 23:33:09 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 26 Feb 2001 17:33:09 -0500 Subject: Splitting comp.lang.python References: <79ym6.2288$TW.12847@tor-nn1.netcom.ca> Message-ID: <9UAm6.21407$P87.223273@e420r-atl2.usenetserver.com> "Skip Montanaro" wrote in message news:mailman.983219407.2513.python-list at python.org... > > Warren> Not again!? We had this discussion ten times over. > > The list seems to have lost a good deal of its collective memory with the > demise of deja.com and hasn't yet regained it in the guise of > groups.google.com. Perhaps it would be worthwhile to add the perennial > c.l.py split question to the FAQ so we can simply point people there in the > future. > That would be a good idea: it probably keeps coming up because the readership of the group is enlarging (or at least thrashing :-) fairly rapidly. Then the old-timers use more bandwidth to explain we've already had these discussions before... regards Steve From gem at hsv.crc.com Mon Feb 26 18:58:34 2001 From: gem at hsv.crc.com (Glen Mettler) Date: Mon, 26 Feb 2001 11:58:34 -0600 Subject: Combinations function Message-ID: <97e52o$41c$1@hobbes2.crc.com> Is there a python function that will give me the possible combinations of a set? ie - in list a,b,c,d there are 4! or 24 possible combinations. Is there an existing function to print the possible combinations? Glen From f8dy at yahoo.com Mon Feb 26 19:50:35 2001 From: f8dy at yahoo.com (Mark Pilgrim) Date: Mon, 26 Feb 2001 13:50:35 -0500 Subject: Combinations function References: <97e52o$41c$1@hobbes2.crc.com> Message-ID: <97e8en$pbr73$1@ID-77331.news.dfncis.de> There is nothing built into Python to do this, but I found this on the Python Knowledge Base (a wonderful resource for those who don't know about it): http://www.faqts.com/knowledge_base/view.phtml/aid/4526/fid/538 -M You're smart; why haven't you learned Python yet? http://diveintopython.org/ "Glen Mettler" wrote in message news:97e52o$41c$1 at hobbes2.crc.com... > Is there a python function that will give me the possible combinations of a > set? > ie - in list a,b,c,d there are 4! or 24 possible combinations. Is there an > existing function to print the possible combinations? > > Glen > > > From aleaxit at yahoo.com Mon Feb 26 20:42:11 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 26 Feb 2001 20:42:11 +0100 Subject: Combinations function References: <97e52o$41c$1@hobbes2.crc.com> Message-ID: <97ebh20kti@news2.newsguy.com> "Glen Mettler" wrote in message news:97e52o$41c$1 at hobbes2.crc.com... > Is there a python function that will give me the possible combinations of a > set? > ie - in list a,b,c,d there are 4! or 24 possible combinations. Is there an > existing function to print the possible combinations? Actually, the term "combinations" is normally used to indicate samples (of m items out of the n in the set, m <= n), without replacement, _order not counting_; those are very easy to generate, but there are 2**n (here, 16) of them, not n!. You appear to desire _permutations_, aka 'orderings', of n items, of which there are indeed n!. Those are easiest to generate in a recursive way, for example: def all_permutations(alist): if not alist: return [[]] result = [] for i in range(len(alist)): for subresult in all_permutations(alist[:i]+alist[i+1:]): result.append([alist[i]] + subresult) return result There's a lot of little things that can be done to optimize this, but this is the basic idea. Be careful not to run this on LONG lists -- it will take a LOT of time (and so would any optimized versions!), because n! grows VERY fast with n. Alex From matthew.feinstein at jhuapl.edu Mon Feb 26 19:17:16 2001 From: matthew.feinstein at jhuapl.edu (Matt Feinstein) Date: Mon, 26 Feb 2001 18:17:16 GMT Subject: PyOpenGL? Message-ID: <3a9a9d48.6629983@aplnews> The Sourceforge link for PyOpenGL doesn't seem to be active and there's no alternate route for the module-- is it available? Matt Feinstein matt.feinstein at jhuapl.edu -------- Harvard Law of Automotive Repair: Anything that goes away by itself will come back by itself. From ljohnson at resgen.com Mon Feb 26 23:12:08 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Mon, 26 Feb 2001 16:12:08 -0600 Subject: PyOpenGL? References: <3a9a9d48.6629983@aplnews> Message-ID: At this moment, the link: http://pyopengl.sourceforge.net is alive and well. Perhaps a temporary outage at SF? "Matt Feinstein" wrote in message news:3a9a9d48.6629983 at aplnews... > > The Sourceforge link for PyOpenGL doesn't seem to be active and > there's no alternate route for the module-- is it available? > > Matt Feinstein matt.feinstein at jhuapl.edu > -------- > Harvard Law of Automotive Repair: Anything that goes away > by itself will come back by itself. > From anderson at pha.jhu.edu Mon Feb 26 19:30:08 2001 From: anderson at pha.jhu.edu (Kenneth Anderson) Date: Mon, 26 Feb 2001 13:30:08 -0500 Subject: os.tmpfile() Message-ID: <3A9AA0B0.4137D4C9@pha.jhu.edu> Hi i am trying to use the os.tmpfile() method to create a file object for writing, but i am seeing weird behaviour that i certainly don't expect: >>> import os >>> f1 = os.tmpfile() >>> f1 ', mode 'w+' at eed68> >>> f1.readlines() [] >>> f1.write('check') >>> f1.readlines() '\000\000\000\000\000\000\000\000\...long, long list of \000 ' Nothing is the FAQ about tmpfile(). any notions about this. I would really prefer not to write a file but rather just write the data to a file object. thanks! Ken Anderson JHU -- =================================================== ...and for lunch, Ken stops by the side of the road and rubs gravel into his hair. =================================================== From stephen_purcell at yahoo.com Tue Feb 27 09:33:56 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 27 Feb 2001 09:33:56 +0100 Subject: os.tmpfile() In-Reply-To: <3A9AA0B0.4137D4C9@pha.jhu.edu>; from anderson@pha.jhu.edu on Mon, Feb 26, 2001 at 01:30:08PM -0500 References: <3A9AA0B0.4137D4C9@pha.jhu.edu> Message-ID: <20010227093356.C7945@freedom.puma-ag.com> Kenneth Anderson wrote: > >>> f1 = os.tmpfile() > >>> f1 > ', mode 'w+' at eed68> > >>> f1.readlines() > [] > >>> f1.write('check') > >>> f1.readlines() > > '\000\000\000\000\000\000\000\000\...long, long list of \000 ' Not sure about this, but you could try 'tempfile.mktemp' to get a unique filename, then explicitly open it yourself to see if the results are any different. > any notions about this. I would really prefer not to write a file > but rather just write the data to a file object. Maybe you just need to use the StringIO (or cStringIO) module if you want an in-memory file-like object? -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 shichang at icubed.com Mon Feb 26 19:33:49 2001 From: shichang at icubed.com (szhao) Date: Mon, 26 Feb 2001 18:33:49 GMT Subject: Python v.s. Ruby? Message-ID: How do you compare the Languague Ruby with Python? http://www.ruby-lang.org/en/ From dbrueck at edgix.com Mon Feb 26 19:54:43 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Mon, 26 Feb 2001 11:54:43 -0700 Subject: Python v.s. Ruby? In-Reply-To: Message-ID: Ruby? Nobody on this list has ever heard of a language called Ruby, much less given any thought to comparing the two. > -----Original Message----- > From: python-list-admin at python.org > [mailto:python-list-admin at python.org]On Behalf Of szhao > Sent: Monday, February 26, 2001 11:34 AM > To: python-list at python.org > Subject: Python v.s. Ruby? > > > How do you compare the Languague Ruby with Python? > > http://www.ruby-lang.org/en/ > > > > > -- > http://mail.python.org/mailman/listinfo/python-list From dsh8290 at rit.edu Mon Feb 26 20:09:36 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 26 Feb 2001 14:09:36 -0500 Subject: Python v.s. Ruby? In-Reply-To: ; from dbrueck@edgix.com on Mon, Feb 26, 2001 at 11:54:43AM -0700 References: Message-ID: <20010226140935.C14108@harmony.cs.rit.edu> On Mon, Feb 26, 2001 at 11:54:43AM -0700, Dave Brueck wrote: | Ruby? Nobody on this list has ever heard of a language called Ruby, much | less given any thought to comparing the two. Yeah, sure, whatever. Check the archives, this has been discussed many times before. -D From shichang at icubed.com Mon Feb 26 20:04:15 2001 From: shichang at icubed.com (szhao) Date: Mon, 26 Feb 2001 19:04:15 GMT Subject: Python v.s. Ruby? References: Message-ID: People told me Ruby is powerful and better than Python. Some simple Ruby example shows weird perl/tcl/tk/python syntax mixins. "Dave Brueck" wrote in message news:mailman.983213784.17876.python-list at python.org... > Ruby? Nobody on this list has ever heard of a language called Ruby, much > less given any thought to comparing the two. > > > -----Original Message----- > > From: python-list-admin at python.org > > [mailto:python-list-admin at python.org]On Behalf Of szhao > > Sent: Monday, February 26, 2001 11:34 AM > > To: python-list at python.org > > Subject: Python v.s. Ruby? > > > > > > How do you compare the Languague Ruby with Python? > > > > http://www.ruby-lang.org/en/ > > > > > > > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > From nospam at mega-nerd.com Mon Feb 26 20:16:29 2001 From: nospam at mega-nerd.com (Erik de Castro Lopo) Date: Mon, 26 Feb 2001 19:16:29 GMT Subject: Python v.s. Ruby? References: Message-ID: <3A9AA8DB.4A7876A5@mega-nerd.com> szhao wrote: > > People told me Ruby is powerful and better than Python. Those kinds of statements are extremely difficult to prove. > Some simple Ruby > example shows weird perl/tcl/tk/python syntax mixins. That may have some truth ot it. Erik -- +----------------------------------------------------------+ Erik de Castro Lopo nospam at mega-nerd.com (Yes its valid) +----------------------------------------------------------+ Linux: generous programmers from around the world all join forces to help you shoot yourself in the foot for free. From fredrik at pythonware.com Mon Feb 26 20:08:19 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 26 Feb 2001 19:08:19 GMT Subject: Python v.s. Ruby? References: Message-ID: "szhao" wrote: > How do you compare the Languague Ruby with Python? groups.google.com Cheers /F From shichang at icubed.com Mon Feb 26 20:21:04 2001 From: shichang at icubed.com (szhao) Date: Mon, 26 Feb 2001 19:21:04 GMT Subject: Python v.s. Ruby? References: Message-ID: Thanks. /F Lots of saying about Ruby. So, what do you say, /F? "Fredrik Lundh" wrote in message news:DQxm6.15634$Qb7.2559170 at newsb.telia.net... > "szhao" wrote: > > How do you compare the Languague Ruby with Python? > > groups.google.com > > Cheers /F > > From tim.one at home.com Mon Feb 26 20:41:48 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 26 Feb 2001 14:41:48 -0500 Subject: Python v.s. Ruby? In-Reply-To: Message-ID: [szhao] > Thanks. /F > > Lots of saying about Ruby. So, what do you say, /F? /F makes his living working with Python, so you don't care what he says about Ruby . Me neither. Sincere suggestion: download Python and *try* it! It's free, it's easy, and if you've programmed in some other language before you can very likely learn most of Python in an afternoon by working through the tutorial that comes with it. Do the same for Ruby, and then you can make up your own mind. Come back then and tell us what *you* think! Overall, that will consume much less of your time (and ours) than slogging through hundreds of argumentative messages about it. I doubt you would *regret* the time you spent introducing yourself to either language. i-hear-you're-even-allowed-to-use-both-ly y'rs - tim From daniel at dittmar.net Mon Feb 26 20:59:20 2001 From: daniel at dittmar.net (Daniel Dittmar) Date: Mon, 26 Feb 2001 20:59:20 +0100 Subject: Python v.s. Ruby? References: Message-ID: <3A9AB598.E63777B5@dittmar.net> > > groups.google.com > > > Lots of saying about Ruby. So, what do you say, /F? > The question about Python vs. Ruby has been asked a few weeks back and Fred asks you to review that discussion at 'The Search Engine Formely Known As DejaNews'. Short Summary of that diskussion: a few had played around with Ruby, but none found an overwhelming reason to use it. Evidence was more anecdotal than anything else. Daniel From parkw at better.net Tue Feb 27 08:42:22 2001 From: parkw at better.net (William Park) Date: Tue, 27 Feb 2001 02:42:22 -0500 Subject: Python v.s. Ruby? In-Reply-To: <3a9c44d2.2862445@news.telus.net>; from root@127.0.0.1 on Tue, Feb 27, 2001 at 06:17:55AM +0000 References: <3a9c44d2.2862445@news.telus.net> Message-ID: <20010227024222.A490@better.net> On Tue, Feb 27, 2001 at 06:17:55AM +0000, David wrote: > On Mon, 26 Feb 2001 18:33:49 GMT, "szhao" wrote: > >How do you compare the Languague Ruby with Python? > >http://www.ruby-lang.org/en/ > > I think the most distinguishing difference between Python and Ruby is that > the formers' users don't compare Python and Ruby; whereas the users of the > latter seem to encourage comparing Ruby and Python. > > Or at least that's my perception. Certainly the Python websites don't have > any references to Ruby. The Ruby websites seem to refer to Python... > > There's a maxim that may apply: "If you have to compare yourself to the > competition, you're not the leader." In the simplest terms, Ruby is OO Perl (not good for my fingers). ---William Park, Open Geometry Consulting From dfan at harmonixmusic.com Tue Feb 27 16:12:16 2001 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 27 Feb 2001 10:12:16 -0500 Subject: Python v.s. Ruby? References: <3a9c44d2.2862445@news.telus.net> Message-ID: root at 127.0.0.1 (David) writes: | I think the most distinguishing difference between Python and Ruby | is that the formers' users don't compare Python and Ruby; whereas | the users of the latter seem to encourage comparing Ruby and Python. | | Or at least that's my perception. Certainly the Python websites | don't have any references to Ruby. The Ruby websites seem to refer | to Python... Yes, the Python websites are too busy disparaging Perl :) (I use all three languages and like them all.) -- http://www.dfan.org From tim at vegeta.ath.cx Tue Feb 27 23:10:42 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 27 Feb 2001 22:10:42 GMT Subject: Python v.s. Ruby? References: <3a9c44d2.2862445@news.telus.net> Message-ID: Dan Schmidt wrote: > Yes, the Python websites are too busy disparaging Perl :) Oh, you noticed that too? That's alright. It's mutual, unfortunately. > (I use all three languages and like them all.) I don't use Ruby, but there are certain projects I'd rather do in Python, and others better suited to Perl...so why should I have to pick? This goes along with Perl's TMTOWTDI (There's More Than One Way To Do It) motto. Python is just another way I might chose to do it. =) -- -Tim Hammerquist Usenet is essentially a HUGE group of people passing notes in class. -- R. Kadel From tim at vegeta.ath.cx Tue Feb 27 23:08:54 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 27 Feb 2001 22:08:54 GMT Subject: Python v.s. Ruby? References: <3a9c44d2.2862445@news.telus.net> Message-ID: William Park wrote: > In the simplest terms, Ruby is OO Perl (not good for my fingers). It looked like it had too many VB qualities to be much like Perl. Most Perlers think Ruby is closer to Python, so maybe Ruby is just its own animal? -- -Tim Hammerquist A liar should have a good memory. -- Quintilian From marvind at Glue.umd.edu Mon Feb 26 21:04:31 2001 From: marvind at Glue.umd.edu (Arvind Mani) Date: Mon, 26 Feb 2001 15:04:31 -0500 Subject: ar: internal error (58) Message-ID: <3A9AB6CF.72F2E862@Glue.umd.edu> hi, I am trying to build and install python 2.0 on solaris. I get this error message when the object files are archived. I used gcc to compile the files. hope you guys can help me out on this one. thanks, arvind From rfileger at bellsouth.net Mon Feb 26 21:11:33 2001 From: rfileger at bellsouth.net (Roy W Fileger) Date: Mon, 26 Feb 2001 15:11:33 -0500 Subject: https Message-ID: <003f01c0a030$5161eb60$4c80d6d1@mpiabose280srr> Hello, I am new to Python but am excited about it. I have a requirement to send a Credit Card transaction to an HTTPS server as the body of a POST transaction. With Python 2.0 supporting OpenSSL, can I simply use the httplib to connect and POST? The POST example the Python Library Reference 11.4.2 seems both simple and clear. So far I have only been executing sample code from the many sources and then making modifications to attempt to insure that I understand. Visa says I can confirm the availability of the gateway by browsing https://ssl.pgs.wcom.net/ and this works Here is a .py I have developed based upon examples in the Python Library Reference and the information provided by Visa re: VirtualNet SSL Gateway but I get a socket error: host not found. =============================================================== tran1 = ('0x82'+'D4.999995'+'0x03'+'0xD1') # provided by Visa def sendTran(ccTran): h = httplib.HTTP("https://ssl.pgs.wcom.net", 443) # my interpretation of Visa data h.putrequest("POST", "/scripts/gateway.dll?Transact HTTP/1.0") # my use Visa data h.putheader("Content-Type", "x-Visa-II/x-auth") # per Visa h.putheader("Content-Length", "%d" % len(tran1)) h.putheader('Accept', 'text/plain') h.putheader('Host', 'https://ssl.pgs.wcom.net') # same as above h.endheaders() h.send(ccTran) reply, msg, hdrs = h.getreply() data = h.getfile().read() # print data sendTran(tran1) ================================================================ Thanks, your help is greatly appreciated, Roy W. Fileger. -------------- next part -------------- An HTML attachment was scrubbed... URL: From erno-news at erno.iki.fi Tue Feb 27 03:56:33 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 27 Feb 2001 04:56:33 +0200 Subject: https References: Message-ID: In article , "Roy W Fileger" writes: | Hello, | I am new to Python but am excited about it. I have a | requirement to send a Credit Card transaction to an | HTTPS server as the body of a POST transaction. if you decide to use the https support that comes with python, be sure to authenticate the other end somehow. by default the python https support doesn't seem to have any database of certificate authorities, so it's not really safe against dns spoofing or the like. someone please correct me if i'm wrong, i'm not sure about the above since there is no documentation for the ssl stuff... i hear m2crypto might be better wrt this, but i'm not sure. you could also consider using some other way, like gnupg + email, to send the information. that would have the advantage that the information would arrive ancrypted at the other end too, so even if your your communications with the server at the other end, or indeed the server at the other end itself, gets compromised, your information is still safe. -- erno From xavier at perceval.net Tue Feb 27 09:11:52 2001 From: xavier at perceval.net (Xavier Defrang) Date: Tue, 27 Feb 2001 09:11:52 +0100 (CET) Subject: https In-Reply-To: <003f01c0a030$5161eb60$4c80d6d1@mpiabose280srr> Message-ID: On Mon, 26 Feb 2001, Roy W Fileger wrote: > With Python 2.0 supporting OpenSSL, can I simply > use the httplib to connect and POST? The POST > example the Python Library Reference 11.4.2 seems > both simple and clear. Despite of all my efforts, I've never been able to build Python 2.0 with built-in SSL support and I ran into a solution that I find simple and elegant. I just run the cryptographic stuff "outside" of my Python application. I use Stunnel (http://www.stunnel.org) which is an SSL proxy to create an encrypted tunnel between my application and the server. Security can be pretty well finetuned using TCP wrapper access control. With this proxy server, I use the good ol' httplib and it works really fine! I also used it for a credit card transaction system so the overhead involved by the SSL proxying doesn't matter very much... Regards. Xavier Defrang Perceval R&D Team xavier at perceval.net ------------------------------------------------- Perceval Technologies SA/NV Tel: +32-2-6409194 Rue Tenbosch, 9 Fax: +32-2-6403154 B-1000 Brussels http://www.perceval.net BELGIUM info at perceval.net ------------------------------------------------- From owen at astrono.junkwashington.emu Mon Feb 26 21:53:15 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Mon, 26 Feb 2001 12:53:15 -0800 Subject: Hiding widgets it Tkinter and shrinking the frame/window? Message-ID: <97efnv$tqq$1@nntp6.u.washington.edu> I am trying to generate a window with basic options always showing and additional panels that are hidden or displayed if needed. I can easily show/hide widgets, but the window does not shrink after a widget is hidden. Is there some basic trick to this? (Also, is there some simple way to get the TopLevel object from a widget, perhaps one that is buried many levels deep in enclosing frames and etc.? I think I may have to make window manager calls, and I don't want to pass the TopLevel widget around if I don't have to.) -- Russell From owen at astrono.junkwashington.emu Tue Feb 27 17:45:12 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Tue, 27 Feb 2001 08:45:12 -0800 Subject: Hiding widgets it Tkinter and shrinking the frame/window? -- a partial answer References: <97efnv$tqq$1@nntp6.u.washington.edu> Message-ID: <97gliu$iba$1@nntp6.u.washington.edu> To partially answer my own post... In article <97efnv$tqq$1 at nntp6.u.washington.edu>, "Russell E. Owen" wrote: >I am trying to generate a window with basic options always showing and >additional panels that are hidden or displayed if needed. I can easily >show/hide widgets, but the window does not shrink after a widget is >hidden. Is there some basic trick to this? The basics of show/hide are to pack() or pack_forget() (if using the pack manager). Unfortunately, pack_forget loses track of where the unpacked widget goes. To work around this, what I was doing was: - create an enclosing frame for each hideable widget and have that be the master for the hideable widget - pack(side=LEFT, anchor=NW) or pack_forget() to show/hide Unfortunately, the enclosing frame wasn't shrinking when the hideable widget was unpacked, hence the window wasn't shrinking either. Just for the heck of it, I tried a variation that worked: - create an enclosing frame to enclose a set of hideable widgets - pack an empty (hence zero-sized) placeholder frame to the left of each hideable widget - use pack(side=LEFT, anchor=NW, after=) to show the widget, and pack_forget() to hide it In this case the enclosing frame and window did shrink when a widget was hidden. I have no idea why the second techinque worked when the first one did not, as they are very similar. But heck, whatever works. (If anybody does have an explanation I'd love to hear it). I plan to try the gridder, as well, since it appears one can ungrid items without forgetting their information (using grid_remove). It'd be nice to dispense with the placeholder frames. -- Russell From owen at astrono.junkwashington.emu Wed Feb 28 17:42:45 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Wed, 28 Feb 2001 08:42:45 -0800 Subject: Hiding widgets it Tkinter and shrinking the frame/window? -- the rest of the answer References: <97efnv$tqq$1@nntp6.u.washington.edu> <97gliu$iba$1@nntp6.u.washington.edu> Message-ID: <97j9pv$hji$1@nntp6.u.washington.edu> Sorry to keep posting, but here's the rest of the answer. I was wondering why Tk frames wouldn't always shrink when their contents were unpacked. Turns out that if you remove all widgets from an enclosing frame, it stays at the size of the last-removed widget. So all you have to do is include a zero-sized widget (I use a frame with nothing in it) and never unpack that. Then the enclosing frame will shrink to nothing when the empty frame is the last widget left in it, i.e. when all hideable widgets have been unpacked. We need a Tk folklore site. -- Russell From cerutti at together.net Tue Feb 27 22:27:18 2001 From: cerutti at together.net (Neil Cerutti) Date: 27 Feb 2001 21:27:18 GMT Subject: Hiding widgets it Tkinter and shrinking the frame/window? References: <97efnv$tqq$1@nntp6.u.washington.edu> Message-ID: Russell E. Owen posted: >(Also, is there some simple way to get the TopLevel object from a >widget, perhaps one that is buried many levels deep in enclosing frames >and etc.? I think I may have to make window manager calls, and I don't >want to pass the TopLevel widget around if I don't have to.) .winfo_toplevel() -- Neil Cerutti From tjg at exceptionalminds.com Mon Feb 26 21:59:03 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Mon, 26 Feb 2001 12:59:03 -0800 Subject: IP Math anyone? Message-ID: <20010226125903.X29494@trufflehunter.avalongroup.net> Hi all, I checked Parnassus, but couldn't find anything, so I'll ask here. Has anyone done anything with IP math (e.g., 192.168.0.254 + 1 = 192.168.1.1). -- 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: 41 days 1:10 hours ago<< From jgraves3 at austin.rr.com Mon Feb 26 22:12:06 2001 From: jgraves3 at austin.rr.com (jay graves) Date: Mon, 26 Feb 2001 21:12:06 GMT Subject: IP Math anyone? References: Message-ID: <3a9ac5c3.13004564@news-server.austin.rr.com> On Mon, 26 Feb 2001 12:59:03 -0800, Timothy Grant wrote: >Hi all, >I checked Parnassus, but couldn't find anything, so I'll ask >here. Has anyone done anything with IP math (e.g., >192.168.0.254 + 1 = 192.168.1.1). >-- >Stand Fast, > tjg. how about: http://www.vex.net/parnassus/apyllo.py?i=35559588 i don't know if it overrides the arithmetic operators but it might be a good starting point for you. ... jay From parkw at better.net Mon Feb 26 22:48:05 2001 From: parkw at better.net (William Park) Date: Mon, 26 Feb 2001 16:48:05 -0500 Subject: IP Math anyone? In-Reply-To: <3a9ac5c3.13004564@news-server.austin.rr.com>; from jgraves3@austin.rr.com on Mon, Feb 26, 2001 at 09:12:06PM +0000 References: <3a9ac5c3.13004564@news-server.austin.rr.com> Message-ID: <20010226164805.A1244@better.net> On Mon, Feb 26, 2001 at 09:12:06PM +0000, jay graves wrote: > On Mon, 26 Feb 2001 12:59:03 -0800, Timothy Grant > wrote: > >Hi all, > >I checked Parnassus, but couldn't find anything, so I'll ask > >here. Has anyone done anything with IP math (e.g., > >192.168.0.254 + 1 = 192.168.1.1). > >-- > >Stand Fast, > > tjg. > > how about: > http://www.vex.net/parnassus/apyllo.py?i=35559588 > > i don't know if it overrides the arithmetic operators but it might be > a good starting point for you. '__add__' implements '+'. But, my question is what happens if 192.168.0.254 + 5 ? ---William Park, Open Geometry Consulting From erno-news at erno.iki.fi Mon Feb 26 22:23:39 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 26 Feb 2001 23:23:39 +0200 Subject: IP Math anyone? References: Message-ID: In article , Timothy Grant writes: | Hi all, | I checked Parnassus, but couldn't find anything, so I'll ask | here. Has anyone done anything with IP math (e.g., | 192.168.0.254 + 1 = 192.168.1.1). assuming you actually mean 192.168.0.254 + 1 = 192.168.0.255, try something like... >>> def dotted2int(ds): ... return struct.unpack('!I', socket.inet_aton(ds))[0] ... >>> def int2dotted(i): ... return socket.inet_ntoa(struct.pack('!I', i)) ... >>> print int2dotted(dotted2int('192.168.0.254') + 1) 192.168.0.255 -- erno From scarblac at pino.selwerd.nl Tue Feb 27 09:08:09 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 27 Feb 2001 08:08:09 GMT Subject: IP Math anyone? References: Message-ID: Erno Kuusela wrote in comp.lang.python: > In article , Timothy > Grant writes: > > | Hi all, > | I checked Parnassus, but couldn't find anything, so I'll ask > | here. Has anyone done anything with IP math (e.g., > | 192.168.0.254 + 1 = 192.168.1.1). > > assuming you actually mean 192.168.0.254 + 1 = 192.168.0.255, He doesn't; .0.255 and .1.0 are not IP addresses you could give to a machine. I've never seen existing code for this, seems to need some custom hacking. (I don't know if .255 and .0 are the only exceptions, probably not). -- Remco Gerlich From sandipan at vsnl.com Tue Feb 27 09:45:48 2001 From: sandipan at vsnl.com (Sandipan Gangopadhyay) Date: Tue, 27 Feb 2001 14:15:48 +0530 Subject: IP Math anyone? References: Message-ID: <00e701c0a099$b6b30580$020000c3@node02> Actually, not only .0 or .255, could be any other IP address as defined by the netmask in sub-nets. Eg, .184 is similar to .0 (network address) if netmask is 252 instead of 0 Similarly, .187 is similar to .255 (broadcast address) with this netmask. In other words, 252 delivers a 4 address sub-net. Therefore the maths operations will have to involve the netmask. Regards, Sandipan ----- Original Message ----- From: "Remco Gerlich" Newsgroups: comp.lang.python To: Sent: Tuesday, February 27, 2001 1:38 PM Subject: Re: IP Math anyone? > Erno Kuusela wrote in comp.lang.python: > > In article , Timothy > > Grant writes: > > > > | Hi all, > > | I checked Parnassus, but couldn't find anything, so I'll ask > > | here. Has anyone done anything with IP math (e.g., > > | 192.168.0.254 + 1 = 192.168.1.1). > > > > assuming you actually mean 192.168.0.254 + 1 = 192.168.0.255, > > He doesn't; .0.255 and .1.0 are not IP addresses you could give to a machine. > I've never seen existing code for this, seems to need some custom hacking. > > (I don't know if .255 and .0 are the only exceptions, probably not). > > -- > Remco Gerlich > > -- > http://mail.python.org/mailman/listinfo/python-list > From jafo at tummy.com Tue Feb 27 09:46:49 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Tue, 27 Feb 2001 01:46:49 -0700 Subject: IP Math anyone? In-Reply-To: ; from scarblac@pino.selwerd.nl on Tue, Feb 27, 2001 at 08:08:09AM +0000 References: Message-ID: <20010227014649.A13115@tummy.com> On Tue, Feb 27, 2001 at 08:08:09AM +0000, Remco Gerlich wrote: >He doesn't; .0.255 and .1.0 are not IP addresses you could give to a machine. >I've never seen existing code for this, seems to need some custom hacking. It all depends on your netmask: 10.0.0.254/24 + 1 = 10.0.1.1/24 10.0.0.254/23 + 1 = 10.0.0.255/23 10.0.0.2/30 + 1 = 10.0.0.5/30 Sean -- A computer is like an Old Testament god, with a lot of rules and no mercy. -- Joseph Campbell Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From erno-news at erno.iki.fi Tue Feb 27 12:55:50 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 27 Feb 2001 13:55:50 +0200 Subject: IP Math anyone? References: Message-ID: In article , scarblac at pino.selwerd.nl (Remco Gerlich) writes: | .0.255 and .1.0 are not IP addresses you could give to a machine. | I've never seen existing code for this, seems to need some custom hacking. | (I don't know if .255 and .0 are the only exceptions, probably not). why do you think .0 or .255 are not usable addresses? -- erno From scarblac at pino.selwerd.nl Tue Feb 27 18:40:45 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 27 Feb 2001 17:40:45 GMT Subject: IP Math anyone? References: Message-ID: Erno Kuusela wrote in comp.lang.python: > In article , > scarblac at pino.selwerd.nl (Remco Gerlich) writes: > > | .0.255 and .1.0 are not IP addresses you could give to a machine. > | I've never seen existing code for this, seems to need some custom hacking. > > | (I don't know if .255 and .0 are the only exceptions, probably not). > > why do you think .0 or .255 are not usable addresses? I was confused about netmasks. I didn't expect the Spanish Inquisition! -- Remco Gerlich From joconnor at cybermesa.com Tue Feb 27 19:04:50 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Tue, 27 Feb 2001 11:04:50 -0700 Subject: IP Math anyone? References: Message-ID: <3A9BEC42.5F9888@cybermesa.com> Remco Gerlich wrote: > Erno Kuusela wrote in comp.lang.python: > > In article , > > scarblac at pino.selwerd.nl (Remco Gerlich) writes: > > > > | .0.255 and .1.0 are not IP addresses you could give to a machine. > > | I've never seen existing code for this, seems to need some custom hacking. > > > > | (I don't know if .255 and .0 are the only exceptions, probably not). > > > > why do you think .0 or .255 are not usable addresses? > > I was confused about netmasks. I didn't expect the Spanish Inquisition! > No one expects the Spanish Inquisition (How many other identical posts will there be ?) From f8dy at yahoo.com Tue Feb 27 20:35:32 2001 From: f8dy at yahoo.com (Mark Pilgrim) Date: Tue, 27 Feb 2001 14:35:32 -0500 Subject: IP Math anyone? References: <3A9BEC42.5F9888@cybermesa.com> Message-ID: <97gvf1$pdbof$1@ID-77331.news.dfncis.de> "Jay O'Connor" wrote in message news:3A9BEC42.5F9888 at cybermesa.com... > > > Remco Gerlich wrote: > > > Erno Kuusela wrote in comp.lang.python: > > > In article , > > > scarblac at pino.selwerd.nl (Remco Gerlich) writes: > > > > > > | .0.255 and .1.0 are not IP addresses you could give to a machine. > > > | I've never seen existing code for this, seems to need some custom hacking. > > > > > > | (I don't know if .255 and .0 are the only exceptions, probably not). > > > > > > why do you think .0 or .255 are not usable addresses? > > > > I was confused about netmasks. I didn't expect the Spanish Inquisition! > > > > No one expects the Spanish Inquisition > > > > (How many other identical posts will there be ?) The real question is, why hasn't anyone written a bot to automate this? import nntplib import time def inquisitionBot(host, port=119, user=None, password=None, starttime=None): if not starttime: starttime = time.localtime(time.time() - 60*60*24) s = nntplib.NNTP(host, port, user, password) try: resp, articles = s.newnews("comp.lang.python", \ time.strftime("%y%m%d", starttime), \ time.strftime("%H%M%S", starttime)) for articleID in articles: resp, status, cmd, body = s.body(articleID) if [line for line in body if \ line[:1]<>'>' and \ line.lower().count("i didn't expect the spanish inquisition")]: # if I continue this someone might actually use it... :) pass finally: s.quit() -M You're smart; why haven't you learned Python yet? http://diveintopython.org/ From joconnor at cybermesa.com Mon Feb 26 22:44:52 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Mon, 26 Feb 2001 14:44:52 -0700 Subject: IP Math anyone? References: Message-ID: <3A9ACE54.65706115@cybermesa.com> Timothy Grant wrote: > Hi all, > > I checked Parnassus, but couldn't find anything, so I'll ask > here. Has anyone done anything with IP math (e.g., > 192.168.0.254 + 1 = 192.168.1.1). You could probably do it by converting the IP address to a number, do the math, and convert back. I've seen algorithms for doing this. Given a.b.c.d for an IP address you can convert it to the proper value using: a(256^3) + b(256^2) + c(256) + d So 192.168.0.254 = (192 * long((256 **3))) + (168 * (256 ** 2)) + (0 * 256) + 254 = 3232235774L You need the long() in there to avoid an integer multiplication error. You might be able to use '3232235774' directly, or convert back to an ip address Take care, Jay From tjg at exceptionalminds.com Tue Feb 27 02:02:23 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Mon, 26 Feb 2001 17:02:23 -0800 Subject: IP Math anyone? In-Reply-To: <20010226125903.X29494@trufflehunter.avalongroup.net>; from tjg@exceptionalminds.com on Mon, Feb 26, 2001 at 12:59:03PM -0800 References: <20010226125903.X29494@trufflehunter.avalongroup.net> Message-ID: <20010226170223.B29494@trufflehunter.avalongroup.net> On Mon, Feb 26, 2001 at 12:59:03PM -0800, Timothy Grant wrote: > Hi all, > > I checked Parnassus, but couldn't find anything, so I'll ask > here. Has anyone done anything with IP math (e.g., > 192.168.0.254 + 1 = 192.168.1.1). > > Thanks to all who replied to this. I greatly appreciated it! I'll be checking out each of those solutions carefully. -- Stand Fast, rhacer. Timothy Grant, RHCE <>< MIG #1433 tjg at exceptionalminds.com '00 Marauder www.exceptionalminds.com/rhacer Craigelachie >>>>>>>>>>Linux, because rebooting is *NOT* normal.<<<<<<<<<<< >>>>This machine was last rebooted: 41 days 5:14 hours ago<< From tino at wildenhain.de Tue Feb 27 10:37:11 2001 From: tino at wildenhain.de (Tino Wildenhain) Date: Tue, 27 Feb 2001 10:37:11 +0100 Subject: IP Math anyone? In-Reply-To: <20010226170223.B29494@trufflehunter.avalongroup.net> References: <20010226170223.B29494@trufflehunter.avalongroup.net> Message-ID: <73931622.983270231@[10.0.0.101]> Hi Timothy, for teaching I made a class for this. you can instantiate it with a=ip('192.168.0.254/24') or a=ip('192.168.0.254','255.255.255.0') just using a=ip('192.168.0.254') would assign a appropriate subnet mask for this class (class B results in /16 or 255.255.0.0) Since IP-adresses are only 32bit non signed integers, they are internally represented like that. If you make a class like that you can simply add the support to add integers to it according to the subnet-mask you use. Regards Tino --On Montag, 26. Februar 2001 17:02 -0800 Timothy Grant wrote: > On Mon, Feb 26, 2001 at 12:59:03PM -0800, Timothy Grant wrote: >> Hi all, >> >> I checked Parnassus, but couldn't find anything, so I'll ask >> here. Has anyone done anything with IP math (e.g., >> 192.168.0.254 + 1 = 192.168.1.1). >> >> > > Thanks to all who replied to this. I greatly appreciated it! > I'll be checking out each of those solutions carefully. > > -- > Stand Fast, > rhacer. > > Timothy Grant, RHCE <>< MIG #1433 > tjg at exceptionalminds.com '00 Marauder > www.exceptionalminds.com/rhacer Craigelachie >>>>>>>>>>> Linux, because rebooting is *NOT* normal.<<<<<<<<<<< >>>>> This machine was last rebooted: 41 days 5:14 hours ago<< > > -- > http://mail.python.org/mailman/listinfo/python-list From chris.gonnerman at usa.net Tue Feb 27 14:38:56 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Tue, 27 Feb 2001 07:38:56 -0600 Subject: IP Math anyone? References: <20010226170223.B29494@trufflehunter.avalongroup.net> <73931622.983270231@[10.0.0.101]> Message-ID: <003f01c0a0c2$ac255040$a100000a@local> You neglected to tell us where to download your class from, or to attach the source. I at least would like to see it. ----- Original Message ----- From: "Tino Wildenhain" Subject: Re: IP Math anyone? > Hi Timothy, > > for teaching I made a class for this. > > you can instantiate it with a=ip('192.168.0.254/24') or > a=ip('192.168.0.254','255.255.255.0') just using a=ip('192.168.0.254') > would assign a appropriate subnet mask for this class (class B results in > /16 or 255.255.0.0) > > Since IP-adresses are only 32bit non signed integers, they are internally > represented > like that. > If you make a class like that you can simply add the support to add > integers to > it according to the subnet-mask you use. > > Regards > Tino From tjg at exceptionalminds.com Tue Feb 27 20:08:30 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Tue, 27 Feb 2001 11:08:30 -0800 Subject: IP Math anyone? In-Reply-To: <003f01c0a0c2$ac255040$a100000a@local>; from chris.gonnerman@usa.net on Tue, Feb 27, 2001 at 07:38:56AM -0600 References: <20010226170223.B29494@trufflehunter.avalongroup.net> <73931622.983270231@[10.0.0.101]> <003f01c0a0c2$ac255040$a100000a@local> Message-ID: <20010227110830.I29494@trufflehunter.avalongroup.net> Thanks to all of you who made this thread much more enlightening than expected! As I expected, it is a somewhat complex problem, for which I will probably throw together a class with a nice interface but internals of which are a crude hack, and then refine the internals as time allows. On Tue, Feb 27, 2001 at 07:38:56AM -0600, Chris Gonnerman wrote: > You neglected to tell us where to download your class from, or to attach > the source. I at least would like to see it. > > ----- Original Message ----- > From: "Tino Wildenhain" > Subject: Re: IP Math anyone? > > Hi Timothy, > > > > for teaching I made a class for this. > > > > you can instantiate it with a=ip('192.168.0.254/24') or > > a=ip('192.168.0.254','255.255.255.0') just using a=ip('192.168.0.254') > > would assign a appropriate subnet mask for this class (class B results in > > /16 or 255.255.0.0) > > > > Since IP-adresses are only 32bit non signed integers, they are internally > > represented > > like that. > > If you make a class like that you can simply add the support to add > > integers to > > it according to the subnet-mask you use. > > > > Regards > > Tino -- 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: 41 days 23:20 hours ago<< From me at home.nl Mon Feb 26 22:22:32 2001 From: me at home.nl (SonoBull) Date: Mon, 26 Feb 2001 21:22:32 GMT Subject: First shot at python. Message-ID: im not a real programmer, having only a little experince in vb pascal an smalltalk. But gona try mastering the art of python programming. First seconds account: Downloaded wrong installing file. Finaly got it, installed it, and immediatly decided to download the tutoria. Got fed up swithing between tutorial and Python and printed the whole damm thing. Ended up with chapter 7. Maybe in a couple of years of practice i wil be a good programmer, Well, wish me luck. Tomorrow at it again. gr. son. From sheila at spamcop.net Mon Feb 26 22:33:44 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 26 Feb 2001 21:33:44 GMT Subject: First shot at python. References: Message-ID: On Mon, 26 Feb 2001 21:22:32 GMT, "SonoBull" wrote in comp.lang.python in article : :First seconds account: : :Downloaded wrong installing file. Finaly got it, installed it, and :immediatly decided to download the tutoria. I can feel your frustration. Wasn't the tutorial included in the installation files you downloaded? When I installed Python, all the docs came in the installation package. :Got fed up swithing between tutorial and Python and printed the whole damm :thing. Why do you have to "switch"? Looking at your message headers, I would guess you are on a Windows machine. Can't you have two windows open at the same time? :Ended up with chapter 7. Yikes! : :Maybe in a couple of years of practice i wil be a good programmer, : :Well, wish me luck. Tomorrow at it again. Yes, good luck! Keep at it! -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From sbrunning at trisystems.co.uk Tue Feb 27 10:52:30 2001 From: sbrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 27 Feb 2001 09:52:30 -0000 Subject: First shot at python. References: Message-ID: <3a9b8049_1@nnrp1.news.uk.psi.net> SonoBull wrote in message ... >im not a real programmer, having only a little experince in vb pascal an >smalltalk. > >But gona try mastering the art of python programming. If you haven't really programmed before, you might find the tutorial a little steep. If this is the case, you might want to look at Alan Gauld's 'Learning to Program using Python', at http://www.crosswinds.net/~agauld/. Cheers, Simon Brunning sbrunning at bigfoot.com From me at home.nl Tue Feb 27 11:44:48 2001 From: me at home.nl (SonoBull) Date: Tue, 27 Feb 2001 10:44:48 GMT Subject: First shot at python. References: <3a9b8049_1@nnrp1.news.uk.psi.net> Message-ID: Tnx looks like i can use it. But small question. Ive been told that python is a good "leaning" language and is a good "expert" language. do u feel the same abouth that? or should i try st else first? gr. son Simon Brunning schreef in berichtnieuws 3a9b8049_1 at nnrp1.news.uk.psi.net... > SonoBull wrote in message ... > >im not a real programmer, having only a little experince in vb > pascal an > >smalltalk. > > > >But gona try mastering the art of python programming. > > If you haven't really programmed before, you might find the tutorial > a little steep. If this is the case, you might want to look at Alan > Gauld's 'Learning to Program using Python', at > http://www.crosswinds.net/~agauld/. > > Cheers, > Simon Brunning > sbrunning at bigfoot.com > > > From sbrunning at trisystems.co.uk Tue Feb 27 12:27:24 2001 From: sbrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 27 Feb 2001 11:27:24 -0000 Subject: First shot at python. References: <3a9b8049_1@nnrp1.news.uk.psi.net> Message-ID: <3a9b9465$1_1@nnrp1.news.uk.psi.net> SonoBull wrote in message ... >Ive been told that python is a good "leaning" language and is a good >"expert" language. It's *certainly* a good learning language. As to whether it's a good language for experts, well, you had better ask an expert. Well, actually I know enough to recognise an expert when I see one, and there are plenty using Python on this newsgroup, so I'd say that it *is* a good expert language. Cheers, Simon Brunning sbrunning at bigfoot.com From sholden at holdenweb.com Wed Feb 28 16:23:27 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 28 Feb 2001 10:23:27 -0500 Subject: First shot at python. References: <3a9b8049_1@nnrp1.news.uk.psi.net> <3a9b9465$1_1@nnrp1.news.uk.psi.net> Message-ID: "Simon Brunning" wrote in message news:3a9b9465$1_1 at nnrp1.news.uk.psi.net... > SonoBull wrote in message ... > >Ive been told that python is a good "leaning" language and is a > good > >"expert" language. > > It's *certainly* a good learning language. As to whether it's a good > language for experts, well, you had better ask an expert. > > Well, actually I know enough to recognise an expert when I see one, > and there are plenty using Python on this newsgroup, so I'd say that > it *is* a good expert language. > "ex" as in "has-been", "spurt" as in "drip under pressure". Expert = "has-been drip under pressure". regards Steve From sbrunning at trisystems.co.uk Wed Feb 28 17:02:29 2001 From: sbrunning at trisystems.co.uk (Simon Brunning) Date: Wed, 28 Feb 2001 16:02:29 -0000 Subject: First shot at python. References: <3a9b8049_1@nnrp1.news.uk.psi.net> <3a9b9465$1_1@nnrp1.news.uk.psi.net> Message-ID: <3a9d2e4b_2@nnrp1.news.uk.psi.net> Steve Holden wrote in message ... >> It's *certainly* a good learning language. As to whether it's a good >> language for experts, well, you had better ask an expert. >> >"ex" as in "has-been", "spurt" as in "drip under pressure". >Expert = "has-been drip under pressure". Hmmm. Perhaps I'm an expert after all. Cheers, Simon Brunning sbrunning at bigfoot.com From phd at phd.russ.ru Mon Feb 26 22:25:12 2001 From: phd at phd.russ.ru (Oleg Broytmann) Date: 26 Feb 2001 15:25:12 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Feb 26) Message-ID: <39CF1142A433B303.A58DD4189090B9CD.F336C38ED04DC6FE@lp.airnews.net> Jeremy Hylton updates PEP 227 (static scoping) http://groups.yahoo.com/group/python-list/message/124981 and thus starts a hot discussion http://groups.yahoo.com/group/python-list/messagesearch?query=Update%20to%20PEP%20227%20%28static%20scoping%29 Guido van Rossum announces nested scopes in 2.1 and 2.2 optional http://mail.python.org/pipermail/python-list/2001-February/030681.html David Mertz announces an oops on gnosis.cx/publish/ and moves to new hosting http://mail.python.org/pipermail/python-list/2001-February/030550.html David Mertz: Charming Python: Getting version 2.0 http://www-106.ibm.com/developerworks/library/l-py20.html?dwzone=linux David Mertz: Functional Programming in Python http://gnosis.cx/publish/programming/charming_python_13.txt Philipp wrapps www.graphviz.org's 'dot' language in Python http://groups.yahoo.com/group/python-list/message/124396 python powered mp3 management http://mpy3.thelocust.org/ Thomas Heller shows how to enter a (possibly dotted) python module name in the Emacs' minibuffer http://groups.yahoo.com/group/python-list/message/124525 gnome-python 1.4.0: Updated to work with the latest GtkHTML http://www.daa.com.au/~james/gnome/ Jerome Alet annonces new version of JAXML XML generator http://groups.yahoo.com/group/python-list/message/124939 Warren Postma announces event module 1.0 for better threading http://groups.yahoo.com/group/python-list/message/124830 Barry Warsaw updates PEP 232, Function Attributes http://groups.yahoo.com/group/python-list/message/124789 Amos Latteier announces Zope Directions Roadmap http://mail.python.org/pipermail/python-announce-list/2001-February/000673.html Stephen Figgins: Zope's New Roadmap http://www.oreillynet.com/pub/a/python/2001/02/22/pythonnews.html Jean-Luc Fontaine creates tclpython that embeds python into tcl http://mail.python.org/pipermail/python-list/2001-February/030652.html Lars Marius Garshol wraps James Clark's SP SGML parser http://www.garshol.priv.no/download/software/pysp/ Norbert Klamann creates a working setup.py for DCOracle 1.3.2 http://groups.yahoo.com/group/python-list/message/124940 Marc-Andre Lemburg launches eGenix and announces that Extensions for Python 2.0 http://mail.python.org/pipermail/python-announce-list/2001-February/000679.html Computer scientists at Endeavors Technology have successfully developed a highly optimized, open source port of Python to the Palm OS(R) platform to stimulate interest in creating Python-based applications for Palm(TM) handheld computers and other devices that use the Palm operating system. http://sf-web1.businesswire.com/cgi-bin/f_headline.cgi?day0/210540113&ticker= http://www.endeavors.com/pippy/ Chris Gonnerman posts an example code explaining how to extend Python in C/C++ http://groups.yahoo.com/group/python-list/message/125374 Uche Ogbuji announces "The Python Web services developer" column http://groups.yahoo.com/group/python-list/message/125405 Mark Hammond explains how to ensures the thread-lock is released when the function is called (SWIG) http://groups.yahoo.com/group/python-list/message/125473 Sean Reifschneider comtinues to think about CPAN functionality for python http://groups.yahoo.com/group/python-list/message/125510 Zope ---- Brian Lloyd announces SECURITY alert and hotfix release http://lists.zope.org/pipermail/zope/2001-February/084053.html Michel Pelletier announces Zope Book is now in public CVS http://lists.zope.org/pipermail/zope/2001-February/084061.html Hot threads of the week ----------------------- locking files http://groups.google.com/groups?lr=&safe=off&ic=1&th=e046814cf6e52ae3&seekd=917102346 Alternative iterator syntax http://groups.google.com/groups?lr=&safe=off&ic=1&th=f90597b5cb186d16&seekd=917023515 Comparison with Ruby http://groups.google.com/groups?lr=&safe=off&ic=1&th=105b832cf34cd872&seekd=916928222 Rounding Question http://groups.google.com/groups?lr=&safe=off&ic=1&th=d054718b0b4ad260&seekd=916921447 import statement is case sensitive http://groups.google.com/groups?lr=&safe=off&ic=1&th=24e0f1d3ddcb2ac5&seekd=916916940 An alternative approach to bound methods http://groups.google.com/groups?lr=&safe=off&ic=1&th=307b2dd2b5d6bc3f&seekd=916902767 ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Michael Hudson continues Andrew Kuchling's marvelous tradition of summarizing action on the python-dev mailing list twice a month. http://starship.python.net/crew/mwh/summaries/ http://www.amk.ca/python/dev The Vaults of Parnassus ambitiously collect Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Consortium emerges as an independent nexus of activity http://www.python.org/consortium Cetus does much of the same http://www.cetus-links.de/oo_python.html Python FAQTS http://python.faqts.com/ Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing trick of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From brian.j.geddes at intel.com Mon Feb 26 23:11:09 2001 From: brian.j.geddes at intel.com (Brian Geddes) Date: Mon, 26 Feb 2001 14:11:09 -0800 Subject: Packet parsing problem... Message-ID: <97ek6i$o6d@news.or.intel.com> Here's my situation: There is an already-existing server (written in C++), which communicates with clients through 1-packet messages. Each packet consists of a header of 2 or 3 C++ DWORDs, followed by 0 to n bytes of data. I have to write a Python client to communicate with this server. In python, is there any structure that approximates the C++ DWORD? I need to be able to parse incoming packets, as well as properly form messages to the server. Any suggestions? Thanks, - Brian From BrianQ at ActiveState.com Mon Feb 26 23:43:26 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Mon, 26 Feb 2001 14:43:26 -0800 Subject: Packet parsing problem... In-Reply-To: <97ek6i$o6d@news.or.intel.com> Message-ID: <002201c0a045$893c6c80$b503a8c0@activestate.ca> A DWORD is just a signed 32-bit integer. Your parsing code could look something like this (usual disclaimer of little thought and no testing). Actually, this is pretty ugly (integerize could be a lot cleaner). There has to be library code to do this... import socket # Do communication stuff here e.g. header = mySocket.recv( 2 * 4 ) def integerize( aString ): myInt = 0 for i in range(4): myInt = myInt + ord( aString[i] ) << 8 * (3 - i ) return myInt word1 = socket.ntohl( integerize( header[0:3] ) ) word2 = socket.ntohl( integerize( header[4:7] ) ) # ... Do more stuff -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Brian Geddes Sent: Monday, February 26, 2001 2:11 PM To: python-list at python.org Subject: Packet parsing problem... Here's my situation: There is an already-existing server (written in C++), which communicates with clients through 1-packet messages. Each packet consists of a header of 2 or 3 C++ DWORDs, followed by 0 to n bytes of data. I have to write a Python client to communicate with this server. In python, is there any structure that approximates the C++ DWORD? I need to be able to parse incoming packets, as well as properly form messages to the server. Any suggestions? Thanks, - Brian -- http://mail.python.org/mailman/listinfo/python-list From ljohnson at resgen.com Tue Feb 27 00:03:08 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Mon, 26 Feb 2001 17:03:08 -0600 Subject: Packet parsing problem... References: <97ek6i$o6d@news.or.intel.com> Message-ID: > In python, is there any structure that approximates the C++ DWORD? I need > to be able to parse incoming packets, as well as properly form messages to > the server. I hate to ask, but is this the DWORD that's commonly typedef'd in the Windows header files? If so, it's just a 32-bit (signed) integer and it should map to a Python integer. From ben.hutchings at roundpoint.com Tue Feb 27 04:09:01 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 26 Feb 2001 19:09:01 -0800 Subject: Packet parsing problem... References: <97ek6i$o6d@news.or.intel.com> Message-ID: "Lyle Johnson" writes: > > In python, is there any structure that approximates the C++ DWORD? I need > > to be able to parse incoming packets, as well as properly form messages to > > the server. > > I hate to ask, but is this the DWORD that's commonly typedef'd in the > Windows header files? If so, it's just a 32-bit (signed) integer and it > should map to a Python integer. No, DWORD is unsigned. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From news at dorb.com Tue Feb 27 01:38:39 2001 From: news at dorb.com (Darrell) Date: Tue, 27 Feb 2001 00:38:39 GMT Subject: Packet parsing problem... References: <97ek6i$o6d@news.or.intel.com> Message-ID: When parsing C structs use the struct model. import struct header = ......... fmt2="!II" fmt2Size=struct.calcsize(fmt2) fmt3="!III" if len(header) == fmt2Size: values = struct.unpack(fmt2, header) else: values = struct.unpack(fmt3, header) --Darrell "Brian Geddes" wrote in message news:97ek6i$o6d at news.or.intel.com... > Here's my situation: > > There is an already-existing server (written in C++), which communicates > with clients through 1-packet messages. Each packet consists of a header of > 2 or 3 C++ DWORDs, followed by 0 to n bytes of data. I have to write a > Python client to communicate with this server. > > In python, is there any structure that approximates the C++ DWORD? I need > to be able to parse incoming packets, as well as properly form messages to > the server. > > Any suggestions? > > Thanks, > - Brian > > From erno-news at erno.iki.fi Tue Feb 27 01:46:26 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 27 Feb 2001 02:46:26 +0200 Subject: Packet parsing problem... References: <97ek6i$o6d@news.or.intel.com> Message-ID: In article <97ek6i$o6d at news.or.intel.com>, "Brian Geddes" writes: | Here's my situation: | There is an already-existing server (written in C++), which communicates | with clients through 1-packet messages. Each packet consists of a header of | 2 or 3 C++ DWORDs, followed by 0 to n bytes of data. I have to write a | Python client to communicate with this server. | In python, is there any structure that approximates the C++ DWORD? I need | to be able to parse incoming packets, as well as properly form messages to | the server. i don't know what a DWORD is, but i suspect it might be an alias for some integer or pointer type in C++ on your software platform. in that case you can use the struct module to convert a sequence of bytes to the corresponding integer. things to keep in mind when using the struct module for on the wire protocols: 1) padding. for example, on the machine i'm reading my news on, >>> struct.calcsize('ich') 8 the struct module attempts to emulate the layout of c structs in memory on your platform, and that often includes padding. so it may be better to unpack the packets one item at a time. 2) portability - the sizes of the types use by the stuct module can vary accross platforms. you may decide it's ok to not be portable, or you may want to use different formats on different platforms you want your program to run on, or for purists, you may want to abandon the struct module completely for this purpouse and do the work completely by hand via ord() an shifts. also byte endianness - you probably need to specify the endianness explicitly. it would be nice to have a struct-ish module in the standard distribution that would be geared towards working with data formats with known bit layout... -- erno From ben.hutchings at roundpoint.com Tue Feb 27 22:37:08 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 27 Feb 2001 13:37:08 -0800 Subject: Packet parsing problem... References: <97ek6i$o6d@news.or.intel.com> Message-ID: Erno Kuusela writes: > In article <97ek6i$o6d at news.or.intel.com>, "Brian Geddes" > writes: > > | Here's my situation: > | There is an already-existing server (written in C++), which > | communicates with clients through 1-packet messages. Each packet > | consists of a header of 2 or 3 C++ DWORDs, followed by 0 to n bytes > | of data. I have to write a Python client to communicate with this > | server. > > | In python, is there any structure that approximates the C++ DWORD? > | I need to be able to parse incoming packets, as well as properly > | form messages to the server. > it would be nice to have a struct-ish module in the standard > distribution that would be geared towards working with data > formats with known bit layout... We already have one! You can use a modifier at the beginning of a struct format string to select one of 5 size, byte ordering and alignment rules (the first one being the default, native, rules). So I suppose Brian might read messages using something like this: from struct import * (type,) = unpack(message[0:4], ' I installed the PyQt bindings and SIP on my RH 6.2 Linux system. Everything compiled quite nicely. But the files do not appear to have been placed in the correct subdirectories. None of the samples will run. Where should the qt directory containing qt.py be located? I tried moving it to the site-packages directory, but that didn't work. Thanks. Bruce From aaron.ginn at motorola.com Tue Feb 27 23:24:08 2001 From: aaron.ginn at motorola.com (Aaron Ginn) Date: 27 Feb 2001 15:24:08 -0700 Subject: PyQt file locations References: <3A9AE155.FF8C3A08@ucdavis.edu> Message-ID: Bruce Wolk writes: > I installed the PyQt bindings and SIP on my RH 6.2 Linux system. > Everything compiled quite nicely. But the files do not appear to have > been placed in the correct subdirectories. None of the samples will > run. Where should the qt directory containing qt.py be located? I > tried moving it to the site-packages directory, but that didn't work. > > Thanks. > > Bruce Here's what's in my site-packages directory: ginn at coronado ginn $ ls python-2.0/lib/python2.0/site-packages/ README libqtcmodule-2.3.so* libqtcmodule.so@ qt.pyc eric/ libqtcmodule.la* qt.py qt.pyo You can't simply move the qt directory there, as there are many more files than what are in my site-packages directory. Shouldn't 'make install' have taken care of this for you? What happened when you did a make install? -- Aaron J. Ginn Phone: 480-814-4463 Motorola SemiCustom Solutions Pager: 877-586-2318 1300 N. Alma School Rd. Fax : 480-814-4463 Chandler, AZ 85226 M/D CH260 mailto:aaron.ginn at motorola.com From bawolk at ucdavis.edu Wed Feb 28 04:20:11 2001 From: bawolk at ucdavis.edu (Bruce Wolk) Date: Tue, 27 Feb 2001 19:20:11 -0800 Subject: PyQt file locations References: <3A9AE155.FF8C3A08@ucdavis.edu> Message-ID: <3A9C6E6B.3B727A37@ucdavis.edu> I have the same files in my site-packages directory, except for qt.pyc. make-install gave me some errors: _______________________________ Making install in qt make[1]: Entering directory `/home/bruce/down/PyQt-2.3/qt' make[2]: Entering directory `/home/bruce/down/PyQt-2.3/qt' /bin/sh ../mkinstalldirs /usr/local/lib/python2.0/site-packages /bin/sh ../libtool --mode=install /usr/bin/install -c libqtcmodule.la /usr/local/lib/python2.0/site-packages/libqtcmodule.la /usr/bin/install -c .libs/libqtcmodule-2.3.so /usr/local/lib/python2.0/site-packages/libqtcmodule-2.3.so (cd /usr/local/lib/python2.0/site-packages && rm -f libqtcmodule.so && ln -s libqtcmodule-2.3.so libqtcmodule.so) /usr/bin/install -c .libs/libqtcmodule.lai /usr/local/lib/python2.0/site-packages/libqtcmodule.la PATH="$PATH:/sbin" ldconfig -n /usr/local/lib/python2.0/site-packages ---------------------------------------------------------------------- Libraries have been installed in: /usr/local/lib/python2.0/site-packages If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,--rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- /bin/sh ../mkinstalldirs /usr/local/lib/python2.0/site-packages /usr/bin/install -c -m 644 ./qt.py /usr/local/lib/python2.0/site-packages/qt.pymake install-data-hook make[3]: Entering directory `/home/bruce/down/PyQt-2.3/qt' (cd /tmp; PYTHONPATH=/usr/local/lib/python2.0/site-packages:/usr/local/lib/python2.0/site-packages python -O -c "import qt") 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? Bruce Aaron Ginn wrote: > Bruce Wolk writes: > > > I installed the PyQt bindings and SIP on my RH 6.2 Linux system. > > Everything compiled quite nicely. But the files do not appear to have > > been placed in the correct subdirectories. None of the samples will > > run. Where should the qt directory containing qt.py be located? I > > tried moving it to the site-packages directory, but that didn't work. > > > > Thanks. > > > > Bruce > > Here's what's in my site-packages directory: > > ginn at coronado ginn $ ls python-2.0/lib/python2.0/site-packages/ > README libqtcmodule-2.3.so* libqtcmodule.so@ qt.pyc > eric/ libqtcmodule.la* qt.py qt.pyo > > You can't simply move the qt directory there, as there are many more > files than what are in my site-packages directory. Shouldn't 'make > install' have taken care of this for you? What happened when you did > a make install? > > -- > Aaron J. Ginn Phone: 480-814-4463 > Motorola SemiCustom Solutions Pager: 877-586-2318 > 1300 N. Alma School Rd. Fax : 480-814-4463 > Chandler, AZ 85226 M/D CH260 mailto:aaron.ginn at motorola.com From fpm at u.washington.edu Wed Feb 28 17:11:32 2001 From: fpm at u.washington.edu (Frank Miles) Date: 28 Feb 2001 16:11:32 GMT Subject: PyQt file locations References: <3A9AE155.FF8C3A08@ucdavis.edu> <3A9C6E6B.3B727A37@ucdavis.edu> Message-ID: <97j7vk$l2c$1@nntp6.u.washington.edu> 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 fimafeng at yahoo.com Tue Feb 27 00:26:54 2001 From: fimafeng at yahoo.com (Chris Nelson) Date: Mon, 26 Feb 2001 23:26:54 GMT Subject: To the point of defeat.....IDLE Message-ID: <3A9AE62B.5070402@yahoo.com> I've tried everyhting I know to try and get IDLE to run on Red Hat Linux 7 with BeOpen Python 2.0 If anyone has done this can they please tell me what they had to do in order to get the setup to work??? I've even went as far as installing the Red Hat 7.1 beta and it's still using python 1.5.2 I need 2.0 support with IDLE Please help... I'll pay whatever karma it takes From stevencooper at isomedia.com Tue Feb 27 01:40:21 2001 From: stevencooper at isomedia.com (Steve Cooper) Date: Mon, 26 Feb 2001 16:40:21 -0800 Subject: To the point of defeat.....IDLE References: <3A9AE62B.5070402@yahoo.com> Message-ID: <3A9AF775.48635594@isomedia.com> I found I needed to install some Tk stuff to get it to work (on Debian). I unfortunately do not remember the exact package. HTH, Steve Cooper Chris Nelson wrote: > I've tried everyhting I know to try and get IDLE to run on Red Hat Linux > 7 with BeOpen Python 2.0 > > If anyone has done this can they please tell me what they had to do in > order to get the setup to work??? > > I've even went as far as installing the Red Hat 7.1 beta and it's still > using python 1.5.2 > > I need 2.0 support with IDLE > > Please help... I'll pay whatever karma it takes > > -- > http://mail.python.org/mailman/listinfo/python-list From bryan at eevolved.com Tue Feb 27 03:35:13 2001 From: bryan at eevolved.com (Bryan Mongeau) Date: Tue, 27 Feb 2001 02:35:13 GMT Subject: To the point of defeat.....IDLE References: <3A9AE62B.5070402@yahoo.com> Message-ID: Chris Nelson wrote: > I've tried everyhting I know to try and get IDLE to run on Red Hat Linux > 7 with BeOpen Python 2.0 > > If anyone has done this can they please tell me what they had to do in > order to get the setup to work??? > > I've even went as far as installing the Red Hat 7.1 beta and it's still > using python 1.5.2 > > I need 2.0 support with IDLE > > Please help... I'll pay whatever karma it takes > Don't despair Chris, I have been able to run IDLE and 2.0 with no problems on Mandrake 7.2. Perhaps the community would be able to help you more if you described your exact problem in greater detail. I am running 2.0 from rpm and IDLE 0.7.1 from a tarball accessible here: http://sourceforge.net/project/idlefork/ I'd be glad to help, I just don't know what your problem is! -- <=====================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. Website: http://www.eevolved.com Public key: http://eevolved.com/bcm.pk <=====================================> "They express a preference for 'natural' methods of population limitation, and a natural method is exactly what they are going to get. It is called starvation." -- Richard Dawkins From fimafeng at yahoo.com Tue Feb 27 03:56:47 2001 From: fimafeng at yahoo.com (Chris Nelson) Date: Tue, 27 Feb 2001 02:56:47 GMT Subject: To the point of defeat.....IDLE References: <3A9AE62B.5070402@yahoo.com> Message-ID: <3A9B175D.8080605@yahoo.com> > > Don't despair Chris, I have been able to run IDLE and 2.0 with no problems > > on Mandrake 7.2. Perhaps the community would be able to help you more if > > you described your exact problem in greater detail. > > > > I am running 2.0 from rpm and IDLE 0.7.1 from a tarball accessible here: > > > > http://sourceforge.net/project/idlefork/ > > > > I'd be glad to help, I just don't know what your problem is! Thank you for responding. Let me tell you where I am in this process. I'll start with what my Red Hat 7 System will typically have on it tcl 8.3-1 tk 8.3-1 python 1.5.2 tkinter for 1.5.2 There is an optional rpm package called "Python tools" which if installed give you IDLE.(assoicated with the 1.5.2 python) First off I can't use the Python2.0 BeOpen RPM at python.org ...When I attempt to. The systemsill complain about library dependencies for tcl and tk 8.0. If I download the source for BeOpen 2.0 and do a "./configure" "make" and "make install" the BeOpen software installs. However... If I try to bring up IDLE...it is associated with the 1.5.2 interpreter. What do I need to do so IDLE will wun with 2.0 instead? Thanks, Chris Nelson From bsass at freenet.edmonton.ab.ca Tue Feb 27 13:02:05 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Tue, 27 Feb 2001 05:02:05 -0700 (MST) Subject: To the point of defeat.....IDLE In-Reply-To: <3A9B175D.8080605@yahoo.com> Message-ID: > First off I can't use the Python2.0 BeOpen RPM at python.org ...When I > attempt to. The systemsill complain about library dependencies for tcl > and tk 8.0. > > If I download the source for BeOpen 2.0 and do a "./configure" "make" > and "make install" the BeOpen software installs. > > However... > If I try to bring up IDLE...it is associated with the 1.5.2 interpreter. > > What do I need to do so IDLE will wun with 2.0 instead? Have a look at the .py executables that came with your py-2.0, I think you will find that they use #!...python - which results in the python-1.5.2 interpreter starting up. Not what you want! You need to track down all the executable scripts and make sure they refer to python2.0. The fixps.py script in the Tools dir of py-2.0 will automate the task - but look at it first and edit it to reflect your setup (namely, the location of python2.0). - Bruce From news at pastelhorn.com Tue Feb 27 00:48:46 2001 From: news at pastelhorn.com (Willem Broekema) Date: Tue, 27 Feb 2001 00:48:46 +0100 Subject: ndiff feature request Message-ID: <3A9AEB5E.6030502@pastelhorn.com> The new 'ndiff.py' module (./tools/scripts/ndiff.py) contains among others this function "fcompare(f1name, f2name)" that opens two files given their names, readlines() them, and creates a 'diff' of the lists: def fcompare(f1name, f2name): f1 = fopen(f1name) f2 = fopen(f2name) if not f1 or not f2: return 0 a = f1.readlines(); f1.close() b = f2.readlines(); f2.close() cruncher = SequenceMatcher(IS_LINE_JUNK, a, b) for tag, alo, ahi, blo, bhi in cruncher.get_opcodes(): ... How about separating these two tasks, by creating a function, say, "lcompare(a,b)" that takes two lists as argument, and does the things from "cruncher = ..." onwards. Then, fcompare could call that function after the files are opened and checked. This would make other ways of diff-ing possible without having to write to a temporary file first. Things like diffing urllib.urlopen("http://someurl").readlines() with a cached list object, for example. Or is there already an easy way to do this? - Willem From ACIUFFO1 at irf.com Tue Feb 27 01:28:36 2001 From: ACIUFFO1 at irf.com (Andrea Ciuffoli) Date: Mon, 26 Feb 2001 16:28:36 -0800 Subject: Ftplib Message-ID: Hello, I am using the "Ftplib" library to connect my PC to an FTP server, list all the files of a specific directory and transfer only the ones created in the last hour. My problem is that the command ftp.retrlines('LIST',listing.append) appends in listing some information about the file but I noticed that if the file is created in 2001 doesn't store the year among the information while if it is created in 2000 or before doesn't stores the year but not the time. e.g. -rwxrwxrwx 1 noone nogroup 40889 Dec 26 1999 1.txt -rwxrwxrwx 1 noone nogroup 40889 Dec 26 2000 2.txt -rwxrwxrwx 1 noone nogroup 40889 Jan 5 2000 3.txt -rwxrwxrwx 1 noone no group 81630 Feb 5 12:12 4.tat -rwxrwxrwx 1 noone no group 81630 Feb 5 12:12 5.tat -rwxrwxrwx 1 noone no group 19456 Feb 8 15:27 6.tat The last 3 files were created in 2001. I was wondering is it is possible to have either Time and Year. Are there some example on how the "Ftplib" commands work? Thanks in advance and my best regards, Andrea. From db3l at fitlinxx.com Tue Feb 27 02:48:54 2001 From: db3l at fitlinxx.com (David Bolen) Date: 26 Feb 2001 20:48:54 -0500 Subject: Ftplib References: Message-ID: "Andrea Ciuffoli" writes: > Hello, > I am using the "Ftplib" library to connect my PC to an FTP server, list = > all the files of a specific directory and transfer only the ones created = > in the last hour. > My problem is that the command > > ftp.retrlines('LIST',listing.append) > > appends in listing some information about the file but I noticed that if = > the file is created in 2001 doesn't store the year among the information = > while if it is created in 2000 or before doesn't stores the year but not = > the time. That's really up to the FTP server that you connect to, but is fairly typical of Unix output format, so I'm guessing you're connecting to some variant of Unix server. If the file is within the past year, it shows full date/time - if more than a year old, it shows date and year. In other words, this is the same sort of listing you'd get if you were locally on that server and asked for a directory from the shell. The LIST command in FTP brings back an ASCII (or EBCDIC), human readable directory listing, but its format is not standardized, so servers are free to pretty much do whatever they want. It's intended to be easy for humans to view but not required to be easy for computers to parse. There's probably not much you can do about this; although some servers may process Unix-like options (which may modify the output format) as part of the arguments to the LIST command, it's pot-luck and not something to depend on. Parsing the format isn't too bad though since the presence of a colon can tell you which format each line is in. Of course if you absolutely need the timestamp for a file more than a year old, you may have a problem :-) But since you mention pulling those from the last hour, this shouldn't be much of an issue. -- -- 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 qrczak at knm.org.pl Tue Feb 27 23:19:30 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 27 Feb 2001 22:19:30 GMT Subject: Ftplib References: Message-ID: 26 Feb 2001 20:48:54 -0500, David Bolen pisze: > If the file is within the past year, it shows full date/time - > if more than a year old, it shows date and year. The threshold is 6 months. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From sholden at holdenweb.com Wed Feb 28 16:17:16 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 28 Feb 2001 10:17:16 -0500 Subject: Ftplib References: Message-ID: "Andrea Ciuffoli" wrote in message news:mailman.983233808.14489.python-list at python.org... Hello, I am using the "Ftplib" library to connect my PC to an FTP server, list all the files of a specific directory and transfer only the ones created in the last hour. My problem is that the command ftp.retrlines('LIST',listing.append) appends in listing some information about the file but I noticed that if the file is created in 2001 doesn't store the year among the information while if it is created in 2000 or before doesn't stores the year but not the time. e.g. -rwxrwxrwx 1 noone nogroup 40889 Dec 26 1999 1.txt -rwxrwxrwx 1 noone nogroup 40889 Dec 26 2000 2.txt -rwxrwxrwx 1 noone nogroup 40889 Jan 5 2000 3.txt -rwxrwxrwx 1 noone no group 81630 Feb 5 12:12 4.tat -rwxrwxrwx 1 noone no group 81630 Feb 5 12:12 5.tat -rwxrwxrwx 1 noone no group 19456 Feb 8 15:27 6.tat The last 3 files were created in 2001. I was wondering is it is possible to have either Time and Year. Are there some example on how the "Ftplib" commands work? Thanks in advance and my best regards, Andrea. Take a look at the ftpmirror.py script in the Tools distribution directory. It handles this problem quite well, and may even do everything you want to do. regards Steve From tim.one at home.com Tue Feb 27 02:18:37 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 26 Feb 2001 20:18:37 -0500 Subject: PEP 236: Back to the __future__ Message-ID: The text of this PEP can also be found online, at: http://python.sourceforge.net/peps/pep-0236.html PEP: 236 Title: Back to the __future__ Version: $Revision: 1.2 $ Author: Tim Peters Python-Version: 2.1 Status: Active Type: Standards Track Created: 26-Feb-2001 Post-History: 26-Feb-2001 Motivation From time to time, Python makes an incompatible change to the advertised semantics of core language constructs, or changes their accidental (implementation-dependent) behavior in some way. While this is never done capriciously, and is always done with the aim of improving the language over the long term, over the short term it's contentious and disrupting. The "Guidelines for Language Evolution" PEP [1] suggests ways to ease the pain, and this PEP introduces some machinery in support of that. The "Statically Nested Scopes" PEP [2] is the first application, and will be used as an example here. Intent [Note: This is policy, and so should eventually move into PEP 5[1]] When an incompatible change to core language syntax or semantics is being made: 1. The release C that introduces the change does not change the syntax or semantics by default. 2. A future release R is identified in which the new syntax or semantics will be enforced. 3. The mechanisms described in the "Warning Framework" PEP [3] are used to generate warnings, whenever possible, about constructs or operations whose meaning may[4] change in release R. 4. The new future_statement (see below) can be explicitly included in a module M to request that the code in module M use the new syntax or semantics in the current release C. So old code continues to work by default, for at least one release, although it may start to generate new warning messages. Migration to the new syntax or semantics can proceed during that time, using the future_statement to make modules containing it act as if the new syntax or semantics were already being enforced. Note that there is no need to involve the future_statement machinery in new features unless they can break existing code; fully backward- compatible additions can-- and should --be introduced without a corresponding future_statement. Syntax A future_statement is simply a from/import statement using the reserved module name __future__: future_statement: "from" "__future__" "import" feature ["as" name] ("," feature ["as" name])* feature: identifier name: identifier In addition, all future_statments must appear near the top of the module. The only lines that can appear before a future_statement are: + The module docstring (if any). + Comments. + Blank lines. + Other future_statements. Example: """This is a module docstring.""" # This is a comment, preceded by a blank line and followed by # a future_statement. from __future__ import nested_scopes from math import sin from __future__ import alabaster_weenoblobs # compile-time error! # That was an error because preceded by a non-future_statement. Semantics A future_statement is recognized and treated specially at compile time: changes to the semantics of core constructs are often implemented by generating different code. It may even be the case that a new feature introduces new incompatible syntax (such as a new reserved word), in which case the compiler may need to parse the module differently. Such decisions cannot be pushed off until runtime. For any given release, the compiler knows which feature names have been defined, and raises a compile-time error if a future_statement contains a feature not known to it[5]. The direct runtime semantics are the same as for any import statement: there is a standard module __future__.py, described later, and it will be imported in the usual way at the time the future_statement is executed. The *interesting* runtime semantics depend on the specific feature(s) "imported" by the future_statement(s) appearing in the module. Note that there is nothing special about the statement: import __future__ [as name] That is not a future_statement; it's an ordinary import statement, with no special semantics or syntax restrictions. Example Consider this code, in file scope.py: x = 42 def f(): x = 666 def g(): print "x is", x g() f() Under 2.0, it prints: x is 42 Nested scopes[2] are being introduced in 2.1. But under 2.1, it still prints x is 42 and also generates a warning. In 2.2, and also in 2.1 *if* "from __future__ import nested_scopes" is included at the top of scope.py, it prints x is 666 Standard Module __future__.py Lib/__future__.py is a real module, and serves three purposes: 1. To avoid confusing existing tools that analyze import statements and expect to find the modules they're importing. 2. To ensure that future_statements run under releases prior to 2.1 at least yield runtime exceptions (the import of __future__ will fail, because there was no module of that name prior to 2.1). 3. To document when incompatible changes were introduced, and when they will be-- or were --made mandatory. This is a form of executable documentation, and can be inspected programatically via importing __future__ and examining its contents. Each statment in __future__.py is of the form: FeatureName = ReleaseInfo ReleaseInfo is a pair of the form: (OptionalRelease, MandatoryRelease) where, normally, OptionalRelease < MandatoryRelease, and both are 5-tuples of the same form as sys.version_info: (PY_MAJOR_VERSION, # the 2 in 2.1.0a3; an int PY_MINOR_VERSION, # the 1; an int PY_MICRO_VERSION, # the 0; an int PY_RELEASE_LEVEL, # "alpha", "beta", "candidate" or "final"; string PY_RELEASE_SERIAL # the 3; an int ) OptionalRelease records the first release in which from __future__ import FeatureName was accepted. In the case of MandatoryReleases that have not yet occurred, MandatoryRelease predicts the release in which the feature will become part of the language. Else MandatoryRelease records when the feature became part of the language; in releases at or after that, modules no longer need from __future__ import FeatureName to use the feature in question, but may continue to use such imports. MandatoryRelease may also be None, meaning that a planned feature got dropped. No line will ever be deleted from __future__.py. Example line: nested_scopes = (2, 1, 0, "beta", 1), (2, 2, 0, "final", 0) This means that from __future__ import nested_scopes will work in all releases at or after 2.1b1, and that nested_scopes are intended to be enforced starting in release 2.2. Unresolved Problems: Runtime Compilation Several Python features can compile code during a module's runtime: 1. The exec statement. 2. The execfile() function. 3. The compile() function. 4. The eval() function. 5. The input() function. Since a module M containing a future_statement naming feature F explicitly requests that the current release act like a future release with respect to F, any code compiled dynamically from text passed to one of these from within M should probably also use the new syntax or semantics associated with F. This isn't always desired, though. For example, doctest.testmod(M) compiles examples taken from strings in M, and those examples should use M's choices, not necessarily doctest module's choices. It's unclear what to do about this. The initial release (2.1b1) is likely to ignore these issues, saying that each dynamic compilation starts over from scratch (i.e., as if no future_statements had been specified). In any case, a future_statement appearing "near the top" (see Syntax above) of text compiled dynamically by an exec, execfile() or compile() applies to the code block generated, but has no further effect on the module that executes such an exec, execfile() or compile(). This can't be used to affect eval() or input(), however, because they only allow expression input, and a future_statement is not an expression. Unresolved Problems: Interactive Shells An interactive shell can be seen as an extreme case of runtime compilation (see above): in effect, each statement typed at an interactive shell prompt runs a new instance of exec, compile() or execfile(). The initial release (2.1b1) is likely to be such that future_statements typed at an interactive shell have no effect beyond their runtime meaning as ordinary import statements. It would make more sense if a future_statement typed at an interactive shell applied to the rest of the shell session's life, as if the future_statement had appeared at the top of a module. Again, it's unclear what to do about this. Questions and Answers Q: What about a "from __past__" version, to get back *old* behavior? A: Outside the scope of this PEP. Seems unlikely to the author, though. Write a PEP if you want to pursue it. Q: What about incompatibilites due to changes in the Python virtual machine? A: Outside the scope of this PEP, although PEP 5[1] suggests a grace period there too, and the future_statement may also have a role to play there. Q: What about incompatibilites due to changes in Python's C API? A: Outside the scope of this PEP. Q: I want to wrap future_statements in try/except blocks, so I can use different code depending on which version of Python I'm running. Why can't I? A: Sorry! try/except is a runtime feature; future_statements are primarily compile-time gimmicks, and your try/except happens long after the compiler is done. That is, by the time you do try/except, the semantics in effect for the module are already a done deal. Since the try/except wouldn't accomplish what it *looks* like it should accomplish, it's simply not allowed. We also want to keep these special statements very easy to find and to recognize. Note that you *can* import __future__ directly, and use the information in it, along with sys.version_info, to figure out where the release you're running under stands in relation to a given feature's status. Q: Going back to the nested_scopes example, what if release 2.2 comes along and I still haven't changed my code? How can I keep the 2.1 behavior then? A: By continuing to use 2.1, and not moving to 2.2 until you do change your code. The purpose of future_statement is to make life easier for people who keep keep current with the latest release in a timely fashion. We don't hate you if you don't, but your problems are much harder to solve, and somebody with those problems will need to write a PEP addressing them. future_statement is aimed at a different audience. Copyright This document has been placed in the public domain. References and Footnotes [1] http://python.sourceforge.net/peps/pep-0005.html [2] http://python.sourceforge.net/peps/pep-0227.html [3] http://python.sourceforge.net/peps/pep-0230.html [4] Note that this is "may" and not "will": better safe than sorry. Of course spurious warnings won't be generated when avoidable with reasonable cost. [5] This ensures that a future_statement run under a release prior to the first one in which a given feature is known (but >= 2.1) will raise a compile-time error rather than silently do a wrong thing. If transported to a release prior to 2.1, a runtime error will be raised because of the failure to import __future__ (no such module existed in the standard distribution before the 2.1 release, and the double underscores make it a reserved name). Local Variables: mode: indented-text indent-tabs-mode: nil End: From wunschname at kapet.de Tue Feb 27 11:25:05 2001 From: wunschname at kapet.de (Karsten Petersen) Date: Tue, 27 Feb 2001 11:25:05 +0100 Subject: PEP 236: Back to the __future__ References: Message-ID: <1avf79.sr1.ln@dollerup.csn.tu-chemnitz.de> Hello, some comments from the lurkers-corner: I am not too lucky with all those improvements/changes inside the language. In fact I am rather scared. Let me explain why: Since 1997 I am using Python for a lot of my projects, the reasons were ease of use, the clearness of the language and its availability and compatibility across platform borders. And well, I still use Python 1.5.2 and am not seeing a reason to upgrade. If I upgrade to 2.0, I will have to recompile all C modules, check everything if it still runs and so on. But what about 2.1 or 2.2? Will I have to recompile and/or recheck everything again? For me it seems so, and I am not willing to do that. I want to _use_ Python, its implementation details are something I am not really interested in. It is possible to compile C sources that were written in the 80s. It is possible to run (more or less simple) Perl programs which are several years old. Will I be able in 2005 to run the code I have written today? If there would be one big change I could cope with it. But with smaller changes and trouble every couple of months I am rather unsatisfied. Greets, Karsten -- 10./11.3.: 3. Chemnitzer Linux-Tag: http://www.tu-chemnitz.de/linux/tag/ ,-, 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 andreas at digicool.com Tue Feb 27 13:52:10 2001 From: andreas at digicool.com (Andreas Jung) Date: Tue, 27 Feb 2001 07:52:10 -0500 Subject: PEP 236: Back to the __future__ References: <1avf79.sr1.ln@dollerup.csn.tu-chemnitz.de> Message-ID: <012c01c0a0bf$f25c3220$d0063bd0@SUXLAP> ----- Original Message ----- From: "Karsten Petersen" > Hello, > some comments from the lurkers-corner: > > I am not too lucky with all those improvements/changes inside the > language. In fact I am rather scared. > > Let me explain why: > Since 1997 I am using Python for a lot of my projects, the reasons were > ease of use, the clearness of the language and its availability and > compatibility across platform borders. > > And well, I still use Python 1.5.2 and am not seeing a reason to > upgrade. > > If I upgrade to 2.0, I will have to recompile all C modules, check > everything if it still runs and so on. But what about 2.1 or 2.2? > Will I have to recompile and/or recheck everything again? > For me it seems so, and I am not willing to do that. > > I want to _use_ Python, its implementation details are something I am > not really interested in. > > > It is possible to compile C sources that were written in the 80s. But you can also find C sources that compile only on the system they were written for. > > It is possible to run (more or less simple) Perl programs which are > several years old. see above... I have also seen Perl hacks and so-called programs that were running under 4.X but no longer under 5.X. > Will I be able in 2005 to run the code I have written today? > I am using Python since 1992 and the canges between the version usually did not require any changes (except when we are talking about extension modules in C/C++). In general there should be no need to change native Python code. Although some extension in 2.1 and 2.2 might break existing code. When you are working in a production environment with Python you must take care of version changes (never change a running system). Andreas From tim.one at home.com Tue Feb 27 18:13:15 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 27 Feb 2001 12:13:15 -0500 Subject: PEP 236: Back to the __future__ In-Reply-To: <1avf79.sr1.ln@dollerup.csn.tu-chemnitz.de> Message-ID: [Karsten Petersen] > ... > I am not too lucky with all those improvements/changes inside the > language. In fact I am rather scared. > > Let me explain why: > Since 1997 I am using Python for a lot of my projects, the reasons were > ease of use, the clearness of the language and its availability and > compatibility across platform borders. I've been using it since 1991, and have found the burden of incompatible Python changes to be trivial over that time. They'll be even easier to deal with using the __future__ mechanism. > And well, I still use Python 1.5.2 and am not seeing a reason to > upgrade. That's OK. The PEP doesn't *require* you to upgrade . > If I upgrade to 2.0, I will have to recompile all C modules, check > everything if it still runs and so on. But what about 2.1 or 2.2? > Will I have to recompile and/or recheck everything again? Depends on the platform (e.g., on Windows the name of the release is in effect buried in .pyds that link to it), and on whether changes are also made to the Python virtual machine and/or C API. > For me it seems so, and I am not willing to do that. > > I want to _use_ Python, its implementation details are something I am > not really interested in. > > It is possible to compile C sources that were written in the 80s. > > It is possible to run (more or less simple) Perl programs which are > several years old. > > Will I be able in 2005 to run the code I have written today? I've got Python that hasn't changed since 1991; I expect it will work fine in 2011 too. Don't overblow this. > If there would be one big change I could cope with it. But with smaller > changes and trouble every couple of months I am rather unsatisfied. No offense, but I don't buy this. If you're still sticking to 1.5.2 by choice, you're simply change-aversive. Nothing wrong with that! But it makes the notion that some other form of change *would* leave you happy is hard to buy. the-pep-is-as-it-says-for-people-who-do-stay-current-ly y'rs - tim From db3l at fitlinxx.com Wed Feb 28 02:13:05 2001 From: db3l at fitlinxx.com (David Bolen) Date: 27 Feb 2001 20:13:05 -0500 Subject: PEP 236: Back to the __future__ References: <1avf79.sr1.ln@dollerup.csn.tu-chemnitz.de> Message-ID: wunschname at kapet.de (Karsten Petersen) writes: > If I upgrade to 2.0, I will have to recompile all C modules, check > everything if it still runs and so on. (...) I believe that so far recompilation and/or relinking has been about it. Existing C extension code should have run into very little (if any) incompatibilities at the source API level. > It is possible to compile C sources that were written in the 80s. Right - "compile" (and or recheck). That's the nature of using C, and also impacts C extensions for Python, but that's one of the tradeoffs (recompilation) of using C extensions rather than Python itself. > It is possible to run (more or less simple) Perl programs which are > several years old. And you could likely same the same thing about Python scripts (note, Python, not C extensions) as well. Don't get me wrong - in a production environment and with a production language I think that transitions must absolutely be clean and backwards compatibility extremely important. But you also can't avoid all change entirely, and I think that recent Python events have been very good at maintaining existing behavior. I am however, more willing to accept some additional burden on C level extensions over the course of time, simply because by their nature they are lower level and subject to many of the C-based constraints (binary compatibility, Windows DLL loading, etc...) that the pure Python source is not. On my own machine, I've kept up with Python 2.0 and now 2.1, but in my production environment and deployed base it's still Python 1.5.2. Some of that delay is ensuring all the extensions I like are available, and some of it is just the hurdle of the deployment. But I don't really feel that Python has moved too quickly yet, and I'm comfortable that my Python scripts themselves (from testing them on my machine with 2.0 and 2.1) will survive the transition when it does come with hardly a burp. -- -- 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 hinsen at cnrs-orleans.fr Tue Feb 27 12:11:22 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 27 Feb 2001 12:11:22 +0100 Subject: PEP 236: Back to the __future__ References: Message-ID: "Tim Peters" writes: > From time to time, Python makes an incompatible change to the > advertised semantics of core language constructs, or changes their > accidental (implementation-dependent) behavior in some way. While this I am not at all happy with this approach. Incompatible changes should not happen "from time to time", but as rarely as possible and then all at the same time. I much preferred the "Py3K" project which was to include all the improvements that had to be held back due to compatibility concern. Like many Python users, I have a huge base of installed code, lots of it written by myself, but the majority written by others. Everything works fine together, and I am happy and productive. Now comes Python 2.1 with nested scopes. I don't expect much of my own code to break, but I can't be sure, I certainly didn't write it with a possible change of scoping rules in mind. So perhaps I'll have to modify it a bit, that shouldn't be much work. But then there's all the code from others that might also break, and that I don't want to fix at all. And since some of my code will depend on code from others, I won't fix my own code either and stick to Python 1.5 instead. Which in turn forces others who depend on my code to do the same. Sure, sooner or later everybody will want to use the new features of Python 2.1. But by then Python 2.1 will have been replaced by 2.2, with its own set of incompatible changes. If, on the other hand, incompatible changes occur only every five years or so, then people will be inclined to install two Python distributions in parallel and update their code over a period of a few months. Moral: incompatible changes should happen on a time scale compatible with uncoordinated collective code development, which is years, not months. -- ------------------------------------------------------------------------------- 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 jeremy at alum.mit.edu Tue Feb 27 16:17:43 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Tue, 27 Feb 2001 10:17:43 -0500 (EST) Subject: PEP 236: Back to the __future__ In-Reply-To: References: Message-ID: <15003.50455.960475.77114@w221.z064000254.bwi-md.dsl.cnc.net> >>>>> "KH" == Konrad Hinsen writes: KH> Moral: incompatible changes should happen on a time scale KH> compatible with uncoordinated collective code development, which KH> is years, not months. The goal of future_statements is to lengthen the time scale for incompatible changes while allowing some users to access the functionality now. With the addition of from __future__ import nested_scopes, there should be no incompatible changes in 2.1. At the same time, I expect very little code to require changes to be compatible with nested scopes. My own survey of three large projects found four problems in 200,000 lines of code. I have yet to hear statistics for any other project. Jeremy From tim.one at home.com Tue Feb 27 19:14:30 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 27 Feb 2001 13:14:30 -0500 Subject: PEP 236: Back to the __future__ In-Reply-To: Message-ID: [posted & mailed] [PEP 236] > From time to time, Python makes an incompatible change to the > advertised semantics of core language constructs, or changes their > accidental (implementation-dependent) behavior in some way. [Konrad Hinsen] > I am not at all happy with this approach. Incompatible changes should > not happen "from time to time", but as rarely as possible and then all > at the same time. The PEP doesn't address either the frequency or nature of incompatible changes, it's defining a mechanism to help people deal with incompatible changes *when* they occur. > I much preferred the "Py3K" project which was to include all the > improvements that had to be held back due to compatibility concern. Incompatible changes have been made with virtually every Python release since before 1.0. The changes are *usually* so minor and affect so little code that few people notice them in practice (for example, how many people were burned by introducing "lambda" as a new keyword? IIRC, none -- but that was an incompatible change!). Still, Python has more users all the time, and a mechanism to ease transitioning to even minor changes has value in proportion to the megalines of code out there. As to P3K, there's no funding for a rewrite from scratch. So, barring a miracle, Python evolves incrementally, and it wouldn't remain Python unless it does so in ways that keep the language clean. > Like many Python users, I have a huge base of installed code, lots of > it written by myself, but the majority written by others. Everything > works fine together, and I am happy and productive. And you've managed to do that despite a decade of incompatible language changes already. Why *assume* the future is going to be so much worse than the past? Perhaps because it hasn't happened yet ? > Now comes Python 2.1 with nested scopes. I don't expect much of my own > code to break, but I can't be sure, It won't break in 2.1, but you'll get warnings about fishy cases in 2.1, and the __future__ stmt will let you know for sure and change such code at your convenience. > I certainly didn't write it with a possible change of scoping rules in > mind. Note that most of the few cases of nested-scope breakage *known* so far actually had nothing to do with nested scopes at heart: they had to do with code violating the Lang Ref's prohibition against using "import *" at other than module scope. Such code was always undefined. Jeremy is bending backwards 167 degrees to make that code still work in the same way it worked by accident (and in violation of the language spec) whenever possible. > So perhaps I'll have to modify it a bit, that shouldn't be much work. The purpose of PEP 236 is to make that easier for you than it would have been otherwise. > But then there's all the code from others that might also break, and > that I don't want to fix at all. And since some of my code will depend > on code from others, I won't fix my own code either and stick to > Python 1.5 instead. Which in turn forces others who depend on my code > to do the same. Sure, sooner or later everybody will want to use the > new features of Python 2.1. But by then Python 2.1 will have been > replaced by 2.2, with its own set of incompatible changes. This would carry more weight if it described a new phenomenon -- but you got to 1.5.2 via a long series of incompatible-in-small-ways releases before 1.5.2. It's just business as usual. Perhaps you jumped on the train at 1.5.2? Many did, and they've enjoyed the illusion of 100% stability simply because no update (not even sorely needed bugfix patches) to 1.5.2 was released for about 18 months. But 1.5.2 was an historical anomaly, not the norm. Still, if you're happy with 1.5.2, stay with it! You won't be forced to upgrade. Perhaps if enough people get burned by "Guido intends to break two lines of code pointed out in a warning message!" <0.9 wink>, some entity will arise to keep 1.5.2 alive forever. > If, on the other hand, incompatible changes occur only every five > years or so, then people will be inclined to install two Python > distributions in parallel and update their code over a period of a few > months. PEP 236 aims to let them update their code, incrementally (one module at a time), over a period of about half a year, and without needing to install two Python distributions in parallel. We're trying to make staying current easier. > Moral: incompatible changes should happen on a time scale compatible > with uncoordinated collective code development, which is years, not > months. As the PEP said, it's aimed at people who intend to keep current. I believe it will be a real help for them. As the PEP also says, people who don't want to keep current have harder problems, which the PEP doesn't even pretend to address. BTW, the only way to avoid all incompatible changes is to avoid fixing bugs too: over the years, and regardless of language, I've had much more of my code break due to accidentally relying on buggy or undefined behavior than due to deliberate changes in correctly implemented defined behavior. the-only-reliable-stability-is-death-ly y'rs - tim From dsh8290 at rit.edu Wed Feb 28 02:02:50 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 27 Feb 2001 20:02:50 -0500 Subject: PEP 236: Back to the __future__ In-Reply-To: ; from hinsen@cnrs-orleans.fr on Tue, Feb 27, 2001 at 12:11:22PM +0100 References: Message-ID: <20010227200249.A21243@harmony.cs.rit.edu> On Tue, Feb 27, 2001 at 12:11:22PM +0100, Konrad Hinsen wrote: | | But then there's all the code from others that might also break, and | that I don't want to fix at all. And since some of my code will depend | on code from others, I won't fix my own code either and stick to | Python 1.5 instead. Which in turn forces others who depend on my code | to do the same. Sure, sooner or later everybody will want to use the | new features of Python 2.1. But by then Python 2.1 will have been | replaced by 2.2, with its own set of incompatible changes. This scenario reminds me of Java. I am working at a place that is using jdk1.1.8 for a rather new product (started ~2 years ago). We've even found a few bugs in that version of javac that won't compile some of our code. So why are we using 1.1.8? We use a 3rd party library whose vendor only supports 1.1.8, because they intend it to be used in applets and many browsers don't have a newer vm. (Using a different compiler, but outputing backwards compatible bytecodes allows us to work around the compiler bugs) (for those who don't know, jdk1.3.0 has been available for quite a while now) | | If, on the other hand, incompatible changes occur only every five | years or so, then people will be inclined to install two Python | distributions in parallel and update their code over a period of a few | months. | | Moral: incompatible changes should happen on a time scale compatible | with uncoordinated collective code development, which is years, not | months. I guess the key is how incompatible are the changes? If it is like Java, where the event model, GUI toolkit, and standard library had major incompatibilities, it is bad. If it is like Tim describes Python's past then it shouldn't be so painful. (I don't know from experience since I first learned of Python at version 1.5.2) However, I would like to see the use of particular future_statements deprecated or even disallowed after the feature becomes mandatory. Once the code has been changed to use the new feature, and the interpreter mandating that feature is commonly in use, the future_statement simply clutters the code with extra unnecessary baggage. Next thing we know, curly braces will be optional . As for the future statement being easy to find : grep -r "__future__" my_source_tree/* will do the job ;-). -D From tim.one at home.com Wed Feb 28 02:29:07 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 27 Feb 2001 20:29:07 -0500 Subject: PEP 236: Back to the __future__ In-Reply-To: <20010227200249.A21243@harmony.cs.rit.edu> Message-ID: [D-Man] > ... > However, I would like to see the use of particular future_statements > deprecated or even disallowed after the feature becomes mandatory. It's deliberately not done that way, so that if someone who moves their code around a lot happens to move to an earlier release, the (earlier) compiler will complain about a __future__ request it can't satsify. This is up to each programmer to deal with in whichever way best fits their usage. I expect many users will ignore future_statements entirely, and simply wait for the next release before fiddling their code. That's fine too. Note that there's more than enough info in __future__.py to allow writing a tool in Python that can reliably search for, identify, and even delete (if you like) obsolete future_statements wrt to any fixed Python release. That was also deliberate. > As for the future statement being easy to find : > grep -r "__future__" my_source_tree/* > will do the job ;-). The syntax restrictions listed in the PEP also ensure that a future_statement begins with "from" starting in the first column (they CANNOT be nested in if or try blocks, etc). everything-about-them-is-simple-except-the-implementation-ly y'rs - tim From tdickenson at devmail.geminidataloggers.co.uk Wed Feb 28 10:46:02 2001 From: tdickenson at devmail.geminidataloggers.co.uk (Toby Dickenson) Date: Wed, 28 Feb 2001 09:46:02 +0000 Subject: PEP 236: Back to the __future__ References: Message-ID: "Tim Peters" wrote: > MandatoryRelease may also be None, meaning that a planned feature got > dropped. Once feature X is dropped, then I assume "from __future__ import X" would give an ImportError (or something derived from ImportError) ? Toby Dickenson tdickenson at geminidataloggers.com From hinsen at cnrs-orleans.fr Wed Feb 28 12:39:12 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 28 Feb 2001 12:39:12 +0100 Subject: PEP 236: Back to the __future__ References: Message-ID: "Tim Peters" writes: > Incompatible changes have been made with virtually every Python release since > before 1.0. The changes are *usually* so minor and affect so little code > that few people notice them in practice (for example, how many people were Indeed. I have been using Python since 1.3 and never had to change a single line due to language changes, and only very few lines due to library changes (regular expressions). > And you've managed to do that despite a decade of incompatible language > changes already. Why *assume* the future is going to be so much worse than > the past? Perhaps because it hasn't happened yet ? I have the impression that Python development has been speeding up recently compared to the good old days. I used to install all alpha and beta releases, and now I didn't even find the time to install 2.0 between 1.5.2 and 2.1. (I admit there might be personal reasons as well, work is taking a lot of potential Python-playing time away from me.) > It won't break in 2.1, but you'll get warnings about fishy cases in 2.1, and > the __future__ stmt will let you know for sure and change such code at your > convenience. Perfectly fine unless 2.2 comes out four weeks after 2.1. ;-) living-in-ever-more-rapidly-changing-times'ly Konrad. -- ------------------------------------------------------------------------------- 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 max at alcyone.com Wed Feb 28 17:44:09 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 28 Feb 2001 08:44:09 -0800 Subject: PEP 236: Back to the __future__ References: Message-ID: <3A9D2AD9.78149FCC@alcyone.com> Konrad Hinsen wrote: > Indeed. I have been using Python since 1.3 and never had to change a > single line due to language changes, and only very few lines due to > library changes (regular expressions). The only changes I've had to make was what amounts to the bugfix with the socket address names (e.g., socket.connect((host, port)) instead of socket.connect(host, port)). And, of course, taking advantage of 2.0 features such as list comprehensions. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Men and women, women and men. It will never work. \__/ Erica Jong Official Buh rules / http://www.alcyone.com/max/projects/cards/buh/ The official rules to the betting card game, Buh. From tim.one at home.com Wed Feb 28 18:21:04 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 28 Feb 2001 12:21:04 -0500 Subject: PEP 236: Back to the __future__ In-Reply-To: <3A9D2AD9.78149FCC@alcyone.com> Message-ID: [Konrad Hinsen] > Indeed. I have been using Python since 1.3 and never had to change a > single line due to language changes, and only very few lines due to > library changes (regular expressions). Then you're not aggressive enough in visiting Python's dark corners . [Erik Max Francis] > The only changes I've had to make was what amounts to the bugfix with > the socket address names (e.g., socket.connect((host, port)) instead of > socket.connect(host, port)). This is one I'm sure we would have used __future__ for, if __future__ had existed. Guido made a convincing case (to me, anyway) that it was a bug in the interpreter that it allowed the latter form, and the docs didn't flatly contradict him . But the docs weren't clear enough, and some instances of the broken form were in the standard distribution. That made it painful to say "oops! we're taking it away now": despite that taking it away was the right thing to do, we knew for certain it would break existing code (under CPython; IIRC, JPython wasn't deluded on this point). In a __futurized__ world, you would have gotten a release in which both forms worked, with warning messages about the broken form. Hmm. Bad example -- this one really has nothing to do with __future__ after all. It has to do with that there *is* a mechanism for producing warnings now (we couldn't warn before just because there was no machinery *to* produce warnings!). > And, of course, taking advantage of 2.0 features such as list > comprehensions. __future__ wouldn't get involved in those either, because those new features were wholly backward compatible. __future__ is only for the rare changes that may break some existing code (changes to the scope rules in the presence of nested functions is the only example we have for 2.1; and that in *some* of those cases, we're going to start enforcing the Ref Man's long-standing restrictions on the use of "import *"). not-that-people-shouldn't-panic-anyway-ly y'rs - tim From glen.mettler at home.com Tue Feb 27 03:42:12 2001 From: glen.mettler at home.com (glen mettler) Date: Tue, 27 Feb 2001 02:42:12 GMT Subject: list to string Message-ID: <1103_983241679@cc462845-a> These commands will turn a string into a list: myword="dog" mywordlist=list(myword) result = ["d","o","g"] is there a command/function that can take the list ["d","o","g"] and make it a string "dog"? Glen From jgraves3 at austin.rr.com Tue Feb 27 03:50:38 2001 From: jgraves3 at austin.rr.com (jay graves) Date: Tue, 27 Feb 2001 02:50:38 GMT Subject: list to string References: <1103_983241679@cc462845-a> Message-ID: <3a9b14c9.33237453@news-server.austin.rr.com> On Tue, 27 Feb 2001 02:42:12 GMT, glen mettler wrote: >These commands will turn a string into a list: >myword="dog" >mywordlist=list(myword) >result = ["d","o","g"] > >is there a command/function that can take the list ["d","o","g"] and make it a string "dog"? One way is to join them. ''.join(result) Some people don't like using the string methods in this way and they might write: (at least until the string module goes away.) import string string.join(result,'') Hope this helps. ... jay From erno-news at erno.iki.fi Tue Feb 27 04:25:25 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 27 Feb 2001 05:25:25 +0200 Subject: list to string References: <1103_983241679@cc462845-a> <3a9b14c9.33237453@news-server.austin.rr.com> Message-ID: In article <3a9b14c9.33237453 at news-server.austin.rr.com>, jgraves3 at austin.rr.com (jay graves) writes: | Some people don't like using the string methods in this way and they | might write: (at least until the string module goes away.) | import string | string.join(result,'') the string module isn't going away, it has lots of stuff that is not available as methods of strings. -- erno From ben.hutchings at roundpoint.com Tue Feb 27 23:31:50 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 27 Feb 2001 14:31:50 -0800 Subject: list to string References: <1103_983241679@cc462845-a> <3a9b14c9.33237453@news-server.austin.rr.com> Message-ID: jgraves3 at austin.rr.com (jay graves) writes: > On Tue, 27 Feb 2001 02:42:12 GMT, glen mettler > wrote: > > >These commands will turn a string into a list: > >myword="dog" > >mywordlist=list(myword) > >result = ["d","o","g"] > > > >is there a command/function that can take the list ["d","o","g"] and > >make it a string "dog"? > > One way is to join them. > > ''.join(result) > > Some people don't like using the string methods in this way I'm happy with string methods in general, but I find the semantics of the above (sending a message to a string to tell it to join a sequence of strings together with copies of itself) ridiculous. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From jeremy at alum.mit.edu Tue Feb 27 03:58:58 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Mon, 26 Feb 2001 21:58:58 -0500 (EST) Subject: list to string In-Reply-To: <1103_983241679@cc462845-a> References: <1103_983241679@cc462845-a> Message-ID: <15003.6130.947922.804395@w221.z064000254.bwi-md.dsl.cnc.net> >>>>> "gm" == glen mettler writes: gm> These commands will turn a string into a list: gm> myword="dog" gm> mywordlist=list(myword) gm> result = ["d","o","g"] gm> is there a command/function that can take the list ["d","o","g"] gm> and make it a string "dog"? string = "".join(result) That is, call the join method of the empty string, passing it result as an argument. or >>> "!".join(result) 'd!o!g' Jeremy From tdelaney at avaya.com Tue Feb 27 04:52:34 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Tue, 27 Feb 2001 14:52:34 +1100 Subject: list to string Message-ID: Indeed. Personally, I think the join() string method is *really* bad. A method should act on the object it is a part of. In this case, there is no conceptual way that ''.join(['a', 'b', 'c']) could be considered to be acting on '' - it is *using* ''. However, join() should also not be a method of sequences in general IMO (although there is more reason to). Instead, there should *only* be string.join() - it is an external function which acts on one thing with the help of another. Actually, there should really be sequence.join(), and string.join() should be deprecated ... The object being acted upon should *always* be listed first, whether it be as the target for a bound method, or as the first parameter of a function. ''.join() is a glaring, non-obvious inconsistency that I will not use. OTOH, ''.length() is perfectly fine. It is obvious. Tim Delaney Avaya Australia +61 2 9352 9079 > -----Original Message----- > From: Erno Kuusela [mailto:erno-news at erno.iki.fi] > Sent: Tuesday, 27 February 2001 2:25 PM > To: python-list at python.org > Subject: Re: list to string > > > In article <3a9b14c9.33237453 at news-server.austin.rr.com>, > jgraves3 at austin.rr.com (jay graves) writes: > > | Some people don't like using the string methods in this way and they > | might write: (at least until the string module goes away.) > > | import string > | string.join(result,'') > > the string module isn't going away, it has lots of stuff that > is not available as methods of strings. > > -- erno > -- > http://mail.python.org/mailman/listinfo/python-list > From aleaxit at yahoo.com Tue Feb 27 08:12:26 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 27 Feb 2001 08:12:26 +0100 Subject: list to string References: Message-ID: <97fjv1028qd@news2.newsguy.com> "Delaney, Timothy" wrote in message news:mailman.983245987.15676.python-list at python.org... > Indeed. > > Personally, I think the join() string method is *really* bad. A method > should act on the object it is a part of. In this case, there is no > conceptual way that ''.join(['a', 'b', 'c']) could be considered to be > acting on '' - it is *using* ''. And, similarly, it's *using* ['a','b','c'] -- not "acting on" it. It's not a mutator. Not all methods of an object mutate it, and you clearly accept that, as you write: > OTOH, ''.length() is perfectly fine. It is obvious. Since join may use the joiner in a completely polymorphic way, but only uses the sequence through a sequence-iteration protocol, it's pragmatically _useful_ to have it be a method of the joiner object (as Python doesn't do multimethod-like dispatching). Usefulness seems to be a good indicator: if something offends your personal sense of purity, but is pragmatically good, then 'practicality beats purity' and it might be wise to reconsider your aesthetics:-). Alex From wayne.izatt at _nospam_myself.com Tue Feb 27 08:16:22 2001 From: wayne.izatt at _nospam_myself.com (Wayne Izatt) Date: Tue, 27 Feb 2001 07:16:22 GMT Subject: list to string References: <1103_983241679@cc462845-a> Message-ID: "glen mettler" wrote in message news:1103_983241679 at cc462845-a... > These commands will turn a string into a list: > myword="dog" > mywordlist=list(myword) > result = ["d","o","g"] > > is there a command/function that can take the list ["d","o","g"] and make it a string "dog"? >>> lst =["d", "o", "g"] >>> lst ['d', 'o', 'g'] >>> dog = lst[0]+lst[1]+lst[2] >>> dog 'dog' or is there something I'm not getting? cheers > > Glen > > > From sheila at spamcop.net Tue Feb 27 08:22:03 2001 From: sheila at spamcop.net (Sheila King) Date: Tue, 27 Feb 2001 07:22:03 GMT Subject: list to string References: <1103_983241679@cc462845-a> Message-ID: On Tue, 27 Feb 2001 07:16:22 GMT, "Wayne Izatt" wrote in comp.lang.python in article : :"glen mettler" wrote in message :news:1103_983241679 at cc462845-a... :> These commands will turn a string into a list: :> myword="dog" :> mywordlist=list(myword) :> result = ["d","o","g"] :> :> is there a command/function that can take the list ["d","o","g"] and make :it a string "dog"? : :>>> lst =["d", "o", "g"] :>>> lst :['d', 'o', 'g'] :>>> dog = lst[0]+lst[1]+lst[2] :>>> dog :'dog' : :or is there something I'm not getting? Your method would be awfully tedious for very long strings. You want something that will be easy to implement, regardless of the length of the string. Fortunately, several others in this thread have already suggested using the join command from the string methods. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From danielk at aracnet.com Tue Feb 27 15:54:52 2001 From: danielk at aracnet.com (Daniel Klein) Date: Tue, 27 Feb 2001 06:54:52 -0800 Subject: list to string References: <1103_983241679@cc462845-a> Message-ID: On Tue, 27 Feb 2001 07:22:03 GMT, Sheila King wrote: >:>>> lst =["d", "o", "g"] >:>>> lst >:['d', 'o', 'g'] >:>>> dog = lst[0]+lst[1]+lst[2] >:>>> dog >:'dog' >: >:or is there something I'm not getting? > >Your method would be awfully tedious for very long strings. You want something >that will be easy to implement, regardless of the length of the string. >Fortunately, several others in this thread have already suggested using the >join command from the string methods. I just _know_ I'm going to get winged for this one but why not mylist = ['d','o','g'] mystring = '' for element in mylist: mystring = mystring + element It's simple and intuitive. I know that it has to build a _new_ string each time but for shorter strings... Dan From glennj at pcard31e.ca.nortel.com Tue Feb 27 16:16:40 2001 From: glennj at pcard31e.ca.nortel.com (Glenn W Jackman) Date: 27 Feb 2001 15:16:40 GMT Subject: list to string References: <1103_983241679@cc462845-a> Message-ID: <97ggco$c55$1@bcarh8ab.ca.nortel.com> Daniel Klein wrote: >On Tue, 27 Feb 2001 07:22:03 GMT, Sheila King wrote: >>:>>> lst =["d", "o", "g"] >>:>>> dog = lst[0]+lst[1]+lst[2] >> >>Your method would be awfully tedious for very long strings. You want something >>that will be easy to implement, regardless of the length of the string. >>Fortunately, several others in this thread have already suggested using the >>join command from the string methods. > >mylist = ['d','o','g'] >mystring = '' >for element in mylist: > mystring = mystring + element >It's simple and intuitive. I know that it has to build a _new_ string each time >but for shorter strings... Having just read "Learning Python", I offer: >>> import operator >>> s = '''Python 1.5.2 (#1, Feb 1 2000, 16:32:16) [GCC egcs-2.91.66 19990314/Linux (egcs- on linux-i386 ... Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam''' >>> l = list(s) >>> s2 = reduce(operator.add, l) >>> s == s2 1 >>> s is s2 0 -- Glenn From gem at hsv.crc.com Tue Feb 27 23:54:15 2001 From: gem at hsv.crc.com (Glen Mettler) Date: Tue, 27 Feb 2001 16:54:15 -0600 Subject: list to string References: <1103_983241679@cc462845-a> Message-ID: <97haor$flu$1@hobbes2.crc.com> I couldn't get "for element in mylist" to work but this does: mylist = ['d','o','g'] mystring = '' for j in range(len(mylist)): mystring= mystring+"".join(mylist[j]) print mystring I am very, very new to Python so this may not be very elegant but it does work Glen (I asked the original question) Thanks for all help! "Daniel Klein" wrote in message news:qlfn9tkckq9g29brr0jiq2638mblclo9jn at 4ax.com... > On Tue, 27 Feb 2001 07:22:03 GMT, Sheila King wrote: > > >:>>> lst =["d", "o", "g"] > >:>>> lst > >:['d', 'o', 'g'] > >:>>> dog = lst[0]+lst[1]+lst[2] > >:>>> dog > >:'dog' > >: > >:or is there something I'm not getting? > > > >Your method would be awfully tedious for very long strings. You want something > >that will be easy to implement, regardless of the length of the string. > >Fortunately, several others in this thread have already suggested using the > >join command from the string methods. > > I just _know_ I'm going to get winged for this one but why not > > mylist = ['d','o','g'] > mystring = '' > for element in mylist: > mystring = mystring + element > > It's simple and intuitive. I know that it has to build a _new_ string each time > but for shorter strings... > > Dan > From BrianQ at ActiveState.com Wed Feb 28 01:14:33 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Tue, 27 Feb 2001 16:14:33 -0800 Subject: list to string In-Reply-To: <97haor$flu$1@hobbes2.crc.com> Message-ID: <002901c0a11b$6dc638b0$b503a8c0@activestate.ca> Nice work. That is a pretty complex construction for someone new. But there are other ways to get this to work that are a bit cleaner: import string mylist = ['d','o','g'] mystring = string.join( mylist, '' ) print mystring OR (and I hate this style): mylist = ['d','o','g'] mystring = ''.join( mylist ) print mystring OR (if you want to do the loop yourself): mylist = ['d','o','g'] mystring = '' for j in mylist: mystring = mystring + j print mystring -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Glen Mettler Sent: Tuesday, February 27, 2001 2:54 PM To: python-list at python.org Subject: Re: list to string I couldn't get "for element in mylist" to work but this does: mylist = ['d','o','g'] mystring = '' for j in range(len(mylist)): mystring= mystring+"".join(mylist[j]) print mystring I am very, very new to Python so this may not be very elegant but it does work Glen (I asked the original question) Thanks for all help! From gReGlAnDrUm at earthlink.net Wed Feb 28 02:50:54 2001 From: gReGlAnDrUm at earthlink.net (Greg Landrum) Date: Tue, 27 Feb 2001 17:50:54 -0800 Subject: list to string References: <1103_983241679@cc462845-a> <97haor$flu$1@hobbes2.crc.com> Message-ID: <97hlc2$9c6$1@slb6.atl.mindspring.net> "Glen Mettler" wrote in message news:97haor$flu$1 at hobbes2.crc.com... > I couldn't get "for element in mylist" to work but this does: > > mylist = ['d','o','g'] > mystring = '' > for j in range(len(mylist)): > mystring= mystring+"".join(mylist[j]) > print mystring > This is a lot more work than you need to be doing. If you just want to convert the array into a string the simplest way possible: mylist = ['d','o','g'] mystring = ''.join(mylist) print mystring Though this may be somewhat ugly (depending upon who you ask), it is very simple. You can also loop over the list. Here are a couple of ways: One way to loop over all the elements in the list (like you are doing) is: mylist = ['d','o','g'] mystring = '' for j in range(len(mylist)): mystring = mystring + mylist[j] Another way to loop over all the elements in the list is: mylist = ['d','o','g'] mystring = '' for item in mylist: mystring = mystring + item > I am very, very new to Python so this may not be very elegant but it does > work It's still a good idea to learn more efficient ways of doing things early in your learning experience. It'll help you avoid developing bad habits that you'll have to break later. If you would like to see what I mean by efficiency, try running a list 10000 elements long through your code and seeing how long it takes in comparison to the ''.join() solution. (hint, you can generate a list which is 10000 elements long like this: mylist = ['d']*10000) I hope this helps, -greg From gem at hsv.crc.com Wed Feb 28 00:00:15 2001 From: gem at hsv.crc.com (Glen Mettler) Date: Tue, 27 Feb 2001 17:00:15 -0600 Subject: list to string References: <1103_983241679@cc462845-a> Message-ID: <97hb44$fn7$1@hobbes2.crc.com> My appologies > mylist = ['d','o','g'] > mystring = '' > for element in mylist: > mystring = mystring + element does work. I failed to take out one of the >. Glen "Daniel Klein" wrote in message news:qlfn9tkckq9g29brr0jiq2638mblclo9jn at 4ax.com... > On Tue, 27 Feb 2001 07:22:03 GMT, Sheila King wrote: > > >:>>> lst =["d", "o", "g"] > >:>>> lst > >:['d', 'o', 'g'] > >:>>> dog = lst[0]+lst[1]+lst[2] > >:>>> dog > >:'dog' > >: > >:or is there something I'm not getting? > > > >Your method would be awfully tedious for very long strings. You want something > >that will be easy to implement, regardless of the length of the string. > >Fortunately, several others in this thread have already suggested using the > >join command from the string methods. > > I just _know_ I'm going to get winged for this one but why not > > mylist = ['d','o','g'] > mystring = '' > for element in mylist: > mystring = mystring + element > > It's simple and intuitive. I know that it has to build a _new_ string each time > but for shorter strings... > > Dan > From tdelaney at avaya.com Tue Feb 27 23:58:24 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 28 Feb 2001 09:58:24 +1100 Subject: list to string Message-ID: > And, similarly, it's *using* ['a','b','c'] -- not "acting on" > it. It's not > a mutator. Not all methods of an object mutate it, and you clearly > accept that, as you write: > > > OTOH, ''.length() is perfectly fine. It is obvious. > > Since join may use the joiner in a completely polymorphic way, but > only uses the sequence through a sequence-iteration protocol, it's > pragmatically _useful_ to have it be a method of the joiner object > (as Python doesn't do multimethod-like dispatching). Usefulness > seems to be a good indicator: if something offends your personal > sense of purity, but is pragmatically good, then 'practicality beats > purity' and it might be wise to reconsider your aesthetics:-). In this case, I think aesthetics and pragmatism are on the same side for me. The chosen string method for join() is completely non-obvious to me. At no time did I mean to suggest that the sequence being "acted on" was mutated. What I meant was the the result of evaluating the expression was a modification of the sequence i.e. "take the sequence, modify it by concatenating each element with this string between each element". It is obvious that the sequence is the object being "acted on". Whilst you could turn it around, it becomes convoluted and messy. "Take this string, stick it between each element of this sequence and then concatenate each element of the sequence into a string". You are still really acting on the sequence, not the string. Tim Delaney Avaya Australia From tdelaney at avaya.com Wed Feb 28 01:42:36 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 28 Feb 2001 11:42:36 +1100 Subject: list to string Message-ID: > import string > > mylist = ['d','o','g'] > mystring = string.join( mylist, '' ) > print mystring > > OR (and I hate this style): > > mylist = ['d','o','g'] > mystring = ''.join( mylist ) > print mystring > > OR (if you want to do the loop yourself): > > mylist = ['d','o','g'] > mystring = '' > for j in mylist: > mystring = mystring + j > print mystring I have no idea why anyone would suggest doing the loop yourself. The first one is good, the second is functionally just as good (although horrible). However, the third method has a number of really horrible drawbacks. We assume that the join() method is optimised. It will probably be written in C (for CPython), and designed to use as little time and space as possible. OTOH, doing the loop oneself means that you create a new string *every* time you go through the loop. As the string gets larger, more and more space needs to be allocated, and more data needs to be copied *every* time through the loop. There is a standard idiom in python for joining the (string) elements of a sequence into a string - string.join(). This is most likely to be the fastest, most efficient and most understandable way to do it. The important thing is to know the core libraries supplied with python very well, and to always try to find pre-done things in the optional libraries before writing it yourself. Code re-use is good. ''.join() is evil ;) *Never* have a loop like (for example): text = '' for line in f.xreadlines() text += line instead do text = [] for line in f.xreadlines() text.append(line) text = string.join(text, '\n') It will be much faster and use much less memory. Of course, for this particular case, there is a much better method ... text = string.join(f.readlines(), '\n') or even text = f.read() # may have slightly different semantics to the above depending on platform, file and open mode but I will ignore those as I was trying to demonstrate a different idiom :) Tim Delaney Avaya Australia From BrianQ at ActiveState.com Wed Feb 28 02:14:49 2001 From: BrianQ at ActiveState.com (Brian Quinlan) Date: Tue, 27 Feb 2001 17:14:49 -0800 Subject: list to string In-Reply-To: Message-ID: <002a01c0a123$d9581690$b503a8c0@activestate.ca> Calm down Tim, my last example was not meant as a HOWTO for joining strings, it was demonstrate how Glen's loop could be simplified by: 1) Iterating accross the list elements directly instead of my index 2) Avoiding the unnecessary use of join (since, in his example, his is joining a string of length 1 on each iteration). -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Delaney, Timothy Sent: Tuesday, February 27, 2001 4:43 PM To: python-list at python.org Subject: RE: list to string > import string > > mylist = ['d','o','g'] > mystring = string.join( mylist, '' ) > print mystring > > OR (and I hate this style): > > mylist = ['d','o','g'] > mystring = ''.join( mylist ) > print mystring > > OR (if you want to do the loop yourself): > > mylist = ['d','o','g'] > mystring = '' > for j in mylist: > mystring = mystring + j > print mystring I have no idea why anyone would suggest doing the loop yourself. The first one is good, the second is functionally just as good (although horrible). However, the third method has a number of really horrible drawbacks. We assume that the join() method is optimised. It will probably be written in C (for CPython), and designed to use as little time and space as possible. OTOH, doing the loop oneself means that you create a new string *every* time you go through the loop. As the string gets larger, more and more space needs to be allocated, and more data needs to be copied *every* time through the loop. There is a standard idiom in python for joining the (string) elements of a sequence into a string - string.join(). This is most likely to be the fastest, most efficient and most understandable way to do it. The important thing is to know the core libraries supplied with python very well, and to always try to find pre-done things in the optional libraries before writing it yourself. Code re-use is good. ''.join() is evil ;) *Never* have a loop like (for example): text = '' for line in f.xreadlines() text += line instead do text = [] for line in f.xreadlines() text.append(line) text = string.join(text, '\n') It will be much faster and use much less memory. Of course, for this particular case, there is a much better method ... text = string.join(f.readlines(), '\n') or even text = f.read() # may have slightly different semantics to the above depending on platform, file and open mode but I will ignore those as I was trying to demonstrate a different idiom :) Tim Delaney Avaya Australia -- http://mail.python.org/mailman/listinfo/python-list From tdelaney at avaya.com Wed Feb 28 02:37:46 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 28 Feb 2001 12:37:46 +1100 Subject: list to string Message-ID: > Calm down Tim, my last example was not meant as a HOWTO for > joining strings, > it was demonstrate how Glen's loop could be simplified by: > > 1) Iterating accross the list elements directly instead of my index > 2) Avoiding the unnecessary use of join (since, in his example, his is > joining a string of length 1 on each iteration). Not a problem, but it should have been stated as such. Otherwise people like Glen, who appears to be new to Python, will likely assume that it is the "correct" way to do it. In fact, Glen's own posts give the impression that he now believes that looping over the sequence himself is the "correct" way. Whilst it will work, it is definitely sub-optimal. In any case, I dispute your point 2. He is not joining strings of length one on each loop - he is appending a string of length one to a string of ever-increasing length. This is one of the the *worst* cases possible, and he should definitely be using join() for this. Tim Delaney Avaya Australia From ben.hutchings at roundpoint.com Wed Feb 28 02:47:33 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 27 Feb 2001 17:47:33 -0800 Subject: list to string References: Message-ID: "Delaney, Timothy" writes: > It will be much faster and use much less memory. Of course, for this > particular case, there is a much better method ... > > text = string.join(f.readlines(), '\n') > > or even > > text = f.read() # may have slightly different semantics to the above > depending on platform, file and open mode f.readlines() leaves the line terminator at the end of each of its lines, so the first expression will double the line terminators (except at the end of the last line). -- Any opinions expressed are my own and not necessarily those of Roundpoint. From db3l at fitlinxx.com Wed Feb 28 03:00:16 2001 From: db3l at fitlinxx.com (David Bolen) Date: 27 Feb 2001 21:00:16 -0500 Subject: list to string References: Message-ID: "Delaney, Timothy" writes: > *Never* have a loop like (for example): > > text = '' > > for line in f.xreadlines() > text += line > > instead do > > text = [] > > for line in f.xreadlines() > text.append(line) > > text = string.join(text, '\n') > > It will be much faster and use much less memory. (...) True it will likely be faster, but I'm not sure I agree on the memory point. It's interesting that you use xreadlines to avoid reading the whole file into memory, but then you go and stick it into a list that has to be kept in memory until it can be joined, at which point you use twice as much memory to build up the final string. Why not just say: text = f.readlines() text = string.join(text) (or as you point out later, "text = f.read()" :-)) it would do the same thing, use the same memory space, and probably run even faster since it can suck the whole file in as quickly as possible. The former case thrashes memory more (although Python probably reuses the same space a lot), but probably uses somewhat less memory, since in the end, the final copy builds the full image from the file contents minus the final line. Also, the file is in memory as a single string, and not a list with the per-line string object overhead and list reference. If you've got lots of lines in the file, that per-object overhead could add up to quite a bit. Which all sort of goes to say that I wouldn't use the term "*Never*" as you do in the first case. It's possible that when first developing the algorithm, that the first case makes sense and is the clearest implementation. I think that reading that code makes it very clear what is happening without having to look ahead some lines (e.g., the reader doesn't have to ask why the lines are being stored in a list). Of course, once you start unit testing and fleshing out the algorithm you may find this code to be a bottleneck and choose to optimize it in various ways, but that needn't be the first inclination, nor perhaps even done at all if the files involved or the overall process makes this a non-performance critical piece of code. Performance concerns are reasonable in any piece of code - I just wouldn't go so far as to declare one algorithm (that aside from implementation performance issues is perfectly clear) never worth doing. -- -- 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 tdelaney at avaya.com Wed Feb 28 03:00:56 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 28 Feb 2001 13:00:56 +1100 Subject: list to string Message-ID: > > text = string.join(f.readlines(), '\n') > f.readlines() leaves the line terminator at the end of each of its > lines, so the first expression will double the line terminators > (except at the end of the last line). I'm willing to believe it - I don't use readlines(), so I was going off the documentation. readlines ([sizehint]) Read until EOF using readline() and return a list containing the lines thus read. If the optional sizehint argument is present, instead of reading up to EOF, whole lines totalling approximately sizehint bytes (possibly after rounding up to an internal buffer size) are read. Doesn't mention whether the end-of-line characters are left or not. So, that should be ... text = string.join(f.readlines(), '') Tim Delaney Avaya Australia From tdelaney at avaya.com Wed Feb 28 03:35:57 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 28 Feb 2001 13:35:57 +1100 Subject: list to string Message-ID: > > text = '' > > > > for line in f.xreadlines() > > text += line > True it will likely be faster, but I'm not sure I agree on the memory > point. It's interesting that you use xreadlines to avoid reading the > whole file into memory, but then you go and stick it into a list that > has to be kept in memory until it can be joined, at which point you > use twice as much memory to build up the final string. Why not just > say: > > text = f.readlines() > text = string.join(text) > > (or as you point out later, "text = f.read()" :-)) Because the whole point was to concentrate on the time and memory used by the string concatentations. We were discussing the string concatenations vs string.join(). I used "reading a file line by line) as an example (as I stated) simply because it is a very common idiom which demonstrates the exact semantics were were discussing. > it would do the same thing, use the same memory space, and probably > run even faster since it can suck the whole file in as quickly as > possible. I agree 100%. Which is why I said that these were *better* for the specific case of my example, but they don't apply to the discussion in question. > The former case thrashes memory more (although Python probably reuses > the same space a lot), but probably uses somewhat less memory, since > in the end, the final copy builds the full image from the file > contents minus the final line. Also, the file is in memory as a > single string, and not a list with the per-line string object overhead > and list reference. If you've got lots of lines in the file, that > per-object overhead could add up to quite a bit. This is perfectly valid. Perhaps the best way in this *particular* case (without using read()) would be text = string.join(f.xreadlines(), '') However, once again this is not the discussion in question. Glen was asking about concatenating the (string) elements of a list which he had in memory. I was extending this to larger sequences, and the simplest way of getting a large sequence is by grabbing the lines from a file. > Which all sort of goes to say that I wouldn't use the term "*Never*" > as you do in the first case. It's possible that when first developing > the algorithm, that the first case makes sense and is the clearest > implementation. I think that reading that code makes it very clear > what is happening without having to look ahead some lines (e.g., the > reader doesn't have to ask why the lines are being stored in a list). Okay - perhaps I should have qualified "never" ;) *Never* use that algorithm in final code in Python. Once you know the core Python libraries, never use it at all as your first thought when confronted with this situation should be to use the Python idiom of string.join(). Better? > Of course, once you start unit testing and fleshing out the algorithm > you may find this code to be a bottleneck and choose to optimize it in > various ways, but that needn't be the first inclination, nor perhaps > even done at all if the files involved or the overall process makes > this a non-performance critical piece of code. And once it becomes second nature to use string.join() you can eliminate needing to consider optimising this part of the code (unless it is such a bottleneck that you think you can make it faster by rewriting it as a C extension, but that's another story entirely competely unrelated to the original discussion). > Performance concerns are reasonable in any piece of code - I just > wouldn't go so far as to declare one algorithm (that aside from > implementation performance issues is perfectly clear) never worth > doing. Personally, I find the string.join() idiom much clearer and more readable than a loop concatenating the elements of a string. Of course, all this becomes moot as soon as you have a sequence which contains elements other than strings ;) Tim Delaney Avaya Australia From fredrik at pythonware.com Wed Feb 28 05:56:57 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 28 Feb 2001 04:56:57 GMT Subject: list to string References: Message-ID: Timothy wrote: > I'm willing to believe it - I don't use readlines(), so I was going off the > documentation. > > readlines ([sizehint]) > > Read until EOF using readline() and return a list containing the lines thus > read. If the optional sizehint argument is present, instead of reading up > to EOF, whole lines totalling approximately sizehint bytes (possibly after > rounding up to an internal buffer size) are read. > > Doesn't mention whether the end-of-line characters are left or not. it says it's using readline, and readline is documented as follows: readline ([size]) Read one entire line from the file. A trailing newline character is kept in the string (but may be absent when a file ends with an incomplete line) Cheers /F From flognat at flognat.myip.org Wed Feb 28 22:13:09 2001 From: flognat at flognat.myip.org (Andrew Markebo) Date: Wed, 28 Feb 2001 21:13:09 GMT Subject: list to string References: Message-ID: FYI: The listing you see, is what the server sends to you, ftplib haven't touched it. /Andy / "Andrea Ciuffoli" wrote: | [....] | The last 3 files were created in 2001. | I was wondering is it is possible to have either Time and Year. | Are there some example on how the "Ftplib" commands work? | | Thanks in advance and my best regards, | Andrea. From max at alcyone.com Tue Feb 27 04:36:42 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 26 Feb 2001 19:36:42 -0800 Subject: PIL and PPM Message-ID: <3A9B20CA.F8B921D2@alcyone.com> Does PIL support the text-based PPMs? It supports the binary formats fine, but for a seemingly-valid text formatted PPM it choked with an invalid format IOError. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Will I disappoint my future / If I stay \__/ Sade Kepler's laws / http://www.alcyone.com/max/physics/kepler/ A proof of Kepler's laws. From gary at esands.com Tue Feb 27 05:19:06 2001 From: gary at esands.com (Gary Quinn) Date: Tue, 27 Feb 2001 15:19:06 +1100 Subject: Determining disk space Message-ID: <3A9B2ABA.AFFC65EC@esands.com> Hello I'm writing a routine to clean up a hard disk which has large numbers of satellite data files written onto it (approx 80MBytes/hr). We must remove oldest files when the disk is 80% full. What is the best way using Python to determine the number of bytes remaining on a disk? What's the best way under NT? under Unix? Thanks From erno-news at erno.iki.fi Tue Feb 27 05:31:51 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 27 Feb 2001 06:31:51 +0200 Subject: Determining disk space References: <3A9B2ABA.AFFC65EC@esands.com> Message-ID: In article <3A9B2ABA.AFFC65EC at esands.com>, Gary Quinn writes: | What is the best way using Python to determine the number of bytes | remaining on a disk? works for me under linux: >>> import os, statvfs >>> x = os.statvfs('/tmp') >>> print 'space in kB:', x[statvfs.F_BAVAIL] * x[statvfs.F_BSIZE] >> 10 space in kB: 789764 -- erno From f8dy at yahoo.com Tue Feb 27 15:51:31 2001 From: f8dy at yahoo.com (Mark Pilgrim) Date: Tue, 27 Feb 2001 09:51:31 -0500 Subject: Determining disk space References: <3A9B2ABA.AFFC65EC@esands.com> Message-ID: <97geqg$p5i8o$1@ID-77331.news.dfncis.de> "Gary Quinn" wrote in message news:3A9B2ABA.AFFC65EC at esands.com... > Hello > I'm writing a routine to clean up a hard disk which has large numbers of > satellite data files written onto it (approx 80MBytes/hr). We must > remove oldest files when the disk is 80% full. > What is the best way using Python to determine the number of bytes > remaining on a disk? > What's the best way under NT? under Unix? # Windows-specific import win32file (sectorsPerCluster, bytesPerSector, freeClusters, totalClusters) = \ win32file.GetDiskFreeSpace("c:\\") # or any other drive letter percentageFull = int(long(freeClusters)*100/long(totalClusters)) bytesOfFreeSpace = sectorsPerCluster*bytesPerSector*long(freeClusters) # etc. The int/long calls are to avoid an OverflowError if your disk is too large for integer math. -M You're smart; why haven't you learned Python yet? http://diveintopython.org/ From clee at gnwy100.wuh.wustl.edu Tue Feb 27 05:26:22 2001 From: clee at gnwy100.wuh.wustl.edu (Christopher Lee) Date: 26 Feb 2001 22:26:22 -0600 Subject: info version of python 2.x documentation? Message-ID: <7ulmqsoioh.fsf@gnwy100.wuh.wustl.edu> As the final step in upgrading to python 2.0, I've been trying to build the info versions of the manuals...and failing spectacularly. I've tried upgrading to the latest latex2html, HTML::Element, etc., but I'm giving up for now. Does some generous soul have them available somewhere? Many thanks, -chris From edcjones at erols.com Tue Feb 27 06:30:37 2001 From: edcjones at erols.com (Edward C. Jones) Date: Tue, 27 Feb 2001 00:30:37 -0500 Subject: How to exit Python nicely after error in embedded C code? Message-ID: <3A9B3B7D.66E31386@erols.com> Suppose I have a C function that is called only by other C functions (so it doesn't return a PyObject *). If I find an error condition in the the C function, is there function I can call that will exit the C code back into Python so Python can clean up and exit. The function is called by many different C function in case of error. int error_callback(int status, char * funcname) { if (status != 0) { printf("Error occured in %s\n", funcname); /* Is this part of what I want: */ PyErr_SetString(PyExc_Exception, "Error in C function"); /* ... what goes here ... */ } return 0; } I am using Python and C on a Linux system. Thanks, Ed Jones From aleaxit at yahoo.com Tue Feb 27 08:03:27 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 27 Feb 2001 08:03:27 +0100 Subject: How to exit Python nicely after error in embedded C code? References: <3A9B3B7D.66E31386@erols.com> Message-ID: <97fjl9028ir@news2.newsguy.com> "Edward C. Jones" wrote in message news:3A9B3B7D.66E31386 at erols.com... > Suppose I have a C function that is called only by other C functions (so it > doesn't return a PyObject *). If I find an error condition in the the C > function, is there function I can call that will exit the C code back into > Python so Python can clean up and exit. The function is called by many different > C function in case of error. > > int error_callback(int status, char * funcname) { > if (status != 0) { > printf("Error occured in %s\n", funcname); > /* Is this part of what I want: */ > PyErr_SetString(PyExc_Exception, "Error in C function"); > /* ... what goes here ... */ > } > return 0; > } In C, you can portably achieve this effect only by having this function return or set an error indicator and having every caller test it (there is a mechanism called setjmp/longjmp, but it may not work as desired everywhere). In C++, it's easy, of course -- that's what exceptions are for. Alex From lluang at northwestern.edu Tue Feb 27 15:43:52 2001 From: lluang at northwestern.edu (Louis Luangkesorn) Date: Tue, 27 Feb 2001 08:43:52 -0600 Subject: How to exit Python nicely after error in embedded C code? References: <3A9B3B7D.66E31386@erols.com> <97fjl9028ir@news2.newsguy.com> Message-ID: <3A9BBD28.8F537F75@northwestern.edu> (I'm asking this out of complete ignorance, obviously) In this situation (error occurs in a C function that is called by other C functions which are called by Python), would having the original C call from Python in a try...except block catch the exception? (I'm just learning how to do this, in both C++ and Python, but I have not done this in real life yet. It seems like a nice, cheap way of using exceptions in C, just call everything from Python :-) Louis Alex Martelli wrote: > "Edward C. Jones" wrote in message > news:3A9B3B7D.66E31386 at erols.com... > > Suppose I have a C function that is called only by other C functions (so > it > > doesn't return a PyObject *). If I find an error condition in the the C > > function, is there function I can call that will exit the C code back into > > Python so Python can clean up and exit. The function is called by many > different > > C function in case of error. > > > > > In C, you can portably achieve this effect only by having this > function return or set an error indicator and having every > caller test it (there is a mechanism called setjmp/longjmp, > but it may not work as desired everywhere). In C++, it's > easy, of course -- that's what exceptions are for. > > Alex -- 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 aleaxit at yahoo.com Tue Feb 27 17:17:46 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 27 Feb 2001 17:17:46 +0100 Subject: How to exit Python nicely after error in embedded C code? References: <3A9B3B7D.66E31386@erols.com> <97fjl9028ir@news2.newsguy.com> <3A9BBD28.8F537F75@northwestern.edu> Message-ID: <97gjv80147@news1.newsguy.com> "Louis Luangkesorn" wrote in message news:3A9BBD28.8F537F75 at northwestern.edu... [talking about "exceptions" from C vs C++] > (I'm asking this out of complete ignorance, obviously) > In this situation (error occurs in a C function that is called by other C > functions which are called by Python), would having the original C call from > Python in a try...except block catch the exception? (I'm just learning how to > do this, in both C++ and Python, but I have not done this in real life yet. It > seems like a nice, cheap way of using exceptions in C, just call everything from > Python :-) The C language does not define nor use exceptions. The Python C API, therefore, does not use them either. Python is entirely coded in C, to the C89 standard of ANSI and later ISO, not in C++. _Python_ exceptions are not the same thing as _C++_ exceptions. A "Python Exception" is "raised" by a C-coded function, in an extension, that is called by Python, by returning 0 (aka NULL) as its PyObject* (and some previous Python C API calls to give the exceptions' details). There are several frameworks that make it easier to extend Python by harnessing (some of) the extra power of C++ wrt C: CXX, SCXX, the Boost Python Library (BPL, part of the free Boost collection, see www.boost.org), and others yet. Some of them do make use of the power of C++ exceptions, somewhat in the way you suggest, and, also, may bridge/translate between C++ exceptions and Python ones. But there is no clean, portable way to "raise an exception" if you choose to use C, rather than C++, to code your Python extensions, and you find yourself in a C function called by a C function [repeat down a few nesting levels...] called by Python. Either switch to C++ (and some appropriate C++/Python framework such as the BPL), or live with patiently returning an error indication from the deeply nested function, and checking-and-propagating-upwards in each caller. That is, of course, IF you care about portability; if you don't, you may experiment to see what your platform[s] of interest will allow in a setjmp/longjmp pair, which is the closest thing that C offers to "exceptions" (just take a *LOT* of care about memory leaks &c, as you get absolutely no protection, no equivalent of C++'s automatic execution of destructors as the stack is unwound due to exceptions). Alex From robin.thomas at starmedia.net Tue Feb 27 18:56:12 2001 From: robin.thomas at starmedia.net (Robin Thomas) Date: Tue, 27 Feb 2001 12:56:12 -0500 Subject: How to exit Python nicely after error in embedded C code? In-Reply-To: <3A9B3B7D.66E31386@erols.com> Message-ID: <4.3.1.2.20010227124027.00cffb10@exchange.starmedia.net> At 12:30 AM 2/27/01 -0500, Edward C. Jones wrote: >Suppose I have a C function that is called only by other C functions (so it >doesn't return a PyObject *). If I find an error condition in the the C >function, is there function I can call that will exit the C code back into >Python so Python can clean up and exit. The function is called by many >different >C function in case of error. Your "wrapper" C function -- the one that returns a PyObject* -- is of course responsible for doing all this work. In most all cases, Python expects your wrapper function to return a non-NULL PyObject* if no error occurred. If an error occurred, Python expects your wrapper function to set the exception state and return NULL. So: PyObject * mywrapperfunc (void) { int result; result = my_pure_c_function(); if ( result == -1 ) { PyErr_SetString(PyExc_RuntimeError, "error in C func"); return NULL; } /* on success, your wrapper function must return *some* valid PyObject; in this example, there is no "return value" from the pure C function, so you want to return None */ /* new reference to None required */ Py_INCREF(PyNone); return PyNone; } >int error_callback(int status, char * funcname) { > if (status != 0) { > printf("Error occured in %s\n", funcname); > /* Is this part of what I want: */ > PyErr_SetString(PyExc_Exception, "Error in C function"); > /* ... what goes here ... */ > } > return 0; >} Very close, but instead of having a general function *decide* whether to set the Python exception state, use a general function only to set the exception state because you're *certain* that an exception must be set. And of course the general function must return the same type that your wrapper functions return -- PyObject*. This approach occurs in Python's own source code. An example from Objects/abstract.c: static PyObject * type_error(const char *msg) { PyErr_SetString(PyExc_TypeError, msg); return NULL; } and it's only used when a "wrapper" function wants to do an error. The wrapper function must do the work if there is no error. To merge the two examples: static PyObject * myerror(const char *msg) { PyErr_SetString(PyExc_RuntimeError, msg); return NULL; } PyObject * mywrapperfunc (void) { int result; result = my_pure_c_function(); if ( result == -1 ) { /* use the new general error function */ return myerror("my_pure_c_function bailed"); } /* on success, your wrapper function must return *some* valid PyObject; in this example, there is no "return value" from the pure C function, so you want to return None */ /* new reference to None required */ Py_INCREF(PyNone); return PyNone; } Hope this helps. -- Robin Thomas Engineering StarMedia Network, Inc. robin.thomas at starmedia.net From dwndgg at opti.cgi.net Tue Feb 27 07:23:04 2001 From: dwndgg at opti.cgi.net (Dan) Date: Tue, 27 Feb 2001 06:23:04 GMT Subject: Breaking out of nested loop Message-ID: <3a9b44f1.226505016@news.okc1.ok.home.com> How might one go about breaking out of a multi level loop? For instance, the following code will go into an endless loop. while(1): while(1): break Is there a statement that one can use to break out of multiple levels of loop control? I really hate to start littering my code with flag variables and if statements. -Dan From erno-news at erno.iki.fi Tue Feb 27 08:00:36 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 27 Feb 2001 09:00:36 +0200 Subject: Breaking out of nested loop References: <3a9b44f1.226505016@news.okc1.ok.home.com> Message-ID: In article <3a9b44f1.226505016 at news.okc1.ok.home.com>, dwndgg at opti.cgi.net (Dan) writes: | How might one go about breaking out of a multi level loop? this was recently discussed on this newsgroup. see (i hope those google urls are persistent like the deja ones used to be...) -- erno From fredrik at pythonware.com Tue Feb 27 08:01:34 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 27 Feb 2001 07:01:34 GMT Subject: Breaking out of nested loop References: <3a9b44f1.226505016@news.okc1.ok.home.com> Message-ID: "Dan" wrote: > How might one go about breaking out of a multi level loop? > > For instance, the following code will go into an endless loop. > > while(1): > while(1): > break refactor: return, raise. (see http://www.refactoring.com/) Cheers /F From phlip_cpp at my-deja.com Tue Feb 27 17:01:42 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 27 Feb 2001 16:01:42 GMT Subject: Breaking out of nested loop References: <3a9b44f1.226505016@news.okc1.ok.home.com> Message-ID: <97gj16$d5d@dispatch.concentric.net> Proclaimed Dan from the mountaintops: > > How might one go about breaking out of a multi level loop? > > For instance, the following code will go into an endless loop. > > while(1): > while(1): > break They covered this in a recent thread. Your best bet (just like in a language that has a 'goto') is 'return'. Otherwiset you can 'raise' (irritating style that reminds one of VB), or you can add a flag to the 'while' conditions and reset it at the 'break' point. Following these style rules... simplify 'if' and 'while' test conditions don't 'raise' except in an emergency shun long functions - don't go over 30 lines or 2 loop statements ...you'l see the best fit is 'return'. -- Phlip phlip_cpp at my-deja.com ============== http://phlip.webjump.com ============== -- Spaghetti Bad. Re-use Good. -- From jmarshal at mathworks.com Tue Feb 27 17:32:17 2001 From: jmarshal at mathworks.com (jcm) Date: 27 Feb 2001 16:32:17 GMT Subject: Breaking out of nested loop References: <3a9b44f1.226505016@news.okc1.ok.home.com> <97gj16$d5d@dispatch.concentric.net> Message-ID: <97gkqh$lsp$1@news.mathworks.com> Phlip wrote: > Proclaimed Dan from the mountaintops: >> >> How might one go about breaking out of a multi level loop? >> >> For instance, the following code will go into an endless loop. >> >> while(1): >> while(1): >> break ... > Your best bet (just like in a language that has a 'goto') is 'return'. > Otherwiset you can 'raise' (irritating style that reminds one of VB), or > you can add a flag to the 'while' conditions and reset it at the 'break' > point. Something I wouldn't mind seeing added to Python is a generalization of break/continue statement[s], allowing you to break out of multiple loops: break_or_continue_stmt: 'break' | 'continue' | 'break' break_or_continue_stmt So you can do something like: while a: # loop A ... while b: # loop B ... while c: # loop C ... break break # breaks loops C and B, bringing # you back to the body of loop A From othello at javanet.com Tue Feb 27 18:22:28 2001 From: othello at javanet.com (Raymond Hettinger) Date: Tue, 27 Feb 2001 12:22:28 -0500 Subject: Breaking out of nested loop References: <3a9b44f1.226505016@news.okc1.ok.home.com> <97gj16$d5d@dispatch.concentric.net> <97gkqh$lsp$1@news.mathworks.com> Message-ID: <3A9BE254.459265C4@javanet.com> jcm wrote: > Phlip wrote: > > Proclaimed Dan from the mountaintops: > > >> > >> How might one go about breaking out of a multi level loop? > >> > >> For instance, the following code will go into an endless loop. > >> > >> while(1): > >> while(1): > >> break > > ... > > > Your best bet (just like in a language that has a 'goto') is 'return'. > > > Otherwiset you can 'raise' (irritating style that reminds one of VB), or > > you can add a flag to the 'while' conditions and reset it at the 'break' > > point. > > Something I wouldn't mind seeing added to Python is a generalization > of break/continue statement[s], allowing you to break out of multiple > loops: > > break_or_continue_stmt: 'break' > | 'continue' > | 'break' break_or_continue_stmt > > So you can do something like: > > while a: # loop A > ... > while b: # loop B > ... > while c: # loop C > ... > break break # breaks loops C and B, bringing > # you back to the body of loop A Adding a feature like is begging for hard to find errors. A factored out function with a return almost always does the trick and does it clearly. And if not, then the needed functionality is provided by try, except, and raise. Raymond From glenfant at equod.com.nospam Tue Feb 27 18:07:47 2001 From: glenfant at equod.com.nospam (Gillou) Date: Tue, 27 Feb 2001 18:07:47 +0100 Subject: Breaking out of nested loop References: <3a9b44f1.226505016@news.okc1.ok.home.com> Message-ID: <97gmho$36q$1@reader1.imaginet.fr> Not very sexy but it should work... import exceptions class LoopBreaker(exceptions.Exception): def __init__(self): pass ... try: while 1: while 1: ... raise LoopBreaker ... except LoopBreaker: pass ... "Dan" a ?crit dans le message news: 3a9b44f1.226505016 at news.okc1.ok.home.com... > > How might one go about breaking out of a multi level loop? > > For instance, the following code will go into an endless loop. > > while(1): > while(1): > break > > > Is there a statement that one can use to break out of multiple levels > of loop control? I really hate to start littering my code with flag > variables and if statements. > > -Dan > From joconnor at cybermesa.com Tue Feb 27 18:20:22 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Tue, 27 Feb 2001 10:20:22 -0700 Subject: Breaking out of nested loop References: <3a9b44f1.226505016@news.okc1.ok.home.com> Message-ID: <3A9BE1D6.5D595D9A@cybermesa.com> Dan wrote: > How might one go about breaking out of a multi level loop? > > For instance, the following code will go into an endless loop. > > while(1): > while(1): > break > > Is there a statement that one can use to break out of multiple levels > of loop control? I really hate to start littering my code with flag > variables and if statements. Factor the inner loop into a seperate function that returns whether or not to keep looping and have that the test condition for the outer loop Example: >>> x = 10 >>> def secondLoop (): global x x = x -1 return x == 1 >>> while not secondLoop(): print x 9 8 7 6 5 4 3 2 >>> I find factor nested loops into seperate functions easier to read, as well, because it allows you to focus on different parts of the logic as you need to. I don't have to look at secondLoop()s logic if I just want to deal with the outer loop. Simularly, I don't have to be distracted by the outer loop if I have a bug in the code inside secondLoop() Take care, Jay From marc.vollmer at mahr.de Tue Feb 27 08:52:22 2001 From: marc.vollmer at mahr.de (Marc Vollmer) Date: Tue, 27 Feb 2001 08:52:22 +0100 Subject: Newbie: Problems with PythonWin and wxPython Message-ID: <97fmla$p8o62$1@ID-59219.news.dfncis.de> Hello, My system is: Windows 2000 PythonWin 2.0 (win32all build 135) wxPython I start the example >>wxpython\lib\wxPlotCanvas.py<< with F5. At the first and second time the program runs normally, but by the third start pythonwin cancel with memory (read) problems. How I can elimate this problem? Thanks Marc Vollmer From fredrik.thernelius at hotsip.com Tue Feb 27 11:28:25 2001 From: fredrik.thernelius at hotsip.com (newscache3.freenet.de) Date: Tue, 27 Feb 2001 11:28:25 +0100 Subject: Accessing java objects in python scripts? Message-ID: <3a9b8049$1@post.newsfeeds.com> *** post for free via your newsreader at post.newsfeeds.com *** I'm sorry if this subject has been discussed before. If it has then please give me a reference to that discussion. I'll now give a short description of my problem: In my java program I have instaciated a javaobject of a certain kind, lets call the class Testclass and new instanciated object testObject. I want to access this testObject from my jython interpreter. What is the best way to do this? By using the "try and fail" concept, I have found out that there are a couple of way to do this. In order to hava a "pretty" solution I want to have a python class that will be able to use methods from the testClass object. In fact, I can't even find this testObject in ANY namespace. Please find it for me! Notice that I've not bothered to add "import" statements and some other stuff in the code. Regards, Fredrik Thernelius Java program: ------------- python = new PythonInterpreter(); Testclass testObject = new TestClass(); //create a java object python.exec("e = Engine()"); //create a python object python.set("obj", testObject); //making the object accessable in python python.exec("e.runEngine()"); //python.set("r.obj", testObject); python.exec("print obj.toString()"); //Here I can access the testObject. python.exec("print globals()"); //<-----in this name space I can see my testObject Python script: -------------- class Engine: def __init__(self): try: self.compiler = Perl5Compiler() self.matcher = Perl5Matcher() #I can't find the testObject print "\nprinting local variables : ", locals().keys() print "\nprinting global variables: ", globals().keys() print "\nprinting __dict__ variables: ", self.__dict__.keys() print "\nprinting vars() variables: ", vars() print "\nprinting dir() variables: ", dir() except: print "Unexpected Error:", sys.exec_info() raise return def runEngine(self): try: print self.obj.toString() #<--- this does not work! #print obj.toString() <--- this does not work either! except: print "Runtime Error!" raise return **** Post for FREE via your newsreader at post.newsfeeds.com **** -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= *** Newsfeeds.com - The #1 Usenet Newsgroup Service on The Planet! *** -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= http://www.newsfeeds.com??? | http://www.newsfeeds.com | * Anonymous posting server! | * Totally Uncensored! * SUPER Servers! | * Over 80,000 Newsgroups! * BINARIES ONLY Servers! | * 16 seperate Newsgroup Servers! * SPAM FILTERED Server! | * Instant access! * ADULT ONLY Server! | * Multiple OC 3's and OC 12's! * MP3 ONLY Server! | * 99% Article Completion! * MULTIMEDIA ONLY Server! | * Months of Retention! * 7 UNCENSORED Newsgroup Servers | * Lightning FAST downloads! | http://www.newsfeeds.com | http://www.newsfeeds.com -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ? **** Point your newsreader to post.newsfeeds.com **** -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= From infotechsys at pivot.net Tue Feb 27 11:30:06 2001 From: infotechsys at pivot.net (Wayne) Date: Tue, 27 Feb 2001 05:30:06 -0500 Subject: running the Setup Message-ID: <3A9B81AD.79B9FB97@pivot.net> Hi, I'm trying to compile the interface PyGreSQL. I have no problem with the install instructions until I get to the "make". When I run "make" I get an error that indicates that readline has no rules. Would I mess thing up if I comment that out? The other Question I have is, shouldn't this error have come up when the person putting together this distribution built the Python package? Can someone recommend a good book for learning "Make"? Thanks Wayne P.S. I know I can get an RPM for this, but I what to learn this stuff. From Max.Haas at unibas.ch Tue Feb 27 11:38:52 2001 From: Max.Haas at unibas.ch (Max Haas) Date: Tue, 27 Feb 2001 11:38:52 +0100 Subject: Norvig on Python Message-ID: Hi, I just received through the MCL (Macintosh Common Lisp) mailing list the following message, sent by Rainer Joswig. Hope it's useful for this list too because Notvig mentions Active Python. Max ======================================================================== Date: Tue, 27 Feb 2001 02:34:12 +0100 From: Rainer Joswig Subject: Norvig: "Extreme Rapid Development" Hi, the March edition of the "Software Development" magazine has an article evaluating Active Python, Allegro CL, MCL and Functional Developer (Dylan). The article is written by Peter Norvig (http://www.norvig.com/). Peter is especially well known for his excellent book "Paradigms of Artificial Intelligence Programming, Case Studies in Common Lisp". A must have for every serious Lisp programmer. He is co-author of another classic: "Artificial Intelligence: A Modern Approach". The article is online at: http://www.sdmagazine.com/articles/2001/0103/0103e/0103e.htm From jafo at tummy.com Tue Feb 27 11:44:37 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Tue, 27 Feb 2001 03:44:37 -0700 Subject: CPAN: RFC on Schema (working-name: Swalow) Message-ID: <20010227034437.A14364@tummy.com> So we were joking around relating to the name "Python Spihon" (and how searching on the web turns up hits for an aquarium water changer), and suggested that we should use "gpw" (a random password generation tool) to generate a unique name for the CPAN-like project. It uses english letter combinations to generate random strings that sound like english words. So, Rob Riggs did just that and came up with "swalow": >Your suggestion set me out to playing with gpw, having it generate >6-byte names, and it spat out "swalow". > >Swallow -- close enough to siphon (in one of its meanings), and with >a memorable Monty Python reference: > >"What is the airspeed velocity of an unladen swallow?" >"What do you mean? An African or European swallow?" > >Of course this means we can have two versions of Swallow ;-) > >And it continues to feed on that snake image... what else does one >envision a python doing with its meal? > >And I really like the command-line implications ># swallow PIL I actually like the name "swalow" (with a single "l"), and searching for "python swalow" on Google turns up like 4 pages... So, that's the name I'm using for my part of the work -- the server that hands out information about packages. I started using the schema I posted last night, and through that ran into some changes that need to be made. I'm not happy with the dependencies table, but that'll come along shortly. At the moment, you can review the schema at: ftp://ftp.tummy.com/pub/tummy/swalow/swalow-1.00/schema I'd appreciate any feedback you might have. Also in there is a small sample data-set named "sample". You might get a better idea of how the schema is to be used from that. I've built a CGI and client program which use this schema to hand the information out over the net. Here's a sample session: guin:swalow$ ./swalow search ITEMNAME=pyntar ITEMTYPE=package ITEMNAME=pyntar PKGVERS=1.10 PKGFMT=tar PKGARCH=* PLATNAME=* PLATVERS=* ITEMTYPE=package ITEMNAME=pyntar PKGVERS=1.14 PKGFMT=tar PKGARCH=* PLATNAME=* PLATVERS=* guin:swalow$ ./swalow locate ITEMNAME=pyntar PKGVERS=1.14 URL=ftp://ftp.tummy.com//pub/tummy/pyntar/pyntar-1.14.tar.gz URL=ftp://dev.tummy.com/pub/mirrors/ftp.tummy.com/pub/tummy/pyntar/pyntar-1.14.tar.gz I decided to use HTTP as the transport mechanism because most firewalls let it through. Making a "native" TCP server to handle the requests will be trivial because of the netstring encoding, and will come much later. For now, the HTTP/CGI should work fine. Any suggestions for making the actual management interface? I figure it'll have to be CGI (though an e-mail for text-form setup might be interesting too). I'm not up on dealing with cookies and all though. I'll probably be asking for help as far as setting up the user accounts and editing of records... The database will allow multiple-maintainers for a package though. Well, that's where it sits tonight. Comments on it would be appreciated. Patches would be appreciated more. ;-) Sean -- If we could sell our experiences for what they cost us, we'd all be millionaires. -- Abigail Van Buren Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From aahz at panix.com Tue Feb 27 17:12:13 2001 From: aahz at panix.com (Aahz Maruch) Date: 27 Feb 2001 08:12:13 -0800 Subject: CPAN: RFC on Schema (working-name: Swalow) References: Message-ID: <97gjkt$ov0$1@panix6.panix.com> In article , Sean Reifschneider wrote: > >I started using the schema I posted last night, and through that ran into >some changes that need to be made. I'm not happy with the dependencies >table, but that'll come along shortly. At the moment, you can review >the schema at: > > ftp://ftp.tummy.com/pub/tummy/swalow/swalow-1.00/schema It's a decent start, but I have a lot of suggestions (in no particular order; I'm writing this as I go back-and-forth over the schema): There's currently little support for archival information; you're going to have to change a lot of the subsidiary tables to key on both packages.itemID and packages.version (which could be packages.id, I suppose; I flip-flop between pure normalization and useful denormalized forms). I think it might be a good idea to split items and packages into items, versions, and packages, allowing multiple packages per version. If you do create the versions table, it should have an URL field in addition to the one in items. If you create the versions table, my comment above applies to versions instead of packages. I think the dependencies table should have fields for minVersion and maxVersion, which apply to requiresItemID. This is probably going to require having a defined format for versions in order to parse them. It should be permitted to leave either or both of minVersion and maxVersion blank. I don't know what capabilities postGreSQL has, but if you can, I strongly recommend adding foreign key restrictions on the subsidiary tables (e.g. require that packages.itemID exist in items.id). Similarly, you should put a unique index on items.name to prevent inserting the same name twice (and in other equivalent spots, such as packages.itemID/packages.version). I think there should be an items.created datetime field, in case an item gets created before there's a package ready for it. I also think there should be a packages.lastUpdated, which would be used if there was a mistake in the packaging, but not the actual code that makes up the package. It's not really clear to me how you intend the relationship between items, users, and maintainers to work, so I'll reserve comments on that for now. It's not clear to me what packages.architecture is for. I have zero clue what ranking is for. One final comment: you should probably change "All Rights Reserved" to some kind of standard license -- GNU, BSD, whatever. -- --- 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 n8gray at caltech.edu.is.my.e-mail.address Wed Feb 28 21:46:53 2001 From: n8gray at caltech.edu.is.my.e-mail.address (Nathan Gray) Date: Wed, 28 Feb 2001 12:46:53 -0800 Subject: Swalow vs. Swallow References: Message-ID: <3A9D63BD.6050500@caltech.edu.is.my.e-mail.address> Sean Reifschneider wrote: > So we were joking around relating to the name "Python Spihon" (and how > searching on the web turns up hits for an aquarium water changer), and > suggested that we should use "gpw" (a random password generation tool) > to generate a unique name for the CPAN-like project. It uses english > letter combinations to generate random strings that sound like english > words. > > So, Rob Riggs did just that and came up with "swalow": > >> Your suggestion set me out to playing with gpw, having it generate >> 6-byte names, and it spat out "swalow". >> >> Swallow -- close enough to siphon (in one of its meanings), and with >> a memorable Monty Python reference: >> >> "What is the airspeed velocity of an unladen swallow?" >> "What do you mean? An African or European swallow?" >> >> Of course this means we can have two versions of Swallow ;-) >> >> And it continues to feed on that snake image... what else does one >> envision a python doing with its meal? >> >> And I really like the command-line implications >> # swallow PIL > > > I actually like the name "swalow" (with a single "l"), and searching for > "python swalow" on Google turns up like 4 pages... So, that's the name > I'm using for my part of the work -- the server that hands out information > about packages. So shouldn't the server-side be "regurgitate"? +1 on swallow -- Monty Python reference good. Mixed Monty Python/snake reference too good to pass up! -1 on swalow -- looks like a script-kiddie mispeling, and I can't help but pronounce it "sway-low". How about pySwallow or py_swallow? I wouldn't worry too much about google searches. Once the sofware starts being used the site will percolate to the top. Try doing a search for "python" and see what site comes up first. ;-) My .02 on the only issue of _real_ importance in this whole CPyAN debate. The rest is just implementation details. ;-) -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From sk at gluit.de Tue Feb 27 12:37:00 2001 From: sk at gluit.de (sk at gluit.de) Date: Tue, 27 Feb 2001 12:37:00 +0100 Subject: Connecting GUI and database? Message-ID: <3A9B915C.4251FE3F@gluit.de> Hi there, I want to build a PyQt application which uses (mx)ODBC to present data from a SQL table in a QTable-like widget. Is there a tool to connect database and GUI such that changes on one side will automatically affect the other? I could make a concession that after changing data in the database the program could be triggered manually to update the widget. Similar tools using tkinter could also be helpful. Thank you. Stefan From tom at teikom.no Tue Feb 27 12:55:21 2001 From: tom at teikom.no (Tom Danielsen) Date: Tue, 27 Feb 2001 11:55:21 GMT Subject: win32com.client - parameter types Message-ID: I have a COM server with the following method: [id(0x60020016)] HRESULT getDict([out] IDispatch** pDictionary); which makepy made into: def getDict(self, pDictionary=defaultNamedNotOptArg): return self._ApplyTypes_(0x60020016, \ 1, (24, 0), ((16393, 2),), \ 'getDict', None,pDictionary) This is, the method returns its value in parameter 1. VB and VBscript handles this, but I cannot get Python (2.0) to work. Is there any way to get at this value in Python? Is there a way I can change the [out] to a [out, retval] and make Python return the value as the return value of the method call? If so, how? Tom From aleaxit at yahoo.com Tue Feb 27 14:23:13 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 27 Feb 2001 14:23:13 +0100 Subject: win32com.client - parameter types References: Message-ID: <97g9or029n3@news1.newsguy.com> "Tom Danielsen" wrote in message news:slrn99n5be.8f8.tom at tnt.teikom.no... > > > I have a COM server with the following method: > > [id(0x60020016)] > HRESULT getDict([out] IDispatch** pDictionary); > > which makepy made into: > > def getDict(self, pDictionary=defaultNamedNotOptArg): > return self._ApplyTypes_(0x60020016, \ > 1, (24, 0), ((16393, 2),), \ > 'getDict', None,pDictionary) Not to worry -- this may be slightly misleading, but it DOES in fact work just right. > This is, the method returns its value in parameter 1. That's what it does COMwise, but, for Python, this output parameter IS transformed into a return value! > VB and VBscript handles this, but I cannot get Python (2.0) to work. > > Is there any way to get at this value in Python? Is there a way I > can change the [out] to a [out, retval] and make Python return the > value as the return value of the method call? If so, how? Nothing more than the makepy you've already done. To try it out, I built a toy (ATL) project (inproc server, just one object, project name toyatl, object name Toy) with IDL: // toyatl.idl : IDL source for toyatl.dll // // This file will be processed by the MIDL tool to // produce the type library (toyatl.tlb) and marshalling code. import "oaidl.idl"; import "ocidl.idl"; [ object, uuid(565B5BFD-0CB2-11D5-9E52-0060B0EB1D67), dual, helpstring("IToy Interface"), pointer_default(unique) ] interface IToy : IDispatch { [id(1), helpstring("method getDict")] HRESULT getDict([out]IDispatch** pDictionary); }; [ uuid(565B5BF1-0CB2-11D5-9E52-0060B0EB1D67), version(1.0), helpstring("Toy ATL project TLB") ] library TOYATLLib { importlib("stdole32.tlb"); importlib("stdole2.tlb"); [ uuid(565B5BFE-0CB2-11D5-9E52-0060B0EB1D67), helpstring("Toy Class") ] coclass Toy { [default] interface IToy; }; }; and the 'obvious' implementation (FinalConstruct of the CToy class builds an instance member that's a CComPtr with a CoCreateInstance on ProgId "Scripting.Dictionary"; method getDisp just calls a CopyTo on that member). After a makepy...: D:\pybridge>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. >>> from win32com.client import Dispatch as disp >>> x=disp("toyatl.Toy") >>> a=x.getDict() >>> a >>> Alex From objectway at divalsim.it Tue Feb 27 12:57:45 2001 From: objectway at divalsim.it (Nicola Musatti) Date: Tue, 27 Feb 2001 12:57:45 +0100 Subject: Rule based programming in Python? Message-ID: <3A9B9639.3417D696@divalsim.it> Hi, is anybody aware of any library/framework for rule based programming in Python? Thank you, Nicola Musatti From sandipan at vsnl.com Tue Feb 27 14:21:10 2001 From: sandipan at vsnl.com (Sandipan Gangopadhyay) Date: Tue, 27 Feb 2001 18:51:10 +0530 Subject: Rule based programming in Python? References: <3A9B9639.3417D696@divalsim.it> Message-ID: <017d01c0a0c0$26ee72a0$020000c3@node02> I believe tuples in Python are the closest to PROLOG kind of rule constructs around. You could look at tuple operations to see whether the library you seek is available, or needs to be built. Regards, Sandipan ----- Original Message ----- From: "Nicola Musatti" Newsgroups: comp.lang.python To: Sent: Tuesday, February 27, 2001 5:27 PM Subject: Rule based programming in Python? > Hi, > is anybody aware of any library/framework for rule based programming in > Python? > > Thank you, > Nicola Musatti > -- > http://mail.python.org/mailman/listinfo/python-list > From hgg9140 at seanet.com Wed Feb 28 01:14:22 2001 From: hgg9140 at seanet.com (Harry George) Date: 27 Feb 2001 16:14:22 -0800 Subject: Rule based programming in Python? References: <3A9B9639.3417D696@divalsim.it> Message-ID: We do it the otehr way around: A C/C++ app with embedded prolog, and then python embedded in that. We are considering the reverse (python with prolog and C extensions). You might look at SWI as a candidate prolog for embedding. Nicola Musatti writes: > Hi, > is anybody aware of any library/framework for rule based programming in > Python? > > Thank you, > Nicola Musatti -- Harry George hgg9140 at seanet.com From gwilder at best.com Wed Feb 28 05:36:59 2001 From: gwilder at best.com (Glen Wilder) Date: Wed, 28 Feb 2001 04:36:59 GMT Subject: Rule based programming in Python? References: <3A9B9639.3417D696@divalsim.it> Message-ID: <3A9C8599.FD6C3375@best.com> I have already embedded SWI-Prolog in Python. It can be retrieved from CVS at http://sourceforge.net/projects/pyprolog. It is pre-alpha, but I know it works on FreeBSD. Harry George wrote: > > We do it the otehr way around: A C/C++ app with embedded prolog, and > then python embedded in that. We are considering the reverse (python > with prolog and C extensions). You might look at SWI as a candidate > prolog for embedding. > > Nicola Musatti writes: > > > Hi, > > is anybody aware of any library/framework for rule based programming in > > Python? > > > > Thank you, > > Nicola Musatti > > -- > Harry George > hgg9140 at seanet.com -- Glen Wilder From hgg9140 at cola.ca.boeing.com Wed Feb 28 15:17:49 2001 From: hgg9140 at cola.ca.boeing.com (Harry George) Date: Wed, 28 Feb 2001 14:17:49 GMT Subject: Rule based programming in Python? References: <3A9B9639.3417D696@divalsim.it> <3A9C8599.FD6C3375@best.com> Message-ID: Great! But the website says no code released yet. What's the status? Glen Wilder writes: > I have already embedded SWI-Prolog in Python. It can be retrieved from > CVS at http://sourceforge.net/projects/pyprolog. It is pre-alpha, but I > know it works on FreeBSD. > > Harry George wrote: > > > > We do it the otehr way around: A C/C++ app with embedded prolog, and > > then python embedded in that. We are considering the reverse (python > > with prolog and C extensions). You might look at SWI as a candidate > > prolog for embedding. > > > > Nicola Musatti writes: > > > > > Hi, > > > is anybody aware of any library/framework for rule based programming in > > > Python? > > > > > > Thank you, > > > Nicola Musatti > > > > -- > > Harry George > > hgg9140 at seanet.com > > -- Glen Wilder -- 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 gwilder at best.com Wed Feb 28 20:52:10 2001 From: gwilder at best.com (Glen Wilder) Date: Wed, 28 Feb 2001 19:52:10 GMT Subject: Rule based programming in Python? References: <3A9B9639.3417D696@divalsim.it> <3A9C8599.FD6C3375@best.com> Message-ID: <3A9D5C04.70C9D3DD@best.com> There are a few things that need to be done before I can make an alpha release: check for memory leaks, add threading release/lock code, and check for insecure code. It would also be nice to test it on systems other that FreeBSD 4.1. (A testsuite is included.) I am not working on any of this right now, but I will accept patches. Harry George wrote: > > Great! But the website says no code released yet. What's the status? > > Glen Wilder writes: > > > I have already embedded SWI-Prolog in Python. It can be retrieved from > > CVS at http://sourceforge.net/projects/pyprolog. It is pre-alpha, but I > > know it works on FreeBSD. > > > > Harry George wrote: > > > > > > We do it the otehr way around: A C/C++ app with embedded prolog, and > > > then python embedded in that. We are considering the reverse (python > > > with prolog and C extensions). You might look at SWI as a candidate > > > prolog for embedding. -- Glen Wilder From marc.vollmer at mahr.de Tue Feb 27 15:07:35 2001 From: marc.vollmer at mahr.de (Marc Vollmer) Date: Tue, 27 Feb 2001 15:07:35 +0100 Subject: Read INI-File Message-ID: <97gcng$oquj3$1@ID-59219.news.dfncis.de> Hello, I want to read information from an INI-File. But it gives me always the default value. Why? >>> import win32ui >>> win32ui.SetProfileFileName('test.ini') >>> k = win32ui.GetProfileVal('Move','MoveSpeed',0) >>> k 0 >>> test.ini --------------------------------------------------------- [MOVE] MoveSpeed=150 Thanks Marc Vollmer From fgeiger at datec.at Tue Feb 27 15:22:30 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Tue, 27 Feb 2001 15:22:30 +0100 Subject: Read INI-File References: <97gcng$oquj3$1@ID-59219.news.dfncis.de> Message-ID: <97gd97$931$1@rex.ip-plus.net> IIRC you have to set the full file path or at least "./filename.ext" if it is in the current dir. Check if "test.ini" is where you expect it to be after a write access. Regards Franz "Marc Vollmer" wrote in message news:97gcng$oquj3$1 at ID-59219.news.dfncis.de... > Hello, > > I want to read information from an INI-File. But it gives me always the > default value. Why? > > >>> import win32ui > >>> win32ui.SetProfileFileName('test.ini') > >>> k = win32ui.GetProfileVal('Move','MoveSpeed',0) > >>> k > 0 > >>> > > test.ini > --------------------------------------------------------- > [MOVE] > MoveSpeed=150 > > > Thanks > Marc Vollmer > > From marc.vollmer at mahr.de Tue Feb 27 16:18:58 2001 From: marc.vollmer at mahr.de (Marc Vollmer) Date: Tue, 27 Feb 2001 16:18:58 +0100 Subject: Read INI-File References: <97gcng$oquj3$1@ID-59219.news.dfncis.de> <97gd97$931$1@rex.ip-plus.net> Message-ID: <97ggqk$p53ii$1@ID-59219.news.dfncis.de> No chance: I try: win32ui.SetProfileFileName('c:\winnt\test.ini') and after copy in the application folder: win32ui.SetProfileFileName('./test.ini') Always it gives me the default value. Exist a functions to test, if Python find the ini file? Because when I print the return value from win32ui.SetProfileFileName, the result is NONE. Regards Marc "Franz GEIGER" schrieb im Newsbeitrag news:97gd97$931$1 at rex.ip-plus.net... > IIRC you have to set the full file path or at least "./filename.ext" if it > is in the current dir. Check if "test.ini" is where you expect it to be > after a write access. > > Regards > Franz > > > "Marc Vollmer" wrote in message > news:97gcng$oquj3$1 at ID-59219.news.dfncis.de... > > Hello, > > > > I want to read information from an INI-File. But it gives me always the > > default value. Why? > > > > >>> import win32ui > > >>> win32ui.SetProfileFileName('test.ini') > > >>> k = win32ui.GetProfileVal('Move','MoveSpeed',0) > > >>> k > > 0 > > >>> > > > > test.ini > > --------------------------------------------------------- > > [MOVE] > > MoveSpeed=150 > > > > > > Thanks > > Marc Vollmer > > > > > > From ws-news at gmx.at Tue Feb 27 16:43:51 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Tue, 27 Feb 2001 16:43:51 +0100 Subject: Read INI-File References: <97gcng$oquj3$1@ID-59219.news.dfncis.de> <97gd97$931$1@rex.ip-plus.net> <97ggqk$p53ii$1@ID-59219.news.dfncis.de> Message-ID: <983288899.644740@newsmaster-04.atnet.at> Marc Vollmer wrote in message news:97ggqk$p53ii$1 at ID-59219.news.dfncis.de... > No chance: > > I try: > > win32ui.SetProfileFileName('c:\winnt\test.ini') If you _really_ wrote it this way it will not work. The backslashes are used to escape the values. Use 'c:\\winnt\\test.ini' or r'c:\winnt\test.ini' hth werner From marc.vollmer at mahr.de Wed Feb 28 08:36:09 2001 From: marc.vollmer at mahr.de (Marc Vollmer) Date: Wed, 28 Feb 2001 08:36:09 +0100 Subject: Read INI-File References: <97gcng$oquj3$1@ID-59219.news.dfncis.de> <97gd97$931$1@rex.ip-plus.net> <97ggqk$p53ii$1@ID-59219.news.dfncis.de> <983288899.644740@newsmaster-04.atnet.at> Message-ID: <97ia2t$p9da2$1@ID-59219.news.dfncis.de> Thanks, but no solution, perhaps my computer don't understand me. So, I test it with the system.ini in the c:\winnt\. Please test it, too. Perhaps it is a windows 2k problem? I don't know, what I still could do. -- import win32ui win32ui.SetProfileFileName('C:\\WINNT\\system.ini') k=win32ui.GetProfileVal('drivers','timer','xxx') print k -- My result is: xxx and yours? Regards Marc "Werner Schiendl" schrieb im Newsbeitrag news:983288899.644740 at newsmaster-04.atnet.at... > > Marc Vollmer wrote in message > news:97ggqk$p53ii$1 at ID-59219.news.dfncis.de... > > No chance: > > > > I try: > > > > win32ui.SetProfileFileName('c:\winnt\test.ini') > > If you _really_ wrote it this way it will not work. > The backslashes are used to escape the values. > > Use 'c:\\winnt\\test.ini' > or r'c:\winnt\test.ini' > > hth > werner > > From schaffer at optonline.net Wed Feb 28 23:30:24 2001 From: schaffer at optonline.net (Les Schaffer) Date: Wed, 28 Feb 2001 22:30:24 GMT Subject: Read INI-File References: <97gcng$oquj3$1@ID-59219.news.dfncis.de> <97gd97$931$1@rex.ip-plus.net> <97ggqk$p53ii$1@ID-59219.news.dfncis.de> <983288899.644740@newsmaster-04.atnet.at> <97ia2t$p9da2$1@ID-59219.news.dfncis.de> Message-ID: On Wed, 28 Feb 2001 08:36:09 +0100, "Marc Vollmer" wrote: >Please test it, too. Perhaps it is a windows 2k problem? under win2k (python scriptname.py): timer.drv under pythonwin (executing script): xxx les schaffer From nobody at home.net Wed Feb 28 23:34:04 2001 From: nobody at home.net (Bernard Delmée) Date: Wed, 28 Feb 2001 23:34:04 +0100 Subject: Read INI-File References: <97gcng$oquj3$1@ID-59219.news.dfncis.de> <97gd97$931$1@rex.ip-plus.net> <97ggqk$p53ii$1@ID-59219.news.dfncis.de> <983288899.644740@newsmaster-04.atnet.at> <97ia2t$p9da2$1@ID-59219.news.dfncis.de> Message-ID: <97jub8$1th5$1@rivage.news.be.easynet.net> Your example works fine for me, on W2K, (prints 'timer.drv') ActivePython 2.0, build 202 I tried both SetProfileFileName('C:\\WINNT\\system.ini') and SetProfileFileName('C:/WINNT/system.ini') "Marc Vollmer" wrote in message news:97ia2t$p9da2$1 at ID-59219.news.dfncis.de... > Thanks, > > but no solution, perhaps my computer don't understand me. > > So, I test it with the system.ini in the c:\winnt\. > > Please test it, too. Perhaps it is a windows 2k problem? I don't know, what > I still could do. > > -- > import win32ui > win32ui.SetProfileFileName('C:\\WINNT\\system.ini') > k=win32ui.GetProfileVal('drivers','timer','xxx') > print k > -- > > My result is: xxx and yours? > > Regards > Marc > > > "Werner Schiendl" schrieb im Newsbeitrag > news:983288899.644740 at newsmaster-04.atnet.at... > > > > Marc Vollmer wrote in message > > news:97ggqk$p53ii$1 at ID-59219.news.dfncis.de... > > > No chance: > > > > > > I try: > > > > > > win32ui.SetProfileFileName('c:\winnt\test.ini') > > > > If you _really_ wrote it this way it will not work. > > The backslashes are used to escape the values. > > > > Use 'c:\\winnt\\test.ini' > > or r'c:\winnt\test.ini' > > > > hth > > werner > > > > > > From marc.vollmer at mahr.de Tue Feb 27 15:09:03 2001 From: marc.vollmer at mahr.de (Marc Vollmer) Date: Tue, 27 Feb 2001 15:09:03 +0100 Subject: Read INI-File? Message-ID: <97gcni$oquj3$2@ID-59219.news.dfncis.de> Hello, I want to read information from an INI-File. But it gives me always the default value. Why? >>> import win32ui >>> win32ui.SetProfileFileName('test.ini') >>> k = win32ui.GetProfileVal('Move','MoveSpeed',0) >>> k 0 >>> test.ini --------------------------------------------------------- [MOVE] MoveSpeed=150 Thanks Marc Vollmer From guido-dot-treutwein-at-nbg-dot-siemens-dot-de.cut-here at no.spam Tue Feb 27 16:07:07 2001 From: guido-dot-treutwein-at-nbg-dot-siemens-dot-de.cut-here at no.spam (guido-dot-treutwein-at-nbg-dot-siemens-dot-de.cut-here at no.spam) Date: Tue, 27 Feb 2001 16:07:07 +0100 Subject: Combined error message for user defined exceptions Message-ID: <3A9BC29B.BE9E0C96@no.spam> Hi there, I finally converted my exceptions from string-based to class-based, but I'm not yet happy with the information in the error traceback. What I did: class excMyError(TypeError): def __str__(self): return "My generic error" #... and later ... raise excMyError, "additional info" What I want is to merge the generic exception text with the additional information just like NameError: There is no variable named 'undefvar' where 'undefvar' corresponds to "additionalInfo" and the rest to the generic information. The obvious way (adding a parameter to __str__) failed, what to do else? Regards From stephen_purcell at yahoo.com Tue Feb 27 17:00:12 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 27 Feb 2001 17:00:12 +0100 Subject: Combined error message for user defined exceptions In-Reply-To: <3A9BC29B.BE9E0C96@no.spam>; from guido-dot-treutwein-at-nbg-dot-siemens-dot-de.cut-here@no.spam on Tue, Feb 27, 2001 at 04:07:07PM +0100 References: <3A9BC29B.BE9E0C96@no.spam> Message-ID: <20010227170012.A21016@freedom.puma-ag.com> guido-dot-treutwein-at-nbg-dot-siemens-dot-de.cut-here at no.spam wrote: > class excMyError(TypeError): > def __str__(self): > return "My generic error" > #... and later ... > raise excMyError, "additional info" > > What I want is to merge the generic exception text with the additional > information just like > > NameError: There is no variable named 'undefvar' There may be nicer ways to do it, but if you promise to always throw the exception with only one argument, you can do the following:- >>> class MyException(TypeError): ... def __str__(self): ... return "there is no variable named '%s'" % self.args[0] ... >>> raise MyException, 'foobar' Traceback (innermost last): File "", line 1, in ? __main__.MyException: there is no variable named 'foobar' >>> But even more simply, you can set the message exactly in the place where you throw the exception, which is often the most appropriate option: >>> class MyException(TypeError): pass ... >>> raise MyException, "no such variable 'foobar'" Traceback (innermost last): File "", line 1, in ? __main__.MyException: no such variable 'foobar' >>> Best wishes, -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 lbates at syscon-computers.com Tue Feb 27 16:12:18 2001 From: lbates at syscon-computers.com (Larry Bates) Date: Tue, 27 Feb 2001 09:12:18 -0600 Subject: Raw string question Message-ID: <3a9bc4f5$1@news1.dbtech.net> Why can't a raw string end with a backslash (\)? example a=r"c:\path\" doesn't work a=r"c:\path" works fine Thanks, Larry BTW - I'm using ActiveState PythonWin (if makes any difference). From emile at fenx.com Tue Feb 27 17:20:42 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 27 Feb 2001 08:20:42 -0800 Subject: Raw string question References: <3a9bc4f5$1@news1.dbtech.net> Message-ID: <97gk6m$p4tnj$1@ID-11957.news.dfncis.de> It can, you just need to escape it if it's the last character: a=r"c:\path\\" -- Emile van Sebille emile at fenx.com ------------------- "Larry Bates" wrote in message news:3a9bc4f5$1 at news1.dbtech.net... > Why can't a raw string end with a backslash (\)? > > example > > a=r"c:\path\" > > doesn't work > > a=r"c:\path" > > works fine > > Thanks, Larry > > > BTW - I'm using ActiveState PythonWin (if makes any difference). > > > > From robin.thomas at starmedia.net Tue Feb 27 17:50:50 2001 From: robin.thomas at starmedia.net (Robin Thomas) Date: Tue, 27 Feb 2001 11:50:50 -0500 Subject: Raw string question In-Reply-To: <3a9bc4f5$1@news1.dbtech.net> Message-ID: <4.3.1.2.20010227112407.00c70f00@exchange.starmedia.net> At 09:12 AM 2/27/01 -0600, Larry Bates wrote: >Why can't a raw string end with a backslash (\)? > >example > >a=r"c:\path\" Below from Python Language Reference 2.4.1. The text explains the behavior and also gives you good hints about how raw string literals are parsed in the current implementation. """ Unlike Standard C, all unrecognized escape sequences are left in the string unchanged, i.e., the backslash is left in the string. (This behavior is useful when debugging: if an escape sequence is mistyped, the resulting output is more easily recognized as broken.) When an `r' or `R' prefix is present, backslashes are still used to quote the following character, but all backslashes are left in the string. For example, the string literal r"\n" consists of two characters: a backslash and a lowercase `n'. String quotes can be escaped with a backslash, but the backslash remains in the string; for example, r"\"" is a valid string literal consisting of two characters: a backslash and a double quote; r"\" is not a value string literal (even a raw string cannot end in an odd number of backslashes). Specifically, a raw string cannot end in a single backslash (since the backslash would escape the following quote character). Note also that a single backslash followed by a newline is interpreted as those two characters as part of the string, not as a line continuation. """ -- Robin Thomas Engineering StarMedia Network, Inc. robin.thomas at starmedia.net From insanc at cc.gatech.edu Tue Feb 27 16:26:40 2001 From: insanc at cc.gatech.edu (Joseph Holland King) Date: 27 Feb 2001 15:26:40 GMT Subject: shadow.h Message-ID: <97ggvg$mqf$1@solaria.cc.gatech.edu> is there anyway to be able to use the functions from this header file? i tried the h2py and using that with the header but that did not seem to work. any other suggestions? -- --- 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 insanc at cc.gatech.edu Wed Feb 28 21:07:14 2001 From: insanc at cc.gatech.edu (Joseph Holland King) Date: 28 Feb 2001 20:07:14 GMT Subject: shadow.h References: <97ggvg$mqf$1@solaria.cc.gatech.edu> Message-ID: <97jlpi$6os$1@solaria.cc.gatech.edu> Joseph Holland King wrote: i have searched the python web site including the starship page and the vaults of parnassus page, to no avail. i have not been able to find a port or any other information that would help me to use the c function lckpwdf. i am really close to just writing it myself. does anyone know of anywhere else to look or any way that is easier to convert the c function to a python module? if not do you have any warnings or comments that i should heed before attempting to write (if you can't tell i am not all that enthusiastic about this idea.) thank you. -- --- 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 fluxent at yahoo.com Tue Feb 27 16:41:19 2001 From: fluxent at yahoo.com (fluxent at yahoo.com) Date: Tue, 27 Feb 2001 15:41:19 -0000 Subject: approach for assigning ODBC results to fieldnames as variables? Message-ID: <97ghqv+6tge@eGroups.com> When you execute a SQL (select) query via ODBC and do a fetchall(), you get back a result set as a tuple (array). You can also ask for the cursor's description, which returns a separate tuple, the first column of which contains the fieldnames (or other labels calculated by SQL). Getting back an unlabelled tuple means that when you want to write out a table of results (with some individual handling of various fields, not just dumbly iterating over the columns), you end up with an ugly line like: Response.Write('%s%s%s%s%s% s' % (row[0],row[1],row[2],row[1],row[3],row[3],row[4],row[5])) (this is a Python-via-IIS model, but would be similar under Apache, etc.). Is there a standard approach to assigning field names to columns, so that this output line could be changed to something like Response.Write('%s%s%s%s%s% s' % (maxDate, clientID, clientName, clientID, jobID, jobID, jobName, totalHours)) or even at least something like Response.Write('%s%s%s%s%s%s' % (maxDate[i], clientID[i], clientName[i], clientID[i], jobID[i], jobID[i], jobName [i], totalHours[i])) thx for your help... From robin.thomas at starmedia.net Tue Feb 27 19:54:30 2001 From: robin.thomas at starmedia.net (Robin Thomas) Date: Tue, 27 Feb 2001 13:54:30 -0500 Subject: approach for assigning ODBC results to fieldnames as variables? In-Reply-To: <97ghqv+6tge@eGroups.com> Message-ID: <4.3.1.2.20010227131547.00c46240@exchange.starmedia.net> At 03:41 PM 2/27/01 +0000, fluxent at yahoo.com wrote: >When you execute a SQL (select) query via ODBC and do a fetchall(), >you get back a result set as a tuple (array). You can also ask for >the cursor's description, which returns a separate tuple, the first >column of which contains the fieldnames (or other labels calculated >by SQL). A common approach is to encapsulate the cursor so that the description is fetched once, and rows are turned into dictionaries with the values in description tuple used as keys. >Is there a standard approach to assigning field names to columns, so >that this output line could be changed to something like > Response.Write('%s%s%shref="matterEdit.asp?clientID=%s&matterID=%s">%s%s% >s' % (maxDate, clientID, clientName, clientID, jobID, jobID, >jobName, totalHours)) Dynamic name binding can be very problematic. Dictionaries give you the desired behavior without the name-binding mess. Especially when you use named placeholders in string formatting. A shortened example: Response.Write('%(MAXDATE)s' % row_as_dictionary) Be careful of the case of the column names returned by description(). >or even at least something like > Response.Write('%s%s%s%s%s%s' % (maxDate[i], >clientID[i], clientName[i], clientID[i], jobID[i], jobID[i], jobName >[i], totalHours[i])) Slicing the row tuples into new column value sequences is, happily, no faster than making dictionaries using the description tuple. Test script is below. # script start def get_description(): return ('ONE', 'TWO', 'THREE', 'FOUR', 'FIVE') def get_row(): return (1,2,3,4,5) def rows_as_dicts(rows, description): if not rows: return [] length = len(rows[0]) r = range(length) l = [] for row in rows: d = {} for i in r: d[description[i]] = row[i] l.append(d) return l def rows_as_columns(rows, description): if not rows: return [] length = len(rows[0]) r = range(length) l = [] for i in r: l.append([]) for row in rows: for i in r: l[i].append(row[i]) return l def test(funcs, rows=20, reps=1000): desc = get_description() rowlist = [] for i in range(rows): rowlist.append(get_row()) from time import time for func in funcs: n = func.__name__ t = time() for i in range(reps): func(rowlist,desc) t = time() - t print "%s on %d rows: %s reps in %.04f s (%.05f s each)" % \ (n, rows, reps, t, t/reps) if __name__ == '__main__': for rowamt in (10,20,50,100): test( (rows_as_dicts, rows_as_columns), rowamt ) # output rows_as_dicts on 10 rows: 1000 reps in 0.4665 s (0.00047 s each) rows_as_columns on 10 rows: 1000 reps in 0.5636 s (0.00056 s each) rows_as_dicts on 20 rows: 1000 reps in 0.9083 s (0.00091 s each) rows_as_columns on 20 rows: 1000 reps in 1.0523 s (0.00105 s each) rows_as_dicts on 50 rows: 1000 reps in 2.5213 s (0.00252 s each) rows_as_columns on 50 rows: 1000 reps in 2.5186 s (0.00252 s each) rows_as_dicts on 100 rows: 1000 reps in 4.5625 s (0.00456 s each) rows_as_columns on 100 rows: 1000 reps in 5.0504 s (0.00505 s each) -- Robin Thomas Engineering StarMedia Network, Inc. robin.thomas at starmedia.net From lbates at syscon-computers.com Tue Feb 27 17:03:42 2001 From: lbates at syscon-computers.com (Larry Bates) Date: Tue, 27 Feb 2001 10:03:42 -0600 Subject: Determining disk space (problem on large disks) Message-ID: <3a9bd102@news1.dbtech.net> I tried your example and apparently win32file needs to be updated to use longints. On disk drives with more than 2Gb of space it doesn't work properly (or am I missing something)? -Larry From jeremy at alum.mit.edu Tue Feb 27 17:13:22 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Tue, 27 Feb 2001 11:13:22 -0500 (EST) Subject: Lightning Talks session at Python Conference Message-ID: <15003.53794.7734.331509@w221.z064000254.bwi-md.dsl.cnc.net> The Lightning Talks session provides an opportunity for conference attendees to present new or ongoing work and cool ideas. Each talk is five to seven minutes long -- time enough for a one good idea and a few questions. In past years, this session has always been fun. If you would like to give a lightning talk, please send email to lightning-talks at python9.org. Speaker slots are available on a first-come, first-served basis. Jeremy Hylton Lightning Talks session chair From dg at pearl.tao.co.uk Tue Feb 27 18:39:28 2001 From: dg at pearl.tao.co.uk (David Given) Date: Tue, 27 Feb 2001 17:39:28 +0000 Subject: Python 2 for Debian? Message-ID: Subject says it all, really. Does anyone know when Python 2 is coming out for Debian? All I can find on my local mirror is 1.5. -- +- David Given ---------------McQ-+ | Work: dg at tao-group.com | ACRONYM: A Contrived Reduction of | Play: dgiven at iname.com | Nomenclature Yielding Mnemonics +- http://wired.st-and.ac.uk/~dg -+ From cookedm+news at physics.mcmaster.ca Tue Feb 27 20:05:31 2001 From: cookedm+news at physics.mcmaster.ca (David M. Cooke) Date: 27 Feb 2001 14:05:31 -0500 Subject: Python 2 for Debian? References: Message-ID: At some point, dg at pearl.tao.co.uk (David Given) wrote: > Subject says it all, really. Does anyone know when Python 2 is coming out > for Debian? All I can find on my local mirror is 1.5. Install the python2-* packages from unstable (they haven't made it into testing yet, unfortunately). -- |>|\/|< /--------------------------------------------------------------------------\ |David M. Cooke |cookedm(at)physics(dot)mcmaster(dot)ca From dg at pearl.tao.co.uk Wed Feb 28 11:36:22 2001 From: dg at pearl.tao.co.uk (David Given) Date: Wed, 28 Feb 2001 10:36:22 +0000 Subject: Python 2 for Debian? References: Message-ID: <6bki79.asq.ln@127.0.0.1> In article , cookedm+news at physics.mcmaster.ca (David M. Cooke) writes: > At some point, dg at pearl.tao.co.uk (David Given) wrote: > >> Subject says it all, really. Does anyone know when Python 2 is coming out >> for Debian? All I can find on my local mirror is 1.5. > > Install the python2-* packages from unstable (they haven't made it > into testing yet, unfortunately). Ah, right. I'm doing this on my work machine, so they probably wouldn't thank me for putting unstable on it, so I'm sticking with testing. Looks like I'm going to have to wait. -- +- David Given ---------------McQ-+ | Work: dg at tao-group.com | ACRONYM: A Contrived Reduction of | Play: dgiven at iname.com | Nomenclature Yielding Mnemonics +- http://wired.st-and.ac.uk/~dg -+ From gregor at mediasupervision.de Wed Feb 28 16:21:53 2001 From: gregor at mediasupervision.de (Gregor Hoffleit) Date: Wed, 28 Feb 2001 16:21:53 +0100 Subject: Python 2 for Debian? In-Reply-To: <6bki79.asq.ln@127.0.0.1>; from dg@pearl.tao.co.uk on Wed, Feb 28, 2001 at 10:36:22AM +0000 References: <6bki79.asq.ln@127.0.0.1> Message-ID: <20010228162153.C1925@mediasupervision.de> On Wed, Feb 28, 2001 at 10:36:22AM +0000, David Given wrote: > In article , > cookedm+news at physics.mcmaster.ca (David M. Cooke) writes: > > At some point, dg at pearl.tao.co.uk (David Given) wrote: > > > >> Subject says it all, really. Does anyone know when Python 2 is coming out > >> for Debian? All I can find on my local mirror is 1.5. > > > > Install the python2-* packages from unstable (they haven't made it > > into testing yet, unfortunately). > > Ah, right. I'm doing this on my work machine, so they probably wouldn't > thank me for putting unstable on it, so I'm sticking with testing. Looks > like I'm going to have to wait. The python2-* packages are currently stuck in unstable, since they depend on tcl/tk8.3. tcl/tk8.3 in turn currently has a severe bug, which prevents it from being moved to testing. That's the crux with package pools ;-) You could either fetch the python2 source ('apt-get source python2' with unstable in sources.list) and recompile it, changing Modules/Setup.in accordingly to use tk8.0 or tk8.2, or you'll have to wait for the resolution of these problems... Gregor From shaleh at valinux.com Tue Feb 27 20:11:38 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Tue, 27 Feb 2001 11:11:38 -0800 (PST) Subject: Python 2 for Debian? In-Reply-To: Message-ID: On 27-Feb-2001 David Given wrote: > Subject says it all, really. Does anyone know when Python 2 is coming out > for Debian? All I can find on my local mirror is 1.5. > apt-get install python2-base. It lives in unstable and testing. Until the licensing gets straightened out, most python modules are not being recompiled under Debian for python2. So you can play with the language, but some of the useful things are missing. From garabik-news at spam.melkor.dnp.fmph.uniba.sk Tue Feb 27 21:58:22 2001 From: garabik-news at spam.melkor.dnp.fmph.uniba.sk (Radovan Garabik) Date: 27 Feb 2001 20:58:22 GMT Subject: Python 2 for Debian? References: Message-ID: <983307400.692337@cdwork.cvt.stuba.sk> David Given wrote: : Subject says it all, really. Does anyone know when Python 2 is coming out : for Debian? All I can find on my local mirror is 1.5. has been already there for some time time to change your mirror :-) -- ----------------------------------------------------------- | 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 avv at quasar.ipa.nw.ru Tue Feb 27 22:02:30 2001 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Tue, 27 Feb 2001 13:02:30 -0800 Subject: Python 2 for Debian? References: Message-ID: <3A9C15E6.F2099AD4@quasar.ipa.nw.ru> Hi Sean 'Shaleh' Perry wrote: > > On 27-Feb-2001 David Given wrote: > > Subject says it all, really. Does anyone know when Python 2 is coming out > > for Debian? All I can find on my local mirror is 1.5. > > > > apt-get install python2-base. It lives in unstable and testing. > > Until the licensing gets straightened out, most python modules are not being > recompiled under Debian for python2. So you can play with the language, but > some of the useful things are missing. Why not to put them into [non-free]? Who would mind? Alexander From kern at myrddin.caltech.edu Tue Feb 27 23:10:51 2001 From: kern at myrddin.caltech.edu (Robert Kern) Date: 27 Feb 2001 22:10:51 GMT Subject: Python 2 for Debian? References: <3A9C15E6.F2099AD4@quasar.ipa.nw.ru> Message-ID: <97h8lb$83s@gap.cco.caltech.edu> In article <3A9C15E6.F2099AD4 at quasar.ipa.nw.ru>, "Alexander V. Voinov" writes: > Hi > > Sean 'Shaleh' Perry wrote: >> >> On 27-Feb-2001 David Given wrote: >> > Subject says it all, really. Does anyone know when Python 2 is coming out >> > for Debian? All I can find on my local mirror is 1.5. >> > >> >> apt-get install python2-base. It lives in unstable and testing. >> >> Until the licensing gets straightened out, most python modules are not being >> recompiled under Debian for python2. So you can play with the language, but >> some of the useful things are missing. > > Why not to put them into [non-free]? Who would mind? IIRC, it's not that Python's license is restrictive; it passes the DFSG fine. It's the fact that it conflicts with the GPL according to RMS, so distributing the readline module binary, say, could be a GPL violation. No one wants to get Debian in legal trouble. > Alexander -- Robert Kern kern at caltech.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter From embed at geocities.com Wed Feb 28 02:01:45 2001 From: embed at geocities.com (Warren Postma) Date: Wed, 28 Feb 2001 01:01:45 GMT Subject: Python 2 for Debian? References: <3A9C15E6.F2099AD4@quasar.ipa.nw.ru> <97h8lb$83s@gap.cco.caltech.edu> Message-ID: > > IIRC, it's not that Python's license is restrictive; it passes the DFSG fine. > It's the fact that it conflicts with the GPL according to RMS, so distributing > the readline module binary, say, could be a GPL violation. No one wants to > get Debian in legal trouble. > This strikes me as so much pussyfooting around a non issue. Sheesh. Warren From thomas at xs4all.net Wed Feb 28 02:20:06 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 28 Feb 2001 02:20:06 +0100 Subject: Python 2 for Debian? In-Reply-To: ; from embed@geocities.com on Wed, Feb 28, 2001 at 01:01:45AM +0000 References: <3A9C15E6.F2099AD4@quasar.ipa.nw.ru> <97h8lb$83s@gap.cco.caltech.edu> Message-ID: <20010228022006.E9678@xs4all.nl> On Wed, Feb 28, 2001 at 01:01:45AM +0000, Warren Postma wrote: > > IIRC, it's not that Python's license is restrictive; it passes the DFSG > > fine. It's the fact that it conflicts with the GPL according to RMS, so > > distributing the readline module binary, say, could be a GPL violation. > > No one wants to get Debian in legal trouble. > This strikes me as so much pussyfooting around a non issue. Sheesh. But who's doing the pussyfooting ? RMS ? Debian ? CNRI ? Each one is doing what they think is best. Note that the licence talks are still ongoing, and a GPL-compatible 1.6.1 was released not a few days ago. Python 2.0 is derived from 1.6 though, not 1.6.1, and also contains some BeOpen (and for 2.1, possibly some DC) specific stuff, so it requires some extra attention. But there is still hope :) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From tim.one at home.com Wed Feb 28 02:43:23 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 27 Feb 2001 20:43:23 -0500 Subject: Python 2 for Debian? In-Reply-To: <20010228022006.E9678@xs4all.nl> Message-ID: [Thomas Wouters] > But who's doing the pussyfooting ? RMS ? Debian ? CNRI ? Each one is doing > what they think is best. Note that the licence talks are still ongoing, and > a GPL-compatible 1.6.1 was released not a few days ago. Careful, there. RMS has not said that 1.6.1 has a GPL-compatible license, so even that part remains unclear (to us too). > Python 2.0 is derived from 1.6 though, not 1.6.1, and also contains > some BeOpen Yup. > (and for 2.1, possibly some DC) Nope. DC is very generously assigning their Python IP rights to the Python Software Foundation, which doesn't yet exist . But until it does, they're assigning them to Guido directly. And despite nested scopes, I still trust Guido. > specific stuff, so it requires some extra attention. > But there is still hope :) Yes, there is. Possibly even in our lifetimes. although-a-lifetime-remains-too-much-to-bet-on-it-ly y'rs - tim From embed at geocities.com Wed Feb 28 15:37:32 2001 From: embed at geocities.com (Warren Postma) Date: Wed, 28 Feb 2001 09:37:32 -0500 Subject: Python 2 for Debian? References: <3A9C15E6.F2099AD4@quasar.ipa.nw.ru> <97h8lb$83s@gap.cco.caltech.edu> Message-ID: Quoth Thomas: > But who's doing the pussyfooting ? RMS ? Debian ? CNRI ? Each one is doing > what they think is best. Note that the licence talks are still ongoing, and > a GPL-compatible 1.6.1 was released not a few days ago. Python 2.0 is > derived from 1.6 though, not 1.6.1, and also contains some BeOpen (and for > 2.1, possibly some DC) specific stuff, so it requires some extra attention. > But there is still hope :) All this "license compatibility" BS boils down to this: Until someone sues somebody, this is all theoretical. Thus, I stand by what I said earlier; it's all just so much pussyfooting around, about nothing. Where is the legal precedent? Until then, it's all speculation. If I break the GPL what happens? NOTHING. Somebody sue me for a GPL violation, PLEASE. License writers are writing Pseudo Code for a problem domain in which the compiler is not yet written. Are there any syntax errors in the GPL? Sorry, we just don't know. So why be picky about pseudo-code? Wisely, the larger Python user community, and the larger Free Software movement, ignores RMS, and everybody else, who opines endlessly on License Compatibility Issues. Licensing? Bah! Warren From scarblac at pino.selwerd.nl Wed Feb 28 14:46:07 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 28 Feb 2001 13:46:07 GMT Subject: Python 2 for Debian? References: <3A9C15E6.F2099AD4@quasar.ipa.nw.ru> <97h8lb$83s@gap.cco.caltech.edu> Message-ID: Robert Kern wrote in comp.lang.python: > IIRC, it's not that Python's license is restrictive; it passes the DFSG fine. > It's the fact that it conflicts with the GPL according to RMS, so distributing > the readline module binary, say, could be a GPL violation. No one wants to > get Debian in legal trouble. But Python 1.6.1 was released recently, with a GPL compatible license. It seems to have been met with silence in this newsgroup, but I hope this means that Python 2.0 and higher can soon have a compatible license as well. http://www.python.org/1.6.1/ (A CNRI release, so not a release by Guido's Flying Circus, I believe) -- Remco Gerlich From mjackson at wc.eso.mc.xerox.com Wed Feb 28 15:04:21 2001 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 28 Feb 2001 14:04:21 GMT Subject: Python 2 for Debian? References: Message-ID: <97j0h5$s41$1@news.wrc.xerox.com> scarblac at pino.selwerd.nl (Remco Gerlich) writes: > But Python 1.6.1 was released recently, with a GPL compatible license. Or not. CNRI concedes that Stallman says "Python 1.6.1 is not technically GPL-compatible, but unlike Python 1.6, the Python 1.6.1 license allows the creation of GPL-compatible derivative works." So things are, as usual, not straightforward. > It seems to have been met with silence in this newsgroup Except for Guido's announcement, and his remarks on the prospects for similar changes to the licenses for 2.x. See the c.l.py.a archives. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson Having your book made into a movie is like having your ox made into a bouillon cube. - Bill Neely From tim.one at home.com Wed Feb 28 19:02:48 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 28 Feb 2001 13:02:48 -0500 Subject: Python 2 for Debian? In-Reply-To: Message-ID: [Remco Gerlich[ > But Python 1.6.1 was released recently, with a GPL compatible license. Please read the note in italics at the referenced link: > http://www.python.org/1.6.1/ The FSF says 1.6.1's is *not* a GPL-compatible license, but is a necessary step on the road to releasing a Python with a license that is GPL-compatible. I don't understand what that means either. You can read the license text and guess for yourself: http://www.handle.net/python_licenses/python1.6.1-2-23-01.html Clause 7 is where the Deep Magic lives; we're waiting for a clarification about what this actually means. or-is-claimed-to-mean-anyway-ly y'rs - tim From jp_reed at yahoo.com Wed Feb 28 00:12:44 2001 From: jp_reed at yahoo.com (Jeremy Reed) Date: Tue, 27 Feb 2001 15:12:44 -0800 Subject: Python 2 for Debian? References: Message-ID: I have just compiled and installed Python 2.0 on my linux server just last night. The source code and instructions for the install can be found on www.python.org/2.0/ Best regards, Jeremy Reed From bryanbz at yahoo.com Tue Feb 27 21:00:43 2001 From: bryanbz at yahoo.com (Bryan BZ) Date: Tue, 27 Feb 2001 15:00:43 -0500 Subject: re.IGNORECASE Message-ID: Why is it I want to ignore the case in my search but Python refuses to match: "Spam" with "spam" OR "ni" with "Ni" For example (a really silly and stupid one) ... searchresult = re.search("Monty Python", "monty Python", re.IGNORECASE) won't match... Ugh, BB. From fredrik at pythonware.com Tue Feb 27 21:20:29 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 27 Feb 2001 20:20:29 GMT Subject: re.IGNORECASE References: Message-ID: "Bryan BZ" wrote: > Why is it I want to ignore the case in my search but Python refuses to > match: > > "Spam" with "spam" OR > "ni" with "Ni" it's a bug in 2.0. if the pattern contains uppercase characters, IGNORECASE may not always work. it's fixed in 2.1, and in the separate SRE distribution: http://www.pythonware.com/products/sre/index.htm Cheers /F From tjg at exceptionalminds.com Tue Feb 27 23:29:51 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Tue, 27 Feb 2001 14:29:51 -0800 Subject: re.IGNORECASE In-Reply-To: ; from bryanbz@yahoo.com on Tue, Feb 27, 2001 at 03:00:43PM -0500 References: Message-ID: <20010227142951.K29494@trufflehunter.avalongroup.net> On Tue, Feb 27, 2001 at 03:00:43PM -0500, Bryan BZ wrote: > Why is it I want to ignore the case in my search but Python refuses to > match: > > "Spam" with "spam" OR > "ni" with "Ni" > > For example (a really silly and stupid one) ... > > searchresult = re.search("Monty Python", "monty Python", re.IGNORECASE) > won't match... >>> import re >>> searchresult = re.search("Monty Python", "monty Python", >>> re.IGNORECASE) >>> print searchresult Worked for me. -- 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: 42 days 2:42 hours ago<< From jpreed00 at MailAndNews.com Tue Feb 27 21:04:02 2001 From: jpreed00 at MailAndNews.com (Jeremy Reed) Date: Tue, 27 Feb 2001 15:04:02 -0500 Subject: Anyone know of a way to get non-blocking keyboard input? Message-ID: <3AA01B31@MailAndNews.com> I am looking to create a telnet client that will, by using the select() statment, poll an open socket for data to be received while at the same time keep accepting keyboard input from the user. I have tried to run a thread in the background that collects input, but I never can figure out how to achieve the 'fluidity' that I desire--i.e. no stopping for a return-key press. Any ideas or help would be appreciated. Please, in addition to posting your answer in this newsgroup, email me a copy of your reply to jp_reed at yahoo.com. Best regards, Jeremy Reed From ben.hutchings at roundpoint.com Wed Feb 28 00:54:55 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 27 Feb 2001 15:54:55 -0800 Subject: Anyone know of a way to get non-blocking keyboard input? References: <3AA01B31@MailAndNews.com> Message-ID: Jeremy Reed writes: > I am looking to create a telnet client that will, by using the select() > statment, poll an open socket for data to be received while at the same time > keep accepting keyboard input from the user. > > I have tried to run a thread in the background that collects input, but I > never can figure out how to achieve the 'fluidity' that I desire--i.e. no > stopping for a return-key press. I think this ought to work for some platforms: try: istty = sys.stdin.isatty() except AttributeError: istty = 0 if istty: if os.name=='posix': import tty tty.setraw(sys.stdin.fileno()) elif os.name=='nt': import win32file, win32con hstdin = win32file._get_osfhandle(sys.stdin.fileno()) modes = (win32file.GetConsoleMode(hstdin) & ~(win32con.ENABLE_LINE_INPUT |win32con.ENABLE_ECHO_INPUT)) win32file.SetConsoleMode(hstdin, modes) Unfortunately, GetConsoleMode, SetConsoleMode, and associated constants don't seem to be included in win32all yet! -- Any opinions expressed are my own and not necessarily those of Roundpoint. From fuess at att.net Wed Feb 28 14:33:16 2001 From: fuess at att.net (David Fuess) Date: Wed, 28 Feb 2001 13:33:16 GMT Subject: Anyone know of a way to get non-blocking keyboard input? References: <3AA01B31@MailAndNews.com> Message-ID: Assuming you are on a Windows platform ... --- Begin Demo Script from msvcrt import * ch = 0 while ch != 'x': if kbhit(): ch = getch() print ch --- End Demo Script Dave On 27 Feb 2001 15:54:55 -0800, Ben Hutchings wrote: >Jeremy Reed writes: > >> I am looking to create a telnet client that will, by using the select() >> statment, poll an open socket for data to be received while at the same time >> keep accepting keyboard input from the user. >> >> I have tried to run a thread in the background that collects input, but I >> never can figure out how to achieve the 'fluidity' that I desire--i.e. no >> stopping for a return-key press. > >I think this ought to work for some platforms: > > try: > istty = sys.stdin.isatty() > except AttributeError: > istty = 0 > > if istty: > if os.name=='posix': > import tty > tty.setraw(sys.stdin.fileno()) > elif os.name=='nt': > import win32file, win32con > hstdin = win32file._get_osfhandle(sys.stdin.fileno()) > modes = (win32file.GetConsoleMode(hstdin) > & ~(win32con.ENABLE_LINE_INPUT > |win32con.ENABLE_ECHO_INPUT)) > win32file.SetConsoleMode(hstdin, modes) > >Unfortunately, GetConsoleMode, SetConsoleMode, and associated >constants don't seem to be included in win32all yet! From chris.gonnerman at usa.net Wed Feb 28 14:57:14 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Wed, 28 Feb 2001 07:57:14 -0600 Subject: Anyone know of a way to get non-blocking keyboard input? References: <3AA01B31@MailAndNews.com> Message-ID: <005301c0a18e$6235e0e0$a100000a@local> DOH! Boy did I send him the long way around! ----- Original Message ----- From: "David Fuess" Subject: Re: Anyone know of a way to get non-blocking keyboard input? > Assuming you are on a Windows platform ... > > --- Begin Demo Script > from msvcrt import * > > ch = 0 > while ch != 'x': > if kbhit(): > ch = getch() > print ch > --- End Demo Script > > Dave From seandc at att.net Tue Feb 27 22:02:25 2001 From: seandc at att.net (Sean) Date: Tue, 27 Feb 2001 21:02:25 GMT Subject: Pmw Megawidgets 0.8.5 - EntryField Message-ID: <3A9C1577.4642FC60@att.net> In this fragment (creating a date-type EntryField), I have used the undocumented - in Pmw - paramater 'label_width' successfully: _e = Pmw.EntryField(Master, labelpos = 'w', label_text = f[0], label_width = 12, value = f[4][0:4] + '/' + f[4][4:6] + '/' + f[4][6:8], validate = {'validator' : 'date', 'format' : 'ymd' }, ) *** [Q] Is there any way to control the width of the underlying Entry widget? In every example I've seen, all Entry widgets grouped in one dialog have the same width....presumably set by default to be the longest Entry in the group. Thanks. Sean From bernie at pacific.net.hk Wed Feb 28 21:16:04 2001 From: bernie at pacific.net.hk (bernie) Date: Thu, 01 Mar 2001 04:16:04 +0800 Subject: Pmw Megawidgets 0.8.5 - EntryField References: <3A9C1577.4642FC60@att.net> Message-ID: <3A9D5C83.C14E7C36@pacific.net.hk> Sean wrote: > In this fragment (creating a date-type EntryField), I have used > the undocumented - in Pmw - paramater 'label_width' successfully: > > _e = Pmw.EntryField(Master, > labelpos = 'w', > label_text = f[0], > label_width = 12, > value = f[4][0:4] + '/' + f[4][4:6] + '/' + f[4][6:8], > validate = {'validator' : 'date', 'format' : 'ymd' }, > ) > > *** [Q] Is there any way to control the width of the underlying Entry > widget? > _e._entryFieldEntry.config( width = ) > > In every example I've seen, all Entry widgets grouped in one dialog > have > the same width....presumably set by default to be the longest Entry in > the group. > > Thanks. > > Sean Bernie From frohne at gci.net Tue Feb 27 23:57:43 2001 From: frohne at gci.net (Ivan Frohne) Date: Tue, 27 Feb 2001 13:57:43 -0900 Subject: PEP 236 Message-ID: The python grows by shedding its skin. When it stops growing, it dies. --Ivan Frohne From m.faassen at vet.uu.nl Wed Feb 28 00:43:32 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 27 Feb 2001 23:43:32 GMT Subject: ANNOUNCE: Python - The RPG Message-ID: <97he34$jhc$1@newshost.accu.uu.nl> Python - The RPG The Hype A Python role playing game! Play your favorite Python community member! While said member watches! Travel through time! Save the planet! The Scenario The aliens are not expected to unleash their whitespace eating nanovirus to Earth for decades, right? There is no Python Secret Underground trying to put a stop to this, right? When? Where? This is to be determined. Tentative time is the evening of wednesday the 7th of january. Participants * Benevolent Dictator For the Game (BDFG) * A number of Players playing Characters * Members of the public (if sufficiently quiet) Sounds Great! How can I play? Mail the BDFG at m.faassen at vet.uu.nl with a convincing explanation on why you want to play a particular character. Don't mail him after sunday; it's no use -- talk to him at the conference. Playing yourself is illegal; you have to pick someone else. Write-in characters are allowed and encouraged, if you can convince the BDFG. If you don't get to play a character, never fear; members of the public have voting rights if deemed Worthy. The use of humor is a good way to convince the BDFG. Cast of Possible Characters Suggestions for new characters and/or character attributes are welcome. If people feel offended, sprinkle the following generously with smileys and in your mind. Yes, you can play any of these characters and others, if you manage to convince the BDFG. The advantages and disadvantages are expected to be roleplayed, mainly. They may also influence people's voting patterns during task resolution (see the rules section). Guido van Rossum (AKA BDFL) Advantages: * BDFL. Other Python Community Members will tend to listen to Guido. Guido can tell them what to do, and especially what they shouldn't do. When team members are deciding on an action, Guido can vote -1, thereby overruling the team members (note that this does not affect success determination, just whether the team will try something). * Access to time machine. Years ago Guido received a mysterious envelope containing the complete plans to a working time machine. He uses it mainly to implement features for Python before they're even suggested on comp.lang.python. Of course, the PSU uses it as well. Disadvantages * Dutch Bluntness. His Dutch bluntness may be a disadvantage when negotiating with NPCs. Tim Peters (AKA the timbot) Advantages: * Channeling Guido. Whenever Guido is absent, Tim Peters can Channel Guido. Tim can use this to gain extra authority over any Python Community Member. Tim can vote the overruling -1 in the absence of Guido. * Invisibility. Tim can turn invisible for a short while, allowing him to hide his secret identity, and to attend IPC8 (last year's Python conference) without being seen. Disadvantages: * Robot. Tim's secret identity is that he's a robot, which may shock some people. Not just an android robot like the effbot and the martellibot -- those look like real people. No, the timbot is a genuine lumbering metallic robot with blinking lights, and a heap of Perl scripts running the innards. * Distracted by side issues. Tim can go on at length on issues which are not really the core of the problem, complicating said problem for himself and everybody else. Fredrik Lundh (AKA the effbot) Advantages: * Gadgeteer. A problem? The effbot can frequently construct a small gadget to solve it, often enlightening people in the process. Disadvantages: * Grouchiness. The effbot does not suffer fools gladly. This may may complicate his interaction with some NPCs, as well as other team members. Alex Martelli (AKA the martellibot) Advantages: * His erudite, knowledgable and *lengthy* discourse. This will either convince NPCs, or otherwise make them fall asleep (which in the case of enemies is good). Disadvantages: * Erupts into berserker rage when reminded of the print >> syntax. Jim Fulton Advantages: * Engineering. Ability to understand and build amazingly complicated machinery. 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. Christian Tismer Advantages: * Can accomplish the impossible by changing the meaning of truth. Mystic ability influencing the fabric of reality. * Inspired Koreans. Christian can inspire hundreds of Koreans to the Pythonic cause. This should come in handy for something. Disadvantage: * A hard time explaining to other people what he's doing, or convincing them. Particilarly Guido. Rules The style of play is very light on actual rules. The only mechanical thing that may sometimes occur is task resolution by voting. Whenever a character wants to accomplish some task in the game, the BDFG decides whether success is trivial or not. For trivial success (for instance, adding simple a bug fix to the standard Python library) or trivial failure (for instance, adding a Perl style $ to the Python language) the BDFG just says whether something succeeds or fails, and that's all there is to it. In case of non-trivial success or failure, the BDFG has the option to put the resolution to a vote. In a vote each player can issue one vote, -1, 0, and +1. The BDFG can vote as well. If the total vote count is above 0, the action succeeds. If it's negative, the action fails. If it's exactly 0, a coin is tossed to determine success. If there is a public, members of the public who are deemed Worthy by the BDFG can participate in the voting process. Members of the public who are too loud at critical moments will likely not be deemed Worthy. Finally, if the BDFG thinks it's necessary, the BDFG can overrule the outcome of the vote. References The PSU's Existence Revealed http://groups.yahoo.com/group/python-list/message/66070 Roswell: The Truth http://groups.yahoo.com/group/python-list/message/87088 Python Labs moves to Digital Creations http://groups.google.com/groups?q=Roswell&rnum=2&seld=971292152&ic=1 Status of the PSU http://groups.google.com/groups?q=alien+whitespace&seld=941359988&ic=1 do-I-really-want-to-post-this-oh-well-here-goes-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From m.faassen at vet.uu.nl Wed Feb 28 11:39:27 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 28 Feb 2001 10:39:27 GMT Subject: ANNOUNCE: Python - The RPG References: <97he34$jhc$1@newshost.accu.uu.nl> Message-ID: <97ikgv$dva$1@newshost.accu.uu.nl> Martijn Faassen wrote: > When? Where? > This is to be determined. Tentative time is the evening of wednesday > the 7th of january. I don't know why I say january when I mean march; I've made the same mistake again after I wrote this. Weird. :) Perhaps-it's-the-PSU's-doing-ly yours, Martijn From jcollin at exis.net Wed Feb 28 03:26:32 2001 From: jcollin at exis.net (Jay Collins) Date: Tue, 27 Feb 2001 21:26:32 -0500 Subject: Passing values to a class Message-ID: Anyone shed some light on what I'm doing stupid/wrong here: import dbm class db: def __init__(self,base): print "using database",base pass def createdb(self): d = dbm.open(base,"n") d['name'] = "Jim Smith" d.close() app = db("databse") app.createdb() how come createdb() doesn't see base? Maybe I'm not getting class scope correctly. My idea was to pass what database I wanted to work on for that instance. Then I could call the methods to do work on the data in it. From bawolk at ucdavis.edu Wed Feb 28 04:40:21 2001 From: bawolk at ucdavis.edu (Bruce Wolk) Date: Tue, 27 Feb 2001 19:40:21 -0800 Subject: Passing values to a class References: Message-ID: <3A9C7325.F14B39D4@ucdavis.edu> Jay, You are right that the scope is wrong. In __init__ add the statement self.base = base and in createdb use self.base instead of base. Bruce Jay Collins wrote: > Anyone shed some light on what I'm doing stupid/wrong here: > > import dbm > > class db: > def __init__(self,base): > print "using database",base > pass > def createdb(self): > d = dbm.open(base,"n") > d['name'] = "Jim Smith" > d.close() > > app = db("databse") > app.createdb() > > how come createdb() doesn't see base? Maybe I'm not getting class scope > correctly. My idea was to pass what database I wanted to work on for that > instance. Then I could call the methods to do work on the data in it. From chris.gonnerman at usa.net Wed Feb 28 04:50:00 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Tue, 27 Feb 2001 21:50:00 -0600 Subject: Passing values to a class References: Message-ID: <00dd01c0a139$8d3bfae0$a100000a@local> ----- Original Message ----- From: "Jay Collins" Subject: Passing values to a class > Anyone shed some light on what I'm doing stupid/wrong here: Let me just mark up your code: import dbm class db: def __init__(self,base): print "using database",base self.base = base # pass # not needed def createdb(self): # d = dbm.open(base,"n") d = dbm.open(self.base,"n") # access the copy of base # stored in self d['name'] = "Jim Smith" d.close() app = db("databse") app.createdb() > how come createdb() doesn't see base? Maybe I'm not getting > class scope correctly. My idea was to pass what database I > wanted to work on for that instance. Then I could call the > methods to do work on the data in it. The concept is good, but simply handing base to __init__ doesn't actually DO anything; you still need to store it somewhere. From jcollin at exis.net Wed Feb 28 04:52:34 2001 From: jcollin at exis.net (Jay Collins) Date: Tue, 27 Feb 2001 22:52:34 -0500 (EST) Subject: Passing values to a class In-Reply-To: <00dd01c0a139$8d3bfae0$a100000a@local> Message-ID: Thanks. I got the hang of it out. Take care On Tue, 27 Feb 2001, Chris Gonnerman wrote: >----- Original Message ----- >From: "Jay Collins" >Subject: Passing values to a class >> Anyone shed some light on what I'm doing stupid/wrong here: > >The concept is good, but simply handing base to __init__ >doesn't actually DO anything; you still need to store it >somewhere. > From max at alcyone.com Wed Feb 28 04:26:23 2001 From: max at alcyone.com (Erik Max Francis) Date: Tue, 27 Feb 2001 19:26:23 -0800 Subject: PIL for the Mac? Message-ID: <3A9C6FDF.3F9422C@alcyone.com> Is PIL (PythonWare Image Library) available on the Mac? I don't see any reference to the Mac on its main Web page, and the source tarball doesn't appear to have any Mac specific files in 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 / \ Can you take my breath away / Can you give him life today \__/ Sweetbox Esperanto reference / http://mirror/alcyone/max/lang/esperanto/ An Esperanto reference for English speakers. From fredrik at pythonware.com Wed Feb 28 05:56:57 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 28 Feb 2001 04:56:57 GMT Subject: PIL for the Mac? References: <3A9C6FDF.3F9422C@alcyone.com> Message-ID: Erik Max Francis wrote: > Is PIL (PythonWare Image Library) available on the Mac? I don't see any > reference to the Mac on its main Web page, and the source tarball > doesn't appear to have any Mac specific files in it ... from what I can tell, it's shipped with the standard Mac distribution: http://www.python.org/download/download_mac.html "This is a single installer which gives you the option to install classic 68k, cfm68k, and/or PPC. The installer also optionally installs NumPy, PIL, img, Tkinter, and an IDE, and interactive development environment. Cheers /F From dev_null at email.com Wed Feb 28 04:27:42 2001 From: dev_null at email.com (Dev_NuLL) Date: Wed, 28 Feb 2001 03:27:42 GMT Subject: Intersesting Questions involving extending and embedding Message-ID: <3a9c6f89.9613214@news.digital.net> There is a free multi-platform 3D package called Blender ( www.blender.nl ) that has builtin python capabilities to help in automating animation and modeling tasks. The Blender Python module is builtin the Blender executable. Others have written external python modules for use with Blender and would like to figure out how it is done. Here is an example of code that would create a plane consisting of 4 vertices and one face: ################## START CODE ################### import Blender scene = Blender.getCurrentScene() mesh = Blender.Mesh("plane") object = Blender.Object("plane") mesh.enterEditMode() indices = [] index = mesh.addVertex(1,-1,0) indices.append(index) index = mesh.addVertex(1,1,0) indices.append(index) index = mesh.addVertex(-1,-1,0) indices.append(index) index = mesh.addVertex(-1,1,0) indices.append(index) mesh.addFace(indices[0],indices[1],indices[2],indices[3]) Blender.connect(object,mesh) Blender.connect(scene,object) mesh.leaveEditMode() ################## END 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 so my code would look like: import Blender import Primitives Primitive.plane() Of course I would like the 'plane' function to take args for the size, rotation, scaling, etc.., I have begun to read the docs on extending and embedding, and since the above does not use any C functions I imagine I would be doing mostly embedding. How would I go about creating a Windows DLL or Linux .so that would do this? I don't need help on compiling, just on how to get the module to directly connect to the 'Blender' module that is builtin the Blender executable. I am having a hard time getting started with the limmited knowledge I have in creating simple external modules that just do things like divide 2 numbers and return a result. How do I attach to the Blender module from within my module and make use of its functions like: mesh = Blender.Mesh("plane") object = Blender.Object("plane") mesh.enterEditMode() I know I sound desparate, but the 2 books I bought and the online docs barely scratch the surface of embedding. TIA From fredrik at pythonware.com Wed Feb 28 08:18:20 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 28 Feb 2001 07:18:20 GMT Subject: Intersesting Questions involving extending and embedding References: <3a9c6f89.9613214@news.digital.net> Message-ID: <0D1n6.15927$Qb7.2600092@newsb.telia.net> "Dev_NuLL" wrote: > 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 so my code would look like: > > import Blender > import Primitives > Primitive.plane() umm. any reason you cannot just put your code in a Primitives.py file? http://www.python.org/doc/current/tut/node8.html Cheers /F From dev_null at email.com Wed Feb 28 15:27:09 2001 From: dev_null at email.com (Dev_NuLL) Date: Wed, 28 Feb 2001 14:27:09 GMT Subject: Intersesting Questions involving extending and embedding References: <3a9c6f89.9613214@news.digital.net> <0D1n6.15927$Qb7.2600092@newsb.telia.net> Message-ID: <3a9f0af7.37387355@news.digital.net> >umm. any reason you cannot just put your code in a >Primitives.py file? The writers of Blender modules release the modules compiled to protect the source code, and that is what I am also interested in doing. This Primitives.py is just an example, I have a much more complicated project involving Catmul-Clark subdivision libs which are not open source. From fredrik at pythonware.com Wed Feb 28 15:34:41 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 28 Feb 2001 14:34: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> Message-ID: <508n6.15966$Qb7.2607706@newsb.telia.net> Dev_NuLL wrote: > >umm. any reason you cannot just put your code in a > >Primitives.py file? > > 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? Cheers /F From sfriedman at bewellnet.com Wed Feb 28 04:48:32 2001 From: sfriedman at bewellnet.com (Steven Friedman) Date: Tue, 27 Feb 2001 20:48:32 -0700 Subject: Newbie needs help on Python CGI scripts Message-ID: <97k893$hr$1@news.bewellnet.com> I am a complete newbie when it comes to CGI and scripting. I am trying to test out some scripts running Savant Server on a Windows 98 machine. Since I only want to learn CGI scripting this seems a perfectly acceptable soltion. Unfortunately everything I read seems to assume a UNIX server. Could someone PLEASE help me get things set right. 1. What and where do I need to set a path and where does my Python20.exe need to be. 2. How do I configure my server to tell it how to execute the file. 3. from what in my browser do I actually call the script? An HTML doc? Please be patient with me, its my first time at CGI. Thanks in advance sfriedman at bewellnet.com From sjuranic at u.washington.edu Wed Feb 28 07:39:36 2001 From: sjuranic at u.washington.edu ('Steve' Stephen W. Juranich) Date: Tue, 27 Feb 2001 22:39:36 -0800 Subject: Changes in __getitem__ in Python 2.0? Message-ID: It's been a while since I've been playing with my Python toys (I've been banished to C++ land for a while ). I have a class with the following definition for __getitem__: def __getitem__(self, key): # In some cases, I'm getting requests for data that are # past the end of the list. Given the sloppy nature of # the hand-labelled data, I don't think this is too much # of a problem, so I'll try this scheme. try: retval = self.data[key] except IndexError: retval = self.data[-1] return retval I'm now encountering a problem with Python 2.0 that I never had with earlier versions (1.5 and 1.6 specifically). I used to be able to do something like this: for foo in MyClass: print foo.member, But now when I do this, Python just starts spinning out of control in an infinite loop (it's like a car wreck... I want to press ^C, but I just can't look away). I am assuming that the problem is because of the __getitem__ definition above. Is there a way around this, or am I going to have to change a bunch of code to make this work on a new Python setup? I apologize if this is a topic that has been beaten to death. I tried looking for somthing relevant on Deja-cum-Google, but I didn't see any relevant hits and I didn't feel like looking through the next 13,000 possibilities. Thanks in advance for any help. I appreciate it. ---------------------------------------------------------------------- Stephen W. Juranich sjuranic at ee.washington.edu Electrical Engineering http://students.washington.edu/sjuranic University of Washington http://ssli.ee.washington.edu From fredrik at pythonware.com Wed Feb 28 08:14:14 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 28 Feb 2001 07:14:14 GMT Subject: Changes in __getitem__ in Python 2.0? References: Message-ID: "'Steve' Stephen W. Juranich" wrote: > def __getitem__(self, key): > # In some cases, I'm getting requests for data that are > # past the end of the list. Given the sloppy nature of > # the hand-labelled data, I don't think this is too much > # of a problem, so I'll try this scheme. > try: > retval = self.data[key] > except IndexError: > retval = self.data[-1] > > return retval > > I'm now encountering a problem with Python 2.0 that I never had with earlier > versions (1.5 and 1.6 specifically). > > I used to be able to do something like this: > > for foo in MyClass: > print foo.member, > > But now when I do this, Python just starts spinning out of control in an > infinite loop (it's like a car wreck... I want to press ^C, but I just can't > look away). it spins out of control in 1.5.2 too: for-in expects getitem to throw an index exception when there are no more items. afaik, for-in has always worked that way. the real problem is probably somewhere else... Cheers /F From tim.one at home.com Wed Feb 28 08:43:26 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 28 Feb 2001 02:43:26 -0500 Subject: Changes in __getitem__ in Python 2.0? In-Reply-To: Message-ID: [Stephen W. Juranich] > It's been a while since I've been playing with my Python toys (I've been > banished to C++ land for a while ). I have a class with the > following definition for __getitem__: > > def __getitem__(self, key): > # In some cases, I'm getting requests for data that are > # past the end of the list. Given the sloppy nature of > # the hand-labelled data, I don't think this is too much > # of a problem, so I'll try this scheme. > try: > retval = self.data[key] > except IndexError: > retval = self.data[-1] > > return retval > > I'm now encountering a problem with Python 2.0 that I never had > with earlier versions (1.5 and 1.6 specifically). Sorry, but this is hard to believe. You Changed Something. > I used to be able to do something like this: > > for foo in MyClass: > print foo.member, I'm assuming you meant to say that you're iterating over an *instance* of the class that contains the __getitem__ shown above. > But now when I do this, Python just starts spinning out of control in an > infinite loop Under the assumption above, it *should* be an infinite loop. Also in 1.6, 1.5, ..., and 0.9.6. Nothing relevant has ever changed here. The "for" protocol doesn't stop until __getitem__ raises an IndexError. The only way your __getitem__() above can raise an IndexError is if self.data is empty: then the first iteration will try self.data[0], that will raise IndexError, but then you'll catch IndexError, then the code will try self.data[-1], and that will raise an uncaught IndexError (which terminates the loop). So your loop should terminate if and only if self.data is empty. > ... > I am assuming that the problem is because of the __getitem__ definition > above. Is there a way around this, or am I going to have to > change a bunch of code to make this work on a new Python setup? Again, it has nothing to do with 2.0, but you're not going to believe that until you accept my challenge to show us a complete piece of executable code that demonstrates the problem under 2.0 but not under earlier Pythons . If your __getitem__ never raises IndexError, your "for" loop will never end; that's always been the case. or-the-problem-isn't-where-you-think-it-is-ly y'rs - tim From sjuranic at u.washington.edu Wed Feb 28 17:44:14 2001 From: sjuranic at u.washington.edu ('Steve' Stephen W. Juranich) Date: Wed, 28 Feb 2001 08:44:14 -0800 Subject: Changes in __getitem__ in Python 2.0? In-Reply-To: References: Message-ID: Thanks to Frank and Tim for the help. After further review on the play, the ruling on the field is that I'm a dunderhead. You guys were both right (as if there was ever any doubt). The same kind of thing chokes in Python 1.6 as well. hoping-that-the-code-is-robust-because-the-project-\ is-due-in-two-weeks-ly y'rs... ---------------------------------------------------------------------- Stephen W. Juranich sjuranic at ee.washington.edu Electrical Engineering http://students.washington.edu/sjuranic University of Washington http://ssli.ee.washington.edu From grobe+news at netins.net Wed Feb 28 09:21:44 2001 From: grobe+news at netins.net (Jonathan Grobe) Date: 28 Feb 2001 08:21:44 GMT Subject: alt.internet.p2p (peer-to-peer) newsgroup created Message-ID: Subject: alt.internet.p2p (peer-to-peer) newsgroup created Followup-To: alt.internet.p2p alt.internet.p2p has just been created for discussion of p2p (peer-to-peer) applications on the internet. Quoting Clay Shirky: "P2P is a class of applications that takes advantage of resources -- storage, cycles, content, human presence -- available at the edges of the Internet. Because accessing these decentralized resources means operating in an environment of unstable connectivity and unpredictable IP addresses, P2P nodes must operate outside the DNS system and have significant or total autonomy from central servers. ... If you're looking for a litmus test for P2P, this is it: 1) Does it treat variable connectivity and temporary network addresses as the norm, and 2) does it give the nodes at the edges of the network significant autonomy? If the answer to both of those questions is yes, the application is P2P. If the answer to either question is no, it's not P2P." These applications include file sharing such as Napster and Gnutella, instant messaging such as ICQ, distributed computing such as SETI at home. Many news administrators only add new alt.* groups on user request. So if it is not available at your site ask your news administrator to add it: Write to him at the address news or usenet at your site or to the technical support people there (address: support)). Because of the poor propagation of new alt groups it will be a while before a significant amount of traffic shows up. -- Jonathan Grobe From jafo at tummy.com Wed Feb 28 10:09:25 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Wed, 28 Feb 2001 02:09:25 -0700 Subject: Swalow: Where to get packages? Message-ID: <20010228020925.E29199@tummy.com> First of all, let me take care of this: Distutils RULES! [Oops, the next 5 paragraphs are rambling with a status update. Skip them to get to what I mentioned in the subject] My goal for tonight was to understand distutils and get a couple of my packages converted over to use it and just get familiar with it a bit. Very well thought-out. Works beautifully and required very little time for me to wrap my mind around. So, I released Distutiled versions of my netstring and CHAP modules (the latter has a dependency on the former), and updated my sample data to include that information. Then I set to work on the prototype code for the server and client. It's reasonably primitive right now, but I've got it to the point where the command "swalow download ITEMNAME=chap PKGVERS=1.13" will pick up the file from one of the listed locations (selected randomly), try the the list of locations until the size and checksum match the what the server said they should be, and return the path and file name it was downloaded to. I also added "swalow install ITEMNAME=chap PKGVERS=1.13", which does the download, extracts the tar.gz file, creates a binary RPM and installs it. Works wonderfully for distutils packages. Oh, I've also asked one of our guys who is familiar with both RPM and .debs about doing a "bdist_deb" target for Distutils, and have asked him to work on it. My goal for tomorrow is to figure out how to deal with dependencies. Dang, I got off topic there... One of my questions now is, where do we get the packages? Is there a collection of nice, juicy distutils packages out there that I just don't know about? What about the Vaults, any way to get information from them? At the very least I need to know: Package name Package version Does it include a Distutils setup.py Where to download it If somone can recommend some locations where I can pick up at least a few nice dist-utils packages to include in the setup, that'd be great as some additional testing. Sean -- "The great thing about Meat Loaf is he's his own special effect." -- J.S. Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From amk at mira.erols.com Wed Feb 28 13:47:17 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 28 Feb 2001 12:47:17 GMT Subject: Swalow: Where to get packages? References: Message-ID: On Wed, 28 Feb 2001 02:09:25 -0700, Sean Reifschneider wrote: >don't know about? What about the Vaults, any way to get information from >them? At the very least I need to know: Write Timothy Middleton, VoP's maintainer. Some HTML dumps of the data are available, which could be parsed, but I can't recall the URL and also don't know if Timothy wants their location to be handed around. Most of my code now uses Distutils -- poke around www.amk.ca/files/ -- but don't use the zodb package, because it has a weird special setup.py. --amk From phd at phd.pp.ru Wed Feb 28 10:30:49 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 28 Feb 2001 12:30:49 +0300 (MSK) Subject: Bug in __contains__ Message-ID: Hello! Python 2.0 (#1, Jan 26 2001, 15:34:20) [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 Type "copyright", "credits" or "license" for more information. >>> 10 in xrange(10) 1 Is it a known bug? Python 1.5.2 (#2, Dec 12 2000, 17:07:14) [GCC 2.95.2 20000220 (Debian GNU/Linux) on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> 10 in xrange(10) 0 It was ok... Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From thomas.heller at ion-tof.com Wed Feb 28 11:08:06 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Wed, 28 Feb 2001 11:08:06 +0100 Subject: Bug in __contains__ References: Message-ID: <97iim7$ogn8k$1@ID-59885.news.dfncis.de> "Oleg Broytmann" wrote in message news:mailman.983352719.16794.python-list at python.org... > Hello! > > Python 2.0 (#1, Jan 26 2001, 15:34:20) > [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 > Type "copyright", "credits" or "license" for more information. > >>> 10 in xrange(10) > 1 > > Is it a known bug? Yes, I reported this to sourceforge some months ago. Should be fixes in 2.1. Thomas Heller From othello at javanet.com Wed Feb 28 18:51:47 2001 From: othello at javanet.com (Raymond Hettinger) Date: Wed, 28 Feb 2001 12:51:47 -0500 Subject: Bug in __contains__ References: Message-ID: <3A9D3AB3.981DD5D9@javanet.com> Oleg Broytmann wrote: > Hello! > > Python 2.0 (#1, Jan 26 2001, 15:34:20) > [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 > Type "copyright", "credits" or "license" for more information. > >>> 10 in xrange(10) > 1 > > Is it a known bug? How did you run across this bug? I have never had reason to check for membership in xrange(). Just curious. Raymond From phd at phd.pp.ru Wed Feb 28 19:07:35 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 28 Feb 2001 21:07:35 +0300 (MSK) Subject: Bug in __contains__ In-Reply-To: <3A9D3AB3.981DD5D9@javanet.com> Message-ID: On Wed, 28 Feb 2001, Raymond Hettinger wrote: > > >>> 10 in xrange(10) > > 1 > > How did you run across this bug? I have never had reason to > check for membership in xrange(). A collegue asked me if it's a known bug :) While he wrote the Russian translation of Python tutorials (http://nd.spb.ru/dialect/book.asp?ID=60) he found some bugs in python 2.0. So expect some more questions from me. If he found some unknow bugs either he or I will file bug reports. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From bsb at winnegan.de Wed Feb 28 11:15:34 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 28 Feb 2001 11:15:34 +0100 Subject: Bug in __contains__ In-Reply-To: References: Message-ID: <87pug3glkp.fsf@winnegan.de> Oleg Broytmann writes: > Hello! > > Python 2.0 (#1, Jan 26 2001, 15:34:20) > [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 > Type "copyright", "credits" or "license" for more information. > >>> 10 in xrange(10) > 1 > > Is it a known bug? Python 2.1a2 (#6, Feb 28 2001, 10:30:37) [GCC 2.95.3 20010219 (prerelease)] on linux2 Type "copyright", "credits" or "license" for more information. >>> 10 in xrange(10) 0 Seems to be fixed :) Siggy From phd at phd.pp.ru Wed Feb 28 11:27:41 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 28 Feb 2001 13:27:41 +0300 (MSK) Subject: Bug in __contains__ In-Reply-To: <87pug3glkp.fsf@winnegan.de> Message-ID: On 28 Feb 2001, Siggy Brentrup wrote: > > Python 2.0 (#1, Jan 26 2001, 15:34:20) > > [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 > > Type "copyright", "credits" or "license" for more information. > > >>> 10 in xrange(10) > > 1 > > > > Is it a known bug? > > Python 2.1a2 (#6, Feb 28 2001, 10:30:37) > [GCC 2.95.3 20010219 (prerelease)] on linux2 > Type "copyright", "credits" or "license" for more information. > >>> 10 in xrange(10) > 0 > > Seems to be fixed :) Thanks! Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From tyler at tylereaves.com Wed Feb 28 15:20:27 2001 From: tyler at tylereaves.com (Tyler Eaves) Date: Wed, 28 Feb 2001 14:20:27 GMT Subject: Annoucing the CyberBio DIrectory System! Message-ID: Annoucing the CyberBio DIrectory System! http://www.ultracoastercentral.com/cyberbio/ The CyberBio is a revolutionary idea, an easy to use system for community building. I'm sure you've all heard that before. However, CyberBio is REALLY unique. There is literally nothing else like it! CyberBio allows the building of an online 'whitepages'. CyberBio is great for: *Schools *Churchs *Community Orginizations *Military Groups *Anyone! Thanks for your time. Tyler Eaves From cg at gaia.intranet.cdegroot.com Wed Feb 28 15:59:19 2001 From: cg at gaia.intranet.cdegroot.com (Cees de Groot) Date: 28 Feb 2001 15:59:19 +0100 Subject: [JOB-Netherlands] Zope/Python developer wanted Message-ID: <97j3o7$jmf$1@gaia.intranet.cdegroot.com> The InternetOne is a young ISP located in Amersfoort, The Netherlands, doing wholesale hosting through an international dealer network. We develop our on-line e-business/commerce software in Zope and Python, and need a skilled developer for this environment on short notice, either as a sub-contractor or as an employee. A temporary assignment is possible, we're looking at at least a three months' job. Necessary skills: Zope, Python, simple HTML design, PostgreSQL, Linux. We are a small shop, so you'll have a broad task range: developing software for on-line webhosting transactions (our dealers need to be able to create new virtual hostings, domain mgt., etcetera through-the-web), 3rd line support, integrating other systems (we host Intershop, Apache, IIS). We welcome foreigners, although chances are that non-EC citizens won't qualify due to time delays in work permit applications. You don't need to speak Dutch, English is fine. Compensation will be according to industry standards, for longer-term commitments we are working on a stock option program. If you are interested or want more information, drop me an email at cg at theinternetone.net. You can also ring me at +31 628 960861. Regards, Cees de Groot CTO The InternetOne -- Cees de Groot http://www.cdegroot.com GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD 1986 F303 937F E098 9E8B From embed at geocities.com Wed Feb 28 16:20:46 2001 From: embed at geocities.com (Warren Postma) Date: Wed, 28 Feb 2001 10:20:46 -0500 Subject: Combinations of n Lists Message-ID: I was just wondering if anyone has a more general version of this little helper function: 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, 'b'), (3, 'c')] So, what if I want def combinations(*lists): .... print combinations( [1,2,3], [4,5,6], [7,8,9], .... ) [ [1,4,7,....], .... [1,4,8, ... ], ..... ] Any takers!? ;-) Warren From aleaxit at yahoo.com Wed Feb 28 17:14:32 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 28 Feb 2001 17:14:32 +0100 Subject: Combinations of n Lists References: Message-ID: <97j85e02ked@news1.newsguy.com> "Warren Postma" wrote in message news:NI8n6.2979$TW.15640 at tor-nn1.netcom.ca... > I was just wondering if anyone has a more general version of this little > helper function: > > def combinations(list1,list2): > return [ (i,j) for i in list1 for j in list2 ] [snip] > def combinations(*lists): > .... > print combinations( [1,2,3], [4,5,6], [7,8,9], .... ) > [ [1,4,7,....], .... [1,4,8, ... ], ..... ] As usual, the easiest approach is through recursion, e.g.: def combinations(*lists): if not lists: return [ [] ] more = combinations(*lists[1:]) return [ [i]+js for i in lists[0] for js in more ] Alex From shaleh at valinux.com Wed Feb 28 17:20:41 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Wed, 28 Feb 2001 08:20:41 -0800 (PST) Subject: Combinations of n Lists In-Reply-To: Message-ID: On 28-Feb-2001 Warren Postma wrote: > I was just wondering if anyone has a more general version of this little > helper function: > > 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, > 'b'), (3, 'c')] > try zip() in python2 (-: From fredrik at pythonware.com Wed Feb 28 18:05:35 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 28 Feb 2001 17:05:35 GMT Subject: Combinations of n Lists References: Message-ID: Sean 'Shaleh' Perry wrote: > > 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, > > 'b'), (3, 'c')] > > > > try zip() in python2 (-: >>> print zip( [1,2,3], ['a','b','c'] ) [(1, 'a'), (2, 'b'), (3, 'c')] Cheers /F From tim.hochberg at ieee.org Wed Feb 28 19:09:08 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Wed, 28 Feb 2001 18:09:08 GMT Subject: Combinations of n Lists References: Message-ID: <89bn6.1121$DY.186465@news1.rdc1.az.home.com> "Warren Postma" wrote in message news:NI8n6.2979$TW.15640 at tor-nn1.netcom.ca... > I was just wondering if anyone has a more general version of this little > helper function: > > 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, > 'b'), (3, 'c')] > > So, what if I want > > def combinations(*lists): > .... > print combinations( [1,2,3], [4,5,6], [7,8,9], .... ) > [ [1,4,7,....], .... [1,4,8, ... ], ..... ] > > Any takers!? ;-) zip([1,2,3], [4,5,6], [7,8,9], .... ) (New in 2.0 I believe). or equivalently map(None, [1,2,3], [4,5,6], [7,8,9], .... ) for you 1.5.2 types out there.... -tim From rich_somerfield at tertio.com Wed Feb 28 16:33:39 2001 From: rich_somerfield at tertio.com (Rich Somerfield) Date: Wed, 28 Feb 2001 15:33:39 -0000 Subject: Problems compiling Tkinter Message-ID: has anybody tried compiling tkinter on linux (suse 6.4, have already downloaded and compiled Python 2.0 and Pil 1.1.1) ? I downloaded the source and couldnt find any info as to how to compile it. i tried the command "python setup.py install" but got the following error. I know that the last path is invalid (my install is in /usr/bin/python) but cant find where it is specified wrongly. Should I cheat and create a softlink so that the install can pick up the relavent files?, or is there something I can do to solve this problem properly? Any help would be appreciated. Regards Rich bash-2.03# python setup.py install running install Traceback (most recent call last): File "setup.py", line 25, in ? long_description = __doc__ File "/usr/bin/python-2.0/Lib/distutils/core.py", line 138, in setup dist.run_commands() File "/usr/bin/python-2.0/Lib/distutils/dist.py", line 829, in run_commands self.run_command(cmd) File "/usr/bin/python-2.0/Lib/distutils/dist.py", line 848, in run_command cmd_obj.ensure_finalized() File "/usr/bin/python-2.0/Lib/distutils/cmd.py", line 112, in ensure_finalized self.finalize_options() File "/usr/bin/python-2.0/Lib/distutils/command/install.py", line 255, in fina lize_options (prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix') File "/usr/bin/python-2.0/Lib/distutils/sysconfig.py", line 368, in get_config _vars func() File "/usr/bin/python-2.0/Lib/distutils/sysconfig.py", line 280, in _init_posi x raise DistutilsPlatformError, my_msg distutils.errors.DistutilsPlatformError: invalid Python installation: unable to open /usr/local/lib/python2.0/config/Makefile (No such file or directory) bash-2.03# From marvind at Glue.umd.edu Wed Feb 28 17:43:22 2001 From: marvind at Glue.umd.edu (Arvind Mani) Date: Wed, 28 Feb 2001 11:43:22 -0500 Subject: c thread routines from python Message-ID: <3A9D2AAA.8B8E3116@Glue.umd.edu> hi, I have a multi-threaded C program that I need to interface with a Tkinter GUI. I used Swig to create a module containing all the thread routines. Then I created a thread in python corresponding to each thread in the C program, and called the C routines in them. The problem is the that the python interpreter executes these instructions sequentially. I will include a small test program to illustrate my problem. The problem is the that the python interpreter executes these instructions sequentially. I will include a small test program to illustrate my problem. I added the code posted by Mark in the interface file but I think I got something messed up. I would be really grateful for any help. Thanks, arvind hello.c ----- void print_hello1(void) { ...... inf loop } void print_hello2(void) { .....inf loop } .i file ---- %typemap (python, except) void { PY_BEGIN_ALLOW_THREADS $function PY_END_ALLOW_THREADS } extern void print_hello1(void); extern void print_hello2(void); .py --- thread.start_new_thread(hello.print_hello1, ()) thread.start_new_thread(hello.print_hello2, ()) From slhath at home.com.nospam Wed Feb 28 17:44:48 2001 From: slhath at home.com.nospam (Scott Hathaway) Date: Wed, 28 Feb 2001 16:44:48 GMT Subject: Pmw ComboBox question Message-ID: <4W9n6.369$xT4.93987904@newssvr10-int.news.prodigy.com> How can I change the length of the entry portion of the combox widget? Thanks, Scott From bernie at pacific.net.hk Wed Feb 28 19:04:50 2001 From: bernie at pacific.net.hk (bernie) Date: Thu, 01 Mar 2001 02:04:50 +0800 Subject: Pmw ComboBox question References: <4W9n6.369$xT4.93987904@newssvr10-int.news.prodigy.com> Message-ID: <3A9D3DC2.5387B37F@pacific.net.hk> Scott Hathaway wrote: > How can I change the length of the entry portion of the combox widget? > _width = 4 # width of entry field _widget = Pmw.ComboBox( parent) _widget._entryfield._entryFieldEntry.config( width = _width) > > Thanks, > Scott From slhath at home.com Wed Feb 28 23:03:52 2001 From: slhath at home.com (Scott Hathaway) Date: Wed, 28 Feb 2001 22:03:52 GMT Subject: Pmw ComboBox question References: <4W9n6.369$xT4.93987904@newssvr10-int.news.prodigy.com> <3A9D3DC2.5387B37F@pacific.net.hk> Message-ID: Thanks! Scott "bernie" wrote in message news:3A9D3DC2.5387B37F at pacific.net.hk... > > > Scott Hathaway wrote: > > > How can I change the length of the entry portion of the combox widget? > > > > _width = 4 # width of entry field > _widget = Pmw.ComboBox( parent) > _widget._entryfield._entryFieldEntry.config( width = _width) > > > > > > Thanks, > > Scott > From spamfranke at bigfoot.de Wed Feb 28 18:49:12 2001 From: spamfranke at bigfoot.de (Stefan Franke) Date: Wed, 28 Feb 2001 17:49:12 GMT Subject: Is += on strings a thread-safe operation? Message-ID: <3a9d3833.737414@news.btx.dtag.de> What about augmented assignments of other built-in types? Being able to thread-safely append to a string buffer (or other sequences) with += would be a big advantage of the somewhat infamous augmented assignment operators in my eyes. Stefan Stefan Franke www.meso.net From aahz at panix.com Wed Feb 28 19:43:22 2001 From: aahz at panix.com (Aahz Maruch) Date: 28 Feb 2001 10:43:22 -0800 Subject: Is += on strings a thread-safe operation? References: <3a9d3833.737414@news.btx.dtag.de> Message-ID: <97jgsa$9it$1@panix6.panix.com> In article <3a9d3833.737414 at news.btx.dtag.de>, Stefan Franke wrote: > >What about augmented assignments of other built-in types? Being able >to thread-safely append to a string buffer (or other sequences) with += >would be a big advantage of the somewhat infamous augmented assignment >operators in my eyes. Using the dis module, we see that the only difference between "x+='b'" and "x=x+'b'" lies in substituting INPLACE_ADD for BINARY_ADD. If the latter is thread-safe, so is the former; I'm not entirely confident enough in my byte-code skills to make an assertion. But it looks to me that it's not thread-safe because you're reading and assigning the same variable in the same statement. I *do* know that x.append('b') is a thread-safe operation -- and that's probably a better bet, anyway, even if threading isn't involved. -- --- 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 embed at geocities.com Wed Feb 28 21:25:05 2001 From: embed at geocities.com (Warren Postma) Date: Wed, 28 Feb 2001 15:25:05 -0500 Subject: Is += on strings a thread-safe operation? References: <3a9d3833.737414@news.btx.dtag.de> Message-ID: <3adn6.3087$TW.15865@tor-nn1.netcom.ca> "Stefan Franke" wrote in message news:3a9d3833.737414 at news.btx.dtag.de... > What about augmented assignments of other built-in types? Being able to thread-safely append > to a string buffer (or other sequences) with += would be a big advantage of the somewhat infamous > augmented assignment operators in my eyes. > > Stefan The sad truth is that everything in Python is thread safe, because ironically, nothing in python is thread safe. What I mean to say is that when Threading support is enabled in Python, which on most systems it now is, everything the Python interpreter runs occurs while it is holding onto a Global Interpreter Lock which is only released explicitly when it is safe to do so. So that means in effect that all Python Bytecode operations are explicitly atomic, thus all Python builtin C functions are atomic, except those which choose not to be (such as time.sleep()) by letting go of and then re-acquiring the global interpreter lock. It is not possible for the interpreter to let go of that lock while in the middle of a string "+=". In other words, anything that resolves to a single bytecode in Python interpreter is done while the current thread holds the lock. That makes invocation of any builtin C function atomic as far as I can see. Am I right? Where is Timbot when you really need him? Warren From tim.one at home.com Wed Feb 28 21:49:42 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 28 Feb 2001 15:49:42 -0500 Subject: Is += on strings a thread-safe operation? In-Reply-To: <3adn6.3087$TW.15865@tor-nn1.netcom.ca> Message-ID: [Warren Postma, correctly explains Python's peculiarly forgiving notion of thread-safety as follows from the global interpreter lock, but falls for a flawed example] > ... > So that means in effect that all Python Bytecode operations are explicitly > atomic, thus all Python builtin C functions are atomic, except those which > choose not to be (such as time.sleep()) by letting go of and then > re-acquiring the global interpreter lock. It is not possible for the > interpreter to let go of that lock while in the middle of a string "+=". There's the rub: += generates more than one bytecode, so there actually are chances for the interpreter to let go of the GIL "in the middle" of *any* += (and for multiple spellings of "+="). > In other words, anything that resolves to a single bytecode in Python > interpreter is done while the current thread holds the lock. Yes. > That makes invocation of any builtin C function atomic as far as > I can see. Your eyes are fine -- at least for long-term viewing . > Am I right? Where is Timbot when you really need him? I only show up when I'm not really needed -- like here. it's-too-stressful-to-take-a-stand-when-i-am-needed-ly y'rs - tim From jp at ulgo.koti.com.pl Wed Feb 28 19:34:55 2001 From: jp at ulgo.koti.com.pl (Jacek =?iso-8859-2?Q?Pop=B3awski?=) Date: 28 Feb 2001 18:34:55 GMT Subject: Python + MySQL + qt Message-ID: 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). 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? - what libraries will I need except pygtk or pyqt? - 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? -- Look all around Can't you open your eyes Voices are calling "Master of Insanity" Killing rain falling down from the sky - Ronnie James Dio From hgg9140 at seanet.com Wed Feb 28 22:14:12 2001 From: hgg9140 at seanet.com (Harry George) Date: 28 Feb 2001 13:14:12 -0800 Subject: Python + MySQL + qt References: Message-ID: jp at ulgo.koti.com.pl (Jacek =?iso-8859-2?Q?Pop=B3awski?=) writes: > 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). > 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 an excellent choice. Python is probably the easy part. DBMS's can be tricky. Are you already a DBA or do you already have a DBMS running (with your database defined and loaded)? I can give you some install scripts if you are starting fresh. Next, you need a DBI 2.0 python binding. I'm using MySQLdb, and it works fine. > - what libraries will I need except pygtk or pyqt? pygtk, pygnome, pyqt, and pykde are all do-able, and interesting exercises in their own right. But if you are on a tight deadline, consider using cgi's (if you are comfortable with forms). Also, python and wxWindows is a nice cros-platform combination. > - 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? > If you use cgi's, you can run of course against a Linux server. Even on Windows, the cgi's may be ok without code changes. Or you can use wxWindows and be cross-platform. MySQL and PostgreSQL can also be served from Linux even if the GUI app is on Windows. If you must run fully in Windows, you might have to do odbc to Access or something like that. In any case, I'm not aware of any code changes due to different platforms, but I'm not much of a Windows programmer. > -- > Look all around > Can't you open your eyes > Voices are calling "Master of Insanity" > Killing rain falling down from the sky - Ronnie James Dio -- Harry George hgg9140 at seanet.com From jbeaulie at softimage.com Wed Feb 28 20:34:45 2001 From: jbeaulie at softimage.com (motif) Date: Wed, 28 Feb 2001 14:34:45 -0500 Subject: How do I load a .png graphic file into a dialog in Irix? Message-ID: <97jjqh$ct3$1@paperboy.CORP.Softimage.COM> Im try to load a .png file in Irix,. Im habe to load it, he program don't display it. whats the problem? where a bit of my code. void CBaseDialog::LoadBitmap(wxString bitmapname,unsigned int nbcontrol) { #if wxUSE_LIBPNG wxImage::AddHandler( new wxPNGHandler ); #endif wxBitmap bit; if (bit.LoadFile(bitmapname,wxBITMAP_TYPE_PNG)) { //wxMessageBox(bitmapname,"Quit setup?", wxICON_EXCLAMATION | wxYES_NO | wxYES_DEFAULT , NULL); wxStaticBitmap* bitmap = static_cast(GetDlgItem(m_BaseDialog,nbcontrol)); bitmap->SetBitmap(bit); } } From leo at iems.nwu.edu Wed Feb 28 21:46:52 2001 From: leo at iems.nwu.edu (Leonardo B Lopes) Date: Wed, 28 Feb 2001 14:46:52 -0600 Subject: docs for mysqldb Message-ID: <3A9D63BC.C3EB9246@iems.nwu.edu> 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? -- ======================================================================= Leonardo B. Lopes leo at iems.nwu.edu Ph.D. Student (847)491-8470 IEMS - Northwestern University http://www.iems.nwu.edu/~leo From jfontain at free.fr Wed Feb 28 22:17:55 2001 From: jfontain at free.fr (Jean-Luc Fontaine) Date: Wed, 28 Feb 2001 21:17:55 GMT Subject: ANNOUNCE: moodss-14.0 Message-ID: <3A9D6B01.83F13FB2@free.fr> Hi everybody: here is a new version of moodss. Check it out! (or at least the screenshots at http://jfontain.free.fr/moodss3.gif or http://jfontain.free.fr/moodss4.gif :). Notes: - moodss modules can now be written in Python! Sample randpy and minipy modules are provided. Documentation (see randpy.py file) needs improving. Feedback is highly welcomed. (modules can also be written in Perl, and Tcl of course) - please let me know if you are interested in writing modules in Ruby (I'm on a roll :-) ### CHANGES ### --- version 14.0 --- modules can now be written in the Python language (the tclpython package is required, available in my homepage) added Python based randpy and minipy modules ### README ### This is moodss (Modular Object Oriented Dynamic SpreadSheet) version 14.0. Moodss won in the Best System Admin Technology category (Tcl Tips and Tricks, Valuable Real World Programming Examples) at the O'Reilly Tcl/Tk 1999 Conference. Linux Magazine calls it a "lifesaver". Tucows gives it 5 stars (cows or penguins :-). Moodss is a modular application. It displays data described and updated in one or more modules, which can be specified in the command line or dynamically loaded or unloaded while the application is running. Data is originally displayed in tables. Graphical views (graph, bar, 3D pie charts, ...), summary tables (with current, average, minimum and maximum values) and free text viewers can be created from any number of table cells, originating from any of the displayed viewers. Thresholds can be set on any number of cells. Specific modules can easily be developed in the Tcl, Perl and Python scripting languages or in C. A thorough and intuitive drag'n'drop scheme is used for most viewer editing tasks: creation, modification, type mutation, destruction, ... and thresholds creation. Table rows can be sorted in increasing or decreasing order by clicking on column titles. The current configuration (modules, tables and viewers geometry, ...) can be saved in a file at any time, and later reused through a command line switch, thus achieving a dashboard functionality. The module code is the link between the moodss core and the data to be displayed. All the specific code is kept in the module package. Since module data access is entirely customizable (through C code, Tcl, Perl, Python, HTTP, ...) and since several modules can be loaded at once, applications for moodss become limitless. For example, thoroughly monitor a dynamic web server on a single dashboard with graphs, using the Apache, MySQL, cpustats, memstats, ... modules. If you have replicated servers, dynamically add them to your view, even load the snmp module on the fly and let your imagination take over... Along with a core trace module, random, ps, cpustats, memstats, diskstats, mounts, route, arp, kernmods, netdev, pci, system, MySQL (myquery, mystatus, myprocs, myvars) modules for Linux, ping, snmp and snmptrap for UNIX, apache and apachex modules are included (running "wish moodss ps cpustats memstats" mimics the "top" application with a graphic edge and remote monitoring capability). Thorough help is provided through menus, widget tips, a message area, a module help window and a global help window with a complete HTML documentation. Moodss is multi-langual thanks to Tcl internationalization capabilities. So far only English and partially French are supported. Help with other languages will be very warmly welcomed. Development of moodss is continuing and as more features are added in future versions, backward module code compatibility will be maintained. I cannot thank the authors of the tkTable, BLT, MIME/SMTP and the HTML libraries enough for their great work. In order to run moodss, you need to install the following packages (unless you can use the rpm utility, see below): Tcl/Tk 8.3.1 or above, at (or at a mirror near you) http://dev.scriptics.com/ or ftp://ftp.scriptics.com/ the latest tkTable widget library at: http://www.hobbs.wservice.com/tcl/main.html the latest BLT library at: ftp://tcltk.sourceforge.net/pub/tcltk/blt/ eventually the latest tclperl library for writing modules in Perl, or the latest tclpython library for writing modules in Python at: http://jfontain.free.fr/ (see the INSTALL file for complete instructions, for UNIX and also Windows platforms). You also have the option of using the moodss rpm file (also in my homepage), if you are using a Redhat Linux system (6.0 or above). You can find the required tcl, tk, tktable, blt, tcpperl and other rpms at: http://jfontain.free.fr/ Whether you like it (or hate it), please let me know. I would like to hear about bugs and improvements you would like to see. I will correct the bugs quickly, especially if you send me a test script (module code with a data trace would be best). ### you may find it now at my homepage: http://jfontain.free.fr/moodss-14.0.tar.gz http://jfontain.free.fr/moodss-14.0-1.i386.rpm http://jfontain.free.fr/moodss-14.0-1.spec and a bit later at: ftp://contrib.redhat.com/ in libc6 sub-directory. Enjoy and please let me know what you think. -- Jean-Luc Fontaine mailto:jfontain at free.fr http://jfontain.free.fr/ From jfontain at free.fr Wed Feb 28 22:20:04 2001 From: jfontain at free.fr (Jean-Luc Fontaine) Date: Wed, 28 Feb 2001 21:20:04 GMT Subject: ANNOUNCE: tclpython-1.1 Message-ID: <3A9D6B7F.D7F73316@free.fr> ### CHANGES ### --- version 1.1 --- include interpreter name in error messages ### README ### tclpython version 1.1: a Python package for Tcl This package allows the execution of Python code from a Tcl interpreter, as in: package require tclpython set interpreter [python::interp new] $interpreter eval {x = 3/2.0} set result [$interpreter eval {print x}] puts $result Sending data from the Python interpreter to the Tcl interpreter requires the print Python command. This will hopefully no longer be required in future versions. 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-1.1.tar.gz http://jfontain.free.fr/tclpython-1.1-1.i386.rpm http://jfontain.free.fr/tclpython-1.1-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 ljohnson at resgen.com Wed Feb 28 22:44:56 2001 From: ljohnson at resgen.com (Lyle Johnson) Date: Wed, 28 Feb 2001 15:44:56 -0600 Subject: ANN: FXPy-0.99.160, Python bindings for FOX GUI toolkit Message-ID: I posted this earlier this morning but it hasn't shown up yet. Apologies in advance if it appears multiple times... This is an update of FXPy, a Python extension module which provides an interface to the FOX cross-platform GUI library: Home Page: http://fxpy.sourceforge.net Download Source: http://download.sourceforge.net/fxpy/FXPy-0.99.160.tar.gz Windows Binaries: http://download.sourceforge.net/fxpy/FXPy-0.99.160-win32.exe To build FXPy from the sources, you will also need to download version 0.99.160 of the FOX library: FOX Home Page: http://www.cfdrc.com/FOX/fox.html Download Source: ftp://ftp.cfdrc.com/pub/FOX/fox-0.99.160.tar.gz ftp://ftp.cfdrc.com/pub/FOX/fox-0.99.160.zip As you may have guessed by now, the latest release of FXPy is version 0.99.160. What is it? ----------- FXPy is a Python extension module which provides an interface to the FOX cross-platform GUI library. With a few minor exceptions, FXPy provides a complete interface to FOX. FOX is a C++-based toolkit for developing graphical user interfaces easily and effectively. Some of the significant features of FOX include: * A rich set of widgets (including dials, shutters, tree lists, and many other "modern" widgets). * Powerful but easy-to-use layout managers. * Extensive support for 3-D modeling using OpenGL or Mesa. * Supports the XDND (v4) protocol for drag-and-drop. * Registry for persistent application settings. * Runs natively under Unix/X and Microsoft Windows. * And much, much more! Please see the FOX home page (URL listed above) for more details about the FOX library's features. Also consider subscribing to the foxgui-users mailing list for the latest news about FOX development; again, see the FOX home page for information on this. FXPy is (c) 1999, 2000, 2001 Lyle Johnson (lyle at users.sourceforge.net) and is released under the GNU Lesser General Public License.

FXPy-0.99.160 - interface to the FOX cross-platform GUI library. (28-Feb-01) From Cayce at actzero.com Wed Feb 28 23:41:21 2001 From: Cayce at actzero.com (Cayce Ullman) Date: Wed, 28 Feb 2001 14:41:21 -0800 Subject: Best way to string compare a python object in a getattrofunc? Message-ID: Hi, I'm writing an extension class that has a getattro method implemented in C. The method takes a python object as it's name, not a string. My question is what is the best way to do this. For example, if I always want my extension class to return "eggs" when attribute "spam" is requested, no matter what is in the instance dictionary, what's the fastest way to compare the python string object with my string constant. Currently I'm doing it this way: static PyObject * myec_getattro(myec_object *self, PyObject *name) { if (strcmp(PyString_AsString(name),"spam")==0) { return PyString_FromString("eggs"); } return Py_FindAttr((PyObject *)self, name); } This obviously requires that the every time an attribute is requested it is converted into a char* then strcmped (obviously some type checking would eventually be appropriate here). This seems like a lot of work. 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. This approach would save me type checking, string convertion, and a strcmp. However, I think it might not be fool proof. Ie, if someone computed the attribute name "sp" + "am", this would no longer work (I don't think that is very likely, though). Also, if the attribute name came from some other C module, it seems like that too could have problems. I can't be the first person wondering about this, is there a universally accepted best practice here? TIA, Cayce From davidlam at cableinet.co.uk Wed Feb 28 23:41:45 2001 From: davidlam at cableinet.co.uk (bruce) Date: Wed, 28 Feb 2001 22:41:45 GMT Subject: python performance Message-ID: 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. TIA Bruce From guido at digicool.com Wed Feb 28 23:54:18 2001 From: guido at digicool.com (Guido van Rossum) Date: Wed, 28 Feb 2001 17:54:18 -0500 Subject: Python webring is dead Message-ID: <200102282254.RAA31089@cj20424-a.reston1.va.home.com> There used to be a Python webring. But from the following exchange, I see it is dead. If someone wants to create a new one, please go ahead -- if you let webmaster at python.org know, we'll add python.org to the ring. --Guido van Rossum (home page: http://www.python.org/~guido/) ------- Forwarded Message Date: Wed, 28 Feb 2001 23:02:19 +0000 From: Manuel Gutierrez Algaba To: Guido van Rossum Subject: Re: Random python site On Mon, 26 Feb 2001, Guido van Rossum wrote: > > I'm the current maintainer of the Python ring. I've lost control of > > my Yahoo account. That is, I've lost any control over the python > > ring. I'd suggest you to create a new ring. > > > > If you don't trust me try to add a new site to the ring. Or just > > watch when was the last adding to the ring ? > > Much more than 3 months. > > > > Sorry for my incompetence. > > Sorry, I'm not interested in taking up more work. If you want to > create a new ring, that's fine. Otherwise, we'll just drop the link. > > --Guido van Rossum (home page: http://www.python.org/~guido/) > Then, please, drop the link, forward this to comp.lang.python to try if anybody is interested or just leave it, but knowing it's a no-end road. - --- Regards/Saludos Manolo http://spain.50g.com ------- End of Forwarded Message From duncan at rcp.co.uk Thu Feb 8 11:11:58 2001 From: duncan at rcp.co.uk (Duncan Booth) Date: Thu, 8 Feb 2001 10:11:58 +0000 (UTC) Subject: urllib.open('http://www.redherring.com/') References: <95th67$36j$1@nnrp1.deja.com> Message-ID: apederse at my-deja.com wrote in <95th67$36j$1 at nnrp1.deja.com>: >I have some problems with urllib. Any URL works >just fine except http://www.redherring.com/ which >returns nothing, no headers, no nothing. (Red >Herring works fine from any browser). It works fine when I try it (using Python 2.0). Changing things like the accept header which might be expected to make a difference don't seem to have any effect. From fredrik at pythonware.com Thu Feb 22 15:57:52 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 22 Feb 2001 14:57:52 GMT Subject: Newbie Error? Compiling _tkinter from Source on Win32 References: Message-ID: Chris Withers wrote: > > --------------------Configuration: _tkinter - Win32 Release-------------------- > > Compiling... > > _tkinter.c > > E:\Python-2.0\Modules\_tkinter.c(44) : fatal error C1083: > > Cannot open include file: 'tcl.h': No such file or directory > > tkappinit.c > > E:\Python-2.0\Modules\tkappinit.c(15) : fatal error C1083: > > Cannot open include file: 'tcl.h': No such file or directory > > Error executing cl.exe. > > > > _tkinter.pyd - 2 error(s), 0 warning(s) > > Any ideas what I'm doing wrong? Does "newbie" mean C newbie? The error message pretty much means what it says: the compiler cannot find and open that file. Make sure you have tcl.h somewhere, and check the compiler's include settings. (iirc, the distributed build file expects to find the Tcl/Tk include files in "\..\tcl\include") Cheers /F From sheila at spamcop.net Wed Feb 14 15:44:04 2001 From: sheila at spamcop.net (Sheila King) Date: Wed, 14 Feb 2001 14:44:04 GMT Subject: smtplib problem References: <966mnl$2dl$1@uranium.btinternet.com> <87pugl1x2c.fsf@psyche.dnsalias.org> Message-ID: On 14 Feb 2001 21:35:39 +1300, Carey Evans wrote in comp.lang.python in article <87pugl1x2c.fsf at psyche.dnsalias.org>: :Tim Roberts writes: : :> There is no such thing. The SMTP protocol does not include authorization. : :RFC2554 specifies an extension to SMTP, that adds authentication on :message submission to an SMTP server. BCP46 (RFC3013) section 5.4 :recommends its use. : :smtplib.py doesn't implement SMTP AUTH, although you could do it :yourself using the docmd(), send() and getreply() methods. Thank you! This is the type of tip I was looking for. Maybe in a few weeks, when I have time, I'll mess around with it. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From rob at netzilient.com Wed Feb 21 23:21:04 2001 From: rob at netzilient.com (Rob Eden) Date: Wed, 21 Feb 2001 16:21:04 -0600 Subject: Interrupting blocking reads Message-ID: <3a943dcb@news.advancenet.net> I have an application that is reading from a number of different files (well, external process' output streams to be precise). I need to be able to interrupt the threads, but I don't see a way to do this other than with a signal. The problem is, I want to be able to interrupt an individual thread while possibly leaving the others running. So can you answer any of these questions: 1) Is there a way to interrupt a blocking file read other than with a signal? 2) Is there a non-blocking file read? read(0) seems to return no data. But it returns right away! (This is useful why?) 3) Is there a way to get signals to work with multiple threads? 4) Any other solutions to the problem? Thanks! Rob Eden From shaleh at valinux.com Mon Feb 19 19:52:44 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Mon, 19 Feb 2001 10:52:44 -0800 Subject: Weird Language Features In-Reply-To: ; from dave@dave.org.uk on Sun, Feb 18, 2001 at 01:16:49PM +0000 References: Message-ID: <20010219105244.B29164@valinux.com> On Sun, Feb 18, 2001 at 01:16:49PM +0000, Dave Cross wrote: > > [Please watch the replies on this message as it's heavily > cross-posted] > > 1/ The programmer calls a function that doesn't actually exist within > the application (or libraries). Is the a feature whereby the > programmer can create a "catch-all" function which is called in cases > like these? Can this function examine the list of existing functions > and call the most appropriate one? Or create a new function on the fly > and install it into the application? > python will throw an exception, the code could then decide that the exception was due to a missing function and decide how to deal with it. I suspect this could be useful in really restricted areas, but in general code it strikes me as horribly confusing. > 2/ Can ou filter the input source code before compilation (or > interpretation) in some way so that language keywords could be changed > for other strings? Imagine you wanted to allow someone to program your > language of choice in, say, French. How would you go about translating > French keywords into ones that the compiler (or interpreter) could > understand. What if the translation wasn't one-to-one or fixed? Could > you put enough intelligence into the translator so that it could > handle certain strings differently depending on where they appeared in > the source code? perligata makes a LOT of assumptions for you. it is not really latin. I presume it is one of the poster children for this in perl. its fun, but a toy. even if you could code essential language words in natural language Foo, things like if and for, there is a wealth of code out there NOT in Foo. So even if I use perligata for the base of my code, when I use any other module I have to be able to speak the language the module was written in. So if I try to import a module written by your friend in French, I now have to know French to figure out the function and variable names. As much as we hate it, a common language is good. As for python, the interpreter, keyword and parser are available, I suspect this could be done with a little work. From latlong at css2.com Wed Feb 14 10:34:31 2001 From: latlong at css2.com (LatLong) Date: Wed, 14 Feb 2001 09:34:31 GMT Subject: ANN: Latitude longitude database Message-ID: Latitude longitude database of over 2.8 million locations worldwide. Download from: http://www.css2.com/latlong.htm Ideal for sales and marketing applications and travel related websites. Includes sample code. From dalke at acm.org Tue Feb 13 03:26:00 2001 From: dalke at acm.org (Andrew Dalke) Date: Mon, 12 Feb 2001 19:26:00 -0700 Subject: Graph (cyclic kind, not pretty picture kind) rendering algorithm? References: <3A87A0EC.BA802E3E@student.gu.edu.au> Message-ID: <96a61a$9ln$1@slb1.atl.mindspring.net> s713221 at student.gu.edu.au wrote: >I don't know of any, but I'd be interested if anyone else could direct >us to one, I need exactly this for a chem editor I'm building at the >moment. > >Joal Heagney/AncientHart Having been involved in several of these discussions, don't use that approach. There is a lot of chemistry involved in making a chemical layout algorithm look correct. Your best bet is to look at how JMDraw http://vanilla.ice.mpg.de/~stein/projects/SmilesViewer/ or JChemPaint http://jchempaint.sourceforge.net/ do their layout. The latter is LGPL'ed. There isn't much other publically available source code to look at for development of new layout algorithms. Even they won't be exactly what a chemist wants, because chemists disagree with what they expect. Eg, many companies have guidelines on how different families of compounds should be laid out, so the only real solution involves a lot of substructure matching against a set of templates. Or you hire someone to draw every molecule, which is done! Andrew dalke at acm.org From aahz at panix.com Tue Feb 20 19:42:16 2001 From: aahz at panix.com (Aahz Maruch) Date: 20 Feb 2001 10:42:16 -0800 Subject: Python 2.x breaks cmp() (was Re: A suspected bug) References: <96os85$1qe$1@panix3.panix.com> Message-ID: <96udq8$mh$1@panix3.panix.com> In article , wrote: >Aahz Maruch wrote: >> >>Is there any chance this can be treated as a bug and fixed for the >>release of 2.1? Alternatively, given that we're already breaking code >>with the change in the way complex numbers are handled, should cmp() now >>raise an exception *every* time the type/class differs? > > If you are referring to the comparision of complex numbers, I'm not >sure how the ordering would be done. For example consider 1 and 1j, >they have the same magnitude so mathematically speaking there is no >way to consistently order them like the real numbers where magnitude >is a more useful measure. IIRC, for any given magnitude n there are an >infinite number of complex numbers with that magnitude, namely all n*e^(ix) >for real x. True enough. Question is, in the Real World [tm], should everyone who calls list.sort() be forced to wrap in try/except on the chance that a pair of complex numbers will sneak in? -- --- 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 The problem with an ever-changing .sig is that you have to keep changing it From clayberg at instantiations.com Mon Feb 19 03:40:35 2001 From: clayberg at instantiations.com (Eric Clayberg) Date: Sun, 18 Feb 2001 21:40:35 -0500 Subject: Weird Language Features References: Message-ID: <96q137$q3d$1@nntp9.atl.mindspring.net> "Dave Cross" wrote in message news:nnhv8t4obq30ljfgseplp7pi4khhsf9g9n at 4ax.com... > > [Please watch the replies on this message as it's heavily > cross-posted] > > I'm doing some comparisons on programming language features and I'd be > very interested to know how you would handle the following scenarios > in your programming language of choice. > > 1/ The programmer calls a function that doesn't actually exist within > the application (or libraries). Is the a feature whereby the > programmer can create a "catch-all" function which is called in cases > like these? Can this function examine the list of existing functions > and call the most appropriate one? Or create a new function on the fly > and install it into the application? Smalltalk can do all of the above very easily. This general technique is used to create generic proxies, for example. I have also played around with "fault tolerant" apps that could automatically detect and correct spelling errors in function calls (as a lark; never in production code). > 2/ Can ou filter the input source code before compilation (or > interpretation) in some way so that language keywords could be changed > for other strings? Imagine you wanted to allow someone to program your > language of choice in, say, French. How would you go about translating > French keywords into ones that the compiler (or interpreter) could > understand. What if the translation wasn't one-to-one or fixed? Could > you put enough intelligence into the translator so that it could > handle certain strings differently depending on where they appeared in > the source code? Smalltalk can also do the above very easily. Everything is Smalltalk is an object - including the parser, the compiler, the compiled methods and the method source. Setting up a pre-processor or modifying the actual parser is very easy to do. Since all of Smalltalk's control structures are built in Smalltalk itself, you can easily alias any function name or operator to another. Enhancing the "syntax" and adding your own control structures is also trivial. > If you're wondering why I'm inventing these bizarre scenarios, it's > for a paper I'm writing for this year's Perl Conference. Perl does > have these features (see the AUTOLOAD function and source filters) and > I'm interested in seeing how widespread they are in other languages. > > Of course, if you'd like to tell me just why you consider it's a good > thing that your language of choice doesn't have these features, then > I'd be only too happy to hear that too. > > I'd just like to make it clear that I'm not interested in getting into > "my language is better than your language" types of flamewars. I'm > certainly not trying to argue that Perl is better than other languages > for having these features. > > Thanks for your time Thanks for the interesting thread. -Eric From thomas.heller at ion-tof.com Tue Feb 27 10:26:21 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Tue, 27 Feb 2001 10:26:21 +0100 Subject: ANN: eGenix.com mx Extensions -- Version 2.0.0 (mxODBC, mxDateTime, ...) References: <3A958CED.F7B95C33@lemburg.com> Message-ID: <97frrt$p1a5r$1@ID-59885.news.dfncis.de> "Paul Moore" wrote in message news:r7cg9toqrkgklmk6egokarju1g3mc9mei2 at 4ax.com... > On Thu, 22 Feb 2001 23:04:29 +0100, "M.-A. Lemburg" > wrote: > > >The download archives and instructions for installing the packages can > >be found at: > > > > http://www.lemburg.com/files/python/ > > One thing which would be nice would be a Win32 binary download, which > was NOT packaged using an installer. Just a zip file to be unzipped in > an appropriate place... > The windows installer (egenix-mx-base-2.0.0.win32-py2.0.exe) is more or less a self-extracting zip.file, which also can be opened with WinZip or other tools... Thomas From rvprasad at cis.ksu.edu Mon Feb 5 21:15:05 2001 From: rvprasad at cis.ksu.edu (Venkatesh Prasad Ranganath) Date: 05 Feb 2001 14:15:05 -0600 Subject: os.popen2 Message-ID: Hi, The following code stalls import os i = os.popen2("/bin/bash") i[0].write("ls -lR") i[1].read() -----------stalls here Am I missing something the way it should behave or isn't it possible to execute a process using popenX, keep it alive and interact with it? waiting for reply, -- Venkatesh Prasad Ranganath From aleaxit at yahoo.com Sat Feb 17 08:48:23 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 17 Feb 2001 08:48:23 +0100 Subject: Win32 COM: Passing NULL as a value References: <904A72E79williamwickerspectra@207.126.101.100> <3A8DBDC4.4040705@ActiveState.com> Message-ID: <96lag10eee@news2.newsguy.com> "Mark Hammond" wrote in message news:3A8DBDC4.4040705 at ActiveState.com... > William Wicker wrote: > > > I am trying to work via the COM interface to an object that exposes a > > method something like this: > > > > AnObject.DoSomething(doWhat, toWho) > > > > where toWho is either a dispatch pointer, or NULL, if toWho is not > > significant. > > > > When I try to do this with > > > > obj = win32com.client.Dispatch("AnObject") > > obj.DoSomething("kick", None) > > None is used to pass a variant with VT_NULL. It works for every object I have come across, so I am afraid I have no idea. If the AnObject used canonical API's to handle its arguments (VariantChangeType, directly or under the covers) it should indeed work -- a VariantChangeType from VT_NULL to VT_DISPATCH should succeed and give a VARIANT with pdispVal of 0. So, I guess from the symptoms described that AnObject is not being 'canonical' in its handling of arguments. Is there a way to prepare a VARIANT directly in Python, with VT_DISPATCH and pdispVal==0? When met with such issues in the past I used a little helper, an in-process COM server I wrote that supplies a few objects for explicit fine-grained issues of Automation ("prepare a variant with exactly this vt tag-part and exactly this bitpattern in its value-union part" being a good example). But Pythoncom looks like it's powerful enough to handle it directly if one digs deep enough, rather than needing an auxiliary C++ coded library of objects...? Alex From m.faassen at vet.uu.nl Mon Feb 12 00:18:26 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 11 Feb 2001 23:18:26 GMT Subject: Is Python for me? References: <20010210175216.26827.00000474@ng-mh1.aol.com> <3A85C996.9000504@hccnet.nl> Message-ID: <9676k2$brc$1@newshost.accu.uu.nl> Jaap Spies wrote: [snip] > Grow up! Miracles are of another World! Are you joking? What's the reason for such a weird response? I'm not used to such behavior on the Python newsgroup, so please adjust. There are many languages that more or less fulfill his criterions, and even if there weren't, you could respond in a more polite fashion. The PSU thanks you. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From porter at et.byu.edu Thu Feb 22 02:13:00 2001 From: porter at et.byu.edu (C. Porter Bassett) Date: Wed, 21 Feb 2001 18:13:00 -0700 (MST) Subject: Curses for Win32? In-Reply-To: <3A9449BB.284DC79B@iol.ie> References: <3A9449BB.284DC79B@iol.ie> Message-ID: I myself would love to have a python2.0 windows curses module, but nobody with the know-how seems to think that it is important. What you could do, though, is create a dummy module called curses. You say that you don't mind if it doesn't function. Just create dummy functions corresponding to the functions that your program calls. -------------------------------------------------------------------------- C. Porter Bassett porter at et.byu.edu http://www.cporterbassett.com -------------------------------------------------------------------------- "Pretend like this is a really witty saying." - Anonymous -------------------------------------------------------------------------- On Wed, 21 Feb 2001, Adam Lock wrote: > I have a Python 2.0 program that uses Tkinter and curses for display. It > works fine on Unix because there is a curses package but not on Win32 > because there isn't. Perversely even MacPython 2.0 has a curses package! > > Does anyone know if a curses package exists for Win32? I would even be > happy if it compiled but didn't function since I want will be using the > Tkinter UI anyway. > > Many thanks > > -- > Adam Lock - locka at iol.ie > -- > http://mail.python.org/mailman/listinfo/python-list > From jh at web.de Wed Feb 7 22:56:50 2001 From: jh at web.de (Jürgen Hermann) Date: Wed, 7 Feb 2001 22:56:50 +0100 Subject: Touch in python? References: <95sfla$adf$1@bunyip.cc.uq.edu.au> Message-ID: <95sg8e$mod$00$1@news.t-online.com> "Chui Tey" schrieb im Newsbeitrag news:95sfla$adf$1 at bunyip.cc.uq.edu.au... > Is there an equivalent of 'touch' in python? I would like to change the file > modified time. os.utime() From alet at unice.fr Tue Feb 20 17:05:43 2001 From: alet at unice.fr (Jerome Alet) Date: Tue, 20 Feb 2001 17:05:43 +0100 Subject: [ANNOUNCE] New version of the JAXML module References: <3A9128D8.35D0EE22@unice.fr> <3A92324B.3F7CD22D@unice.fr> Message-ID: <3A9295D7.9B2231AC@unice.fr> Gerhard H?ring wrote: > options. I might troll and say the GPL is less free than the BSD license, > but let's not start this flamewar again. No, it would be a very bad idea (tm) !-)) > Yes that's my point. If I use a GPL'd module the author forces me to GPL the > rest of my code. That's why using it restricts me. The LGPL would protect > *your* work, but wouldn't try to force *mine* under GPL, too. That's why I > prefer LGPL or BSD licensed libraries. yes but the LGPL wouldn't encourage you to write free software, since you'd be allowed to use it in a non free application. > Just to be clear: Of course I respect your licensing decision. You perfectly > know the implications of putting *libary* under the GPL. That's fine. I just > wanted to be sure. There's no problem. As mentionned by Martin above, I'm open to discussion ;-) bye, Jerome Alet From mmiller3 at iupui.edu Thu Feb 15 18:49:11 2001 From: mmiller3 at iupui.edu (Michael A. Miller) Date: 15 Feb 2001 12:49:11 -0500 Subject: while loop with f.readline() References: Message-ID: <874rxv4z1k.fsf@lumen.med.iupui.edu> > From: "Chris Richard Adams" > I'm trying to create a loop that reads through a simple > file with strings on each line. Take a look at the fileinput module: import fileinput for line in fileinput.input('filename'): process(line) From joconnor at cybermesa.com Mon Feb 26 17:59:34 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Mon, 26 Feb 2001 09:59:34 -0700 Subject: is and == References: <97e17a$o3o$1@panix6.panix.com> Message-ID: <3A9A8B76.777FCA6A@cybermesa.com> Aahz Maruch wrote: > In article , > Daniel Klein wrote: > > > >Is there a functional difference between 'is' and '==' ? If there is, I can't > >find it. > > >>> a = 'xy' > >>> b = a > >>> c = 'x' + 'y' > >>> d = 'xy' > >>> a is b > 1 > >>> a is d > 1 > >>> a is c > 0 > >>> a == c > 1 > > Essentially, is tests for object identity: are two variables pointing to > the same location in memory. == tests to see whether the *values* are > equal. Consider the following example >>> class TestVal: def __init__(self): self.x = 100 def __cmp__(self, other): return cmp (self.x, other.x) >>> x = TestVal() >>> y = TestVal() >>> x == y 1 >>> x is y 0 >>> x =y >>> x is y 1 x == y is true because I've defined what == means, a value comparison, but x is y is false because they are not both the same object. However by assign the variable x to be y, I now get true for "x is y" because they are now the same object Take care, Jay From sanner at scripps.edu Tue Feb 27 17:44:02 2001 From: sanner at scripps.edu (Michel Sanner) Date: Tue, 27 Feb 2001 08:44:02 -0800 Subject: [Distutils] Re: CPAN functionality for python - requirements In-Reply-To: Doug Hellmann "[Distutils] Re: CPAN functionality for python - requirements" (Feb 26, 10:45pm) References: <01022606501904.15046@branagan> <20010226183606.F7531@tummy.com> <01022623140707.15046@branagan> Message-ID: <1010227084403.ZM33944@noah.scripps.edu> Hi, I followed this discussion (probably not as much as I should have). We have setup a Python distribution site for the tools we have produced for computational biology. It is quite primitive but let's us distribute to "ready to go" packages as well as pre-compiled Python interpreters for some platforms to "non-wizard" users. One issue that we are strugling with is versions of packages.Is there a "standard" way to deal with versions ? how do you plan to find out whether someone has a compatible version of any given package ? -Michel On Feb 26, 10:45pm, Doug Hellmann wrote: > Subject: [Distutils] Re: CPAN functionality for python - requirements > On Mon, 26 Feb 2001, Sean Reifschneider wrote: > > On Mon, Feb 26, 2001 at 06:45:33AM -0500, Doug Hellmann wrote: > > >What if Python kept up with its own packages and modules like XEmacs does? We > > >could then use the same format on all platforms -- it might even be something > > >we roll ourself to make sure we can unpack it with *only* Python installed on a > > >platform. > > > > My understanding is that that's what distutils is meant to do, to an extent. > > The problem is that it's not entirely unreasonable to expect that an > > "rpm -qa" produce a list of all the software that's installed on your > > box. If you don't use an RPM, you can't really make use of that, and > > packages WILL get dropped after a re-install. > > The command "rpm -qa" only produces meaningful results on a system where RPM is > the default and primary package installation system. There are more OSes where > that is *not* the case (and where RPM isn't installed at all) than where it is. > > It still isn't clear to me why we would want to use more than one distribution > package format. It appears that one argument is so that sysadmins can use > those tools to track what is installed on the system. But isn't that part of > what this new thing (cyphon?) is supposed to do? Do we want Python to require > an external package management system on each platform where this tool is > supported, or do we want a Python-esq tool which just works the way it is > supposed to, in the same way, everywhere Python is available? > > But I think we're arguing over a design before we've worked out requirements. > The basic tasks of this new tool, as I see them, are: > > 1. Locate Python packages you want on the net. > 2. Resolve dependencies between what you want, what you have, and what you > need. > 3. Download the appropriate packages to give you what you want. > 4. Install those packages. > > Do we agree these are the primary features? > > I sense a consensus that the "install" part should be handled by distutils. Is > that right? > > Other requirements we might lay down up front: > > 1. Should run on all platforms where Python runs. > 2. Must support mirrors on the server side. > 3. Need to include documentation along with source for packages. > > The features related to dependencies and downloads could be handled by a > platform-specific packaging system, but integrating with all of the different > options on all of the different platforms where Python runs increases the > complexity of the new tool. (How do we handle RPMs on MacOS? How do we handle > HQX files on Win32? What about for Pippy, where files as such might not even > be appropriate? Does Jython have any special requirements?) Do we deal with > this complexity by deciding on a per-platform basis what format to use, or do > we force the user to specify the format they want downloaded? > > If we're modeling what we're doing based on CPAN, maybe we should look at > that design. What format does CPAN use when downloading Perl packages? What > features does CPAN have that we want? What does it not have that we want? > > Doug > > _______________________________________________ > Distutils-SIG maillist - Distutils-SIG at python.org > http://mail.python.org/mailman/listinfo/distutils-sig >-- End of excerpt from Doug Hellmann -- ----------------------------------------------------------------------- >>>>>>>>>> AREA CODE CHANGE <<<<<<<<< we are now 858 !!!!!!! Michel F. Sanner Ph.D. The Scripps Research Institute Assistant Professor Department of Molecular Biology 10550 North Torrey Pines Road Tel. (858) 784-2341 La Jolla, CA 92037 Fax. (858) 784-2860 sanner at scripps.edu http://www.scripps.edu/sanner ----------------------------------------------------------------------- From wayne.izatt at _nospam_myself.com Tue Feb 27 08:16:22 2001 From: wayne.izatt at _nospam_myself.com (Wayne Izatt) Date: Tue, 27 Feb 2001 07:16:22 GMT Subject: list to string References: <1103_983241679@cc462845-a> Message-ID: "glen mettler" wrote in message news:1103_983241679 at cc462845-a... > These commands will turn a string into a list: > myword="dog" > mywordlist=list(myword) > result = ["d","o","g"] > > is there a command/function that can take the list ["d","o","g"] and make it a string "dog"? >>> lst =["d", "o", "g"] >>> lst ['d', 'o', 'g'] >>> dog = lst[0]+lst[1]+lst[2] >>> dog 'dog' or is there something I'm not getting? cheers > > Glen > > > From jgraves3 at austin.rr.com Tue Feb 27 03:50:38 2001 From: jgraves3 at austin.rr.com (jay graves) Date: Tue, 27 Feb 2001 02:50:38 GMT Subject: list to string References: <1103_983241679@cc462845-a> Message-ID: <3a9b14c9.33237453@news-server.austin.rr.com> On Tue, 27 Feb 2001 02:42:12 GMT, glen mettler wrote: >These commands will turn a string into a list: >myword="dog" >mywordlist=list(myword) >result = ["d","o","g"] > >is there a command/function that can take the list ["d","o","g"] and make it a string "dog"? One way is to join them. ''.join(result) Some people don't like using the string methods in this way and they might write: (at least until the string module goes away.) import string string.join(result,'') Hope this helps. ... jay From hgg9140 at cola.ca.boeing.com Thu Feb 1 15:56:07 2001 From: hgg9140 at cola.ca.boeing.com (Harry George) Date: Thu, 1 Feb 2001 14:56:07 GMT Subject: Perl-to-Python converter/translator? References: <959jsd$njn$1@nnrp1.deja.com> Message-ID: I've done some perl-->python, and found (at first) that I missed some of the perl idioms. So I did a python module to support perl-ish idioms. See "pyperl" at: http://www.seanet.com/~hgg9140/comp/index.html It lets you pretty much read the perl code and write the python code on the fly. More tedious than true converter, but do-able. I agree with other posters that after you get into python's own idioms, you won't miss perl. Lance Sloan writes: > I'm an experienced Perl programmer who has just been assigned > a project that must be done in Python. I'm looking for a > Perl-to-Python translator to help me out. I don't expect to > write the whole project in Perl and translate it, though. I'm > just looking for some automation to help me see how my old work > could be done in Python. > > I didn't find anything useful via Google or Vaults of Parnassus > searches. So, I would appreciate any pointers! > > Thanks in advance. > > -- > Lance Sloan - lsloan00 at my-deja.com > > -- > Lance Sloan - lsloan00 at my-deja.com > > > Sent via Deja.com > http://www.deja.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 andrew at andrewcooke.free-online.co.uk Sun Feb 18 09:56:06 2001 From: andrew at andrewcooke.free-online.co.uk (Andrew Cooke) Date: Sun, 18 Feb 2001 08:56:06 +0000 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A8F8D9B.78B37578@andrewcooke.free-online.co.uk> Message-ID: <3A8F8E26.2D8D948F@andrewcooke.free-online.co.uk> Andrew Cooke wrote: [...] > For something faster, how about C++ (although all the above have > compilers and will be faster than C - what I mean here is a language [...] Sorry - faster than Python! (and I add "probably") (and the comment that speed isn't that important - I use and like Python myself) (and the comment that Python isn't that slow). OK? Andrew From sandipan at vsnl.com Tue Feb 6 15:35:10 2001 From: sandipan at vsnl.com (Sandipan Gangopadhyay) Date: Tue, 6 Feb 2001 20:05:10 +0530 Subject: smtp mail with attachment References: Message-ID: <00e001c0904a$02831aa0$020000c3@node02> AFAIK, and I could be ignorant, but you just have to construct the mail with MimeWriter: With content-type as multi-part (because the email will have more than one part (itself) - the attachment(s)) And then, in one of the parts, put in the attachment after declaring its type. Please note that if you are going to need to send binary attachments, base64 will come in use to encode it first. As in: Content-Type: whatever/whatever Content-Transfer-Encoding: base64 You can use smtplib to send the mime you have built then. Also, you can have other parts of the email refer to this attachment by giving it an identifier (URL sort of) Works fine on both Unix and Windows. HTH. Regards, Sandipan ----- Original Message ----- From: "Scott Hathaway" Newsgroups: comp.lang.python To: Sent: Tuesday, February 06, 2001 7:07 PM Subject: smtp mail with attachment > How do I send an email with an attachment with python (I need a cross > platform solution for Windows and Unix)? > > Thanks, > Scott > > > -- > http://mail.python.org/mailman/listinfo/python-list > From baasad at qualitynet.net Sat Feb 3 01:39:56 2001 From: baasad at qualitynet.net (bashar A. Asad) Date: Sat, 03 Feb 2001 03:39:56 +0300 Subject: help with python Message-ID: <95g8mv$ne21@news.qualitynet.net> hello ; since am new to python I would like to start my experience with a small project that will my life easier. I would like to connect to a remote linux machines and check for a certain process "may be useing a system command is their something like that in python??" eg. httpd if its up or not if it is up the program will produce an activity file or whatever... I have no idea how to start working on that in python..any hints guys :) thanx bashar From othello at javanet.com Wed Feb 21 01:17:03 2001 From: othello at javanet.com (Raymond Hettinger) Date: Tue, 20 Feb 2001 19:17:03 -0500 Subject: Proposal: allow '?' and '!' in identifiers References: <96sh22$jq5$1@news.mathworks.com> <96sp4s$ni7$1@news.mathworks.com> Message-ID: <3A9308FF.D07FB37F@javanet.com> > > >Introducing some strange behavior with '!' may very well not be worth > >it. However, while adding '?' as a legal identifier character does > >not make the Python more expressive, it can make Python programs more > >self-documenting. The convention of ending predicate function names > >with '?' is useful, in my opinion. > > Definitely. I always found that convention in Scheme to be > very expresive and compact. The convention of ending > predicates with "!" when they modified internal state was also > useful though perhaps not as intuitive as "?". > These naming conventions were useful to me iin Forth and Scheme; however, they're ugly (IMHO). The plain English forms are much more expressive and flexible without carrying the risk of confusing my optical lexer when I read code. Count my vote: -1 Raymond "In theory, there is no difference between theory and practice. In practice, there is." -- Yogi Berra From wware at world.std.com Sat Feb 24 13:23:09 2001 From: wware at world.std.com (Will Ware) Date: Sat, 24 Feb 2001 12:23:09 GMT Subject: where to learn python programing References: <9778so$725$1@news1.Radix.Net> Message-ID: On Fri, Feb 23, 2001 at 10:35:24PM -0500, Pastor Duke wrote: > I'm very interested in learning Python programming as I'm a 3D graphics > designer, and want to develop some games. William Park (parkw at better.net) wrote: > Standard answer is Tutorial which is part of standard docs. You can find this on-line at: http://www.python.org/doc/current/tut/tut.html Other useful stuff here, including the Library Reference: http://www.python.org/doc/current/ -- -----------------------------------+--------------------- 22nd century: Esperanto, geodesic | Will Ware domes, hovercrafts, metric system | wware at world.std.com From swun at esec.com.au Mon Feb 5 23:18:51 2001 From: swun at esec.com.au (Sam Wun) Date: Tue, 06 Feb 2001 09:18:51 +1100 Subject: sorting on IP addresses Message-ID: <3A7F26CB.BE85C96F@esec.com.au> Hi, Does anyone know what is the quickly way to sort a list of IP addresses? ie. 203.21.254.89 should be larger than 203.21.254.9 Thanks Sam From annis at biostat.wisc.edu Thu Feb 22 18:53:03 2001 From: annis at biostat.wisc.edu (William Annis) Date: 22 Feb 2001 11:53:03 -0600 Subject: Module rfc822 - uses file-objects - why? References: <3A954CA3.72A6D51C@gdp-group.com> Message-ID: Thomas Volkmar Worm writes: > Do I need to store every list/string > onto disk when I want to use these classes or methods on them? > > To solve the problem I started to write a helper class which implements > methods like readline for my objects, but I really do not want to write > an emulation of the file-class again and again for each object I create. You have solved a problem other people have had and solved already. The StringIO class -- part of standard Python -- can be used to make strings act like files: http://www.python.org/doc/current/lib/module-StringIO.html -- 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 jschmitt at vmlabs.com Thu Feb 15 04:46:19 2001 From: jschmitt at vmlabs.com (John Schmitt) Date: Wed, 14 Feb 2001 19:46:19 -0800 Subject: __contains__() Message-ID: <008F0A63472BD311AF9800104BCD102561CC8B@minirex.vmlabs.com> I did something a little cheezy. >>>class foo: def __contains__(self,n): return 42 >>>f = foo() >>>3 in f 1 I thought I would get back 42. The manual doesn't say that it must strictly return 0 or 1, just something true or false. I wonder what the PSU has to say about this. How does one become a memb From wilsoncredit at email.com Fri Feb 16 09:56:53 2001 From: wilsoncredit at email.com (wilsoncredit at email.com) Date: Fri, 16 Feb 2001 08:56:53 GMT Subject: ****SPECIAL REPORT**** Message-ID: --_NextPart_0000904A-000004CC-0388DEEA-5224 Content-Type: text/plain Content-Transfer-Encoding: 7bit Get a brand new, clean, credit file in 15 days or less... Get the credit you deserve... For more info, send a email to wilsoncredit at email.com with "INFO" in the subject line... --_NextPart_0000904A-000004CC-0388DEEA-5224-- From robin at jessikat.fsnet.co.uk Sat Feb 3 12:25:23 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 3 Feb 2001 11:25:23 +0000 Subject: nested scopes References: Message-ID: <467PpKAjq+e6EwFJ@jessikat.fsnet.co.uk> In article , Tim Peters writes >[Robin Becker] .... >WRT scopes, the determination of which names are local is entirely done at >compile-time. That wasn't always true, but has been true since version >0.9.9, and was the single biggest speedup in Python's history. The >determination of which names are local is still done at compile-time in the >presence of "import *" and "exec", but then the results can't be trusted, >and the compiler generates different code that does all sorts of crap under >the covers to give "the expected" results -- most of the time. I doubt that >crap will get extended to live nice with deeply nested scopes, though. > >> ... >> Optimality is the enemy of stability. > >in-america-they-tell-us-it's-drugs-ly y'rs - tim > > as I suspected this is about optimality; speed vs clarity/simplicity is the argument here. I guess that the nested scopes stuff has just brought it to the fore. Luckily we're not forced to use nested scopes in python, pascal experience makes me despise them because of all that paging up and down to find the defining declaration. -- Robin Becker From sl0op at my-deja.com Sat Feb 10 23:26:06 2001 From: sl0op at my-deja.com (sl0op at my-deja.com) Date: Sat, 10 Feb 2001 22:26:06 GMT Subject: Python compiler/installer? Message-ID: <964f5n$oqs$1@nnrp1.deja.com> Hi. I'm new to Python (which seems like a very nice language to me) and have a few questions. First, is there any way I can compile it so I don't have to send out any source code I don't want to? Are there any installers for either compiled-Python (if that exists) or simple .py files? And where can I find some examples of Python programs ?(some that will help me learn Tkinter.) Any help would be greatly appreciated. Thank you, Jason Sent via Deja.com http://www.deja.com/ From vasvir at iit.demokritos.gr Mon Feb 26 06:50:35 2001 From: vasvir at iit.demokritos.gr (Vassilis Virvilis) Date: Mon, 26 Feb 2001 07:50:35 +0200 Subject: abusing __builtins__ References: Message-ID: <3A99EEAB.C756064C@iit.demokritos.gr> Tim Peters wrote: > Cute! > > > The language doesn't guarantee this will always work, so it's certainly > abuse. Oups! That's the killer argument here. > > Looking up builtins is slower than looking up module globals (a module's > global dict is always searched before the builtin dict). certainly > The language may someday make "GlobalVariable" the name of its own builtin, > and then your code won't work correctly if you either try to use the new > builtin or call any other module that does (incl. without limitation std > library modules). This I don't get it. Why is that? GlobalVariable is just a name to indicate the purpose of my variable. If a newer version of python use it in a later stage as a reversed word (__builtins__ variable or function), then obviously my old program won't be able to use the new functionality but it will overwrite it happily. So it would work even then. Consider the following imaginary example. In a project where there is no need to open files one replaces the open function. So this project will never manage to open a file but aside from that it will continue to work as designed. > People other than you will be unable to understand your code regardless, > because GlobalVariable will look to them like an unbound variable (i.e., > nobody else uses this trick, so nobody else will recognize the usage > pattern). > > Introspective tools won't think to look in the builtins either (again > because nobody else etc). > Valid points too. Thank you and everybody else for your answers. I think I will try to avoid that trick anyway. .Bill From aahz at panix.com Mon Feb 26 20:35:15 2001 From: aahz at panix.com (Aahz Maruch) Date: 26 Feb 2001 11:35:15 -0800 Subject: Splitting comp.lang.python References: <79ym6.2288$TW.12847@tor-nn1.netcom.ca> Message-ID: <97eb5j$cpr$1@panix2.panix.com> In article <79ym6.2288$TW.12847 at tor-nn1.netcom.ca>, Warren Postma wrote: > >I mean, doesn't anyone search Deja anymore? Oh yeah, Deja is gone, and >replaced by the Beta Groups at groups.google.com. Oh well, ironically, now >that we have no Deja.com, I think we are in for a Lot More of that old time >Deja Vu. Well, at least until Google brings up the full DejaNews archive. I've heard that the initial estimate is on the order of three months. -- --- 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 "I used to have a .sig but I found it impossible to please everyone..." --SFJ From dsh8290 at rit.edu Wed Feb 14 19:29:55 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 14 Feb 2001 13:29:55 -0500 Subject: pth information Message-ID: <20010214132954.A17229@harmony.cs.rit.edu> I was searching through the documentation on python.org, but couldn't find anything describing the usage and syntax for .pth files. All I managed to find was a brief mention of their existence in some extension modules in section 3.23 of the Library Reference. Could someone point me in the right direction? (Or explain here if you feel inclined to do so) Thanks, -D From j.spies at hccnet.nl Mon Feb 12 16:26:12 2001 From: j.spies at hccnet.nl (Jaap Spies) Date: Mon, 12 Feb 2001 16:26:12 +0100 Subject: Is Python for me? References: <20010210175216.26827.00000474@ng-mh1.aol.com> <3A85C996.9000504@hccnet.nl> <9676k2$brc$1@newshost.accu.uu.nl> Message-ID: <3A880094.6060906@hccnet.nl> Martijn Faassen wrote: > Jaap Spies wrote: > [snip] > >> Grow up! Miracles are of another World! Are you joking? > > > What's the reason for such a weird response? I'm not used to such > behavior on the Python newsgroup, so please adjust. There are many languages > that more or less fulfill his criterions, and even if there weren't, > you could respond in a more polite fashion. The PSU thanks you. > > Regards, > > Martijn You'r right! I was a bit short (tempered). But I don't agree that there are many languages (and environments) that fulfill the stated criterions. If any. Python will be close. I followed the thread and I admire all the kind answers. Please accept my apologies. Jaap Spies From fredericbonnet at free.fr Wed Feb 21 11:19:28 2001 From: fredericbonnet at free.fr (Frederic BONNET) Date: Wed, 21 Feb 2001 10:19:28 GMT Subject: Linda, this is cool! References: <33Z6UBPU36939.943275463@frog.nyarlatheotep.org> <96mv3102l3d@news2.newsguy.com> <21gu8tsoknv01eegt4jak2lo7180kijno5@4ax.com> <3A90FAD9.B54BCFF6@cs.man.ac.uk> <3A939540.19FB5346@free.fr> Message-ID: <3A939613.2A32E483@free.fr> Oh, and this one, too: General Massu: "One should eliminate all the idiots" De Gaulle: "Vast program..." -- Fr?d?ric BONNET fredericbonnet at free.fr --------------------------------------------------------------- "Theory may inform, but Practice convinces" George Bain From greg at cosc.canterbury.ac.nz Fri Feb 16 04:24:14 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 16 Feb 2001 16:24:14 +1300 Subject: __contains__() References: Message-ID: <3A8C9D5E.9AEBECB7@cosc.canterbury.ac.nz> John Schmitt wrote: > > The manual doesn't say that it must strictly > return 0 or 1, just something true or false. Which is what you're doing, and it's interpreting it as "true". It also doesn't say that "x in y" will return the exact value returned by y's __contains()__ method, either. The reason is that, internally, it's being funneled through the C version of the __contains__ method in the typeobject, which returns a C int, not a general Python object. The interpreter then converts that into a canonical Python boolean value. -- 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 dave at dave.org.uk Sun Feb 18 18:24:19 2001 From: dave at dave.org.uk (Dave Cross) Date: Sun, 18 Feb 2001 17:24:19 +0000 Subject: Weird Language Features References: <3iTj6.1813$E41.169931@news.uswest.net> Message-ID: On Sun, 18 Feb 2001 09:09:20 -0800, "Robert Hand" wrote: >> >> If you're wondering why I'm inventing these bizarre scenarios, it's >> for a paper I'm writing for this year's Perl Conference. Perl does >> have these features (see the AUTOLOAD function and source filters) and >> I'm interested in seeing how widespread they are in other languages. >> >Really? Thats great! If you can do it in perl, you can probably implement >it in java. >I'm not a perl expert. Is the perl source code translation a function of >perl or a separate app? >if it's a separate app, handling ascii input, give me a link. It's a separate library that gets to see the source code before it's compiled. For an (admittedly extreme) example of what you can do see: Which discusses a filter allowing you to write Perl programs in Latin! Cheers, Dave... -- SMS: sms at dave.org.uk From donn at u.washington.edu Wed Feb 21 19:40:57 2001 From: donn at u.washington.edu (Donn Cave) Date: 21 Feb 2001 18:40:57 GMT Subject: locking files References: <96v06a$l16$1@solaria.cc.gatech.edu> <970kg2$cn0$1@solaria.cc.gatech.edu> Message-ID: <97123p$ojg$1@nntp6.u.washington.edu> Quoth Joseph Holland King : | Joseph Holland King wrote: | : is there anyway to lock a file so that two different programs cannot access | : the file at the same time. ie, my python module is editting file foo, and | : at the same time user x (or program x) tries to read from it. is there | : anyway that the python module can prevent x from accessing the file for | : a given amount of time? | | to clarify: i am on a unix system, i have tried to use flock however when i | locked the file i was still able to read, write and copy the file, none of | which i want to happen while the file is locked. while using the flock | method i was using LOCK_EX. also the third party program is not going to be | controlled, written, or have anything to do with mine. am i just not using | flock properly or is there something else that might do the job? thank you. Basically, that's how file locking works. It's advisory, for the benefit of software components that are designed to work together. But there is a variation that you can find supported on some filesystems, where in combination with an obscure permission mode on the file the lock becomes mandatory and effective against any and all I/O. The permission trick is setgid & not group execute, i.e., (oldperm | 02000) & ~010. It works for me on Digital UNIX local (AdvFS) filesystem. I didn't try on NFS, but from the documentation I doubt that it will work there. It does not work on NetBSD 1.5 local filesystem. Where it does work, you must use fcntl() or lockf() to obtain the lock, not a genuine flock(). While I'm here, let me add a little note about flock(), for the benefit of those whose UNIX platforms don't have the deluxe man pages that you get on NetBSD for example. There are two kinds of locks, one obtained by Berkeley flock() and the other by POSIX 1003.1 fcntl(). The lockf() function is a different, X/Open interface that interoperates with fcntl(). Many modern platforms do not support a genuine flock(). Some of them provide an flock() function that is actually implemented with fcntl(), which means that the semantics of the lock are per fcntl() and not flock(). Python follows this trend and does the same thing if there's no flock(2), so it's up to the programmer to find out what kind of lock fcntl.flock() really gets, if the difference is important. Donn Cave, donn at u.washington.edu From fredrik at effbot.org Mon Feb 5 02:03:35 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Mon, 05 Feb 2001 01:03:35 GMT Subject: How do I know all thrown exceptions of a function? References: <94d93h$55d$1@troll.powertech.no> <3A6B24F0.EA164698@gte.net> <94icr2$6kv$1@animus.fel.iae.nl> <3A6CDBDA.C3120F98@gte.net> <94ipci$afo$1@animus.fel.iae.nl> <3A6CFD8E.BD473DFD@gte.net> <3A6D54CB.2261D535@gte.net> <94jo9u$h45$1@nnrp1.deja.com> <94jt7e01fil@news1.newsguy.com> Message-ID: Pekka Pessi wrote: > >might so be, but I still cannot make any sense of his post. > > He says that according to the docs, "from tkinter include *" should > be used instead of "include tkinter". The latter adds lot of > unnecessary text, ie. cruft, into your program. Cruft makes your > code harder to read. umm. *I* wrote the part on Tkinter, and I'm pretty sure I know what I meant with the original text. still don't know what Steve meant, and frankly, I don't really care. Cheers /F From guido at digicool.com Wed Feb 28 23:54:18 2001 From: guido at digicool.com (Guido van Rossum) Date: Wed, 28 Feb 2001 17:54:18 -0500 Subject: Python webring is dead Message-ID: <200102282254.RAA31089@cj20424-a.reston1.va.home.com> There used to be a Python webring. But from the following exchange, I see it is dead. If someone wants to create a new one, please go ahead -- if you let webmaster at python.org know, we'll add python.org to the ring. --Guido van Rossum (home page: http://www.python.org/~guido/) ------- Forwarded Message Date: Wed, 28 Feb 2001 23:02:19 +0000 From: Manuel Gutierrez Algaba To: Guido van Rossum Subject: Re: Random python site On Mon, 26 Feb 2001, Guido van Rossum wrote: > > I'm the current maintainer of the Python ring. I've lost control of > > my Yahoo account. That is, I've lost any control over the python > > ring. I'd suggest you to create a new ring. > > > > If you don't trust me try to add a new site to the ring. Or just > > watch when was the last adding to the ring ? > > Much more than 3 months. > > > > Sorry for my incompetence. > > Sorry, I'm not interested in taking up more work. If you want to > create a new ring, that's fine. Otherwise, we'll just drop the link. > > --Guido van Rossum (home page: http://www.python.org/~guido/) > Then, please, drop the link, forward this to comp.lang.python to try if anybody is interested or just leave it, but knowing it's a no-end road. - --- Regards/Saludos Manolo http://spain.50g.com ------- End of Forwarded Message From nvithadt at bellsouth.net Wed Feb 7 14:48:51 2001 From: nvithadt at bellsouth.net (nvithadt at bellsouth.net) Date: Wed, 7 Feb 2001 08:48:51 -0500 Subject: using external dll's in Python 2.0 Message-ID: Hey folk, I want to be able to use some 3rd party dll in a python 2.0 program I'm writing. I've searched through the message threads and came across a solution using something called calldll that was available on the parnassus(sp?) site. However, this seems to over useful for python 1.5 . After modifying the makefile script and using vc++ 6.0 I can get a calldll.pyd to be created but whenever I try to import it into my project python dies. I'm fairly new to python as well. I was hoping maybe in the win32 extension libraries there would be some info but alas no. There is LoadLibrary and GetProcAddress but seems to be no way to execute a function pointer. I really would hope I do not have to write a python extension module since there are a lot of functions in the dll's that I would like to use. TIA, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From wilson.austin.aj at bhp.com.au Mon Feb 19 20:36:03 2001 From: wilson.austin.aj at bhp.com.au (Austin Wilson) Date: Tue, 20 Feb 2001 06:36:03 +1100 Subject: Problem with py2exe Message-ID: <96rsie$dsc$1@gossamer.itmel.bhp.com.au> Hi I am trying to freeze a program using py2exe 0.2.2. However, I am getting the following output. Can anyone help. BTW: I am using Python20 and PIL 1.1.1 on Win98. Thanks Austin Resolving binary dependencies: Traceback (most recent call last): File "buildwatcher.py", line 6, in ? scripts=["watcher.py"], File "c:\program files\python20\lib\distutils\core.py", line 138, in setup dist.run_commands() File "c:\program files\python20\lib\distutils\dist.py", line 829, in run_commands self.run_command(cmd) File "c:\program files\python20\lib\distutils\dist.py", line 849, in run_command cmd_obj.run() File "py2exe\py2exe.py", line 354, in run dlls, unfriendly_dlls = self.find_dependend_dlls(use_runw, dlls) File "py2exe\py2exe.py", line 464, in find_dependend_dlls alldlls, warnings = bin_depends(loadpath, images) File "py2exe\py2exe.py", line 674, in bin_depends for result in py2exe_util.depends(image, loadpath).items(): py2exe_util.bind_error: tcl83.dll From me at nospam.net Sat Feb 24 21:13:23 2001 From: me at nospam.net (Scottie) Date: Sat, 24 Feb 2001 12:13:23 -0800 Subject: Weird Language Features References: Message-ID: The "Mesa" language (used as a system language at Xerox Parc in the 70s) allowed this same fully general exception/interrupt structure. their experience, after a number of years, was that it did not work out so well. Finally, they looked at all of their code, found almost all of the uses of "fix and continue" could be easily converted to the same kind of mechanism that Python now uses. Of the few (five, as I recall) remaining instances, one had a bug. So, the last few were rewritten and the feature was removed from the language. "Sean 'Shaleh' Perry" wrote in message news:mailman.982608802.22541.python-list at python.org... > On Sun, Feb 18, 2001 at 01:16:49PM +0000, Dave Cross wrote: > > ...1/ The programmer calls a function that doesn't actually exist within > > the application (or libraries). Is the a feature whereby the > > programmer can create a "catch-all" function which is called in cases > > like these? Can this function examine the list of existing functions > > and call the most appropriate one? Or create a new function on the fly > > and install it into the application? > ...python will throw an exception, the code could then decide that the > exception was due to a missing function and decide how to deal with it. > I suspect this could be useful in really restricted areas, but in general > code it strikes me as horribly confusing. -Scott From bobhicks at adelphia.net Thu Feb 1 19:27:14 2001 From: bobhicks at adelphia.net (Robert L Hicks) Date: Thu, 01 Feb 2001 18:27:14 GMT Subject: function attributes are like function objects References: <3A78AE8D.C9D25694@cosc.canterbury.ac.nz> Message-ID: > From: "Fredrik Lundh" > Organization: Telia Internet > Newsgroups: comp.lang.python > Date: Thu, 01 Feb 2001 17:22:45 GMT > Subject: Re: function attributes are like function objects > > Michael Hudson wrote: >>> What's so special about functions that we need to >>> be able to plonk arbitrary attributes on them, but >>> not any other builtin types? >> >> The fact that people were using the one attribute they could get at >> (__doc__) for things far from its original purpose? > > well, if people are too lazy to write > > def f(...): > ... > a[f] = "something" > > do you really think they'll find it much easier to write: > > def f(...): > ... > f.a = "something" > > (fwiw, I think function attributes is about the dumbest > thing we've added to python lately -- face it, "because > we can" isn't a very good argument when deciding what > to add to the language core...) Was that the rational? Let's add it because we can? From MarkH at ActiveState.com Wed Feb 14 00:07:29 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 13 Feb 2001 23:07:29 GMT Subject: Please Help: COM Events References: <96c7de$mb9$1@bob.news.rcn.net> Message-ID: <3A89BD4F.3040708@ActiveState.com> Ben Shapiro wrote: > Seems to me that when the event handler is called, the argument passed in > loses it's type as a JabberMsg and becomes a generic Dispatch object > so i can't call properties or methods on it.. Is there any way to cast the > argument back to a JabberMsg object? You should be able to say: Msg = win32com.client.Dispatch(Msg) However, event handlers are supposed to do this for you automatically. Hrm. No time to investigate ATM - I am busy adding support for vtable implemented interfaces to win32com ;-) Mark. -- Nominate Your Favorite Programmers for the Perl and Python Active Awards! http://www.ActiveState.com/Awards/ From jhylton at my-deja.com Fri Feb 9 20:48:00 2001 From: jhylton at my-deja.com (Jeremy Hylton) Date: Fri, 09 Feb 2001 19:48:00 GMT Subject: PEP status and python-dev summaries References: <3dg0hn8zlr.fsf@ute.cnri.reston.va.us> Message-ID: <961hhc$gp1$1@nnrp1.deja.com> In article <3dg0hn8zlr.fsf at ute.cnri.reston.va.us>, Andrew Kuchling wrote: > Should the full text of PEPs be posted at some point? I think the text would be too long to post directly. A URL should be sufficient. -- -- Jeremy Hylton, Sent via Deja.com http://www.deja.com/ From aleaxit at yahoo.com Sat Feb 24 17:37:34 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 24 Feb 2001 17:37:34 +0100 Subject: Suffering For Your Art References: Message-ID: <978oih02b74@news1.newsguy.com> wrote in message news:a8bd9tkvianmkqtg5c3qg33i8igq47n6kj at 4ax.com... [snip] > >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 ... > > Other environments allow the true computer geeks to flex their brain > muscles, in an attempt to impress the intellectually-poor masses. So does Python (I'm guilty of my share of "clever" solutions posted to this group), but in Python's case it's clearer that "being clever" is a temptation to be *wisely resisted* -- that "the simplest thing that can possibly work" is the RIGHT way to go (and I try to recall to point this out just about every time I come up with "cleverness" that would likely be a very bad idea to use in production code...:-). Alex From m.faassen at vet.uu.nl Wed Feb 28 00:43:32 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 27 Feb 2001 23:43:32 GMT Subject: ANNOUNCE: Python - The RPG Message-ID: <97he34$jhc$1@newshost.accu.uu.nl> Python - The RPG The Hype A Python role playing game! Play your favorite Python community member! While said member watches! Travel through time! Save the planet! The Scenario The aliens are not expected to unleash their whitespace eating nanovirus to Earth for decades, right? There is no Python Secret Underground trying to put a stop to this, right? When? Where? This is to be determined. Tentative time is the evening of wednesday the 7th of january. Participants * Benevolent Dictator For the Game (BDFG) * A number of Players playing Characters * Members of the public (if sufficiently quiet) Sounds Great! How can I play? Mail the BDFG at m.faassen at vet.uu.nl with a convincing explanation on why you want to play a particular character. Don't mail him after sunday; it's no use -- talk to him at the conference. Playing yourself is illegal; you have to pick someone else. Write-in characters are allowed and encouraged, if you can convince the BDFG. If you don't get to play a character, never fear; members of the public have voting rights if deemed Worthy. The use of humor is a good way to convince the BDFG. Cast of Possible Characters Suggestions for new characters and/or character attributes are welcome. If people feel offended, sprinkle the following generously with smileys and in your mind. Yes, you can play any of these characters and others, if you manage to convince the BDFG. The advantages and disadvantages are expected to be roleplayed, mainly. They may also influence people's voting patterns during task resolution (see the rules section). Guido van Rossum (AKA BDFL) Advantages: * BDFL. Other Python Community Members will tend to listen to Guido. Guido can tell them what to do, and especially what they shouldn't do. When team members are deciding on an action, Guido can vote -1, thereby overruling the team members (note that this does not affect success determination, just whether the team will try something). * Access to time machine. Years ago Guido received a mysterious envelope containing the complete plans to a working time machine. He uses it mainly to implement features for Python before they're even suggested on comp.lang.python. Of course, the PSU uses it as well. Disadvantages * Dutch Bluntness. His Dutch bluntness may be a disadvantage when negotiating with NPCs. Tim Peters (AKA the timbot) Advantages: * Channeling Guido. Whenever Guido is absent, Tim Peters can Channel Guido. Tim can use this to gain extra authority over any Python Community Member. Tim can vote the overruling -1 in the absence of Guido. * Invisibility. Tim can turn invisible for a short while, allowing him to hide his secret identity, and to attend IPC8 (last year's Python conference) without being seen. Disadvantages: * Robot. Tim's secret identity is that he's a robot, which may shock some people. Not just an android robot like the effbot and the martellibot -- those look like real people. No, the timbot is a genuine lumbering metallic robot with blinking lights, and a heap of Perl scripts running the innards. * Distracted by side issues. Tim can go on at length on issues which are not really the core of the problem, complicating said problem for himself and everybody else. Fredrik Lundh (AKA the effbot) Advantages: * Gadgeteer. A problem? The effbot can frequently construct a small gadget to solve it, often enlightening people in the process. Disadvantages: * Grouchiness. The effbot does not suffer fools gladly. This may may complicate his interaction with some NPCs, as well as other team members. Alex Martelli (AKA the martellibot) Advantages: * His erudite, knowledgable and *lengthy* discourse. This will either convince NPCs, or otherwise make them fall asleep (which in the case of enemies is good). Disadvantages: * Erupts into berserker rage when reminded of the print >> syntax. Jim Fulton Advantages: * Engineering. Ability to understand and build amazingly complicated machinery. 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. Christian Tismer Advantages: * Can accomplish the impossible by changing the meaning of truth. Mystic ability influencing the fabric of reality. * Inspired Koreans. Christian can inspire hundreds of Koreans to the Pythonic cause. This should come in handy for something. Disadvantage: * A hard time explaining to other people what he's doing, or convincing them. Particilarly Guido. Rules The style of play is very light on actual rules. The only mechanical thing that may sometimes occur is task resolution by voting. Whenever a character wants to accomplish some task in the game, the BDFG decides whether success is trivial or not. For trivial success (for instance, adding simple a bug fix to the standard Python library) or trivial failure (for instance, adding a Perl style $ to the Python language) the BDFG just says whether something succeeds or fails, and that's all there is to it. In case of non-trivial success or failure, the BDFG has the option to put the resolution to a vote. In a vote each player can issue one vote, -1, 0, and +1. The BDFG can vote as well. If the total vote count is above 0, the action succeeds. If it's negative, the action fails. If it's exactly 0, a coin is tossed to determine success. If there is a public, members of the public who are deemed Worthy by the BDFG can participate in the voting process. Members of the public who are too loud at critical moments will likely not be deemed Worthy. Finally, if the BDFG thinks it's necessary, the BDFG can overrule the outcome of the vote. References The PSU's Existence Revealed http://groups.yahoo.com/group/python-list/message/66070 Roswell: The Truth http://groups.yahoo.com/group/python-list/message/87088 Python Labs moves to Digital Creations http://groups.google.com/groups?q=Roswell&rnum=2&seld=971292152&ic=1 Status of the PSU http://groups.google.com/groups?q=alien+whitespace&seld=941359988&ic=1 do-I-really-want-to-post-this-oh-well-here-goes-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From nyp at njc.ch Sun Feb 25 07:26:06 2001 From: nyp at njc.ch (Yves Perrenoud) Date: Sat, 24 Feb 2001 22:26:06 -0800 Subject: Threading problems with SWIG generated code Message-ID: <3A98A57E.49EBCE99@njc.ch> I've ran into some problems when trying to use multiple threads which make use of modules generated with SWIG. Here's the shortest example I could come up with to illustrate the problem: Given the following SWIG interface file: ---- %module blip unsigned int sleep(unsigned int seconds); ---- I generate the C code using "swig -python", compile it and generate the shared library. Here's some sample code using the newly generated "blip" module: ---- import threading, blip def foo(): blip.sleep(5) threading.Thread(target=foo).start() threading.Thread(target=foo).start() ---- You would expect this function to run for a total of approximately 5 seconds, but instead, it runs for 10 seconds! Clearly, the sleep function calls are running one after the other, when they should be running in parallel. It's almost as if I was acquiring a lock before the sleep and releasing it afterwards. Any idea what's causing this? ..Yves From mix77 at usa.net Thu Feb 8 10:26:38 2001 From: mix77 at usa.net (Mix) Date: Thu, 8 Feb 2001 11:26:38 +0200 Subject: CGI-Python Image viewing Message-ID: <95tp4p$bev$1@ctb-nnrp2.saix.net> I am new to CGI scripting AND Python. What I am trying to do is, display an image on an html page that has been retrieved from a Postgre database using Python (cgi). My problem is : that image that not show up on the page, regardless of where it is sitting on my html or cgi directory! (I am running Apache Web server under Redhat 7.0 with the default linux kernel). But, I CAN display the image on a plain html page (i.e without the scripting). Please help! Thanks From echuck at mindspring.com Fri Feb 2 19:53:27 2001 From: echuck at mindspring.com (Chuck Esterbrook) Date: Fri, 02 Feb 2001 13:53:27 -0500 Subject: Comparison oddities Message-ID: <5.0.2.1.0.20010202134528.05141ad0@mail.mindspring.com> It appears that tuples and strings are "greater than" lists. >python ActivePython 2.0, build 202 (ActiveState Tool Corp.) based on Python 2.0 (#8, Oct 19 2000, 11:30:05) [MSC 32 bit (Intel)] on win32 >>> a = (1, 1) >>> b = [1, 1] >>> a < b 0 >>> a > b 1 >>> a==b 0 >>> a = '1' >>> a < b 0 >>> a > b 1 Does this seem a little odd to anyone? Since tuples and lists are both "sequences of anything", you would hope that they would compare in "the natural fashion". Since comparing a string and a list doesn't make sense, would an exception be more appropriate? And yes, I know the manual says "Otherwise, objects of different types *always* compare unequal, and are ordered consistently but arbitrarily. ... In the future, the comparison rules for objects of different types are likely to change." My question is more of a design question. -Chuck From mrq at for.mat.bham.ac.uk Thu Feb 8 18:38:19 2001 From: mrq at for.mat.bham.ac.uk (Martyn Quick) Date: Thu, 8 Feb 2001 17:38:19 +0000 Subject: Some basic questions about Tkinter (and Python) In-Reply-To: <5A26DA93165A7B85.352CA80CD738363E.9B52D4C723B787A0@lp.airnews.net> References: <7mdg6.13217$AH6.1992583@newsc.telia.net> <5A26DA93165A7B85.352CA80CD738363E.9B52D4C723B787A0@lp.airnews.net> Message-ID: On 7 Feb 2001, Cameron Laird wrote: > So I guess the answer is that we don't have a > Tkinter intro for those new to Python ... Per- > haps it's best to recommend that Mr. Quick > simply buy John Grayson's book without more > delay. You're not the first person to recommend me this book on this newsgroup. Unfortunately, we don't seem to have it in the library at the university where I work, as otherwise it would be in my hands by now. I know you say buy the book, but I can't afford that - perhaps you earn more than I do? I have a friend who is a computer programmer (and definitely earns more than I do ;-) who recommended that I give python a try. He is going to lend me his copy of a book on python on Saturday - Hammond & Robinson, "Python Programming on Win32". I don't know whether this has sufficient info on Tkinter to help, but it's about the only non-online source that I can get hold of. 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 danielk at aracnet.com Sun Feb 4 17:20:24 2001 From: danielk at aracnet.com (Daniel Klein) Date: Sun, 04 Feb 2001 08:20:24 -0800 Subject: While everyone is saying what they want in Python :) References: <3A7D64D8.74E71826@cybermesa.com> Message-ID: <3iuq7t06864beg5hpg1tjcbvo1m1uq81iv@4ax.com> On Sun, 04 Feb 2001 14:19:04 +0000, Jay O'Connor wrote: >Smalltalk-style cascade operations would be *very* cool > >win = GtkWindow(); > set_title("Hello World"); > set_name ("window"); > set_usize (400,200) > >versus > >win = GtkWindow() >win.set_title("Hello World") >win.set_name ("window") >win.set_usize (400,200) That's cos Smalltalk returns 'self' by default when a there is no explicit return value. This can be done in Python if your 'set' methods return 'self' instead of 'None'. For example: >>> class A: def m1(self, t1): self.t1 = t1 return self def m2(self, t2): self.t2 = t2 return self def m3(self, h, w): self.h = h self.w = w return self >>> a = A().m1("Hello World").m2("window").m3(400,200) >>> a.h 400 pythonic-ly yr's, Daniel Klein Portland OR USA From jwbnews at scandaroon.com Fri Feb 23 06:16:19 2001 From: jwbnews at scandaroon.com (John W. Baxter) Date: Thu, 22 Feb 2001 21:16:19 -0800 Subject: bug in string.join()? References: <4o589tsg0u2irh8mtds3u6kn05mvd35dao@4ax.com> <973bqv$iub$1@m1.cs.man.ac.uk> <3A941827.20C9F0F9@deprince.net> Message-ID: In article , "Tim Hochberg" wrote: > Death to map! Use list comprehensions instead. As soon as my 1940s brain comprehends them. ;-) --john -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From bwilk_97 at yahoo.com Sun Feb 11 02:42:35 2001 From: bwilk_97 at yahoo.com (Bill Wilkinson) Date: Sun, 11 Feb 2001 01:42:35 GMT Subject: Python compiler/installer? References: <964f5n$oqs$1@nnrp1.deja.com> Message-ID: | Hi. I'm new to Python (which seems like a very nice language to me) and | have a few questions. First, is there any way I can compile it so I | don't have to send out any source code I don't want to? It compiles to byte code. But the persistant can get to it if they want. It decompiles quite nicely. :) |Are there any installers for either compiled-Python (if that exists) or simple .py | files? For windows only: http://starship.python.net/crew/theller/ (Thanks Thomas!) For windows and Linux: http://starship.python.net/crew/gmcm/distribute.html |And where can I find some examples of Python programs ?(some | that will help me learn Tkinter.) The best way to learn Tkinter IMHO is to read /F's tutorial, It's righteous. http://www.secretlabs.com/library/tkinter/introduction/index.htm From d98aron at dtek.chalmers.se Fri Feb 9 15:06:52 2001 From: d98aron at dtek.chalmers.se (Fredrik Aronsson) Date: 9 Feb 2001 14:06:52 GMT Subject: What is better, JPython or Jython? References: <981723867.586455890@news.t-online.de> Message-ID: <960ths$40u$1@nyheter.chalmers.se> Jython is the mantained, new release of JPython. They have changed name because CNRI have a trademark (or something) on the name JPython. /Fredrik In article <981723867.586455890 at news.t-online.de>, Zamurai writes: > It seems that JPython and Jython are quite similar, but what are the > differences between both? And which one is better? -- From clarence at netlojix.com Sun Feb 4 22:11:57 2001 From: clarence at netlojix.com (Clarence Gardner) Date: Sun, 4 Feb 2001 13:11:57 -0800 Subject: Please translate this easy snip of C++ to Python References: Message-ID: <981321451.86433377@news.silcom.com> On Sun, 04 Feb 2001, chris at onca.catsden.net wrote: >On 4 Feb 2001, Phlip wrote: [C debugging macro snipped] >Try this: > >def TRACE ( str ): > print "%s: %s" % ( str, eval(str) ) > >TRACE('y+z') >TRACE('strAnimals') > >Sorry... you /do/ need to put the parameters in quotes, so Python doesnt >try to evaluate them before calling TRACE You also need to provide the TRACE function with the caller's local namespace, or TRACE will, in general, get NameErrors. def TRACE(str, locals): print "%s: %s" % (str, eval(str, globals(), locals)) and call it like TRACE('y+z', locals()) (I know I'm stomping on a predefined function name in TRACE, but I have no problem with it in this case.) -- Clarence Gardner Software Engineer NetLojix Communications clarence at netlojix.com From erno-news at erno.iki.fi Sun Feb 4 19:46:37 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 04 Feb 2001 20:46:37 +0200 Subject: Q: shelve ovewrites for different users References: Message-ID: In article , Jan Kybic writes: | I am sharing the shelve file between two users on Unix. are your two different users reading and writing it at the same time? if so, problems are to be expected. you need to either 1) set up locking manually, there are some functions in the fcntl module to do that, or 2) use gdbm for the shelf object (gdbm does locking itself): copy the DbfilenameShelf class from shelve.py and change "anydbm" to "gdbm". -- erno From k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m Wed Feb 14 17:41:01 2001 From: k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m (Keith Ray) Date: Wed, 14 Feb 2001 16:41:01 GMT Subject: python interpreter in smalltalk References: <9579gr$g0jjg$1@ID-65212.news.dfncis.de> <95abs4$g1nic$1@ID-65212.news.dfncis.de> <95coka$hp3$1@nnrp1.deja.com> <7MGJOov0nvx+VW3xYgkmsmMz2tDQ@4ax.com> Message-ID: In article <7MGJOov0nvx+VW3xYgkmsmMz2tDQ at 4ax.com>, sma at 3plus4.de wrote: > On Sat, 03 Feb 2001 02:57:36 GMT, Keith Ray > wrote: > > >Has anyone tried to write a Python interpreter in Smalltalk? > > I tried this, although using Squeak Smalltalk not Dolphin Smalltalk. > I never finished the project but there's a partially working parser > which I could share. > > bye > -- > Stefan Matthias Aust____Truth until Paradox!____________________ > Jobs? ==> jobs at baltic-online.de www.baltic-online.de I have the desire to see Python running inside Squeak . I was planning to start porting from the Jython sources, since those are already in an object oriented language (Java). If you could, please email your parser to me and it will help me learn how Squeak could host a Python language. C. Keith Ray remove spaces to get my email address c k e i t h r a y @ h o m e . c o m -- From dsh8290 at rit.edu Wed Feb 21 18:10:06 2001 From: dsh8290 at rit.edu (D-Man) Date: Wed, 21 Feb 2001 12:10:06 -0500 Subject: A simple (newbie) question. In-Reply-To: <9VRk6.116$DT7.616555@newsserver.ip.pt>; from man_at_moon@hotmail.com on Mon, Feb 19, 2001 at 08:08:42PM +0000 References: <9VRk6.116$DT7.616555@newsserver.ip.pt> Message-ID: <20010221121006.A23949@harmony.cs.rit.edu> On Mon, Feb 19, 2001 at 08:08:42PM +0000, David A. wrote: | Hello to everyone, | | maybe I have already sent this question to the group, but I am not sure | (the first one never reached the group I think). Anyway, I am a newbie, so | probably my question is a realy simple for the most experienced python | users. | | Well what I want to is this: | >>> a='python' | >>> b='print' | >>> c=b+a | >>> eval(c) | Traceback (innermost last): | File "", line 1, in ? | eval(c) | File "", line 1 | print"python" | ^ | SyntaxError: invalid syntax Try this to find the problem : >>> print c printpython Once you check the data you are sending to eval you know that printpython is indeed invalid syntax. Instead, try this: a = '"python"' b = 'print' c = b + ' ' + a eval( c ) HTH, -D From vasvir at iit.demokritos.gr Sat Feb 3 15:13:24 2001 From: vasvir at iit.demokritos.gr (Vassilis Virvilis) Date: Sat, 03 Feb 2001 16:13:24 +0200 Subject: Win32 CreateProcess with In/out Redirection and a Way to kill the job? References: Message-ID: <3A7C1204.A226B21E@iit.demokritos.gr> Michael Jonas wrote: > > Seems like I need people with win32 geek factor.... > > What I want: > I'd like to code a extension module with a function popen3 (same as in os) > and a function is_alive() and terminate(). > > What I allready have: > a module which has an popen3 method which does exactly the same like the > posixmodule popen3 except that I extracted it to get hold of the process > Handle (from the normally inaccessible dict). The redirection works fine, I > can check if the job is still alive with my new is_alive(). But I'm > really struggling to terminate the job. > > Where my proble is: > The CreateProcess in the popen3 not only starts the job specified, it first > starts a cmd.exe which then starts the job. Ergo: the process handle I save > is the handle of the console app. The started app does not care at all if I > do a TerminateProcess on the console. The cmd.exe dies and the started job > stays alive. I tried to find a way to get hold of the Window Handle of the > console, but did not find a way. (The doughter process seems to die if I > close the Console Window. So I thought I could send a WM_Close to the > Window....) Nothing really worked till here... > > Any idea how to implement something like this on Win32?!? > > Thanks Michel > > PS. Please cc the mail also to mj at muc.das-werk.de, cause I'm having trouble > getting the mail from the list. I don't know how exactly the popen* functions are implemented but I think it's better to use CreateProcess/DuplicateHandle to mimic the popen* behavior in windows and fork/dup in UNIX. PS In UNIX a libc popen invocation fires a shell also (bin/sh). .Bill From marco at atmosp.physics.utoronto.ca Wed Feb 14 19:48:24 2001 From: marco at atmosp.physics.utoronto.ca (marco at atmosp.physics.utoronto.ca) Date: 14 Feb 2001 18:48:24 GMT Subject: I don't understand popen2 :( Message-ID: <96ejto$4q3$1@news.netmar.com> Hello All, I'm a python newbie, happy so far, but somewhat bewildered :( My problem is with popen2.popen3. It sometimes gets stuck when reading the process std_out/err. Here is an example: >>> (po, pi, pe) = popen2.popen3('ssh computer "ls"') >>> po_out = po.read() >>> pe_err = pe.read() >>> pe_err '' >>> po_out [Directory listing OK] Alternatively (notice the read order): >>> (po, pi, pe) = popen2.popen3('ssh computer "ls"') >>> pe_err = pe.read() >>> po_out = po.read() >>> pe_err '' >>> po_out [Directory listing OK] Fine. Now I try something slightly different: >>> (po, pi, pe) = popen2.popen3('ssh computer "find /home/marco"') >>> po_out = po.read() >>> pe_err = pe.read() >>> pe_err '' >>> po_out [snip find results] which is fine, BUT if I do: >>> (po, pi, pe) = popen2.popen3('ssh computer "find /home/marco"') >>> pe_err = pe.read() [freezes!! I then Ctrl-C] Traceback (innermost last): File "", line 1, in ? KeyboardInterrupt >>> po_out = po.read() >>> po_out [snip find results] So, in this last case if I pe.read() first my script freezes, and I have to Ctrl-C. Sure, I could always po.read() first, but my biggest problem is that sometimes it's the other way around! That is, performing po.read() first causes a freeze! Unfortunately, I cannot reliably reproduce this last behaviour, but here is the result from a script I had to Ctrl-C: prompt> ./myprog.py [frozen -- Ctrl-C] Traceback (innermost last): File "./myprog.py", line 1245, in ? get_files() File "./myprog.py", line 1102, in get_files po_out = po.read() KeyboardInterrupt line # 1101 (po, pi, pe) = popen2.popen3(scp_from_remote_IP) 1102 po_out = po.read() 1103 pe_err = pe.read() Sadly, the scp operation *does* seem to work most of the time, why does it sometimes get stuck? Thoughts? Ideas? I'm using: Python 1.5.2 (#1, Feb 1 2000, 16:32:16) [GCC egcs-2.91.66 19990314/Linux (egcs- on linux-i386)] Thanks for any help! (Oh, and please CC me a reply if possible -- Deja's undergoing transition pains to Google right now) ----- 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 fredrik at effbot.org Sat Feb 3 21:55:12 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Sat, 03 Feb 2001 20:55:12 GMT Subject: nested scopes References: Message-ID: Tim Peters wrote: > Python's "2-level" scheme was a deliberate counterpoint to the abuses of > deep lexical nesting in Pascal programs of the time (according to Guido), > and it's something I've grown to like a lot. But newbies eternally stumble > over that functions nest textually but not lexically in Python, and this > will make life simpler for them. I'm beginning to suspect that a new "sorry, you can no longer nest def statements" might have been an easier sell... Cheers /F From fredrik at pythonware.com Wed Feb 28 05:56:57 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 28 Feb 2001 04:56:57 GMT Subject: PIL for the Mac? References: <3A9C6FDF.3F9422C@alcyone.com> Message-ID: Erik Max Francis wrote: > Is PIL (PythonWare Image Library) available on the Mac? I don't see any > reference to the Mac on its main Web page, and the source tarball > doesn't appear to have any Mac specific files in it ... from what I can tell, it's shipped with the standard Mac distribution: http://www.python.org/download/download_mac.html "This is a single installer which gives you the option to install classic 68k, cfm68k, and/or PPC. The installer also optionally installs NumPy, PIL, img, Tkinter, and an IDE, and interactive development environment. Cheers /F From sholden at holdenweb.com Thu Feb 8 15:57:42 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 8 Feb 2001 09:57:42 -0500 Subject: CGI-Python Image viewing References: <95tp4p$bev$1@ctb-nnrp2.saix.net> Message-ID: Mix" wrote in message news:95tp4p$bev$1 at ctb-nnrp2.saix.net... > I am new to CGI scripting AND Python. What I am trying to do is, > display an image on an html page that has been retrieved from a Postgre > database > using Python (cgi). My problem is : that image that not show up on the page, > regardless of where it is sitting on my html or cgi directory! > (I am running Apache Web server under Redhat 7.0 with the default linux > kernel). > But, I CAN display the image on a plain html page (i.e without the > scripting). > > Please help! > Thanks > > Perhaps you should give us a little more information: for example, is it the HTML you are retrieving from Postgres, or the image as well? An example of the generated / retrieved HTML would be useful. Generally speaking you should be sending HTML to the client with an tag in it to specify the location of the graphic. If the value of the "src" attribute is absolute (begins with a /) then the browser will request by sending a path from the server's root. If, on the other hand, it's relative (does not begin with a /) then the browser will request it by generating an absolute path based on the URL which was used to access the HTML. All this assumes you haven't put tagging in your HTML. Does this help? regards Steve From daniel at dittmar.net Mon Feb 26 20:48:42 2001 From: daniel at dittmar.net (Daniel Dittmar) Date: Mon, 26 Feb 2001 20:48:42 +0100 Subject: Can't redirect output References: Message-ID: <3A9AB31A.31DC2202@dittmar.net> > I guess this is a known problem on NT? I have to work with NT, and > I never found out exactly why it won't redirect. I found that if I create > a .bat file that does nothing but call the .py file, I can redirect that > just fine. Sounds like something evil going on under the covers. There is a known Problem on NT that starting a program through it's extension will make the redirection impossible. So 'python hello.py > somefile.txt' should work. But 'hello.py > somefile.txt' does not. Solutions: don't know, I'm using 4NT as a shell, so I don't have this problem. Maybe auto-creating batch files for every Python program is the simplest method. Daniel From jfontain at winealley.com Thu Feb 15 14:56:45 2001 From: jfontain at winealley.com (Jean-Luc Fontaine) Date: Thu, 15 Feb 2001 14:56:45 +0100 Subject: how to get the output of embedded python? References: <96b6o6$a6e$1@s1.read.news.oleane.net> <96dkvb$eb8$1@s1.read.news.oleane.net> Message-ID: <96gmq7$p9r$1@s1.read.news.oleane.net> David Bolen wrote: > Jean-Luc Fontaine writes: > > > Yes. That is whatever output you would see when in interactive mode, if > > that makes any sense... > > Oh, I think I understand better. You don't actually want to trap any > output generated during the execution of the code - you just want to > deal with the result of the expression you may be evaluating. > > > That does not seem to matter in other scripting languages, such as Tcl > > or Perl: calling an internal eval C function with a script as argument > > returns the result of the script (not what comes out on stdout or > > stderr), which may be empty. > > > > For example, if I define a function foo that returns a string, invoking > > eval("foo()") in C would return that string. Is not that the behavior of > > python in interactive mode, for example? > > On an expression by expression basis, yes, each expression has a > result object (but not statements such as "print" for example). > > You should be able to handle the same thing from your controlling code > by dipping a little lower than the "Simple" high level functions. By > using either PyRun_File or PyRun_String you can evaluate Python code, > and the result of the function is the resulting Python object (a > PyObject *). Use PyEval_GetGlobals and PyEval_GetLocals for the > dictionaries to supply to the execution. > > Once you have the resulting object pointer you can do anything you > want with it (using any of the Python functions available for > extending/embedding applications), including converting it into a > string representation if you like. Note that the result does not > itself have to be a string object, since a Python expression can > result in any Python object. Check out the abstract and concrete > objects layer in the C/API reference or the Python source for all > sorts of functions. > > But if you know you want a string representation, you should be able > to use something like PyObject_Str to return a new Python object with > a string representation of the result object. Then, if you just want > a char*, use PyString_AsString. > > -- Thank you so very much for all this information: that is what I needed to get started. -- Jean-Luc Fontaine mailto:jfontain at winealley.com http://www.winealley.com From scarblac at pino.selwerd.nl Tue Feb 27 18:40:45 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 27 Feb 2001 17:40:45 GMT Subject: IP Math anyone? References: Message-ID: Erno Kuusela wrote in comp.lang.python: > In article , > scarblac at pino.selwerd.nl (Remco Gerlich) writes: > > | .0.255 and .1.0 are not IP addresses you could give to a machine. > | I've never seen existing code for this, seems to need some custom hacking. > > | (I don't know if .255 and .0 are the only exceptions, probably not). > > why do you think .0 or .255 are not usable addresses? I was confused about netmasks. I didn't expect the Spanish Inquisition! -- Remco Gerlich From mwh21 at cam.ac.uk Mon Feb 19 22:32:27 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 19 Feb 2001 21:32:27 +0000 Subject: Language change (was RE: iterators (was: python-dev summary)) References: <3A90A2AA.21FB5D05@seebelow.org> <96qh2f$962$1@216.39.151.169> <96s0oj02nsq@drn.newsguy.com> Message-ID: Grant Griffin writes: > If that were the _only_ reason, it might not be so great. But > you're talking to the guy who actually _likes_ "self.", as a > replacement for the "m_" notation he uses in C++ to mark class > member variables. (True, I sometimes wake up screaming in the > middle of the night about those extra three characters Python's > convention makes me type. But then I tell myself that I could have > used "m." if I had really wanted to. ) I still have the mental scars from trying to understand code that named *local* variables m_blah. Explicit *is* better than implicit. 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 danielk at aracnet.com Fri Feb 16 15:15:29 2001 From: danielk at aracnet.com (Daniel Klein) Date: Fri, 16 Feb 2001 06:15:29 -0800 Subject: equivalent of NULL or OM in Python References: <2G5j6.1$CF4.251@typhoon.nyu.edu> Message-ID: In this case, accessing an element outside of the range of values would produce an IndexError exception. You can 'catch' this exception like this poly = [(2,3),(0,4)] try: thirdpart = poly[2] except IndexError: print 'There are only 2 parts.' In Python, when an object has not been initialized, it is set to 'None' (quotes are for clarity), but I don't think this is useful in this situation. For question 2: for element in poly: print element[1] # prints the second part of each tuple Hope this helps, Daniel Klein Portland OR USA On Fri, 16 Feb 2001 03:37:43 -0500, "cyberian bear" wrote: >1.I'm doing a program in Python which perform +, -, *, / on two polynomials. >Their coefficient and exponentials are stored in tuples. So for example >3X^2+4X+4 would be stored like [(2,3),(1,4),(0,4)] but what if the term is >absent completely from one of the polynomials then i would have to check if >one of the tuuples is not present at all and not just zero. For example >[(2,3),(0,4)]. In Pascal there is NULL in SETL there is OM but is there a >corresponding statement in Python. I've checked through several sources >including my textbook but didn't find the satisfactory answer. Maybe I >should just check if the second term of every tuple(i.e the coefficient) is >zero which means that the term is not present. >2. Also can anyone give me a clue how to iterate over all the coefficient >terms in the tuples in the first polynomials' tuples. >My guess is should be something like >for coefficient in polynomial1: >where polynomial is a list of tuples >but how do i tell it to iterate specifically over the second term in every >tuple and not over the whole tuples >cb > From tjg at exceptionalminds.com Fri Feb 9 19:32:32 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Fri, 9 Feb 2001 10:32:32 -0800 Subject: open("ls -l |", "r") ?? In-Reply-To: ; from fm_duende@yahoo.com on Fri, Feb 09, 2001 at 05:56:39PM +0000 References: Message-ID: <20010209103232.U17173@trufflehunter.avalongroup.net> On Fri, Feb 09, 2001 at 05:56:39PM +0000, steveFarris wrote: > Hi all, is some variation of the above possible in Python? > >>> import os >>> cmd = os.popen('ls -l') >>> for l in cmd.readlines(): ... print l -- 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: 23 days 22:41 hours ago<< From erno-news at erno.iki.fi Fri Feb 16 20:22:43 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 16 Feb 2001 21:22:43 +0200 Subject: iterators (was: python-dev summary) References: <3A8CAC77.91555B93@seebelow.org> <96ipv7$hug$2@nntp9.atl.mindspring.net> <96jt2v$ogk$1@nntp6.u.washington.edu> Message-ID: In article <96jt2v$ogk$1 at nntp6.u.washington.edu>, Donn Cave writes: | I have heard claims that they're faster, and that's a priority I can | understand. actually, they are slower (than map + python function). but don't think that should be important. | But every time some cool notion gets added to Python, it adds to | the amount that we all eventually have to know. I can't indefinitely | postpone my education in list comprehensions without marginalizing | myself, just as someone who comes along and learns them right away | will still have to learn all the alternatives too. Does that add | to our ability to write software, or subtract from it? well said. -- erno From jmarshal at mathworks.com Thu Feb 22 21:22:16 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 22 Feb 2001 20:22:16 GMT Subject: Any way for a function to refer to itself? References: <3A956962.3BBFED86@americasm01.nt.com> <973s4j$2h9$1@news.mathworks.com> Message-ID: <973sdo$2no$1@news.mathworks.com> Joshua Marshall wrote: > Lee, Rick wrote: >> I can't find any other way for a function or method to refer to itself >> than something like the following: >> def foo(): >> myself = foo # only if foo is global >> mydoc = myself.__doc__ >> myname = myself.__name__ >> So it can be done this way, but: >> - only if the function name can actually be accessed from the current >> name space >> - if the function name changes, that first line inside this function >> also has to change >> Seems to me there should be a more "Pythonic" way of doing this. Is >> there? > It might be unpleasant, but you can do something like: > def fib(f, x): > if x < 2: return 1 > return f(f, x-1) + f(f, x-2) > print fib(fib, 10) And I guess if you don't like the idea of always having to pass your function in to itself, you can wrap it: def fib(x): def _fib(f, x): if x < 2: return 1 return f(f, x-1) + f(f, x-2) return _fib(_fib, x) print fib(10) From dsh8290 at rit.edu Tue Feb 13 16:35:56 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 13 Feb 2001 10:35:56 -0500 Subject: python 2.0 won't run scripts with \r\n line termination on RH7? In-Reply-To: <20010213155947.B759@freedom.puma-ag.com>; from stephen_purcell@yahoo.com on Tue, Feb 13, 2001 at 03:59:47PM +0100 References: <3A894883.61C64508@uol.com.br> <"from csrabak"@uol.com.br> <20010213155947.B759@freedom.puma-ag.com> Message-ID: <20010213103555.B10906@harmony.cs.rit.edu> On Tue, Feb 13, 2001 at 03:59:47PM +0100, Steve Purcell wrote: | Cesar Rabak wrote: | > | > So elaborating, on your reasoning, Steve, I think the 'sollution' would | > be the OP to have a kind of "header" or macro in his favorite editor | > which inserts the correct line in whatever OS be the script being | > written. | | Perhaps, although what's the simplest thing? Save the file in UNIX text | format (there must be Windows editors that support this). There are -- I use gvim :-). :set fileformat=unix | | As Toby Dickenson suggests, you can use a technique like CVS' filters to | transparently correct line endings according to the system on which files are | checked out from source code control. In this case, files are usually saved | in UNIX format in the source repository, and Windowsified as necessary on | checkout. | | I think there's a utility that ships with Python for changing the #! line of | a number of scripts -- perhaps that would help. Anybody remember the name? | I don't know if one came with it, but it shouldn't be hard to make such a thing. (Just be sure to open the file in _binary_ not text mode) It would be simplest to use a RandomAccessFile type of interface (there is a Java class by that name) and simply change the first \r\n to \n\n. In (g)vim you could type the following commands : :1 :set binary :s/^V^M// where ^V means Ctrl-V and ^M means Ctrl-M (or enter, in this case) -D From fredrik at pythonware.com Sun Feb 18 12:47:27 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 18 Feb 2001 11:47:27 GMT Subject: Remove directories from os.listdir output References: Message-ID: Fernando Rodr?guez wrote: > I need to filter out all the diretories of the list returned by > os.listdir(). How can I tell if an entry of that list is a dir or a regular > file? O:-) os.path.isdir(filename) os.path.isfile(filename) e.g. for file in os.listdir(mydir): fullname = os.path.join(mydir, file) if os.path.isfile(fullname): ... Cheers /F From phlip_cpp at my-deja.com Sat Feb 17 00:37:44 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 16 Feb 2001 23:37:44 GMT Subject: string, split, sort, None, huh? References: <96kadi$f2t@dispatch.concentric.net> <96kb5d$bb0$2@bcarh8ab.ca.nortel.com> Message-ID: <96kdk8$dtr@freepress.concentric.net> Glenn W Jackman wrote: > ...sort() sorts the list in place... Jay O'Connor wrote: > ...sort() sorts the sequence in in place... Oh, man - I gotta lay off that crack pipe, huh? @-} Thanks, guys. -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- My opinions are those of your employer -- From aleaxit at yahoo.com Tue Feb 27 08:12:26 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 27 Feb 2001 08:12:26 +0100 Subject: list to string References: Message-ID: <97fjv1028qd@news2.newsguy.com> "Delaney, Timothy" wrote in message news:mailman.983245987.15676.python-list at python.org... > Indeed. > > Personally, I think the join() string method is *really* bad. A method > should act on the object it is a part of. In this case, there is no > conceptual way that ''.join(['a', 'b', 'c']) could be considered to be > acting on '' - it is *using* ''. And, similarly, it's *using* ['a','b','c'] -- not "acting on" it. It's not a mutator. Not all methods of an object mutate it, and you clearly accept that, as you write: > OTOH, ''.length() is perfectly fine. It is obvious. Since join may use the joiner in a completely polymorphic way, but only uses the sequence through a sequence-iteration protocol, it's pragmatically _useful_ to have it be a method of the joiner object (as Python doesn't do multimethod-like dispatching). Usefulness seems to be a good indicator: if something offends your personal sense of purity, but is pragmatically good, then 'practicality beats purity' and it might be wise to reconsider your aesthetics:-). Alex From chris.gonnerman at usa.net Fri Feb 23 14:44:39 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Fri, 23 Feb 2001 07:44:39 -0600 Subject: Can't redirect output References: <3A95F8BA.9CD22C6F@pcug.org.au> Message-ID: <002401c09d9e$c91eb3c0$a100000a@local> From: "Robert Olney" Subject: Can't redirect output > I am running Python 2.0 on Windows 98. When I try to redirect output > from a command prompt, e.g. > > C:\> python hello.py > out.txt > > the output is printed on the screen and not to the file. Why? Is the output you are talking about from print commands and/or sys.stdout.write(...) calls, or is it error messages? Unix and Windows processes have two standard channels for writing messages, stdout and stderr, which Python maps to sys.stdout and sys.stderr. The redirection you show only redirects stdout/sys.stdout. On Unix (and reportedly Windows NT) you can write: python hello.py >out.txt 2>errors.txt which separates the output channels, or python hello.py >out.txt 2>&1 to combine them in the file. Unfortunately this does not work on Win9X, but there is a program available called stderr which combines the two channels. Get it from: http://www.teaser.fr/~amajorel/stderr/ IF NONE OF THIS HELPS YOU... please post your hello.py so we can inspect it. >The FAQ > mentions that this is a problem under Linux. I'll have to look at the FAQ, I'm not sure why Linux would have a problem with it. From ssthapa at classes.cs.uchicago.edu Tue Feb 13 04:39:34 2001 From: ssthapa at classes.cs.uchicago.edu (ssthapa at classes.cs.uchicago.edu) Date: Tue, 13 Feb 2001 03:39:34 GMT Subject: CPAN functionality for python References: <969l15$8cm$1@panix6.panix.com> Message-ID: Aahz Maruch wrote: >I suggest: > > ... [[depend1, minVersion, maxVersion], ... > >with None a valid value for minVersion and maxVersion. That sounds like a great idea. -- ---------------------------------------------------------------------------- | 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 yartz at imaginet.fr Mon Feb 19 08:06:02 2001 From: yartz at imaginet.fr (Yann Schwartz) Date: Mon, 19 Feb 2001 08:06:02 +0100 Subject: Why ASP <%@ %> does not work References: <3a909e7f.5108679@News.CIS.DFN.DE> Message-ID: <47F7E45B059247C9.6C3B173F0635E5FD.35F50673E3AFCE68@lp.airnews.net> On Mon, 19 Feb 2001 04:22:34 GMT, costas at springmail.com (Costas Menico) wrote: > >Hi, > > I am trying to execute the following page in PWS which contains >Python ASP. However it does not execute to display the "text". > I have installed the latest ActivePython . Is there some registry >setting that I should be dong? I know >>> from win32com.client.gencache import EnsureDispatch >>> ie = EnsureDispatch('InternetExplorer.Application') >>> ie.Navigate('http://localhost/javascript.html') >>> print ie.Document.documentElement.innerHTML Hello, World! >>> -- - Geoff Talvola Parlance Corporation gtalvola at NameConnector.com From bshapiro at funnygarbage.com Fri Feb 16 18:04:27 2001 From: bshapiro at funnygarbage.com (Ben Shapiro) Date: Fri, 16 Feb 2001 12:04:27 -0500 Subject: pywin and wxPython Message-ID: <96jmi1$jst$1@bob.news.rcn.net> Hey all... Here's the predicament.. I have an OCX control that is responsible for playback of mp3 files that i am trying to use from python. This control is wrapped using makepy. Mark H pointed me in the right direction to use pywin to host the OCX.. only problem is that my app uses wxPython as the GUI framework. From what i can tell you need to attach the activex control to an MFC window for it to load.... Any example of how to do this would be appreciated greatly! My existing code is below: p = win32ui.CreateWnd() win32ui.EnableControlContainer() mp3player = gencache.EnsureModule('{2DF09BC5-B050-11D2-81C1-00C0DFEAA961}', 0, 1, 0) self.olectl = activex.MakeControlInstance(mp3player.AMPL3DLite) self.olectl.CreateControl("", win32con.WS_TABSTOP , (7,43,500,300), p , 131) <---- fails here / nothing seems to happen if i comment out this line self.olectl.Open("c:\\code\\3LP\\pyfileunder\\music\\test.mp3") self.olectl.Play() From cg at schlund.de Wed Feb 14 18:34:17 2001 From: cg at schlund.de (Carsten Gaebler) Date: Wed, 14 Feb 2001 18:34:17 +0100 Subject: Working with DNS via Python References: Message-ID: <3A8AC199.50A4B5BB@schlund.de> > > Could someone point me to some functions or material that'd explain how > to work with DNS functions (nslookup, etc) via Python? > I was looking for such functions today, too, and found this on Parnassus: http://www.interlink.com.au/anthony/python/dns.tar.gz It works. There is a bug in Lib.py: index.append() takes a 2-tuple argument, not two single arguments. cg. From aleaxit at yahoo.com Wed Feb 21 00:20:10 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 21 Feb 2001 00:20:10 +0100 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <3A9008A1.6E7DD27F@pop3.qwestinternet.net> <3A9033B7.D5ADA989@alcyone.com> <8if09tck7vf97h5nm3lm01iigkk40s27pm@4ax.com> <3A905F9F.C7D93AA8@alcyone.com> Message-ID: <96uu2f0j60@news1.newsguy.com> "Marcin 'Qrczak' Kowalczyk" wrote in message news:slrn995hjv.p74.qrczak at qrnik.zagroda... > Sun, 18 Feb 2001 15:49:51 -0800, Erik Max Francis pisze: > > > If one is actually writing Standard C++, one doesn't need the > > str... C functions, since one won't be using NUL-terminated C > > strings, but rather std::string. > > Unless he wants to open a file with a given name, or get command > line arguments. Not to mention string literals. These tasks will use C-strings, but Erik's assertions about not needing "the str... C functions" remains true -- one just builds a std::string out of every C-string one happens to meet, and, when a C-string is needed (e.g., in a std::fstream constructor as the name argument), the .c_str() method of the std::string object supplies it. No functionality at all needs strwhatever()... Alex From scarblac at pino.selwerd.nl Thu Feb 1 01:50:02 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 1 Feb 2001 00:50:02 GMT Subject: Design for slices References: <959uue$k02$1@cubacola.tninet.se> Message-ID: Gustaf Liljegren wrote in comp.lang.python: > I'm learning Python and have a question about defining ranges/slices in > strings. I can't find any defence for what looks like a poor design, so I > have to ask. Why is the first character in the string x defined as x[0] and > not x[1]? This looks just like the typical geek thinking that I'm trying to > avoid with Python. Because experience has taught generations of programmers that this is the right thing to do. For a string x of length n, the following simple equations hold: x == x[0:i]+x[i:n] for any i (even negative i) len(x[i:n]) == n-i for 0 <= i <= n x[i:i] == [] for any i This means that it's always simple to split strings. This is also the reason that a string slice x[i:j] *does not* include x[j]. It really simplifies situations that would otherwise call for "-1" and "+1" everywhere. "Off-by-one errors" have caused lots of problems in the past. The Python choice avoids these problems for the common cases. People often say that you have to think of the indexes as marks *between* the actual values. Say, you have the string "Python", then think of it as P y t h o n 0 1 2 3 4 5 6 And now it's obvious that "Python"[2:5] == "tho", a string of length 3, which is expected since 5-2 = 3. There are more reasons, but you'll come to appreciate them over time. -- Remco Gerlich From phlip_cpp at my-deja.com Sun Feb 18 20:29:56 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 18 Feb 2001 19:29:56 GMT Subject: What's up with enscript for syntax highlighting? References: <96p7f2$bqi@dispatch.concentric.net> Message-ID: <96p7rk$sub@dispatch.concentric.net> Proclaimed Phlip from the mountaintops: > Is there a class > library available somewhere on www.python.org (perhaps under "hilite" or > something? It's in ClassModules.py you dumb f**k - can't you tell by the name? http://www.lemburg.com/files/python/doc.py.html -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- Have a :-) day -- From chris at voodooland.net Tue Feb 13 07:17:54 2001 From: chris at voodooland.net (Chris Watson) Date: Tue, 13 Feb 2001 00:17:54 -0600 (CST) Subject: FreeBSD and Py-Kqueue In-Reply-To: <96ahvl$lo@gap.cco.caltech.edu> Message-ID: Hi all, Has anyone had experience with using python and the python wrapper to kqueue in FreeBSD? I am authoring a book on postfix the MTA and I have read posts about an asynchronous syslogd on linux. Allowing for greater speed for postfix then a normal synchronous syslogd. Well FreeBSD doesn't have the async option. So I believe I have two choices to test to see how much this helps, either port Theodore Tso's syslogd to FreeBSD (icky) or write a cheap syslogd with Python to do writes async. I was wondering if kqueue would help syslogd out at all for increasing read/write performance? Any thoughts on this? -- ============================================================================= -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?" ============================================================================= GNU = Gnu's Non-portable & Unstable irc.openprojects.net #FreeBSD -Join the revolution! ICQ: 20016186 From qrczak at knm.org.pl Mon Feb 19 21:59:33 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 19 Feb 2001 20:59:33 GMT Subject: Windows/Cygwin/MacOSX import (was RE: python-dev summary, 2001-02-01 - 2001-02-15) References: <96kbdd$j7r$1@news.udel.edu> Message-ID: Fri, 16 Feb 2001 18:06:23 -0500, Terry Reedy pisze: > One of the hassles with Win9X is that Windows Explorer displays, I believe, > some files differently from how they are stored. And stores files differently than was asked to. For example when you try to create a directory called Spam, it will create SPAM and display it as Spam. And when asked to create SPAM, it will create it but display Spam. It behaves correctly when the name has more than 8 characters or when a character outside ASCII is used. This is Win95 - I don't know if they fixed this in later versions. Worse: using the Explorer you can create a filename with some non-ASCII characters (e.g. <> or bullet), which will be silently converted to other characters, perhaps different in long and short names (in these cases: '<<' and '>>' character pairs, and '\7' - a control character which displays as bullet in DOS). Details depend on the default codepages (the above is for CP-1250 and CP-852). This can make the file inaccessible under either Windows or DOS or both (because the converted character is sometimes not legal in a filename, but the filename was checked for correctness before conversion). You can't delete or rename such file from either Windows or DOS or both, until you repair the filesystem. Scandisk is not always able to do it. not-using-Windows-anymore-ly y'rs -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From max at alcyone.com Sun Feb 18 20:35:41 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 18 Feb 2001 11:35:41 -0800 Subject: Determining EOF character References: <66409tk72epolackapla0egk4907k9a9hi@4ax.com> Message-ID: <3A90240D.384ABA3E@alcyone.com> Daniel Klein wrote: > When managing child processes (like with popen2.popen2) I have > occasion to do > > instream.readlines() > > to get all lines in a list rather than > > instream.readline() > > which gets the next line terminated with 'os.linesep'. > > On Windows the child process needs to send a ^Z in response to > readlines() and > on UNIX it needs to send ^D. I don't know what this is on MAC. This isn't the way you should signal end of file. You should signal it the client closing his end of the pipe. In fact, what you suggest above may work on Windows, but it won't work on UNIX -- under UNIX, an end of file isn't indicated with a sentinel character in the stream, but rather with an out-of-bounds indicator (the underlying file structure has an end-of-file flag). As I recall, Windows/DOS does much the same thing, but also treats a ^Z as an explicit end-of-file indicator. -- 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 just don't know why they're shooting at us. \__/ Capt. Benjamin "Hawkeye" Pierce Esperanto reference / http://mirror/alcyone/max/lang/esperanto/ An Esperanto reference for English speakers. From Kai.Grossjohann at CS.Uni-Dortmund.DE Sat Feb 17 17:53:08 2001 From: Kai.Grossjohann at CS.Uni-Dortmund.DE (Kai =?iso-8859-1?q?Gro=DFjohann?=) Date: 17 Feb 2001 17:53:08 +0100 Subject: Python emacs mode (newbie) References: <96hu7d$4pq$1@troll.powertech.no> <96kmdc$47q$1@troll.powertech.no> Message-ID: On Sat, 17 Feb 2001, Syver Enstad wrote: > You mean to open modules by parsing import statements in a file? > Ex. > module.py > > import sys > import MyClass > > ...... And then you could place the cursor over let's say MyClass > and press some key combination to load the py file for the > module. Is that what you mean? > > This would be cool as an added bonus, but it's the find-file like > functionality that is crucial. Oh, I'm sorry. With M-x find-file-at-point RET, you could type it on the `import MyClass' statement above and then you'll get a default filename prompt of /some/path/here/MyClass.py. But ffap.el does not provide for a facility where you can enter a module name and then it opens the right file. Hm. But it would be trivial to do: C-x b foo RET, M-x python-mode RET, type in the module name, type M-x find-file-at-point RET, voil?! kai -- Be indiscrete. Do it continuously. From wmiller at mediaone.net Wed Feb 21 23:48:35 2001 From: wmiller at mediaone.net (Walter Miller) Date: Wed, 21 Feb 2001 14:48:35 -0800 Subject: How to get device context for com object? References: <96ujcc12r6k@news1.newsguy.com> <96us1u0dj8@news1.newsguy.com> <9701q102nt4@news1.newsguy.com> Message-ID: That's great! Yes, it works but I'm also trying to call CreateCompatibleDC() and it only works with the device context object not the (int) handle for the device context. Is there an api for creating a device context object based on its own handle? The ultimate plan is to try an replicate the visual basic example of copying the screenshot of the client portion of the window and saving it as a bitmap file. I have an activex control that does this already but that's too easy - I'm _actually_ trying to learn all the details of using Python with win32. > import win32gui > hdc = win32gui.GetDC(hwnd) > > will set hdc to the (int) handle for the device context > corresponding to (the client areas of) the window whose > handle is in (int) hwnd. From othello at javanet.com Sun Feb 25 07:43:53 2001 From: othello at javanet.com (Raymond Hettinger) Date: Sun, 25 Feb 2001 01:43:53 -0500 Subject: data parsing References: Message-ID: <3A98A9A9.8789B127@javanet.com> Gnanasekaran Thoppae wrote: > I have some data in a file 'test', which contains: > > Joe|25|30|49|40| > |28|39|71|| > |30|29||| > Malcolm|43|60|56|| > |28|37||| > Amy||70|45|| > |40|30||40 > |40||30|| > > I want to parse this data and format it in this way: > > Joe|25;28;30|30;39;29|49;71|40| > Malcolm|43;28|60;37|56|| > Amy|40;40|70;30|45;;30|;40;| > name = 'unnamed' # just in-case the file doesn't start with a name result = {} for line in inp.split(): field = line.split('|') while len(field) < 6: # fix misformatted line |40|40||40 field.append('') k = field.pop(0) # grab name field field.pop() # clear final blank if k != '': # on name change name = k if not result.has_key(name): result[name] = [] result[name].append(field) for name in result.keys(): ans = apply( zip, result[name] ) # tranpose matrix ans = map( ';'.join, ans ) ans.insert(0,name) ans.append('') print '|'.join(ans) Raymond From ycheng at sinica.edu.tw Fri Feb 23 09:01:22 2001 From: ycheng at sinica.edu.tw (Y. Cheng) Date: Fri, 23 Feb 2001 08:01:22 +0000 (UTC) Subject: How python output a unicode string. Message-ID: <9755ci$1t4m$1@news1.sinica.edu.tw> Hi, I try to install a big5.py on /usr/lib/python2.0/encodings and it seem working fine. Then I try to output an string which is u"\u9DFD" to stdout by using print. Before that, I call sys.setdefaultencoding("big5") without any error message. As I try to output the string, I got error message: ----------------------- File "/usr/lib/python2.0/encodings/big5.py", line 18, in encode return codecs.charmap_encode(input,errors,encoding_map) TypeError: character mapping must be in range(256) ----------------------- is this means that python can't output multi-byte character with unicode internal encoding ? Yuan-Chen Cheng From spamers at must.die Sun Feb 18 12:21:07 2001 From: spamers at must.die (Fernando Rodríguez) Date: Sun, 18 Feb 2001 12:21:07 +0100 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> Message-ID: On 18 Feb 2001 08:00:11 GMT, Jim Eaton wrote: >I am learning Python as a first language, and I have been wondering what >is a good language to learn after Python? I'm thinking of either going >into C or Java but I'm not sure which one because I've heard many >arguments either way. Will going into Java first be any detriment to >learning C later? Any suggestions would be greatly appreciated. A good combination is, IMHO: Python, CommonLisp, C++ and Prolog. From a didactic point of view, good second languages are CommonLisp (a more powerful Python-like language) and Java (an easier to learn C/C++ language). Remember that there's much more to programming than just learning the syntax of different languages. If you're new to programming, you should first learn some basic concepts. Good beginers books are: "Simply Scheme: Introducing computer science" and "The Schemer's Guide". Both use a lisp dialect called Scheme, that should be easy to undertand (sort of Python with extra parentheses). //----------------------------------------------- // Fernando Rodriguez Romero // // frr at mindless dot com //------------------------------------------------ From 1126-810 at online.de Sun Feb 18 10:18:08 2001 From: 1126-810 at online.de (Stefan Witzgall) Date: Sun, 18 Feb 2001 10:18:08 +0100 Subject: play_animals and MacPython Message-ID: <1126-810-F3D9B6.10180818022001@news.online.de> Hello, I tried to run the sample program "play_animals" found in "Python for the unexperienced". Now I get an error "unslicecable object str"... Ok, str is None, therefore I can't get some part of it. Has anyone run this on his machine with python, is this a MacPython specific prob, how to get around? Thank you for any hints. Bye, Stefan From lreilly at cs.strath.ac.uk Tue Feb 20 17:20:03 2001 From: lreilly at cs.strath.ac.uk (Lee Reilly CS1997) Date: Tue, 20 Feb 2001 16:20:03 +0000 Subject: retrieving file data from an external server - where to start? Message-ID: <3A929933.AA4F81@cs.strath.ac.uk> hi there, i'm using python with zope and am trying to do the following with python method: retrieveFileInfo(matric){ username = getUsername(matric) filename = username + ".gif" server = "http://blahblahblah/yaddieyaddie/" # some code to determine whether or not the file exists # where do i start # e.g if (retrieve.(server+filename) != none): # do something } e.g. given the matric value '9728430' i find that the corresponding user has username == 'lreilly'. if this person has their image stored on the external server then it will be called 'lreilly.gif'. i don't need to actually retrieve the file from python - only determine whether or not it exists or not. i.e. whether the http request reports a 404 or maybe even if the image size == 0 bytes. could someone possible be kind enough to give me an idea where to start? a url? a snippet of code? thanks very much in advance, lee From Norman_Shelley-RRDN60 at email.sps.mot.com Thu Feb 22 17:47:14 2001 From: Norman_Shelley-RRDN60 at email.sps.mot.com (Norman Shelley) Date: Thu, 22 Feb 2001 09:47:14 -0700 Subject: nice articles (Re: The price of fame...) References: <87vgq358bu.fsf@joyful.com> Message-ID: <3A954292.FEED9271@email.sps.mot.com> Simon Michael wrote: > I found eg "Text Processing in Python: Tips for Beginners" a very > useful overview. Thanks! > > If I may, an attempt to summarize for my fellow newbies: > > "Charming Python" columns can be found at, eg > http://gnosis.cx/publish/tech_index.html . > To read, click the title (not the eye logo). > > Best regards Funny, I still get this when I click on the above URL Not Found The requested URL /publish/tech_index.html was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. From doug at postsmart.net Sat Feb 3 18:30:14 2001 From: doug at postsmart.net (Doug Ball) Date: Sat, 3 Feb 2001 11:30:14 -0600 Subject: Python/C++ for graphics vs. other languages? References: <200101231452.IAA15405@starbase.neosoft.com> <63bo7t4qrf0oebbj6hnni9tjjdip8hg5u8@4ax.com> Message-ID: <000501c08e06$f83a6b60$8a00000a@darwin.net> les schaffer wrote in response to a prior posting: > >I am working on a real-time 3d simulation of a medical procedure, to run on > >an Athlon 1.2 GHz machine under windows 2000. > > this sounds interesting. are you at liberty to divulge more details of > the project? Thanks for your interest! We will be working on an interactive simulation of electromyographically-guided Botulinum toxin injection. In this procedure, the practitioner places a needle into a muscle, generally guided by surface landmarks, then more specifically guided by the electrical signals produced when the muscle contracts (summated compound action potentials). Once the needle is placed, Botulinum toxin is injected, subsequently blocking the chemical signals than are responsible for controlling muscle contraction (it blocks the presynaptic vesicle from binding to the presynaptic membrane). This procedure is typically used for patients with severe muscle spasticity. The simulation user will have visual and auditory feedback from a 3D model of the patient and from the EMG-machine monitor. The user will indicate the initial location of needle placement, then will request that the patient model activates the target muscle. This action will result in a simulated signal on the EMG-monitor (with both visual and auditory components) that aids the user in further localizing the muscle, while adjusting the needle for optimal placement within the muscle. Our goal is to develop this application for physician education. Thanks again. Doug From annis at biostat.wisc.edu Thu Feb 15 16:17:16 2001 From: annis at biostat.wisc.edu (William Annis) Date: 15 Feb 2001 09:17:16 -0600 Subject: Gauging system load References: Message-ID: Bryan Mongeau writes: > Out of curiosity, does anyone know of a module or a neat trick that will > permit me to gauge the system load at a given time? What OS? I have no idea how you'd do this on a PC or a Mac, but on any unix flavor you should be able to parse the output from uptime. And if you're running Solaris, you can grab my PyKstat package and rip the information right out of the kernel with no parsing at all. http://www.biostat.wisc.edu/~annis/creations/pykstat.html Under Linux, you can parse the contents of /proc/loadavg. -- 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 rogersd at bigfoot.com Wed Feb 14 05:31:58 2001 From: rogersd at bigfoot.com (Dave Rogers) Date: Tue, 13 Feb 2001 23:31:58 -0500 Subject: Python/ASP Docs/Questions Message-ID: <3A8A0A3E.A1EF40E9@bigfoot.com> I'm a newcomer to this group, but I'm working on a fairly large and exciting web site using Win2K/Python/ASP (win32 135/Python2.0) I cannot find any docs regarding the COM Scripting object that it uses. Can anyone (Mark?) refer me to proper docs for it? - I've checked ActiveState and the net in general with no luck. My two main problems are: 1) I would like for the COM Scripting object to not cache modules for me as I develop my code. I see the following conceivable solutions: a) There is some COM method I can call that will turn it off b) There is some process I can kill or restart (I tried WWW Publishing service) that will knock everything out of memory c) I can do manual reloads everywhere which are not desirable because I have some open source code that does "from foo import foo" where I cannot reload (foo) and I don't want to mess with the open source code because then I mess up the open source project d) Reboot the PC 2) I want to set cookies easily using Response. I would like to go Response.Cookies('name') = 'bob' (for a simple cookie), but instead I am forced to go import Cookie c = Cookie.Cookie() ... Response.AddHeader("Set-Cookie", c[12:]) (or something similar to that) I know Cookies is a collection - I seem to have this problem setting ASP Object values in general as I have to go Session.SetValue to set session variables. I really appreciate any help people can give me - these seem like fairly common issues, yet beyond the newbie level. P.S. One of the neatest things I've seen is Chuck Esterbrook's MiddleKit which was just released under Webware (http://webware.sourceforge.net). What it does is allow you to map your python objects to a database for design and run time access. What this means is that you can relate your objects in a 1 to 1 or 1 to many relationship and the MiddleKit will service all of your SQL needs - you do NOT write SQL or use recordsets. Once you acquire one or more objects from the database, you can follow their object references to other database objects. In fact I have abandoned ADO in favor of this middle layer which resides in between the database and my web site. I probably didn't do it justice but you'll just have to check it out. Thanks, -- Dave Rogers From jfontain at winealley.com Fri Feb 23 12:37:57 2001 From: jfontain at winealley.com (Jean-Luc Fontaine) Date: Fri, 23 Feb 2001 12:37:57 +0100 Subject: ANNOUNCE: tclpython-1.0 References: <3A958C9A.130C7838@free.fr> Message-ID: <975i2e$pa8$1@s1.read.news.oleane.net> Robin Becker wrote: --- How does this compare with the primitive python for tcl package I wrote long ago? http://www.jessikat.demon.co.uk/pyserver.zip The main deficiency of my approach was that it was difficult to get reverse communication ie callbacks from the python side and that everything was done via sockets. --- I did not know that existed: I will check it out, thank you. The difference is that this is using an embedded python interpreter (several I hope in a future version), so communication is done through the C APIs. -- Jean-Luc Fontaine mailto:jfontain at winealley.com http://www.winealley.com From Jerry.Spicklemire at IFLYATA.COM Wed Feb 7 17:43:21 2001 From: Jerry.Spicklemire at IFLYATA.COM (Spicklemire, Jerry) Date: Wed, 7 Feb 2001 11:43:21 -0500 Subject: Red Hat Linux and poplib.py Message-ID: <977A39E65CFCD3119ABF00D0B741D849E0FEB3@innt-73.ata.com> Hi Python fans, I'm hoping someone can point me in the right direction. When I try to use a contributed Zope module that calls poplib.py, Python v.2.5.2, I get a couple of error messages. The first hangs on: > File /l01/Zope/lib/python/Products/POPMailBase/POP.py, > line 132, in > ListMessages > (Object: POPMailAccountBase) > File /l01/Zope/lib/python/Products/POPMailBase/POP.py, > line 68, in > UpdateStatus > (Object: POPMailAccountBase) > File /l01/Zope/lib/python/Products/POPMailBase/POP.py, > line 42, in > Connect > (Object: POPMailAccountBase) > File /l01/Zope-2.2.1-linux2-x86/lib/python1.5/poplib.py, > line 183, in > pass_ > File /l01/Zope-2.2.1-linux2-x86/lib/python1.5/poplib.py, > line 146, in > _shortcmd > File /l01/Zope-2.2.1-linux2-x86/lib/python1.5/poplib.py, > line 125, in > _getresp > error_proto: (see above) with an error message of: > > Error Type: error_proto > > Error Value: -ERR Not implemented This makes me think that poplib.py is trying to interact with some PopMail feature that isn't implemented in the Red Hat v.5.2 distribution. My guess is that the second error is the result of the first, but it really is just a guess. The error is: > File /l01/Zope/lib/python/Products/POPMailBase/POP.py, > line 132, in > ListMessages > (Object: POPMailAccountBase) > File /l01/Zope/lib/python/Products/POPMailBase/POP.py, > line 68, in > UpdateStatus > (Object: POPMailAccountBase) > File /l01/Zope/lib/python/Products/POPMailBase/POP.py, > line 42, in > Connect > (Object: POPMailAccountBase) > File /l01/Zope-2.2.1-linux2-x86/lib/python1.5/poplib.py, > line 183, in > pass_ > File /l01/Zope-2.2.1-linux2-x86/lib/python1.5/poplib.py, > line 146, in > _shortcmd > File /l01/Zope-2.2.1-linux2-x86/lib/python1.5/poplib.py, > line 125, in > _getresp > error_proto: (see above) which is identical to the one above, but with the message: > > Error Type: error_proto > > Error Value: -ERR Mailbox in use It seems like the popmail server isn't updated when the client process drops, and keeps the session open. When that happens, I can't even connect to the user mailbox from Eudora, or even directly from the Python prompt. BTW, I was able to connect to the mailbox via the Python prompt once, after the client process was killed manually. I used some of the examples in the Beazley book, and elswhere, to invoke poplib.py, sign on, etc. I searched the Web for references to Red Hat and PopMail problems, and found a short E-Mail thread about this. http://plug.skylab.org/200009/msg00187.html http://plug.skylab.org/200009/msg00307.html The recommended solution was to use another PopMail server, such as CUCIPOP. Since I'm not the system admin, I don't have much access to the host, and such notions aren't often warmly received. It was far from painless just to get Python and Zope up and running, though we do have one Linux guru on staff. Any ideas would be greatly appreciated! Thanks, Jerry S. From jacobkm at cats.ucsc.edu Wed Feb 21 19:27:58 2001 From: jacobkm at cats.ucsc.edu (Jacob Kaplan-Moss) Date: Wed, 21 Feb 2001 10:27:58 -0800 Subject: Rounding Question References: <96vudj02hnf@news1.newsguy.com> Message-ID: In article <96vudj02hnf at news1.newsguy.com>, "Alex Martelli" wrote: [snip a whole bunch of great ideas...] Thanks so much for the great discussion; although this is really a trivial part of what I'm doing, it's nice to be able to do it right... In the end, I decided that: > def nextHigherOrEqualMultiple(depth, N): > "compute the least multiple of N >= depth" > return int((depth+N-1)/N) * N > > with > > tableDepth = nextHigherOrEqualMultiple(depth, 10) is what I'm going to use; I really only need to make this calculation once, so a long function name really isn't a problem, and although I'm writing for NAUI tables now, I know that certain other tables use increments of 5 feet, so it makes sense to have a generic function available. Thanks once again, Jacob From Pekka.Pessi at nokia.com Mon Feb 5 02:32:34 2001 From: Pekka.Pessi at nokia.com (Pekka Pessi) Date: 05 Feb 2001 03:32:34 +0200 Subject: . Python 2.1 function attributes References: , <$5A+ZwAGjtc6EwE0@jessikat.fsnet.co.uk> <14962.62953.304511.523826@anthem.wooz.org> Message-ID: In message Roy Katz writes: >Let's add bless(). I want to change the class of an object at >runtime. How 'bout it? How about this: class sm: "State machine accepting ab*" def __init__(self): self.__class__ = a valid = 0 class a(sm): def a(self): self.__class__ = b class b(sm): def b(self): pass valid = 1 BTW, have you never looked in the source code of pickle? Pekka From fredrik at pythonware.com Thu Feb 15 08:49:31 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 15 Feb 2001 07:49:31 GMT Subject: Getting Value From Tkinter Text Object References: <96faar$30s$1@ins21.netins.net> Message-ID: Scott Billings wrote: > The only option I can find that even seems to be close to what I want, is > the get() method, which expects a starting and ending point. Starting point > should be easy enough, but I have no way of knowing what the ending point > will be. http://www.pythonware.com/library/tkinter/introduction/text.htm => concepts, patterns "END (or "end") corresponds to the position just after the last character in the buffer. "To fetch the text contents of the widget, use the get method: contents = text.get(1.0, END) Cheers /F From clee at gnwy100.wuh.wustl.edu Wed Feb 21 20:27:45 2001 From: clee at gnwy100.wuh.wustl.edu (Christopher Lee) Date: 21 Feb 2001 13:27:45 -0600 Subject: locking files References: <96v06a$l16$1@solaria.cc.gatech.edu> <970kg2$cn0$1@solaria.cc.gatech.edu> Message-ID: <7ulmqzu98u.fsf@gnwy100.wuh.wustl.edu> Joseph Holland King wrote: : is there anyway to lock a file so that two different programs cannot access : the file at the same time. ie, my python module is editting file foo, and : at the same time user x (or program x) tries to read from it. is there : anyway that the python module can prevent x from accessing the file for : a given amount of time? : to clarify: i am on a unix system, i have tried to use flock however when i : locked the file i was still able to read, write and copy the file, none of : which i want to happen while the file is locked. while using the flock : method i was using LOCK_EX. also the third party program is not going to be : controlled, written, or have anything to do with mine. am i just not using : flock properly or is there something else that might do the job? thank you. flock() is an advisory lock, if you don't have cooperation from the other processes, and if your system supports the SysV interface you can enable mandatory locks. "man lockf" or "man fcntl" and search for information on SysV mandatory locking on your system. Files are marked as candidates for mandatory file locking by setting the file mode with SGID but without the "group execute" bits, (chmod g+s; chmod g-x). Enabling mandatory locking is system dependent, but you need to use fnctl/lockf, flock is always advisory. Under linux, I can do it like this: [as root] # enable file locking by remounting /home file system w/ mand flag mount -o remount -o mand /home [as normal user] > chmod g+s tmp; chmod g-x tmp > python >> import fcntl, FCNTL >> fp = open("tmp", "rw") >> fd = fp.fileno() >> fcntl.lockf(fd, FCNTL.F_LOCK) # secures the lock, prevents # reading/writing From rwklee at home.com Wed Feb 21 03:23:26 2001 From: rwklee at home.com (Rick Lee) Date: Wed, 21 Feb 2001 02:23:26 GMT Subject: Better Threading, starting with Events References: Message-ID: <3A93269A.8AFFC7BB@home.com> I like the idea of being able to wait for several events at once. That's something I can't do with queues in the Queue module. So my wish list would extend to queues as well. Another thing on my wish list is to be able to join to several threads at once. And then finally, to be able to select from any combination of events, queues, joins, and maybe anything else that blocks. Maybe you also want to keep on eye on compatibility with Stackless. - Rick Lee Warren Postma wrote: > Here is my little 'event' module __doc__ string: > > event module 1.0 > > Provides an efficient way for threads to go to sleep while waiting for > work to do, freeing up the python interpreter to run the other threads, > and yet waking up immediately upon signalling the worker thread > > Uses CreateEvent/SetEvent/WaitForMultipleObjects Win32 functions. > > Usage Sample: > > import event > sd = event.new('Shutdown') > sd.MyAttribute = 1 # stores something in event dictionary > work = event.new('DoSomeWork',1) # 'one-shot' > work .work_to_do = func # pass the function to the thread > ret = event.select( (sd,work), 5000 ) # wait 5 seconds for signal > if ret: # Got signal? > print repr(ret) > > ------------------------------------------------------------ > Here are the module methods: > ------------------------------------------------------------ > > event.new( 'name', manualResetFlag=1, initialStateFlag=0) > -> Creates and returns a new event object > manualResetFlag = does event reset automatically when received > (default=1) > initialStateFlag = event signalled or not signalled initially > (default=0) > > e = event.new( 'ASampleEvent') > > Using a WinEvent: > e.name name of event > e.wait() wait indefinitely (until python shutdown) for event > e.wait(500) wait up to 500 milliseconds (0.5 seconds) for event > e.state() query state (non blocking) returns 0 or 1 > e.set() set signalled state > e.reset() reset to non-signalled state > e.handle() get internal handle value (as integer) > > To wait for several events in parallel, use event.select( (e1,e2,..), > timeout ) > > ------------------------------------------------------------ > > event.select( , timeout=None) > -> Waits for a single event or any of a group of events, > returns None if the timeout occurs. > Note that all waits are interruptable by shutdown, > which will cause an exception to be raised. > > Example: > ev1 = event.new('DoSomething') > ev2 = event.new('DoSomethingElse') > ret=event.select( (ev1,ev2), 5000 ) # wait up to 5000 millisec. > if ret: > print 'got event', ret.name # which is it? DoSomething, or > DoSomethingElse > else: # none? > print 'timeout' > > --------------------------- End ---------------------------- > > Now, for a discussion on my Evil Plan: > > Anyone interested in native C Type for Event Signalling? I have written a > 1.0, or 0.1, that works, it just ain't portable off of Win32. I'll make it > portable if there is some agreement on the basic idea behind what I'm doing. > > I'd like feedback on whether my Evil Plan calls for a PEP. Before I go > PEP'ing, I'd like to get some initial comments on other people who have > implemented worker threads. Is anyone else dissatisfied with threading.py? > > My first problem with the existing facilities of threading.py is its > existence. I don't like that the Primitives are not Primitive, the interface > is great, the implementation is in Python. Urgh! Great for Jython/JPython. > Not so great for CPython guys like me. > > Why should Locks, Events, and Signals and Semaphores and so on all live in a > py file? Their efficiency is therefore sub-par, and it will negatively > affect the performance of all apps that use it. I also feel that a > consistent API and underlying implementation ought to permeate downwards > into the core of CPython. Anyone with me? At that stage, you can see my > Evil Plan is beginning to get into swing. > > But back to reality for a minute. The first thing I needed was extremely > efficient Event Objects, which could make a thread be "sleepy", waking up > periodically every 5 seconds to do some housekeeping, then going back to > sleep, but to be instantly interruptable at any time and immediately start > doing whatever work is required. They let go of the python interpreter lock, > and don't make the interpreter do any work, running functions in > threading.py while the thread ought to be idle, etcetera. > > Also, my eventual evil plan involves thread-by-thread signalling in ways not > currently supported by the current frame objects, and the code in ceval.c. > It should also involve making various blocking functions "interruptable". > For example, time.sleep, which calls the C function floatsleep in > timemodule.c: > Py_BEGIN_ALLOW_THREADS > Sleep((unsigned long)millisecs); > Py_END_ALLOW_THREADS > > This should be, IMHO: > Py_BEGIN_ALLOW_THREADS > ret=WaitForSingleObject( hSystemShutdown, INIFINITE); > Py_END_ALLOW_THREADS > if (ret != WAIT_TIMEOUT) > return NULL; // system is shutting down. > > I am basically doing my R&D here anyways to get threading maximally > efficient on my embedded systems. But I am more than willing, excited even, > to try my hand at proposing a PEP. Not for my little event module, but for > a whole bunch of threading primitives, in C. Perhaps the CPython version of > threading.py could be adapted to use them. > > The PEP would probably be for an expanded "thread" module, and a revised > threading system that improves "pervasive threading" inside CPython. > > Anyone? Anyone? Bueller? > > Warren From tjreedy at udel.edu Tue Feb 20 06:39:08 2001 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 20 Feb 2001 00:39:08 -0500 Subject: Windows/Cygwin/MacOSX import (was RE: python-dev summary, 2001-02-01 - 2001-02-15) References: Message-ID: <96sve1$69e$1@news.udel.edu> "Tim Peters" wrote in message news:mailman.982384399.26499.python-list at python.org... > [Terry Reedy] > > One of the hassles with Win9X is that Windows Explorer displays, > > I believe, some files differently from how they are stored. > > This depends on the setting of Explorer's > > View -> Folder Options ... -> View -> Allow all uppercase names > > option. It that's on, file names are shown as stored. But it's off by > default. Then an ALLCAPS name is shown as Allcaps (i.e., first letter > uppercase, all the rest lowercase), while other names are shown as stored. By coincidence, I discovered this 'feature' a couple of days ago, just after posting this, in the process of turning on the display of hidden files. > > So I have sometimes had trouble opening files. > > I don't understand that, as open() is case-insensitive on Windows. I do not believe that this has always been my experience, but the problem I had was a couple of years ago, so I will wait until I reproduce the problem before saying more. From gem at hsv.crc.com Fri Feb 23 18:55:36 2001 From: gem at hsv.crc.com (Glen Mettler) Date: Fri, 23 Feb 2001 11:55:36 -0600 Subject: Python with AMS Real Time Project Message-ID: <9767p9$ear$1@hobbes2.crc.com> Is anyone using Python with AMS Real Time Project? I have just acquired both and I am wondering about the ease and practicality of manipulating RTS from Python. Glen From mjackson at wc.eso.mc.xerox.com Thu Feb 15 21:29:26 2001 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 15 Feb 2001 20:29:26 GMT Subject: python-dev summary 2001-02-01 - 2001-02-15 References: Message-ID: <96he76$f68$1@news.wrc.xerox.com> Michael Hudson writes: > This is the first python-dev summary written by Michael Hudson. Thank you! > was proposed. Discussion went round and round for a while and moved > on to more general iteration constructs, prompting Ka-Ping Yee to > write a PEP entitled "iterators": > > > > Please comment! With the possible exception of ":spam" and "eggs:" it doesn't look like it would make code less readable, and the functionality seems good. Mildly in favor. > * Python's release schedule * > > Skip Montanaro raised some concerns about Python's accelerated > release schedule, and it was pointed out that the default Python for > both debian unstable and Redhat 7.1 beta was still 1.5.2. Have > *you* upgraded to Python 2.0? If not, why not? Ran into difficulties building on Solaris and didn't have the time to resolve them. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson Having your book made into a movie is like having your ox made into a bouillon cube. - Bill Neely From binary at eton.powernet.co.uk Sun Feb 18 18:42:35 2001 From: binary at eton.powernet.co.uk (Richard Heathfield) Date: Sun, 18 Feb 2001 17:42:35 +0000 Subject: Weird Language Features References: Message-ID: <3A90098B.5EBB3993@eton.powernet.co.uk> Dave Cross wrote: > > [Please watch the replies on this message as it's heavily > cross-posted] Noted. > > I'm doing some comparisons on programming language features and I'd be > very interested to know how you would handle the following scenarios > in your programming language of choice. > > 1/ The programmer calls a function that doesn't actually exist within > the application (or libraries). In ISO conforming C, he can't. End of story. > 2/ Can ou filter the input source code before compilation (or > interpretation) in some way so that language keywords could be changed > for other strings? Again in ISO conforming C... #define ALIAS original e.g. #define voiture auto /* :-) */ -- Richard Heathfield "Usenet is a strange place." - Dennis M Ritchie, 29 July 1999. C FAQ: http://www.eskimo.com/~scs/C-faq/top.html K&R answers, C books, etc: http://users.powernet.co.uk/eton From man_at_moon at hotmail.com Sat Feb 17 08:51:01 2001 From: man_at_moon at hotmail.com (David A.) Date: Sat, 17 Feb 2001 07:51:01 -0000 Subject: Yet Another Newbie Question (YANQ) Message-ID: Hi to everyone, I am playing around with python and I have 1 quetions where I hope someone can help I have this problem: >>> a='a' >>> prt='print' >>> t=prt+' '+a >>> t 'print a' now when I try to: >>> eval(t) Traceback (innermost last): File "", line 1, in ? eval(t) File "", line 1 print a ^ SyntaxError: invalid syntax can someone explain me what I am doing wrong! Why can't I use eval(print)? Any help is welcome! David Asfaha -- "Quidquid latine dictum sit, altum viditur." Whatever is said in Latin sounds profound. From knotwell at ix.netcom.com Thu Feb 1 04:50:07 2001 From: knotwell at ix.netcom.com (Brad Knotwell) Date: 31 Jan 2001 19:50:07 -0800 Subject: question on threading.py Message-ID: <86k87brrio.fsf@localhost.my.domain> Hello all-- Do the _Condition methods notify and wait really need to call currentThread? Unless currentThread has some side-effect I couldn't see I think these methods don't have any reason to call them. Lines 182 and 215 of v2.0 threading.py. --Brad From max at alcyone.com Sun Feb 18 11:13:42 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 18 Feb 2001 02:13:42 -0800 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96o0su0mv6@news2.newsguy.com> Message-ID: <3A8FA056.F7E767B4@alcyone.com> Alex Martelli wrote: > There are several possibilities, but I would suggest SQL as the second > language. It's incredibly useful AND when used well it urges you to > think in very different ways from a sequential imperative language > (such as Python, C, Java, ...) -- thus at the same time broadening > your horizons AND providing you with LOTS of real-world returns. > > Similarly, for a THIRD language I would suggest some structured markup > language such as XML (with XPath, XSLT...) or HTML (4.0, with its > DOM). I think he meant programming languages, not database query languages or markup languages. Java or C++ would probably be up his alley, depending on exactly what he wanted to do with that further knowledge. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Human love is often but the encounter of two weaknesses. \__/ Francois Mauriac Interstelen / http://www.interstelen.com/ A multiplayer, strategic, turn-based Web game on an interstellar scale. From Randy.L.Kemp at motorola.com Thu Feb 1 18:00:03 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Thu, 1 Feb 2001 11:00:03 -0600 Subject: Perl-to-Python converter/translator? Message-ID: <69BC4C6AE83ED311BC9400805FA7B14AF84DD6@il93exp01.css.mot.com> Have we converted another to the fray? -----Original Message----- From: Gerhard H?ring [mailto:gerhard.nospam at bigfoot.de] Sent: Wednesday, January 31, 2001 2:48 PM To: python-list at python.org Subject: Re: Perl-to-Python converter/translator? Lance Sloan wrote: > > I'm an experienced Perl programmer who has just been assigned > a project that must be done in Python. I'm looking for a > Perl-to-Python translator to help me out. I don't expect to > write the whole project in Perl and translate it, though. I'm > just looking for some automation to help me see how my old work > could be done in Python. > > I didn't find anything useful via Google or Vaults of Parnassus > searches. So, I would appreciate any pointers! Maybe the Perl/Python phrasebook at http://starship.python.net/~da/jak/cookbook.html is helpful to you. Intra-document links don't work. Does anybody know a better version of this document? 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 joconnor at cybermesa.com Tue Feb 6 22:41:35 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Tue, 06 Feb 2001 21:41:35 GMT Subject: x = y References: Message-ID: <3a806eed.5209768@news.cybermesa.com> On Tue, 06 Feb 2001 21:13:13 GMT, "Jos? Luis Gallego" wrote: >Hi all, > >I want to create a list x from a list y: > >y = [[1,2,3],[4,5,6]] >x = y > >How do I change individual elements of x without changing y? Make a copy of the list x = list (y) x will contain the same elements as y, but will be a seperate list, so you can update either indepently >>> y = [[1,2,3],[4,5,6]] >>> x = list (y) >>> x [[1, 2, 3], [4, 5, 6]] >>> y [[1, 2, 3], [4, 5, 6]] >>> x [0] = "hi there" >>> x ['hi there', [4, 5, 6]] >>> y [[1, 2, 3], [4, 5, 6]] >>> Take care, Jay O'Connor joconnor at cybermesa.com http://www.cybermesa.com/~joconnor Python Language Discussion Forum - http://pub1.ezboard.com/fobjectorienteddevelopmentpython "God himself plays on the bass strings first, when he tunes the soul" From tim.one at home.com Wed Feb 28 02:29:07 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 27 Feb 2001 20:29:07 -0500 Subject: PEP 236: Back to the __future__ In-Reply-To: <20010227200249.A21243@harmony.cs.rit.edu> Message-ID: [D-Man] > ... > However, I would like to see the use of particular future_statements > deprecated or even disallowed after the feature becomes mandatory. It's deliberately not done that way, so that if someone who moves their code around a lot happens to move to an earlier release, the (earlier) compiler will complain about a __future__ request it can't satsify. This is up to each programmer to deal with in whichever way best fits their usage. I expect many users will ignore future_statements entirely, and simply wait for the next release before fiddling their code. That's fine too. Note that there's more than enough info in __future__.py to allow writing a tool in Python that can reliably search for, identify, and even delete (if you like) obsolete future_statements wrt to any fixed Python release. That was also deliberate. > As for the future statement being easy to find : > grep -r "__future__" my_source_tree/* > will do the job ;-). The syntax restrictions listed in the PEP also ensure that a future_statement begins with "from" starting in the first column (they CANNOT be nested in if or try blocks, etc). everything-about-them-is-simple-except-the-implementation-ly y'rs - tim From jkraska1 at san.rr.com Sat Feb 24 06:25:20 2001 From: jkraska1 at san.rr.com (Courageous) Date: Sat, 24 Feb 2001 05:25:20 GMT Subject: Python training in Finland? References: Message-ID: On 20 Feb 2001 14:25:26 GMT, ohyvarin at cc.helsinki.fi (Otto T Hyvarinen) wrote: >We starting to use more Python in our department. So we are looking for >someone to teach us something :-) I suggest that you use the inability of a software person to learn Python without training as a good indicator that you need to let them go. Anyone who can't pick up Python on their own is beyond redemption. `;--) C// From jhauser at ifm.uni-kiel.de Fri Feb 2 14:43:23 2001 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 02 Feb 2001 14:43:23 +0100 Subject: Diamond x Jungle Carpet Python References: <3A7AB6C7.386D14D@engcorp.com> Message-ID: <877l399p50.fsf@lisboa.ifm.uni-kiel.de> Peter Hansen writes: > Rod wrote: > > > > I have several Diamond x Jungle Capret Pythons for SALE. > > > > Make me an offer.... > > > > Go to: www.qnet20.com > > Which platform? Version 1.5.2 or earlier? Doesn't > ActiveState already make these available as a free > download provided you don't need to redistribute them? > > Jeez, why don't people ever provide enough detail in > their posts?! > > :-) What? You do not take this serious? I have just ordered two of them for the sides of my home entrance. And Rod has given me a written guarantee that these babies will not move and only roll their eyes, as long as the the outside temperature is below zero degree (hope he meant celsius). So I think I'm safe for the winter :-) __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 phlip_cpp at my-deja.com Wed Feb 14 06:15:14 2001 From: phlip_cpp at my-deja.com (Phlip) Date: 14 Feb 2001 05:15:14 GMT Subject: while loop with f.readline() References: Message-ID: <96d492$88c@dispatch.concentric.net> Proclaimed Chris Gonnerman from the mountaintops: > I have always been a fan of the FileReader class: > > class FileReader: > def __init__(self, file): > self.file = file > def next(self): > self.line = self.file.readline() > return self.line > > if __name__ == '__main__': > > f = FileReader(open("c:/autoexec.bat")) > > while f.next(): > print f.line, Came to the thread late can't read all posts don't know if this was covered so sue me but... ...what's wrong with this? for z in f.readlines(): print z That's how I done it since I was a chile'. -- Phlip phlip_cpp at my-deja.com ============ http://c2.com/cgi/wiki?PhlIp ============ -- http://www.deja.com/my/pb.xp?member_name=phlip_cpp -- From rich_somerfield at tertio.com Mon Feb 26 10:11:59 2001 From: rich_somerfield at tertio.com (Rich Somerfield) Date: Mon, 26 Feb 2001 09:11:59 -0000 Subject: Help with finding how much memory a variable is using References: <3A986565.BAF4E05B@student.gu.edu.au> Message-ID: wrote in message news:3A986565.BAF4E05B at student.gu.edu.au... > Rich Somerfield wrote: > > > > Hi, > > > > I am generating a huge, huge list of data (cant think of a decent way to > > reduce the required storage size and have it in a usable form). Everytime i > > try to keep this list for future derivations I get a memory problem from > > Windows (effectively terminating my python script). > > > > I presume this is because of the huge list. Is it possible to find out the > > amount of memory a variable [not a type of the variable, the actual data > > contained within the variable] is taking up? This variable is local to a > > class and it would appear that it is when i go out of scope of that class > > that the memory error is being issued. Would I be better making this > > variable global (across all classes)? e.g. would this problem still happen > > if the variable was not just local to 1 class? > > > > Would a different python datatype solve this problem for me ? > > > > If I cant handle this amount of data then I will have to think of a way of > > better representing it, this will be unfortunate though as and compression / > > reduction of data will [as far as i can think] vastly reduce performance - > > which is already a concern. > > > > Regards > > Rich > > Do you have to load all the list into memory, or is there a way you can > load in parts and work on that sequentially. I haven't had a chance to > use persistance modules yet, but their documentation may be a place to > start. > > Joal Heagney/AncientHart Unfortunately I need all of the data in memory at the same time. The only way I can see to solve this problem is to reduce the memory consumption of my application. And the only way I can see how to do that is by vastly reducing the performance. Do u know of any information that suggests how large a datatype can be in Python (are there any upper limits?) ? Regards Rich From shaleh at valinux.com Thu Feb 22 21:39:52 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Thu, 22 Feb 2001 12:39:52 -0800 (PST) Subject: executing shell commands In-Reply-To: Message-ID: On 22-Feb-2001 chris lamb wrote: > I am very new to Python and having to learn quickly! I am enjoying it, > however. It is a flexible and intuitive environment. > > Can someone advise me if there is an equivalent to running a system process > from inside a script as there is in Perl? I mean in perl if I use backticks > to enclose a system command, then the command is executed. Is there a > comparable way of running these commands from Python? > import os os.system() or os.popen() system will run the command, but you do not get anything back other than an exit status. popen() can launch and app and connect its output to a Python file handler and let you read from it. From grante at visi.com Sat Feb 17 17:21:32 2001 From: grante at visi.com (Grant Edwards) Date: Sat, 17 Feb 2001 16:21:32 GMT Subject: ok, so how do I return a sorted list without doing it in place References: <96koqk$gv6$1@panix2.panix.com> Message-ID: In article <96koqk$gv6$1 at panix2.panix.com>, Aahz Maruch wrote: >>> I know I can do: >>> >>> list = dict.keys() >>> list.sort() >>> ..... >>> >>> but it is just plain annoying. >> >>I agree. This has bitten me on the butt more than once. It also seems >>somewhat unPythonic. Usually I expect what happens in Python, but that >>sort process always strikes me as unexpected. On many occasions, I would find it quite handy if there was a sequence method that returned a sorted shallow copy: for k in dict.keys().sorted(): whatever(k) >It's unexpected in some respects, but doing it this way causes the >fewest surprises overall. At least you rarely get a downstream bug >this way. In my mine the used of the adjective "sorted" as a method name conveys the fact that it doesn't modify the list in place they way the imperative "sort" does. YMMV. -- Grant Edwards grante Yow! World War III? No at thanks! visi.com From phd at phd.pp.ru Fri Feb 9 18:05:21 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 9 Feb 2001 20:05:21 +0300 (MSK) Subject: I love Python In-Reply-To: <981736559.1767376098@news.t-online.de> Message-ID: Pedro Vale Lima wrote: > > I love Python too ;-) > Yeah, but have you asked Python if he loves you? It doesn't matter until *I* am satisfied! :) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From tanzer at swing.co.at Fri Feb 23 08:04:56 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Fri, 23 Feb 2001 08:04:56 +0100 Subject: Nested scopes resolution -- you can breathe again! In-Reply-To: Your message of "Thu, 22 Feb 2001 21:59:26 EST." <200102230259.VAA19238@cj20424-a.reston1.va.home.com> Message-ID: Guido van Rossum wrote: > We (PythonLabs) have received a lot of flak over our plan to introduce > nested scopes despite the fact that it appears to break a small but > significant amount of working code. There were lots of complaints about newly introduced Python features recently. While I understand concerns about code breakage (myself being worried about breakage to my code), far more complaints concerned style issues than breakage. As I normally don't want to waste time over religious issues -- like `print >>' being cool or the worst wart ever -- I don't participate in such discussions on c.l.py. But IMO Python still is an excellent language and it got even better in the last year. Thank you and your team for the great work you are doing. > How do you select nested scopes? Tim suggested a mechanism that is > used by the ANSI C committee to enable language features that are > backwards incompatible: they trigger on the import of a specific > previously non-existant header file. (E.g. after #include > , "imaginary" becomes a reserved word.) > > The Python equivalent of this is a magical import that is recognized > by the compiler; this was also proposed by David Scherer for making > integer division yield a float. (See > http://mail.python.org/pipermail/edu-sig/2000-May/000499.html) You > could say that Perl's "use" statement is similar. > > We haven't decided yet which magical import; two proposals are: > > import __nested_scopes__ > from __future__ import nested_scopes Cool. I hope that `from __future__ import ' will win this contest -- it defines a common pattern for introducing backwards incompatible features. -- 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 andi at opencan.cc Sun Feb 11 00:09:09 2001 From: andi at opencan.cc (Andreas Poisel) Date: 10 Feb 2001 23:09:09 GMT Subject: Vim and python efficiently References: <964ag4$c4d$1@news.tuwien.ac.at> Message-ID: <964hml$f36$1@news.tuwien.ac.at> Andreas Poisel wrote: [...] Sorry for the tabs... -- Andi From kevin at GamesandTheory.com Fri Feb 23 16:05:49 2001 From: kevin at GamesandTheory.com (Kevin Douglas) Date: Fri, 23 Feb 2001 10:05:49 -0500 Subject: Suffering For Your Art In-Reply-To: Message-ID: > > Is it just me or is there a lot of animosity towards Python as > > a serious programming language ... > > When I first started looking at Python a few years back I had to > get past the mental block that Python was a "scripting" language > and was therefore inherently less powerful than the more > traditional "compiled" languages (e.g. C/C++ or Fortran). This is the first time I have ever posted to this list, in over a year of being subscribed. I've built and/or worked on systems that are scalable to the level of billions of transactions per month with Python and C and ASM. The premise is simple - Python is an AUTOMATION and PROTOTYPING language. You use it to automate either administrative tasks, management tasks, monitoring and quality assurance tasks, data aggregation or analysis tasks, or - more powerfully - programming tasks (self replicating code, code management, etc). It's quite easy to build an advertising exchange and collaborative filtering system such as DoubleClick has (even better than theirs, actually), or BlueFly or any other such company - in about one to three months - then work for the next 6 to 12 months on filling in the details, and native C functionality and inline ASM where needed. Such a system usually lasts for 3 to 4 years without needing much change (from industry experience, including one of the examples I just mentioned *cough cough*). I've spoken with executives and venture capitalist that are responsible for several million dollars worth of technology expenditures - who re completely confident in the capacity of Python for Enterprise Level developments of any size - ERP, HIRS, CRM, Financial Systems, Accounting Systems, Billing Systems, Trading Systems, data Mining/Warehousing Systems, you name it. I was about to build a Python system for Deutsche Bank, the world's largest bank, with North American, European, and Asia-Pacific operations, multilingual, HRIS, graphical charts and analytics, database, security systems, the whole nine (yes, thin-client Java Swing graphics with distributed load balancing on the client end, plus ORACLE and encrypted one-way anonymous data repository for survey data and aggregate analysis). Of course, we would never tell the general public that it was written in Python - that's silly. Of course, we would never tell the general public if we were running Java either - because that is equally as silly. We run "heterogeneous systems" - and that's all anyone needs to know - for Risk Management purposes. Unfortunately, people generally tend to suck. So that project never completed because someone unnamed wasn't willing to wake up everyday and be their own boss. And Python coders like myself are starving artists because of such silly and trivial things. Mostly because of "grown men" being considerably more immature than most of my peers. On an interesting side note, I've noticed that more money seems to be spent on Welfare Administration than on the actual welfare itself, given some of the rules and regulations that these agencies claim are legal and strictly adhere to. I was turned down for Food Stamps even though I only have water left right now - it's interesting how a CTO level programmer gets no respect because he focused on cost effective realistic solutions instead of Multi-Level Sales and Marketing tactics like the ones that destroyed the US Economy. EMC just announced they'd make $1B less than they thought - because - yes - all those con artists who were selling "solutions" based more on merchant partnerships than real solutions - ripped everyone off and no one is left! My 2 cents worth. If I had 2 cents anyway. Always available for consulting or freelance work or start-up prototyping, resume available if anyone really cares. Kevin Douglas President / Chief Technology Officer Games and Theory Supercomputing, Inc. From william_wicker at spectratechnologies.com Fri Feb 16 19:35:12 2001 From: william_wicker at spectratechnologies.com (William Wicker) Date: Fri, 16 Feb 2001 18:35:12 -0000 Subject: Win32 COM: Passing NULL as a value Message-ID: <904A72E79williamwickerspectra@207.126.101.100> I am trying to work via the COM interface to an object that exposes a method something like this: AnObject.DoSomething(doWhat, toWho) where toWho is either a dispatch pointer, or NULL, if toWho is not significant. When I try to do this with obj = win32com.client.Dispatch("AnObject") obj.DoSomething("kick", None) or obj.DoSomething("kick", 0) I get type mismatch errors back from the COM object. Is there a way to pass a NULL pointer via win32 COM? P.S. I'm trying this with the ActiveState Python 2.0 distribution (python win build 202) Thanks! William. From fakeaddress at nospammail.com Wed Feb 7 00:57:08 2001 From: fakeaddress at nospammail.com (Ben Catanzariti) Date: Wed, 7 Feb 2001 10:57:08 +1100 Subject: Python Users Group Australia Message-ID: Hi, I am looking for the existence of a Python Users Group in Australia ... does one exist?? If so how do I get in contact with them: Elif ... are there other parties interested in forming one? thanks Ben From rickp at telocity.com Sun Feb 25 23:43:11 2001 From: rickp at telocity.com (Rick Pasotto) Date: Sun, 25 Feb 2001 22:43:11 GMT Subject: Tkinter/Pmw callback question References: <3A997794.66A9D4AB@NoNOSpamtheworld.com> Message-ID: On Sun, 25 Feb 2001 21:24:11 GMT in comp.lang.python, David Lees wrote: > I am trying to learn Tkinter and Pmw and am modifying demo Pmw code > (EntryField.py). I want to call a Python function that I have defined > when I push a button and am having problems with the callback. As > long as the function has no arguments all is well, but I am unable to > do a callback on a function that has arguments. For example this > works: > > RunButton = Tkinter.Button(root, text = 'Run',command=foo) > > where foo has no arguments, but when I write: > > RunButton = Tkinter.Button(root, text = 'Run',command=barf('junk')) > > things do not work correctly. The 'barf' function seems to execute > when the program starts up, but not when I click the Run button. > > What goes on here and what is the correct way to do call backs? I'm just learning myself, but I think what I'm going to say is correct. 'command=' takes the *name* of a function. Adding parens changes the *name* to an actual function call. The way to get around this is to use the nameless name 'lambda' for the name of the function and *it* can call the function you really want. So: rb = Button(root, text='Run', command='lambda x="junk":barf(x)') -- "Every great advance in natural knowledge has involved the absolute rejection of authority." -- Thomas Henry Huxley Rick Pasotto email: rickp at telocity.com From embed at geocities.com Tue Feb 20 17:21:45 2001 From: embed at geocities.com (Warren Postma) Date: Tue, 20 Feb 2001 11:21:45 -0500 Subject: Better Threading, starting with Events Message-ID: Here is my little 'event' module __doc__ string: event module 1.0 Provides an efficient way for threads to go to sleep while waiting for work to do, freeing up the python interpreter to run the other threads, and yet waking up immediately upon signalling the worker thread Uses CreateEvent/SetEvent/WaitForMultipleObjects Win32 functions. Usage Sample: import event sd = event.new('Shutdown') sd.MyAttribute = 1 # stores something in event dictionary work = event.new('DoSomeWork',1) # 'one-shot' work .work_to_do = func # pass the function to the thread ret = event.select( (sd,work), 5000 ) # wait 5 seconds for signal if ret: # Got signal? print repr(ret) ------------------------------------------------------------ Here are the module methods: ------------------------------------------------------------ event.new( 'name', manualResetFlag=1, initialStateFlag=0) -> Creates and returns a new event object manualResetFlag = does event reset automatically when received (default=1) initialStateFlag = event signalled or not signalled initially (default=0) e = event.new( 'ASampleEvent') Using a WinEvent: e.name name of event e.wait() wait indefinitely (until python shutdown) for event e.wait(500) wait up to 500 milliseconds (0.5 seconds) for event e.state() query state (non blocking) returns 0 or 1 e.set() set signalled state e.reset() reset to non-signalled state e.handle() get internal handle value (as integer) To wait for several events in parallel, use event.select( (e1,e2,..), timeout ) ------------------------------------------------------------ event.select( , timeout=None) -> Waits for a single event or any of a group of events, returns None if the timeout occurs. Note that all waits are interruptable by shutdown, which will cause an exception to be raised. Example: ev1 = event.new('DoSomething') ev2 = event.new('DoSomethingElse') ret=event.select( (ev1,ev2), 5000 ) # wait up to 5000 millisec. if ret: print 'got event', ret.name # which is it? DoSomething, or DoSomethingElse else: # none? print 'timeout' --------------------------- End ---------------------------- Now, for a discussion on my Evil Plan: Anyone interested in native C Type for Event Signalling? I have written a 1.0, or 0.1, that works, it just ain't portable off of Win32. I'll make it portable if there is some agreement on the basic idea behind what I'm doing. I'd like feedback on whether my Evil Plan calls for a PEP. Before I go PEP'ing, I'd like to get some initial comments on other people who have implemented worker threads. Is anyone else dissatisfied with threading.py? My first problem with the existing facilities of threading.py is its existence. I don't like that the Primitives are not Primitive, the interface is great, the implementation is in Python. Urgh! Great for Jython/JPython. Not so great for CPython guys like me. Why should Locks, Events, and Signals and Semaphores and so on all live in a py file? Their efficiency is therefore sub-par, and it will negatively affect the performance of all apps that use it. I also feel that a consistent API and underlying implementation ought to permeate downwards into the core of CPython. Anyone with me? At that stage, you can see my Evil Plan is beginning to get into swing. But back to reality for a minute. The first thing I needed was extremely efficient Event Objects, which could make a thread be "sleepy", waking up periodically every 5 seconds to do some housekeeping, then going back to sleep, but to be instantly interruptable at any time and immediately start doing whatever work is required. They let go of the python interpreter lock, and don't make the interpreter do any work, running functions in threading.py while the thread ought to be idle, etcetera. Also, my eventual evil plan involves thread-by-thread signalling in ways not currently supported by the current frame objects, and the code in ceval.c. It should also involve making various blocking functions "interruptable". For example, time.sleep, which calls the C function floatsleep in timemodule.c: Py_BEGIN_ALLOW_THREADS Sleep((unsigned long)millisecs); Py_END_ALLOW_THREADS This should be, IMHO: Py_BEGIN_ALLOW_THREADS ret=WaitForSingleObject( hSystemShutdown, INIFINITE); Py_END_ALLOW_THREADS if (ret != WAIT_TIMEOUT) return NULL; // system is shutting down. I am basically doing my R&D here anyways to get threading maximally efficient on my embedded systems. But I am more than willing, excited even, to try my hand at proposing a PEP. Not for my little event module, but for a whole bunch of threading primitives, in C. Perhaps the CPython version of threading.py could be adapted to use them. The PEP would probably be for an expanded "thread" module, and a revised threading system that improves "pervasive threading" inside CPython. Anyone? Anyone? Bueller? Warren From gzeljko at sezampro.yu Wed Feb 7 02:31:50 2001 From: gzeljko at sezampro.yu (gzeljko) Date: Wed, 7 Feb 2001 02:31:50 +0100 Subject: While everyone is saying what they want in Python :) References: <3A7D64D8.74E71826@cybermesa.com> <3A7D9C1D.781F8E5@alcyone.com> <3A7DB154.87E04245@cybermesa.com> <3a8012f5.7625600@nntp.sprynet.com> <3a806c08.26417386@news.skynet.be> Message-ID: <95q8l6$htb$1@neptun.beotel.net> I agree, but this construct can't go in Python (what about assigment in this context ?) Zeljko Daniel wrote in message news:3a806c08.26417386 at news.skynet.be... > > The part where I find the 'with' command interesting is for > readability. Consider : > > MySpecialButton := TSpecialButton; > MySpecialButton.caption := 'Busy'; > MySpecialButton.method2; > MySpecialButton.caption := "Ok"; > > or > > MySpecialButton := TSpecialButton; > with MySpecialButton do > begin > caption := 'Busy'; > method2; > caption := 'Done'; > end; > > Which code would you prefer? > From peter at engcorp.com Fri Feb 2 14:29:56 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 02 Feb 2001 08:29:56 -0500 Subject: import statement within a function References: <95dmp6$n4s$1@news.tpi.pl> <1Yte6.11069$AH6.1772843@newsc.telia.net> <95dr93$dcs$1@news.tpi.pl> <95e9c2$rmm$1@news.tpi.pl> Message-ID: <3A7AB654.D6C16746@engcorp.com> Tomasz Lisowski wrote: > > "Fredrik Lundh" : > > Tomasz Lisowski wrote: > > > for the first time is minimal. What are then advantages of importing a > > > module WITHIN a function. > > > > - lazy importing: if you place it within a function, the module > > is only imported if your program really needs it. > > > > - import dependencies (see the recursive import section in the > > mini-guide). if you use from-import on the module level, you > > can end up in situations where the things you import doesn't > > yet exist. > > > > - performance: local lookup is faster than global lookup. > > Yes, that's really a good point! > > > - readability: it can be easier to grok your code if you import > > things (i.e. define names) near the place you're using them. > > Thanks, Frederik, that is really a good explanation! BTW, I really > appreciate your "Introduction to Tkinter". I am using it alot. The one you highlight, "performance", should probably be considered the _least_ important of the points Fredrik raised. The last one, which implies improved maintainability, is far more important (IMHO), and that alone is a good reason to put import within a function instead of 'without' (provided the imported module is not needed throughout the importing module of course). From aleaxit at yahoo.com Sat Feb 24 10:25:27 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 24 Feb 2001 10:25:27 +0100 Subject: Need to unread or push back bytes to a file References: <9771ks0ic2@news2.newsguy.com> Message-ID: <977ukk0uvd@news1.newsguy.com> "Noah Spurrier" wrote in message news:9771ks0ic2 at news2.newsguy.com... > > > I need to push bytes back into a file object. > Is there a buffered file wrapper for file objects? > (Yes, I looked, but I gave up after almost five minutes of searching.) > > I'm reading from a pipe, but this could be the same for a file. > I call an "expect" method which reads until a pattern is found, > but read() with a pipe will read as much data as there is available > in the pipe. When I have found a pattern match I want to return > the stream with the extra character pushed-back. what about something like: class NSWrapper: def __init__(self, fileob): self.fileob = fileob self.buffer = '' def close(self): self.fileob.close() self.buffer = '' def push_back(self, piece): self.buffer = piece + self.buffer def readall(self): result = self.buffer + self.fileob.read() self.buffer = '' return result def read(self, N=None): if N is None: return self.readall() avail = len(self.buffer) if N>avail: result = self.buffer+file.read(N-avail) self.buffer = '' else: result = self.buffer[:N] self.buffer = self.buffer[N:] return result needs testing, but this should be roughly what you want...? Alex From jurgen.defurne at philips.com Thu Feb 8 16:23:55 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Thu, 8 Feb 2001 16:23:55 +0100 Subject: Memory leaks or other things ? Message-ID: <0056900015777418000002L082*@MHS> Hello, list, I am having the following problem under NT, with Python 2.0 for NT. For some time I have written a cron.pl project (yes, Perl) with Cygwin, which runs fine using fork and exec(). Now, to have easier installation of base programs and script modules, I would like to everything in Python. I had already (re)written much in Python, but cron.py was the last. I implemented cron.py using spawn. The complete application is one script. The main routine syncs on 00 seconds, and then spawns a subprocess, which reads and processes crontab. For every process that should be run, the script is respawned with the appropriate arguments, all using Python 2.0 for NT. The jobs which I have to run allocate a fair amount of memory (160 Mb). The funny thing is that the jobs which are still running under cron.pl do not leak memory, but the same job (different arguments) under cron.py does not give its memory back, although I can't find any processes anymore in the Task Manager. I am retesting now, with one modification : using sys.exit(0) to terminate the spawned scripts properly. Has anyone an idea ? You have the code here. Review at your own will. Jurgen # # External modules import re import os import sys import string from time import * from BitVector import BitVector # Global variables year = month = day = hour = min = sec = None crontab = 'c:\\etc\\crontab2' logfile = 'c:\\var\\log\\cron2.log'; interpreter = 'd:\\python20\\python' script = 'cron.py' shell = 'c:\\winnt\\system32\\cmd.exe' fh = None initialised = None # Class definitions class JobEntry: def __init__(self, line = None): if line: M, H, d, m, w, c = string.split(line, sep = None, maxsplit = 5) self.mins = self.BitInit(M, 60) self.hour = self.BitInit(H, 24) self.days = self.BitInit(d, 31) self.mnth = self.BitInit(m, 12) self.dows = self.BitInit(w, 7) self.cmnd = string.strip(c) else: self.mins = BitVector(60) self.hour = Bitvector(24) self.days = BitVector(31) self.mnth = BitVector(12) self.dows = BitVector(7) self.cmnd = None def BitInit(self, value, length): rv = BitVector(length) if value == '*': for i in range(length): rv[i] = 1 else: args = string.split(value, ',') for arg in args: if string.find(arg, '-') != -1: start, end = string.split(arg, '-') for i in range(eval(start), eval(end) + 1): rv[i] = 1 else: rv[eval(arg)] = 1 return rv # Subroutine definitions def logmsg(msg): fh = open(logfile, 'a') systime = ctime(time()) fh.write('%s -- %s\n' % (systime, msg)) fh.close() """ Running a job using spawn is not as easy as using fork and exec. In the normal Unix a parent process can wait upon the completion of a subprocess, under Windows this doesn't work. To provide support for this, the script will be spawned to execute run_job(), and run_job will provide the necessary services for controlling the job. The job itself will be run synchronously. """ def run_job(argv): job = string.join(argv[2:]) print job # Log activity before job is run logmsg('Starting : %s' % job) # Run job os.system(job) # Log activity after job has finished logmsg('Job %s finished' % job) # Exit system in a good fashion sys.exit(0) def read_crontab(): job_list = [] fh = open(crontab, 'r') line = fh.readline() while line: if re.search('^#', line): line = fh.readline() continue if re.search('^ *$', line): line = fh.readline() continue job_list.append(JobEntry(line)) line = fh.readline() fh.close() return job_list def process_jobs(list): year, mth, day, hrs, min, sec, dow, None, None = localtime(time()) year -= 1 mth -= 1 day -= 1 dow -= 1 for entry in list: if entry.mins[min] == 0: continue if entry.hour[hrs] == 0: continue if entry.days[day] == 0: continue if entry.mnth[mth] == 0: continue if entry.dows[dow] == 0: continue os.spawnl(os.P_NOWAIT, interpreter, 'python', script, 'run', entry.cmnd) def check_jobs(): # Lees inhoud van crontab in tabel # Scan tabel voor jobs die moeten worden uitgevoerd # Per job : # Spawn Python20, python, script, 'run', job en argumenten job_list = read_crontab() process_jobs(job_list) # Exit this script in an orderly fashion sys.exit(0) def start_check_jobs(): os.spawnl(os.P_NOWAIT, interpreter, 'python', script, 'check') def sync(): global initialised (None, None, None, None, None, sec, None, None, None) = localtime(time()) initial = 60 - sec if not initialised: if initial == 60: initial = 0 initialised = 1 sleep(initial) def main(argv): if len(argv) == 1: logmsg('cron.py starting up') sync() while 1: start_check_jobs() sync() elif argv[1] == 'check': check_jobs() elif argv[1] == 'run': run_job(argv) if __name__ == '__main__': main(sys.argv) From max at alcyone.com Mon Feb 5 18:09:48 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 05 Feb 2001 09:09:48 -0800 Subject: Please translate this easy snip of C++ to Python References: <95kcbo$k8s@dispatch.concentric.net> <3A7E3C04.9EB02932@engcorp.com> <3A7ECEAB.DB6F8648@cybermesa.com> Message-ID: <3A7EDE5C.5D3F7050@alcyone.com> Jay O'Connor wrote: > Rainer Deyke wrote: > > > Better make that 'except None'. Unqualified 'except' clauses are > > generally > > a bad idea. In this case, you really don't want to > > catch...'ComputerExplodingError'. > > I hadn't seen that exception raised yet....is it new? What do you > usually do to handle it? Right past you. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ It is much safer to obey than to rule. \__/ Thomas a Kempis 7 sisters productions / http://www.7sisters.com/ Web design for the future. From sholden at holdenweb.com Sun Feb 11 18:20:32 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 11 Feb 2001 12:20:32 -0500 Subject: How to label loops? References: <981845104.329821352@news.t-online.de> Message-ID: First, convince me that loops need labelling! regards Steve -- -- Tools, training and technology to help you meet your information needs "Zamurai" wrote in message news:981845104.329821352 at news.t-online.de... From wware at world.std.com Wed Feb 7 20:19:41 2001 From: wware at world.std.com (Will Ware) Date: Wed, 7 Feb 2001 19:19:41 GMT Subject: embed Tkinter in C References: <95s3m1$db2$1@hecate.umd.edu> Message-ID: Arvind Mani (marvind at glue.umd.edu) wrote: > I am planning to build a user interface with Tkinter and integrate it with > an existing C program. > Can someone tell me where to find links to Tkinter C API and a tutorial Tkinter is a Python wrapper for the Tk gui toolkit, which is written in C and runs on Unix and Windows (and the Mac as well, I believe). If your program is written in C, you might want to connect directly to the Tk toolkit. Here's some info on Tk's C API: http://www.bbso.njit.edu/Documentations/TclTkMan/tk4.2b1/tk4.2b1API.html A possibly better strategy might be to create a Python wrapper for your C code, and then write Python code that connects your C code to Tkinter. This will probably be easier and more maintainable. Some resources that would be useful for this are the Extending-and-Embedding tutorial: http://www.python.org/doc/current/ext/ext.html and Swig, an automatic generator for wrapper code: http://www.swig.org/ http://www.swig.org/Doc1.1/HTML/Python.html -- import string,time,os;print string.join((lambda x:x[:10]+x[8:])(map( lambda x:string.center("*"*(lambda x:((x<24) ### Seasons Greetings, Will Ware *(x-3))+3)(x),24),range(1,28, 2))),"\n") ################ wware at world.std.com From cobrien at Radix.Net Mon Feb 19 00:30:45 2001 From: cobrien at Radix.Net (Cary O'Brien) Date: 18 Feb 2001 18:30:45 -0500 Subject: What to do after Python? References: <3A8F81BC.108488CA@pop3.qwestinternet.net> <96p5mu$3eq$1@gaia.intranet.cdegroot.com> Message-ID: <96plv5$gqg$1@saltmine.radix.net> In article , Roy Smith wrote: >cg at cdegroot.com wrote: >> I'd advise C as a second language because it forces you to deal with the >> computer behind all that code, which tends to give you a good >> perspective for other language. > >Actually, the problem with C is that it hides too much of the computer >behind all that code. I spent a few years writing C on alphas, and never >even found out how many registers the danged thing had. If you really want >to find out what the hardware is all about, learn assembler, which is >perilously close to handing a soldering iron to a software guy. > Your problem is that you C compiler was too good. I learned C and 68000 assembly at the same time with a stupid C compiler. Stupid meaning after a while we knew exactly what the C compiler would do. Often (in the days of vt220 terminals) two of us would work together debugging, one single-stepping through assembly, and one reading the C code and keeping in sync. If you said register you meant register. Plus if you did you loops just right you could get the 68010 cpu to go into wicked-fast-loop-mode. >Another alternative would be to learn lisp. It may not get you a better >job, but will give you the ability to write a better python major mode for >emacs :-) > Prolog is kinda different. Plus I like the SQL suggestion. Go buy Bruce's PostgreSQL book and go to town. -- cary >I don't suppose I could interest you in fortran? From com-zjensen at msn.com Sat Feb 10 07:30:31 2001 From: com-zjensen at msn.com (Zac Jensen) Date: Fri, 9 Feb 2001 23:30:31 -0700 Subject: What is better, JPython or Jython? References: Message-ID: <962n6a$v9$1@news.xmission.com> That's pretty cool, since that's not even the question you moron >"Kemp Randy-W18971" wrote in message news:mailman.981730586.31400.python-list at python.org... > Which is better: a boat or a car? It all depends on whether you are traveling by land or sea. Which is better: python or jpython? >Are you using it with Java or not? > From pen_man at my-deja.com Wed Feb 7 05:24:46 2001 From: pen_man at my-deja.com (penman) Date: Wed, 07 Feb 2001 04:24:46 GMT Subject: Getting one character at a time from sockets References: <95q044$2f9$1@nnrp1.deja.com> <95qg45$5b0$0@216.39.151.169> Message-ID: <95qim7$i38$1@nnrp1.deja.com> In article <95qg45$5b0$0 at 216.39.151.169>, Donn Cave wrote: > Quoth penman : > | Using ordinary TCP/IP sockets with the socket module in Python, I need > | to get a single character at a time from the client; something > | like "talk" in unix. How could I do that? (should be platform > | independent if possible) > | > | recv(1) didn't work. It waited till the carriage return came in. (non- > | blocking didn't work either) > > Don't mess around with non-blocking. Even recv(8000) will return > more or less immediately if you send any data at all, so it seems > kind of likely you're sending no data until the CR. Substitute a > test client that has its data built in, and just send('i') to the > server. I bet recv() will get it right away, Nagel algorithms > notwithstanding. > > Donn Cave, donn at oz.net > Thank you, Donn. But the problem is that I have to use ordinary telnet clients, such as CRT, Netterm, so let the users access to the server without any specialy programs. I wonder why nobody ever had the need to recv 1 character "unbuffered" in Python. Sent via Deja.com http://www.deja.com/ From tim.one at home.com Sat Feb 3 05:28:34 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 2 Feb 2001 23:28:34 -0500 Subject: "in" operator for strings In-Reply-To: <95ftl4$o6b$1@tyfon.itea.ntnu.no> Message-ID: [Magnus Lie Hetland] > ... > What's the built-in string-matching algorithm in Python? > (Not very important to me, but...) Brute force, using memcmp. Note that fancier algorithms that require precomputing tables of size proportional to the alphabet cardinality aren't very attractive in a Unicode world. See mxTextTools for a Boyer-Moore 8-bit string searcher. From thomas.heller at ion-tof.com Thu Feb 15 08:43:22 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 15 Feb 2001 08:43:22 +0100 Subject: Python20 and .pth files References: <3A89FB2B.C1CA8A5E@earthlink.net> <3A8B01F3.1000605@ActiveState.com> Message-ID: <96g1ar$kuoss$1@ID-59885.news.dfncis.de> "Mark Hammond" wrote in message news:3A8B01F3.1000605 at ActiveState.com... > greg Landrum wrote: > > > > However... one of the applications I'm working on creates Python COM > > servers which import Numeric. These work fine when I call them from Python > > applications (so none of my unit tests broke when I upgraded to 2.0, so I > > never noticed the problem). However, when I create one of these COM > > objects from within VB, I get an ImportError for Numeric. After much > > shrieking and pulling of my hair (I'm giving a demo of these objects on > > Friday, so I was not pleased to discover that they were mysteriously > > broken), I worked out a solution: add c:/Python20/Numeric to my PYTHONPATH > > environment variable. Now everything is happy. > > I believe this is a problem in certain embedding situations. Specifically, I believe it is because Python does not know its "home", so doesnt know where to load the .pth files from. Are you sure site.py is imported at all? There PYTHONPATH is extended by the contents of the .pth files. > > > The Question: > > Was it an accident that everything just worked before or has something > > changed? I know old versions of Numeric used to have an installer that may > > or may not have set registry keys to help out with this problem. > > Are .pth files being deprecated so that we (the users) should start > > badgering developers who still ship modules requiring them? > > I dont believe this would ever have worked. As you suggest, it is quite possible that only new versions of Numeric have .pth files. > New versions have a .pth file (since they are distributed via distutils), old versions used registry settings. > This is on my "to-do" list - having Python know its correct home in embedded situations would solve a few other problems too. > This is a bug in getpathp.c, see http://sourceforge.net/bugs/?func=detailbug&bug_id=131064&group_id=5470 > Mark. > Mark, please look at the bug. Otherwise you are forcing my to submit a patch ;-) Thomas From mrq at for.mat.bham.ac.uk Thu Feb 8 11:33:45 2001 From: mrq at for.mat.bham.ac.uk (Martyn Quick) Date: Thu, 8 Feb 2001 10:33:45 +0000 Subject: Some basic questions about Tkinter (probably v easy for experts!) In-Reply-To: References: Message-ID: On Wed, 7 Feb 2001, Fredrik Lundh wrote: > > have you read the introduction document? the first chapter > seems to answer your questions: > > http://www.pythonware.com/library/tkinter/introduction/hello-tkinter.htm Thanks very much for your answer Fredrik - I managed to get some menus working last night, so I think I'm starting to get the hang of things. I'll try having a thorough re-read of the Introduction now that I'm getting an idea of the syntax. > > armadillo.add_command(lable="Exit", command=exit) > > if you fix the typo, this adds a command item to the armadillo > menubar. when that item is selected, Tkinter calls sys.exit. I've realized one point that was confusing me. When I use sys.exit to finish a python script I would type sys.exit() but in the above you use exit rather than exit(). Is it generally the case that you don't use the brackets in the comannd=... part? (Sorry if this is easily to be found in the Introduction document!) Presumably this means that I can't use a command which relies on parameters? Thanks once again... 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 bsass at freenet.edmonton.ab.ca Tue Feb 27 08:53:45 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Tue, 27 Feb 2001 00:53:45 -0700 (MST) Subject: CPAN functionality for python In-Reply-To: <20010226180935.B7531@tummy.com> Message-ID: On Mon, 26 Feb 2001, Sean Reifschneider wrote: > On Mon, Feb 26, 2001 at 11:14:35AM -0700, Bruce Sass wrote: > >from outside the archive. The translation from a generic pkg to a > >distro specific pkg would be a problem for the disto to solve > >(probably a matter of repacking info about the pkg, then using > > The only way having automaticly-generated packages be possible is > if we really force a conformance from the authors of the packages. > I've packaged quite a number of RPMs in my day, and you can get pretty > close to just wrapping a tar file with some meta-information in > some cases, but these are the minority. I have assumed that submitted packages would need to meet a standard of some sort - was that incorrect? > In most cases you have to provide patches which fix incorrect paths > in the tar file (for example, the Python tar file uses > "#!/usr/local/bin/python" all over the place). That is to be expected... and only the distro is really equipted to handle these issues. > If we can force the distributions to be more compatible with being > packaged, it may be very easy. Otherwise, we may have to rely on > people contributing their time to building RPMs if we want to have > RPMs. I'm not sure what you mean here. The distributions are the ones doing the packaging, the Python version of CPAN should supply all the bits needed for the distros to perform that function. > >only way I can see to do that is to not package to anyones spec, but > >provide enough information so that anyone can package to their > >fav spec. > > I don't agree... I believe that we should embrace the different packaging > formats, not act like they don't exist. Maybe we see "embracing" them a little differently. I believe providing everything they need to turn a Python module/package into their standard format, using their packaging and QC tools, does them more of a service than providing pre-built packages created by a third party. I'm not saying binary style packages shouldn't be supported, just that the emphasis should be on portable (in that they can easily be turned into a system's native pkg format) source packages. > If the distutils package can be > made to generate native RPMs, that's great. The *CLIENT* program should > dictate that. If it can handle turning a distutil package into an RPM, > it'll have it's preference be a distutil package. That sounds like exactly what I was enquiring about - as long as the distutils pkg provides enough info for every distro to create their own pkg. > I don't believe having the archive not able to deal with different package > formats is acceptable. If that were the case, then if the package didn't > provide enough information to build an RPM, the user would have no option > within the archive of working around it. Agreed. The submission should not be accepted if it does not contain enough information to be packaged. - Bruce From dan at eevolved.com Fri Feb 2 18:15:57 2001 From: dan at eevolved.com (Dan Parisien) Date: Fri, 02 Feb 2001 17:15:57 GMT Subject: expanding a list and dict to a *args and **dict Message-ID: Is it possible to 'expand' a list or dictionary into its components to call a function expecting many parameters? I want to be able to call a function without accessing each individual element manually (list[0], list[1], list[2]) I'm sending random parameters over a network (*args and **dict). When I unpickle them on the other side, I get a python list and dictionary. I then call an arbitrary function (actually a reference to a function that was bound at runtime a la self.randomfunction = obj.specificfunction ) That function is not expecting a list and a dictionary, instead it is expecting specific parameters(that i don't know at runtime) and I want to take the list and turn it into a bunch of parameters like list[0], list[1], list[2] (but as stated above, I can't do that) Ha. I hope someone understood me :) Dan From jimholliman at heartsoft.com Thu Feb 8 22:41:42 2001 From: jimholliman at heartsoft.com (Jim) Date: Thu, 8 Feb 2001 15:41:42 -0600 Subject: C++ style Stream Operators Message-ID: <3a831395.0@216.0.152.7> I'd like to use C++style stream i/o operators, such as "file_object << some_stuff" in my python code. IS this sort of operator setup and what modules would I need to take advantage of them if so? Thanks Jim From sgriggs at pobox.com Tue Feb 6 13:16:09 2001 From: sgriggs at pobox.com (sgriggs at pobox.com) Date: Tue, 06 Feb 2001 12:16:09 GMT Subject: Pyt;hon 2.1a2 compile problems Message-ID: <95opu4$t8k$1@nnrp1.deja.com> Is anyone else having problems getting Python 2.1a2 to compile on Solaris? I'm using Solaris 2.8 with GCC 2.95.2 and just can't seem to get it to work. I can compile Python 2.0 on this same box. I'm just wondering if it's just me at this point. Thanks. Scott Griggs Sent via Deja.com http://www.deja.com/ From bridgman at wyeth.gsfc.nasa.gov Fri Feb 16 21:09:07 2001 From: bridgman at wyeth.gsfc.nasa.gov (Tom Bridgman) Date: Fri, 16 Feb 2001 15:09:07 -0500 Subject: Converting an instance to a subclass? References: <3A8D7636.B8161C45@wyeth.gsfc.nasa.gov> Message-ID: <3A8D88E3.9FF4CA4B@wyeth.gsfc.nasa.gov> I'm seriously considering your option #2. These utility scripts are doing things which are really non-standard for the process I'm developing. They just exist solely for the purpose of converting an old data format over to a new one, installing new defaults, checking that support files are in the right locations, moving them if they're not, etc. The methods defined for this should never be used once we switch over to the new system so I don't want them in my standard class library to confuse some future maintainer of the code. Thanks for your input, Tom D-Man wrote: > > On Fri, Feb 16, 2001 at 01:49:26PM -0500, Tom Bridgman wrote: > [snip] > | and I have a number of methods that return me instances or lists of > | instances of this class. These are part of my general library of > | classes for this project. > | > | However, I need to write a utility which will define methods that are > | only needed by the utility. I really don't want these methods to be > | 'permanent' members of the class so I define them in a subclass as part > | of the utility. > | > | Class B(A): > | def Cleanup(self,x,y,z): > | ... > | > > This is a good way to add functionality that isn't always needed -- > you can use instances of 'A' when it's not needed, and instances of > 'B' when it is. > > | Is there a way I can cast the instances of class A into instances of > | class B so I can use the additional methods? I can't find anything > | about it in "Programming Python" but then I'm not quite sure where to > | look either. > > Since you use the word 'cast', I take it you have some C, C++ or Java > experience. Those lanugages are statically typed, so if you declared > having one type, but really have another, you must explicitly tell the > compiler with a cast. Python is dynamically typed, so if you really > have a "different" type (it can't really be different since you didn't > declare it in the first place, but) you have it and python is happy. > > What I suspect is happening is that you are creating instances of A > when you really want B. > > >>> class A : pass > ... > >>> class B( A ) : pass > ... > >>> obj1 = A() > >>> obj2 = B() > >>> obj1.__class__ > > >>> obj2.__class__ > > >>> > > In this example, obj2 is an instance of class "B". Since "B" is a > subclass of "A", obj2 is also an instance of class "A". You can use > obj2 whereever an instance of A or B is expected. On the other hand, > obj1 is an instance of class "A", and won't work where an instance of > class B is expected. There is no way automatically to turn obj1 into > an instance of class B. There are a couple of ways to work around > though. > > 1) modify the factory functions to return instances of "B" instead. > Since it is a subclass, all existing code will work. > > 2) Make a conversion that will create a new instance of class "B" and > init all data members based on an instance of class "A" > > 3) Play some obscure tricks using python dynamism to add those > functions to obj1 even though they don't belong there > > #1 may be the easiest, but then you might as well just put the > functions in class "A" and only use them when you need to. > > #2 could be done in B's __init__ function : > > class B( A ) : > def __init__( self , instance_of_A ) : > self.value = instance_of_A.value > # ... > > Then when you want an instance of B, you can create it from the > given instance of A. > > #3 isn't good since it is obscure and will be difficult to maintain. > > HTH, > -D -- Dr. William T."Tom" Bridgman Scientific Visualization Studio Global Science & Technology, Inc. NASA/Goddard Space Flight Center Email: bridgman at wyeth.gsfc.nasa.gov Code 935 Phone: 301-286-1346 Greenbelt, MD 20771 FAX: TBD http://svs.gsfc.nasa.gov/ From janne at oops.nnets.fi Fri Feb 16 12:59:26 2001 From: janne at oops.nnets.fi (Janne Sinkkonen) Date: 16 Feb 2001 13:59:26 +0200 Subject: shelve and the best db possible References: Message-ID: Dan Parisien writes: > I really love shelve, but dbm doesn't seem to scale very well :( Could > anyone point me to a good db with a shelve interface? I've tried to get > bsddb3 to go, but the test scripts all die :( I have used an old bsddb 2.x interface from TCS with a largish data base (btree, hundreds of MB's, hundreds of thousands of updates) without any problems. Don't know whether it's still available somewhere. The module name is bsddb (or TCS.bsddb) -- Janne From embed at geocities.com Mon Feb 26 20:28:32 2001 From: embed at geocities.com (Warren Postma) Date: Mon, 26 Feb 2001 14:28:32 -0500 Subject: Splitting comp.lang.python References: Message-ID: <79ym6.2288$TW.12847@tor-nn1.netcom.ca> Not again!? We had this discussion ten times over. Anyone who feels like weighing in on this one should at least be polite and avoid beating the same dead horses, over and over again. I mean, doesn't anyone search Deja anymore? Oh yeah, Deja is gone, and replaced by the Beta Groups at groups.google.com. Oh well, ironically, now that we have no Deja.com, I think we are in for a Lot More of that old time Deja Vu. Warren Postma From thomas at xs4all.net Fri Feb 2 15:03:00 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 2 Feb 2001 15:03:00 +0100 Subject: sys.exit and exceptions (newbie question) In-Reply-To: <20010202130129.7059DA840@darjeeling.zadka.site.co.il>; from moshez@zadka.site.co.il on Fri, Feb 02, 2001 at 03:01:29PM +0200 References: <20010202002551.S962@xs4all.nl>, <3a7998cf.869169328@localhost> <20010202002551.S962@xs4all.nl> <20010202130129.7059DA840@darjeeling.zadka.site.co.il> Message-ID: <20010202150300.V962@xs4all.nl> On Fri, Feb 02, 2001 at 03:01:29PM +0200, Moshe Zadka wrote: > On Fri, 2 Feb 2001 00:25:51 +0100, Thomas Wouters wrote: > > You can use sys._exit(). > No you can't -- but you can use os._exit(). > Everything else Thomas said is true... D'oh! I really, really need vacation. I've made *four* errors this week! And one of them was even a sysadmin error (added an emailalias in the wrong file, so it didn't work) -- that hasn't happened in years... I think I may be going senile ;P Maybe-I-should-just-move-to-management-ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From s713221 at student.gu.edu.au Sun Feb 18 09:15:20 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Sun, 18 Feb 2001 18:15:20 +1000 Subject: how to unimport something References: Message-ID: <3A8F8498.34B00D23@student.gu.edu.au> Sean 'Shaleh' Perry wrote: > > Suppose I have a program which has logical segments. How do I run each segment > and have modules loaded in that segment get unloaded when I reach the next > one? The direct answer is Import a module into python >>>import modulename Delete a module >>>del modulename Mind you, you may want to post to the group an example of what you're doing. Importing modules can take some time to load in, they may be able to suggest a more efficient and safer method than module swapping to do what it is you're trying to do. If you're trying to do what I think you're doing, which is have a series of modules with similar named functions, and dynamically "plug/unplug" them from the interpreter, a better way may be to: >>>import modulea,moduleb,modulec (Import all your plugin modules at the start, drop the cost of module import into startup.) >>>module = modulea >>>module.function() (Which is actually modulea.function()) >>>module = moduleb >>>module.function() (Which is actually moduleb.function()) >>>module = modulec >>>module.function() (Which is actually modulec.function()) Unless you had the same functions and classes in each module, and they could accept each others argument patterns, there's the risk of your script failing because a piece of calling code called module.function() expecting modulea, but getting moduleb. Messy If you were planning to add different functionalities to the interpreter at the same time and remove that functionality later, you would seriously risk writing code that calls modulea functionality, only to crash your script because another piece of code wiped out modulea earlier. Finally, if you're thinking to only have the modules you need loaded into the interpreter at any time, this may save some memory, but will cost you in module loading time. Usually not worth it unless you're writing scripts which eg. run for days on a resource-scarce server and it only swaps modules a couple of times a day, or are running the scripts in a severely memory scarce environment. Joal Heagney/AncientHart From clgonsal at keeshah.penguinpowered.com Thu Feb 1 08:27:02 2001 From: clgonsal at keeshah.penguinpowered.com (C.Laurence Gonsalves) Date: Thu, 01 Feb 2001 07:27:02 GMT Subject: [Q] ftplib: How to compare date? References: <9I6e6.7505$p8.1228772@typhoon.southeast.rr.com> Message-ID: On Thu, 01 Feb 2001 05:43:33 GMT, Daehyok Shin wrote: >I like to compare the creation dates of two files using ftplib. >But, I cannot find any function to get the date of remote files. >How can I do it? I don't think there's any way to do this reliably. You can try and get a list of the directory, but different FTP servers will return the listing in different formats. If you only want it to work on known FTP servers, you can parse the format yourself though (string.split and time.strptime would probably come in handy at this point). Also, if you want to compare the time stamps of files on the local system with the time stamps of files on a remote FTP server, be aware that the clocks probably aren't in sync, and might not even be in the same time zone. -- C. Laurence Gonsalves "Any sufficiently advanced clgonsal at kami.com technology is indistinguishable http://cryogen.com/clgonsal/ from magic." -- Arthur C. Clarke From ssthapa at classes.cs.uchicago.edu Tue Feb 20 18:53:50 2001 From: ssthapa at classes.cs.uchicago.edu (ssthapa at classes.cs.uchicago.edu) Date: Tue, 20 Feb 2001 17:53:50 GMT Subject: Python 2.x breaks cmp() (was Re: A suspected bug) References: <96os85$1qe$1@panix3.panix.com> Message-ID: Aahz Maruch wrote: >>>>> L=[1j, 2j] >>>>> L.sort() >>Traceback (most recent call last): >> File "", line 1, in ? >>TypeError: cannot compare complex numbers using <, <=, >, >= >>>>> > >Is there any chance this can be treated as a bug and fixed for the >release of 2.1? Alternatively, given that we're already breaking code >with the change in the way complex numbers are handled, should cmp() now >raise an exception *every* time the type/class differs? If you are referring to the comparision of complex numbers, I'm not sure how the ordering would be done. For example consider 1 and 1j, they have the same magnitude so mathematically speaking there is no way to consistently order them like the real numbers where magnitude is a more useful measure. IIRC, for any given magnitude n there are an infinite number of complex numbers with that magnitude, namely all n*e^(ix) for real x. -- ---------------------------------------------------------------------------- | 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 junaftnoon at nospamplzyahoo.com Wed Feb 7 23:01:05 2001 From: junaftnoon at nospamplzyahoo.com (June Kim) Date: Thu, 8 Feb 2001 07:01:05 +0900 Subject: 2nd Python Seminar in Seoul Was a Success References: <95n463$anj$1@news.nuri.net> <95q39h$hji$5@newshost.accu.uu.nl> <95q8tj$1c8$1@news.nuri.net> <95rgng$8ul$1@nnrp1.deja.com> <3dn1bygrmt.fsf@ute.cnri.reston.va.us> Message-ID: <95sgmd$j8v$1@news.nuri.net> "Andrew Kuchling" wrote in message news:3dn1bygrmt.fsf at ute.cnri.reston.va.us... > John Grayson writes: > > I received a package from my publisher at Manning last night: > > Inside was the Korean translation of Python and Tkinter Programming! > > It is published by Infobook ISBN 89-8054-424-3. > > If people can point me at information about the Korean translations, > I'll happily add them to the list of non-English books in the Python > bookstore. > > --amk > There are a few Korean translations and original works as well. Below are the book titles and original publishers, followed by the translators, Korean publisher, and the URL of the web page for the book. (This list isn't comprehensive but it is all I know of, AFAIK) Python Pocket Reference, O'Reilly, translated by Kim, Tae-Sun. Hanbit Media http://www.hanbitbook.co.kr/look.htm?book_code=001016-00001 Learning Python, O'Reilly, translated by Lee, Kang-Sung. Hanbit Media http://www.hanbitbook.co.kr/look.htm?book_code=010201-00001 (The translator is the current president of Korea Python Users Group.) Python and Tkinter Programming, Manning, translated by Ryu Jung-Wook. Infobook. http://www.infobook.co.kr/cgi-bin/Vmk_BookInfo.cgi?bookinfo_but=????&in_book id=ISBN_89_8054_424_3 (This URL includes Korean characters, which means you couldn't access the page. In this case, follow this alternative URL of an online book store in Korea : http://www.wowbook.com/generic/book/info/book_detail.asp?isbn=ISBN1-884777-8 1-3 ) Internet Programming with Python, (by Aaron & Guido), translated by Kwak, Joon-Ki. Samkakhyoung. (translated in 1997 but out of print now) http://www.wowbook.com/generic/book/info/book_detail.asp?isbn=ISBN89-7467-43 5-1 About XML, (originally in Korean), Park Jae-Ho. Youngjin. https://www.youngjin.com/shop/ycom-s-global002-pre.asp?url=ycom-s-002-01-pre .asp&pcode=9788931415575 http://www.wowbook.com/generic/book/info/book_detail.asp?isbn=ISBN89-314-155 7-5 (This book is about XML but uses Python substantially) In addition to these, there are a number of on-going works to write about Python; moreover, I'm leading an open content project(in Korean), with collective authorship, for writing An Introduction to Computer Programming with Python -- it is geared towards complete newbies in computer programming and it's in the spirit of CP4E. I hope open content projects would evolve along with Python. Best regards, June From tjg at exceptionalminds.com Tue Feb 27 20:08:30 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Tue, 27 Feb 2001 11:08:30 -0800 Subject: IP Math anyone? In-Reply-To: <003f01c0a0c2$ac255040$a100000a@local>; from chris.gonnerman@usa.net on Tue, Feb 27, 2001 at 07:38:56AM -0600 References: <20010226170223.B29494@trufflehunter.avalongroup.net> <73931622.983270231@[10.0.0.101]> <003f01c0a0c2$ac255040$a100000a@local> Message-ID: <20010227110830.I29494@trufflehunter.avalongroup.net> Thanks to all of you who made this thread much more enlightening than expected! As I expected, it is a somewhat complex problem, for which I will probably throw together a class with a nice interface but internals of which are a crude hack, and then refine the internals as time allows. On Tue, Feb 27, 2001 at 07:38:56AM -0600, Chris Gonnerman wrote: > You neglected to tell us where to download your class from, or to attach > the source. I at least would like to see it. > > ----- Original Message ----- > From: "Tino Wildenhain" > Subject: Re: IP Math anyone? > > Hi Timothy, > > > > for teaching I made a class for this. > > > > you can instantiate it with a=ip('192.168.0.254/24') or > > a=ip('192.168.0.254','255.255.255.0') just using a=ip('192.168.0.254') > > would assign a appropriate subnet mask for this class (class B results in > > /16 or 255.255.0.0) > > > > Since IP-adresses are only 32bit non signed integers, they are internally > > represented > > like that. > > If you make a class like that you can simply add the support to add > > integers to > > it according to the subnet-mask you use. > > > > Regards > > Tino -- 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: 41 days 23:20 hours ago<< From chris.gonnerman at usa.net Sun Feb 4 02:11:30 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sat, 3 Feb 2001 19:11:30 -0600 Subject: Gratuitous Change (Was: Re: "in" operator for strings) References: <2jae6.119$o3.4587@news.world-online.no> <95beco$e0u$1@tyfon.itea.ntnu.no> <95birk0r0d@news1.newsguy.com> <95eb4r0csk@news1.newsguy.com> <006701c08dfa$08ed8c60$a100000a@local> <20010203094706.B30977@glacier.fnational.com> Message-ID: <007701c08e47$696012a0$a100000a@local> ----- Original Message ----- From: "Neil Schemenauer" Subject: Re: Gratuitous Change (Was: Re: "in" operator for strings) > Can you give some examples of changes you have to "put up with"? > The only controversial changes in 2.1a2 that I know of are nested > scopes, function attributes and weak references. The nested > scope changes are the only ones that affect existing code. You > have to forgive me if I think your spreading FUD. Well, that hurts, but I guess I have it coming. FUD is my enemy, let me spread no FUD. My primary complaint is against changes to the language semantics. I am against change in a language in general when the language is already IMHO the finest I've ever worked with. You are probably right, in that these changes in 2.1 are not so bad. On the other hand, I probably won't use them. Heck, I still import string. I'm not against the changes in 2.0, although I don't use most of them; I still have servers running 1.5.2 that would be a pain to upgrade. One thing I see a lot in 2.0 code that is legal but UGLY is: nstr = ''.join((s,t,u,v)) (for instance) but I guess you can write ugly code in any language. My only real complaint is the need to rebuild ALL MY EXTENSIONS every time the version is upgraded. The build process is painless under Linux but a pain under Windows and I must live in both worlds. Even under Linux, I wind up rebuilding a LOT of software because I use a LOT of Python. Yeah, I'm rambling. The point is (yes, I have one) that I think all changes are potentially dangerous. I do respect and trust GvR though, so perhaps I'll try 2.1 when it's not alpha anymore. BTW I've lost track... is 2.1 stackless or was that just a rumor? From ullrich at math.okstate.edu Fri Feb 2 15:58:08 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Fri, 02 Feb 2001 14:58:08 GMT Subject: pyXML support for XSL tranformations?? References: <94d1tj$6sa$1@nnrp1.deja.com> <3a6aef10.3738521@nntp.sprynet.com> <3A7232DB.C576B547@ogbuji.net> <94vg3k$ed9$1@nnrp1.deja.com> <3A7442FF.E1CFDF6D@ogbuji.net> Message-ID: <3a7ac7f1.3651537@nntp.sprynet.com> On Sun, 28 Jan 2001 16:04:18 GMT, Uche Ogbuji wrote: >"David C. Ullrich" wrote: > >> Once I got it working it went right onto my I-don't-see- >> how-you-guys-can-give-this-stuff-away list, btw - hope >> you don't have the idea I've been wanting my money >> back or anything. > >No, I just wanted to have things clear on the thread because there *was* >a time when installing 4Suite was a huge pain, and I'd like all to know >we've worked very hard to make it a breeze (with some help from Greg >Ward and distutils). The install (probably a year or so ago) _was_ very easy. I may as well say what was so stupid about me: There was a spot in the instructions about unzipping to a "suitable" directory, with no definition of "suitable". Didn't take me long to figure out what was unsuitable about the directory I used. That led to copying some things over some things. I didn't replace a certain subdirectory that already existed cuz I wasn't sure whether anything was using that stuff already. The XSLT didn't work. Then I replaced python\xml\dom with the one that appeared when I unzipped your package and everything worked fine. The "uncleanliness" I was alluding to was having to modify part of an existing installation. But if I were not an idiot I would have chosen a suitable directory to begin with and I wouldn't have noticed the change. Or I would have noticed that the stuff in the directory I was reluctant to replace was _also_ an xml\dom from 4Thought - I thought for no good reason that it was a module from an entirely independent source so that replacing it would likely break something else. >> > There is no >> > reason why you can't download 4Suite-0.10.1.tar.gz, untar it, run >> > "python setup.py install", and be completely ready to go. >> >> You only think that because you're not stupid enough to find >> ways to screw it up... > >Well, we'd actually like 4Suite to be easy to install even for >non-Pythoneers. I think I just slipped through the cracks there - knew just enough to do it wrong. Not your fault. > That's because some of the features are completely >unique in XML space, and we think we can actually draw some XML users to >Python if they don't have to work too hard to get started. That's why >we put together the HOWTOs which even walk you though installing Python. > >> > But just in case, there are a 4Suite Installation HOWTOs for UNIX and >> > Windows. >> > >> > See >> > >> > http://services.4Suite.org/topics/rdf/Top/Documentation/HOWTOs > > >-- >Uche Ogbuji >Personal: uche at ogbuji.net http://uche.ogbuji.net >Work: uche.ogbuji at fourthought.com http://Fourthought.com From SBrunning at trisystems.co.uk Fri Feb 9 15:45:05 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 9 Feb 2001 14:45:05 -0000 Subject: What is better, JPython or Jython? Message-ID: <31575A892FF6D1118F5800600846864D5B17DE@intrepid> > From: Zamurai [SMTP:zamurai at gmx.net] > It seems that JPython and Jython are quite similar, but what are the > differences between both? And which one is better? Jython supersedes JPython, so use the latter. Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From samschul at pacbell.net Mon Feb 5 09:07:41 2001 From: samschul at pacbell.net (Sam Schulenburg) Date: Mon, 05 Feb 2001 08:07:41 GMT Subject: Install PythonWin on top of Python 2.0 References: <95l4en$rbs$1@nnrp1.deja.com> Message-ID: <95ln0b$7vb$1@nnrp1.deja.com> In article <95l4en$rbs$1 at nnrp1.deja.com>, Deja User wrote: You need to get the 2.0 build I think it is build 135 > Hi, there: > > This is a question from a new user. I recently installed the BeOpen > Python 2.0 on my Win98 PC. Now I'd like to install the Win32 extension > so I download "win32all-125.exe". Unfortunately, I cannot install it > because this build insists on the presence of Python 1.5.x. Now, do I > have to install 1.5 so as to install PythonWin? Would the author of > PythonWin please do us a favor to relax the version check in PythonWin? > > Thanks, > > Bin > > Sent via Deja.com > http://www.deja.com/ > Sent via Deja.com http://www.deja.com/ From idfx at my-deja.com Fri Feb 9 20:29:14 2001 From: idfx at my-deja.com (idfx) Date: Fri, 09 Feb 2001 19:29:14 GMT Subject: Python/C++ interface References: <3A79D28B.1BEB46A0@cybermesa.com> Message-ID: <961gdt$fm4$1@nnrp1.deja.com> In article <3A79D28B.1BEB46A0 at cybermesa.com>, Jay O'Connor wrote: > All, > > I was doing some testing with the Python->C++ interface and ran into > something odd. > > The example shows calling a C function from python with > > import spam > spam.system ("ls -l") > > and on the C++ side... the signature reads > PyObject* spam_system(PyObject *self, PyObject * args) { > ... > } > > Now. On the C++ side, args is considered, and parsed, as a Tuple. > However, what I found was that a Tuple was not being passed, just a > String. The only time a Tuple was passed was if there was more than one > argument. The whole argument list would be converted to a Tuple, then. > > Is this an error in the documentation? Or has the passing method > changed between 1.5.x and 2.0 (I'm using 2.0) and the documentation is > just out of date? > > Also, is there a good way of printing the name of the type of a > PyObject? I may be wrong, or over-simplifying, but I think you've gotten confused by the terms, understandably. Yes, args is read into a tuple, always, but if there's only one argument, then it becomes a tuple of length 1. ie: tpl = ("yourstring",) that way, you can refer to as many arguments as there are, ( numargs=len(tpl) ) instead of worrying about special cases for 1 or 0 arguments. Your args is still a string, it's just that it's a string that happens to be an element of a tuple. OTOH, I may be totally mis-reading your problem. The other possibility is that, for a system call, (e.g. 'ls -l'), C++ makes a string of the argument(s) to preserve the command you are passing to the system, which should be a string anyway, or so I'm told. As for the printing of type names, this is something I had trouble with, too. Eventually, I came up with this, although I'm sure there are more elegant ways to address the problem: def printype( obj ): naym = `type(obj)` # string it, i = naym.find("'") naym = naym[(i+1):] # trim it, i = naym.find("'") naym = naym[:i] return naym # return it! (as a string) Hey, what can I say? It works. Usually. ; ) Hope that helps. -- yrs, in_sanity, idfx Sent via Deja.com http://www.deja.com/ From adaminthedomaindevtty.net Sat Feb 10 00:34:56 2001 From: adaminthedomaindevtty.net (Adam Logghe) Date: Fri, 9 Feb 2001 15:34:56 -0800 Subject: PEP status and python-dev summaries References: <3dg0hn8zlr.fsf@ute.cnri.reston.va.us> Message-ID: <3a847ca3$1_1@news.nwlink.com> Thanks for the summaries Andrew. I will be very sorry to see them go. While I didn't see any need to comment, I was very glad to have an idea of what was in the pipe. I would very much like to see the PEPs themselves as they come through so I can plan ahead for changes to my own code as Python moves along. I would suggest that the full text of the PEP should be posted for every change. While this would be painful on a mailing list, I would not find it to be an issue whatsoever on a newsgroup. As a guide to what has changed, ideally a diff from the old version would be attached on the end of the new PEP version. This would allow a quick visual look at the changes. It may not be easy to make perfect sense of the change, it would quickly point out whether the PEP had undergone minor or major change. I would suggest that publishing often provides at least two advantages. A. Eliminating the decision of whether or not to publish will eliminate the tendency for the PEP undergo significant "creep" as minor changes add up to significant changes in actual function. I think anyone that programs can agree that minor syntax changes can and do have profound effects. B. Having the PEP show up in front of people at multiple points during it's life will expose it to more eyeballs. If full posting is not pursued perhaps you might do something like- A weekly summary of the mail traffic on the list simply by listing of the active PEPs and then the number of times that PEP number appears in email subject or body over the week. I would hope that people try to include the PEP number in the subject line as a matter of courtesy anyway. While this may not be the most accurate it would give us a simple representation of the activity around a PEP and would perhaps spur further investigations. Thanks again. Sorry to see the Summary go but you shouldn't let it get in the way of coding. ; ) I will look forward to however Jeremy and Barry decide to proceed. Adam Logghe adam in the domain devtty.net "Andrew Kuchling" wrote in message news:3dg0hn8zlr.fsf at ute.cnri.reston.va.us... > Jeremy Hylton writes: > > - Regular announcements of PEP creation and PEP status changes should > > be posted to comp.lang.python and c.l.p.a. > > Should the full text of PEPs be posted at some point? Perhaps the > first draft, and significant revisions, should be posted so that > people can follow-up directly to the PEP. "Significant" will be left > up to the PEP author; you wouldn't repost after every typo or minor > clarification, but if your first approach was completely bogus, you'd > post the massively revised version. > > --amk From richard at iopen.co.nz Wed Feb 14 22:40:14 2001 From: richard at iopen.co.nz (Richard Waid) Date: Thu, 15 Feb 2001 10:40:14 +1300 Subject: CPAN functionality for python References: Message-ID: <96eu1l$1m3r$1@raewyn.paradise.net.nz> In article , "Oleg Broytmann" wrote: > On Tue, 13 Feb 2001, Doug Hellmann wrote: >> > Ok, so we've found one of these 2 or 3 mirrors. >> > >> > > - Each mirror runs a ZEO client program and its own Zope >> > > server. >> > >> > What will be these other 1 or 2 mirror sites that will run Zope? >> >> Why do you assume no one will run Zope? > > I didn't assume. I know for sure there are not much Zope > installations, and most FTP mirrors will not agree to run Zope for us. Something that seems to be overlooked here - Zope might not be run by large numbers of sites, but the sites that do run it are usually by people fairly keen on Python. I'd suggest that while we might not get huge numbers of mirrors initially, we'd get _enough_ (at least 1-3 per continent to begin with). The advantage of Zope is that you could prototype the system quickly and easily, as well as being an (almost) pure python solution, which just seems 'right' somehow :) Has anyone mentioned using XMLRPC to transfer the metadata and requests around? It would be trivial to leverage that feature with Zope. The actual transfers could be done out-of-band, using ordinary FTP or HTTP. I'd suggest that there were two kinds of mirrors - meta data, and actual data. The actual data could be stored on a regular FTP server, the metadata could be accessed via XMLRPC from a Zope server. A little like www.rpmfind.org in a way. Richard Waid Network/Software Engineer http://iopen.co.nz From quinn at lira.ugcs.caltech.edu Mon Feb 12 00:53:26 2001 From: quinn at lira.ugcs.caltech.edu (Quinn Dunkan) Date: 11 Feb 2001 23:53:26 GMT Subject: Closing a file before or after return? References: <960t2j$9n9$1@cubacola.tninet.se> Message-ID: On Fri, 9 Feb 2001 14:58:39 +0100, Gustaf Liljegren wrote: >I'm using Python 2.0. > >Have a look at this function. It checks if a particular user (mail adress) >exist in a .htpasswd file. The user name is what comes before ':' on each >line. > ># Check if user exists >def user_exist(user): > f = open('.htpasswd', 'r') > for line in f.readlines(): > i = string.find(line, ':') > if line[:i] == user: > return 1 > >I'd like to close the file too, but I don't know where to put that >statement. Of course, the file should be closed in both cases -- not just >when the user is found. # Check if user exists def user_exist(user): f = open('.htpasswd', 'r') try: for line in f.readlines(): i = string.find(line, ':') if line[:i] == user: return 1 finally: f.close() ... will work. But it's not necessary, since python will close the file for you when the last reference disappears. Explicitly deallocating anything more complicated than memory or fds is usually good practice, though. From MarkH at ActiveState.com Sat Feb 24 02:44:27 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sat, 24 Feb 2001 01:44:27 GMT Subject: win32com and makepy References: <88id9tgj54l5q8rgvtss4tc9u9k91kd0kn@4ax.com> Message-ID: <3A97111F.9050705@ActiveState.com> Sean Laurent wrote: > Howdy All, > I'm having a strange problem with win32com.client.Dispatch(). I used > win32com\client\makepy.py to successfully generate Python sources. > Unfortunately, after I call win32com.client.Dispatch(), the object I > get back is of type "COMObject" instead of one of the generated > classes. This comes up fairly regularly, and unfortunately it depends on the object in question. The simplest work around is to use the classes in that generated module directly. Eg: mod = gencache.EnsureModule('{000C1092-0000-0000-C000-000000000046}',1033, 1, 0) i = mod.WhateverTheClassNameIs() And to make life more painful: >>>> db = i.OpenDatabase("d:\\temp\\test.msi", 0) Will need to done like: db = i.OpenDatabase("d:\\temp\\test.msi", 0) db = mod.Database(db) # Assuming "Database" is the class name Mark. From shaleh at valinux.com Sat Feb 17 08:07:52 2001 From: shaleh at valinux.com (Sean 'Shaleh' Perry) Date: Fri, 16 Feb 2001 23:07:52 -0800 Subject: a few linux/unix related questions In-Reply-To: <3a8e191f$0$25513$7f31c96c@news01.syd.optusnet.com.au>; from c941520@alinga.newcastle.edu.au on Sun, Feb 18, 2001 at 05:19:38PM +1100 References: <3a8e191f$0$25513$7f31c96c@news01.syd.optusnet.com.au> Message-ID: <20010216230752.A14988@valinux.com> On Sun, Feb 18, 2001 at 05:19:38PM +1100, Ben de Luca wrote: > I was wondering how i catch various signals in nix python so i can exit my > programs gracefully? > import signal > also how might i start another application then have two way communication > between it's shell and the python program that started it? > os.popen() # just like in C DESCRIPTION The popen() function opens a process by creating a pipe, forking, and invoking the shell. Since a pipe is by defi- nition unidirectional, the type argument may specify only reading or writing, not both; the resulting stream is cor- respondingly read-only or write-only. From aahz at panix.com Wed Feb 7 14:35:03 2001 From: aahz at panix.com (Aahz Maruch) Date: 7 Feb 2001 05:35:03 -0800 Subject: Variable depth of nesting References: Message-ID: <95riu7$6f4$1@panix3.panix.com> In article , Jacek Generowicz wrote: > >Is it somehow possible to write loops with variable nesting depths? Try recursion. -- --- 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 Life as a contractor: when they tell you it's going to rain, sometimes it drizzles and sometimes it pours. From Noah at noah.org Thu Feb 22 09:27:02 2001 From: Noah at noah.org (Noah) Date: Thu, 22 Feb 2001 00:27:02 -0800 Subject: Non-blocking pipe read under Windows NT Message-ID: Hmmm... Windows Python2.0 does not have fcntl. How do I do a non-blocking select on a Pipe file descriptor? Under UNIX I can do something like this: # hard way to read a file import os, fcntl, FCNTL # Open a pipe to read a file. (fin, fout, ferr) = os.popen3 ('cat testfile') # Turn off blocking on file. read() will then return -1 if no data flags = fcntl.fcntl (fout.fileno(), FCNTL.F_GETFL, 0) flags = flags | FCNTL.O_NONBLOCK fcntl.fcntl (fout.fileno(), FCNTL.F_SETFL, flags) # Print out the file without blocking. done = 0 while !done: (r,w,e) = select.select ([fout], [], [], None) if len(r) > 0: data = r[0].read() if data == -1: done = 1 else: print data From fellowsd at cs.man.ac.uk Thu Feb 22 10:54:16 2001 From: fellowsd at cs.man.ac.uk (Donal K. Fellows) Date: Thu, 22 Feb 2001 09:54:16 +0000 Subject: Weird Language Features In-Reply-To: <008F0A63472BD311AF9800104BCD102561CCA6@minirex.vmlabs.com> (message from John Schmitt on Wed, 21 Feb 2001 20:19:05 -0800) References: <008F0A63472BD311AF9800104BCD102561CCA6@minirex.vmlabs.com> Message-ID: John Schmitt > Doesn't Applescript do something like this? I recall browsing the docs > where they mentioned that you can program Applescript in more than one > dialect. I guessed from the docs that you can write Applescript program in > English, French, and Japanese. If you write an Applescript program in one > language (ie English), change your dialect (ie to French) and load the > program in your editor again, the source code will show up in the new > language (ie French). Do I understand that correctly? It's a Mac, so I've no idea! I have heard rumours to this effect though. However, to me this says that the raw program text is a binary form that is never actually displayed to anyone in the normal course of things. Furthermore, this auto-translation is deeply unlikely to affect the bits of the program that usually need attention; strings shown to users (and possibly the names of identifiers in the program if you need it to be maintained by someone with a different native language.) Somehow I'm fairly sure that AppleScript can't change the language of those automatically (since no-one else in the world can either, as many manuals are ample demonstration of... :^) A downside of this is that it makes it difficult for people in different countries to discuss applescript properly, since a correct example fragment for one person might be complete gibberish for another. You'd have to pass structured documents about instead of just plain text messages... :^( Donal. -- Donal K. Fellows, Department of Computer Science, University of Manchester, UK. (work) fellowsd at cs.man.ac.uk Tel: +44-161-275-6137 (preferred email addr.) (home) donal at ugglan.demon.co.uk Tel: +44-1274-401017 Mobile: +44-7957-298955 http://www.cs.man.ac.uk/~fellowsd/ (Don't quote my .sig; I've seen it before!) From tim_one at email.msn.com Thu Feb 1 07:36:19 2001 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 1 Feb 2001 01:36:19 -0500 Subject: "in" for dicts (was: Python 2.1 function attributes) In-Reply-To: <20010130095928.A962@xs4all.nl> Message-ID: [Tim] > we also haven't pulled the platform-dependent tricks Perl does > to optimize char-at-a-time reading the way vendors *should* > optimize fgets() but almost never do (Tru64 Unix appears to be > the sole probable exception to date). [Thomas Wouters] > FreeBSD, actually, had insane performance in that area as well. > (getc() being just as fast as getc_unlocked(), in processes with > only a single thread active.) This one doesn't have anything to do with locking or not, it has to do with whether the inner loop is optimized to use register shadows of _iobuf members, and to use the platform's moral equivalent of the _cnt member to avoid needing to check for EOF in the inner loop. It's not "legal" to do that in user-level code, because it requires breaking into the FILE* abstraction. Vendors can do it under the covers, although apparently almost never do. The unique thing about Tru64 Unix was the report that using the fgets() method was substantially faster than using the getc_unlocked() method; that's darned hard to account for unless Tru64 optimizes the inner loop of fgets() (as Perl does). IOW, just using getc_unlocked() still leaves a pile of *potential* improvement on the floor, even on a single-thread run, but improvement you can't get at without cheating (unless the vendor libc authors were savvy enough to do it for you). If Perl while(<>) is still substantially faster on FreeBSD than Python 2.1 using the fgets() method in single-thread runs, platform failure to optimize fgets() in this way is a top contender for "why". From syver at NOSPAMcyberwatcher.com Fri Feb 16 02:00:14 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Fri, 16 Feb 2001 02:00:14 +0100 Subject: Python emacs mode (newbie) Message-ID: <96hu7d$4pq$1@troll.powertech.no> Is there anybody who has any idea on how to implement a module loading function in GNU Emacs like the one Pythonwin has? The basic idea is that instead of writing a file name you write a module name, like ex: httplib or win32com.client.dynamic and the editor will load the specified module. I guess the implementation would work around searching the python path, but I am total newbie in elisp (and lisp itself for that matter) and could use some pointers as to how to search the filesystem from elisp, get the registry keys or environment variables for the pythonpath, and how to load a file into the current window. From h4rv3st.m00n at gmx.net Thu Feb 1 20:00:50 2001 From: h4rv3st.m00n at gmx.net (Harvest T. Moon) Date: Thu, 1 Feb 2001 20:00:50 +0100 Subject: Q: elements in a list [newbie] Message-ID: <95cbfs$gu0iq$1@ID-22517.news.dfncis.de> i hope this is not some kind of 'very stupid' question, how can i find out how many elements are in a list? (generated by file.readlines()) Harvest T. Moon From peter at engcorp.com Thu Feb 8 06:42:44 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 08 Feb 2001 00:42:44 -0500 Subject: Problem with py2exe References: <95s54j$c72$1@gossamer.itmel.bhp.com.au> Message-ID: <3A8231D4.1E5951A6@engcorp.com> Austin Wilson wrote: > > I have just downloaded py2exe and I am trying to freeze a program. However, > I am getting the following output. Can anyone help. > > BTW: I am using Python20 and wxWindows 2.2.2 on Win98. > > changing back to 'C:\Program Files\Python20' [snip] > ValueError: list.remove(x): x not in list I got the same thing ("list.remove(x) raising ValueError") but happily py2exe _still_ managed to generate the executable successfully and I was able to run the resulting program without difficulty! Not that this helps much, but I have to say I was pretty pleased that something that came without guarantees, which I couldn't take the time to fix when it failed, still managed to do the job I needed in a pinch. A big Thank You to the py2exe crew! :-) From bill at libc.org Mon Feb 12 21:00:55 2001 From: bill at libc.org (Bill Anderson) Date: Tue, 13 Feb 2001 03:00:55 +0700 Subject: Embedding UNIX Commands References: <13EE655665F4D311AB4D0008C789498A01EE2C3C@zei02exm02.cork.cig.mot.com> Message-ID: In article , "Erno Kuusela" wrote: > In article , D-Man > writes: > > | I don't think you can use setenv -- that is a csh thing, and system() > | won't even start up a shell (AFAIK). Even if it did, it wouldn't do > | you any good since that shell would terminate and its environment > | would be meaningless. (Also, on Linux systems bash is the default > | shell) > > actually, system() (and popen()) pass the command line to /bin/sh under > unix. Which _is_ bash (on most Linux Dists): ucntcme at locutus in /home/ucntcme $ ll /bin/sh lrwxrwxrwx 1 root root 4 Jan 13 19:58 /bin/sh -> bash* From thomas.heller at ion-tof.com Thu Feb 8 10:48:05 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 8 Feb 2001 10:48:05 +0100 Subject: Problem with py2exe References: <95s54j$c72$1@gossamer.itmel.bhp.com.au> Message-ID: <95tq0o$ie1b4$1@ID-59885.news.dfncis.de> "Austin Wilson" wrote in message news:95s54j$c72$1 at gossamer.itmel.bhp.com.au... > Hi > > I have just downloaded py2exe and I am trying to freeze a program. However, > I am getting the following output. Can anyone help. > > BTW: I am using Python20 and wxWindows 2.2.2 on Win98. > > Thanks > Austin > > > changing back to 'C:\Program Files\Python20' > creating dist\oww\oww.exe > Using stub 'py2exe\run.exe' > Resolving binary dependencies > Traceback (most recent call last): > File "setup.py", line 6, in ? > scripts=["oww.py"], > File "c:\program files\python20\lib\distutils\core.py", line 138, in setup > dist.run_commands() > File "c:\program files\python20\lib\distutils\dist.py", line 829, in > run_commands > self.run_command(cmd) > File "c:\program files\python20\lib\distutils\dist.py", line 849, in > run_command > cmd_obj.run() > File "py2exe\py2exe.py", line 365, in run > self.copy_dependend_dlls(final_dir, use_runw, dlls) > File "py2exe\py2exe.py", line 417, in copy_dependend_dlls > alldlls.remove(self.get_exe_stub(use_runw)) > ValueError: list.remove(x): x not in list > > > Which py2exe version did you use? Can you send me your script by private email so that I can take a look? Thanks for trying it, Thomas From db3l at fitlinxx.com Wed Feb 14 02:18:45 2001 From: db3l at fitlinxx.com (David Bolen) Date: 13 Feb 2001 20:18:45 -0500 Subject: breasking out of a while loop (in an if statement) References: <3A899AD8.B4182CA4@cs.strath.ac.uk> Message-ID: Lee Reilly CS1997 writes: > Hi, I wonder if anyone could be kind enough to point out what I am doing > wrong here (please see code below). (...) > -=---=-=--=-==-=-=-=-== > while (j!=0): > if (radiobutton=='comma'): > tempString = string.split(text[i-1], ",") > else: > tempString = string.split(text[i-1], "\t") > > matric = string.rstrip(string.lstrip(tempString[0])) > SQL = "select * from STUDENTS where matric= '" + matric + "'" > result=db_conn.query(SQL) > result = len(result) > if (result>=3): > return "Student with matric value " + matric + " already exists > in the database" > # break > else: > j=j-1 > -=---=-=--=-==-=-=-=-== > > => Error Type: IndexError > => Error Value: list index out of range > > I'm using Python with Zope BTW. > > Can anyone see my problem? Any help would be greatly appreciated ;-) It would help to have the full traceback since that would highlight the line where the actual error is occuring. Also, it looks like this code depends on surrounding code (e.g., where is "i" or "text" set?), so having more detail about that surrounding code might help. But given the error, and assuming that the error is actually within this specific code, then it would seem to me to either be arising from your reference to "text[i-1]" or "tempString[0]". In the former case, you should verify that "text" has the contents you expect and that it has enough entries in any pass through the loop as indexed by "i-1". I think the latter case is safe, since from what I can see, using string.split with a dividing character will always at least produce a single entry in the list, although it may be an empty string. But you might want to verify it in this actual code as well, since at least in Python 1.5.2, string.split does return an empty list (e.g., if I split an empty string on the default separator) in some cases, which could then yield the IndexError when you try to access element 0. -- -- 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 ssthapa at classes.cs.uchicago.edu Wed Feb 21 02:12:28 2001 From: ssthapa at classes.cs.uchicago.edu (ssthapa at classes.cs.uchicago.edu) Date: Wed, 21 Feb 2001 01:12:28 GMT Subject: What of Siphon? References: <3A92C86D.282751E3@andrewcooke.free-online.co.uk> Message-ID: Andrew Cooke wrote: > >My ISP seems to have decided the rest of the world doesn't exist (apart >from usenet, which makes it a very odd world that remains), but isn't >this connected with the CPAN-for-Python project? The name rings a bell. > >May be completely wrong... >Andrew Yes, it is. -- ---------------------------------------------------------------------------- | 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 marc.vollmer at mahr.de Tue Feb 27 08:52:22 2001 From: marc.vollmer at mahr.de (Marc Vollmer) Date: Tue, 27 Feb 2001 08:52:22 +0100 Subject: Newbie: Problems with PythonWin and wxPython Message-ID: <97fmla$p8o62$1@ID-59219.news.dfncis.de> Hello, My system is: Windows 2000 PythonWin 2.0 (win32all build 135) wxPython I start the example >>wxpython\lib\wxPlotCanvas.py<< with F5. At the first and second time the program runs normally, but by the third start pythonwin cancel with memory (read) problems. How I can elimate this problem? Thanks Marc Vollmer From stephen_purcell at yahoo.com Wed Feb 14 11:31:29 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Wed, 14 Feb 2001 11:31:29 +0100 Subject: Getting an instance's class name? References: <96dkeb$fcj$1@news.rz.uni-karlsruhe.de> Message-ID: <20010214113129.A9420@freedom.puma-ag.com> Bjoern Giesler wrote: > can anyone tell me how to obtain the name(s) of the class(es) that > constitute an instance's type? > With the '__class__' attribute of the instance, and the '__name__' attribute of the class: >>> p = Exception() >>> p.__class__.__name__ 'Exception' >>> Note that you'll get an attribute error for objects that are not class instances. For non-class instances, a handy way to get the type name is: >>> p = 1 >>> type(p).__name__ 'int' >>> -Steve -- Steve Purcell, Pythangelist http://pyunit.sourceforge.net/ http://pyserv.sourceforge.net/ Available for consulting and training. "Even snakes are afraid of snakes." -- Steven Wright From db3l at fitlinxx.com Wed Feb 28 02:26:13 2001 From: db3l at fitlinxx.com (David Bolen) Date: 27 Feb 2001 20:26:13 -0500 Subject: Nested scopes resolution -- you can breathe again! References: Message-ID: Robin Becker writes: > yes, but it would be just as easy to get the failure to do that. The > message may come from windows, but the extension (in our case zlib) The reason I suggested placing a python15.dll on the system is to get rid of the Windows message, leaving it just to the Python ImportError. > still wasn't loaded and that should have been enough, but we had a > try/except around the particular import. Finding a matching pyd/dll > which then fails to load is surely not 'just an import error' even if it > eventually gets raised as one. Well, but it doesn't have to be too much work. I'm thinking of the specific ImportError of: "Module use of python15.dll conflicts with this version of Python." in which case you know that you have an old extension (which has to be on Python's sys.path somewhere), and that one of three things are true: 1. The imported module directly depends on python15.dll (probably most likely for C extension modules being directly imported, like zlib). 2. The module you imported itself imports some other module with the dependency - in that case you have the traceback showing which import of which module failed, which reverts to the prior 1. 3. The module has a Windows DLL dependency which eventually pulls in python15.dll. In this case, you know the top level module, so use a standard windows tool like depends to check the dependencies. It's really only case (3) where you need something more than Python itself provides, but even in (3) you know the module to check, and it's a relatively straight forward path to fully identifying the root cause. It should also be reasonably rare since most extension modules directly use python15.dll rather than linking to another DLL which itself is the extension. Of course, none of this is to excuse the mess that is Windows DLL-land :-) -- -- 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 guido at digicool.com Mon Feb 26 19:22:45 2001 From: guido at digicool.com (Guido van Rossum) Date: Mon, 26 Feb 2001 13:22:45 -0500 Subject: [Distutils] Re: CPAN functionality for python In-Reply-To: Your message of "Mon, 26 Feb 2001 11:14:35 MST." References: Message-ID: <200102261822.NAA26272@cj20424-a.reston1.va.home.com> > There are enough different packaging schemes around that it seems > unnecessarily heavy-handed to pick one (or two or three) over the > others - Python should not appear to favor any paticular system. The > only way I can see to do that is to not package to anyones spec, but > provide enough information so that anyone can package to their > fav spec. But practicality beats purity: if a large fraction of users, especially newbie users, are using a specific platform, it makes a lot of sense to provide pre-packaged distributions for them! E.g. Windows installers, Red Hat RPMs. (So far my experience with Windows installers is much more positive than with RPMs though -- RPMs forever seem to depend on some version of some other RPM that you don't have.) --Guido van Rossum (home page: http://www.python.org/~guido/) From owen at astrono.spamwashington.emu Fri Feb 23 17:41:26 2001 From: owen at astrono.spamwashington.emu (Russell E. Owen) Date: Fri, 23 Feb 2001 08:41:26 -0800 Subject: package question: getting names one level deep? Message-ID: I like to break my code up into lots of files -- typically one file contains a class and turn a related set of files/classes into a package. When a file contains a class, naturally I give the file the same name as the class. However, I've not found a nice way to refer to the resulting classes. I hope I'm missing some easy, standard trick. Say I have a directory structure such as: apackage/ __init__.py which contains __all__ = [list of all files] classa.py classb.py ... To use these classes I write: import apackage x = package.classa.classa(etc) It's that duplicated file-name.identical-class-name that I'd like to eliminate, so I could say: import apackage (or something) x = apackage.classa(etc) Basically I'd like to do an import * into the "apackage" namespace, and ideally I'd like "import apackage" to somehow magically do it. In other words, ideally I'd like to set up my packages so they act as if all their code (at least all intended-to-be-visible-to-the-outside-world code) was in a single module. Any hints? -- Russell From adolfo.benin at riskmap.it Thu Feb 15 19:55:33 2001 From: adolfo.benin at riskmap.it (Adolfo Benin) Date: Thu, 15 Feb 2001 19:55:33 +0100 Subject: COM server info In-Reply-To: Message-ID: <5.0.2.1.0.20010215193232.00a63eb0@mail1.cs.interbusiness.it> Hi, I've developed a COM object in Python, then I regitered it as a DCOM on my machine. Every time a client makes a request to the server DCOM, the Python interpreter is launched and the COM is created. But when the client ends, the COM server also ends. So every call to the server creates a new python interpreter instance in memory! Is there a way to keep the COM server alive using always the same COM object instance? I have already performed this task succesfully using CORBA (single servant CORBA object), but I need to expose the server as a COM object too. Have you got any suggestion? Thanks, Adolfo. From dbrueck at edgix.com Tue Feb 13 16:50:12 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Tue, 13 Feb 2001 08:50:12 -0700 Subject: spawnv question In-Reply-To: Message-ID: argv[0] is reserved for the program name. > -----Original Message----- > From: python-list-admin at python.org > [mailto:python-list-admin at python.org]On Behalf Of Daniel Klein > Sent: Tuesday, February 13, 2001 8:32 AM > To: python-list at python.org > Subject: spawnv question > > > Here is a snippet of code I'm using with the 'spawnv' command: > > import os > args = ('http://www.python.org', 'http://www.python.org') # This works > os.spawnv(os.P_NOWAIT, 'c:\progra~1\intern~1\iexplore', args) > print "done" > > The Python Reference for the 'spawnv' command says: > > "Execute the program path in a new process, passing the > arguments specified in > args as command-line parameters. args may be a list or a tuple." > > My question is, why do I have to specify the url argument twice > in the 'args' > variable. It doesn't seem to work properly if I specify it as a 1-element > tuple, ie... > > args = ('http://www.python.org',) # This doesn't work > > Thanks, > Daniel Klein > > -- > http://mail.python.org/mailman/listinfo/python-list From dsavitsk at e-coli.net Fri Feb 2 23:38:50 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Fri, 2 Feb 2001 16:38:50 -0600 Subject: ADO/ODBC call via Python/IIS References: <95f558$jgl$1@nnrp1.deja.com> Message-ID: <%FGe6.31314$Ch.7369562@newsrump.sjc.telocity.net> > > adoConn.Open('pyasp') > Is it possobile pyasp is a user DSN, when ASP expects systems DSNs? if this is the issue, asp and python work well (faster in fact on a web server) with dsn-less connection strings. ds From adam at deprince.net Wed Feb 21 21:56:57 2001 From: adam at deprince.net (Adam DePrince) Date: Wed, 21 Feb 2001 15:56:57 -0500 Subject: newbie - concatanating 2 lists References: Message-ID: <3A942B99.490C286C@deprince.net> Remco Gerlich wrote: > Sean 'Shaleh' Perry wrote in comp.lang.python: > > On 21-Feb-2001 Gnanasekaran Thoppae wrote: > > > i am just beginning to use python. > > > i have: > > > li1 = ['a', 'b', 'c'] > > > li2 = ['x', 'y', 'z'] > > > i want: > > > li3 = ['ax', 'by', 'cz'] > > > how do i do it? > > python 2 has a lovely function called zip(), maybe it could help. Otherwise, a > > quick map would probably do this. > For Python 2, with zip and list comprehensions, it would look like > li3 = [a+b for a,b in zip(li1,li2)] > Hmm, or even > li3 = map(''.join, zip(l1,l2)) > I like > li3 = map(operator.add, li1, li2) > best (why do people write their own lambda for operator.add? :)). > But all of these are trying to get it to fit in the least number of > characters (and they're pretty fast, although I have doubts about the zip > things). > A newbie should also understand the basic way: > > A = ['a','b','c'] > B = ['d','e','f'] > C = [] > for i in range(len(A)): And if you want to handle mismatched lists gracefully ... for i in range(min((len(A),len(B)))): > C.append(A[i]+B[i]) > > This will give an exception if l1 is longer than l2, but all the above > methods have problems with different length lists as well. > > zip(), list comprehensions, string methods etc are cool, but we end up > with a lot of ways to do it... > -- > Remco Gerlich From greg at perceval.be Thu Feb 8 12:54:00 2001 From: greg at perceval.be (Gregoire Welraeds) Date: Thu, 8 Feb 2001 12:54:00 +0100 (CET) Subject: None assigment Message-ID: While playing a bit with python 2.0, I found that I can assign some value to None EG: None= 2 which I found to be very pernicious because then the following, for example, won't work any more: >>> b= filter(None, [1,2,'',3]) Bug or feature ? If it is a feature (I suppose it is not a bug :), what is the interest of this ? Gregoire Welraeds Perceval Development team ------------------------------------------------------------------------------- Perceval Technologies sa/nv Tel: +32-2-6409194 Rue Tenbosch, 9 Fax: +32-2-6403154 B-1000 Brussels general information: info at perceval.net BELGIUM technical information: helpdesk at perceval.net URL: http://www.perceval.be/ ------------------------------------------------------------------------------- From uche at ogbuji.net Wed Feb 14 15:12:30 2001 From: uche at ogbuji.net (Uche Ogbuji) Date: Wed, 14 Feb 2001 14:12:30 GMT Subject: DOM creation References: Message-ID: <3A8A9254.C4F9FDC@ogbuji.net> Venkatesh Prasad Ranganath wrote: > I have a question on how DOM for a XML document conforming to DOM 2 should be > constructed? > > Now if there are no namespaces specified in the document then should attributes > be added to DOM using > setAttributeNS('', Name, Value) > or > setAttribute(Name, Value)? > > The problem I am facing is when reading in a XML document with no explicit > namespace specified in it through PyXML the attributes are added to the DOM > using setAttributeNS with an empty NameSpace. So, I wanted to clarify if this > is a problem with PyXML or is this how other DOM Constructors work. This is correct behavior. Of course, if you use the xml.dom.ext.reader.Sax reader, you get a tree with no namespace specifiers at all, which is also correct. If you plan to migrate to namespaces in future, or to mix namespace with non-namespace behavior, I'd suggest sticking to the PyExpat and Sax2 readers and using the DOm Level 2 methods (with appended "NS"). > waiting for reply, This reminds me. I'm not sure I sent a reply to your last enquiry. I had a few questions, such as which Reader you were trying to use (It looked as if you didn't paste all of your example code in). However, I'd suggest trying the latest 4Suite 0.10.2 beta that was announced (since I noticed you're using XPath), and see if you still have those problems. If so, pleace copy follow-ups to xml-sig at python.org, which I check more regularly than this newsgroup. Thanks. -- Uche Ogbuji Personal: uche at ogbuji.net http://uche.ogbuji.net Work: uche.ogbuji at fourthought.com http://Fourthought.com From aleaxit at yahoo.com Thu Feb 8 23:35:34 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 8 Feb 2001 23:35:34 +0100 Subject: C++ style Stream Operators References: <3a831395.0@216.0.152.7> Message-ID: <95v75u021ll@news2.newsguy.com> "Jim" wrote in message news:3a831395.0 at 216.0.152.7... > I'd like to use C++style stream i/o operators, such as "file_object << > some_stuff" in my python code. > IS this sort of operator setup and what modules would I need to take > advantage of them if so? You can get a somewhat similar look with the new-ish print >> file_object, some_stuff syntax. Or, go whole hog (the expression somehow seems particularly appropriate) and write a class with an overloaded __lshift__ operator: class Stream: def __init__(self, file): self.file = file def __lshift__(self, stuff): self.file.write(str(stuff)) return self def __repr__(self): return '' import sys cout = Stream(sys.stdout) so you can code beauties like cout<<"Hi there!". The 'return self' at the end of __lshift__ lets you chain your '<<'s, and the __repr__ even lets you try it out at the interactive interpreter command line. I think you'd be very badly advised to pursue this route, spending energy to enable doubtful syntax sugar which many Pythonistas will find quite unpleasant, but, in any case, Python offers you "enough rope to shoot yourself in the foot" -- and you could argue that "print>>flob" is a precedent that legitimates what you're doing:-). Alex From digitig at cix.co.uk Sun Feb 25 22:17:00 2001 From: digitig at cix.co.uk (Tim Rowe) Date: Sun, 25 Feb 2001 21:17 +0000 (GMT Standard Time) Subject: equivalent of NULL or OM in Python References: Message-ID: In article , sholden at holdenweb.com (Steve Holden) wrote: > Choice of data representation can be critical in algorithm design, and > this > is quite a good example. However, I have not fully considered the > symbolic > manipulations you want to perform, so I may be putting my foot in my > mouth > here. That's how I know I have a size 10 mouth: the foot fits perfectly. > > It would appear to be more regular to represent absent terms as a > coefficient of zero. Furthermore, if you reverse the order of the terms, > putting x^0 at the left, you can then use the index into the list as the > power. So your examples could be represented as follows: > > 3X^2+4X+4 : [4, 4, 3] > 3x^2+4: [4, 0, 3] It depends what he wants to do. If he's doing things like CRC calculations the lists are likely to have a lot of zeroes. I think it would be worth considering numpy, as polynomial conversions are easily represented as array operations, and ISTR numpy is clued up on sparse arrays. From neo at thezion.net Wed Feb 21 20:10:04 2001 From: neo at thezion.net (Neo) Date: Wed, 21 Feb 2001 20:10:04 +0100 Subject: Unicode error with ado in win 32 Message-ID: <9713oe$mse8b$1@ID-35431.news.dfncis.de> I've created a simple script which read and print on the interactive window the data from a database field (sql server 7). It work properly but when into the rs.fields('azienda') theres the string "abb?" the script returns the following message. Traceback (most recent call last): File "g:\programmi\Python20\Pythonwin\pywin\framework\scriptutils.py", line 298, in RunScript debugger.run(codeObject, __main__.__dict__, start_stepping=0) File "g:\programmi\Python20\Pythonwin\pywin\debugger\__init__.py", line 60, in run _GetCurrentDebugger().run(cmd, globals,locals, start_stepping) File "g:\programmi\Python20\Pythonwin\pywin\debugger\debugger.py", line 582, in run _doexec(cmd, globals, locals) File "g:\programmi\Python20\Pythonwin\pywin\debugger\debugger.py", line 921, in _doexec exec cmd in globals, locals File "G:\Programmi\Python20\fede.py", line 12, in ? print unicode(a) File "g:\programmi\Python20\win32com\client\dynamic.py", line 165, in __str__ return str(self.__call__()) UnicodeError: ASCII encoding error: ordinal not in range(128) I've try to translate the string into my regional unicode character set, but it not work. Help me please. The strange kind is that using an ODBC connection this error not appear. Thanks. -- Neo **************************** Follow the White Rabbit... Knock Knock Neo... www.thezion.net **************************** Below there's the block code that i've used. Bye dataconn.Open (strConn) sql="select * from GpAzienda ;" rs.Open(sql, dataconn) while not rs.eof: a = gettext.gettext(rs.Fields('azienda')) print a rs.MoveNext() del rs del dataconn From thomas at xs4all.net Fri Feb 2 19:46:09 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Fri, 2 Feb 2001 19:46:09 +0100 Subject: nested scopes In-Reply-To: <55q$5KAmrte6EwVo@jessikat.fsnet.co.uk>; from robin@jessikat.fsnet.co.uk on Fri, Feb 02, 2001 at 04:05:58PM +0000 References: <55q$5KAmrte6EwVo@jessikat.fsnet.co.uk> Message-ID: <20010202194609.W962@xs4all.nl> On Fri, Feb 02, 2001 at 04:05:58PM +0000, Robin Becker wrote: > In article ac.uk>, John J. Lee writes > >On Fri, 2 Feb 2001, Robin Becker wrote: > > > >> Is it really true that J Hylton's nested scopes will cause code like > >> > >> def bingo(): > >> from string import * > >> .... > >> > >> to be declared bad? I'm already against nested scopes, but requiring > >> this to be wrong seems awful. We seem to be replacing a simple 2-level > >> system by a more complex one & restrictions. > >[...] > > > >Are nested scopes actually going to end up in Python proper, then? As > >opposed to remaining as an optional patch? > don't know about that, apparently 2.1a has it It won't be optional, it'll be part of Python. I guess that if there is a *really* *really* *really* lot of code out there that will break, it could be withheld until Python 2.2, and the practice of 'from foo import *' in function/class scopes be made to issue a warning in Python 2.1, but frankly I doubt there'll be that much code breakage. At least it's not a *silent* breakage ! It's a compiler error, so the first run of a script under the new Python will detect it. It's not like it's a new kind of exception being raised. > >And why should the above become bad rather than just import into the > >appropriate namespace? > > > ... > I have a feeling that in order to make nested scopes workable/acceptable > the byte compiler is being hacked and this has had some unfortunate side > effects. Now, now, 'hacked' is a bit strong. Jeremy did a fairly extensive rewrite of the compiler, complete and decent enough not to be called a 'hack' for sure. Besides, developers never 'hack', they 'extend' :-) The problem with 'from foo import *' in a function or class scope, though, is that it makes it impossible for the compiler to see what names will be defined in that scope, and hence what names a nested scope uses will resolve to that. I don't like it at all, either. In fact, I was the first to whine about it, incessantly, on python-dev. I think I have to buy Jeremy a beer (or whatever's his poison) on the Python conference to make up ;) The situation does lend itself to a workaround (a *true* hack, mind you:) but I haven't looked into implementing it, yet. (Jeremy might be doing that, but I'm not sure): The compiler could try and live with 'from foo import *' as long as the function doesn't define a scope nested in that function. Unfortunately, this isn't going to fix every instance of the problem: a single lambda statement inside the function will make the import illegal again. Disabling nested-scoping in the presense of 'from foo import *' might be technically possible, but would create enormous amounts of confusion, I'm sure. And lastly, I'd like to point out (as Jeremy does :) that the reference manual already states that 'from foo import *' in anything but a module scope is illegal. Even if the nested scopes patch was withdrawn from Python 2.1, 'from foo import *' in local scopes *will* generate a warning (warnings are also new in 2.1) so your best bet, either way, is sanitizing your code. (Don't get me wrong: I seriously think 'from foo import *' is overused. The language reference makes it pretty clear what it was intended for, and I think even the common 'from Tkinter import *' is wrong use -- but I don't like code breakage, regardless.) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From hamish_lawson at yahoo.co.uk Thu Feb 22 10:22:46 2001 From: hamish_lawson at yahoo.co.uk (hamish_lawson at yahoo.co.uk) Date: Thu, 22 Feb 2001 09:22:46 -0000 Subject: Problems using Grail. In-Reply-To: <3A943B33.CD618A9B@olen.to> Message-ID: <972lp6+iiqq@eGroups.com> Joonas Paalasmaa wrote: > When I tried to start Grail by typing "python grail-0.6\grail.py" > Python gave the following error message. > File "C:\Python16\grail-0.6\Stylesheet.py", line 45, in load > massaged.append((g, c), v % fparms_dict) > TypeError: append requires exactly 1 argument; 2 given The append() call is officially meant to take one argument, but in versions of Python before 1.6, multiple arguments would be understood as comprising a tuple. However this behaviour was never officially documented or approved, and was dropped in Python 1.6 to bring the actual behaviour in line with the official documentation. This line of code will therefore need to be modified to use an explicit tuple in the append argument: massaged.append(((g, c), v % fparms_dict)) Hamish Lawson From bryan at eevolved.com Sun Feb 18 15:32:40 2001 From: bryan at eevolved.com (Bryan Mongeau) Date: Sun, 18 Feb 2001 14:32:40 GMT Subject: 3D animation References: Message-ID: shaka wrote: > > > Ya, I am planning to write a program to present a project at school. I > need > a language that will allow me to do 3D animations and other animation. > And I am struggling between writting the program in java or using python. > Can someone help me? If python is the ultimate choice then can you give > me some instructions on what libraries I should use, because I am quite a > beginner here> > > Thanks. > > Shaka. Z > > Honestly couldn't tell you if Java has anything better for this purpose but I can tell you python has what you need. First you need a real GUI toolkit. Try: http://sourceforge.net/projects/foxgui/ Make sure to compile with OpenGL support. with the python bindings here: http://sourceforge.net/projects/fxpy/ Grab the openGL bindings: http://sourceforge.net/projects/pyopengl/ Now you should be set to look at the funky GL tests that come in the FXPy bindings. This should give you a great example of what you can do easily in python. Good luck. -- <==================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. http://www.eevolved.com <==================================> "This is one of the hardest lessons for humans to learn. We cannot admit that things might be neither good nor evil, neither cruel nor kind, but simply callous - indifferent to all suffering, lacking all purpose." -- Richard Dawkins From johngrayson at home.com Sun Feb 11 00:54:35 2001 From: johngrayson at home.com (John Grayson) Date: Sat, 10 Feb 2001 23:54:35 GMT Subject: New to Tkinter References: <961qd3$50l$1@hecate.umd.edu> Message-ID: <964kbq$su9$1@nnrp1.deja.com> In article <961qd3$50l$1 at hecate.umd.edu>, "Arvind Mani" wrote: > Hi, > > I need a menu based GUI. Clicking on a menu item should open a new dialog > box. I tried to do this - only the application main window disappears when > the dialog box corresponding to a menu item pops up. Also it has the same > title as the application main window. > > Thanks, > Arvind > If you want help, you'll need to post some (or all) of your code so that we can see what you're doing. In case you're not aware, menus work pretty well... John Sent via Deja.com http://www.deja.com/ From kirschh at lionbioscience.com Fri Feb 2 14:08:20 2001 From: kirschh at lionbioscience.com (Harald Kirsch) Date: 02 Feb 2001 14:08:20 +0100 Subject: execfile('bla.py'), can bla.py know its full path Message-ID: When a script is called by execfile, can it find out the full absolute path name by which it was called? Harald Kirsch -- ----------------+------------------------------------------------------ Harald Kirsch | kirschh at lionbioscience.com | "How old is the epsilon?" LION Bioscience | +49 6221 4038 172 | -- Paul Erd?s From elflord at panix.com Sun Feb 18 23:28:52 2001 From: elflord at panix.com (Donovan Rebbechi) Date: 18 Feb 2001 22:28:52 GMT Subject: Weird Language Features References: Message-ID: On Sun, 18 Feb 2001 13:16:49 +0000, Dave Cross wrote: >1/ The programmer calls a function that doesn't actually exist within >the application (or libraries). Is the a feature whereby the >programmer can create a "catch-all" function which is called in cases >like these? Can this function examine the list of existing functions >and call the most appropriate one? Or create a new function on the fly >and install it into the application? Posting this from comp.lang.c++. In C++, the object model itself does not support this. In both C and C++, one uses dynamic loading to get this kind of behaviour. Indeed, interpreters written in C and C++ tend to rely heavily on dynamic loading. To get the kind of functionality you're talking about, one would probably store a function table in a map/tree and one could put a "default" method in there that acts as a catch all. However, typically one uses exceptions to deal with failed requests, the idea being that if a request fails, the caller is in a better position than the library author to work out what to do. >2/ Can ou filter the input source code before compilation (or >interpretation) in some way so that language keywords could be changed >for other strings? Imagine you wanted to allow someone to program your >language of choice in, say, French. How would you go about translating >French keywords into ones that the compiler (or interpreter) could >understand. What if the translation wasn't one-to-one or fixed? Could >you put enough intelligence into the translator so that it could >handle certain strings differently depending on where they appeared in >the source code? One could do this with macros but it's a fairly primitive solution ... > Perl does >have these features (see the AUTOLOAD function and source filters) and >I'm interested in seeing how widespread they are in other languages. ... of course one could always write a preprocessor in perl (-; >Of course, if you'd like to tell me just why you consider it's a good >thing that your language of choice doesn't have these features, then >I'd be only too happy to hear that too. C and C++ are standardised (as opposed to implementation defined) languages, the former is meant to be small, the latter is big enough as it is. Introducing support for this kind of thing in the language (either C or C++) would probably be a mistake IMO. -- Donovan Rebbechi * http://pegasus.rutgers.edu/~elflord/ * elflord at panix dot com From footech at get2net.dk Fri Feb 23 13:09:08 2001 From: footech at get2net.dk (Mikkel Rasmussen) Date: Fri, 23 Feb 2001 13:09:08 +0100 Subject: Newbie: Large dictionaries References: Message-ID: Hi! I can also put more than 4 million entries *into* the dictionary. But I can only get less than 65.000 back out! What do you get with: len(dict.keys()) ? And with a loop like count = 0 for elem in dict: count = count + 1 print count The keys are ordinary words like an ordinary dictionary :-) with an average length of about 6 characters. Mikkel Rasmussen Steve Purcell wrote in message news:mailman.982924567.27809.python-list at python.org... > Mikkel Rasmussen wrote: > > Why can't there be more than about 65.000 entries in a dictionary, or more > > importantly: how can I make a large dictionary with room for at least > > 500.000 > > elements? > > It's probably a memory issue: how big are the keys and/or values? > > On my machine, I can easily get a million entries into a dictionary:- > > >>> dict = {} > >>> try: > ... for i in xrange(1000000): > ... dict[i] = None > ... except: > ... print "stopped at", i > ... raise > ... > >>> > > -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 bsass at freenet.edmonton.ab.ca Tue Feb 27 23:37:21 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Tue, 27 Feb 2001 15:37:21 -0700 (MST) Subject: CPAN functionality for python - requirements In-Reply-To: <20010227125351.H1781@tummy.com> Message-ID: 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) client: send me this(deb), that(mandrake.rpm), other() server: sorry don't have that(mandrake.rpm) client: send me that(deb) server: sorry don't have that(deb) client: send me that() This is how I would handle a curious server... client: what do you have? server: what format do you want? In other words... the server is just that - a server - it does not ask questions, it does not keep track of any preferences, it serves up files. This could work... client: only show me (deb) and () client: what do you have? ... 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"). - Bruce From adam at deprince.net Fri Feb 23 07:34:04 2001 From: adam at deprince.net (Adam DePrince) Date: Fri, 23 Feb 2001 01:34:04 -0500 Subject: may i get sample source ? References: Message-ID: <3A96045C.FC182C5D@deprince.net> jayhawks at netsgo.com wrote: > > HI? > > may i get sample source about python + informix ? > or > where get i sample ? > > i don't know wel about using python+informix . > > i am new to python . > > thank You can look up python addons here: http://www.vex.net/parnassus/ Two interfaces to informix are here: http://www.vex.net/parnassus/apyllo.py?find=informix Informixdb claims to support DB1.0; documentation on DB1.0 can be found here: http://www.python.org/topics/database/DatabaseAPI-1.0.html Adam DePrince Starmedia Network, Inc. Email: zlib.decompress('x\332KLI\314\325KI-(\312\314KNu(.I,\312MM\311L\324K\316\317\005\000\221\331\012s') From m.hadfield at niwa.cri.nz Wed Feb 28 00:06:19 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Wed, 28 Feb 2001 12:06:19 +1300 Subject: output of shell command References: <3A99FC5D.158A407B@al.com.au> <97diqu$nq7ks$1@ID-11957.news.dfncis.de> <983237981.694338@clam-ext> <983312067.173004@clam-ext> Message-ID: <983315235.473229@clam-ext> "Steve Holden" wrote in message news:pgWm6.169$jv4.27104 at e420r-atl2.usenetserver.com... > Dunno. Still won't work for me on Windows 98. Neither, come to that, does > the parenthesized version > > a=(os.popen("dir")).readlines() > > I get the same error. OK so the parentheses were a red herring. It's a difference in the behaviour of piping in windowed applications vs console applications under Windows 9x. --- Mark Hadfield m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield National Institute for Water and Atmospheric Research From tim.one at home.com Mon Feb 5 04:52:03 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 4 Feb 2001 22:52:03 -0500 Subject: Install PythonWin on top of Python 2.0 In-Reply-To: <95l4en$rbs$1@nnrp1.deja.com> Message-ID: [Deja User] > This is a question from a new user. I recently installed the > BeOpen Python 2.0 on my Win98 PC. Now I'd like to install the Win32 > xtension so I download "win32all-125.exe". Unfortunately, I cannot > install it because this build insists on the presence of Python 1.5.x. That's because 125 only knew about 1.5.x -- unfortunately, it wasn't able to see into the future so that it could work correctly with a release of Python that didn't yet exist . > Now, do I have to install 1.5 so as to install PythonWin? Would the > author of PythonWin please do us a favor to relax the version check > in PythonWin? Heh. Some favor! That would probably send your machine crashing in flames. You simply need to get a newer version of win32all. Look here: http://www.activestate.com/Products/ActivePython/win32all.html The version for use with 2.0 is clearly marked. Or you can uninstall BeOpen 2.0 and get ActiveState's 2.0 package (which includes the Win32 extensions) instead: http://www.activestate.com/Products/ActivePython/Download.html consumer-choice-is-a-wonderful-thing-although-it's-just-confusing- at-first-ly y'rs - tim From daniel.dittmar at sap.com Tue Feb 6 17:46:15 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Tue, 6 Feb 2001 17:46:15 +0100 Subject: While everyone is saying what they want in Python :) References: <3A7D64D8.74E71826@cybermesa.com> <3A7D9C1D.781F8E5@alcyone.com> <3A7DB154.87E04245@cybermesa.com> <3a8012f5.7625600@nntp.sprynet.com> Message-ID: <95p9om$h23$1@news1.wdf.sap-ag.de> In VB, although WITH can be nested, only the innermost is valid. Together with the .dot notation makes your intentions pretty explicit. In Pascal, you have - nested with - multiple expressions allowed in the with clause - no dots which leads to very messy code. Although cascading in Smalltalk and with in VB are very different, in most cases, they lead to similar code (Pythonified): sys.stdout .write (...); .write (...); .write (...) with sys.stdout: .write (...); .write (...); .write (...) The main exception is object creation, where in Smalltalk, you can create an object and send it a bunch of cascaded initialization messages. One problem with cascading is that I don't know yet of a syntax using indentation. And using ';' as a delimiter? There are already far too many people writing 'if : thenstmt', all in one line. Daniel -- Daniel Dittmar daniel.dittmar at sap.com SAP DB, SAP Labs Berlin http://www.sapdb.org/ From ben.hutchings at roundpoint.com Wed Feb 21 01:07:45 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 20 Feb 2001 16:07:45 -0800 Subject: Optimisation problem - in C? References: Message-ID: Tim Churches writes: > def makevector(sourcelist,elementlist): > resultvector = [] > for element in elementlist: > resultvector.append(sourcelist[element]) > return resultvector > My test data has about 300,000 elements in sourcelist and between about > 10,000 and 70,000 elements in elementlist, but larger lists are > envisaged, hence the earnest desire for maximum speed. > > Questions: > Can this function (which essentially does the fairly generic operation > of "fetch the elements of sequence a using the element indexes contained > in sequence b") be optimised without resorting to a C module? I think it can. Since a list's contents are contiguous in memory (in order to support random access), appending to it will cause it to reallocate and move all its contents periodically. If I remember correctly, Python's lists increase their memory allocations by constant amounts rather than by a constant factor, so this loop will run in quadratic time, i.e. proportional to the square of the length of elementlist! Each of the following definitions should be equivalent to the above, and I think at least one will run faster: def makevector(sourcelist,elementlist): resultvector = [None] * len(elementlist) for i in range(len(elementlist)): resultvector[i] = sourcelist[elementlist[i]] return resultvector def makevector(sourcelist,elementlist): return [sourcelist[element] for element in elementlist] def makevector(sourcelist,elementlist): return map(lambda i,l=sourcelist: l[i], elementlist) -- Any opinions expressed are my own and not necessarily those of Roundpoint. From fredrik at pythonware.com Wed Feb 28 15:21:18 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 28 Feb 2001 14:21:18 GMT Subject: CPAN functionality for python - requirements References: <01022623140707.15046@branagan> <20010226214909.A10411@tummy.com> <01022706564001.20069@branagan> Message-ID: Sean Reifschneider wrote: > Don't get me wrong, I'm all for documentation. The lack of "javadoc" for > Python has really hurt though... current CVS version: >>> import pydoc >>> print pydoc.__doc__ Generate Python documentation in HTML or as text for interactive use. At the shell command line outside of Python, run "pydoc " to show documentation on something. may be the name of a Python function, module, package, or a dotted reference to a class or function within a module or module in a package. Alternatively, the argument can be the path to a Python source file. Or, at the shell prompt, run "pydoc -k " to search for a keyword in the one-line descriptions of modules. Or, at the shell prompt, run "pydoc -p " to start an HTTP server on a given port on the local machine to generate documentation web pages. Or, at the shell prompt, run "pydoc -w " to write out the HTML documentation for a module to a file named ".html". In the Python interpreter, do "from pydoc import help" to provide online help. Calling help(thing) on a Python object documents the object. Cheers /F From cerutti at together.net Mon Feb 12 20:02:55 2001 From: cerutti at together.net (Neil Cerutti) Date: 12 Feb 2001 19:02:55 GMT Subject: Tkinter event References: <963ekd$7si$1@buty.wanadoo.nl> Message-ID: knock knock posted: >got a canvas with items (lines). the mouseover event should give a specifc >desciption for every item in the canvas. so i did a mouseover bind to a >unique tag for every item! the idea is to make function that listens to the >event and look ups the description. how can this method find out which item >(tag) sent the event?? this must be possible, right? Use the widget method of your event object. -- Neil Cerutti From chris.gonnerman at usa.net Mon Feb 5 04:39:38 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Sun, 4 Feb 2001 21:39:38 -0600 Subject: Install PythonWin on top of Python 2.0 References: <95l4en$rbs$1@nnrp1.deja.com> Message-ID: <008601c08f25$48e987c0$a100000a@local> ----- Original Message ----- From: "Deja User" Subject: Install PythonWin on top of Python 2.0 > Hi, there: > > This is a question from a new user. I recently installed the BeOpen > Python 2.0 on my Win98 PC. Now I'd like to install the Win32 extension > so I download "win32all-125.exe". Unfortunately, I cannot install it > because this build insists on the presence of Python 1.5.x. Now, do I > have to install 1.5 so as to install PythonWin? Would the author of > PythonWin please do us a favor to relax the version check in PythonWin? You have the wrong version. Sadly the python.org site is a bit confusing; ActiveState distributes this software, and you need the 2.0 compatible version. Visit: http://www.activestate.com/Products/ActivePython/win32all.html for downloads and info. From embed at geocities.com Fri Feb 9 15:17:51 2001 From: embed at geocities.com (Warren Postma) Date: Fri, 9 Feb 2001 09:17:51 -0500 Subject: types.FunctionType vs types.LambdaType References: Message-ID: "Xavier Defrang" deftly observed: > I was exploring the wonderful world of the Python > documentation when I saw that the standard library > types module had two distinct function types : > FunctionType and LambdaType. Both of these are > references to the type 'function' (see code snippet). Maybe it's historical baggage. It's been the same actual object, with two 'name bindings' in the 'types' module at least since 1.5.2. Warren From jafo at tummy.com Tue Feb 27 05:49:09 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Mon, 26 Feb 2001 21:49:09 -0700 Subject: CPAN functionality for python - requirements In-Reply-To: <01022623140707.15046@branagan>; from doughellmann@home.com on Mon, Feb 26, 2001 at 10:45:38PM -0500 References: <01022606501904.15046@branagan> <20010226183606.F7531@tummy.com> <01022623140707.15046@branagan> Message-ID: <20010226214909.A10411@tummy.com> On Mon, Feb 26, 2001 at 10:45:38PM -0500, Doug Hellmann wrote: >The command "rpm -qa" only produces meaningful results on a system where RPM is >the default and primary package installation system. There are more OSes where >that is *not* the case (and where RPM isn't installed at all) than where it is. Apaprently I wasn't canonical enough... On an rpm-based system, it's bogus if "rpm -qa" doesn't list packages installed by CPAN. Just as it's bogus for the similar to happen on Debian, HP, Sun, Windows, etc... >It still isn't clear to me why we would want to use more than one distribution >package format. It appears that one argument is so that sysadmins can use >those tools to track what is installed on the system. But isn't that part of That's one argument, and I'd say it's a good one at that... Other reasons are: The admin doesn't have to learn new packaging formats to deal with the Python packages. If we don't leverage off the platform's package management tool, we have to write our own. Who's volunteering? If the packages aren't listed in the native packaging system, they are much more likely to get overlooked if admins search for things to update and the like. >1. Locate Python packages you want on the net. By "packages" do you mean modules only? I envision it also handling distribution of Python applications and even Python itself. >2. Resolve dependencies between what you want, what you have, and what you > need. >3. Download the appropriate packages to give you what you want. >4. Install those packages. > >Do we agree these are the primary features? Yes. >I sense a consensus that the "install" part should be handled by distutils. Is >that right? That seems to be where we diverge... If somone has made an RPM of it, I'd rather have that than some files winding up hanging around my file-system. >3. Need to include documentation along with source for packages. Not gonna happen... Until there's tools and standards for such documentation, it's not really possible to deal with them... In the cases where docstrings are used, installing the module produces the documentation, but that seems to be the exception... >complexity of the new tool. (How do we handle RPMs on MacOS? How do we handle My schema lists the package format, architecture and platform. If you search for a package for MacOS, and are returned an RPM, then apparently somone has built an RPM for MacOS. Your client should list the package formats that it desires and prefers, which means that if you don't have RPM on your Mac, you will pull down something else -- without penalizing those who *DO* have RPM running on their Mac... >HQX files on Win32? What about for Pippy, where files as such might not even >be appropriate? Does Jython have any special requirements?) Do we deal with My setup handles that -- set the platform to "pilot" and you get access to only the things that will work there (in theory). Again, there are two distinct things here. The archive network and the tools which make use of it... >this complexity by deciding on a per-platform basis what format to use, or do >we force the user to specify the format they want downloaded? You say "we force the user to specify". I say "we allow the user the choose". >If we're modeling what we're doing based on CPAN, maybe we should look at >that design. What format does CPAN use when downloading Perl packages? What >features does CPAN have that we want? What does it not have that we want? CPAN is a Unix-like directory structure, files are downloaded as .tar bundles which are extracted and a "perl Makefile.pl; make; make test; make install" is run. Does Pippy have "make"? Sean -- Gone Postal Sort: Iterate over elements, any element that is out of order you blow away. -- Evelyn, Kevin, and Sean, watching Monty Python and reading DDJ Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From johngrayson at home.com Fri Feb 9 12:56:40 2001 From: johngrayson at home.com (John Grayson) Date: Fri, 09 Feb 2001 11:56:40 GMT Subject: shift tab Tkinter References: <95voh4$oj$1@nnrp1.deja.com> Message-ID: <960ltm$mrn$1@nnrp1.deja.com> In article <95voh4$oj$1 at nnrp1.deja.com>, bernard604 at my-deja.com wrote: > I can not get Tkinter to respond to any double key events. This little snippet works... from Tkinter import * root = Tk() def gotit(event): print 'Got Shift-Tab' frame = Frame(root) entry = Entry(frame) entry.pack(anchor=CENTER) frame.pack() root.bind_class('Entry', '', gotit) root.mainloop() John Grayson Sent via Deja.com http://www.deja.com/ From root at rainerdeyke.com Tue Feb 6 22:45:39 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 06 Feb 2001 21:45:39 GMT Subject: nested scopes References: <95lu1i$ebs@gap.cco.caltech.edu> <3A7EF349.407C71E1@san.rr.com> <3A804026.AD3D1540@san.rr.com> Message-ID: <7g_f6.182817$ge4.63254223@news2.rdc2.tx.home.com> "Michael Hudson" wrote in message news:m3lmrj35z6.fsf at atrus.jesus.cam.ac.uk... > "Rainer Deyke" writes: > > Some Python functions (including 'globals' and 'locals') have behavior > > similar to that of dynamic scoping. > > How so? Note I'm using "dynamic scope" in a pretty technical sense > here - "indefinite scope and dynamic extent". Python variables have > definite scope and dynamic extent (although the objects they point to > have indefinite extent). I am referring to the fact that these functions access the namespace of the calling function. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From jon_warner at my-deja.com Thu Feb 8 18:39:38 2001 From: jon_warner at my-deja.com (jon_warner at my-deja.com) Date: Thu, 08 Feb 2001 17:39:38 GMT Subject: anydbm can't find type of dbm file References: <95s05c$njd$1@nnrp1.deja.com> Message-ID: <95ulko$2eg$1@nnrp1.deja.com> In article , Sean Reifschneider wrote: > > File "/usr/lib/python1.5/anydbm.py", line 83, in open > > raise error, "db type could not be determined" > >anydbm.error: db type could not be determined > > Please see http://www.tummy.com/radiuscontext/errata.html for a discussion > of this and possible ways to fix it. Thanks Sean, I'll install a newer Python. Jonathan Sent via Deja.com http://www.deja.com/ From Bill.Scherer at VerizonWireless.com Tue Feb 13 17:01:07 2001 From: Bill.Scherer at VerizonWireless.com (Bill Scherer) Date: Tue, 13 Feb 2001 11:01:07 -0500 Subject: Python 2.1 release schedule References: <3A895617.C7EDB5C8@javanet.com> Message-ID: <3A895A43.6C2DA72@VerizonWireless.com> Raymond Hettinger wrote: > > Jeremy Hylton wrote: > > > I updated the Python 2.1 release schedule (PEP 226): > > > > second beta in mid- to late-March, and aim for a final release > > sometime in April. > > Call me superstitious, but going final on Friday, April 13th > in the first year of a new millineum, at tax time seems a > trifle risky. > > RH I disagree. Could you imagine a better confluence of external events to coincide with the release of a wonderful new Python? There has to be a balance between good and evil, right? ;-) -- William K. Scherer Sr. Member of Applications Staff - Verizon Wireless Bill.Scherer_at_VerizonWireless.com From amk at mira.erols.com Tue Feb 20 01:54:43 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 20 Feb 2001 00:54:43 GMT Subject: What's up with enscript for syntax highlighting? References: <96p7f2$bqi@dispatch.concentric.net> <96p7rk$sub@dispatch.concentric.net> <96pf0m$sur@dispatch.concentric.net> Message-ID: On 18 Feb 2001 21:32:06 GMT, Phlip wrote: >Proclaimed Thomas Wouters from the mountaintops: >> one everyone commits at some point in life. Furthermore, RTFM is much more >> effective if you do it gently and make them feel nicely embarassed, rather >> than having them just say 'well, fuck you too' when reading the first >> insult, and not learn a thing. > >Thanks. I'l try to keep that in mind the next time I flame myself. Isn't comp.lang.python a great newsgroup? :) --amk From thomas at xs4all.net Sun Feb 18 22:13:36 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 18 Feb 2001 22:13:36 +0100 Subject: What's up with enscript for syntax highlighting? In-Reply-To: <96p7rk$sub@dispatch.concentric.net>; from phlip_cpp@my-deja.com on Sun, Feb 18, 2001 at 07:29:56PM +0000 References: <96p7f2$bqi@dispatch.concentric.net> <96p7rk$sub@dispatch.concentric.net> Message-ID: <20010218221336.C14292@xs4all.nl> On Sun, Feb 18, 2001 at 07:29:56PM +0000, Phlip wrote: > Proclaimed Phlip from the mountaintops: > > Is there a class >