From duncan at rcp.co.uk Thu Feb 8 05: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 09: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 09: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 17: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 13: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 topmind at technologist.com Wed Feb 28 20:17:10 2001 From: topmind at technologist.com (Topmind) Date: Thu, 01 Mar 2001 01:17: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> <97ibmc0k47@news1.newsguy.com> <3A9D2F7D.A5FB0A30@cybermesa.com> Message-ID: > 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 > But OO pumped "refactoring" more into the mainstream. IOW, the birth of a concept and it's growth are not necessarily related. > -- > Jay O'Connor From latlong at css2.com Wed Feb 14 04: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 Mon Feb 12 21: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 13: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 Sun Feb 18 21: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 04: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 15: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 02: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 Sun Feb 11 18: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 Wed Feb 21 20: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 16: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 11: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 12: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 11: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 11: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 02: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 Mon Feb 26 21: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 09: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 03: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 09: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 Fri Feb 2 19: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 Tue Feb 20 19: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 07: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 17: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 12: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 Wed Feb 14 22: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 03: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 06: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 17: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 00: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 14: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 13: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 10: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 05: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 Thu Feb 15 22: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 12: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 13: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 Sun Feb 4 20: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 17: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 08: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 14: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 15: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 13: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 Tue Feb 13 18: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 14: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 11: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 Tue Feb 27 18: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 01: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 04: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 13: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 12: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 11: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 00: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 Sat Feb 10 20: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 09: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 16: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 13: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 11: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 12: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 09: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 13: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 15: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 Tue Feb 27 23: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 09: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 14: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 08: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 12: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 16: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 09: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 13: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 14: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 15: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 10: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 06: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 Fri Feb 16 18: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 02: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 08: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 Mon Feb 12 22: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 02: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 12: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 12: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 Tue Feb 20 18: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 phlip_cpp at my-deja.com Sun Feb 18 14: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 01: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 15: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 14: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 11: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 17: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 01: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 03: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 06: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 04: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 11: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 11: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 12: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 10: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 Tue Feb 13 23: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 06: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 11: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 13: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 Sun Feb 4 20: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 02: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 14: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 Tue Feb 20 21: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 00: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 12: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 15: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 12: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 02: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 max at alcyone.com Sun Feb 18 05: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 12: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 16: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 Tue Feb 27 20: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 00: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 08: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 00: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 04: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 15: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 11: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 12: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 02: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 Sat Feb 10 18: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 10: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 13: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 Tue Feb 6 18: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 17: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 11: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 Tue Feb 6 20: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 08: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 04: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 10: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 12: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 neelk at alum.mit.edu Wed Feb 28 20:43:58 2001 From: neelk at alum.mit.edu (Neelakantan Krishnaswami) Date: 1 Mar 2001 01:43:58 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: On 28 Feb 2001 14:40:12 -0800, Don Dwiggins wrote: >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 > > 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?) Dylan, a close relative of Scheme and CL, does exactly what you suggest to implement its Streams heterarchy. I don't know enough about CL to say, but the answer is probably yes there too. Neel From sholden at holdenweb.com Sun Feb 11 12: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 14: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 Sun Feb 18 18: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 01: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 Tue Feb 6 23: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 Fri Feb 2 23: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 02: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 05: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 02: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 12: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 16: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 07: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 15: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 06: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 14: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 09: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 03: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 02: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 12: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 17: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 14: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 Sat Feb 3 20: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 09: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 09: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 03: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 14: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 Fri Feb 9 18: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 16: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 Sun Feb 11 18: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 Fri Feb 23 20: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 02: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 08: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 03: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 04: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 01: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 Thu Feb 15 20: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 14: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 00: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 15: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 04: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 Tue Feb 13 20: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 Tue Feb 20 20: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 02: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 05: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 Tue Feb 27 20: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 13: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 11: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 13: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 10: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 17: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 15: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 06: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 09: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 17: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 16: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 14: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 13: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 04: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 09: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 Sat Feb 10 18: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 08: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 17: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 07: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 17: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 01: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 Tue Feb 27 18: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 Sun Feb 4 22: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 11: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 Tue Feb 20 19: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 09: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 14: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 Sun Feb 4 22: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 09: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 Mon Feb 26 23: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 06: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 16: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 12: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 11: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 Mon Feb 19 19: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 16: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 thomas at xs4all.net Sun Feb 4 18:00:09 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 5 Feb 2001 00:00:09 +0100 Subject: Please translate this easy snip of C++ to Python In-Reply-To: ; from bowman@montana.com on Sun, Feb 04, 2001 at 01:58:17PM -0700 References: <95kcbo$k8s@dispatch.concentric.net> Message-ID: <20010205000008.G962@xs4all.nl> On Sun, Feb 04, 2001 at 01:58:17PM -0700, bowman wrote: > Fredrik Lundh wrote in message news:BTif6.12144 > > > > (iirc, bjarne thinks that real C++ programmers shouldn't > > use the preprocessor at all, but what does he know...) > "The C preprocessor is a powerful but blunt tool, however, and macros are a > dangerous way to program because they change the lexical structure of the > program underfoot. Let the language proper do the work." > Kernighan & Pike, _The Practice of Programming_. > iirc, either K or R have mentioned they would have left macros out of the > language if they could have forseen the clever and wondrous uses that would > be found for them. Note how Python lacks a preprocessor and macros :) People occasionally rally for a macro preprocessor, but usually not of the C type. Being fairly ignorant in languages featuring macros other than the C style, I can't really say what they *are* rallying for, but apparently there are sane macro preprocessors in existance, somewhere :) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From max at alcyone.com Sun Feb 18 15: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 topmind at technologist.com Tue Feb 27 00: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 rerla at channing.harvard.edu Fri Feb 16 14: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 stadt at cs.utwente.nl Tue Feb 6 06:17:29 2001 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Tue, 06 Feb 2001 12:17:29 +0100 Subject: tempfile(s) problem (Re: cgi.FieldStorage() problem) References: <3A7F20D9.4BE57828@cs.utwente.nl> <3A7FC939.DAC10B75@cs.utwente.nl> Message-ID: <3A7FDD49.201783F@cs.utwente.nl> Richard van de Stadt wrote: > > Erno Kuusela wrote: > > > > In article <3A7F20D9.4BE57828 at cs.utwente.nl>, Richard van de Stadt > > writes: > > > > | OSError: [Errno 24] Too many open files: '/var/tmp/@24739.61' > > > > you probably just need to increase the resource limits for the account > > that your http daemon runs under. i don't know what kind of startup > > procedure you're using for the daemon so it's hard to say exactly how > > to fix it, but the /bin/sh command for manipulating resource limits is > > "ulimit" ("limit" with csh descendants). > > > > if it still blows up after you've upped the limit, it might > > be a problem with the cgi module going haywire and opening > > new files boundlessly, but that seems pretty unlikely. > > But still, it looks like that, although only 1 at the time. > The webform it gets to work with has 140 lines, > while the number of temporary files that were created is 61. > The limit is probably set at 64, If you count the opening of > the script, and some modules, this makes sense. > > It seems like each line causes one temporary file to be > opened, although only 1 exists at the same time. Does cgi.FieldStorage() > work like that??? > > calling ulimit from within the script, which should, I think, do what you > suggest: > > ulimitCommand = "/usr/bin/ulimit -n 512" > os.system (ulimitCommand) > > doesn't help. > > Richard. I copied the data to another system where ulimit -n shows the number 260 for the maximum number of open files, and there it works! So, indeed it seems that cgi.FieldStorage() creates a temporary file for each line of a webform, only one at the time, however, each time with a different file descriptor. I think this looks bad: "You can use this program, but in order to run it, Python requires you to change your system settings"... (I'm using Python for CyberChair, an online paper submission and reviewing system. The webform under discussion has one input field for each reviewer, stating the papers he or she is supposed to be reviewing. ICML'01 has almost 140 reviewers...). Richard. To boldly go where no webform has gone before :-) From btheld2 at my-deja.com Thu Feb 1 17: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 quinn at lira.ugcs.caltech.edu Sun Feb 11 19:07:42 2001 From: quinn at lira.ugcs.caltech.edu (Quinn Dunkan) Date: 12 Feb 2001 00:07:42 GMT Subject: How to label loops? References: <981845104.329821352@news.t-online.de> <981916280.1465025599@news.t-online.de> Message-ID: On Sun, 11 Feb 2001 19:35:53 GMT, Steffen Ries wrote: >> while 1: # first loop >> while 1: # second loop >> break >> >> >> this break breaks only out of the first loop, but what, if i want to >> break out of the first loop, while i?m in the second one? > >one way is to use control variables, e.g.: > >outer_active = 1 >inner_active = 1 >while outer_active: > while inner_active: > outer_active = 0 > break > >another way would be to use exceptions, e.g.: > >try: > while 1: > while 1: > raise Exception, "broken loop" >except Exception: > pass That will catch and ignore all sorts of things you don't want to ignore, like OSError and MemoryError. If you must (ab)use an exception for control flow, you should probably use a string: try: while 1: while 1: raise 'outer loop' except 'outer loop': # just don't misspell this :) pass I've found that I rarely need to break from two levels at once, and when I think I do, often python's (unique) 'while x: ... else:' construct will do the trick. But if you find yourself doing complicated 'while x: xxx else: break' to break from the outer loop if the inner one isn't, and then break from the inner loop if you want to *not* break the outer loop, which is only a nominal loop since it has 'break' at the end and you use continue... well, what you really want here is 'goto' :) As in "go back to fortran" :) From bryan at eevolved.com Mon Feb 26 21: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 thelazydogsback at my-deja.com Sat Feb 3 01:30:05 2001 From: thelazydogsback at my-deja.com (thelazydogsback at my-deja.com) Date: Sat, 03 Feb 2001 06:30:05 GMT Subject: Newest release issues (was: Nested Scopes) Message-ID: <95g8h9$ghg$1@nnrp1.deja.com> i'm sure I'm not understanding things fully and also don't want to start a religous war... (ok, what the heck...) I've seen Py described as both a "scripting language" and "programming language" - I think one could equally read the universe or nothing into these adjectives, but one qualification that comes to mind that may grant a language status in the latter camp is run-time efficiency. In evaluating Py I was surprised that apparently the compiler creates code such that in "f(x)" the binding for "f" is looked up in a dictionary every time "f" is executed. (E.g, even in "for...for...f(x)") This seems very slow (as was shown in an article showing how to optimize Python) and allows the (dubious, IHMO) flexibility of allowing "f" to be re-bound at will, even given the "static" nature of the syntax. I would think that "f(x)" (calling a function that you assume to be bound to a single fn object for the duration) is such a common metaphor that the defualt would be to do all one could to optimize for this case. If the user really wants the flexibily of "f" to be re-bound, (s)he should be forced to lookup the reference and call apply() (or similar) explicitly - this usage is also far more descriptive of the actual effect. Anyway... I was wondering if the new "nested scope" (2 pass?) compiler did anything differently as far as late vs. earlier binding of the fn obj. If I'm misunderstanding the way things work, sorry... On a related note, on "weak references" w.r.t. gc(), I thought cycles have been collected correctly for a few versions now? thanks, mike Sent via Deja.com http://www.deja.com/ From mwa at gate.net Tue Feb 27 10:55:03 2001 From: mwa at gate.net (Mark W. Alexander) Date: Tue, 27 Feb 2001 10:55:03 -0500 (EST) Subject: [Catalog-sig] Re: [Distutils] Re: CPAN functionality for python - requirements In-Reply-To: <01022710324002.20069@branagan> Message-ID: On Tue, 27 Feb 2001, Doug Hellmann wrote: > Date: Tue, 27 Feb 2001 10:17:06 -0500 > From: Doug Hellmann > To: python-list at python.org, distutils-sig at python.org, catalog-sig at python.org > Subject: [Catalog-sig] Re: [Distutils] Re: CPAN functionality for python > - requirements > [snip] > > It seems there's a misunderstanding of what distutils does. It provides > > a standard mechanism for producing installable python packages. IOW, > > I think the misunderstanding was on my part, and between your description and > reviewing the distutils help I think I'm straightened out now. > > With that said, I agree that the network needs to allow, optionally, for binary > distributions for platforms where building binary distributions is unusually > difficult (like having no compiler on Win32). All packages should be available > in source form (assuming some OS license) by default. The client should offer > the user the option of downloading any available package format, which can then > be installed using a separate tool ("./setup.py install" or rpm or whatever). > > If as a user, I choose to download an RPM, that's up to me. If no RPM is > available, the thing I do download should be able to *make* an RPM, so that's > where distutils comes in. Agreed. [snip] > I'm going to back off my request that this be an all-the-way tool. Let's stick > to finding a package and all of its dependencies, and leave the installation to > the packages which are downloaded. As a Python user, I may not have system > privileges sufficient to allow me to install a downloaded package. As a system > administrator, I may not know how to use this tool to find packages. So, the > Python user can find the package and provide it to the sysadmin for > installation. Nice and clean. > > Optionally, there could be an argument which would invoke an installation > command for the package(s) being downloaded. Yes, after I sent this off, I started thinking this as well. It's better as well for sites with multiple machines. Go get it once and install everywhere. > > If it is not buildable, then it would need to seek out pre-built > > binaries, download and install them. So, either the network archive > > interfaces with distutils such that a back-end can produce binaries, > > Can I build binaries for all platforms on whatever platform I use for the > network archive? That's an interesting question. What would it take to include cross-compiling support in distutils? > > OR archive maintainers manually produce binaries for whatever > > platforms they choose to support, > > OR automatically. If the source distribution is always available, part of the > mirroring process could be to convert the source distributions into binary > distributions for the platform serviced by the mirror site. That was my original thought. I would hate to see, however, that some platform gets "slighted" because there's no one to run a mirror for them. > > OR people without development tools (Windows, Macs(?), disk-space tight > > OS's) are SOL. > > OR developers who do not have access to platforms where binary distributions > are prefered enlist other interested parties to assist them in preparing binary > packages. > > OR third party volunteers post binary distributions to other sites on the > network These last 2 are where I hoped the combination of distutils and a network archive would reduce the number of volunteers needed. As long as distutils can produce a binary for a particular platform/ package manager combination, there's really no need for a dedicated (official or UNofficial) "package mantainer". All that's needed is a place where "python setup.py --bdist format=MyPackager" works. How about an interarchive-API (or redirector?), so archives can forward requests for binary packages to other sites known to support that type of binary package? Mark From cyberian_bear at hotmail.com Sat Feb 17 21: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 jafo at tummy.com Tue Feb 27 14:29:03 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Tue, 27 Feb 2001 12:29:03 -0700 Subject: CPAN functionality for python - requirements In-Reply-To: <01022706564001.20069@branagan>; from doughellmann@home.com on Tue, Feb 27, 2001 at 06:50:52AM -0500 References: <01022623140707.15046@branagan> <20010226214909.A10411@tummy.com> <01022706564001.20069@branagan> Message-ID: <20010227122903.F1781@tummy.com> On Tue, Feb 27, 2001 at 06:50:52AM -0500, Doug Hellmann wrote: >> 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. > >So why did distutils make it into the Python core? How does distutils making it into the Python distribution rule out that somone may want to prefer RPMs? >3. Need to support including documentation along with source for packages when >documentation is available. The practice in many RPMs is that the documentation is a "sub package" (see my Python SRPM), which can be installed on your development machines, but bypassed on the production machines... Don't get me wrong, I'm all for documentation. The lack of "javadoc" for Python has really hurt though... >But that leaves it up to the person posting the package to make distributions >in formats for any platforms where folks might want to install their stuff, or >to have someone *else* create those packages. That may lead to a situation What's wrong with allowing people to select different packaging formats if they're available? >where someone believes that they cannot install my package on MacOS because I >didn't make an HQX file (or whatever) when I posted HappyDoc. Again, my tool isn't concerned with such policies except that it allows the user to define it. If the user has defined a policy of "I won't accept any package that's not in .hqx format", then they should indeed not be shown HappyDoc if it doesn't have one. However, it would also allow them to say "I prefer .hqx files, but will take a distutils package if it's my only choice". That user then *WOULD* see HappyDoc if it had a distutils package. >I can go with "allow" but if we do not help then the user must specify in order >to get useful results from the tool, and that becomes "force." I don't follow that logic. >So, it sounds like their tool just does the download and then they use the >equivalent of distutils to do the installation. Is that all we want? For the archive server, I think it is... That doesn't preclude the archive client from being overly clever though... That's what I'm going to work on next, since I have the server in a state where it can handle giving out such information. Sean -- He who wonders discovers that this in itself is wonder. -- M. C. Escher Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From robin at alldunn.com Mon Feb 26 15:36:46 2001 From: robin at alldunn.com (Robin Dunn) Date: Mon, 26 Feb 2001 12:36:46 -0800 Subject: [Distutils] Re: CPAN functionality for python References: Message-ID: <02f501c0a033$d7bedd00$0100a8c0@Rogue> > > > > 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/) > > Isn't this the point of distutils --bdist functionality? The > catalog should provide download capability of any binary format > supported byu distutils. It can either be done on the fly at > request time, or batched periodically depending on the space > availability of the catalog providing site. > That would work for pure python packages, but not for any that contains an extension module. They would still have to be built on the target platform and then the taget package format can be built with --bdist. -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From gerhard.nospam at bigfoot.de Sat Feb 3 01:36:43 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sat, 03 Feb 2001 07:36:43 +0100 Subject: MySQLdb on a VPS... References: Message-ID: <3A7BA6FB.46F33B56@bigfoot.de> "trace s. ruggles" wrote: > > I'm at a total loss here and desperately need help!!! I'm trying to install > the MySQLdb module but this is what I get... (running FreeBSD4.2 on a VPS, > note my "/usr/home/axiomfir/" prefix to all folder listings) > > .. > > axiomfire% ./python Lib/site-packages/MySQLdb/setup.py build > running build > running build_py > warning: build_py: file MySQLdb.py (for module MySQLdb) not found > warning: build_py: file CompatMysqldb.py (for module CompatMysqldb) not > found > warning: build_py: file MySQLdb.py (for module MySQLdb) not found > warning: build_py: file CompatMysqldb.py (for module CompatMysqldb) not > found > running build_ext > Traceback (most recent call last): > File "Lib/site-packages/MySQLdb/setup.py", line 90, in ? > extra_objects=extra_objects, > File "/usr/home/axiomfir/usr/local/python2/Lib/distutils/core.py", line > 138, in setup > File "/usr/home/axiomfir/usr/local/python2/Lib/distutils/dist.py", line > 829, in run_commands > File "/usr/home/axiomfir/usr/local/python2/Lib/distutils/dist.py", line > 849, in run_command > File > "/usr/home/axiomfir/usr/local/python2.0/Lib/distutils/command/build.py", > line 106, in run > File "/usr/home/axiomfir/usr/local/lib/python2.0/Lib/cmd.py", line 328, in > run_command > print "\n" > File "/usr/home/axiomfir/usr/local/python2/Lib/distutils/dist.py", line > 849, in run_command > File > "/usr/home/axiomfir/usr/local/python2.0/Lib/distutils/command/build_ext.py", > line 200, in run > File "/usr/home/axiomfir/usr/local/python2.0/Lib/distutils/sysconfig.py", > line 107, in customize_compiler > File "/usr/home/axiomfir/usr/local/python2.0/Lib/distutils/sysconfig.py", > line 369, in get_config_vars > File "/usr/home/axiomfir/usr/local/python2.0/Lib/distutils/sysconfig.py", > line 281, in _init_posix > distutils.errors.DistutilsPlatformError: invalid Python installation: unable > to open /usr/home/axiomfir/usr/local/lib/python2.0/config/Makefile (No such > file or directory) This sounds as if your Python installation were screwed up in the first place. Does basic Python work? You should check first if simple things work, like importing modules and such: import socket, sys, os print socket.gethostname(), 'running', sys.platform print os.system('uname -a') If Python is ok, the MySQLdb module is usually built by just untarring it somewhere (*not* in the lib/site-packages of your Python installation). Somewhere like /tmp. Then check if the paths to MySQL are ok in the setup.py file. Then issuing python setup.py build. Then python setup.py install. Gerhard PS: Why is the path like this: /usr/home/axiomfir/usr/local/python2.0/Lib/... Why is the Lib with an uppercase L? This is very strange. -- 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 fredrik at pythonware.com Fri Feb 16 05: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 phd at phd.pp.ru Mon Feb 19 04: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 eatonalive%qwestinternet.net at pop3.qwestinternet.net Sun Feb 18 03: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 scarblac at pino.selwerd.nl Thu Feb 8 06:36:07 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 8 Feb 2001 11:36:07 GMT Subject: String formatting characters - looking for details References: <3a81cfa2.1708851@news.muenster.de> Message-ID: Martin Bless wrote in comp.lang.python: > (1) Where can I find some more details about the string formatting > characters? > (2) How I print hex values with zeros padded left, like 0F or 0A? > print '%X' % 15 # two digits, wanted '%02X'. '%2X' pads with spaces so it is width 2, '%02X' pads with zeroes. > (3) This is from the Python docs - I'm looking for more information on > how to use the formatting characters. Well, the Python docs say what you can use, not what it does... The best option is probably to look at a Unix man page for printf. Type 'man printf' at a Unix/Linux prompt or into Google. > ------------------- from the Python docs -------- > 2.1.5.2 String Formatting Operations > > String objects have one unique built-in operation: the % operator > (modulo) with a string left argument interprets this string as a C > sprintf() format string to be applied to the right argument, and > returns the string resulting from this formatting operation. > > The right argument should be a tuple with one item for each argument > required by the format string; if the string requires a single > argument, the right argument may also be a single non-tuple object.2.5 > The following format characters are understood: %, c, s, i, d, u, o, > x, X, e, E, f, g, G. Width and precision may be a * to specify that an > integer argument specifies the actual width or precision. The flag > characters -, +, blank, # and 0 are understood. The size specifiers h, > l or L may be present but are ignored. > --------------------- -- Remco Gerlich From sbcomm1 at my-deja.com Thu Feb 8 22:25:48 2001 From: sbcomm1 at my-deja.com (sbcomm1 at my-deja.com) Date: Fri, 09 Feb 2001 03:25:48 GMT Subject: path from save dialog? Message-ID: <95vnvl$9h$1@nnrp1.deja.com> Before I get crispied for trying to break every security rule on the books, I am planning on using this technique from a locally running application only. The set up: I am working in an environment where my application can be run as standalone from CD but has no access to the users local hard drive. I am very determined to use the interface built already. It is critical that the user be able to read and write to the local drive. Possible solution: Have my application start a local python simpleHTTPServer with CGI capabilities, have a CGI prompt the user to open/save the desired file, grab the path selected and use CGI to open and process or write to the file. This needs only be a simple text file. The specific questions: How do you, in general, get the saveas/open dialog to appear to the user on a Mac? on Win? I am not necessarily looking for code. I have spent hours scouring the web and perusing books for an example of this so if you have a specific link to this functionality send it my way. The general question: In your expert opinions do you think this is a viable plan? Cheers, John Andrew Morrison Sent via Deja.com http://www.deja.com/ From qrczak at knm.org.pl Sun Feb 18 12:02:10 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 18 Feb 2001 17:02:10 GMT Subject: None assigment References: <3A857E90.18EE0634@engcorp.com> <981857533.2047761672@news.silcom.com> Message-ID: Sat, 10 Feb 2001 18:09:18 -0800, Clarence Gardner pisze: > I think, if there is a reason, it is probably that they want the > language to prevent the programmer from *accidentally* doing bad > things that happen to be possible. But nobody types > None = 3 > by accident. It's harmless anyway: it rebinds a local name, not the builtin one. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From gbell at uclink.berkeley.edu Thu Feb 1 03: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 paul.moore at uk.origin-it.com Tue Feb 20 07: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 flognat at flognat.myip.org Tue Feb 20 14: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 mwh21 at cam.ac.uk Wed Feb 21 12: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 ssthapa at classes.cs.uchicago.edu Mon Feb 12 14:15:54 2001 From: ssthapa at classes.cs.uchicago.edu (ssthapa at classes.cs.uchicago.edu) Date: Mon, 12 Feb 2001 19:15:54 GMT Subject: CPAN functionality for python References: Message-ID: A.M. Kuchling wrote: >On Sun, 11 Feb 2001 14:06:37 GMT, > ssthapa at cs.uchicago.edu wrote: >>code up there. Any comments, suggestions, or help on where to go from here >>would also be appreciated. > >How about getting a Starship account? Then you can run CGI scripts to >allow searching and using your proposed index, as a way of getting >user feedback. I'll set up an account on starship early this week. The biggest problems I see are getting authors to add their modules to the package index and getting sites to host the archive. But before that I would like to work out a format for package entries so that it wouldn't need to be changed later on. -- ---------------------------------------------------------------------------- | 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 ivnowa at hvision.nl Tue Feb 6 03:44:19 2001 From: ivnowa at hvision.nl (Hans Nowak) Date: Tue, 06 Feb 2001 08:44:19 GMT Subject: using a func param in a nested function References: Message-ID: <3A7FB77E.5BF6@hvision.nl> Steven D. Arnold wrote: > > Hi, > > I know this is illegal: > > def a(self, *x): > def b(m, n): > global x > for pref in x: > > The documentation says that you can't use global with a name defined as a > formal parameter in a function. The question, then, is how can I use x in > function b, other than by passing it as a parameter? As far as I understand, the new scoping rules in Python 2.1 will fix this. Take a look at this document: http://amk.ca/python/2.1/ --Hans Nowak From sampe99 at my-deja.com Fri Feb 9 07:44:35 2001 From: sampe99 at my-deja.com (sampe99 at my-deja.com) Date: Fri, 09 Feb 2001 12:44:35 GMT Subject: Binary numbers References: <95p7ks$9e6$1@nnrp1.deja.com> <95ru6u$lfg$1@nnrp1.deja.com> <95rvs3$n6n$1@nnrp1.deja.com> Message-ID: <960onh$ov3$1@nnrp1.deja.com> > How are you planning on deciding which one of the many n-th roots > of your matrix is the "right" one? (Is there some reason to > think that your matrix _has_ an n-th root which is also a > transition matrix???) All matrices with negative or complex elements can be excluded and those left can be ranked after certain criterias. The question if there exist a transition matrix or not among the roots is still left unanswered. My intuitive feeling is that there exists one unique "correct" matrix after my experiments on 3x3 and 4x4 matrices (calculations by hand). If I have a transistion matrix and want to transform it to a longer time horizon I take the n:th power of it (under certain assumptions). Sent via Deja.com http://www.deja.com/ From jurgen.defurne at philips.com Mon Feb 19 07: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 pearu at cens.ioc.ee Tue Feb 6 08:42:55 2001 From: pearu at cens.ioc.ee (Pearu Peterson) Date: Tue, 6 Feb 2001 15:42:55 +0200 Subject: list.index(..) -> TypeError bug or feature? Message-ID: In Python 2.1a2 I get TypeError exception from list index() method even if the list contains given object: >>> from gmpy import mpz >>> a = [mpz(1),[]] >>> a.index([]) Traceback (most recent call last): File "", line 1, in ? TypeError: coercion to gmpy.mpz type failed while in Python 2.0b2 it works: >>> a = [mpz(1),[]] >>> a.index([]) 1 Is this Python 2.1a2 bug or gmpy bug? Or my bug and Python 2.1 feature? Thanks, Pearu From ImranG at btinternet.com Sun Feb 11 13:47:17 2001 From: ImranG at btinternet.com (Imran) Date: Sun, 11 Feb 2001 18:47:17 +0000 Subject: smtplib problem Message-ID: <966mnl$2dl$1@uranium.btinternet.com> When using smtplib can you get the "header text" which mail servers introduces themselves with ? Imran -- BTInternet FAQ V2.1 (Unofficial) http://redrival.com/btifaq/ Petition for a Software Patent Free Europe http://petition.eurolinux.org/index_html?LANG=en From dalke at acm.org Sat Feb 17 22: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 stadt at cs.utwente.nl Tue Feb 6 07:25:46 2001 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Tue, 06 Feb 2001 13:25:46 +0100 Subject: cgi.FieldStorage() problem References: <3A7F20D9.4BE57828@cs.utwente.nl> <3A7FC939.DAC10B75@cs.utwente.nl> Message-ID: <3A7FED4A.7F4918EA@cs.utwente.nl> Erno Kuusela wrote: > > In article <3A7FC939.DAC10B75 at cs.utwente.nl>, Richard van de Stadt > writes: > > | calling ulimit from within the script, which should, I think, do what you > | suggest: > > | ulimitCommand = "/usr/bin/ulimit -n 512" > | os.system (ulimitCommand) > > that can't work. it's like trying to run os.system('/usr/bin/cd /tmp') > to change directory. do it in the shell you start httpd from, or use > the resource module, or something. I don't start the httpd. It is not in my control... I've asked the sysadmins of the server it concerns (at Purdue Univ.) to have a look at it. Richard. From slaurent at sonicfoundry.com Mon Feb 26 13: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 bawolk at ucdavis.edu Mon Feb 26 18:05:57 2001 From: bawolk at ucdavis.edu (Bruce Wolk) Date: Mon, 26 Feb 2001 15:05:57 -0800 Subject: PyQt file locations Message-ID: <3A9AE155.FF8C3A08@ucdavis.edu> 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 MailFreeZone Thu Feb 15 04: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 Bill.Scherer at VerizonWireless.com Thu Feb 1 17: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 fredrik at effbot.org Fri Feb 2 04: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 gem at hsv.crc.com Mon Feb 26 12: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 rich_somerfield at tertio.com Mon Feb 19 05: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 embed at geocities.com Fri Feb 9 09:22:49 2001 From: embed at geocities.com (Warren Postma) Date: Fri, 9 Feb 2001 09:22:49 -0500 Subject: python-dev summary, Jan. 16-31 References: <3d4ry56vzg.fsf@ute.cnri.reston.va.us> <95v7gg$8ne$1@animus.fel.iae.nl> Message-ID: "Carel Fellinger" wrote in message news:95v7gg$8ne$1 at animus.fel.iae.nl... > Andrew Kuchling wrote: > > > Envoi > > ===== > > > This will be the last python-dev summary I write, accounting for its > > rushed and sketchy quality. > > This is really, really, really sad news! Py_INCREF('news:95v7gg$8ne$1 at animus.fel.iae.nl...') From ctavares at develop.com Wed Feb 21 01: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 phys137 at mailcity.com Fri Feb 16 18: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 phil at river-bank.demon.co.uk Tue Feb 6 05:39:22 2001 From: phil at river-bank.demon.co.uk (Phil Thompson) Date: Tue, 06 Feb 2001 10:39:22 +0000 Subject: SIP References: <95moca+k29p@eGroups.com> <00ba01c08ff2$c9b34300$a100000a@local> Message-ID: <3A7FD45A.F5B581ED@river-bank.demon.co.uk> Chris Gonnerman wrote: > > ----- Original Message ----- > From: > Subject: Re: SIP > > > Sorry - documentation is the weakest aspect of SIP. The best approach > > is to use PyQt as a working example. Feel free to ask SIP questions on > > the PyQt/PyKDE mailing list. > > Except I know squat about QT, and as I am a GNOME user I have little > interest. I just meant to look at it as a good example of SIP specification files for a variety of C++ classes. I wasn't suggesting polluting you system by compiling it. :) > What I am wanting to do is connect the Xbase library to Python. Xbase is a > dBase > compatible C++ library. > > I am probably not qualified to do this anyway. I have many thousands of > lines of > C in my history but zero C++. Phil From aleaxit at yahoo.com Thu Feb 22 03: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 MarkH at ActiveState.com Tue Feb 20 17: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 othello at javanet.com Sun Feb 18 19: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 tjg at exceptionalminds.com Mon Feb 12 14: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 phlip_cpp at my-deja.com Sun Feb 18 17: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 jcollins at endeavors.com Fri Feb 23 19: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 mark at chem.uwa.edu.au Mon Feb 19 16: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 jepler at inetnebr.com Wed Feb 14 22: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 chris at cogdon.org Sat Feb 3 14:08:15 2001 From: chris at cogdon.org (Chris Cogdon) Date: Sat, 3 Feb 2001 11:08:15 -0800 (PST) Subject: Help detecting partial upload Message-ID: Hi folks. Hope someone can help me out with this (quick?) question. I need to be able to detect when a file upload through a web form fails due to a timeout, or other partial transfer. I've hunted through the cgi.py module, and I cant see any facility to represent a incomplete transfer. I know exceptions certainly aren't being raised If people want to send private replies, I'll post a summary back to the list. Thanks in advance. ("`-/")_.-'"``-._ Chris Cogdon . . `; -._ )-;-,_`) (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' ((,.-' ((,/ fL From ransen_spam_me_not at nemo.it Sat Feb 17 12: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 schaffer at optonline.net Wed Feb 28 17: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 qrczak at knm.org.pl Sat Feb 24 09: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 gregj at pobox.com Thu Feb 8 02:54:15 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Thu, 08 Feb 2001 07:54:15 GMT Subject: Sorting strings. References: <4a1yt93frj.fsf@kern.srcf.societies.cam.ac.uk> Message-ID: <95tjb7$4ic$1@nnrp1.deja.com> In article <4a1yt93frj.fsf at kern.srcf.societies.cam.ac.uk>, Gaute B Strokkenes wrote: > ... > The problem with this approach is that string comparison doesn't quite > have the behaviour that I would like. For instance, I'd like numbers > to come after letters, and I'd like to be case insensitive. Is there > a reasonably clean way to do this? You can write a function to compare strings according to your rules: ignore case, make the digits greater than letters, and (maybe) ignore punctuation and anything else not alphanumeric. Then use that function to compare author, title, etc. rather than <, ==, >. -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com Sent via Deja.com http://www.deja.com/ From neo at thezion.net Wed Feb 21 17: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 tuttledon at hotmail.com Thu Feb 22 14: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 tim.one at home.com Tue Feb 27 20: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 gmcm at hypernet.com Fri Feb 23 21: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 rich_somerfield at tertio.com Fri Feb 23 11: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 max at alcyone.com Mon Feb 19 02: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 tim_one at email.msn.com Sat Feb 17 01: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 stephen_purcell at yahoo.com Fri Feb 23 02: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 aahz at panix.com Tue Feb 20 19: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 othello at javanet.com Tue Feb 20 20: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 joseamartin at venmex.com Wed Feb 21 14: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 dalke at acm.org Fri Feb 16 18: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 paul at fxtech.com Tue Feb 20 18: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 oconnor at bioreason.com Fri Feb 16 15: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 n8gray at caltech.edu.is.my.email.address Mon Feb 5 05: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 tino at wildenhain.de Tue Feb 27 04: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 bobhicks at adelphia.net Wed Feb 14 17: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 sandj.williams at gte.net Mon Feb 12 15: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 gangli at msn.com Thu Feb 8 10:34:47 2001 From: gangli at msn.com (gangli at msn.com) Date: Thu, 08 Feb 2001 15:34:47 GMT Subject: Please translate this easy snip of C++ to Python References: <95kcbo$k8s@dispatch.concentric.net> Message-ID: <95uean$qsf$1@nnrp1.deja.com> In article , "Fredrik Lundh" wrote: How do you make trace("a = 1") work ? > "Phlip" wrote: > Or use something like this: > > def trace(expr): > # evaluate expression in callers namespace > import sys > try: > raise None > except: > frame = sys.exc_info()[2].tb_frame.f_back > print expr, "=", eval(expr, frame.f_globals, frame.f_locals) > > x = 10 > y = 20 > trace("x + y") > > ## prints: > ## x + y = 30 > > Cheers /F > > > > Sent via Deja.com http://www.deja.com/ From rozen at rgv.hp.com Fri Feb 9 13:24:10 2001 From: rozen at rgv.hp.com (Don Rozenberg) Date: Fri, 09 Feb 2001 10:24:10 -0800 Subject: [ANN] PAGE 0.1 - A drag and drop GUI generator for Python Message-ID: <3A8435C9.CA99421@rgv.hp.com> AGE 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 reborn at neozone.net Fri Feb 2 17: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 kopfarzt at my-deja.com Mon Feb 5 14:36:25 2001 From: kopfarzt at my-deja.com (kopfarzt at my-deja.com) Date: Mon, 05 Feb 2001 19:36:25 GMT Subject: Python 2.1a[12] and MySQLdb 0.3.2 Message-ID: <95mvbp$c2r$1@nnrp1.deja.com> Hi, I get SEGFAULTs (backtrace included) when fetching more than one row with Python 2.1, MySQLdb 0.3.2 and mxDateTime from a table that contains a date. I tried to reduce the problem to the max: I got this table: create table test (some_date datetime); insert into test values ('2000-01-01'); insert into test values ('2000-01-02'); and this testprogram ---------------------------------------------------------------- import MySQLdb import mxDateTime db = MySQLdb.connect (host='localhost', db='test', user='test', passwd='test') cr = db.cursor () cr.execute ('select * from test') rw = cr.fetchone () print type (rw[0]), rw[0] ---------------------------------------------------------------- will print: 2000-01-01 00:00:00.00 Segmentation fault (core dumped) my setup is: linux 2.2.12 python 2.1a1 (and 2.1a2) mysql 3.22.32 mxDateTime 1.3.0 without any special configuration options. I also tried Python 1.5.2, 1.6 and 2.0 where it works. Anybody else experiencing similar problems or got a solution? Thanks in advance Peter The gdb backtrace is: #0 0x400ae352 in chunk_free (ar_ptr=0x40145d00, p=0x80f2af0) at malloc.c:3048 #1 0x400ae157 in __libc_free (mem=0x80f2c38) at malloc.c:2950 #2 0x808f08c in string_dealloc (op=0x80f2c38) at Objects/stringobject.c:235 #3 0x805a45e in code_dealloc (co=0x80f2e90) at Python/compile.c:89 #4 0x8084703 in func_dealloc (op=0x813efa4) at Objects/funcobject.c:249 #5 0x808b42d in dict_dealloc (mp=0x813430c) at Objects/dictobject.c:602 #6 0x807c219 in class_dealloc (op=0x813454c) at Objects/classobject.c:116 #7 0x808aec6 in insertdict (mp=0x80f3a64, key=0x811f8b0, hash=-113409806, value=0x80bb42c) at Objects/dictobject.c:364 #8 0x808b190 in PyDict_SetItem (op=0x80f3a64, key=0x811f8b0, value=0x80bb42c) at Objects/dictobject.c:498 #9 0x808cbbc in _PyModule_Clear (m=0x80f65e4) at Objects/moduleobject.c:118 #10 0x8065635 in PyImport_Cleanup () at Python/import.c:291 #11 0x806b428 in Py_Finalize () at Python/pythonrun.c:212 #12 0x8051c83 in Py_Main (argc=1, argv=0xbffff764) at Modules/main.c:302 #13 0x8051670 in main (argc=2, argv=0xbffff764) at Modules/python.c:10 Sent via Deja.com http://www.deja.com/ From ransen_spam_me_not at nemo.it Mon Feb 19 13: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 fimafeng at yahoo.com Mon Feb 26 18: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 adam at deprince.net Fri Feb 23 02: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 sdm7g at virginia.edu Tue Feb 6 09:36:00 2001 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Tue, 6 Feb 2001 09:36:00 -0500 (EST) Subject: Pyt;hon 2.1a2 compile problems In-Reply-To: <95opu4$t8k$1@nnrp1.deja.com> Message-ID: On Tue, 6 Feb 2001 sgriggs at pobox.com wrote: > 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. There have been a lot of changes to the Makefile, Setup and the rest of the build process -- and besides, this is an alpha release. Odds are it's not just you. How about some details about how exactly it doesn't compile ? What is it doing differently at the point of failure than what it did building 2.0 ? You could also check the bug tracker at: http://sourceforge.net/bugs/?group_id=5470 to see if it's already been reported (and if not, post it there). ---| 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 danielk at aracnet.com Sun Feb 4 12:53:33 2001 From: danielk at aracnet.com (Daniel Klein) Date: Sun, 04 Feb 2001 09:53:33 -0800 Subject: Preventing direct access to a class Message-ID: I have a situation where I need to prevent direct access to a class. IOW, the only way I wish a class to be instantiated is via another class. For example >>> class A: pass >>> class B: def foo(self): return A() >>> b = B() >>> a = b.foo() ...and there might be other classes that 'return A()'. I do not want the user to be allowed to do this... >>>a = A() It doesn't look like classes can be made 'private to the module' as I tried to define class A as 'class __A'. The user could still access with a=__A() (no mangling needed). Other than placing some convoluted logic in each class, is there a way to accomplish this pythonic-ly? Thanks, Daniel Klein From loewis at informatik.hu-berlin.de Tue Feb 20 13: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 esr at thyrsus.com Tue Feb 13 01:59:24 2001 From: esr at thyrsus.com (Eric S. Raymond) Date: Tue, 13 Feb 2001 01:59:24 -0500 Subject: CPAN functionality for python In-Reply-To: <20010212115117.A7546@tummy.com>; from jafo@tummy.com on Mon, Feb 12, 2001 at 11:51:18AM -0700 References: <20010212110204.A4625@harmony.cs.rit.edu> <20010212115117.A7546@tummy.com> Message-ID: <20010213015924.Q1764@thyrsus.com> Sean Reifschneider : > The first question I would ask is: is there any way we can leverage > the work done by the Trove project? I really don't know the status > of that project though. Eric? Trove is dead. Long live SourceForge. The SourceForge guys picked up many of Trove's core ideas. SourceForge II, which we're doing a planning meeting for on Wedneday, will pick up more of them. -- Eric S. Raymond Morality is always the product of terror; its chains and strait-waistcoats are fashioned by those who dare not trust others, because they dare not trust themselves, to walk in liberty. -- Aldous Huxley From jcoffin at taeus.com Wed Feb 28 18:08:52 2001 From: jcoffin at taeus.com (Jerry Coffin) Date: Wed, 28 Feb 2001 16:08:52 -0700 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: In article , patrickdlogan at home.com says... [ ... ] > 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. Strictly speaking, that's not really true: OO has requirements above and beyond polymorphism. Therefore, not all mechanisms that supply polymorphism are necessarily OO. -- Later, Jerry. The Universe is a figment of its own imagination. From claird at starbase.neosoft.com Wed Feb 7 11:36:45 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 7 Feb 2001 10:36:45 -0600 Subject: need some help for sending a msg in python References: Message-ID: <43C7B0D7025A197A.45FA2931D58DFD5C.57F2A1F0A65DC462@lp.airnews.net> In article , kyrsa wrote: >Hi, >I have big problem about this part of the file : . . . > temp_mail.write('Pour vous desabonner de la liste de diffusion :\n') > >temp_mail.write('http://www.domaine.com/listedif/desabon.php3?email='+values >+'\n') > temp_mail.close() > rc = os.system('%s %s < %s' % (sendmail_path, values, temp_mail_name)) > > > >when i'm testing it, it's writing : > > File "mail_list.py", line 87 > >temp_mail.write('http://www.domaine.com/listedif/desabon.php3?email='+values >+'\n') > ^ >SyntaxError: invalid syntax . . . Is the leading white space on that line not consistent with what's around it? The only other explanation con- sistent with the symptom you describe is that there's an unprintable character someplace outside the quotes in that statement. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From doughellmann at bigfoot.com Wed Feb 28 06:53:11 2001 From: doughellmann at bigfoot.com (Doug Hellmann) Date: Wed, 28 Feb 2001 11:53:11 GMT Subject: CPAN functionality for python - requirements References: <20010226214909.A10411@tummy.com> Message-ID: In article , "Sean Reifschneider" wrote: > On Tue, Feb 27, 2001 at 02:49:40AM -0700, Bruce Sass wrote: > >>Huh, there are tools and standards. Isn't /usr/shar/doc/package the FHS >>place for general package specific > > Where are the tools for turning doc-strings into HTML, and how are the http://happydoc.sourceforge.net > links between doc packages handled? Hrm, not sure about that one. HappyDoc can write output to a subdirectory inside where the source code is... > What is the markup format for the > doc strings? StructuredText. > We spent quite a while discussing the sad state of the documentation at > our last pythoneers meeting. Mark Lutz was shocked that people would > actually use javadoc, but they do seem to simply becuase it was > available and was > "good enough". > > We are missing similar functionality. Working on it... Doug From d98aron at dtek.chalmers.se Fri Feb 2 11: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 loewis at informatik.hu-berlin.de Tue Feb 20 04: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 duke at radix.net Fri Feb 23 22: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 loewis at informatik.hu-berlin.de Tue Feb 20 08: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 spamers at must.die Sun Feb 18 09: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 bkc at Murkworks.com Thu Feb 8 16:02:43 2001 From: bkc at Murkworks.com (Brad Clements) Date: Thu, 8 Feb 2001 16:02:43 -0500 Subject: python-dev summary, Jan. 16-31 References: <3d4ry56vzg.fsf@ute.cnri.reston.va.us> <3A82E0A1.9F5BD7EC@stroeder.com> Message-ID: And me too. I always read them with interest, specifically because I don't have the time to follow all the threads personally. I think python-dev summary is very useful. I'm sorry I can't personally contribute. -- Brad Clements, bkc at murkworks.com "Michael Str?der" wrote in message news:3A82E0A1.9F5BD7EC at stroeder.com... > Joel Lucsy wrote: > > > > "Konrad Hinsen" wrote in message > > news:m3ofwdp1u7.fsf at chinon.cnrs-orleans.fr... > > > Andrew Kuchling writes: > > > > > > > To me, this makes it crystal clear that the summaries aren't achieving > > > > their goal of making the development process more transparent to the > > > > community. Perhaps giving the PEPs higher visibility -- posting > > > > > > The fact that there are people who read neither the PEPs nor the > > > summaries doesn't prove that the summaries aren't useful. I have > > > always read them with much interest, > > > > Same here. > > +1 > > Ciao, Michael. From Paul.Moore at uk.origin-it.com Wed Feb 28 04:59:38 2001 From: Paul.Moore at uk.origin-it.com (Moore, Paul) Date: Wed, 28 Feb 2001 09:59:38 -0000 Subject: [Distutils] Re: CPAN functionality for python - requirements Message-ID: <714DFA46B9BBD0119CD000805FC1F53B01B5AD44@UKRUX002.rundc.uk.origin-it.com> From: Sean Reifschneider [mailto:jafo at tummy.com] > On Tue, Feb 27, 2001 at 09:30:13AM -0700, Evelyn Mitchell wrote: > >But it will also discover and resolve dependences in your perl > >site-packages, and automatically fetch them from your closest > >CPAN archive. > > Not according to my tests the night before last. I did a test CPAN > install of "News::Newsrc", which failed because the "make test" was > failing. I then installed the "Set::BitSet" (? Something like that) > module and tried News::Newsrc again and it worked... > > Maybe this was just a fluke and News::Newsrc is the exception and/or > isn't used enough that people have gotten the prereqs right yet. If > anyone knows for sure, I'm curious. There are basically a number of aspects to "CPAN", which need separating out. MakeMaker --------- This is a perl module which implements a build process. You write a Makefile.PL, which calls MakeMaker defining the module's structure and metadata. Thanks to MakeMaker, the process for building a Perl module is (nearly always) simply perl Makefile.PL make make test <-- optional, but pretty much standard - runs module unit tests make install <-- installs the module This is, in both concept and functionality, almost identical to Distutils. There are some areas in which distutils is better (building of platform-specific installers, for instance) and some where MakeMaker is better (it hooks into a very standard structure for modules, generated by thye h2xs program, which practically forces module authors to write test suites and documentation in a standard format), but these are details. We can consider this covered. (Although the distutils-sig could still usefully learn from MakeMaker). The system of FTP sites and mirrors ----------------------------------- Frankly, this is nothing special. It has some nice features (automated uploads for module authors, plus quite nice indexing and server multiplexing features), but it isn't rocket science as far as I know. We could quite happily start with a simple FTP site for this (that's what CPAN did - the mirroring came later as popularity grew). CPAN.pm ------- This is a Perl module, which automates the process of downloading and installing modules. I don't use this personally, for a number of reasons. Frankly, I find that manual downloading and running the 4 lines noted above is fine. It relies for things like dependency tracking on metadata added into the Makefile.PL which is not necessary for the straight 4-line build above. As such, the level to which that metadata is added by module authors is variable (to be polite). In practice, I wouldn't rely on it - accurate dependency data seems to be the exception rather than the rule. I *don't* regard CPAN.pm to be important to the overall CPAN "phenomenon". But some people like it. Writing something "at least as good as" CPAN.pm shouldn't be hard in Python - not least because the standard library is rich enough that things like FTP client support is available out of the box (whereas CPAN.pm won't work until you manually install libnet, and possibly some other modules, I forget which...) But writing a "perfect" utility for automated download-and-install, with dependency tracking, etc etc, is going to be VERY HARD. Don't get misled - Perl doesn't have such a beast. And We won't even have what Perl has if we focus on perfection rather than practicality. The h2xs program ---------------- This is VERY important. The idea is that when you write a Perl module, either pure perl or a C (XS) extension, you run h2xs first, to generate a template build directory. It automatically includes * The perl module, with some basic template code and embedded POD documentation * The XS extension, with template code (if requested) * A Makefile.PL shell * A basic test script - all it does is test that the module loads, but it includes a placeholder for your own tests Essentially, h2xs forces a standard structure on all Perl modules. This is important for Perl, where modules have to conform to some standards in order to work at all. However, it brings HUGE benefits in standardisation of all the "other" parts of the process (documentation, tests, etc). Python is at a disadvantage here, precisely because writing a Python module involves so little in the way of a specific structure. So people will likely rebel against having a structure "imposed"... A social structure ------------------ This is a bit of a chicken and egg issue, but Perl developers expect to write modules using h2xs and MakeMaker, they expect to write tests (even if they are minimal), they expect to fill in the sections in the POD documentation, and they expect to submit their modules to CPAN. So this all "just works". Interestingly, developers probably don't "expect" to have to include dependency information, and hence many don't - resulting in the problems you hit. But then again, Perl users don't "expect" to be totally shielded from dependency issues. Python is VERY far behind here. This is a maturity issue - distutils is still (relatively) new, and so there are LOTS of packages which don't come with a setup.py yet. Often, adding one isn't hard, but it is still to happen. And when you are distributing a pure python module, as a single .py file, it's hard to see the benefit of changing that into a .tar.gz file containing the module, plus a setup.py. (Once you start adding test suites and documentation, the point of the whole archive bit is clearer, but we're not even close to that stage yet). Things are looking better with Python 2.1, though. Included with 2.1, it looks like there will be a standard unit testing module, and a new "pydoc" package, which will extract documentation from module docstrings. So the infrastructure will be there, it just becomes a case of getting developers to use it consistently. Distutils can help with this, by "just working" if people follow a standard structure. Sorry, this wasn't meant to get so long... Paul. From spbridge at my-deja.com Thu Feb 1 07: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 fredrik at pythonware.com Wed Feb 21 15: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 gregj at pobox.com Mon Feb 19 02: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 root at rainerdeyke.com Tue Feb 6 15: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 thorben.schulte at dcc-asia.de Mon Feb 19 05: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 aleaxit at yahoo.com Fri Feb 2 12: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 scarblac at pino.selwerd.nl Tue Feb 13 18: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 fredrik at pythonware.com Tue Feb 13 11:36:27 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 13 Feb 2001 16:36:27 GMT Subject: Python 2.1 release schedule References: <3A8856AE.F49F5024@spacenet.tn.cornell.edu> Message-ID: Tom Loredo wrote: > Is it yet settled which of the Python unit test frameworks this > will be? doctest.py (already in the repository, since it's cool) PyUnit.py (by BDFL decree, since his employer was already using it) > If there is a standard or default framework experts feel > is particularly suited to Python, I'd like to start there. doctest.py Cheers /F From ljohnson at resgen.com Wed Feb 14 09: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 MarkH at ActiveState.com Wed Feb 14 17: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 thomas at xs4all.net Wed Feb 14 10: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 quinn at hork.ugcs.caltech.edu Fri Feb 2 13: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 akuchlin at mems-exchange.org Thu Feb 8 10:42:06 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 08 Feb 2001 10:42:06 -0500 Subject: Python Unicode strangeness. References: Message-ID: <3dvgql5ghd.fsf@ute.cnri.reston.va.us> "Syver Enstad" writes: > '%s, %s' % ('??asfd', u'a') > this throws unicode error. > Is this by design? I believe so, though either MAL or /F are more likely to give a definitive reply. Because one of the arguments to % is a Unicode string, it will coerce everything to Unicode. The encoding used when coercing a regular string into a Unicode string is 7-bit ASCII, so only characters <128 are handled. The first string in the tuple has characters >128, so a UnicodeError is raised. If you make it a Unicode string, there's no problem since it doesn't need to be coerced; if you make 'a' a regular string, no coercion is attempted. In either case, the exception isn't raised. --amk From macky at edsamail.com Tue Feb 20 03: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 ullrich at math.okstate.edu Wed Feb 7 10:43:10 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Wed, 07 Feb 2001 15:43:10 GMT 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> <8w_f6.13141$AH6.1969901@newsc.telia.net> Message-ID: <95rqec$hot$1@nnrp1.deja.com> In article <8w_f6.13141$AH6.1969901 at newsc.telia.net>, "Fredrik Lundh" wrote: > Daniel Kinnaer wrote: > > 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? > > b = mybutton = TSpecialButton() > b.caption = "Busy" > b.method2() > b.caption = "Ok" > > (variables are just names in Python -- you can have any > number of names pointing to the same thing...) You can do more or less the same thing in Pascal. Doesn't have the same effect of reducing the amount of typing while keeping things explicit, because (at least in Delphi) the syntax would be NewNameFortheButtonThatIInventedToSaveKeystrokes:= mybutton; NewNameFortheButtonThatIInventedToSaveKeystrokes.caption:= 'Busy'; > Cheers /F > > -- Oh, dejanews lets you add a sig - that's useful... Sent via Deja.com http://www.deja.com/ From sampe99 at my-deja.com Tue Feb 6 11:10:09 2001 From: sampe99 at my-deja.com (sampe99 at my-deja.com) Date: Tue, 06 Feb 2001 16:10:09 GMT Subject: Binary numbers Message-ID: <95p7ks$9e6$1@nnrp1.deja.com> Does anyone know an easy way to get a list of binary numbers within a certain range in python? E.g for n=1 [0],[1] n=2 [0,0],[0,1],[1,0],[1,1] n=3 [0,0,0],[0,0,1] a.s.o I need this for n<=18... Thanks a lot in advance /Sam Sent via Deja.com http://www.deja.com/ From tjg at exceptionalminds.com Sun Feb 18 17: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 mfletch at tpresence.com Fri Feb 16 05: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 uche at ogbuji.net Tue Feb 27 00: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 cfelling at iae.nl Sat Feb 10 14:42:20 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 10 Feb 2001 20:42:20 +0100 Subject: modify files? References: <961q8q$7qk$1@sapa.inka.de> Message-ID: <9645is$4jv$1@animus.fel.iae.nl> Ingo 'resISt' Siebert wrote: > Hi, > i?m very new to Python but i have to learn that. So i?m starting with litte > programs but i have now a big problem. Welcome aboard, and let my tell you right away: often problems with Python are not big at all:) Just a matter of picking the right modules (re in this case). > I have (Win-)Files which contains something like ... > So I wrote the following Program. ... 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 trotts at mit.edu Tue Feb 6 00:48:27 2001 From: trotts at mit.edu (Issac Trotts) Date: Mon, 5 Feb 2001 21:48:27 -0800 Subject: do...while loops In-Reply-To: ; from dan@eevolved.com on Tue, Feb 06, 2001 at 05:26:52AM +0000 References: Message-ID: <20010205214827.A5294@llnl.gov> How about this: file = open(...) while(1): line = file.readline() if(line == ""): break -Issac Dan Parisien (dan at eevolved.com) wrote: > why don't do...while loops exist in python? Is there are better way to get > to that functionality? > > e.g. > file = open(...) > do: > line = file.readline() > while line != "" > > > Do I have to write a PEP or read some more documentation? ;-) > > Thanks, > Dan > -- > http://mail.python.org/mailman/listinfo/python-list From -$Paul$- at verence.demon.co.uk Sun Feb 18 17:27:59 2001 From: -$Paul$- at verence.demon.co.uk (Paul Wright) Date: 18 Feb 2001 22:27:59 -0000 Subject: Graph (cyclic kind, not pretty picture kind) rendering algorithm? References: Message-ID: <96pi9f$3rg$1@verence.demon.co.uk> In article , Phlip wrote: >Python for Pyros: > >Click here, then scoot down about 2 pages: > > http://www.tomsawyer.com/glt/index.html > >On the left we see a Graph (a math object describing vertices connected by >edges), and on the right's the same graph drawn with all the lengths of the >lines balanced. > >Is there a Python library out there that can draw a graph like that? Or >which can take a graph as an input and return XY coordinates telling where >to place each vertice and each line? AT&T's GraphViz tools will do directed and undirected graph drawing, though I'm not sure what "balanced" means in this context so it may be that they don't quite do what you want. The input format is something like digraph fred { v1 -> v2; v3 -> v2; } to put lines between v1 and v2 and between v3 and v2. Shapes, colours and labels for vertices and edges can be controlled. is the URL I have, if it's wrong, Google should find them. GraphViz is excellent: I wrote a set of tools to produce data flow diagrams from C code using Exuberant Ctags, Perl and GraphViz. -- ----- Paul Wright ------| For my part, I travel not to go anywhere, but to -paul.wright at pobox.com--| go. I travel for travel's sake. The great affair is http://pobox.com/~pw201 | to move. -Stevenson From erno-news at erno.iki.fi Fri Feb 16 11: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 gerhard.nospam at bigfoot.de Thu Feb 1 17: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 billy_bill_1 at my-deja.com Sun Feb 11 04:28:36 2001 From: billy_bill_1 at my-deja.com (billy_bill_1 at my-deja.com) Date: Sun, 11 Feb 2001 09:28:36 GMT Subject: Using Python for Web development Message-ID: <965m01$lr7$1@nnrp1.deja.com> Hi all, I'm new to Python and so far I like what I see! I would really like to use it for web development as I'm currently using PHP and ASP and I'm a bit sick of thier lack of good OO support and the c style syntax etc etc (especially php). PHP can be used as an apache module, can python be used in this way too? I don't want to have to deal with any of the header information stuff as well like in PERL cgi scripts. Any links or information anyone can give me to get me on my way? Thanks, Billy Sent via Deja.com http://www.deja.com/ From alf at leo.logilab.fr Mon Feb 12 09: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 nospam at nospam.com Wed Feb 7 19:23:19 2001 From: nospam at nospam.com (MrBill) Date: Wed, 7 Feb 2001 19:23:19 -0500 Subject: Image Capture And Processing Message-ID: <95sok6$gvt$1@bob.news.rcn.net> I would like to capture and process images from my USB connected Logitech digicam. Does anyone know where I would start to acquire images from the camera and control it from python (or any other programming environment). I'm running on windoze 2000. Thanks, -- Bill Rodgers From pinard at iro.umontreal.ca Wed Feb 7 19:06:40 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=e7ois?= Pinard) Date: 07 Feb 2001 19:06:40 -0500 Subject: Martin Loewis? (sorry) Message-ID: Hi, Martin. (Sorry for the noise to the list.) I cannot reach you, getting: ... Deferred: Connection refused by mira.cs.tu-berlin.de. Message could not be delivered for 1 week Message will be deleted from queue Reporting-MTA: dns; mail.cs.tu-berlin.de Arrival-Date: Wed, 31 Jan 2001 15:46:09 +0100 (MET) This was about the Translation Project, Python, and other fun things... Do you have a better address? -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From tim.one at home.com Wed Feb 28 02: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 jepler at inetnebr.com Mon Feb 19 18: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 andrew at intertrader.com Thu Feb 8 03:35:52 2001 From: andrew at intertrader.com (Andrew Cooke) Date: Thu, 08 Feb 2001 08:35:52 +0000 Subject: urllib.open('http://www.redherring.com/') References: <95th67$36j$1@nnrp1.deja.com> <95tj33$4g1$1@nnrp1.deja.com> Message-ID: <3A825A68.B1023097@intertrader.com> Maybe they're checking an HTTP header line and only responding to known browsers? Andrew Greg Jorgensen wrote: > > In article <95th67$36j$1 at nnrp1.deja.com>, > apederse at my-deja.com wrote: > > I have some problems with urllib. Any URL works > > just fine except http://www.redherring.com/ which > > returns nothing, no headers, no nothing > > It's broken for me, too. I can get to the site with my browser, but > urllib.urlopen() hangs for a long time, then aborts with a "connection > reset by peer" error. The same thing happens with httplib. > > -- > Greg Jorgensen > Portland, Oregon, USA > gregj at pobox.com > > Sent via Deja.com > http://www.deja.com/ From marten at phoenix-edv.netzservice.de Thu Feb 15 02: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 fredrik at effbot.org Wed Feb 7 11:52:23 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 07 Feb 2001 16:52:23 GMT Subject: Tkinter: How to remove stacking order of a widget in grid manager References: <3A80712D.BAF8FC0D@pacific.net.hk> Message-ID: Bernie wrote: > I have an application which requires reordering the widgets during > runtime. I am using the grid manager and found two functions > grid_remove() and grid_forget(). I thought grid_remove() should > does the job, it doesn't, neither do grid_forget(). > > How can that be done? just calling "grid" again (with or without grid_remove or grid_forget) works fine for me. try this: # a simple regridding test from Tkinter import * root = Tk() def flip(): buttons.reverse() for i in range(10): buttons[i].grid(column=0, row=i) buttons = [] for i in range(10): b = Button(root, text=i, width=20, command=flip) b.grid(column=0, row=i) buttons.append(b) mainloop() (just click on any of the buttons to move them around) Cheers /F From phlip_cpp at my-deja.com Sun Feb 18 10: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 stephen_purcell at yahoo.com Tue Feb 13 09: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 dsh8290 at rit.edu Wed Feb 14 15: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 tim_one at email.msn.com Wed Feb 21 01: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 fredrik at pythonware.com Wed Feb 21 17: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 parz at home.com Mon Feb 12 15: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 alet at unice.fr Wed Feb 14 05: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 grante at visi.com Wed Feb 7 13: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 marvind at Glue.umd.edu Wed Feb 28 11: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 schnoerr at mailzone.com Thu Feb 15 16: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 jon_warner at my-deja.com Wed Feb 7 12:20:57 2001 From: jon_warner at my-deja.com (jon_warner at my-deja.com) Date: Wed, 07 Feb 2001 17:20:57 GMT Subject: anydbm can't find type of dbm file Message-ID: <95s05c$njd$1@nnrp1.deja.com> Hi, I am a newbie to the Python language, so there may be some errors in the following source code, but I wonder if you guys could help me work out what is going on here? I have written a test program to find out how object persistence works in Python, and when it is run Python complains that anydbm cannot determine the dbm file type (i.e. whether it is gdbm orany other type of dbm file). Here is the code: #!/usr/bin/python import sys import shelve class link_url: def __init__(self, url_link, description, author, type): self.url = url_link self.desc = description self.auth = author self.type = type def input_url_hand(): global new_url _url = raw_input("What is the name of the URL? ") _auth = raw_input("What is your name? ") _desc = raw_input("Give a description ") _type = raw_input("What type of URL is it? ") new_url = link_url(_url, _desc, _auth, _type) def get_url_link(url_in): sys.stdout.write(url_in.url) def store_link(link_in): link_store = shelve.open('my_db') link_store[link_in.url]=link_in link_store.close def print_links(): link_store = shelve.open('my_db') for name in link_store.keys(): print link_store[name] def test(): input_url_hand() get_url_link(new_url) store_link(new_url) print_links() if __name__ == "__main__": test() And when this is run, the output is: Traceback (innermost last): File "link_url.py", line 42, in ? test() File "link_url.py", line 38, in test store_link(new_url) File "link_url.py", line 26, in store_link link_store = shelve.open('my_db') # open, with (g)dbm filename File "/usr/lib/python1.5/shelve.py", line 152, in open return DbfilenameShelf(filename, flag) File "/usr/lib/python1.5/shelve.py", line 142, in __init__ Shelf.__init__(self, anydbm.open(filename, flag)) 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 Is there anything I can do to correct this? The Python I am using is: Python 1.5.2 (#1, Sep 17 1999, 20:15:36) [GCC egcs-2.91.66 19990314/Linux (egcs - on linux-i386 Thanks in advance, Jonathan Sent via Deja.com http://www.deja.com/ From ken at lt.com Tue Feb 13 08: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 aleaxit at yahoo.com Fri Feb 16 15: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 jafo-pythonlist at tummy.com Thu Feb 15 18:38:25 2001 From: jafo-pythonlist at tummy.com (Sean Reifschneider) Date: Thu, 15 Feb 2001 16:38:25 -0700 Subject: CPAN functionality for python In-Reply-To: ; from ssthapa@classes.cs.uchicago.edu on Mon, Feb 12, 2001 at 09:03:39PM +0000 References: <20010212110204.A4625@harmony.cs.rit.edu> Message-ID: <20010215163825.H23577@tummy.com> On Mon, Feb 12, 2001 at 09:03:39PM +0000, ssthapa at classes.cs.uchicago.edu wrote: > I'm not familiar with Trove, what is it? It would be difficult Seems based on Eric's response that you need to use "was" instead of "is". It was meant to be a large software catalog, originally meant to replace the mirrors of Sunsite. >to integrate this system with dkpg, or rpm. At the very least, it Being a catalog means that it doesn't have to interfere with dpkg or rpm. > I've taken some of CPAN's ideas as inspiration while writing my code >but I'm not sure how much more help CPAN can be outside as being an example >of a similar system. The architecture I see is (simplified): A package has one or more versions. A version has one or more flavors. A flavor has one or more locations. A package identifies the name and other attributes of the software. The version identifies the revisions. The flavor would identify: Packaging format (tar, SRPM, dpkg, Distutils) Architecture (any, i386, alpha) Platform (any, RedHat, Debian, Windows) PlatformVersion (any, 7.0, 2.2, 3.11) So that way a user can set preferences: I'd prefer to get an SRPM to have built on my box. If there isn't one of those, snag a binary RPM for RedHat 7.0. Ok, then I'd try installing from Distutils, and if all else fails give me the tar file and I'll try building from that. It doesn't preclude dpkg, it embraces it. IMHO, a requirement. > Parts of this are already implemented, e.g. the config file lists >a group of mirrors and the script will try to grab the file from one and will >move on to the next if its connection is refused. I guess an extension to >this would be randomize which server is choosen or to allow the mirrors >to have preferences associated with them. However, at the moment the Personally, I think that's more a mirror decision than something that should be put in the catalog. If I've got a list of 10 mirrors for a file, it would be nice to send them a UDP packet asking if how willing they are to serve a file. Their willingness depends highly on the time of day and other factors that you can't predict ahead of time (going to a host that has a RedHat mirror is going to suck the day that they announce 7.1, eh). Really, most of the mirror selection should probably be done by the client software. It'd be especially cool if the client could ask it's squid proxy if it had any of the URLs cached... > With a conventional ftp client, this is sort of doable. If you let >administrators place a dummy file in the archive that indicates that this >mirror is overloaded, then you can get a crude way of skipping loaded servers. Well, they usually do that by spitting out a file that says "I'm busy, go away", and then you're off to search for another mirror. Not very effective, and rather heavy-weight. Ideally, the client would send a UDP packet to all the mirrors saying "Hey, I want this file", the mirrors would receive it, maybe delay responding if they were loaded, drop it if they were heavily loaded, and respond with a willingness level if they have it and are up to sending it. The first reply the client gets is likely to be the best choice for trying to get a response from, especially if servers make an effort to delay the response an appropriate period of time based on the mirror load. Sean -- "All I'm saying is that when I'm around you I find myself showing off, which is the idiots version of being interesting." -- _LA_Story_ Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From max at alcyone.com Mon Feb 19 23: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 sholden at holdenweb.com Fri Feb 16 12: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 skip at mojam.com Wed Feb 14 18: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 jmarshal at mathworks.com Thu Feb 22 17: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 aahz at panix.com Sun Feb 18 14: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 jcollin at exis.net Mon Feb 5 16:22:30 2001 From: jcollin at exis.net (Jay Collins) Date: Mon, 5 Feb 2001 16:22:30 -0500 Subject: Processing on a string Message-ID: Hello, I'm trying to do the following: I have a list that is all the lines from the password file. if I did print p[0] # p being a line in /etc/passwd I would get: uucp:x:10:14:uucp:/var/spool/uucp: or whatever. My question is how do process this list into another list with just everything before the first ":". I'm not quite sure how to do this. From akuchlin at mems-exchange.org Fri Feb 9 13:45:20 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 09 Feb 2001 13:45:20 -0500 Subject: PEP status and python-dev summaries References: Message-ID: <3dg0hn8zlr.fsf@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 jeremy at alum.mit.edu Fri Feb 23 12: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 aleaxit at yahoo.com Thu Feb 22 03: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 joconnor at cybermesa.com Tue Feb 6 16:11:59 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Tue, 06 Feb 2001 21:11:59 GMT Subject: do...while loops References: <95p75f$85m$1@panix3.panix.com> <3A802319.46EBCA35@cybermesa.com> <95pmjp$p3b$1@nnrp1.deja.com> Message-ID: <3a806855.3522055@news.cybermesa.com> On Tue, 06 Feb 2001 20:25:50 GMT, Greg Jorgensen wrote: >That's a common C idiom, but I've always disliked it Me too. I was being silly. I much prefer to loop over sequences, even sequences of numbers 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 fredrik at effbot.org Sat Feb 3 15:35:01 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Sat, 03 Feb 2001 20:35:01 GMT Subject: [NEWBIE] Priority Queue in Python References: <3a7c5ada.67417497@news.gw.total-web.net> Message-ID: David Boeren wrote: > Also, one specific question. Maybe it's because I don't know the > idioms yet, but I keep wanting to have access to a loop counter > variable in my for loops. For example: > > for i in list: > print i, "is the", list.index(i), "element" Ouch. > The index() call takes too long, I wish there was like a hidden > variable so I could say it like this. Is there? > > for i in list: > print i, "is the", __loopindex__, "element" > > Or is there just a better way to do this that I don't know? There's is an index counter deep inside Python, but you cannot access it from the "outside" [1]. But there are more efficient ways to do what you want: for i in range(len(list)): item = list[i] print item, "is the", i, "element" or i = 0 for item in list: print item, "is the", i, "element" i += 1 Cheers /F 1) the counter is passed to the list's __getitem__ method. you can wrap the list in an adapter object whose __getitem__ method returns both the element and the index as a tuple (but don't do that if you care about performance). From uche at ogbuji.net Wed Feb 14 09: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 fredrik at pythonware.com Mon Feb 19 19: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 max at alcyone.com Mon Feb 19 11: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 tim.one at home.com Sat Feb 17 14: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 db3l at fitlinxx.com Mon Feb 26 17: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 max at alcyone.com Mon Feb 5 12:12:12 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 05 Feb 2001 09:12:12 -0800 Subject: Socket woes and signals References: <3dfs7tkv4g6ulmeng4a1pnf94b1dfak2rd@4ax.com> Message-ID: <3A7EDEEC.3F1D395B@alcyone.com> Craig Findlay wrote: > The loop is basically the standard: > > while 1: > conn, addr = s.accept() > data = conn.recv(bufsize) > if not data: break > do something with data > conn.close() > > Q. This is fine if the client closes the connection, but how do I > break out of the look in response to say a signal? You can change the signal handler to raise a custom exception which you can then catch and act on. > If I force the loop to end ungracefully, the socket is left hanging > and I have to reboot the machine to free it up. It takes a few minutes for it to clear, but you won't need to actually reboot to free it up. > But the code normally > stops at the accept line until a connection is accepted, so how do I > close the socket properly in that state? If that's all you need, there's an easier way. AFter you create the socket, call: s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) Now you won't have to wait to rebind to the address. -- 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 davygrvy at pobox.com Sat Feb 24 23: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 jcollins at endeavors.com Fri Feb 23 16: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 sholden at holdenweb.com Thu Feb 8 07:54:31 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 8 Feb 2001 07:54:31 -0500 Subject: Newbie Query References: Message-ID: "eki" wrote in message news:Y7pg6.9822$En4.180927 at typhoon.jacksonville.mediaone.net... > Hello all, > > I am just getting restarted in programming after learning a bit of BASIC > back in the seventies. I would like to take a course online in programming > in python. > > Does anyone know of any beginners classes which are being offered online? > > Thanks, > > Eki > Go to www.python.org and look for the tutorial under "Documentation". There are also links to lots of other good stuff there. regards Steve From zamurai at gmx.net Sat Feb 10 07:10:56 2001 From: zamurai at gmx.net (Zamurai) Date: Sat, 10 Feb 2001 13:10:56 +0100 Subject: Embeding Jython In Java References: <95v4ir$g6m$1@nnrp1.deja.com> Message-ID: <981807056.38482970@news.t-online.de> Just write a programm, or only a class. compile it with Jython and import it in your Javaprogramm. cybereal at my-deja.com wrote: > I'm in desperate need of some wisdom on the > subject, how do I go about distribution with my > app? hell, how do I include it for compilation? > Do I decompress the .jar? Any ideas? I would > have no problem USING it, I just don't know how > to get it into my app; and please, I'm not stupid > don't tell me "Import it" because that's > obviously not my problem > > THANKS! > > btw, you can email me direct if you have a heart > if you send it to cybereal at hotmail dot co... > you know > > > Sent via Deja.com > http://www.deja.com/ From trentm at ActiveState.com Mon Feb 19 17: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 erno-news at erno.iki.fi Sat Feb 10 00:26:13 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 10 Feb 2001 07:26:13 +0200 Subject: Should I use Python? References: <3A84BBA7.74688DFD@orcon.net.nz> Message-ID: In article , msoulier at storm.ca (Michael P. Soulier) writes: | The only way to do what you're talking about is to distribute | binaries for the target platform. Python is a good choice if you | want to use the frozen tool and compile the Python to native code. do you have a url for this "frozen"? or do you mean freeze? from what i hear py2exe and installer have superseded freeze, and freeze does not compile python to native code. -- erno From sholden at holdenweb.com Sun Feb 11 12:29:43 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 11 Feb 2001 12:29:43 -0500 Subject: CPAN functionality for python References: Message-ID: wrote in message news:slrn98c5fc.2ah.ssthapa at ntcs-ip45.uchicago.edu... > I've created a sort of proof of concept that implements something > similar to perl's CPAN. Right now, it allows basic user interaction > and should be able to download and install modules. Sounds like what catalog-sig should have been doing. > At this point, I want to know whether I should continue on this. Also > and possibly more importantly, I would like to know if there is any place > to discuss formats for holding information about packages and other similar > information. I have some ideas floating around but would like to get other > opinons and it seems like the Catalog-SIG is inactive. If there is enough > positive feedback, I'll open up a project on Sourceforge and put my > code up there. Any comments, suggestions, or help on where to go from here > would also be appreciated. > > I think the most important thing is maintaining dependencies, which becomes trickier the more you change things. Assuming nobody ever breaks with backward compaitibility, then at least a module should be able to specifiy the minimum facility-level it requires in other modules. But then I don't want to change Python into Perl! Just my 2c-worth. Steve From ken at lt.com Sun Feb 18 18: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 DavidLNonoSpam at raqia.com Tue Feb 20 13: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 J.Jonkers at acriter.com Thu Feb 1 08: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 mbel44 at dial.pipex.net Wed Feb 21 08: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 hamish_lawson at yahoo.co.uk Tue Feb 13 10: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 R.Liebscher at gmx.de Tue Feb 27 04:02:46 2001 From: R.Liebscher at gmx.de (Rene Liebscher) Date: Tue, 27 Feb 2001 10:02:46 +0100 Subject: [Distutils] Re: CPAN functionality for python References: <14984.49127.853606.286789@w221.z064000254.bwi-md.dsl.cnc.net> <20010215170227.K23577@tummy.com> <20010226013903.B3221@tummy.com> Message-ID: <3A9B6D36.20B1B3C2@gmx.de> I don't know if I missed something, but if you want for all users install a package in their native format, why not so: 1. - download the binary in a format which can be unpacked by python/distutils on every system where this binary works (Linux -> tar.gz?) - download some meta data 2. extract the binaries in a directory 3. feed the meta data and the directory in distutils bdist_{rpm|debian|...) and create a package for the users prefered system (RPM,...) (You probably have to extend the bdist_* commands, but this way we also get people to write bdist_* commands for their platforms.) 4. use the finished package to install it Kind regards Rene Liebscher From geoff at homegain.com Fri Feb 2 18: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 chris at onca.catsden.net Sat Feb 3 15:33:34 2001 From: chris at onca.catsden.net (chris at onca.catsden.net) Date: Sat, 3 Feb 2001 12:33:34 -0800 (PST) Subject: Basic problem - Syntax error In-Reply-To: Message-ID: On Sat, 3 Feb 2001, Michael Ellwood wrote: > Im writing a programme to decrypt a casaer cipher. Im using a while loop > with a counter, and when the counter exceeds a certain value , the loop > stops and the alphabet generated is printed eg: > > plaintextalphabet="abcdefghijklmnopqrstuvwxyz" > ciphertext="mhily lza zbhl xbpzxbl mvyabuhl hwwpbz jshbkpbz jhljbz kpjabt > hyjhubt lza ulbayvu" > > counter=0 > alphabetpos=0 > > while counter < 26: > cipheralphabet.append(plaintextalphabet[counter:] > ** counter = counter + 1 > > print cipheralphabet You're missing a ) on the line beforehand. ("`-/")_.-'"``-._ Ch'marr, a.k.a. . . `; -._ )-;-,_`) Chris Cogdon (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' FC1.3: FFH3cmA+>++C++D++H++M++P++R++T+++WZ++Sm++ ((,.-' ((,/ fL RLCT acl+++d++e+f+++h++i++++jp-sm++ From aahz at panix.com Wed Feb 14 10: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 matt at mondoinfo.com Mon Feb 12 14:34:35 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Mon, 12 Feb 2001 19:34:35 GMT Subject: smtplib problem References: <966mnl$2dl$1@uranium.btinternet.com> Message-ID: On Mon, 12 Feb 2001 06:48:20 GMT, Sheila King wrote: >Nice. And how does one do SMTP authorization? (There must be a way. I >see that the NNTP module includes authorization commands, but the >smtplib doesn't!) Sheila, Unfortunately SMTP authentication is a Big Mess. NNTP authentication is generally just a matter of sending a username and a password. It's described in a couple of hundred lines in RFC 2980. The information necessary to implement SMTP authentication is scattered through a stack of seemingly unrelated and difficult to follow RFCs (2104, 2195 2222, 2554, and 2595, I think). Figuring out the right thing to do is no trivial task. So you wind up with a chicken-and-egg problem: Few SMTP servers implement authentication because few clients want to use it. Since few servers implement it, there's little reason for the authors of mail clients to implement it. I don't use it on my MTAs or MUAs. I just tell people to have ssh forward port 25. Regards, Matt From dsh8290 at rit.edu Wed Feb 21 22: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 akuchlin at mems-exchange.org Mon Feb 12 17:53:12 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 12 Feb 2001 17:53:12 -0500 Subject: CPAN functionality for python References: Message-ID: <3d4rxz8qef.fsf@ute.cnri.reston.va.us> ssthapa at classes.cs.uchicago.edu () writes: > I'll set up an account on starship early this week. The biggest problems > I see are getting authors to add their modules to the package index and > getting sites to host the archive. But before that I would like to work out > a format for package entries so that it wouldn't need to be changed later on. I posted a list of fields (http://mail.python.org/pipermail/catalog-sig/2000-November/000016.html) that no one had problems with. --amk From pinard at iro.umontreal.ca Mon Feb 19 14: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 missive at frontiernet.net Fri Feb 16 23: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 swun at esec.com.au Mon Feb 5 17:42:42 2001 From: swun at esec.com.au (Sam Wun) Date: Tue, 06 Feb 2001 09:42:42 +1100 Subject: sorting on IP addresses References: Message-ID: <3A7F2C62.79E828BC@esec.com.au> Many thanks. sam chris at onca.catsden.net wrote: > On Tue, 6 Feb 2001, Sam Wun wrote: > > > 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 > > This may not be the fastest way, but it works, and its elegant :) > > import string > > def cmp_ipaddress ( ip1, ip2 ): > parts1 = map(lambda x:int(x), string.split(ip1,'.')) > parts2 = map(lambda x:int(x), string.split(ip2,'.')) > comparisons = map ( lambda x,y: cmp(x,y), parts1, parts2 ) > return reduce ( lambda x,y: x or y, comparisons ) > > ips = [ '203.21.254.89', '203.21.254.9' ] > > ips.sort ( cmp_ipaddress ) > > print `ips` > > -> ['203.21.254.9', '203.21.254.89'] > > ("`-/")_.-'"``-._ Ch'marr, a.k.a. > . . `; -._ )-;-,_`) Chris Cogdon > (v_,)' _ )`-.\ ``-' > _.- _..-_/ / ((.' FC1.3: FFH3cmA+>++C++D++H++M++P++R++T+++WZ++Sm++ > ((,.-' ((,/ fL RLCT acl+++d++e+f+++h++i++++jp-sm++ -- Sam Wun Firewalls / Security Senior Software Engineer Electronic Commerce eSec Limited Phone: +61 3 8371 5376 mailto:swun at eSec.com.au C++/JAVA/UNIX/OOP/OOD -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Thu Feb 22 12: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 davidlam at cableinet.co.uk Wed Feb 28 17: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 bernhard at abnoba.intevation.de Mon Feb 5 08: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 MarkH at ActiveState.com Wed Feb 7 19:31:27 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 08 Feb 2001 00:31:27 GMT Subject: python abstract syntax trees References: <95s8fc$59g$1@news.mathworks.com> Message-ID: <3A81E7F6.4080908@ActiveState.com> Joshua Marshall wrote: > In ther parser module, expr and suite return concrete syntax trees. > Does anyone know of any quick routines that build more minimal abstract > syntax trees? Check out the "compiler" project - the source code exists in the CVS tree, and I believe may be in the normal Python 2.1 distro. It uses an AST flattening module before working with the tree. The Python for .NET compiler uses the exact same code, and it was all based on "p2c"'s effort. Mark. From snake-or-bear at worldofbeverage.net Wed Feb 14 04:28:31 2001 From: snake-or-bear at worldofbeverage.net (snake-or-bear at worldofbeverage.net) Date: Wed, 14 Feb 2001 14:28:31 +0500 Subject: Accessing Widget With GTK References: <3A826E68.E77DB89@bellsouth.net> Message-ID: This is just a guess, but could it be a scoping problem? Does your event handler know who pName is? If it's a class you might want to set it up as self.pName... Could you post more code? In article <3A826E68.E77DB89 at bellsouth.net>, "Tony Corrente" wrote: > Hello. > > I am very new to Python so please excuse me if this question is stupid > but I can't find an example anywhere. I've created a form using Glade. > The form has a entry field name pName and a button. I've run glc.py and > created the Python code. Everything worked.. glc created 2 files. the > main program and the window handler file for the button. What I want to > know is... How do I update pName when the button is clicked? I've tried > just using def on_bNext_clicked(widget, mainObj): > pname.set_text("This is a test") > when I run the program and click the button I get the following error > Traceback (innermost last): > File "/usr/lib/python1.5/site-packages/gtk.py", line 125, in __call__ > ret = apply(self.func, a) > File "window1Handlers.py", line 15, in on_bNext_clicked > pName.set_text("This is a test") > NameError: pName > > How do I access pName ( or any other widget in the window ) ??? Could > anyone please guide me in the right direction ??? > > Thanks in advance... > > > > > > > > From Pierre.Blanchet at solsoft.fr Fri Feb 16 10: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 zamurai at gmx.net Sat Feb 10 05:20:12 2001 From: zamurai at gmx.net (Zamurai) Date: Sat, 10 Feb 2001 11:20:12 +0100 Subject: Has anyone information on writing file compressing and decompressing programms? Message-ID: <981800412.2025307082@news.t-online.de> I want to write a file compressing/decompressing programm. Has anyone inforamtions about how to compress data? Zamurai From rtrocca at libero.it Thu Feb 1 14: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 gary at esands.com Mon Feb 26 23: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 aleaxit at yahoo.com Thu Feb 22 04: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 stephen_purcell at yahoo.com Sun Feb 4 11:23:56 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Sun, 4 Feb 2001 17:23:56 +0100 Subject: [Announce] PyUnit 1.3 released Message-ID: <20010204172355.C16150@freedom.puma-ag.com> Version 1.3 of the PyUnit unit testing framework is out, for those who are interested. Quick summary for those not familiar with PyUnit:- - PyUnit is a Python port of Java's popular JUnit testing framework - It provides a framework for easily writing unit and functional tests for your Python code, for aggregating the tests to run en-masse, and for running tests in text or GUI mode - PyUnit has been around since 1999 and is used in many projects, including Zope. Here's what's new in this release:- - Clearer and more verbose text output format - JPython and Python 2 compatibility - New FunctionTestCase class provides support for wrapping legacy test functions into PyUnit test case instances - Support for short descriptions of tests, taken from __doc__ strings by default - Updated and expanded documentation - Convenient new unittest.main() function for use by all test modules - Tests run in text mode can now be interrupted using ctrl-c For further information and downloadable packages, visit:- - http://pyunit.sourceforge.net/ Happy testing! -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Available for consulting and training. "Even snakes are afraid of snakes." -- Steven Wright From sma at 3plus4.de Sun Feb 18 03: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 simon at callan.demon.co.uk Thu Feb 15 14: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 emile at fenx.com Sat Feb 10 17:32:24 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 10 Feb 2001 14:32:24 -0800 Subject: Python equivalent of static member data? References: <#USeY36kAHA.359@cpmsnbbsa07> Message-ID: <964fkh$j21aa$1@ID-11957.news.dfncis.de> I'm not familiar with C++ static members, but it sounds like you are looking for something like: class Test: instances = 0 def __init__(self, incBy=1): Test.instances = Test.instances + incBy print Test.instances a = Test() b = Test(2) HTH, -- Emile van Sebille emile at fenx.com ------------------- "Roger H" wrote in message news:#USeY36kAHA.359 at cpmsnbbsa07... > I've just gotten done digging through the docs for 1.5.2, > and did not find an answer to my question: Is there a > Python equivalent to the C++ concept of static member > data? I'd like to make a class, and have each instance > of that class share a variable and its associated value. > Each instance would have the ability to modify that value, > and the new value would be updated through all instances. > > Make sense? > > ~Roger the Shrubber~ > > From ben.hutchings at roundpoint.com Thu Feb 22 19: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 lluang at northwestern.edu Thu Feb 8 14:27:35 2001 From: lluang at northwestern.edu (Louis Luangkesorn) Date: Thu, 08 Feb 2001 13:27:35 -0600 Subject: Newbie Query References: Message-ID: <3A82F327.71D7A668@northwestern.edu> The following article, Python Books Online by Stephen Figgens is about online books that are aimed at people learning how to program using Python as a language of instruction (as opposed to people who know how to program and are trying to learn Python) It seems to be directed directly at you. It points to Alan Gauld's text which Steve referred to as well as How to Think Like a Computer Scientist by Allen B. Downey and Jeffrey Elkner, which has been used as a text for High School Computer science courses (and also has C++ and Java counterparts). http://www.oreillynet.com/pub/a/python/2001/02/07/pythonnews.html eki wrote: > Hello all, > > I am just getting restarted in programming after learning a bit of BASIC > back in the seventies. I would like to take a course online in programming > in python. > > Does anyone know of any beginners classes which are being offered online? > > Thanks, > > Eki -- Louis Luangkesorn lluang at northwestern.edu http://pubweb.nwu.edu/~kll560 Who am I? They mock me, these lonely questions of mine. Whoever I am, Thou knowest, O God, I am thine. - Dietrich Bonhoeffer "Who am I?" From footech at get2net.dk Fri Feb 23 04: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 seandc at att.net Wed Feb 28 18:38:30 2001 From: seandc at att.net (Sean) Date: Wed, 28 Feb 2001 23:38:30 GMT Subject: Pmw Megawidgets 0.8.5 - EntryField References: <3A9C1577.4642FC60@att.net> <3A9D5C83.C14E7C36@pacific.net.hk> Message-ID: <3A9D8B88.D024CB66@att.net> Thanks. It turns out to be one line more complicated than you said. The default settings in PMW for the grid used to place the label and the entry field are (sticky = "nsew"). It's this that stretches all the fields *even*if*you*set*the*width*!!! My code now looks like this (and it works as expected): _e = Pmw.EntryField(Master, labelpos = 'w', label_text = f[0], label_width = 12, value = '2001/02/28', validate = {'validator' : 'date', 'format' : 'ymd'}, ) _e._entryFieldEntry.grid( sticky = 'w' ) # Overwrite Pmw default 'nsew' _e._entryFieldEntry.config( width = ( f[2] + 2 ) ) # Set width Thanks again. Sean ==== bernie wrote: > > 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 = ) From ngps at madcap.dyndns.org Fri Feb 2 22: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 kclark at ntlug.org Wed Feb 21 05:05:25 2001 From: kclark at ntlug.org (Kendall G. Clark) Date: 21 Feb 2001 10:05:25 GMT Subject: Is Python for me? References: <20010210175216.26827.00000474@ng-mh1.aol.com> <965fhd02uv1@news2.newsguy.com> <96toeh012hd@news2.newsguy.com> Message-ID: On Tue, 20 Feb 2001 13:37:40 +0100, Alex Martelli wrote: >Yes (such as: what is the best C-coded ANOVA package for Python... >see my latest post!), but the (non-empty) set does not include >O'Haskell (nor, alas, Mondrian -- which is a hack of which >respondent sayeth no further). O'Haskell looks cool, but I just >would not recommend it within the given constraints 1-5 (which >I invite you to review) -- it may mature into something *really* >great, but it's still at "rabid early-adopters" stage now (IMHO). Re: Mondrian, I didn't find it very compelling either, but if someone is just really aching for objects and Haskell, it's at least in the neighborhood. (I don't claim it satisfies the 5 criteria of the original poster.) (Perhaps the only real claim to widespread interest Mondrian has is that it seems one of the many languages, variants, or alternative implementations springing up around MS's .NET project. As an assiduous avoider of all things MS, and a booster of all things open source or free software, I have some concerns about .NET. But I'm also finding the kind of ancillary initiatives it's either causing or funding to be of some interest when I put on my 'social informatics' hat. Off the top of my head, I can think of several languages that are working to accomodate .NET in some way: Mondrian, Mercury, Smalltalk, Python, and so on. There may yet be some interesting things of an analytic sort to be said about all this. I just don't know what they are yet!) Of course if one is *really* aching for objects and Haskell, Ocaml may be the best practical choice (even given the differ- ences between Haskell and the ML family). Er, and it was also a decent chance to give a pointer to O'Haskell, an effort that deserves to find some success. >> 2. the Timbot is (still) spreading about the hoary 'Common Lisp is >> *really* huge' myth[1]? >Wasn't that in the context of a comparison with Scheme? In which >case, it seems to me that it's no myth, but simple fact. It's not >an issue of dimension of executable images, etc -- it's an issue >of how big the *language* (with its libraries) is. Hmm, no, I didn't read it like that. But the original point was just a throwaway line, I suspect, so it's not worth quibbling about, at least not as matter of Timbotean exegesis. :>. Your distinction between library and language conceptual size and the size of *all* the parts and pieces required to make working programs in a given language is exactly right. CL isn't a large system in the latter sense; but for many cases -- except perhaps all those where Scheme *really* flourishes (like pedagogical uses and embed-and- extend uses) -- library "largeness" is a very good thing. It's just about the only good thing *I* can say about Perl, for example, though Perl and CL libraries are rather different in the terrain they cover (and cover best). I did take Timbot to be making a claim about CL's largeness re: development infrastructure, runtime requirements, etc. Maybe I was just misreading him. At any rate, that *is* one of the hoary myths -- together with 'it's slow' and 'it's interpreted, so slow' and 'it's just for AI' and 'it's just for academic wankers' -- that, together with other factors, tends to hold CL back from the more widespread commercial acceptance it rightly, in my view, deserves. My *real* point was that one has to look far and wide, as I think I've proven (!), to find stuff to complain about on c.l.python, which is consistently excellent and often fun. ;> Best, Kendall Clark -- In this world there are only two tragedies. One is not getting what one wants, and the other is getting it. --Oscar Wilde From slhath at home.com.nospam Wed Feb 28 11: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 sholden at holdenweb.com Thu Feb 15 20: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 mikael at isy.liu.se Fri Feb 23 04: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 djc at object-craft.com.au Tue Feb 20 23: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 jschmitt at vmlabs.com Wed Feb 21 23: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 sholden at holdenweb.com Thu Feb 8 12:49:13 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 8 Feb 2001 12:49:13 -0500 Subject: None assigment References: Message-ID: "Gregoire Welraeds" wrote in message news:mailman.981652444.20002.python-list at python.org... > [ ... ] > > Now that I look at this problem, I'm totally confused about None. Any > explanaition is welcome. Anyway, I don't understand that one can override > None. Could you give me at least one single good reason to do that. > The built in name None is defined as the value None, which is the only value of type None. When you assign to None, you create a new name in your module (or function) namespace, and bind it to whatever value is assigned. This new name will be found before the built in name, since the built in namespace is the last to be searched. When you delete None you delete it from your module or function namespace, and the built in name again becomes available. To quote Mark Lutz' excellent advice from "Learning Python": don't do that! There is no "single good reason" to do it. This is Python, however, and just because there's no good reason to do something doesn't mean the implementers will implement a prohibition. You are free to shoot yourself in the foot if you want... There really is no advantage, except perhaps in obfuscated Python contests, to redefining None. It's just an implementation artefact that you can do it. Try to forget it's possible and I'm sure you'll feel better! > Gregoire & Xavier > From Perceval Development team, (python division :) > regards Steve From phd at phd.pp.ru Thu Feb 15 11: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 adom at i.am Thu Feb 22 10: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 MarkH at ActiveState.com Fri Feb 16 19: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 doughellmann at home.com Tue Feb 27 10:17:06 2001 From: doughellmann at home.com (Doug Hellmann) Date: Tue, 27 Feb 2001 10:17:06 -0500 Subject: [Distutils] Re: CPAN functionality for python - requirements In-Reply-To: References: Message-ID: <01022710324002.20069@branagan> On Tue, 27 Feb 2001, Mark W. Alexander wrote: > I have no idea how this cc: list came to be. I'm adding catalog-sig > and will drop individuals on subsequent posts.... I've done that, too. It was getting a bit long. > On Tue, 27 Feb 2001, Bruce Sass wrote: > > Subject: [Distutils] Re: CPAN functionality for python - requirements > > > > > I sense a consensus that the "install" part should be handled by distutils. Is > > > that right? > > > > As long as distutils does not presume to know how to do the > > installation. > > > > > 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. > > It seems there's a misunderstanding of what distutils does. It provides > a standard mechanism for producing installable python packages. IOW, I think the misunderstanding was on my part, and between your description and reviewing the distutils help I think I'm straightened out now. With that said, I agree that the network needs to allow, optionally, for binary distributions for platforms where building binary distributions is unusually difficult (like having no compiler on Win32). All packages should be available in source form (assuming some OS license) by default. The client should offer the user the option of downloading any available package format, which can then be installed using a separate tool ("./setup.py install" or rpm or whatever). If as a user, I choose to download an RPM, that's up to me. If no RPM is available, the thing I do download should be able to *make* an RPM, so that's where distutils comes in. So, we don't quite get to a *standard* set of download and install instructions because downloading different package types requires different installation steps. By trading that off we get package management using the user's favorite package system. That seems to be a reasonable trade. > So the catalog client will need to be able to acquire dependency > information from the network archive in order to ascertain whether > the module is buildable on the target system. If it is, it will > also need to acquire, invoke distutils to build and package, and > invoke the package manager to install all dependencies in order. I'm going to back off my request that this be an all-the-way tool. Let's stick to finding a package and all of its dependencies, and leave the installation to the packages which are downloaded. As a Python user, I may not have system privileges sufficient to allow me to install a downloaded package. As a system administrator, I may not know how to use this tool to find packages. So, the Python user can find the package and provide it to the sysadmin for installation. Nice and clean. Optionally, there could be an argument which would invoke an installation command for the package(s) being downloaded. > If it is not buildable, then it would need to seek out pre-built > binaries, download and install them. So, either the network archive > interfaces with distutils such that a back-end can produce binaries, Can I build binaries for all platforms on whatever platform I use for the network archive? > OR archive maintainers manually produce binaries for whatever > platforms they choose to support, OR automatically. If the source distribution is always available, part of the mirroring process could be to convert the source distributions into binary distributions for the platform serviced by the mirror site. > OR people without development tools (Windows, Macs(?), disk-space tight > OS's) are SOL. OR developers who do not have access to platforms where binary distributions are prefered enlist other interested parties to assist them in preparing binary packages. OR third party volunteers post binary distributions to other sites on the network > I hope this clarifies distutils (potential) role a bit. Significantly. Thanks, Doug From scarblac at pino.selwerd.nl Tue Feb 6 05:00:13 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 6 Feb 2001 10:00:13 GMT Subject: importing text code References: Message-ID: Dan Parisien wrote in comp.lang.python: > Is it possible to import from a string in memory instead of a file? I can't > find information on how to do it... I asked that last year and the effbot replied thusly: # import module from string # fredrik lundh, may 2000 import imp, sys def do_import(name, source): module = imp.new_module(name) sys.modules[name] = module exec source in vars(module) return module script = """ def hello(): print 'hello you too' """ do_import("mymodule", script) import mymodule mymodule.hello() -- Remco Gerlich From tjg at exceptionalminds.com Sun Feb 18 16: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 lisowski.tomasz at sssa.NOSPAM.com.pl Fri Feb 2 07: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 root at rainerdeyke.com Tue Feb 20 22: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 sholden at holdenweb.com Sun Feb 4 18: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 dave at dogwood.com Fri Feb 23 02: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 jeremy at alum.mit.edu Thu Feb 22 20: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 eq3pvl at eq.uc.pt Fri Feb 9 11:20:10 2001 From: eq3pvl at eq.uc.pt (Pedro Vale Lima) Date: Fri, 09 Feb 2001 16:20:10 +0000 Subject: I love Python References: <960qnb$p3t$1@mail.cn99.com> <981725795.486882899@news.t-online.de> Message-ID: <3A8418BA.1F228AA7@eq.uc.pt> Zamurai wrote: > "debugboy" wrote: > > Test > > I love Python too ;-) Yeah, but have you asked Python if he loves you? From seefeld at sympatico.ca Mon Feb 5 14:43:08 2001 From: seefeld at sympatico.ca (Stefan Seefeld) Date: Mon, 05 Feb 2001 19:43:08 GMT Subject: passing keyword arguments that are themselfs python keywords Message-ID: <3A7F109D.60FD712B@sympatico.ca> Hi, I'm trying to write a python function that can take keywords such as 'class'. Is that possible ? I'd like to be able to define something like: def entity(type, body, **attr): print '<' + type + ' ' + string.join(map(lambda item:', %s="%s"'%item, attr.items())) + '>' print body print '' and would like to call it like entity('div', text, class='header') Is there any way to achieve the desired effect ? Thanks, Stefan From raikov at cc.gatech.edu Wed Feb 7 09:09:55 2001 From: raikov at cc.gatech.edu (Ivan Raikov) Date: 07 Feb 2001 09:09:55 -0500 Subject: Python 1.5.2 and threads under SCO OpenServer 5.0.4 Message-ID: Greetings, I've been trying to get Python 1.5.2 to compile with thread support under SCO OpenServer 5.0.4 (i586-pc-sco3.2v5.0.4), and finally managed to get it (almost) working after I compiled it with GCC 2.95 and linked it against the GNU Pthreads library (pth-1.3.7). The problem is, that although most of the threading examples in the 'Demo/threads' directory appear to be working, the script called 'telnet.py' is having problems: once it connects, it receives the login prompt from the server, but after the user name is sent, it never receives the server's responses -- apparently after the listening thread is created. I also haven't been able to get Zope to work; Medusa appears to be running, and it does return an error message when I send an invalid request, but for some reason I can never get a response from Zope itself. So I was wondering if anyone has had similar difficulties under this platform, and knows how to go about resolving them. Any help is much appreciated. Thanks, Ivan Raikov -- Ivan Raikov 800 Fowler Street, Atlanta, Georgia 30313-2554 Phone: 404-892-6579 x. 106 Email: raikov at cc.gatech.edu From fluxent at yahoo.com Wed Feb 14 13: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 bernie at pacific.net.hk Wed Feb 28 12: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 slenhartsprint at earthlink.net Sun Feb 18 11: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 fredrik at pythonware.com Thu Feb 22 02: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 glen.mettler at home.com Sun Feb 18 10: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 spamers at must.die Tue Feb 20 04: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 dsavitsk at e-coli.net Mon Feb 19 21: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 kendall at monkeyfist.com Tue Feb 20 05:49:46 2001 From: kendall at monkeyfist.com (Kendall G. Clark) Date: 20 Feb 2001 10:49:46 GMT Subject: Is Python for me? References: <20010210175216.26827.00000474@ng-mh1.aol.com> <965fhd02uv1@news2.newsguy.com> Message-ID: On Sun, 11 Feb 2001 08:37:56 +0100, Alex Martelli wrote: >If I wanted to meet your constraints 1-5, I'd be torn between Haskell >(no objects, but...) Well, there's always O'Haskell http://www.cs.chalmers.se/~nordland/ohaskell/ and Mondrian http://www.mondrian-script.org/ (But beware the Mondrian syntax; my Python-as-first-language eyes were nearly burned out at the site of the unholy mixture of Haskell and Java syntaxes. Yeek!) So lemme see if I've got this right: 1. There's something Alex Martelli doesn't know; and 2. the Timbot is (still) spreading about the hoary 'Common Lisp is *really* huge' myth[1]? Martelli omissions and a Timbot imprecision in one night's news-reading session? c.l.py is slipping! :> Best, Kendall Clark [1] See the recent c.l.lisp thread wherein Kent Pitman (the Timbot of c.l.l. Or is our Timbot the Kentbot of c.l.py? -- those CL hackers have all that tricky AI, doncha know!) said, Add to this the fact that Lisp has a Large Footprint(TM). That is, it takes up MANY megabytes. I say "(TM)" to underscore the fact that there are some factoids (or false-oids) that get enshrined as lemmas and not re-evaluated with time. Lisp WAS big back in the early 90's but it so panicked customers that Lisp images have hardly grown in size for the last decade. During the same interval, every release of every other language has grown by leaps and bounds. A Lisp image is now competitive with, and often tiny, compared to images of other languages. The difference is often a distribution of .dll's that make it hard to see the size of the other things. And even there, the commercial vendors have dll solutions that do similar tricks. So this is just a myth perpetuated by people not going back to find out what the real truth is. (I haven't sorted out the Google refurb of Deja well enough to have a chance in hell of finding a proper URL. My SLRN newspool says "Message-ID: ". It's the thread called "Re: Help me convince skeptics! Lisp success stories wanted...".) -- THIS MACHINE KILLS FASCISTS http://monkeyfist.com/ From slhath at home.com.nospam Thu Feb 15 08: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 DanielK at jBASE.com Tue Feb 13 18: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 NoSpam at NoSpam.com Thu Feb 22 11: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 thomas.heller at ion-tof.com Fri Feb 2 13: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 mwh21 at cam.ac.uk Sun Feb 18 19: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 joconnor at cybermesa.com Fri Feb 16 18: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 db3l at fitlinxx.com Thu Feb 22 21: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 topmind at technologist.com Wed Feb 28 20:15:08 2001 From: topmind at technologist.com (Topmind) Date: Thu, 01 Mar 2001 01:15:08 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> <97jfj3$9e2@gazette.lmig.com> Message-ID: > 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. > Anecdotes can be used to prove anything. I used to keep copies of OO projects gone bad. Of course, when they go bad, you blame it on the programmers, and when it goes good, you give the paradigm the credit. Double standOOrd. Do you know what killed Smalltalk's market? VB! I am not saying VB is wonderful, but to be killed by VB is not saying much for Smalltalk. > "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... > -tmind- From fluxent at yahoo.com Wed Feb 7 17:40:14 2001 From: fluxent at yahoo.com (Bill Seitz) Date: Wed, 07 Feb 2001 22:40:14 GMT Subject: ADO/ODBC call via Python/IIS References: <95f558$jgl$1@nnrp1.deja.com> <%FGe6.31314$Ch.7369562@newsrump.sjc.telocity.net> Message-ID: <95sisd$ahc$1@nnrp1.deja.com> Well, it's a User DSN. Do you know that ASP expects a system DSN? And, I'm not clear on what a DSN-less connection is. Does this mean that I don't set up an ODBC source at all, but just pass all the connection details along in a code call? If so, do I need to use a different COM object (see my original posting for code), or just call the same object with a bigger set of params? (Sorry, I'm new at this, probably need some additional books of examples...) In article <%FGe6.31314$Ch.7369562 at newsrump.sjc.telocity.net>, "dsavitsk" wrote: > > > 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 > > Sent via Deja.com http://www.deja.com/ From cerutti at together.net Wed Feb 7 11:13:03 2001 From: cerutti at together.net (Neil Cerutti) Date: 7 Feb 2001 16:13:03 GMT Subject: Some basic questions about Tkinter (probably v easy for experts!) References: Message-ID: Martyn Quick posted: >On 7 Feb 2001, Neil Cerutti wrote: > >> For the rest of your questions, the easiest thing will be to >> read: >> >> http://www.pythonware.com/library/tkinter/introduction/ > >As I said in my reply to Fredrik Lundh's answer, I did *try* to >read this, but unfortunately I found it rather difficult. It >doesn't actually seem to be aimed at beginners who are new to >Object Oriented Programming. Oh! That'll make it difficult to follow. Sorry. Using Tkinter isn't a good way to learn OOP. Luckily, the semantics and syntax of OOP is easy to learn in Python, if not the practice. >> In particular, read Section 1, "Introducing Tkinter". But don't >> only read it; also open a Python interpreter (a simple CLI will >> work best), and type in the examples as they appear in the >> manual. > >What's a CLI? It stands for Command Line Interface. I meant to imply that you should use, e.g., on Windows, python.exe instead of IDLE (the graphical integrated development environment that comes with some versions of Python). Tkinter acts funny under IDLE, since IDLE is written in Tkinter. Typing along with the demos, seeing what happens as each line is entered, should be illuminating. It's also kind of fun. Here's a small demo. I'm not going to use "import *" here, to hopefully make it a little clearer. You don't need to type in the comments. ;-) import Tkinter # Create the root window. All widgets and other windows will be # controlled by this window. Tk is a "class" in the Tkinter # library. root becomes an "instance", or instantiation, of the # class Tk after this line is run. root = Tkinter.Tk() # Use the title method of the window object to set the text in the # title bar of the window. root.title("Greetings") # Create an instance of Tkinter Button class, and call it # hello_button. The Button class needs some parameters in order # to be created properly. The first parameter tells the button # who its "master", or controller, is. The next argument contains # both a keyword, and its value. "text" is an option of the # Tkinter button widget; its value becomes the text printed on # the button. Only the first parameter (root) is required, but # including keyword arguments is the quickest way to set the # initial options for new widgets. hello_button = Tkinter.Button(root, text="Hello World") # The button has been created, but it doesn't know where to # appear in its master. For that, you must use a "geometry # manager". There are several available in Tkinter, but the # easiest is "pack". "pack" is a powerful but squinchy geometry # manager that always uses the minimum possible space. hello_button.pack() # There will be a button, but it doesn't do anything. You can set # the "command" option of your button widget instance to tell # Tkinter to run arbitrary code when the button is pressed. I # could have set this option in the line above when the button # was created; but since the button is already in existence, I # use the "config" method. # This is just a function. def change_hello_message(): hello_button.config(text="Salutations Planet") hello_button.config(command=change_hello_message) # The window won't appear and your other widgets won't function # until: root.mainloop() Have fun. -- Neil Cerutti From fgeiger at datec.at Thu Feb 8 02: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 peter at engcorp.com Sat Feb 10 12:55:50 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 10 Feb 2001 12:55:50 -0500 Subject: python-dev summary, Jan. 16-31 References: <3d4ry56vzg.fsf@ute.cnri.reston.va.us> <95v2lq$hjl$1@slb7.atl.mindspring.net> <95v3mt$lnh$1@nntp9.atl.mindspring.net> <95v5t3$d3q$1@panix3.panix.com> <962j8r$i9i@gap.cco.caltech.edu> Message-ID: <3A8580A6.7210BA53@engcorp.com> Nathaniel Gray wrote: > > I'm a bit puzzled by AMK's tone of disappointment with the fact that his > summaries haven't generated messages to python-dev. It's never been clear > to me that comments from the peanut gallery were appreciated on python-dev. > When subscription to a mailing list is advertised as "by invitiation only" > and the location of its archives is intentionally obscure, it sends a > strong message that outsiders are not welcome. Hear hear! When I first heard about python-dev and tried to find it, but saw the "by invitation only" note, I thought to myself "Dang... oh well, at least that guy who posts summaries of ongoing discussions from python-dev is willing to post those summaries of ongoing discussions from python-dev." AMK, I appreciate the effort required for such "volunteer" work, and the way limited feedback makes it seem like a pointless endeavour. I think there might actually be a _huge_, but silent (and somewhat silenced), audience for those summaries and I hate to see them go. Rest assured that had I really seen something objectionable, and had it not already been available as a thread in c.l.p, I would have inquired in c.l.p myself. The fact that that hasn't happened (much?) with me or some others should perhaps be taken more as a sign of how well the caretakers of Python are doing their (volunteer) job, and not as a sign of disinterest on our part. In any case, I too thank you for your past efforts. From pplumlee at omnigon.com Tue Feb 20 00: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 tjg at exceptionalminds.com Tue Feb 20 11: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 aahz at panix.com Sat Feb 17 10: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 embed at geocities.com Wed Feb 28 09: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 Bill.Scherer at VerizonWireless.com Wed Feb 7 08:15:16 2001 From: Bill.Scherer at VerizonWireless.com (Bill Scherer) Date: Wed, 07 Feb 2001 08:15:16 -0500 Subject: im new to python threading question References: <3a81470b$0$16373$7f31c96c@news01.syd.optusnet.com.au> Message-ID: <3A814A64.3970A79A@VerizonWireless.com> Ben de Luca wrote: > > I want to start a new object and pass an object to it how do i do that? > > if > > def funks(s): > do stuff with f > > how do i call def in a new thread and send it args s import thread thread.start_new_thread(funk, (s)) -- William K. Scherer Sr. Member of Applications Staff - Verizon Wireless Bill.Scherer_at_VerizonWireless.com From lluang at northwestern.edu Tue Feb 27 09: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 tjg at exceptionalminds.com Tue Feb 20 18: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 cmh at bDistributed.com Thu Feb 22 09: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 R.Brodie at rl.ac.uk Tue Feb 6 12:03:59 2001 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Tue, 6 Feb 2001 17:03:59 -0000 Subject: cgi.py and HTML 4.0 compliancy References: <95p461$62h$1@nnrp1.deja.com> Message-ID: <95papp$110s@newton.cc.rl.ac.uk> "Juergen" wrote in message news:95p461$62h$1 at nnrp1.deja.com... > it seems that the "&" character between firstParam and secondParam is > not allowed. A bare & is not allowed in HTML because it starts an entity. It should be encoded as & (you might have e.g. A href="users/Jürgen). Even better, follow the HTML4 recommendation (B.2.2) and use ; (semicolon) as a delimiter. cgi.py supports this out of the box. From fredrik at pythonware.com Mon Feb 19 08: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 dkuhlman at rexx.com Sun Feb 25 17: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 fredp at mygale.org.nospam Thu Feb 8 12:19:17 2001 From: fredp at mygale.org.nospam (Fred Pacquier) Date: 8 Feb 2001 17:19:17 GMT Subject: Alpha release of ZODB programming guide References: <95tlrt$7f2$1@nnrp1.deja.com> Message-ID: ndev42 at yahoo.com said : >Seems like you are exploring the namespace of ZO* words, >so just to avoid a faux pas I'd point out that "zob" is a very >rude word in french. Avoid naming a piece of software with anything >close to that! :-) Actually it is a (north-African) Arab word that has become very common in colloquial French, meaning more or less "dick" (pardon my French :-). >No kidding. Indeed. As it is, both "ZOPE" and "ZODB" are close enough, phonetically, when pronounced in French, as to be incomfortable in corporate settings. This may sound trivial, but starting with "Python", a lot of valuable open source software meets credibility problems over here that stem from unfortunate (French-wise) naming choices. Curiously, "Perl" seems to come across much more easily, which is very frustrating :-) -- YAFAP : http://www.multimania.com/fredp/ From fredrik at effbot.org Mon Feb 5 14:57:09 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Mon, 05 Feb 2001 19:57:09 GMT Subject: Can't Generate Random # References: <95mu0p$aqc$1@nnrp1.deja.com> Message-ID: jimmypop181 at my-deja.com wrote: > Does somebody know how to generate a random number in > Python? I read the docs and it says rand(x, y) should do it. what docs? the rand module disappeared from the language years ago... use the "random" module instead: >>> import random >>> random.random() 0.78562250893885366 >>> random.randrange(0, 10) 4 > This also happens when trying to get the Square Root. you mean "sqrt"? did you import the "math" module first? did you use the full name of the function (math.sqrt)? >>> import math >>> math.sqrt(2) 1.4142135623730951 (btw, have you read the tutorial at www.python.org?) Cheers /F From rtexier at elikya.com Mon Feb 19 05: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 dan at eevolved.com Thu Feb 15 18: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 aleaxit at yahoo.com Tue Feb 20 15: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 fredrik at pythonware.com Fri Feb 9 11:22:02 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 09 Feb 2001 16:22:02 GMT Subject: urllib.open('http://www.redherring.com/') References: <95th67$36j$1@nnrp1.deja.com> <95tj33$4g1$1@nnrp1.deja.com> <3A825A68.B1023097@intertrader.com> <95tq9r$afs$1@nnrp1.deja.com> <9607c5$bkj$1@nnrp1.deja.com> <3ditmj99pd.fsf@ute.cnri.reston.va.us> Message-ID: Andrew Kuchling wrote: > I don't believe urllib or httplib were massively rewritten for 2.0 > (nor will they be in 2.1), so if it's a bug, it's probably still there. on my box, it sometimes work under 1.5.2, and never works under an unmodified 2.0 installation. however, the following hack works for both versions (note the explicit socket shutdown). import httplib h = httplib.HTTP("www.redherring.com") h.set_debuglevel(1) h.putrequest("GET","/") h.endheaders() try: h.sock.shutdown(1) # 1.5.2 except AttributeError: h._conn.sock.shutdown(1) # 2.0 errcode, errmsg, headers = h.getreply() f = h.getfile() s = f.read() f.close() print "content length: %d" % len(s) this prints: connect: (www.redherring.com, 80) send: 'GET / HTTP/1.0\015\012' send: '\015\012' reply: 'HTTP/1.1 200 OK\015\012' header: Server: Netscape-Enterprise/4.0 header: Date: Fri, 09 Feb 2001 16:15:36 GMT header: Set-cookie: AnalysisUserId=28177981735337; path=/; expires=Friday, 31 Dec-2010 23:59:59 GMT header: AnalysisUserId: 28177981735337 header: Content-type: text/html header: Connection: close Cheers /F From embed at geocities.com Thu Feb 22 13: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 carifio.nospam at nospam.usys.com Sat Feb 10 11:59:26 2001 From: carifio.nospam at nospam.usys.com (Mike Carifio) Date: Sat, 10 Feb 2001 11:59:26 -0500 Subject: python 2.0 won't run scripts with \r\n line termination on RH7? Message-ID: I have a network of Linux and Windows machines. On a Windows box, I have several python scripts which I'd also like to run on the Linux machines. I've smbmounted the Windows share to see the scripts, but having been created on the Windows box, the line termination in those files is \r\n. When I try to execute the script, say 'start', I get: bash: ./start.py: No such file or directory When I "clean up" start.py with tr - tr -d '\r' < start.py > reallystart.py, it runs. So it seems like python 2 can't compensate for wierd Windows line terminators. Any workarounds, other than 'tr'? Pl. advise. Tx. From sdm7g at virginia.edu Tue Feb 13 19: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 root at rainerdeyke.com Tue Feb 6 16:49:21 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 06 Feb 2001 21:49:21 GMT Subject: x = y References: <3a806eed.5209768@news.cybermesa.com> Message-ID: "Jay O'Connor" wrote in message news:3a806eed.5209768 at 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) I think he wants a deep copy. The 'copy' module might be useful here. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From guido-dot-treutwein-at-nbg-dot-siemens-dot-de.cut-here at no.spam Tue Feb 27 10: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 dan at eevolved.com Tue Feb 6 03:44:01 2001 From: dan at eevolved.com (Dan Parisien) Date: Tue, 06 Feb 2001 08:44:01 GMT Subject: do...while loops References: Message-ID: Issac Trotts wrote: > How about this: > > file = open(...) > while(1): > line = file.readline() > if(line == ""): break > > -Issac Oh yeah... breaks. *sigh* (not a big fan...) Thank you Issac, Dan From mix77 at usa.net Wed Feb 14 05: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 f8dy at my-deja.com Tue Feb 6 11:54:07 2001 From: f8dy at my-deja.com (Mark Pilgrim) Date: Tue, 06 Feb 2001 16:54:07 GMT Subject: Binary numbers References: <95p7ks$9e6$1@nnrp1.deja.com> Message-ID: <95pa79$c0j$1@nnrp1.deja.com> In article <95p7ks$9e6$1 at nnrp1.deja.com>, sampe99 at my-deja.com wrote: > Does anyone know an easy way to get a list of binary numbers within a > certain range in python? E.g for > n=1 [0],[1] > n=2 [0,0],[0,1],[1,0],[1,1] > n=3 [0,0,0],[0,0,1] a.s.o >>> def b(l): return l>1 and [x+y for x in ['0','1'] for y in b(l-1)] or ['0','1'] >>> b(1) ['0', '1'] >>> b(2) ['00', '01', '10', '11'] >>> b(3) ['000', '001', '010', '011', '100', '101', '110', '111'] Why do I get the feeling I'm doing your CS homework? ;) -M -- You're smart; why haven't you learned Python yet? http://diveintopython.org/ Sent via Deja.com http://www.deja.com/ From jurgen.defurne at philips.com Mon Feb 19 03: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 mikael at isy.liu.se Fri Feb 23 05: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 avv at quasar.ipa.nw.ru Tue Feb 27 16: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 gregj at pobox.com Sun Feb 18 05: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 hvrosen at world-online.no Thu Feb 1 04: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 phd at phd.pp.ru Wed Feb 14 04:25:28 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 14 Feb 2001 12:25:28 +0300 (MSK) Subject: CPAN functionality for python In-Reply-To: <01021319314200.05138@branagan> Message-ID: 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. > How many mirrors do we really need? Not "We want as many as CPAN!" but how > many do we actually need to have in order to support the load we expect this > service to undertake and to give some fail-over capabilities. Initially we don't need much mirrors. But I personally hope sooner or later the load will be high. I certainly want to develop Python community and make it bigger and more eager for good modules and extensions! :) > > Please count current mirrors of CPAN. The figure looks good, isn't it? > > This is because there are sites that provide FTP mirrors. > > What is mirrored on all of these sites, the actual database or the service > which does the lookups? All things. Modules, docs, the perl distribution itself, etc. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From amyk at foretec.com Mon Feb 12 18: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 danw at rtp.ericsson.se Mon Feb 12 17: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 robin at jessikat.fsnet.co.uk Sat Feb 3 18: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 chris at voodooland.net Tue Feb 13 19: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 Timo.Becker at INOSOFT.de Wed Feb 21 18: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 tjreedy at udel.edu Sun Feb 18 03: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 doughellmann at home.com Tue Feb 27 21:03:43 2001 From: doughellmann at home.com (Doug Hellmann) Date: Tue, 27 Feb 2001 21:03:43 -0500 Subject: CPAN functionality for python - requirements In-Reply-To: References: Message-ID: <01022721090603.20069@branagan> On Tue, 27 Feb 2001, Bruce Sass wrote: > I'm a little concerned about the privacy aspect of this... > > > That decision is up to the client. If the client has the smarts to turn > > a distutils package into an RPM, then the client would list it's preferred > > format as a distutils package and it would handle the rest. If it can't, > > you can either select an RPM, or fall back to a distutils package. > > Why should the client need to "list" anything. > > client: what do you have? > server: this(deb,rh-5.rpm,rh-6.2.rpm,rh-7.rpm) that() other(hqx) > 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() I'm not sure why the "what do you have" question is needed. The "send me that(mandrake.rpm)" interaction is what we want. The client requests packages in the formats prefered. A standard source format should be available for all packages so that everybody can get every package in some form. If the standard source format contains distutil-enabled scripts, platform specific distribution files could be generated from the source. > 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. No, of course not. > This could work... > client: only show me (deb) and () > client: what do you have? Right, that would be a bit more efficient than specifying a format for every package for every request. > The server should NOT be usable as a tool to track Python users and > their habits, and making it do so should require a conscious effort on > the operators part (so there is no opportunity for the operator to > say, "I don't track you, that's just how the software works"). The server is likely to be a cgi, which by its nature means requests may be written to a log file. Should that be disallowed? Doug From insanc at cc.gatech.edu Wed Feb 21 15: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 precisa at uai.com.br Wed Feb 21 05: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 sheila at spamcop.net Tue Feb 20 19: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 aahz at panix.com Mon Feb 26 11: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 zope at thewebsons.com Mon Feb 19 11: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 robin at jessikat.fsnet.co.uk Fri Feb 23 04: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 alexlong at earthlink.net Wed Feb 21 10: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 aleaxit at yahoo.com Sun Feb 18 03: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 bowman at montana.com Fri Feb 23 08: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 grante at visi.com Tue Feb 20 13: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 billy_bill_1 at my-deja.com Sun Feb 11 23:23:37 2001 From: billy_bill_1 at my-deja.com (billy_bill_1 at my-deja.com) Date: Mon, 12 Feb 2001 04:23:37 GMT Subject: Using Python for Web development References: <965m01$lr7$1@nnrp1.deja.com> Message-ID: <967og3$7hl$1@nnrp1.deja.com> Thanks heaps for all the links and help, I think I'll start with mod_python. One more thing I just thought of, how fast is python compared to php, asp perl etc? PHP is damn fast for a scripting language, any benchmarks around? I just need to see if its in the same sort of league as php and asp. I have to know this (for client and boss) if I'm going to get use it in a commercial environment... here's hoping! Oh and that Servlet in Jpython, would that be like JSP and servlets with no type checking crap? Thanks! Billy In article <965m01$lr7$1 at nnrp1.deja.com>, billy_bill_1 at my-deja.com wrote: > Hi all, > > I'm new to Python and so far I like what I see! I would really like to > use it for web development as I'm currently using PHP and ASP and I'm a > bit sick of thier lack of good OO support and the c style syntax etc > etc (especially php). PHP can be used as an apache module, can python > be used in this way too? I don't want to have to deal with any of the > header information stuff as well like in PERL cgi scripts. Any links > or information anyone can give me to get me on my way? > > Thanks, > Billy > > Sent via Deja.com > http://www.deja.com/ > Sent via Deja.com http://www.deja.com/ From tim.one at home.com Fri Feb 9 02:22:10 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 9 Feb 2001 02:22:10 -0500 Subject: None assigment In-Reply-To: <95vst8$1na$1@panix2.panix.com> Message-ID: [Aahz and Rainer Deyke, volley over a stupid-ass program too long without changing topics ] > b=2 > def foo(): > b=4 > print b > del b > global b > print b > foo() Just noting that the program's behavior is undefined, so "works" vs "doesn't work" is a bogus argument (Ref Man, "global" stmt): Names listed in a global statement must not be used in the same code block textually preceding that global statement. ... (The current implementation does not enforce the latter two restrictions, but programs should not abuse this freedom, as future implementations may enforce them or silently change the meaning of the program.) Which is a lot like saying we left bear traps set all over the room, and you shouldn't abuse your freedom by stepping into one lest you lose a foot or two <0.9 wink>. So why doesn't the compiler check for that and gripe? Don't know. A good guess is because Guido figured he had more important things to do at the time. and-if-we-knew-what-they-were-i-bet-we'd-agree-ly y'rs - tim From objectway at divalsim.it Fri Feb 9 09:20:10 2001 From: objectway at divalsim.it (Nicola Musatti) Date: Fri, 09 Feb 2001 15:20:10 +0100 Subject: Closing a file before or after return? References: <960t2j$9n9$1@cubacola.tninet.se> Message-ID: <3A83FC9A.721F153@divalsim.it> Hi, I'm not even a newbie, but I'll venture an answer. 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: ret = 1 break else: ret = 0 f.close() return ret Best regards, Nicola Musatti From grante at visi.com Wed Feb 21 18: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 muk_pr at yahoo.com Sat Feb 17 11: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 tgagne at ix.netcom.com Tue Feb 27 10: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 johnw at gnu.org Fri Feb 23 03: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 ssthapa at classes.cs.uchicago.edu Tue Feb 13 14:14:29 2001 From: ssthapa at classes.cs.uchicago.edu (ssthapa at classes.cs.uchicago.edu) Date: Tue, 13 Feb 2001 19:14:29 GMT Subject: CPAN functionality for python References: Message-ID: Oleg Broytmann wrote: > I completeley agree that this task *can* be solved using Zope. We can >develop data formats, protocols, etc. And I completely disagree that the >task *should* be solved with Zope. It shouldn't. > Please count current mirrors of CPAN. The figure looks good, isn't it? >This is because there are sites that provide FTP mirrors. > Who will agree to run Zope only to mirror CPyAN? It shouldn't be a problem to have both ftp and zope functionality at the same time. The way the code currently works is new toplevel commands are implemented in separate modules. The main program imports the module and calls a function in the module which registers a top level command and help for the command. It wouldn't be any problem to have an ftpinstall and zopeinstall module coexisting at the same time. -- ---------------------------------------------------------------------------- | 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 chris.gonnerman at usa.net Mon Feb 19 21: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 qrczak at knm.org.pl Thu Feb 22 18: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 rtrocca at libero.it Thu Feb 15 02: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 sandipan at vsnl.com Wed Feb 21 05: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 tjg at exceptionalminds.com Thu Feb 15 15: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 tim.one at home.com Thu Feb 1 02: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 mbel44 at dial.pipex.net Tue Feb 6 12:04:31 2001 From: mbel44 at dial.pipex.net (Toby Dickenson) Date: Tue, 06 Feb 2001 17:04:31 +0000 Subject: Alpha release of ZODB programming guide References: <95mr3t$ad2$1@troll.powertech.no> Message-ID: "Syver Enstad" wrote: >This sounds very exciting, I had been looking forward to an object database >on python. I've tried ZEO under MS Win 2000 but it doesn't seem to work. Is >it supposed to? Some older versions did. Later versions added some socketness that win32 didnt like, although I believe that is fixed on the most recent version. Toby Dickenson tdickenson at geminidataloggers.com From dalke at acm.org Sat Feb 17 06: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 fredrik at pythonware.com Sat Feb 10 08:49:51 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 10 Feb 2001 13:49:51 GMT Subject: Tkinter event References: <963ekd$7si$1@buty.wanadoo.nl> Message-ID: <3Gbh6.14482$AH6.2127525@newsc.telia.net> "knock knock" wrote: > 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? it's probably easier (for everyone, including Tk) to use a canvas- level binding, and do the lookup in the event handler: def eventhandler(event): canvas = event.widget x = canvas.canvasx(event.x) y = canvas.canvasx(event.y) items = canvas.find_overlapping(x, y, x+1, y+1) for item in items: tags = canvas.gettags(item) ... Cheers /F From jafo at tummy.com Mon Feb 26 20:31:38 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Mon, 26 Feb 2001 18:31:38 -0700 Subject: [Distutils] Re: CPAN functionality for python In-Reply-To: ; from bsass@freenet.edmonton.ab.ca on Mon, Feb 26, 2001 at 11:57:36AM -0700 References: <200102261822.NAA26272@cj20424-a.reston1.va.home.com> Message-ID: <20010226183138.E7531@tummy.com> On Mon, Feb 26, 2001 at 11:57:36AM -0700, Bruce Sass wrote: >Ya, RPMs are not known for doing a good job of dependencies. Debian They aren't? The example given was a situation where one could say that RPM was doing *TOO* good a job of dependencies -- it was failing to install because you didn't have what was needed. For quite a long time I was runing a 5.2 machine running the newest versions of GTK, but older versions of glibc. Practicly none of the stock binary RPMs would install on it because of that. However, if you pick up an SRPM, and do "rpm --rebuild package.src.rpm", it will build the RPM against *EXACTLY* the set of libraries and files you have. It works brilliantly. Sean -- "No early worm is giving ME the bird!" -- Bullwinkle J. Moose Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From kvthan at wm.edu Thu Feb 1 12: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 aahz at panix.com Wed Feb 21 11: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 mfletch at tpresence.com Fri Feb 23 23: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 aahz at panix.com Wed Feb 21 11: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 echuck at mindspring.com Fri Feb 23 14: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 gem at hsv.crc.com Tue Feb 27 17: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 juergen.erhard at gmx.net Tue Feb 6 19: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 costas at springmail.com Tue Feb 20 07: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 roy at panix.com Sun Feb 18 14: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 aahz at panix.com Thu Feb 1 14: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 f8dy at yahoo.com Mon Feb 26 09: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 moshez at zadka.site.co.il Mon Feb 5 06:16:50 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Mon, 5 Feb 2001 13:16:50 +0200 (IST) Subject: Please translate this easy snip of C++ to Python In-Reply-To: <20010205000008.G962@xs4all.nl> References: <20010205000008.G962@xs4all.nl>, <95kcbo$k8s@dispatch.concentric.net> Message-ID: <20010205111650.BE66BA840@darjeeling.zadka.site.co.il> On Mon, 5 Feb 2001 00:00:09 +0100, Thomas Wouters wrote: > Note how Python lacks a preprocessor and macros :) People occasionally rally > for a macro preprocessor, but usually not of the C type. Being fairly > ignorant in languages featuring macros other than the C style, I can't > really say what they *are* rallying for, but apparently there are sane macro > preprocessors in existance, somewhere :) If I'm in a mood to annoy Guido, I propose hygienic(sp?) macros, like in R5RS. These are things which are macros, but on the verge on being functions: no accidental name collision, for one. Real macros work on the parser level, not the tokenizer levels, so you can't do idiotic stuff like #define BEGIN { #define END ;} Or other shoot-on-sight offense. -- 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 aleaxit at yahoo.com Sun Feb 18 13: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 s2mdalle at titan.vcu.edu Tue Feb 6 19:31:43 2001 From: s2mdalle at titan.vcu.edu (David Allen) Date: Wed, 07 Feb 2001 00:31:43 GMT Subject: Tkinter: How to remove stacking order of a widget in grid manager References: <3A80712D.BAF8FC0D@pacific.net.hk> Message-ID: In article <3A80712D.BAF8FC0D at pacific.net.hk>, "Bernie" wrote: > Below is the code fragment: > > # remove widget from Grid Display manager > for w in widget_list > w.grid_remove() > > # re-ordering the widget > widget_list.sort( mySort) # mySort() is not listed > > # display widgets in new orders > col = range(5) row = 0 for w in widget_list: > for i in col: > w.grid( column = i, row = row) > row = row + 1 I think what the problem is that it has to be done in the parent, not the child. So if 5 things are grid() into a widget called wid, then wid.grid_forget() will ungrid all of the items. By calling grid_forget on the items you want to take out of the grid, you're unpacking their subitems but not them. Example: f = Frame(parent) b = Button(f, text="Foobar") b.grid(row=0, col=0) if you then want to get rid of b, you do f.grid_forget() NOT b.grid_forget() Hope this helps. -- David Allen http://opop.nols.com/ ---------------------------------------- "I must say that I find television very educational. The minute somebody turns it on, I go to the library and read a book." --Groucho Marx From g_will at cyberus.ca Fri Feb 2 10: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 Jerry.Spicklemire at IFLYATA.COM Thu Feb 15 17: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 Roy.Culley at switzerland.org Fri Feb 16 10: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 chakie at infa.abo.fi Thu Feb 8 02:20:56 2001 From: chakie at infa.abo.fi (Jan Ekholm) Date: 8 Feb 2001 09:20:56 +0200 Subject: Geometric classes (lines, planes etc)? Message-ID: <3a8248d8_1@newsflash.abo.fi> Hi all, For a project we would need to use some classes for manipulating geometric entities. We need something like planes, lines, points etc, and possibilities to manipulate and calculate with them. We do however not want to draw them in any way, so I'm not looking for anything graphical here, just something that allows me to represent simple geometric shapes in space. Is there anything available that we could use, or do we need to build our own? A Google search turned up a *lot* about Tk (which is not what we want) and about using Python with Qt and Gnome. I apologise if this is a RTFM or FAQ. In that case please point me in the right direction. Kind regards, Chakie -- --------------------+-------------------------------------------------------- Jan 'Chakie' Ekholm | Balrog New Media http://www.balrog.fi/ Linux Inside | I'm the blue screen of death, nobody hears your screams From gtalvola at nameconnector.com Thu Feb 8 09:58:05 2001 From: gtalvola at nameconnector.com (Geoff Talvola) Date: Thu, 08 Feb 2001 09:58:05 -0500 Subject: Sorting strings. References: <4a1yt93frj.fsf@kern.srcf.societies.cam.ac.uk> <3A828674.177DFEAE@tismer.com> Message-ID: <3A82B3FC.42BD0D68@NameConnector.com> Christian Tismer wrote: > Gaute B Strokkenes wrote: > > > The problem with this approach is that string comparison doesn't quite > > have the behaviour that I would like. For instance, I'd like numbers > > to come after letters, and I'd like to be case insensitive. Is there > > a reasonably clean way to do this? > > There are several ways. As someone else pointed out, you can of > course make your cmp function as sophisticated as necessary. > > Slightly less powerful, but reasonably faster is to calculate > a suitable key field (which might be a tuple) and do the > sorting on that, without supplying an extra cmp function. > Here's a utility function that makes it easy to sort by providing a function that constructs a sort key: def sortUsingKeyFunc(l, keyfunc): l = [(keyfunc(x), x) for x in l] l.sort() return [y for x,y in l] To use it, simply provide a "keyfunc" that constructs a sort key for the items in the list. For example, to sort a list of strings alphabetically: >>> l = ['E', 'd', 'A', 'b', 'C'] >>> import string >>> sortUsingKeyFunc(l, string.upper) ['A', 'b', 'C', 'd', 'E'] Or to sort a list of dictionaries on "name" case-insensitively, and secondarily on "value": >>> l = [{'name':'AAA', 'value':5}, ... {'name':'aaa', 'value':4}, ... {'name':'AAA', 'value':3}, ... {'name':'bbb', 'value':2}] >>> def keyfunc(d): ... return d['name'].upper(), d['value'] ... >>> from pprint import pprint >>> pprint(sortUsingKeyFunc(l, keyfunc)) [{'value': 3, 'name': 'AAA'}, {'value': 4, 'name': 'aaa'}, {'value': 5, 'name': 'AAA'}, {'value': 2, 'name': 'bbb'}] Note that sortUsingKeyFunc returns a new list -- the original list is unmodified. -- - Geoff Talvola Parlance Corporation gtalvola at NameConnector.com From aleaxit at yahoo.com Wed Feb 28 11: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 lbates at syscon-computers.com Tue Feb 27 11: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 rturpin at my-deja.com Tue Feb 6 18:10:47 2001 From: rturpin at my-deja.com (rturpin at my-deja.com) Date: Tue, 06 Feb 2001 23:10:47 GMT Subject: Scope: Simple and explicit better than nested? Message-ID: <95q09f$2j1$1@nnrp1.deja.com> The recent discussions of nested scope have convinced me that this is the wrong and unpythonic solution to newbies confused by global, local, and builtin namespaces. Instead of making name resolution more complex and more implicit, just to give people something familiar, let's solve the problem by requiring everything to be explicit. Let's do away with both global and builtin namespaces. There is only one namespace, and it is the local namespace. Both "builtin" and the containing module (if any) are automatically entered into it. But to get to THEIR objects would require EXPLICIT scoping: if (builtin.callable(foo)): my_module.doSomething(foo) The only unscoped names would be local variables and parameters. Period, full stop. That should be easy to understand, even for Pascal and SmallTalk programmers. Along with this change, we should eliminate the "from" statement. Names inside modules would be explicitly scoped. Always. Simple and explicit. That is the pythonic way to go. Hating-name-space-rules-ly yrs, Russell Sent via Deja.com http://www.deja.com/ From aaron.ginn at motorola.com Tue Feb 27 17: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 tdelaney at avaya.com Mon Feb 26 22: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 dsh8290 at rit.edu Tue Feb 6 09: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 ljohnson at resgen.com Wed Feb 21 18: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 mbel44 at dial.pipex.net Tue Feb 6 09: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 me at home.nl Mon Feb 26 16: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 alain at onesite.org Sun Feb 18 16:55:22 2001 From: alain at onesite.org (Alain TESIO) Date: Sun, 18 Feb 2001 22:55:22 +0100 Subject: Wish there was an error message References: Message-ID: On Sat, 03 Feb 2001 00:39:57 -0000, kwasi007uk at yahoo.co.uk wrote: >I was using poplib's example as in the documentation. Unfortunately I >typed in the following at the end of the script: > >M.quit instead of M.quit()! > >I forgot the parenthesis. The effect was, that my pop-server produced >really strange things, doubled the number of messages each time I >queried it with poplib. > >But M.quit does not exist. So it should give me an error message? Why >doesn't it? Can I turn it on somehow? > You get the function object, like for this : x=1 x This syntax is useful for interactive use if you want to know what is in an object, but for non-interactive scripts I don't see what is the interest, maybe an option to turn raise an error would help. Alain From deragon at aqiii.org Sat Feb 10 15:01:31 2001 From: deragon at aqiii.org (deragon at aqiii.org) Date: Sat, 10 Feb 2001 20:01:31 -0000 Subject: Compiling Python 2.0 on RedHat 7.0. -> XML stuff missing. Message-ID: <9646mr+7cfv@eGroups.com> Greetings. I am trying to compile Python 2.0 on RedHat 7.0, but I get the following problem: gcc -fpic -I/usr/local/include/xmlparse -g -O2 -Wall -Wstrict-prototypes -I./../Include -I.. -DHAVE_CONFIG_H -c ./pyexpat.c ./pyexpat.c: In function `newxmlparseobject': ./pyexpat.c:639: warning: implicit declaration of function `XML_ParserCreateNS' ./pyexpat.c:639: warning: assignment makes pointer from integer without a cast ./pyexpat.c: In function `pyxml_SetStartNamespaceDeclHandler': ./pyexpat.c:1024: `XML_SetNamespaceDeclHandler' undeclared (first use in this function) ./pyexpat.c:1024: (Each undeclared identifier is reported only once ./pyexpat.c:1024: for each function it appears in.) ./pyexpat.c: In function `pyxml_SetEndNamespaceDeclHandler': ./pyexpat.c:1032: `XML_SetNamespaceDeclHandler' undeclared (first use in this function) ./pyexpat.c: In function `pyxml_SetStartCdataSection': ./pyexpat.c:1040: `XML_SetCdataSectionHandler' undeclared (first use in this function) ./pyexpat.c: In function `pyxml_SetEndCdataSection': ./pyexpat.c:1048: `XML_SetCdataSectionHandler' undeclared (first use in this function) ./pyexpat.c: At top level: ./pyexpat.c:1077: `XML_SetCommentHandler' undeclared here (not in a function) ./pyexpat.c:1077: initializer element is not constant ./pyexpat.c:1077: (near initialization for `handler_info[8].setter') ./pyexpat.c:1089: `XML_SetDefaultHandlerExpand' undeclared here (not in a function) ./pyexpat.c:1089: initializer element is not constant ./pyexpat.c:1089: (near initialization for `handler_info[12].setter') ./pyexpat.c:1092: `XML_SetNotStandaloneHandler' undeclared here (not in a function) ./pyexpat.c:1092: initializer element is not constant ./pyexpat.c:1092: (near initialization for `handler_info[13].setter') make[1]: *** [pyexpat.o] Error 1 make[1]: Leaving directory `/usr/src/redhat/BUILD/Python-2.0/Modules' make: *** [sharedmods] Error 2 I do have expat-1.95.0-1 installed. I am building the python-2.0-2tummy.src.rpm. Anybody have a clue how to get passed this problem? Or if there are any other ways to compile Python 2.0 on RedHat 7.0, please provide the "receipe". Sincerely, Hans Deragon From aahz at panix.com Fri Feb 16 21: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 max at alcyone.com Mon Feb 19 01: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 sjuranic at u.washington.edu Wed Feb 28 01: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 phlip_cpp at my-deja.com Fri Feb 16 17: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 jl.berliet at triade.tm.fr Thu Feb 1 08: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 latlong at css2.com Tue Feb 13 18: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 junaftnoon at nospamplzyahoo.com Tue Feb 6 20:36:11 2001 From: junaftnoon at nospamplzyahoo.com (June Kim) Date: Wed, 7 Feb 2001 10:36:11 +0900 Subject: 2nd Python Seminar in Seoul Was a Success References: <95n463$anj$1@news.nuri.net> <95q39h$hji$5@newshost.accu.uu.nl> Message-ID: <95q8tj$1c8$1@news.nuri.net> "Martijn Faassen" wrote in message news:95q39h$hji$5 at newshost.accu.uu.nl... > June Kim wrote: > > Hello Python users all over the world, > > > We are happy to tell you that the 2nd Python Seminar in Seoul, South Korea > > on Feb. 2 was a great success. We had more than 600 people on the day, and a > > few had to go back home in the morning because we didn't have enough seats > > for them. It was such a boom. A few reporters came to cover the seminar and > > interviewed the people. There'll be several articles about the seminar in > > some magazines next month. > > Woah, we were happy in Europe to have about 70 people attending our > EuroZopeCon a few weeks ago, and you people get 600 people coming to > see about Stackless Python? What are you doing in Korea that we're It wasn't merely about SP. It was a Python seminar: ZOPE, wxPython, C/API, Internet programming, XML, URL, and whole lot more. > not doing in Europe? :) > We gave out Python Reference Library to the people and had a reception at the end; it wasn't totally free, though. (but we had sponsorship from several companies) Warmest regards, June. p.s. the coverage of Python in one of the four major newspapers a few days b4 the seminar and developers' magazine's competitvely carrying articles about Python seem to be major factors of our success. From fuess at att.net Tue Feb 27 08: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 fredrik at pythonware.com Tue Feb 6 07:54:45 2001 From: fredrik at pythonware.com (fredrik at pythonware.com) Date: Tue, 06 Feb 2001 12:54:45 GMT Subject: Q: Python regular expression \Z delimiter References: <95oj66$oi0$1@nnrp1.deja.com> Message-ID: <95os6k$v0b$1@nnrp1.deja.com> Milan Gardian wrote: > Could anybody explain this behavior to me please? Perhaps I do > something wrong, but currently it seems to me this behavior is > a bug in Python's implementation of re. It's a bug. It has been fixed in 2.1. Cheers /F Sent via Deja.com http://www.deja.com/ From objectway at divalsim.it Tue Feb 27 06: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 syver at NOSPAMcyberwatcher.com Sun Feb 4 16:37:04 2001 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Sun, 4 Feb 2001 22:37:04 +0100 Subject: Jython incompatibilities Message-ID: <95ki6h$gst$1@troll.powertech.no> I've tried to reach the Jython list but it wouldn't listen to me so.... I'm checking out Jython while waiting for .NET python. One thing that was a bit weird was that the max function behaves differently on Jython than Cpython. Ex under python: min([]) throws a ValueError exception Ex under jython: min([]) throws a TypeError exception. This is not so great as it can break an application, it did to one of mine. From mwh21 at cam.ac.uk Fri Feb 2 07: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 tim.one at home.com Sat Feb 17 13: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 chris at onca.catsden.net Tue Feb 6 02:24:35 2001 From: chris at onca.catsden.net (chris at onca.catsden.net) Date: Mon, 5 Feb 2001 23:24:35 -0800 (PST) Subject: how to send email in python? In-Reply-To: <3A7FA5BA.82FB7593@esec.com.au> Message-ID: On Tue, 6 Feb 2001, Sam Wun wrote: > hi, > > does anyone knows? I am using python 1.6. import os f = os.popen ( "/usr/sbin/sendmail", "w" ) f.write ( """\ From: your address To: recipient address Subject: spam spam spam wonderful spam spam spam """ ) If you dont have sendmail on your system, or some other MTA, then you can use smtplib to send it directly to an off-site MTA. I can get you some simple code for that, but the above is the preferred way. ("`-/")_.-'"``-._ Ch'marr, a.k.a. . . `; -._ )-;-,_`) Chris Cogdon (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' FC1.3: FFH3cmA+>++C++D++H++M++P++R++T+++WZ++Sm++ ((,.-' ((,/ fL RLCT acl+++d++e+f+++h++i++++jp-sm++ From claird at starbase.neosoft.com Wed Feb 7 10:36:58 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 7 Feb 2001 09:36:58 -0600 Subject: Some basic questions about Tkinter (and Python) References: <7mdg6.13217$AH6.1992583@newsc.telia.net> Message-ID: <5A26DA93165A7B85.352CA80CD738363E.9B52D4C723B787A0@lp.airnews.net> In article <7mdg6.13217$AH6.1992583 at newsc.telia.net>, Fredrik Lundh wrote: . . . >(note that the Tkinter introduction assumes that you can >read Python code fluently, and that you have a basic under- >standing of Python's object and class model). . . . 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. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From wmiller at mediaone.net Mon Feb 19 18: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 chris.gonnerman at usa.net Thu Feb 22 00: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 Max.Haas at unibas.ch Wed Feb 21 13: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 jafo at tummy.com Tue Feb 27 22:41:38 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Tue, 27 Feb 2001 20:41:38 -0700 Subject: CPAN functionality for python - requirements In-Reply-To: <01022721090603.20069@branagan>; from doughellmann@home.com on Tue, Feb 27, 2001 at 09:03:43PM -0500 References: <01022721090603.20069@branagan> Message-ID: <20010227204138.C1781@tummy.com> On Tue, Feb 27, 2001 at 09:03:43PM -0500, Doug Hellmann wrote: >> > 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. If you mean "why would it need to send the list of preferred package formats to the server", it would do that so that the server could return the list of specific entries that the client wants. Currently, the implementation is that the client can ask for a specific package format, and can ask again if there isn't one available, or it can ask the server to list all of them that it has, and then discard the ones it does't want. If this is a privacy concern, don't use it, eh? We can only do so much if you want to be tight-lipped: "I want a package, but I don't want to say what it is." "Ok." >I'm not sure why the "what do you have" question is needed. The "send me >that(mandrake.rpm)" interaction is what we want. If you know exactly the versions, package formats, etc which are available? One could say that if you expect the client to know all this, then you might as well expect them to know where to get the thing... >The server is likely to be a cgi, which by its nature means requests may be >written to a log file. Should that be disallowed? A user is more than welcome to use an anonimizer for connecting to the archive. 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 m.bless at gmx.de Thu Feb 8 14:02:50 2001 From: m.bless at gmx.de (Martin Bless) Date: Thu, 08 Feb 2001 19:02:50 GMT Subject: String formatting characters - looking for details References: <3a81cfa2.1708851@news.muenster.de> Message-ID: <3a82eb27.915141@news.muenster.de> Thanks to all of you. Yes, I'm learning Python, I'm using Python, and I love it. It's probably hard to imagine, but I don't have a Linux/Unix machine at hand. That was part of the problem. And I've done some languages but never really C. And I did some searching but obviously knew to little to find "the needle in that heap of hay" (Brutal attempt of translating a german saying ... So, thanks again, you really helped me. Martin From jafo-pythonlist at tummy.com Thu Feb 15 19: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 eq3pvl at eq.uc.pt Fri Feb 9 07:42:29 2001 From: eq3pvl at eq.uc.pt (Pedro Vale Lima) Date: Fri, 09 Feb 2001 12:42:29 +0000 Subject: embedding C and Python in Perl References: Message-ID: <3A83E5B5.2141B629@eq.uc.pt> Eric Hagemann wrote: > Hey all --- maybe Python needs the same ? Anybody seen this ? > http://www.perl.com/pub/2001/02/inline.html?wwwrrr_20010206.txt That is one thing I'm sure Python can live without. From db3l at fitlinxx.com Fri Feb 23 20: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 danielk at aracnet.com Mon Feb 26 23: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 thomas at xs4all.net Sun Feb 25 15: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 bryan at eevolved.com Mon Feb 5 12:17:33 2001 From: bryan at eevolved.com (Bryan Mongeau) Date: Mon, 05 Feb 2001 17:17:33 GMT Subject: Beginning to learn python...help needed! References: Message-ID: Hi Martyn, I think its great you chose python to expand on your programming abilities. Hopefully you'll become one of those programmers that learnt the best way of doing things right off the bat. Object Oriented (OO) programming is built around one fundamental concept: Everything can (and should) be built with small, *independent* components. Break a task down conceptually first into its components. Then create objects that are ignorant of everything else but their assigned task. Then build your complete program by plugging your objects together. This also has the effect of helping you code in a style that will permit you to reuse those objects over and over again, in different projects. Other people will be able to use your objects and save time because they are self-contained "mini-programs" that accomplish a single task. > I'm also getting nowhere with Tkinter. I tried to look at the Tkinter > tutorial which can be downloaded from python.org, but found that it went > far to fast without nearly enough explanation. I've seen that wxPython is > an alternative, but someone said that there was less documentation > available for that. Given what I've found with the documentation for > Tkinter, this comment puts me off slightly. Can anyone point me in the > direction of detailed info on an appropriate GUI? (Am I right in thinking > that the reason I'm having trouble with Tkinter is that the Object > Orientedness is more apparent early on?) > Ugh TKinter. Well, I can make a few recommendations but most (read: all) GUI toolkits are heavily OO. My experience has also taught me that good documentation is more important that the features of the toolkit itself, due to the fact that if you can't figure out how to use it, it's useless to you. Trolltech develops a premiere GUI toolkit called QT which has by far the best documentation of any I've seen. Check out: http://doc.trolltech.com/ for proof. :) The toolkit is written in C++ but python wrappings that make your job incredibly easy are available at: http://www.thekompany.com/projects/pykde/ For anything more complicated than a toy program, I would consider QT. > Apologies for writing a rather long and rambly message! The ramblier, the better... -- <==================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. www.eevolved.com <==================================> "Now he has departed from this strange world a little ahead of me. That means nothing. People like us, who believe in physics, know that the distinction between past, present, and future is only a stubbornly persistent illusion."-- Einstein From ssthapa at classes.cs.uchicago.edu Tue Feb 20 20: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 jurgen.defurne at philips.com Mon Feb 19 08: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 stephen_purcell at yahoo.com Sun Feb 18 05: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 michael.ellwood at virgin.net Sat Feb 3 15:30:28 2001 From: michael.ellwood at virgin.net (Michael Ellwood) Date: Sat, 3 Feb 2001 20:30:28 -0000 Subject: Basic problem - Syntax error Message-ID: Im writing a programme to decrypt a casaer cipher. Im using a while loop with a counter, and when the counter exceeds a certain value , the loop stops and the alphabet generated is printed eg: plaintextalphabet="abcdefghijklmnopqrstuvwxyz" ciphertext="mhily lza zbhl xbpzxbl mvyabuhl hwwpbz jshbkpbz jhljbz kpjabt hyjhubt lza ulbayvu" counter=0 alphabetpos=0 while counter < 26: cipheralphabet.append(plaintextalphabet[counter:] ** counter = counter + 1 print cipheralphabet Python tells me there is a syntax error on the starred line - can some one please explain why!! Im so annoyed - this is such a basic problem!! -=+Stephen+=- From aleaxit at yahoo.com Thu Feb 22 12: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 danielk at aracnet.com Sun Feb 18 23: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 meowbot at meowing.net Thu Feb 22 04: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 doughellmann at home.com Mon Feb 26 06:45:33 2001 From: doughellmann at home.com (Doug Hellmann) Date: Mon, 26 Feb 2001 06:45:33 -0500 Subject: CPAN functionality for python In-Reply-To: References: Message-ID: <01022606501904.15046@branagan> On Mon, 26 Feb 2001, Bruce Sass wrote: > On Mon, 26 Feb 2001, Sean Reifschneider wrote: > <...> > > My thoughts on that are that it's a job that's probably going to be > > something subject largely to being handed off to appropriate scripts > > based on the platform and some user input (for example, a user may > > prefer to have packages they download installed in ~/lib/python1.5, > > instead of /usr/lib/python1.5). > > > > Ideally though, the tool should be able to deal with allowing the user > > to select their preferred distribution media. I'd prefer to see an ix86 > > RedHat 7.0 RPM, a SRPM, and then would fall back to a distutils file or > > tar file. > > Do you mean: > > A tool that would download a python pkg, then pass it onto scripts > that could turn it into a .deb, .rpm (bunch of flavours), tarball, > etc., then install it. > > or > > A tool that would download pre-packaged distro specific pkgs. > > > Regarding the first... I like this because users will always get an > installable package that fits into their system, and every system can > have packages in their native format - something you can't expect if > developers are doing the distro specific packaging and arbitrary > individuals are filling in the rest. I realize the distros will > probably start auto-building once python modules are available in a > standard format, but users should also have the ability to do the > packaging with a minimum of hoops to jump through. Why is this a desirable feature? Is it worth the complexity? 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. Doug From fredrik at pythonware.com Wed Feb 28 12: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 m.hadfield at niwa.cri.nz Tue Feb 6 18:10:55 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Wed, 7 Feb 2001 12:10:55 +1300 Subject: speed comparison of IDL, numPy, Matlab References: <3A7EEE5C.6419B707@pacific.jpl.nasa.gov> Message-ID: <981501055.966870@clam-ext> "Benyang Tang" wrote in message news:3A7EEE5C.6419B707 at pacific.jpl.nasa.gov... > > Out of curiosity, I did a quick benchmark test of IDL, NumPy and Matlab on my > desktop machine. I know benchmarking is a complicated issue; don't take my > naive test too serious. I don't take it seriously at all, because you've only exercised a tiny fraction of the code in each product. As another very small contribution to the IDL vs NumPy vs Matlab discussion, may I offer my observation that, when you are forced to write (quelle horreur!) a for loop, IDL will process that loop significantly faster than Matlab and orders of magnitude faster than Python. (I'm afraid I can't offer the numbers to back up that assertion right now--it's based on comparisons I did some time ago.) Speaking as a long-time IDL user who has dabbled with Matlab & Python/NumPy, I'd love to switch to NumPy, and I'd do it tomorrow if the graphics capabilities were there. --- Mark Hadfield m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield/ National Institute for Water and Atmospheric Research PO Box 14-901, Wellington, New Zealand From parker at gol.com Wed Feb 21 17: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 binary3418 at my-deja.com Mon Feb 5 05:16:49 2001 From: binary3418 at my-deja.com (Deja User) Date: Mon, 05 Feb 2001 10:16:49 GMT Subject: Install PythonWin on top of Python 2.0 References: <95l4en$rbs$1@nnrp1.deja.com> Message-ID: <95luie$e1g$1@nnrp1.deja.com> Hi, Thanks to all the replies. I've downloaded the right build and the installation is smooth. Regards, Bin Sent via Deja.com http://www.deja.com/ From db3l at fitlinxx.com Fri Feb 23 19: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 bryan at eevolved.com Thu Feb 15 20: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 matthias.oberlaender at daimlerchrysler.com Mon Feb 12 07:16:59 2001 From: matthias.oberlaender at daimlerchrysler.com (matthias.oberlaender at daimlerchrysler.com) Date: 12 Feb 2001 12:16:59 GMT Subject: How to copy class objects? References: <960b75$a2e$1@news.sns-felb.debis.de> <961103$a2e$2@news.sns-felb.debis.de> <9615nm0sjd@news2.newsguy.com> <968bq2$dm7$1@news.sns-felb.debis.de> <968eqo$npm$1@nnrp1.deja.com> Message-ID: <968k7r$dm7$2@news.sns-felb.debis.de> Folks, I don't want to be unfriendly. So, thanks for picking up my post and the numerous replies. But, ... the subject line reads "How to copy class objects?" About 90 % of the replies don't even refer to that question. Once again: I just invented examples so we can talk about something concrete. Perhaps class copying is not the best thing to do in thoses cases. But that is just _another_ question question. Ok, yes, I agree that in over 90 percent a feature someone demands does not match his real intent. But not in my case. Please, believe it. Well.,somebody hinted me towards the 'new' module. Thanks a lot. After a litle trying by myself it seems that the following code would answer my question: # make a clone of class X, with name XClone, and bind it to name Xclone. Xclone = new.classobj('Xclone', X.__bases__, X.__dict__.copy()) I suspect that Xclone is indeed a perfect clone of X. But changes to Xclone's attributes would not affect X (ensured by copying X.__dict__). So I can even kick out a method! Right? -- ____ __ _/_/ . ( / / ( / / / / From dsh8290 at rit.edu Mon Feb 12 15:15:45 2001 From: dsh8290 at rit.edu (D-Man) Date: Mon, 12 Feb 2001 15:15:45 -0500 Subject: CPAN functionality for python In-Reply-To: <20010212115117.A7546@tummy.com>; from jafo@tummy.com on Mon, Feb 12, 2001 at 11:51:18AM -0700 References: <20010212110204.A4625@harmony.cs.rit.edu> <"from dsh8290"@rit.edu> <20010212115117.A7546@tummy.com> Message-ID: <20010212151545.D5667@harmony.cs.rit.edu> On Mon, Feb 12, 2001 at 11:51:18AM -0700, Sean Reifschneider wrote: | On Mon, Feb 12, 2001 at 11:02:04AM -0500, D-Man wrote: | >On Sun, Feb 11, 2001 at 02:06:37PM +0000, ssthapa at cs.uchicago.edu wrote: | >| I've created a sort of proof of concept that implements something | >| similar to perl's CPAN. Right now, it allows basic user interaction | >| and should be able to download and install modules. | > | >Debian has a great system for package management and dependency | >resolving. Maybe we should port dpkg/apt to all other OSes? ;-) | | The first question I would ask is: is there any way we can leverage | the work done by the Trove project? I really don't know the status | of that project though. Eric? Any way to leverage off the work done I'm not familiar with Trove. What is it and where is it used? | by CPAN? Trying to leverage off existing art is a good idea, but I | don't think that dpkg is the right sort of tool for it. If the I don't know. It would be cool to have dpkg and apt-get for Windo~1 though (Or at least rpm). I was over at my friend's house yesterday trying to install drivers for an ethernet card on his Win98 system. It was a mess! To finally get the install to work, we had to manually remove the old (from earlier failed installs) driver files from the C:\Windows\System directory. My friend is computer literate, and familiar with RH Linux as well. We were both wishing we could locate files (such as with a rpm/dpkg query) and not reboot several dozen times! Probably just wishful thinking ... | system could integrate with dpkg, rpm, swinstall, great! | | The other thing I'd say is exactly what I said to ESR about Trove: | it would be ideal if the system could deal with mirror functionality. | The central site(s) wouldn't necessarily have the content, but you'd | ask them and they'd tell you where you can get the content. | | For example, you may ask about "filterinput", and it would report | that there are versions X and Y and Z. Then you'd ask where to find | "filterinput" version X and it would give you a list of URLs that | have it (or the like). Ideally, you'd then be able to send a light-weight | packet to the servers listed asking about their willingness to provide | that resource, but that could be optional. It would be nice to be | able to easily prune out the mirrors that were already at capacity, | no longer had that file or that version, etc... | That would be a cool feature. | ESR dismissed it because it wasn't really possible to do with a regular | web or ftp client. However, if we're probably going to have our own | client anyway (a browser isn't likely to be able to install the software | once it's downloaded). Something like dselect or apt right? I don't have a problem with that. -D From emile at fenx.com Thu Feb 22 09: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 skip at mojam.com Mon Feb 26 15: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 paul at fxtech.com Sat Feb 17 10: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 bsb at winnegan.de Thu Feb 8 10:23:16 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 08 Feb 2001 16:23:16 +0100 Subject: catching all exceptions In-Reply-To: <87y9vhp5r0.fsf@winnegan.de> References: <95uati$cm4$1@icrf.news> <87y9vhp5r0.fsf@winnegan.de> Message-ID: <87snlpp5az.fsf@winnegan.de> Sorry for the typo :-( Siggy Brentrup writes: > import traceback, cStringIO > > f = cStringIO.StringIO f = cStringIO.StringIO() > traceback.print_exc(None, f) > > write_to_database(f.getvalue()) > > HTH > Siggy From db3l at fitlinxx.com Wed Feb 7 22:37:54 2001 From: db3l at fitlinxx.com (David Bolen) Date: 07 Feb 2001 22:37:54 -0500 Subject: threading.RLock not subclassible? References: <3A7D5B5F.AADAA673@ll.mit.edu> <3A7F5C74.6C9BC395@home.com> <3A80A969.54B41DFF@home.com> Message-ID: Rick Lee writes: > "A multithreaded program executes by dividing its processing time > between all active threads. For example, a program with 10 active > threads of execution would allow approximately 1/10 of its CPU time > to each thread and cycle between threads in rapid succession." > > I certainly was not seeing this behaviour on some platforms, even > for threads that take a long time to perform computations. Well, that may be a different issue than your posted point about the active thread count. It is possible that depending on the local thread implementation (at the process level, OS kernel level, pre-emptive versus cooperative, etc...) that you may get better or worse sharing. Really the only bad case is if the threads are cooperative (that is, a thread has to yield before the scheduler moves to another thread). I'm not sure which if any platforms fall into that category (perhaps someone else can answer for the typical Unix pthreads implementation). How were you measuring the division of labor amongst the threads? > - what is the thread switching performance penalty, and how sensitive is the > penalty to the number of threads? There's a hit to the Python interpreter to support threading (I think I recall seeing something like 10%) in general, but actually switching between the threads should be quite low overhead. Certainly when threads are native to the platform's OS (such as with Windows NT), the system scheduler really only thinks in terms of threads anyway, so thread context switches are just the normal mode of dispatching. It should also be fairly insensitive to the number of threads, providing overall system resources are not exceeded. > - is there an upper limit to the number of threads? That depends on the platform - you'll definitely run out of resources eventually, but it's sort of like asking what's the upper limit on the number of processes on the system, which can vary. It also depends on what they are doing, since you can likely support far more threads if the majority are blocked, then if you are trying to share the CPU among them all as active threads. Certainly I would expect that hundreds should not be out of the question, and probably thousands. My desktop NT machine just with a normal mix of stuff active sits with 42 processes and about 250 threads, and I expect it could easily handle an order of magnitude higher - as long as they weren't all trying to run simultaneously. But I don't have a hard limit for you, nor do I personally know of such values across all platforms. It's a per-platform resource issue and is related to the activity of the code as well, so I'm not sure there's a fixed answer. Certainly if you're thinking in terms of thousands you may want to find a way to share them - but if you're thinking 10s or hundreds, you're probably ok. > Regarding what happens on the Mac: I have a multi-threaded program > with several threads, each of which blocks without timeout on > sockets.accept, sockets.recv, and queues.get respectively. This > program runs perfectly on NT and Linux, but the blocked threads on > the Mac don't seem to execute when the blocking condition is removed > (I am 99% sure that's what's happening). If anyone can shed light > on this, I will be very grateful. By blocking condition removed, do you mean that data shows up on the socket or queues? I really can't think why if such data were to arrive that the system calls wouldn't be satisfied. I don't see the Mac implementation in the CVS tree I've currently got checked out, so I'm not sure how the Mac threading is implemented - perhaps someone else could chime in with some info. > Another weirdness includes a bit of code like this, which is a > recursive call on itself to create threads: Well, my first inclination is that the code itself appears dangerous - and unpredictable - because you don't have any protection against simultaneous access to the shared objects (e.g., runners). But it's hard to say without seeing more of the surrounding code. But for example, it would appear that by the time you get around to appending "me" to your completedRunObj, it's probably been changed by a new thread. Personally, if you're trying to observe behavior of threads, I find that a few judicial print statements can help out a lot. Yes, if your problems have a time component, the additional time to do the output can interfere, but for basic scheduling (what thread ran when) it can be enlightening to just print the names of threads and points of their execution all in sequence. If you keep your output as a single string to the "print" statement, it won't get split amongst different threads either, which can be a problem sometimes with this approach. -- -- 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 jafo-pythonlist at tummy.com Thu Feb 15 17: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 dan at eevolved.com Sun Feb 11 18: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 marc.vollmer at mahr.de Mon Feb 12 01: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 thomas.heller at ion-tof.com Mon Feb 19 07: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 sheila at spamcop.net Sun Feb 18 21: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 Bill.Scherer at VerizonWireless.com Thu Feb 1 19: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 dsh8290 at rit.edu Sat Feb 3 12:34:46 2001 From: dsh8290 at rit.edu (D-Man) Date: Sat, 3 Feb 2001 12:34:46 -0500 Subject: Python and GTK In-Reply-To: <3A7C364B.695D274A@cybermesa.com>; from joconnor@cybermesa.com on Sat, Feb 03, 2001 at 04:48:11PM +0000 References: <3A7C364B.695D274A@cybermesa.com> Message-ID: <20010203123446.A18900@harmony.cs.rit.edu> On Sat, Feb 03, 2001 at 04:48:11PM +0000, Jay O'Connor wrote: [snip] | ImportError: /usr/local/lib/python2.0/site-packages/_gtkmodule.so: | undefined symbol: GTK_TYPE_GDK_COLOR | [jay at altaica gtk_test]$ | | Anyone else run into anything like this or have success or failure | running GTK with Python? I haven't had problems on my system. It looks like _gtkmodule.so (the C shared library part of the GTK bindins) makes a reference to the symbol GTK_TYPE_GDK_COLOR. Do you have GTK installed on the system? I think this is a problem with the C libraries and ld's config on your system. HTH, -D From rickp at telocity.com Wed Feb 14 18:10:37 2001 From: rickp at telocity.com (Rick Pasotto) Date: Wed, 14 Feb 2001 23:10:37 GMT Subject: Accessing Widget With GTK References: <3A826E68.E77DB89@bellsouth.net> Message-ID: On Thu, 08 Feb 2001 10:00:58 GMT in comp.lang.python, Tony Corrente wrote: > Hello. > > I am very new to Python so please excuse me if this question is stupid > but I can't find an example anywhere. I've created a form using Glade. > The form has a entry field name pName and a button. I've run glc.py and > created the Python code. Where do I find this? (glc.py) -- "Freedom is just chaos with better lighting." -- Alan Dean Foster Rick Pasotto email: rickp at telocity.com From f8dy at my-deja.com Wed Feb 7 15:05:27 2001 From: f8dy at my-deja.com (Mark Pilgrim) Date: Wed, 07 Feb 2001 20:05:27 GMT Subject: perl regex to python References: <95qodk$mh9$1@nnrp1.deja.com> Message-ID: <95s9pv$1h0$1@nnrp1.deja.com> In article , scarblac at pino.selwerd.nl wrote: > >>> import time > >>> time.asctime(time.strptime("11/05/2001","%m/%d/%Y")) > 'Mon Nov 5 00:00:00 2001' > > If you need this on Windows, there are pure Python implementations out > there, somewhere. http://www.fukt.hk-r.se/~flognat/hacks/strptime.py -M -- You're smart; why haven't you learned Python yet? http://diveintopython.org/ Sent via Deja.com http://www.deja.com/ From tuttledon at hotmail.com Mon Feb 5 20:35:02 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Tue, 06 Feb 2001 01:35:02 GMT Subject: While everyone is saying what they want in Python :) References: <3A7D64D8.74E71826@cybermesa.com> <3A7D9C1D.781F8E5@alcyone.com> <3A7DB154.87E04245@cybermesa.com> Message-ID: "Jay O'Connor" wrote in message news:3A7DB154.87E04245 at cybermesa.com... > I'm not familiar with the 'with' keyword in Delphi. Here's a vbscript example. With MyLabel .Height = 2000 .Width = 2000 .Caption = "This is MyLabel" End With Personally, I'd love to see Python include the 'with' keyword! It improves readability and should execute a bit faster as well. Don From fuess at att.net Wed Feb 7 20:50:55 2001 From: fuess at att.net (David Fuess) Date: Thu, 08 Feb 2001 01:50:55 GMT Subject: ADO/ODBC call via Python/IIS References: <95f558$jgl$1@nnrp1.deja.com> <%FGe6.31314$Ch.7369562@newsrump.sjc.telocity.net> <95sisd$ahc$1@nnrp1.deja.com> <95sjll$bbs$1@nnrp1.deja.com> <95skd2$c13$1@nnrp1.deja.com> <1ilg6.61167$Ch.11522747@newsrump.sjc.telocity.net> Message-ID: Here is the beginning of my SQL Server class: class Database: def __init__(self,Name,Server="Default",Arg=""): self.adoConn = None self.adoRS = None self.RecordCount = 0 self.eof = 1 self.ConnectString = "database=%s;driver={SQL Server};QueryTimeout=300;server=%s;uid=sa%s"%(Name,Server,Arg) self.Schema = {} if AutoOpenOnInit: self.Open(Name) def Open(self,Name): if self.adoConn is not None: self.Close() self.adoConn = win32com.client.Dispatch('ADODB.Connection') self.adoConn.CursorLocation = 3 self.adoConn.CommandTimeout = 900 self.adoConn.Open(self.ConnectString) if AutoloadSchema: self.LoadSchema() And so on ... I use it regularly to connect to SQL Server Databases. It is DSNless in that it attaches directly to SQL Server without any specific DSN assignments. It has nothing to do with IIS, only ADO. Dave On Wed, 7 Feb 2001 17:57:47 -0600, "dsavitsk" wrote: >maybe not the error here, but you need a ";" at the end of the string ... >see below. > >> adoConn.Open('driver=SQL >> Server;server=sql0;uid=xxx;pwd=yyy;database=zzz;') > > From scarblac at pino.selwerd.nl Thu Feb 15 12: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 tim.one at home.com Sun Feb 18 13: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 rgruet at intraware.com Tue Feb 13 12: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 shaleh at valinux.com Sun Feb 25 23: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 jdgorman at nospam.ieee.org Tue Feb 13 23:39:51 2001 From: jdgorman at nospam.ieee.org (John D. Gorman) Date: Wed, 14 Feb 2001 04:39:51 GMT Subject: Attention Travis Oliphant References: <3A7CE79E.455935D0@mega-nerd.com> Message-ID: <3A8A0C15.D2F13D84@nospam.ieee.org> Eric, I had the same question a few weeks ago. Those files are now being maintained at Travis Oliphant's Python Pages which is at http://pylab.sourceforge.net/ . Cheers, John Gorman Erik de Castro Lopo wrote: > Sorry for posting this to the group but email to Travis does > not get answered. > > Travis, > > I have been trying for two weeks now to get a copy of two Python > extensions you wrote and listed on Vaults of Parnassus. > > Both are advertised as being available at > > http://oliphant.netpedia.net/ > > which requires a password. > > Is this software still available? If so can you either fix your > web server so that it can be accessed without a password or > move it to as server that doesn't require one. > > Erik > -- > +----------------------------------------------------------+ > Erik de Castro Lopo nospam at mega-nerd.com (Yes its valid) > +----------------------------------------------------------+ > Linux: Because rebooting is for adding new hardware -------------- next part -------------- An HTML attachment was scrubbed... URL: From andymac at bullseye.apana.org.au Thu Feb 8 21:11:26 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Fri, 9 Feb 2001 13:11:26 +1100 (EDT) Subject: python-dev summary, Jan. 16-31 In-Reply-To: Message-ID: On 8 Feb 2001, Konrad Hinsen wrote: > So personally I hope that someone will take up the job of providing > development summaries in the future. And I'd like to thank Andrew > for having done so for many months already. Ditto on both counts. -- 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 dan at eevolved.com Tue Feb 13 21: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 dsh8290 at rit.edu Fri Feb 2 13: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 stephen_purcell at yahoo.com Thu Feb 15 09: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 wayne.izatt at _nospam_myself.com Sat Feb 24 01: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 costas at meezon.com Wed Feb 21 22: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 pieter at equinox.co.za Mon Feb 5 06: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 thomas at xs4all.net Sat Feb 3 21:05:04 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 4 Feb 2001 03:05:04 +0100 Subject: Wish there was an error message In-Reply-To: <95fk0t+uu67@eGroups.com>; from kwasi007uk@yahoo.co.uk on Sat, Feb 03, 2001 at 12:39:57AM -0000 References: <95fk0t+uu67@eGroups.com> Message-ID: <20010204030503.B962@xs4all.nl> On Sat, Feb 03, 2001 at 12:39:57AM -0000, kwasi007uk at yahoo.co.uk wrote: > But M.quit does not exist. So it should give me an error message? Why > doesn't it? Can I turn it on somehow? M.quit does exist. It's a function or method object. M.quit is simply an attribute access, which yields the object that is 'stored' in the 'quit' attribute of 'M'. If you then 'call' that object, using ()'s, you execute the code. This would do exactly the same: q = M.quit q() As would getattr(M, "quit")() There is nothing special about functions or methods, they are just objects like everything else. In fact, you can create your own class that behaves just like a function, by supplying a __call__ method. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From thomas at xs4all.net Mon Feb 26 01: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 doughellmann at bigfoot.com Tue Feb 20 20: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 hwanjoyu at uiuc.edu Wed Feb 7 17:45:38 2001 From: hwanjoyu at uiuc.edu (Hwanjo Yu) Date: Wed, 7 Feb 2001 16:45:38 -0600 Subject: Q: urlopen and timeout Message-ID: Hi, It seems there is no way for us to set up the timeout explicitly in the urlopen function. Although it may have the default timeout in the function, it seems to wait forever sometimes because of the unexpected web site's behavior. Is there any way to set the timeout explicitly ? And, The socket function also doesn't have timeout parameter, so I don't have any idea when the socket connection function is gonna return. How to set timeout for these cases ? Thanks. From tushar at hursley.ibm.com Thu Feb 1 14: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 Uwe.Hoffmann at bc.boehringer-ingelheim.com Thu Feb 8 03:03:24 2001 From: Uwe.Hoffmann at bc.boehringer-ingelheim.com (Uwe.Hoffmann at bc.boehringer-ingelheim.com) Date: Thu, 8 Feb 2001 09:03:24 +0100 Subject: Trace function with automatic source code location reporting Message-ID: <14074F0BA53BD411803000A0C9DD65111F0EF1@bc0exch7.bc.de.bic> Hi! J?rgen Hermann wrote: >>The following is the core of a tracing function, is there any less obscure >> way to get the location of the caller? Maybe you are looking for : tb = traceback.extract_stack()[-2] print "%s,%i,%s: " %(tb[0],tb[1],tb[2],) , Regards Uwe From jmg at ecs.soton.ac.uk Mon Feb 5 05: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 s713221 at student.gu.edu.au Wed Feb 21 16: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 echuck at mindspring.com Thu Feb 22 22: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 rturpin at do.not.use Mon Feb 19 14: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 news at pastelhorn.com Mon Feb 26 18: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 none at none.com Sat Feb 10 08:00:10 2001 From: none at none.com (knock knock) Date: Sat, 10 Feb 2001 14:00:10 +0100 Subject: Tkinter event Message-ID: <963ekd$7si$1@buty.wanadoo.nl> 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? - David From n8gray at caltech.edu.is.my.email.address Tue Feb 6 02:58:50 2001 From: n8gray at caltech.edu.is.my.email.address (Nathaniel Gray) Date: Mon, 5 Feb 2001 23:58:50 -0800 Subject: speed comparison of IDL, numPy, Matlab References: <3A7EEE5C.6419B707@pacific.jpl.nasa.gov> <3A7F0856.3CFA7FA2@ncep.noaa.gov> Message-ID: <95ob6p$oba@gap.cco.caltech.edu> Paul van Delst wrote: > I've never used Python, and Matlab only once or twice, but what's with the > Python syntax? Seems a tad wordy. Looks like Nick Bower's IDL-like package > in Python (http://nickbower.com/computer/pydl) is worth another look > though...... It's true that Numpy code can end up more verbose than Matlab, although this example doesn't really hilight that issue. This is to be expected from a language that wasn't designed from the ground up as a numerical computing language. There's a faint glimmer of hope that we may get a new Python operator for matrix multiplication, though. (See PEP 211) On the flipside, have you ever tried to write user interfaces in Matlab? Have you ever tried to implement a dictionary in Matlab? Have you ever tried to understand when Matlab is making a copy of a giant array and when it's using a reference? Have you ever had your Matlab license expire the day of a meeting, _before_ you've made your plots? I have. Having used IDL and Matlab quite extensively, I've realized that in any moderately complex numerical program 75% of the code is *programming* and only 25% of the code is *numerical*. I'd take a great general-purpose language with decent numerical extensions over a decent language with great numerical capabilities any day of the week, and twice on Sunday. :^) > paulv > > P.S. BTW, in Matlab, how do you simply multiply the corresponding matrix > elements? (i.e. not a matrix multiply). mat1 .* mat2; -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From gregor at mediasupervision.de Tue Feb 20 10: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 m.faassen at vet.uu.nl Wed Feb 28 05: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 snowzone at home.com Sat Feb 24 22: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 chrisw at nipltd.com Wed Feb 21 10: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 aleaxit at yahoo.com Thu Feb 22 05: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 max at alcyone.com Fri Feb 23 11: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 robin.thomas at starmedia.net Tue Feb 27 13: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 gst at sysfrog.org Sat Feb 10 19:26:59 2001 From: gst at sysfrog.org (Guenther Starnberger) Date: 11 Feb 2001 01:26:59 +0100 Subject: nassi-shneiderman generator Message-ID: <87bssa6p4c.fsf@nirvana.sysfrog.org> i'm searching a nassi-shneiderman generator for python code (or some other tool which generates nice diagrams, etc. stuff from my python code (i need it for a school project)). tnx /gst -- sysfrog.org From bridgman at wyeth.gsfc.nasa.gov Wed Feb 21 09: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 drewpc at my-deja.com Thu Feb 1 15: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 phlip_cpp at my-deja.com Wed Feb 14 09: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 robin at jessikat.fsnet.co.uk Fri Feb 2 08: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 tim.one at home.com Fri Feb 16 17: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 phlip_cpp at my-deja.com Thu Feb 22 15: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 jpet at eskimo.com Sun Feb 18 22: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 quinn at retch.ugcs.caltech.edu Tue Feb 6 16: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 bryan at eevolved.com Mon Feb 5 14:37:24 2001 From: bryan at eevolved.com (Bryan Mongeau) Date: Mon, 05 Feb 2001 19:37:24 GMT Subject: Why "undefined reference to `Py_Initialize' " error? References: Message-ID: Have you tried explicitly including "pythonrun.h"? That file specifies Py_Initialize I think. Bill Xu wrote: > Hi, Buddies: > > Please help me with Python embeded C++ problem: > I compile the following file with gcc -I /usr/local/include/python2.0/ > basic1.c > It gives me " undefined reference to `Py_Initialize' " error, > Do I miss some setting in Python 2.0 or miss some package? > I can't find my Modules, Python ... directorys in my python 2.0 directory. > Please give me some hints! Thanks in advance. > > Bill > > The makefile with this sample is: > PY = /usr/include/python1.5 > > PLIBS = $(PY)/Modules/libModules.a \ > $(PY)/Python/libPython.a \ > $(PY)/Objects/libObjects.a \ > $(PY)/Parser/libParser.a > > POBJS = $(PY)/Modules/config.o $(PY)/Modules/getpath.o > > basic1: basic1.o > cc -g basic1.o $(POBJS) $(PLIBS) -lm -o basic1 > > basic1.o: basic1.c > cc basic1.c -c -g -I$(PY)/Include -I$(PY)/. > > > > $ gcc -I /usr/local/include/python2.0/ basic1.c > /tmp/ccNyWd2r.o: In function `main': > /tmp/ccNyWd2r.o(.text+0x2d): undefined reference to `Py_Initialize' > collect2: ld returned 1 exit status > > > #include "Python.h" > char *getprogramname() { return "basic1"; } > > main() { > printf("%s\n", getprogramname()); > Py_Initialize(); > // PyRun_SimpleString("import string"); > // PyRun_SimpleString("print string.uppercase"); > // PyRun_SimpleString("x = string.uppercase"); > // PyRun_SimpleString("print string.lower(x)"); > } > > > > > > > -- <==================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. www.eevolved.com <==================================> "Now he has departed from this strange world a little ahead of me. That means nothing. People like us, who believe in physics, know that the distinction between past, present, and future is only a stubbornly persistent illusion."-- Einstein From sandipan at vsnl.com Wed Feb 14 08: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 tim.one at home.com Sat Feb 3 23:20:02 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Feb 2001 23:20:02 -0500 Subject: Will nested scoping break restricted execution ?? In-Reply-To: Message-ID: [Martin von Loewis] > ... > I believe there isn't a way to prevent restricted code from accessing > a specific __builtin__, either - instead, you have to provide > alternative or missing versions of the builtins in advance. RExec.nok_builtin_names is a tuple of the builtin names to be rendered invisible. A subclass can define its own tuple of forbidden builtins. Attempts to reference one of these names in restricted code just raises a NameError, because it's plain missing: >>> from rexec import RExec >>> class NoIntRExec(RExec): ... nok_builtin_names = RExec.nok_builtin_names + ("int",) ... >>> def int_abuser(): ... print int(44.4) ... >>> RExec().r_exec(int_abuser.func_code) # fine by regular RExec 44 >>> NoIntRExec().r_exec(int_abuser.func_code) # but not mine Traceback (most recent call last): File "", line 1, in ? ... [lotsa rexec stuff] ... File "c:\code\python\dist\src\lib\ihooks.py", line 326, in load_module exec code in m.__dict__ File "c:\code\python\dist\src\lib\string.py", line 189, in ? _int = int NameError: name 'int' is not defined >>> simple-and-effective-is-a-delightful-combo-ly y'rs - tim From dbrueck at edgix.com Tue Feb 6 11:45:36 2001 From: dbrueck at edgix.com (Dave Brueck) Date: Tue, 6 Feb 2001 09:45:36 -0700 Subject: profile + threads? Message-ID: Has anybody had problems using the profile module with threads? This program: ---------------------------- import profile def yo(): for j in range(5): print j, profile.run('yo()') ---------------------------- displays: 0 1 2 3 4 3 function calls in 0.070 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 0.000 0.000 :1(?) 1 0.000 0.000 0.000 0.000 p1.py:3(yo) 0 0.000 0.000 profile:0(profiler) 1 0.069 0.069 0.070 0.070 profile:0(yo()) but this version: ---------------------------- import threading, profile, time def yo(): for j in range(5): print j, def go(): threading.Thread(target=yo).start() time.sleep(1) profile.run('go()') ---------------------------- displays: 0 1 2 3 4 14 function calls in 1.052 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 1.001 1.001 :1(?) 1 1.000 1.000 1.001 1.001 p1.py:7(go) 1 0.050 0.050 1.052 1.052 profile:0(go()) 0 0.000 0.000 profile:0(profiler) 1 0.000 0.000 0.000 0.000 threading.py:135(Condition) 1 0.000 0.000 0.000 0.000 threading.py:140(__init__) 1 0.000 0.000 0.000 0.000 threading.py:304(_newname) 1 0.000 0.000 0.000 0.000 threading.py:321(__init__) 1 0.000 0.000 0.000 0.000 threading.py:335(_set_daemon) 1 0.001 0.001 0.001 0.001 threading.py:350(start) 2 0.000 0.000 0.000 0.000 threading.py:39(__init__) 1 0.000 0.000 0.000 0.000 threading.py:44(_note) 1 0.000 0.000 0.000 0.000 threading.py:444(isDaemon) 1 0.000 0.000 0.000 0.000 threading.py:516(currentThread) The function yo() isn't mentioned anywhere. The single call to threading.start shows up, but in the real program in which I'm seeing this program has many threads, each of which calls many child functions, so I can't rely on that. Any ideas? Thanks, Dave From dan at eevolved.com Mon Feb 5 10: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 erno-news at erno.iki.fi Wed Feb 14 03: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 MarkH at ActiveState.com Thu Feb 15 07: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 tim.one at home.com Fri Feb 23 01: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 sholden at holdenweb.com Tue Feb 6 18:34:55 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 6 Feb 2001 18:34:55 -0500 Subject: Getting one character at a time from sockets References: <95q044$2f9$1@nnrp1.deja.com> Message-ID: "penman" wrote in message news:95q044$2f9$1 at nnrp1.deja.com... > 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) > > Thanks in advance. > > > Sent via Deja.com > http://www.deja.com/ > I suspect the problem here is the sending end: if you can convince the transport layer to flush its buffers after getting one character from the sending application then you should, in theory, be able to receive that single byte (since the PSH flag should cause the receiving end to debuffer). This isn't easy without closing the socket, however ... have you considered revising your application architecture? The Unix Socket FAQ has the following (and a lot more) to say about this subject: 11. How can I force a socket to send the data in its buffer? >From Richard Stevens (rstevens at noao.edu): You can't force it. Period. TCP makes up its own mind as to when it can send data. Now, normally when you call write() on a TCP socket, TCP will indeed send a segment, but there's no guarantee and no way to force this. There are lots of reasons why TCP will not send a segment: a closed window and the Nagle algorithm are two things to come immediately to mind. (Snipped suggestion from Andrew Gierth to use TCP_NODELAY) Setting this only disables one of the many tests, the Nagle algorithm. But if the original poster's problem is this, then setting this socket option will help. A quick glance at tcp_output() shows around 11 tests TCP has to make as to whether to send a segment or not. Now from Dr. Charles E. Campbell Jr. (cec at gryphon.gsfc.nasa.gov): As you've surmised, I've never had any problem with disabling Nagle's algorithm. Its basically a buffering method; there's a fixed overhead for all packets, no matter how small. Hence, Nagle's algorithm collects small packets together (no more than .2sec delay) and thereby reduces the amount of overhead bytes being transferred. This approach works well for rcp, for example: the .2 second delay isn't humanly noticeable, and multiple users have their small packets more efficiently transferred. Helps in university settings where most folks using the network are using standard tools such as rcp and ftp, and programs such as telnet may use it, too. However, Nagle's algorithm is pure havoc for real-time control and not much better for keystroke interactive applications (control-C, anyone?). It has seemed to me that the types of new programs using sockets that people write usually do have problems with small packet delays. One way to bypass Nagle's algorithm selectively is to use "out-of-band" messaging, but that is limited in its content and has other effects (such as a loss of sequentiality) (by the way, out-of-band is often used for that ctrl-C, too). More from Vic: So to sum it all up, if you are having trouble and need to flush the socket, setting the TCP_NODELAY option will usually solve the problem. If it doesn't, you will have to use out-of-band messaging, but according to Andrew, "out-of-band data has its own problems, and I don't think it works well as a solution to buffering delays (haven't tried it though). It is not 'expedited data' in the sense that exists in some other protocols; it is transmitted in-stream, but with a pointer to indicate where it is." etc., etc., ... regards Steve From scarblac at pino.selwerd.nl Mon Feb 19 12: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 sholden at holdenweb.com Fri Feb 16 09: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 mwh21 at cam.ac.uk Tue Feb 6 13: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 info at pythonware.com Mon Feb 19 06: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 joconnor at cybermesa.com Tue Feb 6 11:15:21 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Tue, 06 Feb 2001 16:15:21 +0000 Subject: do...while loops References: <95p75f$85m$1@panix3.panix.com> Message-ID: <3A802319.46EBCA35@cybermesa.com> Aahz Maruch wrote: > > In article , > Simon Brunning wrote: > > From: Langa Kentane [SMTP:LangaK at discoveryhealth.co.za] > >> > >> Why is is it while 1: > >> would while 2: > >> or while 3: work? > > > >Yup - any non-zero number is considered true. They wouldn't do anything > >different, though, and they just might confuse someone. (Why 2?) > > Well, let's split the difference: > > while 2.5: Umm..then how about a counter? Would this work? x = 100 while x: print x x -= 1 Yeah, just tried it...it works. Umm...anyone really like it? :) -- Jay O'Connor joconnor at cybermesa.com http://www.cybermesa.com/~joconnor Python Language Discussion Forum - http://pub1.ezboard.com/fobjectorienteddevelopmentpython From db3l at fitlinxx.com Thu Feb 8 17:53:44 2001 From: db3l at fitlinxx.com (David Bolen) Date: 08 Feb 2001 17:53:44 -0500 Subject: mxODBC problems References: Message-ID: "Nicole Cook" writes: > I've installed mxODBC on Windows, and I'm still trying to get it to the > point where I can use it. I know it's all there, and it's not colliding > with win32all. Is there something wrong with my python path? I don't know > what to try next. Are you sure you're getting mxODBC and not some other ODBC module? It sort of looks like you may still not be getting the module you think you are? > Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [ > Copyright 1991-1995 Stichting Mathematisch > >>> import ODBC What happens if you "print ODBC.__file__" - you should see it reference the __init__.py file from your mxODBC installation (normally beneath the lib\ODBC directory of your Python installation). -- -- 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 Thu Feb 15 17: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 timo at lightdog.com Mon Feb 26 12: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 djc at object-craft.com.au Tue Feb 13 20: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 victor at chaoszero.com Sat Feb 17 08: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 jepler at inetnebr.com Thu Feb 15 08: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 bsass at freenet.edmonton.ab.ca Tue Feb 27 07: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 dalke at acm.org Fri Feb 16 02: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 adam at deprince.net Tue Feb 20 00: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 hamish_lawson at yahoo.co.uk Wed Feb 14 07: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 fredrik at pythonware.com Sun Feb 18 06: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 SBrunning at trisystems.co.uk Wed Feb 21 04: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 mwh21 at cam.ac.uk Thu Feb 1 16: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 aleaxit at yahoo.com Thu Feb 22 11: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 peter at engcorp.com Mon Feb 5 00:37:08 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 05 Feb 2001 00:37:08 -0500 Subject: Please translate this easy snip of C++ to Python References: <95kcbo$k8s@dispatch.concentric.net> Message-ID: <3A7E3C04.9EB02932@engcorp.com> Fredrik Lundh wrote: > > "Phlip" wrote: > > Ogle this awesome snip of C++: > > > > #define TRACE_(x) cout << #x ": " << x << endl > > > How do I do that, just as easy to call, in Python? > > Or use something like this: > [code snippet snipped] > > Cheers /F If I may humbly offer a small change which even handles something like the original __LINE__ request, I believe: def trace(expr = None): # evaluate expression in callers namespace import sys try: raise None except: frame = sys.exc_info()[2].tb_frame.f_back if expr != None: print expr, ":", eval(expr, frame.f_globals, frame.f_locals) else: print '__LINE__ :', frame.f_lineno x = 10 y = 20 strAnimals = "Lemmings" trace("x + y") trace("strAnimals") trace() ## prints: ## x + y : 30 ## strAnimals : Lemmings ## __LINE__ : 19 From alberik at gmx.de Wed Feb 14 05: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 fredrik at pythonware.com Mon Feb 12 04: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 dcarboni at crs4.it Thu Feb 8 11:38:57 2001 From: dcarboni at crs4.it (Davide Carboni) Date: Thu, 8 Feb 2001 17:38:57 +0100 Subject: problems with PIL Message-ID: <95uemq$7vr$1@pietro.crs4.it> Hi to all, I'm fighting against PIL, I put _imaging20.dll and _imagingTK.dll in DLLs but when I try the piece of code below I get the error, wht's wrong in your opinion ?? Thanx. >>> import Image >>> i=Image.new("PPM",(100,100)) Traceback (most recent call last): File "", line 1, in ? File "c:\bin\python20\extensions\PIL\Image.py", line 848, in new return Image()._makeself(core.fill(mode, size, color)) File "c:\bin\python20\extensions\PIL\Image.py", line 43, in __getattr__ raise ImportError, "The _imaging C module is not installed" ImportError: The _imaging C module is not installed -- _______________________________________________________________________ Davide Carboni Email: davide.carboni at crs4.it Network Distributed Applications Phone: +39 070 2796 303 CRS4, VI Str. Ovest, Z.I. Macchiareddu ICQ # 107447153 I-09010 Uta (CA), ITALY WWW : www.crs4.it/~dcarboni _______________________________________________________________________ From michael at stroeder.com Tue Feb 6 10:44:06 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Tue, 06 Feb 2001 16:44:06 +0100 Subject: cgi.py and HTML 4.0 compliancy References: <95p461$62h$1@nnrp1.deja.com> Message-ID: <3A801BC6.6ED77FEA@stroeder.com> Juergen wrote: > > according to "validator.w3.org" the following URL is not HTML 4 > compliant: > Some > Text Maybe HTML4 mandates to use a form.
> I think the correct form of the above URL would be: > Some > Text > but I am not sure. At least the validator doesn't complain anymore. Well, this is not the same as the URL above. > The problem with this URL is, that the cgi modules FieldStorage class > can't handle this format properly. Yes, off course. You URL-quoted the ampersand ('&') which is necessary to separate the input fields. > As a workaround I modified cgi.parse_qsl by adding a new line: Don't do that. It violates the standard and works only if your parameter values does not contain an ampersand. > I wonder if some Python core developer should take care of this or if > the HTML validator needs to be fixed. Both are ok. IMHO your HTML has to be fixed. Ciao, Michael. From robin.thomas at starmedia.net Tue Feb 27 12: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 glennj at pcard31e.ca.nortel.com Sun Feb 18 12: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 aleaxit at yahoo.com Thu Feb 22 12: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 stephen_purcell at yahoo.com Tue Feb 20 08: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 gillet at scripps.edu Fri Feb 9 20:37:54 2001 From: gillet at scripps.edu (Alexandre Gillet) Date: Fri, 09 Feb 2001 17:37:54 -0800 Subject: problem with numeric array on window. Message-ID: <3A849B72.28AEAA22@scripps.edu> Hi all, We are having problems when creating numeric arrays in C extensions under windows. We narrowed the problem down to a very simple example (shown below) where we simply allocate some memory, create a Numeric array using PyArrayFromDimsAndData. If we call that function as soon as we delete the returned array the python interpreter crashes as it tries to free self->data. If we do not the the OWN_DATA flag in the array it works fine but we have a memory leak. We tried this using both release and Debug versions of Python1.5.2, and Numeric 17.1.1. I have been using this mechanism under Unix for a long time and have not had this problem before ! Using the same extension and test under unix works fine. Has something changed ? Any help is welcome ... Thank you I join the two files we are using. bug.c : a C module that create an array numeric with the flags set to own_data, so when the array is garbage collected, the memory is free. ################# bug.c##################################################### #ifdef WIN32 #include #include #endif #include "Python.h" #include "arrayobject.h" static PyObject* createArray(PyObject* self, PyObject* args) { int *dims; float *data; PyArrayObject *out; dims = (int *)malloc(2 * sizeof(int)); dims[0] = 500; dims[1] = 2; data = (float *)malloc(100000 * sizeof(float)); out = (PyArrayObject *)PyArray_FromDimsAndData(2, dims, PyArray_FLOAT, (char *)data); if (!out) { PyErr_SetString(PyExc_RuntimeError, "Failed to allocate memory for normals"); return NULL; } out->flags |= OWN_DATA; /*so we'll free this memory when this array will be garbage collected */ return (PyObject *)out; } static PyMethodDef bug_methods[] = { {"createArray", createArray, 1}, {NULL, NULL} /* Sentinel */ }; static char bug_documentation[] = "No Doc"; #ifdef WIN32 extern __declspec(dllexport) #endif void initbug() { PyObject *m, *d; m = Py_InitModule4("bug", bug_methods, bug_documentation, (PyObject *)NULL, PYTHON_API_VERSION); d = PyModule_GetDict(m); import_array(); if (PyErr_Occurred()) Py_FatalError("can't initialize module bug"); } ##################################################################### ###############testbug.py############################################ import bug ar = bug.createArray() del ar # fatal if ar owns the data member ##################################################################### -- ********************************** Alexandre Gillet The Scripps Research Institute, tel: (858) 784-9557 Dept. Molecular Biology, MB-5, fax: (858) 784-2860 10550 North Torrey Pines Road, email: gillet at scripps.edu La Jolla, CA 92037-1000, USA. From jpet at eskimo.com Sat Feb 17 01: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 mrq at for.mat.bham.ac.uk Wed Feb 7 09:02:43 2001 From: mrq at for.mat.bham.ac.uk (Martyn Quick) Date: Wed, 7 Feb 2001 14:02:43 +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: I've tried to read the introduction document, but I found it rather confusing, I'm afraid. I'm very new to this game and the use of lowercase and uppercase variants of the same English word to denote almost the same thing caused me problems. It is to avoid the confusion that I introduced aardvark and armadillo as the names for my widgets below. > > (4) Will the following correctly add a menu to my aardvark object? > > short answer: almost. > > > from sys import exit > > armadillo = Menu(aardvark) > > this creates a menu component instance. > > > armadillo.add_cascade(label="File") > > this adds a submenu to the admadillo menubar. but you > didn't pass in the submenu instance, so there's nothing to > display when the user clicks on "File"... > > try this instead: > > filemenu = Menu(armadillo) # create a submenu > armadillo.add_cascade(label="File", menu=filemenu) Hold it - is "filemenu" a user defined name or is it built into Tkinter? Would the following work equally well? dongle = Menu(armadillo) armadillo.add_cascade(label="File", menu=dongle) > > 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. Oh good. (And "Oops!" about the typo.) > if you want to add it to the file menu instead of the armadillo > menubar, try this: > > filemenu.add_command(label="Exit", command=exit) > > finally, you need to attach the menu to your window: > > aardvark.config(menu=armadillo) What *exactly* does config do? The Introduction document (p26) says "We use the config method to attach it to the root window". But I couldn't find anywhere telling me what the config method was. Furthermore in the example on p26 of the document it has the following code: menu = Menu(root) root.config(menu=menu) But what happens if I call the menu bar on my root "aardvark"? Say aardvark = Menu(root) Does the next line contain "menu=aardvark", "aardvark=menu", or "aardvark=aardvark"? > > > If this isn't right - what is right, and more importantly *why* is it > > right? > > http://www.pythonware.com/library/tkinter/introduction/x953-menus.htm Ah yes - this is precisely the printed page that I have in front of me that I'm not really understanding. A related question is the Second Tkinter Program in that document (Hello, Again). The command use to quite is frame.quit . Why is this used instead of sys.exit() ? Am I right in thinking that frame is the user defined name for the Frame, so if I wrote aardvark = Frame(master) I would use command = aardvark.quit Thanks for the previous reply! 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 janne at oops.nnets.fi Tue Feb 20 17: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 jeremy at alum.mit.edu Tue Feb 20 12: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 shaleh at valinux.com Fri Feb 16 11: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 stephen_purcell at yahoo.com Sat Feb 24 05: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 jmarshal at mathworks.com Sat Feb 3 22:37:35 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 4 Feb 2001 03:37:35 GMT Subject: Stringbuffer References: Message-ID: <95iipv$lro$1@news.mathworks.com> chris at onca.catsden.net wrote: > On 4 Feb 2001, Joshua Marshall wrote: >> I'm plucking characters off a stream and concatenating them. >> Currently, I'm doing something like: >> >> buf = [] >> while stream.more(): >> buf = buf + stream.read() >> string.join(buf, '') >> >> Is there a faster way? I'm thinking of writing a Stringbuffer >> class in C. Or does a quick, reliable one already exist? > You could try buf.append(stream.read()) > And... I dont know what you're trying to achive with string.join(buf,''). > Are you just adding a space?? :) I'm using string.join to convert a list of strings into a single string. My use of a list is for efficiency. Intuitively, I'm trying to do: ret = '' while stream.more(): ret = ret + stream.read() but this is too slow. Appending to a list is better, but I'm looking for more speed. From keisari_ at hotmail.com Sat Feb 3 14:00:32 2001 From: keisari_ at hotmail.com (Joonas) Date: Sat, 03 Feb 2001 21:00:32 +0200 Subject: How can I redirect stderr into stdout. Message-ID: <3A7C554F.60D5556D@hotmail.com> How can I redirect stderr to stdout. Joonas From danielsatalandanielsdotcom Sat Feb 10 22:47:12 2001 From: danielsatalandanielsdotcom (Alan Daniels) Date: Sat, 10 Feb 2001 22:47:12 -0500 Subject: Vim and python efficiently References: Message-ID: <3n2c8tsol3b3rbh6uvkqm37tujvpk3d1rp@4ax.com> On Sat, 10 Feb 2001 12:53:12 +0000, Viktor Lakics wrote: >I would like to collect the tips, hints and macros, regarding how to edit >python sorce code in vim. I don't have any macros, but you may find my customized Pyrhon syntax file for VIM to be handy... http://www.alandaniels.com/vim/python.vim ============================== Alan Daniels daniels at alandaniels dot com From zamurai at gmx.net Fri Feb 9 09:38:40 2001 From: zamurai at gmx.net (Zamurai) Date: Fri, 9 Feb 2001 15:38:40 +0100 Subject: What is better, JPython or Jython? References: <981723867.586455890@news.t-online.de> <960ths$40u$1@nyheter.chalmers.se> Message-ID: <981729520.404872677@news.t-online.de> Thank you for Informations! From thomas at xs4all.net Mon Feb 26 03: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 tim.one at home.com Sat Feb 3 03: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 johann at physics.berkeley.edu Fri Feb 23 15: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 robin at jessikat.fsnet.co.uk Sat Feb 17 04: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 erno-news at erno.iki.fi Mon Feb 12 22: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 s2mdalle at titan.vcu.edu Sat Feb 24 15: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 zamurai at gmx.net Mon Feb 19 14: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 max at alcyone.com Mon Feb 19 12: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 db3l at fitlinxx.com Wed Feb 14 15: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 dan at eevolved.com Wed Feb 14 00: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 s2mdalle at titan.vcu.edu Sat Feb 24 16: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 g_will at cyberus.ca Fri Feb 2 01: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 shaleh at valinux.com Sun Feb 18 04: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 dan at eevolved.com Sat Feb 3 20:13:03 2001 From: dan at eevolved.com (Dan Parisien) Date: Sun, 04 Feb 2001 01:13:03 GMT Subject: Function Attribute funkiness... Message-ID: I was reading up on function attributes. Incredible new feature... You can now add member functions to classes and class instances without having to inherit from them. Can be done at runtime! Look what you can do with them ------picklesocket.py------ from cPickle import loads, dumps, UnpickleError def unpickle(maxbytes): data = self.sock.recv(maxbytes) return dumps(data) def pickle(anything): """anything can be a list, dictionary, tuple, string.. you name it """ data = loads(anything) self.sock.send(data) def patchSocket(instance): pickle.sock = unpickle.sock = instance instance.pickle = pickle instance.unpickle = unpickle sock = socket(...) patchSocket(sock) # adds new member methods : pickle and unpickle From bowman at montana.com Sun Feb 18 16: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 dsh8290 at rit.edu Tue Feb 6 14:15:16 2001 From: dsh8290 at rit.edu (D-Man) Date: Tue, 6 Feb 2001 14:15:16 -0500 Subject: do...while loops In-Reply-To: <3A802319.46EBCA35@cybermesa.com>; from joconnor@cybermesa.com on Tue, Feb 06, 2001 at 04:15:21PM +0000 References: <95p75f$85m$1@panix3.panix.com> <3A802319.46EBCA35@cybermesa.com> Message-ID: <20010206141516.A2046@harmony.cs.rit.edu> On Tue, Feb 06, 2001 at 04:15:21PM +0000, Jay O'Connor wrote: | Aahz Maruch wrote: | > | > In article , | > Simon Brunning wrote: | > > From: Langa Kentane [SMTP:LangaK at discoveryhealth.co.za] | > >> | > >> Why is is it while 1: | > >> would while 2: | > >> or while 3: work? | > > | > >Yup - any non-zero number is considered true. They wouldn't do anything | > >different, though, and they just might confuse someone. (Why 2?) | > | > Well, let's split the difference: | > | > while 2.5: Shouldn't that be 1.5 ? ;-) | | | Umm..then how about a counter? Would this work? | | x = 100 | while x: | print x | x -= 1 | | Yeah, just tried it...it works. | | Umm...anyone really like it? :) for x in range( 100 , 0 , -1 ) : print x With for you only have 1 one line that describes the entire loop, instead of 3 lines that are spread about. You also have no chance of forgetting to (de/in)crement the counter when you get to the end of the loop body. -D From un4e at rzstud1.rz.uni-karlsruhe.de Wed Feb 14 04: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 brian.j.geddes at intel.com Mon Feb 26 17: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 fredrik at pythonware.com Sat Feb 17 13: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 baasad at qualitynet.net Fri Feb 2 18:55:00 2001 From: baasad at qualitynet.net (bashar A. Asad) Date: Sat, 03 Feb 2001 02:55:00 +0300 Subject: help with process monitoring using python Message-ID: <95g62e$ne31@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 michael at stroeder.com Wed Feb 7 09:41:25 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Wed, 07 Feb 2001 15:41:25 +0100 Subject: python-crypto list hosted at SURFnet.nl Message-ID: <3A815E95.5399B6C3@stroeder.com> HI! I'm glad to announce that SURFnet in the Netherlands agreed on providing the service to host the mailing list for crypto-related Python development: PYTHON-CRYPTO at NIC.SURFNET.NL The reason for this new mailing list is that the situation regarding export regulations for cryptographic code from the U.S. is still not clear enough. IMHO we can avoid a problems with crypto code posted to the mailing list by hosting in a country known to be very liberal in this field. Please join the list at: http://listserv.surfnet.nl/archives/python-crypto.html Hope to see you there. Citizens of the U.S. or any other country with export regulations for cryptographic software have to take care about themselves for not getting into trouble by posting code to this list. Ciao, Michael. From max at alcyone.com Tue Feb 20 12: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 tuttledon at hotmail.com Thu Feb 22 13: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 glennj at pcard31e.ca.nortel.com Fri Feb 16 17: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 mjackson at wc.eso.mc.xerox.com Thu Feb 8 19:59:29 2001 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 9 Feb 2001 00:59:29 GMT Subject: python-dev summary, Jan. 16-31 References: <3dpugs6cqi.fsf@ute.cnri.reston.va.us> Message-ID: <95vfdh$3k4$1@news.wrc.xerox.com> Andrew Kuchling writes: > "Andrew Dalke" writes: [a whole bunch of stuff to which I add a firm "me, too."] > > about. To contribute to a thread, I would need to catch up > > on the mailing list to see what arguments have been presented, > > then bring up my questions or objections. But it would be > > about two weeks late, which means people may have already > > decided on what to do, and making changes is more likely to > > be frowned upon. > > Two weeks late is a bit annoying, but it's much less annoying than > only finding out about objections when the first alpha ships, months > later! Note that you *can* send messages to python-dev; only > subscription is limited. Hm. That wasn't clear to me either, and I *do* keep the python-dev page bookmarked, and check it out from time to time. Had I ever felt well-informed enough to want to speak up I wouldn't have known I could address python-dev directly. > > So I really place the problem on the main python-dev people > > who don't bother to disseminate their ideas to the broader > > audience of people who develop a lot of Python code but > > aren't language designers. > > Indeed. I'm increasingly worried that python-dev is becoming too > insular, working on things while the community is unaware of what's > coming. Risk: the language moves in the direction of being easier for wizards to write, at the (probable) expense of becoming less easy for nonwizards to read. -- 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 ylee12 at uiuc.edu Wed Feb 21 23: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 fredrik at effbot.org Fri Feb 2 10: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 erno-news at erno.iki.fi Tue Feb 27 06: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 aahz at panix.com Thu Feb 8 14:06:45 2001 From: aahz at panix.com (Aahz Maruch) Date: 8 Feb 2001 11:06:45 -0800 Subject: None assigment References: <95ugd4$jka$1@panix6.panix.com> <95unqf$4j3$1@nnrp1.deja.com> Message-ID: <95uqo5$ek9$1@panix6.panix.com> In article <95unqf$4j3$1 at nnrp1.deja.com>, Mark Pilgrim wrote: > >- Once you've redefined a built-in function like 'dir', is there any >way to get it back without restarting Python? del dir -- --- 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 zzizz_ at notmail.com Sat Feb 17 08: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 cyberian_bear at hotmail.com Sat Feb 17 18: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 gReGlAnDrUm at earthlink.net Wed Feb 14 00: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 thomas.heller at ion-tof.com Fri Feb 2 04: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 MarkH at ActiveState.com Tue Feb 6 22:34:20 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 07 Feb 2001 03:34:20 GMT Subject: Python Users Group Australia References: Message-ID: <3A80C151.3000504@ActiveState.com> Ben Catanzariti wrote: > Hi, > > I am looking for the existence of a Python Users Group in Australia ... does > one exist?? Not as such... But there is a mailing list: http://starship.python.net/mailman/listinfo/python-au Mark. From robin.thomas at starmedia.net Tue Feb 27 11: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 gbell at uclink.berkeley.edu Thu Feb 1 16: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 joconnor at cybermesa.com Sun Feb 11 09:11:37 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Sun, 11 Feb 2001 14:11:37 GMT Subject: C++ style Stream Operators References: <3a831395.0@216.0.152.7> Message-ID: <3a869d32.47459032@news.cybermesa.com> On Thu, 8 Feb 2001 15:41:42 -0600, "Jim" wrote: >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? Well, not C++ style, but I've started working on some Smalltalk-style Streams for Python. First rudimentary example is here: http://pub1.ezboard.com/fobjectorienteddevelopmentprogrammingexamples.showMessage?topicID=41.topic Discussion is here: http://pub1.ezboard.com/fobjectorienteddevelopmentpython.showMessage?topicID=81.topic 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 claird at starbase.neosoft.com Tue Feb 20 19: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 jjlucsy at concentric.net Thu Feb 8 12:55:42 2001 From: jjlucsy at concentric.net (Joel Lucsy) Date: Thu, 8 Feb 2001 12:55:42 -0500 Subject: python-dev summary, Jan. 16-31 References: <3d4ry56vzg.fsf@ute.cnri.reston.va.us> Message-ID: "Konrad Hinsen" wrote in message news:m3ofwdp1u7.fsf at chinon.cnrs-orleans.fr... > Andrew Kuchling writes: > > > To me, this makes it crystal clear that the summaries aren't achieving > > their goal of making the development process more transparent to the > > community. Perhaps giving the PEPs higher visibility -- posting > > The fact that there are people who read neither the PEPs nor the > summaries doesn't prove that the summaries aren't useful. I have > always read them with much interest, since I don't have the time at > the moment to follow the development in detail. And I would have > shouted out loud if I had noticed a tendency that looks dangerous to > me - it just hasn't happened. Same here. -- Joel Lucsy (jjlucsy at concentric.net) From fredrik at pythonware.com Tue Feb 27 15: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 stephen_purcell at yahoo.com Tue Feb 6 12:05:19 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 6 Feb 2001 18:05:19 +0100 Subject: Binary numbers In-Reply-To: <95p7ks$9e6$1@nnrp1.deja.com>; from sampe99@my-deja.com on Tue, Feb 06, 2001 at 04:10:09PM +0000 References: <95p7ks$9e6$1@nnrp1.deja.com> Message-ID: <20010206180519.A23598@freedom.puma-ag.com> sampe99 at my-deja.com wrote: > Does anyone know an easy way to get a list of binary numbers within a > certain range in python? E.g for > n=1 [0],[1] > n=2 [0,0],[0,1],[1,0],[1,1] > n=3 [0,0,0],[0,0,1] a.s.o > > I need this for n<=18... How about: def binary(num): digits = [] power = 0 while 2 ** power <= num: if 2 ** power & num: digits.append(1) else: digits.append(0) power = power + 1 digits.reverse() return digits for n in range(18): print n, '=', binary(n) The output is as follows: 0 = [] 1 = [1] 2 = [1, 0] 3 = [1, 1] 4 = [1, 0, 0] 5 = [1, 0, 1] 6 = [1, 1, 0] The 'reverse' means that the list output has the most significant digits first, which seems to be what you want. -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Available for consulting and training. "Even snakes are afraid of snakes." -- Steven Wright From phd at phd.pp.ru Tue Feb 13 11:50:25 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 13 Feb 2001 19:50:25 +0300 (MSK) Subject: CPAN functionality for python In-Reply-To: <14984.49127.853606.286789@w221.z064000254.bwi-md.dsl.cnc.net> Message-ID: On Tue, 13 Feb 2001, Jeremy Hylton wrote: > I think you skipped my very first suggestion -- to use some simple > data format to support exchange between a Zope-based solution and > other solutions. Ok, so we should create formats and protocols and reference implementations. Zope can be use for one of such reference implementations, but we must have other implementations as well. > OB> Please count current mirrors of CPAN. The figure looks good, > OB> isn't it? This is because there are sites that provide FTP > OB> mirrors. > > The CPAN mirrors provide access to the actual libraries, right? That > is, you can download mumble.pm from any CPAN mirror. I'm not clear on > whether the application being proposed for Python has only the catalog > information or also the actual data. If the latter, then an FTP > mirror doesn't buy you much. But I certainly think of real FTP mirrors, not only catalogs. I hate perl, and avoid it as much as possible. But even for me there is one good thing about perl - and it is exactly CPAN. The process of perl -MCPAN -e "install mod_perl;" is simply the best! Python really need such thing. With all goodies about local/nearest mirror, "make", "make test" and "make install"! PS. When I first ran "perl -MCPAN" it started to configure itself, and it asked lots of questions to find nearest mirror. The first question was "Please select your nearest continent or a list of continetens" :))) Tthanks goodnes, not "a list of nearest planets" or "galaxies" :))) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From aahz at panix.com Thu Feb 15 15: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 loewis at informatik.hu-berlin.de Fri Feb 2 16: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 jeremy at alum.mit.edu Tue Feb 13 10: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 bobhicks.nospam at adelphia.net Thu Feb 15 13: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 danielk at aracnet.com Sun Feb 18 13: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 J.Jonkers at acriter.com Wed Feb 7 03:50:12 2001 From: J.Jonkers at acriter.com (Johan Jonkers) Date: Wed, 07 Feb 2001 09:50:12 +0100 Subject: Tkinter: How to remove stacking order of a widget in grid manager References: <3A80712D.BAF8FC0D@pacific.net.hk> <3A81060A.4ED32F2@pacific.net.hk> Message-ID: <3A810C44.EF8E9280@acriter.com> I tried the grid_forget on a frame with a single button. It did not dissapear. However, if you call the destroy() (or the forget()) method on the button, it did dissapear. Maybe this helps. Johan -- -- Programmers don't die; they just GOSUB with no RETURN -- From fernstrom at geocities.com Thu Feb 1 16: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 marvind at glue.umd.edu Wed Feb 7 13:30:52 2001 From: marvind at glue.umd.edu (Arvind Mani) Date: Wed, 7 Feb 2001 13:30:52 -0500 Subject: embed Tkinter in C Message-ID: <95s3m1$db2$1@hecate.umd.edu> Hi, 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 Thanks, marvind From zamurai at gmx.net Fri Feb 9 08:04:27 2001 From: zamurai at gmx.net (Zamurai) Date: Fri, 9 Feb 2001 14:04:27 +0100 Subject: What is better, JPython or Jython? Message-ID: <981723867.586455890@news.t-online.de> It seems that JPython and Jython are quite similar, but what are the differences between both? And which one is better? From tjreedy at udel.edu Tue Feb 13 15: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 max at alcyone.com Thu Feb 15 21: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 Sun Feb 4 01:01:57 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 4 Feb 2001 01:01:57 -0500 Subject: [NEWBIE] Priority Queue in Python In-Reply-To: <3a7c5ada.67417497@news.gw.total-web.net> Message-ID: [David Boeren, timing priority queues] Some notes: Three of your Python priority queue guys have the extra burden (compared to your Python insert_priority4 and your Java insert_priority) of mucking around with an extra key_index argument. Stick to the same thing throughout. Effort devoted to timing naive algorithms is better spent dreaming up better algorithms. "The usual" naive priority queue in Python uses the std bisect module directly: import bisect bisect.insort(list, item) Then finding the place to insert is an O(log(len(list))) time operation, although doing the actual insert remains O(len(list)) time, but where the latter is at full C speed. While faster then doing a linear search, if your priority queues are going to get large, this is a disastrous approach regardless of language. Note that Python compares tuples lexicographically (strings and lists too), so even if the item is a tuple this works fine provided item[0] is the primary key. If your benchmarks are typical of your expected access pattern (i.e., nothing but inserts -- no lookups), or an approximation to your expected access pattern (perhaps lots of inserts followed by lots of lookups), it would be much faster to do the insert via list.append(item) and do list.sort() later before your first access. Python's list.sort() realizes if a list is "sorted at the start, and then has 'some small amount of' disordered gunk at the end", and in that case does a fast sequence of binary inserts under covers to clean up the gunk. Yet this is still a disaster if priority queues get very large. A much better way to do priority queues if they can get large is via a heap. Then insertion, deletion and lookup never take worse than O(log(n)) time. Finally, note that the std module random has a random.shuffle function. luckily-the-python-libraries-are-much-smaller-than-java's-so-it's- possible-to-learn-all-of-them-in-less-than-a-decade-ly y'rs - tim From r2d2 at mao.acc.umu.se Mon Feb 19 03: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 jayhawks at netsgo.com Fri Feb 23 00: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 rjroy at takingcontrol.com Sun Feb 25 02: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 f8dy at my-deja.com Tue Feb 6 11:33:18 2001 From: f8dy at my-deja.com (Mark Pilgrim) Date: Tue, 06 Feb 2001 16:33:18 GMT Subject: sorting on IP addresses References: <3A7F26CB.BE85C96F@esec.com.au> Message-ID: <95p90e$aot$1@nnrp1.deja.com> In article , Jacob Kaplan-Moss wrote: > In article <3A7F26CB.BE85C96F at esec.com.au>, Sam Wun > wrote: > > 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 A quick-and-dirty timing test reveals that mapping the IP addresses to packed IP addresses (via socket.inet_aton), sorting that list, and mapping the result back to unpacked IP addresses (via socket.inet_ntoa) is about much, much faster than defining a custom sort routine. def packunpack(li): import socket packed = [socket.inet_aton(addr) for addr in li] packed.reverse() packed.sort() li = [socket.inet_ntoa(addr) for addr in packed] def cmplambda(li): def cmp_ipaddress ( ip1, ip2 ): import string parts1 = map(lambda x:int(x), string.split(ip1,'.')) parts2 = map(lambda x:int(x), string.split(ip2,'.')) comparisons = map ( lambda x,y: cmp(x,y), parts1, parts2 ) return reduce ( lambda x,y: x or y, comparisons ) li.sort(cmp_ipaddress) def cmpfor(li): def ip_compare( a, b ): """a and b are valid IP addresses of the form w.x.y.z.""" la = [int(n) for n in a.split(".")] lb = [int(n) for n in b.split(".")] for pair in zip(la, lb): if pair[0] > pair[1]: return -1 elif pair[0] < pair[1]: return 1 return 0 li.sort(ip_compare) def makelist(): import random li = [] for i in range(10000): li.append("%s.%s.%s.%s" % (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))) return li def timedsort(li, funcname): import time func = eval(funcname) startTime = time.time() func(li) endTime = time.time() print funcname.ljust(20), str(endTime - startTime) if __name__ == "__main__": li = makelist() timedsort(li[:], "packunpack") timedsort(li[:], "cmplambda") timedsort(li[:], "cmpfor") ##Output (smaller numbers are better): packunpack 0.230000019073 cmplambda 15.3830000162 cmpfor 9.73399996758 -M -- You're smart; why haven't you learned Python yet? http://diveintopython.org/ Sent via Deja.com http://www.deja.com/ From glenfant at equod.com.nospam Sun Feb 18 11: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 tim.one at home.com Sun Feb 11 23:19:27 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 11 Feb 2001 23:19:27 -0500 Subject: PEP status and python-dev summaries In-Reply-To: Message-ID: [A.M. Kuchling] > ... > IMHO the full text of every PEP should have been posted at least > once in the PEP's lifetime. Like I said, that was the intent, and that's what the Post-History tag in each PEP is there to record. People should have been posting PEPs all along! There are 43 PEPs today, consuming a grand total of about 300Kb, for an average of less than 10 Kb/PEP. We would probably average about 2 PEP posts per week. Anyone worried about 20Kb/week should take up a hobby better suited to their irrationalities . From cg at schlund.de Fri Feb 23 04: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 digitig at cix.co.uk Sat Feb 10 09:50:00 2001 From: digitig at cix.co.uk (Tim Rowe) Date: Sat, 10 Feb 2001 14:50 +0000 (GMT Standard Time) Subject: XML processing in Python -- changing horses in mid-stream Message-ID: I have a Python program that parses a test script written in XML and puts the test results to stdout in XML (with a different DOCTYPE). I also have a Python program that takes the test result XML and processes it for graphical presentation. Here's my challenge. If the second program were given a test script instead of results, I would like it to recognise the different doctype, run the tests and process the results all in one. When my result parser spots a test script I should be able to pass the script to the test program via a pipe, put the results of the test through a new result parser, and copy anything relevant from the new result parser to the old one. But can I stop the old result parser parsing the rest of the test script? I plan to use either expat or pyxie, whichever is easiest. TIA. From boud at rempt.xs4all.nl Wed Feb 21 01: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 cerutti at together.net Thu Feb 8 11:29:58 2001 From: cerutti at together.net (Neil Cerutti) Date: 8 Feb 2001 16:29:58 GMT Subject: Some basic questions about Tkinter (probably v easy for experts!) References: Message-ID: Martyn Quick posted: >On 7 Feb 2001, Neil Cerutti wrote: > >> >As I said in my reply to Fredrik Lundh's answer, I did *try* to >> >read this, but unfortunately I found it rather difficult. It >> >doesn't actually seem to be aimed at beginners who are new to >> >Object Oriented Programming. >> >> Oh! That'll make it difficult to follow. Sorry. Using Tkinter >> isn't a good way to learn OOP. >> >> Luckily, the semantics and syntax of OOP is easy to learn >> in Python, if not the practice. > >I *think* I'm beginning to get the idea of OOP - it just doesn't >come as second nature yet. Thanks very much for your example >below - I have one question about it (apologies!) but I've >managed to make a start on writing the code I want. My own code >isn't very OOP yet - but I've put lots of comments in to remind >me to adjust it when I've got a better idea of what will make >sensible classes, etc. Just remember the syntax. And use Fredrik Lundh's docs to find out what options, methods, and especially programming patterns are in there for the widgets you use. >> Here's a small demo. I'm not going to use "import *" here, to >> hopefully make it a little clearer. You don't need to type in the >> comments. ;-) >> >> [snip example] >> >> # The window won't appear and your other widgets won't function >> # until: >> root.mainloop() > >OK, I followed that example and it was very helpful - *however* >I think I am misunderstanding your final comment here. When I >typed the example into python running in a DOSbox window, the >window & button did appear and did do what they were supposed to >before I used root.mainloop(). This seems contrary to what >you've written above. (Perhaps when I run the thing as a script >I need the mainloop() but less so when it's done at command >prompt??). I'm confused about this issue too, I guess. -- Neil Cerutti From fgeiger at datec.at Sun Feb 4 04: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 nas at arctrix.com Wed Feb 7 17:28:03 2001 From: nas at arctrix.com (Neil Schemenauer) Date: Wed, 7 Feb 2001 14:28:03 -0800 Subject: python abstract syntax trees In-Reply-To: <95s8fc$59g$1@news.mathworks.com>; from jmarshal@mathworks.com on Wed, Feb 07, 2001 at 07:42:36PM +0000 References: <95s8fc$59g$1@news.mathworks.com> Message-ID: <20010207142803.A10885@glacier.fnational.com> On Wed, Feb 07, 2001 at 07:42:36PM +0000, Joshua Marshall wrote: > In ther parser module, expr and suite return concrete syntax trees. > Does anyone know of any quick routines that build more minimal abstract > syntax trees? Look at Tools/compiler Neil From bridgman at wyeth.gsfc.nasa.gov Fri Feb 16 13: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 michael at stroeder.com Sat Feb 17 04: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 ransen_spam_me_not at nemo.it Wed Feb 14 01: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 stephen_purcell at yahoo.com Wed Feb 7 03:56:56 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Wed, 7 Feb 2001 09:56:56 +0100 Subject: How can I change newline code? In-Reply-To: <3A810721.68294483@yahoo.co.jp>; from stksee@yahoo.co.jp on Wed, Feb 07, 2001 at 05:28:17PM +0900 References: <3A810721.68294483@yahoo.co.jp> Message-ID: <20010207095656.A6730@freedom.puma-ag.com> stksee at yahoo.co.jp wrote: > > It seems "\n" is treated as LF. > > Instead, I want to set "\n" as "CRLF" in string object. > What should I do ? '\n' will always be LF. You should use 'os.linesep' to get the right end-of-line character(s) for the machine running your program: >>> import os >>> os.linesep '\012' -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Available for consulting and training. "Even snakes are afraid of snakes." -- Steven Wright From danielk at aracnet.com Mon Feb 26 11: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 dan at eevolved.com Sun Feb 11 15:30:44 2001 From: dan at eevolved.com (Dan Parisien) Date: Sun, 11 Feb 2001 20:30:44 GMT Subject: retry in try:...except: Message-ID: Does something like this exist def getval(self, key) try: return self.__keys[key] except KeyError: self.__keys[key] = None retry #!!!! thanks, Dan From gvwilson at interlog.com Mon Feb 12 11: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 bowman at montana.com Sun Feb 18 17: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 topmind at technologist.com Wed Feb 28 11: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 emile at fenx.com Fri Feb 23 21: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 jurgen.defurne at philips.com Fri Feb 23 01: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 grobe+news at netins.net Wed Feb 28 03: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 burkhard.kayser at freenet.de Thu Feb 1 15: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 gradha at iname.com Thu Feb 22 08: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 tjg at exceptionalminds.com Fri Feb 9 12:45:37 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Fri, 9 Feb 2001 09:45:37 -0800 Subject: time.sleep() and cpu cycles Message-ID: <20010209094537.P17173@trufflehunter.avalongroup.net> Hi, We were having some problems on one of our Linux boxes with inodes being allocated and not deallocated. (kernel 2.2.14). So, wanting to understand this behaviour, I wrote a little python logging script that reads the inode info out of /proc every 10 seconds, and then uses python's logging facilities to write out a log file with what it found. This solution worked wonderfully, and gave us all the information we needed about what was going on on the box just before it would die. We have resolved the problem, but left the logging programme running just for fun. When the box is under load with users logged running things, the python process does not interfere with anything. However, on an unloaded system, the python process is taking 60% of the CPU. Maybe that's the way it should be, but it sure seemed odd to me. I use time.sleep() for my delay loop, and was wondering if there is a better way to put a task to sleep, or if what I'm seeing is normal behaviour. -- 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 21:51 hours ago<< From gerhard.nospam at bigfoot.de Fri Feb 23 18: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 erno-news at erno.iki.fi Wed Feb 21 14: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 bpederson at geocities.com Mon Feb 12 15: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 tim.hochberg at ieee.org Wed Feb 28 13: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 aleaxit at yahoo.com Sat Feb 24 12: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 jafo at tummy.com Tue Feb 27 03:41:16 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Tue, 27 Feb 2001 01:41:16 -0700 Subject: [Distutils] Re: CPAN functionality for python In-Reply-To: ; from bsass@freenet.edmonton.ab.ca on Tue, Feb 27, 2001 at 01:35:56AM -0700 References: <20010226183138.E7531@tummy.com> Message-ID: <20010227014116.V1781@tummy.com> On Tue, Feb 27, 2001 at 01:35:56AM -0700, Bruce Sass wrote: >I suppose one could provide SRPMs only - let everyone else do a >conversion - but that is favoring a specific packaging system and >could easily be misconstrued... which is why I suggested a neutral >format. There is no such thing as a neutral format. If it uses .tar.gz files, then Slackware users will be winging that we swiped theirs. ;-) Sean -- It usually takes more than three weeks to prepare a good impromptu speech. -- Mark Twain Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From rturpin at my-deja.com Thu Feb 8 11:17:53 2001 From: rturpin at my-deja.com (rturpin at my-deja.com) Date: Thu, 08 Feb 2001 16:17:53 GMT Subject: Scope: Simple and explicit better than nested? References: <95q09f$2j1$1@nnrp1.deja.com> Message-ID: <95ugr5$tbc$1@nnrp1.deja.com> In article , scarblac at pino.selwerd.nl wrote: > Having to use builtin.range, builtin.int, builtin.open, > builtin.repr, etc etc completely kills the ease of use > of Python. .. Not at all. There is MUCH more to Python that makes it an easy and great language than a few dozen builtin functions. And if typing a few more characters makes it easier for people corrupted by Pascal to understand what's going on, well .. > And it breaks all existing code. OK, so we leave the local and builtin namespaces, and get rid only of the global namespace. That breaks code only for people who use the "from" statement, and we get rid of that, too. Module names are always explicitly scoped, as they should be anyway. This should still be simple enough for Pascal programmers to understand. I bet I can have a patch tomorrow that eliminates the "from" statement. Despite that, I suspect we are doomed to nested scope. For some reason, people prefer the complexity they learned at their mother's knees to true simplicity. Python seems destined to inherit the sins of the languages we left behind. Feh. Russell Sent via Deja.com http://www.deja.com/ From wware at world.std.com Fri Feb 9 08:56:52 2001 From: wware at world.std.com (Will Ware) Date: Fri, 9 Feb 2001 13:56:52 GMT Subject: A special Python with microthreads? References: <981723410.1058806687@news.t-online.de> Message-ID: Zamurai (zamurai at gmx.net) wrote: > I've heard about a special Python which can use microthreads. > Can anyone tell me, where I can get it and wether the developing > group has a homepage? Try http://www.stackless.com/ There you will find sources and executables for Windows and Linux. -- 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 db3l at fitlinxx.com Tue Feb 13 16: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 dsh8290 at rit.edu Mon Feb 26 14: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 m.faassen at vet.uu.nl Wed Feb 7 09:07:57 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 7 Feb 2001 14:07:57 GMT 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> Message-ID: <95rkru$k1s$1@newshost.accu.uu.nl> June Kim wrote: [me] >> Woah, we were happy in Europe to have about 70 people attending our >> EuroZopeCon a few weeks ago, and you people get 600 people coming to >> see about Stackless Python? What are you doing in Korea that we're > It wasn't merely about SP. It was a Python seminar: ZOPE, wxPython, C/API, > Internet programming, XML, URL, and whole lot more. Yeah, I figured actually, it just sounded funnier to just say SP, as that was what I initially thought -- I shall strive for more accuracy in my next post. :) >> not doing in Europe? :) > We gave out Python Reference Library to the people and had a reception at > the end; it wasn't totally free, though. (but we had sponsorship from several > companies) We were totally free, and did have sponsorship. Anyway, more people couldn't have fitted well in the room that we had, so in retrospect we must've been glad 600 people did not show up. :) [snip] > p.s. the coverage of Python in one of the four major newspapers a few days > b4 the seminar and developers' magazine's competitvely carrying articles about > Python seem to be major factors of our success. We shall attempt to strive for the same effect here, then! Anyway, you people have my respect! Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From sandipan at vsnl.com Mon Feb 12 21: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 MarkH at ActiveState.com Wed Feb 14 17: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 bowman at montana.com Mon Feb 19 00: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 fredrik at pythonware.com Sun Feb 25 18: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 shaleh at valinux.com Mon Feb 19 20: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 matt at mondoinfo.com Mon Feb 19 22: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 SBrunning at trisystems.co.uk Fri Feb 16 12: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 max at alcyone.com Sat Feb 17 22: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 phlip_cpp at my-deja.com Tue Feb 20 10: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 sgriggs at pobox.com Fri Feb 9 11:23:24 2001 From: sgriggs at pobox.com (sgriggs at pobox.com) Date: Fri, 09 Feb 2001 16:23:24 GMT Subject: Python 2.1a2 compile problems References: <95pfsu$ht1$1@nnrp1.deja.com> <3dpugvh6ot.fsf_-_@ute.cnri.reston.va.us> <95q16e$3go$1@nnrp1.deja.com> <95u774$ktc$1@tyfon.itea.ntnu.no> Message-ID: <9615hf$4u2$1@nnrp1.deja.com> I put the patches on sourceforge in python's patch area. Scott Griggs Sent via Deja.com http://www.deja.com/ From fredrik at pythonware.com Tue Feb 20 04: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 phd at phd.pp.ru Wed Feb 14 13: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 junaftnoon at nospamplzyahoo.com Mon Feb 5 15:57:00 2001 From: junaftnoon at nospamplzyahoo.com (June Kim) Date: Tue, 6 Feb 2001 05:57:00 +0900 Subject: 2nd Python Seminar in Seoul Was a Success Message-ID: <95n463$anj$1@news.nuri.net> Hello Python users all over the world, We are happy to tell you that the 2nd Python Seminar in Seoul, South Korea on Feb. 2 was a great success. We had more than 600 people on the day, and a few had to go back home in the morning because we didn't have enough seats for them. It was such a boom. A few reporters came to cover the seminar and interviewed the people. There'll be several articles about the seminar in some magazines next month. We expect our next seminar will be much larger than this and want to participate in the international community. Thank you for keeping up and improving Python, and without you guys Korea Python Users Group and its seminar couldn't have been this successful. From KatMouse at gmx.de Wed Feb 21 15: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 cjc26 at nospam.cornell.edu Mon Feb 5 20:34:47 2001 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Tue, 06 Feb 2001 01:34:47 GMT Subject: While everyone is saying what they want in Python :) References: <3A7D64D8.74E71826@cybermesa.com> <3A7D9C1D.781F8E5@alcyone.com> <3A7DB154.87E04245@cybermesa.com> <3A7DB923.AD330F7E@cybermesa.com> Message-ID: * Jay O'Connor menulis: | Jay O'Connor wrote: | | Actually, it's not *that* big a deal. There seemed to be a lot of | traffic about what people like or dislike about 2.x, so I thought I'd | throw out an idea of something I liked about Smalltalk that I hadn't | seen in other languages. | | I can live without it :) (do I have a choice?) You could try writing a PEP for it. I would mention the Tkinter example in it, that gives it a slight chance of being considered at least, since the inconvenience of using Tkinter was the impetus for adding a previous change to the language (namely, keyword arguments). -- Cliff Crawford http://www.people.cornell.edu/pages/cjc26/ print "Just another Python hacker" From mkx at excite.com Sun Feb 25 04: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 sheila at spamcop.net Thu Feb 1 00: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 mrq at for.mat.bham.ac.uk Thu Feb 8 05:28:23 2001 From: mrq at for.mat.bham.ac.uk (Martyn Quick) Date: Thu, 8 Feb 2001 10:28:23 +0000 Subject: Some basic questions about Tkinter (probably v easy for experts!) In-Reply-To: References: Message-ID: On 7 Feb 2001, Neil Cerutti wrote: > >As I said in my reply to Fredrik Lundh's answer, I did *try* to > >read this, but unfortunately I found it rather difficult. It > >doesn't actually seem to be aimed at beginners who are new to > >Object Oriented Programming. > > Oh! That'll make it difficult to follow. Sorry. Using Tkinter > isn't a good way to learn OOP. > > Luckily, the semantics and syntax of OOP is easy to learn > in Python, if not the practice. I *think* I'm beginning to get the idea of OOP - it just doesn't come as second nature yet. Thanks very much for your example below - I have one question about it (apologies!) but I've managed to make a start on writing the code I want. My own code isn't very OOP yet - but I've put lots of comments in to remind me to adjust it when I've got a better idea of what will make sensible classes, etc. > Here's a small demo. I'm not going to use "import *" here, to > hopefully make it a little clearer. You don't need to type in the > comments. ;-) > > [snip example] > > # The window won't appear and your other widgets won't function > # until: > root.mainloop() OK, I followed that example and it was very helpful - *however* I think I am misunderstanding your final comment here. When I typed the example into python running in a DOSbox window, the window & button did appear and did do what they were supposed to before I used root.mainloop(). This seems contrary to what you've written above. (Perhaps when I run the thing as a script I need the mainloop() but less so when it's done at command prompt??). Once more, thank you very much for your answer Neil, I found it extremely helpful. 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 qrczak at knm.org.pl Thu Feb 22 11: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 stephen_purcell at yahoo.com Wed Feb 14 06: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 chris.gonnerman at usa.net Thu Feb 22 08: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 owen at astrono.junkwashington.emu Tue Feb 27 11: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 phlip_cpp at my-deja.com Fri Feb 16 19: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 bk at xk7.com Wed Feb 14 06: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 moshez at zadka.site.co.il Thu Feb 1 19: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 tim.one at home.com Thu Feb 22 23: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 rc-bashar at gmx.net Tue Feb 20 13: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 chris.gonnerman at usa.net Mon Feb 5 23:10:34 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Mon, 5 Feb 2001 22:10:34 -0600 Subject: SIP References: <95moca+k29p@eGroups.com> Message-ID: <00ba01c08ff2$c9b34300$a100000a@local> ----- Original Message ----- From: Subject: Re: SIP > Sorry - documentation is the weakest aspect of SIP. The best approach > is to use PyQt as a working example. Feel free to ask SIP questions on > the PyQt/PyKDE mailing list. Except I know squat about QT, and as I am a GNOME user I have little interest. What I am wanting to do is connect the Xbase library to Python. Xbase is a dBase compatible C++ library. I am probably not qualified to do this anyway. I have many thousands of lines of C in my history but zero C++. From akuchlin at mems-exchange.org Thu Feb 8 17:17:41 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 08 Feb 2001 17:17:41 -0500 Subject: python-dev summary, Jan. 16-31 References: <3d4ry56vzg.fsf@ute.cnri.reston.va.us> <95v2lq$hjl$1@slb7.atl.mindspring.net> Message-ID: <3dpugs6cqi.fsf@ute.cnri.reston.va.us> "Andrew Dalke" writes: > The first mention on c.l.py on function attributes was from Jan. 24 > http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=719772745&fmt=text > even though, yes, the PEP was created on Dec. 2. I meant python-dev discussion here; clearly the PEPs aren't visible enough in c.l.p. > about. To contribute to a thread, I would need to catch up > on the mailing list to see what arguments have been presented, > then bring up my questions or objections. But it would be > about two weeks late, which means people may have already > decided on what to do, and making changes is more likely to > be frowned upon. Two weeks late is a bit annoying, but it's much less annoying than only finding out about objections when the first alpha ships, months later! Note that you *can* send messages to python-dev; only subscription is limited. > So I really place the problem on the main python-dev people > who don't bother to disseminate their ideas to the broader > audience of people who develop a lot of Python code but > aren't language designers. Indeed. I'm increasingly worried that python-dev is becoming too insular, working on things while the community is unaware of what's coming. The fixes for this seem to be: * Announce PEP drafts and status changes to c.l.py.announce * Write a set of introductory pages for Python development (this has been brought up before). * A read-only alias for python-dev would be useful for several people, but may require serious Mailman hackery (I don't know). Any other suggestions? --amk From slhath at home.com Sun Feb 18 09: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 chris.gonnerman at usa.net Sun Feb 18 22: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 marc.vollmer at mahr.de Wed Feb 28 02: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 hzhu at users.sourceforge.net Mon Feb 19 22: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 ben.hutchings at roundpoint.com Thu Feb 22 21: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 stephen_purcell at yahoo.com Sat Feb 17 06: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 marco at atmosp.physics.utoronto.ca Fri Feb 16 00: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 costas at meezon.com Tue Feb 20 22: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 scarblac at pino.selwerd.nl Wed Feb 21 12: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 sampe99 at my-deja.com Wed Feb 7 11:47:28 2001 From: sampe99 at my-deja.com (sampe99 at my-deja.com) Date: Wed, 07 Feb 2001 16:47:28 GMT Subject: Binary numbers References: <95p7ks$9e6$1@nnrp1.deja.com> Message-ID: <95ru6u$lfg$1@nnrp1.deja.com> In article , Kenneth Loafman wrote: > This is my second post on this subject. Mail to this user bounces. > Could be a troll, but since I'd already answered, here's what I said > (important to conserve electrons, don't you know)... > > sampe99 at my-deja.com wrote: > > > > Does anyone know an easy way to get a list of binary numbers within a > > certain range in python? E.g for > > n=1 [0],[1] > > n=2 [0,0],[0,1],[1,0],[1,1] > > n=3 [0,0,0],[0,0,1] a.s.o > > > > I need this for n<=18... > > With n=18, you're asking for > [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], > [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], > [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1], > ... > [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] > > n=18 would be a huge list of lists, (2^18) * 18 in size. > > Assuming 4-byte integers, that would be (262144 * 18 * 4) = 18,874,368 > which is 18MB in data alone. Throw in the python list overhead and it > would probably occupy 25-30MB. Of course, printing it out would be > impractical (useless?). > > Any practical use for such a list? > > ...Ken > > First, thanks to you all that presented excellent solutions to my problem. And to Ken. The basic problem is to make a transition probability matrix (over one year) apply to a smaller time frame (like a week). To do this I take the n:th root of the matrix which produces n different solutions for each eigenvalue. I found python returns only one answer to x**(1/n) and I therefor need to try all possible combinations of positive and negative eigenvalues to find the correct solution. It would also be preferred to try the complex roots too... Do you have a better solution to this main problem I would be happy :) Thanks again, Sam Sent via Deja.com http://www.deja.com/ From cfelling at iae.nl Thu Feb 15 19: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 andrew at andrewcooke.free-online.co.uk Wed Feb 14 09: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 mmueller at dgfz.de Fri Feb 2 02: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 chris.gonnerman at usa.net Thu Feb 1 23: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 not.this at seebelow.org Thu Feb 15 23: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 robin at jessikat.fsnet.co.uk Wed Feb 28 05: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 francois.granger at free.fr Sun Feb 25 17: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 macky at edsamail.com Tue Feb 20 04: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 erno-news at erno.iki.fi Tue Feb 6 11:32:32 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 06 Feb 2001 18:32:32 +0200 Subject: cgi.py and HTML 4.0 compliancy References: <95p461$62h$1@nnrp1.deja.com> Message-ID: In article <95p461$62h$1 at nnrp1.deja.com>, Juergen writes: | Hello, | I am using PYTHON 2.0 and had a slight problem with the cgi module in | combination with HTML 4.0 compliant HTML code. | according to "validator.w3.org" the following URL is not HTML 4 | compliant: | Some | Text correct form: Some Text -- erno From thomas.heller at ion-tof.com Thu Feb 15 08: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 jeremy at alum.mit.edu Mon Feb 26 21: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 aleaxit at yahoo.com Wed Feb 7 12:08:58 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 7 Feb 2001 18:08:58 +0100 Subject: ScriptControl+Python+win32all+Procedures -- known bug? Message-ID: <95rvfg0b3j@news1.newsguy.com> I'm trying to load Python as ActiveScripting compliant language into an application that uses Microsoft ScriptControl, but there seems to be a bug with (whatever is it in IActiveScript that ScriptControl uses to implement its Procedures collection...) -- or is the application perhaps doing something wrong? I did manage to reproduce the problem on a toy-scale with a tiny application that does nothing but: 1 -- instantiate a ScriptControl 2 -- set its Language property 3 -- AddCode to it a script textfile's contents 4 -- get its Procedures collection 5 -- get the Count property of said collection 6 -- get the _NewEnum property of said collection 7 -- enumerate on said _NewEnum and it all works fine if Language is 'VBScript' (and the textfile a correct foo.vbs script); however, with the same application code, if Language is 'Python' (and the textfile a correct foo.py script), steps 5 and 6 each fail (and thus 7 is not even tried) with an HRESULT of 0x8002000b (meaning "Invalid index"). VC++6 code for steps 1-5 can be summarized as: #import "msscript.ocx" ... MSScriptControl::IScriptControlPtr pScr("MSScriptControl.ScriptControl"); pScr->Language = "Python"; pScr->AddCode("def foo():\n pass\n"); MSScriptControl::IScriptProcedureCollectionPtr pProcedures; pProcedures = pScr->Procedures; /* so far so good, but...: */ printf("Number of procedures is %d\n", pProcedures->GetCount()); /* this last line raises a _com_error C++ exception, as above detailed, and so does most any other attempt at doing anything with pProcedures. */ Is this a known bug of build 135 of ActivePython? I cannot find it on the ActiveState site (and thus have submitted it there, hoping it's not a duplicate!). Any help/advice/workaround would be welcome, anyway! Alex From bryan at eevolved.com Mon Feb 19 21: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 bobhicks at adelphia.net Tue Feb 27 16: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 crmartin at indra.com Thu Feb 15 20: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 phrxy at csv.warwick.ac.uk Sun Feb 11 18:23:24 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Sun, 11 Feb 2001 23:23:24 +0000 Subject: Is Python for me? In-Reply-To: <965fhd02uv1@news2.newsguy.com> References: <20010210175216.26827.00000474@ng-mh1.aol.com> <965fhd02uv1@news2.newsguy.com> Message-ID: On Sun, 11 Feb 2001, Alex Martelli wrote: [...about Haskell...] > elegant encapsulation of monads) and the English books about it > are nothing short of superb. [...] Which ones? Or just all of them? John From arildh at stud.cs.uit.no Mon Feb 5 08:00:02 2001 From: arildh at stud.cs.uit.no (Arild Hansen) Date: Mon, 5 Feb 2001 14:00:02 +0100 Subject: IPv6 patch for python 2.0 anyuone? In-Reply-To: References: Message-ID: Thx a lot !! I really wanted that patch, A. Hansen On 5 Feb 2001, Erno Kuusela wrote: > In article > , > Arild Hansen writes: > > | Does anyone know if an IPv6 patch has been released for python 2.0 yet? > > looks like there is one at func=detailpatch&patch_id=101196&group_id=5470>. > > -- erno > From joconnor at cybermesa.com Tue Feb 27 13: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 phd at phd.pp.ru Fri Feb 9 11:04:55 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 9 Feb 2001 19:04:55 +0300 (MSK) Subject: Executing Sytem Commands In-Reply-To: <3A84118D.180E1CDC@usa.net> Message-ID: On Fri, 9 Feb 2001 mix77 at usa.net wrote: > How do you execute a sytem command like "mv file1 file2" in Python? Exactly like system. It is in module "os". So well: import os os.system("xsetbg foo.jpg") 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 7 05:16:41 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: Wed, 07 Feb 2001 10:16:41 GMT Subject: perl regex to python References: <95qodk$mh9$1@nnrp1.deja.com> Message-ID: <95r7a6$21q$1@nnrp1.deja.com> nlymbo at my-deja.com wrote: > Hi all, in perl i would do this to pick apart a date string: > > if ($date_str =~ m#(\d+)/(\d+)/(\d+)#) { > print "month: $1, $day: $2, $year: $3\n"; > } > > How does one save the matches in a reg expression using Python?? Python's re module provides the functionality of Perl's regular expressions. The main difference is that Python doesn't have special syntax and variables for dealing with REs (m//, $1, etc.), preferring to do it via functions, methods and objects. The re module provides a search function which returns a match object if the search was successful or None if not. The group() method of the match object returns the specified matched group. (When specifying REs it's often a good idea to use the r"" raw-string notation to prevent expansion of backslashed characters by Python itself.) import re date_str = "Today is 02/07/2001" m = re.search(r"(\d+)/(\d+)/(\d+)", date_str) if m: print "month: %s, day: %s, year: %s" % \ (m.group(1), m.group(2), m.group(3)) Since the groups in your example are being printed out in order, you could use the groups() method instead to return a tuple of the matched groups: print "month: %s, day: %s, year: %s" % m.groups() If you were going to be matching dates in a number of candidate strings, then you would probably want to compile the regular expression into a matcher object first and then repeatedly call the matcher object's own search() method: matcher = re.compile(r"(\d+)/(\d+)/(\d+)") m = matcher.search(date_str) This is similar to Perl's 'o' modifier for m//, but demonstrates Python's preference of having an explicit object to represent the compiled RE. Hamish Lawson Sent via Deja.com http://www.deja.com/ From tim.one at home.com Mon Feb 26 19: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 scarblac at pino.selwerd.nl Mon Feb 12 03: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 mbel44 at dial.pipex.net Mon Feb 5 09: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 fredrik at pythonware.com Wed Feb 14 10: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 ljohnson at resgen.com Wed Feb 14 09: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 max at alcyone.com Tue Feb 13 02: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 ccosse at psl.nmsu.edu Thu Feb 1 14: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 clickron at webtv.net Sat Feb 10 11:56:18 2001 From: clickron at webtv.net (clickron at webtv.net) Date: Sat, 10 Feb 2001 11:56:18 -0500 (EST) Subject: def problem Message-ID: <10844-3A8572B2-38@storefull-161.iap.bryant.webtv.net> I write this, save it. and run it. def hello(): print "hello" print "bye bye" hello() and I get this message hello Traceback innermost last): File "",line 1, in ? hello NameError: There is no variable named 'hello' What am I doing wrong? Ron From landauer at apple.com Wed Feb 28 16: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 phd at phd.pp.ru Mon Feb 26 11: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 NoSpam at NoSpam.com Sun Feb 11 00:33:47 2001 From: NoSpam at NoSpam.com (Tom) Date: Sun, 11 Feb 2001 05:33:47 GMT Subject: python-dev summary, Jan. 16-31 References: <3d4ry56vzg.fsf@ute.cnri.reston.va.us> Message-ID: <%uph6.125320$V22.25862028@news4.rdc1.on.home.com> I read and appreciate all your 'python-dev summaries'. I find them interesting and informative, but more importantly, they make Python 'feel' more open and inclusive. Tom. "Andrew Kuchling" wrote in message news:3d4ry56vzg.fsf at ute.cnri.reston.va.us... > Python-dev summary, January 16-31, 2001 > ======================================= > > To comment on material in this python-dev summary, you can simply post > to comp.lang.python / . These summaries are > archived at . > > This two week period saw the release of the first alpha of Python 2.1, > and the second alpha was released a few days into February. There's a > lot of bugfixing going on, much of which isn't of interest here, but > there were a few general discussions worth noting. > > > 2.1alpha1 > ========= > > The first alpha of Python 2.1 was released on January 22, and is the > debut of Python 2.1. It didn't compile cleanly on Cygwin, and the new > autodetecting build system needs some more work to support more > platforms correctly, but no major problems or brown paper bag bugs > showed up. > > 2.1alpha2 was subsequently released on February 2, slightly out of the > bounds of this summary. 2.1a2 incorporated the nested scopes from PEP > 227 and the weak reference type from PEP 205. > > A draft of "What's New in Python 2.1" is available, and will be continuously > updated until 2.1final is shipped: > http://www.amk.ca/python/2.1/ > > > unistr() > ======== > > M.-A. Lemburg checked in a unistr() built-in, but later backed out the > change after subsequent discussion. str() takes any Python object and > converts it to a string, and unistr() would take any object and return > a Unicode string. ?!ng wondered why the existing unicode() built-in > shouldn't do this -- currently it only accepts a string and an optional > encoding -- or should this functionality be added to str()? > > This also raised the question of how a type could return a Unicode > representation of itself. Should the tp_str slot in the Py_TypeObject > struct be permitted to return either an 8-bit or a Unicode string, or > should a tp_unicode slot be added? Some discussion followed, but no > clear answer was apparent, so unistr() was removed. This issue will > probably have to wait for a PEP to be written, which means that it'll > have to wait until 2.2. > > > Sets > ==== > > Eric S. Raymond posted the docs for a set module he's written with an > eye toward getting it into the standard library. "The \module{set} > module defines functions for treating lists and other sequences as > mathematical sets, and defines a set class that uses these operations > natively and overloads Python's standard operator set." > http://mail.python.org/pipermail/python-dev/2001-January/012005.html > > But there's already a PEP for a set type, #218 by Greg Wilson: > http://python.sourceforge.net/peps/pep-0218.html > > Reconciling the two proposals doesn't seem difficult, but opinion was > divided: are sets so commonly used that they should be in the standard > library, particularly if dictionaries can be used to implement many > common set operations? > > ?!ng pointed out that simply allowing "if key in dict" would make > using dictionaries as sets a bit more natural. /F agreed, and GvR > added "You know, I've long resisted this, but I agree now -- this is > the right thing." Thomas Wouters submitted a patch, but it hasn't yet > been checked in. > > A subthread wondered about the related question of 'for X in > dictionary:' Should this do anything, and if so, what? X could be > "key" or "key, value", but the best choice isn't obvious. Another > subthread drifted into the question of the Batteries Included > distribution proposed by Moshe Zadka in PEP 206, and yet another one > proposed dictionaries that can be marked as unmodified ("frozen" or > "locked"). No clear conclusions were made, and the problems seem > messy enough that a PEP will be required, so this is another thing > likely to be postponed until 2.2. > > > Envoi > ===== > > This will be the last python-dev summary I write, accounting for its > rushed and sketchy quality. > > The goal of these summaries has been to make the discussions on > python-dev more visible to the community, letting people offer timely > comments while a thread is still reasonably current and fresh in > memory. Unfortunately that doesn't seem to happen, and no messages to > python-dev are spurred by them. Ideally people would come forward to > say "The last summary mentioned you were talking about X. I use X a > lot, and here's what I think: ...", but that isn't happening. > > The release of 2.1 offers a second calibration on their effectiveness. > 2.1 is the first Python release to have been carried out using PEPs as > the mechanism, so there are no sizable changes in 2.1 that don't have > a corresponding PEP. Yet many people were *surprised* by some of the > changes in Python 2.1 such as function attributes and nested scopes, > even though PEPs were written and discussed, often in lengthy threads > months ago. > > To me, this makes it crystal clear that the summaries aren't achieving > their goal of making the development process more transparent to the > community. Perhaps giving the PEPs higher visibility -- posting > announcements of status changes and new PEPs to > comp.lang.python.announce, for example -- would do a better job, and > it would definitely require less effort. In any case, I feel there's > no point in continuing to write them. > > (Should anyone want to volunteer to continue writing them, please do > so; contact me if you want copies of the previous summaries for a > complete archive.) > > My thanks to the various people who've offered comments and > encouragement along the way; you've all kept me going over the last 7 > months... > > > Related Links > ============= > > Python-dev archives: > http://www.python.org/pipermail/python-dev/ > > Python project page on SourceForge: > http://sourceforge.net/projects/python > > Python Enhancement Proposals (PEPs): > http://python.sourceforge.net/peps/ > > What's New in Python 2.1 > http://www.amk.ca/python/2.1/ > From bsass at freenet.edmonton.ab.ca Mon Feb 26 03: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 tim.one at home.com Sun Feb 4 17:45:50 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 4 Feb 2001 17:45:50 -0500 Subject: new command for getting traceback? In-Reply-To: Message-ID: [Pete Shinners] > one trick in python i've always thought was bizarre was getting > the current stack trace by raising a false exception. > > import sys > try: > raise None > except: > return sys.exc_info()[2].tb_frame > > obviously grabbing the current stack is usually a sign of some > sort of "magic ahead", this is one of those things that is a > bit obscure. even harder from inside my C extension modules. It > would make things a bit nicer and more understandable if there > was some sort of traceback() builtin. (accessable from C too!) The details of frame manipulation are internal, and not guaranteed to work the same way across releases. So it's *good* that deep magic looks like deep magic -- you're playing with fire. Nevertheless, Python 2.1a2 (#10, Feb 3 2001, 22:01:45) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> import sys >>> print sys._getframe.__doc__ _getframe([depth]) -> frameobject Return a frame object from the call stack. If optional integer depth is given, return the frame object that many calls below the top of the stack. If that is deeper than the call stack, ValueError is raised. The default for depth is zero, returning the frame at the top of the call stack. This function should be used for internal and specialized purposes only. >>> That's new for 2.1, and can replace current uses of the try/except trick, if you're willing to live with that frame interals are subject to change without notice. Note that there have long been traceback-manipulating functions in the std traceback module, if you want to work at a more abstract (and safer) level. If you want more than that, you'll have to talk someone into submitting a patch and making a case for it. From chrisw at nipltd.com Wed Feb 21 11: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 tim.one at home.com Fri Feb 16 23: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 ajung-ml at andreas-jung.com Mon Feb 26 08: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 junaftnoon at nospamplzyahoo.com Wed Feb 7 13:24:38 2001 From: junaftnoon at nospamplzyahoo.com (June Kim) Date: Thu, 8 Feb 2001 03:24:38 +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> Message-ID: <95s40f$pui$1@news.nuri.net> "John Grayson" wrote in message news:95rgng$8ul$1 at nnrp1.deja.com... > In article <95q8tj$1c8$1 at news.nuri.net>, > "June Kim" wrote: > > > > > > > > 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. > Yes, we now have Learning Python in Korean published on the seminar day Feb. 2. and Python and Tkinter Programming a few weeks ago. (I'm sure there are some more translations and some original works in Korean as well.) > This is great news for Python -- my only fear is that the frequent > Monty Python quips in the book translate to something offensive > in Korean... I reckon the people who are reading the translated version of the quips would think them rather pedantic and esoteric than offensive; or very valueable and profound about programming than laughable and comedic. Nonetheless, it wouldn't hurt anyone's heart at least -- it would hurt some of the reader's brains; they would struggle to interpret it. Best regards, June Kim ps. I have a copy of your book in English and I like it pretty much. thank you John for this great book. From mwh21 at cam.ac.uk Wed Feb 21 14: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 aleaxit at yahoo.com Mon Feb 5 08:14:52 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 5 Feb 2001 14:14:52 +0100 Subject: Win Development References: Message-ID: <95m90f01do3@news1.newsguy.com> "Michael Jonas" wrote in message news:mailman.981305180.32424.python-list at python.org... [snip] > I've allready seen that VC debugger (and the look at Python's source) is one > of my best friends and I want to make it find everything as required. ( I > used vi the last years...) So maybe there are some additional benefits using I see Hammond already gave precious advice, and just want to add two cents -- VIM (at www.vim.org) is just great (on Windows as well as on Unixy platforms) if you like VI, and, among many other abilities, it can hook itself up as the editor to use within Visual Studio *AND* it can be built to use Python as its editor scripting language. Try it, you'll love it (the gui-enabled version, GVIM, is what you'll need to use for Visual Studio integration -- but you also get a console based version, VIM, for those occasional editing needs right from a console commandline...). Alex From stephen_purcell at yahoo.com Tue Feb 20 02: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 arildh at stud.cs.uit.no Sun Feb 4 07:15:45 2001 From: arildh at stud.cs.uit.no (Arild Hansen) Date: Sun, 4 Feb 2001 13:15:45 +0100 Subject: IPv6 patch for python 2.0 anyuone? Message-ID: Does anyone know if an IPv6 patch has been released for python 2.0 yet? A. Hansen From bsass at freenet.edmonton.ab.ca Tue Feb 27 18:10:32 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Tue, 27 Feb 2001 16:10:32 -0700 (MST) Subject: CPAN functionality for python - requirements In-Reply-To: <20010227132028.L1781@tummy.com> Message-ID: On Tue, 27 Feb 2001, Sean Reifschneider wrote: > On Tue, Feb 27, 2001 at 02:49:40AM -0700, Bruce Sass wrote: > >Even if the RPM was made by someone who didn't have a clue? > > Yes, because it's easier to remove an RPM from somone who doesn't have a > clue than a .tar file from somone who doesn't have a clue. I'm a little more careful. I only install DEBs from Debian or a trusted packager (usually unofficial pkgs from a Debian developer), third party DEBs and tarballs get manually unpacked and inspected. Installing a third-party DEB or RPM is worse than doing "cd / ; tar xzf..." with that tarball you found at mess-with-your-system.com - at least the tarball is not going to run scripts as root on you system! > >Wouldn't it be better to have a standard way to convert a Python > >package into an RPM, that way any packaging problems will be seen by > >everyone and the fix will be fast. > > The thing about automated systems is that they often fail in particularly > spetacular ways. If that happens an human intervention is required, then > the archive network should be able to handle it, without requiring that > distutils be fixed, then handed off to the author of the package to make > a new release from. That sounds much better than the alternatives to me; everything is likely to fail at some point, when it comes to the dull task of packaging software... I'll go with the well defined automated process 'cause it doesn't get tired and make mistakes. The archive network is not going to fix anything, it may dump packages that are getting complaints, but that should - must - require human intervention. > >Huh, there are tools and standards. > >Isn't /usr/shar/doc/package the FHS place for general package specific > > Where are the tools for turning doc-strings into HTML, and how are the > links between doc packages handled? What is the markup format for the > doc strings? > > We spent quite a while discussing the sad state of the documentation at our > last pythoneers meeting. Mark Lutz was shocked that people would actually > use javadoc, but they do seem to simply becuase it was available and was > "good enough". > > We are missing similar functionality. Oh, ok. I though the reference was to READMEs, .html files, etc. Doc strings are a great replacement for bunches of "rem" statements, but as program documentation... I don't want my programs cluttered up with user level documentation. Literate programming is interesting. - Bruce From zessin at decus.de Sun Feb 18 11: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 thomas at xs4all.net Sun Feb 4 18: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 tim.one at home.com Tue Feb 27 13: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 robin.thomas at starmedia.net Wed Feb 28 22:58:27 2001 From: robin.thomas at starmedia.net (Robin Thomas) Date: Wed, 28 Feb 2001 22:58:27 -0500 Subject: d = {}; d[0:1] = 1; d[0:1] = 2; print d[:] Message-ID: <4.3.1.2.20010228223714.00d29430@exchange.starmedia.net> Using Python 2.0 on Win32. Am I the only person to be depressed by the following behavior now that __getitem__ does the work of __getslice__? Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32 >>> d = {} >>> d[0:1] = 1 >>> d {slice(0, 1, None): 1} And then, for more depression: >>> d[0:1] = 2 >>> d {slice(0, 1, None): 1, slice(0, 1, None): 2} And then, for extra extra chagrin: >>> print d[0:1] Traceback (innermost last): File "", line 1, in ? d[0:1] KeyError: slice(0, 1, None) So, questions: 1) Is this behavior considered a bug by the BDFL or the community at large? If so, has a fix been conceived? Am I re-opening a long-resolved issue? 2) If we're still open to proposed solutions, which of the following do you like: a) make slices hash and cmp as their 3-tuple (start,stop,step), so that if I accidentally set a slice object as a key, I can at least re-set it or get it or del it :) b) have dict.__setitem__ expressly reject objects of SliceType as keys, raising your favorite in (TypeError, ValueError) -- Robin Thomas Engineering StarMedia Network, Inc. robin.thomas at starmedia.net From aleaxit at yahoo.com Fri Feb 23 06: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 ryu-jin at bigfoot.com Sat Feb 10 06:33:16 2001 From: ryu-jin at bigfoot.com (Ryujin) Date: Sat, 10 Feb 2001 11:33:16 GMT Subject: XML Parser problem Message-ID: <96395l$4e2$1@ryu.it> I'm tryng to run some example from the Demos in the Python2.0 distro. When I try to run the xml parser example I get the following error: bash-2.03$ python2.0 roundtrip.py /home/matte/PROGRAMMING/WORK/doc.xml Traceback (most recent call last): File "roundtrip.py", line 43, in ? parser = make_parser() File "/usr/local/lib/python2.0/xml/sax/__init__.py", line 88, in make_parser raise SAXReaderNotAvailable("No parsers found", None) xml.sax._exceptions.SAXReaderNotAvailable: No parsers found And here is the content of the xml/sax directory in /usr/lib/python2.0: bash-2.03$ ls /usr/local/lib/python2.0/xml/sax/ __init__.py _exceptions.py expatreader.py handler.py saxutils.py xmlreader.py __init__.pyc _exceptions.pyc expatreader.pyc handler.pyc saxutils.pyc xmlreader.pyc __init__.pyo _exceptions.pyo expatreader.pyo handler.pyo saxutils.pyo xmlreader.pyo Any suggestion? What am I missing? thx in advance matte -- --------------------------------------- Memelli Matteo Could u imagine a world without Windoz? ryu-jin at bigfoot.com --------------------------------------- From moshez at zadka.site.co.il Tue Feb 6 06:01:08 2001 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Tue, 6 Feb 2001 13:01:08 +0200 (IST) Subject: Is comp.lang.python.announce dead? In-Reply-To: <90an59.4hk.ln@127.0.0.1> References: <90an59.4hk.ln@127.0.0.1> Message-ID: <20010206110108.88F2BA840@darjeeling.zadka.site.co.il> On Mon, 5 Feb 2001 23:38:01 +0100, gradha at iname.com wrote: > Hi. > > Just today I fetched the news and got around 10 "announce" messages, in > this newsgroup instead of comp.lang.python.announce. Does this mean that > the latter is officially dead? Hardly. c.l.p.a is very much alive and being used. Perhaps less often then it should be. Consider this a call to announce stuff on c.l.p.a -- we have a 24/7 team of moderators around the world, ready to approve postings. -- 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 s713221 at student.gu.edu.au Mon Feb 12 03:38:04 2001 From: s713221 at student.gu.edu.au (s713221 at student.gu.edu.au) Date: Mon, 12 Feb 2001 18:38:04 +1000 Subject: Graph (cyclic kind, not pretty picture kind) rendering algorithm? References: Message-ID: <3A87A0EC.BA802E3E@student.gu.edu.au> Phlip wrote: > > Python for Pyros: > > Click here, then scoot down about 2 pages: > > http://www.tomsawyer.com/glt/index.html > > On the left we see a Graph (a math object describing vertices connected by > edges), and on the right's the same graph drawn with all the lengths of the > lines balanced. > > Is there a Python library out there that can draw a graph like that? Or > which can take a graph as an input and return XY coordinates telling where > to place each vertice and each line? 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 From othello at javanet.com Tue Feb 13 10:43:19 2001 From: othello at javanet.com (Raymond Hettinger) Date: Tue, 13 Feb 2001 10:43:19 -0500 Subject: Python 2.1 release schedule References: Message-ID: <3A895617.C7EDB5C8@javanet.com> 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 From donn at oz.net Wed Feb 21 02: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 aleaxit at yahoo.com Mon Feb 19 11: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 aahz at panix.com Thu Feb 8 11:08:20 2001 From: aahz at panix.com (Aahz Maruch) Date: 8 Feb 2001 08:08:20 -0800 Subject: dictionary sub-value lookup References: <3A80F9B4.E072037D@millinfo.co.za> <3A826E2E.611F9DBD@millinfo.co.za> Message-ID: <95ug9k$j72$1@panix6.panix.com> In article <3A826E2E.611F9DBD at millinfo.co.za>, Richard wrote: >Okie, : > >The object comes from a program. I have no control over it. >Example of M[0]: >({'Label': 251, 'value': 1275.0}) > >I just throught there was some easy way of getting M[i] given that >M[i]['Label'] = 251 ... when what I really want is M[i]['value'] > >ie: given '251', find corrosponding 1275. For starters, you probably want a real database for this kind of thing. That way, someone else has already done the work. But if you really want to do this in Python, you need to create a dict that looks something like this: M[251] = (1275.0, 0) If it's possible that more than one label of 251 will exist, you need to do this: M[251] = [(1275.0, 0), ...] -- --- 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 glennj at pcard31e.ca.nortel.com Sun Feb 25 14: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 geoff at homegain.com Sat Feb 3 03: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 phd at phd.pp.ru Tue Feb 6 05:20:45 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 6 Feb 2001 13:20:45 +0300 (MSK) Subject: SOAP In-Reply-To: <3a7fc9f1$0$11094@reader4> Message-ID: On 6 Feb 2001 lawick at wanadoo.nl wrote: > Is there a SOAP module available for Python? Yes, soaplib.py. Search the Net. (Hint: PythonWare) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From bawolk at ucdavis.edu Tue Feb 27 22: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 stephen_purcell at yahoo.com Tue Feb 13 03:46:23 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 13 Feb 2001 09:46:23 +0100 Subject: python 2.0 won't run scripts with \r\n line termination on RH7? In-Reply-To: ; from carifio.nospam@nospam.usys.com on Mon, Feb 12, 2001 at 11:32:54AM -0500 References: Message-ID: <20010213094623.D5558@freedom.puma-ag.com> Mike Carifio wrote: > So here's my solution, crufty though it is. I created a link to the python > executable named 'python^M', in other words I added the carriage return to > the end of the file name so bash would find it. Ay-ay-ay... Ingenious lateral thinking, but... I can't imagine why people freak out when they can't write UNIX scripts that don't have UNIX line endings! If the first line starts '#!' it should finish '\n', not '\r\n'. If it doesn't, fix the file, not the OS. -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 hgg9140 at seanet.com Fri Feb 16 08: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 morten at esol.no Sat Feb 3 13:19:48 2001 From: morten at esol.no (Morten W. Petersen) Date: Sat, 3 Feb 2001 19:19:48 +0100 Subject: Creating a safe counter with Python for Zope Message-ID: Hi guys, I've been contemplating to create a safe counter for Zope using Python. I've tried using the FSCounter product (available from zope.org), but that occassionally barfs up an Exception. Now, the problem is that I don't really know too much about threads and semaphores (which I'm assuming is the best/easiest way to do it), much less how to make this work safely with Zope (the ZODB). This counter is going to be used as a system wide unique identifier, and it therefore needs to be completely safe and also persistent. I've built a simple counter without persistence that seems to work: """ import thread import threading import time class test_counter: def __init__(self, start=0): self.counter = start self.lock = thread.allocate_lock() def __call__(self): self.lock.acquire() counter = self.counter = self.counter + 1 self.lock.release() return counter get_unique_id = test_counter() id_list = [] def crack_it(): while 1: id_list.append(get_unique_id()) time.sleep(0.01) threading._start_new_thread(crack_it, ()) threading._start_new_thread(crack_it, ()) threading._start_new_thread(crack_it, ()) threading._start_new_thread(crack_it, ()) """ And I've run tests on this that append around 100000 integers to the list, all unique. Now, with this working, can I be sure that if it subclasses the persistence machinery that it will always be unique? And that multiple threads or whatever can't modify it at the same time and screw up the uniqueness of the value?.. Thank you for your time. -Morten From robin at jessikat.fsnet.co.uk Thu Feb 8 05:08:51 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 8 Feb 2001 10:08:51 +0000 Subject: Reportlab fonts References: Message-ID: In article , Matt Fair writes >Hello, >Does anyone know if it is possible yet to expand the standard 14 fonts >when generating pdfs with reportlab? In the user manual it says that >they are working on embedding fonts into the pdf. What are the >limitations to pdfs? Are the 14 standard fonts on the clients computer >with Acrobat? Would there be a way to expand the fonts even though you >could embed the fonts into the pdf (the user would require to have the >fonts on the computer). How accurate can you make these pdf for >printing? I need to make printable files that are very accurate to >where the text is and the size and font. >Thanks >Matt > > so far as I know standard reportlab only allows the 14 standard fonts. A colleague reports an extended version with japanese fonts. I'll repost this into the reportlab-users mail list. -- Robin Becker From aahz at panix.com Thu Feb 8 11:10:12 2001 From: aahz at panix.com (Aahz Maruch) Date: 8 Feb 2001 08:10:12 -0800 Subject: None assigment References: Message-ID: <95ugd4$jka$1@panix6.panix.com> In article , Gregoire Welraeds wrote: > >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 ? Neither, really; it's Just The Way Things 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 "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 fredrik at pythonware.com Fri Feb 23 16: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 support at internetdiscovery.com Sat Feb 10 05:26:31 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Sat, 10 Feb 2001 10:26:31 GMT Subject: [ANN] PAGE 0.1 - A drag and drop GUI generator for Python References: <3A8435C9.CA99421@rgv.hp.com> Message-ID: <3a851656.3694347@24.0.228.33> On Fri, 09 Feb 2001 10:24:10 -0800, Don Rozenberg wrote: >AGE 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. Great to hear of this - I'll try it out. I've been maintaning Python/Tix and am glad to see it being used. If you are working inside HP with Tix and have a spare minute, could you send me a short note on what HP's type of uses and applications of Tix are? Many thanks, Mike. From chrisa at ASPATECH.COM.BR Tue Feb 13 14: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 dnew at san.rr.com Wed Feb 21 13: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 loewis at informatik.hu-berlin.de Fri Feb 2 16: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 jpet at eskimo.com Mon Feb 19 00: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 jgraves3 at austin.rr.com Mon Feb 26 16: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 KatMouse at gmx.de Wed Feb 14 14: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 akuchlin at mems-exchange.org Thu Feb 8 10:36:16 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 08 Feb 2001 10:36:16 -0500 Subject: Python 2.1a2 compile problems References: <95pfsu$ht1$1@nnrp1.deja.com> <3dpugvh6ot.fsf_-_@ute.cnri.reston.va.us> <95q16e$3go$1@nnrp1.deja.com> <95u774$ktc$1@tyfon.itea.ntnu.no> Message-ID: <3dy9vh5gr3.fsf@ute.cnri.reston.va.us> "Magnus Lie Hetland" writes: > I'm having the same problems, and was prepared to wait > for a beta... ;) Erm... you do know that problems don't get fixed unless they actually get reported, right? --amk From tim.one at home.com Fri Feb 2 00: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 martin.franklin at westerngeco.com Mon Feb 12 03:17:27 2001 From: martin.franklin at westerngeco.com (Martin Franklin) Date: Mon, 12 Feb 2001 08:17:27 +0000 Subject: Fonts in Pmw.ScrolledListBox? Message-ID: <3A879C17.C46AE6F5@westerngeco.com> I think you can also do it when you create the widget...(untested) lb=Pmw.ScrolledListBox(root, listbox_font='7x15', listbox_height=8, labelpos='n' ..... etc) Martin Matthew Dixon Cowles wrote: > > On Sat, 10 Feb 2001 18:14:36 -0600, Barron wrote: > > >How does one set the font in a Pmw.ScrolledListBox. The "font" option > >doesn't seem to work like it does in a regular list box and I didn't see > >anything about fonts in the Megawidget documentation for the > >ScrolledListBox. > > Barron, > You want something like: > > mylistbox.component("listbox").configure(font="7x13") > > Since Pmw commonly wraps up standard Tkinter widgets, configuring the > ordinary widget is usually just a matter of asking the megawidget for > it and doing the configuration normally. > > Regards, > Matt > -- > http://mail.python.org/mailman/listinfo/python-list From shredwheat at mediaone.net Wed Feb 14 01: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 timin at homeSPAMNOT.com Mon Feb 26 10: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 dsh8290 at rit.edu Thu Feb 8 17:03:03 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 8 Feb 2001 17:03:03 -0500 Subject: C++ style Stream Operators In-Reply-To: <3a831395.0@216.0.152.7>; from jimholliman@heartsoft.com on Thu, Feb 08, 2001 at 03:41:42PM -0600 References: <3a831395.0@216.0.152.7> Message-ID: <20010208170303.A14287@harmony.cs.rit.edu> As of Python 2.0 you can use this : a_file = open( "filename" , "w" ) print >> a_file , "something to output" On Thu, Feb 08, 2001 at 03:41:42PM -0600, Jim wrote: | 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 johann at physics.berkeley.edu Sun Feb 18 21: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 db3l at fitlinxx.com Fri Feb 9 13:54:19 2001 From: db3l at fitlinxx.com (David Bolen) Date: 09 Feb 2001 13:54:19 -0500 Subject: threading.RLock not subclassible? References: <3A7D5B5F.AADAA673@ll.mit.edu> <3A7F5C74.6C9BC395@home.com> <3A80A969.54B41DFF@home.com> <3A8341B1.6B7CB4C6@home.com> Message-ID: Rick Lee writes: > Regarding your comment on what you think may be the unsafe and > unpredictable code: the code does access a couple of global lists, > the only things done with these lists are len() and append(), which > I read somewhere are "atomic". Perhaps, although given that any given method might behind the scenes have been overridden with arbitrary code, I would probably suggest never making such assumptions and instead always protecting common data. (And in particular when you are having uncertain behavior :-)) One point was that the code seemed to assume the object pointed to by "me" is the same between when you append it to started and when you later append it to completedRunObj (if the completed is supposed to track the started), but since I think "me" may end as the same local label accessed simultaneously by multiple threads, you could fine "me" change in between (so perhaps you'd add "n" to the started list, but then append "n-1" to the completed list when the new thread just started re-evaluates the length of the runners and assigns it to "me"). Basically, with threading it's always better to play it safe when it involves any potential for multi-thread access to the same data. -- -- 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 zzizz_ at notmail.com Mon Feb 19 21: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 akhar at videotron.ca Mon Feb 19 03: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: 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 thomas at xs4all.net Sun Feb 25 18: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 lisowski.tomasz at sssa.NOSPAM.com.pl Fri Feb 2 03: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 Randy.L.Kemp at motorola.com Tue Feb 6 09:42:18 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Tue, 6 Feb 2001 08:42:18 -0600 Subject: Software engineer Message-ID: <69BC4C6AE83ED311BC9400805FA7B14AF84DE7@il93exp01.css.mot.com> Haghdad: I think you are addressing the wrong list, since the Python mailing list is a non profit organization. Of course, you may have been trying to influence the readers of these mailing lists. If you were to indulge in a sharp display of Python code, you would catch their attention off the bat. Seriously -- there are many good, free internet sites where you can post your resume, such as monster.com, headhunter, etc. Good luck. Randy -----Original Message----- From: Kian Haghdad [mailto:khaghdad23 at yahoo.com] Sent: Tuesday, February 06, 2001 8:34 AM To: python-list at python.org Subject: Software engineer Hi: I have got your email from the Web site and I am very interested in working for your company. I have a BS in Electrical Engineering and computer science and worked on my Master degree in Telecommunication engineering (not finished due to the lucrative market!). I have also 7++ years of experience with software development, Internet development and hardware. I have worked for many companies both in Iran and in the United States using different development environments. I am looking for a position which utilizes my experience. I am open to both Permanent position or contract to permanent positions. I am Canadian resident and have permission to work in Canada. I have attached my resume and sincerely appreciate your attention, thank you. Sincerely, Kian Haghdad Here is my resume: Kian Haghdad 8 Kingsbridge Crt., Apt. 508 Toronto, Ontario M2R 1L5 Home: (416) 630-7066 Fax: (416) 630-7991 Email: khaghdad23 at yahoo.com I have more than 7+ years of experience in application development, Database Management, Internet development. I have also been involved in hardware design. My software development experience is mainly in Visual Basic, Visual C++, Visual J++, Visual InterDev, COM, DCOM, MFC, SDKs, MS-Access, MS-SQL, FoxPro, Java script and VB script. Over the years I have been responsible for the Development of many applications from design to commercial release. EDUCATION: Sharif University OF Technology, Tehran (The best technical school in Iran) 9/87-6/92 B.S. Degree: Electrical Engineering and computer science Worked on M.S. degree in Telecommunication engineering EXPERIENCE: 01Communique, Mississauga, Ontario 12/00-Present Involved in the development of a web supported version of the communicating Interface using Active Server Pages, JavaScript, VB Script and browser compatibility, Visual C++6.0, Borland C++, MSMQ, TCP/IP. Application increases the Modem compatibility for the wide variety of connections. It also provides additional capabilities for the desktop version on the web. American SkySat, Walnut Creek, California 5/00-Present * Involved in the development of a web application in Visual InterDev 6.0 using Active Server Pages (ASP), Microsoft E-Commerce, SQL 7.0, XML, Visual C++ 6.0 and Visual Basic 6.0, Visual J++ 6.0, COM (ATL), DCOM, JavaScript and VB Script. The web server was Microsoft Internet Information Server (IIS), Microsoft site server 3.0, with Microsoft E-Commerce edition 3.0 and FrontPage extension running under the NT Server The web application provides NT related services online. The user can register and buy services and also allows the user to troubleshoot and configure a system at real time online. The web site also provides the capability of chatting online, customer support online, statistical analysis online and transaction online. * Developed a database management application for a medical health care center, using Visual Basic 6.0, SQL 7.0, Crystal report and Access 2000. (Windows 98 and NT) American Computech, Pleasanton, California 3/98-5/00 Developed different applications using Visual C++, Visual J++, and Access. * Involved in the development of a CRM (Customer Relation Management)web application in Visual InterDev 6.0 using Active Server Pages (ASP), Microsoft E-Commerce, SQL 7.0, XML, Visual Basic 6.0, Visual J++ 6.0, COM, DCOM, JavaScript and VB Script. (Windows 98 and NT) Developed an application in Visual Basic 5.0, Access 97 and Crystal reports (using ODBC) for financial analyses department of FHP (Concord, California). The application is capable of importing data from other systems, analyzing and processing the data and generating hundreds of reports base on the original data. *Developed an MDI application in Visual C++5,0 and Access 97 for windows called ID maker. The application is designed to drive a digital camera, capture a picture and generate different ID cards using OLE (marketing for schools and clubs). The Cannon digital camera is controlled via DLL functions calls to the camera's driver. The camera is connected via a parallel port. I have also developed several OCXs for this project. Developed an application in Visual Basic 5.0, Access 97 and Crystal reports (using ODBC). The application is a very large information management system for CBI (City Building Inc. in San Francisco). The application contains 28 relational tables large number of queries forms and reports. Tavanir Co., Tehran, Iran 9/95-3/98 *Developed an application in Visual C++ 5.0 intended for network control managements. The application is able to get information such as voltage, active and reactive power from power plants and transmission stations and specifies transmission state using power flow method after a fault occurs on the transmission line. * Developed an application for voltage drop on the net. The application was developed in Visual Basic 5.0 using graphical OCXs. * Developed hardware for the high voltage network. *Developed an application in Visual C++ 4.0. The application checks the transmitting power on the lines and controls the system's steady state by alarm system. *Developed an application in Visual C++ 4.0 set the protection relays in substations to protect the network's reliability. Pishro Co., Tehran, Iran 11/94-6/95 Designed, developed and implemented electrical systems using computer aided software. The electrical systems were intended for both indoors (Buildings) and outdoors (Airports and Terminals). The systems were designed and based on the standard and regulation of electrical system. Pardis Tower Co, Tehran, Iran 1/93-11/94 Designed simulators for training purpose. *Developed an application in C++ for cycloconvertor simulator. The cycloconvertor is used in the starters of synchronous motors. *Developed application using C++ for control speed of DC motors. The application gets input voltage to the motor, speed of motor and rotor's current. It can control the motor speed based on requested speed. *Developed application using C++ for step motor's control speed. In order to change the angle of dish antenna, the application orders to step motor to change the rotor's situation. SKILLS: Software development Visual C++, Visual Basic, Visual InterDev, Visual J++, MFC, SDKs, COM, DCOM, ATL ActiveXs , C++, Fortran, Intel 8085 Assembler Access. Internet development Visual InterDev 6.0, Active Server Pages (ASP), SQL 7.0, COM, DCOM, Java script. Database development MS-SQL, Access, FoxPro Operating System Used NT, MS-Win, UNIX, VAX, MS-DOS From joconnor at cybermesa.com Wed Feb 7 18: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 ransen_spam_me_not at nemo.it Fri Feb 23 11: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 Gareth.McCaughan at pobox.com Tue Feb 20 14: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 scarblac at pino.selwerd.nl Sun Feb 4 09: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 noselasd at frisurf.no Wed Feb 21 04: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 fredrik at pythonware.com Wed Feb 21 13: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 fredrik at pythonware.com Wed Feb 21 01: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 m.bless at gmx.de Wed Feb 7 17:55:49 2001 From: m.bless at gmx.de (Martin Bless) Date: Wed, 07 Feb 2001 22:55:49 GMT Subject: String formatting characters - looking for details Message-ID: <3a81cfa2.1708851@news.muenster.de> (1) Where can I find some more details about the string formatting characters? (2) How I print hex values with zeros padded left, like 0F or 0A? print '%X' % 15 # two digits, wanted (3) This is from the Python docs - I'm looking for more information on how to use the formatting characters. Thanks, Martin ------------------- from the Python docs -------- 2.1.5.2 String Formatting Operations String objects have one unique built-in operation: the % operator (modulo) with a string left argument interprets this string as a C sprintf() format string to be applied to the right argument, and returns the string resulting from this formatting operation. The right argument should be a tuple with one item for each argument required by the format string; if the string requires a single argument, the right argument may also be a single non-tuple object.2.5 The following format characters are understood: %, c, s, i, d, u, o, x, X, e, E, f, g, G. Width and precision may be a * to specify that an integer argument specifies the actual width or precision. The flag characters -, +, blank, # and 0 are understood. The size specifiers h, l or L may be present but are ignored. --------------------- From sholden at holdenweb.com Fri Feb 16 08: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 tim.one at home.com Sat Feb 17 14: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 timr at probo.com Wed Feb 14 01: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 mertz at gnosis.cx Fri Feb 16 12: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 jcollin at exis.net Tue Feb 27 21: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 bsass at freenet.edmonton.ab.ca Mon Feb 26 13:57:36 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Mon, 26 Feb 2001 11:57:36 -0700 (MST) Subject: [Distutils] Re: CPAN functionality for python In-Reply-To: <200102261822.NAA26272@cj20424-a.reston1.va.home.com> Message-ID: On Mon, 26 Feb 2001, Guido van Rossum wrote: > > 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.) Sure, but if you can build packages on the fly, transparently to the user... it is a "six of one, half dozen of the other" situation. I would expect there to be situation where autobuilding would fail or not be practical (C based modules), supporting "binary" packages would be a necessity. Ya, RPMs are not known for doing a good job of dependencies. Debian would be a better model to look at with respect to what dependency info is required and how it should be handled. I rarely (can't remember the last time) have dependency problems with DEBs, that includes third party DEBs (they usually have problems with "Policy", but that's a whole other story ;). - Bruce From dan.rolander at marriott.com Wed Feb 14 09: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 joconnor at cybermesa.com Tue Feb 27 13: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 danielk at aracnet.com Sun Feb 4 16:50:57 2001 From: danielk at aracnet.com (Daniel Klein) Date: Sun, 04 Feb 2001 13:50:57 -0800 Subject: Preventing direct access to a class References: <95kfpo$e9s$1@panix2.panix.com> Message-ID: On 4 Feb 2001 12:58:32 -0800, aahz at panix.com (Aahz Maruch) wrote: >In article , >Daniel Klein wrote: >> >>I have a situation where I need to prevent direct access to a class. > >BTW, the standard Python idiom for declaring this is to precede the >class name with a single underscore (see threading.py for a real >example): > >class _foo: > pass Yes, I see. But this only prevents access to class A if the user does 'from/import'. Thanks, Dan From qrczak at knm.org.pl Wed Feb 21 18: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 s713221 at student.gu.edu.au Sun Feb 18 03: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 ben.hutchings at roundpoint.com Tue Feb 27 17: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 root at rainerdeyke.com Tue Feb 20 22: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 phd at phd.russ.ru Mon Feb 26 16: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 moshez at zadka.site.co.il Sun Feb 4 06: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 gregj at pobox.com Thu Feb 1 14: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 NoSpam at NoSpam.com Sun Feb 25 11: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 pfenn at mmm.com Tue Feb 13 14: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 topmind at technologist.com Mon Feb 26 23: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 Randy.L.Kemp at motorola.com Fri Feb 9 10:02:21 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Fri, 9 Feb 2001 09:02:21 -0600 Subject: I love Python Message-ID: <69BC4C6AE83ED311BC9400805FA7B14AF84E08@il93exp01.css.mot.com> I noticed this message was sent three times. There is an ancient legend that if everyone in the world says "I love Python" three times, Perl will disappear. -----Original Message----- From: Zamurai [mailto:zamurai at gmx.net] Sent: Friday, February 09, 2001 7:37 AM To: python-list at python.org Subject: Re: I love Python "debugboy" wrote: > Test I love Python too ;-) From johann at physics.berkeley.edu Tue Feb 20 15: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 doug at postsmart.net Sat Feb 3 01: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 rhyde99 at email.msn.com Wed Feb 7 16:35:11 2001 From: rhyde99 at email.msn.com (Roger H) Date: Wed, 7 Feb 2001 13:35:11 -0800 Subject: Python wierdness Message-ID: In my Python musings I came across a bit of seeming wierdness. I threw some code at the Python 1.5.2 command line to demonstrate: >>> # This function prints "bar" if the input ... # variable modulo 0.1 is equal to 0.1, and ... # "no bar" if it is not equal to 0.1: ... >>> def foo(n): ... if n % 0.1 == 0.1: ... print "bar" ... else: ... print "no bar" ... >>> # Here I create a variable x with the value 0.3: ... >>> x = 0.3 >>> >>> # Let's check whether x modulo 0.1 is equal to 0.1: ... >>> x % 0.1 0.1 >>> >>> # Obviously, x modulo 0.1 is indeed equal to 0.1. ... # If we pass it to foo(), we should see "bar", right? ... >>> foo(x) no bar >>> >>> # Hmmm... "no bar." So foo() doesn't agree that ... # x modulo 0.1 is equal to 0.1, even though the ... # command line shows that it is. Why not? What's going on here, and how could one get around it? ~Roger the Shrubber~ From aleaxit at yahoo.com Wed Feb 21 04: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 ken at lt.com Tue Feb 6 14:01:31 2001 From: ken at lt.com (Kenneth Loafman) Date: Tue, 06 Feb 2001 13:01:31 -0600 Subject: Binary numbers References: <95p7ks$9e6$1@nnrp1.deja.com> Message-ID: <3A804A0B.E0445B7F@lt.com> This is my second post on this subject. Mail to this user bounces. Could be a troll, but since I'd already answered, here's what I said (important to conserve electrons, don't you know)... sampe99 at my-deja.com wrote: > > Does anyone know an easy way to get a list of binary numbers within a > certain range in python? E.g for > n=1 [0],[1] > n=2 [0,0],[0,1],[1,0],[1,1] > n=3 [0,0,0],[0,0,1] a.s.o > > I need this for n<=18... With n=18, you're asking for [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1], ... [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] n=18 would be a huge list of lists, (2^18) * 18 in size. Assuming 4-byte integers, that would be (262144 * 18 * 4) = 18,874,368 which is 18MB in data alone. Throw in the python list overhead and it would probably occupy 25-30MB. Of course, printing it out would be impractical (useless?). Any practical use for such a list? ...Ken From neelk at alum.mit.edu Fri Feb 16 10: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 matt at netasol.com Wed Feb 7 22:31:07 2001 From: matt at netasol.com (Matt Fair) Date: Wed, 07 Feb 2001 21:31:07 -0600 Subject: Reportlab fonts Message-ID: <3A8212FB.5F15BF60@netasol.com> Hello, Does anyone know if it is possible yet to expand the standard 14 fonts when generating pdfs with reportlab? In the user manual it says that they are working on embedding fonts into the pdf. What are the limitations to pdfs? Are the 14 standard fonts on the clients computer with Acrobat? Would there be a way to expand the fonts even though you could embed the fonts into the pdf (the user would require to have the fonts on the computer). How accurate can you make these pdf for printing? I need to make printable files that are very accurate to where the text is and the size and font. Thanks Matt From sverker.is at home.se Wed Feb 28 22:25:46 2001 From: sverker.is at home.se (Sverker Nilsson) Date: Thu, 01 Mar 2001 04:25:46 +0100 Subject: Allow anything in identifiers? Message-ID: <3A9DC13A.1647EE51@home.se> This would be a new kind of identifiers, I suppose one can make them by writing for example id like in: id 'a>b' = a > b id 'x.b' = x.b alu.id'+' = lambda x, y... I think it could make programs easier to read by allowing more evident identifiers in many cases. The extended identifier syntax should not break anything, and it seems it might be easy to implement... Should try to come up with more better examples, but it's late, any takings, comments? Cheers, Sverker From tim.one at home.com Mon Feb 26 01: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 tim.one at home.com Sun Feb 18 00: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 info at black-karma.de Thu Feb 15 16: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 bowman at montana.com Sun Feb 4 00: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 gReGlAnDrUm at earthlink.net Tue Feb 13 22: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 garry at sage.att.com Tue Feb 20 11: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 mwa at gate.net Mon Feb 26 15:14:24 2001 From: mwa at gate.net (Mark W. Alexander) Date: Mon, 26 Feb 2001 15:14:24 -0500 (EST) Subject: [Distutils] Re: CPAN functionality for python In-Reply-To: <200102261822.NAA26272@cj20424-a.reston1.va.home.com> Message-ID: On Mon, 26 Feb 2001, Guido van Rossum wrote: > Date: Mon, 26 Feb 2001 13:22:45 -0500 > From: Guido van Rossum > To: Bruce Sass > Cc: python-list at python.org, distutils-sig at python.org > Subject: Re: [Distutils] Re: CPAN functionality for python > > 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/) Isn't this the point of distutils --bdist functionality? The catalog should provide download capability of any binary format supported byu distutils. It can either be done on the fly at request time, or batched periodically depending on the space availability of the catalog providing site. Mark mwa at gate.net From jepler at inetnebr.com Sat Feb 17 11: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 R.Liebscher at gmx.de Tue Feb 27 04:44:51 2001 From: R.Liebscher at gmx.de (Rene Liebscher) Date: Tue, 27 Feb 2001 10:44:51 +0100 Subject: [Distutils] Re: CPAN functionality for python References: <14984.49127.853606.286789@w221.z064000254.bwi-md.dsl.cnc.net> <20010215170227.K23577@tummy.com> <20010226013903.B3221@tummy.com> <3A9B6D36.20B1B3C2@gmx.de> <20010227022801.W1781@tummy.com> Message-ID: <3A9B7713.334CD75D@gmx.de> Sean Reifschneider wrote: > > On Tue, Feb 27, 2001 at 10:02:46AM +0100, Rene Liebscher wrote: > >3. feed the meta data and the directory in distutils > > bdist_{rpm|debian|...) and create a package for the > > users prefered system (RPM,...) > > As I understand it, the bdist_* can create a binary RPM from a set of > pre-compiled binaries? Can this be used in conjunction with the other > distutils tools to actually take the source file and turn it into > the binaries on a given platform? The bdist_* commands do an install in a temporary directory and create from this a package (RPM,...). I think it is not a big deal to provide an already existing directory and create from it a package. ------------------------------------------------------- rob at cvs/distutils >python setup.py bdist_rpm --help Global options: --verbose (-v) run verbosely (default) --quiet (-q) run quietly (turns verbosity off) --dry-run (-n) don't actually do anything --help (-h) show detailed help message Options for 'bdist_rpm' command: --bdist-base base directory for creating built distributions --rpm-base base directory for creating RPMs (defaults to "rpm" under --bdist-base; must be specified for RPM 2) --dist-dir (-d) directory to put final RPM files in (and .spec files if --spec-only) --python path to Python interpreter to hard-code in the .spec file (default: "python") --fix-python hard-code the exact path to the current Python interpreter in the .spec file --spec-only only regenerate spec file --source-only only generate source RPM --binary-only only generate binary RPM --use-bzip2 use bzip2 instead of gzip to create source distribution --distribution-name name of the (Linux) distribution to which this RPM applies (*not* the name of the module distribution!) --group package classification [default: "Development/Libraries"] --release RPM release number --serial RPM serial number --vendor RPM "vendor" (eg. "Joe Blow ") [default: maintainer or author from setup script] --packager RPM packager (eg. "Jane Doe ")[default: vendor] --doc-files list of documentation files (space or comma-separated) --changelog path to RPM changelog --icon name of icon file --provides capabilities provided by this package --requires capabilities required by this package --conflicts capabilities which conflict with this package --build-requires capabilities required to build this package --obsoletes capabilities made obsolete by this package --keep-temp (-k) don't clean up RPM build directory --no-keep-temp clean up RPM build directory [default] --use-rpm-opt-flags compile with RPM_OPT_FLAGS when building from source RPM --no-rpm-opt-flags do not pass any RPM CFLAGS to compiler --rpm3-mode RPM 3 compatibility mode (default) --rpm2-mode RPM 2 compatibility mode usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: setup.py --help [cmd1 cmd2 ...] or: setup.py --help-commands or: setup.py cmd --help ------------------------------------------------------------------------ May be it is enough to specify --bdist-base and --binary-only. The other option could get values from some downloaded meta data. > If so, that's exactly what we need... > > Once I have the archive network back-end done, I'm going to start looking at > the client. I'm getting fairly close to a bare-bones server as it is > (without the admin tools -- adding a package requires some SQL). > > I've only looked passingly at the distutils, but will obviously have to > get further into it shortly. > > Thanks, > Sean > -- > Any sufficiently advanced technology is indistinguishable from a rigged demo. > Sean Reifschneider, Inimitably Superfluous > tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From garry at sage.att.com Tue Feb 13 14:06:55 2001 From: garry at sage.att.com (Garry Hodgson) Date: Tue, 13 Feb 2001 19:06:55 GMT Subject: Is Python for me? References: Message-ID: <3A8985CF.33A67363@sage.att.com> Tim Peters wrote: > Lots of fun. See also Clean (which was designed to make standalones): > > http://www.cs.kun.nl/~clean/ while it appears rather nice, it varies widely with respect to what libraries are supported on what platforms. building something truly cross platform might be tricky, restricting one to a small subset. -- 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 tim_one at email.msn.com Thu Feb 15 19: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 n8gray at caltech.edu.is.my.email.address Fri Feb 16 01:31:09 2001 From: n8gray at caltech.edu.is.my.email.address (Nathaniel Gray) Date: Thu, 15 Feb 2001 22:31:09 -0800 Subject: python-dev summary, Jan. 16-31 References: <3d4ry56vzg.fsf@ute.cnri.reston.va.us> <95v3mt$lnh$1@nntp9.atl.mindspring.net> <95v5t3$d3q$1@panix3.panix.com> <962j8r$i9i@gap.cco.caltech.edu> <969nkf$5nd$1@panix3.panix.com> Message-ID: <96ihqb$dou@gap.cco.caltech.edu> Aahz Maruch wrote: > > Actually, I was thinking that this would be a one-directional gateway > from mailing list to newsgroup, no posting allowed. True, this would help keep the common folk up to date with Python-dev, but it sounded to me like the dev crew was disappointed that there hadn't been any feedback generated by the summaries. If feedback is actually what they want (maybe it isn't, and maybe it shouldn't be), I don't see this idea solving the problem. -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From jcm at bigskytel.com Thu Feb 1 20: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 michael at stroeder.com Wed Feb 7 12:53:42 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Wed, 07 Feb 2001 18:53:42 +0100 Subject: python-crypto list hosted at SURFnet.nl References: <3A815E95.5399B6C3@stroeder.com> Message-ID: <3A818BA6.A40A2C27@stroeder.com> Dan Parisien wrote: > > Michael Str?der wrote: > > > Citizens of the U.S. or any other country with export regulations > > for cryptographic software have to take care about themselves for > > not getting into trouble by posting code to this list. > > I know you are not a legal expert, but it seems you have more knowledge > than me in this area. Does this export control only matter to US > citizens? > What if crypto code written by Canadian citizens is hosted on a US web > server? (PyAES on sourceforge.net) Canadian and U.S. law seemed to be pretty similar. At least from a European point of view. ;-) Sorry, I can't give any useful information. I'd suggest digging the openssl-dev mailing list archives with search string "export restrictions" since this topic was discussed to death there. Ciao, Michael. From mwh21 at cam.ac.uk Sun Feb 4 13:16:25 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 04 Feb 2001 18:16:25 +0000 Subject: Preventing direct access to a class References: Message-ID: Daniel Klein writes: > I have a situation where I need to prevent direct access to a class. IOW, the > only way I wish a class to be instantiated is via another class. For example > > >>> class A: > pass > > >>> class B: > def foo(self): > return A() > > >>> b = B() > >>> a = b.foo() > > ...and there might be other classes that 'return A()'. > > I do not want the user to be allowed to do this... > > >>>a = A() > > It doesn't look like classes can be made 'private to the module' as > I tried to define class A as 'class __A'. The user could still > access with a=__A() (no mangling needed). > > Other than placing some convoluted logic in each class, is there a way to > accomplish this pythonic-ly? You won't be able to do this completely. You can make it sufficiently hard that people won't do it by mistake, which is good enough for most folk (it is for me). Here's one way: ------------------------------- class A: pass class B: def foo(self,A=A): return A() del A ------------------------------- the class A is still there: >>> B.foo.im_func.func_defaults (,) but I think you can rely on people not doing >>> B.foo.im_func.func_defaults[0]() accidentally . Cheers, M. -- I'm okay with intellegent buildings, I'm okay with non-sentient buildings. I have serious reservations about stupid buildings. -- Dan Sheppard, ucam.chat (from Owen Dunn's summary of the year) From cookedm+news at physics.mcmaster.ca Tue Feb 27 14: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 tiddlerdeja at my-deja.com Fri Feb 2 12: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 jmarshal at mathworks.com Fri Feb 16 12: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 tim.one at home.com Tue Feb 27 12: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 f8dy at my-deja.com Tue Feb 6 08:02:37 2001 From: f8dy at my-deja.com (Mark Pilgrim) Date: Tue, 06 Feb 2001 13:02:37 GMT Subject: how to send email in python? References: <3A7FA5BA.82FB7593@esec.com.au> Message-ID: <95osl9$vds$1@nnrp1.deja.com> In article <3A7FA5BA.82FB7593 at esec.com.au>, Sam Wun wrote: > does anyone knows? I am using python 1.6. You don't specify which platform you're on, so I won't assume you have sendmail or anything easy like that, so we'll do it the hard (and cross-platform) way. from smtplib import SMTP def sendmail(smtpserver, fromaddr, toaddr, subject, msg): smtpsock = SMTP(smtpserver) msg = "From: Your name <%(fromaddr)s\nSubject: %(subject)s\n\n%(msg)s" % vars() rc = smtpsock.sendmail(fromaddr, [toaddr], msg) smtpsock.quit() return rc ## If your mail server requires POP authentication (like Yahoo! Mail does), you can't call the above function directly; call this one instead: from poplib import POP3 def sendmailwithPOPauth(popserver, popuser, poppassword, smtpserver, fromaddr, toaddr, subject, msg): popsock = POP3(popserver) popsock.user(popuser) popsock.pass_(poppassword) # note weird function name; "pass" is reserved word in Python popsock.quit() return sendmail(smtpserver, fromaddr, toaddr, subject, msg) Hope this helps. -M -- You're smart; why haven't you learned Python yet? http://diveintopython.org/ Sent via Deja.com http://www.deja.com/ From debl at NoNOSpamtheworld.com Sun Feb 25 16: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 phd at phd.pp.ru Wed Feb 28 04: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 bsb at winnegan.de Mon Feb 12 13: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 chris.gonnerman at usa.net Wed Feb 21 08: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 ten.llun at ttam Fri Feb 9 03:34:11 2001 From: ten.llun at ttam (Matthew Schinckel) Date: Fri, 09 Feb 2001 19:04:11 +1030 Subject: sorting question References: Message-ID: <3a83ac08_7@news.chariot.net.au> In message , "dsavitsk" wrote: > Thank you all for the suggestions. > > i am trying to unscramble scrambled words (which i am frustratingly bad at) > so i send all of the permutations to Word's spell checker and see what it > thinks are words. I'll post the code this afternoon when i'm done in case > anyone wants it. > Hmm, sort of sounds similar to what I did the year before last. The local 'Newspaper' (I give it more credit than it is due :-), the Adelaide Advertiser, has a 9-letter word puzzle, where 9 letters are given, and the aim is to make as many words as possible that are 4 letters or more, and contain the magic 'middle' letter. For instance: C A R D A B R O O would give many words, with cardboard as the 9-letter word. My school had a competition where each homegroup had to try and find as many words, and the results were tallied over the whole term. Naturally, I wrote a python program, and took all of the fun out of it. If anyone is interested, you might find it at: http://www.chariot.net.au/~jaq/matt/NineLetter.zip (It's almost 2Mb, and includes a large, almost[?] comprehensive word list.) -- Matthew Schinckel matt at null dot net From bkc at Murkworks.com Mon Feb 19 16: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 infotechsys at pivot.net Tue Feb 27 05: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 deblNoNONspammy at theworld.com Tue Feb 6 00:44:14 2001 From: deblNoNONspammy at theworld.com (David Lees) Date: Tue, 06 Feb 2001 05:44:14 GMT Subject: speed comparison of IDL, numPy, Matlab References: <3A7EEE5C.6419B707@pacific.jpl.nasa.gov> <3A7F0856.3CFA7FA2@ncep.noaa.gov> Message-ID: <3A7F8F35.13FD8BB8@theworld.com> Paul, Thanks for the URL to pydl. It looks quite interesting. I am a Python newbie, but your comments Python syntax and being "wordy" seem a bit misplaced. The 'for' statement could have been written with a 'range' so that it looks similar to the IDL for statement. The wordiness of Python relative to IDL or Matlab is just due to the built in functions used, not something inherent in Python. A function could easily be defined for generating the uniform square matrices used in the benchmark. I really like the balance that Python achieves between clarity and program length. Certainly there have been languages like APL that were far more compact than IDL or Matlab, but they were a bit cryptic for my taste. david lees Paul van Delst wrote: > > Benyang Tang wrote: > > > > Out of curiosity, I did a quick benchmark test of IDL, NumPy and Matlab on my > > desktop machine. I know benchmarking is a complicated issue; don't take my > > naive test too serious. > > O.k. :o) > > I've never used Python, and Matlab only once or twice, but what's with the Python syntax? > Seems a tad wordy. Looks like Nick Bower's IDL-like package in Python > (http://nickbower.com/computer/pydl) is worth another look though...... > > paulv > From jhauser at ifm.uni-kiel.de Wed Feb 14 08: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 emile at fenx.com Sun Feb 18 12: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 locka at iol.ie Wed Feb 21 18: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 paul.moore at uk.origin-it.com Mon Feb 12 11:59:54 2001 From: paul.moore at uk.origin-it.com (Paul Moore) Date: Mon, 12 Feb 2001 17:59:54 +0100 Subject: PEP status and python-dev summaries References: <3dg0hn8zlr.fsf@ute.cnri.reston.va.us> <3A844423.8AF2B87A@intertrader.com> Message-ID: On Fri, 9 Feb 2001 20:25:23 +0100 , Andrew Cooke wrote: >All IMHO - I'm not involved in Python, just curious about how this >problem is going to be handled. How is it handled in Perl? Is there a >Python equivalent of the porters, for example? The perl5 porters list is the equivalent of python-dev. The difference is that P5P is basically an open list. This has some significant downsides (P5P has had a history of degenerating into flamefests and noise), but that is more likely a consequence of certain personality issues and a lack of any sort of moderation on P5P than an essential aspect of the process... P5P is a good counterexample to the argument that python-dev should be completely open, but IMHO there should be a middle ground somewhere. Paul Moore. From nicky001 at gofree.indigo.ie Mon Feb 26 04: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 muk_pr at yahoo.com Sat Feb 17 13: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 costas at springmail.com Sun Feb 18 22: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 apederse at my-deja.com Thu Feb 8 02: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 jhauser at ifm.uni-kiel.de Mon Feb 19 06: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 donn at u.washington.edu Thu Feb 1 14: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 seandc at att.net Sun Feb 18 16: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 phd at phd.pp.ru Fri Feb 9 03:56:55 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 9 Feb 2001 11:56:55 +0300 (MSK) Subject: SAXReaderNotAvailable In-Reply-To: Message-ID: On Fri, 9 Feb 2001, Oleg Broytmann wrote: > Did the compiled PyExpat - Python wrapper for expat? I meant "did theY" :) Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From Roy.Culley at switzerland.org Fri Feb 16 13: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 jeremy at alum.mit.edu Fri Feb 9 20:14:33 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Fri, 9 Feb 2001 20:14:33 -0500 (EST) Subject: PEP status and python-dev summaries In-Reply-To: References: <3dg0hn8zlr.fsf@ute.cnri.reston.va.us> Message-ID: <14980.38393.244828.153715@w221.z064000254.bwi-md.dsl.cnc.net> The PEPs are kept under CVS control, which supports differencing directly. So you can read the current PEPs via python.sourceforge.net and you can review changes using the CVS repository at sourceforge.net/projects/python. Jeremy From MarkH at ActiveState.com Sun Feb 25 16: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 db3l at fitlinxx.com Fri Feb 23 20: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 Burkhard.Kayser at marconi.com Thu Feb 15 11: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 tony at lsl.co.uk Wed Feb 14 05:26:10 2001 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Wed, 14 Feb 2001 10:26:10 -0000 Subject: Python 2.1 release schedule In-Reply-To: Message-ID: <008001c09670$8c5ad340$f05aa8c0@lslp7o.int.lsl.co.uk> Tom Loredo wrote: > Is it yet settled which of the Python unit test frameworks this > will be? Fredrik Lundh replied: > doctest.py (already in the repository, since it's cool) > PyUnit.py (by BDFL decree, since his employer was already using it) Yeh! (you'll have to imagine me shouting that whilst raising my arms in the air, as our two year old does when he gets good news - or perhaps you'd rather not). doctest is really neat (I've finally managed to get round to using it) - having *just* changed the names of a handful of variables in some source code, it's very nice to be able to run the module "at itself" and have it tell me it's still working... (well, as much as it was before, anyway!) I guess now I'll have to bite the bullet and learn how to use PyUnit as well. Tibs -- Tony J Ibbs (Tibs) http://www.tibsnjoan.co.uk/ Give a pedant an inch and they'll take 25.4mm (once they've established you're talking a post-1959 inch, of course) My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From grante at visi.com Tue Feb 20 15: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 jafo at tummy.com Thu Feb 15 17: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 sholden at holdenweb.com Wed Feb 7 19:36:15 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 7 Feb 2001 19:36:15 -0500 Subject: sorting question References: Message-ID: "dsavitsk" wrote in message news:tmlg6.61202$Ch.11526305 at newsrump.sjc.telocity.net... > i would like to iterate through all possible combinations of the characters > in a string, and i am not thinking very clearly about how to approach this. > that is, if the initial string is 'bar', i want to print > ['bar', 'bra', 'abr', 'arb', 'rba', 'rab'] > any hints? > > thanks, > ds > Tim Peters was working on something a while ago, see http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=558836665 but I'm not sure where it eventually went to live regards Steve -- Tools, training and technology to help you meet your information needs From bobhicks at adelphia.net Wed Feb 21 14: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 erno-news at erno.iki.fi Fri Feb 16 04: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 dwig at advancedmp.net Wed Feb 21 12: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 avle at rogn.ii.uib.no Sat Feb 10 04:49:28 2001 From: avle at rogn.ii.uib.no (Helge Avlesen) Date: 10 Feb 2001 10:49:28 +0100 Subject: RedHat 7.0 LONG_BIT compilation error References: Message-ID: <72pugqx3yv.fsf@rogn.ii.uib.no> Try update glibc as well, I think the problem was in the header files, not the compiler. Helge "Mark Hatasaka" writes: | I'm trying to compile Python 2.0 on RedHat 7.0 i386, but keep getting the following LONG_BIT error. | | gcc -g -O2 -Wall -Wstrict-prototypes -I./../Include -I.. -DHAVE_CONFIG_H -c -o listnode.o listnode.c | gcc -g -O2 -Wall -Wstrict-prototypes -I./../Include -I.. -DHAVE_CONFIG_H -c -o node.o node.c | In file included from ../Include/Python.h:54, | from node.c:3: | ../Include/pyport.h:390:2: #error "LONG_BIT definition appears wrong for platform (bad gcc config?)." | make[1]: *** [node.o] Error 1 | make[1]: Leaving directory `/usr/Python-2.0/Parser' | make: *** [Parser] Error 2 | [root at Piglet Python-2.0]# | | I've applied the latest RedHat gcc updates (gcc-2.96-69) | | I've run the following commands | | marke clean | | rm config.cache | | ./configure | | make | | | | Any suggestions would be greatly appreciated. | | Mark | | | -- Helge Avlesen, Para//ab, University of Bergen WWW: http://www.ii.uib.no/~avle Phone: +47 55 58 40 35, Fax: +47 55 58 41 99, Office: HIB 317H1 From phd at phd.pp.ru Tue Feb 13 11:34:38 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 13 Feb 2001 19:34:38 +0300 (MSK) Subject: CPAN functionality for python In-Reply-To: <14984.48195.455785.172253@w221.z064000254.bwi-md.dsl.cnc.net> Message-ID: On Mon, 12 Feb 2001, Jeremy Hylton wrote: > OB> This metadata can be put in static files. Thus, it can be easily > OB> mirrored/reached by www/ftp/rsync/etc. In case of Zope, mirror > OB> site must run Zope, so mirroring will be limited to probably 2-3 > OB> sites in the world. > > I think this would be a fine project for Zope, in part because we're > going to be spinning up zope.python.org in the next few weeks and > could probably provide a home for it. (Yeah, I work for Digital > Creations, too, but only because I think it's a great company.) 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? I completeley agree that this task *can* be solved using Zope. We can develop data formats, protocols, etc. And I completely disagree that the task *should* be solved with Zope. It shouldn't. Please count current mirrors of CPAN. The figure looks good, isn't it? This is because there are sites that provide FTP mirrors. Who will agree to run Zope only to mirror CPyAN? Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From fredrik at pythonware.com Fri Feb 23 07: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 robin at jessikat.fsnet.co.uk Wed Feb 7 07:28:35 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 7 Feb 2001 12:28:35 +0000 Subject: Variable depth of nesting References: Message-ID: In article , Jacek Generowicz writes for the variable length list comprehension I tried >>> def vlc(L): ... v = '' ... f = '' ... for i in xrange(len(L)): ... v += ',x%d'%i ... f += ' for x%d in L[%d]' % (i,i) ... return eval('[(%s) %s]' % (v[1:],f)) ... and it seems to work -- Robin Becker From ehagemann at home.com Thu Feb 8 17:36:13 2001 From: ehagemann at home.com (Eric Hagemann) Date: Thu, 08 Feb 2001 22:36:13 GMT Subject: embedding C and Python in Perl Message-ID: Hey all --- maybe Python needs the same ? Anybody seen this ? http://www.perl.com/pub/2001/02/inline.html?wwwrrr_20010206.txt From aahz at panix.com Fri Feb 16 11:27:01 2001 From: aahz at panix.com (Aahz Maruch) Date: 16 Feb 2001 08:27:01 -0800 Subject: python-dev summary, Jan. 16-31 References: <3d4ry56vzg.fsf@ute.cnri.reston.va.us> <962j8r$i9i@gap.cco.caltech.edu> <969nkf$5nd$1@panix3.panix.com> <96ihqb$dou@gap.cco.caltech.edu> Message-ID: <96jkcl$f4k$1@panix2.panix.com> In article <96ihqb$dou at gap.cco.caltech.edu>, Nathaniel Gray wrote: >Aahz Maruch wrote: >> >> Actually, I was thinking that this would be a one-directional gateway >> from mailing list to newsgroup, no posting allowed. > >True, this would help keep the common folk up to date with Python-dev, but >it sounded to me like the dev crew was disappointed that there hadn't been >any feedback generated by the summaries. If feedback is actually what they >want (maybe it isn't, and maybe it shouldn't be), I don't see this idea >solving the problem. As I said in another post, if Followup-To goes to c.l.py, everything is hunky-dory. -- --- 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 chrisw at nipltd.com Fri Feb 2 10: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 db3l at fitlinxx.com Mon Feb 5 19:54:22 2001 From: db3l at fitlinxx.com (David Bolen) Date: 05 Feb 2001 19:54:22 -0500 Subject: threading.RLock not subclassible? References: <3A7D5B5F.AADAA673@ll.mit.edu> Message-ID: "Tim Peters" writes: > BTW, an acquire with a timeout is a cool idea! Feel encouraged to submit a > patch to add such a thing directly to threading.py: If anyone does think along these lines I'd suggest investigating adding a timeout to the code per-platform thread code as opposed to something at a high level in threading.py. Using a loop construct around a non-blocking lock acquisition runs the risk of never getting the lock, even if you were the first to start waiting, such as in the case where you are in the loop part of the code when the lock releases. What's really needed is a true blocking acquire with timeout, so that you remain constantly in the queue for the lock at the OS level, and are guaranteed to get it if it frees up within your timeout. For systems where that isn't supported at the OS level, the non-blocking loop could be implemented in the appropriate thread_* OS module. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From topmind at technologist.com Tue Feb 27 21: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 pvandelst at ncep.noaa.gov Mon Feb 5 15:08:54 2001 From: pvandelst at ncep.noaa.gov (Paul van Delst) Date: Mon, 05 Feb 2001 15:08:54 -0500 Subject: speed comparison of IDL, numPy, Matlab References: <3A7EEE5C.6419B707@pacific.jpl.nasa.gov> Message-ID: <3A7F0856.3CFA7FA2@ncep.noaa.gov> Benyang Tang wrote: > > Out of curiosity, I did a quick benchmark test of IDL, NumPy and Matlab on my > desktop machine. I know benchmarking is a complicated issue; don't take my > naive test too serious. O.k. :o) I've never used Python, and Matlab only once or twice, but what's with the Python syntax? Seems a tad wordy. Looks like Nick Bower's IDL-like package in Python (http://nickbower.com/computer/pydl) is worth another look though...... paulv P.S. BTW, in Matlab, how do you simply multiply the corresponding matrix elements? (i.e. not a matrix multiply). -- Paul van Delst A little learning is a dangerous thing; CIMSS @ NOAA/NCEP Drink deep, or taste not the Pierian spring; Ph: (301) 763-8000 x7274 There shallow draughts intoxicate the brain, Fax: (301) 763-8545 And drinking largely sobers us again. Email: pvandelst at ncep.noaa.gov Alexander Pope. From peter at engcorp.com Sat Feb 3 09: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 bk at xk7.com Tue Feb 20 09:42:23 2001 From: bk at xk7.com (Burkhard Kloss) Date: Tue, 20 Feb 2001 14:42:23 -0000 Subject: Hosting service supporting 2.0 References: Message-ID: <982680144.675737@master.nyc.kbcfp.com> > >I'm looking for a moderately priced web hosting service that supports > >Python 2.0. Anyone know of any such? Hurricane Electric (www.he.net) allows you to install your own software - including in my case python. From grante at visi.com Wed Feb 21 18: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 Sat Feb 17 11: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 sandj.williams at gte.net Fri Feb 2 23: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 jeremy at alum.mit.edu Tue Feb 13 00:02:31 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Tue, 13 Feb 2001 00:02:31 -0500 (EST) Subject: CPAN functionality for python In-Reply-To: References: <14984.48195.455785.172253@w221.z064000254.bwi-md.dsl.cnc.net> Message-ID: <14984.49127.853606.286789@w221.z064000254.bwi-md.dsl.cnc.net> >>>>> "OB" == Oleg Broytmann writes: OB> I completeley agree that this task *can* be solved using Zope. We can OB> develop data formats, protocols, etc. And I completely disagree OB> that the task *should* be solved with Zope. It shouldn't. I think you skipped my very first suggestion -- to use some simple data format to support exchange between a Zope-based solution and other solutions. OB> Please count current mirrors of CPAN. The figure looks good, OB> isn't it? This is because there are sites that provide FTP OB> mirrors. The CPAN mirrors provide access to the actual libraries, right? That is, you can download mumble.pm from any CPAN mirror. I'm not clear on whether the application being proposed for Python has only the catalog information or also the actual data. If the latter, then an FTP mirror doesn't buy you much. OB> Who will agree to run Zope only to mirror CPyAN? I don't know. I presume we'd need to ask places that are already running Zope. There are at least a couple sites... Jeremy From Lance.Ellinghaus at eConnections.com Tue Feb 27 14: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 bowman at montana.com Wed Feb 21 09: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 barry at digicool.com Fri Feb 2 03: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 dougfort at downright.com Thu Feb 1 20: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 glenfant at equod.com.nospam Mon Feb 12 06:00:40 2001 From: glenfant at equod.com.nospam (Gillou) Date: Mon, 12 Feb 2001 12:00:40 +0100 Subject: mxODBC question References: Message-ID: <968fdg$1pd$1@reader1.imaginet.fr> I use this small module with mxODBC. These functions (selectdict and fetchdict) return a dictionnary of tuples. The keys of the dictionnary are the names of the fields in the 'select' statement. the tuples are the values of the columns. Warning: like these function make a "curs.fetchall()", do not use select statement like "select * from agianttable" or you'll run out of memory. You can use these like below: curs = aconnection.cursor() curs.execute('select name city from people') result = fetchdict(curs) count = len(result['name']) for i in (0, count): print result['name'][i], result['city'][i] or like this if there is no reusable cursor: result= selectdict(aconnection, 'select name city from people') count = len(result['name']) for i in (0, count): print result['name'][i], result['city'][i] "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 MarkH at ActiveState.com Thu Feb 15 23: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 mj at muc.das-werk.de Thu Feb 1 12: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 stephen_purcell at yahoo.com Fri Feb 16 03: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 spahievi at vega.bg Wed Feb 21 17: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 dustin at blacksky.org Sun Feb 4 19:02:46 2001 From: dustin at blacksky.org (J Dustin Flesher) Date: Sun, 4 Feb 2001 17:02:46 -0700 Subject: calldll with Python 2.0 Message-ID: Does anyone have a compiled version of calldll for ActiveState ActivePython 2.0? Has anyone got calldll working with ActiveState Python 2.0? Thank you. From gavin at madzag.com Mon Feb 12 06: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 n8gray at caltech.edu.is.my.email.address Sat Feb 10 00:17:49 2001 From: n8gray at caltech.edu.is.my.email.address (Nathaniel Gray) Date: Fri, 9 Feb 2001 21:17:49 -0800 Subject: python-dev summary, Jan. 16-31 References: <3d4ry56vzg.fsf@ute.cnri.reston.va.us> <95v2lq$hjl$1@slb7.atl.mindspring.net> <95v3mt$lnh$1@nntp9.atl.mindspring.net> <95v5t3$d3q$1@panix3.panix.com> Message-ID: <962j8r$i9i@gap.cco.caltech.edu> Aahz Maruch wrote: > [cc'd to Andrew Kuchling] > > In article <95v3mt$lnh$1 at nntp9.atl.mindspring.net>, > Andrew Dalke wrote: > > > > [...] > > I'm adding a strong "Me, too!" to everything Andrew D. said. Me too, too. > The idea doesn't thrill me, but one possible way to handle this would be > to gateway python-dev to a moderated newsgroup. It sounds like a good idea to me. I'm a bit puzzled by AMK's tone of disappointment with the fact that his summaries haven't generated messages to python-dev. It's never been clear to me that comments from the peanut gallery were appreciated on python-dev. When subscription to a mailing list is advertised as "by invitiation only" and the location of its archives is intentionally obscure, it sends a strong message that outsiders are not welcome. A moderated newsgroup seems like a much better vehicle if you intend for the public to participate in the discussion of Python development without sending the SNR plummetting. I imagine most people would hesitate to post to a moderated newsgroup without having given their message a modicum of thought. (Unlike *most* newsgroups ;^) Nonetheless, a hearty "thank you" to Andrew for taking the time to keep us up to date for so long. -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From dsavitsk at e-coli.net Wed Feb 7 23:23:44 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Wed, 7 Feb 2001 22:23:44 -0600 Subject: ADO/ODBC call via Python/IIS References: <95f558$jgl$1@nnrp1.deja.com> <%FGe6.31314$Ch.7369562@newsrump.sjc.telocity.net> <95sisd$ahc$1@nnrp1.deja.com> <3A81E8B4.2000402@ActiveState.com> Message-ID: > >> And, I'm not clear on what a DSN-less connection is. this isn't going to be technical ... a DSN-less connection is placing the entire DSN file (a text file) in a string and executing it there. There are 3 benefits. One is that if your web site runs on a win32 server, you don't need admin access to set up database access (making hosting simpler and less expensive). The second is that since there is a little less communication with the OS (no searching for or calling DSN files and what not), DSN-Less runs a little faster (I think this is only true for 'small' uses (and i don't know what that means exactly either)). The third is that one doesn't need to create a system/user DSN when installing software. i am not an expert ... or even good at ADO (i'm in law school and computer time is limited), but i have a little Python/ADO/MS Access tutorial (using DSN-Less connection strings) @ www.e-coli.net/pyado.html doug From erno-news at erno.iki.fi Mon Feb 5 12:44:23 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 05 Feb 2001 19:44:23 +0200 Subject: Alpha release of ZODB programming guide References: Message-ID: In article , Andrew Kuchling writes: | What I'd like right now: | * Suggestions for topics that should be covered. This would be | the most helpful. here's one: how does one implement searching? i would have expected the btree objects to have "find key nearest to this" and "next" methods, (like bsddb's set_location)... -- erno From porter at et.byu.edu Sun Feb 25 23: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 hgg9140 at cola.ca.boeing.com Tue Feb 20 09: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 loewis at informatik.hu-berlin.de Fri Feb 2 17: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 fredrik at pythonware.com Tue Feb 27 02: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 andymac at bullseye.apana.org.au Thu Feb 1 15: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 fredrik at pythonware.com Wed Feb 7 14:42:35 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Feb 2001 19:42:35 GMT Subject: im new to python threading question References: <3a81470b$0$16373$7f31c96c@news01.syd.optusnet.com.au> Message-ID: Bill Scherer wrote: > > def funks(s): > > do stuff with f > > > > how do i call def in a new thread and send it args s > > import thread > thread.start_new_thread(funk, (s)) better make that: thread.start_new_thread(funks, (s,)) or even better, use the "threading" module instead. Cheers /F From jdries at mail.com Sun Feb 18 13: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 niessink at serc.nl Tue Feb 13 05: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 thomas at cintra.no Mon Feb 26 06: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 chris at onca.catsden.net Sun Feb 4 15:07:20 2001 From: chris at onca.catsden.net (chris at onca.catsden.net) Date: Sun, 4 Feb 2001 12:07:20 -0800 (PST) Subject: Please translate this easy snip of C++ to Python In-Reply-To: <95kcbo$k8s@dispatch.concentric.net> Message-ID: On 4 Feb 2001, Phlip wrote: > Pythonographers: > > Ogle this awesome snip of C++: > > #define TRACE_(x) cout << #x ": " << x << endl > > When you use that like this: > > TRACE_(y + z); > TRACE_(strAnimals); > TRACE_(__LINE__); > > the program emits this: > > y + z: 12 > strAnimals: Lemmings > __LINE__: 69 > > Mighty healthy and easy to write debug statements with, huh? Saves a lot of > keystrokes, huh? > > How do I do that, just as easy to call, in Python? 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 And... not sure if there's a equivalent of __line__ ("`-/")_.-'"``-._ Ch'marr, a.k.a. . . `; -._ )-;-,_`) Chris Cogdon (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' FC1.3: FFH3cmA+>++C++D++H++M++P++R++T+++WZ++Sm++ ((,.-' ((,/ fL RLCT acl+++d++e+f+++h++i++++jp-sm++ From fredrik at pythonware.com Wed Feb 28 02: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 loewis at informatik.hu-berlin.de Fri Feb 2 17: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 neilt at bigfoot.com Fri Feb 9 12:52:38 2001 From: neilt at bigfoot.com (Neil Timms) Date: Fri, 9 Feb 2001 17:52:38 +0000 Subject: class scope questions References: <3a83bea8$0$16388$7f31c96c@news01.syd.optusnet.com.au> <960m0p0d3r@news2.newsguy.com> Message-ID: <961app$1ei1@imsp212.netvigator.com> Not a real star for this sort of thing but... in the post.. call a is incorrect. a is a class so we don't call it but instaniate it - that is make an object described by a ...thus.. (and we'll call it A by convention because it is a class): (presumes A is already imported) myObject = A() use __init__ and put the variables in there. They are then private (but not totally, there is a way...) to instances of the class A. Attributes (variables of a class instance ) are best only altered by a setter or getter methods = encapsulation.. Now that we have loads of RAM and much speed from the CPUs we can use these conventions for more robust and esier to read/debug code. so we can have: def setDog(anObject): self.dog = anObject or: def getDog(): return self.dog or even more cunning (or not) ... the setter getter def dog(anObject=''): if anObject: self.dog = anObject return self.dog Using the setter/getter version of above - to alter the value of dog we would then: myObject.dog('puppy') # the attribute dog of myObject (of class A) now has the value of 'puppy' to get the value of the attribute dog we would: theValueOfDog = myObject.dog() (sorry just back from finishing a Smalltalk exam - so I'm full of it.). Basically we hide or variables away from direct access and only alter then via methods definind in the class. This restricts the extent of one part of the program interacting with others and causing unintended results (bugs, or in MS speak features), making implementation and maintenance easier - but making us think for the deisgn. cheers Neil From wonkowatson at yahoo.com Thu Feb 8 08:46:54 2001 From: wonkowatson at yahoo.com (John Sands) Date: Thu, 08 Feb 2001 13:46:54 -0000 Subject: Python and JabberCOM Message-ID: <95u80e+g1f3@eGroups.com> I'm trying to use JabberCOM from Python and it isn't working. Here's some code: import win32com.client import pythoncom class JabberEvents: def OnAuthError(self, ErrorText): print "OnAuthError", ErrorText def OnCommError(self, ErrorText): print "OnCommError", ErrorText def OnConnect(self): print "OnConnect" def test1(): jabber = win32com.client.DispatchWithEvents ("JabberCOM.JabberSession", JabberEvents) jabber.Server = "jabber.org" jabber.Username = "WonkoWatson" jabber.Password = "pass" jabber.Resource = "sync" print jabber.Active jabber.DoConnect(0 , 0) pythoncom.PumpWaitingMessages() win32api.Sleep(10000) print jabber.Active test1() print "end" I get no events firing, and the jabber.Active shows 0 both times. If I comment out any of the Server,Username,Password or Resource properties then I get an OnAuthError, so I know the event hook is working. I can execute exactly the same code from VB and I get the OnConnect event in a few seconds: Public WithEvents JSession As JabberSession ... Set JSession = New JabberSession JSession.server = server JSession.username = username JSession.password = password JSession.Resource = "VBJC_Tester" JSession.DoConnect False, jatPlainText Thanks for any advice. From Mike_B at T-Online.de Tue Feb 20 17: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 mfletch at tpresence.com Fri Feb 23 17: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 barry at digicool.com Fri Feb 2 17: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 costas at springmail.com Sun Feb 18 23: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 lvirden at cas.org Fri Feb 23 06: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 dan at eevolved.com Thu Feb 8 17:46:58 2001 From: dan at eevolved.com (Dan Parisien) Date: Thu, 08 Feb 2001 22:46:58 GMT Subject: Python developers of the world unite ;) Message-ID: Maybe the subject line is a little grandiose... :) I'm wondering why there isn't a good web site service out there for reducing the 'reinventing of the wheel' effect that innefficient communication seems to have brought to the python community. I'm not saying what already exists already isn't working, because it is (obviously!) but I feel it could be better... Doesn't anyone feel a sort of CPAN for Python should exist? What about a documentation system not unlike that of PHP (at php.net). User contributed comments embedded into the documentation would reduce the amount of redundant questions posted here and help new users 'get up to speed', don't you think? I just picked up Python a few weeks ago and became an instant evangelist! It's a great language with so many possibilities. I believe in it so much, my business partner and I placed all our chips (so to say) on it, making it the core of our next desktop app. I've marvelled at the beauty of shelve, pickle, lists, dictionaries, python threads, python sockets and all those other modules that make my life (coding) so much easier. Unfortunately, it was harder than it should have been to get information when I ran into non-documented problems. There is a lot of information at python.org, but I feel it isn't very well organized. I hope no one takes offense to this :( Does anyone agree with me? Couldn't it be better? I think python.org should be the central place to go for non-commercial, community supported help and modules. The most important thing would be to make it easy for volunteers to help when they want to. I know a few people who would love to code a great backend/frontend system for python.org just to get their name out... especially that anyone I know who learns python loves it instantly :-) What do you guys think? Dan Parisien From bryan at eevolved.com Tue Feb 20 02: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 fgeiger at datec.at Fri Feb 9 02:01:01 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Fri, 9 Feb 2001 08:01:01 +0100 Subject: ZODB: What does change if classes get persistent? References: <95ti61$2p$1@newsreaderm1.core.theplanet.net> <3d1yt96vd0.fsf@ute.cnri.reston.va.us> Message-ID: <9604jg$76v$1@newsreaderm1.core.theplanet.net> Thank you, Andrew, that did the trick! Best regards Franz "Andrew Kuchling" wrote in message news:3d1yt96vd0.fsf at ute.cnri.reston.va.us... > "Franz GEIGER" writes: > > class TCarts(TCollection, Persistence.Persistent): > > def __init__(self): > > TCollection.__init__(self) > > > > TCollection.__init__(self, self) > > TypeError: unbound method must be called with class instance 1st argument > > > > upon creation. > > > > Does anybody know what's going on here behind the scenes? > > Ooh, something I forgot to cover. TCarts is no longer a regular > Python class, but an ExtensionClass; this breaks the usual convention > for calling superclass constructors. (Does Python 2.1 try to fix this? > Anyone from DC know?) > > Anyway, the fix would be to use this instead: > TCarts.inheritedAttribute('__init__')(self) > > See http://www.digicool.com/releases/ExtensionClass/ for a lengthier > discussion (search for __init__). > > > File "C:\Program Files\Python20\ZODB\lock_file.py", line 115, in lock_file > > raise error, (StorageSystemError: Could not lock the database file. > > There must be another process that has opened the file. > > Use ZEO if you need to have multiple processes accessing data at the > same time. The lowest-level class, the Storage class, isn't written > to handle concurrent access to the same files. You probably couldn't > run two completely different instances of Oracle and point them at the > same disk partitions, either, and the ZODB's storages impose similar > limitations. > > --amk From phrxy at csv.warwick.ac.uk Sun Feb 11 18:07:51 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Sun, 11 Feb 2001 23:07:51 +0000 Subject: retry in try:...except: In-Reply-To: References: Message-ID: On Sun, 11 Feb 2001, Dan Parisien wrote: > Does something like this exist > > def getval(self, key) > try: > return self.__keys[key] > except KeyError: > self.__keys[key] = None > retry #!!!! [...] For this particular case, >>> foo={"eggs": 1} >>> print foo.get("eggs") 1 >>> print foo.get("spam") None But maybe you had another example in mind that this doesn't apply to? John From mix77 at usa.net Fri Feb 16 08: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 andi at opencan.cc Sat Feb 10 16:06:12 2001 From: andi at opencan.cc (Andreas Poisel) Date: 10 Feb 2001 21:06:12 GMT Subject: Vim and python efficiently References: Message-ID: <964ag4$c4d$1@news.tuwien.ac.at> Viktor Lakics wrote: > Hi All, > I would like to collect the tips, hints and macros, regarding how to edit python > sorce code in vim. I mean stuff like macros for commentify, > uncommentify, bracket and keyword autocomlpletion, python style > indenting, etc. (I know that all this exist in IDLE, but I like vim > very much and I do not like to use different editors for different > languages... [...] Hi Viktor, I really like your idea of a python + vim HOWTO. I'm not a vim expert, but I have some small pieces of python code I use in vim, maybe it's useful for you: I use this function to get a list of the python functions in the current buffer with their line numbers: def Functions(fname): print"----------------------------------------------------------------" cbuffer= vim.current.buffer zn= 0 for line in cbuffer: zn= zn+1 if re.compile(fname).search(line): print "%s %s" % (string.strip(line), zn) I call it with map :py Functions("def ") from my .vimrc Sometimes I work with files containing similar large functions. I use this one to get the name of the function the cursor is in: def thisFunc(str): cbuffer= vim.current.buffer cwindow= vim.current.window (line, column)= cwindow.cursor lnr= line-1 while (lnr > 0): line= cbuffer[lnr] if string.find(line, str) != -1: print string.strip(line) break lnr= lnr-1 I call it with map :py thisFunc("def ") from my .vimrc This one is a classbrowser using tkinter and Pmw. Its an ugly hack and I'm sure it's buggy (I don't know, because I don't use this) but somehow it works. You can navigate through buffers and classes by doubleclicking their names and jump to a buffer/class/method by klicking the "go" button or doubleclicking on a methods name. class ClassBrowser: def __init__(self, kid, mid): sys.argv= ["/home/andi/vim/avim.py"] self.mid= mid self.kid= kid self.methDia= None self.claDia= None self.buffers= [] self.getBuffer() self.root= Tk() Pmw.initialise() self.erzeugPanes() self.BufferBrowser() self.root.mainloop() def erzeugPanes(self): self.pane= Pmw.PanedWidget(self.root, hull_width= 650, hull_height= 300, orient= HORIZONTAL) self.pane.add("buffer", size= 200) self.pane.add("classes", size= 200) self.pane.add("methods", size= 200) self.pane.pack(expand= YES, fill= BOTH) def getClasses(self): self.classes= [] self.cladict= {} self.lnrdict= {} lnr= 0 for line in vim.current.buffer: lnr= lnr+1 if re.compile(self.kid).search(line): kl= string.strip(line) self.classes.append(kl) self.cladict[kl]= [] self.lnrdict[kl]= lnr elif re.compile(self.mid).search(line): me= string.strip(line) try: self.cladict[kl].append(me) except NameError: ff= "Functions" try: self.cladict[ff].append(me) except KeyError: self.lnrdict[ff]= lnr self.classes.append(ff) self.cladict[ff]= [] self.cladict[ff].append(me) self.lnrdict[me]= lnr def getBuffer(self): bnr= 1 for buffer in vim.buffers: self.buffers.append("%s %s" % (bnr, os.path.basename(buffer.name))) bnr= bnr+1 def goMethod(self): m= "%s" % self.methDia.getcurselection() lnr= "%s" % self.lnrdict[m] vim.command(lnr) def goClass(self): k= "%s" % self.claDia.getcurselection() lnr= "%s" % self.lnrdict[k] vim.command(lnr) def goBuffer(self): b= string.split("%s" % self.bufDia.getcurselection()) vim.command("b%s" % b[0]) def BufferBrowser(self): self.bufDia= Pmw.ScrolledListBox(self.pane.pane("buffer"), listbox_selectmode= SINGLE, labelpos= NW, usehullsize= 1, hull_width= 200, hull_height= 200, label_text= 'Buffers:', items= self.buffers, selectioncommand= self.goBuffer, dblclickcommand= self.ClassBrowser) self.bufDia.pack(expand= 1, fill= BOTH, padx= 5, pady= 5, side= LEFT) Button(self.root, text= "go!", command= self.root.destroy).pack(side= RIGHT, anchor= S) def ClassBrowser(self): self.getClasses() if self.methDia: self.methDia.destroy() self.methDia= None if self.claDia: self.claDia.destroy() self.KlaDia= None self.claDia= Pmw.ScrolledListBox(self.pane.pane("classes"), listbox_selectmode= SINGLE, labelpos= NW, usehullsize= 1, hull_width= 200, hull_height= 200, label_text= 'Classes:', items= self.classes, selectioncommand= self.goClass, dblclickcommand= self.MethodBrowser) self.claDia.pack(expand= 1, fill= BOTH, padx= 5, pady= 5, side= LEFT) def MethodBrowser(self): if self.methDia: self.methDia.destroy() self.methDia= None self.methDia= Pmw.ScrolledListBox(self.pane.pane("methods"), listbox_selectmode= SINGLE, labelpos= NW, usehullsize= 1, hull_width= 200, hull_height= 200, label_text= 'Methods:', items= self.cladict["%s" % self.claDia.getcurselection()], selectioncommand= self.goMethod, dblclickcommand= self.root.destroy) self.methDia.pack(expand= 1, fill= BOTH, padx= 5, pady= 5, side= LEFT) I invoke this one in the .gvimrc: map :py ClassBrowser("class ", "def ") Maybe you can use this somehow. -- Andi From dsh8290 at rit.edu Thu Feb 15 20: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 hgg9140 at cola.ca.boeing.com Wed Feb 28 09: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 bsass at freenet.edmonton.ab.ca Tue Feb 27 03:22:34 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Tue, 27 Feb 2001 01:22:34 -0700 (MST) Subject: CPAN functionality for python In-Reply-To: <20010226182601.D7531@tummy.com> Message-ID: On Mon, 26 Feb 2001, Sean Reifschneider wrote: > On Mon, Feb 26, 2001 at 02:56:51AM -0700, Bruce Sass wrote: > >Do you mean: > > Ideally, it would be able to deal with both. The ability to download > a distutils package and produce a .deb or a .rpm is more a function of > the client program than of the archive network... It also largely depends > on distutils as well. So we are thinking along the same lines. > >As for the second... it seems like an awful waste of archive space to > >have the same code in many different formats, just because some want > >to put stuff in /usr/share and others in /usr/lib, etc. > > I'm really not familiar with .deb packages. Howeer, for RPMs, if the > author has included a .spec file in the tar file, you can simply run > "rpm -ta foo.tar.gz" and the results will (should) be a compiled binary > RPM. That is, if the author of the package has thought ahead about > producing an RPM. In a nutshell... Debian's equivalent of a .spec is the "debian" subdir in the source tree, containing administrivia and a "rules" makefile; doing "debian/rules" compiles, "debian/rules binary" compiles and packages, "debuild" compiles, packages and checks the package for errors and conformance to Policy. There can be a lot more to it, but nothing the author needs to worry about, in fact the author does not need to know anything about Debian. There are tools that create the debian dir and pull information from the source tree to customize the package, it is very easy to script so it can debianize anything thrown at it - provided the source tree is reasonably consistent. > The question becomes: Is it reasonable to require authors of packages > for the archive network to do the same? Convince me it is... No, it isn't. The authors should not need to know anything about the final format of their module, just that they need to provide specific pieces of information if they want to be included in the network (imo). Hmmm, so RPM based systems don't have a way to automatically generate a .spec file from a source tree... that would be a must. - Bruce From craigf at ilid.com.au Mon Feb 5 00:52:31 2001 From: craigf at ilid.com.au (Craig Findlay) Date: Mon, 05 Feb 2001 16:52:31 +1100 Subject: Socket woes and signals Message-ID: <3dfs7tkv4g6ulmeng4a1pnf94b1dfak2rd@4ax.com> I am writing a simple socket server on an OpenBSD machine, and I would like to program the following functionality: If I send the server a SIGTERM signal, I want it to break out of the loop that it is in, and close gracefully. The loop is basically the standard: while 1: conn, addr = s.accept() data = conn.recv(bufsize) if not data: break do something with data conn.close() Q. This is fine if the client closes the connection, but how do I break out of the look in response to say a signal? If I force the loop to end ungracefully, the socket is left hanging and I have to reboot the machine to free it up. But the code normally stops at the accept line until a connection is accepted, so how do I close the socket properly in that state? Craig From sean at digitome.com Sat Feb 10 11:24:49 2001 From: sean at digitome.com (Sean Mc Grath) Date: Sat, 10 Feb 2001 16:24:49 GMT Subject: XML processing in Python -- changing horses in mid-stream References: Message-ID: <3a8563ae.3383090887@news.iol.ie> Tim, How big are the test scripts / test results? If the sizes are manageable I would suggest looking at Pyxie Tree processing. While processing a tree T, you can create another tree, T1 with the results of running the second test script, you can then use the Paste functions to paste the new tree into the existing one. If size is a problem, you might like to look that the Sparse Tree Processing stuff in Pyxie that allows you to switch from event processing to tree processing as needed. Sean On Sat, 10 Feb 2001 14:50 +0000 (GMT Standard Time), digitig at cix.co.uk (Tim Rowe) wrote: >I have a Python program that parses a test script written in XML and puts >the test results to stdout in XML (with a different DOCTYPE). > >I also have a Python program that takes the test result XML and processes >it for graphical presentation. > >Here's my challenge. If the second program were given a test script >instead of results, I would like it to recognise the different doctype, >run the tests and process the results all in one. > >When my result parser spots a test script I should be able to pass the >script to the test program via a pipe, put the results of the test through >a new result parser, and copy anything relevant from the new result parser >to the old one. But can I stop the old result parser parsing the rest of >the test script? > >I plan to use either expat or pyxie, whichever is easiest. > >TIA. > > From aleaxit at yahoo.com Mon Feb 26 14: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 cfelling at iae.nl Sun Feb 18 15: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 moshez at zadka.site.co.il Tue Feb 6 07: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 n8gray at caltech.edu.is.my.email.address Fri Feb 16 01:15:31 2001 From: n8gray at caltech.edu.is.my.email.address (Nathaniel Gray) Date: Thu, 15 Feb 2001 22:15:31 -0800 Subject: PEP status and python-dev summaries References: <962pdj$kb0@gap.cco.caltech.edu> <96ahvl$lo@gap.cco.caltech.edu> <96bv80$4dg$1@panix6.panix.com> Message-ID: <96igt0$dao@gap.cco.caltech.edu> Aahz Maruch wrote: > In article <96ahvl$lo at gap.cco.caltech.edu>, > Nathaniel Gray wrote: > > > >I guess that would provide _some_ reason to read c.l.py.announce. :^) > > > >Since we're likely to want to discuss PEPs, it seems like c.l.py would be > >more appropriate. > > My personal preference would be a x-post to c.l.py and c.l.py.announce, > with followups to just c.l.py. (Essentially, exactly the same way > news.announce.newgroups and news.groups work.) Even better. -n8 -- _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ Nathaniel Gray California Institute of Technology Computation and Neural Systems n8gray caltech edu _.~'^`~._.~'^`~._.~'^`~._.~'^`~._.~'^`~._ From jeremy at alum.mit.edu Fri Feb 16 12: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 dsh8290 at rit.edu Tue Feb 27 20: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 benpark at my-deja.com Thu Feb 8 10:19:33 2001 From: benpark at my-deja.com (Ben Park) Date: Thu, 08 Feb 2001 15:19:33 GMT Subject: i/o for NumPy Message-ID: <95uddp$q35$1@nnrp1.deja.com> What are the unformatted i/o functions in NumPy? I see fromstring, but you have to read the binary data into a string first and then transfer to an array. What I am looking for is something like fread/fwrite in Matlab, or readu/writeu in IDL. Sent via Deja.com http://www.deja.com/ From fredrik at pythonware.com Mon Feb 26 14: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 tuttledon at hotmail.com Wed Feb 14 18: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 zdweeb at hotmail.com Tue Feb 13 20: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 gwilder at best.com Wed Feb 28 14: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 tim.one at home.com Sat Feb 17 00: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 stephen_purcell at yahoo.com Tue Feb 13 03: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 aahz at panix.com Sat Feb 17 21: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 akuchlin at mems-exchange.org Fri Feb 9 10:07:10 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 09 Feb 2001 10:07:10 -0500 Subject: urllib.open('http://www.redherring.com/') References: <95th67$36j$1@nnrp1.deja.com> <95tj33$4g1$1@nnrp1.deja.com> <3A825A68.B1023097@intertrader.com> <95tq9r$afs$1@nnrp1.deja.com> <9607c5$bkj$1@nnrp1.deja.com> Message-ID: <3ditmj99pd.fsf@ute.cnri.reston.va.us> apederse at my-deja.com writes: > to me it looks like the problem lies whithin python itself? is there any > point in reporting such bugs when everyone will soon be using python 2.0 > anyway? I don't believe urllib or httplib were massively rewritten for 2.0 (nor will they be in 2.1), so if it's a bug, it's probably still there. On the other hand, if you try it with 2.0 and it works fine, then there won't be much interest; a 1.5.3 release is not going to happen. --amk From gst at sysfrog.org Sat Feb 17 15: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 tjg at exceptionalminds.com Wed Feb 7 20:17:47 2001 From: tjg at exceptionalminds.com (Timothy Grant) Date: Wed, 7 Feb 2001 17:17:47 -0800 Subject: ARP Anyone? Message-ID: <20010207171747.E27007@trufflehunter.avalongroup.net> Hi all, Has anyone ever done anything with ARP and Python? I'm looking for a way to track new workstations on a network (before they ever get an IP address) using python. -- 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: 22 days 5:29 hours ago<< From erno-news at erno.iki.fi Wed Feb 7 23:15:21 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 08 Feb 2001 06:15:21 +0200 Subject: newbie question References: <3A820E6B.CB29AFBC@dsuper.net> Message-ID: In article <3A820E6B.CB29AFBC at dsuper.net>, Denis Laroche writes: | Hello Python enthusiasts, | I just started to learn the language this week. | Could someone tell me how to recreate a list or a dictionary object from | its string representation obtained with repr(). you can't do that in general, but if you only put objects that have a eval()-able string representation inside your list/dictionary, you can use eval(). >>> l = [1, 2] >>> eval(repr(l)) == l 1 >>> l = [sys.stdout, l.append] >>> eval(repr(l)) == l Traceback (innermost last): File "", line 1, in ? File "", line 1 [', mode 'w' at 804ab68>, ] ^ SyntaxError: invalid syntax if you want to serialize stuff, the pickle module is more suited to that (although it can't handle files and such either). -- erno From aleaxit at yahoo.com Thu Feb 22 12: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 rytrom at zoote.com Wed Feb 14 07: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 aahz at panix.com Fri Feb 9 16:59:41 2001 From: aahz at panix.com (Aahz Maruch) Date: 9 Feb 2001 13:59:41 -0800 Subject: PEP status and python-dev summaries References: <3dg0hn8zlr.fsf@ute.cnri.reston.va.us> <3A844423.8AF2B87A@intertrader.com> <3dd7cr8rsl.fsf@ute.cnri.reston.va.us> Message-ID: <961p8d$scs$1@panix3.panix.com> In article <3dd7cr8rsl.fsf at ute.cnri.reston.va.us>, Andrew Kuchling wrote: > >python-dev is the equivalent of perl5-porters. However, Perl hasn't >previously had a formal mechanism such as PEPs; a bunch of RFCs were >written for Perl 6, but who knows if such formality will continue once >actual development starts? It seems like a curious cultural >difference; c.l.python posters often suggest new language features, >while in the Perl and Tcl groups, there are very few postings which >suggest language changes. I can't speak for Tcl, but in the case of Perl, there are few enough people outside the core development group who actually understand Perl to suggest changes in the language. -- --- 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 footech at get2net.dk Fri Feb 23 07: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 mwh21 at cam.ac.uk Wed Feb 7 16:44:34 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 07 Feb 2001 21:44:34 +0000 Subject: Python wierdness References: Message-ID: "Roger H" writes: [snip] > >>> x = 0.3 > >>> > >>> # Let's check whether x modulo 0.1 is equal to 0.1: > ... > >>> x % 0.1 > 0.1 > >>> > >>> # Obviously, x modulo 0.1 is indeed equal to 0.1. > ... # If we pass it to foo(), we should see "bar", right? [snip] > What's going on here, and how could one get around it? Floating point is going on here. Python 2.0 is more helpful in this regard: >>> 0.3 % 0.1 0.099999999999999978 >>> 0.1 0.10000000000000001 >>> 0.3 % 0.1 - 0.1 -2.7755575615628914e-17 Comparing floats for equality is always fraught. Enjoy :-) (I may be a mathematician, but you aren't going to catch me doing numerical analysis...) Cheers, M. -- I'd certainly be shocked to discover a consensus. ;-) -- Aahz Maruch, comp.lang.python From sheila at spamcop.net Tue Feb 6 02:37:23 2001 From: sheila at spamcop.net (Sheila King) Date: Tue, 06 Feb 2001 07:37:23 GMT Subject: how to send email in python? References: <3A7FA5BA.82FB7593@esec.com.au> Message-ID: On Tue, 06 Feb 2001 18:20:26 +1100, Sam Wun wrote in comp.lang.python in article <3A7FA5BA.82FB7593 at esec.com.au>: :does anyone knows? I am using python 1.6. Here is one way: ------------------------------------------- import smtplib def readManyLines(): """Read lines from the user until they enter a line with a single period, and return a single string.""" result = "" while 1: line = raw_input() if line == '.': return result result = result + line + "\n" servername=raw_input("SMTP server name: ") Fromaddress=raw_input("From address: ") Toaddress=raw_input("To address: ") print "Enter your message. To end, enter a line that begins with a" print "period and has no other characters: " MessageText=readManyLines() server=smtplib.SMTP(servername) server.sendmail(Fromaddress, Toaddress, MessageText) server.quit() ------------------------------------------- Note: This is very crude. When it runs, it will prompt you for a smtp server. You input that data. This doesn't handle any type of authorization (I don't know how SMTP authorization is done in Python. None of the examples for SMTP that I've seen deal with authorization.)' Then it prompts you for a From and To address. These are not the headers that go in the message body. They are part of the message envelope. When you enter the message body, you will have to type all the e-mail headers yourself. Enter a period at the beginning of the line to get the program to finish execution (stop looping) and send off the e-mail. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From tjg at exceptionalminds.com Sun Feb 25 20: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 db3l at fitlinxx.com Wed Feb 21 01: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 robin at jessikat.fsnet.co.uk Fri Feb 23 04: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 hannah at schlund.de Thu Feb 8 13:06:25 2001 From: hannah at schlund.de (Hannah Schroeter) Date: 8 Feb 2001 19:06:25 +0100 Subject: Is Python "Compiled"? References: <3a81ad07_3@goliath2.newsfeeds.com> <5Iig6.1295$D3.5361@tor-nn1.netcom.ca> <95ug7b$qp0$1@c3po.schlund.de> Message-ID: <95un71$alp$1@c3po.schlund.de> Hello! In article , Steve Holden wrote: >[...] >Well, LISP is kind of special: the typical list representation and >car()/cdr() operations are pretty efficient if properly compiled. But most >interpreted languages A language can't be classified as interpreted or compiled. Implementations can be. Lisp has one implementation (e.g. sbcl) which can both interpret, compile to bytecode or compile to native code. Another implementation (e.g. clisp) can only interpret or compile to bytecode. There could be an implementation that would only do minimal compilation (only that which is required by the standard, mostly macro expansion) and would thus be an almost only interpreting implementation. Yet another possibility would be compiling everything to native, even forms from the interactive REPL. >end up "compiling" down into calls to the interpreter >bytecode routines, which doesn't save much space or time. That was certainly >true for Icon, anyway, and I suspect would be for other similar languages. Again, that's a property of implementations, not of languages. Sure, some languages might be especially difficult to compile to efficient native code (or efficient bytecodes), others make it easier. >JIT might or might not be a win for Python, but programs would still end up >lugging a lot of support code around, Support code, yes. Many (esp. the free ones) Lisp systems don't create standalone executables but images to be run with the runtime, which provides low level functionality like image loading, GC, low level object representation, predefined functions (as long as they are not implemented in Lisp themselves). Many Smalltalk implementations do the same, and still, that's no hinderance in using native processor instructions in the image file, amounting to more than just calling one runtime function after the other. >and without static typing a lot of >decisions still have to be deferred until run-time. See again Smalltalk. That's an area where many gains are possible to make. One is static analysis: if, in a method call x.y(), the compiler can infer that the type of x is A, the compiler can statically code a call to A's y() method. If the compiler knows that x can be of two types B or C, it can code something like if (typeof(x) is B) call B's y() method else call C's y() method which on many processors is even faster than C++'s vtables (one indirect jump), because for many branch prediction units, indirect jumps are poison. (The SmallEiffel people do *all* method dispatches using such a technique and found the break even point [where vtable would be better] to be over around 50 possible object types). The other comes from the JIT world. At precompilation time, code an instrumented method call: runtime_call_method(x, "y", (no arguments)) That can gather evidence about the real call patterns (i.e. which methods get really called for how often), after some time, it will change that code to something resembling that evidence: call B's checked y() method where B's checked y() method is: 1: if (typeof(self) is NOT B) jump out to the runtime system indicating the type mismatch, passing self to the RTS for re-dispatching 2: here, the real code of the y() method follows. (i.e. methods are two-entry-point functions, the first is the checked entry point, the second is unchecked [compiler is statically sure about the type) The code after 1 can usually translated to less than a handful of machine instructions. >regards > Steve Kind regards, Hannah. From chris.gonnerman at usa.net Sat Feb 24 01: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 syver at NOSPAMcyberwatcher.com Thu Feb 15 07: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 phd at phd.pp.ru Wed Feb 21 05: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 max at alcyone.com Sun Feb 18 18: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 mwh21 at cam.ac.uk Fri Feb 2 12: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 tim at vegeta.ath.cx Tue Feb 27 17: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 ben.hutchings at roundpoint.com Wed Feb 28 20:05:28 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 28 Feb 2001 17:05:28 -0800 Subject: How do I load a .png graphic file into a dialog in Irix? References: <97jjqh$ct3$1@paperboy.CORP.Softimage.COM> Message-ID: "motif" writes: > Im try to load a .png file in Irix,. Im habe to load it, he program don't > display it. > whats the problem? What makes you think it has anything to do with Python? -- Any opinions expressed are my own and not necessarily those of Roundpoint. From mikael at isy.liu.se Wed Feb 21 10: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 m.faassen at vet.uu.nl Sun Feb 11 18:33:35 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 11 Feb 2001 23:33:35 GMT Subject: Is Python for me? References: <965041$618$1@nnrp1.deja.com> <20010211002236.20899.00000455@ng-fr1.aol.com> Message-ID: <9677gf$brc$3@newshost.accu.uu.nl> DvdAvins wrote: [snip] > I do have programming experience, but the vast majority of my work has been > LotusScript (an OO variant of VB) or Domino/Notes's @Formula language > (which has lovely list operations and can *almost* be made to behave like a > real language, despite its total lack of a looping/iteration construct). > I've also written production code in Javascript and Sybase's stored > procedure language (T-SQL is the name, if I remember right). On top of that, > I fiddled around a little in Java recently and C, Fortran, and Pascal > in the distant past. Given this background, Python would be among the languages easiest to learn for you. It's a breath of fresh air to step away from application specific scripting languages to a general one, I imagine, and it's still far higher level than Java, and definitely C, Fortran or Pascal. If you're interested in object oriented programming techniques Python is a very nice language to help learn about them as well. Given your background Python may also be intereresting if you want to learn about how to scale your applications up to larger sizes, while you still don't lose easy integration abilities with all kinds of external systems (databases, GUI toolkits, etc). > But the point here is to use something I'm *not* familiar with and something > that will help me think in new ways. I imagine there will be enough to learn that you're not familiar with in Python. But if this is really a big goal of yours then a functional language may be more suitable. Python has some properties of functional languages but is not really one itself. > The project is a non-animated game. To a less technical audience, I'd say > "non-graphical", but I will use a GUI. The game will rely on an extensive > database of actual historical information, but that database will be > updatable and even replacable by the user. > Therefor I imagine I'll use CSVs rather than write > a custom import/export interface. I don't think I'll need the performance of an > RDBMS. If you're interested in learning new things, you could also look into the Zope Object Database that you can use with Python, or just the plain 'pickle' module that comes with the Python standard library. > Incidentally, there are similar programs out there now, but they rely on > proprietary data formats. My innovation would be to sell people the game > without making them have to pay me to update the data. Makes me curious about what the game could be. Historical information? > The first iteration of the game will be, as you say, a cross-platform GUI > application, but there is also a market for a web-based version. Python is good at glueing all kinds of components together, probably better than most of the other languages you're looking at. So if this is a criterion you should look at Python. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From wolfgang.grafen at marconi.com Wed Feb 21 14: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 timr at probo.com Thu Feb 1 23: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 f8dy at my-deja.com Wed Feb 7 21:28:15 2001 From: f8dy at my-deja.com (Mark Pilgrim) Date: Thu, 08 Feb 2001 02:28:15 GMT Subject: String formatting characters - looking for details References: <3a81cfa2.1708851@news.muenster.de> <6Pkg6.39716$o5.497716@e420r-atl1.usenetserver.com> Message-ID: <95t07p$m5g$1@nnrp1.deja.com> In article <6Pkg6.39716$o5.497716 at e420r-atl1.usenetserver.com>, "Steve Holden" wrote: > "Martin Bless" wrote in message > news:3a81cfa2.1708851 at news.muenster.de... > > (1) Where can I find some more details about the string formatting > > characters? > > (2) How I print hex values with zeros padded left, like 0F or 0A? > > print '%X' % 15 # two digits, wanted > > 1. If you have a UNIX system handy, the man page on printf(3) will tell you And if you don't, it's Google to the rescue! Search for "printf format identifiers". I found lots of very useful pages, like this one: http://www.cs.huji.ac.il/support/docs/reference/C/FUNCTIONS/format.html -M -- You're smart; why haven't you learned Python yet? http://diveintopython.org/ Sent via Deja.com http://www.deja.com/ From Mike_B at T-Online.de Sun Feb 18 17: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 fellowsd at cs.man.ac.uk Mon Feb 19 05: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 aahz at panix.com Thu Feb 8 12:58:42 2001 From: aahz at panix.com (Aahz Maruch) Date: 8 Feb 2001 09:58:42 -0800 Subject: None assigment References: Message-ID: <95umoi$is5$1@panix2.panix.com> In article , Gregoire Welraeds wrote: > >Always according to this logic, I have tried to run the following: > >>>> a= [1,'',3] >>>> b= 0 # b could be anything >>>> del b >>>> filter(b,a) > >but this won't work either as stated in the documentation. Referencing a >"deleted" variable is an error at least until another value is assigned to >it (see del statement section in the tutorial). > >It seems that (the so called variable) None is neither a variable like any >other, nor is it a label as stated by Simon Brunning in another post. What you're missing is the issue of Python scopes. Try this: b=2 def foo(): b=4 print b del b global b print b foo() None has a bit of magic associated with it, but not much. -- --- 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 joe at al.com.au Mon Feb 26 01: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 p.g at figu.no Thu Feb 15 19: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 spamers at must.die Wed Feb 21 14: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 gtalvola at nameconnector.com Thu Feb 1 19: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 nas at arctrix.com Fri Feb 23 09: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 embed at geocities.com Wed Feb 28 10: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 bowman at montana.com Mon Feb 19 09: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 mwh21 at cam.ac.uk Thu Feb 15 11: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 tim.one at home.com Thu Feb 22 01: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 MarkH at ActiveState.com Fri Feb 16 18: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 hamish_lawson at yahoo.co.uk Mon Feb 12 15: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 emile at fenx.com Sat Feb 10 17:56:49 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 10 Feb 2001 14:56:49 -0800 Subject: CGIHTTPServer References: Message-ID: <964h29$j9l7o$1@ID-11957.news.dfncis.de> I find Zope an easy to deploy alternative for simply running scripts under NT. Download and install the Zope software. I generally install it to run as a service under NT. Browse to the manage interface, set up a new user with Owner and Manager roles selected (highlight them in the list). Put a sample.py in the extensions directory, something like: def sample(self, REQUEST=REQUEST): "function doc string required by zope" return "There's no such thing as the P.S" Then, sign back in to manage Zope as the new user. Add a new external method and specify sample for each of the fields. Now you should be able to browse to http://localhost/sample and see the return value. Changes to your function are reflected immediately by Zope without further intervention. I sometimes need to go into zope and update the external method, but I'm unclear as to what kind of changes require this (cache/reload?). I'm not sure if this is what you were after, but perhaps it helps. -- Emile van Sebille emile at fenx.com ------------------- "R?schmann, Thies" wrote in message news:mailman.981842112.10482.python-list at python.org... > Hello, > > How can I configure my own CGIHTTPServer from Python1.5.2-Lib to run my > Python-scripts on WinNT4.0? > Or, > how can I set the world-executable and world-readable bits like this: > "chmod ugo+rx myfile.py" > > Thanks for your help, > Thies > From not.this at seebelow.org Mon Feb 19 15: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 Max.Haas at unibas.ch Tue Feb 27 05: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 aleaxit at yahoo.com Mon Feb 26 11: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 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 dalke at acm.org Mon Feb 5 13:36:52 2001 From: dalke at acm.org (Andrew Dalke) Date: Mon, 5 Feb 2001 11:36:52 -0700 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: <95mru3$2ar$1@slb2.atl.mindspring.net> Rainer Deyke: > ComputerExplodingError is one of the "hidden" exception > of the Underground of Pythonic Secrecy (UPS), created in > response to the much cooler names of rival groups Secret > Pythonic Underground (SPU) amd Pythonic Secret Underground > (SPU). It is raised automatically when a computer "goes > postal". The proper response is to panic and scream a > lot. This is done automatically by the interpreter when > stack unwinding is complete. And if you have sound support then the computer says "I'm sorry %{USER}s, I can't do that right now" % os.environ if os.environ.has_key("USER"), else it plays "Daisy, Daisy, give me your answer true" But I don't actually know this since I'm not a member of From akuchlin at mems-exchange.org Tue Feb 6 15:56:02 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 06 Feb 2001 15:56:02 -0500 Subject: Python 2.1a2 compile problems References: <95pfsu$ht1$1@nnrp1.deja.com> Message-ID: <3dpugvh6ot.fsf_-_@ute.cnri.reston.va.us> sgriggs at pobox.com writes: > Here's a small amount of the output. I've also tried to compile on 2.6 > and 2.7 with no luck. > > building 'sunaudiodev' extension > skipping /var/tmp/Python-2.1a2/Modules/sunaudiodev.c > (build/temp.solaris-2.8-sun4u-2.1/sunaudiodev.o up-to-date) > gcc -shared build/temp.solaris-2.8-sun4u-2.1/sunaudiodev.o > -L/usr/local/lib -o build/lib.solaris-2.8-sun4u-2.1/sunaudiodev.so > Text relocation remains referenced > against symbol offset in file > 0x174 > build/temp.solaris-2.8-sun4u-2.1/sunaudiodev.o > 0x17c > build/temp.solaris-2.8-sun4u-2.1/sunaudiodev.o Confirmed. This isn't specific to the sunaudiodev module; the struct module doesn't compile for me for similar problems. The errors are triggered by the gcc -shared invocation, like this: gcc -shared build/temp.solaris-2.6-sun4u-2.1/sunaudiodev.o -L/usr/local/lib -o build/lib.solaris-2.6-sun4u-2.1/sunaudiodev.so Did some compiler argument change? --amk From craigf at ilid.com.au Tue Feb 6 18:46:21 2001 From: craigf at ilid.com.au (Craig Findlay) Date: Wed, 07 Feb 2001 10:46:21 +1100 Subject: Socket woes and signals References: <3dfs7tkv4g6ulmeng4a1pnf94b1dfak2rd@4ax.com> <95mobi$q44$1@nntp6.u.washington.edu> Message-ID: Donn Cave wrote: >But in any event, when the process that bound the socket exits, with >any luck the bound port should close and you won't need to reboot >the computer. When it gets like that, you probably aren't going to >solve everything with a SIGTERM anyway. It couldn't hurt to turn >on the SOL_SOCKET attribute SO_REUSEADDR (see setsockopt.) Thanks Don for your help. I'll do some reading and some more playing :) Cheers, Craig From mlh at idi.ntnu.no Fri Feb 2 22: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 kwasi007uk at yahoo.co.uk Fri Feb 2 19:39:57 2001 From: kwasi007uk at yahoo.co.uk (kwasi007uk at yahoo.co.uk) Date: Sat, 03 Feb 2001 00:39:57 -0000 Subject: Wish there was an error message Message-ID: <95fk0t+uu67@eGroups.com> I was using poplib's example as in the documentation. Unfortunately I typed in the following at the end of the script: M.quit instead of M.quit()! I forgot the parenthesis. The effect was, that my pop-server produced really strange things, doubled the number of messages each time I queried it with poplib. But M.quit does not exist. So it should give me an error message? Why doesn't it? Can I turn it on somehow? From dvoitenko at qode.com Wed Feb 14 11: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 jcollins at endeavors.com Tue Feb 27 13: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 spamfranke at bigfoot.de Wed Feb 28 12: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 thomas at cbs.dtu.dk Tue Feb 20 12: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 ben.hutchings at roundpoint.com Thu Feb 1 16: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 bowman at montana.com Sun Feb 18 11: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 Pekka.Pessi at nokia.com Sun Feb 4 19: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 tim.one at home.com Sun Feb 18 12: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 max at alcyone.com Fri Feb 23 11: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 loewis at informatik.hu-berlin.de Sat Feb 3 06:34:16 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 03 Feb 2001 12:34:16 +0100 Subject: Will nested scoping break restricted execution ?? References: Message-ID: "Tim Peters" writes: > [rturpin at my-deja.com] > > I thought that the restricted execution module functioned > > partly by controlling the builtin, local, and global > > namespaces. > > Right. Actually wrong, I think. It does not control local and global namespaces. Instead, it controls what names you can get from elsewhere. I.e. you can't prohibit a program doing socket = 1 but you can prevent that it does import socket although either code creates a socket variable, from a local and global namespace point of view. Likewise, you can prevent the code from doing import socket as string even if importing "string" is allowed, as long import "socket" is not. > My offhand *opinion* is that it's darned hard to see any way in > which it could hurt at all: there's nothing you can do with nested > functions that you couldn't do before with classes and instance > data. Exactly. Furthermore, with the current code, rexec operates on a per-module basis: r_exec, r_execfile etc always take an entire module code, and execute it restrictedly (which sometimes means that they create a new __main__ to do so). So there never is a need to prevent restricted code from accessing its global variables. I believe there isn't a way to prevent restricted code from accessing a specific __builtin__, either - instead, you have to provide alternative or missing versions of the builtins in advance. Regards, Martin From dsh8290 at rit.edu Thu Feb 8 12:36:00 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 8 Feb 2001 12:36:00 -0500 Subject: None assigment In-Reply-To: ; from greg@perceval.be on Thu, Feb 08, 2001 at 06:12:27PM +0100 References: Message-ID: <20010208123600.A12837@harmony.cs.rit.edu> On Thu, Feb 08, 2001 at 06:12:27PM +0100, Gregoire Welraeds wrote: | | > There's nothing special about the name "None"; it's just a variable, | > like any other. | | > After doing "None = 2", you can "del None" to get the default value | > back. | | If we follow that logic, I could use any non assigned variable to have the | following working: | | >>> a= [1,'',3] | >>> filter(b,a) | | but this won't work as the interpreter complains that there is no variable | named b. This is because the interpreter tries to evaluate all expressions before the actual call to the functions. When the interpreter tries to evaluate the expression b it can't. When it evaluates the expression None it can. If you were to "del None" , then try and pass it to a function it would fail the same way. (Or instead of using the del statement, just remove the name None from the dictionary) | | | And finally, to add to the confusion, I have try the following: | | >>> a= [1,'',3] | >>> filter(0,a) | | for what the system complains that 0 is a non function type ! Correct. | | Now If we resume: | None is a value | None is a built in type | None is an object | None is an alias (as I understand it) for lambda x: x in the case of | filter(None, some_list) | | Now that I look at this problem, I'm totally confused about None. Any "None" is a name/binding. By default it refers to an object whose type is called "None". This object is a Singleton, and is built in. Objects can have many properties, one of them is "callable". If you were to make a replacement class for None, you could do something like: class MyNone : def __call__( self , arg ) : return arg If I try this : n = MyNone() filter( n , [ 1 , 2 , 3 ] ) it would be the same as using the builtin None object. (Unless I missed some sublties) None is simply an object, provided at interpreter startup, that has some (special) properties. (All classes define new objects, and each has "special" properties) | explanaition is welcome. Anyway, I don't understand that one can override | None. Could you give me at least one single good reason to do that. Being able to "override" None is simply how the language works. Python allows you to assign an object (everything in python is an object!) to any name. "None" isn't a special case. I can't think of any good reason to assign a new object to "None", but that doesn't mean the language disallows it. (Ab)using None in this manner would certainly obfuscate your code. I also don't think it is really necessary for the interpreter to disallow assignment to None since it adds complexity to the interpreter's workings without providing any real advantage. Instead, programmer discipline to use None appropriately works just fine IMO. :-) -D From drewpc at colorado.edu Thu Feb 1 16: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 rtexier at elikya.com Thu Feb 15 06: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 smigowsky at dspace.de Wed Feb 14 05: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 fredrik at pythonware.com Sun Feb 18 06: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 donn at u.washington.edu Thu Feb 15 13: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 bernie at pacific.net.hk Wed Feb 7 03:23:38 2001 From: bernie at pacific.net.hk (Bernie) Date: Wed, 07 Feb 2001 16:23:38 +0800 Subject: Tkinter: How to remove stacking order of a widget in grid manager References: <3A80712D.BAF8FC0D@pacific.net.hk> Message-ID: <3A81060A.4ED32F2@pacific.net.hk> Hi David, I've try your suggestion but it still doesn't work. Below is the code I've used. root = Tkinter.Tk() frame = Tkinter.Frame( root) frame.pack() a = [] for i in range(10): a.append( Tkinter.Button( frame, text=i)) a[i].grid( column = 0, row = i) frame.grid_forget() # buttons did not unmapped a.reverse() for i in range(10): a[i].grid( column = 0, row = i) # now the widgets are reordered but the stacking order did not reverse Bernie David Allen wrote: > In article <3A80712D.BAF8FC0D at pacific.net.hk>, "Bernie" > wrote: > > > Below is the code fragment: > > > > # remove widget from Grid Display manager > > for w in widget_list > > w.grid_remove() > > > > # re-ordering the widget > > widget_list.sort( mySort) # mySort() is not listed > > > > > # display widgets in new orders > > col = range(5) row = 0 for w in widget_list: > > for i in col: > > w.grid( column = i, row = row) > > row = row + 1 > > I think what the problem is that it has to be done > in the parent, not the child. So if 5 things are > grid() into a widget called wid, then > > wid.grid_forget() will ungrid all of the items. > By calling grid_forget on the items you want to take > out of the grid, you're unpacking their subitems > but not them. > > Example: > > f = Frame(parent) > b = Button(f, text="Foobar") > b.grid(row=0, col=0) > > if you then want to get rid of b, you do > f.grid_forget() > > NOT > b.grid_forget() > > Hope this helps. > -- > David Allen > http://opop.nols.com/ > ---------------------------------------- > "I must say that I find television very educational. The minute > somebody turns it on, I go to the library and read a book." > --Groucho Marx ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ From rwklee at home.com Thu Feb 8 20:02:43 2001 From: rwklee at home.com (Rick Lee) Date: Fri, 09 Feb 2001 01:02:43 GMT Subject: threading.RLock not subclassible? References: <3A7D5B5F.AADAA673@ll.mit.edu> <3A7F5C74.6C9BC395@home.com> <3A80A969.54B41DFF@home.com> Message-ID: <3A8341B1.6B7CB4C6@home.com> Thanks for your explanations and tips. I found the thread behaviour on the Mac extremely perplexing. Regarding your comment on what you think may be the unsafe and unpredictable code: the code does access a couple of global lists, the only things done with these lists are len() and append(), which I read somewhere are "atomic". David Bolen wrote: > Rick Lee writes: > > > "A multithreaded program executes by dividing its processing time > > between all active threads. For example, a program with 10 active > > threads of execution would allow approximately 1/10 of its CPU time > > to each thread and cycle between threads in rapid succession." > > > > I certainly was not seeing this behaviour on some platforms, even > > for threads that take a long time to perform computations. > > Well, that may be a different issue than your posted point about the > active thread count. It is possible that depending on the local > thread implementation (at the process level, OS kernel level, > pre-emptive versus cooperative, etc...) that you may get better or > worse sharing. Really the only bad case is if the threads are > cooperative (that is, a thread has to yield before the scheduler moves > to another thread). I'm not sure which if any platforms fall into > that category (perhaps someone else can answer for the typical Unix > pthreads implementation). > > How were you measuring the division of labor amongst the threads? > > > - what is the thread switching performance penalty, and how sensitive is the > > penalty to the number of threads? > > There's a hit to the Python interpreter to support threading (I think > I recall seeing something like 10%) in general, but actually switching > between the threads should be quite low overhead. Certainly when > threads are native to the platform's OS (such as with Windows NT), the > system scheduler really only thinks in terms of threads anyway, so > thread context switches are just the normal mode of dispatching. > > It should also be fairly insensitive to the number of threads, > providing overall system resources are not exceeded. > > > - is there an upper limit to the number of threads? > > That depends on the platform - you'll definitely run out of resources > eventually, but it's sort of like asking what's the upper limit on the > number of processes on the system, which can vary. > > It also depends on what they are doing, since you can likely support > far more threads if the majority are blocked, then if you are trying > to share the CPU among them all as active threads. > > Certainly I would expect that hundreds should not be out of the > question, and probably thousands. My desktop NT machine just with a > normal mix of stuff active sits with 42 processes and about 250 > threads, and I expect it could easily handle an order of magnitude > higher - as long as they weren't all trying to run simultaneously. > > But I don't have a hard limit for you, nor do I personally know of > such values across all platforms. It's a per-platform resource issue > and is related to the activity of the code as well, so I'm not sure > there's a fixed answer. Certainly if you're thinking in terms of > thousands you may want to find a way to share them - but if you're > thinking 10s or hundreds, you're probably ok. > > > Regarding what happens on the Mac: I have a multi-threaded program > > with several threads, each of which blocks without timeout on > > sockets.accept, sockets.recv, and queues.get respectively. This > > program runs perfectly on NT and Linux, but the blocked threads on > > the Mac don't seem to execute when the blocking condition is removed > > (I am 99% sure that's what's happening). If anyone can shed light > > on this, I will be very grateful. > > By blocking condition removed, do you mean that data shows up on the > socket or queues? I really can't think why if such data were to > arrive that the system calls wouldn't be satisfied. I don't see the > Mac implementation in the CVS tree I've currently got checked out, so > I'm not sure how the Mac threading is implemented - perhaps someone > else could chime in with some info. > > > Another weirdness includes a bit of code like this, which is a > > recursive call on itself to create threads: > > Well, my first inclination is that the code itself appears dangerous - > and unpredictable - because you don't have any protection against > simultaneous access to the shared objects (e.g., runners). But it's > hard to say without seeing more of the surrounding code. But for > example, it would appear that by the time you get around to appending > "me" to your completedRunObj, it's probably been changed by a new > thread. > > Personally, if you're trying to observe behavior of threads, I find > that a few judicial print statements can help out a lot. Yes, if your > problems have a time component, the additional time to do the output > can interfere, but for basic scheduling (what thread ran when) it can > be enlightening to just print the names of threads and points of their > execution all in sequence. If you keep your output as a single string > to the "print" statement, it won't get split amongst different threads > either, which can be a problem sometimes with this approach. > > -- > -- 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 jmarshal at mathworks.com Wed Feb 7 14:42:36 2001 From: jmarshal at mathworks.com (Joshua Marshall) Date: 7 Feb 2001 19:42:36 GMT Subject: python abstract syntax trees Message-ID: <95s8fc$59g$1@news.mathworks.com> In ther parser module, expr and suite return concrete syntax trees. Does anyone know of any quick routines that build more minimal abstract syntax trees? From lbates at syscon-computers.com Tue Feb 27 10: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 wmiller at mediaone.net Tue Feb 20 12: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 zala_ at hotmail.com Sun Feb 18 12: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 phlip_cpp at my-deja.com Tue Feb 27 11: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 rcalco at cortechs.com Sun Feb 18 15: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 aleaxit at yahoo.com Tue Feb 27 02: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 andym at ActiveState.com Wed Feb 14 18:44:03 2001 From: andym at ActiveState.com (Andy McKay) Date: Wed, 14 Feb 2001 15:44:03 -0800 Subject: CPAN functionality for python References: <96eu1l$1m3r$1@raewyn.paradise.net.nz> Message-ID: <96f51s$gno$1@postum.activestate.com> > 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. I wrote a product for Zope that provides a simple proof of concept called the ZPM. It checks the product data on a Zope installation against the a website (http://www.zopezen.org/products). Zope is serving back a simple xml file containing the requested products information in XML. Zope could handle the metadata quite easily, a regular FTP could do the hard work. -- Andy McKay. From tyler at tylereaves.com Wed Feb 28 09: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 dan at eevolved.com Tue Feb 6 00:26:52 2001 From: dan at eevolved.com (Dan Parisien) Date: Tue, 06 Feb 2001 05:26:52 GMT Subject: do...while loops Message-ID: why don't do...while loops exist in python? Is there are better way to get to that functionality? e.g. file = open(...) do: line = file.readline() while line != "" Do I have to write a PEP or read some more documentation? ;-) Thanks, Dan From brian at sweetapp.com Sun Feb 25 14: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 aleaxit at yahoo.com Tue Feb 20 05: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 timr at probo.com Wed Feb 14 01:12:50 2001 From: timr at probo.com (Tim Roberts) Date: Tue, 13 Feb 2001 22:12:50 -0800 Subject: smtplib problem References: <966mnl$2dl$1@uranium.btinternet.com> Message-ID: Sheila King wrote: > >Nice. And how does one do SMTP authorization? (There must be a way. I see that >the NNTP module includes authorization commands, but the smtplib doesn't!) There is no such thing. The SMTP protocol does not include authorization. Some providers have gone to a scheme whereby you have to check for POP mail before you can use SMTP. You have to send a password for POP, after which they open a short window wherein you can send mail. That doesn't take any changes to smtplib. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From dvoitenko at qode.com Wed Feb 14 12: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 dan at eevolved.com Mon Feb 5 21:14:39 2001 From: dan at eevolved.com (Dan Parisien) Date: Tue, 06 Feb 2001 02:14:39 GMT Subject: importing text code Message-ID: Is it possible to import from a string in memory instead of a file? I can't find information on how to do it... thanks, Dan From jasonic at nomadicsltd.com Fri Feb 2 23: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 hinsen at cnrs-orleans.fr Mon Feb 19 05: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 debl at NoNOSpamtheworld.com Sun Feb 25 18: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 root at rainerdeyke.com Thu Feb 22 10: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 loewis at informatik.hu-berlin.de Fri Feb 2 16: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 stephen_purcell at yahoo.com Mon Feb 26 06: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 donod at home.com Sat Feb 17 04: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 aleaxit at yahoo.com Fri Feb 9 08:26:31 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 9 Feb 2001 14:26:31 +0100 Subject: How to write integers to a file? References: Message-ID: <960r680hsk@news2.newsguy.com> "Steven Sartorius" wrote in message news:wXRg6.3723$bu4.792238 at typhoon2.ba-dsg.net... > I'm trying to write a series of whitespace delimited integers to a file. > The 'write' method only accepts strings and using arrays produces binary > data when I open the file with less. What I want is somehting like > printf for python. Is there any easy way to do this? (there must > be...this is python!) There are several. Suppose you have a list (or other sequence) L of integers and want to write them to a file object F, as readable digits, one integer per line. A few "easy ways" to obtain this are: for i in L: F.write(str(i)+'\n') for i in L: F.write("%s\n" % i) for i in L: print >>F, i F.writelines([str(i)+'\n' for i in L]) F.writelines(["%s\n" % i for i in L]) def myformat(i): return "%s\n" % i F.writelines([myformat(i) for i in L]) F.writelines(map(myformat, L)) Alex From fredrik at pythonware.com Mon Feb 19 08: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 graham at nospam.microtonal.co.uk Thu Feb 15 15: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 qrczak at knm.org.pl Thu Feb 22 11: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 stephen_purcell at yahoo.com Mon Feb 12 13: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 cook at maya.com Thu Feb 8 10:00:49 2001 From: cook at maya.com (Nicole Cook) Date: Thu, 8 Feb 2001 10:00:49 -0500 Subject: mxODBC problems Message-ID: <000901c091df$f673e9a0$21fe46c0@maya.com> I've installed mxODBC on Windows, and I'm still trying to get it to the point where I can use it. I know it's all there, and it's not colliding with win32all. Is there something wrong with my python path? I don't know what to try next. Nicole Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [ Copyright 1991-1995 Stichting Mathematisch >>> import ODBC >>> import ODBC.Windows Traceback (innermost last): File "", line 1, in ? ImportError: No module named Windows >>> from ODBC import Windows Traceback (innermost last): File "", line 1, in ? ImportError: cannot import name Windows >>> from ODBC import * >>> db = ODBC.Windows.connect Traceback (innermost last): File "", line 1, in ? AttributeError: Windows >>> from ODBC.Windows import * Traceback (innermost last): File "", line 1, in ? ImportError: No module named Windows >>> From stephen_purcell at yahoo.com Tue Feb 27 11: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 root at rainerdeyke.com Thu Feb 8 20:20:58 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 09 Feb 2001 01:20:58 GMT Subject: None assigment References: <95umoi$is5$1@panix2.panix.com> Message-ID: <_BHg6.195181$ge4.67634054@news2.rdc2.tx.home.com> "Aahz Maruch" wrote in message news:95umoi$is5$1 at panix2.panix.com... > What you're missing is the issue of Python scopes. Try this: > > b=2 > def foo(): > b=4 > print b > del b > global b > print b > foo() And what *you*'re missing is that whether a variable is local or global is determined at compile time (in the absensce of 'exec' or 'from ... import *'). The above does not work. However, Whether a global variable is taken from the module dictionary or '__builtins__' is a run-time decision. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From u504516601 at spawnkill.ip-mobilphone.net Tue Feb 13 11: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 tjg at exceptionalminds.com Fri Feb 16 19: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 real.email at signature.this.is.invalid Mon Feb 19 13: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 glennj at pcard31e.ca.nortel.com Tue Feb 27 10: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 dalke at acm.org Fri Feb 16 03: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 paul.robinson at businesscollaborator.com Thu Feb 8 08:13:56 2001 From: paul.robinson at businesscollaborator.com (Paul Robinson) Date: Thu, 08 Feb 2001 13:13:56 +0000 Subject: Forking and Threads Message-ID: <3A829B94.9AF5A831@businesscollaborator.com> OK, before I start, I realise that threading and forking are not necessarily well known for playing well with each other. But given that, and assuming that this is the road I have chosen to go down can anyone explain why the attached program (also available at: http://cobweb.quantisci.co.uk/pub/english.cgi/d10030658/forkingtest2.py ) will run happily for several minutes (upto about 10mins so far) and then just sit there with the main process running with as much CPU time as the OS will give it! This is the "distilled down" version of the problem that I'm seeing in a much larger application. I've only tested this on: Python 1.5.2 Red Hat Linux release 6.2 (Zoot) Kernel 2.2.14-5.0smp on a 2-processor i686 and would very interested in how (and if) it performs on other operating systems - obviously only those with both threading and forking need apply. I find that "watch -n 1 "pstree -c -p -a | grep python | grep -v grep"" gives a overview of the running of the program as you can see the child processes appearing and disappearing. A large number of child processes and a short run time for the children seems to cause the crash most quickly. These parameters can be set with -MC (MAX_CHILDREN) and -MS (MAX_SECONDS the child will wait for). forkingtest2.py -MC 20 -MS 3 crashes after a while on my dual 350MHz PII. Any insight into this behaviour would be gratefully appreciated. Paul Robinson Business Collaborator Development Manager Enviros Software Solutions WWW: http://www.businesscollaborator.com -------------- next part -------------- #!/usr/bin/python import os, sys import marshal from threading import Thread, currentThread from time import sleep, time from random import choice, seed from string import atoi CHILD = 0 MAX_CHILDREN = 5 MAX_SLEEP = 5 def log(*args): print '\t'*CHILD, os.getpid(),' : ', currentThread(), \ ' : ', reduce(lambda x, y: x + ' '+ y, map(str,args)) def processLoop(): children = [] while 1: while len(children) < MAX_CHILDREN: pid = os.fork() if pid: #parent children.append(pid) else: #child try: global CHILD CHILD = CHILD + 1 #Do stuff seed(time()) pause = choice(range(1,MAX_SLEEP)) log('Sleeping', pause) sleep(pause) log('Exitting') finally: os._exit(0) else: log('Too many children') sleep(3) # Wait on children for i in range(len(children)-1, -1, -1): # Call waitpid (os.WNOHANG - non-blocking) status = os.waitpid(children[i], os.WNOHANG) if status[0] > 0: # Child has been "deaded" del children[i] if __name__ == '__main__': try: i = sys.argv.index('-MC') global MAX_CHILDREN MAX_CHILDREN = atoi(sys.argv[i+1]) except: pass print 'Set MAX_CHILDREN to', MAX_CHILDREN, ' - use "-MC n" to change' try: i = sys.argv.index('-MS') global MAX_SLEEP MAX_SLEEP = atoi(sys.argv[i+1]) MAX_SLEEP = ((MAX_SLEEP >= 2) and MAX_SLEEP) or 2 except: pass print 'Set MAX_SLEEP to', MAX_SLEEP, ' - use "-MS m" to change (where m >= 2)' pl = Thread(target=processLoop, name='processLoop') pl.start() currentThread().setName('Main Loop') f = open('/tmp/temp','a') while 1: log('Looping') sleep(5) From gregj at pobox.com Tue Feb 6 15:25:50 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Tue, 06 Feb 2001 20:25:50 GMT Subject: do...while loops References: <95p75f$85m$1@panix3.panix.com> <3A802319.46EBCA35@cybermesa.com> Message-ID: <95pmjp$p3b$1@nnrp1.deja.com> In article <3A802319.46EBCA35 at cybermesa.com>, Jay O'Connor wrote: > Umm..then how about a counter? Would this work? > > x = 100 > while x: > print x > x -= 1 > > Yeah, just tried it...it works. > > Umm...anyone really like it? :) That's a common C idiom, but I've always disliked it because x is either a logical or arithmetic value depending on which statement you are looking at. I prefer: while x > 0: ... x -= 1 To me this has several advantages: 1. There is absolutely no question about what the loop is doing: counting down to zero, not waiting for some flag named x to be false. 2. If x is initially negative the loop won't even get started, whereas x = -1 ... while x: ... x -= 1 Will loop for a long time and then crash. 3. The explicit comparison will still work if x is changed from an integer to a floating point type. This kind of bug is particularly hard to find: x = (((11.0 / 3.0) / 3.0) * 3.0) * 3.0 # 10.999999999999998 ... while x: print x x -= 1 x will never be exactly equal to 0 because of floating-point representation and rounding errors. The example above will even print the sequence 11.0, 10.0, 9.0, ... 1.0, so it may not be immediately obvious why the loop doesn't terminate. -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com Sent via Deja.com http://www.deja.com/ From tanzer at swing.co.at Fri Feb 23 02: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 gregj at pobox.com Thu Feb 1 19: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 martin.skott at propylon.com Thu Feb 1 11: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 ken at lt.com Mon Feb 19 13: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 scarblac at pino.selwerd.nl Tue Feb 6 06:28:13 2001 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 6 Feb 2001 11:28:13 GMT Subject: do...while loops References: Message-ID: Dan Parisien wrote in comp.lang.python: > why don't do...while loops exist in python? Is there are better way to get > to that functionality? > > e.g. > file = open(...) > do: > line = file.readline() > while line != "" > > Do I have to write a PEP or read some more documentation? ;-) This has been discussed to death, over and over again. Some of the reasons cited are that the construct is redundant, there is no way to indent it in a way consistent with the rest of Python, and Guido doesn't like it (all of those may or may not be true...). The Python idiom in the general case is: while 1: line = file.readline() ... if not line: break ... But in the specific case of reading lines from files, this is neater: for line in file.readlines(): ... Which reads the whole file into memory at once. For the case your files are too big, the upcoming Python 2.1 will have the .xreadlines() method which works the same way but does not load everything at once. At the moment, the fileinput module gives that functionality: import fileinput for line in fileinput.input("filename"): ... HTH. -- Remco Gerlich From guettli at interface-business.de Mon Feb 19 10: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 darked at my-deja.com Fri Feb 9 13:30:55 2001 From: darked at my-deja.com (darked at my-deja.com) Date: Fri, 09 Feb 2001 18:30:55 GMT Subject: open("ls -l |", "r") ?? References: Message-ID: <961d0v$cg8$1@nnrp1.deja.com> Hi Steve, this works for me: import os file_list = os.popen('ls -l').readlines() Greetings Darek Sent via Deja.com http://www.deja.com/ From aleaxit at yahoo.com Mon Feb 5 11: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 aahz at panix.com Mon Feb 19 14: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 stephen_purcell at yahoo.com Tue Feb 6 05:44:36 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 6 Feb 2001 11:44:36 +0100 Subject: flock() question In-Reply-To: <3A7FCDE9.2AD808CD@schlund.de>; from cg@schlund.de on Tue, Feb 06, 2001 at 11:11:53AM +0100 References: <3A7FCDE9.2AD808CD@schlund.de> Message-ID: <20010206114436.A21002@freedom.puma-ag.com> Carsten Gaebler wrote: > It seems I don't understand file locking. In the following example the > parent process locks a file and then the child process locks the same file > but does not wait until the parent unlocks it. What am I doing wrong? >From the 'flock' man page: "A file is locked (i.e., the inode), not the file descriptor." So the correct procedure is to open the lock file separately in each process: pid = os.fork() if pid == 0: f = open("/tmp/locktest", "w") time.sleep(1) print "Child: locking file" fcntl.flock(f.fileno(), FCNTL.LOCK_EX) print "Child: file locked" time.sleep(5) os._exit(0) else: f = open("/tmp/locktest", "w") print "Parent: locking file" fcntl.flock(f.fileno(), FCNTL.LOCK_EX) print "Parent: file locked" time.sleep(10) fcntl.flock(f.fileno(), FCNTL.LOCK_UN) -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Available for consulting and training. "Even snakes are afraid of snakes." -- Steven Wright From ohyvarin at cc.helsinki.fi Wed Feb 21 06: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 vasvir at iit.demokritos.gr Fri Feb 9 12:30:25 2001 From: vasvir at iit.demokritos.gr (Vassilis Virvilis) Date: Fri, 09 Feb 2001 19:30:25 +0200 Subject: I love Python References: Message-ID: <3A842931.8C46014C@iit.demokritos.gr> Daniel Klein wrote: > > On Fri, 9 Feb 2001 09:02:21 -0600, Kemp Randy-W18971 > wrote: > > >I noticed this message was sent three times. There is an ancient legend that if everyone in the world says "I love Python" three times, Perl will disappear. > > What's Perl? Hey, it worked! I don't want to offend anybody but this is the best off-topic thread I have ever read. .Bill From jasonic at nomadicsltd.com Fri Feb 2 23: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 andymac at bullseye.apana.org.au Sat Feb 10 03:35:29 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Sat, 10 Feb 2001 19:35:29 +1100 (EDT) Subject: python-dev summary, Jan. 16-31 In-Reply-To: Message-ID: On Fri, 9 Feb 2001, Tim Peters wrote: > I read c.l.py first, because, well, *somebody* ought to . And I am most appreciative of your presence and insight. I have to say that it disappoints me that Guido has found it necessary to retreat from this community into the monastery of python-dev. I fear that Python's priesthood and citizenry will lose contact with each other as a result. It won't happen overnight, but incrementally. -- 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 SBrunning at trisystems.co.uk Thu Feb 8 07:20:27 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Thu, 8 Feb 2001 12:20:27 -0000 Subject: None assigment Message-ID: <31575A892FF6D1118F5800600846864D5B17D1@intrepid> > From: Gregoire Welraeds [SMTP:greg at perceval.be] > While playing a bit with python 2.0, I found that I can assign some value > to None (snip) > If it is a feature (I suppose it is not a bug :), what is the interest of > this ? Feature. 'None' is just a label, and just like any other label, you can always assign to it. I'm not aware of any way of preventing a label from being assigned to. Doesn't make it a good idea, though... 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 teyc at bigfoot.com Wed Feb 7 16:42:34 2001 From: teyc at bigfoot.com (Chui Tey) Date: Thu, 8 Feb 2001 07:42:34 +1000 Subject: Touch in python? Message-ID: <95sfla$adf$1@bunyip.cc.uq.edu.au> Hi, Is there an equivalent of 'touch' in python? I would like to change the file modified time. Chui From loewis at informatik.hu-berlin.de Fri Feb 9 12: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 sss at ed.com Wed Feb 21 06: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 grante at visi.com Fri Feb 9 11:21:31 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 09 Feb 2001 16:21:31 GMT Subject: [xyz]modem module? References: Message-ID: In article , Warren Postma wrote: >> A couple months back somebody asked about Python [xyz]modem >> support, but I didn't find any positive answers with deja. > >Sounds like a good job for a C module wrapper for SZ. X and YModem-Batch >are easily implemented (I have tonnes of sample code in C already written). >But I've never written my own Z-Modem. It's kind of a "black art". I'm doing a spawnv of sz/sx now, and that works OK, but I was hoping for something portable. One of these days I'll write X or Y in Python. -- Grant Edwards grante Yow! All of life is a blur at of Republicans and meat! visi.com From gerhard.nospam at bigfoot.de Wed Feb 28 21:54:25 2001 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Thu, 01 Mar 2001 03:54:25 +0100 Subject: [ANNOUNCE] pyAda, first public release Message-ID: <3A9DB9E1.8DD0E36D@bigfoot.de> I am glad that I can finally announce a first version of pyAda. As the name implies, it's an Ada 95 binding to the Python interpreter. With pyAda, you can write Python extensions in Ada 95, and, much more important, you can also embed a Python interpreter in your Ada applications. The current release is far from finished, but the thin binding works already quite well for me. The thin binding is a one-to-one mapping of the Python -> C interface. website: http://pyada.sourceforge.net release: http://download.sourceforge.net/pyada/pyAda-2001-03-01.tar.gz docs: included in release pyAda currently works for me under (SuSE 7.1) Linux and FreeBSD (4.2). It used to work on win32, too, but currently doesn't. That's to be fixed in the next release. Porting to other Unixen should be fairly straightforward. pyAda currently depends on GNU make, GNAT 3.13p and Python 2.0 (and DocBook SGML for doc creation). The license is a BSD variant. Future plans include bugfixes, code cleanup, and development of a thick binding that renders manual reference counting obsolete. And more ports. Gerhard PS: This is my first major Ada project, so I am open to any suggestions for improvement. -- 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 john at dhh.gt.org Wed Feb 21 00: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 cerutti at together.net Thu Feb 15 10: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 mlh at idi.ntnu.no Thu Feb 8 08:30:22 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Thu, 8 Feb 2001 14:30:22 +0100 Subject: Python 2.1a2 compile problems References: <95pfsu$ht1$1@nnrp1.deja.com> <3dpugvh6ot.fsf_-_@ute.cnri.reston.va.us> <95q16e$3go$1@nnrp1.deja.com> Message-ID: <95u774$ktc$1@tyfon.itea.ntnu.no> > Thanks again. I can post my changes here if > anyone cares. > Please do! I'm having the same problems, and was prepared to wait for a beta... ;) > Scott Griggs -- Magnus Lie Hetland (magnus at hetland dot org) "Reality is what refuses to disappear when you stop believing in it" -- Philip K. Dick From hinsen at cnrs-orleans.fr Wed Feb 28 06: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 embed at geocities.com Mon Feb 19 16: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 SBrunning at trisystems.co.uk Fri Feb 9 04:29:25 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 9 Feb 2001 09:29:25 -0000 Subject: Some basic questions about Tkinter (and Python) Message-ID: <31575A892FF6D1118F5800600846864D5B17D7@intrepid> > From: Martyn Quick [SMTP:mrq at for.mat.bham.ac.uk] > 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. This book doesn't cover Tkinter in any detail, I'm afraid. (5 or 6 pages, IIRC.) *Very* good book, but it doesn't *intend* to cover everything - it concentrates on Win 32 stuff. FWIW, I find Grayson's book *very* tough going. I have *no* experience of GUI building at all, and there isn't much in the way of gentle introduction. It's probably a good book for learning Tkinter if you already know Python pretty well and know how to build a GUI. What *I* need is a gentle introduction to the art of building an event driver GUI using Tkinter, and I haven't found one yet. BTW, I picked up Andre Lessa's 'Python Developers Handbook' at the weekend (Sams, ?33) - it has a very brief intro to Python, but then moves on to cover a wide range of advanced topics. Looks good so far. This has a section on GUI building with Tkinter, which I haven't reached yet. I'll report back when I've finished, and had a play. 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 mjackson at wc.eso.mc.xerox.com Wed Feb 7 16:52:28 2001 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 7 Feb 2001 21:52:28 GMT Subject: Python wierdness References: Message-ID: <95sg2s$bjs$1@news.wrc.xerox.com> "Roger H" writes: > What's going on here, and how could one get around it? Display rounding of finite-precision floating point arithmetic: yngvi> python Python 1.5.2 (#7, May 6 1999, 14:39:45) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> 0.3 % 0.1 - 0.1 -2.77555756156e-17 In other words, 0.3 % 0.1 == 0.1 is indeed false. -- 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 hs at paradise.nirvananet Sun Feb 18 20: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 michael at stroeder.com Fri Feb 2 12: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 grante at visi.com Fri Feb 23 21: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 dsh8290 at rit.edu Sun Feb 18 21:56:45 2001 From: dsh8290 at rit.edu (D-Man) Date: Sun, 18 Feb 2001 21:56:45 -0500 Subject: None assigment In-Reply-To: ; from fredrik@pythonware.com on Sun, Feb 18, 2001 at 09:35:37PM +0000 References: <3A857E90.18EE0634@engcorp.com> <981857533.2047761672@news.silcom.com> Message-ID: <20010218215645.A12311@harmony.cs.rit.edu> On Sun, Feb 18, 2001 at 09:35:37PM +0000, Fredrik Lundh wrote: | Thomas Wouters wrote: | > It's *mostly* harmless. Consider | > | > spam, None, eggs, None = string.split("this is a string") | > viking = filter(None, (spam, eggs)) | | now put them both in the same function, with the filter | statement on line 5 and the split on line 65. | | trust me, you can waste lots of time trying to figure out | what causes that "NameError: None" message on line 5... True (been there, done that, with other guns), but, my terminal is only 24 lines long. Functions that don't fit on the screen (usually) need to be split up better. :-) -D From bfunk33 at qwest.NOSPAM.net.invalid.net.com.gov Wed Feb 7 20:22:16 2001 From: bfunk33 at qwest.NOSPAM.net.invalid.net.com.gov (Bill Funk) Date: Thu, 08 Feb 2001 01:22:16 GMT Subject: Image Capture And Processing References: <95sok6$gvt$1@bob.news.rcn.net> Message-ID: <3a81f3d1.25710123@news.qwest.net> On Wed, 7 Feb 2001 19:23:19 -0500, "MrBill" wrote: >I would like to capture and process images from my USB connected Logitech >digicam. > >Does anyone know where I would start to acquire images from the camera and >control it from python (or any other programming environment). I'm running >on windoze 2000. > >Thanks, >-- >Bill Rodgers > > While I don't have that particular camera, a good place to start would be with the bundled software. Did you get any? If so, there should be help files or a manual. If not, you will need to find a way to *see* the camera, and to do this with USB usually requires the right drivers for both the camera and the OS. Often, these can be downloaded from the camera maker's site on the Web. Or, if the camera has removable media, some sort of reader for the media wil make things immensly easier. For most of us, a USB reader is going to be the fastest/easiest. These make the memory card look like a removable drive (like a floppy), and you can use Windows Explorer to copy the image files to your hard drive. >From there, any graphics program can access the files, and you are set! ================ Bill Funk bfunk1 on Ebay From frohne at gci.net Thu Feb 1 19: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 joconnor at cybermesa.com Sun Feb 4 09:19:04 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Sun, 04 Feb 2001 14:19:04 +0000 Subject: While everyone is saying what they want in Python :) Message-ID: <3A7D64D8.74E71826@cybermesa.com> 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) -- 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 dalke at acm.org Sun Feb 4 00:50:30 2001 From: dalke at acm.org (Andrew Dalke) Date: Sat, 3 Feb 2001 22:50:30 -0700 Subject: Stringbuffer References: <95if87$juo$1@news.mathworks.com> Message-ID: <95iqk3$msa$1@slb1.atl.mindspring.net> Joshua Marshall: > buf = [] > while stream.more(): > buf = buf + stream.read() > string.join(buf, '') > >Is there a faster way? I'm thinking of writing a Stringbuffer >class in C. Or does a quick, reliable one already exist? Might want to look at cStringIO import cStringIO buf = cStringIO.StringIO() while stream.more(): buf.write(stream.read()) s = buf.getvalue() Or you can use an array import array buf = array.array("c", "") while stream.more(): buf.fromstring(stream.read()) s = buf.tostring() Must admit that I would like the method names to be more similar between these two. Andrew dalke at acm.org From dsh8290 at rit.edu Tue Feb 27 14: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 geoff at homegain.com Fri Feb 2 14: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 apederse at my-deja.com Mon Feb 12 05:43:28 2001 From: apederse at my-deja.com (apederse at my-deja.com) Date: Mon, 12 Feb 2001 10:43:28 GMT Subject: urllib.open('http://www.redherring.com/') References: <95th67$36j$1@nnrp1.deja.com> <95tj33$4g1$1@nnrp1.deja.com> <3A825A68.B1023097@intertrader.com> <95tq9r$afs$1@nnrp1.deja.com> <9607c5$bkj$1@nnrp1.deja.com> <3ditmj99pd.fsf@ute.cnri.reston.va.us> Message-ID: <968eog$ni4$1@nnrp1.deja.com> In article , "Fredrik Lundh" wrote: > Andrew Kuchling wrote: > > I don't believe urllib or httplib were massively rewritten for 2.0 > > (nor will they be in 2.1), so if it's a bug, it's probably still there. > > on my box, it sometimes work under 1.5.2, and never > works under an unmodified 2.0 installation. > > however, the following hack works for both versions > (note the explicit socket shutdown). > is it possible to do a similar fix to urllib? (For convenience reasons I always use urllib in my applications...) btw. I'm not very familiar with how the Python community works, but I'm thinking at this point, shouldn't whoever that has been involved in the programming of httplib and urllib be informed about the problems? /Asle Sent via Deja.com http://www.deja.com/ From bbollenbach at homenospam.com Thu Feb 15 23: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 teep at inet.co.th Sun Feb 11 09:00:56 2001 From: teep at inet.co.th (Prateep Siamwalla) Date: Sun, 11 Feb 2001 21:00:56 +0700 Subject: Does an pdf create module exist? References: <981805696.255883005@news.t-online.de> Message-ID: <9665p0$rgj$1@news.inet.co.th> Definately check out report lab www.reportlab.com -teep Zamurai wrote in message news:981805696.255883005 at news.t-online.de... ? From delza at antarcti.ca Thu Feb 15 12: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 parz at home.com Sun Feb 4 22:05:20 2001 From: parz at home.com (Parzival Herzog) Date: Mon, 05 Feb 2001 03:05:20 GMT Subject: How to detect client closed socket in server? Message-ID: I have written a client-server application using socket.py. The model is one where the server loops accepting connections, starting worker threads for each connection. I am having two problems: 1) the client is able to detect when the server disconnects (it gets an exception), but the server is unable to detect when the client disconnects using socket.close() (no exception arises in the server). An exception will aris in the server if the client process terminates. 2) Although the maximum number of connections is limited to 16, in practise my server accepts an unlimited number of connections. An earlier newsgroup thread mentioned a similar, with some responders asserted that the client side "should" receive an exception, but this seemed to be an opinion, not a hard fact. I most definitely want an exception when the client closes, and can't seem to get one. I am running Python 2.0 on Win 2000. Can anyone tell if this is a bug (in socket.py), or if I am doing something incorrect? -- Parzival. ---------------------------------------------------------------------------- --------------------- # extract of the server code: ServerPort = 10800 MaxConnections = 16 # Maximum number of connections to serve class Server(threading.Thread): def __init__(self,name,ServerClass): self.ServerClass = ServerClass threading.Thread.__init__(self, name=name) def run(self): try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.bind(('', ServerPort)) sock.listen(MaxConnections) except Exception, E: SocketDiagnostic(E, "Unable to start server.") else: try: try: while 1: self.ServerClass(sock.accept()).start() except Exception, E: SocketDiagnostic(E, "Unable to accept new connections.") finally: sock.close() class EmsUpdate(threading.Thread): def __init__(self,conn): self.client, self.addr = conn threading.Thread.__init__(self, name="EmsUpdate") def run(self): print "Connected to", self.addr try: try: MaxReqSize = 9600 self.client.setsockopt(socket.SOL_SOCKET, socket.SO_RCVTIMEO, struct.pack("ll",5000,0)) while self.KeepRunning: req = self.client.recv(MaxReqSize) if not req: print "Null request received from", self.addr break self.ProcessRequest(req) except Exception, E: # I am expecting an exception (socket.error) here if the client closes its # socket, but none arises. SocketDiagnostic(E,"Unable to provide EmsUpdate services for %s." % str(self.addr)) finally: self.client.close() print "Disconnected from", self.addr def ProcessRequest(self,req): try: # service the request (specific request service code is not shown) func, args = eval(req, {}) res = apply(self.Requests[func],args) self.client.send(repr(res)) except Exception, E: SocketDiagnostic(E,"Unable to complete '%s' request from %s." % (func, str(self.addr))) # Start a server using the EmsUpdate class to serve Server("EmsUpdateServer", EmsUpdate).start() ---------------------------------------------------------------------------- ---------------------- Extract of the client code. def run(self): while self.keeprunning: self.Log("Trying to connect to %s port %d" % (ServerHost, ServerPort)) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: try: sock.connect((ServerHost, ServerPort)) sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVTIMEO, struct.pack("ll",ServerTimeoutMs,0)) self.Log("Connected to " + str(sock.getpeername())) # Compaose a request for the server rq = repr(("PAGE", ((), self.Page, self.DataEvents.keytexts()))) sock.send(rq) rcv = sock.recv(32) assert int(rcv) == len(self.DataEvents) while self.keeprunning: # Wait for an update of the page rq=repr(("GETWAIT", (self.Page,))) sock.send(rq) rcv = sock.recv(UpdateBufferSize) assert rcv ... do soemthing with rcv ... # Politely end the connection rq=repr(("CLOSE", ())) sock.send(rq) rcv = sock.recv(32) assert rcv == "1" except Exception, E: msg = "Exception: " + SocketErrCodes.SpecificErrMsg(E)[1] tb = sys.exc_info()[2] msg = msg + " at line " + str(traceback.tb_lineno(tb)) del tb self.Log(msg) finally: # ********************* This code has no effect on the server ******************** self.Log("Shutting down connection") sock.close() del sock # just to make sure! for i in range(ReConnectSecs): if self.keeprunning: time.sleep(1.0) From mbel44 at dial.pipex.net Tue Feb 13 08:59:58 2001 From: mbel44 at dial.pipex.net (Toby Dickenson) Date: Tue, 13 Feb 2001 13:59:58 +0000 Subject: python 2.0 won't run scripts with \r\n line termination on RH7? References: <981930999.1446113299@news.silcom.com> <3A874ED8.75C9A92@uol.com.br> Message-ID: I use cvs to distribute scripts, which will happily take care of of changing between \n and \r\n. Toby Dickenson tdickenson at geminidataloggers.com From amk at mira.erols.com Sun Feb 11 21:32:01 2001 From: amk at mira.erols.com (A.M. Kuchling) Date: 12 Feb 2001 02:32:01 GMT Subject: PEP status and python-dev summaries References: <3dg0hn8zlr.fsf@ute.cnri.reston.va.us> Message-ID: On Fri, 9 Feb 2001 20:14:33 -0500 (EST), Jeremy Hylton wrote: >The PEPs are kept under CVS control, which supports differencing >directly. So you can read the current PEPs via python.sourceforge.net >and you can review changes using the CVS repository at >sourceforge.net/projects/python. Following up to a posted PEP and adding interspersed comments is much easier if the full text of the PEP is posted; any mail or news reader probably has a single keystore for it. If the only thing posted is the URL, then it requires more steps to do that by hand-- pull up the PEP in your Web browser, get an ASCII version (what the poor benighted souls who use Netscape do to get plain text, I don't know), insert '>' at the start of every line, annotate it, etc. IMHO the full text of every PEP should have been posted at least once in the PEP's lifetime. --amk From shichang at icubed.com Mon Feb 26 14: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 martin.franklin at westerngeco.com Wed Feb 28 02: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 wtanksle at dolphin.openprojects.net Mon Feb 26 18: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 barry at digicool.com Fri Feb 9 10:26:04 2001 From: barry at digicool.com (Barry A. Warsaw) Date: Fri, 9 Feb 2001 10:26:04 -0500 Subject: Is comp.lang.python.announce dead? References: <90an59.4hk.ln@127.0.0.1> Message-ID: <14980.3084.424354.137797@anthem.wooz.org> >>>>> "gradha" == writes: gradha> Just today I fetched the news and got around 10 "announce" gradha> messages, in this newsgroup instead of gradha> comp.lang.python.announce. Does this mean that the latter gradha> is officially dead? c.l.py.a is absolutely live again, and as mentioned in a different follow, there is a team of moderators who are helping to approve messages for the newsgroup. There was a separate and temporary outage of the moderation gateway as we changed mail daemons on mail.python.org (for reasons I won't go into). That problem should be fixed now. Please post your announcements to c.l.py.a! Also, register your programs with Parnassus and those announcements can be automatically forwarded to the newsgroup. -Barry From matthias.horst at ruhr-uni-bochum.de Mon Feb 12 09: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 rwklee at home.com Tue Feb 20 21: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 hungjunglu at yahoo.com Sun Feb 11 21:45:32 2001 From: hungjunglu at yahoo.com (hungjunglu at yahoo.com) Date: Mon, 12 Feb 2001 02:45:32 -0000 Subject: creating DSN in Windows In-Reply-To: <4xDh6.66249$bb.1038647@news1.rdc1.tx.home.com> Message-ID: <967ioc+9p7t@eGroups.com> --- In python-list at y..., "Scott Hathaway" wrote: > I posted this a few weeks ago: > ... > Hope this helps someone else! > > Scott It surely does. Thanks so much! (See my other posting, where I already found your posted code.) I have done the code now in Python and Visual Basic, for Windows 95 and NT. And I think I'll just do it in C directly next week, just to make the executable as small as possible. I almost did in in Java, too, but somehow found out Java community is not very keen towards Windows registry... some of them charge money for some very simple api to talk to Windows dlls. Arrghh. thanks again, Hung Jung From erno-news at erno.iki.fi Mon Feb 26 23: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 embed at geocities.com Mon Feb 12 10: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 vasvir at iit.demokritos.gr Sat Feb 24 00: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 hgg9140 at seanet.com Tue Feb 13 19: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 tjg at exceptionalminds.com Mon Feb 12 13: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 piet at cs.uu.nl Wed Feb 21 09: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 loewis at informatik.hu-berlin.de Tue Feb 20 07: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 bencr at bigpond.com Sat Feb 24 08: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 timr at probo.com Mon Feb 12 01:16:12 2001 From: timr at probo.com (Tim Roberts) Date: Sun, 11 Feb 2001 22:16:12 -0800 Subject: python 2.0 won't run scripts with \r\n line termination on RH7? References: Message-ID: "Mike Carifio" wrote: > >I have a network of Linux and Windows machines. On a Windows box, I have >several python scripts which I'd also like to run on the Linux machines. >I've >smbmounted the Windows share to see the scripts, but having been created >on the Windows box, the line termination in those files is \r\n. When I try >to execute the script, say 'start', I get: > >bash: ./start.py: No such file or directory > >When I "clean up" start.py with tr - tr -d '\r' < start.py > reallystart.py, >it runs. So it seems like python 2 can't compensate for wierd Windows line >terminators. Any workarounds, other than 'tr'? Pl. advise. Tx. Your diagnosis is incorrect, as you should have seen by the error message. Python handles either line terminator on either operating system. The problem here is not Pyhton, it is the shell. The first line of your script probably says: #! /usr/bin/python When bash tries to figure out how to run this file, it looks at the first two characters. When it finds #!, it assumes the next token on the line is the name of a file to be executed to handle the script. In your case, it reads the file name as /usr/bin/python\r, and there is no such file or directory. Hence, the error. The script will run correctly if you say: python start.py Admittedly, this is not ideal. You also might be able to work around this by adding something to the #! line, but this might require experimentation. Adding a single space might be an interesting option. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From a.mueller at icrf.icnet.uk Thu Feb 8 11:34:00 2001 From: a.mueller at icrf.icnet.uk (Arne Mueller) Date: Thu, 08 Feb 2001 16:34:00 +0000 Subject: catching all exceptions References: <95uati$cm4$1@icrf.news> <87y9vhp5r0.fsf@winnegan.de> Message-ID: <3A82CA78.7D9B12F0@icrf.icnet.uk> Siggy Brentrup wrote: > > Sorry for the typo :-( > > Siggy Brentrup writes: > > > import traceback, cStringIO > > > > f = cStringIO.StringIO > f = cStringIO.StringIO() > > traceback.print_exc(None, f) > > > > write_to_database(f.getvalue()) > > > > HTH > > Siggy Thanks alot for the code above, this is what I was looking for. Also sorry, I should have known about the traceback module - obviously didn't read the python reference manual carefully anough ;-( here's some code to do a test: import sys, traceback, StringIO x = 5 def boo(n): x.append(n) # raises AttributeError try: boo(6) except: f = StringIO.StringIO() print "Start" traceback.print_exc(None, f) #s = f.getvalue() # this works s = f.readlines() # empty array print s f.close() print "End" f.readline() returns an empty array, but shouldn't have traceback.print_exc(None, f) filled f, so that 'readlines' can access it? thanks very much, Arne From jeremy at alum.mit.edu Tue Feb 27 10: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 zamurai at gmx.net Fri Feb 9 08:37:21 2001 From: zamurai at gmx.net (Zamurai) Date: Fri, 9 Feb 2001 14:37:21 +0100 Subject: I love Python References: <960qnb$p3t$1@mail.cn99.com> Message-ID: <981725841.459312559@news.t-online.de> "debugboy" wrote: > Test From stadt at cs.utwente.nl Mon Feb 5 17:31:59 2001 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Mon, 05 Feb 2001 23:31:59 +0100 Subject: cgi.FieldStorage() problem References: <3A7F20D9.4BE57828@cs.utwente.nl> Message-ID: <3A7F29DF.17D5C91C@cs.utwente.nl> Richard van de Stadt wrote: > > Hi, > > I have a problem, which seems to happen with 2.0, and not with 1.5.2 Not true, Python 1.5.2. has the same problem. On another system this does not happen, so I assume it's a kernel setting. Richard. From emile at fenx.com Thu Feb 22 23: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 parkw at better.net Mon Feb 26 16: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 fredrik at pythonware.com Sun Feb 18 16:35:37 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 18 Feb 2001 21:35:37 GMT Subject: None assigment References: <3A857E90.18EE0634@engcorp.com> <981857533.2047761672@news.silcom.com> Message-ID: Thomas Wouters wrote: > It's *mostly* harmless. Consider > > spam, None, eggs, None = string.split("this is a string") > viking = filter(None, (spam, eggs)) now put them both in the same function, with the filter statement on line 5 and the split on line 65. trust me, you can waste lots of time trying to figure out what causes that "NameError: None" message on line 5... Cheers /F From cbaumann at post.ch Sun Feb 11 09:03:37 2001 From: cbaumann at post.ch (Carmen Baumann) Date: Sun, 11 Feb 2001 15:03:37 +0100 Subject: language switching References: <9634c9$p2m$1@nnrp1.deja.com> Message-ID: <3a869c62$1_1@news.datacomm.ch> On OpenVMS, never a problem. During the debug session just tell the debugger: set lang c set lang ada set lang pascal whatsoever Jakob Emmanuel STAPF schrieb in im Newsbeitrag: B6AB8878.E2F%manu_no_address at no_spam_svp.org... > > what would be needed to debug code going across two languages, such as > > python and eiffel, maybe with a little c in between (ie for gtk), maybe > > over corba or xmlrpc? > > If you take the new .NET technology from Microsoft, Eiffel# from ISE Eiffel > and Python from ActiveState. You don't have to do anything, it is simply > there for you to do cross language development and debugging. > > Manu > From rozen at rgelpc254.rgv.hp.com Wed Feb 14 12: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 donn at oz.net Mon Feb 19 01: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 nospam at mega-nerd.com Wed Feb 14 02:49:08 2001 From: nospam at mega-nerd.com (Erik de Castro Lopo) Date: Wed, 14 Feb 2001 07:49:08 GMT Subject: Attention Travis Oliphant References: <3A7CE79E.455935D0@mega-nerd.com> <3A8A0C15.D2F13D84@nospam.ieee.org> Message-ID: <3A8A364C.2F124DA4@mega-nerd.com> John D. Gorman wrote: > > Eric, > I had the same question a few weeks ago. Those files are now > being maintained at Travis Oliphant's Python Pages which is at > http://pylab.sourceforge.net/ . > > Cheers, > John Gorman Thank you, thank you thank you!!!!! Erik -- +----------------------------------------------------------+ Erik de Castro Lopo nospam at mega-nerd.com (Yes its valid) +----------------------------------------------------------+ "Using Java as a general purpose application development language is like going big game hunting armed with Nerf weapons." -- Author Unknown From stephen_purcell at yahoo.com Fri Feb 23 09: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 bsb at winnegan.de Thu Feb 22 18: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 not.this at seebelow.org Thu Feb 15 22: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 aahz at panix.com Thu Feb 8 23:49:44 2001 From: aahz at panix.com (Aahz Maruch) Date: 8 Feb 2001 20:49:44 -0800 Subject: None assigment References: <95umoi$is5$1@panix2.panix.com> <_BHg6.195181$ge4.67634054@news2.rdc2.tx.home.com> Message-ID: <95vst8$1na$1@panix2.panix.com> In article <_BHg6.195181$ge4.67634054 at news2.rdc2.tx.home.com>, Rainer Deyke wrote: >"Aahz Maruch" wrote in message >news:95umoi$is5$1 at panix2.panix.com... >> >> What you're missing is the issue of Python scopes. Try this: >> >> b=2 >> def foo(): >> b=4 >> print b >> del b >> global b >> print b >> foo() > >And what *you*'re missing is that whether a variable is local or global is >determined at compile time (in the absensce of 'exec' or 'from ... import >*'). The above does not work. It doesn't, eh? Did you try running it? (After a few blunders of my own, I rarely post code to c.l.py without testing it -- just to make sure.) Note that this is not the same as the issue with None, but it's still a scoping 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 "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 sholden at holdenweb.com Wed Feb 28 12: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 apederse at my-deja.com Fri Feb 9 10:53:08 2001 From: apederse at my-deja.com (apederse at my-deja.com) Date: Fri, 09 Feb 2001 15:53:08 GMT Subject: urllib.open('http://www.redherring.com/') References: <95th67$36j$1@nnrp1.deja.com> <95tj33$4g1$1@nnrp1.deja.com> <3A825A68.B1023097@intertrader.com> <95tq9r$afs$1@nnrp1.deja.com> <9607c5$bkj$1@nnrp1.deja.com> <3ditmj99pd.fsf@ute.cnri.reston.va.us> Message-ID: <9613ov$367$1@nnrp1.deja.com> In article <3ditmj99pd.fsf at ute.cnri.reston.va.us>, Andrew Kuchling wrote: > apederse at my-deja.com writes: > > to me it looks like the problem lies whithin python itself? is there any > > point in reporting such bugs when everyone will soon be using python 2.0 > > anyway? > > I don't believe urllib or httplib were massively rewritten for 2.0 > (nor will they be in 2.1), so if it's a bug, it's probably still > there. On the other hand, if you try it with 2.0 and it works fine, > then there won't be much interest; a 1.5.3 release is not going to > happen. > > --amk > > a 1.5.3 release is a bit drastic ...a simple bugfix will do! /Asle Sent via Deja.com http://www.deja.com/ From me at nospam.net Wed Feb 7 00: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 DSHIN at nc.rr.com Fri Feb 2 01: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 dale at out-think.NOSPAMco.uk Thu Feb 1 03: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 matt at mondoinfo.com Thu Feb 22 18: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 erno-news at erno.iki.fi Sun Feb 18 20: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 mbel44 at dial.pipex.net Mon Feb 19 13: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 micheljonas at web.de Sun Feb 4 11:42:14 2001 From: micheljonas at web.de (Michael Jonas) Date: Sun, 4 Feb 2001 17:42:14 +0100 Subject: Win Development Message-ID: I'm going to start a bigger project which is primary based on a Win32 Environment. Cause I used python only on IRIX and Linux the last years, I'm not used to the Win32 environment and I think I need some tips how to organize the whole stuff. What I did till here: I installed the python20 binary dist to C:\PYTHON20 and put the source dist to C:\PYTHON20SRC. I compiled the Release and the Debug version. Now there are some conceptual questions... Should I copy the self_build (debug and release?) libs, dll and exe files to the binary dist and do my Development there?!? Or do I leave the stuff in the source dist to code my C Modules?!? And build python Modules in the binary dist!? Or should I develop my C-Modules in the source dist and put the result to the binary Dist?!? Or should I put the source into the root of my binary dist ?!? I've allready seen that VC debugger (and the look at Python's source) is one of my best friends and I want to make it find everything as required. ( I used vi the last years...) So maybe there are some additional benefits using VC. By the way... is there a way to do Python development in VC's interface?!? I could go on and try every solution myself, but there's a lack of expirience with the Win32 Concept. On Linux I was used to build my C-Modules in the source tree and get them installed using make. I was a little bit confused that there's no installer which put's everything in place from the source dist, or at least I did not find it. Thanks in advance... Michael ----------------------------------------- Michael Jonas Das Werk Digitale Bildverarbeitungs GmbH mail: mj at muc.das-werk.de phone: +49(89)368148-700 fax: +49(89)368148-111 ----------------------------------------- From amk at mira.erols.com Tue Feb 20 19: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 tim.one at home.com Thu Feb 22 17: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 apederse at my-deja.com Mon Feb 12 05:42:48 2001 From: apederse at my-deja.com (apederse at my-deja.com) Date: Mon, 12 Feb 2001 10:42:48 GMT Subject: urllib.open('http://www.redherring.com/') References: <95th67$36j$1@nnrp1.deja.com> <95tj33$4g1$1@nnrp1.deja.com> <3A825A68.B1023097@intertrader.com> <95tq9r$afs$1@nnrp1.deja.com> <9607c5$bkj$1@nnrp1.deja.com> <3ditmj99pd.fsf@ute.cnri.reston.va.us> Message-ID: <968en7$nhn$1@nnrp1.deja.com> In article , "Fredrik Lundh" wrote: > Andrew Kuchling wrote: > > I don't believe urllib or httplib were massively rewritten for 2.0 > > (nor will they be in 2.1), so if it's a bug, it's probably still there. > > on my box, it sometimes work under 1.5.2, and never > works under an unmodified 2.0 installation. > > however, the following hack works for both versions > (note the explicit socket shutdown). > is it possible to do a similar fix to urllib? (For convenience reasons I always use urllib in my applications...) btw. I'm not very familiar with how the Python community works, but I'm thinking at this point, shouldn't whoever that has been involved in the programming of httplib and urllib be informed about the problems? /Asle Sent via Deja.com http://www.deja.com/ From hgg9140 at cola.ca.boeing.com Tue Feb 20 09: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 ssthapa at classes.cs.uchicago.edu Tue Feb 13 14: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 jafo at tummy.com Tue Feb 27 04:28:01 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Tue, 27 Feb 2001 02:28:01 -0700 Subject: [Distutils] Re: CPAN functionality for python In-Reply-To: <3A9B6D36.20B1B3C2@gmx.de>; from R.Liebscher@gmx.de on Tue, Feb 27, 2001 at 10:02:46AM +0100 References: <14984.49127.853606.286789@w221.z064000254.bwi-md.dsl.cnc.net> <20010215170227.K23577@tummy.com> <20010226013903.B3221@tummy.com> <3A9B6D36.20B1B3C2@gmx.de> Message-ID: <20010227022801.W1781@tummy.com> On Tue, Feb 27, 2001 at 10:02:46AM +0100, Rene Liebscher wrote: >3. feed the meta data and the directory in distutils > bdist_{rpm|debian|...) and create a package for the > users prefered system (RPM,...) As I understand it, the bdist_* can create a binary RPM from a set of pre-compiled binaries? Can this be used in conjunction with the other distutils tools to actually take the source file and turn it into the binaries on a given platform? If so, that's exactly what we need... Once I have the archive network back-end done, I'm going to start looking at the client. I'm getting fairly close to a bare-bones server as it is (without the admin tools -- adding a package requires some SQL). I've only looked passingly at the distutils, but will obviously have to get further into it shortly. Thanks, Sean -- Any sufficiently advanced technology is indistinguishable from a rigged demo. Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From stephen_purcell at yahoo.com Tue Feb 20 08: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 timr at probo.com Fri Feb 23 01: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 jafo at tummy.com Mon Feb 26 20:26:01 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Mon, 26 Feb 2001 18:26:01 -0700 Subject: CPAN functionality for python In-Reply-To: ; from bsass@freenet.edmonton.ab.ca on Mon, Feb 26, 2001 at 02:56:51AM -0700 References: <20010226013903.B3221@tummy.com> Message-ID: <20010226182601.D7531@tummy.com> On Mon, Feb 26, 2001 at 02:56:51AM -0700, Bruce Sass wrote: >Do you mean: Ideally, it would be able to deal with both. The ability to download a distutils package and produce a .deb or a .rpm is more a function of the client program than of the archive network... It also largely depends on distutils as well. >As for the second... it seems like an awful waste of archive space to >have the same code in many different formats, just because some want >to put stuff in /usr/share and others in /usr/lib, etc. I'm really not familiar with .deb packages. Howeer, for RPMs, if the author has included a .spec file in the tar file, you can simply run "rpm -ta foo.tar.gz" and the results will (should) be a compiled binary RPM. That is, if the author of the package has thought ahead about producing an RPM. The question becomes: Is it reasonable to require authors of packages for the archive network to do the same? Convince me it is... Sean -- "McGuyver stole all his tricks from Dr. Who." Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From nospam at no.spam Thu Feb 8 18:27:45 2001 From: nospam at no.spam (Carsten Geckeler) Date: Fri, 9 Feb 2001 00:27:45 +0100 (MET) Subject: speed comparison of IDL, numPy, Matlab In-Reply-To: <981501055.966870@clam-ext> Message-ID: On Wed, 7 Feb 2001, Mark Hadfield wrote: [snip] > > Speaking as a long-time IDL user who has dabbled with Matlab & Python/NumPy, > I'd love to switch to NumPy, and I'd do it tomorrow if the graphics > capabilities were there. Although I haven't tried it myself yet, there was mentioned a package collection called PyDL just a few days ago on this list. The URL is http://nickbower.com/computer/pydl Ciao, Carsten -- Carsten Geckeler: carsten dot geckeler at gmx dot de To get proper email-address replace `dot' and `at' by the corresponding symbols. From stephen_purcell at yahoo.com Thu Feb 22 05: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 rapto at arrakis.es Fri Feb 23 08: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 wolfgang.grafen at marconi.com Wed Feb 21 11: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 vonehr at ira.uka.de Wed Feb 7 05:52:47 2001 From: vonehr at ira.uka.de (Markus von Ehr) Date: Wed, 07 Feb 2001 11:52:47 +0100 Subject: COM objects in threads References: <3A7E8176.2B2DBB@ira.uka.de> Message-ID: <3A8128FF.268F5EDC@ira.uka.de> Thanx for all answers, finally I could solve the problem using the pythoncom.CoMarshalInterThreadInterfaceInStream without the book (just kiddin Mark ;-) ), after having two beers and taking a sharp look at the testMarshal.py program. The last problem was a repeated COM call in the Thread. It is only possible, if CoUninitialize is omitted. try: pythoncom.CoInitialize() if first_ThreadCall == 1: interp = pythoncom.CoGetInterfaceAndReleaseStream(Globals.interpStream, pythoncom.IID_IDispatch) interp = win32com.client.Dispatch(interp) doc = interp.Document mplayer = doc.body.children("MediaPlayer1").object first_ThreadCall = 0 mplayer.FileName = "C:/Programme/Python/lightcontrol/null.wav" except pythoncom.com_error, details: print "Pythoncomerror, ", details The first time I thought the COM interface is the biggest shit in the world but know I think it is quite a simple interface, when it works. I'm just implementing my next COM interface using win32com. But it's quite slow. Markus. From fredrik at pythonware.com Thu Feb 22 12: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 chris.gonnerman at usa.net Mon Feb 12 21: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 ngreco at softhome.net Mon Feb 19 16: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 ptb at oboe.it.uc3m.es Wed Feb 21 06: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 dubois at users.sourceforge.net Wed Feb 14 18: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 apederse at my-deja.com Thu Feb 8 02:17:30 2001 From: apederse at my-deja.com (apederse at my-deja.com) Date: Thu, 08 Feb 2001 07:17:30 GMT Subject: urllib.open('http://www.redherring.com/') Message-ID: <95th67$36j$1@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). I have tried to rule out any possible causes, such as cache and problems regarding headerfields by emulating a real browser request from netscape and konqueror (using fancyURLopener) and I have monitored network traffic using tcpdump. Using tcpdump it looks like there is a request sendt to vip.redherring.com and a response coming back. Could anyone look into this problem and see if this is related my particular computer and network configurations or if it is a problem lying within urllib or python. best regards, /Asle Sent via Deja.com http://www.deja.com/ From jeremy at alum.mit.edu Tue Feb 13 00:03:51 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Tue, 13 Feb 2001 00:03:51 -0500 (EST) Subject: Python 2.1 release schedule In-Reply-To: <3A895617.C7EDB5C8@javanet.com> References: <3A895617.C7EDB5C8@javanet.com> Message-ID: <14984.49207.794730.539580@w221.z064000254.bwi-md.dsl.cnc.net> >>>>> "RH" == Raymond Hettinger writes: RH> 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. RH> Call me superstitious, but going final on Friday, April 13th RH> in the first year of a new millineum, at tax time seems a RH> trifle risky. Because we're more likely to get audited or because we'll sit watching the download statistics and forget to file our taxes? Jeremy From robin.thomas at starmedia.net Sun Feb 25 16:02:28 2001 From: robin.thomas at starmedia.net (Robin Thomas) Date: Sun, 25 Feb 2001 16:02:28 -0500 Subject: Working, posting with html-forms.. In-Reply-To: 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 SBrunning at trisystems.co.uk Tue Feb 6 08:41:50 2001 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 6 Feb 2001 13:41:50 -0000 Subject: do...while loops Message-ID: <31575A892FF6D1118F5800600846864D5B17BB@intrepid> > From: Langa Kentane [SMTP:LangaK at discoveryhealth.co.za] > Why is is it while 1: Because 1 is considered a true value, so this while loop will run forever. Or until broken, hopefully! > would while 2: > or while 3: work? Yup - any non-zero number is considered true. They wouldn't do anything different, though, and they just might confuse someone. (Why 2?) 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 robin at jessikat.fsnet.co.uk Fri Feb 2 19: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 not.this at seebelow.org Sun Feb 18 23: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 aleaxit at yahoo.com Fri Feb 2 09: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 gregj at pobox.com Thu Feb 1 14: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 stephen_purcell at yahoo.com Fri Feb 16 03: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 cg at schlund.de Fri Feb 23 04: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 fredrik at effbot.org Fri Feb 2 15: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 mertz at gnosis.cx Thu Feb 15 15: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 burkhard.kayser at freenet.de Tue Feb 6 16:06:15 2001 From: burkhard.kayser at freenet.de (Burkhard Kayser) Date: Tue, 6 Feb 2001 22:06:15 +0100 Subject: timeoutsocket - error 10022 Message-ID: <95pp8k$o0r$02$1@news.t-online.com> I want to user timeoutsocket together with telnetlib. File "F:\PythonScripts\tn.py", line 13, in ? tn = telnetlib.Telnet(HOST) File "f:\python20\lib\telnetlib.py", line 122, in __init__ self.open(host, port) File "f:\python20\lib\telnetlib.py", line 139, in open self.sock.connect((self.host, self.port)) File "f:\python20\lib\timeoutsocket.py", line 210, in connect return self.connect(addr, dumbhack=1) File "f:\python20\lib\timeoutsocket.py", line 182, in connect sock.connect(addr) File "", line 1, in connect error: (10022, 'Invalid argument') I seems that the value of addr is incorrect. But if I test the script in by stepping through the code it works. I'm running ActivePython build 202. Has anyone had the same problem. From aleaxit at yahoo.com Sat Feb 3 04: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 scarblac at pino.selwerd.nl Sun Feb 18 11: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 fredrik at pythonware.com Wed Feb 7 17:06:18 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Feb 2001 22:06:18 GMT Subject: Python wierdness References: Message-ID: Roger wrote: > In my Python musings I came across a bit of seeming wierdness not Python's fault, really. > >>> x % 0.1 > 0.1 > >>> > >>> # Obviously, x modulo 0.1 is indeed equal to 0.1. obviously, x modulo 0.1 *prints* as 0.1 under 1.5.2. doesn't mean that it contains exactly the same bits, does it? let's see: >>> (0.3 % 0.1) - 0.1 -2.77555756156e-017 nope. > ... # If we pass it to foo(), we should see "bar", right? obviously not. > >>> # Hmmm... "no bar." So foo() doesn't agree that > ... # x modulo 0.1 is equal to 0.1, even though the > ... # command line shows that it is. Why not? full story here: http://www.python.org/cgi-bin/moinmoin/RepresentationError also note that Python 2.0 shows more precision: >>> x = 0.3 >>> x % 0.1 0.099999999999999978 > What's going on here, and how could one get around it? unless you know exactly what you're doing, don't use "==" on floating point values. alternatives: if abs(a - b) < some_small_value: ... or even if str(a) == str(b): ... Cheers /F From aleaxit at yahoo.com Tue Feb 20 07:37:40 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 20 Feb 2001 13:37:40 +0100 Subject: Is Python for me? References: <20010210175216.26827.00000474@ng-mh1.aol.com> <965fhd02uv1@news2.newsguy.com> Message-ID: <96toeh012hd@news2.newsguy.com> "Kendall G. Clark" wrote in message news:slrn994ieu.utn.kclark at cmpu.net... > On Sun, 11 Feb 2001 08:37:56 +0100, Alex Martelli wrote: > > >If I wanted to meet your constraints 1-5, I'd be torn between Haskell > >(no objects, but...) > > Well, there's always O'Haskell > http://www.cs.chalmers.se/~nordland/ohaskell/ [snip] > 1. There's something Alex Martelli doesn't know; and Yes (such as: what is the best C-coded ANOVA package for Python... see my latest post!), but the (non-empty) set does not include O'Haskell (nor, alas, Mondrian -- which is a hack of which respondent sayeth no further). O'Haskell looks cool, but I just would not recommend it within the given constraints 1-5 (which I invite you to review) -- it may mature into something *really* great, but it's still at "rabid early-adopters" stage now (IMHO). > 2. the Timbot is (still) spreading about the hoary 'Common Lisp is > *really* huge' myth[1]? Wasn't that in the context of a comparison with Scheme? In which case, it seems to me that it's no myth, but simple fact. It's not an issue of dimension of executable images, etc -- it's an issue of how big the *language* (with its libraries) is. CLisp is right up there with C++, Ada, etc, in the "really huge languages" class (Java is an interesting anomaly -- middling *language*, but the 'standard libraries' are *SO* deucedly MANY, that overall it may be considered big again:-). I don't particularly care if some clever compiler is able to turn: #include int main() { std::cout<<"Hello world!\n"; } into a "completely standalone" executable of 392 bytes or less -- that doesn't make *C++* any smaller. (How many alleged C++ users KNOW that the 'int' here is mandatory _but_ it's OK to leave the "return 0;" out because it's IMPLIED if function ::main -- and IT only -- "falls off the end"...? just a tiny example of the kind of things that make a _language_ "big" -- lots of "convenient" ad-hoc little special-cases and such...:-). Alex From soerense at verwaltung.uni-mainz.de Thu Feb 1 10: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 fuess at att.net Wed Feb 28 08: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 herne at orcon.net.nz Sat Feb 10 17:45:21 2001 From: herne at orcon.net.nz (Grant) Date: Sun, 11 Feb 2001 11:45:21 +1300 Subject: Should I use Python? References: <3A84BBA7.74688DFD@orcon.net.nz> Message-ID: <3A85C481.7539DC3F@orcon.net.nz> "Michael P. Soulier" wrote: > On Sat, 10 Feb 2001 16:55:19 +1300, Grant wrote: > >I have been creating some useful utilities in java and now find other > >people I work with also wish to use them. Problem is they are > >applications and require the java runtime environment to be installed. > > > >I would prefer to be able to write the utilities on Linux as I do now. > >The file created must be able to be run by others on NT machines - > >either from a server or from their own machines. It should not require > >any additonal setup or libraries to install, and will need to read from > >remote servers on a local network, reading and parsing files. > > > >Would Python be the best choice?Any other suggestions? > > The only way to do what you're talking about is to distribute binaries for > the target platform. Python is a good choice if you want to use the frozen > tool and compile the Python to native code. > > Mike Thanks - I will keep it in mind. Learning a new language is always a big step - I am still looking around at what best suits my needs. From corour01 at motorola.com Thu Feb 22 04: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 hgg9140 at cola.ca.boeing.com Mon Feb 19 15: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 lsloan at bigfoot.com Mon Feb 19 20: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 chris at voodooland.net Sat Feb 3 00:49:48 2001 From: chris at voodooland.net (Chris Watson) Date: Fri, 2 Feb 2001 23:49:48 -0600 (CST) Subject: MySQLdb on a VPS... In-Reply-To: Message-ID: > I'm at a total loss here and desperately need help!!! I'm trying to install > the MySQLdb module but this is what I get... (running FreeBSD4.2 on a VPS, > note my "/usr/home/axiomfir/" prefix to all folder listings) Trace, If your on FreeBSD why dont you just use the py-MySQLdb port? cd /usr/ports/databases/py-MySQLdb make install make clean And thats it. It's already been ported. Is there a reason the port wont work in your scenario? -- ============================================================================= -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 rytrom at zootec.com Wed Feb 14 09: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 thomas.heller at ion-tof.com Thu Feb 8 10:45:04 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 8 Feb 2001 16:45:04 +0100 Subject: Problem with py2exe References: <95s54j$c72$1@gossamer.itmel.bhp.com.au> <3A8231D4.1E5951A6@engcorp.com> Message-ID: <95ueuo$iseg7$1@ID-59885.news.dfncis.de> "Peter Hansen" wrote in message news:3A8231D4.1E5951A6 at 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! I have just uploaded a new release 0.2.2. If the problem still occurs with this version, I would certainly like to find this bug. Thanks, Thomas From boswell at caltech.edu Tue Feb 13 07: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 ullrich at math.okstate.edu Tue Feb 6 16:51:19 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Tue, 06 Feb 2001 21:51:19 GMT 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: <95prki$tt4$1@nnrp1.deja.com> In article , "Don Tuttle" wrote: > "David C. Ullrich" wrote in message > news:3a8012f5.7625600 at nntp.sprynet.com... > > Delphi's "with" is more or less the same < as vbscript> except without the > > dots at the start of the field names. For a long time I've > > seen Delphi people say that with is bad, the reason > > being it leads to bugs > > > > with AnObject do > > begin > > OneThing > > AnotherThing > > end > > > > when AnObject does not have a OneThing method > > but there _is_ a OneThing in the surrounding scope. > > I'm not familar with Delphi, but I suspect this is why vbscript uses the > leading 'dot' notation. No doubt. > > Right or not, it certainly seems contrary to the > > "explciit is better than implicit" philosophy. > > Perhaps I'm missing something but using a keyword to define a single block > of code seems very explicit (ie Select Case). Again, maybe the leading 'dot' > makes all the difference. I didn't mean to get into off-topic heresy, but I don't know what you mean by calling this "explicit". The problem is that the methods could be methods of AnObject or they could have nothing to do with AnObject. As opposed to an explicit AnObject,OneThing. > Don > > > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > > > >Here's a vbscript example. > >> > > >With MyLabel > > > .Height = 2000 > > > .Width = 2000 > > > .Caption = "This is MyLabel" > > >End With > >> > > >Personally, I'd love to see Python include the 'with' keyword! It > improves > > >readability and should execute a bit faster as well. > > -- Oh, dejanews lets you add a sig - that's useful... Sent via Deja.com http://www.deja.com/ From stephen_purcell at yahoo.com Fri Feb 23 13: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 loewis at informatik.hu-berlin.de Tue Feb 20 08: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 wilson.austin.aj at bhp.com.au Wed Feb 7 13:45:47 2001 From: wilson.austin.aj at bhp.com.au (Austin Wilson) Date: Thu, 8 Feb 2001 05:45:47 +1100 Subject: Problem with py2exe Message-ID: <95s54j$c72$1@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 From n8gray at caltech.edu.is.my.e-mail.address Tue Feb 20 23: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 zzizz_ at notmail.com Sat Feb 24 02: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 mertz at gnosis.cx Thu Feb 22 13: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 fredrik at effbot.org Wed Feb 7 08:42:00 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 07 Feb 2001 13:42:00 GMT Subject: Some basic questions about Tkinter (probably v easy for experts!) References: Message-ID: Martyn Quick wrote: > (1) If I am going to use Pmw, then I need to have Tkinter installed. But > do I need to understand how to use Tkinter (at least to a basic > degree) before I can use Pmw? cannot hurt -- Pmw just adds (a whole bunch of) new components to Tkinter. > (2) Should a typical Tkinter program contain the following sort of lines: > > from import Tkinter * > aardvark = Tk() > aardvark.mainloop() > > Am I right in thinking the last line is what produces the Tk window and > that without it nothing would happen? Do I then just attach widgets the > aardvark object defined above and further widgets to these ones, etc.? have you read the introduction document? the first chapter seems to answer your questions: http://www.pythonware.com/library/tkinter/introduction/hello-tkinter.htm > (3) How do I run such a program? Is the right way to open up a DOS box > (I'm using Windows 95) and type python aardvark.py at the prompt? fwiw, that's what I usually do (when I'm not using PythonWorks). > (4) Will the following correctly add a menu to my aardvark object? short answer: almost. > from sys import exit > armadillo = Menu(aardvark) this creates a menu component instance. > armadillo.add_cascade(label="File") this adds a submenu to the admadillo menubar. but you didn't pass in the submenu instance, so there's nothing to display when the user clicks on "File"... try this instead: filemenu = Menu(armadillo) # create a submenu armadillo.add_cascade(label="File", menu=filemenu) > 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. if you want to add it to the file menu instead of the armadillo menubar, try this: filemenu.add_command(label="Exit", command=exit) finally, you need to attach the menu to your window: aardvark.config(menu=armadillo) > If this isn't right - what is right, and more importantly *why* is it > right? http://www.pythonware.com/library/tkinter/introduction/x953-menus.htm hope this helps! Cheers /F From lawick at wanadoo.nl Tue Feb 6 04:54:57 2001 From: lawick at wanadoo.nl (lawick at wanadoo.nl) Date: 06 Feb 2001 09:54:57 GMT Subject: SOAP Message-ID: <3a7fc9f1$0$11094@reader4> Is there a SOAP module available for Python? Cheers, Joost -- Joost van Lawick E: lawick at wanadoo.nl W: http://home.wanadoo.nl/lawick From phrxy at csv.warwick.ac.uk Mon Feb 26 13:56:37 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Mon, 26 Feb 2001 18:56:37 +0000 (GMT) Subject: [Distutils] Re: CPAN functionality for python In-Reply-To: <200102261822.NAA26272@cj20424-a.reston1.va.home.com> Message-ID: On Mon, 26 Feb 2001, Guido van Rossum wrote: [...] > 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.) Surely this is a function of free vs. non-free software as opposed to which particular packaging format you are using? John From cfelling at iae.nl Thu Feb 8 17:44:32 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 8 Feb 2001 23:44:32 +0100 Subject: python-dev summary, Jan. 16-31 References: <3d4ry56vzg.fsf@ute.cnri.reston.va.us> Message-ID: <95v7gg$8ne$1@animus.fel.iae.nl> Andrew Kuchling wrote: > Envoi > ===== > This will be the last python-dev summary I write, accounting for its > rushed and sketchy quality. This is really, really, really sad news! You know, by reading your nice wrapups on the discussions in python-dev I better understood why things changed as they did. And more over it gave me a good community feeling, it opened up the development process to us mere mortals:) > The goal of these summaries has been to make the discussions on > python-dev more visible to the community, letting people offer timely > comments while a thread is still reasonably current and fresh in > memory. Unfortunately that doesn't seem to happen, and no messages to I guess that you did to good a job, your wrapups informed me that new proposals were thouroughly discussed, and mostly the objections I had I shared with someone more knowledgable *and* involved in the development so no need to react. > The release of 2.1 offers a second calibration on their effectiveness. > 2.1 is the first Python release to have been carried out using PEPs as > the mechanism, so there are no sizable changes in 2.1 that don't have > a corresponding PEP. Yet many people were *surprised* by some of the > changes in Python 2.1 such as function attributes and nested scopes, > even though PEPs were written and discussed, often in lengthy threads > months ago. To me that's because the status of the PEPS isn't cristal clear. You have to frequent the PEPS status page and keep an eye on changes there. It would be much easier (for me atleast:) if someone (you again:) would inform us that the status of a PEP changed. I know all the needed info is availeble right now, but I've to go out (on the net) and go over lots of messages just to get the info you summed up so nicely for me all those months. Prior to your wrapups I really had no idea were Python development was heading, so I really liked it. -- groetjes, carel From jpet at eskimo.com Sun Feb 25 15: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 n8gray at caltech.edu.is.my.email.address Sat Feb 24 19: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 tim_one at email.msn.com Sun Feb 11 00:45:05 2001 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 11 Feb 2001 00:45:05 -0500 Subject: Is Python for me? In-Reply-To: <20010210175216.26827.00000474@ng-mh1.aol.com> Message-ID: [DvdAvins] > ... > I'm looking for as many of the following traits as possible: I bet you're not married . > 1:a functional language. I've been intrigued by functional > languages for a while, but have had no occasion to use them at work. > 2: automatic garbage collection and other programmers' > convenience features (I still have to take care of my day job) > 3: support for objects (not necessary, just a convenience) > 4: it MUST be distributable as a stand-alone program for Windows. You have to understand that this one implies large executables, because the language's entire runtime system and libraries have to be built into the standalone. Standalones for, e.g., C programs can be much smaller, because they can *assume* every system already has the standard C runtime libraries installed (or a JVM, in the case of Java). > I'd like to be able to distribute to Mac and Linux as well. This is at odds with desiring standalones, unless you want to build a different standalone for every platform. > 5. there has to a good book on the language available in English > or at least an IDE with and excdellent help environment. > > I'm investigating at M, Don't know it. > Python, Not functional at heart; making standalones is possible with enough pain but not how the language was intended to be used (i.e., you'll fight it in this area). > BETA, Could be cool. Unsure about license restrictions (it's a commercial product). > Scheme, Many, many implementations available, and generally compact. Does it support objects? Sure, provided you build them yourself -- which is a common answer to many "how do I xyz?" questions in Scheme. Nevertheless, it's a beautiful little language. > Haskell, Lots of fun. See also Clean (which was designed to make standalones): http://www.cs.kun.nl/~clean/ > Icon, Not functional; difficult to make standalones; no native support for objects; but unique in many respects and well worth learning anyway. > and Common Lisp. Huge. Really huge. > Which would you use? Python. > Why? This is a Python newsgroup. Stick around and you'll get a few thousand answers to that every month without even asking . python-scores-highest-on-"plays-well-with-others"-ly y'rs - tim From claird at starbase.neosoft.com Wed Feb 21 11: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 aahz at panix.com Thu Feb 1 14: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 fredrik at pythonware.com Sun Feb 11 16:28:41 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 11 Feb 2001 21:28:41 GMT Subject: Where goes stdout ? References: <966iqa$lu5$1@reader1.imaginet.fr> Message-ID: Siggy Brentrup wrote:> > > How to check in a script if stdout is a console (or xterm) or if it is > > redirected to something else (file, pipe...) from command line. > > import os, sys > > if os.isatty(sys.stdout.fileno()): > # output goes to a tty or: if sys.stdout.isatty(): # output goes to a tty Cheers /F From tismer at tismer.com Fri Feb 23 14: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 shaleh at valinux.com Mon Feb 19 13: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 xyzmats at laplaza.org Tue Feb 27 12: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 max at alcyone.com Wed Feb 28 11: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 donn at oz.net Fri Feb 9 12:18:47 2001 From: donn at oz.net (Donn Cave) Date: 9 Feb 2001 17:18:47 GMT Subject: python-dev summary, Jan. 16-31 References: Message-ID: <9618pn$mfv$0@216.39.151.169> Quoth Simon Brunning : |> From: Andrew Kuchling [SMTP:akuchlin at mems-exchange.org] |> * Announce PEP drafts and status changes to c.l.py.announce |> * Write a set of introductory pages for Python development (this has been |> brought up before). |> * A read-only alias for python-dev would be useful for several people, but |> |> may require serious Mailman hackery (I don't know). | | Sounds to me like if these three could be achieved, 99.9% of c.l.py would be | more than happy. I know that *I* would. Since you presume to speak for 99.9% of c.l.py, it's fair for me to suggest you don't know what you're talking about. I doubt even the present membership of python-dev really has time to read it, and very few of us with only an observer's interest are going to be able to keep up. I'm not making this up, see comments in this thread. Most of us don't have even the knowledge to always follow what's going on. Which has been part of the value of the summaries, digested by someone who does. I would be more than happy if I didn't have any reason to read python-dev. Donn Cave, donn at oz.net From dima at xenon.spb.ru Sat Feb 10 19:40:02 2001 From: dima at xenon.spb.ru (Dmitry Rozmanov) Date: Sun, 11 Feb 2001 03:40:02 +0300 Subject: test2 Message-ID: <964n12$6c7$1@news.wplus.spb.ru> test. direct test. From root at rainerdeyke.com Sat Feb 17 02: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 gregj at pobox.com Sun Feb 25 14: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 stephen_purcell at yahoo.com Fri Feb 9 08:46:02 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Fri, 9 Feb 2001 14:46:02 +0100 Subject: How to write integers to a file? In-Reply-To: ; from ssartor@bellatlantic.net on Fri, Feb 09, 2001 at 01:06:36PM +0000 References: Message-ID: <20010209144602.A4920@freedom.puma-ag.com> Steven Sartorius wrote: > I'm trying to write a series of whitespace delimited integers to a file. > The 'write' method only accepts strings and using arrays produces binary > data when I open the file with less. What I want is somehting like > printf for python. Is there any easy way to do this? (there must > be...this is python!) > Yep:- >>> "the number is %d" % 5 'the number is 5' >>> See the docs at: http://www.python.org/doc/current/lib/typesseq-strings.html But for your case, maybe you just want to do the following >>> ints = range(5) >>> import string >>> string.join(map(str, ints), ' ') '0 1 2 3 4' -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Available for consulting and training. "Even snakes are afraid of snakes." -- Steven Wright From jmarshal at mathworks.com Mon Feb 19 20: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 joconnor at cybermesa.com Fri Feb 16 17: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 tim.one at home.com Sun Feb 18 16: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 grante at visi.com Thu Feb 8 15:37:42 2001 From: grante at visi.com (Grant Edwards) Date: Thu, 08 Feb 2001 20:37:42 GMT Subject: [xyz]modem module? Message-ID: A couple months back somebody asked about Python [xyz]modem support, but I didn't find any positive answers with deja. Did anybody ever find anything? If not, what's the easiest way to running program like "sz" with its stdout/stdin connected to a socket's file descriptor? Does one just do the traditional fork/close/dup/exec using the os module? -- Grant Edwards grante Yow! CHUBBY CHECKER owns at my BUILDING! visi.com From fluxent at yahoo.com Tue Feb 27 10: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 tim.one at home.com Thu Feb 1 13: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 senux at my-deja.com Mon Feb 5 10:14:22 2001 From: senux at my-deja.com (senux at my-deja.com) Date: Mon, 05 Feb 2001 15:14:22 GMT Subject: [mod_python] Getting data from FORM tag Message-ID: <95mg04$sa6$1@nnrp1.deja.com> Hi, I'm new at mod_python and want to use the fuction of embedded Python code in HTML file by mod_snake. There are 2 files. One form.html and the other is login.epy. I want to get what the web visitor inputed in
..
tag. How can I code them? Thanks in any postings. :) - Brian,. Sent via Deja.com http://www.deja.com/ From bogus@does.not.exist.com Sat Feb 3 15: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 jmarshal at mathworks.com Wed Feb 21 15: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 wilson.austin.aj at bhp.com.au Fri Feb 9 14:40:46 2001 From: wilson.austin.aj at bhp.com.au (Austin Wilson) Date: Sat, 10 Feb 2001 06:40:46 +1100 Subject: Problem with py2exe References: <95s54j$c72$1@gossamer.itmel.bhp.com.au> <3A8231D4.1E5951A6@engcorp.com> <95ueuo$iseg7$1@ID-59885.news.dfncis.de> <95uoi6$n5$1@gossamer.itmel.bhp.com.au> Message-ID: <961h3k$jrb$1@gossamer.itmel.bhp.com.au> I have just tried 0.2.2 and it seems to have worked. Regards Austin "Robin Dunn" wrote in message news:ePHg6.1649$QtQ.68550953 at news.randori.com... > > "Austin Wilson" wrote in message > news:95uoi6$n5$1 at gossamer.itmel.bhp.com.au... > > I used version 0.2.1. > > > > I have now successfully gotten the program to work but I had to do the > > following > > > > 1. Copy the exe file generated by py2exe from the dist directory to the > > winexe directory > > 2. Copy wxc.pyd and wx22_2.dll from the wxPython directory into the winexe > > directory. > > > > Try either 0.2.0 or 0.2.2. I've had success with wxPython apps with both os > these versions. > > > -- > Robin Dunn > Software Craftsman > robin at AllDunn.com Java give you jitters? > http://wxPython.org Relax with wxPython! > > > From aleaxit at yahoo.com Mon Feb 5 08:02:02 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 5 Feb 2001 14:02:02 +0100 Subject: COM objects in threads References: <3A7E8176.2B2DBB@ira.uka.de> <3A7E9BE2.1040203@ActiveState.com> Message-ID: <95m88c01cph@news1.newsguy.com> "Mark Hammond" wrote in message news:3A7E9BE2.1040203 at ActiveState.com... [snip] > You are going to have to find a reasonable reference on COM threading models, or see the "threading" appendix in "Python Programming on Win32" - that appendix was hell to write, and I am not going to attempt it again on Usenet ;-) Deja threads (no pun intended;) on the subject may also help. Don Box, "Essential COM", Addison-Wesley; a MUST if you're doing anything advanced with COM -- and communicating COM objects between multiple threads qualifies as advanced. Also very helpful reading, AFTER "Essential COM", is "Effective COM", by Box et al, also Addison-Wesley. Alex From robin at alldunn.com Wed Feb 21 18: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 fakeaddress at nospammail.com Tue Feb 6 23:14:07 2001 From: fakeaddress at nospammail.com (Ben Catanzariti) Date: Wed, 7 Feb 2001 15:14:07 +1100 Subject: Python Users Group Australia References: <3A80C151.3000504@ActiveState.com> Message-ID: Mark As you already have a mailing list up and running ... would you like to expand that to an Australian Python Users Group? or APUG ... (I think I think I got involved in IT just to use acronymns :) There is an Australian Users Group conference running this weekend ... ie (linux, Perl, Cold fusion etc etc no Python however :( ... I would consider going to try and gather a base membership ... "Mark Hammond" wrote in message news:3A80C151.3000504 at ActiveState.com... > Ben Catanzariti wrote: > > > Hi, > > > > I am looking for the existence of a Python Users Group in Australia ... does > > one exist?? > > Not as such... But there is a mailing list: > > http://starship.python.net/mailman/listinfo/python-au > > Mark. > From chris.gonnerman at usa.net Thu Feb 22 08: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 sheila at spamcop.net Mon Feb 12 01:48:20 2001 From: sheila at spamcop.net (Sheila King) Date: Mon, 12 Feb 2001 06:48:20 GMT Subject: smtplib problem References: <966mnl$2dl$1@uranium.btinternet.com> Message-ID: On Sun, 11 Feb 2001 19:40:13 GMT, "Fredrik Lundh" wrote in comp.lang.python in article : :Imran wrote: :> When using smtplib can you get the "header text" which mail servers :> introduces themselves with ? : :>>> import smtplib :>>> server = smtplib.SMTP() :>>> server.connect("localhost") :(220, 'spam.egg ESMTP pymail 1.2.3/4.5.6; Sun, 11 Feb 2001 12:34:56 +0100') :>>> server.helo() :(250, 'spam.egg Hello IDENT:fredrik at spam.egg [1.2.3.4], pleased to meet you') : :Cheers /F : Nice. And how does one do SMTP authorization? (There must be a way. I see that the NNTP module includes authorization commands, but the smtplib doesn't!) -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From clee at gnwy100.wuh.wustl.edu Sun Feb 18 10: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 tshumway at transafari.com Fri Feb 2 08: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 sheila at spamcop.net Sun Feb 25 22: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 aahz at panix.com Fri Feb 23 11: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 phd at phd.pp.ru Wed Feb 14 12: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 geoff at homegain.com Fri Feb 2 18: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 akuchlin at mems-exchange.org Tue Feb 20 12: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 db3l at fitlinxx.com Tue Feb 6 14:42:31 2001 From: db3l at fitlinxx.com (David Bolen) Date: 06 Feb 2001 14:42:31 -0500 Subject: threading.RLock not subclassible? References: <3A7D5B5F.AADAA673@ll.mit.edu> <3A7F5C74.6C9BC395@home.com> Message-ID: Rick Lee writes: > It seems to me that OS-specific behaviour of thread switching is _very_ > different among platforms. For example, if the parent thread starts up 100 > different threads each with some long loop to run: > > for i in xrange(100): > try: > t = threading.Thread(target=runObj, args=()) > t.start() > except: > break > snapshot = threading.activeCount() > > If I run it in different platforms, snapshot is consistently > different, anywhere between very close to 100, or just 1. You may > argue it depends on how long runObj takes to run; but I can change > runObj to run for a very long time, say seconds, and the results are > consistently different across the platforms (NT, Mac, Linux). I suppose the question is why would the difference in shapshot be a problem to an application? What you're seeing is that how threads are dispatched at creation with respect to the currently executing thread can differ across platforms (and presumably whether the thread support is native or how deep in the OS it is supported). But it's not really a problem, per se, except that it's something that's part and parcel of multi-threaded development. By it's nature, when you attempt to start threads their execution with respect to the starting thread is asynchronous and unrelated. I'm guessing the two major cases you're seeing are either (a) when each new thread gets some execution time right at creation and (b) when the main thread runs to completion before any of the created threads really got started. Thus having nearly a full count versus just a count of your main thread. Changing the runtime of runObj won't likely change that since it's the the scheduling aspect of the separate threads with respect to the main thread that is causing the behavior. You might find though that adding a delay to your main thread in between (or just after) the creation of the other threads gives them all a chance to start. If it's important to you that all of the threads actually begin executing before you continue the main thread, you'll need to use some sort of event or other notification mechanism (the quickest way being a slow loop that waits until the activeCount shows all threads). You can't assume that the execution timeframe of the main thread will have any specific correlation (technically even on the same platform, much less cross-platform) to the execution timeframe of the other threads. > I have some even weirder differences, if I use say time.sleep(.001) > inside a thread, as the FAQ says. And I have a few other examples I > ran across. (The one that bugs me the most is that some blocked > threads in the Mac just don't get to run, when the blocking > condition is removed.) Can you be more specific as to the other wierder differences - they may just be natural behavior in a multi-threaded environment. Adding a time.sleep() within a thread will typically cause that thread to yield it's control of the processor, and some other thread will get dispatched, but that's about it. Within Python, time.sleep() will also release the global interpreter lock, thus permitting other Python threads to execute. That can be important if you have a thread that otherwise would loop rapidly (without any natural blocking point), since it relieves some of the unnecessary CPU load. The best case is having a thread block until some event occurs that needs to be serviced. For your Mac case, how are you blocking the threads? If you have multiple threads all using wait() with a timeout on the same event, then the threading module implements the timeout wait as a loop around a non-blocking wait, and (as discussed in this thread) that can result in a thread never being woken up, since the looping construct is not atomic. But I believe that uncertainty is cross-platform :-) But if you use non-timeout waits, then I believe it should eventually wake up, although the order may be non-deterministic, although someone else may know more about the Mac thread implementation to comment differently. -- -- 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 wcanopy at covad.net Tue Feb 13 19: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 grumble at mailcity.com Sun Feb 25 11: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 kwasi007uk at yahoo.co.uk Sat Feb 3 17:33:33 2001 From: kwasi007uk at yahoo.co.uk (kwasi007uk at yahoo.co.uk) Date: Sat, 03 Feb 2001 22:33:33 -0000 Subject: Syntax Error Message-ID: <95i0vt+kju6@eGroups.com> Using e.g. poplib, m=poplib.POP3 ... I typed in error m.quit. It should have been m.quit(). Why doesn't Python give me an error message? It definitely should since q.quit does not exist! From fimafeng at yahoo.com Tue Feb 20 21: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 janne at oops.nnets.fi Tue Feb 20 17: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 aleaxit at yahoo.com Mon Feb 5 08: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 urner at alumni.princeton.edu Tue Feb 13 16: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 adam at deprince.net Wed Feb 21 15: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 phd at phd.pp.ru Wed Feb 14 11: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 porter at et.byu.edu Sun Feb 11 01:29:41 2001 From: porter at et.byu.edu (C. Porter Bassett) Date: Sat, 10 Feb 2001 23:29:41 -0700 (MST) Subject: python 2.0 won't run scripts with \r\n line termination on RH7? In-Reply-To: References: Message-ID: I have noticed the same thing. One easy work-around is to run "python start.py" instead of "./start.py". It appears that it is bash that has problems with the \r\n, not python. -------------------------------------------------------------------------- C. Porter Bassett porter at et.byu.edu http://www.et.byu.edu/~porter -------------------------------------------------------------------------- "Pretend like this is a really witty saying." - Anonymous -------------------------------------------------------------------------- On Sat, 10 Feb 2001, Mike Carifio wrote: > I have a network of Linux and Windows machines. On a Windows box, I have > several python scripts which I'd also like to run on the Linux machines. > I've > smbmounted the Windows share to see the scripts, but having been created > on the Windows box, the line termination in those files is \r\n. When I try > to execute the script, say 'start', I get: > > bash: ./start.py: No such file or directory > > When I "clean up" start.py with tr - tr -d '\r' < start.py > reallystart.py, > it > runs. So it seems like python 2 can't compensate for wierd Windows line > terminators. Any workarounds, other than 'tr'? Pl. advise. Tx. > > > -- > http://mail.python.org/mailman/listinfo/python-list > From olafb+usenet at pvv.org Thu Feb 15 08: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 duncan at rcp.co.uk Fri Feb 9 05:48:31 2001 From: duncan at rcp.co.uk (Duncan Booth) Date: Fri, 9 Feb 2001 10:48:31 +0000 (UTC) Subject: class scope questions References: <3a83bea8$0$16388$7f31c96c@news01.syd.optusnet.com.au> Message-ID: "Ben de Luca" wrote in <3a83bea8$0$16388$7f31c96c at news01.syd.optusnet.com.au>: >if i do this > >class a: > dog='woof' > > def blah(): > something > > > >how do i call a >how do i get soemthing in blah to refernce dog? either to read it or >write to it > class a: dog='woof' def blah(self): print self.dog def update(self, value): self.dog = value >>> a1 = a() >>> a1.blah() woof >>> a1.update('bow wow') >>> a2 = a() >>> a2.blah() woof >>> a1.blah() bow wow >>> But, although this works fine, there is a problem with it. dog is actually a variable in the class a until it is set by the update method when it becomes a variable in the instance a1. This works fine for strings, but if you used a mutable object such as a list or dictionary you would see that dog was shared between all instances of the class: class B: list = [] def show(self): print self.list def append(self, value): self.list.append(value) >>> b1 = B() >>> b1.append('hello') >>> b1.show() ['hello'] >>> b2 = B() >>> b2.show() ['hello'] >>> b2.append('world') >>> b1.show() ['hello', 'world'] To avoid this you should generally define an __init__ method in your class and use that to initialise any instance variables. From qrczak at knm.org.pl Sat Feb 3 08: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 info at black-karma.de Fri Feb 16 12: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 tim.one at home.com Fri Feb 23 11: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 gregj at pobox.com Thu Feb 8 02:49:55 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Thu, 08 Feb 2001 07:49:55 GMT Subject: urllib.open('http://www.redherring.com/') References: <95th67$36j$1@nnrp1.deja.com> Message-ID: <95tj33$4g1$1@nnrp1.deja.com> In article <95th67$36j$1 at nnrp1.deja.com>, apederse at my-deja.com wrote: > I have some problems with urllib. Any URL works > just fine except http://www.redherring.com/ which > returns nothing, no headers, no nothing It's broken for me, too. I can get to the site with my browser, but urllib.urlopen() hangs for a long time, then aborts with a "connection reset by peer" error. The same thing happens with httplib. -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com Sent via Deja.com http://www.deja.com/ From garabik-news at spam.melkor.dnp.fmph.uniba.sk Thu Feb 22 10: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 cg at schlund.de Thu Feb 8 13:04:40 2001 From: cg at schlund.de (Carsten Gaebler) Date: Thu, 08 Feb 2001 19:04:40 +0100 Subject: Hosting service supporting 2.0 References: Message-ID: <3A82DFB8.9DA8D438@schlund.de> Richard Blumberg wrote: > > I'm looking for a moderately priced web hosting service that supports > Python 2.0. Anyone know of any such? > www.oneandone.co.uk has Python 2.0. And as long as they don't fire me, it will always be up to date. :-) Regards Carsten. From scarblac at pino.selwerd.nl Tue Feb 27 03: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 dalke at acm.org Sat Feb 17 00: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 marvind at Glue.umd.edu Mon Feb 26 15: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 thomas at xs4all.net Sun Feb 18 17: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 bhoel at starship.python.net Fri Feb 2 15: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 thomas at cintra.no Wed Feb 21 07: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 scarblac at pino.selwerd.nl Thu Feb 22 05: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 paul.robinson at businesscollaborator.com Fri Feb 9 04:26:06 2001 From: paul.robinson at businesscollaborator.com (Paul Robinson) Date: Fri, 09 Feb 2001 09:26:06 +0000 Subject: Forking and Threads References: <3A829B94.9AF5A831@businesscollaborator.com> Message-ID: <3A83B7AE.5D312C6@businesscollaborator.com> David Bolen wrote: > > Paul Robinson writes: > > > Update: > > My last run ( forkingtest2.py -MC 50 -MS 3 ) ran for 24 minutes before > > running at a steady 99% CPU! > > What do you see in your log file leading up to the hang? Does there > seem to be continued logging during the CPU burn or is it quiet? Normal upto the the CPU burn and then nothing. > I'd > probably try to figure out just what portion of the code the main > process was in while burning CPU (it sort of looks like it could > really only be in your waitpid loop, but a few additional log messages > might be useful). Yes, I agree. The original case I was working on (in the larger program) was instrumented more heavily and I came to the conclusion that it was getting stuck at a random point! There were sockets and select involved with that as well so it was slightly more complicated. 90% of the time it would crash while doing the select - but I guess that was just because 90% of the program time was spent doing the select! > BTW, I can't actually run it here (Windows) but do you ever see a log > message from a child other than "1" - it looks like you only increment > CHILD inside the child process itself, so wouldn't all the children > get a value of 1? The value of CHILD is just there in case children are spawning children (they were in previous versions...) It ran successfully overnight using Python 2.0! Paul Robinson Business Collaborator Development Manager Enviros Software Solutions WWW: http://www.businesscollaborator.com From othello at javanet.com Tue Feb 20 19: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 max at alcyone.com Mon Feb 19 23: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 gmunsey at adobe.com Thu Feb 15 09: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 fredrik at effbot.org Mon Feb 5 14:57:09 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Mon, 05 Feb 2001 19:57:09 GMT Subject: passing keyword arguments that are themselfs python keywords References: <3A7F109D.60FD712B@sympatico.ca> Message-ID: Stefan Seefeld wrote: > I'm trying to write a python function that can take keywords such as 'class'. > Is that possible ? nope. the usual workaround is to use a trailing underscore, and strip it away inside your function: entity('div', text, class_='header') or you could force your users to use ** syntax and an ordinary dictionary: entity('div', text, **{'class': 'header'}) Cheers /F From agold at bga.com Sun Feb 18 13: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 mwh21 at cam.ac.uk Fri Feb 16 13: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 paulus132 at my-deja.com Tue Feb 6 10: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 janne at oops.nnets.fi Fri Feb 16 17: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 tim.one at home.com Wed Feb 14 03:39:52 2001 From: tim.one at home.com (Tim Peters) Date: Wed, 14 Feb 2001 03:39:52 -0500 Subject: python-dev summary, Jan. 16-31 In-Reply-To: Message-ID: [Paul Moore, among others, wants easier access to Python-Dev] Just a note to let people know that schemes are afoot to make this easier. Guido does not want to open the list up, but is quite in favor of making it easier to follow. Whether or not you're all being ignored, he certainly doesn't like it to *appear* that you're being ignored . Can't yet say exactly how, though. "Trust Guido". that-is-all-ye-know-on-earth-and-all-ye-need-to-know-ly y'rs - tim From thomas at xs4all.net Mon Feb 26 06: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 aleaxit at yahoo.com Fri Feb 9 11:29:05 2001 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 9 Feb 2001 17:29:05 +0100 Subject: What is better, JPython or Jython? References: Message-ID: <9615sm0sop@news2.newsguy.com> "Simon Brunning" wrote in message news:mailman.981729975.28507.python-list at python.org... > > 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. Funny -- exactly for this reason, I'd suggest using the _former_:-). Alex From dwig at advancedmp.net Fri Feb 16 13: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 timr at probo.com Sun Feb 18 21: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 aahz at panix.com Sun Feb 18 12: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 reborn at neozone.net Thu Feb 1 12: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 MarkH at ActiveState.com Mon Feb 5 07:30:08 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Mon, 05 Feb 2001 12:30:08 GMT Subject: COM objects in threads References: <3A7E8176.2B2DBB@ira.uka.de> Message-ID: <3A7E9BE2.1040203@ActiveState.com> Markus von Ehr wrote: > Anybody can help me accessing the mp object in the thread? How > can I set the new FileName? I have already replied to this - there is no easy answer. Either, you must ensure _all_ threads, including the main thread, are in the free-threading apartment. This will involve setting sys.coinit_flags=0 before importing pythoncom for the first time, and ensuring you call CoInitializeEx(0) on each thread you create. The only other alternative is to use pythoncom.CoMarshalInterThreadInterfaceInStream and pythoncom.CoGetInterfaceAndReleaseStream to pass a COM object between 2 apartment-model threads. The default is apartment-model threading. COM says it is illegal to share objects between apartments, and as you have seen, often enforces it! You are going to have to find a reasonable reference on COM threading models, or see the "threading" appendix in "Python Programming on Win32" - that appendix was hell to write, and I am not going to attempt it again on Usenet ;-) Deja threads (no pun intended;) on the subject may also help. Mark. From root at rainerdeyke.com Sat Feb 3 12: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 qrczak at knm.org.pl Thu Feb 22 14: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 hinsen at cnrs-orleans.fr Mon Feb 5 12: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 froydnj at rose-hulman.edu Thu Feb 15 00: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 mlh at idi.ntnu.no Thu Feb 1 05: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 wware at world.std.com Tue Feb 6 08:44:55 2001 From: wware at world.std.com (Will Ware) Date: Tue, 6 Feb 2001 13:44:55 GMT Subject: MIDI extensions (WIN32, Mac)? References: <3A3FACEF.DAF77229@cableinet.co.uk> <3A3FE5C3.76B4@loop.com> <3A3FF97B.BBF116C3@cableinet.co.uk> <3A7FADE4.16B3AFF5@yahoo.com> Message-ID: Richard Dobson wrote: (snip) > I want to be > able to at least write MIDI messages to the MIDI OUT port, and hopefully > to be able to read them from MIDI IN too. Then I could write a simple > MIDI filter in Python which would, for example, receive live note data > from MIDI IN, transpose it by some interval, and ouptut the result. I haven't done anything with reading and writing MIDI ports, but I've tinkered a bit with a MIDI parser, which might be useful: http://www.deja.com/getdoc.xp?AN=711228575&fmt=text -- 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 donn at oz.net Mon Feb 19 02: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 claird at starbase.neosoft.com Fri Feb 9 12:29:42 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 9 Feb 2001 11:29:42 -0600 Subject: A special Python with microthreads? References: <981723410.1058806687@news.t-online.de> Message-ID: <74D932C58CD4BEC2.2D646FA7E61F81E8.713EBCC0534B1497@lp.airnews.net> In article , Will Ware wrote: >Zamurai (zamurai at gmx.net) wrote: >> I've heard about a special Python which can use microthreads. >> Can anyone tell me, where I can get it and wether the developing >> group has a homepage? > >Try http://www.stackless.com/ >There you will find sources and executables for Windows and Linux. . . . Also documentation, press coverage, news, ... -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From claird at starbase.neosoft.com Fri Feb 16 09: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 jurgen.defurne at philips.com Thu Feb 15 08: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 faraway at mhtc.net Wed Feb 21 16: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 bbollenbach at homenospam.com Fri Feb 2 21:53:49 2001 From: bbollenbach at homenospam.com (Brad Bollenbach) Date: Sat, 03 Feb 2001 02:53:49 GMT Subject: Wish there was an error message References: Message-ID: <1pKe6.8850$wI1.683172@news1.rdc1.mb.home.com> Actually, if you meant to access M.quit() I'll assume quit() is a valid method of object M. That said, M.quit is a _reference_ to M.quit(), and in fact does exist. For examples of using references to functions look at the documentation on custom sorting a list, and you'll see that if you define a function called funcname() you also have reference to that function with funcname. wrote in message news:mailman.981165805.9847.python-list at python.org... > I was using poplib's example as in the documentation. Unfortunately I > typed in the following at the end of the script: > > M.quit instead of M.quit()! > > I forgot the parenthesis. The effect was, that my pop-server produced > really strange things, doubled the number of messages each time I > queried it with poplib. > > But M.quit does not exist. So it should give me an error message? Why > doesn't it? Can I turn it on somehow? > > From stephen_purcell at yahoo.com Tue Feb 20 08: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 d98aron at dtek.chalmers.se Fri Feb 9 12:58:49 2001 From: d98aron at dtek.chalmers.se (Fredrik Aronsson) Date: 9 Feb 2001 17:58:49 GMT Subject: embedding C and Python in Perl References: Message-ID: <961b4p$596$1@nyheter.chalmers.se> In article , "Warren Postma" writes: > I think you'll find more Smalltalk programmers willing to embed > COBOL in their nice clean language than you'll find Pythonistas > willing to muck with inline-Perl. Warren Yes, but embedding c and c++ to do few library calls could be very convenient for testing I think. /Fredrik -- From jfontain at free.fr Wed Feb 28 16: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 hinsen at cnrs-orleans.fr Tue Feb 27 05: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 db3l at fitlinxx.com Thu Feb 8 17:45:22 2001 From: db3l at fitlinxx.com (David Bolen) Date: 08 Feb 2001 17:45:22 -0500 Subject: Forking and Threads References: <3A829B94.9AF5A831@businesscollaborator.com> Message-ID: Paul Robinson writes: > Update: > My last run ( forkingtest2.py -MC 50 -MS 3 ) ran for 24 minutes before > running at a steady 99% CPU! What do you see in your log file leading up to the hang? Does there seem to be continued logging during the CPU burn or is it quiet? I'd probably try to figure out just what portion of the code the main process was in while burning CPU (it sort of looks like it could really only be in your waitpid loop, but a few additional log messages might be useful). Also, you might try exiting the child process more nicely (e.g., with a sys.exit rather than os._exit) in case it's a question of resource cleanup of some sort. BTW, I can't actually run it here (Windows) but do you ever see a log message from a child other than "1" - it looks like you only increment CHILD inside the child process itself, so wouldn't all the children get a value of 1? -- -- 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 05: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 jwbnews at scandaroon.com Tue Feb 20 00: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 fimafeng at yahoo.com Sat Feb 24 19: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 k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m Thu Feb 15 21: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 embed at geocities.com Mon Feb 19 16: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 karl.grammer at univie.ac.at Wed Feb 21 03: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 grante at visi.com Tue Feb 20 14: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 joconnor at cybermesa.com Wed Feb 7 09:52:26 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Wed, 07 Feb 2001 14:52:26 GMT Subject: Variable depth of nesting References: <95riu7$6f4$1@panix3.panix.com> Message-ID: <3a8160c3.25290480@news.cybermesa.com> On 7 Feb 2001 05:35:03 -0800, aahz at panix.com (Aahz Maruch) wrote: >In article , >Jacek Generowicz wrote: >> >>Is it somehow possible to write loops with variable nesting depths? > >Try recursion. Here's an example that will recusively print the elements in a list >>> import types >>> def printList(aList): for item in aList: if type(item) == types.ListType: printList(item) else: print item >>> printList ([1,2,3]) 1 2 3 >>> printList ([1,2,3, [4,5,6]]) 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 tmealy at my-deja.com Thu Feb 1 12: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 nas at arctrix.com Thu Feb 1 22: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 al053162 at anubis.uji.es Sat Feb 24 08: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 max at alcyone.com Sat Feb 24 15: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 tismer at tismer.com Mon Feb 26 06: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 pearu at cens.ioc.ee Sat Feb 17 04: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 graham at nospam.microtonal.co.uk Wed Feb 14 18:25:00 2001 From: graham at nospam.microtonal.co.uk (Graham Breed) Date: Wed, 14 Feb 2001 23:25 +0000 (GMT Standard Time) Subject: MIDI extensions (WIN32, Mac)? References: <3A7FADE4.16B3AFF5@yahoo.com> Message-ID: Below is some code that actually works. I don't think it's fully compliant with the MIDI standard, but you can check that. There's no obvious problem with speed. Note: do not use input.read() without an argument. It will block indefinitely. I have written code in C to use the MIDI ports in Windows. I don't think it can be done directly in Python, but I would be interested in working on a C module. I have no idea about Macintosh. Hopefully, OSX will behave like Linux in this respect. import string #messages noteOff = 0x80 noteOn = 0x90 polyAftertouch = 0xA0 controlChange = 0xB0 programChange = 0xC0 monoAftertouch = 0xD0 pitchBend = 0xE0 beginSysEx = 0xF0 songPositionPointer = 0xF2 songSelect = 0xF3 tuneRequest = 0xF6 endSysEx = 0xF7 timingClock = 0xF8 start = 0xFA cont = 0xFB stop = 0xFC activeSensing = 0xFE systemReset = 0xFF messagesWithNotes = (noteOn, noteOff, polyAftertouch) messageNames = { noteOff: 'note off', noteOn: 'note on', polyAftertouch: 'poly aftertouch', controlChange: 'control change', programChange: 'program change', monoAftertouch: 'mono aftertouch', pitchBend: 'pitch bend', beginSysEx: 'begin SysEx', endSysEx: 'end SysEx', songPositionPointer: 'song position pointer', songSelect: 'song select', tuneRequest: 'tune request', endSysEx: 'end SysEx', timingClock: 'timing clock', start: 'start', cont: 'continue', stop: 'stop', activeSensing: 'active sensing', systemReset: 'system reset'} nDataBytes = { noteOff: 2, noteOn: 2, polyAftertouch: 2, controlChange: 2, programChange: 1, monoAftertouch: 1, pitchBend: 2} noteNames = ('C','C#','D','Eb','E','F','F#', 'G','GA','A','Bb','B') def isData(byte): return byte<0x80; def isChannelMessage(byte): return 0x80<=byte<0xF0; def formatNote(noteNum): return noteNames[noteNum%12] + str(noteNum/12 - 1) def sendMessage(output, message): output.write(string.join(map(chr, message),'')) try: output.flush() except: print "couldn't flush" midiIn = open('/dev/midi00', 'r') midiOut = open('/dev/midi1','w') messageNumber = '' data = [] dataLength = 0 channel=-1 while 1: inputData = midiIn.read(1) if len(inputData)>1 : print 'read to much '+map(hex, map(ord, inputData)) else: datum = ord(inputData) if isData(datum): data.append(datum) if len(data)==dataLength: print messageNames[messageNumber], 'channel', channel, if messageNumber in messagesWithNotes: print formatNote(data[0]), data[1] else: print string.join(map(hex, data)) sendMessage(midiOut, [messageNumber+channel]+data) data = [] elif isChannelMessage(datum): channel = datum%16 messageNumber = datum-channel dataLength = nDataBytes[messageNumber] if data: print 'residual data '+string.join(map(hex, data)) data = [] elif datum==beginSysEx: messageNumber=beginSysEx dataLength = -1 data = [] # should this be different to the normal data? elif datum==endSysEx: if messageNumber != beginSysEx: print 'end with no beginning' formattedData = [] for byte in data: formattedData.append(hex(byte)[-2:]) print 'SysEx', string.replace(string.join( formattedData,''),'x','0') sendMessage(midiOut, [beginSysEx]+data+[endSysEx]) data = [] else: print messageNames.get(datum, 'undefined') sendMessage(midiOut, datum) From aleaxit at yahoo.com Sun Feb 18 05: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 erno-news at erno.iki.fi Sun Feb 18 11: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 s2mdalle at titan.vcu.edu Mon Feb 19 22: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 geoff at homegain.com Fri Feb 2 14: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 fredrik at effbot.org Wed Feb 7 14:27:27 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 07 Feb 2001 19:27:27 GMT Subject: embed Tkinter in C References: <95s3m1$db2$1@hecate.umd.edu> Message-ID: > Here's some info on Tk's C API: > http://www.bbso.njit.edu/Documentations/TclTkMan/tk4.2b1/tk4.2b1API.html for the latest/greatest docs, see: http://dev.scriptics.com/ Cheers /F From dan at eevolved.com Fri Feb 23 11: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 jhauser at ifm.uni-kiel.de Tue Feb 6 05:23:20 2001 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 06 Feb 2001 11:23:20 +0100 Subject: SOAP References: <3a7fc9f1$0$11094@reader4> Message-ID: <87snlshzzb.fsf@lisboa.ifm.uni-kiel.de> For SOAP and xml-rpc look at http://www.pythonware.com/products/soap/index.htm 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 erno-news at erno.iki.fi Mon Feb 12 19: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 jcollins at endeavors.com Mon Feb 26 11: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 costas at springmail.com Sun Feb 18 23: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 > > 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 daniel at dittmar.net Mon Feb 26 14: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 vbg-news at bitjungle.com Mon Feb 12 05: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 shaleh at valinux.com Fri Feb 16 18: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 jafo at tummy.com Tue Feb 27 03:30:19 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Tue, 27 Feb 2001 01:30:19 -0700 Subject: CPAN functionality for python In-Reply-To: ; from bsass@freenet.edmonton.ab.ca on Tue, Feb 27, 2001 at 12:53:45AM -0700 References: <20010226180935.B7531@tummy.com> Message-ID: <20010227013019.T1781@tummy.com> (I'm going to remove the non-list entities in further messages -- if you want to follow this discussion you can find it on the lists. Not entirely sure how the CC list got so big in the first place) On Tue, Feb 27, 2001 at 12:53:45AM -0700, Bruce Sass wrote: >I have assumed that submitted packages would need to meet a >standard of some sort - was that incorrect? Obviously there will be some level of standards. I don't know that the tool should govern a policy decision though... It seems that you're pushing for a standard that's more than "just dump a .tar.gz here" and less than "schlep up tars and RPMs and .debs, and don't forget about HP-UX swinstall". Maybe something like those (defunct?) Linux Software Map entries? I don't know the answers to what the standards will be and how they'll be enforced... I do suspect that they'll change over time, so the tool should probably be flexible. >That is to be expected... and only the distro is really equipted to >handle these issues. I don't agree with that. Historicly, it's been fairly common for the package to say "Hey, I've got some paths I need in the various files. Here's the macros that represent them." >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. What do you mean by "the distributions"? How will they do the packaging? Are you saying that RedHat should be creating the RPMs? That's just not how it's actually done in the real world... We just can't wait for the distribution vendors to decide to include them on their disc. It's not that sort of world. If tools can be provided so that a user can turn a .tar.gz file into a .RPM file easily, I'm all for it. What about systems where that isn't possible? As far as I can tell, my system doesn't *REQUIRE* the inclusion of RPMs, it just *ALLOWS* it. You seem to be arguing for the exclusion of that capability. Why? Sean -- The early bird may get the worm, but the second mouse gets the cheese. Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From grante at visi.com Mon Feb 19 18: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 ray_drew at yahoo.co.uk Fri Feb 2 04: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 sholden at holdenweb.com Wed Feb 28 15: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 fakeaddress at nospammail.com Tue Feb 6 23:21:31 2001 From: fakeaddress at nospammail.com (Ben Catanzariti) Date: Wed, 7 Feb 2001 15:21:31 +1100 Subject: Python Users Group Australia References: <3A80C151.3000504@ActiveState.com> Message-ID: Actually the Users Group conference is on Saturday 10 March, 2001 This is from the website ... USER GROUPS OPEN DAY Saturday, 10 March, 2001 10 am-3 pm VTR Consulting is please to announce that our first IT event in the new year will be the User Groups Open Day. The event will take place at VTR's new premises, Roseneath Place, between 10 am and 3 pm on 10 February 2001. Roseneath Place is located in South Melbourne, off Market Street, between Clarendon and Cecil Streets. For further information, concerning our location, please click on the link The idea behind the organisation of the Open Day is for VTR to facilitate a meeting between IT professionals and the numerous user groups that together represent a wide range of IT skills. Groups that will be represented on the day include: Visual Basic (AVBUG), Delphi (ADUG), Java (AJUG), System Administrators (SAGE-AU), Linux (LUV), Technical Writers (ASTC), Cold Fusion (CFUG), etc...The Open Day will represent an excellent opportunity to to talk to members about their group activities and the benefits of membership (a 10% membership discount, in any of the user groups, will be offered on the day!) in an informal setting. .... From ljohnson at resgen.com Wed Feb 28 16: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 cjensen at bioeng.ucsd.edu Wed Feb 7 12:39:19 2001 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Wed, 07 Feb 2001 09:39:19 -0800 Subject: os.popen2 References: Message-ID: <3A818847.D83E6EAB@bioeng.ucsd.edu> Venkatesh Prasad Ranganath wrote: > > 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 just a guess, try putting a carrage return at the end. i[0].write("ls -lR\n") -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From emile at fenx.com Mon Feb 19 12: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 rayvd at nospam.firetail.org Wed Feb 7 01:32:44 2001 From: rayvd at nospam.firetail.org (Ray Van Dolson) Date: Wed, 07 Feb 2001 06:32:44 GMT Subject: Radix sort algorithm in Python question Message-ID: I'm designing a Radix sort algorithm in Python (for an assignment). I have the algorithm done, but it's not exactly fast. Since I'm supposed to be comparing this to Quicksort (my Python Quicksort implementation is - infinitely- faster). Here's the code: def rSort(a,n,maxLen): bins=[[],[],[],[],[],[],[],[],[],[],[]] for x in range(0,maxLen): if x == 0: for y in a: bins[y%n].append(y) else: for y in a: origValue=y if y < 10**x: bins[0].append(y) else: y=y/(10**x) bins[y%n].append(origValue) del a a=[] for section in bins: if len(section) > 0: for times in range(0,len(section)): a.append(section.pop(0)) I'm guessing the problem lies when I am taking the elements out of the "bins" and putting them back into the array. I delete the array and then step through the bins popping the numbers out. When we're talking about thousands of elements this takes a while. Anyone have any suggestions on how I could better streamline this? I don't think radix should be 40 times slower than quicksort, but I could be wrong. Thanks, Ray Van Dolson From fellowsd at cs.man.ac.uk Mon Feb 19 05: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 alan.gauld at gssec.bt.co.uk Mon Feb 26 11: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 thomas at xs4all.net Sun Feb 4 10:18:22 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 4 Feb 2001 16:18:22 +0100 Subject: HTTPD Writable In-Reply-To: <5.0.2.1.0.20010203234754.00a4d0d0@thewebsons.com>; from linux@thewebsons.com on Sat, Feb 03, 2001 at 11:48:08PM -0800 References: <5.0.2.1.0.20010203234754.00a4d0d0@thewebsons.com> Message-ID: <20010204161822.E962@xs4all.nl> On Sat, Feb 03, 2001 at 11:48:08PM -0800, Ben Ocean wrote: > I'm trying to install a program that requires I create an *httpd writable* > file. How do I do this? What does it mean to have httpd write to a file? Do > I need to assign httpd a passwd? Do I need to group it with root? Please > advise. Unclear why you are posting it here; it's terribly off-topic, even if the program you are installing is a Python program. Nevertheless, what you are probably supposed to do is make a file writable for the httpd process. It depends on your installation (and indeed, your 'brand' of httpd) what userid and permissions the httpd process is running as, but as a wild guess, you can use 'chmod a+w ' (dangerous, but sure to work) or 'chown nobody ' (sometimes inconvenient, but slightly less dangerous.) If you happen to know that httpd is running as a particular group, and noone else is in that group, chgrp the file to that group and make it only writable for the group, not the rest of the world: chmod g+w . For further questions I suggest you ask the author or supplier of the program you are installing, they're sure to know exactly what they mean :) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From dkstewart at hotmail.com Sat Feb 24 19: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 NoSpam at NoSpam.com Thu Feb 22 11: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 k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m Sun Feb 18 21: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 fredrik at pythonware.com Wed Feb 21 01: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 spam at spam.com Tue Feb 13 19: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 patrickdlogan at home.com Sun Feb 25 21: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 gangli at msn.com Thu Feb 8 14:55:15 2001 From: gangli at msn.com (gangli at msn.com) Date: Thu, 08 Feb 2001 19:55:15 GMT Subject: Touch in python? References: <95sfla$adf$1@bunyip.cc.uq.edu.au> <95sg8e$mod$00$1@news.t-online.com> Message-ID: <95utiv$a55$1@nnrp1.deja.com> In article <95sg8e$mod$00$1 at news.t-online.com>, "J?rgen Hermann" wrote: > > "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() > > os.utime won't work against directory on Windows Sent via Deja.com http://www.deja.com/ From ngps at madcap.dyndns.org Thu Feb 1 12: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 doughellmann at bigfoot.com Sat Feb 24 08: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 sholden at holdenweb.com Wed Feb 28 10: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 MarkH at ActiveState.com Thu Feb 8 06: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 dev_null at email.com Wed Feb 28 09: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 Sun Feb 25 12: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 aahz at panix.com Mon Feb 19 20: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 ben.hutchings at roundpoint.com Tue Feb 27 16: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], ' Message-ID: You've already asked this question once, and recieved two accurate and helpful replies. Was there a reason for asking it again (the next day)? wrote in message news:mailman.981239644.2167.python-list at python.org... > Using e.g. poplib, m=poplib.POP3 ... > I typed in error m.quit. > It should have been m.quit(). > Why doesn't Python give me an error message? > It definitely should since q.quit does not exist! > > From chris at rpgarchive.com Thu Feb 8 15:26:25 2001 From: chris at rpgarchive.com (Chris Davis) Date: Thu, 8 Feb 2001 14:26:25 -0600 Subject: SAXReaderNotAvailable Message-ID: <0102081426250S.12796@lab.rpgarchive.com> Anyone know what could be causing this error? I'm getting tons of people who use my program reporting this bug. The one thing they all have in common is they installed python20 from source on linux. They all have expat installed. Please, can anyone help? File "./minidom.py", line 570, in _doparse ? ? events = apply(func, args, kwargs) ? File "./pulldom.py", line 244, in parseString ? ? parser = xml.sax.make_parser() ? File "/usr/lib/python2.0/xml/sax/__init__.py", line 88, in make_parser ? ? raise SAXReaderNotAvailable("No parsers found", None) xml.sax._exceptions.SAXReaderNotAvailable: No parsers found Terminated -- Chris Davis chris at rpgarchive.com RPGArchive http://rpgarchive.com OpenRPG http://openrpg.com From chris.gonnerman at usa.net Sat Feb 17 01: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 jbauer at rubic.com Sat Feb 17 18: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 dalke at acm.org Thu Feb 8 16:21:52 2001 From: dalke at acm.org (Andrew Dalke) Date: Thu, 8 Feb 2001 14:21:52 -0700 Subject: python-dev summary, Jan. 16-31 References: <3d4ry56vzg.fsf@ute.cnri.reston.va.us> Message-ID: <95v2lq$hjl$1@slb7.atl.mindspring.net> amk: >The release of 2.1 offers a second calibration on their effectiveness. >2.1 is the first Python release to have been carried out using PEPs as >the mechanism, so there are no sizable changes in 2.1 that don't have >a corresponding PEP. Yet many people were *surprised* by some of the >changes in Python 2.1 such as function attributes and nested scopes, >even though PEPs were written and discussed, often in lengthy threads >months ago. I for one am not on the python-dev mailing list. It's too much mail traffic for me to follow. There were about 1,000 messages in January and while the signal level is high, the content is usually beyond my ken. (Following the newsgroup is easier because I can defer reading the newsgroup then kill threads I don't want to follow. I suppose I can do that with email as well, by redirecting incoming messages to a special mailbox, but that's a hassle and I would have to see if it's possible and learn how to do it. Barrier to entry.) Speaking of the archive, it's always been hard for me to remember where the archive is located. There's nothing on the python.org page pointing to it. I know it's at sourceforge, but python.sourceforge.com doesn't work nor does .org. I finally figured out it was python.sourceforge.net but I don't see a link to the back archive. (Sorry, but my ability to remember names isn't perfect - that's one reason I like Python :) There are also no links from the python.org page to the PEPs although python.sourceforge.net points directory to it. More importantly, the PEPs are rarely announced to c.l.py, which means I don't know what's going on. When a PEP *is* announced on c.l.py there are discussions about it, which implies that others are like me in being interested in giving input but don't have the time to follow all of the technical details of python-dev. I used DejaNews to search for threads named "PEP". The ones which came up were: PEP 4 PEP 201 PEP 203 PEP 214 PEP 222 (because of you) PEP 223 PEP 224 Given that there are some 40 PEPs, this implies that only 20% of them were announced to c.l.py, which greatly reduces the dissemination of their ideas to the rest of the Python world. Missing Finished PEPs are: 207, 208, 217, 221, 240 and 232. I'm looking at PEP 0001, "PEP Purpose and Guidlines". It says: ] PEP authors are responsible for collecting community feedback on a ] PEP before submitting it for review. A PEP that has not been ] discussed on python-list and python-dev will not be accepted for ] review. However, wherever possible, long open-ended discussions ] on public mailing lists should be avoided. A better strategy is ] to encourage public feedback directly to the PEP author, who ] collects and integrates the comments back into the PEP. This is obviously not being done. I searched Deja for "PEP 217", which I first knew about from your python-dev summary. There was only a single reference from Tim Peters about it. Take PEP 232, which is the one on function attributes. You said > Yet many people were *surprised* by some of the > changes in Python 2.1 such as function attributes and nested scopes, > even though PEPs were written and discussed, often in lengthy threads > months ago. The first mention on c.l.py on function attributes was from Jan. 24 http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=719772745&fmt=text even though, yes, the PEP was created on Dec. 2. Jeremy Hylton first mentioned PEP 227 ("Statically Nested Scopes") on Nov. 19 in the thread "Ruby and Python" http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=695547859&fmt=text then was mentioned again in passing by Tim on Dec. 20. The PEP was created on Nov. 1. No wonder there have been complaints - how is anyone not interested in following python-dev supposed to know what is going on with Python development? >To me, this makes it crystal clear that the summaries aren't achieving >their goal of making the development process more transparent to the >community. The problem is the summaries are just that - summaries. I *really* enjoy reading them because there are a concise description of what occured and the only way I have these days to know what is going on with development. However, consider this latest summary. I received it on the 7th, which is 1 to 3 weeks after the discussions it talked about. To contribute to a thread, I would need to catch up on the mailing list to see what arguments have been presented, then bring up my questions or objections. But it would be about two weeks late, which means people may have already decided on what to do, and making changes is more likely to be frowned upon. (Not saying that that will happen, but that's my perception, which makes it harder for me to decide to put in the effort to make a useful comment.) > Perhaps giving the PEPs higher visibility -- posting >announcements of status changes and new PEPs to >comp.lang.python.announce, for example -- would do a better job Just mentioning them on c.l.py as per PEP 0001 would help! I *really* miss the pre-python-dev newsgroup days. Spinning the core technical discussions off has not only reduced my awareness of Python's direction, but it has almost eliminated my education in CS topics like continuations. (Which you clarified for me at the Houston conference :) And there are far fewer posts from Tim Peters than the schriebfest days. So I really place the problem on the main python-dev people who don't bother to disseminate their ideas to the broader audience of people who develop a lot of Python code but aren't language designers. >I feel there's no point in continuing to write them. I agree with the others who have replied - I will miss the summaries greatly. They were nearly the only way I had to know what was going on with Python development. >(Should anyone want to volunteer to continue writing them, please do >so; contact me if you want copies of the previous summaries for a >complete archive.) I can't as I don't have the time to follow python-dev, much less comment anywhere near as intellegently about it as you have. Andrew dalke at acm.org From bsb at winnegan.de Thu Feb 8 10:13:39 2001 From: bsb at winnegan.de (Siggy Brentrup) Date: 08 Feb 2001 16:13:39 +0100 Subject: catching all exceptions In-Reply-To: <95uati$cm4$1@icrf.news> References: <95uati$cm4$1@icrf.news> Message-ID: <87y9vhp5r0.fsf@winnegan.de> nospam at our.site writes: [...] > currently I'm doing: > > try: > do_something() > except Exceptions, value: > write_Exception_to_database('Python-Error: ' + repr(value)) > sys.exit(-1) > > with this I think I can catch all predefined exception classes, because > Exceptions is the base class for all other exceptions, but I realy want > to know which derived exception class was raised (and also the > stack-trace). > > Is there (simple) way to do that in python (1.5.2)? import traceback, cStringIO f = cStringIO.StringIO traceback.print_exc(None, f) write_to_database(f.getvalue()) HTH Siggy From peter at engcorp.com Sat Feb 10 13:04:15 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 10 Feb 2001 13:04:15 -0500 Subject: What is better, JPython or Jython? References: <962n6a$v9$1@news.xmission.com> Message-ID: <3A85829F.6BA7B9AC@engcorp.com> Zac Jensen wrote: > > "Kemp Randy-W18971" wrote: > > 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? > > That's pretty cool, since that's not even the question you moron That's pretty uncool, since anyone can misread a question you jerk From tjg at exceptionalminds.com Tue Feb 27 17: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 jafo at tummy.com Fri Feb 16 23: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 tim.one at home.com Thu Feb 15 22: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 tshumway at transafari.com Fri Feb 2 09: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 matthias.oberlaender at daimlerchrysler.com Fri Feb 9 10:05:39 2001 From: matthias.oberlaender at daimlerchrysler.com (matthias.oberlaender at daimlerchrysler.com) Date: 9 Feb 2001 15:05:39 GMT Subject: How to copy class objects? References: <960b75$a2e$1@news.sns-felb.debis.de> Message-ID: <961103$a2e$2@news.sns-felb.debis.de> In <960b75$a2e$1 at news.sns-felb.debis.de> matthias.oberlaender at daimlerchrysler.com wrote: > This is the question I'd like to be answered: > > Is there some easy way to copy a class object? > > Here is the background: > > In order to generate classes from templates I'd prefer the following method > over writing additional wrapper function > > class X: > > sratchdir = "/tmp/" > > > > # I want a new class Xnew differing from X in that its instances use a > different scratch directory. > Xnew = copyclass(X) > # Now set scratchdir to something else > Xnew.scratchdir = '/home/me/tmp' > > > Quite a few people have already tried to help me. Thanks! But it seems it is sowewhat dangerous to give background information, because it often distracts people from the real question, which is: How can I copy a class object? ========================= Somebody suggested the copy module. But copy.copy does not apply to classes! Ok, don't tell me that I don't need such a feature for the toy problem given. It's solely for illustration. The real intent is much different. I can't accept subclassing, because I don't want instances of X and Xnew have any base classes in common. So new.classobj won't work either! Ok? -- Matthias From itamar at maxnm.com Mon Feb 26 10: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 joconnor at cybermesa.com Thu Feb 1 16: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 f8dy at my-deja.com Thu Feb 8 13:16:59 2001 From: f8dy at my-deja.com (Mark Pilgrim) Date: Thu, 08 Feb 2001 18:16:59 GMT Subject: None assigment References: <95ugd4$jka$1@panix6.panix.com> Message-ID: <95unqf$4j3$1@nnrp1.deja.com> In article <95ugd4$jka$1 at panix6.panix.com>, aahz at panix.com (Aahz Maruch) wrote: > In article , > Gregoire Welraeds wrote: > > > >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 ? > > Neither, really; it's Just The Way Things Work. Indeed. I once had a similar experience; while playing around in the Python IDE, I defined a variable 'dir' to hold some directory path. Then days later (having never shut down Python), I wondered why the built-in 'dir' function didn't work. Which leads to the following questions: - Are there any true constants in Python? (I don't think so, but correct me if I'm wrong.) - Once you've redefined a built-in function like 'dir', is there any way to get it back without restarting Python? -M -- You're smart; why haven't you learned Python yet? http://diveintopython.org/ Sent via Deja.com http://www.deja.com/ From grey at despair.rpglink.com Fri Feb 9 13:14:27 2001 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 09 Feb 2001 18:14:27 -0000 Subject: open("ls -l |", "r") ?? References: Message-ID: On Fri, 09 Feb 2001 17:56:39 GMT, steveFarris wrote: >Hi all, is some variation of the above possible in Python? import os foo = os.popen("ls -l") for line in foo.readlines(): print line, -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From doughellmann at home.com Tue Feb 13 19:26:56 2001 From: doughellmann at home.com (Doug Hellmann) Date: Tue, 13 Feb 2001 19:26:56 -0500 Subject: CPAN functionality for python In-Reply-To: References: Message-ID: <01021319314200.05138@branagan> On Tue, 13 Feb 2001, Oleg Broytmann wrote: > On Mon, 12 Feb 2001, Jeremy Hylton wrote: > > OB> This metadata can be put in static files. Thus, it can be easily > > OB> mirrored/reached by www/ftp/rsync/etc. In case of Zope, mirror > > OB> site must run Zope, so mirroring will be limited to probably 2-3 > > OB> sites in the world. How is the meta data indexed? How is it searched? It is possible to export data from a Zope server and import it into another one, or even use it directly without having to import it. This allows us to actually *mirror* the content, and not have multiple Zope front ends to a single ZEO-driven database on the backend. I do this at my job and it works fine. > > I think this would be a fine project for Zope, in part because we're > > going to be spinning up zope.python.org in the next few weeks and > > could probably provide a home for it. (Yeah, I work for Digital > > Creations, too, but only because I think it's a great company.) > > 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? How many mirrors do we really need? Not "We want as many as CPAN!" but how many do we actually need to have in order to support the load we expect this service to undertake and to give some fail-over capabilities. > I completeley agree that this task *can* be solved using Zope. We can > develop data formats, protocols, etc. And I completely disagree that the > task *should* be solved with Zope. It shouldn't. > Please count current mirrors of CPAN. The figure looks good, isn't it? > This is because there are sites that provide FTP mirrors. What is mirrored on all of these sites, the actual database or the service which does the lookups? Doug From kwoeltje at mail.mcg.edu Mon Feb 19 18: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 cjc26 at nospam.cornell.edu Wed Feb 14 15: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 schlatterbeck at tttech.com Mon Feb 5 07: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 seandc at att.net Tue Feb 27 16: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 fgeiger at datec.at Fri Feb 23 12: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 csrabak at uol.com.br Tue Feb 13 09:45:23 2001 From: csrabak at uol.com.br (Cesar Rabak) Date: Tue, 13 Feb 2001 11:45:23 -0300 Subject: python 2.0 won't run scripts with \r\n line termination on RH7? References: Message-ID: <3A894883.61C64508@uol.com.br> Steve Purcell wrote: > > Mike Carifio wrote: > > So here's my solution, crufty though it is. I created a link to the python > > executable named 'python^M', in other words I added the carriage return to > > the end of the file name so bash would find it. > > Ay-ay-ay... > > Ingenious lateral thinking, but... > > I can't imagine why people freak out when they can't write UNIX scripts that > don't have UNIX line endings! If the first line starts '#!' it should finish > '\n', not '\r\n'. If it doesn't, fix the file, not the OS. > 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. just my .01999... From rturpin at do.not.use Sun Feb 25 11: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 m_hussain at trillium.com Tue Feb 20 00: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 NOSPAM at pacificnet.net Mon Feb 5 17:54:20 2001 From: NOSPAM at pacificnet.net (Ian L) Date: Mon, 05 Feb 2001 22:54:20 GMT Subject: gdchart problem Message-ID: i just installed gdchart http://www.fred.net/brv/chart/ along with the python interface. I've gotten it to work, sort of. When i run my file from the command line, it works fine. If i then try to run the same file from a web browser, it doesnt work. Or rather, the code on the page executes without any errors. But it doesnt generate the image. I assume this is a permission problem. I've tried giving full permissions to both the file and directory, but it still only works when i run it from the command line. can anyone give me some suggestions as to what i could check to get it working from the browser? From joconnor at cybermesa.com Sat Feb 3 11:48:11 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Sat, 03 Feb 2001 16:48:11 +0000 Subject: Python and GTK Message-ID: <3A7C364B.695D274A@cybermesa.com> I tried using Python with GTK and ran into some problems. It seems I didn't have GTK support installed. So I downloaded it and attempted to compile it, but I was missing a lot of the GTK dev header files needed to compile. So I got them all installed, I think. The Python/GTK stuff at least compiles. My first script has the following two lines from gtk import * from GTK import * and on the first line I get... [jay at altaica gtk_test]$ ./gtktest.py Traceback (most recent call last): File "./gtktest.py", line 3, in ? from gtk import * File "/usr/local/lib/python2.0/site-packages/gtk.py", line 21, in ? import _gtk ImportError: /usr/local/lib/python2.0/site-packages/_gtkmodule.so: undefined symbol: GTK_TYPE_GDK_COLOR [jay at altaica gtk_test]$ Anyone else run into anything like this or have success or failure running GTK with Python? 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 rosemann at imkt.uni-hannover.de Wed Feb 21 03: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 ken at lt.com Fri Feb 9 11:25:36 2001 From: ken at lt.com (Kenneth Loafman) Date: Fri, 09 Feb 2001 10:25:36 -0600 Subject: embedding C and Python in Perl References: <3A83E5B5.2141B629@eq.uc.pt> Message-ID: <3A841A00.8C2ED375@lt.com> Pedro Vale Lima wrote: > > Eric Hagemann wrote: > > > Hey all --- maybe Python needs the same ? Anybody seen this ? > > > http://www.perl.com/pub/2001/02/inline.html?wwwrrr_20010206.txt > > That is one thing I'm sure Python can live without. Not really. I'm in a Python shop, but I have a great need for some of the more advanced regex capability of Perl. Let's see, it would play out like this... (very loose description). 1) Wrap Python main code in Inline 2) Python main needs advanced regex capability, calls Perl 3) Perl regex embedded code calls out to C during regex eval 4) C code does its thing (long) and returns true or false 5) Regex fails or goes on based on return from C code 6) Result returned to Python Solves the problem of the missing (?) construct. Returns regex evaluation to regex, rather than artificial manual coding to attempt the same thing. ...Ken From loewis at informatik.hu-berlin.de Fri Feb 2 16: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 mj at muc.das-werk.de Tue Feb 6 02:37:04 2001 From: mj at muc.das-werk.de (Michael Jonas) Date: Tue, 6 Feb 2001 08:37:04 +0100 Subject: Parsing C Code Message-ID: Hi, I need to parse code which is formatted like C. Is there a bison-like module? or just stick to re and do it myself?! Michael ----------------------------------------- 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 ekibismuth at privacyx.com Wed Feb 7 23:20:08 2001 From: ekibismuth at privacyx.com (eki) Date: Thu, 08 Feb 2001 04:20:08 GMT Subject: Newbie Query Message-ID: Hello all, I am just getting restarted in programming after learning a bit of BASIC back in the seventies. I would like to take a course online in programming in python. Does anyone know of any beginners classes which are being offered online? Thanks, Eki From gnana at mips.biochem.mpg.de Wed Feb 21 12: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 doughellmann at bigfoot.com Tue Feb 13 07:49:35 2001 From: doughellmann at bigfoot.com (Doug Hellmann) Date: Tue, 13 Feb 2001 12:49:35 GMT Subject: CPAN functionality for python References: Message-ID: In article , "Oleg Broytmann" wrote: > On Tue, 13 Feb 2001, Doug Hellmann wrote: >> Why use standard CGI? This is a perfect application for Zope, the ZODB, > > The big advatnage of CPAn is that it's distributed and has many > mirrors. > Zope-based solution will be hard to mirror. > I don't follow that at all. To support mirrors, the data needs to be replicated from one server to another. That problem exists independant of any tool. Doug From m.faassen at vet.uu.nl Tue Feb 13 01:41:45 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 13 Feb 2001 06:41:45 GMT Subject: Is Python for me? References: <20010210175216.26827.00000474@ng-mh1.aol.com> <3A85C996.9000504@hccnet.nl> <9676k2$brc$1@newshost.accu.uu.nl> <3A880094.6060906@hccnet.nl> Message-ID: <96akv9$dik$2@newshost.accu.uu.nl> Jaap Spies wrote: [snip] > 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. Well, I used 'more or less' fulfill, a conveniently vague expression. :) > I followed the thread and I admire all the kind answers. > Please accept my apologies. And accept my thanks; that was gracious of you. Thanks again, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From ohyvarin at cc.helsinki.fi Tue Feb 20 09: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 johnw at gnu.org Sat Feb 24 19: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 ujen at nino.ru Tue Feb 20 04: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 db3l at fitlinxx.com Mon Feb 26 20: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 sholden at holdenweb.com Thu Feb 8 12:32:29 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 8 Feb 2001 12:32:29 -0500 Subject: Is Python "Compiled"? References: <3a81ad07_3@goliath2.newsfeeds.com> <5Iig6.1295$D3.5361@tor-nn1.netcom.ca> <95ug7b$qp0$1@c3po.schlund.de> Message-ID: "Hannah Schroeter" wrote in message news:95ug7b$qp0$1 at c3po.schlund.de... > Hello! > > In article <5Iig6.1295$D3.5361 at tor-nn1.netcom.ca>, > Warren Postma wrote: > > >[...] > > >Various efforts to build a Compiler are in "research stages". Dynamic > >languages don't respond well to attempts to compile them. . Nevertheless, > >some very smart people seem to be trying. > > What about Lisp, which is very often compiled to native code? > > Besides, JIT technology is also there, already for a long time > (look at Smalltalk implementation techniques and see stuff implemented > a decade ago which they just "discover" for Java). > > Bottom line: I don't think that "dynamic languages don't respond well > to attempts to compile them". Techniques are there (again, see Lisp, > see Smalltalk, see Cecil/vortex for examples). I'd believe that > techniques from Smalltalk implementations could also apply to the > Python language. > > >Warren > > Kind regards, > > Hannah. > Well, LISP is kind of special: the typical list representation and car()/cdr() operations are pretty efficient if properly compiled. But most interpreted languages end up "compiling" down into calls to the interpreter bytecode routines, which doesn't save much space or time. That was certainly true for Icon, anyway, and I suspect would be for other similar languages. JIT might or might not be a win for Python, but programs would still end up lugging a lot of support code around, and without static typing a lot of decisions still have to be deferred until run-time. regards Steve From drewpc at my-deja.com Thu Feb 1 15: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 dan at eevolved.com Thu Feb 8 17:59:15 2001 From: dan at eevolved.com (Dan Parisien) Date: Thu, 08 Feb 2001 22:59:15 GMT Subject: I forgot to mention the Vaults of Parnassus References: Message-ID: <7xFg6.75948$Pm2.1584072@news20.bellglobal.com> That site is very important and useful (I've used it many times). I feel it can be improved upon as well... especially if integrated into a system like was proposed on my previous post. Would it be feasible to host python modules as well? Like sourceforge; however sourceforge is a lot of hassle for hosting simple python modules considering most are a few kb of ascii text. Sorry about the unforgivable oversight, Dan From burton at tx420.org Wed Feb 7 18:20:48 2001 From: burton at tx420.org (JackBurton) Date: Wed, 7 Feb 2001 17:20:48 -0600 Subject: Error during make? Message-ID: <3a81d7bd$0$65278$38c90ffe@news1.twtelecom.net> Hi, I was installing Python on Slackware Linux 2.2.6 kernel, and am getting the error message: make[1]: *** [selectmodule.o] Error 1 make[1]: Leaving directory `/home/jay/Python/Python-2.0/Modules' make: *** [Modules] Error 2 I was wondering if anyone could help me with this? advthanxance Jack From sbrunning at trisystems.co.uk Tue Feb 27 04: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 aleaxit at yahoo.com Sat Feb 17 13: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 erno-news at erno.iki.fi Tue Feb 27 02: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 erno-news at erno.iki.fi Tue Feb 6 06:28:24 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 06 Feb 2001 13:28:24 +0200 Subject: cgi.FieldStorage() problem References: <3A7F20D9.4BE57828@cs.utwente.nl> <3A7FC939.DAC10B75@cs.utwente.nl> Message-ID: In article <3A7FC939.DAC10B75 at cs.utwente.nl>, Richard van de Stadt writes: | calling ulimit from within the script, which should, I think, do what you | suggest: | ulimitCommand = "/usr/bin/ulimit -n 512" | os.system (ulimitCommand) that can't work. it's like trying to run os.system('/usr/bin/cd /tmp') to change directory. do it in the shell you start httpd from, or use the resource module, or something. -- erno From mkx at excite.com Wed Feb 21 11: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 jcollin at exis.net Tue Feb 27 22: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 skip at mojam.com Fri Feb 9 13:22:29 2001 From: skip at mojam.com (Skip Montanaro) Date: Fri, 9 Feb 2001 12:22:29 -0600 (CST) Subject: embedding C and Python in Perl In-Reply-To: References: Message-ID: <14980.13669.919478.471926@beluga.mojam.com> Steve> Wow, this aids clarity SO much I think I'll retain my sanity by Steve> staying miles away from it, thank you very much. Yet another Steve> example of "because we can" design. OTOH, it makes it easy (assuming this wasn't all a big joke) to infest Perl code with Python, which could be particularly useful if you're stuck with Perl on some project. use inline Python; main; __END__ __PYTHON__ def main(): import myprogram myprogram.main() ;-) -- Skip Montanaro (skip at mojam.com) Support Mojam & Musi-Cal: http://www.musi-cal.com/sponsor.shtml (847)971-7098 From topmind at technologist.com Tue Feb 27 23: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 johann at physics.berkeley.edu Tue Feb 6 16: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 swun at esec.com.au Tue Feb 6 02:20:26 2001 From: swun at esec.com.au (Sam Wun) Date: Tue, 06 Feb 2001 18:20:26 +1100 Subject: how to send email in python? Message-ID: <3A7FA5BA.82FB7593@esec.com.au> hi, does anyone knows? I am using python 1.6. Thansk Sam From dsh8290 at rit.edu Fri Feb 16 13: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 dbrueck at edgix.com Mon Feb 26 13: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 chris.gonnerman at usa.net Thu Feb 8 09:13:42 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Thu, 8 Feb 2001 08:13:42 -0600 Subject: ANNOUNCE: new gdmodule Message-ID: <009601c091d9$5bc45c60$a100000a@local> With Richard Jones' blessing I have taken over support for his Python GD module, and issued a new version. Visit: http://newcenturycomputers.net/projects/gdmodule if you are interested. The new version includes support for most GD 1.8.3 functionality including TrueType font support. From ssthapa at the-400.cs.uchicago.edu Wed Feb 14 14:55:43 2001 From: ssthapa at the-400.cs.uchicago.edu (Suchandra S Thapa) Date: Wed, 14 Feb 2001 19:55:43 GMT Subject: CPAN functionality for python References: Message-ID: The source code is now available on sourceforge under the project name pythonsiphon. From gchiaramonte at yahoo.com Fri Feb 16 08: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 robin at jessikat.fsnet.co.uk Thu Feb 15 06: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 phil at river-bank.demon.co.uk Sun Feb 4 09:50:51 2001 From: phil at river-bank.demon.co.uk (phil at river-bank.demon.co.uk) Date: Sun, 04 Feb 2001 14:50:51 -0000 Subject: ANNOUNCE: PyQt v2.3 (Python Bindings for Qt GUI Toolkit) Message-ID: <95jq8b+3tt4@eGroups.com> PyQt v2.3 has been released and is available from http://www.thekompany.com/projects/pykde/. PyQt is a complete set of Python bindings for Trolltech's Qt GUI toolkit. It implements over 200 classes and includes pyuic, a utility for generating Python code for user interfaces created with Qt Designer. Phil From spam at spam.com Wed Feb 14 17: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 andrew at andrewcooke.free-online.co.uk Tue Feb 20 14: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 sav at ulmen.mv.ru Mon Feb 19 14: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 sampe99 at my-deja.com Mon Feb 5 11:07:45 2001 From: sampe99 at my-deja.com (sampe99 at my-deja.com) Date: Mon, 05 Feb 2001 16:07:45 GMT Subject: Square root of a matrix? Message-ID: <95mj49$vbs$1@nnrp1.deja.com> I'm looking for a module or a function that can preferably perform a n-root of a matrix or the x- power of a matrix (where x is a float). The second best alternative is a square root of a matrix. The matrix is not symmetric so a cholesky factorization is not an option. I'd be forever greatful for any help. Sent via Deja.com http://www.deja.com/ From Denys.Duchier at ps.uni-sb.de Wed Feb 21 16: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 matthew.feinstein at jhuapl.edu Mon Feb 26 13: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 slhath at home.com Tue Feb 13 18: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 cjc26 at nospam.cornell.edu Thu Feb 1 09: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 gem at hsv.crc.com Tue Feb 27 18: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 slhath at home.com Tue Feb 6 18:56:02 2001 From: slhath at home.com (Scott Hathaway) Date: Tue, 06 Feb 2001 23:56:02 GMT Subject: python training class in dallas, tx Message-ID: Hello Everyone, If this is not appropriate for this newsgroup, please let me know which group would be appropriate. My company is providing a beginner's python training class April 4-6 in Dallas, TX. Anyone interested, please send a mail to hathaways at infotrain.com and I will send you pricing, etc. Thanks, Scott Hathaway From phd at phd.pp.ru Wed Feb 14 04: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 mikael at isy.liu.se Thu Feb 22 02: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 jeremy at alum.mit.edu Mon Feb 12 17: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 sheila at spamcop.net Mon Feb 19 00: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 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 boud at rempt.xs4all.nl Sun Feb 11 16:08:32 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 11 Feb 2001 21:08:32 GMT Subject: PyQT problems... References: <3A867F6E.FD5C7C3F@crepido.com> Message-ID: <966v0g$f20$1@news1.xs4all.nl> marco at crepido.com wrote: > Hi all, > I hope this is the right place to kindly ask for help. > I have a problem with the Python bindings for QT. But I'm not > sure if it is a QT or Python problem... > When I run a pyQT program that uses signals and slots (about 99.99% > do...) > Python complains about the signal being of the wrong type to match > the slot. > I tried several PyQT programs and they all behave the same. > Example error message running Eric... > Traceback (most recent call last): > File "/usr/local/lib/python2.1/site-packages/eric/eric.py", line 23, > in ? > mw = UserInterface(dbs,prog) > File "/usr/local/lib/python2.1/site-packages/eric/UserInterface.py", > line 53, in __init__ > self.connect(openAct,SIGNAL('activated()'),self.handleOpen) > RuntimeError: Signal has wrong argument types for slot > Have anyone seen this error and knows what to do about it?? Most likely self.handleOpen isn't defined as: class ... def handleOpen(self) but has zero or more than one arguments. There are certainly no problems at all using signals and slots in PyQt: look at the example scripts, or my work (http://www.valdyas.org/python), or my article on the subject in January's Dr Dobbs. -- Boudewijn Rempt | http://www.valdyas.org From erno-news at erno.iki.fi Mon Feb 12 11: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 grante at visi.com Tue Feb 20 13: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 walterm at cmat.edu.uy Fri Feb 16 20: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 jurgen.defurne at philips.com Wed Feb 7 02:17:03 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Wed, 7 Feb 2001 08:17:03 +0100 Subject: While everyone is saying what they want in Python :) Message-ID: <0056900015716907000002L072*@MHS> In fact, 'with' is not an artefact of Delphi, but from the plain, original Pascal! Jurgen ullrich at math.okstate.edu@SMTP at python.org on 06/02/2001 16:42:59 Please respond to ullrich at math.okstate.edu@SMTP Sent by: python-list-admin at python.org To: python-list at python.org@SMTP cc: Subject: Re: While everyone is saying what they want in Python :) Classification: On Tue, 06 Feb 2001 01:35:02 GMT, "Don Tuttle" wrote: > >"Jay O'Connor" wrote in message >news:3A7DB154.87E04245 at cybermesa.com... >> I'm not familiar with the 'with' keyword in Delphi. > >Here's a vbscript example. >With MyLabel > .Height = 2000 > .Width = 2000 > .Caption = "This is MyLabel" >End With >Personally, I'd love to see Python include the 'with' keyword! It improves >readability and should execute a bit faster as well. Delphi's "with" is more or less the same except without the dots at the start of the field names. For a long time I've seen Delphi people say that with is bad, the reason being it leads to bugs with AnObject do begin OneThing AnotherThing end when AnObject does not have a OneThing method but there _is_ a OneThing in the surrounding scope. For years I thought this was just stupid - you should know what sort of object you're dealing with. The Python slogans about how explicit is better than implicit just about have me convinced that people are right, with is bad. Right or not, it certainly seems contrary to the "explciit is better than implicit" philosophy. >Don > > > > -- http://mail.python.org/mailman/listinfo/python-list From jeremy at alum.mit.edu Wed Feb 21 14: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 hgg9140 at cola.ca.boeing.com Tue Feb 6 10:34:59 2001 From: hgg9140 at cola.ca.boeing.com (Harry George) Date: Tue, 6 Feb 2001 15:34:59 GMT Subject: UDDI (XML discovery)? Message-ID: Anyone working on a python rendition of UDDI? There are some open source java implementation which could server as templates if need be. -- 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 btheld2 at my-deja.com Tue Feb 6 17:49:48 2001 From: btheld2 at my-deja.com (btheld2 at my-deja.com) Date: Tue, 06 Feb 2001 22:49:48 GMT Subject: Getting result of dir(object) in C++ Message-ID: <95pv28$1de$1@nnrp1.deja.com> I need to get a string in C++ that contains all of the functions and member data of a PyObject. I know how to do this in raw python (dir(ob.__class__)), but how do I do this in C++? Assume I have a PyObject* retreived from PyEval_EvalCode("objectstring")... Ideas? Sent via Deja.com http://www.deja.com/ From fredrik at effbot.org Sat Feb 3 04: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 bsass at freenet.edmonton.ab.ca Mon Feb 26 14:22:47 2001 From: bsass at freenet.edmonton.ab.ca (Bruce Sass) Date: Mon, 26 Feb 2001 12:22:47 -0700 (MST) Subject: [Distutils] Re: CPAN functionality for python In-Reply-To: Message-ID: On Mon, 26 Feb 2001, John J. Lee wrote: > On Mon, 26 Feb 2001, Guido van Rossum wrote: > [...] > > 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.) > > Surely this is a function of free vs. non-free software as opposed to > which particular packaging format you are using? I think the problem with RPMs is that they depend on a specific package, instead of depending on the contents of a package. e.g., If you have code depending on libfoo-1.x, depending on the package that provides libfoo-1.1 will work, but is no good to people with libfoo-1.2, the dependency should be on any package that provides libfoo-1. - Bruce From xavier at perceval.net Fri Feb 9 04:22:53 2001 From: xavier at perceval.net (Xavier Defrang) Date: Fri, 9 Feb 2001 10:22:53 +0100 (CET) Subject: types.FunctionType vs types.LambdaType Message-ID: Dear fellow Pythoneers, 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). >>> def f(x): ... return x ... >>> t1=type(f) >>> t2=type(lambda x: x) >>> t1, t2 (, ) >>> import types >>> types.FunctionType >>> types.LambdaType >>> types.FunctionType == types.LambdaType 1 I can't figure out the rationale for this LambdaType. It might even be confusing for people who think they can make the difference between a "real" function and a function created from a lambda expression. I think that it's fair that no one can tell the difference between a "real" function (a 'def' statement) and a lambda statement but why are there two types ?!? 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 l.szyster at ibm.net Thu Feb 8 09:31:55 2001 From: l.szyster at ibm.net (Laurent Szyster) Date: Thu, 08 Feb 2001 15:31:55 +0100 Subject: SSL Client-Server References: <95ru3l$2hk$1@ryu.it> Message-ID: <3A82ADDB.F7B6902@ibm.net> Ryujin wrote: > > I have Python2.0 and OpenSSL-0.9.6 installed > Anybody knows where to find a tutorial showing how > to create a client-server ssl socket connection? I'd > like to realize a simple client connecting and sending > something to the server using SSL > > I could only find out this: > > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > s.connect((HOST, PORT)) > ssl = socket.ssl(s, keyfile, certfile) > > whatabout the server? and whatbout the documentation? > Any help would be really appreciated. Have a look at the m2crypto package, it has it all: http://mars.post1.com/home/ngps/m2/ Good luck ... Laurent Szyster From joconnor at cybermesa.com Mon Feb 5 12:45:59 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Mon, 05 Feb 2001 17:45:59 GMT Subject: Please translate this easy snip of C++ to Python References: <95kcbo$k8s@dispatch.concentric.net> <3A7E3C04.9EB02932@engcorp.com> <3A7ECEAB.DB6F8648@cybermesa.com> <3A7EDE5C.5D3F7050@alcyone.com> Message-ID: <3a7ee6b3.673800@news.cybermesa.com> On Mon, 05 Feb 2001 09:09:48 -0800, Erik Max Francis wrote: >Jay O'Connor wrote: > >> Rainer Deyke wrote: >> > catch...'ComputerExplodingError'. >> >> I hadn't seen that exception raised yet....is it new? What do you >> usually do to handle it? > >Right past you. Nope, just being silly :) Take care, Jay O'Connor joconnor at cybermesa.com http://www.cybermesa.com/~joconnor "God himself plays on the bass strings first, when he tunes the soul" From sholden at holdenweb.com Wed Feb 14 07: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 adam at deprince.net Mon Feb 19 20: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 bowman at montana.com Sun Feb 18 11: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 wmiller at mediaone.net Tue Feb 20 18: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 chris.gonnerman at usa.net Tue Feb 27 22: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 jarober at mail.com Mon Feb 26 08: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 jafo at tummy.com Mon Feb 26 03: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 danielk at aracnet.com Fri Feb 23 08: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 sfriedman at bewellnet.com Tue Feb 27 22: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 fuess at att.net Wed Feb 21 23: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 dnew at san.rr.com Sat Feb 3 19: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 noahnoah.org Sat Feb 24 15: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 fgeiger at datec.at Thu Feb 8 02:34:31 2001 From: fgeiger at datec.at (Franz GEIGER) Date: Thu, 8 Feb 2001 08:34:31 +0100 Subject: ZODB: What does change if classes get persistent? Message-ID: <95ti61$2p$1@newsreaderm1.core.theplanet.net> Hello all, 1) "How do you lock your web app data" was a question I asked about a week ago (many thanks to all who contributed!!!). Alex Martelli pointed me to try working with a database. So I started to do so. A few days later I came across A.M. Kuchling's contribution "Alpha release of ZODB programming guide". As I plan to "upgrade" my cgi lessons to Zope, I thought it'd be a good idea to try ZODB which is part of Zope. I downloaded the package from AMK's site and gave it a try, because it indeed sounds rather promising, what I read in the docs. So I played around but soon ran into troubles: I have a class class TCarts(TCollection, Persistence.Persistent): def __init__(self): TCollection.__init__(self) which inherits from TCollection. TCollection wraps a dictionary. After mixin' in Persistence.Persistent I get the following error TCollection.__init__(self, self) TypeError: unbound method must be called with class instance 1st argument upon creation. Does anybody know what's going on here behind the scenes? 2) A few contributors of "How do you lock your web app data" stated that using a lock file to protect data against multiple access is somewhat problematic especially in case of app crahes. This is the very problem I encountered with my ferw lines of ZODB app! This astonished me a bit. ZODB provides such sophisticated functionality to a user's app but runs into troubles because of a simple lock file? BTW, the error message is File "C:\Program Files\Python20\ZODB\lock_file.py", line 115, in lock_file raise error, (StorageSystemError: Could not lock the database file. There must be another process that has opened the file. Any suggestions how to proceed? Did I miss something substantial? Many thanks in advance and best regards Franz GEIGER From mkx at excite.com Wed Feb 21 11: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 scarblac at pino.selwerd.nl Thu Feb 22 15: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 ben.hutchings at roundpoint.com Tue Feb 27 18: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 chris at onca.catsden.net Sat Feb 3 17:34:26 2001 From: chris at onca.catsden.net (chris at onca.catsden.net) Date: Sat, 3 Feb 2001 14:34:26 -0800 (PST) Subject: Syntax Error In-Reply-To: <95i0vt+kju6@eGroups.com> Message-ID: On Sat, 3 Feb 2001 kwasi007uk at yahoo.co.uk wrote: > Using e.g. poplib, m=poplib.POP3 ... > I typed in error m.quit. > It should have been m.quit(). > Why doesn't Python give me an error message? > It definitely should since q.quit does not exist! m.quit returns a callable function object, and () calls it. If m.quit were to return some sort of error, then you would not be able to assign it to something else. Eg: x = m.quit However, I'm sure there are a lot of inadvertant errors that could have been picked up if Python issued a warning if return results are not used unless a special construct is employed. I'm sure this has all been gone over before, but its fun... lets do it again: Eg, say a function f returned a value, and had a side effect (yes, this is bad practise, but this is just an example, okay? :) Now say I wanted to call this function f /just/ for the side effect: f() With the scheme above, this would issue a warning. However, if the language had a discard construct: discard f() This would solve kwasi's problem. 'm.quit' would return a warning since the value is not used anywhere. He (she?) would them either change that to m.quit() as he intended, or add the 'discard' keyword, telling the interpretor to suppress the warning. Personally, I dont think its worth the extra work. I've learned not to screw up so often ;) ("`-/")_.-'"``-._ Ch'marr, a.k.a. . . `; -._ )-;-,_`) Chris Cogdon (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' FC1.3: FFH3cmA+>++C++D++H++M++P++R++T+++WZ++Sm++ ((,.-' ((,/ fL RLCT acl+++d++e+f+++h++i++++jp-sm++ From stadt at cs.utwente.nl Mon Feb 5 16:53:29 2001 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Mon, 05 Feb 2001 22:53:29 +0100 Subject: cgi.FieldStorage() problem Message-ID: <3A7F20D9.4BE57828@cs.utwente.nl> Hi, I have a problem, which seems to happen with 2.0, and not with 1.5.2 I have a webform (with quite some data in it) which is "POST"ed to a cgi-script that calls cgi.FieldStorage() It fails. This exception is what I get if I "try" it: Traceback (most recent call last): File "/...../cgi-bin/submitAssignRP.py", line 144, in main File "/opt/python/2.0/sparc-sunos5.6/lib/python2.0/cgi.py", line 504, in __init__ File "/opt/python/2.0/sparc-sunos5.6/lib/python2.0/cgi.py", line 593, in read_multi File "/opt/python/2.0/sparc-sunos5.6/lib/python2.0/cgi.py", line 506, in __init__ File "/opt/python/2.0/sparc-sunos5.6/lib/python2.0/cgi.py", line 603, in read_single File "/opt/python/2.0/sparc-sunos5.6/lib/python2.0/cgi.py", line 623, in read_lines File "/opt/python/2.0/sparc-sunos5.6/lib/python2.0/cgi.py", line 713, in make_file File "/opt/python/2.0/sparc-sunos5.6/lib/python2.0/tempfile.py", line 144, in TemporaryFile OSError: [Errno 24] Too many open files: '/var/tmp/@24739.61' Would anyone know what is causing this? Is it python, is it the OS? And what's more, if there is a solution for this? Richard. From rolney at pcug.org.au Fri Feb 23 00: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 sburr at home.com Thu Feb 8 23:13:10 2001 From: sburr at home.com (Steven Burr) Date: Fri, 09 Feb 2001 04:13:10 GMT Subject: Is Python "Compiled"? References: <3a81ad07_3@goliath2.newsfeeds.com> <5Iig6.1295$D3.5361@tor-nn1.netcom.ca> <95ug7b$qp0$1@c3po.schlund.de> Message-ID: In article <95ug7b$qp0$1 at c3po.schlund.de>, hannah at schlund.de (Hannah Schroeter) wrote: > Hello! > > In article <5Iig6.1295$D3.5361 at tor-nn1.netcom.ca>, > Warren Postma wrote: > > >[...] > > >Various efforts to build a Compiler are in "research stages". Dynamic > >languages don't respond well to attempts to compile them. . Nevertheless, > >some very smart people seem to be trying. > > What about Lisp, which is very often compiled to native code? > > Besides, JIT technology is also there, already for a long time > (look at Smalltalk implementation techniques and see stuff implemented > a decade ago which they just "discover" for Java). > [snip] According to Apple's documentation, Objective C, the programming language for the Mac OSX Cocoa environment, also supports dynamic typing and dynamic binding. See http://developer.apple.com/techpubs/macosx/Cocoa/ObjectiveC/ObjC.pdf Since I'm at best a programming diletante, this may be entirely beside the point, and if so forgive me. I thought it might be useful information for those attempting to build a Python compiler. From dsh8290 at rit.edu Thu Feb 8 14:05:48 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 8 Feb 2001 14:05:48 -0500 Subject: None assigment In-Reply-To: <20010208105540.A13016@glacier.fnational.com>; from nas@arctrix.com on Thu, Feb 08, 2001 at 10:55:40AM -0800 References: <31575A892FF6D1118F5800600846864D5B17D5@intrepid> <20010208131523.A13104@harmony.cs.rit.edu> <"from dsh8290"@rit.edu> <20010208105540.A13016@glacier.fnational.com> Message-ID: <20010208140547.A13209@harmony.cs.rit.edu> On Thu, Feb 08, 2001 at 10:55:40AM -0800, Neil Schemenauer wrote: | On Thu, Feb 08, 2001 at 01:15:23PM -0500, D-Man wrote: | > Interesting. So normally "None" is a special keyword (that is a | > reference to an object) , but that doesn't prevent one from creating | > a local variable named "None" that shadows the keyword. | | Sounds like something another P language would do. Things are | simpler. None is a builtin. It exists in the __builtin__ | module. The buildin module is searched for names after the | global namespace is searched. So why can't I 'del' it then? It is the response from del that made me think it was a special keyword. -D From ransen_spam_me_not at nemo.it Fri Feb 16 06: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 tim.one at home.com Sun Feb 25 14: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 akuchlin at mems-exchange.org Thu Feb 8 13:41:24 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 08 Feb 2001 13:41:24 -0500 Subject: Alpha release of ZODB programming guide References: <95tlrt$7f2$1@nnrp1.deja.com> Message-ID: <3dsnlp586j.fsf@ute.cnri.reston.va.us> fredp at mygale.org.nospam (Fred Pacquier) writes: > Indeed. As it is, both "ZOPE" and "ZODB" are close enough, phonetically, > when pronounced in French, as to be incomfortable in corporate settings. Well, you could expand the acronym to Z Object Database. Or maybe "Base a Donnees Z", which would have the French acronym BDZ. --amk From thomas at xs4all.net Sat Feb 3 21:31:11 2001 From: thomas at xs4all.net (Thomas Wouters) Date: Sun, 4 Feb 2001 03:31:11 +0100 Subject: NameError in cross imports of modules In-Reply-To: ; from pearu@cens.ioc.ee on Sat, Feb 03, 2001 at 09:31:01PM +0200 References: Message-ID: <20010204033111.C962@xs4all.nl> On Sat, Feb 03, 2001 at 09:31:01PM +0200, Pearu Peterson wrote: > I have two classes defined in separate files and both classes use each > other: > File A.py: > from B import * > class A: > def asB(self): return B() > File B.py: > from A import * > class B: > def asA(self): return A() > > In Python session I get NameError: > >>> from A import * > >>> from B import * > >>> B().asA() > Traceback (most recent call last): > File "", line 1, in ? > File "B.py", line 5, in asA > return A() > NameError: global name 'A' is not defined > but > >>> A().asB() > > Note: I am not interested in converting the 'from-import' statements to > 'import' statements, rather I have collected the classes A and B into the > same file but it's really inconvenient to maintain a large package in one > file :( You really should be interested in not using from-import; it solves your problem. It works like this: You execute 'from A import *': 'A' has not been loaded yet; A.py is found and loaded: A new module object is created, and stored in sys.modules['A'] A.py is executed, in the namespace of the newly created module: On the first line, the interpreter finds 'from B import *'. 'B' has not been loaded yet; B.py is found and loaded: A new module object is created and stored in sys.modules['B'] B.py is executed, in the namespace of the newly created module. On the first line, the interpreter finds 'From A import *'. 'A' has already been loaded (it's present in sys.modules) 'A' is retrieved from sys.modules, and scanned for names: none found B executes the rest of the code, defining class B. A retrieves module 'B' from sys.modules, and scans it for names: B found A executes the rest of the code, defining class A. (I know from your posting you know at least part of this, but it's also to educate others who might not :) By the time 'B' loads 'A' (too early), there is no class 'A' to from-import, and because you use 'from A import *', it isn't added later. Where we to 'automatically' reload the 'right' module (magically finding out the right time and module to reload) we could very easily start looping. In fact, this entire behaviour is intended to avoid looping. > >>> reload(sys.modules['B']) --- is needed in order to fix the > NameError: module B will be imported > "completely". This is not true, and implies that you didn't really understand what was happening. 'B' isn't the one incompletely imported, 'A' was! And because you use 'from-import-*', which makes *copies* of the variables (which are themselves references) in a module, reloading 'A' won't help, because 'B' won't see the new variables. You have two real ways to fix this: don't use 'from-import *'. Honestly, it is the best solution. 'from-import *' was not intended for this kind of hackery, and as far as I'm concerned there are only two viable uses: the way os.py uses it (import any and all symbols from a platform-dependant C module) and the way Mailman uses it (import all symbols from a template config file into the user-editable config file, so it only needs to contain overriding values.) I still owe Fred a "From module import * considered harmful" tutorial-section ;-P If prefixing all module variables with the module name is too painful because the module name is too long or unclear, consider using 'import my_long_module as _a' or some such. Alternatively, move the 'from-import *' to the bottom of the file, instead of the top. That way, 'A' will have defined all the variables before it starts loading B, and B won't have any problem finding them. Definately the inferior solution, though ;) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From glen.mettler at home.com Sun Feb 18 09: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 rwklee at home.com Tue Feb 20 19: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 mikael at isy.liu.se Fri Feb 23 04: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 claird at starbase.neosoft.com Thu Feb 22 10: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 fredrik at pythonware.com Wed Feb 21 15: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 glen.mettler at home.com Mon Feb 26 21: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 bashanguy at hotmail.com Sun Feb 4 17:29:41 2001 From: bashanguy at hotmail.com (guy bashan) Date: Mon, 5 Feb 2001 00:29:41 +0200 Subject: TKInter installation problems Message-ID: <3a7dd337@news.bezeqint.net> Hello, I have just installed the ActiveState Komodo. I thought that the tkinter package should be already included in the ActivePython, but when I tried running some simple samlpe demo using the tkinter, it wrote me that I'm missing: tcl83.dll. After a little search I downloaded the PythonWare package, which should have the tkinter in it. The PythonWare looks pretty much like the ActivePython, but it really did include the missing DLL. after copying the requested DLL to the folder of the ActivePython (under the DLL folder), I tried running the sample again, but encountered some weird long sequence of errors, and at the end got a message that the TCL is probably not installed well . . . What have I done wrong ??? thanks in advance, Guy Bashan. bashan at newmail.net From phlip_cpp at my-deja.com Sun Feb 18 14: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 che at debian.org Mon Feb 5 17:25:06 2001 From: che at debian.org (Ben Gertzfield) Date: 05 Feb 2001 14:25:06 -0800 Subject: sorting on IP addresses References: <3A7F26CB.BE85C96F@esec.com.au> Message-ID: >>>>> "Sam" == Sam Wun writes: Sam> Hi, Does anyone know what is the quickly way to sort a list Sam> of IP addresses? Sam> ie. 203.21.254.89 should be larger than 203.21.254.9 If you're using Python 1.6 or greater, the socket module includes inet_aton and inet_ntoa functions, used for converting IP addresses from 123.45.67.89 format to the 4-byte "packed IP" representation. You can then just use a normal sort on the packed IPs. Ben -- Brought to you by the letters P and R and the number 1. "Atatakaku natta kara, otaku to uchi no kazoku de, nani ka shimasen ka?" Debian GNU/Linux maintainer of Gimp and GTK+ -- http://www.debian.org/ From donn at u.washington.edu Fri Feb 2 12: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 porter at et.byu.edu Wed Feb 14 01: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 stephen_purcell at yahoo.com Fri Feb 16 08: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 n8gray at caltech.edu.is.my.email.address Tue Feb 20 01: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 walterm at cmat.edu.uy Mon Feb 12 08: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 rtrocca at libero.it Tue Feb 13 03: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 zope at thewebsons.com Wed Feb 14 14: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 jafo at tummy.com Tue Feb 27 23:13:31 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Tue, 27 Feb 2001 21:13:31 -0700 Subject: [Distutils] Re: CPAN functionality for python - requirements In-Reply-To: <01022710324002.20069@branagan>; from doughellmann@home.com on Tue, Feb 27, 2001 at 10:17:06AM -0500 References: <01022710324002.20069@branagan> Message-ID: <20010227211331.A24378@tummy.com> On Tue, Feb 27, 2001 at 10:17:06AM -0500, Doug Hellmann wrote: >OR automatically. If the source distribution is always available, part of the >mirroring process could be to convert the source distributions into binary >distributions for the platform serviced by the mirror site. That seems like it would be a huge security issue. Sean -- Passionate hatred can give meaning and purpose to an empty life. -- Eric Hoffer Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From amk at mira.erols.com Wed Feb 28 07: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 andrew at intertrader.com Wed Feb 7 09:30:42 2001 From: andrew at intertrader.com (Andrew Cooke) Date: Wed, 07 Feb 2001 14:30:42 +0000 Subject: Variable depth of nesting References: Message-ID: <3A815C12.A375380F@intertrader.com> I think this is "Power Loops" - see the first chapter (IIRC) of Finkel at http://cseng.aw.com/book/related/0,3833,0805311912+20,00.html (although I may be wrong as they never made much sense to me and my brand-spanking-new firewall won't let me look at the book that URL indicates any more because it's FTP). Andrew Jacek Generowicz wrote: > > Is it somehow possible to write loops with variable nesting depths? > > For example, I would like to write something like the function > outlined below without having to use the if clauses. Particularly, I > would like to make it work for a GENERAL length of list_of_lists. > > def hmm ( list_of_lists ): > if len( list_of_lists ) == 1: > for x in list_of_lists[0]: > # do something > return > > if len( list_of_lists ) == 2: > for x in list_of_lists[0]: > for y in list_of_lists[1] > # do somehting > return > > if len( list_of_lists ) == 3: > for x . . . : > for y . . . : > for z . . . : > # do something > return > > if len( list_of_lists ) == 4: > > #etc. > #etc. > > Alternatively, how about list comprehensions with variable order: > > def hmm ( l ): > if len( l ) == 1: > return [ x for x in l[0] ] > > if len( l ) == 2: > return [ (x,y) for x in l[0] for y in l[1] ] > > if len( l ) == 3: > return [ (x,y,z) for x in l[0] for y in l[1] for z in l[2] ] > > #etc. > #etc. > > Any ideas ? > > Thanks, > > Jacek From eq3pvl at eq.uc.pt Tue Feb 20 08: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 sciasbat at inorbit.com Wed Feb 21 11: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 slaurent at sonicfoundry.com Fri Feb 23 15: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 tim.one at home.com Wed Feb 28 15: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 nem00u at cs.nott.ac.uk Sun Feb 18 11: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 gbell at uclink.berkeley.edu Thu Feb 1 10: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 dsh8290 at rit.edu Thu Feb 15 19:58:27 2001 From: dsh8290 at rit.edu (D-Man) Date: Thu, 15 Feb 2001 19:58:27 -0500 Subject: CPAN functionality for python In-Reply-To: <20010215165234.J23577@tummy.com>; from jafo@tummy.com on Thu, Feb 15, 2001 at 04:52:34PM -0700 References: <"from doughellmann"@bigfoot.com> <20010215165234.J23577@tummy.com> Message-ID: <20010215195827.B2150@harmony.cs.rit.edu> On Thu, Feb 15, 2001 at 04:52:34PM -0700, Sean Reifschneider wrote: | I see the catalog and the actual file contents being two very | distinct things, and that they don't necessarily need to be placed | on the same machine. I agree with this. Something I sometimes wish for is a single site that has a list of all the software goodies I want. I can easily forget where I found a certain neat proggy, and google, etc, usually give a lot of extraneous results. Sounds like this is what Trove tried to do, but it must not have succeeded. I guess I need to keep my own list ;-). -D From ransen_spam_me_not at nemo.it Wed Feb 21 11: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 ssthapa at barnacle-bill.cs.uchicago.edu Fri Feb 16 13: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 gustav at morpheus.demon.co.uk Mon Feb 12 16:56:52 2001 From: gustav at morpheus.demon.co.uk (Paul Moore) Date: Mon, 12 Feb 2001 21:56:52 +0000 Subject: python-dev summary, Jan. 16-31 References: <3d4ry56vzg.fsf@ute.cnri.reston.va.us> <95v2lq$hjl$1@slb7.atl.mindspring.net> <3dpugs6cqi.fsf@ute.cnri.reston.va.us> Message-ID: On 08 Feb 2001 17:17:41 -0500, Andrew Kuchling wrote: >Note that you *can* send messages to python-dev; only >subscription is limited. Um. So let's just get this straight. Anyone can post to python-dev, anyone can read it via the web interface, so the only purpose of the restricted access is to stop people being able to read the content via a mailreader....??? This is seriously dumb. The subscription process does nothing practical apart from making it *look like* the Python development team are insular and unwilling to accept input from the community? Please, someone. Straighten this out, or explain the reasons behind the current setup! Paul. From phrxy at csv.warwick.ac.uk Sun Feb 11 18:15:29 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Sun, 11 Feb 2001 23:15:29 +0000 Subject: PyQT problems... In-Reply-To: <3A867F6E.FD5C7C3F@crepido.com> References: <3A867F6E.FD5C7C3F@crepido.com> Message-ID: On Sun, 11 Feb 2001 marco at crepido.com wrote: > I hope this is the right place to kindly ask for help. [snipped PyQt question] Yes, but there's a PyKDE mailing list too (covers both PyQt and PyKDE). http://mats.gmd.de/mailman/listinfo/pykde John From tim.one at home.com Sat Feb 17 13: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 aleaxit at yahoo.com Sun Feb 18 06: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 cerutti at together.net Wed Feb 7 08:41:56 2001 From: cerutti at together.net (Neil Cerutti) Date: 7 Feb 2001 13:41:56 GMT Subject: Some basic questions about Tkinter (probably v easy for experts!) References: Message-ID: Martyn Quick posted: >(1) If I am going to use Pmw, then I need to have Tkinter >installed. But do I need to understand how to use Tkinter (at >least to a basic degree) before I can use Pmw? Yes, definitely. Pmw adds more widgets to your toolbox, but they act like Tkinter widgets in every way. For the rest of your questions, the easiest thing will be to read: http://www.pythonware.com/library/tkinter/introduction/ In particular, read Section 1, "Introducing Tkinter". But don't only read it; also open a Python interpreter (a simple CLI will work best), and type in the examples as they appear in the manual. -- Neil Cerutti From db3l at fitlinxx.com Tue Feb 27 20: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 bs1535 at sbc.com Mon Feb 12 16: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 chris.gonnerman at usa.net Thu Feb 22 22: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 dwig at advancedmp.net Fri Feb 16 13: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 sholden at holdenweb.com Fri Feb 2 16:49:32 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 2 Feb 2001 16:49:32 -0500 Subject: ADO/ODBC call via Python/IIS References: <95f558$jgl$1@nnrp1.deja.com> Message-ID: "Bill Seitz" wrote in message news:95f558$jgl$1 at 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 " 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 othello at javanet.com Thu Feb 22 22: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 Bill.Scherer at VerizonWireless.com Fri Feb 2 00: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 MarkH at ActiveState.com Tue Feb 13 18: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 dan at eevolved.com Sun Feb 11 15:26:25 2001 From: dan at eevolved.com (Dan Parisien) Date: Sun, 11 Feb 2001 20:26:25 GMT Subject: PyQT problems... References: <3A867F6E.FD5C7C3F@crepido.com> Message-ID: marco at crepido.com wrote: > Hi all, > > I hope this is the right place to kindly ask for help. Sure. I can direct you towards better help though Here's docs on signals and slots http://www.thekompany.com/projects/pykde/pyqt_docs/x125.html Here's the mailing list (full of other PyQt developers that can answer your questions) http://mats.gmd.de/mailman/listinfo/pykde > Have anyone seen this error and knows what to do about it?? Wow. No I haven't. Very interesting though. I suggest joining the mailing list and asking this question there (not that you won't receive help here, it's just that the people with the knowledge are there) peace, Dan From jhylton at my-deja.com Mon Feb 5 13: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 b.l.crawford at worldnet.att.net Sat Feb 17 18: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 dan at eevolved.com Thu Feb 15 20: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 chrisa at ASPATECH.COM.BR Fri Feb 23 14: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 topmind at technologist.com Tue Feb 27 14: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 Milan.Gardian at leibinger.com Tue Feb 6 05:16:37 2001 From: Milan.Gardian at leibinger.com (Milan.Gardian at leibinger.com) Date: Tue, 06 Feb 2001 10:16:37 GMT Subject: Q: Python regular expression \Z delimiter Message-ID: <95oiu2$o7v$1@nnrp1.deja.com> Hello, I have the following problem with Python's re module: When using multiline mode (re.MULTILINE alias re.M) together with single-line mode (re.DOTALL alias re.S), the regular expression should evaluate metacharacter \Z as the end of string regardless of any embedded newlines in the processed string (unlike $). Unfortunately it does not work for me this way... Please consider those examples: --- #Perl: r1.pl $txt = "Hello\nWorld\n"; $txt =~ /(.*?\Z)/ms; print "$1\n"; --- #Python: r1.py import re; txt = "Hello\nWorld\n"; reg = re.compile(r'(.*?\Z)', re.M | re.S); res = reg.search(txt); print res.group(1); --- They should both produce the same result because they use the same regular expression with the same modifiers (ms). Perl behaves as expected (matches the string until the end): C:\Temp>r1.pl Hello World C:\Temp> On the other hand, Python behaves differently (matches the string only until the first line-delimiter): C:\Temp>r1.py Hello C:\Temp> The \Z metacharacter evidently does not match at the end of string (as it should), but at the end of line (i.e. behaves exactly like '$' should and does in multiline mode). When using '$' delimiter instead, both scripts behave alike: --- #Perl: r2.pl $txt = "Hello\nWorld\n"; $txt =~ /(.*?$)/ms; print "$1\n"; --- #Python: r2.py import re; txt = "Hello\nWorld\n"; reg = re.compile(r'(.*?$)', re.M | re.S); res = reg.search(txt); print res.group(1); --- C:\Temp>r2.pl Hello C:\Temp>r2.py Hello Could anybody explain this behavior to me please? Perhaps I do something wrong, but currently it seems to me this behavior is a bug in Python's implementation of re. Regards, Milan G. Sent via Deja.com http://www.deja.com/ From stksee at yahoo.co.jp Wed Feb 7 03:28:17 2001 From: stksee at yahoo.co.jp (stksee at yahoo.co.jp) Date: Wed, 07 Feb 2001 17:28:17 +0900 Subject: How can I change newline code? Message-ID: <3A810721.68294483@yahoo.co.jp> It seems "\n" is treated as LF. Instead, I want to set "\n" as "CRLF" in string object. What should I do ? From jimmypop181 at my-deja.com Mon Feb 5 14:13:39 2001 From: jimmypop181 at my-deja.com (jimmypop181 at my-deja.com) Date: Mon, 05 Feb 2001 19:13:39 GMT Subject: Can't Generate Random # Message-ID: <95mu0p$aqc$1@nnrp1.deja.com> Does somebody know how to generate a random number in Python? I read the docs and it says rand(x, y) should do it. But whenever I try that, It says that "there is no variable named rand". This also happens when trying to get the Square Root. Please help. Sent via Deja.com http://www.deja.com/ From loewis at informatik.hu-berlin.de Fri Feb 2 17:45:47 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Feb 2001 23:45:47 +0100 Subject: Substring functions References: <95f8u7$n1f$1@nnrp1.deja.com> Message-ID: dnedrow at usa.net writes: > The are two functions (is that even the term?) Sure. What you got are functions. > def shellProtect(file): > """Protects a filename against shell interpretation. > This is done by putting the name in single quotes, and by > escaping single quotes in the filename. > """ > return "'%s'" % string.replace(file, "'", "'\\''") > > > def mv(self, src, dest): > """Shorthand for the pattern trace('mv...);os.system("mv...).""" > self.system("mv %s %s" % (shellProtect(src), shellProtect(dest))) As a side note: Isn't os.rename good enough? On Unix, os.rename won't work across filesystem boundaries, but some versions of mv will; if you can exclude that case, os.rename is faster and more reliable than invoking a shell. > Basically, mv() is called with source and destination parameters. These > are quoted via shellProtext() and then passed as input parameters for the > Unix mv command. > > E.g. if src=/usr/tmp/1/* and dest=/usr/tmp/2, the mv command issued by > calling mv() above would be: > > mv '/usr/tmp/1/*' '/usr/tmp/2' > > Unfortunately, a wildcard doesn't work when quoted as above. How do I > check for an * at the end of the string and quote the input as > '/usr/tmp/1/'* > rather than > '/usr/tmp/1/*' > > Any pointers would be appreciated. Again, I suggest to operate differently. glob.glob will expand wildcards, and just leave the name as-is if it is a non-pattern valid file name (actually, it returns a list of file names in either case). It turns out that os.rename wants the target filename; it doesn't automatically generate a file name if the target is a directory. That is where glob.glob1 helps. So to do the equivalent of your move, I'd do import os,glob srcdir = "/usr/tmp/1" dstdir = "/usr/tmp/2" for srcfile in glob.glob1(srcdir,"*"): src = os.path.join(srcdir,srcfile) dst = os.paht.join(dstdir,srcfile) os.rename(src, dst) In addition, if the only pattern you care about is "*" (i.e. all files), then for srcfile in os.listdir(srcdir): ... is even better: it is faster, clearer to read, and it will catch dotfiles (.foo) in /usr/tmp/1 whereas * won't. I don't know whether you have to support a single move-all-files operation or whether this is just a special case of something more general, so I can't advise a "best" solution. Regards, Martin From stephen_purcell at yahoo.com Tue Feb 13 09:59:47 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 13 Feb 2001 15:59:47 +0100 Subject: python 2.0 won't run scripts with \r\n line termination on RH7? In-Reply-To: <3A894883.61C64508@uol.com.br>; from csrabak@uol.com.br on Tue, Feb 13, 2001 at 11:45:23AM -0300 References: <3A894883.61C64508@uol.com.br> Message-ID: <20010213155947.B759@freedom.puma-ag.com> 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). 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? -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 binnc at my-deja.com Thu Feb 1 14: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 cjw at sympatico.ca Sun Feb 18 12: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 rtrocca at libero.it Thu Feb 15 02: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 jmarshal at mathworks.com Mon Feb 19 22: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 jpet at eskimo.com Thu Feb 8 01:49:17 2001 From: jpet at eskimo.com (Jeff Petkau) Date: Thu, 08 Feb 2001 06:49:17 GMT Subject: Radix sort algorithm in Python question References: Message-ID: Ray Van Dolson wrote in message news:g_5g6.12851$1%2.627095 at sjc-read.news.verio.net... > I'm designing a Radix sort algorithm in Python (for an assignment). I have > the algorithm done, but it's not exactly fast. Since I'm supposed to be > comparing this to Quicksort (my Python Quicksort implementation is - > infinitely- faster). Here's the code: > > def rSort(a,n,maxLen): > bins=[[],[],[],[],[],[],[],[],[],[],[]] > for x in range(0,maxLen): > if x == 0: > for y in a: > bins[y%n].append(y) > else: > for y in a: > origValue=y > if y < 10**x: > bins[0].append(y) > else: > y=y/(10**x) > bins[y%n].append(origValue) > del a > a=[] > for section in bins: > if len(section) > 0: > for times in range(0,len(section)): > a.append(section.pop(0)) > > > I'm guessing the problem lies when I am taking the elements out of the > "bins" and putting them back into the array. I delete the array and then > step through the bins popping the numbers out. When we're talking about > thousands of elements this takes a while. > > Anyone have any suggestions on how I could better streamline this? I don't > think radix should be 40 times slower than quicksort, but I could be wrong. > > Thanks, > Ray Van Dolson First the minor stuff: all of the complicated if/else logic in the first loop is unnecessary--you end up doing the same thing in all cases. So you can change it to: for x in range(maxLen): bins[(y/10**x)%n].append(y) But the real problem is the 'section.pop(0)' call. Lists in Python are stored as linear arrays, and pop(0) removes the *first* element from the array, copying all the other elements down one position. Since the size of each bin is proportional to the size of the input array, this changes the algorithm from O(N) to O(N^2)! Instead, you could use 'a.extend(section)' to add the contents of section to a. This doesn't empty out section, so you have to do that (say with 'del section[:]') or just recreate the bins array each time through the loop. So the faster version is: def rSort2(a,n,maxLen): for x in range(maxLen): bins = [[] for i in range(n)] for y in a: bins[(y/10**x)%n].append(y) a=[] for section in bins: a.extend(section) return a On a 100,000 element list, rSort(x,10,6) takes about 59 seconds on my machine; rSort2() takes just under 5 seconds. On a 1,000,000 element list, rSort2(x,10,6) takes 54 seconds; I expect rSort() to take about an hour and a half, but I'm tired of waiting for it so I'll just send this message now. --Jeff From emile at fenx.com Mon Feb 26 07: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 matthias.oberlaender at daimlerchrysler.com Fri Feb 9 03:53:57 2001 From: matthias.oberlaender at daimlerchrysler.com (matthias.oberlaender at daimlerchrysler.com) Date: 9 Feb 2001 08:53:57 GMT Subject: How to copy class objects? Message-ID: <960b75$a2e$1@news.sns-felb.debis.de> This is the question I'd like to be answered: Is there some easy way to copy a class object? Here is the background: In order to generate classes from templates I'd prefer the following method over writing additional wrapper function class X: sratchdir = "/tmp/" # I want a new class Xnew differing from X in that its instances use a different scratch directory. Xnew = copyclass(X) # Now set scratchdir to something else Xnew.scratchdir = '/home/me/tmp' -- ____ __ _/_/ . ( / / ( / / / / ===================================================================== Matthias Oberlaender, DaimlerChrysler AG, Research Center Ulm FT3/AB (Information Technology / Image Understanding) Wilhelm-Runge-Str. 11, P.O. Box 2360, 89013 Ulm, Germany Phone: +49 731 505 2354 Fax: +49 731 505 4113 Email: matthias.oberlaender at daimlerchrysler.com ===================================================================== From dhjung7 at orgio.net Thu Feb 22 21: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 max at alcyone.com Sun Feb 18 22: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 phd at phd.pp.ru Tue Feb 13 07:14:33 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 13 Feb 2001 15:14:33 +0300 (MSK) Subject: CPAN functionality for python In-Reply-To: Message-ID: On Tue, 13 Feb 2001, Doug Hellmann wrote: > Why use standard CGI? This is a perfect application for Zope, the ZODB, The big advatnage of CPAn is that it's distributed and has many mirrors. Zope-based solution will be hard to mirror. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From tim.hochberg at ieee.org Wed Feb 21 14: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 qrczak at knm.org.pl Sat Feb 24 09: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 joseamartin at venmex.com Wed Feb 14 15: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 sheila at spamcop.net Mon Feb 26 09: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 oconnor at bioreason.com Wed Feb 14 10: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 aahz at panix.com Sun Feb 4 13:31:11 2001 From: aahz at panix.com (Aahz Maruch) Date: 4 Feb 2001 10:31:11 -0800 Subject: While everyone is saying what they want in Python :) References: <3A7D64D8.74E71826@cybermesa.com> <3iuq7t06864beg5hpg1tjcbvo1m1uq81iv@4ax.com> Message-ID: <95k75f$oqb$1@panix3.panix.com> In article , Jim Richardson wrote: > >can someone explain to me what exactly "self" is for? I just don't get >it. (I am trying to learn this language, but this puzzles me.) Every >time I think I get it, I find proof otherwise :) Let's start by considering a class: class foo: pass To create an instance of the class we call it like a function: a = foo() b = foo() We now have two instances of the class. Normally classes have functions associated with them (called methods): class foo: def __init__(self, bar): self.bar = bar def print(self): x = type(self.bar) print self.bar, "is type", x In order to create instances of this new class, we do this: a = foo(5) b = foo('Hi there!') In order to call the print() method of foo, we do this: a.print() b.print() Now, inside the print() method, how is Python supposed to distinguish between a variable that belongs to the instance versus one that is strictly local to the method (as x is)? -- --- 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 wolfson at midway.uchicago.edu Wed Feb 21 16: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 MarkH at ActiveState.com Wed Feb 28 05: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 emile at fenx.com Fri Feb 9 07:10:30 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 9 Feb 2001 04:10:30 -0800 Subject: python-dev summary, Jan. 16-31 References: Message-ID: <960mqj$itm0s$1@ID-11957.news.dfncis.de> I thought earlier this week that I had missed the recent summary, and then was pleased to see it show up, and now saddened to see it pass on. Thanks for your efforts in the past on this. It has been much appreciated. -- Emile van Sebille emile at fenx.com ------------------- "Oleg Broytmann" wrote in message news:mailman.981716953.9412.python-list at python.org... > Hello! Me too! :) > > On Fri, 9 Feb 2001, Tony J Ibbs (Tibs) wrote: > > I too am very sad that you're deciding to stop writing the python-dev > > summaries (sometimes a resounding silence is appreciation, not > > disdain!). The summaries have been on my "looking forwards to that" list > > Exactly! > > > for a good while now. Many thanks for what you've done (any chance of > > Many thinks. We really appreciate your good job! > > > reconsidering now you know how much we *really* love you?). > > Any chance you'll continue the summaries? > > Oleg. > ---- > Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru > Programmers don't die, they just GOSUB without RETURN. > > From nikifor at sky.inp.nsk.su Sun Feb 11 07:48:10 2001 From: nikifor at sky.inp.nsk.su (Alex A. Nikiforov) Date: 11 Feb 2001 12:48:10 GMT Subject: C++ style Stream Operators References: <3a831395.0@216.0.152.7> <%BHg6.195182$ge4.67633843@news2.rdc2.tx.home.com> Message-ID: <9661ma$1ev8j$1@sky.inp.nsk.su> Rainer Deyke wrote: > "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? > File objects in Python are somewhat like 'streambuf's in C++. Just write > your own class with a '__lshift__' that formats the text and writes it to a > file object: > class ostream: > def __init__(self, buf): > self.buf = buf > def __lshift__(self, rhs): > self.buf.write(str(rhs)) > cout = ostream(sys.stdout) > cout << 'Hello world!\n' what about cin ? From bobhicks.nospam at adelphia.net Wed Feb 14 14: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 joconnor at cybermesa.com Sun Feb 4 14:45:24 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Sun, 04 Feb 2001 19:45:24 +0000 Subject: While everyone is saying what they want in Python :) References: <3A7D64D8.74E71826@cybermesa.com> <3A7D9C1D.781F8E5@alcyone.com> Message-ID: <3A7DB154.87E04245@cybermesa.com> Erik Max Francis wrote: > This general type of functionality (compare to the `with' keyword in > Pascal/Delphi) I'm not familiar with the 'with' keyword in Delphi. > The amount of typing required should never be the primary concern in > desiging a language; clarity of what you're typing is much more > important than how many keys you physically have to hit. Actually, this construct in Smalltalk adds clarity because you don't have the redundancy of the same object name repeated so the whitespace helps clarify which objects are receiving which messages. Plus it allows building complex structures without building needing to create temporary variables to hold them. Such as... (this is quasi Python with what I have in mind based on Smalltalk) win = GtKWindow(); connect ("destroy", mainquit); set_name("window"); set_title("My Window"); set_location (100,100); add (GtkHBox(); add (GtkLabel ("Hi There"); show()); add (GtkButton ("Push Me"); connect ("clicked", buttonClicked); show()); show()); show() Here I've created four widgets without needing extra temp variables. More importantly, the whitespace indicates the exact structural relationship of the widgets. I find this much easier to read than the normal way of doing it. win = GtkWindow() win.connect("destroy", mainquit) win.set_name ("window") win.set_title ("My Window") win.show() box = GtkHBox () label = GtkLabel("Hi There") button = GtkButton ("Hi there") box.add (label) box.add (button) win.add (box) box.show() label.show() button.show() button.connect ("clicked", buttonClicked) win.show() 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 tgw at email.msn.com Tue Feb 20 09: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 mark at chem.uwa.edu.au Mon Feb 19 02: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 scarblac at pino.selwerd.nl Mon Feb 19 04: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 othello at javanet.com Fri Feb 16 16: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 alet at unice.fr Tue Feb 20 05: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 loredo at spacenet.tn.cornell.edu Mon Feb 12 16:33:34 2001 From: loredo at spacenet.tn.cornell.edu (Tom Loredo) Date: Mon, 12 Feb 2001 16:33:34 -0500 Subject: Python 2.1 release schedule References: Message-ID: <3A8856AE.F49F5024@spacenet.tn.cornell.edu> Jeremy et al.- The 2.1 PEP mentions: > Add a default unit testing framework to the standard library. Is it yet settled which of the Python unit test frameworks this will be? Or is there at least a "short list" of candidates? I looked for a PEP on this, but couldn't find one. I ask because I don't yet use unit testing, but was just starting to look into it. If there is a standard or default framework experts feel is particularly suited to Python, I'd like to start there. Thanks, Tom Loredo From shaleh at valinux.com Sat Feb 17 23: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 ulf.engstrom at b2b-link.com Fri Feb 16 06:59:03 2001 From: ulf.engstrom at b2b-link.com (=?iso-8859-1?Q?Ulf_Engstr=F8m?=) Date: Fri, 16 Feb 2001 12:59:03 +0100 Subject: smtplib problem References: <966mnl$2dl$1@uranium.btinternet.com> Message-ID: <033701c0980f$dbadb660$9d8647c1@mobiliant.com> Hello :) As in RFC2554(http://www.landfield.com/rfcs/rfc2554.html) (1) the name of the SMTP service extension is "Authentication" (2) the EHLO keyword value associated with this extension is "AUTH" (3) The AUTH EHLO keyword contains as a parameter a space separated list of the names of supported SASL mechanisms. (4) a new SMTP verb "AUTH" is defined (5) an optional parameter using the keyword "AUTH" is added to the MAIL FROM command, and extends the maximum line length of the MAIL FROM command by 500 characters. This is not included in smtplib, but can be used with .ehlo(). One problem arises; the MAILFROM command has to be accompanied with an AUTH as well on most servers supporting RFC2554. I made a patch for this a long time ago, but I've lost it since, don't know it it's possible to obtain it from the patch-manager on sourceforge in some way. The number of mailservers supporting this is not in majority, but it's growing, especially in Europe. If it's interesting for more people I could probably make a new patch to smtplib, or just create an authsmtplib. Or has someone done this already? Ulf Engstr?m Sheila King wrote: > >Nice. And how does one do SMTP authorization? (There must be a way. I see that >the NNTP module includes authorization commands, but the smtplib doesn't!) Tim Roberts: > There is no such thing. The SMTP protocol does not include authorization. > > Some providers have gone to a scheme whereby you have to check for POP mail > before you can use SMTP. You have to send a password for POP, after which > they open a short window wherein you can send mail. That doesn't take any > changes to smtplib. From emile at fenx.com Sun Feb 11 18:12:35 2001 From: emile at fenx.com (Emile van Sebille) Date: Sun, 11 Feb 2001 15:12:35 -0800 Subject: mxODBC question References: Message-ID: <9676c6$jpmt8$1@ID-11957.news.dfncis.de> Scott, I've put together a class to handle this. I'm only using it at one site, so it probably won't scale well, but it allows me to work with the data by using the database column names. It's geared to handle only sql statements of the form "select colA, colB, colC from tablename where conditions", which in my case is about 90% of my usage. It works by parsing the sql select statement, mapping the retrieved cols to class instance attributes with those names, then returning a list of thoses instances. --sample usage: import SQLdata all_open_ar = SQLdata.cache(('',), "select CUSTOMER_ID, INVOICE_ID, TYPE, INVOICE_DATE, STATUS, \ TOTAL_AMOUNT, PAID_AMOUNT, DISCOUNT_GIVEN, LAST_PAID_DATE, ZERO_DATE \ from RECEIVABLE \ where INVOICE_DATE < %s",1) open_ar = all_open_ar('09/30/2000') for openInvoice in open_ar: bal = openInvoice.TOTAL_AMOUNT - openInvoice.PAID_AMOUNT ------ If you're interested, E-mail me, and I'll send it to you. -- Emile van Sebille emile at fenx.com ------------------- "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 knight at baldmt.com Sun Feb 25 15: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 bsb at winnegan.de Thu Feb 1 16: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 tjg at exceptionalminds.com Mon Feb 26 20: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 ransen_spam_me_not at nemo.it Sun Feb 18 02: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 tim.one at home.com Mon Feb 26 20: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 timr at probo.com Mon Feb 12 01:21:11 2001 From: timr at probo.com (Tim Roberts) Date: Sun, 11 Feb 2001 22:21:11 -0800 Subject: Using Python for Web development References: <965m01$lr7$1@nnrp1.deja.com> <967og3$7hl$1@nnrp1.deja.com> Message-ID: billy_bill_1 at my-deja.com wrote: >Thanks heaps for all the links and help, I think I'll start with >mod_python. It might be easier for you to forget about an Apache module to start with, and just do plain CGI scripts. The python interpreter isn't all that big. >One more thing I just thought of, how fast is python >compared to php, asp perl etc? PHP is damn fast for a scripting >language, any benchmarks around? Does it really matter? CGI script execution time is negligible compared to network overhead time. The cost savings in development is significant enough that I'll pay a performance penalty that cannot be measured, anyway. If you program Python like you program Perl, you will find Python to be slower. For example, Perl programs often become a morass of regular expression tweaks; Python doesn't do as well for that. But once you figure out the "Python" way to do things, the difference becomes slight. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From anandg at cs.utexas.edu Sun Feb 18 14: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 Mike_B at T-Online.de Mon Feb 19 04: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 donn at u.washington.edu Tue Feb 13 20: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 rpm1deleteme at frontiernet.net Sat Feb 10 19:17:37 2001 From: rpm1deleteme at frontiernet.net (RPM1) Date: Sat, 10 Feb 2001 19:17:37 -0500 Subject: Grab window contents in Python? Message-ID: <964m55$oee$1@node17.cwnet.frontiernet.net> Hi, Is there a way I can grab the contents of a text window of a commercial program, using Python 2.0? I've seen a VB program that could tell you the window handle of any window you pointed at with the mouse. I'm thinking that if I could do something like that in Python 2.0, that would be a start. Any thoughts? Thanks, Patrick M. P.S. I don't want to use VB. From joseamartin at venmex.com Thu Feb 15 08: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 parkw at better.net Tue Feb 27 02: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 spamers at must.die Wed Feb 21 14: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 uche at ogbuji.net Sat Feb 24 17: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 bernie at pacific.net.hk Wed Feb 28 12: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 amused at webamused.com Thu Feb 8 14:26:25 2001 From: amused at webamused.com (amused at webamused.com) Date: Thu, 08 Feb 2001 19:26:25 GMT Subject: None assigment References: <95ugd4$jka$1@panix6.panix.com> <95unqf$4j3$1@nnrp1.deja.com> Message-ID: <95ursl$8j4$1@nnrp1.deja.com> In article <95unqf$4j3$1 at nnrp1.deja.com>, Mark Pilgrim wrote: > > Indeed. I once had a similar experience; while playing around in the > Python IDE, I defined a variable 'dir' to hold some directory path. > Then days later (having never shut down Python), I wondered why the > built-in 'dir' function didn't work. > > Which leads to the following questions: > - Are there any true constants in Python? (I don't think so, but > correct me if I'm wrong.) > - Once you've redefined a built-in function like 'dir', is there any > way to get it back without restarting Python? > > -M > -- You can delete it from the local namespace with del: Python 2.1a1 (#9, Jan 22 2001, 20:58:30) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> dir >>> dir = "Spam" >>> dir 'Spam' >>> del dir >>> dir >>> Joshua Sent via Deja.com http://www.deja.com/ From aahz at panix.com Fri Feb 2 14: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 rozen at rgv.hp.com Thu Feb 8 11:20:21 2001 From: rozen at rgv.hp.com (Don Rozenberg) Date: Thu, 08 Feb 2001 08:20:21 -0800 Subject: [ANN] PAGE 0.1 - A drag and drop GUI generator for Python Message-ID: <3A82C745.CAD4BA9@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 barry at digicool.com Fri Feb 2 22: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 phrxy at csv.warwick.ac.uk Fri Feb 2 10: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 akhar at videotron.ca Mon Feb 19 03: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 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 fredrik at effbot.org Wed Feb 7 02:30:42 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 07 Feb 2001 07:30:42 GMT Subject: New Instance for Pmw.Notebook()? References: <3A7F12E1.14EEAC60@home.com> Message-ID: jakegren at home.com wrote: > I'm having difficulty creating a Pmw.Notebook() outside of the root > window. I would like to click on a menu item and have a new window > created with the Pmw.Notebook(). try this: > def TestClick(): + top = Toplevel() # create a new toplevel window + notebook=Pmw.NoteBook(top) # create in new toplevel window - notebook=Pmw.NoteBook() # create in root window > notebook.pack() > page=notebook.add('My Tab') > entry=Entry(page,width=20) > entry.pack() for more info on toplevel windows, see: http://www.pythonware.com/library/tkinter/introduction/application-windows.htm http://www.pythonware.com/library/tkinter/introduction/toplevel.htm Cheers /F From Randy.L.Kemp at motorola.com Fri Feb 9 09:54:50 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Fri, 9 Feb 2001 08:54:50 -0600 Subject: What is better, JPython or Jython? Message-ID: <69BC4C6AE83ED311BC9400805FA7B14AF84E07@il93exp01.css.mot.com> 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? -----Original Message----- From: Warren Postma [mailto:embed at geocities.com] Sent: Friday, February 09, 2001 8:12 AM To: python-list at python.org Subject: Re: What is better, JPython or Jython? Check the labels. See which one says "30% more Python inside, Free". And buy that one. Warren From aleaxit at yahoo.com Thu Feb 1 10: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 phlip_cpp at my-deja.com Wed Feb 21 00: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 guido at digicool.com Wed Feb 21 19: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 ben.hutchings at roundpoint.com Thu Feb 22 21: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 matt at mondoinfo.com Sat Feb 10 19:29:46 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sun, 11 Feb 2001 00:29:46 GMT Subject: Fonts in Pmw.ScrolledListBox? References: Message-ID: On Sat, 10 Feb 2001 18:14:36 -0600, Barron wrote: >How does one set the font in a Pmw.ScrolledListBox. The "font" option >doesn't seem to work like it does in a regular list box and I didn't see >anything about fonts in the Megawidget documentation for the >ScrolledListBox. Barron, You want something like: mylistbox.component("listbox").configure(font="7x13") Since Pmw commonly wraps up standard Tkinter widgets, configuring the ordinary widget is usually just a matter of asking the megawidget for it and doing the configuration normally. Regards, Matt From aahz at panix.com Mon Feb 19 02: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 donn at oz.net Sat Feb 17 00: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 sheila at spamcop.net Sun Feb 18 16: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 pingster at cs.berkeley.edu Sun Feb 18 05: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 erik.wilsher at iname.com Thu Feb 15 09: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 fredrik at effbot.org Fri Feb 2 04: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 jmarshal at mathworks.com Fri Feb 23 09: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 ben.hutchings at roundpoint.com Tue Feb 6 17:10:07 2001 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 06 Feb 2001 14:10:07 -0800 Subject: cgi.py and HTML 4.0 compliancy References: <95p461$62h$1@nnrp1.deja.com> <3A801BC6.6ED77FEA@stroeder.com> <95p9cf$b0g$1@nnrp1.deja.com> Message-ID: Mark Pilgrim writes: > In article <3A801BC6.6ED77FEA at stroeder.com>, > Michael =?iso-8859-1?Q?Str=F6der?= wrote: > > Juergen wrote: > > > > > > according to "validator.w3.org" the following URL is not HTML 4 > > > compliant: > > > Some > > > Text > > Technically, this is not a valid URL. It's a valid URL, but the value of the HREF attribute is interpreted as PCDATA, i.e. ampersands within it introduce entities. > The "&" must be written as "&". Right. > This is not true; URLs can contain parameters, as long as they are > properly URL-encoded. No, this is not URL-encoding. URL-encoding (which is what Michael was trying, replacing '&' with '%26') is a way of escaping characters that are outside the range of legal characters for URLs or have special meaning in URL syntax. Since the '&' here is *meant* to have special meaning as a query parameter separator, it must not be escaped. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From dfan at harmonixmusic.com Wed Feb 21 17: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 fgeiger at datec.at Tue Feb 27 09: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 joconnor at cybermesa.com Sun Feb 4 15:28:57 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Sun, 04 Feb 2001 20:28:57 +0000 Subject: Please translate this easy snip of C++ to Python References: Message-ID: <3A7DBB89.A79A769F@cybermesa.com> chris at onca.catsden.net wrote: > And... not sure if there's a equivalent of __line__ Of more interest would be to be able to get a hold of execution stack information, such as what method called this method (and maybe the parameter values, such as 'self' of *that* method) If it's called 'trace'? it'd be nice to trace back :) This may be possible, I don't know how the Traceback works in Python; I haven't explored it yet. 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 amk at mira.erols.com Tue Feb 27 21: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 jajvirta at cc.helsinki.fi Tue Feb 20 02: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 sholden at holdenweb.com Fri Feb 9 11:41:49 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 9 Feb 2001 11:41:49 -0500 Subject: class scope questions References: <3a83bea8$0$16388$7f31c96c@news01.syd.optusnet.com.au> Message-ID: "Duncan Booth" wrote in message news:Xns90436DAD61713duncanrcpcouk at 127.0.0.1... > "Ben de Luca" wrote in > <3a83bea8$0$16388$7f31c96c at news01.syd.optusnet.com.au>: > > >if i do this > > > >class a: > > dog='woof' > > > > def blah(): > > something > > > > > > > >how do i call a > >how do i get soemthing in blah to refernce dog? either to read it or > >write to it > > > class a: > dog='woof' > def blah(self): > print self.dog > def update(self, value): > self.dog = value > >>> a1 = a() > >>> a1.blah() > woof > >>> a1.update('bow wow') > >>> a2 = a() > >>> a2.blah() > woof > >>> a1.blah() > bow wow > >>> > > But, although this works fine, there is a problem with it. dog is > actually a variable in the class a until it is set by the update method > when it becomes a variable in the instance a1. This works fine for > strings, but if you used a mutable object such as a list or dictionary > you would see that dog was shared between all instances of the class: > class B: list = [] > def show(self): > print self.list > def append(self, value): > self.list.append(value) > > > >>> b1 = B() > >>> b1.append('hello') > >>> b1.show() > ['hello'] > >>> b2 = B() > >>> b2.show() > ['hello'] > >>> b2.append('world') > >>> b1.show() > ['hello', 'world'] > > To avoid this you should generally define an __init__ method in your > class and use that to initialise any instance variables. > Note, however: >>> a.dog 'woof' >>> If dog is really intended to be a class variable, shared among all instances, then you are much safer treating it as an attribute of the class. regards Steve From ws-news at gmx.at Mon Feb 19 11: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 root at rainerdeyke.com Sat Feb 3 12: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 f8dy at my-deja.com Tue Feb 6 11:39:45 2001 From: f8dy at my-deja.com (Mark Pilgrim) Date: Tue, 06 Feb 2001 16:39:45 GMT Subject: cgi.py and HTML 4.0 compliancy References: <95p461$62h$1@nnrp1.deja.com> <3A801BC6.6ED77FEA@stroeder.com> Message-ID: <95p9cf$b0g$1@nnrp1.deja.com> In article <3A801BC6.6ED77FEA at stroeder.com>, Michael =?iso-8859-1?Q?Str=F6der?= wrote: > Juergen wrote: > > > > according to "validator.w3.org" the following URL is not HTML 4 > > compliant: > > Some > > Text Technically, this is not a valid URL. The "&" must be written as "&". Try using the HTML validator at http://htmlhelp.com/. I have found that it gives more descriptive error messages than the w3 validator, including this (very common) error. > > Maybe HTML4 mandates to use a form. > This is not true; URLs can contain parameters, as long as they are properly URL-encoded. -M -- You're smart; why haven't you learned Python yet? http://diveintopython.org/ Sent via Deja.com http://www.deja.com/ From marc.vollmer at mahr.de Tue Feb 27 10: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 MarkH at ActiveState.com Wed Feb 14 17: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 jschmitt at vmlabs.com Wed Feb 28 23:14:59 2001 From: jschmitt at vmlabs.com (John Schmitt) Date: Wed, 28 Feb 2001 20:14:59 -0800 Subject: Collection interfaces Message-ID: <008F0A63472BD311AF9800104BCD102561CCB3@minirex.vmlabs.com> > -----Original Message----- > From: topmind at technologist.com [mailto:topmind at technologist.com] > Sent: Wednesday, February 28, 2001 7:56 AM > To: python-list at python.org > Subject: Re: Collection interfaces [lots of deletia] > 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. I choose collections based on their behaviours. So, I would chose a stack collection because retreiving the most recently pushed object is very quick (O(1)) while other operations are more expensive and not needed for my domain. If I needed random access, I would chose some other collection based on its random access costs. Just how do you choose a collection class? It sounds like you look for the collection that does everything with considering its performance or costs. [even more deletia] > 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. I have not written even a single line of Smalltalk code, so I have no experience with it. But I hope to look at it someday for the same reason I looked at Python - someone said it was interesting. Are you saying that Smalltalk (or other languages (SML would be my favourite)) failed commercially due to a lack of technical merits rather than marketing effort? I would be inclined to believe that Smalltalk's commercial failure would be due in part to decisons made by PHBs. [still more deletia] John From fredrik at pythonware.com Thu Feb 8 13:33:03 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 08 Feb 2001 18:33:03 GMT Subject: Some basic questions about Tkinter (probably v easy for experts!) References: Message-ID: Martin Quick/Neil Cerutti: > >OK, I followed that example and it was very helpful - *however* > >I think I am misunderstanding your final comment here. When I > >typed the example into python running in a DOSbox window, the > >window & button did appear and did do what they were supposed to > >before I used root.mainloop(). This seems contrary to what > >you've written above. > > I'm confused about this issue too, I guess. Under some versions/builds/platforms/phases-of-the-moon, Tkinter uses the PyOS_EventHook mechanism to keep the event loop running under the interactive prompt. > >(Perhaps when I run the thing as a script > >I need the mainloop() but less so when it's done at command > >prompt??). Exactly. Cheers /F From ievsikov at flowpath.com Thu Feb 8 15:19:55 2001 From: ievsikov at flowpath.com (Igor Evsikov) Date: Thu, 8 Feb 2001 15:19:55 -0500 Subject: EvalIt32 is a 32-bit library that allows programs to evaluate math expressions defined at run time. Message-ID: EvalIt32 is a 32-bit library that allows programs to evaluate math expressions defined at run time. EvalIt32 includes functions etEvalIt and etCompEval for evaluate math expression, etEvalFile to evaluate math expressions from input files, and writes results to output files. This .dll supports common math operators and functions for real and complex numbers, as well as user variables and functions. This version includes direct support for Visual Basic, C++ Builder (Borland) and Delphi. Other compilers can use modified versions of a headers.Requires Win9x/NT/2000. Download: http://www.zdnet.com/downloads/stories/info/0,,001EU4,.html Features: - Arithmetic and logical operators and functions - Common functions such as exp, ln, sqrt, sqr, bnml etc. - Common, trigonometric, hyperbolic complex functions - Trigonometric, Hyperbolic functions - Numerical Integration - Equations can be solved - Special functions (Gamma, Bessel's, Si, Ci, erf, erfc, Fresnel's) - Statistic functions (Average, Standard deviation, Sum, Random, Gauss random, statistical variance, etc ) - FOR-type loop - if (...) then (...) else (...) function - Error position fixed - Print results, graphics and print preview - Save graphics to BMP, WMF, EMF formats - Radian and Degree modes for trigonometric functions - Precision: 10-12 significant digits. - Range: _(3.4E-4392 to 1.1E+4392) - User define functions(only profesional edition) - User defined constants Special requirements: None. Shareware. Uploaded by the author. Igor Evsikov ievsikov at flowpath.com From joconnor at cybermesa.com Tue Feb 6 14:43:29 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Tue, 06 Feb 2001 19:43:29 GMT Subject: do...while loops References: <95p75f$85m$1@panix3.panix.com> <3A802319.46EBCA35@cybermesa.com> Message-ID: <3a80537c.8644434@news.cybermesa.com> On Tue, 6 Feb 2001 14:15:16 -0500, D-Man wrote: >On Tue, Feb 06, 2001 at 04:15:21PM +0000, Jay O'Connor wrote: >| Umm..then how about a counter? Would this work? >| >| x = 100 >| while x: >| print x >| x -= 1 >| >| Yeah, just tried it...it works. >| >| Umm...anyone really like it? :) > >for x in range( 100 , 0 , -1 ) : > print x > > >With for you only have 1 one line that describes the entire loop, >instead of 3 lines that are spread about. You also have no chance of >forgetting to (de/in)crement the counter when you get to the end of >the loop body. Oh, I agree totally, for the reasons you mention. I thought it was goofy which is why I put the smiley I was just trying to think of a practical (?) use for doing a "while" loop with a number other than 1 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 tino at wildenhain.de Thu Feb 22 18: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 s2mdalle at titan.vcu.edu Mon Feb 19 22: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 scarblac at pino.selwerd.nl Tue Feb 20 08: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 roy at panix.com Sun Feb 18 19: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 MarkH at ActiveState.com Wed Feb 21 17: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 worm at gdp-group.com Thu Feb 22 12: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 sav at ulmen.mv.ru Thu Feb 22 13: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 doughellmann at bigfoot.com Mon Feb 26 22:42:17 2001 From: doughellmann at bigfoot.com (Doug Hellmann) Date: Tue, 27 Feb 2001 03:42:17 GMT Subject: CPAN functionality for python References: Message-ID: In article , "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. But "rpm -qa" only works on a system where RPM is the default and primary package installation system. There are more OSes where that is not the case than where it is. It isn't clear to me why we would want to use more than one distribution package format. It appears that the 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 is supposed to do? It finds newer versions of what you have, resolves dependencies, downloads and installs the packages. Doug From sbrunning at trisystems.co.uk Wed Feb 28 11: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 william_wicker at spectratechnologies.com Sat Feb 17 15: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 jhauser at ifm.uni-kiel.de Tue Feb 20 03: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 chris at voodooland.net Tue Feb 27 03:00:40 2001 From: chris at voodooland.net (Chris Watson) Date: Tue, 27 Feb 2001 02:00:40 -0600 (CST) Subject: CPAN functionality for python In-Reply-To: Message-ID: > > 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. Not to toss a pebble in the still waters here. But it *might* be worth the effort to work with or at least get idea's from the openpackages people. Who are now wrestling with certain issues discussed here for handling a common package system across several platforms. Just a thought. Info can be found at http://www.openpackages.net. -- ============================================================================= -Chris Watson (316) 326-3862 | FreeBSD Consultant, FreeBSD Geek Work: scanner at jurai.net | Open Systems Inc., Wellington, Kansas Home: scanner at deceptively.shady.org | http://open-systems.net ============================================================================= WINDOWS: "Where do you want to go today?" LINUX: "Where do you want to go tomorrow?" BSD: "Are you guys coming or what?" ============================================================================= irc.openprojects.net #FreeBSD -Join the revolution! ICQ: 20016186 From jeremy at alum.mit.edu Wed Feb 28 12: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 clarence at netlojix.com Sun Feb 4 16: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 jeremy at alum.mit.edu Fri Feb 9 14:13:14 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Fri, 09 Feb 2001 19:13:14 GMT Subject: global, was Re: None assigment References: <95umoi$is5$1@panix2.panix.com> <_BHg6.195181$ge4.67634054@news2.rdc2.tx.home.com> <95vst8$1na$1@panix2.panix.com> <9613mn$9v$1@news.mathworks.com> Message-ID: <961fg0$etd$1@nnrp1.deja.com> In article <9613mn$9v$1 at news.mathworks.com>, Joshua Marshall wrote: > Michael Hudson wrote: > > Michael Hudson writes: > > >> Which version are you using? They all print 4 for me, and all but > >> foo() do modify the value of `b'. foo() doesn't because what follows > >> an > > > OTOH, that was a version that had the PEP 227 code checked into it. > > With an older version, I see what you see. Wierd. > > Sounds like a bug fix. > As Tim will explain in a post that hasn't made it to DejaNews yet, earlier versions of Python did not define the behavior of assignment before a global statement. The recent round of compiler changes uses separate passes to determine a name's scope and to generate code for loads and stores. As a result, the global statement affects all assignments. It's unclear what we should happen in this case. It could be an error, since it's dodgy and the behavior will change with 2.1. -- -- Jeremy Hylton, Sent via Deja.com http://www.deja.com/ From ssartor at bellatlantic.net Fri Feb 9 15:04:12 2001 From: ssartor at bellatlantic.net (Steven Sartorius) Date: Fri, 09 Feb 2001 20:04:12 GMT Subject: How to write integers to a file? References: Message-ID: <03Yg6.4777$bu4.895297@typhoon2.ba-dsg.net> In article , "Chris Gonnerman" wrote: > outf.write("%d %d %d %d\n" % (i, j, k, l)) > > The % operator with a string on the left and a singleton value or tuple > on the right performs printf-style substitution on the string. You may > need to read the man page for printf if you are not a C programmer. > This did the trick! Thanks a lot. Steve From sheila at spamcop.net Sat Feb 17 11:01:39 2001 From: sheila at spamcop.net (Sheila King) Date: Sat, 17 Feb 2001 16:01:39 GMT Subject: smtplib problem References: <966mnl$2dl$1@uranium.btinternet.com> Message-ID: On Fri, 16 Feb 2001 12:59:03 +0100, Ulf Engstr?m wrote in comp.lang.python in article : :Hello :) :As in RFC2554(http://www.landfield.com/rfcs/rfc2554.html) : :(1) the name of the SMTP service extension is "Authentication" :(2) the EHLO keyword value associated with this extension is "AUTH" :(3) The AUTH EHLO keyword contains as a parameter a space separated : list of the names of supported SASL mechanisms. :(4) a new SMTP verb "AUTH" is defined :(5) an optional parameter using the keyword "AUTH" is added to the : MAIL FROM command, and extends the maximum line length of the : MAIL FROM command by 500 characters. Ulf, Thanks for providing more tips and suggestions on this topic. :This is not included in smtplib, but can be used with .ehlo(). One problem :arises; the MAILFROM command has to be accompanied with an AUTH as well on :most servers supporting RFC2554. I made a patch for this a long time ago, :but I've lost it since, don't know it it's possible to obtain it from the :patch-manager on sourceforge in some way. :The number of mailservers supporting this is not in majority, but it's :growing, especially in Europe. If it's interesting for more people I could :probably make a new patch to smtplib, or just create an authsmtplib. Or has :someone done this already? Well, clearly I'm interested. I wonder if others are? I'd suspect there is not such a big demand, since I was even told in this thread, that there is no such thing as SMTP authorization, and that hardly anyone uses it! Please don't go to any trouble on only my account, as I don't know how soon I'd get around to using it (many other projects on my slate at this time...) -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ :Sheila King wrote: :> :>Nice. And how does one do SMTP authorization? (There must be a way. I see :that :>the NNTP module includes authorization commands, but the smtplib doesn't!) From stephen_purcell at yahoo.com Tue Feb 6 12:14:27 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Tue, 6 Feb 2001 18:14:27 +0100 Subject: Binary numbers In-Reply-To: <20010206180519.A23598@freedom.puma-ag.com>; from stephen_purcell@yahoo.com on Tue, Feb 06, 2001 at 06:05:19PM +0100 References: <95p7ks$9e6$1@nnrp1.deja.com> <20010206180519.A23598@freedom.puma-ag.com> Message-ID: <20010206181427.A23935@freedom.puma-ag.com> Steve Purcell wrote: > sampe99 at my-deja.com wrote: > > Does anyone know an easy way to get a list of binary numbers within a > > certain range in python? E.g for > > n=1 [0],[1] > > n=2 [0,0],[0,1],[1,0],[1,1] > > n=3 [0,0,0],[0,0,1] a.s.o > > > > I need this for n<=18... Or even: def binary(num): digits = map(lambda p, n=num: 2**p & n and 1, range(31)) digits.reverse() try: return digits[digits.index(1):] except: return [0] for n in range(18): print n, '=', binary(n) -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ Available for consulting and training. "Even snakes are afraid of snakes." -- Steven Wright From erno-news at erno.iki.fi Sat Feb 24 16: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 tim.one at home.com Sat Feb 3 22: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 aahz at panix.com Sat Feb 17 19: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 nielsenjf at my-deja.com Thu Feb 1 08: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 tuttledon at hotmail.com Thu Feb 15 23: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 fuess at att.net Sun Feb 11 23:28:31 2001 From: fuess at att.net (David Fuess) Date: Mon, 12 Feb 2001 04:28:31 GMT Subject: Using Python for Web development References: <965m01$lr7$1@nnrp1.deja.com> Message-ID: On Sun, 11 Feb 2001 13:28:22 +0100, Steve Purcell wrote: >billy_bill_1 at my-deja.com wrote: >> I'm new to Python and so far I like what I see! > >Then you are a wise and discerning soul. > >> I would really like to >> use it for web development as I'm currently using PHP and ASP and I'm a >> bit sick of thier lack of good OO support and the c style syntax etc >> etc (especially php). PHP can be used as an apache module, can python >> be used in this way too? I don't want to have to deal with any of the >> header information stuff as well like in PERL cgi scripts. Any links >> or information anyone can give me to get me on my way? [snip] I particularly like the Python web scripting that installs with Win32Com extensions. Then, you can execute Python from within an ASP file like this ... About Me <%@ Language=Python %> <% url = Request.ServerVariables("PATH_INFO") %>

Current Document

<% for key in Request.ServerVariables: print("%s=%s
"%(key,Request.ServerVariables(key)) %> From max at alcyone.com Tue Feb 27 22: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 tim.one at home.com Thu Feb 22 17: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 loewis at informatik.hu-berlin.de Fri Feb 2 16: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 owen at astrono.junkwashington.emu Thu Feb 22 14: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 fredrik at pythonware.com Thu Feb 8 13:33:04 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 08 Feb 2001 18:33:04 GMT Subject: Some basic questions about Tkinter (probably v easy for experts!) References: Message-ID: Martyn Quick wrote: > 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? not unless you want to *call* the function. > (Sorry if this is easily to be found in the Introduction document!) it's a Python thing, not a Tkinter thing. functions (and methods, classes, modules, etc) are objects -- just like integers, strings, and other simple types: to call an object, add parentheses: >>> import sys >>> sys # this name points to a module object >>> sys.exit # this name points to a function >>> x = sys.exit # add another name for the same function >>> x >>> sys.exit() # call the function $ (after the assignment, you could also have typed x()) so in the following statement, we're passing the *function* itself as the command value: widget.config(command=sys.exit) while in the following statement, we're *calling* the function. if the function returns (sys.exit() doesn't), the return value is passed on to the widget: widget.config(command=sys.exit()) (functions can return function objects, so this might actually make sense in some cases. but not for sys.exit() ;-) > Presumably this means that I can't use a command which relies on > parameters? not directly -- there's something called lambdas (in Python, not in Tkinter), but it's usually better to use a plain function: def myfunc(): otherfunc(1, 2, 3) b = Button(master, command=myfunc) Cheers /F From jacobkm at cats.ucsc.edu Mon Feb 5 17:46:07 2001 From: jacobkm at cats.ucsc.edu (Jacob Kaplan-Moss) Date: Mon, 05 Feb 2001 14:46:07 -0800 Subject: sorting on IP addresses References: <3A7F26CB.BE85C96F@esec.com.au> Message-ID: In article <3A7F26CB.BE85C96F at esec.com.au>, Sam Wun wrote: > 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 > Sam -- Not sure about quick, but this is the way I've been doing it. If any of the gurus out there would like to point out a better method, I would be happy to read it. iplist = ["203.21.254.89", "203.21.254.9", "1.2.3.4", "1.2.3.5", "211.1.50.124", "207.1.23.4", "192.168.1.101", "192.168.1.1"] def ip_compare( a, b ): """a and b are valid IP addresses of the form w.x.y.z.""" la = [int(n) for n in a.split(".")] lb = [int(n) for n in b.split(".")] for pair in zip(la, lb): if pair[0] > pair[1]: return -1 elif pair[0] < pair[1]: return 1 return 0 iplist.sort(ip_compare) print iplist Hope that helps, Jacob From tony at lsl.co.uk Wed Feb 21 05: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 brondsem at my-deja.com Sat Feb 17 23: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 aleaxit at yahoo.com Tue Feb 20 11: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 vonehr at ira.uka.de Tue Feb 13 11: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 monpetit at orgio.net Tue Feb 20 21: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 dougfort at downright.com Fri Feb 16 21: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 fredrik at effbot.org Wed Feb 7 02: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 sheila at spamcop.net Mon Feb 19 03: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 scarblac at pino.selwerd.nl Wed Feb 28 08: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 shaleh at valinux.com Mon Feb 19 18: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 ryu-jin at bigfoot.com Thu Feb 1 10: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 Gareth.McCaughan at pobox.com Sun Feb 18 14: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 piet at cs.uu.nl Tue Feb 27 08: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 theller at python.net Thu Feb 15 03: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 f8dy at yahoo.com Tue Feb 27 09: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 ws-news at gmx.at Tue Feb 27 10: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 shaleh at valinux.com Fri Feb 16 19: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 sholden at holdenweb.com Sun Feb 11 12:26:27 2001 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 11 Feb 2001 12:26:27 -0500 Subject: def problem (Got it!) References: <10844-3A8572B2-38@storefull-161.iap.bryant.webtv.net> <25253-3A86B2BF-12@storefull-163.iap.bryant.webtv.net> Message-ID: wrote in message news:25253-3A86B2BF-12 at storefull-163.iap.bryant.webtv.net... > As a newbie you have to know I'm going to make some stupid mistakes, and > this was one of them. > Don't worry, we all do it (except Tim Peters). > What I was doing was sometimes clicking "run script" and mostly hitting > the "F5 key" which I just realized is not "run script" but "import > module." > Cool, so you have found ot what was wrong. > I might have another question, but I think I'll go and hang my head in > shame for while. > Please don't feel you need to do that. > Thanks again for taking the time to answer my question. > > Ron > > From max at alcyone.com Sun Feb 18 14: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 tim_one at email.msn.com Sat Feb 17 02: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 rpm1deleteme at frontiernet.net Sun Feb 18 09: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 jeremy at alum.mit.edu Mon Feb 12 10:00:03 2001 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Mon, 12 Feb 2001 10:00:03 -0500 (EST) Subject: urllib.open('http://www.redherring.com/') In-Reply-To: <968en7$nhn$1@nnrp1.deja.com> References: <95th67$36j$1@nnrp1.deja.com> <95tj33$4g1$1@nnrp1.deja.com> <3A825A68.B1023097@intertrader.com> <95tq9r$afs$1@nnrp1.deja.com> <9607c5$bkj$1@nnrp1.deja.com> <3ditmj99pd.fsf@ute.cnri.reston.va.us> <968en7$nhn$1@nnrp1.deja.com> Message-ID: <14983.64115.291676.385646@w221.z064000254.bwi-md.dsl.cnc.net> >>>>> "AP" == apederse writes: AP> In article , AP> "Fredrik Lundh" wrote: >> Andrew Kuchling wrote: >> > I don't believe urllib or httplib were massively rewritten for >> > 2.0 (nor will they be in 2.1), so if it's a bug, it's probably >> > still there. >> >> on my box, it sometimes work under 1.5.2, and never works under >> an unmodified 2.0 installation. >> >> however, the following hack works for both versions (note the >> explicit socket shutdown). AP> is it possible to do a similar fix to urllib? (For convenience AP> reasons I always use urllib in my applications...) AP> btw. I'm not very familiar with how the Python community works, AP> but I'm thinking at this point, shouldn't whoever that has been AP> involved in the programming of httplib and urllib be informed AP> about the problems? The preferred mechanism for reporting bugs is the SourceForge Bug Tracker: http://sourceforge.net/bugs/?group_id=5470 Jeremy From jurgen.defurne at philips.com Thu Feb 8 10:46:53 2001 From: jurgen.defurne at philips.com (jurgen.defurne at philips.com) Date: Thu, 8 Feb 2001 16:46:53 +0100 Subject: Followup : Memory problem Message-ID: <0056900015778525000002L052*@MHS> I monitored (Task Manager) my system. Every minute there is activity from the daemon. Every minute, regardless of the job being run, I seem to lose 800 to 1200 kB of memory. (Info : previous message w. script included) Jurgen From aleaxit at yahoo.com Tue Feb 27 02: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 mwh21 at cam.ac.uk Thu Feb 8 13:53:30 2001 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 08 Feb 2001 18:53:30 +0000 Subject: None assigment References: <31575A892FF6D1118F5800600846864D5B17D5@intrepid> Message-ID: D-Man writes: > Interesting. So normally "None" is a special keyword (that is a > reference to an object) , but that doesn't prevent one from creating > a local variable named "None" that shadows the keyword. Not really. It's a builtin. Ever used a variable called list? Cheers, M. -- The "of course, while I have no problem with this at all, it's surely too much for a lesser being" flavor of argument always rings hollow to me. -- Tim Peters, 29 Apr 1998 From butcuz at yahoo.com Wed Feb 21 15: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 info at pythonware.com Mon Feb 26 04: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 txzd at my-deja.com Sat Feb 10 14:12:17 2001 From: txzd at my-deja.com (txzd) Date: Sat, 10 Feb 2001 19:12:17 GMT Subject: Hosting service supporting 2.0 References: <962dd5$8rk$1@nnrp1.deja.com> Message-ID: <9643qd$fn9$1@nnrp1.deja.com> In article <962dd5$8rk$1 at nnrp1.deja.com>, Gil G. wrote: > Hello Richard, > > Go to: http://keskydee.com/hosting.html > Python 2.0, mod_python 2.6.3 > Plus PHP 4.04 and Perl/mod_perl > > Sincerely, > > Gil. > > In article , > Richard Blumberg wrote: > > I'm looking for a moderately priced web hosting service that supports > > Python 2.0. Anyone know of any such? > > > > Thanks > > > > Richard > > Sent via Deja.com > http://www.deja.com/ > Richard: Here's another option. http://quicksitemaker.com/members/djedwards Sent via Deja.com http://www.deja.com/ From rolney at pcug.org.au Fri Feb 23 19: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 joseamartin at venmex.com Thu Feb 1 09: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 maxwell at ebioinformatics.com Fri Feb 9 06:48:15 2001 From: maxwell at ebioinformatics.com (Peter Maxwell) Date: Fri, 09 Feb 2001 22:48:15 +1100 Subject: Forking and Threads References: Message-ID: <3A83D8FF.A90F4E4A@ebioinformatics.com> Paul Robinson wrote: > Is there any suggestion of how I could do something similar (or work > around the problem) using 1.5.2? I had a different forking-and-locking problem which might share a similar solution: A multithreaded python program running on solaris which would lock up when running on a multiprocessor machine. The program didn't use os.fork but it did use os.popen, os.system and commands.getstatusoutput and of course at some level those all fork. Simultaneous forking by two threads seemed to be the problem so I replaced os.popen with: AT_FORK = thread.allocate_lock() def popen(cmd, mode="r"): AT_FORK.acquire() try: pipe = os.popen(cmd, mode) finally: AT_FORK.release() return pipe and implemented replacements for os.system and commands.getstatusoutput using this version of popen. -- Peter Maxwell From chris at collegewafer.com Wed Feb 14 04: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 richard at wmblake.com Thu Feb 8 11:42:13 2001 From: richard at wmblake.com (Richard Blumberg) Date: Thu, 08 Feb 2001 11:42:13 -0500 Subject: Hosting service supporting 2.0 Message-ID: I'm looking for a moderately priced web hosting service that supports Python 2.0. Anyone know of any such? Thanks Richard From max at alcyone.com Sun Feb 4 15:44:12 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 04 Feb 2001 12:44:12 -0800 Subject: Please translate this easy snip of C++ to Python References: <95kcbo$k8s@dispatch.concentric.net> Message-ID: <3A7DBF1C.B03B8200@alcyone.com> Fredrik Lundh wrote: > (iirc, bjarne thinks that real C++ programmers shouldn't > use the preprocessor at all, but what does he know...) C++ features such as namespaces, templates, and const variables acting as true constants generally render it unnecessary to use the preprocessor to accomplish most tasks it was traditionally used for. It's generally considered bad style to make excessive use of the preprocessor in Standard C++. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ When one is in love, a cliff becomes a meadow. \__/ (an Ethiopian saying) Official Buh rules / http://www.alcyone.com/max/projects/cards/buh/ The official rules to the betting card game, Buh. From ten.llun at ttam Fri Feb 9 03:39:25 2001 From: ten.llun at ttam (Matthew Schinckel) Date: Fri, 09 Feb 2001 19:09:25 +1030 Subject: Geometric classes (lines, planes etc)? References: <3a8248d8_1@newsflash.abo.fi> Message-ID: <3a83ac09_7@news.chariot.net.au> In message <3a8248d8_1 at newsflash.abo.fi>, Jan Ekholm wrote: > > Hi all, > > For a project we would need to use some classes for manipulating geometric > entities. We need something like planes, lines, points etc, and > possibilities to manipulate and calculate with them. We do however not > want to draw them in any way, so I'm not looking for anything graphical > here, just something that allows me to represent simple geometric shapes > in space. > > Is there anything available that we could use, or do we need to build our > own? A Google search turned up a *lot* about Tk (which is not what we > want) and about using Python with Qt and Gnome. You can have a look at my rudimentary CAD framework - at this stage it does only what you are after. (And is incomplete :-) http://www.chariot.net.au/~jaq/matt/ -- Matthew Schinckel matt at null dot net From dhjung7 at orgio.net Tue Feb 13 02: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 footech at get2net.dk Sat Feb 24 13: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 fredrik at effbot.org Fri Feb 2 09: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 mickeyz at qwest.net Wed Feb 28 11: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 aleaxit at yahoo.com Sun Feb 18 06: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 akuchlin at mems-exchange.org Fri Feb 9 16:34:02 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 09 Feb 2001 16:34:02 -0500 Subject: PEP status and python-dev summaries References: <3dg0hn8zlr.fsf@ute.cnri.reston.va.us> <3A844423.8AF2B87A@intertrader.com> Message-ID: <3dd7cr8rsl.fsf@ute.cnri.reston.va.us> Andrew Cooke writes: > All IMHO - I'm not involved in Python, just curious about how this > problem is going to be handled. How is it handled in Perl? Is there a > Python equivalent of the porters, for example? python-dev is the equivalent of perl5-porters. However, Perl hasn't previously had a formal mechanism such as PEPs; a bunch of RFCs were written for Perl 6, but who knows if such formality will continue once actual development starts? It seems like a curious cultural difference; c.l.python posters often suggest new language features, while in the Perl and Tcl groups, there are very few postings which suggest language changes. --amk From slaurent at sonicfoundry.com Fri Feb 23 22: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 gregj at pobox.com Wed Feb 21 02: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 jeremy at alum.mit.edu Tue Feb 27 11: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 aahz at panix.com Wed Feb 21 15: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 chris.gonnerman at usa.net Sat Feb 3 10: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 hgg9140 at seanet.com Tue Feb 27 19: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 maxm at normik.dk Mon Feb 19 08: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 dg at pearl.tao.co.uk Wed Feb 28 05: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 bobhicks at adelphia.net Mon Feb 5 11:54:44 2001 From: bobhicks at adelphia.net (Robert L Hicks) Date: Mon, 05 Feb 2001 16:54:44 GMT Subject: Alpha release of ZODB programming guide References: Message-ID: AMK - Will there be a PDF of the *final* version? - Bob > From: Andrew Kuchling > Organization: Baymountain > Reply-To: akuchlin at mems-exchange.org > Newsgroups: comp.lang.python > Date: Mon, 05 Feb 2001 10:46:39 -0500 > To: python-list at python.org > Cc: zope-dev at zope.org, zope-zeo at zope.org > Subject: Alpha release of ZODB programming guide > > For what seems like half an eternity, I've been working on a ZODB > programming guide, written for Python programmers who want to use the > ZODB to store data. The document is placed under the GNU Free > Documentation License. It's still far from being finished, but while > on vacation I filled it out enough to make it alpha-worthy, though > note that there are still empty sections. Please take a look at: > > http://www.amk.ca/zodb/guide/ > > What I'd like right now: > * Suggestions for topics that should be covered. This would be > the most helpful. > > * Comments on the organization (ordering of chapters, topics, &c.) > > * Reporting errors and inaccuracies would also be helpful, but > are less important at the moment. Getting the outline correct > is my primary concern at the moment. > > --amk > > Table of contents: > * 1 Introduction > + 1.1 What is ZODB? > + 1.2 OODBs vs. Relational DBs > + 1.3 What is ZEO? > + 1.4 About this guide > * 2 ZODB Programming > + 2.1 Installing ZODB > o 2.1.1 Requirements > o 2.1.2 Installing the Packages > + 2.2 How ZODB Works > + 2.3 Opening a ZODB > + 2.4 Writing a Persistent Class > + 2.5 Rules for Writing Persistent Classes > o 2.5.1 Modifying Mutable Objects > o 2.5.2 Some Special Methods Don't Work > o 2.5.3 Fixing isinstance and issubclass > o 2.5.4 __getattr__, __delattr__, and __setattr__ > + 2.6 Writing Persistent Classes > o 2.6.1 Changing Class Attributes > * 3 ZEO > + 3.1 How ZEO Works > + 3.2 Installing ZEO > o 3.2.1 Requirements > o 3.2.2 Installation > + 3.3 Configuring and Running a ZEO Server > + 3.4 Testing the ZEO Installation > + 3.5 Sample Application: chatter.py > * 4 Transactions and Versioning > + 4.1 Subtransactions > + 4.2 Undoing Changes > + 4.3 Versions > + 4.4 Multithreaded ZODB Programs > * 5 Storages > + 5.1 FileStorage > + 5.2 BerkeleyStorage > + 5.3 OracleStorage > * 6 Related Modules > + 6.1 ZODB.PersistentMapping > + 6.2 ZODB.PersistentList > + 6.3 B-tree Modules > * A. Resources > * B. GNU Free Documentation License > From cborn at swbell.net Sun Feb 18 03: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 Mike_B at T-Online.de Sun Feb 18 18: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 01: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 tjreedy at udel.edu Fri Feb 16 17: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 JeffH at ActiveState.com Mon Feb 19 12: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 mwh21 at cam.ac.uk Mon Feb 19 08: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 robin at jessikat.fsnet.co.uk Fri Feb 2 05: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 jafo at tummy.com Tue Feb 27 03:53:38 2001 From: jafo at tummy.com (Sean Reifschneider) Date: Tue, 27 Feb 2001 01:53:38 -0700 Subject: [Distutils] Re: CPAN functionality for python In-Reply-To: ; from wware@world.std.com on Mon, Feb 26, 2001 at 11:49:32PM +0000 References: Message-ID: <20010227015338.B13115@tummy.com> On Mon, Feb 26, 2001 at 11:49:32PM +0000, Will Ware wrote: >Red Hat's RPM installer) handles this much better. Where the RPM system >will inform you about dependencies but insist that the burden of resolving >them falls to you (and heaven forbid that _those_ packages have unmet My impression from most RedHat users is that they really aren't interested in having their system pick up files unless they ask for them. The "rpm" tool can be given a URL to pick the files up from, so implementing something that follows dependencies and picks them up isn't really a hard thing to do... It has been implemented in things like rpmfind and autorpm, but they just don't seem to be that popular... The question that makes this relavent to the discussion at hand is: is this more or less true of Python modules than of your OS software? Correct me if I'm wrong, but CPAN doesn't do this... Or at least doesn't seem to. Just last night I was installing one package and the test for it failed. I tried installing other packages listed which the software needed, and then went back to the "trouble child" and found it now worked fine. The thing is to give the users the option of doing it manually. What about if the download and build is happening because of an "import module_i_dont_already_have"? Sean -- Home is where your source is. -- Sean Reifschneider, 1999 Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From r2d2 at mao.acc.umu.se Mon Feb 19 03: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 whisper at oz.net Fri Feb 23 15: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 aleaxit at yahoo.com Tue Feb 20 07: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 amk at mira.erols.com Tue Feb 20 21: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 danielk at aracnet.com Tue Feb 6 09:52:39 2001 From: danielk at aracnet.com (Daniel Klein) Date: Tue, 06 Feb 2001 06:52:39 -0800 Subject: do...while loops References: Message-ID: On Tue, 6 Feb 2001 15:00:33 +0200, Langa Kentane wrote: >Why is is it while 1: >would while 2: >or while 3: work? Of course it will work. The only integer that doesn't test for 'true' is 0 (or -0). Coming from a Smalltalk background I don't like using integer literals for this. Instead I define a module like system_constants.py true = 1 false = 0 etc... and then write the loop as: while true: Daniel Klein Portland OR USA From anderson at pha.jhu.edu Mon Feb 26 13: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 bawolk at ucdavis.edu Tue Feb 27 22: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 roy at panix.com Sun Feb 18 11: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 pierre.puiseux at univ-pau.fr Thu Feb 8 05:02:27 2001 From: pierre.puiseux at univ-pau.fr (Pierre Puiseux) Date: Thu, 08 Feb 2001 11:02:27 +0100 Subject: SWIG and C++ Message-ID: <3A826EB3.B25975B9@univ-pau.fr> > > Hello, > > is it possible with SWIG, to import in python a C++ class with 2 methods > WITH THE SAME NAME but with different arguments.For instance : > //file truc.h > class truc > {... > void mymethod(int, int); > void mymethod(float); > } > // > > //File : truc.i > %module truc > > %{ > #include "truc.h" > %} > > %include truc.h > // > > //here is the swig command and the error message : > >swig -c++ -shadow -python truc.i > >Generating wrappers for Python truc.h : Line 17. Function truc_mymethod (member mymethod) multiply defined (2nd definition ignored). > > Thanks > > -- > Pierre PUISEUX > Universit? de Pau et des Pays de l'Adour > Laboratoire de Math?matiques Appliqu?es > T?l: (+) 33-5-59-92-31-67 > http://www.univ-pau.fr/~puiseux/home.htm From juanjux at yahoo.es Fri Feb 16 23: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 max at alcyone.com Fri Feb 2 12: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 ben.hutchings at roundpoint.com Tue Feb 20 19: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 paul at fxtech.com Sat Feb 17 11: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 jp.roumian at mobileway.com Tue Feb 27 13: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 aleaxit at yahoo.com Tue Feb 27 16: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 loewis at informatik.hu-berlin.de Fri Feb 2 17: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 dale at out-think.NOSPAMco.uk Mon Feb 19 06: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 phlip_cpp at my-deja.com Tue Feb 20 13: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 MarkH at ActiveState.com Sun Feb 4 17:05:20 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 04 Feb 2001 22:05:20 GMT Subject: Win Development References: Message-ID: <3A7DD132.7050309@ActiveState.com> Michael Jonas wrote: > Should I copy the self_build (debug and release?) libs, dll and exe files to > the binary dist and do my Development there?!? > Or do I leave the stuff in the source dist to code my C Modules?!? And build > python Modules in the binary dist!? > Or should I develop my C-Modules in the source dist and put the result to > the binary Dist?!? > Or should I put the source into the root of my binary dist ?!? What I do is to build everything I can from sources, and run them directly. Thus, Python itself is always run from the CVS source directory, with the executables directly in the "PCBuild" directory. If you run Python in this way, it doesnt need any PYTHONPATH setup at all for its core library. This just leaves you with your extension modules. Again, you should be able to setup to run directly from the source tree. Hit the registry editor, and manually add the paths to your extensions to the PYTHONPATH. > I've allready seen that VC debugger (and the look at Python's source) is one > of my best friends and I want to make it find everything as required. ( I > used vi the last years...) Doing what I descrribed keeps VC happy, and it never needs to ask where source-code is. > VC. By the way... is there a way to do Python development in VC's > interface?!? Not yet, but ActiveState are working on "Visual Python" for the VC7 environment. Mark. From MailFreeZone Thu Feb 15 12: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 TRoeschmann at ohltec.de Sat Feb 10 16:54:41 2001 From: TRoeschmann at ohltec.de (=?iso-8859-1?Q?=22R=F6schmann=2C_Thies=22?=) Date: Sat, 10 Feb 2001 22:54:41 +0100 Subject: CGIHTTPServer Message-ID: <2153422094D9D311A58B00508B9B199533EA57@HZ_KOMM> Hello, How can I configure my own CGIHTTPServer from Python1.5.2-Lib to run my Python-scripts on WinNT4.0? Or, how can I set the world-executable and world-readable bits like this: "chmod ugo+rx myfile.py" Thanks for your help, Thies From jack at oratrix.nl Wed Feb 28 04:13:51 2001 From: jack at oratrix.nl (Jack Jansen) Date: Wed, 28 Feb 2001 10:13:51 +0100 Subject: [Distutils] Re: CPAN functionality for python - requirements In-Reply-To: Message by Doug Hellmann , Tue, 27 Feb 2001 21:03:43 -0500 , <01022721090603.20069@branagan> Message-ID: <20010228091351.C4A41371690@snelboot.oratrix.nl> > I'm not sure why the "what do you have" question is needed. The "send me > that(mandrake.rpm)" interaction is what we want. Well, one of the things I'd like to do is integrate all this in MacPython IDE, and the same probably holds for PythonWin and Idle. Then the "what do you have" is pretty useful for building menus and such. -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen at oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From aahz at panix.com Sat Feb 3 16: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 robin at jessikat.fsnet.co.uk Mon Feb 12 05:11:03 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Mon, 12 Feb 2001 10:11:03 +0000 Subject: Graph (cyclic kind, not pretty picture kind) rendering algorithm? References: <3A87A0EC.BA802E3E@student.gu.edu.au> Message-ID: In article <3A87A0EC.BA802E3E at student.gu.edu.au>, s713221 at student.gu.edu.au writes >Phlip wrote: >> >> Python for Pyros: >> >> Click here, then scoot down about 2 pages: >> >> http://www.tomsawyer.com/glt/index.html >> >> On the left we see a Graph (a math object describing vertices connected by >> edges), and on the right's the same graph drawn with all the lengths of the >> lines balanced. >> >> Is there a Python library out there that can draw a graph like that? Or >> which can take a graph as an input and return XY coordinates telling where >> to place each vertice and each line? > >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 Well you translate the java demo code to do this. There was also some stuff in Dr Dobbs (in 1999 I think) on the spring/charge model for displaying graphs. A starting place for such efforts might be the demo/guido/tkinter/electr ons.py file. Which shows how to put the nodes onto a canvas. -- Robin Becker From uche at ogbuji.net Sat Feb 24 17: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 rich_somerfield at tertio.com Mon Feb 26 04: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 donn at u.washington.edu Fri Feb 16 13: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 DOUGS at oceanic.com Wed Feb 7 09:15:15 2001 From: DOUGS at oceanic.com (Doug Stanfield) Date: Wed, 7 Feb 2001 04:15:15 -1000 Subject: IP address and its netmask Message-ID: <8457258D741DD411BD3D0050DA62365907A5E3@huina.oceanic.com> I found this: ftp://ftp.cendio.se/pub/playground/python/ipaddr-1.1.tar.gz By way of the Vaults: http://www.vex.net/parnassus/ Its a module that has a lot of very useful utility if you're working with IP numbers and networks. For example, your problem (changed slightly to make it a challenge): [dougs at lawehana dougs]$ python Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 (egcs-1.1.1 on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import ipaddr >>> aNet = ipaddr.network('203.21.67.0','255.255.252.0',ipaddr.DEMAND_NONE) >>> aNet {network 203.21.67.0/22} >>> anIP = ipaddr.ipaddr('203.21.67.89') >>> anIP ipaddr.ipaddr('203.21.67.89') >>> aNet.overlaps(anIP) 1 >>> otherIP = ipaddr.ipaddr('204.21.67.89') >>> aNet.overlaps(otherIP) 0 >>> -Doug- > -----Original Message----- > From: Sam Wun [mailto:swun at esec.com.au] > Sent: Tuesday, February 06, 2001 7:26 PM > To: python-list at python.org > Subject: IP address and its netmask > > > Hi, > > I want to know whether 203.21.67.89 is in 203.21.67.0/32 A /32 is a host address. Maybe you meant something like /22? > network. How do > I do that in Python? > > Thanks > sam > > -- > http://mail.python.org/mailman/listinfo/python-list > From mnajmeddine at geo.census.gov Fri Feb 16 11: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 adam at deprince.net Fri Feb 23 01: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 akuchlin at mems-exchange.org Wed Feb 7 15:33:30 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 07 Feb 2001 15:33:30 -0500 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> Message-ID: <3dn1bygrmt.fsf@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 From bobhicks at adelphia.net Thu Feb 1 09: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 aahz at panix.com Fri Feb 9 10: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 fredrik at pythonware.com Wed Feb 21 14: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 bernie at pacific.net.hk Tue Feb 6 16:58:26 2001 From: bernie at pacific.net.hk (Bernie) Date: Wed, 07 Feb 2001 05:58:26 +0800 Subject: x = y References: Message-ID: <3A807382.298371E0@pacific.net.hk> "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? > I think you need the copy module. import copy y = [[1,2,3],[4,5,6]] x = copy.copy(y) This will do for a shadow copy. See documentation for the copy module in Python Library Reference for furthur details > Thanks in advance, > > Jose Luis Bernie From nstalkie at tvd.be Wed Feb 14 17: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 chris.gonnerman at usa.net Mon Feb 5 09:19:36 2001 From: chris.gonnerman at usa.net (Chris Gonnerman) Date: Mon, 5 Feb 2001 08:19:36 -0600 Subject: SIP Message-ID: <000901c08f7e$b317b320$a100000a@local> Does anyone know of a tutorial on SIP? I am a C (not C++) programmer, but there is a specific C++ library I'd like to 'wrap' and I am not finding docs anywhere. Sorry if I've missed an obvious link. From claird at starbase.neosoft.com Fri Feb 9 12:21:28 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 9 Feb 2001 11:21:28 -0600 Subject: Some basic questions about Tkinter (and Python) References: <7mdg6.13217$AH6.1992583@newsc.telia.net> <5A26DA93165A7B85.352CA80CD738363E.9B52D4C723B787A0@lp.airnews.net> Message-ID: <29D1A1897E293522.BDB05FE58D09D409.B94B74AE507E733D@lp.airnews.net> In article , Martyn Quick wrote: . . . >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? As your countryman David Ricardo so vividly expressed it, it's the *comparative* advan- tage, not absolute income, which best explains our behavior. Does your University not offer inter-library loan services? When I write, "buy", that abbreviates an entire constellation of assumptions and reali- zations. Most bluntly, if it's worth the expense to the kingdom to keep you titled as a Research Fellow in Mathematics, then it's worth it to someone to ensure a book which will benefit you so much reaches your hands safely. If no one else steps forward, Dr. Quick, I will; write me privately and I'll arrange for a copy to reach you. > >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. This book has many virtues. Its coverage of Tkinter occupies ten pages, and is slightly outdated. It uses those ten pages to good advantage, though. . . . -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From clee at gnwy100.wuh.wustl.edu Mon Feb 12 10:14:04 2001 From: clee at gnwy100.wuh.wustl.edu (Christopher Lee) Date: 12 Feb 2001 09:14:04 -0600 Subject: speed comparison of IDL, numPy, Matlab References: <3A7EEE5C.6419B707@pacific.jpl.nasa.gov> <968kd0$rml$1@nnrp1.deja.com> Message-ID: <7u66igaq83.fsf@gnwy100.wuh.wustl.edu> >>>>> "Gavrie" == Gavrie writes: Gavrie> In article <3A7EEE5C.6419B707 at pacific.jpl.nasa.gov>, Benyang Gavrie> Tang wrote: Gavrie> So, this difference seems a bit strange, doesn't it? I'm using Gavrie> MATLAB 6 (whichis supposed to be *slower* than 5.3), and Python Gavrie> 1.5.2. I believe there's an explaination for this: While I've heard that Matlab 6's footprint is much larger, especially the interface, I have heard that Matlab 6 does (finally) use LAPACK and BLAS which are optimized for modern machines w/ hierarchical memory. I would therefore expect that it would do substantially better than the out-of-the-box numpy build for matrix multiplication. By default, numpy uses a naive algorithm for matrix multiplication which is quite cache unfriendly. When numpy is linked to ATLAS's BLAS routines and LAPACK, it's more cache-friendly---and much faster. I did some benchmarks myself: For matrix inversion of a 1000x1000 matrix, numpy-atlas is 7 times faster than matlab 5.3 (no lapack). The difference is greater if you have a dual processor machine because ATLAS now has options for multi-threaded operation. And for matrix multiplication you can compare the naive numpy multiplication with the optmized-dgemm based version on the same matrix: # 1000 x 1000 matrix time elapsed for matrixmultiply (sec) 24.142714 time elapsed for dgemm-matrixmultiply (sec) 5.997188 -chris [BTW: I'm working on putting together an optimized-numpy distribution that uses ATLAS by default.] From syver at NOSPAMcyberwatcher.com Tue Feb 20 16: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 andreas.dietrich at news.online.de Mon Feb 12 15: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 fpm at u.washington.edu Tue Feb 27 12: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 MarkH at ActiveState.com Wed Feb 7 19:34:37 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 08 Feb 2001 00:34:37 GMT Subject: ADO/ODBC call via Python/IIS References: <95f558$jgl$1@nnrp1.deja.com> <%FGe6.31314$Ch.7369562@newsrump.sjc.telocity.net> <95sisd$ahc$1@nnrp1.deja.com> Message-ID: <3A81E8B4.2000402@ActiveState.com> Bill Seitz wrote: > Well, it's a User DSN. Do you know that ASP expects a system DSN? ASP does not execute as your user, but as its own system user. Thus, a user DSN created for your user is simply not visible by ASP. It must be system DSN, or a user DSN for the ASP specific user > And, I'm not clear on what a DSN-less connection is. Does this mean Neither do I - hopefully someone else will ;-) Mark. From topmind at technologist.com Sun Feb 25 15: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 dsh8290 at rit.edu Fri Feb 9 11:21:56 2001 From: dsh8290 at rit.edu (D-Man) Date: Fri, 9 Feb 2001 11:21:56 -0500 Subject: Executing Sytem Commands In-Reply-To: <3A84118D.180E1CDC@usa.net>; from mix77@usa.net on Fri, Feb 09, 2001 at 05:49:33PM +0200 References: <3A84118D.180E1CDC@usa.net> Message-ID: <20010209112156.A16615@harmony.cs.rit.edu> import os os.system( "mv file1 file2" ) -D On Fri, Feb 09, 2001 at 05:49:33PM +0200, mix77 at usa.net wrote: | How do you execute a sytem command like "mv file1 file2" in Python? | P.S. I'm working under Linux 2.x (redhat 7 distribution with default | linux kernel). | From carifio.nospam at nospam.usys.com Mon Feb 12 11:32:54 2001 From: carifio.nospam at nospam.usys.com (Mike Carifio) Date: Mon, 12 Feb 2001 11:32:54 -0500 Subject: python 2.0 won't run scripts with \r\n line termination on RH7? References: Message-ID: Insightful responses. Mr. Rabak suggested convincing Samba to convert the end of line characteristics. A good suggestion, but one that the Samba team decided against for several versions. They contend that they shouldn't fool with the insides of files. I tend to agree with them. In any event, its not in version 2.0.7. So here's my solution, crufty though it is. I created a link to the python executable named 'python^M', in other words I added the carriage return to the end of the file name so bash would find it. (In bash, Ctrl-V inserts the next character as a literal.) This way, I don't have to worry about whether I created the file on Linux or NT. Umm, that's not really true, but I don't have to worry about line termination for invocation. That's a start. This "solution" unfortunately doesn't handle options, for example: #!/usr/local/bin/python -i print "some stuff" doesn't work. Thanks for help. From tim_one at email.msn.com Wed Feb 21 01:07:03 2001 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 21 Feb 2001 01:07:03 -0500 Subject: Is Python for me? In-Reply-To: Message-ID: [Kendall G. Clark] > ... > So lemme see if I've got this right: > > 1. There's something Alex Martelli doesn't know; and Na, that's an illusion. Alex is working hard to keep his posts under 50Kb these days, so he can't afford to divulge more than the tiniest fraction of what he knows. > 2. the Timbot is (still) spreading about the hoary 'Common Lisp is > *really* huge' myth[1]? In terms of language size, yes. CL is a big language -- it's a *huge* language. The original questioner was attracted to functional languages, and they tend to be on the minimal side (notwithstanding that in recent years they've grudgingly allowed that some people need to do I/O <0.9 wink>). > Martelli omissions and a Timbot imprecision in one night's > news-reading session? c.l.py is slipping! :> The question is whether that precedes or follows Python ballooning out of control. Newsgroups and languages reflect each other, but it's hard to say which is more cause and which effect . BTW, I suspect the biggest contributor to the myth that Lisp *implementations* are huge may still be Emacs. More than a decade ago that stood for Eighty Megs And Constantly Swapping, and I doubt it's gone on a diet since then. Doesn't matter that Lisp has nothing to do with that; it's like the equally bizarre myth that Python's treatment of whitespace was taken from Fortran. myths-are-too-comforting-to-fight-ly y'rs - tim From ACIUFFO1 at irf.com Mon Feb 26 19: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 paul.moore at uk.origin-it.com Mon Feb 12 11:49:04 2001 From: paul.moore at uk.origin-it.com (Paul Moore) Date: Mon, 12 Feb 2001 17:49:04 +0100 Subject: python-dev summary, Jan. 16-31 References: <3d4ry56vzg.fsf@ute.cnri.reston.va.us> <95v2lq$hjl$1@slb7.atl.mindspring.net> <95v3mt$lnh$1@nntp9.atl.mindspring.net> Message-ID: On Thu, 8 Feb 2001 22:38:55 +0100 , "Andrew Dalke" wrote: >Oh yeah, I forgot: > http://mail.python.org/mailman/listinfo/python-dev > >says in bold that > > Subscription is by invitation only. > >and adds > > This is a closed list > >So just how am I supposed to follow what is going on >in Python development and how do I make comments in a >timely manner? > >Feeling snubbed, I agree entirely. I follow python-dev avidly, but I hate the web interface for doing so. The tone of the comments on the subscription page seem to make it vey clear that "casual observers" are not welcome, and that is all I would be likely to be. I may well be glad to make the odd comment, but I cannot commit myself to any significant level of participation, so I am stuck with only the web interface. I'd argue for, at the least, making python-dev available freely on a "read only" basis, and preferably allowing open access, with a strong policy of keeping postings on-topic (I don't really have a feeling that the Python community would abuse write access to python-dev, but it is a potential issue, witness the perl5 porters list...) But nevertheless, thanks Andrew for the work you have done. Paul Moore. From erno-news at erno.iki.fi Sat Feb 10 00:32:56 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 10 Feb 2001 07:32:56 +0200 Subject: Should I use Python? References: <3A84BBA7.74688DFD@orcon.net.nz> Message-ID: In article , msoulier at storm.ca (Michael P. Soulier) writes: | The only way to do what you're talking about is to distribute | binaries for the target platform. Python is a good choice if you | want to use the frozen tool and compile the Python to native code. do you have a url for this "frozen"? or do you mean freeze? from what i hear py2exe and installer have superseded freeze, and none of those compile python to native code... -- erno From mwh21 at cam.ac.uk Thu Feb 1 07: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 bobhicks at adelphia.net Wed Feb 21 15: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 cg at gaia.intranet.cdegroot.com Wed Feb 28 09: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 qrczak at knm.org.pl Sat Feb 24 12: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 fredrik at pythonware.com Thu Feb 8 01:40:21 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 08 Feb 2001 06:40:21 GMT Subject: String formatting characters - looking for details References: <3a81cfa2.1708851@news.muenster.de> Message-ID: Martin Bless wrote: > (1) Where can I find some more details about the string formatting > characters? your nearest C/Unix manual. or the Python 2.1 docs: http://python.sourceforge.net/devel-docs/lib/typesseq-strings.html > (2) How I print hex values with zeros padded left, like 0F or 0A? > print '%X' % 15 # two digits, wanted print "%02X" % 15 > (3) This is from the Python docs - I'm looking for more information on > how to use the formatting characters. searching the net for "sprintf" brings up an infinite number of manual pages. (fwiw, the perl manual page says these formatting codes are "universally known"...) Cheers /F From costas at meezon.com Wed Feb 21 21: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 mkx at excite.com Fri Feb 23 13: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 fluxent at yahoo.com Fri Feb 9 16:52:51 2001 From: fluxent at yahoo.com (Bill Seitz) Date: Fri, 09 Feb 2001 21:52:51 GMT Subject: ADO/ODBC call via Python/IIS References: <95f558$jgl$1@nnrp1.deja.com> <%FGe6.31314$Ch.7369562@newsrump.sjc.telocity.net> <95sisd$ahc$1@nnrp1.deja.com> <95sjll$bbs$1@nnrp1.deja.com> <95skd2$c13$1@nnrp1.deja.com> <1ilg6.61167$Ch.11522747@newsrump.sjc.telocity.net> Message-ID: <961orf$nsk$1@nnrp1.deja.com> Well, my simpler DSN-less code seems to be doing the right thing. But get that lovely "Not associated with a trusted SQL Server connection." error message. I've tried with and without a domain prefix on the uid. Could this be related to running SQL in "active directory only" mode? In article , David Fuess wrote: > > Here is the beginning of my SQL Server class: > > class Database: > def __init__(self,Name,Server="Default",Arg=""): > self.adoConn = None > self.adoRS = None > self.RecordCount = 0 > self.eof = 1 > self.ConnectString = "database=%s;driver={SQL > Server};QueryTimeout=300;server=%s;uid=sa%s"%(Name,Server,Arg) > self.Schema = {} > if AutoOpenOnInit: > self.Open(Name) > > def Open(self,Name): > if self.adoConn is not None: > self.Close() > self.adoConn = win32com.client.Dispatch('ADODB.Connection') > self.adoConn.CursorLocation = 3 > self.adoConn.CommandTimeout = 900 > self.adoConn.Open(self.ConnectString) > if AutoloadSchema: > self.LoadSchema() > > And so on ... > > I use it regularly to connect to SQL Server Databases. It is DSNless > in that it attaches directly to SQL Server without any specific DSN > assignments. It has nothing to do with IIS, only ADO. > > Dave > On Wed, 7 Feb 2001 17:57:47 -0600, "dsavitsk" > wrote: > > >maybe not the error here, but you need a ";" at the end of the string ... > >see below. > > > >> adoConn.Open('driver=SQL > >> Server;server=sql0;uid=xxx;pwd=yyy;database=zzz;') > > > > > > Sent via Deja.com http://www.deja.com/ From aahz at panix.com Mon Feb 19 17: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 mikael at isy.liu.se Tue Feb 13 04:06:32 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Tue, 13 Feb 2001 10:06:32 +0100 (MET) Subject: PEP status and python-dev summaries In-Reply-To: <962pdj$kb0@gap.cco.caltech.edu> Message-ID: On 10-Feb-01 Nathaniel Gray wrote: > [PEP 666 Text] Curly-Braces for Delimiting Blocks It's only natural that the particular PEP with that number is dealing with something evil. /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: 13-Feb-01 Time: 10:05:24 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- From dsh8290 at rit.edu Tue Feb 20 23: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 sholden at holdenweb.com Mon Feb 26 17: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 cobrien at Radix.Net Tue Feb 20 18: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 sgriggs at pobox.com Tue Feb 6 18:26:18 2001 From: sgriggs at pobox.com (sgriggs at pobox.com) Date: Tue, 06 Feb 2001 23:26:18 GMT Subject: Python 2.1a2 compile problems References: <95pfsu$ht1$1@nnrp1.deja.com> <3dpugvh6ot.fsf_-_@ute.cnri.reston.va.us> Message-ID: <95q16e$3go$1@nnrp1.deja.com> Thank you for the pointer Andrew. I have changed the SunOS entry in configure and now I can run configure and make and it works. Also, after all that, changes in the makefile have broken make install. I fixed that. Let me figure out how to make a patch and I'll submit it python.sourceforge.net. Thanks again. I can post my changes here if anyone cares. Scott Griggs Sent via Deja.com http://www.deja.com/ From fredrik at effbot.org Wed Feb 7 09:56:03 2001 From: fredrik at effbot.org (Fredrik Lundh) Date: Wed, 07 Feb 2001 14:56:03 GMT Subject: Some basic questions about Tkinter (and Python) References: Message-ID: <7mdg6.13217$AH6.1992583@newsc.telia.net> Martyn Quick wrote: > I'm very new to this game and the use of lowercase and > uppercase variants of the same English word to denote > almost the same thing caused me problems. Python is case-sensitive. You better get used to it ;-) by convention, "foo" is a variable (a named reference to an object) or a function/method, "Foo" is a class, and "FOO" is a constant. (functions, methods, classes and constants are objects too, of course) > > filemenu = Menu(armadillo) # create a submenu > > armadillo.add_cascade(label="File", menu=filemenu) > > Hold it - is "filemenu" a user defined name or is it built into Tkinter? "filemenu" is just a variable name. If you assign a value to a name (or to be more precise, if you bind a name to a value), you "own" that name. (note that the Tkinter introduction assumes that you can read Python code fluently, and that you have a basic under- standing of Python's object and class model). > Would the following work equally well? > > dongle = Menu(armadillo) > armadillo.add_cascade(label="File", menu=dongle) yes. > The Introduction document (p26) says "We use the config method to attach > it to the root window". But I couldn't find anywhere telling me what the > config method was. http://www.pythonware.com/library/tkinter/introduction/widget-configuration.htm the syntax is: widget.config(option=value) Where "option" is the configuration option you want to change, and "value" is the value you want to set it to. You can also set several options per call: widget.config(option1=value1, option2=value2, ...) Also read up on keyword arguments (a Python feature). > A related question is the Second Tkinter Program in that document (Hello, > Again). The command use to quite is frame.quit . Why is this used > instead of sys.exit() ? quit causes Tkinter to return from the call to mainloop, while sys.exit terminates the Python interpreter. If calling mainloop is the last thing you do in your program, it doesn't really matter which one you use... > Am I right in thinking that frame is the user defined name for > the Frame, so if I wrote it's a variable name (a named reference to the widget, not necessarily the name of the Frame instance itself. see the section on widget names for more info) > > aardvark = Frame(master) > > I would use command = aardvark.quit yes. Cheers /F From Denys.Duchier at ps.uni-sb.de Wed Feb 21 17: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 db3l at fitlinxx.com Thu Feb 8 18:03:38 2001 From: db3l at fitlinxx.com (David Bolen) Date: 08 Feb 2001 18:03:38 -0500 Subject: python-dev summary, Jan. 16-31 References: <3d4ry56vzg.fsf@ute.cnri.reston.va.us> <95v2lq$hjl$1@slb7.atl.mindspring.net> <95v3mt$lnh$1@nntp9.atl.mindspring.net> Message-ID: "Andrew Dalke" writes: > So just how am I supposed to follow what is going on > in Python development and how do I make comments in a > timely manner? Well, it's not quite as closed as it may sound - the membership on the list itself is closed to those participating in the core development, but anyone can send e-mail to the list, and all mail is archived and can be followed through the archive. (Although as suggested elsewhere, a gateway to a newsgroup (even if one-way) would be cool as I find news the most efficient vehicle to follow active lists.) I'm not totally clear on the rationale for the closed status (and I'm not currently on the list), but I'm guessing there was an expectation that an open list would get lots of lurking subscriptions which might really ratchet up the load tremendously for spurious discussions. This way, those directly on the list are those writing the code. In effect, it really is a core developers list, but it's been opened up enough so that anyone can peruse it - or contribute individual mail. -- -- 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 shaleh at valinux.com Tue Feb 27 14: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 gregj at pobox.com Sat Feb 10 22:15:16 2001 From: gregj at pobox.com (Greg Jorgensen) Date: Sun, 11 Feb 2001 03:15:16 GMT Subject: Is Python for me? References: <20010210175216.26827.00000474@ng-mh1.aol.com> Message-ID: <965041$618$1@nnrp1.deja.com> In article <20010210175216.26827.00000474 at ng-mh1.aol.com>, dvdavins at aol.com (DvdAvins) wrote: > I'm planning to write a program for myself which, if I'm happy with > the way it turns out, I will likely distribute as shareware. > ... > I'm investigating at M, Python, BETA, Scheme, Haskell, Icon, and Common Lisp. Which would you use? Why? You don't say anything about the program you are planning, so no one can give a meaningful answer to your question. The language I would choose for a cross-platform GUI application may not be the language I'd choose for writing web server applications, or querying a database. There is no one best programming language for everything. I would use the language and tools I am most productive with. For the vast majority of programmers, that means using one of the handful (or fewer) programming languages they know well. I can't tell for sure, but your post gives the impression that you don't know any of the programming languages you are asking about. Do you have any programming experience at all? If yes, what language or languages are you most experienced and comfortable with? Imagine if someone asked you: "I'm planning to take some photographs, and if they turn out I may sell them. Should I use a Nikon, Minolta, Canon, Hasselblad, or Olympus camera? Why?" What kind of sensible answer could you give them? If you don't have any significant programming experience, I'd say Python is a great choice to start with. The language is easy to learn, tools are widely available, several good books are in bookstores, and the support community is first-rate. But the hard part is learning how to program, not learning a language. I can teach my kids how to use a camera, but that won't make them as good as Ansel Adams. For more about learning programming and why you should be prepared to spend a lot of time at it, have a look at: http://www.norvig.com/21-days.html -- Greg Jorgensen Portland, Oregon, USA gregj at pobox.com Sent via Deja.com http://www.deja.com/ From joconnor at cybermesa.com Sun Feb 4 14:55:28 2001 From: joconnor at cybermesa.com (Jay O'Connor) Date: Sun, 04 Feb 2001 19:55:28 +0000 Subject: NameError in cross imports of modules References: <3A7D0729.C7BF5EF1@cybermesa.com> Message-ID: <3A7DB3B0.9425BF64@cybermesa.com> Thomas Wouters wrote: > > Well, I already made clear here that the answer is 'no' :-) I'm not sure > what kind of situation you are in when you say you are 'importing classes' > (I've never done that, myself, and it's only possible since Python 2.1 in > any case :), I was careless in my terminology, I meant importing a module for the sake of access to the classes the module contains. > but 'from module import *' imports a lot more than classes, and > can do all kinds of nasty things, like shadowing builtins and globals, and > clobbering your own variables. If you want to import a couple of class names > from a module to your own namespace, you best name them explicitly, so you > are sure those are the only names imported. And more importantly, so that > you, and everyone else, can always find out where a name comes from. For > instance: > > from spamsong import * > > > > from Eric import * > > > > class ExtendedViking(Viking): > > > Where did the 'Viking' come from ? Everyone knows both the spamsong and Eric > the Viking feature Vikings. Maybe spamsong named its viking differently when > you first wrote the module, or you never noticed spamsong had a viking > because it was always overwritten by the one in Eric. Or maybe it's the > other way 'round, you intended to use spamsong's Viking, but didn't know > Eric had one, too. Or maybe Eric grew its viking later. Or even worse, both > spamsong and Eric had vikings, but the on in Eric wasn't supposed to be > exported (like, it should have been named _Viking and someone forgot) and > they removed it in a later release -- but you were relying on that > undocumented misfeature. Suddenly your extended viking behaves differently, > 'for no apparent reason'. I haven't run into this problem (yet!) because I tend to prefix my class names with an identifier that indicates what project, etc...the class is from. That is a habit from using pre-namespace Smalltalk where the was no scoping tool for namespaces so you had to create Class names likely not to be clobbered Of course the return argument is that using "moduleName.ClassName" is the correct scoping tool. I see your points; I will rethink my approach Thank you -- 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 9 12: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 ransen_spam_me_not at nemo.it Sun Feb 18 11: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 zamurai at gmx.net Mon Feb 19 13: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 chrisa at ASPATECH.COM.BR Tue Feb 13 15: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 akuchlin at mems-exchange.org Mon Feb 5 14:03:46 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 05 Feb 2001 14:03:46 -0500 Subject: Alpha release of ZODB programming guide References: <95mr3t$ad2$1@troll.powertech.no> Message-ID: <3dg0htymst.fsf@ute.cnri.reston.va.us> "Syver Enstad" writes: > This sounds very exciting, I had been looking forward to an object database > on python. I've tried ZEO under MS Win 2000 but it doesn't seem to work. Is > it supposed to? I don't know, but suspect it should work -- for some value of "work" -- on Windows. But note that I can't make Windows binaries available, so you'd need to have a C compiler in order to install it. Try asking on one of the Zope mailing lists: zope-zeo at zope.org. (Oh, wait, they're apparently down at the moment, so maybe this should be kept on python-list for now.) --amk From whisper at oz.net Thu Feb 15 16: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 moshez at zadka.site.co.il Fri Feb 2 08: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 chris at onca.catsden.net Mon Feb 5 14:48:37 2001 From: chris at onca.catsden.net (chris at onca.catsden.net) Date: Mon, 5 Feb 2001 11:48:37 -0800 (PST) Subject: Can't Generate Random # In-Reply-To: <95mu0p$aqc$1@nnrp1.deja.com> Message-ID: On Mon, 5 Feb 2001 jimmypop181 at my-deja.com wrote: > Does somebody know how to generate a random number in > Python? I read the docs and it says rand(x, y) should do it. But > whenever I try that, It says that "there is no variable named rand". > This also happens when trying to get the Square Root. Please > help. Are you sure you're reading the /python/ documentation?? :) I've no idea where you got 'rand' from. import whrandom r = whrandom.randint(a,b) # Depricated r = whrandom.randrange(a,b) # Better, gives you a random integer [a,b) import math i = math.sqrt(j) or from math import * i = sqrt(j) ("`-/")_.-'"``-._ Ch'marr, a.k.a. . . `; -._ )-;-,_`) Chris Cogdon (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' FC1.3: FFH3cmA+>++C++D++H++M++P++R++T+++WZ++Sm++ ((,.-' ((,/ fL RLCT acl+++d++e+f+++h++i++++jp-sm++ From tim.one at home.com Sat Feb 3 02: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 f8dy at yahoo.com Tue Feb 27 14: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 db3l at fitlinxx.com Tue Feb 13 13: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 akuchlin at mems-exchange.org Fri Feb 9 09:55:52 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 09 Feb 2001 09:55:52 -0500 Subject: python-dev summary, Jan. 16-31 References: Message-ID: <3dofwbhpmv.fsf@ute.cnri.reston.va.us> Oleg Broytmann writes: > Any chance you'll continue the summaries? Not really. All of this is sparked by my wanting to reduce the load, really; I recently realized that I haven't hacked on *any* of my projects (Oedipus, amkCrypto, etc.) lately. Therefore I've dropped out of my book club (one night a week), dropped the summaries, (two nights every two weeks, or 15% of my evenings), and after 2.1final is released I'll probably unsubscribe from python-dev, too. So, to rescuing the summaries... For the information of potential volunteers, I'll summarize the process. Writing them isn't difficult and can easily be done while watching TV -- I usually pull the mail archive on my laptop and do just that. They're just time-consuming, taking up two evenings at a time. 1) Grab a copy of the mailbox archive for the month. 2) Load it up into mutt (or other MUA of choice), and delete messages outside of the two-week period being summarized. 3) Sort the remaining messages by thread, and go through finding the interesting threads. What makes a thread interesting? * Threads discussing how to fix a particular bug, or tracing down a bug's root cause, can be quite lengthy but usually aren't interesting. * Minute discussions of language syntax are rarely interesting, and I think even Guido tunes them out after a while. * New proposals that spark off a discussion are interesting. * Discussions surrounding a PEP are interesting. 4)